Exemple #1
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);
        }
Exemple #2
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);
            }
        }
        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);
            }
        }
Exemple #4
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();
            }
        }
Exemple #5
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);
        }
        public static void execIncrement(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            var v = step.arg1.getValue(scope, frame);

            StackSlotAccessor register = step.arg1 as StackSlotAccessor;

            if (register != null)
            {
                ((StackSlot)register.getSlotForAssign(scope, frame)).linkTo(null);
            }

            switch (v.rtType)
            {
            case ASBinCode.RunTimeDataType.rt_int:
            {
                ASBinCode.rtData.rtInt iv = (ASBinCode.rtData.rtInt)v;
                iv.value++;
                ((LeftValueBase)step.arg1).getSlot(scope, frame).directSet(iv);
                step.reg.getSlot(scope, frame).setValue(iv.value);
            }
            break;

            case ASBinCode.RunTimeDataType.rt_uint:
            {
                ASBinCode.rtData.rtUInt iv = (ASBinCode.rtData.rtUInt)v;
                iv.value++;
                ((LeftValueBase)step.arg1).getSlot(scope, frame).directSet(iv);
                step.reg.getSlot(scope, frame).setValue(iv.value);
            }
            break;

            case ASBinCode.RunTimeDataType.rt_number:
            {
                ASBinCode.rtData.rtNumber iv = (ASBinCode.rtData.rtNumber)v;
                iv.value++;
                ((LeftValueBase)step.arg1).getSlot(scope, frame).directSet(iv);
                step.reg.getSlot(scope, frame).setValue(iv.value);
            }
            break;

            case ASBinCode.RunTimeDataType.rt_string:

            {
                double n = TypeConverter.ConvertToNumber(v);
                if (string.IsNullOrEmpty(((ASBinCode.rtData.rtString)v).value))
                {
                    n = 0;
                }

                ASBinCode.rtData.rtNumber num = new ASBinCode.rtData.rtNumber(++n);
                step.reg.getSlot(scope, frame).directSet(num);
            }
            break;

            case ASBinCode.RunTimeDataType.rt_boolean:
            case ASBinCode.RunTimeDataType.rt_void:
            case ASBinCode.RunTimeDataType.rt_null:
            {
                double n = TypeConverter.ConvertToNumber(v);
                ASBinCode.rtData.rtNumber num = new ASBinCode.rtData.rtNumber(++n);
                ((ASBinCode.LeftValueBase)step.reg).getSlot(scope, frame).directSet(num);
            }
            break;

            case ASBinCode.RunTimeDataType.unknown:
            default:
            {
                OpCast.InvokeTwoValueOf(v, ASBinCode.rtData.rtNull.nullptr, frame, step.token,
                                        scope, frame._tempSlot1,
                                        frame._tempSlot2, step, _execIncrement_ValueOf_Callbacker);
                return;
            }
            }

            //frame.endStep(step);
            frame.endStepNoError();
        }