41
41
package com .oracle .graal .python .builtins .objects .common ;
42
42
43
43
import static com .oracle .graal .python .nodes .frame .FrameSlotIDs .RETURN_SLOT_ID ;
44
+ import static com .oracle .graal .python .nodes .frame .FrameSlotIDs .TEMP_LOCAL_PREFIX ;
44
45
45
46
import java .util .Iterator ;
46
47
import java .util .NoSuchElementException ;
@@ -76,11 +77,6 @@ private Object getValue(FrameSlot slot) {
76
77
return null ;
77
78
}
78
79
79
- @ TruffleBoundary
80
- private static FrameSlot findReturnSlot (Frame frame ) {
81
- return frame .getFrameDescriptor ().findFrameSlot (RETURN_SLOT_ID );
82
- }
83
-
84
80
public Frame getFrame () {
85
81
return frame ;
86
82
}
@@ -96,11 +92,17 @@ public Object getItem(Object key, Equivalence eq) {
96
92
assert eq == DEFAULT_EQIVALENCE ;
97
93
if (RETURN_SLOT_ID .equals (key )) {
98
94
return null ;
95
+ } else if (isTempLocal (key )) {
96
+ return null ;
99
97
}
100
98
FrameSlot slot = frame .getFrameDescriptor ().findFrameSlot (key );
101
99
return getValue (slot );
102
100
}
103
101
102
+ private static boolean isTempLocal (Object key ) {
103
+ return key instanceof String && ((String ) key ).startsWith (TEMP_LOCAL_PREFIX );
104
+ }
105
+
104
106
@ Override
105
107
public void setItem (Object key , Object value , Equivalence eq ) {
106
108
throw UnmodifiableStorageException .INSTANCE ;
@@ -122,6 +124,8 @@ public boolean hasKey(Object key, Equivalence eq) {
122
124
assert eq == DEFAULT_EQIVALENCE ;
123
125
if (RETURN_SLOT_ID .equals (key )) {
124
126
return false ;
127
+ } else if (isTempLocal (key )) {
128
+ return false ;
125
129
}
126
130
return frame .getFrameDescriptor ().findFrameSlot (key ) != null ;
127
131
}
@@ -132,7 +136,8 @@ public int length() {
132
136
if (length == -1 ) {
133
137
length = frame .getFrameDescriptor ().getSize ();
134
138
for (FrameSlot slot : frame .getFrameDescriptor ().getSlots ()) {
135
- if (slot .getIdentifier ().equals (RETURN_SLOT_ID ) || frame .getValue (slot ) == null ) {
139
+ Object identifier = slot .getIdentifier ();
140
+ if (identifier .equals (RETURN_SLOT_ID ) || isTempLocal (identifier ) || frame .getValue (slot ) == null ) {
136
141
length --;
137
142
}
138
143
}
@@ -210,7 +215,8 @@ public FrameSlot nextSlot() {
210
215
private boolean loadNext () {
211
216
while (keysIterator ().hasNext ()) {
212
217
FrameSlot nextCandidate = keysIterator ().next ();
213
- if (!RETURN_SLOT_ID .equals (nextCandidate .getIdentifier ())) {
218
+ Object identifier = nextCandidate .getIdentifier ();
219
+ if (!RETURN_SLOT_ID .equals (identifier ) && !isTempLocal (identifier )) {
214
220
Object nextValue = frame .getValue (nextCandidate );
215
221
if (skipCells && nextValue instanceof PCell ) {
216
222
continue ;
0 commit comments