com.caucho.quercus.expr
Class ExprGenerator

java.lang.Object
  extended by com.caucho.quercus.expr.ExprGenerator
Direct Known Subclasses:
AbstractAssignGenerateExpr, AbstractBinaryGenerateExpr, AbstractMethodGenerator, AbstractUnaryExprGenerator, DummyGenerator

public abstract class ExprGenerator
extends java.lang.Object

Represents compilable PHP expression.


Field Summary
static int COMPILE_ARG_MAX
           
 
Constructor Summary
ExprGenerator()
           
ExprGenerator(Location location)
           
 
Method Summary
abstract  ExprType analyze(AnalyzeInfo info)
          Analyze the expression
 ExprType analyzeAssign(AnalyzeInfo info, ExprGenerator value)
          Analyze the expression
 void analyzeSetModified(AnalyzeInfo info)
          Analyze as modified.
 void analyzeSetPostIncrement()
          Set a post increment
 void analyzeSetReference(AnalyzeInfo info)
          Analyze as reference
 void analyzeTop(AnalyzeInfo info)
          Analyze the expression as a statement
 void analyzeUnset(AnalyzeInfo info)
          Analyze as unset
protected  VarState combineBinaryVarState(VarState leftState, VarState rightState)
          Returns the variables state.
 void generate(PhpWriter out)
          Generates code to evaluate the expression.
 void generateAppend(PhpWriter out)
          Generates code to append to a string builder.
 void generateArg(PhpWriter out, boolean isTop)
          Generates code for a function arg, where the declaration of the argument is unknown.
 void generateArray(PhpWriter out)
          Generates code for a reference that can be used as an array.
 void generateAssign(PhpWriter out, Expr value, boolean isTop)
          Generates code to evaluate the expression
 void generateAssignBoolean(PhpWriter out, Expr value, boolean isTop)
          Generates code to evaluate the expression
 void generateAssignClose(PhpWriter out)
          Generates code to evaluate the expression
 void generateAssignOpen(PhpWriter out)
          Generates code to evaluate the expression
 void generateAssignRef(PhpWriter out, Expr value, boolean isTop)
          Generates code to evaluate the expression
 void generateBoolean(PhpWriter out)
          Generates code to evaluate a boolean directly
 void generateChar(PhpWriter out)
          Generates code to evaluate a string directly
 void generateCopy(PhpWriter out)
          Generates code to recreate the expression.
 void generateDirty(PhpWriter out)
          Generates code to evaluate the expression, expecting a modification.
 void generateDouble(PhpWriter out)
          Generates code to evaluate the expression directly
 void generateExpr(PhpWriter out)
          Generates code to recreate the expression.
 void generateGetOut(PhpWriter out)
          Generates code to get the out.
 void generateInt(PhpWriter out)
          Generates code to evaluate the expression directly
 void generateIsset(PhpWriter out)
          Generates an expression for isset().
 void generateListEachStatement(PhpWriter out, Expr value)
          Generates code to recreate the expression.
 void generateLong(PhpWriter out)
          Generates code to evaluate the expression directly
 void generateModifiedRead(PhpWriter out)
          Generates code to eval the expression when the content might be modified, e.g.
 void generateObject(PhpWriter out)
          Generates code to recreate the expression, creating an object for an unset value.
 void generatePrint(PhpWriter out)
          Generates code to print the expression directly
 void generateRef(PhpWriter out)
          Generates code for a reference.
 void generateRefArg(PhpWriter out)
          Generates code for a reference.
 void generateReturn(PhpWriter out)
          Generates code for a return value
 void generateReturnRef(PhpWriter out)
          Generates code for a return reference.
 void generateStatement(PhpWriter out)
          Generates code to recreate the expression.
 void generateString(PhpWriter out)
          Generates code to evaluate a string directly
 void generateStringValue(PhpWriter out)
          Generates code to evaluate a string directly
 void generateTop(PhpWriter out)
          Generates code to recreate the expression.
 void generateType(PhpWriter out)
          Generates code for the native type
 void generateUnset(PhpWriter out)
          Generates code to unset the expression
 void generateUnsetArray(PhpWriter out, ExprGenerator index)
          Generates code to unset the expression
 void generateValue(PhpWriter out)
          Generates code for a function arg.
 void generateValueArg(PhpWriter out)
          Generates code for a call arg, where the function is known to take a value, i.e.
 void generateVar(PhpWriter out)
          Generates code for a reference.
 java.lang.Object getConstant()
          Returns the constant value
 java.lang.Object getLiteral()
          Returns the literal value
 Location getLocation()
          Properties.
 ExprType getType()
          Returns the static, analyzed type
 boolean isAssignment()
          Returns true for an assignment expression.
 boolean isBoolean()
           
 boolean isConstant()
          Returns true for a constant.
 boolean isDefault()
           
 boolean isDouble()
          Returns true for a double-valued expression.
 boolean isLiteral()
          Returns true for a literal
 boolean isLong()
          Returns true for a long-valued expression.
 boolean isNumber()
          Returns true for a number.
 boolean isString()
          Returns true for a String-valued expression.
 boolean isVar()
          Returns true for a Var, i.e.
 boolean isVarAssigned(VarExpr var)
          Returns true if the variable is ever assigned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPILE_ARG_MAX

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

ExprGenerator

public ExprGenerator()

ExprGenerator

public ExprGenerator(Location location)
Method Detail

getLocation

public Location getLocation()
Properties.


isLong

public boolean isLong()
Returns true for a long-valued expression.


isDouble

public boolean isDouble()
Returns true for a double-valued expression.


isNumber

public boolean isNumber()
Returns true for a number.


isBoolean

public boolean isBoolean()

isString

public boolean isString()
Returns true for a String-valued expression.


isAssignment

public boolean isAssignment()
Returns true for an assignment expression.


isLiteral

public boolean isLiteral()
Returns true for a literal


isConstant

public boolean isConstant()
Returns true for a constant.


isVar

public boolean isVar()
Returns true for a Var, i.e. an Expr which will return a Var for generateRef


isDefault

public boolean isDefault()

getLiteral

public java.lang.Object getLiteral()
Returns the literal value


getConstant

public java.lang.Object getConstant()
Returns the constant value


getType

public ExprType getType()
Returns the static, analyzed type


analyze

public abstract ExprType analyze(AnalyzeInfo info)
Analyze the expression


analyzeTop

public void analyzeTop(AnalyzeInfo info)
Analyze the expression as a statement


analyzeAssign

public ExprType analyzeAssign(AnalyzeInfo info,
                              ExprGenerator value)
Analyze the expression


analyzeSetModified

public void analyzeSetModified(AnalyzeInfo info)
Analyze as modified.


analyzeSetReference

public void analyzeSetReference(AnalyzeInfo info)
Analyze as reference


analyzeSetPostIncrement

public void analyzeSetPostIncrement()
Set a post increment


analyzeUnset

public void analyzeUnset(AnalyzeInfo info)
Analyze as unset


combineBinaryVarState

protected VarState combineBinaryVarState(VarState leftState,
                                         VarState rightState)
Returns the variables state.

Parameters:
leftState - the variables to test
rightState - the owning expression

isVarAssigned

public boolean isVarAssigned(VarExpr var)
Returns true if the variable is ever assigned.

Parameters:
var - the variable to test

generate

public void generate(PhpWriter out)
              throws java.io.IOException
Generates code to evaluate the expression.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateIsset

public void generateIsset(PhpWriter out)
                   throws java.io.IOException
Generates an expression for isset().

Throws:
java.io.IOException

generateModifiedRead

public void generateModifiedRead(PhpWriter out)
                          throws java.io.IOException
Generates code to eval the expression when the content might be modified, e.g. when evaluating $a[0], $a needs to use generateModified

Throws:
java.io.IOException

generateDirty

public void generateDirty(PhpWriter out)
                   throws java.io.IOException
Generates code to evaluate the expression, expecting a modification.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateArg

public void generateArg(PhpWriter out,
                        boolean isTop)
                 throws java.io.IOException
Generates code for a function arg, where the declaration of the argument is unknown.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateValueArg

public void generateValueArg(PhpWriter out)
                      throws java.io.IOException
Generates code for a call arg, where the function is known to take a value, i.e. a fun($x) declaration.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateValue

public void generateValue(PhpWriter out)
                   throws java.io.IOException
Generates code for a function arg.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateRef

public void generateRef(PhpWriter out)
                 throws java.io.IOException
Generates code for a reference.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateArray

public void generateArray(PhpWriter out)
                   throws java.io.IOException
Generates code for a reference that can be used as an array.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateVar

public void generateVar(PhpWriter out)
                 throws java.io.IOException
Generates code for a reference.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateReturnRef

public void generateReturnRef(PhpWriter out)
                       throws java.io.IOException
Generates code for a return reference.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateRefArg

public void generateRefArg(PhpWriter out)
                    throws java.io.IOException
Generates code for a reference.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateCopy

public void generateCopy(PhpWriter out)
                  throws java.io.IOException
Generates code to recreate the expression.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateObject

public void generateObject(PhpWriter out)
                    throws java.io.IOException
Generates code to recreate the expression, creating an object for an unset value.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateAssign

public void generateAssign(PhpWriter out,
                           Expr value,
                           boolean isTop)
                    throws java.io.IOException
Generates code to evaluate the expression

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateAssignRef

public void generateAssignRef(PhpWriter out,
                              Expr value,
                              boolean isTop)
                       throws java.io.IOException
Generates code to evaluate the expression

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateAssignOpen

public void generateAssignOpen(PhpWriter out)
                        throws java.io.IOException
Generates code to evaluate the expression

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateAssignClose

public void generateAssignClose(PhpWriter out)
                         throws java.io.IOException
Generates code to evaluate the expression

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateAssignBoolean

public void generateAssignBoolean(PhpWriter out,
                                  Expr value,
                                  boolean isTop)
                           throws java.io.IOException
Generates code to evaluate the expression

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateUnset

public void generateUnset(PhpWriter out)
                   throws java.io.IOException
Generates code to unset the expression

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateUnsetArray

public void generateUnsetArray(PhpWriter out,
                               ExprGenerator index)
                        throws java.io.IOException
Generates code to unset the expression

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateTop

public void generateTop(PhpWriter out)
                 throws java.io.IOException
Generates code to recreate the expression.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateReturn

public void generateReturn(PhpWriter out)
                    throws java.io.IOException
Generates code for a return value

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateStatement

public void generateStatement(PhpWriter out)
                       throws java.io.IOException
Generates code to recreate the expression.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateListEachStatement

public void generateListEachStatement(PhpWriter out,
                                      Expr value)
                               throws java.io.IOException
Generates code to recreate the expression.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateBoolean

public void generateBoolean(PhpWriter out)
                     throws java.io.IOException
Generates code to evaluate a boolean directly

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateString

public void generateString(PhpWriter out)
                    throws java.io.IOException
Generates code to evaluate a string directly

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateStringValue

public void generateStringValue(PhpWriter out)
                         throws java.io.IOException
Generates code to evaluate a string directly

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateAppend

public void generateAppend(PhpWriter out)
                    throws java.io.IOException
Generates code to append to a string builder.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateChar

public void generateChar(PhpWriter out)
                  throws java.io.IOException
Generates code to evaluate a string directly

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateInt

public void generateInt(PhpWriter out)
                 throws java.io.IOException
Generates code to evaluate the expression directly

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateLong

public void generateLong(PhpWriter out)
                  throws java.io.IOException
Generates code to evaluate the expression directly

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateDouble

public void generateDouble(PhpWriter out)
                    throws java.io.IOException
Generates code to evaluate the expression directly

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateType

public void generateType(PhpWriter out)
                  throws java.io.IOException
Generates code for the native type

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateGetOut

public void generateGetOut(PhpWriter out)
                    throws java.io.IOException
Generates code to get the out.

Throws:
java.io.IOException

generatePrint

public void generatePrint(PhpWriter out)
                   throws java.io.IOException
Generates code to print the expression directly

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException

generateExpr

public void generateExpr(PhpWriter out)
                  throws java.io.IOException
Generates code to recreate the expression.

Parameters:
out - the writer to the Java source code.
Throws:
java.io.IOException