Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Variable lookupVariable(String id) {
- /*
- * A variable lookup can only occur inside a method or a class.
- * Everything else is invalid.
- */
- /*
- * TODO: improve this hack!
- */
- Variable variable;
- Scopeable currentScope = this.currentScope();
- Scopeable outerScope = this.currentScope().getOuterScope();
- if((variable = currentScope.lookupVariable(id)) != null){ // check local scope
- return variable;
- } else if(outerScope != null) { // check class scope / outer scope
- Identifier classId;
- if((variable = outerScope.lookupVariable(id)) != null) {
- return variable;
- } else if(outerScope.isClass() && (classId = outerScope.getId()) != null) { // check parent class scope
- Klass klass = this.globalScope().lookupClass(classId.toString());
- Klass derivedClass;
- if(klass.isDerived() && (derivedClass = this.globalScope().lookupClass(klass.getDerivedId())) != null) {
- if((variable = derivedClass.lookupVariable(id)) != null) {
- return variable;
- }
- }
- }
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement