コード例 #1
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            vm.LeaveFrame();

            // 让指令完CALL后, 往后走
            return(true);
        }
コード例 #2
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            int valueCount = cmd.DataA;

            var map = Convertor.CastObject(vm.DataStack.Get(-valueCount * 2 - 1)).Raw as Map;

            if (map == null)
            {
                throw new RuntimeException("Expect 'Builtin.Map' value");
            }

            map.Raw.Clear();

            var argBegin = vm.DataStack.Count - valueCount * 2;

            for (int i = 0; i < valueCount * 2; i += 2)
            {
                var key   = vm.DataStack.Get(argBegin + i);
                var value = vm.DataStack.Get(argBegin + i + 1);

                map.Raw.Add(key, value);
            }

            vm.DataStack.PopMulti(valueCount * 2);

            return(true);
        }
コード例 #3
0
        internal override void Compile(CompileParameter param)
        {
            var newset = new ValuePhoFunc(new ObjectName("fakepkg", "constcalc"), ConstPos, 0, null);


            var funcParam = param.SetCmdSet(newset);

            // 用空的常量表
            funcParam.Constants = new ConstantSet();

            // 生成表达式计算指令
            Value.Compile(funcParam);

            try
            {
                var eval = VMachine.MiniExec(newset, funcParam.Constants);

                var ci = param.Constants.Add(eval);
                Name.Symbol.RegIndex = ci;
            }
            catch (RuntimeException)
            {
                throw new CompileException("Expect constant value to caculate value", ConstPos);
            }
        }
コード例 #4
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            int valueCount = cmd.DataA;

            var arr = Convertor.CastObject(vm.DataStack.Get(-valueCount - 1)).Raw as Array;

            if (arr == null)
            {
                throw new RuntimeException("Expect 'Builtin.Array' value");
            }



            arr.Raw.Clear();

            arr.Raw.Capacity = valueCount;

            var argBegin = vm.DataStack.Count - valueCount;

            for (int i = 0; i < valueCount; i++)
            {
                arr.Raw.Add(vm.DataStack.Get(argBegin + i));
            }

            vm.DataStack.PopMulti(valueCount);

            return(true);
        }
コード例 #5
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            var d = vm.DataStack.Pop();

            vm.GetRuntimePackage(cmd.DataA).Reg.Set(cmd.DataB, d);

            return(true);
        }
コード例 #6
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            var ci = Convertor.CastClassInstance(vm.DataStack.Pop());

            vm.DataStack.Push(ci.GetBaseValue(cmd.DataA));

            return(true);
        }
コード例 #7
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            var ci = vm.DataStack.Pop();

            vm.DataStack.Push(ci.OperateGetMemberValue(cmd.DataA));

            return(true);
        }
コード例 #8
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            var ins = Convertor.CastClassType(vm.GetEntry(cmd.DataA)).CreateInstance();

            vm.DataStack.Push(ins);

            return(true);
        }
コード例 #9
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            var obj = vm.DataStack.Pop();

            var func = Convertor.CastFunc(obj);

            return(func.Invoke(vm, cmd.DataA, cmd.DataB, obj as ValueClosure));
        }
コード例 #10
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            var proc = Convertor.CastFunc(vm.GetEntry(cmd.DataA));

            vm.DataStack.Push(new ValueClosure(proc));

            return(true);
        }
コード例 #11
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            // var c = Convertor.CastObject(vm.DataStack.Pop());

            // vm.DataStack.Push(c.GetValue(cmd.DataA));

            return(true);
        }
コード例 #12
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            Value v = vm.GetRuntimePackage(cmd.DataA).Reg.Get(cmd.DataB);

            vm.DataStack.Push(v);

            return(true);
        }
コード例 #13
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            var c = vm.Constants.Get(cmd.DataA);

            vm.DataStack.Push(c);

            return(true);
        }
コード例 #14
0
ファイル: MapWrapper.cs プロジェクト: mind-owner/PhotonSharp
        public static int Clear(VMachine phoVM)
        {
            var phoClassIns = phoVM.DataStack.GetNativeInstance <Photon.Map>(0);

            phoClassIns.Clear(  );


            return(0);
        }
コード例 #15
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            int regIndex = cmd.DataA;

            var d = vm.DataStack.Pop();

            vm.LocalReg.Set(regIndex, d);

            return(true);
        }
コード例 #16
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            var regIndex = cmd.DataA;

            var d = vm.DataStack.Pop();

            vm.CurrFrame.Closure.SetValue(regIndex, d);

            return(true);
        }
コード例 #17
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            var a = vm.DataStack.Pop();

            var x = a.OperateUnary(cmd.Op);

            vm.DataStack.Push(x);

            return(true);
        }
コード例 #18
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            int regIndex = cmd.DataA;

            var v = vm.CurrFrame.Closure.GetValue(regIndex);

            vm.DataStack.Push(v);

            return(true);
        }
コード例 #19
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            var obj = vm.DataStack.Pop();

            var v = vm.DataStack.Pop();

            obj.OperateSetMemberValue(cmd.DataA, v);

            return(true);
        }
コード例 #20
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            int regIndex = cmd.DataA;

            Value v = vm.LocalReg.Get(regIndex);

            vm.DataStack.Push(v);

            return(true);
        }
コード例 #21
0
        public static int RemoveAt(VMachine phoVM)
        {
            var phoClassIns = phoVM.DataStack.GetNativeInstance <Photon.Array>(0);

            var index = phoVM.DataStack.GetInteger32(1);

            phoClassIns.RemoveAt(index);


            return(0);
        }
コード例 #22
0
        public static int Remove(VMachine phoVM)
        {
            var phoClassIns = phoVM.DataStack.GetNativeInstance <Photon.Array>(0);

            var v = phoVM.DataStack.GetValue(1);

            phoClassIns.Remove(v);


            return(0);
        }
コード例 #23
0
        internal bool ExecCode(VMachine vm, Command cmd)
        {
            var inc = _instruction[(int)cmd.Op];

            if (inc == null)
            {
                throw new RuntimeException("invalid instruction");
            }


            return(inc.Execute(vm, cmd));
        }
コード例 #24
0
ファイル: MapWrapper.cs プロジェクト: mind-owner/PhotonSharp
        public static int ContainsValue(VMachine phoVM)
        {
            var phoClassIns = phoVM.DataStack.GetNativeInstance <Photon.Map>(0);

            var k = phoVM.DataStack.GetValue(1);

            var phoRetArg = phoClassIns.ContainsValue(k);

            phoVM.DataStack.PushBool(phoRetArg);

            return(1);
        }
コード例 #25
0
        public static int Set(VMachine phoVM)
        {
            var phoClassIns = phoVM.DataStack.GetNativeInstance <Photon.Array>(0);

            var index = phoVM.DataStack.GetInteger32(1);
            var v     = phoVM.DataStack.GetValue(2);

            phoClassIns.Set(index, v);


            return(0);
        }
コード例 #26
0
        public static int Get(VMachine phoVM)
        {
            var phoClassIns = phoVM.DataStack.GetNativeInstance <Photon.Array>(0);

            var index = phoVM.DataStack.GetInteger32(1);

            var phoRetArg = phoClassIns.Get(index);

            phoVM.DataStack.PushValue(phoRetArg);

            return(1);
        }
コード例 #27
0
        public static int IndexOf(VMachine phoVM)
        {
            var phoClassIns = phoVM.DataStack.GetNativeInstance <Photon.Array>(0);

            var v = phoVM.DataStack.GetValue(1);

            var phoRetArg = phoClassIns.IndexOf(v);

            phoVM.DataStack.PushInteger32(phoRetArg);

            return(1);
        }
コード例 #28
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            var obj = vm.DataStack.Pop();

            var key = vm.DataStack.Pop();

            var value = obj.OperateGetKeyValue(key);

            vm.DataStack.Push(value);

            return(true);
        }
コード例 #29
0
        public static int TryGet(VMachine phoVM)
        {
            var phoClassIns = phoVM.DataStack.GetNativeInstance <Photon.Array>(0);

            var index = phoVM.DataStack.GetInteger32(1);

            Value v         = default(Value);
            var   phoRetArg = phoClassIns.TryGet(index, out v);

            phoVM.DataStack.PushValue(v);
            phoVM.DataStack.PushBool(phoRetArg);

            return(2);
        }
コード例 #30
0
        public override bool Execute(VMachine vm, Command cmd)
        {
            var iterObj = vm.DataStack.Pop();
            var x       = vm.DataStack.Pop();

            if (x.Visit(iterObj, vm.DataStack))
            {
                return(true);
            }

            vm.CurrFrame.PC = cmd.DataA;

            return(false);
        }