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);
            }
        }
        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);
     }
 }
Beispiel #4
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 _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);
            }
        }