KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > neu > ccs > jmk > Environment


1 // $Id: Environment.java,v 1.1.1.1 2000/09/26 11:20:34 ramsdell Exp $
2

3 // Environments
4

5 /*
6  * Copyright 1999 by John D. Ramsdell
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 package edu.neu.ccs.jmk;
24
25 /**
26  * Environments used during expression evaluation.
27  * An environment is a list of arrays of values.
28  * @version May 1999
29  * @author John D. Ramsdell
30  */

31 final class Environment
32 {
33   private /* final */ Environment parent;
34   private /* final */ Value[] rib;
35
36   Environment (Environment parent, Value[] rib) {
37     this.parent = parent;
38     this.rib = rib;
39   }
40
41   static Value lookup(Environment env, int up, int offset) {
42     for(; up > 0; up--)
43       env = env.parent;
44     return env.rib[offset];
45   }
46 }
47
Popular Tags