Package jminusminus

Class MethodContext


class MethodContext extends LocalContext
A method context is where formal parameters are declared. Also, it's where we start computing the offsets for local variables (formal parameters included), which are allocated in the current stack frame (for a method invocation).
  • Constructor Details

    • MethodContext

      public MethodContext(Context surrounding, boolean isStatic, Type methodReturnType)
      Constructs a method context.
      Parameters:
      surrounding - the surrounding (class) context.
      isStatic - is this method static?
      methodReturnType - return type of this method.
  • Method Details

    • isStatic

      public boolean isStatic()
      Returns true if this is a static method, and false otherwise.
      Returns:
      true if this is a static method, and false otherwise.
    • confirmMethodHasReturn

      public void confirmMethodHasReturn()
      Records fact that (non-void) method has at least one return.
    • methodHasReturn

      public boolean methodHasReturn()
      Returns true if this (non-void) method has at least one return, and false otherwise.
      Returns:
      true if this (non-void) method has at least one return, and false otherwise.
    • methodReturnType

      public Type methodReturnType()
      Returns the return type of this method.
      Returns:
      the return type of this method.
    • toJSON

      public void toJSON(JSONElement json)
      Adds information pertaining to this context to the given JSON element.
      Overrides:
      toJSON in class LocalContext
      Parameters:
      json - JSON element.