@@ -249,7 +249,8 @@ public boolean visit(Node node) {
249
249
} else if (node instanceof FunctionDefinitionNode ) {
250
250
constants .add (new PCode (PythonBuiltinClassType .PCode , ((FunctionDefinitionNode ) node ).getCallTarget ()));
251
251
} else if (node instanceof GeneratorExpressionNode ) {
252
- constants .add (new PCode (PythonBuiltinClassType .PCode , ((GeneratorExpressionNode ) node ).getCallTarget ()));
252
+ // TODO: we do it this way here since we cannot deserialize generator expressions right now
253
+ constants .addAll (Arrays .asList (extractConstants (((GeneratorExpressionNode ) node ).getCallTarget ().getRootNode ())));
253
254
}
254
255
return true ;
255
256
}
@@ -259,7 +260,19 @@ public boolean visit(Node node) {
259
260
260
261
@ TruffleBoundary
261
262
private static Object [] extractNames (RootNode rootNode ) {
262
- return NodeUtil .findAllNodeInstances (rootNodeForExtraction (rootNode ), GlobalNode .class ).stream ().map ((n ) -> n .getAttributeId ()).distinct ().toArray ();
263
+ List <Object > names = new ArrayList <>();
264
+ rootNode .accept (new NodeVisitor () {
265
+ public boolean visit (Node node ) {
266
+ if (node instanceof GlobalNode ) {
267
+ names .add (((GlobalNode ) node ).getAttributeId ());
268
+ } else if (node instanceof GeneratorExpressionNode ) {
269
+ // TODO: since we do *not* add GeneratorExpressionNodes in #extractConstants, we need to find the names referenced in them here
270
+ names .addAll (Arrays .asList (extractNames (((GeneratorExpressionNode ) node ).getCallTarget ().getRootNode ())));
271
+ }
272
+ return true ;
273
+ }
274
+ });
275
+ return names .toArray ();
263
276
}
264
277
265
278
private static RootNode rootNodeForExtraction (RootNode rootNode ) {
0 commit comments