root/trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/MethodClosureInstance.java
| Revision 4002, 2.4 KB (checked in by sukyoungryu, 4 months ago) |
|---|
| Line | |
|---|---|
| 1 | /******************************************************************************* |
| 2 | Copyright 2009 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 com.sun.fortress.interpreter.evaluator.Environment; |
| 21 | import com.sun.fortress.interpreter.evaluator.types.FType; |
| 22 | import com.sun.fortress.nodes.Applicable; |
| 23 | |
| 24 | import java.util.List; |
| 25 | |
| 26 | /** |
| 27 | * A MethodClosureInstance is the result of instantiating an object generic method. |
| 28 | * Its environment is unusual. |
| 29 | * |
| 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, |
| 38 | Environment genericEnv, |
| 39 | Applicable fndef, |
| 40 | FType definer, |
| 41 | List<FType> args, |
| 42 | GenericMethod generator) { |
| 43 | super(within, fndef, definer, args); |
| 44 | this.generator = generator; |
| 45 | this.genericEnv = genericEnv; |
| 46 | if (!genericEnv.getBlessed()) { |
| 47 | System.out.println( |
| 48 | "Creating a MethodClosureInstance for " + fndef + args + "with unblessed genericEnv " + genericEnv); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | public Environment getEvalEnv() { |
| 53 | return genericEnv; |
| 54 | } |
| 55 | |
| 56 | // The choice of evaluation environment is the only difference between applying |
| 57 | // a MethodClosure and applying its subclass, a PartiallyDefinedMethod (which |
| 58 | // appears to actually represent some piece of a functional method in practice). |
| 59 | @Override |
| 60 | protected Environment envForApplication(FObject selfValue) { |
| 61 | return selfValue.getLexicalEnv().genericLeafEnvHack(genericEnv); |
| 62 | } |
| 63 | |
| 64 | public GenericMethod getGenerator() { |
| 65 | return generator; |
| 66 | } |
| 67 | |
| 68 | } |
Note: See TracBrowser
for help on using the browser.

