else
$$ = $4;
+ lbag.InsertLocation ($$, 0, PopLocation ());
if ($5 != null) {
- lbag.AddLocation ($$, PopLocation (), GetLocation ($2), GetLocation ($5), GetLocation ($6));
+ lbag.AddLocation ($$, GetLocation ($2), GetLocation ($5), GetLocation ($6));
} else {
- lbag.AddLocation ($$, PopLocation (), GetLocation ($2), GetLocation ($6));
+ lbag.AddLocation ($$, GetLocation ($2), GetLocation ($6));
}
current_attr_target = null;
{
$$ = $1;
+ lbag.InsertLocation ($$, 0, PopLocation ());
if ($2 != null) {
- lbag.AddLocation ($$, PopLocation (), GetLocation($2), GetLocation ($3));
+ lbag.AddLocation ($$, GetLocation($2), GetLocation ($3));
} else {
- lbag.AddLocation ($$, PopLocation (), GetLocation($3));
+ lbag.AddLocation ($$, GetLocation($3));
}
}
| IDENTIFIER error
| attribute_list COMMA attribute
{
var attrs = (List<Attribute>) $1;
- attrs.Add ((Attribute) $3);
+ if (attrs != null) {
+ attrs.Add ((Attribute) $3);
+ lbag.AppendTo (attrs, GetLocation ($2));
+ }
$$ = attrs;
}
opt_local_variable_initializer opt_variable_declarators
{
$$ = current_variable;
+ if ($4 != null)
+ lbag.AddLocation (current_variable, PopLocation ());
+
current_variable = null;
}
| statement_expression_list
public class MemberLocations
{
public readonly IList<Tuple<Modifiers, Location>> Modifiers;
- Location[] locations;
+ List<Location> locations;
- public MemberLocations (IList<Tuple<Modifiers, Location>> mods, Location[] locs)
+ public MemberLocations (IList<Tuple<Modifiers, Location>> mods)
{
Modifiers = mods;
+ }
+
+ public MemberLocations (IList<Tuple<Modifiers, Location>> mods, Location loc)
+ : this (mods)
+ {
+ AddLocations (loc);
+ }
+
+ public MemberLocations (IList<Tuple<Modifiers, Location>> mods, Location[] locs)
+ : this (mods)
+ {
+ AddLocations (locs);
+ }
+
+ public MemberLocations (IList<Tuple<Modifiers, Location>> mods, List<Location> locs)
+ : this (mods)
+ {
locations = locs;
}
public int Count {
get {
- return locations.Length;
+ return locations.Count;
}
}
#endregion
+ public void AddLocations (Location loc)
+ {
+ if (locations == null) {
+ locations = new List<Location> ();
+ }
+
+ locations.Add (loc);
+ }
+
public void AddLocations (params Location[] additional)
{
if (locations == null) {
- locations = additional;
+ locations = new List<Location> (additional);
} else {
- int pos = locations.Length;
- Array.Resize (ref locations, pos + additional.Length);
- additional.CopyTo (locations, pos);
+ locations.AddRange (additional);
}
}
}
- Dictionary<object, Location[]> simple_locs = new Dictionary<object, Location[]> (ReferenceEquality<object>.Default);
+ Dictionary<object, List<Location>> simple_locs = new Dictionary<object, List<Location>> (ReferenceEquality<object>.Default);
Dictionary<MemberCore, MemberLocations> member_locs = new Dictionary<MemberCore, MemberLocations> (ReferenceEquality<MemberCore>.Default);
[Conditional ("FULL_AST")]
public void AddLocation (object element, params Location[] locations)
{
- simple_locs.Add (element, locations);
+ simple_locs.Add (element, new List<Location> (locations));
+ }
+
+ [Conditional ("FULL_AST")]
+ public void InsertLocation (object element, int index, Location location)
+ {
+ List<Location> found;
+ if (!simple_locs.TryGetValue (element, out found)) {
+ found = new List<Location> ();
+ simple_locs.Add (element, found);
+ }
+
+ found.Insert (index, location);
}
[Conditional ("FULL_AST")]
if (locations.Length == 0)
throw new ArgumentException ("Statement is missing semicolon location");
- simple_locs.Add (element, locations);
+ AddLocation (element, locations);
+ }
+
+ [Conditional ("FULL_AST")]
+ public void AddMember (MemberCore member, IList<Tuple<Modifiers, Location>> modLocations)
+ {
+ member_locs.Add (member, new MemberLocations (modLocations));
+ }
+
+ [Conditional ("FULL_AST")]
+ public void AddMember (MemberCore member, IList<Tuple<Modifiers, Location>> modLocations, Location location)
+ {
+ member_locs.Add (member, new MemberLocations (modLocations, location));
}
[Conditional ("FULL_AST")]
}
[Conditional ("FULL_AST")]
- public void AppendTo (object existing, params Location[] locations)
+ public void AddMember (MemberCore member, IList<Tuple<Modifiers, Location>> modLocations, List<Location> locations)
{
- Location[] locs;
- if (simple_locs.TryGetValue (existing, out locs)) {
- simple_locs [existing] = locs.Concat (locations).ToArray ();
- return;
+ member_locs.Add (member, new MemberLocations (modLocations, locations));
+ }
+
+ [Conditional ("FULL_AST")]
+ public void AppendTo (object element, Location location)
+ {
+ List<Location> found;
+ if (!simple_locs.TryGetValue (element, out found)) {
+ found = new List<Location> ();
+ simple_locs.Add (element, found);
}
+
+ found.Add (location);
}
[Conditional ("FULL_AST")]
}
}
- public Location[] GetLocations (object element)
+ public List<Location> GetLocations (object element)
{
- Location[] found;
+ List<Location> found;
simple_locs.TryGetValue (element, out found);
return found;
}