internal void PrepareSerialization() { foreach (Handler handler in handlers) { module.RegisterType(handler.exception); } }
internal void PrepareSerialization(ChelaModule module) { for (int i = 0; i < parameters.Length; ++i) { module.RegisterType(parameters[i]); } }
internal override void PrepareSerialization() { ChelaModule module = GetModule(); // Prepare myself. base.PrepareSerialization(); // Register the function type. module.RegisterType(type); // Prepare the blocks. foreach (BasicBlock bb in basicBlocks) { bb.PrepareSerialization(module); } // Prepare the locals. foreach (LocalVariable local in locals) { local.PrepareSerialization(); } // Prepare exceptions. if (exceptionContext != null) { exceptionContext.PrepareSerialization(); } }
public override void Write(ModuleWriter writer) { // Write the header. MemberHeader header = new MemberHeader(); header.memberType = (byte)MemberHeaderType.Property; header.memberName = GetModule().RegisterString(GetName()); header.memberFlags = (uint)GetFlags(); header.memberSize = (uint)(13 + 4 * GetIndexCount()); header.Write(writer); // Write the type. ChelaModule module = GetModule(); writer.Write((uint)module.RegisterType(GetVariableType())); // Write the indices. byte numIndices = (byte)GetIndexCount(); writer.Write(numIndices); for (int i = 0; i < numIndices; ++i) { writer.Write(module.RegisterType((IChelaType)indices[i])); } // Write the get accessor. if (getAccessor != null) { writer.Write((uint)getAccessor.GetSerialId()); } else { writer.Write((uint)0); } // Write the set accessor. if (setAccessor != null) { writer.Write((uint)setAccessor.GetSerialId()); } else { writer.Write((uint)0); } }
public void PrepareSerialization(ChelaModule module) { // Register the placeholders for (int i = 0; i < placeHolders.Length; ++i) { PlaceHolderType placeHolder = placeHolders[i]; module.RegisterType(placeHolder); } }
public void PrepareSerialization(ChelaModule module) { // Register the attribute class. module.RegisterType(attributeClass); // Register the attribute ctor. if (attributeCtor != null) { module.RegisterMember(attributeCtor); } // Register the properties. foreach (PropertyValue prop in propertyValues) { module.RegisterMember(prop.Property); module.RegisterType(prop.Property.GetVariableType()); } }
internal override void PrepareSerialization() { // Prepare myself. base.PrepareSerialization(); // Register the property type. ChelaModule module = GetModule(); module.RegisterType(GetVariableType()); // Register the indices type. int numindices = GetIndexCount(); for (int i = 0; i < numindices; ++i) { module.RegisterType((IChelaType)indices[i]); } }
public void Write(ModuleWriter writer, ChelaModule module) { // Write the type count. writer.Write((byte)parameters.Length); // Write the types. for (int i = 0; i < parameters.Length; ++i) { writer.Write((uint)module.RegisterType(parameters[i])); } }
public void Write(ModuleWriter writer, ChelaModule module) { // Write the placeholder count. writer.Write((byte)placeHolders.Length); // Write the placeholders. for (int i = 0; i < placeHolders.Length; ++i) { PlaceHolderType placeHolder = placeHolders[i]; writer.Write((uint)module.RegisterType(placeHolder)); } }
public void Write(ChelaModule module, ModuleWriter writer) { // Write the opcode. writer.Write((byte)opcode); // Write the instruction arguments. InstructionDescription desc = InstructionDescription.GetInstructionTable()[(int)opcode]; InstructionArgumentType[] args = desc.GetArguments(); byte n; for (int i = 0, k = 0; i < arguments.Length; i++, k++) { object arg = arguments[i]; switch (args[k]) { case InstructionArgumentType.UInt8: writer.Write((byte)arg); break; case InstructionArgumentType.UInt8V: { n = (byte)arg; writer.Write(n); i++; for (int j = 0; j < n; j++) { writer.Write((byte)arguments[i++]); } } break; case InstructionArgumentType.Int8: writer.Write((sbyte)arg); break; case InstructionArgumentType.Int8V: { n = (byte)arg; writer.Write(n); i++; for (int j = 0; j < n; j++) { writer.Write((sbyte)arguments[i++]); } } break; case InstructionArgumentType.UInt16: writer.Write((ushort)arg); break; case InstructionArgumentType.UInt16V: { n = (byte)arg; writer.Write(n); i++; for (int j = 0; j < n; j++) { writer.Write((ushort)arguments[i++]); } } break; case InstructionArgumentType.Int16: writer.Write((short)arg); break; case InstructionArgumentType.Int16V: { n = (byte)arg; writer.Write(n); i++; for (int j = 0; j < n; j++) { writer.Write((short)arguments[i++]); } } break; case InstructionArgumentType.UInt32: writer.Write((uint)arg); break; case InstructionArgumentType.UInt32V: { n = (byte)arg; writer.Write(n); i++; for (int j = 0; j < n; j++) { writer.Write((uint)arguments[i++]); } } break; case InstructionArgumentType.Int32: writer.Write((int)arg); break; case InstructionArgumentType.Int32V: { n = (byte)arg; writer.Write(n); i++; for (int j = 0; j < n; j++) { writer.Write((int)arguments[i++]); } } break; case InstructionArgumentType.UInt64: writer.Write((ulong)arg); break; case InstructionArgumentType.UInt64V: { n = (byte)arg; writer.Write(n); i++; for (int j = 0; j < n; j++) { writer.Write((ulong)arguments[i++]); } } break; case InstructionArgumentType.Int64: writer.Write((long)arg); break; case InstructionArgumentType.Int64V: { n = (byte)arg; writer.Write(n); i++; for (int j = 0; j < n; j++) { writer.Write((long)arguments[i++]); } } break; case InstructionArgumentType.Fp32: writer.Write((float)arg); break; case InstructionArgumentType.Fp32V: { n = (byte)arg; writer.Write(n); i++; for (int j = 0; j < n; j++) { writer.Write((float)arguments[i++]); } } break; case InstructionArgumentType.Fp64: writer.Write((double)arg); break; case InstructionArgumentType.Fp64V: { n = (byte)arg; writer.Write(n); i++; for (int j = 0; j < n; j++) { writer.Write((double)arguments[i++]); } } break; case InstructionArgumentType.TypeID: { uint tyid = module.RegisterType((IChelaType)arg); writer.Write(tyid); } break; case InstructionArgumentType.GlobalID: case InstructionArgumentType.FieldID: case InstructionArgumentType.FunctionID: { ScopeMember member = (ScopeMember)arg; uint id = member != null?module.RegisterMember(member) : 0u; writer.Write(id); } break; case InstructionArgumentType.StringID: { uint sid = module.RegisterString((string)arg); writer.Write(sid); } break; case InstructionArgumentType.BasicBlockID: { BasicBlock bb = (BasicBlock)arg; writer.Write((ushort)bb.GetIndex()); } break; case InstructionArgumentType.JumpTable: { ushort tableLen = (ushort)arg; writer.Write(tableLen); ++i; for (int j = 0; j < tableLen; j++) { int constant = (int)arguments[i++]; writer.Write((int)constant); BasicBlock bb = (BasicBlock)arguments[i++]; writer.Write((ushort)bb.GetIndex()); } } break; } } }
internal void PrepareSerialization(ChelaModule module) { // Register types and external members used. InstructionDescription desc = InstructionDescription.GetInstructionTable()[(int)opcode]; InstructionArgumentType[] args = desc.GetArguments(); for (int i = 0, k = 0; i < arguments.Length; i++, k++) { object arg = arguments[i]; switch (args[k]) { case InstructionArgumentType.UInt8V: case InstructionArgumentType.Int8V: case InstructionArgumentType.UInt16V: case InstructionArgumentType.Int16V: case InstructionArgumentType.UInt32V: case InstructionArgumentType.Int32V: case InstructionArgumentType.UInt64V: case InstructionArgumentType.Int64V: case InstructionArgumentType.Fp32V: case InstructionArgumentType.Fp64V: { // Ignore the vector arguments. byte n = (byte)arg; i += n; } break; case InstructionArgumentType.TypeID: { // Prepare serialization of generic instances. IChelaType argType = (IChelaType)arg; if (argType.IsGenericInstance() && (argType.IsStructure() || argType.IsClass() || argType.IsInterface())) { ScopeMember member = (ScopeMember)argType; member.PrepareSerialization(); } // Register types. module.RegisterType(argType); } break; case InstructionArgumentType.GlobalID: case InstructionArgumentType.FieldID: case InstructionArgumentType.FunctionID: { // Register external members. ScopeMember member = (ScopeMember)arg; if (member != null) { if (member.IsGenericInstance()) { member.PrepareSerialization(); } module.RegisterMember(member); } } break; case InstructionArgumentType.JumpTable: { // Ignore the jump table ushort tableLen = (ushort)arg; i += tableLen * 2; } break; default: // Do nothing. break; } } }