Ejemplo n.º 1
0
        private static void _execAdd_InvokeToString_CallBacker(
            ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2,
            StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            ASBinCode.RunTimeDataType v1type = v1.rtType;
            ASBinCode.RunTimeDataType v2type = v2.rtType;

            if (v1type == ASBinCode.RunTimeDataType.rt_void)
            {
                v1type = ASBinCode.RunTimeDataType.rt_number;
            }
            if (v2type == ASBinCode.RunTimeDataType.rt_void)
            {
                v2type = ASBinCode.RunTimeDataType.rt_number;
            }

            ASBinCode.RunTimeDataType finalType =
                TypeConverter.getImplicitOpType(
                    v1type,
                    v2type,
                    ASBinCode.OpCode.add, frame.player.swc
                    );

            if (finalType == ASBinCode.RunTimeDataType.rt_number)
            {
                step.reg.getSlot(scope, frame).setValue(
                    TypeConverter.ConvertToNumber(v1)
                    +
                    TypeConverter.ConvertToNumber(v2)

                    );
                frame.endStepNoError();
                return;
            }
            else if (finalType == ASBinCode.RunTimeDataType.rt_string)
            {
                BlockCallBackBase cb = frame.player.blockCallBackPool.create();
                cb.setCallBacker(D_Cast_TwoString_Callbacker);
                cb.args  = frame;
                cb.scope = scope;
                cb.step  = step;

                OpCast.CastTwoValue(v1, v2, finalType, frame, step.token, scope,
                                    frame._tempSlot1, frame._tempSlot2, cb
                                    );


                return;
            }
            else if (finalType == ASBinCode.RunTimeDataType.rt_void)
            {
                step.reg.getSlot(scope, frame).setValue(ASBinCode.rtData.rtUndefined.undefined);
            }
            else
            {
                frame.throwOpException(step.token, ASBinCode.OpCode.add);
            }

            frame.endStep(step);
        }
        private static void _execSuffixInc_ValueOf_Callbacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2,
                                                              StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            if (v1.rtType > ASBinCode.RunTimeDataType.unknown)
            {
                OpCast.InvokeTwoToString(v1, ASBinCode.rtData.rtNull.nullptr,
                                         frame, step.token, scope, frame._tempSlot1, frame._tempSlot2,
                                         step, _execSuffixInc_toString_Callbacker);
            }
            else
            {
                double n = TypeConverter.ConvertToNumber(v1);

                step.reg.getSlot(scope, frame).setValue(n);

                ASBinCode.rtData.rtNumber num = new ASBinCode.rtData.rtNumber(++n);

                StackSlotAccessor register = step.arg1 as StackSlotAccessor;
                if (register != null)
                {
                    bool issuccess;
                    ((StackSlot)register.getSlotForAssign(scope, frame)).assign(num, out issuccess);
                    if (!issuccess)
                    {
                        frame.throwError(step.token, 0, "操作失败");
                    }
                }
                else
                {
                    ((ASBinCode.LeftValueBase)step.arg1).getSlot(scope, frame).directSet(num);
                }

                frame.endStep(step);
            }
        }
        private void _primitive_toObj(ASBinCode.RunTimeValueBase v1,
                                      ASBinCode.RunTimeValueBase v_temp,
                                      StackFrame frame,ASBinCode.OpStep step,
                                      ASBinCode.RunTimeScope scope)
        {
            var c = stackCallers.Pop();

            if (v1.rtType < RunTimeDataType.unknown)
            {
                c.SetFunctionThis(null);
            }
            else
            {
                rtObjectBase rtObj = (rtObjectBase)v1;
                c.SetFunctionThis(rtObj);
            }

            if (!c.createParaScope())
            {
                return;
            }

            SLOT[] argements = (SLOT[])c.tag;

            if (argements[1].getValue().rtType != rtNull.nullptr.rtType)
            {
                rtArray argArray = (rtArray)argements[1].getValue();
                for (int i = 0; i < argArray.innerArray.Count; i++)
                {
                    bool success;
                    c.pushParameter(argArray.innerArray[i],i,out success);
                }
            }
            c.call();
        }
        private static void _execSuffixDec_toString_Callbacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2,
                                                               StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            double n = TypeConverter.ConvertToNumber(v1);

            step.reg.getSlot(scope, frame).setValue(n);

            ASBinCode.rtData.rtNumber num      = new ASBinCode.rtData.rtNumber(--n);
            StackSlotAccessor         register = step.arg1 as StackSlotAccessor;

            if (register != null)
            {
                bool issuccess;
                register.getSlotForAssign(scope, frame).assign(num, out issuccess);
                if (!issuccess)
                {
                    frame.throwError(step.token, 0, "操作失败");
                }
            }
            else
            {
                ((ASBinCode.LeftValueBase)step.arg1).getSlot(scope, frame).directSet(num);
            }


            frame.endStep(step);
        }
Ejemplo n.º 5
0
        public static void execBitOR(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            ASBinCode.RunTimeValueBase v1 = step.arg1.getValue(scope, frame);
            ASBinCode.RunTimeValueBase v2 = step.arg2.getValue(scope, frame);

            var f = frame.player.swc.operatorOverrides.getOperatorFunction(OverrideableOperator.bitOr,
                                                                           v1.rtType, v2.rtType);

            if (f != null)
            {
                FunctionCaller fc = frame.player.funcCallerPool.create(frame, step.token);
                fc.SetFunction(f);
                fc.loadDefineFromFunction();
                if (!fc.createParaScope())
                {
                    return;
                }
                //fc.releaseAfterCall = true;

                bool success;
                fc.pushParameter(v1, 0, out success);
                fc.pushParameter(v2, 1, out success);
                fc.returnSlot = step.reg.getSlot(scope, frame);
                fc.callbacker = fc;
                fc.call();
            }
            else
            {
                OpCast.InvokeTwoValueOf(v1, v2, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _BitOR_ValueOf_CallBacker);
            }
        }
Ejemplo n.º 6
0
        public static void execBitXOR(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            ASBinCode.RunTimeValueBase v1 = step.arg1.getValue(scope, frame);
            ASBinCode.RunTimeValueBase v2 = step.arg2.getValue(scope, frame);

            OpCast.InvokeTwoValueOf(v1, v2, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _BitXOR_ValueOf_Callbacker);
        }
Ejemplo n.º 7
0
        internal static void _objectmemberslotConvertCallbacker(BlockCallBackBase sender,object args)
        {
            StackFrame frame = (StackFrame)sender.args;
            OpStep     step  = sender.step;

            ASBinCode.RunTimeValueBase v = frame._tempSlot1.getValue();
            //ASBinCode.SLOT slot = step.reg.getSlot(sender.scope, frame);

            ObjectMemberSlot slot = (ObjectMemberSlot)sender.cacheObjects[0];

            bool success;

            slot.assign(v,out success);

            if (!success)
            {
                frame.throwCastException(step.token,
                                         step.arg1.getValue(sender.scope,frame).rtType,
                                         slot.slottype
                                         );
                frame.endStep(step);
            }
            else
            {
                frame.endStepNoError();
            }
        }
Ejemplo n.º 8
0
            public override bool directSet(RunTimeValueBase value)
            {
                double v = value.toNumber();

                cache[id]    = v;
                number.value = v;
                return(true);
            }
Ejemplo n.º 9
0
 public override bool directSet(RunTimeValueBase value)
 {
     base.directSet(value);
     if (!_canDelete && backup == null)
     {
         backup = value;
     }
     return(true);
 }
Ejemplo n.º 10
0
            public override bool directSet(RunTimeValueBase value)
            {
                int v = ((rtInt)value).value;

                cache[id]    = v;
                number.value = v;

                return(true);
            }
Ejemplo n.º 11
0
            public override SLOT assign(RunTimeValueBase value,out bool success)
            {
                double v = value.toNumber();

                cache[id]    = v;
                number.value = v;
                success      = true;
                return(this);
            }
Ejemplo n.º 12
0
        public override void clear()
        {
            setindex = null;

            bindObj = null;

            set_this_item = null;
            get_this_item = null;
        }
Ejemplo n.º 13
0
            public override SLOT assign(RunTimeValueBase value,out bool success)
            {
                int v = ((rtInt)value).value;

                cache[id]    = v;
                number.value = v;
                success      = true;
                return(this);
            }
Ejemplo n.º 14
0
 public InternalError(CSWC swc, ASBinCode.SourceToken token, ASBinCode.RunTimeValueBase errorValue) : this(swc)
 {
     this.token      = token;
     this.errorValue = errorValue;
     if (errorValue != null)
     {
         this.message = getErrorInfo();                 //errorValue.ToString();
     }
 }
 public virtual void execute2(RunTimeValueBase thisObj,
                              rtti.FunctionDefine functionDefine,
                              SLOT[] argements,
                              SLOT returnSlot,
                              SourceToken token,
                              object stackframe,
                              out bool success)
 {
     throw new NotImplementedException();
 }
        private static void _execDecrement_toString_Callbacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2,
                                                               StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope
                                                               )
        {
            double n = TypeConverter.ConvertToNumber(v1);

            ASBinCode.rtData.rtNumber num = new ASBinCode.rtData.rtNumber(--n);
            ((ASBinCode.LeftValueBase)step.reg).getSlot(scope, frame).directSet(num);
            frame.endStep(step);
        }
Ejemplo n.º 17
0
 private static void _execNeg_ToString_Callbacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2,
                                                  StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope
                                                  )
 {
     step.reg.getSlot(scope, frame).setValue(
         -TypeConverter.ConvertToNumber(v1)
         //-((ASBinCode.rtData.rtNumber)v1).value
         );    //new ASBinCode.rtData.rtNumber( -((ASBinCode.rtData.rtNumber)v).value));
     //frame.endStep(step);
     frame.endStepNoError();
 }
Ejemplo n.º 18
0
        private static void _BitNot_ValueOf_Callbacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2,
                                                       StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            int n1 = TypeConverter.ConvertToInt(v1);

            int r = ~n1;

            step.reg.getSlot(scope, frame).setValue(r);
            //frame.endStep(step);
            frame.endStepNoError();
        }
Ejemplo n.º 19
0
        private static void _BitXOR_ValueOf_Callbacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2,
                                                       StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            uint n1 = TypeConverter.ConvertToUInt(v1, frame, step.token);
            uint n2 = TypeConverter.ConvertToUInt(v2, frame, step.token);

            int r = (int)(n1 ^ n2);

            step.reg.getSlot(scope, frame).setValue(r);
            //frame.endStep(step);
            frame.endStepNoError();
        }
Ejemplo n.º 20
0
        private static void _execMulti_CallBacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2, StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            double n1 = v1.toNumber();

            double n2 = v2.toNumber();

            {
                step.reg.getSlot(scope, frame).setValue(n1 * n2);// ((ASBinCode.rtData.rtNumber)v1).value - ((ASBinCode.rtData.rtNumber)v2).value);//new ASBinCode.rtData.rtNumber(((ASBinCode.rtData.rtNumber)v1).value - ((ASBinCode.rtData.rtNumber)v2).value));
            }
            //frame.endStep(step);
            frame.endStepNoError();
        }
Ejemplo n.º 21
0
        public static void execAdd(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            ASBinCode.RunTimeValueBase v1 = step.arg1.getValue(scope, frame);
            ASBinCode.RunTimeValueBase v2 = step.arg2.getValue(scope, frame);

            var f = frame.player.swc.operatorOverrides.getOperatorFunction(OverrideableOperator.addition,
                                                                           v1.rtType, v2.rtType);

            if (f != null)
            {
                FunctionCaller fc = frame.player.funcCallerPool.create(frame, step.token);
                fc.SetFunction(f);
                fc.loadDefineFromFunction();
                if (!fc.createParaScope())
                {
                    return;
                }

                //fc.releaseAfterCall = true;

                bool success;
                fc.pushParameter(v1, 0, out success);
                fc.pushParameter(v2, 1, out success);
                fc.returnSlot = step.reg.getSlot(scope, frame);
                fc.callbacker = fc;
                fc.call();
            }
            else if (
                (v1.rtType > ASBinCode.RunTimeDataType.unknown && v2.rtType > ASBinCode.RunTimeDataType.unknown)
                ||
                v1.rtType == ASBinCode.RunTimeDataType.rt_int
                ||
                v1.rtType == ASBinCode.RunTimeDataType.rt_uint
                ||
                v1.rtType == ASBinCode.RunTimeDataType.rt_number
                ||
                v2.rtType == ASBinCode.RunTimeDataType.rt_int
                ||
                v2.rtType == ASBinCode.RunTimeDataType.rt_uint
                ||
                v2.rtType == ASBinCode.RunTimeDataType.rt_number
                )
            {
                OpCast.InvokeTwoValueOf(v1, v2, frame, step.token, scope,
                                        frame._tempSlot1, frame._tempSlot2, step, _execAdd_CallBacker);
            }
            else //toString
            {
                OpCast.InvokeTwoToString(v1, v2, frame, step.token, scope,
                                         frame._tempSlot1, frame._tempSlot2, step, _execAdd_InvokeToString_CallBacker);
            }
        }
 private static void _execIncrement_ValueOf_Callbacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2,
                                                       StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope
                                                       )
 {
     if (v1.rtType > ASBinCode.RunTimeDataType.unknown)
     {
         OpCast.InvokeTwoToString(v1, ASBinCode.rtData.rtNull.nullptr, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _execIncrement_ToString_Callbacker);
     }
     else
     {
         double n = TypeConverter.ConvertToNumber(v1);
         ASBinCode.rtData.rtNumber num = new ASBinCode.rtData.rtNumber(++n);
         ((ASBinCode.LeftValueBase)step.reg).getSlot(scope, frame).directSet(num);
         frame.endStep(step);
     }
 }
Ejemplo n.º 23
0
 private static void _execNeg_ValueOf_Callbacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2,
                                                 StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope
                                                 )
 {
     if (v1.rtType > ASBinCode.RunTimeDataType.unknown)
     {
         OpCast.InvokeTwoToString(v1, ASBinCode.rtData.rtNull.nullptr, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _execNeg_ToString_Callbacker);
     }
     else
     {
         step.reg.getSlot(scope, frame).setValue(
             -TypeConverter.ConvertToNumber(v1)
             );
         //frame.endStep(step);
         frame.endStepNoError();
     }
 }
        private static void _func_ToObj(ASBinCode.RunTimeValueBase v1,
                                        ASBinCode.RunTimeValueBase v2,
                                        StackFrame frame,
                                        ASBinCode.OpStep step,
                                        ASBinCode.RunTimeScope scope)
        {
            var _class = frame.player.swc.classes[0];

            //frame.instanceCreator = new InstanceCreator(frame.player, frame, step.token, _class);
            frame.activeInstanceCreator(step.token, _class);
            frame.instanceCreator.constructor = (ASBinCode.rtData.rtObjectBase)v1;
            if (!frame.instanceCreator.prepareConstructorArgements())
            {
                return;
            }

            frame.endStep(step);
        }
        public RunTimeScope(

            HeapSlot[] memberDataList,

            int blockid,
            RunTimeScope parent,

            RunTimeValueBase this_pointer,
            RunTimeScopeType type
            )
        {
            this.blockId = blockid;
            this.parent  = parent;

            this.memberData = memberDataList;

            this.this_pointer = this_pointer;
            this.scopeType    = type;
        }
Ejemplo n.º 26
0
        private static void _BitLeftShift_ValueOf_Callbacker(ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2, StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            int n1 = TypeConverter.ConvertToInt(v1);
            int n2 = TypeConverter.ConvertToInt(v2);

            if (n2 < 0)
            {
                n2 = 0;
            }
            else if (n2 > 31)
            {
                n2 = 31;
            }

            int r = n1 << n2;

            step.reg.getSlot(scope, frame).setValue(r);

            //frame.endStep(step);
            frame.endStepNoError();
        }
Ejemplo n.º 27
0
        public static void execNeg(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            ASBinCode.RunTimeValueBase v = step.arg1.getValue(scope, frame);

            if (v.rtType != ASBinCode.RunTimeDataType.rt_number)
            {
                var f = frame.player.swc.operatorOverrides.getOperatorFunction(OverrideableOperator.Unary_negation,
                                                                               v.rtType, RunTimeDataType.unknown);
                if (f != null)
                {
                    FunctionCaller fc = frame.player.funcCallerPool.create(frame, step.token);  //fc.releaseAfterCall = true;
                    fc.SetFunction(f);
                    fc.loadDefineFromFunction();
                    if (!fc.createParaScope())
                    {
                        return;
                    }
                    bool success;
                    fc.pushParameter(v, 0, out success);
                    fc.returnSlot = step.reg.getSlot(scope, frame);
                    fc.callbacker = fc;
                    fc.call();

                    return;
                }
                else
                {
                    OpCast.InvokeTwoValueOf(v, ASBinCode.rtData.rtNull.nullptr, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _execNeg_ValueOf_Callbacker);
                }
            }
            else
            {
                step.reg.getSlot(scope, frame).setValue(-((ASBinCode.rtData.rtNumber)v).value);//new ASBinCode.rtData.rtNumber( -((ASBinCode.rtData.rtNumber)v).value));
                //frame.endStep(step);
                frame.endStepNoError();
            }
        }
Ejemplo n.º 28
0
        public static void execUnaryPlus(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            ASBinCode.RunTimeValueBase v = step.arg1.getValue(scope, frame);

            var f = frame.player.swc.operatorOverrides.getOperatorFunction(OverrideableOperator.Unary_plus,
                                                                           v.rtType, RunTimeDataType.unknown);

            if (f != null)
            {
                FunctionCaller fc = frame.player.funcCallerPool.create(frame, step.token); //fc.releaseAfterCall = true;
                fc.SetFunction(f);
                fc.loadDefineFromFunction();
                if (!fc.createParaScope())
                {
                    return;
                }
                bool success;
                fc.pushParameter(v, 0, out success);
                fc.returnSlot = step.reg.getSlot(scope, frame);
                fc.callbacker = fc;
                fc.call();

                return;
            }
            else
            {
                BlockCallBackBase cb = frame.player.blockCallBackPool.create();
                cb.scope = scope;
                cb.step  = step;
                cb.args  = frame;
                cb.setCallBacker(_tonumber_cb);

                OpCast.CastValue(v, RunTimeDataType.rt_number,
                                 frame, step.token, scope, frame._tempSlot1, cb, false);
            }
        }
Ejemplo n.º 29
0
        private static void _execAdd_CallBacker(
            ASBinCode.RunTimeValueBase v1, ASBinCode.RunTimeValueBase v2,
            StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            ASBinCode.RunTimeDataType v1type = v1.rtType;
            ASBinCode.RunTimeDataType v2type = v2.rtType;

            if (v1type == ASBinCode.RunTimeDataType.rt_void)
            {
                v1type = ASBinCode.RunTimeDataType.rt_number;
            }
            if (v2type == ASBinCode.RunTimeDataType.rt_void)
            {
                v2type = ASBinCode.RunTimeDataType.rt_number;
            }

            if (v1type > ASBinCode.RunTimeDataType.unknown || v2type > ASBinCode.RunTimeDataType.unknown)
            {
                //***调用toString()***
                OpCast.InvokeTwoToString(v1, v2, frame, step.token, scope,
                                         frame._tempSlot1, frame._tempSlot2, step, _execAdd_InvokeToString_CallBacker);
            }
            //else if (v1type > ASBinCode.RunTimeDataType.unknown)
            //{
            //    OpCast.InvokeTwoToString(v1, v2, frame, step.token, scope,
            //        frame._tempSlot1, frame._tempSlot2, step, _execAdd_InvokeToString_CallBacker);
            //}
            //else if (v2type > ASBinCode.RunTimeDataType.unknown)
            //{

            //}
            else
            {
                _execAdd_InvokeToString_CallBacker(v1, v2, frame, step, scope);
            }
        }
Ejemplo n.º 30
0
        public static void execBitNot(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            ASBinCode.RunTimeValueBase v1 = step.arg1.getValue(scope, frame);

            OpCast.InvokeTwoValueOf(v1, ASBinCode.rtData.rtNull.nullptr, frame, step.token, scope, frame._tempSlot1, frame._tempSlot2, step, _BitNot_ValueOf_Callbacker);
        }