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); } }
private void EmitFunctionDebugInfo(ModuleWriter writer, Function function) { // Emit the function id. uint functionId = function.GetSerialId(); writer.Write(functionId); // Emit the function position. EmitPosition(writer, function.Position); // Emit the lexical scopes. byte numscopes = (byte)function.GetLexicalScopeCount(); writer.Write(numscopes); for(int i = 0; i < numscopes; ++i) { // Get the lexical scope. LexicalScope scope = function.GetLexicalScope(i); // Find the parent index. byte parentIndex = 0; LexicalScope parentScope = scope.GetParentScope() as LexicalScope; if(parentScope != null) parentIndex = (byte)parentScope.Index; // Emit the parent scope. writer.Write(parentIndex); // Write the scope position. EmitPosition(writer, scope.Position); } // Emit the local data and positions. ushort localCount = (ushort)function.GetLocalCount(); writer.Write(localCount); foreach(LocalVariable local in function.GetLocals()) { // Get the local scope. byte localScope = 0; LexicalScope scope = local.GetParentScope() as LexicalScope; if(scope != null) localScope = (byte)scope.Index; // Write the variable data. writer.Write(AddString(local.GetName())); writer.Write(localScope); writer.Write((byte)local.Type); writer.Write((byte)local.ArgumentIndex); EmitPosition(writer, local.Position); } // Emit each basic block position information. ushort blockCount = (ushort)function.GetBasicBlockCount(); writer.Write(blockCount); foreach(BasicBlock bb in function.GetBasicBlocks()) EmitBasicBlockDebugInfo(writer, bb); }
private void EmitFunctionDebugInfo(ModuleWriter writer, Function function) { // Emit the function id. uint functionId = function.GetSerialId(); writer.Write(functionId); // Emit the function position. EmitPosition(writer, function.Position); // Emit the lexical scopes. byte numscopes = (byte)function.GetLexicalScopeCount(); writer.Write(numscopes); for (int i = 0; i < numscopes; ++i) { // Get the lexical scope. LexicalScope scope = function.GetLexicalScope(i); // Find the parent index. byte parentIndex = 0; LexicalScope parentScope = scope.GetParentScope() as LexicalScope; if (parentScope != null) { parentIndex = (byte)parentScope.Index; } // Emit the parent scope. writer.Write(parentIndex); // Write the scope position. EmitPosition(writer, scope.Position); } // Emit the local data and positions. ushort localCount = (ushort)function.GetLocalCount(); writer.Write(localCount); foreach (LocalVariable local in function.GetLocals()) { // Get the local scope. byte localScope = 0; LexicalScope scope = local.GetParentScope() as LexicalScope; if (scope != null) { localScope = (byte)scope.Index; } // Write the variable data. writer.Write(AddString(local.GetName())); writer.Write(localScope); writer.Write((byte)local.Type); writer.Write((byte)local.ArgumentIndex); EmitPosition(writer, local.Position); } // Emit each basic block position information. ushort blockCount = (ushort)function.GetBasicBlockCount(); writer.Write(blockCount); foreach (BasicBlock bb in function.GetBasicBlocks()) { EmitBasicBlockDebugInfo(writer, bb); } }