UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

33 lines (31 loc) 1.15 kB
import { tsUtils } from '@neo-one/ts-utils'; import { isBuffer } from '../../helper/types'; import { BuiltinInstanceMemberCall } from '../BuiltinInstanceMemberCall'; export class BufferEquals extends BuiltinInstanceMemberCall { canCall(sb, _func, node) { const arg = tsUtils.argumented.getArguments(node)[0]; if (arg === undefined) { return false; } const type = sb.context.analysis.getType(arg); return type !== undefined && isBuffer(sb.context, arg, type); } 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; } sb.visit(tsUtils.argumented.getArguments(node)[0], options); sb.emitOp(node, 'EQUAL'); if (optionsIn.pushValue) { sb.emitHelper(node, options, sb.helpers.wrapBoolean); } else { sb.emitOp(node, 'DROP'); } } } //# sourceMappingURL=equals.js.map