public DictionaryKey(RunTimeValueBase key, bool needclone)
 {
     if (needclone)
     {
         key = (RunTimeValueBase)key.Clone();
     }
     this.key = key;
 }
Exemplo n.º 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;
        }
Exemplo n.º 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();
            }
        }
            public override SLOT assign(RunTimeValueBase value,out bool success)
            {
                if (vector_data.vector_type != value.rtType
                    &&
                    !
                    (
                        //***检查子类关系****
                        (vector_data.vector_type > RunTimeDataType.unknown &&
                         value.rtType > RunTimeDataType.unknown &&
                         (
                             ClassMemberFinder.check_isinherits(value,vector_data.vector_type,classfinder)
                             ||
                             ClassMemberFinder.check_isImplements(value,vector_data.vector_type,classfinder)
                         )
                        )
                        ||
                        (
                            vector_data.vector_type > RunTimeDataType.unknown &&
                            value.rtType == RunTimeDataType.rt_null
                        )
                        ||
                        (
                            vector_data.vector_type == RunTimeDataType.rt_array &&
                            value.rtType == RunTimeDataType.rt_null
                        )
                        ||
                        (
                            vector_data.vector_type == RunTimeDataType.rt_function &&
                            value.rtType == RunTimeDataType.rt_null
                        )
                        ||
                        (
                            vector_data.vector_type == RunTimeDataType.rt_string &&
                            value.rtType == RunTimeDataType.rt_null
                        )
                    )
                    )
                {
                    //return false;
                    success = false;
                    return(this);
                }
                else
                {
                    switch (value.rtType)
                    {
                    case RunTimeDataType.rt_int:
                    {
                        ((rtInt)vector_data.innnerList[idx]).value = ((rtInt)value).value;
                        success = true;
                        return(this);
                    }

                    case RunTimeDataType.rt_uint:
                    {
                        ((rtUInt)vector_data.innnerList[idx]).value = ((rtUInt)value).value;
                        success = true;
                        return(this);
                    }

                    case RunTimeDataType.rt_number:
                    {
                        ((rtNumber)vector_data.innnerList[idx]).value = ((rtNumber)value).value;
                        success = true;
                        return(this);
                    }

                    case RunTimeDataType.rt_string:
                    {
                        ((rtString)vector_data.innnerList[idx]).value = ((rtString)value).value;
                        success = true;
                        return(this);
                    }

                    case RunTimeDataType.rt_function:
                    {
                        ((rtFunction)vector_data.innnerList[idx]).CopyFrom((rtFunction)value);
                        success = true;
                        return(this);
                    }

                    default:
                        break;
                    }

                    if (value.rtType > RunTimeDataType.unknown)
                    {
                        var vd = vector_data.innnerList[idx];
                        if (vd != null)
                        {
                            var cls = classfinder.getClassByRunTimeDataType(value.rtType);
                            if (cls.isLink_System)
                            {
                                ASBinCode.rtti.LinkSystemObject link = (ASBinCode.rtti.LinkSystemObject)((rtObjectBase)vd).value;

                                if (cls.isStruct)
                                {
                                    link.CopyStructData((ASBinCode.rtti.LinkSystemObject)((rtObjectBase)value).value);
                                }
                                else
                                {
                                    ((rtObjectBase)vd).value = ((rtObjectBase)value).value;
                                }
                                success = true;
                                return(this);
                            }
                        }
                    }

                    vector_data.innnerList[idx] = (RunTimeValueBase)value.Clone();                     //对容器的直接赋值,需要Clone																				   //return true;
                    success = true;
                    return(this);
                }
            }
        public bool rtValueToLinkObject
            (RunTimeValueBase value,Type linkType,IClassFinder bin,bool needclone,out object linkobject)
        {
            RunTimeDataType vt = value.rtType;

            if (vt == RunTimeDataType.rt_null)
            {
                linkobject = null;
                return(true);
            }

            if (vt > RunTimeDataType.unknown)
            {
                var cls = bin.getClassByRunTimeDataType(vt);

                RunTimeDataType ot;
                if (TypeConverter.Object_CanImplicit_ToPrimitive(
                        cls,out ot
                        ))
                {
                    vt    = ot;
                    value = TypeConverter.ObjectImplicit_ToPrimitive((ASBinCode.rtData.rtObjectBase)value);
                }
                else if (linkType is AS3Class_Type && cls.staticClass == null)
                {
                    if (cls.getRtType() == ((AS3Class_Type)linkType).rttype)
                    {
                        linkobject = ((AS3Class_Type)linkType).linktype;
                        return(true);
                    }
                }
            }
            RunTimeDataType at =
                getRuntimeDataType(
                    linkType);

            if (at == RunTimeDataType.rt_int)
            {
                linkobject = (TypeConverter.ConvertToInt(value));
            }
            else if (at == RunTimeDataType.rt_uint)
            {
                linkobject = (TypeConverter.ConvertToUInt(value,null,null));
            }
            else if (at == RunTimeDataType.rt_string)
            {
                linkobject = (TypeConverter.ConvertToString(value,null,null));
            }
            else if (at == RunTimeDataType.rt_number)
            {
                linkobject = (TypeConverter.ConvertToNumber(value));
            }
            else if (at == RunTimeDataType.rt_boolean)
            {
                var b = TypeConverter.ConvertToBoolean(value,null,null);
                linkobject = b.value;
            }
            else if (at == RunTimeDataType.rt_array)
            {
                linkobject = (ASBinCode.rtData.rtArray)value;
            }
            else if (at == RunTimeDataType.rt_function)
            {
                if (needclone)
                {
                    linkobject = (ASBinCode.rtData.rtFunction)value;
                }
                else
                {
                    linkobject = ((ASBinCode.rtData.rtFunction)value).Clone();
                }
            }
            else if (at == _OBJECT_LINK)
            {
                if (vt > RunTimeDataType.unknown)
                {
                    if (needclone)
                    {
                        linkobject = ((ASBinCode.rtData.rtObjectBase)value).Clone();
                    }
                    else
                    {
                        linkobject = (ASBinCode.rtData.rtObjectBase)value;
                    }
                }
                else
                {
                    if (needclone)
                    {
                        linkobject = value.Clone();
                    }
                    else
                    {
                        linkobject = value;
                    }
                }
            }
            else if (at > RunTimeDataType.unknown)
            {
                if (vt > RunTimeDataType.unknown)
                {
                    Class c = bin.getClassByRunTimeDataType(vt);
                    if (c.isLink_System)
                    {
                        LinkSystemObject lo = (LinkSystemObject)((ASBinCode.rtData.rtObjectBase)value).value;
                        linkobject = lo.GetLinkData();
                    }
                    else if (c.isCrossExtend)
                    {
                        LinkSystemObject lo = (LinkSystemObject)((ASBinCode.rtData.rtObjectBase)value).value;
                        linkobject = lo.GetLinkData();
                    }
                    else if (c.staticClass == null)
                    {
                        if (c.instanceClass.isCrossExtend)
                        {
                            //***isCrossExtend Class转换为 基础类型的type
                            var sc = c.instanceClass.super;
                            while (!sc.isLink_System)
                            {
                                sc = sc.super;
                            }

                            var nf = (ICrossExtendAdapterCreator)swc.getNativeFunction(((ClassMethodGetter)sc.crossExtendAdapterCreator.bindField).functionId);

                            linkobject = nf.GetAdapterType();
                        }
                        else
                        {
                            linkobject = null;
                            return(false);
                        }
                    }
                    else
                    {
                        linkobject = null;
                        return(false);
                    }
                }
                else if (at == _objectType_) //托管object
                {
                    if (vt == RunTimeDataType.rt_int)
                    {
                        linkobject = (TypeConverter.ConvertToInt(value));
                    }
                    else if (vt == RunTimeDataType.rt_uint)
                    {
                        linkobject = (TypeConverter.ConvertToUInt(value,null,null));
                    }
                    else if (vt == RunTimeDataType.rt_string)
                    {
                        linkobject = (TypeConverter.ConvertToString(value,null,null));
                    }
                    else if (vt == RunTimeDataType.rt_number)
                    {
                        linkobject = (TypeConverter.ConvertToNumber(value));
                    }
                    else if (vt == RunTimeDataType.rt_boolean)
                    {
                        var b = TypeConverter.ConvertToBoolean(value,null,null);
                        linkobject = b.value;
                    }
                    else if (vt == RunTimeDataType.rt_void)
                    {
                        linkobject = null;
                    }
                    else
                    {
                        linkobject = null;
                        return(false);
                    }
                }
                else
                {
                    linkobject = null;
                    return(false);
                }
            }
            else
            {
                linkobject = null;
                return(false);
            }

            return(true);
        }
Exemplo n.º 6
0
            public override SLOT assign(RunTimeValueBase value,out bool success)
            {
                if (vector_data.vector_type != value.rtType
                    &&
                    !
                    (
                        //***检查子类关系****
                        (vector_data.vector_type > RunTimeDataType.unknown &&
                         value.rtType > RunTimeDataType.unknown &&
                         (
                             ClassMemberFinder.check_isinherits(value,vector_data.vector_type,classfinder)
                             ||
                             ClassMemberFinder.check_isImplements(value,vector_data.vector_type,classfinder)
                         )
                        )
                        ||
                        (
                            vector_data.vector_type > RunTimeDataType.unknown &&
                            value.rtType == RunTimeDataType.rt_null
                        )
                        ||
                        (
                            vector_data.vector_type == RunTimeDataType.rt_array &&
                            value.rtType == RunTimeDataType.rt_null
                        )
                        ||
                        (
                            vector_data.vector_type == RunTimeDataType.rt_function &&
                            value.rtType == RunTimeDataType.rt_null
                        )
                        ||
                        (
                            vector_data.vector_type == RunTimeDataType.rt_string &&
                            value.rtType == RunTimeDataType.rt_null
                        )
                    )
                    )
                {
                    //return false;
                    success = false;
                    return(this);
                }
                else
                {
                    switch (value.rtType)
                    {
                    case RunTimeDataType.rt_int:
                    {
                        ((rtInt)vector_data.innnerList[idx]).value = ((rtInt)value).value;
                        success = true;
                        return(this);
                    }

                    case RunTimeDataType.rt_uint:
                    {
                        ((rtUInt)vector_data.innnerList[idx]).value = ((rtUInt)value).value;
                        success = true;
                        return(this);
                    }

                    case RunTimeDataType.rt_number:
                    {
                        ((rtNumber)vector_data.innnerList[idx]).value = ((rtNumber)value).value;
                        success = true;
                        return(this);
                    }

                    case RunTimeDataType.rt_string:
                    {
                        ((rtString)vector_data.innnerList[idx]).value = ((rtString)value).value;
                        success = true;
                        return(this);
                    }

                    case RunTimeDataType.rt_function:
                    {
                        ((rtFunction)vector_data.innnerList[idx]).CopyFrom((rtFunction)value);
                        success = true;
                        return(this);
                    }

                    default:
                        break;
                    }

                    vector_data.innnerList[idx] = (RunTimeValueBase)value.Clone();                     //对容器的直接赋值,需要Clone																				   //return true;
                    success = true;
                    return(this);
                }
            }