Skip to content

Commit d6a98de

Browse files
committed
LocalsStorage: fix forEachUntyped message (skip non user frame slots)
1 parent 26f676c commit d6a98de

File tree

1 file changed

+11
-8
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common

1 file changed

+11
-8
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/LocalsStorage.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
*/
4141
package com.oracle.graal.python.builtins.objects.common;
4242

43+
import static com.oracle.graal.python.nodes.frame.FrameSlotIDs.isUserFrameSlot;
44+
4345
import java.util.Iterator;
4446
import java.util.List;
4547
import java.util.NoSuchElementException;
@@ -51,7 +53,6 @@
5153
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
5254
import com.oracle.graal.python.builtins.objects.str.PString;
5355
import com.oracle.graal.python.nodes.PGuards;
54-
import com.oracle.graal.python.nodes.frame.FrameSlotIDs;
5556
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
5657
import com.oracle.truffle.api.CompilerDirectives;
5758
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
@@ -117,7 +118,7 @@ private void calculateLength() {
117118
this.len = this.frame.getFrameDescriptor().getSize();
118119
for (FrameSlot slot : this.frame.getFrameDescriptor().getSlots()) {
119120
Object identifier = slot.getIdentifier();
120-
if (!FrameSlotIDs.isUserFrameSlot(identifier) || getValue(frame, slot) == null) {
121+
if (!isUserFrameSlot(identifier) || getValue(frame, slot) == null) {
121122
this.len--;
122123
}
123124
}
@@ -137,7 +138,7 @@ static Object getItemCached(LocalsStorage self, String key, ThreadState state,
137138

138139
@Specialization(replaces = "getItemCached")
139140
static Object string(LocalsStorage self, String key, ThreadState state) {
140-
if (!FrameSlotIDs.isUserFrameSlot(key)) {
141+
if (!isUserFrameSlot(key)) {
141142
return null;
142143
}
143144
FrameSlot slot = findSlot(self, key);
@@ -219,9 +220,11 @@ public Object forEachUntyped(ForEachNode<Object> node, Object arg) {
219220
bailout();
220221
Object result = arg;
221222
for (FrameSlot slot : this.frame.getFrameDescriptor().getSlots()) {
222-
Object value = getValue(slot);
223-
if (value != null) {
224-
result = node.execute(slot.getIdentifier(), result);
223+
if (isUserFrameSlot(slot)) {
224+
Object value = getValue(slot);
225+
if (value != null) {
226+
result = node.execute(slot.getIdentifier(), result);
227+
}
225228
}
226229
}
227230
return result;
@@ -372,7 +375,7 @@ protected boolean loadNext() {
372375
FrameSlot nextCandidate = this.slots.get(this.index++);
373376
Object identifier = nextCandidate.getIdentifier();
374377
if (identifier instanceof String) {
375-
if (FrameSlotIDs.isUserFrameSlot(identifier)) {
378+
if (isUserFrameSlot(identifier)) {
376379
Object nextValue = getValue(this.frame, nextCandidate);
377380
if (nextValue != null) {
378381
this.nextFrameSlot = nextCandidate;
@@ -399,7 +402,7 @@ protected boolean loadNext() {
399402
FrameSlot nextCandidate = this.slots.get(this.index--);
400403
Object identifier = nextCandidate.getIdentifier();
401404
if (identifier instanceof String) {
402-
if (FrameSlotIDs.isUserFrameSlot(identifier)) {
405+
if (isUserFrameSlot(identifier)) {
403406
Object nextValue = getValue(this.frame, nextCandidate);
404407
if (nextValue != null) {
405408
this.nextFrameSlot = nextCandidate;

0 commit comments

Comments
 (0)