Beispiel #1
0
        public void ResolveGenParams()
        {
            GenericParameters type_params = (type_def != null) ? type_def.TypeParameters : null;

            if (gen_params == null && type_params == null)
            {
                return;
            }

            if (gen_params != null)
            {
                gen_params.ResolveConstraints(type_params, gen_params);
            }

            BaseGenericTypeRef gtr = RetType as BaseGenericTypeRef;

            if (gtr != null)
            {
                gtr.Resolve(type_params, gen_params);
            }

            if (param_list == null)
            {
                return;
            }

            foreach (ParamDef param in param_list)
            {
                gtr = param.Type as BaseGenericTypeRef;
                if (gtr != null)
                {
                    gtr.Resolve(type_params, gen_params);
                }
            }
        }
Beispiel #2
0
 public void ResolveConstraints(GenericParameters type_gen_params, GenericParameters method_gen_params)
 {
     foreach (GenericParameter param in param_list)
     {
         param.ResolveConstraints(type_gen_params, method_gen_params);
     }
     param_str = null;
 }
Beispiel #3
0
		public void Resolve (GenericParameters type_gen_params, GenericParameters method_gen_params)
		{
			foreach (BaseTypeRef type in type_list) {
				BaseGenericTypeRef gtr = type as BaseGenericTypeRef;
				if (gtr != null)
					gtr.Resolve (type_gen_params, method_gen_params);
			}
			/* Reset, might have changed (think GenericParamRef) */
			type_str = null;
		}
Beispiel #4
0
        public TypeDef(PEAPI.TypeAttr attr, string name_space, string name,
                       BaseClassRef parent, ArrayList impl_list, Location location, GenericParameters gen_params, TypeDef outer)
        {
            this.attr       = attr;
            this.parent     = parent;
            this.impl_list  = impl_list;
            this.gen_params = gen_params;
            this.outer      = outer;
            this.location   = location;

            field_table = new Hashtable();
            field_list  = new ArrayList();

            method_table = new Hashtable();
            method_list  = new ArrayList();

            size = -1;
            pack = -1;

            is_defined   = false;
            is_intransit = false;

            is_value_class = false;
            is_enum_class  = false;

            ResolveGenParams();

            int lastdot = name.LastIndexOf('.');

            /* Namespace . name split should not be done for nested classes */
            if (lastdot >= 0 && outer == null)
            {
                if (name_space == null || name_space == "")
                {
                    this.name_space = name.Substring(0, lastdot);
                }
                else
                {
                    this.name_space = name_space + "." + name.Substring(0, lastdot);
                }
                this.name = name.Substring(lastdot + 1);
            }
            else
            {
                this.name_space = name_space;
                this.name       = name;
            }

            //Fixup attributes
            if (IsInterface)
            {
                this.attr |= PEAPI.TypeAttr.Abstract;
            }
        }
 public void Resolve(GenericParameters type_gen_params, GenericParameters method_gen_params)
 {
     foreach (BaseTypeRef type in type_list)
     {
         BaseGenericTypeRef gtr = type as BaseGenericTypeRef;
         if (gtr != null)
         {
             gtr.Resolve(type_gen_params, method_gen_params);
         }
     }
     /* Reset, might have changed (think GenericParamRef) */
     type_str = null;
 }
Beispiel #6
0
        public void BeginTypeDef(TypeAttr attr, string name, BaseClassRef parent,
                                 ArrayList impl_list, Location location, GenericParameters gen_params)
        {
            TypeDef outer      = null;
            string  cache_name = CacheName(name);

            if (typedef_stack_top > 0)
            {
                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < typedef_stack_top; i++)
                {
                    outer = (TypeDef)typedef_stack [i];
                    if (i == 0)
                    {
                        /* Use FullName for outermost class to get the
                         * namespace also */
                        sb.Append(outer.FullName);
                    }
                    else
                    {
                        sb.Append(outer.Name);
                    }
                    sb.Append("/");
                }
                sb.Append(name);
                cache_name = sb.ToString();
            }

            TypeDef typedef = type_manager[cache_name];

            if (typedef != null)
            {
                // Class head is allready defined, we are just reopening the class
                current_customattrtarget = current_typedef = typedef;
                current_declsectarget    = typedef;
                typedef_stack.Add(current_typedef);
                typedef_stack_top++;
                return;
            }

            typedef = new TypeDef(attr, current_namespace,
                                  name, parent, impl_list, location, gen_params, outer);

            type_manager[cache_name] = typedef;
            current_customattrtarget = current_typedef = typedef;
            current_declsectarget    = typedef;
            typedef_stack.Add(typedef);
            typedef_stack_top++;
        }
Beispiel #7
0
        public void ResolveConstraints(GenericParameters type_gen_params, GenericParameters method_gen_params)
        {
            if (constraintsList == null)
            {
                return;
            }

            foreach (BaseTypeRef constraint in constraintsList)
            {
                BaseGenericTypeRef gtr = constraint as BaseGenericTypeRef;
                if (gtr != null)
                {
                    gtr.Resolve(type_gen_params, method_gen_params);
                }
            }
        }
Beispiel #8
0
                public override void Resolve (GenericParameters type_gen_params, GenericParameters method_gen_params)
                {
                        if (param.Name == "") {
                                /* Name wasn't specified */
                                return;
                        }

                        if (param.Type == PEAPI.GenParamType.MVar && method_gen_params != null)
                                param.Index = method_gen_params.GetGenericParamNum (param.Name); 
                        else if (type_gen_params != null)
                                param.Index = type_gen_params.GetGenericParamNum (param.Name);

                        if (param.Index < 0)
                                Report.Error (String.Format ("Invalid {0}type parameter '{1}'", 
                                                        (param.Type == PEAPI.GenParamType.MVar ? "method " : ""),
                                                         param.Name));
                }
Beispiel #9
0
                public TypeDef (PEAPI.TypeAttr attr, string name_space, string name,
                                BaseClassRef parent, ArrayList impl_list, Location location, GenericParameters gen_params, TypeDef outer)
                {
                        this.attr = attr;
                        this.parent = parent;
                        this.impl_list = impl_list;
                        this.gen_params = gen_params;
                        this.outer = outer;
                        this.location = location;

                        field_table = new Hashtable ();
                        field_list = new ArrayList ();

                        method_table = new Hashtable ();
                        method_list = new ArrayList ();

                        size = -1;
                        pack = -1;

                        is_defined = false;
                        is_intransit = false;

                        is_value_class = false;
                        is_enum_class = false;

                        ResolveGenParams ();

                        int lastdot = name.LastIndexOf ('.');
                        /* Namespace . name split should not be done for nested classes */
                        if (lastdot >= 0 && outer == null) {
                                if (name_space == null || name_space == "")
                                        this.name_space = name.Substring (0, lastdot);
                                else
                                        this.name_space = name_space + "." + name.Substring (0, lastdot);
                                this.name = name.Substring (lastdot + 1);
                        } else {
                                this.name_space = name_space;
                                this.name = name;
                        }

                        //Fixup attributes
                        if (IsInterface)
                                this.attr |= PEAPI.TypeAttr.Abstract;
                }
Beispiel #10
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);
            }
        }
Beispiel #11
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);
                }
Beispiel #12
0
        public override void Resolve(GenericParameters type_gen_params, GenericParameters method_gen_params)
        {
            if (param.Name == "")
            {
                /* Name wasn't specified */
                return;
            }

            if (param.Type == PEAPI.GenParamType.MVar && method_gen_params != null)
            {
                param.Index = method_gen_params.GetGenericParamNum(param.Name);
            }
            else if (type_gen_params != null)
            {
                param.Index = type_gen_params.GetGenericParamNum(param.Name);
            }

            if (param.Index < 0)
            {
                Report.Error(String.Format("Invalid {0}type parameter '{1}'",
                                           (param.Type == PEAPI.GenParamType.MVar ? "method " : ""),
                                           param.Name));
            }
        }
Beispiel #13
0
 public override void Resolve(GenericParameters type_gen_params, GenericParameters method_gen_params)
 {
     gen_args.Resolve(type_gen_params, method_gen_params);
 }
Beispiel #14
0
		public void ResolveConstraints (GenericParameters type_gen_params, GenericParameters method_gen_params)
		{
			if (constraintsList == null)
				return;
				
			foreach (BaseTypeRef constraint in constraintsList) {
				BaseGenericTypeRef gtr = constraint as BaseGenericTypeRef;
				if (gtr != null)
					gtr.Resolve (type_gen_params, method_gen_params);
			}
		}
Beispiel #15
0
		public void ResolveConstraints (GenericParameters type_gen_params, GenericParameters method_gen_params)
		{
			foreach (GenericParameter param in param_list)
				param.ResolveConstraints (type_gen_params, method_gen_params);
			param_str = null;
		}
Beispiel #16
0
 /* Used to resolve any gen params in arguments, constraints etc */
 public abstract void Resolve(GenericParameters type_gen_params, GenericParameters method_gen_params);
Beispiel #17
0
 public override void Resolve (GenericParameters type_gen_params, GenericParameters method_gen_params)
 {
         gen_args.Resolve (type_gen_params, method_gen_params);
 }
                public void BeginTypeDef (TypeAttr attr, string name, BaseClassRef parent,
                                ArrayList impl_list, Location location, GenericParameters gen_params)
                {
                        TypeDef outer = null;
                        string cache_name = CacheName (name);
                        if (typedef_stack_top > 0) {
				StringBuilder sb = new StringBuilder ();

				for (int i = 0; i < typedef_stack_top; i++){
					outer = (TypeDef) typedef_stack [i];
					if (i == 0)
						/* Use FullName for outermost class to get the
						   namespace also */
						sb.Append (outer.FullName);
					else
						sb.Append (outer.Name);
					sb.Append ("/");
				}
				sb.Append (name);
				cache_name = sb.ToString ();
                        }

                        TypeDef typedef = type_manager[cache_name];

                        if (typedef != null) {
                                // Class head is allready defined, we are just reopening the class
                                current_customattrtarget = current_typedef = typedef;
                                current_declsectarget = typedef;
                                typedef_stack.Add (current_typedef);
				typedef_stack_top++;
                                return;
                        }

                        typedef = new TypeDef (attr, current_namespace,
                                        name, parent, impl_list, location, gen_params, outer);

                        type_manager[cache_name] = typedef;
                        current_customattrtarget = current_typedef = typedef;
                        current_declsectarget = typedef;
			typedef_stack.Add (typedef);
			typedef_stack_top++;
                }
Beispiel #19
0
 /* Used to resolve any gen params in arguments, constraints etc */
 public abstract void Resolve (GenericParameters type_gen_params, GenericParameters method_gen_params);