コード例 #1
0
ファイル: State.cs プロジェクト: DatZach/Xi
 public State()
 {
     Modules = new List<Module>();
     CallStack = new VmStack<CallInfo>();
     Stack = new VmStack<Variant>();
     Scope = new ExpandoObject();
 }
コード例 #2
0
ファイル: Context.cs プロジェクト: zhouzu/Hex-Virtualization
        public Context(List <HxInstruction> instrs, object[] args)
        {
            Index        = 0;
            Instructions = instrs;
            Stack        = new VmStack();
            Locals       = new VmLocal();
            Args         = new VmArgs(args);

            Handlers = new Dictionary <HxOpCodes, HxOpCode>
            {
                // custom
                { HxOpCodes.HxCall, new HxCall() },   // universal call
                { HxOpCodes.HxLdc, new HxLdc() },     // universal ldc]
                { HxOpCodes.HxArray, new HxArray() }, // array stuff
                { HxOpCodes.HxLoc, new HxLoc() },     // stloc, ldloc
                { HxOpCodes.HxArg, new HxArg() },     // starg, ldarg
                { HxOpCodes.HxFld, new HxFld() },     // fld
                { HxOpCodes.HxConv, new HxConv() },   // conv

                // stuff where operand is null
                { HxOpCodes.AClt, new Clt() },   //  y<x
                { HxOpCodes.ACgt, new Cgt() },   // y > x (first value compare first)

                { HxOpCodes.ANeg, new Neg() },   // -val
                { HxOpCodes.ANot, new Not() },   //  ˜val
                { HxOpCodes.AAnd, new And() },   // true and true

                { HxOpCodes.AShr, new Shr() },   // >>
                { HxOpCodes.AShl, new Shl() },   //  <<
                { HxOpCodes.AXor, new Xor() },   //  y^x

                { HxOpCodes.ARem, new Rem() },   // module  y % x
                { HxOpCodes.ACeq, new Ceq() },   // x == y
                { HxOpCodes.AMul, new Mul() },   // y * x
                { HxOpCodes.ANop, new Nop() },   //  nop do nothing

                { HxOpCodes.AAdd, new Add() },   // y+x
                { HxOpCodes.ASub, new Sub() },   // y-x
                { HxOpCodes.ARet, new Ret() },   // return
                { HxOpCodes.APop, new Pop() },   // pop val on top of stack
                { HxOpCodes.ALdlen, new Len() }, // length of array
                { HxOpCodes.ADup, new Dup() },   // dup on top of stack
                { HxOpCodes.ADiv, new Div() },   // divide

                // not custom & not null operand
                { HxOpCodes.Ldtoken, new Ldtoken() },
                { HxOpCodes.Br, new Br() },
                { HxOpCodes.Brtrue, new Brtrue() },
                { HxOpCodes.Brfalse, new Brfalse() },
                { HxOpCodes.Box, new Box() },
                { HxOpCodes.Newobj, new Newobj() }
            };
        }