Example #1
0
			public MethodTableItem (MethodDef method, Location location)
			{
				flags = 0;
				Method = method;
				LocationList = new ArrayList ();
				LocationList.Add (location);
			}
Example #2
0
			public FieldTableItem (FieldDef field, Location location)
			{
				flags = 0;
				Field = field;
				LocationList = new ArrayList ();
				LocationList.Add (location);
			}
Example #3
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;
                }
Example #4
0
		public ILReader (StreamReader reader)
		{
			this.reader = reader;
			putback_stack = new Stack ();
			
			location = new Location ();
			markedLocation = Location.Unknown;
		}
Example #5
0
 public ClassTableItem (ClassDef klass, Location location)
 {
         flags = 0;
         Class = klass;
         LocationList = new ArrayList ();
         LocationList.Add (location);
         method_table = new MethodTable (klass);
         field_table = new FieldTable (klass);
 }
Example #6
0
                public static void Warning (Location location, string message)
                {
                        string location_str = " : ";
                        if (location != null)
                                location_str = " (" + location.line + ", " + location.column + ") : ";

                        Console.Error.WriteLine (String.Format ("{0}{1}Warning -- {2}",
                                (file_path != null ? file_path : ""), location_str, message));
                }
Example #7
0
                public MethodInstr (PEAPI.MethodOp op, BaseMethodRef operand, Location loc)
			: base (loc)
                {
                        this.op = op;
                        this.operand = operand;

                        if (op == PEAPI.MethodOp.newobj || op == PEAPI.MethodOp.callvirt)
                                operand.CallConv |= PEAPI.CallConv.Instance;
                }
Example #8
0
		public SourceMethod (CompileUnitEntry file, MethodDef method, Location start)
		{
			this.file = file;
			this.method = method;
			this.StartLine = start.line;

			lines = new ArrayList ();
			MarkLocation (start.line, 0);
		}
Example #9
0
		public Field GetReference (TypeRef type, string name, Location location)
		{
			FieldTableItem item = table[name] as FieldTableItem;
			
			if (item != null) {
				item.LocationList.Add (location);
				return item.Field;
			}
			
			FieldDef field = parent_class.AddField (name, type.Type);
			AddReferenced (name, field, location);

			return field;
		}
Example #10
0
		public FieldDef AddDefinition (FieldAttr field_attr, string name, 
			TypeRef type, Location location) 
		{
			FieldTableItem item = (FieldTableItem) table[name];
			
			if (item == null) {
				FieldDef field = parent_class.AddField (field_attr, name, type.Type);
				AddDefined (name, field, location);
				return field;
			}
			
			item.Field.AddFieldAttr (field_attr);
			item.Defined = true;
			
			return item.Field;
		}
Example #11
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;
                }
Example #12
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);
                }
Example #13
0
                public SimpInstr (PEAPI.Op op, Location loc)
			: base (loc)
                {
                        this.op = op;
                }
Example #14
0
		protected void AddReferenced (string signature, FieldDef field, Location location)
		{
			FieldTableItem item = new FieldTableItem (field, location);
			
			table[signature] = item;
		}
Example #15
0
                public TypeInstr (PEAPI.TypeOp op, BaseTypeRef operand, Location loc)
			: base (loc)
                {
                        this.op = op;
                        this.operand = operand;
                }
Example #16
0
		public void EndMethod (Location end)
		{
			current_method.EndLine = end.line;
			current_method = null;
		}
Example #17
0
                public FieldTable GetFieldTable (string full_name, Location location)
                {
                        ClassTableItem item = table[full_name] as ClassTableItem;

                        if (item == null) {
                                GetReference (full_name, location);
                                return GetFieldTable (full_name, location);
                        }

                        return item.FieldTable;
                }
Example #18
0
 public TypeRef (string full_name, bool is_valuetype, Location location, ArrayList conv_list, string sig_mod)
         : base (full_name, is_valuetype, conv_list, sig_mod)
 {
         this.location = location;
 }
Example #19
0
		public Mono.ILASM.SourceMethod BeginMethod (MethodDef method, Location start)
		{
			current_method = new Mono.ILASM.SourceMethod (current_source, method, start);
			methods.Add (current_method);
			return current_method;
		}
Example #20
0
                public ClassDef AddDefinition (string name_space, string name,
                        TypeAttr attr, Location location)
                {
                        string full_name;

                        if (name_space != null)
                                full_name = String.Format ("{0}.{1}", name_space, name);
                        else
                                full_name = name;

                        ClassTableItem item = (ClassTableItem) table[full_name];

                        if (item == null) {
                                ClassDef klass = pefile.AddClass (attr, name_space, name);
                                AddDefined (full_name, klass, location);
                                return klass;
                        }

                        item.Class.AddAttribute (attr);
                        item.Defined = true;

                        return item.Class;
                }
Example #21
0
                public ClassDef AddDefinition (string name_space, string name,
                        TypeAttr attr, Class parent, Location location)
                {
                        string full_name;

                        if (name_space != null)
                                full_name = String.Format ("{0}.{1}", name_space, name);
                        else
                                full_name = name;

                        ClassTableItem item = (ClassTableItem) table[full_name];

                        if (item == null) {
                                ClassDef klass = pefile.AddClass (attr, name_space, name, parent);
                                AddDefined (full_name, klass, location);
                                return klass;
                        }

                        /// TODO: Need to set parent, will need to modify PEAPI for this.
                        item.Class.AddAttribute (attr);
                        item.Defined = true;

                        return item.Class;
                }
Example #22
0
                public void EndMethodDef (Location location)
                {
			if (symwriter != null)
				symwriter.EndMethod (location);

                        current_methoddef = null;
                }
Example #23
0
                protected void AddReference (string full_name, ClassDef klass, Location location)
                {
                        if (table.Contains (full_name))
                                return;

                        ClassTableItem item = new ClassTableItem (klass, location);

                        table[full_name] = item;
                }
Example #24
0
                protected void AddDefined (string full_name, ClassDef klass, Location location)
                {
                        if (table.Contains (full_name))
                                return;

                        ClassTableItem item = new ClassTableItem (klass, location);
                        item.Defined = true;

                        table[full_name] = item;
                }
Example #25
0
		protected void AddDefined (string signature, FieldDef field, Location location)
		{
			if (table.Contains (signature))
				return; 

			FieldTableItem item = new FieldTableItem (field, location);
			item.Defined = true;

			table[signature] = item;
		}
Example #26
0
                public FieldInstr (PEAPI.FieldOp op, IFieldRef operand, Location loc)
			: base (loc)
                {
                        this.op = op;
                        this.operand = operand;
                }
Example #27
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++;
                }
Example #28
0
 public TypeRef (string full_name, bool is_valuetype, Location location)
         : this (full_name, is_valuetype, location, null, null)
 {
 }
Example #29
0
		public ILSyntaxError (string msg, Location loc) : base (msg)
		{
			this.loc = loc.Clone () as Location;
		}
Example #30
0
                public Class GetReference (string full_name, Location location)
                {
                        ClassTableItem item = table[full_name] as ClassTableItem;

                        if (item != null) {
                                item.LocationList.Add (location);
                                return item.Class;
                        }

                        string name_space, name;
                        GetNameAndNamespace (full_name, out name_space, out name);
                        ClassDef klass = pefile.AddClass (DefaultAttr, name_space, name);
                        AddReference (full_name, klass, location);

                        return klass;
                }