using System; using SemanticTree; using System.Collections; using System.Reflection; namespace TreeConverter { public class NetScope : SymbolTable.DotNETScope { //private base_scope _up_scope; private using_namespaceArrayList _unar; private System.Reflection.Assembly _assembly; //For SymbolTable DEBUGGING private NetIntScope _nis; public NetScope(using_namespaceArrayList unar,System.Reflection.Assembly assembly) { _unar=unar; _assembly=assembly; NetHelper.init_namespaces(assembly); //For SymbolTable DEBUGGING _nis=new NetIntScope(this); _sc=_nis; } public using_namespaceArrayList used_namespaces { get { return _unar; } } /*public override base_scope top_scope { get { return _up_scope; } }*/ public override SymbolInfo Find(string name) { SymbolInfo si=null; if (NetHelper.IsNetNamespace(name.ToLower()) == true) { compiled_namespace_node cnn = new compiled_namespace_node(name); si = new SymbolInfo(cnn); } else { //Type t = Type.GetType("System."+name,false,true); Type t=null; int i=0; t = NetHelper.FindType(name); if (t != null) { compiled_type_node ctn = compiled_type_node.get_type_node(t); ctn.Scope = new NetTypeScope(ctn.compiled_type); si = new SymbolInfo(ctn); } else { while ((t==null)&&(i<_unar.Count)) { t=_assembly.GetType(_unar[i].namespace_name+"."+name,false,true); i++; } if (t != null) { compiled_type_node ctn = compiled_type_node.get_type_node(t); ctn.Scope = new NetTypeScope(ctn.compiled_type); si = new SymbolInfo(ctn); NetHelper.AddType(name,t); } } } return si; } } public class NetTypeScope : SymbolTable.DotNETScope { //private base_scope _up_scope; private Type type_info; //For SymbolTable DEBUGGING private NetIntTypeScope _nits; public NetTypeScope(Type type_info) { this.type_info = type_info; //For SymbolTable DEBUGGING _nits=new NetIntTypeScope(this); _sc=_nits; } /*public override base_scope top_scope { get { return _up_scope; } }*/ public Type TypeInfo { get { return type_info; } set { type_info = value; } } public override SymbolInfo Find(string name) { /*MethodInfo[] mis = NetHelper.FindMethods(type_info,"get_"+name); if (mis.Length == 0) mis = NetHelper.FindMethods(type_info,name); SymbolInfo si=null; if (mis.Length != 0) { si = new SymbolInfo(NetHelper.GetMethodNode(mis[0])); SymbolInfo temp=si; for (int i=1; i0) break; } } if (mis.Length != 0) { //Console.WriteLine(mis[0].GetAccessors()[0].Name); si = new SymbolInfo(GetFieldNode(mis[0])); SymbolInfo temp=si; for (int i=1; i0) break; } } if (mis.Length != 0) { //Console.WriteLine(mis[0].GetAccessors()[0].Name); si = new SymbolInfo(GetPropertyNode(mis[0])); SymbolInfo temp=si; for (int i=1; i0) break; } } if (mis.Length != 0) { si = new SymbolInfo(GetMethodNode(mis[0])); SymbolInfo temp=si; for (int i=1; i 0) break; } } if (mis.Length != 0) { //Console.WriteLine(mis[0].GetAccessors()[0].Name); if (mis[0] is MethodInfo) { si = new SymbolInfo(GetMethodNode((MethodInfo)mis[0])); SymbolInfo temp=si; for (int i=1; i