@@ -214,10 +214,10 @@ private static int extractStackSize(RootNode rootNode) {
214
214
}
215
215
216
216
private void extractArgStats () {
217
- String [] freevars = getFreeVars (rootNode );
218
- String [] cellvars = getCellVars (rootNode );
219
- Set <String > freeVarsSet = asSet (freevars );
220
- Set <String > cellVarsSet = asSet (cellvars );
217
+ this . freevars = getFreeVars (rootNode );
218
+ this . cellvars = getCellVars (rootNode );
219
+ Set <String > freeVarsSet = asSet (( String []) freevars );
220
+ Set <String > cellVarsSet = asSet (( String []) cellvars );
221
221
222
222
List <ReadKeywordNode > readKeywordNodes = NodeUtil .findAllNodeInstances (rootNode , ReadKeywordNode .class );
223
223
List <ReadIndexedArgumentNode > readIndexedArgumentNodes = NodeUtil .findAllNodeInstances (rootNode , ReadIndexedArgumentNode .class );
@@ -229,52 +229,49 @@ private void extractArgStats() {
229
229
allArgNames .addAll (kwNames );
230
230
allArgNames .addAll (argNames );
231
231
232
- int argcount = readIndexedArgumentNodes .size ();
233
- int kwonlyargcount = 0 ;
234
- int flags = 0 ;
232
+ this . argcount = readIndexedArgumentNodes .size ();
233
+ this . kwonlyargcount = 0 ;
234
+ this . flags = 0 ;
235
235
236
236
for (ReadKeywordNode kwNode : readKeywordNodes ) {
237
237
if (!kwNode .canBePositional ()) {
238
238
kwonlyargcount ++;
239
239
}
240
240
}
241
241
242
- Set <String > varnames = new HashSet <>();
242
+ Set <String > varnamesSet = new HashSet <>();
243
243
for (Object identifier : rootNode .getFrameDescriptor ().getIdentifiers ()) {
244
244
if (identifier instanceof String ) {
245
245
String varName = (String ) identifier ;
246
246
247
247
if (core .getParser ().isIdentifier (core , varName )) {
248
248
if (allArgNames .contains (varName )) {
249
- varnames .add (varName );
249
+ varnamesSet .add (varName );
250
250
} else if (!freeVarsSet .contains (varName ) && !cellVarsSet .contains (varName )) {
251
- varnames .add (varName );
251
+ varnamesSet .add (varName );
252
252
}
253
253
}
254
254
}
255
255
}
256
256
257
- // set the flags
257
+ // 0x20 - generator
258
+ RootNode funcRootNode = rootNode ;
259
+ if (funcRootNode instanceof GeneratorFunctionRootNode ) {
260
+ flags |= (1 << 5 );
261
+ funcRootNode = ((GeneratorFunctionRootNode ) funcRootNode ).getFunctionRootNode ();
262
+ }
263
+
258
264
// 0x04 - *arguments
259
- if (NodeUtil .findAllNodeInstances (rootNode , ReadVarArgsNode .class ).size () == 1 ) {
265
+ if (NodeUtil .findAllNodeInstances (funcRootNode , ReadVarArgsNode .class ).size () == 1 ) {
260
266
flags |= (1 << 2 );
261
267
}
262
268
// 0x08 - **keywords
263
- if (NodeUtil .findAllNodeInstances (rootNode , ReadVarKeywordsNode .class ).size () == 1 ) {
269
+ if (NodeUtil .findAllNodeInstances (funcRootNode , ReadVarKeywordsNode .class ).size () == 1 ) {
264
270
flags |= (1 << 3 );
265
271
}
266
- // 0x20 - generator
267
- if (rootNode instanceof GeneratorFunctionRootNode ) {
268
- flags |= (1 << 5 );
269
- }
270
272
271
- this .argcount = argcount ;
272
- this .kwonlyargcount = kwonlyargcount ;
273
- this .freevars = freevars ;
274
- this .cellvars = cellvars ;
275
- this .varnames = varnames .toArray ();
276
- this .nlocals = varnames .size ();
277
- this .flags = flags ;
273
+ this .varnames = varnamesSet .toArray ();
274
+ this .nlocals = varnamesSet .size ();
278
275
}
279
276
280
277
public RootNode getRootNode () {
0 commit comments