Esempio n. 1
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);
        }
Esempio n. 2
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);
            }
        }