| 312 | } |
| 313 | |
| 314 | void fxScopeLookup(txScope* self, txAccessNode* access, txBoolean closureFlag) |
| 315 | { |
| 316 | txDeclareNode* declaration; |
| 317 | if (self->token == XS_TOKEN_EVAL) { |
| 318 | declaration = fxScopeGetDeclareNode(self, access->symbol); |
| 319 | if (declaration) { |
| 320 | if ((!(self->flags & mxStrictFlag)) && ((declaration->description->token == XS_TOKEN_VAR) || (declaration->description->token == XS_TOKEN_DEFINE))) { |
| 321 | declaration = C_NULL; |
| 322 | } |
| 323 | else if (closureFlag) |
| 324 | declaration->flags |= mxDeclareNodeClosureFlag; |
| 325 | } |
| 326 | else if ((self->flags & mxStrictFlag) && (access->description->token == XS_TOKEN_PRIVATE_MEMBER)) { |
| 327 | declaration = fxDeclareNodeNew(self->parser, XS_TOKEN_PRIVATE, access->symbol); |
| 328 | declaration->flags |= mxDeclareNodeClosureFlag; |
| 329 | declaration->line = access->line; |
| 330 | fxScopeAddDeclareNode(self, declaration); |
| 331 | self->closureNodeCount++; |
| 332 | } |
| 333 | access->declaration = declaration; |
| 334 | } |
| 335 | else if (self->token == XS_TOKEN_FUNCTION) { |
| 336 | declaration = fxScopeGetDeclareNode(self, access->symbol); |
| 337 | if (declaration) { |
| 338 | if (closureFlag) |
| 339 | declaration->flags |= mxDeclareNodeClosureFlag; |
| 340 | access->declaration = declaration; |
| 341 | } |
| 342 | else if ((self->node->flags & mxEvalFlag) && !(self->node->flags & mxStrictFlag)) { |
| 343 | // eval can create variables that override closures |
| 344 | access->declaration = C_NULL; |
| 345 | } |
| 346 | else if (self->scope) { |
| 347 | fxScopeLookup(self->scope, access, 1); |
| 348 | if (access->declaration) { |
| 349 | txDeclareNode* closureNode = fxDeclareNodeNew(self->parser, XS_NO_TOKEN, access->symbol); |
| 350 | closureNode->flags |= mxDeclareNodeClosureFlag | mxDeclareNodeUseClosureFlag; |
| 351 | closureNode->line = access->declaration->line; |
| 352 | closureNode->declaration = access->declaration; |
| 353 | fxScopeAddDeclareNode(self, closureNode); |
| 354 | self->closureNodeCount++; |
| 355 | access->declaration = closureNode; |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | else if (self->token == XS_TOKEN_PROGRAM) { |
| 360 | declaration = fxScopeGetDeclareNode(self, access->symbol); |
| 361 | if (declaration && ((declaration->description->token == XS_TOKEN_VAR) || (declaration->description->token == XS_TOKEN_DEFINE))) { |
| 362 | declaration = C_NULL; |
| 363 | } |
| 364 | access->declaration = declaration; |
| 365 | } |
| 366 | else if (self->token == XS_TOKEN_WITH) { |
| 367 | // with object can have properties that override variables |
| 368 | access->declaration = C_NULL; |
| 369 | } |
| 370 | else { |
| 371 | declaration = fxScopeGetDeclareNode(self, access->symbol); |
no test coverage detected