public override void ExecuteInstruction(YeetCore core, YeetInstruction instr) { object x = core.VMStack.Pop(); object y = core.VMStack.Pop(); core.VMStack.Push((int)y * (int)x); core.Index++; }
public override void ExecuteInstruction(YeetCore core, YeetInstruction instr) { if (core.VMStack.Count == 0) { core.VMStack.Push(null); } object ret = core.VMStack.Pop(); core.VMStack.Push(ret); core.Index++; }
private static void Main(string[] args) { // An example of a method body, which adds the numbers 4 and 2 togheter and returns it. List <YeetInstruction> instruction = new List <YeetInstruction> { new YeetInstruction(YeetOpCodes.Ldc, 4), new YeetInstruction(YeetOpCodes.Ldc, 2), new YeetInstruction(YeetOpCodes.Add), new YeetInstruction(YeetOpCodes.Ret) }; // Initialize the VM. YeetCore core = new YeetCore(instruction); // Execute and print result. Console.WriteLine(core.Execute()); Console.ReadLine(); }
public override void ExecuteInstruction(YeetCore core, YeetInstruction instr) { core.VMStack.Push(core.VMStack.Count == 0 ? null : core.VMStack.Pop()); core.Index++; }
public override void ExecuteInstruction(YeetCore core, YeetInstruction instr) { core.VMStack.Push((int)instr.Operand); core.Index++; }
public abstract void ExecuteInstruction(YeetCore core, YeetInstruction instr);