private void MakeTree(TypeDefTable t1, TypeDefTable t2) { t1.Children = new ArrayList[] { new ArrayList(), new ArrayList(), new ArrayList() } ; ArrayList listField = this.Tables[(int) MetadataTables.Field]; ArrayList listMethod = this.Tables[(int) MetadataTables.MethodDef]; int f1 = t1.FieldList, f2 =(t2 != null) ? t2.FieldList: listField.Count + 1; for (int i = f1; i < f2; i++) { FieldTable f = listField[i - 1] as FieldTable; t1.Children[(int) Children.DefField].Add(f); f.ParentTable = t1; } int m1 = t1.MethodList, m2 =(t2 != null) ? t2.MethodList: listMethod.Count + 1; for (int i = m1; i < m2; i++) { MethodDefTable m = listMethod[i - 1] as MethodDefTable; t1.Children[(int) Children.DefMethod].Add(m); m.ParentTable = t1; this.MakeTree(m); } }
public bool WriteAsm(StreamWriter sw, TypeDefTable t) { bool ok = true; sw.WriteLine("; class {0}", this.pedata.idxm.GetName(t)); bool first = true; foreach (object obj in t.Children[(int)Children.DefField]) { FieldTable f = obj as FieldTable; if ((f.Flags & (int)FieldAttributes.Static) == 0 || (f.Flags & (int)FieldAttributes.Literal) != 0) { continue; } if (first) { sw.WriteLine(); first = false; } sw.WriteLine("{0} dw 0", MangleField(f)); } foreach (object obj in t.Children[(int)Children.DefMethod]) { MethodDefTable m = obj as MethodDefTable; MethodData md = m.Tag as MethodData; if (md.HasThis) continue; // static only sw.WriteLine(); if (!this.WriteAsm(sw, md)) ok = false; } return ok; }
public string GetName(TypeDefTable t) { string n = this.GetStringsString(t.Name); TableBase tb = t.ParentTable; if (tb is TypeDefTable) { return this.GetName(tb as TypeDefTable) + "." + n; } if (t.Namespace != 0) { n = this.GetStringsString(t.Namespace) + "." + n; } return n; }