2001-09-30 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Sun, 30 Sep 2001 02:22:09 +0000 (02:22 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Sun, 30 Sep 2001 02:22:09 +0000 (02:22 -0000)
* class.cs: Only add constructor to hashtable if it is non-null
(as now constructors can fail on define).

(TypeManager, Class, Struct): Take location arguments.

Catch field instance initialization in structs as errors.

accepting_filter: a new filter for FindMembers that is static so
that we dont create an instance per invocation.

(Constructor::Define): Catch errors where a struct constructor is
parameterless

* cs-parser.jay: Pass location information for various new
constructs.

* delegate.cs (Delegate): take a location argument.

* driver.cs: Do not call EmitCode if there were problesm in the
Definition of the types, as many Builders wont be there.

* decl.cs (Decl::Decl): Require a location argument.

* cs-tokenizer.cs: Handle properly hex constants that can not fit
into integers, and find the most appropiate integer for it.

* literal.cs: Implement ULongLiteral.

* rootcontext.cs: Provide better information about the location of
failure when CreateType fails.

2001-09-29  Miguel de Icaza  <miguel@ximian.com>

* rootcontext.cs (RootContext::PopulateTypes): Populates structs
as well.

* expression.cs (Binary::CheckShiftArguments): Add missing type
computation.
(Binary::ResolveOperator): Add type to the logical and and logical
or, Bitwise And/Or and Exclusive Or code paths, it was missing
before.

(Binary::DoNumericPromotions): In the case where either argument
is ulong (and most signed types combined with ulong cause an
error) perform implicit integer constant conversions as well.

svn path=/trunk/mcs/; revision=1035

14 files changed:
mcs/mcs/ChangeLog
mcs/mcs/class.cs
mcs/mcs/cs-parser.jay
mcs/mcs/cs-tokenizer.cs
mcs/mcs/decl.cs
mcs/mcs/delegate.cs
mcs/mcs/driver.cs
mcs/mcs/enum.cs
mcs/mcs/expression.cs
mcs/mcs/interface.cs
mcs/mcs/literal.cs
mcs/mcs/parameter.cs
mcs/mcs/rootcontext.cs
mcs/mcs/tree.cs

index 2726c0c320d0591d7c7b4162e8dab217cd5fb915..e1e1dc3690404afdbd1b05ac0504892ec5c3cd76 100755 (executable)
@@ -1,3 +1,51 @@
+2001-09-30  Miguel de Icaza  <miguel@ximian.com>
+
+       * class.cs: Only add constructor to hashtable if it is non-null
+       (as now constructors can fail on define).
+
+       (TypeManager, Class, Struct): Take location arguments.
+
+       Catch field instance initialization in structs as errors.
+
+       accepting_filter: a new filter for FindMembers that is static so
+       that we dont create an instance per invocation.
+
+       (Constructor::Define): Catch errors where a struct constructor is
+       parameterless 
+
+       * cs-parser.jay: Pass location information for various new
+       constructs. 
+       
+       * delegate.cs (Delegate): take a location argument.
+
+       * driver.cs: Do not call EmitCode if there were problesm in the
+       Definition of the types, as many Builders wont be there. 
+
+       * decl.cs (Decl::Decl): Require a location argument.
+
+       * cs-tokenizer.cs: Handle properly hex constants that can not fit
+       into integers, and find the most appropiate integer for it.
+
+       * literal.cs: Implement ULongLiteral.
+
+       * rootcontext.cs: Provide better information about the location of
+       failure when CreateType fails.
+       
+2001-09-29  Miguel de Icaza  <miguel@ximian.com>
+
+       * rootcontext.cs (RootContext::PopulateTypes): Populates structs
+       as well.
+
+       * expression.cs (Binary::CheckShiftArguments): Add missing type
+       computation.
+       (Binary::ResolveOperator): Add type to the logical and and logical
+       or, Bitwise And/Or and Exclusive Or code paths, it was missing
+       before.
+
+       (Binary::DoNumericPromotions): In the case where either argument
+       is ulong (and most signed types combined with ulong cause an
+       error) perform implicit integer constant conversions as well.
+
 2001-09-28  Miguel de Icaza  <miguel@ximian.com>
 
        * expression.cs (UserImplicitCast): Method should always be
index 4d6b60508f780b7faf02bf03240760c172346b1e..fbb5ab0f5f3b6b24ef1fb7d203988eebf4d5fd7a 100755 (executable)
@@ -98,7 +98,8 @@ namespace CIR {
                // Attributes for this type
                protected Attributes attributes;
 
-               public TypeContainer (RootContext rc, TypeContainer parent, string name) : base (name)
+               public TypeContainer (RootContext rc, TypeContainer parent, string name, Location l)
+                       : base (name, l)
                {
                        string n;
                        types = new ArrayList ();
@@ -539,7 +540,8 @@ namespace CIR {
                        int mods = 0;
 
                        c = new Constructor (Name, new Parameters (null, null),
-                                            new ConstructorBaseInitializer (null, new Location ("", 0, 0)));
+                                            new ConstructorBaseInitializer (null, new Location ("", 0, 0)),
+                                            new Location ("Internal", 1, 1));
                        AddConstructor (c);
                        c.Block = new Block (null);
                        
@@ -549,6 +551,18 @@ namespace CIR {
                        c.ModFlags = mods;      
                }
 
+               public void ReportStructInitializedInstanceError ()
+               {
+                       string n = TypeBuilder.FullName;
+                       
+                       foreach (Field f in initialized_fields){
+                               RootContext.Report.Error (
+                                       573, Location,
+                                       "`" + n + "." + f.Name + "': can not have " +
+                                       "instance field initializers in structs");
+                       }
+               }
+
                //
                // Populates our TypeBuilder with fields and methods
                //
@@ -564,19 +578,36 @@ namespace CIR {
                                        f.Define (this);
                        }
 
-                       if (default_constructor == null) 
-                               DefineDefaultConstructor (false);
+                       if (this is Class){
+                               if (default_constructor == null) 
+                                       DefineDefaultConstructor (false);
 
-                       if (initialized_static_fields != null && default_static_constructor == null)
-                               DefineDefaultConstructor (true);
+                               if (initialized_static_fields != null &&
+                                   default_static_constructor == null)
+                                       DefineDefaultConstructor (true);
+                       }
 
+                       if (this is Struct){
+                               //
+                               // Structs can not have initialized instance
+                               // fields
+                               //
+                               if (initialized_static_fields != null &&
+                                   default_static_constructor == null)
+                                       DefineDefaultConstructor (true);
+
+                               if (initialized_fields != null)
+                                       ReportStructInitializedInstanceError ();
+                       }
                        
                        if (Constructors != null){
                                foreach (Constructor c in Constructors){
                                        c.Define (this);
                                        if (method_builders_to_methods == null)
                                                method_builders_to_methods = new Hashtable ();
-                                       method_builders_to_methods.Add (c.ConstructorBuilder, c);
+                                       object key = c.ConstructorBuilder;
+                                       if (key != null)
+                                               method_builders_to_methods.Add (key, c);
                                }
                        } 
 
@@ -678,11 +709,25 @@ namespace CIR {
                        return RootContext.LookupType (this, name, silent);
                }
 
-               bool AlwaysAccept (MemberInfo m, object filterCriteria)
+               //
+               // This function is based by a delegate to the FindMembers routine
+               //
+               static bool AlwaysAccept (MemberInfo m, object filterCriteria)
                {
                        return true;
                }
                
+               //
+               // This filter is used by FindMembers, and we just keep
+               // a global for the filter to `AlwaysAccept'
+               //
+               static MemberFilter accepting_filter;
+               
+               static TypeContainer ()
+               {
+                       accepting_filter = new MemberFilter (AlwaysAccept);
+               }
+               
                // <summary>
                //   This method returns the members of this type just like Type.FindMembers would
                //   Only, we need to use this for types which are _being_ defined because MS' 
@@ -694,7 +739,7 @@ namespace CIR {
                        ArrayList members = new ArrayList ();
 
                        if (filter == null)
-                               filter = new MemberFilter (AlwaysAccept);
+                               filter = accepting_filter; 
                        
                        if ((mt & MemberTypes.Field) != 0 && Fields != null) {
                                foreach (Field f in Fields) {
@@ -775,8 +820,9 @@ namespace CIR {
                        Modifiers.ABSTRACT |
                        Modifiers.SEALED;
 
-               public Class (RootContext rc, TypeContainer parent, string name, int mod, Attributes attrs)
-                       : base (rc, parent, name)
+               public Class (RootContext rc, TypeContainer parent, string name, int mod,
+                             Attributes attrs, Location l)
+                       : base (rc, parent, name, l)
                {
                        int accmods;
 
@@ -811,8 +857,9 @@ namespace CIR {
                        Modifiers.INTERNAL |
                        Modifiers.PRIVATE;
 
-               public Struct (RootContext rc, TypeContainer parent, string name, int mod, Attributes attrs)
-                       : base (rc, parent, name)
+               public Struct (RootContext rc, TypeContainer parent, string name, int mod,
+                              Attributes attrs, Location l)
+                       : base (rc, parent, name, l)
                {
                        int accmods;
                        
@@ -848,16 +895,18 @@ namespace CIR {
                public readonly string Name;
                public int ModFlags;
                Block block;
+               public readonly Location Location;
                
                //
                // Parameters, cached for semantic analysis.
                //
                InternalParameters parameter_info;
                
-               public MethodCore (string name, Parameters parameters)
+               public MethodCore (string name, Parameters parameters, Location l)
                {
                        Name = name;
                        Parameters = parameters;
+                       Location = l;
                }
                
                //
@@ -936,8 +985,8 @@ namespace CIR {
                
                // return_type can be "null" for VOID values.
                public Method (string return_type, int mod, string name, Parameters parameters,
-                              Attributes attrs)
-                       : base (name, parameters)
+                              Attributes attrs, Location l)
+                       : base (name, parameters, l)
                {
                        ReturnType = return_type;
                        ModFlags = Modifiers.Check (AllowedModifiers, mod, Modifiers.PRIVATE);
@@ -1106,8 +1155,8 @@ namespace CIR {
                // The spec claims that static is not permitted, but
                // my very own code has static constructors.
                //
-               public Constructor (string name, Parameters args, ConstructorInitializer init)
-                       : base (name, args)
+               public Constructor (string name, Parameters args, ConstructorInitializer init, Location l)
+                       : base (name, args, l)
                {
                        Initializer = init;
                }
@@ -1129,8 +1178,16 @@ namespace CIR {
                {
                        MethodAttributes ca = (MethodAttributes.RTSpecialName |
                                               MethodAttributes.SpecialName);
+
                        Type [] parameters = ParameterTypes (parent);
-                       
+
+                       if (parent is Struct && parameters == null){
+                               parent.RootContext.Report.Error (
+                                       568, Location, 
+                                       "Structs can not contain explicit parameterless constructors");
+                               return;
+                       }
+
                        if ((ModFlags & Modifiers.STATIC) != 0)
                                ca |= MethodAttributes.Static;
 
@@ -1146,20 +1203,27 @@ namespace CIR {
                //
                public void Emit (TypeContainer parent)
                {
-                       if (Initializer != null)
+                       if (parent is Class){
+                               if (Initializer == null)
+                                       Initializer = new ConstructorBaseInitializer (null, parent.Location);
                                if (!Initializer.Resolve (parent))
                                        return;
+                       }
 
                        ILGenerator ig = ConstructorBuilder.GetILGenerator ();
                        EmitContext ec = new EmitContext (parent, ig);
 
-                       if ((ModFlags & Modifiers.STATIC) == 0)
-                               Initializer.Emit (ec);
+                       //
+                       // Classes can have base initializers and instance field initializers.
+                       //
+                       if (parent is Class){
+                               if ((ModFlags & Modifiers.STATIC) == 0)
+                                       Initializer.Emit (ec);
+                               parent.EmitFieldInitializers (ec, false);
+                       }
                        
                        if ((ModFlags & Modifiers.STATIC) != 0)
                                parent.EmitFieldInitializers (ec, true);
-                       else
-                               parent.EmitFieldInitializers (ec, false);
 
                        ec.EmitTopBlock (Block);
                }
@@ -1507,7 +1571,8 @@ namespace CIR {
                                                               Parameter.Modifier.NONE, null);
                        
                        OperatorMethod = new Method (ReturnType, ModFlags, MethodName,
-                                                    new Parameters (param_list, null), OptAttributes);
+                                                    new Parameters (param_list, null),
+                                                    OptAttributes, null);
                        
                        OperatorMethod.Define (parent);
                        OperatorMethodBuilder = OperatorMethod.MethodBuilder;
index a63bd994814a82887fb949aea9394515ff31100f..95225224426e3cb9d2c1d0ebb9ec58dfd16c93b9 100755 (executable)
@@ -524,7 +524,8 @@ struct_declaration
                Struct new_struct;\r
                string full_struct_name = MakeName ((string) $4);\r
 \r
-               new_struct = new Struct (rc, current_container, full_struct_name, (int) $2, (Attributes) $1);\r
+               new_struct = new Struct (rc, current_container, full_struct_name, (int) $2, \r
+                                        (Attributes) $1, lexer.Location);\r
                current_container = new_struct;\r
                current_container.Namespace = current_namespace;\r
                tree.RecordStruct (full_struct_name, new_struct);\r
@@ -698,7 +699,8 @@ method_header
          member_name\r
          OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS \r
          {\r
-               Method method = new Method ((string) $3, (int) $2, (string) $4, (Parameters) $6, (Attributes) $1);\r
+               Method method = new Method ((string) $3, (int) $2, (string) $4, \r
+                                           (Parameters) $6, (Attributes) $1, lexer.Location);\r
 \r
                current_local_parameters = (Parameters) $6;\r
 \r
@@ -710,7 +712,8 @@ method_header
          member_name\r
          OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS \r
          {\r
-               Method method = new Method ("System.Void", (int) $2, (string) $4, (Parameters) $6, (Attributes) $1);\r
+               Method method = new Method ("System.Void", (int) $2, (string) $4, \r
+                                           (Parameters) $6, (Attributes) $1, lexer.Location);\r
 \r
                current_local_parameters = (Parameters) $6;\r
                $$ = method;\r
@@ -903,7 +906,8 @@ interface_declaration
                Interface new_interface;\r
                string full_interface_name = MakeName ((string) $4);\r
 \r
-               new_interface = new Interface (current_container, full_interface_name, (int) $2, (Attributes) $1);\r
+               new_interface = new Interface (current_container, full_interface_name, (int) $2, \r
+                                              (Attributes) $1, lexer.Location);\r
                if (current_interface != null) {\r
                        Location l = lexer.Location;\r
                        rc.Report.Error (-2, l, "Internal compiler error: interface inside interface");\r
@@ -1164,10 +1168,7 @@ constructor_declaration
                                Location l = lexer.Location;\r
                                rc.Report.Error (103, l, "Static constructors should not have parameters");\r
                        }\r
-               } else {\r
-                       if (c.Initializer == null)\r
-                               c.Initializer = new ConstructorBaseInitializer (null, lexer.Location);\r
-               }\r
+               } \r
                \r
                CheckDef (current_container.AddConstructor (c), c.Name);\r
 \r
@@ -1180,7 +1181,9 @@ constructor_declarator
          OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS \r
          opt_constructor_initializer\r
          {\r
-               $$ = new Constructor ((string) $1, (Parameters) $3, (ConstructorInitializer) $5);\r
+               Location l = lexer.Location;\r
+\r
+               $$ = new Constructor ((string) $1, (Parameters) $3, (ConstructorInitializer) $5, l);\r
        \r
                current_local_parameters = (Parameters) $3;\r
          }\r
@@ -1205,7 +1208,8 @@ constructor_initializer
 destructor_declaration\r
        : opt_attributes TILDE IDENTIFIER OPEN_PARENS CLOSE_PARENS block\r
          {\r
-               Method d = new Method ("System.Void", 0, "Finalize", new Parameters (null, null), (Attributes) $1);\r
+               Method d = new Method ("System.Void", 0, "Finalize", \r
+                                      new Parameters (null, null), (Attributes) $1, lexer.Location);\r
                  \r
                d.Block = (Block) $6;\r
                CheckDef (current_container.AddMethod (d), d.Name);\r
@@ -1336,7 +1340,7 @@ enum_declaration
          opt_semicolon\r
          { \r
                string name = (string) $4;\r
-               Enum e = new Enum ((string) $5, (int) $2, name, (Attributes) $1);\r
+               Enum e = new Enum ((string) $5, (int) $2, name, (Attributes) $1, lexer.Location);\r
 \r
                foreach (VariableDeclaration ev in (ArrayList) $6){\r
                        CheckDef (e.AddEnumMember (ev.identifier, \r
@@ -1403,7 +1407,8 @@ delegate_declaration
          CLOSE_PARENS \r
          SEMICOLON\r
          {\r
-               Delegate del = new Delegate ((string) $4, (int) $2, (string) $5, (Parameters) $7, (Attributes) $1);\r
+               Delegate del = new Delegate ((string) $4, (int) $2, (string) $5, (Parameters) $7, \r
+                                            (Attributes) $1, lexer.Location);\r
 \r
                CheckDef (current_container.AddDelegate (del), del.Name);\r
          }     \r
@@ -1415,7 +1420,8 @@ delegate_declaration
          CLOSE_PARENS \r
          SEMICOLON\r
          {\r
-               Delegate del = new Delegate (null, (int) $2, (string) $5, (Parameters) $7, (Attributes) $1);\r
+               Delegate del = new Delegate (null, (int) $2, (string) $5, (Parameters) $7, \r
+                                            (Attributes) $1, lexer.Location);\r
 \r
                CheckDef (current_container.AddDelegate (del), del.Name);\r
          }\r
@@ -1548,7 +1554,24 @@ real_literal
        ;\r
 \r
 integer_literal\r
-       : LITERAL_INTEGER       { $$ = new IntLiteral ((Int32) lexer.Value); }\r
+       : LITERAL_INTEGER       { \r
+               object v = lexer.Value;\r
+\r
+               // \r
+               // FIXME: Possible optimization would be to \r
+               // compute the *Literal objects directly in the scanner\r
+               //\r
+               if (v is int)\r
+                       $$ = new IntLiteral ((Int32) v); \r
+               else if (v is uint)\r
+                       $$ = new UIntLiteral ((UInt32) v);\r
+               else if (v is long)\r
+                       $$ = new LongLiteral ((Int64) v);\r
+               else if (v is ulong)\r
+                       $$ = new ULongLiteral ((UInt64) v);\r
+               else\r
+                       Console.WriteLine ("OOPS.  Unexpected result from scanner");\r
+         }\r
        ;\r
 \r
 boolean_literal\r
@@ -2169,7 +2192,8 @@ class_declaration
                Class new_class;\r
                string full_class_name = MakeName ((string) $4);\r
 \r
-               new_class = new Class (rc, current_container, full_class_name, (int) $2, (Attributes) $1);\r
+               new_class = new Class (rc, current_container, full_class_name, (int) $2, \r
+                                      (Attributes) $1, lexer.Location);\r
                current_container = new_class;\r
                current_container.Namespace = current_namespace;\r
                tree.RecordClass (full_class_name, new_class);\r
index e1615f79d737ae099db98b7069fff161a98e75de..f27439a557179d8e3b19ae83fa8fe68e3f4aa70e 100755 (executable)
@@ -558,10 +558,27 @@ namespace CIR
 \r
                        if (Char.IsDigit ((char)c)){\r
                                if (c == '0' && peekChar () == 'x' || peekChar () == 'X'){\r
+                                       ulong ul;\r
                                        getChar ();\r
                                        hex_digits (-1);\r
-                                       val = new System.Int32 ();\r
-                                       val = System.Int32.Parse (number.ToString (), NumberStyles.HexNumber);\r
+\r
+                                       string s = number.ToString ();\r
+\r
+                                       ul = System.UInt64.Parse (s, NumberStyles.HexNumber);\r
+                                       if ((ul & 0xffffffff00000000) == 0){\r
+                                               uint ui = (uint) ul;\r
+                                               \r
+                                               if ((ui & 0x80000000) != 0)\r
+                                                       val = ui;\r
+                                               else\r
+                                                       val = (int) ui;\r
+                                       } else {\r
+                                               if ((ul & 0x8000000000000000) != 0)\r
+                                                       val = ul;\r
+                                               else\r
+                                                       val = (long) ul;\r
+                                       }\r
+\r
                                        return integer_type_suffix (peekChar ());\r
                                }\r
                                decimal_digits (c);\r
index 2f09a1ee3160d8f8d1c08026a9aefa2dbfe4638a..ca20802f8dd7993a5c043a89309df69ea0b5cf60 100755 (executable)
@@ -28,6 +28,11 @@ namespace CIR {
                //   created with System.Reflection.Emit
                // </summary>
                TypeBuilder definition;
+
+               // <summary>
+               //   Location where this declaration happens
+               // </summary>
+               public readonly Location Location;
                
                string name, basename;
                
@@ -81,11 +86,12 @@ namespace CIR {
                // </summary>
                protected Hashtable defined_names;
 
-               public DeclSpace (string name)
+               public DeclSpace (string name, Location l)
                {
                        this.name = name;
                        this.basename = name.Substring (1 + name.LastIndexOf ('.'));
                        defined_names = new Hashtable ();
+                       Location = l;
                }
 
                // <summary>
@@ -138,5 +144,12 @@ namespace CIR {
                                definition = value;
                        }
                }
+
        }
 }
+
+
+
+
+
+
index ee920ca6aa7fb4602be79a453f8b5cd16cd65174..78c8520c93b43d03837d00872c1d79a1b0dc1015 100644 (file)
@@ -33,7 +33,7 @@ namespace CIR {
                        Modifiers.PRIVATE;\r
 \r
                public Delegate (string type, int mod_flags, string name, Parameters param_list,\r
-                                Attributes attrs) : base (name)\r
+                                Attributes attrs, Location l) : base (name, l)\r
                {\r
                        this.name       = name;\r
                        this.type       = type;\r
index 217bd9f34f9a56d2d74f3988e3f1daf1b8df6a28..f2ecdaf3042a52ef47f0348ba62e8580f2a493f4 100755 (executable)
@@ -373,6 +373,11 @@ namespace CIR
                        //\r
                        context.TypeManager.InitCoreTypes ();\r
 \r
+                       if (context.Report.Errors > 0){\r
+                               error ("Compilation failed");\r
+                               return;\r
+                       }\r
+                       \r
                        //\r
                        // The code generator\r
                        //\r
index 216746a2198497120b7ef1a9352ff0cd2777533b..18437d9bdb37bbb568c9f31881548a1caff455ea 100755 (executable)
@@ -31,7 +31,8 @@ namespace CIR {
                        Modifiers.INTERNAL |
                        Modifiers.PRIVATE;
 
-               public Enum (string type, int mod_flags, string name, Attributes attrs) : base (name)
+               public Enum (string type, int mod_flags, string name, Attributes attrs, Location l)
+                       : base (name, l)
                {
                        this.type = type;
                        this.name = name;
index 2fd714e59ecd33c2ffd7837a274337828111b349..e54a9616dd653fa7c9c0a652048fb1b05c0deff5 100755 (executable)
@@ -1873,17 +1873,29 @@ namespace CIR {
                                        left = ConvertImplicit (tc, left, TypeManager.float_type, location);
                                type = TypeManager.float_type;
                        } else if (l == TypeManager.uint64_type || r == TypeManager.uint64_type){
+                               Expression e;
+                               Type other;
                                //
                                // If either operand is of type ulong, the other operand is
                                // converted to type ulong.  or an error ocurrs if the other
                                // operand is of type sbyte, short, int or long
                                //
-                               Type other = null;
                                
-                               if (l == TypeManager.uint64_type)
-                                       other = r;
-                               else if (r == TypeManager.uint64_type)
-                                       other = l;
+                               if (l == TypeManager.uint64_type){
+                                       if (r != TypeManager.uint64_type && right is IntLiteral){
+                                               e = TryImplicitIntConversion (l, (IntLiteral) right);
+                                               if (e != null)
+                                                       right = e;
+                                       }
+                                       other = right.Type;
+                               } else {
+                                       if (left is IntLiteral){
+                                               e = TryImplicitIntConversion (r, (IntLiteral) left);
+                                               if (e != null)
+                                                       left = e;
+                                       }
+                                       other = left.Type;
+                               }
 
                                if ((other == TypeManager.sbyte_type) ||
                                    (other == TypeManager.short_type) ||
@@ -1891,7 +1903,7 @@ namespace CIR {
                                    (other == TypeManager.int64_type)){
                                        string oper = OperName ();
                                        
-                                       Error (tc, 34, "Operator `" + OperName ()
+                                       Error (tc, 34, location, "Operator `" + OperName ()
                                               + "' is ambiguous on operands of type `"
                                               + TypeManager.CSharpName (l) + "' "
                                               + "and `" + TypeManager.CSharpName (r)
@@ -1934,7 +1946,7 @@ namespace CIR {
                                        // operand is converd to type uint
                                        //
                                        left = ForceConversion (tc, left, TypeManager.uint32_type);
-                                       right = ForceConversion (tc, left, TypeManager.uint32_type);
+                                       right = ForceConversion (tc, right, TypeManager.uint32_type);
                                        type = TypeManager.uint32_type;
                                } 
                        } else if (l == TypeManager.decimal_type || r == TypeManager.decimal_type){
@@ -1980,6 +1992,7 @@ namespace CIR {
                            ((e = ConvertImplicit (tc, left, TypeManager.int64_type, loc)) != null) ||
                            ((e = ConvertImplicit (tc, left, TypeManager.uint64_type, loc)) != null)){
                                left = e;
+                               type = e.Type;
 
                                return this;
                        }
@@ -2073,6 +2086,7 @@ namespace CIR {
                                if (l != TypeManager.bool_type || r != TypeManager.bool_type)
                                        error19 (tc);
 
+                               type = TypeManager.bool_type;
                                return this;
                        } 
 
@@ -2095,6 +2109,7 @@ namespace CIR {
                                        error19 (tc);
                                        return null;
                                }
+                               type = l;
                        }
 
                        if (oper == Operator.Equality ||
@@ -2118,9 +2133,13 @@ namespace CIR {
                                return null;
 
                        if (left.Type == null)
-                               throw new Exception ("Resolve returned non null, but did not set the type!");
+                               throw new Exception (
+                                       "Resolve returned non null, but did not set the type! (" +
+                                       left + ")");
                        if (right.Type == null)
-                               throw new Exception ("Resolve returned non null, but did not set the type!");
+                               throw new Exception (
+                                       "Resolve returned non null, but did not set the type! (" +
+                                       right + ")");
 
                        eclass = ExprClass.Value;
 
index 1845720e583ea5b6816781e5e482c1fc823af21e..9ce6a7ee21be382c123a73e3fab5784dd0818db7 100755 (executable)
@@ -59,7 +59,8 @@ namespace CIR {
                        Modifiers.INTERNAL |
                        Modifiers.PRIVATE;
 
-               public Interface (TypeContainer parent, string name, int mod, Attributes attrs) : base (name)
+               public Interface (TypeContainer parent, string name, int mod, Attributes attrs, Location l)
+                       : base (name, l)
                {
                        this.mod_flags = Modifiers.Check (AllowedModifiers, mod, Modifiers.PUBLIC);
                        this.parent = parent;
index 97fd0954bea9c595468492fb3abea22addd30236..d4cfa76e978ae60f16b8bdd20b7436c5c840bfb9 100755 (executable)
@@ -285,6 +285,34 @@ namespace CIR {
                }
        }
 
+       public class ULongLiteral : Literal {
+               public readonly ulong Value;
+
+               public ULongLiteral (ulong l)
+               {
+                       Value = l;
+               }
+
+               override public string AsString ()
+               {
+                       return Value.ToString ();
+               }
+
+               public override Expression DoResolve (TypeContainer tc)
+               {
+                       type = TypeManager.uint64_type;
+
+                       return this;
+               }
+
+               public override void Emit (EmitContext ec)
+               {
+                       ILGenerator ig = ec.ig;
+
+                       LongLiteral.EmitLong (ig, unchecked ((long) Value));
+               }
+       }
+       
        public class FloatLiteral : Literal {
                public readonly float Value;
 
index a5dc4d2e5a405515d21a702180f05af9d2ca6eeb..0cc4cafad6f04dce5918ae6febc2f00379b49d1a 100755 (executable)
@@ -157,7 +157,7 @@ namespace CIR {
                public Parameter GetParameterByName (string name, out int idx)
                {
                        idx = 0;
-                       
+
                        if (FixedParameters == null)
                                return null;
 
index 8a1f9f651caa8bd98a58b88827ec7c8833b3aa0c..37203067830e7a5d11235db72bcb1f1ff08594a3 100755 (executable)
@@ -506,7 +506,12 @@ namespace CIR {
                public void CloseTypes ()
                {
                        foreach (TypeBuilder t in TypeManager.UserTypes){
-                               t.CreateType ();
+                               try {
+                                       t.CreateType ();
+                               } catch (Exception e){
+                                       Console.WriteLine ("Caught Exception while creating type for " + t);
+                                       Console.WriteLine (e);
+                               }
                        }
                }
 
@@ -577,7 +582,7 @@ namespace CIR {
                // have been defined through `ResolveTree' 
                public void PopulateTypes ()
                {
-                       Hashtable ifaces, classes;
+                       Hashtable ifaces, classes, structs;
                        
                        if ((ifaces = tree.Interfaces) != null){
                                foreach (DictionaryEntry de in ifaces){
@@ -594,11 +599,19 @@ namespace CIR {
                                        tc.Populate ();
                                }
                        }
+
+                       if ((structs = tree.Structs) != null){
+                               foreach (DictionaryEntry de in structs){
+                                       TypeContainer tc = (TypeContainer) de.Value;
+
+                                       tc.Populate ();
+                               }
+                       }
                }
 
                public void EmitCode ()
                {
-                       Hashtable classes;
+                       Hashtable classes, structs;
                        
                        if ((classes = tree.Classes) != null){
                                foreach (DictionaryEntry de in classes){
@@ -607,6 +620,14 @@ namespace CIR {
                                        tc.Emit ();
                                }
                        }
+
+                       if ((structs = tree.Structs) != null){
+                               foreach (DictionaryEntry de in structs){
+                                       TypeContainer tc = (TypeContainer) de.Value;
+
+                                       tc.Emit ();
+                               }
+                       }
                }
                
                // <summary>
index 4fecbcdc0745f122df611df481909126654fefbb..844ef124d9d2b0fa4075a2c5cc4f3e2dc0b75e3d 100755 (executable)
@@ -57,7 +57,7 @@ namespace CIR
                
                public Tree (RootContext rc)
                {
-                       root_types = new TypeContainer (rc, null, "");
+                       root_types = new TypeContainer (rc, null, "", new Location ("Internal", 1, 1));
                        this.rc = rc;
                }