Author: raja
Date: 2007-06-04 10:41:01 -0400 (Mon, 04 Jun 2007)
New Revision: 78563
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/linq.cs
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/expression.cs
trunk/mcs/mcs/statement.cs
Log:
In mcs:
* statement.cs (ToplevelBlock.CloneTo): New. Copy over parameter
information too.
(ToplevelBlock.GetParameterInfo): Split out of ...
(ToplevelBlock.GetParameterRefernce): ... this.
(ToplevelBlock.ParameterMap): Remove.
* expression.cs (ParameterReference): Update to use
ToplevelParameterInfo.
In gmcs:
* linq.cs (Select.DoResolve): Pass the created parameters to the
ToplevelBlock too.
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2007-06-04 14:10:02 UTC (rev 78562)
+++ trunk/mcs/gmcs/ChangeLog 2007-06-04 14:41:01 UTC (rev 78563)
@@ -1,3 +1,8 @@
+2007-06-04 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * linq.cs (Select.DoResolve): Pass the created parameters to the
+ ToplevelBlock too.
+
2007-05-29 Raja R Harinath <[EMAIL PROTECTED]>
* cs-parser.jay: Update to changes in ToplevelBlock.
Modified: trunk/mcs/gmcs/linq.cs
===================================================================
--- trunk/mcs/gmcs/linq.cs 2007-06-04 14:10:02 UTC (rev 78562)
+++ trunk/mcs/gmcs/linq.cs 2007-06-04 14:41:01 UTC (rev 78563)
@@ -70,11 +70,9 @@
}
// TODO: eplicit li.Type means .Cast between
IEnumerable and IEnumerable<T>
- AnonymousMethodExpression ame = new
AnonymousMethodExpression (
- null, null, host,
- new Parameters (new Parameter (li.Type,
li.Name, Parameter.Modifier.NONE, null, loc)),
- block, loc);
- ame.Block = new ToplevelBlock (loc);
+ Parameters p = new Parameters (new Parameter (li.Type,
li.Name, Parameter.Modifier.NONE, null, loc));
+ AnonymousMethodExpression ame = new
AnonymousMethodExpression (null, null, host, p, block, loc);
+ ame.Block = new ToplevelBlock (p, loc);
ame.Block.AddStatement (new Return (expr, loc));
ArrayList args = new ArrayList (2);
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2007-06-04 14:10:02 UTC (rev 78562)
+++ trunk/mcs/mcs/ChangeLog 2007-06-04 14:41:01 UTC (rev 78563)
@@ -1,5 +1,13 @@
2007-06-04 Raja R Harinath <[EMAIL PROTECTED]>
+ * statement.cs (ToplevelBlock.CloneTo): New. Copy over parameter
+ information too.
+ (ToplevelBlock.GetParameterInfo): Split out of ...
+ (ToplevelBlock.GetParameterRefernce): ... this.
+ (ToplevelBlock.ParameterMap): Remove.
+ * expression.cs (ParameterReference): Update to use
+ ToplevelParameterInfo.
+
* statement.cs (ToplevelBlock.ProcessParameters): Workaround some
regression.
Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2007-06-04 14:10:02 UTC (rev 78562)
+++ trunk/mcs/mcs/expression.cs 2007-06-04 14:41:01 UTC (rev 78563)
@@ -3710,97 +3710,84 @@
/// representation.
/// </summary>
public class ParameterReference : VariableReference, IVariable {
- Parameter par;
- string name;
- int idx;
+ ToplevelParameterInfo pi;
ToplevelBlock referenced;
- VariableInfo vi;
+
public bool is_ref, is_out;
public bool IsOut {
- get {
- return is_out;
- }
+ get { return is_out; }
}
public override bool IsRef {
- get {
- return is_ref;
- }
+ get { return is_ref; }
}
public string Name {
- get {
- return name;
- }
+ get { return Parameter.Name; }
}
public Parameter Parameter {
- get {
- return par;
- }
+ get { return pi.Parameter; }
}
Variable variable;
- public ParameterReference (Parameter par, ToplevelBlock
referenced, int idx, Location loc)
+ public ParameterReference (ToplevelBlock referenced,
ToplevelParameterInfo pi, Location loc)
{
- this.par = par;
- this.name = par.Name;
+ this.pi = pi;
this.referenced = referenced;
- this.idx = idx;
this.loc = loc;
eclass = ExprClass.Variable;
}
public VariableInfo VariableInfo {
- get { return vi; }
+ get { return pi.VariableInfo; }
}
public override Variable Variable {
- get { return variable != null ? variable :
par.Variable; }
+ get { return variable != null ? variable :
Parameter.Variable; }
}
public bool VerifyFixed ()
{
// A parameter is fixed if it's a value parameter
(i.e., no modifier like out, ref, param).
- return par.ModFlags == Parameter.Modifier.NONE;
+ return Parameter.ModFlags == Parameter.Modifier.NONE;
}
public bool IsAssigned (EmitContext ec, Location loc)
{
- if (!ec.DoFlowAnalysis || !is_out ||
ec.CurrentBranching.IsAssigned (vi))
+ if (!ec.DoFlowAnalysis || !is_out ||
ec.CurrentBranching.IsAssigned (VariableInfo))
return true;
- Report.Error (269, loc,
- "Use of unassigned out parameter `{0}'",
par.Name);
+ Report.Error (269, loc, "Use of unassigned out
parameter `{0}'", Name);
return false;
}
public bool IsFieldAssigned (EmitContext ec, string field_name,
Location loc)
{
- if (!ec.DoFlowAnalysis || !is_out ||
ec.CurrentBranching.IsFieldAssigned (vi, field_name))
+ if (!ec.DoFlowAnalysis || !is_out ||
ec.CurrentBranching.IsFieldAssigned (VariableInfo, field_name))
return true;
- Report.Error (170, loc,
- "Use of possibly unassigned field `" +
field_name + "'");
+ Report.Error (170, loc, "Use of possibly unassigned
field `{0}'", field_name);
return false;
}
public void SetAssigned (EmitContext ec)
{
if (is_out && ec.DoFlowAnalysis)
- ec.CurrentBranching.SetAssigned (vi);
+ ec.CurrentBranching.SetAssigned (VariableInfo);
}
public void SetFieldAssigned (EmitContext ec, string field_name)
{
if (is_out && ec.DoFlowAnalysis)
- ec.CurrentBranching.SetFieldAssigned (vi,
field_name);
+ ec.CurrentBranching.SetFieldAssigned
(VariableInfo, field_name);
}
protected bool DoResolveBase (EmitContext ec)
{
+ Parameter par = Parameter;
if (!par.Resolve (ec)) {
//TODO:
}
@@ -3811,13 +3798,8 @@
is_out = (mod & Parameter.Modifier.OUT) ==
Parameter.Modifier.OUT;
eclass = ExprClass.Variable;
- ToplevelBlock declared = referenced;
- while (!declared.IsLocalParameter (name))
- declared = declared.Container;
+ ToplevelBlock declared = pi.Block;
- if (is_out)
- vi = declared.ParameterMap [idx];
-
AnonymousContainer am = ec.CurrentAnonymousMethod;
if (am == null)
return true;
@@ -3833,14 +3815,14 @@
return true;
ScopeInfo scope = declared.CreateScopeInfo ();
- variable = scope.AddParameter (par, idx);
+ variable = scope.AddParameter (par, pi.Index);
type = variable.Type;
return true;
}
- public override int GetHashCode()
+ public override int GetHashCode ()
{
- return name.GetHashCode ();
+ return Name.GetHashCode ();
}
public override bool Equals (object obj)
@@ -3849,7 +3831,7 @@
if (pr == null)
return false;
- return name == pr.name && referenced == pr.referenced;
+ return Name == pr.Name && referenced == pr.referenced;
}
//
@@ -3870,7 +3852,7 @@
return null;
if (is_out && ec.DoFlowAnalysis &&
- (!ec.OmitStructFlowAnalysis ||
!vi.TypeInfo.IsStruct) && !IsAssigned (ec, loc))
+ (!ec.OmitStructFlowAnalysis ||
!VariableInfo.TypeInfo.IsStruct) && !IsAssigned (ec, loc))
return null;
return this;
@@ -3902,7 +3884,7 @@
public override string ToString ()
{
- return "ParameterReference[" + name + "]";
+ return "ParameterReference[" + Name + "]";
}
}
Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs 2007-06-04 14:10:02 UTC (rev 78562)
+++ trunk/mcs/mcs/statement.cs 2007-06-04 14:41:01 UTC (rev 78563)
@@ -2390,22 +2390,24 @@
}
public class ToplevelParameterInfo : IKnownVariable {
- ToplevelBlock block;
- int idx;
+ public readonly ToplevelBlock Block;
+ public readonly int Index;
public VariableInfo VariableInfo;
- public Block Block {
- get { return block; }
+ Block IKnownVariable.Block {
+ get { return Block; }
}
-
+ public Parameter Parameter {
+ get { return Block.Parameters [Index]; }
+ }
public Location Location {
- get { return block.Parameters [idx].Location; }
+ get { return Parameter.Location; }
}
public ToplevelParameterInfo (ToplevelBlock block, int idx)
{
- this.block = block;
- this.idx = idx;
+ this.Block = block;
+ this.Index = idx;
}
}
@@ -2517,6 +2519,19 @@
{
}
+ protected override void CloneTo (CloneContext clonectx,
Statement t)
+ {
+ ToplevelBlock target = (ToplevelBlock) t;
+ base.CloneTo (clonectx, t);
+
+ if (this.parameters.Count == 0)
+ return;
+
+ target.parameter_info = new ToplevelParameterInfo
[parameters.Count];
+ for (int i = 0; i < parameters.Count; ++i)
+ target.parameter_info [i] = new
ToplevelParameterInfo (target, i);
+ }
+
public bool CheckError158 (string name, Location loc)
{
if (AnonymousChildren != null) {
@@ -2639,11 +2654,17 @@
//
public ParameterReference GetParameterReference (string name,
Location loc)
{
+ ToplevelParameterInfo p = GetParameterInfo (name);
+ return p == null ? null : new ParameterReference (this,
p, loc);
+ }
+
+ public ToplevelParameterInfo GetParameterInfo (string name)
+ {
int idx;
for (ToplevelBlock t = this; t != null; t =
t.Container) {
Parameter par = t.Parameters.GetParameterByName
(name, out idx);
if (par != null)
- return new ParameterReference (par,
this, idx, loc);
+ return t.parameter_info [idx];
}
return null;
}
@@ -2705,15 +2726,6 @@
return this_variable == null ||
this_variable.IsThisAssigned (ec);
}
- VariableInfo [] param_map;
- public VariableInfo [] ParameterMap {
- get {
- if ((flags & Flags.VariablesInitialized) == 0)
- throw new Exception ("Variables have
not been initialized yet");
- return param_map;
- }
- }
-
public bool ResolveMeta (EmitContext ec, Parameters ip)
{
int errors = Report.Errors;
@@ -2737,10 +2749,9 @@
if ((mod & Parameter.Modifier.OUT) !=
Parameter.Modifier.OUT)
continue;
- if (param_map == null)
- param_map = new VariableInfo
[parameters.Count];
- param_map [i] = new VariableInfo (ip, i,
offset);
- offset += param_map [i].Length;
+ VariableInfo vi = new VariableInfo (ip, i,
offset);
+ parameter_info [i].VariableInfo = vi;
+ offset += vi.Length;
}
ResolveMeta (ec, offset);
@@ -2757,12 +2768,12 @@
{
if (vector.IsUnreachable)
return;
- VariableInfo [] param_map = ParameterMap;
- if (param_map == null)
- return;
- for (int i = 0; i < param_map.Length; i++) {
- VariableInfo var = param_map [i];
+ int n = parameter_info == null ? 0 :
parameter_info.Length;
+
+ for (int i = 0; i < n; i++) {
+ VariableInfo var = parameter_info
[i].VariableInfo;
+
if (var == null)
continue;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches