@neo-one/smart-contract-compiler
Version:
NEO•ONE TypeScript smart contract compiler.
31 lines (29 loc) • 1.15 kB
JavaScript
import { tsUtils } from '@neo-one/ts-utils';
import ts from 'typescript';
import { DiagnosticCode } from '../../DiagnosticCode';
import { DiagnosticMessage } from '../../DiagnosticMessage';
import { BuiltinType, } from './types';
export class BuiltinInstanceMemberValue {
constructor() {
this.types = new Set([BuiltinType.InstanceMemberValue]);
this.canSet = false;
this.isReadonly = true;
}
emitValue(sb, node, options, visited = false) {
if (!this.canSet && options.setValue) {
if (!this.isReadonly) {
sb.context.reportError(node, DiagnosticCode.InvalidBuiltinModify, DiagnosticMessage.CannotModifyBuiltin);
}
return;
}
if (!visited && (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node))) {
sb.visit(tsUtils.expression.getExpression(node), sb.pushValueOptions(options));
}
if (!this.canSet && !options.pushValue) {
sb.emitOp(node, 'DROP');
return;
}
this.emit(sb, node, options);
}
}
//# sourceMappingURL=BuiltinInstanceMemberValue.js.map