Example #1
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")));
        }
Example #2
0
        public ExternTypeRef GetTypeRef(string _name, bool is_valuetype)
        {
            string first = _name;
            string rest  = "";
            int    slash = _name.IndexOf('/');

            if (slash > 0)
            {
                first = _name.Substring(0, slash);
                rest  = _name.Substring(slash + 1);
            }

            ExternTypeRef ext_typeref = nestedtypes_table [first] as ExternTypeRef;

            if (ext_typeref != null)
            {
                if (is_valuetype && rest == "")
                {
                    ext_typeref.MakeValueClass();
                }
            }
            else
            {
                ext_typeref = new ExternTypeRef(this, first, is_valuetype);
                nestedtypes_table [first] = ext_typeref;
            }

            return(rest == "" ? ext_typeref : ext_typeref.GetTypeRef(rest, is_valuetype));
        }
        public ExternTypeRef GetTypeRef(string full_name, bool is_valuetype)
        {
            string first = full_name;
            string rest  = "";
            int    slash = full_name.IndexOf('/');

            if (slash > 0)
            {
                first = full_name.Substring(0, slash);
                rest  = full_name.Substring(slash + 1);
            }

            ExternTypeRef type_ref = typeref_table [first] as ExternTypeRef;

            if (type_ref != null)
            {
                if (is_valuetype && rest == "")
                {
                    type_ref.MakeValueClass();
                }
            }
            else
            {
                type_ref = new ExternTypeRef(this, first, is_valuetype);
                typeref_table [first] = type_ref;
            }

            return(rest == "" ? type_ref : type_ref.GetTypeRef(rest, is_valuetype));
        }
Example #4
0
		public ExternTypeRefInst (ExternTypeRef type_ref, GenericArguments gen_args, bool is_valuetypeinst)
		{
			this.type_ref = type_ref;
			this.gen_args = gen_args;
			this.is_valuetypeinst = is_valuetypeinst;

			is_resolved = false;
		}
Example #5
0
                public ExternFieldRef (ExternTypeRef owner, BaseTypeRef type, string name)
                {
                        this.owner = owner;
                        this.type = type;
                        this.name = name;
			
			is_resolved = false;
                }
Example #6
0
        public ExternTypeRefInst(ExternTypeRef type_ref, GenericArguments gen_args, bool is_valuetypeinst)
        {
            this.type_ref         = type_ref;
            this.gen_args         = gen_args;
            this.is_valuetypeinst = is_valuetypeinst;

            is_resolved = false;
        }
        public ExternFieldRef(ExternTypeRef owner, BaseTypeRef type, string name)
        {
            this.owner = owner;
            this.type  = type;
            this.name  = name;

            is_resolved = false;
        }
Example #8
0
        private PEAPI.Method ResolveAsMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv,
                                                string name, BaseTypeRef [] param, int gen_param_count, CodeGen code_gen)
        {
            ExternTypeRef   type_ref  = code_gen.ThisModule.GetTypeRef(FullName, false);
            ExternMethodRef methodref = (ExternMethodRef)type_ref.GetMethodRef(ret_type, call_conv, name, param, gen_param_count);

            methodref.Resolve(code_gen);

            return(methodref.PeapiMethod);
        }
Example #9
0
        public PEAPI.Field ResolveField(string name, BaseTypeRef ret_type, CodeGen code_gen)
        {
            FieldDef fielddef = (FieldDef)field_table[new DictionaryEntry(name, ret_type.FullName)];

            if (fielddef != null)
            {
                return(fielddef.Resolve(code_gen, classdef));
            }

            ExternTypeRef type_ref = code_gen.ThisModule.GetTypeRef(FullName, false);
            IFieldRef     fieldref = type_ref.GetFieldRef(ret_type, name);

            fieldref.Resolve(code_gen);

            return(fieldref.PeapiField);
        }
Example #10
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);
        }
Example #11
0
        public override void Resolve(CodeGen code_gen)
        {
            if (is_resolved)
            {
                return;
            }

            ExternTypeRef etr = extern_ref as ExternTypeRef;

            if (etr != null)
            {
                //This is a nested class, so resolve parent
                etr.Resolve(code_gen);
            }

            type = extern_ref.GetType(full_name, is_valuetype);
            type = Modify(code_gen, type);

            is_resolved = true;
        }
Example #12
0
                public ExternTypeRef GetTypeRef (string full_name, bool is_valuetype)
                {
                        string first= full_name;
                        string rest = "";
                        int slash = full_name.IndexOf ('/');
                        if (slash > 0) {
                                first = full_name.Substring (0, slash);
                                rest = full_name.Substring (slash + 1);
                        }
				
                        ExternTypeRef type_ref = typeref_table [first] as ExternTypeRef;
                        
                        if (type_ref != null) {
                                if (is_valuetype && rest == "")
                                        type_ref.MakeValueClass ();
                        } else {
                                type_ref = new ExternTypeRef (this, first, is_valuetype);
                                typeref_table [first] = type_ref;
                        }

                        return (rest == "" ? type_ref : type_ref.GetTypeRef (rest, is_valuetype));
                }
 public ExternMethodRef(ExternTypeRef owner, BaseTypeRef ret_type,
                        PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
     : base(owner, call_conv, ret_type, name, param, gen_param_count)
 {
 }
Example #14
0
 public ExternMethodRef (ExternTypeRef owner, BaseTypeRef ret_type,
         PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
         : base (owner, call_conv, ret_type, name, param, gen_param_count)
 {
 }
Example #15
0
                public ExternTypeRef GetTypeRef (string _name, bool is_valuetype)
                {
                        string first= _name;
                        string rest = "";
                        int slash = _name.IndexOf ('/');

                        if (slash > 0) {
                                first = _name.Substring (0, slash);
                                rest = _name.Substring (slash + 1);
                        }

                        ExternTypeRef ext_typeref = nestedtypes_table [first] as ExternTypeRef;
                        
                        if (ext_typeref != null) {
                                if (is_valuetype && rest == "")
                                        ext_typeref.MakeValueClass ();
                        } else {
                                ext_typeref = new ExternTypeRef (this, first, is_valuetype);
                                nestedtypes_table [first] = ext_typeref;
                        }        
                        
                        return (rest == "" ? ext_typeref : ext_typeref.GetTypeRef (rest, is_valuetype));
                }