63 lines
1.7 KiB
Java
63 lines
1.7 KiB
Java
/*
|
|
* The contents of this file are subject to the Netscape Public
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.mozilla.org/NPL/
|
|
*
|
|
* Software distributed under the License is distributed on an "AS
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
* implied. See the License for the specific language governing
|
|
* rights and limitations under the License.
|
|
*
|
|
* The Original Code is mozilla.org code.
|
|
*
|
|
* The Initial Developer of the Original Code is Mountain View Compiler
|
|
* Company. Portions created by Mountain View Compiler Company are
|
|
* Copyright (C) 1998-2000 Mountain View Compiler Company. All
|
|
* Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
* Jeff Dyer <jeff@compilercompany.com>
|
|
*/
|
|
|
|
package com.compilercompany.ecmascript;
|
|
import java.util.Vector;
|
|
|
|
/**
|
|
* A code value (intermediate).
|
|
*
|
|
* This value holds the intermediate code for an non-constant value.
|
|
*/
|
|
|
|
public class CodeValue extends Value {
|
|
|
|
private static final boolean debug = false;
|
|
private Node node;
|
|
|
|
public CodeValue( Node node ) {
|
|
this.node = node;
|
|
}
|
|
|
|
public String toString() {
|
|
return "code("+node+")";
|
|
}
|
|
|
|
/**
|
|
* The result depends on during what phase this function
|
|
* is called. At compile time it will either return itself,
|
|
* or a compile-time constant value. At runtime it will
|
|
* return a runtime value.
|
|
*/
|
|
|
|
public Value getValue(Context context) throws Exception {
|
|
|
|
// ACTION: execute the code to get the value.
|
|
|
|
return node.evaluate(context,context.evaluator);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* The end.
|
|
*/
|