public static InterfaceMethodGetter LoadInterfaceMethodGetter(BinaryReader reader, CSWCSerizlizer serizlizer, IDictionary <int, object> serizlized, int key)
        {
            //protected int indexofMember;
            int indexofMember = reader.ReadInt32();
            //private readonly string _name;
            string _name = reader.ReadString();
            //public readonly int refdefinedinblockid;
            int refdefinedinblockid = reader.ReadInt32();
            //protected int functionid;
            int functionid = reader.ReadInt32();

            ///// <summary>
            ///// 比如说,私有方法就肯定不是虚方法
            ///// </summary>
            //protected bool isNotReadVirtual = false;
            bool isNotReadVirtual = reader.ReadBoolean();

            RunTimeDataType datetype = reader.ReadInt32();

            InterfaceMethodGetter ig = new InterfaceMethodGetter(_name, null, refdefinedinblockid);

            serizlized.Add(key, ig);
            //protected readonly ASBinCode.rtti.Class _class;
            ASBinCode.rtti.Class _class = serizlizer.DeserializeObject <rtti.Class>(reader, rtti.Class.LoadClass);
            ig._class           = _class;
            ig.functionid       = functionid;
            ig.indexofMember    = indexofMember;
            ig.isNotReadVirtual = isNotReadVirtual;

            ig.valueType = datetype;
            ig.link      = (InterfaceMethodGetter)serizlizer.DeserializeObject <ISWCSerializable>(reader, ISWCSerializableLoader.LoadIMember);

            return(ig);
        }
Beispiel #2
0
        public static OperatorFunctions LoadOperatorFunctions(BinaryReader reader, CSWCSerizlizer serizlizer, IDictionary <int, object> serizlized, int key)
        {
            OperatorFunctions operatorFunctions = new OperatorFunctions(); serizlized.Add(key, operatorFunctions);

            for (int i = 0; i < operatorFunctions.operFunctions.Length; i++)
            {
                var dict  = operatorFunctions.operFunctions[i];
                int count = reader.ReadInt32();
                for (int j = 0; j < count; j++)
                {
                    RunTimeDataType v1 = reader.ReadInt32();
                    RunTimeDataType v2 = reader.ReadInt32();

                    OperatorFunctionKey operatorFunctionKey = new OperatorFunctionKey(v1, v2);

                    rtti.FunctionDefine define   = serizlizer.DeserializeObject <rtti.FunctionDefine>(reader, rtti.FunctionDefine.LoadFunctionDefine);
                    rtData.rtFunction   function = serizlizer.DeserializeObject <rtData.rtFunction>(reader, RunTimeValueBase.LoadRunTimeValueBase);

                    DefineAndFunc defineAndFunc = new DefineAndFunc();
                    defineAndFunc.define = define;
                    defineAndFunc.func   = function;

                    dict.Add(operatorFunctionKey, defineAndFunc);
                }
            }

            return(operatorFunctions);
        }
Beispiel #3
0
        public static SuperPointer LoadSuperPointer(BinaryReader reader, CSWCSerizlizer serizlizer, IDictionary <int, object> serizlized, int key)
        {
            RunTimeDataType valuetype = reader.ReadInt32();

            rtti.Class superClass = serizlizer.DeserializeObject <rtti.Class>(reader, rtti.Class.LoadClass);
            rtti.Class thisClass  = serizlizer.DeserializeObject <rtti.Class>(reader, rtti.Class.LoadClass);

            SuperPointer sp = new SuperPointer(superClass, thisClass); serizlized.Add(key, sp);

            sp.valueType = valuetype;

            return(sp);
        }
        public static ClassPropertyGetter LoadClassPropertyGetter(BinaryReader reader,CSWCSerizlizer serizlizer,IDictionary <int,object> serizlized,int key)
        {
            int    indexofMember = reader.ReadInt32();
            string _name         = reader.ReadString();

            ClassPropertyGetter cpg = new ClassPropertyGetter(_name,null,indexofMember);

            serizlized.Add(key,cpg);

            rtti.Class _class = serizlizer.DeserializeObject <rtti.Class>(reader,rtti.Class.LoadClass);
            cpg._class = _class;


            cpg.getter = serizlizer.DeserializeObject <MethodGetterBase>(reader,ISWCSerializableLoader.LoadIMember);
            cpg.setter = serizlizer.DeserializeObject <MethodGetterBase>(reader,ISWCSerializableLoader.LoadIMember);

            return(cpg);
        }
        public static ThisPointer LoadThisPointer(BinaryReader reader, CSWCSerizlizer serizlizer, IDictionary <int, object> serizlized, int key)
        {
            RunTimeDataType type  = reader.ReadInt32();
            SourceToken     token = serizlizer.DeserializeObject <SourceToken>(reader, SourceToken.LoadToken);

            ThisPointer pointer = new ThisPointer(null, token); serizlized.Add(key, pointer);

            pointer.valueType = type;

            return(pointer);
        }
Beispiel #6
0
        public static StaticClassDataGetter LoadStaticClassDataGetter(BinaryReader reader, CSWCSerizlizer serizlizer, IDictionary <int, object> serizlized, int key)
        {
            RunTimeDataType type = reader.ReadInt32();

            rtti.Class _class = serizlizer.DeserializeObject <rtti.Class>(reader, rtti.Class.LoadClass);

            StaticClassDataGetter sd = new StaticClassDataGetter(_class); serizlized.Add(key, sd);

            sd.valueType = type;

            return(sd);
        }
Beispiel #7
0
        public static CodeBlock Deserialize(BinaryReader reader, CSWCSerizlizer serizlizer, IDictionary <int, object> serizlized, int key)
        {
            var id              = reader.ReadInt32();
            var name            = reader.ReadString();   //writer.Write(name);
            var define_class_id = reader.ReadInt32();    //writer.Write(define_class_id);
            var isoutclass      = reader.ReadBoolean();  //writer.Write(isoutclass);
            var hasTryStmt      = reader.ReadBoolean();  // writer.Write(hasTryStmt);

            CodeBlock block = new CodeBlock(id, name, define_class_id, isoutclass);

            block.hasTryStmt = hasTryStmt;
            serizlized.Add(key, block);

            block.totalStackSlots = reader.ReadUInt16();
            block.scope           = serizlizer.DeserializeObject <scopes.ScopeBase>(reader, scopes.ScopeBase.Deserialize);

            int stepscount = reader.ReadUInt16();

            block.instructions = new OpStep[stepscount]; block.opSteps = null;
            for (int i = 0; i < stepscount; i++)
            {
                OpStep step = serizlizer.DeserializeObject <OpStep>(reader, OpStep.Deserialize);
                //block.opSteps.Add(step);
                block.instructions[i] = step;
            }

            int regconvcount = reader.ReadUInt16();

            block.regConvFromVar = new StackSlotAccessor[regconvcount];
            for (int i = 0; i < regconvcount; i++)
            {
                StackSlotAccessor register = (StackSlotAccessor)serizlizer.DeserializeObject <ISWCSerializable>(reader, ISWCSerializableLoader.LoadIMember);
                block.regConvFromVar[i] = register;
            }

            return(block);
        }
Beispiel #8
0
        public static Field LoadField(BinaryReader reader,CSWCSerizlizer serizlizer,IDictionary <int,object> serizlized,int key)
        {
            //	private string _name;
            string _name = reader.ReadString();
            //protected int _indexOfMembers;
            int _indexOfMembers = reader.ReadInt32();
            //protected readonly int refblockid;
            int refblockid = reader.ReadInt32();

            ///// <summary>
            ///// 赋值是否忽略编译期类型检查
            ///// </summary>
            //public readonly bool ignoreImplicitCast;
            bool ignoreImplicitCast = reader.ReadBoolean();
            ///// <summary>
            ///// 是否不可赋值
            ///// </summary>
            //public readonly bool isConst;
            bool isConst = reader.ReadBoolean();

            RunTimeDataType valuetype = reader.ReadInt32();

            Field field = new Field(_name,_indexOfMembers,refblockid,isConst);

            field.valueType = valuetype;

            serizlized.Add(key,field);



            field.isPublic    = reader.ReadBoolean();
            field.isInternal  = reader.ReadBoolean();
            field.isPrivate   = reader.ReadBoolean();
            field.isProtected = reader.ReadBoolean();
            field.isStatic    = reader.ReadBoolean();

            int metas = reader.ReadInt32();

            for (int i = 0; i < metas; i++)
            {
                field.metas.Add(serizlizer.DeserializeObject <FieldMeta>(reader,FieldMeta.LoadFieldMeta));
            }

            return(field);
        }
Beispiel #9
0
        public static OpStep Deserialize(BinaryReader reader, CSWCSerizlizer serizlizer, IDictionary <int, object> serizlized, int key)
        {
            //public OpCode opCode;
            OpCode opCode = (OpCode)reader.ReadByte();
            //	public SourceToken token;
            SourceToken token = serizlizer.DeserializeObject <SourceToken>(reader, SourceToken.LoadToken);

            OpStep step = new OpStep(opCode, token); serizlized.Add(key, step);

            ///// <summary>
            ///// 行标
            ///// </summary>
            //public string flag;
            if (reader.ReadBoolean())
            {
                step.flag = reader.ReadString();
            }

            ///// <summary>
            ///// 跳转偏移量
            ///// </summary>
            //public int jumoffset;
            step.jumoffset = reader.ReadInt32();
            ///// <summary>
            ///// 所属标签
            ///// </summary>
            //public Stack<string> labels;

            if (reader.ReadBoolean())
            {
                step.labels = new Stack <string>();
                int count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    step.labels.Push(reader.ReadString());
                }
            }

            //string[] lbls = labels.ToArray();
            //writer.Write(lbls.Length);
            //for (int i = 0; i < lbls.Length; i++)
            //{
            //	writer.Write(lbls[i]);
            //}



            ///// <summary>
            ///// 当前行在哪个try块里
            ///// -1表示不在任何try块里
            ///// </summary>
            //public int tryid;
            step.tryid = reader.ReadInt32();
            ///// <summary>
            ///// 当前块所属try类型
            ///// 0 try 1 catch 2 finally
            ///// </summary>
            //public int trytype;
            step.trytype = reader.ReadInt32();

            //public LeftValueBase reg;
            step.reg = (LeftValueBase)serizlizer.DeserializeObject <ISWCSerializable>(reader, ISWCSerializableLoader.LoadIMember);
            //public RightValueBase arg1;
            step.arg1 = (RightValueBase)serizlizer.DeserializeObject <ISWCSerializable>(reader, ISWCSerializableLoader.LoadIMember);
            //public RightValueBase arg2;
            step.arg2 = (RightValueBase)serizlizer.DeserializeObject <ISWCSerializable>(reader, ISWCSerializableLoader.LoadIMember);

            ///// <summary>
            ///// 输出结果类型
            ///// </summary>
            //public RunTimeDataType regType;
            step.regType = reader.ReadInt32();
            ///// <summary>
            ///// 输入参数1类型
            ///// </summary>
            //public RunTimeDataType arg1Type;
            step.arg1Type = reader.ReadInt32();
            ///// <summary>
            ///// 输入参数2类型
            ///// </summary>
            //public RunTimeDataType arg2Type;
            step.arg2Type = reader.ReadInt32();


            step.memregid1 = reader.ReadInt16();
            step.memregid2 = reader.ReadInt16();
            step.memregid3 = reader.ReadInt16();

            step.constnumber1 = reader.ReadDouble();
            step.constnumber2 = reader.ReadDouble();

            return(step);
        }