Example #1
0
        public int GetFuncRef(FuncRef funcRef)
        {
            SerializedFuncRef data = new SerializedFuncRef(this, funcRef.InModule, funcRef.FunctionName);
            int id = _funcRefs.Count;

            _funcRefs.Add(data);
            return(id);
        }
Example #2
0
        public ILModule(BinaryReader inStream)
        {
            Name  = inStream.ReadString();
            Types = new TypeRegistry(this);

            // deserialize module refs
            int moduleCount = inStream.ReadInt32();

            for (int i = 0; i < moduleCount; i++)
            {
                ModuleRefs.Add(inStream.ReadString());
            }

            // deserialize type refs
            int typeCount = inStream.ReadInt32();

            for (int i = 0; i < typeCount; i++)
            {
                SerializedTypeRef typeRef = new SerializedTypeRef();
                typeRef.ModuleID  = inStream.ReadInt32();
                typeRef.TypeID    = inStream.ReadInt32();
                typeRef.Ref       = inStream.ReadBoolean();
                typeRef.Pointer   = inStream.ReadInt32();
                typeRef.Array     = inStream.ReadBoolean();
                typeRef.ArraySize = inStream.ReadUInt32();

                _typeRefs.Add(typeRef);
            }

            // deserialize func refs
            int funcRefCount = inStream.ReadInt32();

            for (int i = 0; i < funcRefCount; i++)
            {
                SerializedFuncRef funcRef = new SerializedFuncRef();
                funcRef.ModuleID = inStream.ReadInt32();
                funcRef.FuncName = inStream.ReadString();

                _funcRefs.Add(funcRef);
            }

            // deserialize string pool
            int strCount = inStream.ReadInt32();

            for (int i = 0; i < strCount; i++)
            {
                StringPool.Add(inStream.ReadString());
            }

            // deserialize types
            Types.Deserialize(inStream);

            // deserialize globals
            int globalCount = inStream.ReadInt32();

            for (int i = 0; i < globalCount; i++)
            {
                var globalName = inStream.ReadString();
                var globalType = TypeInfo.Deserialize(inStream);

                Globals.Add(new GlobalVarInfo()
                {
                    Name = globalName,
                    ID   = Globals.Count,
                    Type = globalType
                });
            }

            int funcImageSize = inStream.ReadInt32();

            _funcImage = inStream.ReadBytes(funcImageSize);
        }