2004-08-07 Anirban Bhattacharjee <banirban@novell.com>
[mono.git] / mcs / mbas / expression.cs
index 0baa58b9413334176c14d18085672ed46954415c..492632b2dd384ea85e1069a058b9794a4ce18f9b 100644 (file)
@@ -9,7 +9,7 @@
 //
 #define USE_OLD
 
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
        using System;
        using System.Collections;
        using System.Reflection;
@@ -142,8 +142,8 @@ namespace Mono.CSharp {
                {
                        Error (
                                23, "Operator " + OperName (Oper) +
-                               " cannot be applied to operand of type `" +
-                               TypeManager.CSharpName (t) + "'");
+                               " cannot be applied to operand of type '" +
+                               TypeManager.MonoBASIC_Name (t) + "'");
                }
 
                /// <remarks>
@@ -189,7 +189,7 @@ namespace Mono.CSharp {
 
                // <summary>
                //   This routine will attempt to simplify the unary expression when the
-               //   argument is a constant.  The result is returned in `result' and the
+               //   argument is a constant.  The result is returned in 'result' and the
                //   function returns true or false depending on whether a reduction
                //   was performed or not
                // </summary>
@@ -445,7 +445,7 @@ namespace Mono.CSharp {
 
                                if (expr_type == TypeManager.uint64_type){
                                        //
-                                       // FIXME: Handle exception of `long value'
+                                       // FIXME: Handle exception of 'long value'
                                        // -92233720368547758087 (-2^63) to be wrote as
                                        // decimal integer literal.
                                        //
@@ -484,7 +484,7 @@ namespace Mono.CSharp {
                        }
 
                        Error (187, "No such operator '" + OperName (Oper) + "' defined for type '" +
-                              TypeManager.CSharpName (expr_type) + "'");
+                              TypeManager.MonoBASIC_Name (expr_type) + "'");
                        return null;
                }
 
@@ -538,7 +538,7 @@ namespace Mono.CSharp {
                }
 
                /// <summary>
-               ///   This will emit the child expression for `ec' avoiding the logical
+               ///   This will emit the child expression for 'ec' avoiding the logical
                ///   not.  The parent will take care of changing brfalse/brtrue
                /// </summary>
                public void EmitLogicalNot (EmitContext ec)
@@ -658,7 +658,7 @@ namespace Mono.CSharp {
        /// classes (indexers require temporary access;  overloaded require method)
        ///
        /// Maybe we should have classes PreIncrement, PostIncrement, PreDecrement,
-       /// PostDecrement, that way we could save the `Mode' byte as well.  
+       /// PostDecrement, that way we could save the 'Mode' byte as well.  
        /// </remarks>
        public class UnaryMutator : ExpressionStatement {
                public enum Mode : byte {
@@ -691,12 +691,12 @@ namespace Mono.CSharp {
                {
                        Error (
                                23, "Operator " + OperName (mode) + 
-                               " cannot be applied to operand of type `" +
-                               TypeManager.CSharpName (t) + "'");
+                               " cannot be applied to operand of type '" +
+                               TypeManager.MonoBASIC_Name (t) + "'");
                }
 
                /// <summary>
-               ///   Returns whether an object of type `t' can be incremented
+               ///   Returns whether an object of type 't' can be incremented
                ///   or decremented with add/sub (ie, basically whether we can
                ///   use pre-post incr-decr operations on it, but it is not a
                ///   System.Decimal, which we require operator overloading to catch)
@@ -781,7 +781,7 @@ namespace Mono.CSharp {
                        }
 
                        Error (187, "No such operator '" + OperName (mode) + "' defined for type '" +
-                              TypeManager.CSharpName (expr_type) + "'");
+                              TypeManager.MonoBASIC_Name (expr_type) + "'");
                        return null;
                }
 
@@ -948,11 +948,11 @@ namespace Mono.CSharp {
        }
 
        /// <summary>
-       ///   Base class for the `Is' and `As' classes. 
+       ///   Base class for the 'Is' and 'As' classes. 
        /// </summary>
        ///
        /// <remarks>
-       ///   FIXME: Split this in two, and we get to save the `Operator' Oper
+       ///   FIXME: Split this in two, and we get to save the 'Operator' Oper
        ///   size. 
        /// </remarks>
        public abstract class Probe : Expression {
@@ -987,7 +987,7 @@ namespace Mono.CSharp {
        }
 
        /// <summary>
-       ///   Implementation of the `is' operator.
+       ///   Implementation of the 'is' operator.
        /// </summary>
        public class Is : Probe {
                public Is (Expression expr, Expression probe_type, Location l)
@@ -1018,7 +1018,7 @@ namespace Mono.CSharp {
                                IntConstant.EmitInt (ig, 1);
                                return;
                        case Action.LeaveOnStack:
-                               // the `e != null' rule.
+                               // the 'e != null' rule.
                                return;
                        case Action.Probe:
                                ig.Emit (OpCodes.Isinst, probe_type);
@@ -1073,14 +1073,14 @@ namespace Mono.CSharp {
                                if (warning_always_matches)
                                        Warning (
                                                183,
-                                               "The expression is always of type `" +
-                                               TypeManager.CSharpName (probe_type) + "'");
+                                               "The expression is always of type '" +
+                                               TypeManager.MonoBASIC_Name (probe_type) + "'");
                                else if (warning_never_matches){
                                        if (!(probe_type.IsInterface || expr.Type.IsInterface))
                                                Warning (
                                                        184,
-                                                       "The expression is never of type `" +
-                                                       TypeManager.CSharpName (probe_type) + "'");
+                                                       "The expression is never of type '" +
+                                                       TypeManager.MonoBASIC_Name (probe_type) + "'");
                                }
                        }
 
@@ -1089,7 +1089,7 @@ namespace Mono.CSharp {
        }
 
        /// <summary>
-       ///   Implementation of the `as' operator.
+       ///   Implementation of the 'as' operator.
        /// </summary>
        public class As : Probe {
                public As (Expression expr, Expression probe_type, Location l)
@@ -1112,9 +1112,9 @@ namespace Mono.CSharp {
                static void Error_CannotConvertType (Type source, Type target, Location loc)
                {
                        Report.Error (
-                               39, loc, "as operator can not convert from `" +
-                               TypeManager.CSharpName (source) + "' to `" +
-                               TypeManager.CSharpName (target) + "'");
+                               39, loc, "as operator can not convert from '" +
+                               TypeManager.MonoBASIC_Name (source) + "' to '" +
+                               TypeManager.MonoBASIC_Name (target) + "'");
                }
                
                public override Expression DoResolve (EmitContext ec)
@@ -1130,7 +1130,7 @@ namespace Mono.CSharp {
 
                        if (TypeManager.IsValueType (probe_type)){
                                Report.Error (77, loc, "The as operator should be used with a reference type only (" +
-                                             TypeManager.CSharpName (probe_type) + " is a value type");
+                                             TypeManager.MonoBASIC_Name (probe_type) + " is a value type)");
                                return null;
                        
                        }
@@ -1161,12 +1161,14 @@ namespace Mono.CSharp {
        public class Cast : Expression {
                Expression target_type;
                Expression expr;
+               bool runtime_cast;
                        
                public Cast (Expression cast_type, Expression expr, Location loc)
                {
                        this.target_type = cast_type;
                        this.expr = expr;
                        this.loc = loc;
+                       runtime_cast = false;
                }
 
                public Expression TargetType {
@@ -1184,6 +1186,16 @@ namespace Mono.CSharp {
                        }
                }
 
+               public bool IsRuntimeCast\r
+               {
+                       get {
+                               return runtime_cast;
+                       }
+                       set{
+                               runtime_cast = value;
+                       }
+               }
+
                /// <summary>
                ///   Attempts to do a compile-time folding of a constant cast.
                /// </summary>
@@ -1462,7 +1474,7 @@ namespace Mono.CSharp {
                        int errors = Report.Errors;
 
                        type = ec.DeclSpace.ResolveType (target_type, false, Location);
-                       
+
                        if (type == null)
                                return null;
 
@@ -1475,7 +1487,7 @@ namespace Mono.CSharp {
                                        return e;
                        }
                        
-                       expr = ConvertExplicit (ec, expr, type, loc);
+                       expr = ConvertExplicit (ec, expr, type, runtime_cast, loc);
                        return expr;
                }
 
@@ -1639,16 +1651,16 @@ namespace Mono.CSharp {
                        if (expr.Type == target_type)
                                return expr;
 
-                       return ConvertImplicit (ec, expr, target_type, new Location (-1));
+                       return ConvertImplicit (ec, expr, target_type, Location.Null);
                }
 
                public static void Error_OperatorAmbiguous (Location loc, Operator oper, Type l, Type r)
                {
                        Report.Error (
-                               34, loc, "Operator `" + OperName (oper) 
-                               + "' is ambiguous on operands of type `"
-                               + TypeManager.CSharpName (l) + "' "
-                               + "and `" + TypeManager.CSharpName (r)
+                               34, loc, "Operator '" + OperName (oper) 
+                               + "' is ambiguous on operands of type '"
+                               + TypeManager.MonoBASIC_Name (l) + "' "
+                               + "and '" + TypeManager.MonoBASIC_Name (r)
                                + "'");
                }
 
@@ -1813,9 +1825,9 @@ namespace Mono.CSharp {
                static public void Error_OperatorCannotBeApplied (Location loc, string name, Type l, Type r)
                {
                        Report.Error (19, loc,
-                              "Operator " + name + " cannot be applied to operands of type `" +
-                              TypeManager.CSharpName (l) + "' and `" +
-                              TypeManager.CSharpName (r) + "'");
+                              "Operator " + name + " cannot be applied to operands of type '" +
+                              TypeManager.MonoBASIC_Name (l) + "' and '" +
+                              TypeManager.MonoBASIC_Name (r) + "'");
                }
                
                void Error_OperatorCannotBeApplied ()
@@ -2302,7 +2314,7 @@ namespace Mono.CSharp {
                ///   context of a conditional bool expression.  This function will return
                ///   false if it is was possible to use EmitBranchable, or true if it was.
                ///
-               ///   The expression's code is generated, and we will generate a branch to `target'
+               ///   The expression's code is generated, and we will generate a branch to 'target'
                ///   if the resulting expression value is equal to isTrue
                /// </remarks>
                public bool EmitBranchable (EmitContext ec, Label target, bool onTrue)
@@ -2610,7 +2622,7 @@ namespace Mono.CSharp {
                bool is_add;
 
                //
-               // We assume that `l' is always a pointer
+               // We assume that 'l' is always a pointer
                //
                public PointerArithmetic (bool is_addition, Expression l, Expression r, Type t,
                                          Location loc)
@@ -2752,8 +2764,8 @@ namespace Mono.CSharp {
                                        if (ConvertImplicit (ec, falseExpr, true_type, loc) != null){
                                                Error (172,
                                                       "Can not compute type of conditional expression " +
-                                                      "as `" + TypeManager.CSharpName (trueExpr.Type) +
-                                                      "' and `" + TypeManager.CSharpName (falseExpr.Type) +
+                                                      "as '" + TypeManager.MonoBASIC_Name (trueExpr.Type) +
+                                                      "' and '" + TypeManager.MonoBASIC_Name (falseExpr.Type) +
                                                       "' convert implicitly to each other");
                                                return null;
                                        }
@@ -2765,8 +2777,8 @@ namespace Mono.CSharp {
                                } else {
                                        Error (173, "The type of the conditional expression can " +
                                               "not be computed because there is no implicit conversion" +
-                                              " from `" + TypeManager.CSharpName (trueExpr.Type) + "'" +
-                                              " and `" + TypeManager.CSharpName (falseExpr.Type) + "'");
+                                              " from '" + TypeManager.MonoBASIC_Name (trueExpr.Type) + "'" +
+                                              " and '" + TypeManager.MonoBASIC_Name (falseExpr.Type) + "'");
                                        return null;
                                }
                        }
@@ -2816,7 +2828,7 @@ namespace Mono.CSharp {
                        eclass = ExprClass.Variable;
                }
 
-               // Setting `is_readonly' to false will allow you to create a writable
+               // Setting 'is_readonly' to false will allow you to create a writable
                // reference to a read-only variable.  This is used by foreach and using.
                public LocalVariableReference (Block block, string name, Location l,
                                               VariableInfo variable_info, bool is_readonly)
@@ -2897,7 +2909,7 @@ namespace Mono.CSharp {
                                return null;
 
                        if (is_readonly){
-                               Error (1604, "cannot assign to `" + Name + "' because it is readonly");
+                               Error (1604, "cannot assign to '" + Name + "' because it is readonly");
                                return null;
                        }
                        
@@ -2960,7 +2972,7 @@ namespace Mono.CSharp {
 
                        if (!ec.CurrentBranching.IsParameterAssigned (idx)) {
                                Report.Error (165, loc,
-                                             "Use of unassigned local variable `" + name + "'");
+                                             "Use of unassigned local variable '" + name + "'");
                                return false;
                        }
 
@@ -2977,7 +2989,7 @@ namespace Mono.CSharp {
 
                        if (!ec.CurrentBranching.IsParameterAssigned (idx, field_name)) {
                                Report.Error (170, loc,
-                                             "Use of possibly unassigned field `" + field_name + "'");
+                                             "Use of possibly unassigned field '" + field_name + "'");
                                return false;
                        }
 
@@ -3129,155 +3141,17 @@ namespace Mono.CSharp {
                }
        }
        
-       /// <summary>
-       ///   Used for arguments to New(), Invocation()
-       /// </summary>
-       public class Argument {
-               public enum AType : byte {
-                       Expression,
-                       Ref,
-                       Out,
-                       NoArg
-               };
-
-               public AType ArgType;
-               public Expression Expr;
-               
-               public Argument (Expression expr, AType type)
-               {
-                       this.Expr = expr;
-                       this.ArgType = type;
-               }
-
-               public Type Type {
-                       get {
-                               if (ArgType == AType.Ref || ArgType == AType.Out)
-                                       return TypeManager.LookupType (Expr.Type.ToString () + "&");
-                               else
-                                       return Expr.Type;
-                       }
-               }
-
-               public Parameter.Modifier GetParameterModifier ()
-               {
-                       switch (ArgType) {
-                       case AType.Out:
-                               return Parameter.Modifier.OUT | Parameter.Modifier.ISBYREF;
-
-                       case AType.Ref:
-                               return Parameter.Modifier.REF | Parameter.Modifier.ISBYREF;
-
-                       default:
-                               return Parameter.Modifier.NONE;
-                       }
-               }
-
-               public static string FullDesc (Argument a)
-               {
-                       return (a.ArgType == AType.Ref ? "ref " :
-                               (a.ArgType == AType.Out ? "out " : "")) +
-                               TypeManager.CSharpName (a.Expr.Type);
-               }
-
-               public bool ResolveMethodGroup (EmitContext ec, Location loc)
-               {
-                       // FIXME: csc doesn't report any error if you try to use `ref' or
-                       //        `out' in a delegate creation expression.
-                       Expr = Expr.Resolve (ec, ResolveFlags.VariableOrValue | ResolveFlags.MethodGroup);
-                       if (Expr == null)
-                               return false;
-
-                       return true;
-               }
-
-               public bool Resolve (EmitContext ec, Location loc)
-               {
-                       // Optional void arguments - MyCall (1,,2) - are resolved later
-                       // in VerifyArgsCompat
-                       if (ArgType == AType.NoArg || ArgType == AType.Ref) 
-                       {
-                               return true;                            
-                       }
-/*
-                       if (ArgType == AType.Ref) {
-                               Expr = Expr.Resolve (ec);
-                               if (Expr == null)
-                                       return false;
-
-                               Expr = Expr.ResolveLValue (ec, Expr);
-                       } else */if (ArgType == AType.Out)
-                               Expr = Expr.ResolveLValue (ec, new EmptyExpression ());
-                       else
-                               Expr = Expr.Resolve (ec);
-
-
-                       if (Expr == null)
-                               return false;
-
-                       if (ArgType == AType.Expression)
-                               return true;
-
-                       if (Expr.eclass != ExprClass.Variable){
-                               //
-                               // We just probe to match the CSC output
-                               //
-                               if (Expr.eclass == ExprClass.PropertyAccess ||
-                                   Expr.eclass == ExprClass.IndexerAccess){
-                                       Report.Error (
-                                               206, loc,
-                                               "A property or indexer can not be passed as an out or ref " +
-                                               "parameter");
-                               } else {
-                                       Report.Error (
-                                               1510, loc,
-                                               "An lvalue is required as an argument to out or ref");
-                               }
-                               return false;
-                       }
-                               
-                       return true;
-               }
-
-               public void Emit (EmitContext ec)
-               {
-                       //
-                       // Ref and Out parameters need to have their addresses taken.
-                       //
-                       // ParameterReferences might already be references, so we want
-                       // to pass just the value
-                       //
-                       if (ArgType == AType.Ref || ArgType == AType.Out){
-                               AddressOp mode = AddressOp.Store;
-
-                               if (ArgType == AType.Ref)
-                                       mode |= AddressOp.Load;
-                               
-                               if (Expr is ParameterReference){
-                                       ParameterReference pr = (ParameterReference) Expr;
-
-                                       if (pr.is_ref)
-                                               pr.EmitLoad (ec);
-                                       else {
-                                               
-                                               pr.AddressOf (ec, mode);
-                                       }
-                               } else
-                                       ((IMemoryLocation)Expr).AddressOf (ec, mode);
-                       } else
-                               Expr.Emit (ec);
-               }
-       }
-
+       
        /// <summary>
        ///   Invocation of methods or delegates.
        /// </summary>
        public class Invocation : ExpressionStatement {
                public ArrayList Arguments;
 
-               Expression expr;
+               public Expression expr;
                MethodBase method = null;
                bool is_base;
-
+               bool is_left_hand; // Needed for late bound calls
                static Hashtable method_parameter_cache;
                static MemberFilter CompareName;
 
@@ -3309,7 +3183,7 @@ namespace Mono.CSharp {
 
                /// <summary>
                ///   Returns the Parameters (a ParameterData interface) for the
-               ///   Method `mb'
+               ///   Method 'mb'
                /// </summary>
                public static ParameterData GetParameterData (MethodBase mb)
                {
@@ -3372,7 +3246,7 @@ namespace Mono.CSharp {
                        // An implicit constant expression conversion permits the following
                        // conversions:
                        //
-                       //    * A constant-expression of type `int' can be converted to type
+                       //    * 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.
                        //
@@ -3560,7 +3434,7 @@ namespace Mono.CSharp {
                        string ret_type = "";
 
                        if (mb is MethodInfo)
-                               ret_type = TypeManager.CSharpName (((MethodInfo) mb).ReturnType) + " ";
+                               ret_type = TypeManager.MonoBASIC_Name (((MethodInfo) mb).ReturnType) + " ";
                        
                        StringBuilder sb = new StringBuilder (ret_type + mb.Name);
                        ParameterData pd = GetParameterData (mb);
@@ -3711,8 +3585,8 @@ namespace Mono.CSharp {
                                ~(Parameter.Modifier.OUT | Parameter.Modifier.REF);
 
                        if (a_mod == p_mod || (a_mod == Parameter.Modifier.NONE && p_mod == Parameter.Modifier.PARAMS)) {
-                               if (a_mod == Parameter.Modifier.NONE)
-                                       if (!ImplicitConversionExists (ec, a.Expr, ptype))
+                               if (a_mod == Parameter.Modifier.NONE)   
+                                       if (! (ImplicitConversionExists (ec, a.Expr, ptype) || RuntimeConversionExists (ec, a.Expr, ptype)) )
                                                return false;
                                
                                if ((a_mod & Parameter.Modifier.ISBYREF) != 0) {
@@ -3725,8 +3599,7 @@ namespace Mono.CSharp {
                                                return false;
                                }
                        } else
-                               return false;           
-                               
+                               return false;                                   
                        return true;                                    
                }
                
@@ -3746,13 +3619,11 @@ namespace Mono.CSharp {
 
                        ParameterData pd = GetParameterData (candidate);
                        Parameters ps = GetFullParameters (candidate);
-                       
                        if (ps == null) {
                                ps_count = 0;
                                po_count = 0;
                        }
-                       else
-                       {
+                       else {
                                ps_count = ps.CountStandardParams();                    
                                po_count = ps.CountOptionalParams();
                        }
@@ -3763,8 +3634,7 @@ namespace Mono.CSharp {
                                if (arg_count != pd.Count)
                                        return false;
                        }
-                       else
-                       {
+                       else {
                                if ((arg_count < ps_count) || (arg_count > pd_count))
                                        return false;   
                        }       
@@ -3774,33 +3644,59 @@ namespace Mono.CSharp {
                                        i--;
 
                                        Argument a = (Argument) arguments [i];
-                                       if (a.ArgType == Argument.AType.NoArg)
-                                       {
+                                       if (a.ArgType == Argument.AType.NoArg) {
                                                Parameter p = (Parameter) ps.FixedParameters[i];
                                                a = new Argument (p.ParameterInitializer, Argument.AType.Expression);
                                                param_type = p.ParameterInitializer.Type;
                                        }
-                                       else 
-                                       {
+                                       else {
                                                param_type = pd.ParameterType (i);
+                                               Parameter.Modifier mod;
                                                if (ps != null) {
                                                        Parameter p = (Parameter) ps.FixedParameters[i];
-                                                       
-                                                       if ((p.ModFlags & Parameter.Modifier.REF) != 0) 
-                                                       {
-                                                               a = new Argument (a.Expr, Argument.AType.Ref);
-                                                               if (!a.Resolve(ec,Location.Null))
+                                                       bool IsDelegate = TypeManager.IsDelegateType (param_type);
+
+                                                       if (IsDelegate) {       
+                                                               if (a.ArgType == Argument.AType.AddressOf) {
+                                                                       a = new Argument ((Expression) a.Expr, Argument.AType.Expression);
+                                                                       ArrayList args = new ArrayList();
+                                                                       args.Add (a);
+                                                                       string param_name = pd.ParameterDesc(i).Replace('+', '.');
+                                                                       Expression pname = MonoBASIC.Parser.DecomposeQI (param_name, Location.Null);
+
+
+                                                                       New temp_new = new New ((Expression)pname, args, Location.Null);
+                                                                       Expression del_temp = temp_new.DoResolve(ec);
+
+                                                                       if (del_temp == null)
+                                                                               return false;
+
+                                                                       a = new Argument (del_temp, Argument.AType.Expression);
+                                                                       if (!a.Resolve(ec, Location.Null))\r
+                                                                               return false;
+                                                               }
+                                                       }
+                                                       else {
+                                                               if (a.ArgType == Argument.AType.AddressOf)
                                                                        return false;
                                                        }
+
+                                                       mod = p.ModFlags;
+                                               } else
+                                                       mod = pd.ParameterModifier (i);
+
+                                               if ((mod & Parameter.Modifier.REF) != 0) {
+                                                       a = new Argument (a.Expr, Argument.AType.Ref);
+                                                       if (!a.Resolve(ec,Location.Null))
+                                                               return false;
                                                }
                                        }       
-       
+\r
                                        if (!CheckParameterAgainstArgument (ec, pd, i, a, param_type))
                                                return (false);
                                }
                        }
-                       else
-                       {
+                       else {
                                // If we have no arguments AND the first parameter is optional
                                // we must check for a candidate (the loop above wouldn't)      
                                if (po_count > 0) {
@@ -3823,6 +3719,7 @@ namespace Mono.CSharp {
                        }
                        // We've found a candidate, so we exchange the dummy NoArg arguments
                        // with new arguments containing the default value for that parameter
+
                        ArrayList newarglist = new ArrayList();
                        for (int i = 0; i < arg_count; i++) {
                                Argument a = (Argument) arguments [i];
@@ -3834,19 +3731,44 @@ namespace Mono.CSharp {
                                if (a.ArgType == Argument.AType.NoArg){
                                        a = new Argument (p.ParameterInitializer, Argument.AType.Expression);
                                        a.Resolve(ec, Location.Null);
-                               }               
-                               
-                               if ((p != null) && ((p.ModFlags & Parameter.Modifier.REF) != 0))
-                               {
+                               }
+
+                               // ToDo - This part is getting resolved second time within this function
+                               // This is a costly operation
+                               // The earlier resoved result should be used here.
+                               // Has to be done during compiler optimization.
+                               if (a.ArgType == Argument.AType.AddressOf) {
+                                       param_type = pd.ParameterType (i);
+                                       bool IsDelegate = TypeManager.IsDelegateType (param_type);
+
+                                       a = new Argument ((Expression) a.Expr, Argument.AType.Expression);
+                                       ArrayList args = new ArrayList();
+                                       args.Add (a);
+                                       string param_name = pd.ParameterDesc(i).Replace('+', '.');
+                                       Expression pname = MonoBASIC.Parser.DecomposeQI (param_name, Location.Null);
+                                                               
+                                       New temp_new = new New ((Expression)pname, args, Location.Null);
+                                       Expression del_temp = temp_new.DoResolve(ec);
+
+                                       if (del_temp == null)
+                                               return false;
+
+                                       a = new Argument (del_temp, Argument.AType.Expression);
+                                       if (!a.Resolve(ec, Location.Null))\r
+                                               return false;
+                               }
+
+                               if ((p != null) && ((p.ModFlags & Parameter.Modifier.REF) != 0)) {
+                                       a.ArgType = Argument.AType.Ref;
+                                       a.Resolve(ec, Location.Null);
+                               } else if ((pd.ParameterModifier (i) & Parameter.Modifier.REF) != 0) {
                                        a.ArgType = Argument.AType.Ref;
                                        a.Resolve(ec, Location.Null);
                                }       
                                newarglist.Add(a);
                                int n = pd_count - arg_count;
-                               if (n > 0) 
-                               {
-                                       for (int x = 0; x < n; x++) 
-                                       {
+                               if (n > 0) {
+                                       for (int x = 0; x < n; x++) {
                                                Parameter op = (Parameter) ps.FixedParameters[x + arg_count];
                                                Argument b = new Argument (op.ParameterInitializer, Argument.AType.Expression);
                                                b.Resolve(ec, Location.Null);
@@ -3906,7 +3828,7 @@ namespace Mono.CSharp {
                        Type current_type = null;
                        int argument_count;
                        ArrayList candidates = new ArrayList ();
-                       
+
                        foreach (MethodBase candidate in me.Methods){
                                int x;
 
@@ -4047,12 +3969,16 @@ namespace Mono.CSharp {
                        for (int j = 0; j < argument_count; j++) {
                                Argument a = (Argument) Arguments [j];
                                Expression a_expr = a.Expr;
-                               Type parameter_type = pd.ParameterType (j);
-                               
+                               Type parameter_type = pd.ParameterType(j);
+                                       
+                               if (parameter_type == null)
+                               {
+                                       Error_WrongNumArguments(loc, (InvokingProperty == null)?((delegate_type == null)?FullMethodDesc (method):delegate_type.ToString ()):InvokingProperty, argument_count);
+                                       return false;   
+                               }
                                if (pd.ParameterModifier (j) == Parameter.Modifier.PARAMS &&
-                                   chose_params_expanded)
+                               chose_params_expanded)
                                        parameter_type = TypeManager.TypeToCoreType (parameter_type.GetElementType ());
-
                                if (a.Type != parameter_type){
                                        Expression conv;
                                        
@@ -4115,6 +4041,12 @@ namespace Mono.CSharp {
 
                        return true;
                }
+       
+               public override Expression DoResolveLValue (EmitContext ec, Expression right_side)
+               {
+                       this.is_left_hand = true;
+                       return DoResolve (ec);
+               }
 
                public override Expression DoResolve (EmitContext ec)
                {
@@ -4127,17 +4059,24 @@ namespace Mono.CSharp {
                        if (expr is BaseAccess)
                                is_base = true;
 
-                       expr = expr.Resolve (ec, ResolveFlags.VariableOrValue | ResolveFlags.MethodGroup);
+                       if ((ec.ReturnType != null) && (expr.ToString() == ec.BlockName)) {
+                               ec.InvokingOwnOverload = true;
+                               expr = expr.Resolve (ec, ResolveFlags.MethodGroup);
+                               ec.InvokingOwnOverload = false;
+                       }
+                       else                            
+                       {
+                               ec.InvokingOwnOverload = false;
+                               expr = expr.Resolve (ec, ResolveFlags.VariableOrValue | ResolveFlags.MethodGroup);
+                       }       
                        if (expr == null)
                                return null;
-                               
-                       Console.WriteLine(expr);
+
                        if (expr is Invocation) {
-                               Console.WriteLine("-->must first resolve a call");
+                               // FIXME Calls which return an Array are not resolved (here or in the grammar)
                                expr = expr.Resolve(ec);
-                               Console.WriteLine ("-->expr resolved: " + (expr == null ? "NULL" : "OK"));
                        }
-                       
+
                        if (!(expr is MethodGroupExpr)) 
                        {
                                Type expr_type = expr.Type;
@@ -4150,12 +4089,6 @@ namespace Mono.CSharp {
                                                        this.expr, Arguments, loc)).Resolve (ec);
                                }
                        }
-                       /*
-                       if (!(expr is MethodGroupExpr)){
-                               expr.Error118 (ResolveFlags.MethodGroup);
-                               return null;
-                       }
-                       */
 
                        //
                        // Next, evaluate all the expressions in the argument list
@@ -4166,12 +4099,13 @@ namespace Mono.CSharp {
                                {
                                        if ((a.ArgType == Argument.AType.NoArg) && (!(expr is MethodGroupExpr)))
                                                Report.Error (999, "This item cannot have empty arguments");
-                                       
+
+                       
                                        if (!a.Resolve (ec, loc))
                                                return null;                            
                                }
                        }
-
+                       
                        if (expr is MethodGroupExpr) 
                        {
                                MethodGroupExpr mg = (MethodGroupExpr) expr;
@@ -4179,19 +4113,27 @@ namespace Mono.CSharp {
 
                                if (method == null)
                                {
-                                       Error (-6,
-                                               "Could not find any applicable function for this argument list");
+                                       Error (30455,
+                                               "Could not find any applicable function to invoke for this argument list");
                                        return null;
                                }
 
-                               MethodInfo mi = method as MethodInfo;
-                               if (mi != null) 
+                               if ((method as MethodInfo) != null) 
                                {
+                                       MethodInfo mi = method as MethodInfo;
                                        type = TypeManager.TypeToCoreType (mi.ReturnType);
                                        if (!mi.IsStatic && !mg.IsExplicitImpl && (mg.InstanceExpression == null))
                                                SimpleName.Error_ObjectRefRequired (ec, loc, mi.Name);
                                }
 
+                               if ((method as ConstructorInfo) != null) 
+                               {
+                                       ConstructorInfo ci = method as ConstructorInfo;
+                                       type = TypeManager.void_type;
+                                       if (!ci.IsStatic && !mg.IsExplicitImpl && (mg.InstanceExpression == null))
+                                               SimpleName.Error_ObjectRefRequired (ec, loc, ci.Name);
+                               }
+
                                if (type.IsPointer)
                                {
                                        if (!ec.InUnsafe)
@@ -4219,26 +4161,67 @@ namespace Mono.CSharp {
                                        expr_to_return = pe.DoResolve (ec);
                                        expr_to_return.eclass = ExprClass.PropertyAccess;
                                }
+                               else
+                               {
+                                       throw new Exception("Error resolving Property Access expression\n" + pe.ToString());
+                               }
                        }
 
-                       if (expr is FieldExpr || expr is LocalVariableReference) {
-                               // If we are here, expr must be an ArrayAccess
-                               // FIXME: we should check dimensions, etc.
-                               Console.WriteLine ("I am an array access");
-                               ArrayList idxs = new ArrayList();
-                               foreach (Argument a in Arguments) 
+                       if (expr is FieldExpr || expr is LocalVariableReference || expr is ParameterReference) {
+                               if (expr.Type.IsArray) {
+                                       // If we are here, expr must be an ArrayAccess
+                                       ArrayList idxs = new ArrayList();
+                                       foreach (Argument a in Arguments)
+                                       {
+                                               idxs.Add (a.Expr);
+                                       }
+                                       ElementAccess ea = new ElementAccess (expr, idxs, expr.Location);
+                                       ArrayAccess aa = new ArrayAccess (ea, expr.Location);
+                                       expr_to_return = aa.DoResolve(ec);
+                                       expr_to_return.eclass = ExprClass.Variable;
+                               }
+                               else
                                {
-                                       idxs.Add (a.Expr);
+                                       // We can't resolve now, but we
+                                       // have to try to access the array with a call
+                                       // to LateIndexGet/Set in the runtime
+                                       Expression lig_call_expr;
+
+                                       if (!is_left_hand)
+                                               lig_call_expr = Mono.MonoBASIC.Parser.DecomposeQI("Microsoft.VisualBasic.CompilerServices.LateBinding.LateIndexGet", Location.Null);
+                                       else
+                                               lig_call_expr = Mono.MonoBASIC.Parser.DecomposeQI("Microsoft.VisualBasic.CompilerServices.LateBinding.LateIndexSet", Location.Null);
+                                       Expression obj_type = Mono.MonoBASIC.Parser.DecomposeQI("System.Object", Location.Null);
+                                       ArrayList adims = new ArrayList();
+
+                                       ArrayList ainit = new ArrayList();
+                                       foreach (Argument a in Arguments)
+                                               ainit.Add ((Expression) a.Expr);
+
+                                       adims.Add ((Expression) new IntLiteral (Arguments.Count));
+
+                                       Expression oace = new ArrayCreation (obj_type, adims, "", ainit, Location.Null);
+
+                                       ArrayList args = new ArrayList();
+                                       args.Add (new Argument(expr, Argument.AType.Expression));
+                                       args.Add (new Argument(oace, Argument.AType.Expression));
+                                       args.Add (new Argument(NullLiteral.Null, Argument.AType.Expression));
+
+                                       Expression lig_call = new Invocation (lig_call_expr, args, Location.Null);
+                                       expr_to_return = lig_call.Resolve(ec);
+                                       expr_to_return.eclass = ExprClass.Variable;
                                }
-                               ElementAccess ea = new ElementAccess (expr, idxs, expr.Location);
-                               ArrayAccess aa = new ArrayAccess (ea, expr.Location);
-                               expr_to_return = aa.DoResolve(ec);
-                               expr_to_return.eclass = ExprClass.Variable;
                        }
 
                        return expr_to_return;
                }
 
+        static void Error_WrongNumArguments (Location loc, String name, int arg_count)
+        {
+            Report.Error (1501, loc, "No overload for method `" + name + "' takes `" +
+                                      arg_count + "' arguments");
+        }
+
                // <summary>
                //   Emits the list of arguments as an array
                // </summary>
@@ -4275,7 +4258,7 @@ namespace Mono.CSharp {
                /// 
                ///   The MethodBase argument might be null if the
                ///   emission of the arguments is known not to contain
-               ///   a `params' field (for example in constructors or other routines
+               ///   a 'params' field (for example in constructors or other routines
                ///   that keep their arguments in this structure)
                /// </summary>
                public static void EmitArguments (EmitContext ec, MethodBase mb, ArrayList arguments)
@@ -4332,7 +4315,7 @@ namespace Mono.CSharp {
                }
 
                /// <remarks>
-               ///   is_base tells whether we want to force the use of the `call'
+               ///   is_base tells whether we want to force the use of the 'call'
                ///   opcode instead of using callvirt.  Call is required to call
                ///   a specific method, while callvirt will always use the most
                ///   recent method in the vtable.
@@ -4383,7 +4366,7 @@ namespace Mono.CSharp {
                        }
 
                        //
-                       // This checks the `ConditionalAttribute' on the method, and the
+                       // This checks the 'ConditionalAttribute' on the method, and the
                        // ObsoleteAttribute
                        //
                        TypeManager.MethodFlags flags = TypeManager.GetMethodFlags (method, loc);
@@ -4543,6 +4526,7 @@ namespace Mono.CSharp {
                //
                Expression value_target;
                bool value_target_set = false;
+               public bool isDelegate = false;
                
                public New (Expression requested_type, ArrayList arguments, Location l)
                {
@@ -4584,14 +4568,23 @@ namespace Mono.CSharp {
                        // To enable this, look into:
                        // test-34 and test-89 and self bootstrapping.
                        //
-                       // For instance, we can avoid a copy by using `newobj'
+                       // For instance, we can avoid a copy by using 'newobj'
                        // instead of Call + Push-temp on value types.
 //                     value_target = MyEmptyExpression;
                }
                
                public override Expression DoResolve (EmitContext ec)
                {
-                       type = ec.DeclSpace.ResolveType (RequestedType, false, loc);
+                       if (this.isDelegate) {
+                               // if its a delegate resolve the type of RequestedType first
+                               Expression dtype = RequestedType.Resolve(ec);
+                               string ts = (dtype.Type.ToString()).Replace ('+','.');
+                               dtype = Mono.MonoBASIC.Parser.DecomposeQI (ts, Location.Null);
+
+                               type = ec.DeclSpace.ResolveType (dtype, false, loc);
+                       }
+                       else
+                               type = ec.DeclSpace.ResolveType (RequestedType, false, loc);
                        
                        if (type == null)
                                return null;
@@ -4603,8 +4596,8 @@ namespace Mono.CSharp {
 
                        if (type.IsInterface || type.IsAbstract){
                                Error (
-                                       144, "It is not possible to create instances of interfaces " +
-                                       "or abstract classes");
+                                       30376, "It is not possible to create instances of Interfaces " +
+                                       "or classes marked as MustInherit");
                                return null;
                        }
                        
@@ -4747,7 +4740,7 @@ namespace Mono.CSharp {
 
                //
                // The list of Argument types.
-               // This is used to construct the `newarray' or constructor signature
+               // This is used to construct the 'newarray' or constructor signature
                //
                ArrayList arguments;
 
@@ -4820,7 +4813,7 @@ namespace Mono.CSharp {
 
                void Error_IncorrectArrayInitializer ()
                {
-                       Error (178, "Incorrectly structured array initializer");
+                       Error (30567, "Incorrectly structured array initializer");
                }
                
                public bool CheckIndices (EmitContext ec, ArrayList probe, int idx, bool specified_dims)
@@ -4966,7 +4959,7 @@ namespace Mono.CSharp {
                }
                
                //
-               // Converts `source' to an int, uint, long or ulong.
+               // Converts 'source' to an int, uint, long or ulong.
                //
                Expression ExpressionToArrayArgument (EmitContext ec, Expression source)
                {
@@ -5020,7 +5013,7 @@ namespace Mono.CSharp {
                        StringBuilder array_qualifier = new StringBuilder (rank);
 
                        //
-                       // `In the first form allocates an array instace of the type that results
+                       // 'In the first form allocates an array instace of the type that results
                        // from deleting each of the individual expression from the expression list'
                        //
                        if (num_arguments > 0) {
@@ -5035,6 +5028,7 @@ namespace Mono.CSharp {
                        //
                        Expression array_type_expr;
                        array_type_expr = new ComposedCast (requested_base_type, array_qualifier.ToString (), loc);
+                       string sss = array_qualifier.ToString ();
                        type = ec.DeclSpace.ResolveType (array_type_expr, false, loc);
 
                        if (type == null)
@@ -5465,7 +5459,7 @@ namespace Mono.CSharp {
        }
        
        /// <summary>
-       ///   Represents the `this' construct
+       ///   Represents the 'this' construct
        /// </summary>
        public class This : Expression, IAssignMethod, IMemoryLocation, IVariable {
 
@@ -5536,7 +5530,7 @@ namespace Mono.CSharp {
                                vi.SetAssigned (ec);
                        
                        if (ec.TypeContainer is Class){
-                               Error (1604, "Cannot assign to `this'");
+                               Error (1604, "Cannot assign to 'this'");
                                return null;
                        }
 
@@ -5575,7 +5569,7 @@ namespace Mono.CSharp {
                        //
                        // consider: struct X { int val; int P { set { val = value; }}}
                        //
-                       // Yes, this looks very bad. Look at `NOTAS' for
+                       // Yes, this looks very bad. Look at 'NOTAS' for
                        // an explanation.
                        // ec.ig.Emit (OpCodes.Ldarga_S, (byte) 0);
                }
@@ -5643,7 +5637,7 @@ namespace Mono.CSharp {
                                return null;
 
                        if (!TypeManager.IsUnmanagedType (type_queried)){
-                               Report.Error (208, "Cannot take the size of an unmanaged type (" + TypeManager.CSharpName (type_queried) + ")");
+                               Report.Error (208, "Cannot take the size of an unmanaged type (" + TypeManager.MonoBASIC_Name (type_queried) + ")");
                                return null;
                        }
                        
@@ -5686,7 +5680,7 @@ namespace Mono.CSharp {
 
                static void error176 (Location loc, string name)
                {
-                       Report.Error (176, loc, "Static member `" +
+                       Report.Error (176, loc, "Static member '" +
                                      name + "' cannot be accessed " +
                                      "with an instance reference, qualify with a " +
                                      "type name instead");
@@ -5715,13 +5709,13 @@ namespace Mono.CSharp {
                {
                        bool left_is_type, left_is_explicit;
 
-                       // If `left' is null, then we're called from SimpleNameResolve and this is
+                       // If 'left' is null, then we're called from SimpleNameResolve and this is
                        // a member in the currently defining class.
                        if (left == null) {
                                left_is_type = ec.IsStatic || ec.IsFieldInitializer;
                                left_is_explicit = false;
 
-                               // Implicitly default to `this' unless we're static.
+                               // Implicitly default to 'this' unless we're static.
                                if (!ec.IsStatic && !ec.IsFieldInitializer && !ec.InEnumContext)
                                        left = ec.This;
                        } else {
@@ -5769,12 +5763,16 @@ namespace Mono.CSharp {
                                                Enum en = TypeManager.LookupEnum (decl_type);
 
                                                Constant c;
-                                               if (en != null)
+                                               if (en != null) {
                                                        c = Constantify (o, en.UnderlyingType);
-                                               else 
+                                                       return new EnumConstant (c, en.UnderlyingType);
+                                               }
+                                               else {
                                                        c = Constantify (o, enum_member.Type);
+                                                       return new EnumConstant (c, enum_member.Type);
+                                               }
+                                               
                                                
-                                               return new EnumConstant (c, decl_type);
                                        }
                                        
                                        Expression exp = Constantify (o, t);
@@ -5847,10 +5845,10 @@ namespace Mono.CSharp {
                                                if (IdenticalNameAndTypeName (ec, left_original, loc))
                                                        return member_lookup;
 
-                                               if (left_is_explicit) {
+                                               /*if (left_is_explicit) {
                                                        error176 (loc, me.Name);
                                                        return null;
-                                               }
+                                               }*/
                                        }
 
                                        //
@@ -5910,51 +5908,33 @@ namespace Mono.CSharp {
 
                        if (expr is SimpleName){
                                SimpleName child_expr = (SimpleName) expr;
-                               
+
                                Expression new_expr = new SimpleName (child_expr.Name + "." + Identifier, loc);
 
-                               return new_expr.Resolve (ec, flags);
+                               if ((flags & ResolveFlags.MaskExprClass) == ResolveFlags.Type)
+                                       return new_expr.Resolve (ec, flags);
+                               else
+                                       return new_expr.Resolve (ec, flags | ResolveFlags.MethodGroup | ResolveFlags.VariableOrValue);
                        }
                                        
-                       //
-                       // TODO: I mailed Ravi about this, and apparently we can get rid
-                       // of this and put it in the right place.
-                       // 
-                       // Handle enums here when they are in transit.
-                       // Note that we cannot afford to hit MemberLookup in this case because
-                       // it will fail to find any members at all
-                       //
-
                        int errors = Report.Errors;
                        
                        Type expr_type = expr.Type;
-                       if ((expr is TypeExpr) && (expr_type.IsSubclassOf (TypeManager.enum_type))){
-                               
-                               Enum en = TypeManager.LookupEnum (expr_type);
-                               
-                               if (en != null) {
-                                       object value = en.LookupEnumValue (ec, Identifier, loc);
-
-                                       if (value != null){
-                                               Constant c = Constantify (value, en.UnderlyingType);
-                                               return new EnumConstant (c, expr_type);
-                                       }
-                               }
-                       }
 
                        if (expr_type.IsPointer){
-                               Error (23, "The `.' operator can not be applied to pointer operands (" +
-                                      TypeManager.CSharpName (expr_type) + ")");
+                               Error (23, "The '.' operator can not be applied to pointer operands (" +
+                                      TypeManager.MonoBASIC_Name (expr_type) + ")");
                                return null;
                        }
 
                        member_lookup = MemberLookup (ec, expr_type, Identifier, loc);
 
-                       if (member_lookup == null){
+                       if (member_lookup == null)
+                       {
                                // Error has already been reported.
                                if (errors < Report.Errors)
                                        return null;
-
+                               
                                //
                                // Try looking the member up from the same type, if we find
                                // it, we know that the error was due to limited visibility
@@ -5962,42 +5942,57 @@ namespace Mono.CSharp {
                                object lookup = TypeManager.MemberLookup (
                                        expr_type, expr_type, AllMemberTypes, AllBindingFlags |
                                        BindingFlags.NonPublic, Identifier);
+                                       
                                if (lookup == null)
-                                       Error (117, "`" + expr_type + "' does not contain a " +
-                                              "definition for `" + Identifier + "'");
-                               else if ((expr_type != ec.ContainerType) &&
-                                        ec.ContainerType.IsSubclassOf (expr_type)){
-
-                                       // Although a derived class can access protected members of
-                                       // its base class it cannot do so through an instance of the
-                                       // base class (CS1540).  If the expr_type is a parent of the
-                                       // ec.ContainerType and the lookup succeeds with the latter one,
-                                       // then we are in this situation.
-
-                                       lookup = TypeManager.MemberLookup (
-                                               ec.ContainerType, ec.ContainerType, AllMemberTypes,
-                                               AllBindingFlags, Identifier);
-
-                                       if (lookup != null)
-                                               Error (1540, "Cannot access protected member `" +
+                                       Error (30456, "'" + expr_type + "' does not contain a definition for '" + Identifier + "'");
+                               else
+                               {
+                                       if ((expr_type != ec.ContainerType) &&
+                                                ec.ContainerType.IsSubclassOf (expr_type))
+                                       {
+
+                                               // Although a derived class can access protected members of
+                                               // its base class it cannot do so through an instance of the
+                                               // base class (CS1540).  If the expr_type is a parent of the
+                                               // ec.ContainerType and the lookup succeeds with the latter one,
+                                               // then we are in this situation.
+
+                                               lookup = TypeManager.MemberLookup(
+                                                                       ec.ContainerType, ec.ContainerType, AllMemberTypes, 
+                                                                       AllBindingFlags, Identifier);
+
+                                               if (lookup != null)
+                                                       Error (1540, "Cannot access protected member '" +
                                                       expr_type + "." + Identifier + "' " +
-                                                      "via a qualifier of type `" +
-                                                      TypeManager.CSharpName (expr_type) + "'; the " +
-                                                      "qualifier must be of type `" +
-                                                      TypeManager.CSharpName (ec.ContainerType) + "' " +
+                                                      "via a qualifier of type '" + TypeManager.MonoBASIC_Name (expr_type) + "'; the " +
+                                                      "qualifier must be of type '" + TypeManager.MonoBASIC_Name (ec.ContainerType) + "' " +
                                                       "(or derived from it)");
-                                       else
-                                               Error (122, "`" + expr_type + "." + Identifier + "' " +
+                                               else
+                                                       Error (30390, "'" + expr_type + "." + Identifier + "' " +
                                                       "is inaccessible because of its protection level");
-                               } else
-                                       Error (122, "`" + expr_type + "." + Identifier + "' " +
+                                       } else
+                                               Error (30390, "'" + expr_type + "." + Identifier + "' " +
                                               "is inaccessible because of its protection level");
-                                             
+                               }  
                                return null;
                        }
 
+                       if ((expr is TypeExpr) && (expr_type.IsSubclassOf (TypeManager.enum_type)))     {
+                               Enum en = TypeManager.LookupEnum (expr_type);
+                               
+                               if (en != null) {
+                                       object value = en.LookupEnumValue (ec, Identifier, loc);
+                                       expr_type = TypeManager.int32_type;
+                                       if (value != null) {
+                                               Constant c = Constantify (value, en.UnderlyingType);
+                                               return new EnumConstant (c, en.UnderlyingType);
+                                       }
+                               }
+                       }
+
                        if (member_lookup is TypeExpr){
                                member_lookup.Resolve (ec, ResolveFlags.Type);
+
                                return member_lookup;
                        } else if ((flags & ResolveFlags.MaskExprClass) == ResolveFlags.Type)
                                return null;
@@ -6008,7 +6003,6 @@ namespace Mono.CSharp {
 
                        // The following DoResolve/DoResolveLValue will do the definite assignment
                        // check.
-
                        if (right_side != null)
                                member_lookup = member_lookup.DoResolveLValue (ec, right_side);
                        else
@@ -6045,6 +6039,8 @@ namespace Mono.CSharp {
                }
        }
 
+       
+       
        /// <summary>
        ///   Implements checked expressions
        /// </summary>
@@ -6252,7 +6248,7 @@ namespace Mono.CSharp {
                ElementAccess ea;
 
                LocalTemporary [] cached_locations;
-               
+
                public ArrayAccess (ElementAccess ea_data, Location l)
                {
                        ea = ea_data;
@@ -6274,6 +6270,35 @@ namespace Mono.CSharp {
 #endif
 
                        Type t = ea.Expr.Type;
+/*
+                       if (t == typeof (System.Object))
+                       {
+                               // We can't resolve now, but we
+                               // have to try to access the array with a call
+                               // to LateIndexGet in the runtime
+
+                               Expression lig_call_expr = Mono.MonoBASIC.Parser.DecomposeQI("Microsoft.VisualBasic.CompilerServices.LateBinding.LateIndexGet", Location.Null);
+                               Expression obj_type = Mono.MonoBASIC.Parser.DecomposeQI("System.Object", Location.Null);
+                               ArrayList adims = new ArrayList();
+
+                               ArrayList ainit = new ArrayList();
+                               foreach (Argument a in ea.Arguments)
+                                       ainit.Add ((Expression) a.Expr);
+
+                               adims.Add ((Expression) new IntLiteral (ea.Arguments.Count));
+
+                               Expression oace = new ArrayCreation (obj_type, adims, "", ainit, Location.Null);
+
+                               ArrayList args = new ArrayList();
+                               args.Add (new Argument(ea.Expr, Argument.AType.Expression));
+                               args.Add (new Argument(oace, Argument.AType.Expression));
+                               args.Add (new Argument(NullLiteral.Null, Argument.AType.Expression));
+
+                               Expression lig_call = new Invocation (lig_call_expr, args, Location.Null);
+                               lig_call = lig_call.Resolve(ec);
+                               return lig_call;
+                       }
+*/
                        if (t.GetArrayRank () != ea.Arguments.Count){
                                ea.Error (22,
                                          "Incorrect number of indexes for array " +
@@ -6313,7 +6338,7 @@ namespace Mono.CSharp {
                }
 
                /// <summary>
-               ///    Emits the right opcode to load an object of Type `t'
+               ///    Emits the right opcode to load an object of Type 't'
                ///    from an array of T
                /// </summary>
                static public void EmitLoadOpcode (ILGenerator ig, Type type)
@@ -6348,7 +6373,7 @@ namespace Mono.CSharp {
                }
 
                /// <summary>
-               ///    Emits the right opcode to store an object of Type `t'
+               ///    Emits the right opcode to store an object of Type 't'
                ///    from an array of T.  
                /// </summary>
                static public void EmitStoreOpcode (ILGenerator ig, Type t)
@@ -6645,7 +6670,7 @@ namespace Mono.CSharp {
                        }
 
                        Report.Error (21, loc,
-                                     "Type `" + TypeManager.CSharpName (lookup_type) +
+                                     "Type '" + TypeManager.MonoBASIC_Name (lookup_type) +
                                      "' does not have any indexers defined");
                        return null;
                }
@@ -6697,7 +6722,7 @@ namespace Mono.CSharp {
                                return null;
 
                        //
-                       // Step 1: Query for all `Item' *properties*.  Notice
+                       // Step 1: Query for all 'Item' *properties*.  Notice
                        // that the actual methods are pointed from here.
                        //
                        // This is a group of properties, piles of them.  
@@ -6715,7 +6740,7 @@ namespace Mono.CSharp {
 
                        if (get == null){
                                Error (154, "indexer can not be used in this context, because " +
-                                      "it lacks a `get' accessor");
+                                      "it lacks a 'get' accessor");
                                return null;
                        }
 
@@ -6749,8 +6774,8 @@ namespace Mono.CSharp {
                        }
                        
                        if (set == null){
-                               Error (200, "indexer X.this [" + TypeManager.CSharpName (right_type) +
-                                      "] lacks a `set' accessor");
+                               Error (200, "indexer X.this [" + TypeManager.MonoBASIC_Name (right_type) +
+                                      "] lacks a 'set' accessor");
                                return null;
                        }
 
@@ -6779,7 +6804,7 @@ namespace Mono.CSharp {
        ///   The base operator for method names
        /// </summary>
        public class BaseAccess : Expression {
-               string member;
+               public string member;
                
                public BaseAccess (string member, Location l)
                {
@@ -6795,16 +6820,20 @@ namespace Mono.CSharp {
                        Expression e;
 
                        if (ec.IsStatic){
-                               Error (1511, "Keyword base is not allowed in static method");
+                               Error (1511, "Keyword MyBase is not allowed in static method");
                                return null;
                        }
-                               
+                       
+                       if (member == "New")
+                               member = ".ctor";
+                       
                        member_lookup = MemberLookup (ec, base_type, base_type, member,
                                                      AllMemberTypes, AllBindingFlags, loc);
+
                        if (member_lookup == null) {
-                               Error (117,
-                                             TypeManager.CSharpName (base_type) + " does not " +
-                                             "contain a definition for `" + member + "'");
+                               Error (30456,
+                                             TypeManager.MonoBASIC_Name (base_type) + " does not " +
+                                             "contain a definition for '" + member + "'");
                                return null;
                        }
 
@@ -6868,7 +6897,7 @@ namespace Mono.CSharp {
        ///   we only care about the side effect conversions to be performed
        ///
        ///   This is also now used as a placeholder where a no-action expression
-       ///   is needed (the `New' class).
+       ///   is needed (the 'New' class).
        /// </summary>
        public class EmptyExpression : Expression {
                public EmptyExpression ()
@@ -7093,7 +7122,7 @@ namespace Mono.CSharp {
        }
        
        //
-       // Implements the `stackalloc' keyword
+       // Implements the 'stackalloc' keyword
        //
        public class StackAlloc : Expression {
                Type otype;