using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using Indy.IL2CPU.Assembler; using Indy.IL2CPU.IL; namespace Indy.IL2CPU.Compiler { partial class CompilerHelper { public class AssemblyCompilationInfo: IComparable { private Assembly mAssembly; public AssemblyCompilationInfo() { Methods = new Dictionary(); StaticFields = new Dictionary(); } public Assembly Assembly { get { return mAssembly; } set { if(value == null) { throw new ArgumentException("Assembly cannot be null!"); } mAssembly = value; mAssemblyName = value.FullName; } } private string mAssemblyName; public List Externals = new List(); public List IDLabels = new List(); /// /// Adds the specified method to the Methods dictionary, skipping that action if it already is in. /// /// public void AddMethod(MethodBase aMethod) { var xName = aMethod.GetFullName(); if(!Methods.ContainsKey(xName)) { Methods.Add(xName, aMethod); } } public void ReferenceMethod(MethodBase aMethod) { var xName = aMethod.GetFullName(); if(!Externals.Contains(xName)) { Externals.Add(xName); } } public void ReferenceStaticField(FieldInfo aField) { var xName = DataMember.GetStaticFieldName(aField); if (!Externals.Contains(xName)) { Externals.Add(xName); } } public void ReferenceID(string aID) { if (!Externals.Contains(aID)) { Externals.Add(aID); } } public Dictionary Methods { get; private set; } /// /// Adds the specified method to the Methods dictionary, skipping that action if it already is in. /// /// public void AddStaticField(FieldInfo aField) { if(!aField.IsStatic) { throw new Exception("Can only add static fields!"); } var xName = aField.GetFullName(); if (!StaticFields.ContainsKey(xName)) { StaticFields.Add(xName, aField); } } public Dictionary StaticFields { get; private set; } #region Implementation of IComparable public int CompareTo(AssemblyCompilationInfo other) { return String.Compare(mAssemblyName, other.mAssemblyName); } #endregion } } }