Flush:
authorMiguel de Icaza <miguel@gnome.org>
Wed, 19 Sep 2001 23:14:09 +0000 (23:14 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 19 Sep 2001 23:14:09 +0000 (23:14 -0000)
svn path=/trunk/mcs/; revision=889

16 files changed:
mcs/mcs/ChangeLog
mcs/mcs/class.cs
mcs/mcs/codegen.cs
mcs/mcs/compiler.csproj
mcs/mcs/compiler.csproj.user
mcs/mcs/cs-parser.jay
mcs/mcs/cs-tokenizer.cs
mcs/mcs/expression.cs
mcs/mcs/literal.cs
mcs/mcs/typemanager.cs
mcs/tests/makefile [new file with mode: 0755]
mcs/tests/test-1.cs [new file with mode: 0755]
mcs/tests/test-2.cs [new file with mode: 0755]
mcs/tests/test-3.cs [new file with mode: 0755]
mcs/tests/test-4.cs [new file with mode: 0755]
mcs/tests/test-5.cs [new file with mode: 0755]

index 95393cd420e5ab0b109c7b545fb6a64eac14b90e..71381dbde35b59dd1178234dd590874478035f09 100755 (executable)
@@ -1,3 +1,19 @@
+2001-09-19  Miguel de Icaza  <miguel@ximian.com>
+
+       * typemanager.cs (TypeManager::CoreLookupType): A function to make sure that we
+       are loading the correct data types (throws an exception if not).
+       (TypeManager::InitCoreTypes): Use CoreLookupType
+
+       * expression.cs (Unary::ResolveOperator): return the child
+       expression for expressions which are just +expr.
+       (Unary::ResolveOperator): Return negative literals for -LITERAL
+       expressions (otherwise they are Unary {Literal}).
+       (Invocation::Badness): Take into account `Implicit constant
+       expression conversions'.
+
+       * literal.cs (LongLiteral): Implement long literal class.
+       (IntLiteral): export the `Value' of the intliteral. 
+
 2001-09-19  Ravi Pratap  <ravi@ximian.com>
 
        * expression.cs (Binary::Emit): Finally get the emission right ! Woo!
index 46763cb98aee35b01a43167fb2c1cde4f471a165..72e087bd44035bb56f93b546794d68da6a221f79 100755 (executable)
@@ -209,7 +209,8 @@ namespace CIR {
                                methods = new ArrayList ();
 
                        methods.Add (method);
-                       DefineName (name, method);
+                       if (value != null)
+                               DefineName (name, method);
 
                        return AdditionResult.Success;
                }
index 0f6cb5caaf777d09020ac5c744238dbd31f79ea2..4d0d801f2672d5afb8714f9d08116afdb0f06bc8 100755 (executable)
@@ -17,6 +17,20 @@ namespace CIR {
                AppDomain current_domain;
                AssemblyBuilder assembly_builder;
                ModuleBuilder   module_builder;
+
+               string Basename (string name)
+               {
+                       int pos = name.LastIndexOf ("/");
+
+                       if (pos != -1)
+                               return name.Substring (pos + 1);
+
+                       pos = name.LastIndexOf ("\\");
+                       if (pos != -1)
+                               return name.Substring (pos + 1);
+
+                       return name;
+               }
                
                public CodeGen (string name, string output)
                {
@@ -26,9 +40,15 @@ namespace CIR {
                        an.Name = "AssemblyName";
                        current_domain = AppDomain.CurrentDomain;
                        assembly_builder = current_domain.DefineDynamicAssembly (
-                                                                                an, AssemblyBuilderAccess.RunAndSave);
-                       
-                       module_builder = assembly_builder.DefineDynamicModule (name, output);
+                               an, AssemblyBuilderAccess.RunAndSave);
+
+                       //
+                       // Pass a path-less name to DefineDynamicModule.  Wonder how
+                       // this copes with output in different directories then.
+                       // FIXME: figure out how this copes with --output /tmp/blah
+                       //
+                       module_builder = assembly_builder.DefineDynamicModule (
+                               Basename (name), Basename (output));
                }
                
                public AssemblyBuilder AssemblyBuilder {
@@ -45,8 +65,10 @@ namespace CIR {
                
                public void Save (Report report, string name)
                {
+                       Console.WriteLine ("This is it " + Basename (name));
+                       
                        try {
-                               assembly_builder.Save (name);
+                               assembly_builder.Save (Basename (name));
                        } catch (System.IO.IOException io){
                                report.Error (16, "Coult not write to file `"+name+"', cause: " + io.Message);
                        }
@@ -91,7 +113,7 @@ namespace CIR {
 
                        if (e == null)
                                return false;
-                       
+
                        if (e.Type != TypeManager.bool_type)
                                e = Expression.ConvertImplicit (e, TypeManager.bool_type);
 
@@ -125,12 +147,9 @@ namespace CIR {
                        Statement false_stat = s.FalseStatement;
                        bool is_ret;
                        
-                       Console.WriteLine ("Emitting IF");
-
                        if (!EmitBoolExpression (s.Expr))
                                return false;
                        
-                       Console.WriteLine ("Ok, so like the bool expression was emitted");
                        ig.Emit (OpCodes.Brfalse, false_target);
                        is_ret = EmitStatement (s.TrueStatement);
 
index 00ee7bc1d09f40c0e6d419e876a3d6608821a658..af06db7a759eb112688caf202585022e2537165f 100755 (executable)
@@ -68,7 +68,7 @@
                 />\r
                 <Reference\r
                     Name = "System.XML"\r
-                    AssemblyName = "System.XML"\r
+                    AssemblyName = "System.Xml"\r
                 />\r
             </References>\r
         </Build>\r
@@ -85,7 +85,7 @@
                     BuildAction = "Compile"\r
                 />\r
                 <File\r
-                    RelPath = "cil-codegen.cs"\r
+                    RelPath = "attribute.cs"\r
                     SubType = "Code"\r
                     BuildAction = "Compile"\r
                 />\r
                     SubType = "Code"\r
                     BuildAction = "Compile"\r
                 />\r
+                <File\r
+                    RelPath = "codegen.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
                 <File\r
                     RelPath = "constant.cs"\r
                     SubType = "Code"\r
                     BuildAction = "Compile"\r
                 />\r
                 <File\r
-                    RelPath = "driver.cs"\r
+                    RelPath = "delegate.cs"\r
                     SubType = "Code"\r
                     BuildAction = "Compile"\r
                 />\r
                 <File\r
-                    RelPath = "enum.cs"\r
+                    RelPath = "driver.cs"\r
                     SubType = "Code"\r
                     BuildAction = "Compile"\r
                 />\r
                 <File\r
-                    RelPath = "errors.cs"\r
+                    RelPath = "enum.cs"\r
                     SubType = "Code"\r
                     BuildAction = "Compile"\r
                 />\r
                     SubType = "Code"\r
                     BuildAction = "Compile"\r
                 />\r
+                <File\r
+                    RelPath = "genericparser.cs"\r
+                    SubType = "Code"\r
+                    BuildAction = "Compile"\r
+                />\r
                 <File\r
                     RelPath = "gen-treedump.cs"\r
                     SubType = "Code"\r
                     BuildAction = "Compile"\r
                 />\r
                 <File\r
-                    RelPath = "tree.cs"\r
+                    RelPath = "support.cs"\r
                     SubType = "Code"\r
                     BuildAction = "Compile"\r
                 />\r
                 <File\r
-                    RelPath = "type.cs"\r
+                    RelPath = "tree.cs"\r
                     SubType = "Code"\r
                     BuildAction = "Compile"\r
                 />\r
index 0c76164add8faa22cda5aab4fcb65811ffa925ea..dbd420d48a1c097fc882e12e740f74618eacdb1e 100755 (executable)
@@ -9,7 +9,7 @@
                     EnableUnmanagedDebugging = "false"\r
                     EnableSQLServerDebugging = "false"\r
                     StartAction = "Project"\r
-                    StartArguments = "i-undefined.cs"\r
+                    StartArguments = "c:\mono\mcs\test\test-4.cs"\r
                     StartPage = ""\r
                     StartProgram = ""\r
                     StartURL = ""\r
index ad2f9014bb141d760d198b44c18dbeac718b2ebd..2884b9426778915ef74efa202d5b9d08a330ffd1 100755 (executable)
@@ -1587,7 +1587,8 @@ invocation_expression
                        Location l = lexer.Location;\r
                        rc.Report.Error (1, l, "THIS IS CRAZY");\r
                }\r
-               $$ = new Invocation ((Expression) $1, (ArrayList) $3);\r
+               $$ = new Invocation ((Expression) $1, (ArrayList) $3, lexer.Location);\r
+               \r
          }\r
        ; \r
 \r
@@ -2597,7 +2598,8 @@ foreach_statement
                foreach_block.AddVariable ((string) $3, (string) $4);\r
                assign_e = new Assign (new LocalVariableReference (foreach_block, temp_id), \r
                                       new Invocation (\r
-                                               new MemberAccess ((Expression) $6, "GetEnumerator"), null));\r
+                                               new MemberAccess ((Expression) $6, "GetEnumerator"), \r
+                                               null, lexer.Location));\r
                current_block.AddStatement (new StatementExpression (assign_e));\r
                ma = new MemberAccess (new LocalVariableReference (foreach_block, temp_id), "MoveNext");\r
                child_block = new Block (current_block);\r
index 6bc7c0d404c30730e6df44a7a52b283d0abeec99..46c643fd3efb6ee7e1f064c42ccfbe2d1fd3d42f 100755 (executable)
@@ -518,7 +518,6 @@ namespace CIR
                {\r
                        string s = number.ToString ();\r
 \r
-                       Console.WriteLine (s);\r
                        switch (t){\r
                        case Token.LITERAL_DECIMAL:\r
                                val = new System.Decimal ();\r
index 7d0fb8a6476134555a555dc43b938f73ebaaef3b..c0cafaa2b6c833208dbcb276bf452a7370ec2cba 100755 (executable)
@@ -643,6 +643,31 @@ namespace CIR {
                                }
                        }
 
+                       //
+                       // A plus in front of something is just a no-op
+                       //
+                       if (oper == Operator.Add)
+                               return expr;
+
+                       //
+                       // Fold -Constant into a negative constant
+                       //make
+                       if (oper == Operator.Subtract){
+                               Expression e = null;
+                               
+                               if (expr is IntLiteral)
+                                       e = new IntLiteral (-((IntLiteral) expr).Value);
+                               else if (expr is LongLiteral)
+                                       e = new LongLiteral (-((LongLiteral) expr).Value);
+                               else if (expr is FloatLiteral)
+                                       e = new FloatLiteral (-((FloatLiteral) expr).Value);
+
+                               if (e != null){
+                                       e = e.Resolve (tc);
+                                       return e;
+                               }
+                       }
+
                        // FIXME : Are we supposed to check that we have an object type
                        // for & and * operators ?
 
@@ -686,8 +711,7 @@ namespace CIR {
 
                        switch (oper){
                        case Operator.Add:
-                               // Which one ?
-                               break;
+                               throw new Exception ("This should be caught by Resolve");
 
                        case Operator.Subtract:
                                // Which one ?
@@ -766,6 +790,7 @@ namespace CIR {
                public override Expression Resolve (TypeContainer tc)
                {
                        // FIXME: Implement;
+                       throw new Exception ("Unimplemented");
                        return this;
                }
 
@@ -801,7 +826,13 @@ namespace CIR {
                
                public override Expression Resolve (TypeContainer tc)
                {
-                       // FIXME: Implement;
+                       type = tc.LookupType (target_type, false);
+                       eclass = ExprClass.Value;
+                       
+                       if (type == null)
+                               return null;
+
+                       // FIXME: Finish this.
                        return this;
                }
 
@@ -1417,6 +1448,8 @@ namespace CIR {
                public override Expression Resolve (TypeContainer tc)
                {
                        // FIXME: Implement;
+                       throw new Exception ("Unimplemented");
+
                        return this;
                }
 
@@ -1559,7 +1592,8 @@ namespace CIR {
                        VariableInfo vi = VariableInfo;
                        ILGenerator ig = ec.ig;
                        int idx = vi.Idx;
-                       
+
+                       Console.WriteLine ("Variable: " + vi);
                        switch (idx){
                        case 0:
                                ig.Emit (OpCodes.Ldloc_0);
@@ -1660,9 +1694,11 @@ namespace CIR {
        // </summary>
        public class Invocation : Expression {
                public readonly ArrayList Arguments;
+               public readonly Location Location;
+               
                Expression expr;
                MethodBase method = null;
-               
+                       
                static Hashtable method_parameter_cache;
 
                static Invocation ()
@@ -1677,10 +1713,11 @@ namespace CIR {
                // FIXME: only allow expr to be a method invocation or a
                // delegate invocation (7.5.5)
                //
-               public Invocation (Expression expr, ArrayList arguments)
+               public Invocation (Expression expr, ArrayList arguments, Location l)
                {
                        this.expr = expr;
                        Arguments = arguments;
+                       Location = l;
                }
 
                public Expression Expr {
@@ -1690,7 +1727,7 @@ namespace CIR {
                }
 
                /// <summary>
-               ///   Computes whether Argument `a' and the ParameterInfo `pi' are
+               ///   Computes whether Argument `a' and the Type t of the  ParameterInfo `pi' are
                ///   compatible, and if so, how good is the match (in terms of
                ///   "better conversions" (7.4.2.3).
                ///
@@ -1700,14 +1737,75 @@ namespace CIR {
                /// </summary>
                static int Badness (Argument a, Type t)
                {
-                       if (a.Expr.Type == null){
+                       Expression argument_expr = a.Expr;
+                       Type argument_type = argument_expr.Type;
+
+                       if (argument_type == null){
                                throw new Exception ("Expression of type " + a.Expr + " does not resolve its type");
                        }
                        
-                       if (t == a.Expr.Type) 
+                       if (t == argument_type) 
                                return 0;
+
+                       //
+                       // Now probe whether an implicit constant expression conversion
+                       // can be used.
+                       //
+                       // An implicit constant expression conversion permits the following
+                       // conversions:
+                       //
+                       //    * A constant-expression of type `int' can be converted to type
+                       //      sbyte, byute, short, ushort, uint, ulong provided the value of
+                       //      of the expression is withing the range of the destination type.
+                       //
+                       //    * A constant-expression of type long can be converted to type
+                       //      ulong, provided the value of the constant expression is not negative
+                       //
+                       // FIXME: Note that this assumes that constant folding has
+                       // taken place.  We dont do constant folding yet.
+                       //
+
+                       if (argument_type == TypeManager.int32_type && argument_expr is IntLiteral){
+                               IntLiteral ei = (IntLiteral) argument_expr;
+                               int value = ei.Value;
+                               
+                               if (t == TypeManager.sbyte_type){
+                                       if (value >= SByte.MinValue && value <= SByte.MaxValue)
+                                               return 1;
+                               } else if (t == TypeManager.byte_type){
+                                       if (Byte.MinValue >= 0 && value <= Byte.MaxValue)
+                                               return 1;
+                               } else if (t == TypeManager.short_type){
+                                       if (value >= Int16.MinValue && value <= Int16.MaxValue)
+                                               return 1;
+                               } else if (t == TypeManager.ushort_type){
+                                       if (value >= UInt16.MinValue && value <= UInt16.MaxValue)
+                                               return 1;
+                               } else if (t == TypeManager.uint32_type){
+                                       //
+                                       // we can optimize this case: a positive int32
+                                       // always fits on a uint32
+                                       //
+                                       if (value >= 0)
+                                               return 1;
+                               } else if (t == TypeManager.uint64_type){
+                                       //
+                                       // we can optimize this case: a positive int32
+                                       // always fits on a uint64
+                                       //
+                                       if (value >= 0)
+                                               return 1;
+                               }
+                       } else if (argument_type == TypeManager.int64_type && argument_expr is LongLiteral){
+                               LongLiteral ll = (LongLiteral) argument_expr;
+                               
+                               if (t == TypeManager.uint64_type){
+                                       if (ll.Value > 0)
+                                               return 1;
+                               }
+                       }
                        
-                       // FIXME: Implement implicit conversions here.
+                       // FIXME: Implement user-defined implicit conversions here.
                        // FIXME: Implement better conversion here.
                        
                        return -1;
@@ -1790,7 +1888,7 @@ namespace CIR {
                                                Argument a = (Argument) Arguments [j];
 
                                                x = Badness (a, pd.ParameterType (j));
-                                               
+
                                                if (x < 0){
                                                        badness = best_match;
                                                        continue;
@@ -1846,7 +1944,7 @@ namespace CIR {
                        method = OverloadResolve ((MethodGroupExpr) this.expr, Arguments);
 
                        if (method == null){
-                               tc.RootContext.Report.Error (-6,
+                               tc.RootContext.Report.Error (-6, Location,
                                "Figure out error: Can not find a good function for this argument list");
                                return null;
                        }
@@ -2040,6 +2138,8 @@ namespace CIR {
                public override Expression Resolve (TypeContainer tc)
                {
                        // FIXME: Implement;
+                       throw new Exception ("Unimplemented");
+
                        return this;
                }
 
@@ -2214,6 +2314,8 @@ namespace CIR {
                public override Expression Resolve (TypeContainer tc)
                {
                        // FIXME: Implement;
+                       throw new Exception ("Unimplemented");
+
                        return this;
                }
 
@@ -2297,7 +2399,8 @@ namespace CIR {
 
                override public void Emit (EmitContext ec)
                {
-                       // FIXME: Implement.
+                       // FIXME: Implement;
+                       throw new Exception ("Unimplemented");
                }
        }
 
@@ -2406,7 +2509,9 @@ namespace CIR {
 
                public override Expression Resolve (TypeContainer tc)
                {
-                       // FIXME : Implement
+                       // FIXME: Implement;
+                       throw new Exception ("Unimplemented");
+
                        return this;
                }
                
@@ -2438,7 +2543,9 @@ namespace CIR {
 
                public override Expression Resolve (TypeContainer tc)
                {
-                       // FIXME : Implement !
+                       // FIXME: Implement;
+                       throw new Exception ("Unimplemented");
+
                        return this;
                }
 
index 43648cb4f99a5e929a793ed4008328ad059e9024..b4904330f2574082aea239c614aea9305b859804 100755 (executable)
@@ -56,6 +56,11 @@ namespace CIR {
                        }
                        return c.ToString ();
                }
+
+               protected Literal ()
+               {
+                       eclass = ExprClass.Value;
+               }
        }
 
        public class NullLiteral : Literal {
@@ -70,9 +75,7 @@ namespace CIR {
 
                public override Expression Resolve (TypeContainer tc)
                {
-                       eclass = ExprClass.Value;
                        type = TypeManager.object_type;
-
                        return this;
                }
 
@@ -97,7 +100,6 @@ namespace CIR {
 
                public override Expression Resolve (TypeContainer tc)
                {
-                       eclass = ExprClass.Value;
                        type = TypeManager.bool_type;
 
                        return this;
@@ -127,7 +129,6 @@ namespace CIR {
 
                public override Expression Resolve (TypeContainer tc)
                {
-                       eclass = ExprClass.Value;
                        type = TypeManager.char_type;
 
                        return this;
@@ -140,21 +141,20 @@ namespace CIR {
        }
 
        public class IntLiteral : Literal {
-               int i;
+               public readonly int Value;
 
                public IntLiteral (int l)
                {
-                       i = l;
+                       Value = l;
                }
 
                override public string AsString ()
                {
-                       return i.ToString ();
+                       return Value.ToString ();
                }
 
                public override Expression Resolve (TypeContainer tc)
                {
-                       eclass = ExprClass.Value;
                        type = TypeManager.int32_type;
 
                        return this;
@@ -164,7 +164,7 @@ namespace CIR {
                {
                        ILGenerator ig = ec.ig;
 
-                       EmitInt (ig, i);
+                       EmitInt (ig, Value);
                }
 
                static public void EmitInt (ILGenerator ig, int i)
@@ -220,22 +220,57 @@ namespace CIR {
                }
        }
 
+       public class LongLiteral : Literal {
+               public readonly long Value;
+
+               public LongLiteral (long l)
+               {
+                       Value = l;
+               }
+
+               override public string AsString ()
+               {
+                       return Value.ToString ();
+               }
+
+               public override Expression Resolve (TypeContainer tc)
+               {
+                       type = TypeManager.int64_type;
+
+                       return this;
+               }
+
+               public override void Emit (EmitContext ec)
+               {
+                       ILGenerator ig = ec.ig;
+
+                       EmitLong (ig, Value);
+               }
+
+               static public void EmitLong (ILGenerator ig, long l)
+               {
+                       if (l >= -1 || l < Int32.MaxValue)
+                               IntLiteral.EmitInt (ig, (int) l);
+                       else
+                               ig.Emit (OpCodes.Ldc_I8, l);
+               }
+       }
+
        public class FloatLiteral : Literal {
-               float f;
+               public readonly float Value;
 
                public FloatLiteral (float f)
                {
-                       this.f = f;
+                       Value = f;
                }
 
                override public string AsString ()
                {
-                       return f.ToString ();
+                       return Value.ToString ();
                }
 
                public override Expression Resolve (TypeContainer tc)
                {
-                       eclass = ExprClass.Value;
                        type = TypeManager.float_type;
 
                        return this;
@@ -243,26 +278,25 @@ namespace CIR {
 
                public override void Emit (EmitContext ec)
                {
-                       ec.ig.Emit (OpCodes.Ldc_R4, f);
+                       ec.ig.Emit (OpCodes.Ldc_R4, Value);
                }
        }
 
        public class DoubleLiteral : Literal {
-               double d;
+               public readonly double Value;
 
                public DoubleLiteral (double d)
                {
-                       this.d = d;
+                       Value = d;
                }
 
                override public string AsString ()
                {
-                       return d.ToString ();
+                       return Value.ToString ();
                }
 
                public override Expression Resolve (TypeContainer tc)
                {
-                       eclass = ExprClass.Value;
                        type = TypeManager.double_type;
 
                        return this;
@@ -270,7 +304,7 @@ namespace CIR {
 
                public override void Emit (EmitContext ec)
                {
-                       ec.ig.Emit (OpCodes.Ldc_R8, d);
+                       ec.ig.Emit (OpCodes.Ldc_R8, Value);
                }
        }
 
@@ -289,7 +323,6 @@ namespace CIR {
 
                public override Expression Resolve (TypeContainer tc)
                {
-                       eclass = ExprClass.Value;
                        type = TypeManager.decimal_type;
 
                        return this;
@@ -316,7 +349,6 @@ namespace CIR {
 
                public override Expression Resolve (TypeContainer tc)
                {
-                       eclass = ExprClass.Value;
                        type = TypeManager.string_type;
 
                        return this;
index efbc6ee2809070ab0afc078c1136b3557222efae..50c8e3b60f4fdfc3b3e5f1af02162fba5dea4a78 100755 (executable)
@@ -100,7 +100,7 @@ public class TypeManager {
                t = (Type) types [name];
                if (t != null)
                        return t;
-               
+
                foreach (Assembly a in assemblies){
                        t = a.GetType (name);
                        if (t != null){
@@ -147,7 +147,17 @@ public class TypeManager {
                else
                        return t.FullName;
        }
-       
+
+       Type CoreLookupType (string name)
+       {
+               Type t = LookupType (name);
+
+               if (t == null)
+                       throw new Exception ("Can not find core type " + name);
+
+               return t;
+       }
+              
        // <remarks>
        //   The types have to be initialized after the initial
        //   population of the type has happened (for example, to
@@ -155,20 +165,21 @@ public class TypeManager {
        // </remarks>
        public void InitCoreTypes ()
        {
-               object_type  = LookupType ("System.Object");
-               string_type  = LookupType ("System.String");
-               int32_type   = LookupType ("System.Int32");
-               int64_type   = LookupType ("System.Int64");
-               uint32_type  = LookupType ("System.UInt32"); 
-               uint64_type  = LookupType ("System.UInt64"); 
-               float_type   = LookupType ("System.Single");
-               double_type  = LookupType ("System.Double");
-               byte_type    = LookupType ("System.Byte");
-               sbyte_type   = LookupType ("System.SByte");
-               char_type    = LookupType ("System.Char");
-               short_type   = LookupType ("System.Short");
-               decimal_type = LookupType ("System.Decimal");
-               bool_type    = LookupType ("System.Bool");
+               object_type  = CoreLookupType ("System.Object");
+               string_type  = CoreLookupType ("System.String");
+               int32_type   = CoreLookupType ("System.Int32");
+               int64_type   = CoreLookupType ("System.Int64");
+               uint32_type  = CoreLookupType ("System.UInt32"); 
+               uint64_type  = CoreLookupType ("System.UInt64"); 
+               float_type   = CoreLookupType ("System.Single");
+               double_type  = CoreLookupType ("System.Double");
+               byte_type    = CoreLookupType ("System.Byte");
+               sbyte_type   = CoreLookupType ("System.SByte");
+               char_type    = CoreLookupType ("System.Char");
+               short_type   = CoreLookupType ("System.Int16");
+               ushort_type  = CoreLookupType ("System.UInt16");
+               decimal_type = CoreLookupType ("System.Decimal");
+               bool_type    = CoreLookupType ("System.Boolean");
        }
        
        public MemberInfo [] FindMembers (Type t, MemberTypes mt, BindingFlags bf, MemberFilter filter, object criteria)
diff --git a/mcs/tests/makefile b/mcs/tests/makefile
new file mode 100755 (executable)
index 0000000..37c9f32
--- /dev/null
@@ -0,0 +1,15 @@
+TEST_SOURCES = \
+       test-1 test-2 test-3
+
+test-compiler:
+       for i in $(TEST_SOURCES); do \
+               if ../mcs/compiler $$i.cs > /dev/null; then \
+                       if ./$$i.exe; then \
+                               echo $$i: ok; \
+                       else \
+                               echo failed; \
+                       fi; \
+               else \
+                       echo compiler failed on $$i;   \
+               fi \
+       done
diff --git a/mcs/tests/test-1.cs b/mcs/tests/test-1.cs
new file mode 100755 (executable)
index 0000000..adb1dd8
--- /dev/null
@@ -0,0 +1,9 @@
+using System;
+
+class X {
+       static int Main (string [] args)
+       {
+               Console.WriteLine ("Hello, World!");
+               return 0;
+       }
+}
diff --git a/mcs/tests/test-2.cs b/mcs/tests/test-2.cs
new file mode 100755 (executable)
index 0000000..950a2f2
--- /dev/null
@@ -0,0 +1,6 @@
+class X {
+       static int Main (string [] args)
+       {
+               System.Console.WriteLine ("Hello, World");
+       }
+}
diff --git a/mcs/tests/test-3.cs b/mcs/tests/test-3.cs
new file mode 100755 (executable)
index 0000000..5e7d4e1
--- /dev/null
@@ -0,0 +1,62 @@
+
+public class TestIntOps {
+
+       public static sbyte sbyte_add (sbyte a, sbyte b) {
+               return (sbyte)(a+b);
+       }
+
+       public static short short_add (short a, short b) {
+               return (short)(a+b);
+       }
+
+       public static double double_add (double a, double b) {
+               return a+b;
+       }
+
+       public static int int_add (int a, int b) {
+               return a+b;
+       }
+
+       public static int int_sub (int a, int b) {
+               return a-b;
+       }
+       
+       public static int int_mul (int a, int b) {
+               return a*b;
+       }
+       
+       public static int Main() {
+               int num = 1;
+
+               if (int_add (1, 1)   != 2)  return num;
+               num++;
+
+               if (int_add (31, -1) != 30) return num;
+               num++;
+
+               if (int_sub (31, -1) != 32) return num;
+               num++;
+
+               if (int_mul (12, 12) != 144) return num;
+               num++;
+
+               if (sbyte_add (1, 1) != 2)  return num;
+               num++;
+               
+               if (sbyte_add (31, -1) != 30)  return num;
+               num++;
+               
+               if (short_add (1, 1) != 2)  return num;
+               num++;
+               
+               if (short_add (31, -1) != 30)  return num;
+               num++;
+               
+               if (double_add (1.5, 1.5) != 3)  return num;
+               num++;
+
+               // add more meaningful tests
+       
+       return 0;
+       }
+}
diff --git a/mcs/tests/test-4.cs b/mcs/tests/test-4.cs
new file mode 100755 (executable)
index 0000000..ab1fb3e
--- /dev/null
@@ -0,0 +1,40 @@
+using System;
+class X {
+       bool sbyte_selected;
+       bool int_selected;
+
+       void test (sbyte s)
+       {
+               sbyte_selected = true;
+       }
+
+       void test (int i)
+       {
+               int_selected = true;
+       }
+
+       static int Main ()
+       {
+               X x = new X ();
+
+               x.test (1); 
+               if (x.sbyte_selected){
+                       Console.WriteLine ("FAILED: Sbyte selected on constant int argument");
+                       return 1;
+               } else {
+                       Console.WriteLine ("OK: int selected for constant constant int");
+               }
+               
+               X y = new X ();
+               sbyte s = 10;
+
+               y.test (s);
+               if (y.sbyte_selected){
+                       Console.WriteLine ("OK: sbyte selected for sbyte argument");
+               } else {
+                       Console.WriteLine ("FAILED: sbyte not selected for sbyte argument");
+                       return 1;
+               }
+               return 0;
+       }
+}              
diff --git a/mcs/tests/test-5.cs b/mcs/tests/test-5.cs
new file mode 100755 (executable)
index 0000000..80c0326
--- /dev/null
@@ -0,0 +1,30 @@
+using System;
+class X {
+       bool sbyte_selected;
+       bool int_selected;
+
+       void test (sbyte s)
+       {
+               sbyte_selected = true;
+       }
+
+       void test (int i)
+       {
+               int_selected = true;
+       }
+
+       static int Main ()
+       {
+               X y = new X ();
+               sbyte s = 10;
+
+               y.test (s);
+               if (y.sbyte_selected){
+                       Console.WriteLine ("OK: sbyte selected for sbyte argument");
+               } else {
+                       Console.WriteLine ("FAILED: sbyte not selected for sbyte argument");
+                       return 1;
+               }
+               return 0;
+       }
+}