//
using System;
-using System.Text;
-using System.Reflection.Emit;
-using System.Diagnostics;
using System.Collections.Generic;
+#if STATIC
+using IKVM.Reflection.Emit;
+#else
+using System.Reflection.Emit;
+#endif
+
namespace Mono.CSharp {
public abstract class Statement {
public SwitchLabel Clone (CloneContext clonectx)
{
+ if (label == null)
+ return this;
+
return new SwitchLabel (label.Clone (clonectx), loc);
}
}
{
var cloned_labels = new List<SwitchLabel> ();
- foreach (SwitchLabel sl in cloned_labels)
+ foreach (SwitchLabel sl in Labels)
cloned_labels.Add (sl.Clone (clonectx));
return new SwitchSection (cloned_labels, clonectx.LookupBlock (Block));
int ResolvePredefinedMethods (ResolveContext rc)
{
if (TypeManager.void_monitor_enter_object == null || TypeManager.void_monitor_exit_object == null) {
- TypeSpec monitor_type = TypeManager.CoreLookupType (rc.Compiler, "System.Threading", "Monitor", MemberKind.Class, true);
+ TypeSpec monitor_type = rc.Module.PredefinedTypes.Monitor.Resolve (loc);
if (monitor_type == null)
return 0;
pinned_string.Type = TypeManager.string_type;
if (TypeManager.int_get_offset_to_string_data == null) {
- TypeManager.int_get_offset_to_string_data = TypeManager.GetPredefinedProperty (
- TypeManager.runtime_helpers_type, "OffsetToStringData", pinned_string.Location, TypeManager.int32_type);
+ var helper = rc.Module.PredefinedTypes.RuntimeHelpers.Resolve (loc);
+ if (helper != null) {
+ TypeManager.int_get_offset_to_string_data = TypeManager.GetPredefinedProperty (helper,
+ "OffsetToStringData", pinned_string.Location, TypeManager.int32_type);
+ }
}
eclass = ExprClass.Variable;
}
if (General != null) {
- if (CodeGen.Assembly.WrapNonExceptionThrows) {
- foreach (Catch c in Specific){
- if (c.CatchType == TypeManager.exception_type && ec.Compiler.PredefinedAttributes.RuntimeCompatibility.IsDefined) {
- ec.Report.Warning (1058, 1, c.loc,
- "A previous catch clause already catches all exceptions. All non-exceptions thrown will be wrapped in a `System.Runtime.CompilerServices.RuntimeWrappedException'");
- }
- }
+ foreach (Catch c in Specific) {
+ if (c.CatchType != TypeManager.exception_type)
+ continue;
+
+ if (!ec.Module.DeclaringAssembly.WrapNonExceptionThrows)
+ continue;
+
+ if (!ec.Module.PredefinedAttributes.RuntimeCompatibility.IsDefined)
+ continue;
+
+ ec.Report.Warning (1058, 1, c.loc,
+ "A previous catch clause already catches all exceptions. All non-exceptions thrown will be wrapped in a `System.Runtime.CompilerServices.RuntimeWrappedException'");
}
ec.CurrentBranching.CreateSibling (General.Block, FlowBranching.SiblingType.Catch);
// Option 2: Try to match using IEnumerable interfaces with preference of generic version
//
TypeSpec iface_candidate = null;
- for (TypeSpec t = expr.Type; t != null && t != TypeManager.object_type; t = t.BaseType) {
+ var t = expr.Type;
+ do {
var ifaces = t.Interfaces;
if (ifaces != null) {
foreach (var iface in ifaces) {
}
}
}
- }
+
+ if (t.IsGenericParameter)
+ t = t.BaseType;
+ else
+ t = null;
+
+ } while (t != null);
if (iface_candidate == null) {
rc.Report.Error (1579, loc,