Package jminusminus

Class JExpression

Direct Known Subclasses:
JArrayExpression, JArrayInitializer, JBinaryExpression, JCastOp, JConditionalExpression, JFieldSelection, JInstanceOfOp, JLiteralBoolean, JLiteralChar, JLiteralDouble, JLiteralInt, JLiteralLong, JLiteralNull, JLiteralString, JMessageExpression, JNewArrayOp, JNewOp, JSuper, JSuperConstruction, JThis, JThisConstruction, JUnaryExpression, JVariable, JWildExpression

abstract class JExpression extends JStatement
The AST node for an expression. The syntax says all expressions are statements, but a semantic check throws some (those without a side-effect) out. Every expression has a type and a flag indicating whether or not it's a statement-expression.
  • Field Details

    • type

      protected Type type
      Expression type.
    • isStatementExpression

      protected boolean isStatementExpression
      Whether or not this expression is a statement.
  • Constructor Details

    • JExpression

      protected JExpression(int line)
      Constructs an AST node for an expression.
      Parameters:
      line - line in which the expression occurs in the source file.
  • Method Details

    • type

      public Type type()
      Returns the expression type.
      Returns:
      the expression type.
    • isStatementExpression

      public boolean isStatementExpression()
      Returns true if this expression is being used as a statement, and false otherwise.
      Returns:
      true if this expression is being used as a statement, and false otherwise.
    • analyze

      public abstract JExpression analyze(Context context)
      Analyzes and returns a JExpression.
      Specified by:
      analyze in class JAST
      Parameters:
      context - context in which names are resolved.
      Returns:
      the analyzed (and possibly rewritten) AST subtree.
    • codegen

      public void codegen(CLEmitter output, String targetLabel, boolean onTrue)
      Performs short-circuit code generation for a boolean expression, given the code emitter, a target label, and whether we branch to that label on true or on false.
      Parameters:
      output - the code emitter.
      targetLabel - the label to which we should branch.
      onTrue - do we branch on true?