Author: martin
Date: 2005-04-18 03:48:10 -0400 (Mon, 18 Apr 2005)
New Revision: 43198
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/enum.cs
trunk/mcs/gmcs/expression.cs
Log:
**** Merged r42254 from MCS ****
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2005-04-18 07:47:33 UTC (rev 43197)
+++ trunk/mcs/gmcs/ChangeLog 2005-04-18 07:48:10 UTC (rev 43198)
@@ -1,3 +1,13 @@
+2005-03-25 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * enum.cs (Enum.DefineType): Set ec.InEnumContext and
+ ec.ContainerType.
+ (Enum.current_ec): Remove.
+ (Enum.LookupEnumValue): Remove EmitContext argument.
+ Just uses the one created during DefineType.
+ (Enum.FindMembers): Update.
+ * expression.cs (MemberAccess.DoResolve): Update.
+
2005-03-22 Marek Safar <[EMAIL PROTECTED]>
* assign.cs (Assign.DoResolve): Check for CS1717 when
@@ -2,6 +12,6 @@
source and target are same (uses Equals).
-
+
* expression.cs (LocalVariableReference, ParameterReference,
This): Implemented Equals, GetHashCode.
-
+
* statement.cs (Block.GetParameterReference): Removed useless
@@ -16,14 +26,14 @@
blocks before deciding whether the error is cs0136 or cs0128.
* cs-parser.jay: Pass MemberName to RootContext.Tree.RecordDecl.
- (using_alias_directive, using_namespace_directive): Pass
- MemberName, not an expression to Namespace.UsingAlias and
+ (using_alias_directive, using_namespace_directive): Pass
+ MemberName, not an expression to Namespace.UsingAlias and
Namespace.Using.
(MakeName): Use the MemberName of the namespace.
* namespace.cs (Namespace.MemberName): New.
(UsingEntry.UsingEntry): Take a MemberName, not an expression.
- (AliasEntry.AliasEntry, Namespace.Using, Namespace.UsingAlias):
- Likewise.
+ (AliasEntry.AliasEntry, Namespace.Using, Namespace.UsingAlias):
+ Likewise.
* decl.cs (MemberName.Name): Make readonly.
(MemberName.FromDotted): New "constructor".
(MemberName.Equals, MemberName.GetHashCode): Implement overrides.
@@ -67,7 +77,7 @@
fixed buffer attribute (CS1716).
(PropertyMethod.HasCustomAccessModifier): When property accessor
has custom modifier.
-
+
* ecore (PropertyExpr.DoResolve): Add CS0271 for custom accessor
modifiers.
(PropertyExpr.DoResolveLValue): Add CS0272.
@@ -78,7 +88,7 @@
or Conv.I depending on the source data type.
* cs-tokenizer.cs: Make the size for large decimal constants,
- fixes #72957.
+ fixes #72957.
2005-03-17 Martin Baulig <[EMAIL PROTECTED]>
@@ -139,11 +149,11 @@
* delegate.cs (DelegateCreation.Error_NoMatchingMethodForDelegate):
Added CS0407.
-
+
* expression.cs (ParameterReference.IsAssigned): Changed error to
CS0269.
- (Error_WrongNumArguments): Moved CS0245 detection here.
-
+ (Error_WrongNumArguments): Moved CS0245 detection here.
+
* statement.cs (Return.Resolve): Add CS1622 report.
2005-03-11 Marek Safar <[EMAIL PROTECTED]>
Modified: trunk/mcs/gmcs/enum.cs
===================================================================
--- trunk/mcs/gmcs/enum.cs 2005-04-18 07:47:33 UTC (rev 43197)
+++ trunk/mcs/gmcs/enum.cs 2005-04-18 07:48:10 UTC (rev 43198)
@@ -34,7 +34,7 @@
this.Type = expr;
}
- public override void ApplyAttributeBuilder(Attribute a,
CustomAttributeBuilder cb)
+ public override void ApplyAttributeBuilder (Attribute a,
CustomAttributeBuilder cb)
{
if (a.Type == TypeManager.marshal_as_attr_type) {
UnmanagedMarshal marshal = a.GetMarshal (this);
@@ -215,6 +215,7 @@
TypeAttributes attr = Modifiers.TypeAttr (ModFlags,
IsTopLevel);
ec = new EmitContext (this, this, Location, null, null,
ModFlags, false);
+ ec.InEnumContext = true;
attr |= TypeAttributes.Class | TypeAttributes.Sealed;
@@ -260,6 +261,8 @@
Basename, attr, TypeManager.enum_type);
}
+ ec.ContainerType = TypeBuilder;
+
//
// Call MapToInternalType for corlib
//
@@ -485,19 +488,14 @@
return false;
}
- //
- // Horrible, horrible. But there is no other way we can pass
the EmitContext
- // to the recursive definition triggered by the evaluation of a
forward
- // expression
- //
- static EmitContext current_ec = null;
-
/// <summary>
/// This is used to lookup the value of an enum member. If the
member is undefined,
/// it attempts to define it and return its value
/// </summary>
- public object LookupEnumValue (EmitContext ec, string name,
Location loc)
+ public object LookupEnumValue (string name, Location loc)
{
+ if (ec == null)
+ Report.Error (-1, loc, "Enum.LookupEnumValue ()
called too soon");
object default_value = null;
Constant c = null;
@@ -538,14 +536,7 @@
Location m_loc =
(Mono.CSharp.Location)
member_to_location [n];
in_transit.Add (name, true);
-
- EmitContext old_ec = current_ec;
- current_ec = ec;
-
- default_value = LookupEnumValue
(ec, n, m_loc);
-
- current_ec = old_ec;
-
+ default_value = LookupEnumValue
(n, m_loc);
in_transit.Remove (name);
if (default_value == null)
return null;
@@ -555,17 +546,12 @@
}
} else {
- bool old = ec.InEnumContext;
- ec.InEnumContext = true;
- in_transit.Add (name, true);
+ if (!EmitContext.InEnumContext)
+ Report.Error (-1, loc, "foo");
- EmitContext old_ec = current_ec;
- current_ec = ec;
- val = val.Resolve (ec);
- current_ec = old_ec;
-
+ in_transit.Add (name, true);
+ val = val.Resolve (EmitContext);
in_transit.Remove (name);
- ec.InEnumContext = old;
if (val == null)
return null;
@@ -630,7 +616,8 @@
if (TypeBuilder == null)
return false;
- ec = new EmitContext (this, this, Location, null,
UnderlyingType, ModFlags, false);
+ if (ec == null)
+ throw new InternalErrorException ("Enum.Define
() called too soon");
object default_value = 0;
@@ -645,7 +632,7 @@
Location loc = (Mono.CSharp.Location)
member_to_location [name];
if (this [name] != null) {
- default_value = LookupEnumValue (ec,
name, loc);
+ default_value = LookupEnumValue (name,
loc);
if (default_value == null)
return true;
@@ -748,10 +735,8 @@
ArrayList members = new ArrayList ();
if ((mt & MemberTypes.Field) != 0) {
- if (criteria is string){
- if (member_to_value [criteria] == null
&& current_ec != null){
- LookupEnumValue (current_ec,
(string) criteria, Location.Null);
- }
+ if (criteria is string && member_to_value
[criteria] == null) {
+ LookupEnumValue ((string) criteria,
Location.Null);
}
foreach (FieldBuilder fb in field_builders)
Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs 2005-04-18 07:47:33 UTC (rev 43197)
+++ trunk/mcs/gmcs/expression.cs 2005-04-18 07:48:10 UTC (rev 43198)
@@ -7675,7 +7675,7 @@
Enum en = TypeManager.LookupEnum
(expr_type);
if (en != null) {
- object value =
en.LookupEnumValue (ec, Identifier, loc);
+ object value =
en.LookupEnumValue (Identifier, loc);
if (value != null){
MemberCore mc =
en.GetDefinition (Identifier);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches