Class LocalObject


public final class LocalObject extends Expression

LocalObject i.e. This class expression.


Simula Standard: 3.8 Object expressions

local-object = THIS class-identifier

A local object "this C" is valid provided that the expression is used within the class body of C or that of any subclass of C, or a connection block whose block qualification is C or a subclass of C (see 4.8).

The value of a local object in a given context is the object which is, or is connected by, the smallest textually enclosing block instance in which the local object is valid.

If there is no such block the local object is illegal (in the given context). For an instance of a procedure or a class body, "textually enclosing" means containing its declaration.

Link to GitHub: Source File.

Author:
Simula Standard, Øystein Myhre Andersen
  • Field Details

    • classIdentifier

      private String classIdentifier
      The class identifier.
    • classDeclaration

      ClassDeclaration classDeclaration
      The class declaration. Set by doChecking.
    • thisScope

      private DeclarationScope thisScope
      THIS scope. Set by doChecking.
    • ctxDiff

      private int ctxDiff
      Context difference. Set by doChecking.
  • Constructor Details

    • LocalObject

      private LocalObject(String ident)
      Create a new LocalObject
      Parameters:
      ident - class-identifier
    • LocalObject

      public LocalObject()
      Default constructor used by Attribute File I/O
  • Method Details

    • expectThisIdentifier

      static Expression expectThisIdentifier()
      Expect Identifier following THIS.
      Returns:
      the newly created LocalObject.
    • doChecking

      public void doChecking()
      Description copied from class: SyntaxClass

      Perform semantic checking.

      This must be redefined in every subclass.

      Overrides:
      doChecking in class SyntaxClass
    • findThis

      private void findThis()
      Follow Static Chain Looking for a Class named 'classIdentifier'
    • maybeStatement

      public boolean maybeStatement()
      Description copied from class: Expression
      Returns true if this expression may be used as a statement.
      Specified by:
      maybeStatement in class Expression
      Returns:
      true if this expression may be used as a statement
    • toJavaCode

      public String toJavaCode()
      Description copied from class: SyntaxClass
      Generate Java code for this Syntax Class.
      Overrides:
      toJavaCode in class SyntaxClass
      Returns:
      Java code
    • buildEvaluation

      public void buildEvaluation(Expression rightPart, CodeBuilder codeBuilder)
      Description copied from class: Expression
      ClassFile coding utility: Build Evaluation Code.
      Specified by:
      buildEvaluation in class Expression
      Parameters:
      rightPart - expression
      codeBuilder - the codeBuilder used.
    • toString

      public String toString()
      Overrides:
      toString in class Expression
    • writeObject

      public void writeObject(AttributeOutputStream oupt) throws IOException
      Description copied from class: SyntaxClass
      Write a SyntaxClass object to a AttributeOutputStream.
      Overrides:
      writeObject in class SyntaxClass
      Parameters:
      oupt - the AttributeOutputStream to write to.
      Throws:
      IOException - if something went wrong.
    • readObject

      public static LocalObject readObject(AttributeInputStream inpt) throws IOException
      Read and return an object.
      Parameters:
      inpt - the AttributeInputStream to read from
      Returns:
      the object read from the stream.
      Throws:
      IOException - if something went wrong.