root/trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/MethodClosureInstance.java

Revision 2072, 2.3 kB (checked in by dlsmith, 2 months ago)

Updated ASTGen with improved support for custom extensions. Related bug fixes in ASTGen exposed the fact that the Applicable node class doesn't belong in the Node hierarchy -- there are non-node instances that don't support visiting, for example -- so it was moved to nodes_util. Similarly, Fortress.ast was adjusted to be compatible with clarified semantics of ASTGen.

Line 
1 /*******************************************************************************
2     Copyright 2008 Sun Microsystems, Inc.,
3     4150 Network Circle, Santa Clara, California 95054, U.S.A.
4     All rights reserved.
5
6     U.S. Government Rights - Commercial software.
7     Government users are subject to the Sun Microsystems, Inc. standard
8     license agreement and applicable provisions of the FAR and its supplements.
9
10     Use is subject to license terms.
11
12     This distribution may include materials developed by third parties.
13
14     Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
15     trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
16 ******************************************************************************/
17
18 package com.sun.fortress.interpreter.evaluator.values;
19
20 import java.util.List;
21
22 import com.sun.fortress.interpreter.evaluator.Environment;
23 import com.sun.fortress.interpreter.evaluator.types.FType;
24 import com.sun.fortress.nodes_util.Applicable;
25 import com.sun.fortress.useful.HasAt;
26
27 /**
28  * A MethodClosureInstance is the result of instantiating an object generic method.
29  * Its environment is unusual.
30  * @author chase
31  */
32 public class MethodClosureInstance extends MethodClosure implements MethodInstance {
33
34     GenericMethod generator;
35     Environment genericEnv;
36
37     public MethodClosureInstance(Environment within, Environment genericEnv, Applicable fndef, FType definer, List<FType> args, GenericMethod generator) {
38         super(within, fndef, definer, args);
39         this.generator = generator;
40         this.genericEnv = genericEnv;
41         if (!genericEnv.getBlessed()) {
42             System.out.println("Creating a MethodClosureInstance for "+fndef+args+
43                                "with unblessed genericEnv "+genericEnv);
44         }
45     }
46
47     public Environment getEvalEnv() {
48         return genericEnv;
49     }
50
51     // The choice of evaluation environment is the only difference between applying
52     // a MethodClosure and applying its subclass, a PartiallyDefinedMethod (which
53     // appears to actually represent some piece of a functional method in practice).
54     @Override
55     protected Environment envForApplication(FObject selfValue, HasAt loc) {
56         return selfValue.getLexicalEnv().genericLeafEnvHack(genericEnv, loc);
57     }
58
59     public GenericMethod getGenerator() {
60         return generator;
61     }
62
63 }
Note: See TracBrowser for help on using the browser.