Ejemplo n.º 1
0
        private void _SeptoString_CB(BlockCallBackBase sender,object args)
        {
            object[]   receiveArgs = (object[])sender.args;
            StackFrame frame       = (StackFrame)receiveArgs[2];

            rtArray array = (rtArray)receiveArgs[1];

            BlockCallBackBase valueCB = frame.player.blockCallBackPool.create();

            valueCB._intArg = sender._intArg + 1;
            valueCB.args    = valueCB.copyFromReceiveArgs(receiveArgs);
            valueCB.setCallBacker(_ValueToString_CB);
            valueCB._intArg2 = sender._intArg2;
            var v = array.innerArray[sender._intArg];

            if (v.rtType == RunTimeDataType.rt_void)
            {
                v = UNDEFINED;
            }

            sender.noticeEnd();


            operators.OpCast.CastValue(v,RunTimeDataType.rt_string,
                                       frame,
                                       (SourceToken)receiveArgs[3],
                                       (RunTimeScope)receiveArgs[4],
                                       frame._tempSlot1,
                                       valueCB,false
                                       );
        }
Ejemplo n.º 2
0
        private void check_para(BlockCallBackBase checkparacb)
        {
            while (check_para_id < pushedArgs)
            {
                var parameter = toCallFunc.signature.parameters;

                RunTimeValueBase argement = getToCheckParameter(check_para_id);

                var argtype    = argement.rtType;
                var targettype = parameter[check_para_id].type;

                if (argtype != targettype
                    &&
                    targettype != RunTimeDataType.rt_void
                    &&
                    !(argtype == RunTimeDataType.rt_null && targettype > RunTimeDataType.unknown)
                    &&
                    !(argtype > RunTimeDataType.unknown && targettype > RunTimeDataType.unknown
                      &&
                      (
                          ClassMemberFinder.check_isinherits(argement,targettype,player.swc)
                          ||
                          ClassMemberFinder.check_isImplements(argement,targettype,player.swc)
                      )
                      )

                    )
                {
                    BlockCallBackBase cb = player.blockCallBackPool.create();
                    cb.args    = argement;
                    cb._intArg = check_para_id;
                    cb.setCallBacker(check_para_callbacker);
                    cb.setWhenFailed(check_para_failed);

                    check_para_id++;

                    OpCast.CastValue(argement,parameter[
                                         cb._intArg].type,

                                     invokerFrame,token,invokerFrame.scope,_tempSlot,cb,false);

                    return;
                }
                else
                {
                    check_para_id++;
                }
            }

            if (pushedArgs < toCallFunc.signature.parameters.Count && !toCallFunc.IsAnonymous)             //匿名函数能跳过参数检查
            {
                for (int i = pushedArgs; i < toCallFunc.signature.parameters.Count; i++)
                {
                    if (toCallFunc.signature.parameters[pushedArgs].defaultValue == null
                        &&
                        !toCallFunc.signature.parameters[pushedArgs].isPara
                        )
                    {
                        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
                                )

                            );
                        clear_para_slot(invokerFrame,onstackparametercount); onstackparametercount = 0;
                        //***中断本帧本次代码执行进入try catch阶段
                        invokerFrame.endStep();

                        if (callbacker != null)
                        {
                            callbacker.noticeRunFailed();
                        }
                        release();


                        return;
                    }
                }
            }

            if (!check_return_objtypeisclasscreated())
            {
                return;
            }

            if (checkparacb != null)
            {
                checkparacb.noticeEnd();
            }
            //***全部参数检查通过***
            doCall_allcheckpass();
        }