Package jminusminus

Class JLiteralBoolean


class JLiteralBoolean extends JExpression
The AST node for a boolean literal.
  • Constructor Details

    • JLiteralBoolean

      public JLiteralBoolean(int line, String text)
      Constructs an AST node for a boolean literal given its line number and string representation.
      Parameters:
      line - line in which the literal occurs in the source file.
      text - string representation of the literal.
  • Method Details

    • toBoolean

      public boolean toBoolean()
      Returns the literal as a boolean.
      Returns:
      the literal as a boolean.
    • analyze

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

      public void codegen(CLEmitter output)
      Performs code generation for this AST.
      Specified by:
      codegen in class JAST
      Parameters:
      output - the code emitter.
    • 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.
      Overrides:
      codegen in class JExpression
      Parameters:
      output - the code emitter.
      targetLabel - the label to which we should branch.
      onTrue - do we branch on true?
    • toJSON

      public void toJSON(JSONElement json)
      Stores information about this AST in JSON format.
      Overrides:
      toJSON in class JAST
      Parameters:
      json - the JSON emitter.