예제 #1
0
        public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements,object stackframe,out string errormessage,out int errorno)
        {
            errormessage = null;
            errorno      = 0;

            var newvalue = new ASBinCode.rtData.rtArray();

            newvalue.objHandle.bindArrayObject = (rtObjectBase)thisObj;

            ((rtObjectBase)thisObj).value.memberData[0].directSet(newvalue);


            var args = argements[0].getValue();

            if (args.rtType == RunTimeDataType.rt_array)
            {
                rtArray arr = (rtArray)args;

                if (arr.innerArray.Count == 1)
                {
                    var a1 = arr.innerArray[0];
                    if (TypeConverter.ObjectImplicit_ToNumber(a1.rtType,bin))
                    {
                        a1 = TypeConverter.ObjectImplicit_ToPrimitive((rtObjectBase)a1);
                    }

                    if (a1.rtType == RunTimeDataType.rt_int || a1.rtType == RunTimeDataType.rt_uint || a1.rtType == RunTimeDataType.rt_number)
                    {
                        int c = TypeConverter.ConvertToInt(a1);

                        if (c < 0)
                        {
                            errormessage = "Array index is not a positive integer (" + c + ").";
                            errorno      = 1005;
                            return(ASBinCode.rtData.rtUndefined.undefined);
                        }
                        else
                        {
                            while (newvalue.innerArray.Count < c)
                            {
                                newvalue.innerArray.Add(rtUndefined.undefined);
                            }
                        }
                    }
                    else
                    {
                        newvalue.innerArray.Add(a1);
                    }
                }
                else
                {
                    newvalue.innerArray.AddRange(arr.innerArray);
                }
            }

            //throw new NotImplementedException();

            return(ASBinCode.rtData.rtUndefined.undefined);
        }
예제 #2
0
        public static RunTimeValueBase LoadRunTimeValueBase(BinaryReader reader, CSWCSerizlizer serizlizer, IDictionary <int, object> list, int key)
        {
            RunTimeDataType type = reader.ReadInt32();

            switch (type)
            {
            case RunTimeDataType.rt_boolean:
            {
                bool b = reader.ReadBoolean();
                if (b)
                {
                    return(rtData.rtBoolean.True);
                }
                else
                {
                    return(rtData.rtBoolean.False);
                }
            }

            case RunTimeDataType.rt_array:
            {
                int            c     = reader.ReadInt32();
                rtData.rtArray array = new rtData.rtArray();
                for (int i = 0; i < c; i++)
                {
                    array.innerArray.Add(LoadRunTimeValueBase(reader, serizlizer, list, key));
                }
                return(array);
            }

            case RunTimeDataType.rt_function:
            {
                return(new ASBinCode.rtData.rtFunction(reader.ReadInt32(), reader.ReadBoolean()));
            }

            case RunTimeDataType.rt_int:
            {
                return(new rtData.rtInt(reader.ReadInt32()));
            }

            case RunTimeDataType.rt_null:
            {
                return(rtData.rtNull.nullptr);
            }

            case RunTimeDataType.rt_number:
            {
                return(new rtData.rtNumber(reader.ReadDouble()));
            }

            case RunTimeDataType.rt_string:
            {
                bool isnull = reader.ReadBoolean();
                if (isnull)
                {
                    return(new rtData.rtString(null));
                }
                else
                {
                    return(new rtData.rtString(reader.ReadString()));
                }
            }

            case RunTimeDataType.rt_uint:
            {
                return(new rtData.rtUInt(reader.ReadUInt32()));
            }

            case RunTimeDataType.rt_void:
            {
                return(rtData.rtUndefined.undefined);
            }

            default:

                throw new IOException("错误数据类型");
            }
        }