com.caucho.quercus.expr
Class Expr

java.lang.Object
  extended by com.caucho.quercus.expr.Expr
Direct Known Subclasses:
AbstractBinaryExpr, AbstractLongValuedExpr, AbstractMethodExpr, AbstractUnaryExpr, AbstractVarExpr, ArrayIsSetExpr, ArrayUnsetExpr, BinaryAppendExpr, BinaryAssignExpr, BinaryAssignListEachExpr, BinaryAssignListExpr, BinaryAssignRefExpr, BinarySetCharAtExprPro, CallExpr, CallVarExpr, ClassConstExpr, ClassConstructorExpr, ClassVarConstExpr, ClassVarMethodExpr, ClassVarMethodVarExpr, ClassVirtualConstExpr, ClassVirtualMethodExpr, ClassVirtualMethodVarExpr, ClosureExpr, ConditionalExpr, ConditionalShortExpr, ConstDirExpr, ConstExpr, ConstFileExpr, DieExpr, FunArrayExpr, FunDieExpr, FunExitExpr, FunGetCalledClassExpr, FunGetClassExpr, ImportExpr, JavaCodeExprPro, ListHeadExpr, LiteralExpr, LiteralLongExpr, LiteralNullExpr, LiteralStringExpr, LiteralUnicodeExpr, ObjectMethodVarExpr, ObjectNewExpr, ObjectNewVarExpr, ParamDefaultExpr, ParamRequiredExpr, UnaryUnsetExpr, VarUnsetExpr

public abstract class Expr
extends java.lang.Object

Represents a PHP expression.


Field Summary
static int COMPILE_ARG_MAX
           
 
Constructor Summary
Expr()
           
Expr(Location location)
           
 
Method Summary
 void assign(QuercusParser parser)
          Mark as an assignment for a list()
 boolean canRead()
          Returns true for an expression that can be read (only $a[] uses this)
 Expr createAssign(QuercusParser parser, Expr value)
           
 Expr createAssignFrom(QuercusParser parser, AbstractVarExpr leftHandSide)
          Creates an assignment using this value as the right hand side.
 Expr createAssignRef(QuercusParser parser, Expr value)
           
 Expr createCall(QuercusParser parser, Location location, java.util.ArrayList<Expr> args)
          Creates a function call expression
 Expr createClassConst(QuercusParser parser, java.lang.String name)
          Creates a class field $class::foo
 Expr createClassField(QuercusParser parser, Expr name)
          Creates a class field $class::${foo}
 Expr createClassField(QuercusParser parser, java.lang.String name)
          Creates a class field $class::$foo
 Expr createCopy(ExprFactory factory)
          Creates a assignment
 Expr createDeref(ExprFactory factory)
           
 Expr createFieldGet(ExprFactory factory, Expr name)
          Creates a field ref
 Expr createFieldGet(ExprFactory factory, StringValue name)
          Creates a field ref
 Expr createIsset(ExprFactory factory)
          Creates an isset expression
 Expr createRef(QuercusParser parser)
          Creates a reference.
 Statement createUnset(ExprFactory factory, Location location)
          Creates a assignment
abstract  Value eval(Env env)
          Evaluates the expression, returning a Value, never a Var.
 Value evalArg(Env env, boolean isTop)
          Evaluates the expression as a function argument where it is unknown if the value will be used as a reference.
static Value[] evalArgs(Env env, Expr[] exprs)
          Evaluates arguments
 Value evalArray(Env env)
          Evaluates the expression, creating an array for unassigned values.
 Value evalArrayAssign(Env env, Value index, Value value)
          Evaluates as an array index assign ($a[index] = value).
 Value evalAssignRef(Env env, Value value)
          Evaluates an assignment.
 Value evalAssignValue(Env env, Value value)
          Evaluates an assignment.
 boolean evalBoolean(Env env)
          Evaluates the expression as a boolean.
 char evalChar(Env env)
          Evaluates the expression as a string
 Value evalConstant()
          Evaluates the expression as a constant.
 Value evalConstantPrefix()
          Evaluates as a constant prefix.
 Value evalConstantSuffix()
          Evaluates as a constant prefix.
 Value evalCopy(Env env)
          Evaluates the expression as a copy.
 Value evalDirty(Env env)
          Evaluates the expression, with the object expected to be modified, e.g.
 double evalDouble(Env env)
          Evaluates the expression as a double
 boolean evalIsset(Env env)
          Evaluates the expression as an isset() statement.
 long evalLong(Env env)
          Evaluates the expression as a long
 Value evalObject(Env env)
          Evaluates the expression, creating an object for unassigned values.
 Value evalPostIncrement(Env env, int incr)
          Handles post increments.
 Value evalPreIncrement(Env env, int incr)
          Handles post increments.
 Value evalRef(Env env)
          Evaluates the expression, returning a Var for variables, and a Value for values.
 java.lang.String evalString(Env env)
          Evaluates the expression as a string
 StringValue evalStringValue(Env env)
          Evaluates the expression as a string value
 Value evalTop(Env env)
          Evaluates the expression.
 void evalUnsetArray(Env env, Value index)
          Evaluates the expression as an array index unset
 Value evalValue(Env env)
          Evaluates the expression, returning a Value.
 Var evalVar(Env env)
          Evaluates the expression, always returning a variable.
 java.lang.String getFileName()
          Returns the filename.
 java.lang.String getFunctionLocation()
          Returns the function name.
 int getLine()
          Returns the line number in the file.
 Location getLocation()
          Returns the location.
 java.lang.String getLocationLine()
          Returns the file name and line number, if location is known.
 boolean isArray()
          Returns true if the expression evaluates to an array.
 boolean isAssign()
           
 boolean isBoolean()
          Returns true if the expression evaluates to a boolean.
 boolean isConstant()
          Returns true for a constant expression.
 boolean isDouble()
          Returns true if the expression evaluates to a double.
 boolean isFalse()
          Returns true if a static false value.
 boolean isLiteral()
          Returns true for a literal expression.
 boolean isLong()
          Returns true if the expression evaluates to a long.
 boolean isNumber()
          Returns true if the expression evaluates to a number.
 boolean isRef()
          Returns true for a reference.
 boolean isString()
          Returns true if the expression evaluates to a string.
 boolean isTrue()
          Returns true if a static true value.
 boolean isVar()
          Returns true if the expression is a var/left-hand-side.
 void print(Env env)
          Prints to the output as an echo.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPILE_ARG_MAX

public static final int COMPILE_ARG_MAX
See Also:
Constant Field Values
Constructor Detail

Expr

public Expr(Location location)

Expr

public Expr()
Method Detail

getLocation

public final Location getLocation()
Returns the location.


getFileName

public java.lang.String getFileName()
Returns the filename.


getLine

public int getLine()
Returns the line number in the file.


getFunctionLocation

public java.lang.String getFunctionLocation()
Returns the function name.


getLocationLine

public java.lang.String getLocationLine()
Returns the file name and line number, if location is known.


isRef

public boolean isRef()
Returns true for a reference.


isConstant

public boolean isConstant()
Returns true for a constant expression.


isLiteral

public boolean isLiteral()
Returns true for a literal expression.


isTrue

public boolean isTrue()
Returns true if a static true value.


isFalse

public boolean isFalse()
Returns true if a static false value.


isAssign

public boolean isAssign()

canRead

public boolean canRead()
Returns true for an expression that can be read (only $a[] uses this)


isBoolean

public boolean isBoolean()
Returns true if the expression evaluates to a boolean.


isLong

public boolean isLong()
Returns true if the expression evaluates to a long.


isDouble

public boolean isDouble()
Returns true if the expression evaluates to a double.


isNumber

public boolean isNumber()
Returns true if the expression evaluates to a number.


isString

public boolean isString()
Returns true if the expression evaluates to a string.


isArray

public boolean isArray()
Returns true if the expression evaluates to an array.


isVar

public boolean isVar()
Returns true if the expression is a var/left-hand-side.


createAssign

public Expr createAssign(QuercusParser parser,
                         Expr value)
                  throws java.io.IOException
Throws:
java.io.IOException

createAssignFrom

public Expr createAssignFrom(QuercusParser parser,
                             AbstractVarExpr leftHandSide)
Creates an assignment using this value as the right hand side.


assign

public void assign(QuercusParser parser)
            throws java.io.IOException
Mark as an assignment for a list()

Throws:
java.io.IOException

createAssignRef

public Expr createAssignRef(QuercusParser parser,
                            Expr value)
                     throws java.io.IOException
Throws:
java.io.IOException

createRef

public Expr createRef(QuercusParser parser)
               throws java.io.IOException
Creates a reference.

Parameters:
location -
Throws:
java.io.IOException

createDeref

public Expr createDeref(ExprFactory factory)
                 throws java.io.IOException
Throws:
java.io.IOException

createCopy

public Expr createCopy(ExprFactory factory)
Creates a assignment

Parameters:
location -

createFieldGet

public Expr createFieldGet(ExprFactory factory,
                           StringValue name)
Creates a field ref


createFieldGet

public Expr createFieldGet(ExprFactory factory,
                           Expr name)
Creates a field ref


createClassConst

public Expr createClassConst(QuercusParser parser,
                             java.lang.String name)
Creates a class field $class::foo


createClassField

public Expr createClassField(QuercusParser parser,
                             java.lang.String name)
Creates a class field $class::$foo


createClassField

public Expr createClassField(QuercusParser parser,
                             Expr name)
Creates a class field $class::${foo}


createUnset

public Statement createUnset(ExprFactory factory,
                             Location location)
                      throws java.io.IOException
Creates a assignment

Throws:
java.io.IOException

createIsset

public Expr createIsset(ExprFactory factory)
                 throws java.io.IOException
Creates an isset expression

Throws:
java.io.IOException

createCall

public Expr createCall(QuercusParser parser,
                       Location location,
                       java.util.ArrayList<Expr> args)
                throws java.io.IOException
Creates a function call expression

Throws:
java.io.IOException

evalConstant

public Value evalConstant()
Evaluates the expression as a constant.

Returns:
the expression value.

evalConstantPrefix

public Value evalConstantPrefix()
Evaluates as a constant prefix.

Returns:
the expression value as a prefix.

evalConstantSuffix

public Value evalConstantSuffix()
Evaluates as a constant prefix.

Returns:
the expression value as a suffix.

eval

public abstract Value eval(Env env)
Evaluates the expression, returning a Value, never a Var.

Parameters:
env - the calling environment.
Returns:
the expression value.

evalVar

public Var evalVar(Env env)
Evaluates the expression, always returning a variable.

Parameters:
env - the calling environment.
Returns:
the expression value.

evalValue

public Value evalValue(Env env)
Evaluates the expression, returning a Value.

Parameters:
env - the calling environment.
Returns:
the expression value.

evalRef

public Value evalRef(Env env)
Evaluates the expression, returning a Var for variables, and a Value for values.

Parameters:
env - the calling environment.
Returns:
the expression value.

evalCopy

public Value evalCopy(Env env)
Evaluates the expression as a copy. The default is not to copy because the absence of copying is more testable.

Parameters:
env - the calling environment.
Returns:
the expression value.

evalArg

public Value evalArg(Env env,
                     boolean isTop)
Evaluates the expression as a function argument where it is unknown if the value will be used as a reference.

Parameters:
env - the calling environment.
isTail - true for the top expression
Returns:
the expression value.

evalTop

public Value evalTop(Env env)
Evaluates the expression.

Parameters:
env - the calling environment.
Returns:
the expression value.

evalDirty

public Value evalDirty(Env env)
Evaluates the expression, with the object expected to be modified, e.g. from an unset.

Parameters:
env - the calling environment.
Returns:
the expression value.

evalArray

public Value evalArray(Env env)
Evaluates the expression, creating an array for unassigned values.

Parameters:
env - the calling environment.
Returns:
the expression value.

evalObject

public Value evalObject(Env env)
Evaluates the expression, creating an object for unassigned values.

Parameters:
env - the calling environment.
Returns:
the expression value.

evalAssignValue

public Value evalAssignValue(Env env,
                             Value value)
Evaluates an assignment. The value must not be a Var.


evalAssignRef

public Value evalAssignRef(Env env,
                           Value value)
Evaluates an assignment. If the value is a Var, it replaces the current Var.


evalArrayAssign

public Value evalArrayAssign(Env env,
                             Value index,
                             Value value)
Evaluates as an array index assign ($a[index] = value).

Returns:
what was assigned

evalPostIncrement

public Value evalPostIncrement(Env env,
                               int incr)
Handles post increments.


evalPreIncrement

public Value evalPreIncrement(Env env,
                              int incr)
Handles post increments.


evalString

public java.lang.String evalString(Env env)
Evaluates the expression as a string

Parameters:
env - the calling environment.
Returns:
the expression value.

evalStringValue

public StringValue evalStringValue(Env env)
Evaluates the expression as a string value

Parameters:
env - the calling environment.
Returns:
the expression value.

evalChar

public char evalChar(Env env)
Evaluates the expression as a string

Parameters:
env - the calling environment.
Returns:
the expression value.

evalBoolean

public boolean evalBoolean(Env env)
Evaluates the expression as a boolean.

Parameters:
env - the calling environment.
Returns:
the expression value.

evalLong

public long evalLong(Env env)
Evaluates the expression as a long

Parameters:
env - the calling environment.
Returns:
the expression value.

evalDouble

public double evalDouble(Env env)
Evaluates the expression as a double

Parameters:
env - the calling environment.
Returns:
the expression value.

evalIsset

public boolean evalIsset(Env env)
Evaluates the expression as an isset() statement.


evalUnsetArray

public void evalUnsetArray(Env env,
                           Value index)
Evaluates the expression as an array index unset


evalArgs

public static Value[] evalArgs(Env env,
                               Expr[] exprs)
Evaluates arguments


print

public void print(Env env)
           throws java.io.IOException
Prints to the output as an echo.

Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object