@@ -317,38 +317,50 @@ class Parser {
317317 }
318318 }
319319
320- ASTScopeContext* popScopeContext (ASTScopeContext* lastPushedScopeContext)
321- {
322- auto ret = this ->currentScopeContext ;
323- this ->lastUsingName = AtomicString ();
324- this ->lastPoppedScopeContext = ret;
325- this ->currentScopeContext = lastPushedScopeContext;
326320#ifndef ESCARGOT_DEBUGGER
327- ASTScopeContext* scopeCtx = ret;
321+ void setParameterUsedValue (ASTScopeContext* scopeCtx)
322+ {
328323 while (scopeCtx) {
329- if (!scopeCtx->m_parameters .size ()) {
330- scopeCtx->m_parameterUsed = 0xFFFF ;
331- }
332-
333- if (scopeCtx->m_parameterUsed == 0xFFFF ) {
334- scopeCtx = scopeCtx->m_parentScope ;
335- continue ;
336- }
324+ for (size_t i = 0 ; i < this ->currentScopeContext ->m_parameters .size (); i++) {
325+ if (this ->currentScopeContext ->m_parameterUsed == 0xFFFF ) {
326+ break ;
327+ }
337328
338- for (size_t i = 0 ; i < scopeCtx->m_parameters .size (); i++) {
339- AtomicString paramName = scopeCtx->m_parameters [i];
340- for (size_t j = 0 ; j < ret->m_childBlockScopes .size (); j++) {
341- ASTBlockContext* block = ret->m_childBlockScopes [j];
342- if (VectorUtil::findInVector (block->m_usingNames , paramName) != VectorUtil::invalidIndex) {
343- scopeCtx->m_parameterUsed |= (1 << i);
329+ AtomicString name = this ->currentScopeContext ->m_parameters [i];
330+ for (size_t j = 0 ; j < scopeCtx->m_childBlockScopes .size (); j++) {
331+ ASTBlockContext* blockCtx = scopeCtx->m_childBlockScopes [j];
332+ if (VectorUtil::findInVector (blockCtx->m_usingNames , name) != VectorUtil::invalidIndex) {
333+ this ->currentScopeContext ->m_parameterUsed |= (1 << i);
334+ break ;
335+ } else if (UNLIKELY (VectorUtil::findInVector (blockCtx->m_usingNames , stringArguments) != VectorUtil::invalidIndex)) {
336+ this ->currentScopeContext ->m_parameterUsed = 0xFFFF ;
344337 break ;
345338 }
346339 }
347340 }
348341
349- scopeCtx = scopeCtx->m_parentScope ;
342+ if (scopeCtx->firstChild ()) {
343+ setParameterUsedValue (scopeCtx->firstChild ());
344+ }
345+
346+ if (scopeCtx != this ->currentScopeContext ) {
347+ scopeCtx = scopeCtx->nextSibling ();
348+ } else {
349+ break ;
350+ }
350351 }
352+ }
353+ #endif
354+
355+ ASTScopeContext* popScopeContext (ASTScopeContext* lastPushedScopeContext)
356+ {
357+ #ifndef ESCARGOT_DEBUGGER
358+ setParameterUsedValue (this ->currentScopeContext );
351359#endif
360+ auto ret = this ->currentScopeContext ;
361+ this ->lastUsingName = AtomicString ();
362+ this ->lastPoppedScopeContext = ret;
363+ this ->currentScopeContext = lastPushedScopeContext;
352364 return ret;
353365 }
354366
@@ -381,10 +393,6 @@ class Parser {
381393 parentContext->appendChild (this ->currentScopeContext );
382394 }
383395
384- #ifndef ESCARGOT_DEBUGGER
385- this ->currentScopeContext ->m_parentScope = parentContext;
386- #endif
387-
388396 return parentContext;
389397 }
390398
@@ -1075,16 +1083,6 @@ class Parser {
10751083 }
10761084 }
10771085
1078- #ifndef ESCARGOT_DEBUGGER
1079- if (UNLIKELY (ret->asIdentifier ()->name () == this ->stringArguments )) {
1080- ASTScopeContext* scopeCtx = this ->currentScopeContext ;
1081- while (scopeCtx) {
1082- scopeCtx->m_parameterUsed = 0xFFFF ;
1083- scopeCtx = scopeCtx->m_parentScope ;
1084- }
1085- }
1086- #endif
1087-
10881086 if (this ->trackUsingNames ) {
10891087 this ->insertUsingName (ret->asIdentifier ()->name ());
10901088 }
@@ -1755,9 +1753,6 @@ class Parser {
17551753 this ->currentScopeContext ->m_parameterCount = 1 ;
17561754 this ->currentScopeContext ->m_parameters .resizeWithUninitializedValues (1 );
17571755 this ->currentScopeContext ->m_parameters [0 ] = className;
1758- #ifndef ESCARGOT_DEBUGGER
1759- this ->currentScopeContext ->m_parameterUsed |= 1 ;
1760- #endif
17611756 this ->currentScopeContext ->insertVarName (className, 0 , true , true , true );
17621757 }
17631758
@@ -3584,9 +3579,6 @@ class Parser {
35843579 this ->currentScopeContext ->m_parameterCount = 1 ;
35853580 this ->currentScopeContext ->m_parameters .resizeWithUninitializedValues (1 );
35863581 this ->currentScopeContext ->m_parameters [0 ] = paramName;
3587- #ifndef ESCARGOT_DEBUGGER
3588- this ->currentScopeContext ->m_parameterUsed |= 1 ;
3589- #endif
35903582 this ->currentScopeContext ->insertVarName (paramName, 0 , true , true , true );
35913583 }
35923584
@@ -5108,7 +5100,7 @@ class Parser {
51085100 }
51095101 case RestElement: {
51105102#ifndef ESCARGOT_DEBUGGER
5111- if (this ->codeBlock ->parameterUsed () & (1 << paramIndex) || param-> asRestElement ()-> argument ()-> type () != Identifier || this -> codeBlock -> parameterUsed () == 0xFFFF ) {
5103+ if (this ->codeBlock ->parameterUsed () & (1 << paramIndex) || this -> codeBlock -> parameterUsed () == 0xFFFF || param-> asRestElement ()-> argument ()-> type () != Identifier ) {
51125104#endif
51135105 Node* statement = this ->finalize (node, builder.createExpressionStatementNode (param));
51145106 container->appendChild (statement);
0 commit comments