TARGET_JVM icon support
[mono.git] / mcs / mcs / statement.cs
index 2e81c2fed5629e604e75ccde88ac4792ac318d4e..7d70945eca849c1b7146c0755aaf7a127d440dbb 100644 (file)
@@ -46,8 +46,8 @@ namespace Mono.CSharp {
                        // in unreachable code, for instance.
                        //
 
-                       if (warn && (RootContext.WarningLevel >= 2))
-                               Report.Warning (162, loc, "Unreachable code detected");
+                       if (warn)
+                               Report.Warning (162, 2, loc, "Unreachable code detected");
 
                        ec.StartFlowBranching (FlowBranching.BranchingType.Block, loc);
                        bool ok = Resolve (ec);
@@ -808,7 +808,7 @@ namespace Mono.CSharp {
                        sl = (SwitchLabel) ec.Switch.Elements [val];
 
                        if (sl == null){
-                               Report.Error (159, loc, "No such label `case {0}:' within the scope of the goto statement", c.GetValue () == null ? "null" : val);
+                               Report.Error (159, loc, "No such label `case {0}:' within the scope of the goto statement", c.GetValue () == null ? "null" : val.ToString ());
                                return false;
                        }
 
@@ -1670,7 +1670,7 @@ namespace Mono.CSharp {
                ///   tc: is our typecontainer (to resolve type references)
                ///   ig: is the code generator:
                /// </remarks>
-               public void ResolveMeta (ToplevelBlock toplevel, EmitContext ec, InternalParameters ip)
+               public void ResolveMeta (ToplevelBlock toplevel, EmitContext ec, Parameters ip)
                {
                        bool old_unsafe = ec.InUnsafe;
 
@@ -1837,9 +1837,9 @@ namespace Mono.CSharp {
                                        name = (string) de.Key;
 
                                        if (vector.IsAssigned (vi.VariableInfo)){
-                                               Report.Warning (219, vi.Location, "The variable `{0}' is assigned but its value is never used", name);
+                                               Report.Warning (219, 3, vi.Location, "The variable `{0}' is assigned but its value is never used", name);
                                        } else {
-                                               Report.Warning (168, vi.Location, "The variable `{0}' is declared but never used", name);
+                                               Report.Warning (168, 3, vi.Location, "The variable `{0}' is declared but never used", name);
                                        }
                                }
                        }
@@ -1903,12 +1903,14 @@ namespace Mono.CSharp {
                                // Warn if we detect unreachable code.
                                //
                                if (unreachable) {
+                                       if (s is EmptyStatement)
+                                               continue;
+
                                        if (s is Block)
                                                ((Block) s).unreachable = true;
 
-                                       if (!unreachable_shown && (RootContext.WarningLevel >= 2)) {
-                                               Report.Warning (
-                                                       162, s.loc, "Unreachable code detected");
+                                       if (!unreachable_shown) {
+                                               Report.Warning (162, 2, s.loc, "Unreachable code detected");
                                                unreachable_shown = true;
                                        }
                                }
@@ -1954,7 +1956,7 @@ namespace Mono.CSharp {
                        if ((labels != null) && (RootContext.WarningLevel >= 2)) {
                                foreach (LabeledStatement label in labels.Values)
                                        if (!label.HasBeenReferenced)
-                                               Report.Warning (164, label.loc,
+                                               Report.Warning (164, 2, label.loc,
                                                                "This label has not been referenced");
                        }
 
@@ -1978,8 +1980,8 @@ namespace Mono.CSharp {
                        unreachable_shown = true;
                        unreachable = true;
 
-                       if (warn && (RootContext.WarningLevel >= 2))
-                               Report.Warning (162, loc, "Unreachable code detected");
+                       if (warn)
+                               Report.Warning (162, 2, loc, "Unreachable code detected");
 
                        ec.StartFlowBranching (FlowBranching.BranchingType.Block, loc);
                        bool ok = Resolve (ec);
@@ -2205,7 +2207,7 @@ namespace Mono.CSharp {
                                Parameters pars = t.Parameters;
                                par = pars.GetParameterByName (name, out idx);
                                if (par != null)
-                                       return new ParameterReference (pars, this, idx, name, loc);
+                                       return new ParameterReference (par, this, idx, loc);
                        }
                        return null;
                }
@@ -2267,7 +2269,7 @@ namespace Mono.CSharp {
                        return this_variable == null || this_variable.IsThisAssigned (ec, loc);
                }
 
-               public bool ResolveMeta (EmitContext ec, InternalParameters ip)
+               public bool ResolveMeta (EmitContext ec, Parameters ip)
                {
                        int errors = Report.Errors;
 
@@ -3754,12 +3756,15 @@ namespace Mono.CSharp {
                                        if (vi == null)
                                                throw new Exception ("Variable does not exist in this block");
 
-                                       ig.Emit (OpCodes.Stloc, vi.LocalBuilder);
                                        if (vi.IsCaptured){
+                                               LocalBuilder e = ig.DeclareLocal (vi.VariableType);
+                                               ig.Emit (OpCodes.Stloc, e);
+                                               
                                                ec.EmitCapturedVariableInstance (vi);
-                                               ig.Emit (OpCodes.Ldloc, vi.LocalBuilder);
+                                               ig.Emit (OpCodes.Ldloc, e);
                                                ig.Emit (OpCodes.Stfld, vi.FieldBuilder);
-                                       }
+                                       } else
+                                               ig.Emit (OpCodes.Stloc, vi.LocalBuilder);
                                } else
                                        ig.Emit (OpCodes.Pop);
                                
@@ -3941,7 +3946,7 @@ namespace Mono.CSharp {
                                                MethodInfo mi = null;
 
                                                foreach (MethodInfo mk in ((MethodGroupExpr) ml).Methods) {
-                                                       if (TypeManager.GetArgumentTypes (mk).Length == 0) {
+                                                       if (TypeManager.GetParameterData (mk).Count == 0) {
                                                                mi = mk;
                                                                break;
                                                        }
@@ -4011,7 +4016,7 @@ namespace Mono.CSharp {
                                        MethodInfo mi = null;
 
                                        foreach (MethodInfo mk in ((MethodGroupExpr) ml).Methods) {
-                                               if (TypeManager.GetArgumentTypes (mk).Length == 0) {
+                                               if (TypeManager.GetParameterData (mk).Count == 0) {
                                                        mi = mk;
                                                        break;
                                                }
@@ -4422,10 +4427,8 @@ namespace Mono.CSharp {
 
                                foreach (MemberInfo m in move_next_list){
                                        MethodInfo mi = (MethodInfo) m;
-                                       Type [] args;
                                
-                                       args = TypeManager.GetArgumentTypes (mi);
-                                       if ((args != null) && (args.Length == 0) &&
+                                       if ((TypeManager.GetParameterData (mi).Count == 0) &&
                                            TypeManager.TypeToCoreType (mi.ReturnType) == TypeManager.bool_type) {
                                                move_next = mi;
                                                return true;
@@ -4466,10 +4469,8 @@ namespace Mono.CSharp {
 
                                foreach (MemberInfo m in dispose_list){
                                        MethodInfo mi = (MethodInfo) m;
-                                       Type [] args;
 
-                                       args = TypeManager.GetArgumentTypes (mi);
-                                       if (args != null && args.Length == 0){
+                                       if (TypeManager.GetParameterData (mi).Count == 0){
                                                if (mi.ReturnType == TypeManager.void_type)
                                                        return mi;
                                        }
@@ -4497,8 +4498,7 @@ namespace Mono.CSharp {
                                        return false;
 
                                foreach (MethodBase mb in mg.Methods) {
-                                       Type [] args = TypeManager.GetArgumentTypes (mb);
-                                       if (args != null && args.Length != 0)
+                                       if (TypeManager.GetParameterData (mb).Count != 0)
                                                continue;
                        
                                        // Check whether GetEnumerator is public