public PermissionMember(MemberTypes member_type, BaseTypeRef type_ref, string name, object value)
 {
     this.member_type = member_type;
     this.type_ref    = type_ref;
     this.name        = name;
     this.value       = value;
 }
Exemple #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")));
        }
Exemple #3
0
        public GlobalFieldRef(BaseTypeRef ret_type, string name)
        {
            this.ret_type = ret_type;
            this.name     = name;

            is_resolved = false;
        }
Exemple #4
0
        static string CreateSignature(BaseTypeRef RetType, string name, BaseTypeRef[] param_list, int gen_param_count, bool include_optional)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(RetType.FullName);
            builder.Append(" ");
            builder.Append(name);
            if (gen_param_count > 0)
            {
                builder.AppendFormat("`{0}", gen_param_count);
            }
            builder.Append('(');

            if (param_list != null)
            {
                bool first = true;
                foreach (BaseTypeRef param in param_list)
                {
                    if (!first)
                    {
                        builder.Append(',');
                    }
                    builder.Append(param.FullName);
                    first = false;
                    if (!include_optional && param is SentinelTypeRef)
                    {
                        break;
                    }
                }
            }
            builder.Append(')');

            return(builder.ToString());
        }
Exemple #5
0
        public virtual BaseMethodRef GetMethodRef(BaseTypeRef ret_type,
                                                  PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
        {
            BaseMethodRef mr = null;

            /* Note: FullName not reqd as this is cached per object */
            string key = MethodDef.CreateSignature(ret_type, call_conv, name, param, gen_param_count, true);

            if (method_table == null)
            {
                method_table = new Hashtable();
            }
            else
            {
                mr = (BaseMethodRef)method_table [key];
            }

            if (mr == null)
            {
                mr = CreateMethodRef(ret_type, call_conv, name, param, gen_param_count);
                method_table [key] = mr;
            }

            return(mr);
        }
Exemple #6
0
        static string CreateSignature(BaseTypeRef RetType, string name, IList param_list, int gen_param_count)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(RetType.FullName);
            builder.Append(" ");
            builder.Append(name);
            if (gen_param_count > 0)
            {
                builder.AppendFormat("`{0}", gen_param_count);
            }
            builder.Append('(');

            if (param_list != null)
            {
                bool first = true;
                foreach (ParamDef paramdef in param_list)
                {
                    if (!first)
                    {
                        builder.Append(',');
                    }
                    builder.Append(paramdef.TypeName);
                    first = false;
                }
            }
            builder.Append(')');

            return(builder.ToString());
        }
Exemple #7
0
 public PermissionMember (MemberTypes member_type, BaseTypeRef type_ref, string name, object value)
 {
         this.member_type = member_type;
         this.type_ref = type_ref;
         this.name = name;
         this.value = value;
 }
Exemple #8
0
 public EventDef (FeatureAttr attr, BaseTypeRef type, string name)
 {
         this.attr = attr;
         this.name = name;
         this.type = type;
         is_resolved = false;
 }
Exemple #9
0
 public EventDef(FeatureAttr attr, BaseTypeRef type, string name)
 {
     this.attr   = attr;
     this.name   = name;
     this.type   = type;
     is_resolved = false;
 }
Exemple #10
0
                public GlobalFieldRef (BaseTypeRef ret_type, string name)
                {
                        this.ret_type = ret_type;
                        this.name = name;

			is_resolved = false;
                }
Exemple #11
0
                public FieldRef (TypeRef owner, BaseTypeRef ret_type, string name)
                {
                        this.owner = owner;
                        this.ret_type = ret_type;
                        this.name = name;
			
			is_resolved = false;
                }
        public TypeSpecFieldRef(BaseTypeRef owner, BaseTypeRef type, string name)
        {
            this.owner = owner;
            this.type  = type;
            this.name  = name;

            is_resolved = false;
        }
Exemple #13
0
 public PropertyDef (FeatureAttr attr, BaseTypeRef type, string name, ArrayList arg_list)
 {
         this.attr = attr;
         this.name = name;
         this.type = type;
         this.arg_list = arg_list;
         is_resolved = false;
 }
Exemple #14
0
        public FieldRef(TypeRef owner, BaseTypeRef ret_type, string name)
        {
            this.owner    = owner;
            this.ret_type = ret_type;
            this.name     = name;

            is_resolved = false;
        }
Exemple #15
0
                public ExternFieldRef (ExternTypeRef owner, BaseTypeRef type, string name)
                {
                        this.owner = owner;
                        this.type = type;
                        this.name = name;
			
			is_resolved = false;
                }
 public PropertyDef(FeatureAttr attr, BaseTypeRef type, string name, ArrayList arg_list)
 {
     this.attr     = attr;
     this.name     = name;
     this.type     = type;
     this.arg_list = arg_list;
     is_resolved   = false;
 }
Exemple #17
0
 protected override BaseMethodRef CreateMethodRef (BaseTypeRef ret_type,
         PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
 {
         if (SigMod == null | SigMod == "")
                 return new MethodRef (this, call_conv, ret_type, name, param, gen_param_count);
         else
                 return new TypeSpecMethodRef (this, call_conv, ret_type, name, param, gen_param_count);
 }
Exemple #18
0
                public CalliInstr (PEAPI.CallConv call_conv, BaseTypeRef ret_type,
				   BaseTypeRef[] param, Location loc)
			: base (loc)
                {
                        this.call_conv = call_conv;
                        this.ret_type = ret_type;
                        this.param = param;
                }
 public CalliInstr(PEAPI.CallConv call_conv, BaseTypeRef ret_type,
                   BaseTypeRef[] param, Location loc)
     : base(loc)
 {
     this.call_conv = call_conv;
     this.ret_type  = ret_type;
     this.param     = param;
 }
Exemple #20
0
 public ParamDef (PEAPI.ParamAttr attr, string name,
                 BaseTypeRef typeref) {
         this.attr = attr;
         this.name = name;
         this.typeref = typeref;
         is_defined = false;
         defval = null;
 }
Exemple #21
0
 public void AddOverride(MethodDef body, BaseTypeRef parent, string name)
 {
     if (override_list == null)
     {
         override_list = new ArrayList();
     }
     override_list.Add(new DictionaryEntry(body,
                                           new DictionaryEntry(parent, name)));
 }
 public ParamDef(PEAPI.ParamAttr attr, string name,
                 BaseTypeRef typeref)
 {
     this.attr    = attr;
     this.name    = name;
     this.typeref = typeref;
     is_defined   = false;
     defval       = null;
 }
Exemple #23
0
		public void AddConstraint (BaseTypeRef constraint)
		{
			if (constraint == null)
				throw new InternalErrorException ();

			if (constraintsList == null)
				constraintsList = new ArrayList ();

			constraintsList.Add (constraint);
		}
Exemple #24
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);
        }
Exemple #25
0
		public void Add (BaseTypeRef type)
		{
			if (type == null)
				throw new InternalErrorException ();

			if (type_list == null)
				type_list = new ArrayList ();
			type_list.Add (type);
			type_str = null;
			type_arr = null;
		}
Exemple #26
0
                public MethodPointerTypeRef (PEAPI.CallConv callconv, BaseTypeRef ret, ArrayList param_list, ArrayList conv_list, string sig_mod)
                        : base (String.Empty, conv_list, sig_mod)
                {
                        this.callconv = callconv;
                        this.ret = ret;
                        this.param_list = param_list;

                        // We just need these to not break the interface
                        full_name = BuildTypeName ();
                        //sig_mod = String.Empty;
                }
        public MethodPointerTypeRef(PEAPI.CallConv callconv, BaseTypeRef ret, ArrayList param_list, ArrayList conv_list, string sig_mod)
            : base(String.Empty, conv_list, sig_mod)
        {
            this.callconv   = callconv;
            this.ret        = ret;
            this.param_list = param_list;

            // We just need these to not break the interface
            full_name = BuildTypeName();
            //sig_mod = String.Empty;
        }
Exemple #28
0
        public PEAPI.Method ResolveMethod(BaseTypeRef ret_type, PEAPI.CallConv call_conv,
                                          string name, BaseTypeRef [] param, int gen_param_count, CodeGen code_gen)
        {
            string    signature = MethodDef.CreateSignature(ret_type, call_conv, name, param, gen_param_count, false);
            MethodDef methoddef = (MethodDef)method_table[signature];

            if (methoddef != null)
            {
                return(methoddef.Resolve(code_gen, classdef));
            }
            return(ResolveAsMethodRef(ret_type, call_conv, name, param, gen_param_count, code_gen));
        }
Exemple #29
0
 // @include_optional: include optional parameters for vararg methods
 // This will be true mostly for *Ref use, eg. methodrefs at call sites
 // and false for *Def (include only the required params)
 public static string CreateSignature(BaseTypeRef RetType, PEAPI.CallConv call_conv, string name,
                                      BaseTypeRef[] param_list, int gen_param_count, bool include_optional)
 {
     if ((call_conv & PEAPI.CallConv.Vararg) != 0)
     {
         return(CreateVarargSignature(RetType, name, param_list, include_optional));
     }
     else
     {
         return(CreateSignature(RetType, name, param_list, gen_param_count, include_optional));
     }
 }
 protected override BaseMethodRef CreateMethodRef(BaseTypeRef ret_type,
                                                  PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
 {
     if (SigMod == null | SigMod == "")
     {
         return(new MethodRef(this, call_conv, ret_type, name, param, gen_param_count));
     }
     else
     {
         return(new TypeSpecMethodRef(this, call_conv, ret_type, name, param, gen_param_count));
     }
 }
Exemple #31
0
 public BaseMethodRef (BaseTypeRef owner, PEAPI.CallConv call_conv,
         BaseTypeRef ret_type, string name, BaseTypeRef[] param, int gen_param_count)
 {
         this.owner = owner;
         this.call_conv = call_conv;
         this.ret_type = ret_type;
         this.name = name;
         this.param = param;
         this.gen_param_count = gen_param_count;
         if (gen_param_count > 0)
                 CallConv |= PEAPI.CallConv.Generic;
         is_resolved = false;
 }
        public void AddConstraint(BaseTypeRef constraint)
        {
            if (constraint == null)
            {
                throw new InternalErrorException();
            }

            if (constraintsList == null)
            {
                constraintsList = new ArrayList();
            }

            constraintsList.Add(constraint);
        }
Exemple #33
0
        public BaseMethodRef GetMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv,
                                          string name, BaseTypeRef[] param, int gen_param_count)
        {
            string            key = type_ref.FullName + MethodDef.CreateSignature(ret_type, name, param, gen_param_count) + type_ref.SigMod;
            TypeSpecMethodRef mr  = method_table [key] as TypeSpecMethodRef;

            if (mr == null)
            {
                mr = new TypeSpecMethodRef(this, ret_type, call_conv, name, param, gen_param_count);
                method_table [key] = mr;
            }

            return(mr);
        }
Exemple #34
0
                public override BaseMethodRef GetMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
                                string name, BaseTypeRef[] param, int gen_param_count)
                {
                        /* Use FullName also here, as we are caching in a static hashtable */
                        string key = FullName + MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, true);
                        TypeSpecMethodRef mr = s_method_table [key] as TypeSpecMethodRef;
                        if (mr != null)
                                return mr;

			//FIXME: generic methodref for primitive type?
                        mr = new TypeSpecMethodRef (this, call_conv, ret_type, name, param, gen_param_count);
                        s_method_table [key] = mr;
                        return mr;
                }
Exemple #35
0
                public FieldDef (PEAPI.FieldAttr attr, string name,
                                BaseTypeRef type)
                {
                        this.attr = attr;
                        this.name = name;
                        this.type = type;

                        offset_set = false;
//                        datavalue_set = false;
                        value_set = false;

                        at_data_id = null;

                        is_resolved = false;
                }
Exemple #36
0
 public BaseMethodRef(BaseTypeRef owner, PEAPI.CallConv call_conv,
                      BaseTypeRef ret_type, string name, BaseTypeRef[] param, int gen_param_count)
 {
     this.owner           = owner;
     this.call_conv       = call_conv;
     this.ret_type        = ret_type;
     this.name            = name;
     this.param           = param;
     this.gen_param_count = gen_param_count;
     if (gen_param_count > 0)
     {
         CallConv |= PEAPI.CallConv.Generic;
     }
     is_resolved = false;
 }
Exemple #37
0
        protected override IFieldRef CreateFieldRef(BaseTypeRef ret_type, string field_name)
        {
            /* Note: Using FullName here as we are caching in a static hashtable */
            string key = FullName + ret_type.FullName + field_name;

            IFieldRef fr = (IFieldRef)s_field_table [key];

            if (fr == null)
            {
                fr = new TypeSpecFieldRef(this, ret_type, field_name);
                s_field_table [key] = fr;
            }

            return(fr);
        }
Exemple #38
0
        public BaseTypeRef[] ParamTypeList()
        {
            if (param_list == null)
            {
                return(new BaseTypeRef[0]);
            }
            int count = 0;

            BaseTypeRef[] type_list = new BaseTypeRef[param_list.Count];
            foreach (ParamDef param in param_list)
            {
                type_list[count++] = param.Type;
            }
            return(type_list);
        }
Exemple #39
0
        public override BaseMethodRef GetMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv,
                                                   string meth_name, BaseTypeRef[] param, int gen_param_count)
        {
            /* Note: Using FullName here as we are caching in a static hashtable */
            string            key = FullName + MethodDef.CreateSignature(ret_type, call_conv, meth_name, param, gen_param_count, true);
            TypeSpecMethodRef mr  = s_method_table [key] as TypeSpecMethodRef;

            if (mr == null)
            {
                mr = new TypeSpecMethodRef(this, call_conv, ret_type, meth_name, param, gen_param_count);
                s_method_table [key] = mr;
            }

            return(mr);
        }
        public void Add(BaseTypeRef type)
        {
            if (type == null)
            {
                throw new InternalErrorException();
            }

            if (type_list == null)
            {
                type_list = new ArrayList();
            }
            type_list.Add(type);
            type_str = null;
            type_arr = null;
        }
Exemple #41
0
        public FieldDef(PEAPI.FieldAttr attr, string name,
                        BaseTypeRef type)
        {
            this.attr = attr;
            this.name = name;
            this.type = type;

            offset_set = false;
//                        datavalue_set = false;
            value_set = false;

            at_data_id = null;

            is_resolved = false;
        }
Exemple #42
0
        PEAPI.Type GetType(CodeGen code_gen, PEAPI.CustomModifier modifier, BaseTypeRef klass)
        {
            klass.Resolve(code_gen);
            var bcr = klass as BaseClassRef;

            if (bcr != null)
            {
                return(new PEAPI.CustomModifiedType(peapi_type, modifier, bcr.PeapiClass));
            }

            var pt = klass as PrimitiveTypeRef;

            return(new PEAPI.CustomModifiedType(peapi_type, modifier, code_gen.PEFile.AddPrimitiveType((PEAPI.PrimitiveType)pt.PeapiType)));

            throw new NotSupportedException(klass.GetType().ToString());
        }
Exemple #43
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);
        }
Exemple #44
0
                public virtual IFieldRef GetFieldRef (BaseTypeRef ret_type, string name)
                {
                        IFieldRef fr = null;
                        string key = ret_type.FullName + name;

                        if (field_table == null)
                                field_table = new Hashtable ();
                        else
                                fr = (IFieldRef) field_table [key];

                        if (fr == null) {
                                fr = CreateFieldRef (ret_type, name);
                                field_table [key] = fr;
                        }

                        return fr;
                }
Exemple #45
0
        public PEAPI.Method ResolveVarargMethod(BaseTypeRef ret_type, PEAPI.CallConv call_conv,
                                                string name, BaseTypeRef [] param, int gen_param_count, PEAPI.Type [] opt, CodeGen code_gen)
        {
            // Only MethodDef sig required to lookup in the method_table
            string    signature = MethodDef.CreateSignature(ret_type, call_conv, name, param, 0, false);
            MethodDef methoddef = (MethodDef)method_table[signature];

            if (methoddef != null)
            {
                methoddef.Resolve(code_gen, classdef);
                return(methoddef.GetVarargSig(
                           opt,
                           MethodDef.CreateSignature(ret_type, call_conv, name, param, 0, true)));
            }

            return(ResolveAsMethodRef(ret_type, call_conv, name, param, gen_param_count, code_gen));
        }
        public override BaseMethodRef GetMethodRef(BaseTypeRef ret_type, PEAPI.CallConv call_conv,
                                                   string name, BaseTypeRef[] param, int gen_param_count)
        {
            /* Use FullName also here, as we are caching in a static hashtable */
            string            key = FullName + MethodDef.CreateSignature(ret_type, call_conv, name, param, gen_param_count, true);
            TypeSpecMethodRef mr  = s_method_table [key] as TypeSpecMethodRef;

            if (mr != null)
            {
                return(mr);
            }

            //FIXME: generic methodref for primitive type?
            mr = new TypeSpecMethodRef(this, call_conv, ret_type, name, param, gen_param_count);
            s_method_table [key] = mr;
            return(mr);
        }
Exemple #47
0
                public virtual BaseMethodRef GetMethodRef (BaseTypeRef ret_type,
                        PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
                {
                        BaseMethodRef mr = null;

                        /* Note: FullName not reqd as this is cached per object */
                        string key = MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, true);
                        if (method_table == null)
                                method_table = new Hashtable ();
                        else
                                mr = (BaseMethodRef) method_table [key];

                        if (mr == null) {
                                mr = CreateMethodRef (ret_type, call_conv, name, param, gen_param_count);
                                method_table [key] = mr;
                        }

                        return mr;
                }
Exemple #48
0
                public MethodDef (CodeGen codegen, PEAPI.MethAttr meth_attr,
				  PEAPI.CallConv call_conv, PEAPI.ImplAttr impl_attr,
				  string name, BaseTypeRef ret_type, ArrayList param_list,
				  Location start, GenericParameters gen_params, TypeDef type_def)
                {
                        this.codegen = codegen;
                        this.meth_attr = meth_attr;
                        this.call_conv = call_conv;
                        this.impl_attr = impl_attr;
                        this.name = name;
                        this.param_list = param_list;
                        this.type_def = type_def;
                        this.gen_params = gen_params;
                        this.ret_param = new ParamDef (PEAPI.ParamAttr.Default, "", ret_type);
                        this.start = (Location) start.Clone ();

                        inst_list = new ArrayList ();
                        label_table = new Hashtable ();
                        labelref_table = new Hashtable ();
                        label_list = new ArrayList ();
                        local_list = new ArrayList ();
                        named_local_tables = new ArrayList ();
                        named_local_tables.Add (new Hashtable ());
                        current_scope_depth = 0;

                        entry_point = false;
                        zero_init = false;
                        init_locals = false;
                        max_stack = -1;
                        pinvoke_info = false;

                        is_defined = false;
                        is_resolved = false;
                        ResolveGenParams ();
                        CreateSignature ();

			codegen.BeginMethodDef (this);

			if (codegen.SymbolWriter != null)
				source = codegen.SymbolWriter.BeginMethod (this, start);
                }
                public GlobalMethodRef GetGlobalMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
                                string name, BaseTypeRef[] param, int gen_param_count)
                {
                        string key = MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, true);

                        GlobalMethodRef methref = null;

                        if (global_methodref_table == null)
                                global_methodref_table = new Hashtable ();
                        else
                                methref = (GlobalMethodRef) global_methodref_table [key];

                        if (methref == null) {
                                methref = new GlobalMethodRef (ret_type, call_conv, name, param, gen_param_count);
                                global_methodref_table [key] = methref;
                        }
                        
                        return methref;
                }
Exemple #50
0
 protected override IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name)
 {
          return new FieldRef (this, ret_type, name);
 }
Exemple #51
0
                static string CreateVarargSignature (BaseTypeRef RetType, string name, IList param_list)
                {
                        StringBuilder builder = new StringBuilder ();
                        ParamDef last = null;

			builder.Append (RetType.FullName);
			builder.Append (" ");
                        builder.Append (name);
                        builder.Append ('(');

                        bool first = true;
                        if (param_list != null) {
                                foreach (ParamDef paramdef in param_list) {
                                        if (!first)
                                                builder.Append (',');
                                        builder.Append (paramdef.TypeName);
                                        first = false;
                                }
                                last = (ParamDef) param_list[param_list.Count - 1];
                        }

                        
                        if (last == null || !last.IsSentinel ()) {
                                if (!first)
                                        builder.Append (',');
                                builder.Append ("...");
                        }

                        builder.Append (')');

                        return builder.ToString ();
                }
Exemple #52
0
		public BaseMethodRef GetMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
				string name, BaseTypeRef[] param, int gen_param_count)
		{
			string key = type_ref.FullName + MethodDef.CreateSignature (ret_type, name, param, gen_param_count) + type_ref.SigMod;
			TypeSpecMethodRef mr = method_table [key] as TypeSpecMethodRef;
			if (mr == null) {	 
				mr = new TypeSpecMethodRef (this, ret_type, call_conv, name, param, gen_param_count);
				method_table [key] = mr;
			}

			return mr;
		}
Exemple #53
0
                public BaseTypeRef[] ParamTypeList () {

                        if (param_list == null)
                                return new BaseTypeRef[0];
                        int count = 0;
                        BaseTypeRef[] type_list = new BaseTypeRef[param_list.Count];
                        foreach (ParamDef param in param_list) {
                                type_list[count++] = param.Type;
                        }
                        return type_list;
                }
Exemple #54
0
				static string CreateSignature (BaseTypeRef RetType, string name, BaseTypeRef[] param_list, int gen_param_count, bool include_optional, PEAPI.CallConv call_conv)
                {
                        StringBuilder builder = new StringBuilder ();

						if ((call_conv & PEAPI.CallConv.Instance) != 0)
							builder.Append ("instance ");


			builder.Append (RetType.FullName);
			builder.Append (" ");
                        builder.Append (name);
                        if (gen_param_count > 0)
                                builder.AppendFormat ("`{0}", gen_param_count);
                        builder.Append ('(');

                        if (param_list != null) {
                                bool first = true;
                                foreach (BaseTypeRef param in param_list) {
                                        if (!first)
                                                builder.Append (',');
                                        builder.Append (param.FullName);
                                        first = false;
                                        if (!include_optional && param is SentinelTypeRef)
                                                break;
                                }
                        }
                        builder.Append (')');

                        return builder.ToString ();
                }
Exemple #55
0
				static string CreateVarargSignature (BaseTypeRef RetType, string name, BaseTypeRef [] param_list, bool include_optional)
                {
                        StringBuilder builder = new StringBuilder ();
                        BaseTypeRef last = null;

			builder.Append (RetType.FullName);
			builder.Append (" ");
                        builder.Append (name);
                        builder.Append ('(');

                        bool first = true;
                        if (param_list != null && param_list.Length > 0) {
                                foreach (BaseTypeRef param in param_list) {
                                        if (!first)
                                                builder.Append (',');
                                        builder.Append (param.FullName);
                                        first = false;
                                        last = param;
                                        if (!include_optional && param is SentinelTypeRef)
                                                break;
                                }
                                
                        }
                        
                        if (!include_optional && (last == null || !(last is SentinelTypeRef))) {
                                if (!first)
                                        builder.Append (',');
                                builder.Append ("...");
                        }

                        builder.Append (')');

                        return builder.ToString ();
                }
Exemple #56
0
 // @include_optional: include optional parameters for vararg methods
 // This will be true mostly for *Ref use, eg. methodrefs at call sites
 // and false for *Def (include only the required params)
 public static string CreateSignature (BaseTypeRef RetType, PEAPI.CallConv call_conv, string name,
                 BaseTypeRef[] param_list, int gen_param_count, bool include_optional)
 {
         if ((call_conv & PEAPI.CallConv.Vararg) != 0)
                 return CreateVarargSignature (RetType, name, param_list, include_optional);
         else
                 return CreateSignature (RetType, name, param_list, gen_param_count, include_optional, call_conv);
 }
                public GlobalFieldRef GetGlobalFieldRef (BaseTypeRef ret_type, string name)
                {
                        string key = ret_type.FullName + name;

                        GlobalFieldRef fieldref = null;

                        if (global_fieldref_table == null)
                                global_fieldref_table = new Hashtable ();
                        else
                                fieldref = (GlobalFieldRef) global_fieldref_table [key];

                        if (fieldref == null) {
                                fieldref = new GlobalFieldRef (ret_type, name);
                                global_fieldref_table [key] = fieldref;
                        }
                        
                        return fieldref;
                }
Exemple #58
0
		public IFieldRef GetFieldRef (BaseTypeRef ret_type, string name)
		{
			return new TypeSpecFieldRef (this, ret_type, name);
		}
Exemple #59
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)
 {
 }
Exemple #60
0
				static string CreateSignature (BaseTypeRef RetType, string name, IList param_list, int gen_param_count, PEAPI.MethAttr attrs)
                {
                        StringBuilder builder = new StringBuilder ();

						if ((attrs & PEAPI.MethAttr.Static) == 0)
							builder.Append ("instance ");

			builder.Append (RetType.FullName);
			builder.Append (" ");
                        builder.Append (name);
                        if (gen_param_count > 0)
                                builder.AppendFormat ("`{0}", gen_param_count);
                        builder.Append ('(');

                        if (param_list != null) {
                                bool first = true;
                                foreach (ParamDef paramdef in param_list) {
                                        if (!first)
                                                builder.Append (',');
                                        builder.Append (paramdef.TypeName);
                                        first = false;
                                }
                        }
                        builder.Append (')');

                        return builder.ToString ();
                }