Package jminusminus

Class JReturnStatement


class JReturnStatement extends JStatement
The AST node for a return-statement. If the enclosing method is non-void, then there is a value to return, so we keep track of the expression denoting that value and its type.
  • Constructor Details

    • JReturnStatement

      public JReturnStatement(int line, JExpression expr)
      Constructs an AST node for a return-statement.
      Parameters:
      line - line in which the return-statement appears in the source file.
      expr - the returned expression.
  • Method Details

    • analyze

      public JStatement analyze(Context context)
      Performs semantic analysis on this AST and returns the (possibly modified) AST.
      Specified by:
      analyze in class JAST
      Parameters:
      context - the environment (scope) in which code is analyzed.
      Returns:
      the (possibly modified) AST.
    • codegen

      public void codegen(CLEmitter output)
      Performs code generation for this AST.
      Specified by:
      codegen in class JAST
      Parameters:
      output - the code emitter.
    • toJSON

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