public ExternTypeRef GetTypeRef(string asmb_name, string full_name, bool is_valuetype)
        {
            ExternAssembly ext_asmb = null;

            if (assembly_table == null && (asmb_name == "mscorlib" || asmb_name == "corlib"))
            {
                /* AddCorlib if mscorlib is being referenced but
                 * we haven't encountered a ".assembly 'name'" as yet. */
                Report.Warning(String.Format("Reference to undeclared extern assembly '{0}', adding.", asmb_name));
                AddCorlib();
            }
            if (assembly_table != null)
            {
                ext_asmb = assembly_table[asmb_name] as ExternAssembly;
            }

            if (ext_asmb == null)
            {
                System.Reflection.AssemblyName asmname = new System.Reflection.AssemblyName();
                asmname.Name = asmb_name;

                Report.Warning(String.Format("Reference to undeclared extern assembly '{0}', adding.", asmb_name));
                ext_asmb = AddAssembly(asmb_name, asmname, 0);
            }

            return(ext_asmb.GetTypeRef(full_name, is_valuetype));
        }
示例#2
0
        public bool IsSuppressUnmanaged(CodeGen codegen)
        {
            string asmname = "";

            BaseTypeRef owner = method_ref.Owner;

            if (owner == null)
            {
                return(false);
            }

            ExternTypeRef etr = owner as ExternTypeRef;

            if (etr != null)
            {
                ExternAssembly ea = etr.ExternRef as ExternAssembly;
                if (ea != null)
                {
                    asmname = ea.Name;
                }
            }

            return(owner.FullName == "System.Security.SuppressUnmanagedCodeSecurityAttribute" &&
                   (asmname == "mscorlib" || codegen.IsThisAssembly("mscorlib")));
        }
示例#3
0
        public ExternAssembly GetAssemblyRef(string assembly_name)
        {
            ExternAssembly ass = null;

            if (assembly_table != null)
            {
                ass = assembly_table [assembly_name] as ExternAssembly;
            }

            if (ass == null)
            {
                Report.Error("Assembly " + assembly_name + " is not defined.");
            }

            return(ass);
        }
示例#4
0
        public System.Type GetReflectedType()
        {
            ExternRef er = extern_ref as ExternRef;

            if (er != null)
            {
                ExternAssembly ea = er as ExternAssembly;
                if (ea != null)
                {
                    System.Reflection.Assembly asm = System.Reflection.Assembly.Load(ea.Name);

                    //Type name required here, so don't use FullName
                    return(asm.GetType(Name));
                }         /* else ExternModule */
            }             /*else - nested type? */
            return(null);
        }
示例#5
0
        public PEAPI.Permission Resolve(CodeGen code_gen)
        {
            string fname;

            type_ref.Resolve(code_gen);

            if (type_ref is ExternTypeRef)
            {
                ExternAssembly ea = ((ExternTypeRef)type_ref).ExternRef as ExternAssembly;
                if (ea == null)
                {
                    //FIXME: module.. ?
                    throw new NotImplementedException();
                }

                string        name;
                ExternTypeRef etr = type_ref as ExternTypeRef;
                if (etr != null)
                {
                    name = etr.Name;
                }
                else
                {
                    name = type_ref.FullName;
                }

                fname = String.Format("{0}, {1}", name, ea.AssemblyName.FullName);
            }
            else
            {
                fname = type_ref.FullName;
            }

            perm = new PEAPI.Permission(type_ref.PeapiType, fname);

            foreach (PermissionMember member in members)
            {
                perm.AddMember(member.Resolve(code_gen));
            }

            return(perm);
        }
        public ExternAssembly AddAssembly(string name, AssemblyName asmb_name, PEAPI.AssemAttr attr)
        {
            ExternAssembly ea = null;

            if (assembly_table == null)
            {
                assembly_table = new Hashtable();
            }
            else
            {
                ea = assembly_table [name] as ExternAssembly;
                if (ea != null)
                {
                    return(ea);
                }
            }

            ea = new ExternAssembly(name, asmb_name, attr);

            assembly_table [name] = ea;

            return(ea);
        }
示例#7
0
                public ExternAssembly AddAssembly (string name, AssemblyName asmb_name, PEAPI.AssemAttr attr)
                {
                        ExternAssembly ea = null;

                        if (assembly_table == null) {
                                assembly_table = new Hashtable ();
                        } else {
                                ea = assembly_table [name] as ExternAssembly;
                                if (ea != null)
                                        return ea;
                        }

                        ea = new ExternAssembly (name, asmb_name, attr);

                        assembly_table [name] = ea;

                        return ea;
                }
示例#8
0
 public void EndAssemblyRef ()
 {
         current_assemblyref = null;
         current_customattrtarget = null;
         current_declsectarget = null;
 }
示例#9
0
 public void BeginAssemblyRef (string name, AssemblyName asmb_name, PEAPI.AssemAttr attr)
 {
         current_customattrtarget = current_assemblyref = ExternTable.AddAssembly (name, asmb_name, attr);
         current_declsectarget = current_assemblyref;
 }
示例#10
0
文件: CodeGen.cs 项目: zixing131/mono
 public void EndAssemblyRef()
 {
     current_assemblyref      = null;
     current_customattrtarget = null;
     current_declsectarget    = null;
 }
示例#11
0
文件: CodeGen.cs 项目: zixing131/mono
 public void BeginAssemblyRef(string name, AssemblyName asmb_name, PEAPI.AssemAttr attr)
 {
     current_customattrtarget = current_assemblyref = ExternTable.AddAssembly(name, asmb_name, attr);
     current_declsectarget    = current_assemblyref;
 }