Ejemplo n.º 1
0
        private void WriteScopesAndLocals(XmlElement node, SymbolToken localSigToken)
        {
            Debug.Assert(m_writer != null, "XML Writer not innitialized");
            Debug.Assert(node != null, "Node must be passed.");
            m_writer.OpenScope(Util.ToInt32(node.GetAttribute("startOffset"), 16));
            foreach (XmlElement child in node.ChildNodes)
            {
                switch (child.Name)
                {
                case "scope":
                    WriteScopesAndLocals(child, localSigToken);
                    break;

                case "local":
                    string name        = child.GetAttribute("name");
                    int    addr1       = Util.ToInt32(child.GetAttribute("il_index"));
                    int    startOffset = Util.ToInt32(child.GetAttribute("il_start"), 16);
                    int    endOffset   = Util.ToInt32(child.GetAttribute("il_end"), 16);
                    int    attributes  = Util.ToInt32(child.GetAttribute("attributes"));
                    m_writer.DefineLocalVariable(name, attributes, localSigToken, (int)SymAddressKind.ILOffset,
                                                 addr1, 0, 0, startOffset, endOffset);
                    break;

                case "constant":
                    m_writer.DefineConstant(child.GetAttribute("name"), child.GetAttribute("value"),
                                            Util.ToByteArray(child.GetAttribute("signature")));
                    break;

                default:
                    throw new FormatException("Unrecognized Xml element");
                }
            }
            m_writer.CloseScope(Util.ToInt32(node.GetAttribute("endOffset"), 16));
        }