UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

30 lines (28 loc) 1.24 kB
import { tsUtils } from '@neo-one/ts-utils'; import ts from 'typescript'; import { Types } from '../../../constants'; import { BuiltinInstanceMemberCall } from '../../BuiltinInstanceMemberCall'; export class MapStorageGet extends BuiltinInstanceMemberCall { canCall(_sb, _func, node) { return tsUtils.argumented.getArguments(node).length === 1; } emitCall(sb, func, node, optionsIn, visited) { const options = sb.pushValueOptions(optionsIn); if (!visited) { sb.visit(tsUtils.expression.getExpression(func), options); } if (tsUtils.argumented.getArguments(node).length < 1) { return; } const arg = tsUtils.argumented.getArguments(node)[0]; const type = sb.context.analysis.getType(arg); sb.visit(arg, options); if (arg.kind === ts.SyntaxKind.NumericLiteral) { sb.emitHelper(arg, options, sb.helpers.unwrapNumber); sb.emitHelper(arg, options, sb.helpers.coerceToInt); sb.emitHelper(arg, options, sb.helpers.wrapNumber); } sb.emitHelper(node, optionsIn, sb.helpers.getStructuredStorage({ type: Types.MapStorage, keyType: type })); } } //# sourceMappingURL=get.js.map