Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. public Variable search(String name) {
  2.         ListIterator<ArrayList<Variable>> blocks = stack.listIterator(stack.size());
  3.         while(blocks.hasPrevious()) {
  4.             ArrayList<Variable> block = blocks.previous();
  5.             for(Variable v : block) {
  6.                 if( v.get_name().equals(name) ) {
  7.                     return v;
  8.                 }
  9.             }
  10.         }
  11.         return null;
  12.     }
  13.  
  14.  
  15.  
  16. public Variable search_scope(String name, int _scope) {
  17.         int diff;
  18.        
  19.         if(_scope > scope)
  20.             return null;
  21.  
  22.         if(_scope == 0)
  23.             diff = 0;
  24.         else
  25.             diff = scope - _scope;
  26.         ArrayList<Variable> block = stack.elementAt(diff);
  27.         for(Variable v : block) {      
  28.             if( v.get_name().equals(name) ) {
  29.                 return v;
  30.             }
  31.         }
  32.         return null;
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement