public static void exec_Push(StackFrame frame, ASBinCode.OpStep step, ASBinCode.RunTimeScope scope)
        {
            ASBinCode.rtData.rtArray array = (ASBinCode.rtData.rtArray)step.reg.getValue(scope, frame);

            //防止引用了StackSlot中的值类型,因此这里需要Clone()
            array.innerArray.Add((ASBinCode.RunTimeValueBase)step.arg1.getValue(scope, frame).Clone());

            frame.endStepNoError();
            //frame.endStep(step);
        }
Example #2
0
        public void pushParameter_Para(RunTimeValueBase argement,int id,out bool success)
        {
            if (doPushNativeModeConstParameter(argement,id,out success))
            {
                return;
            }

            //***最后一个是参数数组,并且id大于等于最后一个
            SLOT slot = _getArgementSlot(toCallFunc.signature.parameters.Count - 1);             //CallFuncHeap[toCallFunc.signature.parameters.Count - 1];

            if (slot.getValue().rtType == RunTimeDataType.rt_null)
            {
                slot.directSet(new ASBinCode.rtData.rtArray());
            }

            ASBinCode.rtData.rtArray arr = (ASBinCode.rtData.rtArray)slot.getValue();
            arr.innerArray.Add((RunTimeValueBase)argement.Clone());                //可能从StackSlot中读的数据,因此必须Clone后再传入.


            success = true;
        }
Example #3
0
        public void pushParameter(RunTimeValueBase argement,int id,out bool success)
        {
            if (doPushNativeModeConstParameter(argement,id,out success))
            {
                return;
            }

            var parameters = toCallFunc.signature.parameters;

            if (parameters.Count > 0 || toCallFunc.IsAnonymous)
            {
                bool lastIsPara = false;

                if (parameters.Count > 0 && parameters[parameters.Count - 1].isPara)
                {
                    lastIsPara = true;
                }

                if (!lastIsPara ||
                    id < parameters.Count - 1
                    ||
                    (
                        toCallFunc.IsAnonymous
                        &&
                        !(lastIsPara && id >= parameters.Count - 1)
                    )

                    )
                {
                    if (id < parameters.Count)
                    {
                        //CallFuncHeap[id].directSet(argement);

                        _storeArgementToSlot(id,argement);

                        pushedArgs++;
                    }
                    else
                    {
                        if (!toCallFunc.IsAnonymous)
                        {
                            //参数数量不匹配
                            invokerFrame.throwArgementException(
                                token,
                                string.Format(
                                    "Argument count mismatch on Function/{0}. Expected {1}, got {2}.",
                                    player.swc.blocks[toCallFunc.blockid].name,toCallFunc.signature.parameters.Count,pushedArgs + 1
                                    )

                                );

                            //***中断本帧本次代码执行进入try catch阶段
                            success = false;

                            clear_para_slot(invokerFrame,onstackparametercount);
                            if (callbacker != null)
                            {
                                callbacker.noticeRunFailed();
                            }
                            release();


                            return;
                        }
                    }
                }
                else
                {
                    //***最后一个是参数数组,并且id大于等于最后一个
                    SLOT slot = _getArgementSlot(parameters.Count - 1);                     //CallFuncHeap[toCallFunc.signature.parameters.Count - 1];
                    if (slot.getValue().rtType == RunTimeDataType.rt_null)
                    {
                        slot.directSet(new ASBinCode.rtData.rtArray());
                    }

                    ASBinCode.rtData.rtArray arr = (ASBinCode.rtData.rtArray)slot.getValue();
                    arr.innerArray.Add((RunTimeValueBase)argement.Clone());                        //可能从StackSlot中读的数据,因此必须Clone后再传入.
                }

                success = true;
            }
            else
            {
                invokerFrame.throwArgementException(
                    token,
                    string.Format(
                        "Argument count mismatch on Function/{0}. Expected {1}, got {2}.",
                        player.swc.blocks[toCallFunc.blockid].name,toCallFunc.signature.parameters.Count,pushedArgs + 1
                        )

                    );
                success = false;

                clear_para_slot(invokerFrame,onstackparametercount);
                if (callbacker != null)
                {
                    callbacker.noticeRunFailed();
                }
                release();
            }
        }