UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

30 lines (28 loc) 1.16 kB
import { tsUtils } from '@neo-one/ts-utils'; import ts from 'typescript'; import { NodeCompiler } from '../NodeCompiler'; export class SuperExpressionCompiler extends NodeCompiler { constructor() { super(...arguments); this.kind = ts.SyntaxKind.SuperKeyword; } visitNode(sb, node, options) { if (options.pushValue) { const superClass = options.superClass; if (superClass === undefined) { throw new Error('Something went wrong, expected super class to be defined.'); } const methodDeclaration = tsUtils.node.getFirstAncestorByKind(node, ts.SyntaxKind.MethodDeclaration); if (methodDeclaration === undefined) { sb.context.reportUnsupported(node); return; } sb.scope.get(sb, node, options, superClass); if (!tsUtils.modifier.isStatic(methodDeclaration)) { sb.emitPushString(node, 'prototype'); sb.emitHelper(node, options, sb.helpers.getPropertyObjectProperty); } } } } //# sourceMappingURL=SuperExpressionCompiler.js.map