コード例 #1
0
        public static bool create_paraScope_WithSignature_AllParaOnStack(StackFrame frame, ASBinCode.OpStep step, RunTimeScope scope)
        {
            rtFunction function
                = (rtFunction)step.arg1.getValue(frame.scope, frame);

            var functionDefine = frame.player.swc.functions[function.functionId];

            if (frame.baseBottomSlotIndex + frame.call_parameter_slotCount + functionDefine.signature.onStackParameters >= Player.STACKSLOTLENGTH)
            {
                frame.throwError(new error.InternalError(frame.player.swc, step.token, "stack overflow"));
                frame.endStep();
                return(false);
            }

            var funcCaller = frame.player.funcCallerPool.create(frame, step.token);

            funcCaller.SetFunction(function); function.Clear();
            funcCaller.toCallFunc = functionDefine;
            frame.funCaller       = funcCaller;

            frame.call_parameter_slotCount  += functionDefine.signature.onStackParameters;
            funcCaller.onstackparametercount = functionDefine.signature.onStackParameters;
            funcCaller.CallFuncHeap          = Player.emptyMembers;

            var parameters = functionDefine.signature.parameters; int len = parameters.Count; int parast = frame.baseBottomSlotIndex + frame.call_parameter_slotCount;

            for (int i = step.jumoffset; i < len; i++)
            {
                var parameter = parameters[i];
                if (parameter.defaultValue != null)
                {
                    var dv = FunctionCaller.getDefaultParameterValue(parameter.type, parameter.defaultValue.getValue(null, null));

                    frame.stack[parast - i - 1].directSet(dv);
                    //_storeArgementToSlot(i, dv);
                }
                else if (parameter.isPara)
                {
                    frame.stack[parast - i - 1].directSet(new ASBinCode.rtData.rtArray());
                    //_storeArgementToSlot(i, new ASBinCode.rtData.rtArray());
                }
            }



            frame.endStepNoError();
            return(true);
        }