Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function invokeStatic(
context: SyntaxCompilationContext,
action: InvokeStaticOp
): StatementCompileActions {
let compilable = action.op1;
if (context.program.mode === CompileMode.aot) {
let handle = compilable.compile(context);
// If the handle for the invoked component is not yet known (for example,
// because this is a recursive invocation and we're still compiling), push a
// function that will produce the correct handle when the heap is
// serialized.
if (handle === PLACEHOLDER_HANDLE) {
return op(MachineOp.InvokeStatic, () => compilable.compile(context));
} else {
return op(MachineOp.InvokeStatic, handle);
}
} else {
return [op(Op.Constant, other(action.op1)), op(Op.CompileBlock), op(MachineOp.InvokeVirtual)];
}
}
ifUnhandled: () => [
op(MachineOp.PushFrame),
op(HighLevelResolutionOpcode.Expr, value),
op(MachineOp.InvokeStatic, {
type: 'stdlib',
value: trusted ? 'trusting-append' : 'cautious-append',
}),
op(MachineOp.PopFrame),
],
});
evaluateMachine(opcode: RuntimeOp) {
switch (opcode.type) {
case MachineOp.PushFrame:
return this.pushFrame();
case MachineOp.PopFrame:
return this.popFrame();
case MachineOp.InvokeStatic:
return this.call(opcode.op1);
case MachineOp.InvokeVirtual:
return this.call(this.stack.pop());
case MachineOp.Jump:
return this.goto(opcode.op1);
case MachineOp.Return:
return this.return();
case MachineOp.ReturnTo:
return this.returnTo(opcode.op1);
}
}
ops: [],
operands: 0,
check: false,
};
MACHINE_METADATA[MachineOp.InvokeVirtual] = {
name: 'InvokeVirtual',
mnemonic: 'vcall',
before: null,
stackChange: -1,
ops: [],
operands: 0,
check: true,
};
MACHINE_METADATA[MachineOp.InvokeStatic] = {
name: 'InvokeStatic',
mnemonic: 'scall',
before: null,
stackChange: 0,
ops: [
{
name: 'offset',
type: 'u32',
},
],
operands: 1,
check: true,
};
MACHINE_METADATA[MachineOp.Jump] = {
name: 'Jump',