UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

33 lines (31 loc) 1.26 kB
import { tsUtils } from '@neo-one/ts-utils'; import ts from 'typescript'; import { BuiltinInstanceMemberCall } from '../../BuiltinInstanceMemberCall'; export class StorageHas extends BuiltinInstanceMemberCall { constructor(type) { super(); this.type = type; } 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.hasStructuredStorage({ type: this.type, keyType: type })); } } //# sourceMappingURL=has.js.map