Author: raja
Date: 2007-05-29 08:01:03 -0400 (Tue, 29 May 2007)
New Revision: 78112
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/cs-parser.jay
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/cs-parser.jay
trunk/mcs/mcs/statement.cs
Log:
In mcs:
* statement.cs (ToplevelBlock.container): Remove field. It's
redundant with 'Parent'.
(ToplevelBlock.ContainerBlock): Remove accessor.
(ToplevelBlock..ctor): Update to changes. Register anonymous
child with parent here, ...
* cs-parser.jay (end_anonymous): ... not here. Don't modify
current_block.
(start_anonymous): Don't save current_block.
(top_current_block): Remove.
In gmcs:
* cs-parser.jay: Update to changes in ToplevelBlock.
(top_current_block): Remove.
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2007-05-29 11:45:13 UTC (rev 78111)
+++ trunk/mcs/gmcs/ChangeLog 2007-05-29 12:01:03 UTC (rev 78112)
@@ -1,3 +1,8 @@
+2007-05-29 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * cs-parser.jay: Update to changes in ToplevelBlock.
+ (top_current_block): Remove.
+
2007-05-27 Raja R Harinath <[EMAIL PROTECTED]>
* cs-parser.jay: Update to new ExplicitBlock invariant.
Modified: trunk/mcs/gmcs/cs-parser.jay
===================================================================
--- trunk/mcs/gmcs/cs-parser.jay 2007-05-29 11:45:13 UTC (rev 78111)
+++ trunk/mcs/gmcs/cs-parser.jay 2007-05-29 12:01:03 UTC (rev 78112)
@@ -42,7 +42,7 @@
/// Current block is used to add statements as we find
/// them.
/// </summary>
- Block current_block, top_current_block;
+ Block current_block;
Delegate current_delegate;
@@ -2323,11 +2323,10 @@
}
open_parens opt_formal_parameter_list CLOSE_PARENS
{
- current_local_parameters = (Parameters) $4;
- current_block = top_current_block = new ToplevelBlock (null,
- current_local_parameters, null, Location.Null);
-
LocatedToken lt = (LocatedToken) $1;
+ current_local_parameters = (Parameters) $4;
+ current_block = new ToplevelBlock (null,
current_local_parameters, null, lt.Location);
+
$$ = new Constructor (current_class, lt.Value, 0,
current_local_parameters,
null, lt.Location);
@@ -2337,7 +2336,7 @@
constructor_body
: block_prepared
- | SEMICOLON { current_block = top_current_block = null; $$
= null; }
+ | SEMICOLON { current_block = null; $$ = null; }
;
constructor_initializer
@@ -5870,18 +5869,9 @@
void
start_block (Location loc)
{
- if (parsing_anonymous_method) {
- top_current_block = new ToplevelBlock (
- current_block, current_local_parameters,
current_generic_method, loc);
- if (current_block != null)
- current_block.AddAnonymousChild ((ToplevelBlock)
top_current_block);
- current_block = top_current_block;
+ if (current_block == null || parsing_anonymous_method) {
+ current_block = new ToplevelBlock (current_block,
current_local_parameters, current_generic_method, loc);
parsing_anonymous_method = false;
- } else if (current_block == null) {
- current_block = new ToplevelBlock (
- (ToplevelBlock) top_current_block,
current_local_parameters,
- current_generic_method, loc);
- top_current_block = current_block;
} else {
current_block = new ExplicitBlock (current_block, loc,
Location.Null);
}
@@ -5893,8 +5883,6 @@
Block retval = current_block.Explicit;
retval.SetEndLocation (loc);
current_block = retval.Parent;
- if (current_block == null)
- top_current_block = null;
return retval;
}
@@ -5906,18 +5894,17 @@
current_local_parameters = parameters;
- // Force the next block to be created as a ToplevelBlock
- oob_stack.Push (current_block);
- oob_stack.Push (top_current_block);
+ ToplevelBlock top_current_block = current_block == null ? null :
current_block.Toplevel;
current_anonymous_method = lambda
? new LambdaExpression (
current_anonymous_method, current_generic_method,
current_container,
- parameters, (ToplevelBlock) top_current_block, loc)
+ parameters, top_current_block, loc)
: new AnonymousMethodExpression (
current_anonymous_method, current_generic_method,
current_container,
- parameters, (ToplevelBlock) top_current_block, loc);
+ parameters, top_current_block, loc);
+ // Force the next block to be created as a ToplevelBlock
parsing_anonymous_method = true;
}
@@ -5930,15 +5917,10 @@
{
AnonymousMethodExpression retval;
- top_current_block = (Block) oob_stack.Pop ();
- current_block = (Block) oob_stack.Pop ();
-
if (RootContext.Version == LanguageVersion.ISO_1){
Report.FeatureIsNotISO1 (loc, "anonymous methods");
retval = null;
} else {
- anon_block.Parent = current_block;
-
current_anonymous_method.Block = anon_block;
if ((anonymous_host != null) &&
(current_anonymous_method.Parent == null))
anonymous_host.AddAnonymousMethod
(current_anonymous_method);
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2007-05-29 11:45:13 UTC (rev 78111)
+++ trunk/mcs/mcs/ChangeLog 2007-05-29 12:01:03 UTC (rev 78112)
@@ -1,5 +1,15 @@
2007-05-29 Raja R Harinath <[EMAIL PROTECTED]>
+ * statement.cs (ToplevelBlock.container): Remove field. It's
+ redundant with 'Parent'.
+ (ToplevelBlock.ContainerBlock): Remove accessor.
+ (ToplevelBlock..ctor): Update to changes. Register anonymous
+ child with parent here, ...
+ * cs-parser.jay (end_anonymous): ... not here. Don't modify
+ current_block.
+ (start_anonymous): Don't save current_block.
+ (top_current_block): Remove.
+
* statement.cs (Block.Flags): Remove IsExplicit and IsToplevel flags.
(Block.Resolve): Update to changes.
(Block..ctor): Move setting of "correct" 'Toplevel'
Modified: trunk/mcs/mcs/cs-parser.jay
===================================================================
--- trunk/mcs/mcs/cs-parser.jay 2007-05-29 11:45:13 UTC (rev 78111)
+++ trunk/mcs/mcs/cs-parser.jay 2007-05-29 12:01:03 UTC (rev 78112)
@@ -42,7 +42,7 @@
/// Current block is used to add statements as we find
/// them.
/// </summary>
- Block current_block, top_current_block;
+ Block current_block;
Delegate current_delegate;
@@ -2151,8 +2151,7 @@
{
LocatedToken lt = (LocatedToken) $1;
current_local_parameters = (Parameters) $4;
- current_block = top_current_block = new ToplevelBlock (null,
- current_local_parameters, null, lt.Location);
+ current_block = new ToplevelBlock (null,
current_local_parameters, null, lt.Location);
$$ = new Constructor (current_class, lt.Value, 0,
current_local_parameters,
null, lt.Location);
@@ -2163,7 +2162,7 @@
constructor_body
: block_prepared
- | SEMICOLON { current_block = top_current_block = null; $$
= null; }
+ | SEMICOLON { current_block = null; $$ = null; }
;
constructor_initializer
@@ -5146,18 +5145,9 @@
void start_block (Location loc)
{
- if (parsing_anonymous_method) {
- top_current_block = new ToplevelBlock (
- current_block, current_local_parameters,
current_generic_method, loc);
- if (current_block != null)
- current_block.AddAnonymousChild ((ToplevelBlock)
top_current_block);
- current_block = top_current_block;
+ if (current_block == null || parsing_anonymous_method) {
+ current_block = new ToplevelBlock (current_block,
current_local_parameters, current_generic_method, loc);
parsing_anonymous_method = false;
- } else if (current_block == null) {
- current_block = new ToplevelBlock (
- (ToplevelBlock) top_current_block,
current_local_parameters,
- current_generic_method, loc);
- top_current_block = current_block;
} else {
current_block = new ExplicitBlock (current_block, loc,
Location.Null);
}
@@ -5169,8 +5159,6 @@
Block retval = current_block.Explicit;
retval.SetEndLocation (loc);
current_block = retval.Parent;
- if (current_block == null)
- top_current_block = null;
return retval;
}
@@ -5182,18 +5170,17 @@
current_local_parameters = parameters;
- // Force the next block to be created as a ToplevelBlock
- oob_stack.Push (current_block);
- oob_stack.Push (top_current_block);
+ ToplevelBlock top_current_block = current_block == null ? null :
current_block.Toplevel;
current_anonymous_method = lambda
? new LambdaExpression (
current_anonymous_method, current_generic_method,
current_container,
- parameters, (ToplevelBlock) top_current_block, loc)
+ parameters, top_current_block, loc)
: new AnonymousMethodExpression (
current_anonymous_method, current_generic_method,
current_container,
- parameters, (ToplevelBlock) top_current_block, loc);
+ parameters, top_current_block, loc);
+ // Force the next block to be created as a ToplevelBlock
parsing_anonymous_method = true;
}
@@ -5206,15 +5193,10 @@
{
AnonymousMethodExpression retval;
- top_current_block = (Block) oob_stack.Pop ();
- current_block = (Block) oob_stack.Pop ();
-
if (RootContext.Version == LanguageVersion.ISO_1){
Report.FeatureIsNotISO1 (loc, "anonymous methods");
retval = null;
} else {
- anon_block.Parent = current_block;
-
current_anonymous_method.Block = anon_block;
if ((anonymous_host != null) &&
(current_anonymous_method.Parent == null))
anonymous_host.AddAnonymousMethod
(current_anonymous_method);
Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs 2007-05-29 11:45:13 UTC (rev 78111)
+++ trunk/mcs/mcs/statement.cs 2007-05-29 12:01:03 UTC (rev 78112)
@@ -1740,7 +1740,7 @@
return false;
}
- for (Block b = Toplevel.ContainerBlock; b != null; b =
b.Toplevel.ContainerBlock) {
+ for (Block b = Toplevel.Parent; b != null; b =
b.Toplevel.Parent) {
if (!b.CheckError136_InParents (name, loc))
return false;
}
@@ -1801,7 +1801,7 @@
return false;
}
- for (Block c = Toplevel.ContainerBlock; c != null; c =
c.Toplevel.ContainerBlock) {
+ for (Block c = Toplevel.Parent; c != null; c =
c.Toplevel.Parent) {
if (!c.DoCheckError136 (name, "parent or
current", loc))
return false;
}
@@ -2440,11 +2440,6 @@
// Methods was implemented.
//
public class ToplevelBlock : ExplicitBlock {
- //
- // Pointer to the host of this anonymous method, or null
- // if we are the topmost block
- //
- Block container;
GenericMethod generic;
FlowBranchingToplevel top_level_branching;
AnonymousContainer anonymous_container;
@@ -2469,15 +2464,13 @@
public bool CompleteContexts (EmitContext ec)
{
- Report.Debug (64, "TOPLEVEL COMPLETE CONTEXTS", this,
- container, root_scope);
+ Report.Debug (64, "TOPLEVEL COMPLETE CONTEXTS", this,
Parent, root_scope);
if (root_scope != null)
root_scope.LinkScopes ();
- if ((container == null) && (root_scope != null)) {
- Report.Debug (64, "TOPLEVEL COMPLETE CONTEXTS
#1", this,
- root_scope);
+ if (Parent == null && root_scope != null) {
+ Report.Debug (64, "TOPLEVEL COMPLETE CONTEXTS
#1", this, root_scope);
if (root_scope.DefineType () == null)
return false;
@@ -2497,30 +2490,21 @@
}
public ToplevelBlock Container {
- get { return container != null ? container.Toplevel :
null; }
+ get { return Parent == null ? null : Parent.Toplevel; }
}
- public Block ContainerBlock {
- get { return container; }
- }
-
public AnonymousContainer AnonymousContainer {
get { return anonymous_container; }
set { anonymous_container = value; }
}
- //
- // Parent is only used by anonymous blocks to link back to their
- // parents
- //
- public ToplevelBlock (Block container, Parameters parameters,
Location start) :
- this (container, (Flags) 0, parameters, start)
+ public ToplevelBlock (Block parent, Parameters parameters,
Location start) :
+ this (parent, (Flags) 0, parameters, start)
{
}
- public ToplevelBlock (Block container, Parameters parameters,
GenericMethod generic,
- Location start) :
- this (container, parameters, start)
+ public ToplevelBlock (Block parent, Parameters parameters,
GenericMethod generic, Location start) :
+ this (parent, parameters, start)
{
this.generic = generic;
}
@@ -2535,13 +2519,17 @@
{
}
- public ToplevelBlock (Block container, Flags flags, Parameters
parameters, Location start) :
+ // We use 'Parent' to hook up to the containing block, but
don't want to register the current block as a child.
+ // So, we use a two-stage setup -- first pass a null parent to
the base constructor, and then override 'Parent'.
+ public ToplevelBlock (Block parent, Flags flags, Parameters
parameters, Location start) :
base (null, flags, start, Location.Null)
{
this.Toplevel = this;
this.parameters = parameters == null ?
Parameters.EmptyReadOnlyParameters : parameters;
- this.container = container;
+ this.Parent = parent;
+ if (parent != null)
+ parent.AddAnonymousChild (this);
}
public ToplevelBlock (Location loc) : this (null, (Flags) 0,
null, loc)
@@ -2595,10 +2583,9 @@
public void CreateIteratorHost (RootScopeInfo root)
{
- Report.Debug (64, "CREATE ITERATOR HOST", this, root,
- container, root_scope);
+ Report.Debug (64, "CREATE ITERATOR HOST", this, root,
Parent, root_scope);
- if ((container != null) || (root_scope != null))
+ if (Parent != null || root_scope != null)
throw new InternalErrorException ();
scope_info = root_scope = root;
@@ -2633,7 +2620,6 @@
if ((flags & Flags.VariablesInitialized) != 0)
throw new InternalErrorException ("block has
already been resolved");
- container = new_parent;
Parent = new_parent;
}
@@ -2728,7 +2714,7 @@
if (ip != null)
parameters = ip;
- if (!IsIterator && (container != null) && (parameters
!= null)) {
+ if (!IsIterator && Parent != null && parameters !=
null) {
foreach (Parameter p in
parameters.FixedParameters) {
if (!CheckError136_InParents (p.Name,
loc))
return false;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches