@@ -85,10 +85,13 @@ public TranslatorEnvironment(
85
85
BlockFrameDescriptorInfo parentBlockDescriptor = Objects
86
86
.requireNonNull (parent .blockFrameDescriptorInfo );
87
87
this .frameDescriptorBuilder = newFrameDescriptorBuilderForBlock (parentBlockDescriptor );
88
+ this .blockFrameDescriptorInfo = new BlockFrameDescriptorInfo (
89
+ parentBlockDescriptor .getSpecialVariableAssumption ());
88
90
} else {
89
- this .frameDescriptorBuilder = newFrameDescriptorBuilderForMethod ();
91
+ var specialVariableAssumption = createSpecialVariableAssumption ();
92
+ this .frameDescriptorBuilder = newFrameDescriptorBuilderForMethod (specialVariableAssumption );
93
+ this .blockFrameDescriptorInfo = new BlockFrameDescriptorInfo (specialVariableAssumption );
90
94
}
91
- this .blockFrameDescriptorInfo = new BlockFrameDescriptorInfo ();
92
95
} else {
93
96
this .frameDescriptor = descriptor ;
94
97
this .blockFrameDescriptorInfo = new BlockFrameDescriptorInfo (descriptor );
@@ -163,15 +166,16 @@ public static FrameDescriptor.Builder newFrameDescriptorBuilderForBlock(BlockFra
163
166
return builder ;
164
167
}
165
168
166
- public static FrameDescriptor .Builder newFrameDescriptorBuilderForMethod () {
169
+ private static Assumption createSpecialVariableAssumption () {
170
+ return Assumption .create (SpecialVariableStorage .ASSUMPTION_NAME );
171
+ }
167
172
173
+ private static FrameDescriptor .Builder newFrameDescriptorBuilderForMethod (Assumption specialVariableAssumption ) {
168
174
var builder = FrameDescriptor .newBuilder ().defaultValue (Nil .INSTANCE );
169
175
// We need to access this Assumption from the FrameDescriptor,
170
176
// and there is no way to get a RootNode from a FrameDescriptor, so we store it in the descriptor info.
171
177
// We do not store it as slot info for footprint, to avoid needing an info array per FrameDescriptor.
172
- final Assumption doesNotNeedSpecialVariableStorageAssumption = Assumption
173
- .create (SpecialVariableStorage .ASSUMPTION_NAME );
174
- builder .info (doesNotNeedSpecialVariableStorageAssumption );
178
+ builder .info (specialVariableAssumption );
175
179
176
180
177
181
int selfIndex = builder .addSlot (FrameSlotKind .Illegal , SelfNode .SELF_IDENTIFIER , null );
@@ -187,6 +191,12 @@ public static FrameDescriptor.Builder newFrameDescriptorBuilderForMethod() {
187
191
return builder ;
188
192
}
189
193
194
+
195
+ public static FrameDescriptor .Builder newFrameDescriptorBuilderForMethod () {
196
+ var specialVariableAssumption = createSpecialVariableAssumption ();
197
+ return newFrameDescriptorBuilderForMethod (specialVariableAssumption );
198
+ }
199
+
190
200
public int declareVar (Object name ) {
191
201
assert name != null && !(name instanceof String && ((String ) name ).isEmpty ());
192
202
0 commit comments