Resolve a variable relative to a This reference. This is the general variable resolution method, accommodating special fields from the This context. Together the namespace and interpreter comprise the This context. The callstack, if available allows for the this.caller construct. Opti
( CallStack callstack, NameSpace thisNameSpace, Interpreter interpreter, String varName, boolean specialFieldsVisible )
| 466 | same as the top of the stack? |
| 467 | */ |
| 468 | Object resolveThisFieldReference( |
| 469 | CallStack callstack, NameSpace thisNameSpace, Interpreter interpreter, |
| 470 | String varName, boolean specialFieldsVisible ) |
| 471 | throws UtilEvalError |
| 472 | { |
| 473 | if ( varName.equals("this") ) |
| 474 | { |
| 475 | /* |
| 476 | Somewhat of a hack. If the special fields are visible (we're |
| 477 | operating relative to a 'this' type already) dissallow further |
| 478 | .this references to prevent user from skipping to things like |
| 479 | super.this.caller |
| 480 | */ |
| 481 | if ( specialFieldsVisible ) |
| 482 | throw new UtilEvalError("Redundant to call .this on This type"); |
| 483 | |
| 484 | // Allow getThis() to work through BlockNameSpace to the method |
| 485 | // namespace |
| 486 | // XXX re-eval this... do we need it? |
| 487 | This ths = thisNameSpace.getThis( interpreter ); |
| 488 | thisNameSpace= ths.getNameSpace(); |
| 489 | Object result = ths; |
| 490 | |
| 491 | NameSpace classNameSpace = getClassNameSpace( thisNameSpace ); |
| 492 | if ( classNameSpace != null ) |
| 493 | { |
| 494 | if ( isCompound( evalName ) ) |
| 495 | result = classNameSpace.getThis( interpreter ); |
| 496 | else |
| 497 | result = classNameSpace.getClassInstance(); |
| 498 | } |
| 499 | |
| 500 | return result; |
| 501 | } |
| 502 | |
| 503 | /* |
| 504 | Some duplication for "super". See notes for "this" above |
| 505 | If we're in an enclsing class instance and have a superclass |
| 506 | instance our super is the superclass instance. |
| 507 | */ |
| 508 | if ( varName.equals("super") ) |
| 509 | { |
| 510 | //if ( specialFieldsVisible ) |
| 511 | //throw new UtilEvalError("Redundant to call .this on This type"); |
| 512 | |
| 513 | // Allow getSuper() to through BlockNameSpace to the method's super |
| 514 | This ths = thisNameSpace.getSuper( interpreter ); |
| 515 | thisNameSpace = ths.getNameSpace(); |
| 516 | // super is now the closure's super or class instance |
| 517 | |
| 518 | // XXXX re-evaluate this |
| 519 | // can getSuper work by itself now? |
| 520 | // If we're a class instance and the parent is also a class instance |
| 521 | // then super means our parent. |
| 522 | if ( |
| 523 | thisNameSpace.getParent() != null |
| 524 | && thisNameSpace.getParent().isClass |
| 525 | ) |
no test coverage detected