UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

29 lines (27 loc) 1.25 kB
import { tsUtils } from '@neo-one/ts-utils'; import ts from 'typescript'; import { DiagnosticCode } from '../../../../DiagnosticCode'; import { DiagnosticMessage } from '../../../../DiagnosticMessage'; import { BuiltinMemberCall } from '../../BuiltinMemberCall'; export class StorageFor extends BuiltinMemberCall { constructor(type) { super(); this.type = type; } emitCall(sb, _func, node, optionsIn) { const prefix = sb.context.analysis.extractStorageKey(node); if (prefix === undefined) { const parent = tsUtils.node.getParent(node); const parentClass = tsUtils.node.getFirstAncestorByTest(parent, ts.isClassDeclaration); if (!ts.isPropertyDeclaration(parent) || parentClass === undefined || !sb.context.analysis.isSmartContract(parentClass)) { sb.context.reportError(parent, DiagnosticCode.InvalidStructuredStorageFor, DiagnosticMessage.InvalidStructuredStorageForProperty); } return; } const options = sb.pushValueOptions(optionsIn); sb.emitHelper(node, options, sb.helpers.createStructuredStorage({ type: this.type, prefix })); } } //# sourceMappingURL=for.js.map