@neo-one/smart-contract-compiler-esnext-esm
Version:
NEO•ONE TypeScript smart contract compiler.
45 lines (43 loc) • 1.47 kB
JavaScript
import { Helper } from '../../Helper';
export class FindObjectPropertyHelper extends Helper {
constructor({ accessor, dataExists, data, getObject }) {
super();
this.accessor = accessor;
this.dataExists = dataExists;
this.data = data;
this.getObject = getObject;
}
emit(sb, node, options) {
if (!options.pushValue) {
sb.emitOp(node, 'DROP');
sb.emitOp(node, 'DROP');
return;
}
sb.emitHelper(node, options, sb.helpers.findObjectPropertyBase({
whenHasProperty: () => {
sb.emitOp(node, 'PICKITEM');
sb.emitOp(node, 'DUP');
sb.emitHelper(node, options, sb.helpers.if({
condition: () => {
sb.emitOp(node, 'ARRAYSIZE');
sb.emitPushInt(node, 2);
sb.emitOp(node, 'EQUAL');
},
whenTrue: () => {
this.accessor();
},
whenFalse: () => {
this.dataExists();
},
}));
},
whenNotHasProperty: () => {
sb.emitOp(node, 'DROP');
sb.emitOp(node, 'DROP');
this.data();
},
getObject: this.getObject,
}));
}
}
//# sourceMappingURL=FindObjectPropertyHelper.js.map