public LocalVariable findVariable ( String name , int depth ) { LocalVariable variable = localVariables . get ( name ) ; if ( variable != null ) { // Destined scope need adjusted variable since it need to know how deep to look for it. if ( depth != 0 ) { return new LocalVariable ( name , variable . getOffset ( ) , depth ) ; } return variable ; } if ( parent != null ) { return parent . findVariable ( name , depth + 1 ) ; } return null ; }
Tries to find a variable or returns null if it cannot . This will walk all scopes to find a captured variable .