summaryrefslogtreecommitdiff
path: root/BCT
diff options
context:
space:
mode:
authorGravatar mikebarnett <unknown>2011-01-18 18:17:47 +0000
committerGravatar mikebarnett <unknown>2011-01-18 18:17:47 +0000
commite49b15c05e51ffa2d6700fa61500d7f7a3a81745 (patch)
tree8cb34df4d4d0d0561758729bab9d2dc2e1dd506a /BCT
parent4dc3a9e20f85ab403d70a59e40a2494d3e6a5067 (diff)
Removing resolution: there's no need to resolve field references in order to translate them.
Diffstat (limited to 'BCT')
-rw-r--r--BCT/BytecodeTranslator/Heap.cs4
-rw-r--r--BCT/BytecodeTranslator/Sink.cs13
2 files changed, 11 insertions, 6 deletions
diff --git a/BCT/BytecodeTranslator/Heap.cs b/BCT/BytecodeTranslator/Heap.cs
index 349beab0..1d5cb352 100644
--- a/BCT/BytecodeTranslator/Heap.cs
+++ b/BCT/BytecodeTranslator/Heap.cs
@@ -38,9 +38,9 @@ namespace BytecodeTranslator {
/// Creates a fresh BPL variable to represent <paramref name="field"/>, deciding
/// on its type based on the heap representation.
/// </summary>
- public Bpl.Variable CreateFieldVariable(IFieldDefinition field) {
+ public Bpl.Variable CreateFieldVariable(IFieldReference field) {
Bpl.Variable v;
- string fieldname = field.ContainingTypeDefinition.ToString() + "." + field.Name.Value;
+ string fieldname = TypeHelper.GetTypeName(field.ContainingType) + "." + field.Name.Value;
Bpl.IToken tok = field.Token();
Bpl.Type t = TranslationHelper.CciTypeToBoogie(field.Type.ResolvedType);
diff --git a/BCT/BytecodeTranslator/Sink.cs b/BCT/BytecodeTranslator/Sink.cs
index 8c7169b0..05166313 100644
--- a/BCT/BytecodeTranslator/Sink.cs
+++ b/BCT/BytecodeTranslator/Sink.cs
@@ -110,18 +110,23 @@ namespace BytecodeTranslator {
}
public Dictionary<IParameterDefinition, MethodParameter> FormalMap = null;
- public Bpl.Variable FindOrCreateFieldVariable(IFieldDefinition field) {
+ public Bpl.Variable FindOrCreateFieldVariable(IFieldReference field) {
// The Heap has to decide how to represent the field (i.e., its type),
// all the Sink cares about is adding a declaration for it.
Bpl.Variable v;
- if (!this.declaredFields.TryGetValue(field, out v)) {
+ var key = Tuple.Create(field.ContainingType.InternedKey, field.Name);
+ if (!this.declaredFields.TryGetValue(key, out v)) {
v = this.Heap.CreateFieldVariable(field);
- this.declaredFields.Add(field, v);
+ this.declaredFields.Add(key, v);
this.TranslatedProgram.TopLevelDeclarations.Add(v);
}
return v;
}
- private Dictionary<IFieldDefinition, Bpl.Variable> declaredFields = new Dictionary<IFieldDefinition, Bpl.Variable>();
+ /// <summary>
+ /// The keys to the table are tuples of the containing type (its interned key) and the name of the field. That
+ /// should uniquely identify each field.
+ /// </summary>
+ private Dictionary<Tuple<uint, IName>, Bpl.Variable> declaredFields = new Dictionary<Tuple<uint, IName>, Bpl.Variable>();
public void BeginMethod() {
this.localVarMap = new Dictionary<ILocalDefinition, Bpl.LocalVariable>();