示例#1
0
        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++;
        }
示例#2
0
        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++;
        }
示例#3
0
        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();
        }
示例#4
0
 public override void ExecuteInstruction(YeetCore core, YeetInstruction instr)
 {
     core.VMStack.Push(core.VMStack.Count == 0 ? null : core.VMStack.Pop());
     core.Index++;
 }
示例#5
0
 public override void ExecuteInstruction(YeetCore core, YeetInstruction instr)
 {
     core.VMStack.Push((int)instr.Operand);
     core.Index++;
 }
示例#6
0
 public abstract void ExecuteInstruction(YeetCore core, YeetInstruction instr);