@@ -125,17 +125,18 @@ public static void insertAncestorFrame(RubyContext context, DynamicObject bindin
125
125
newFrame (binding , newFrameDescriptor (context ));
126
126
}
127
127
128
- public static boolean hiddenVariable (Object name ) {
128
+ public static boolean isHiddenVariable (Object name ) {
129
129
if (name instanceof String ) {
130
- return hiddenVariable ((String ) name );
130
+ return isHiddenVariable ((String ) name );
131
131
} else {
132
132
return true ;
133
133
}
134
134
}
135
135
136
- public static boolean hiddenVariable (String name ) {
136
+ private static boolean isHiddenVariable (String name ) {
137
137
assert !name .isEmpty ();
138
- return name .startsWith ("$" ) || name .charAt (0 ) == TranslatorEnvironment .TEMP_PREFIX ;
138
+ return name .charAt (0 ) == '$' || // Frame-local global variable
139
+ name .charAt (0 ) == TranslatorEnvironment .TEMP_PREFIX ;
139
140
}
140
141
141
142
@ CoreMethod (names = { "dup" , "clone" })
@@ -166,7 +167,7 @@ public RubyNode coerceToString(RubyNode name) {
166
167
167
168
@ Specialization (guards = {
168
169
"name == cachedName" ,
169
- "!hiddenVariable (cachedName)" ,
170
+ "!isHiddenVariable (cachedName)" ,
170
171
"getFrameDescriptor(binding) == descriptor"
171
172
}, limit = "getCacheLimit()" )
172
173
public boolean localVariableDefinedCached (DynamicObject binding , String name ,
@@ -177,13 +178,13 @@ public boolean localVariableDefinedCached(DynamicObject binding, String name,
177
178
}
178
179
179
180
@ TruffleBoundary
180
- @ Specialization (guards = "!hiddenVariable (name)" )
181
+ @ Specialization (guards = "!isHiddenVariable (name)" )
181
182
public boolean localVariableDefinedUncached (DynamicObject binding , String name ) {
182
183
return FindDeclarationVariableNodes .findFrameSlotOrNull (name , getFrame (binding )) != null ;
183
184
}
184
185
185
186
@ TruffleBoundary
186
- @ Specialization (guards = "hiddenVariable (name)" )
187
+ @ Specialization (guards = "isHiddenVariable (name)" )
187
188
public Object localVariableDefinedLastLine (DynamicObject binding , String name ) {
188
189
throw new RaiseException (getContext (), coreExceptions ().nameError ("Bad local variable name" , binding , name , this ));
189
190
}
@@ -205,7 +206,7 @@ public RubyNode coerceToString(RubyNode name) {
205
206
return NameToJavaStringNodeGen .create (name );
206
207
}
207
208
208
- @ Specialization (guards = "!hiddenVariable (name)" )
209
+ @ Specialization (guards = "!isHiddenVariable (name)" )
209
210
public Object localVariableGetUncached (DynamicObject binding , String name ,
210
211
@ Cached ("create(null)" ) FindDeclarationVariableNodes .FindAndReadDeclarationVariableNode readNode ) {
211
212
MaterializedFrame frame = getFrame (binding );
@@ -217,7 +218,7 @@ public Object localVariableGetUncached(DynamicObject binding, String name,
217
218
}
218
219
219
220
@ TruffleBoundary
220
- @ Specialization (guards = "hiddenVariable (name)" )
221
+ @ Specialization (guards = "isHiddenVariable (name)" )
221
222
public Object localVariableGetLastLine (DynamicObject binding , String name ) {
222
223
throw new RaiseException (getContext (), coreExceptions ().nameError ("Bad local variable name" , binding , name , this ));
223
224
}
@@ -242,7 +243,7 @@ public RubyNode coerceToString(RubyNode name) {
242
243
243
244
@ Specialization (guards = {
244
245
"name == cachedName" ,
245
- "!hiddenVariable (cachedName)" ,
246
+ "!isHiddenVariable (cachedName)" ,
246
247
"getFrameDescriptor(binding) == cachedFrameDescriptor" ,
247
248
"cachedFrameSlot != null"
248
249
}, limit = "getCacheLimit()" )
@@ -257,7 +258,7 @@ public Object localVariableSetCached(DynamicObject binding, String name, Object
257
258
258
259
@ Specialization (guards = {
259
260
"name == cachedName" ,
260
- "!hiddenVariable (cachedName)" ,
261
+ "!isHiddenVariable (cachedName)" ,
261
262
"getFrameDescriptor(binding) == cachedFrameDescriptor" ,
262
263
"cachedFrameSlot == null"
263
264
}, limit = "getCacheLimit()" )
@@ -273,7 +274,7 @@ public Object localVariableSetNewCached(DynamicObject binding, String name, Obje
273
274
}
274
275
275
276
@ TruffleBoundary
276
- @ Specialization (guards = "!hiddenVariable (name)" )
277
+ @ Specialization (guards = "!isHiddenVariable (name)" )
277
278
public Object localVariableSetUncached (DynamicObject binding , String name , Object value ) {
278
279
MaterializedFrame frame = getFrame (binding );
279
280
final FrameSlotAndDepth frameSlot = FindDeclarationVariableNodes .findFrameSlotOrNull (name , frame );
@@ -290,7 +291,7 @@ public Object localVariableSetUncached(DynamicObject binding, String name, Objec
290
291
}
291
292
292
293
@ TruffleBoundary
293
- @ Specialization (guards = "hiddenVariable (name)" )
294
+ @ Specialization (guards = "isHiddenVariable (name)" )
294
295
public Object localVariableSetLastLine (DynamicObject binding , String name , Object value ) {
295
296
throw new RaiseException (getContext (), coreExceptions ().nameError ("Bad local variable name" , binding , name , this ));
296
297
}
@@ -333,8 +334,7 @@ public static DynamicObject listLocalVariables(RubyContext context, Materialized
333
334
334
335
private static void addNamesFromFrame (RubyContext context , Frame frame , final Set <Object > names ) {
335
336
for (FrameSlot slot : frame .getFrameDescriptor ().getSlots ()) {
336
- if (slot .getIdentifier () instanceof String &&
337
- !hiddenVariable ((String ) slot .getIdentifier ())) {
337
+ if (!isHiddenVariable (slot .getIdentifier ())) {
338
338
names .add (context .getSymbolTable ().getSymbol ((String ) slot .getIdentifier ()));
339
339
}
340
340
}
0 commit comments