Module Simula

Class ClassDeclaration

All Implemented Interfaces:
Externalizable, Serializable
Direct Known Subclasses:
PrefixedBlockDeclaration, StandardClass

public sealed class ClassDeclaration extends BlockDeclaration implements Externalizable permits StandardClass, PrefixedBlockDeclaration
Simula Class Declaration.
 
 Simula Standard: 5.5 Class declaration
 
 class-declaration = [ prefix ] main-part
 
   prefix = class-identifier

   main-part = CLASS class-identifier
               [ formal-parameter-part ; [ value-part ] specification-part ] ;
               [ protection-part ; ]
               [ virtual-part ; ]
               class-body
   
      class-identifier = identifier
 
      formal-parameter-part = "(" FormalParameter { , FormalParameter } ")"
            FormalParameter = identifier

      value-part = VALUE identifier-list

      specification-part = class-parameter-specifier  identifier-list ; { class-parameter-specifier  identifier-list ; }
               class-parameter-specifier = Type | [Type] ARRAY 

      protection-part = protection-specification { ; protection-specification }
               protection-specification = HIDDEN identifier-list | HIDDEN PROTECTED identifier-list
                                        | PROTECTED identifier-list | PROTECTED HIDDEN identifier-list

      virtual-part = VIRTUAL: virtual-spec ; { virtual-spec ; }
         virtual-spec
             = virtual-specifier identifier-list
             | PROCEDURE procedure-identifier  procedure-specification
             
                virtual-Specifier = [ type ] PROCEDURE | LABEL | SWITCH
                
                procedure-specification = IS procedure-declaration

      
      class-body = statement | split-body
      
         split-body = initial-operations inner-part final-operations
         
            initial-operations = ( BEGIN | block-head ; ) { statement ; }
         
            inner-part = [ label : ] INNER ;
'
            final-operations
               = END
               | ; statement { ; statement } END

 

This class is prefix to StandardClass and PrefixedBlockDeclaration.

Link to GitHub: Source File.

Author:
SIMULA Standards Group, Øystein Myhre Andersen
See Also:
  • Field Details

    • externalPrefixIdent

      private String externalPrefixIdent
      The external prefix'identifier.
    • parameterList

      Vector<Parameter> parameterList
      The parameter list.
    • virtualSpecList

      protected Vector<VirtualSpecification> virtualSpecList
      The virtual spec list.
    • virtualMatchList

      protected Vector<VirtualMatch> virtualMatchList
      The virtual match list.
    • protectedList

      The protected list.
    • hiddenList

      public Vector<HiddenSpecification> hiddenList
      The hidden list.
    • code1

      protected Vector<CodeLine> code1
      Statement code before inner.
    • code2

      public Vector<CodeLine> code2
      Statement code after inner.
    • prefix

      public String prefix
      Class Prefix in case of a SubClass or Prefixed Block.
    • detachUsed

      public boolean detachUsed
      Set true when attribute procedure 'detach' is used in/on this class.
  • Constructor Details

    • ClassDeclaration

      protected ClassDeclaration(String identifier)
      Create a new ClassDeclaration.
      Parameters:
      identifier - the given identifier
    • ClassDeclaration

      public ClassDeclaration()
      Default constructor used by Externalization.
  • Method Details

    • expectClassDeclaration

      public static ClassDeclaration expectClassDeclaration(String prefix)
      Parse Class Declaration.
       
       Syntax:
       
       class-declaration = [ prefix ] main-part
       
         prefix = class-identifier
      
         main-part = CLASS class-identifier
                     [ formal-parameter-part ; [ value-part ] specification-part ] ;
                     [ protection-part ; ]
                     [ virtual-part ; ]
                     class-body
      
       
      Parameters:
      prefix - class identifier
      Returns:
      the resulting ClassDeclaration
    • acceptValuePart

      private static void acceptValuePart(Vector<Parameter> pList)
      Parse utility: Accept value part and set matching parameter's mode.
       Syntax:
                    VALUE identifier-list ;
       
      Parameters:
      pList - Parameter list
    • acceptParameterSpecificationPart

      private static void acceptParameterSpecificationPart(Vector<Parameter> pList)
      Parse Utility: Accept Class Parameter specification-part updating Parameter's type and kind.
       Syntax:
       
           specification-part
                 = class-parameter-specifier identifier-list { ; class-parameter-specifier identifier-list }
           
              class-parameter-specifier = Type | [Type] ARRAY
       
      Parameters:
      pList - the parameter list
    • acceptProtectionPart

      private static void acceptProtectionPart(ClassDeclaration cls)
      Parse Utility: Accept protection-part updating Hidden and Protected lists.
       Syntax:
       
            protection-part = protection-specification { ; protection-specification }
            
                 protection-specification
                      = HIDDEN identifier-list
                      | HIDDEN PROTECTED identifier-list
                      | PROTECTED identifier-list
                      | PROTECTED HIDDEN identifier-list
       
      Parameters:
      cls - the ClassDeclaration
    • expectHiddenProtectedList

      private static void expectHiddenProtectedList(ClassDeclaration cls, boolean hidden, boolean prtected)
      Parse Utility: Expect Hidden Protected list.
       Syntax:
       
            identifier-list
       
      Parameters:
      cls - the ClassDeclaration
      hidden - if true, update the hidden list
      prtected - if true, update the protected list
    • expectClassBody

      private static void expectClassBody(ClassDeclaration cls)
      Parse Utility: Expect class-body. In case of a split-body, updating the class's declaration and statement lists.
       Syntax:
                      
            class-body = statement | split-body
            
               split-body = initial-operations inner-part final-operations
               
                  initial-operations = ( BEGIN | block-head ; ) { statement ; }
               
                  inner-part = [ label : ] INNER ;
      '
                  final-operations
                     = END
                     | ; statement { ; statement } END
       
      Parameters:
      cls - the ClassDeclaration
    • isSubClassOf

      public boolean isSubClassOf(ClassDeclaration other)
      Checks if this class is a subclass of the 'other' class.

      Consider the class definitions:

        
            Class A ......;
          A Class B ......;
          B Class C ......;
       
      Then Class B is a subclass of Class A, While Class C is subclass of both B and A.
      Parameters:
      other - the other ClassDeclaration
      Returns:
      Boolean true iff this class is a subclass of the 'other' class.
    • doChecking

      public void doChecking()
      Description copied from class: SyntaxClass
      Perform semantic checking.

      This must be redefined in every subclass.

      Overrides:
      doChecking in class SyntaxClass
    • checkHiddenList

      private void checkHiddenList()
      Perform sematic checking of the Hidden list.
    • checkProtectedList

      private void checkProtectedList()
      Perform sematic checking of the Protected list.
    • searchVirtualSpecList

      public VirtualSpecification searchVirtualSpecList(String ident)
      Utility: Search VirtualSpec-list for 'ident'
      Parameters:
      ident - argument
      Returns:
      a VirtualSpecification when it was found, otherwise null
    • prefixLevel

      public int prefixLevel()
      Returns the prefix level.
      Returns:
      the prefix level
    • getNlabels

      int getNlabels()
      Returns the number of labels in this class.
      Returns:
      the number of labels in this class
    • findLocalAttribute

      public Declaration findLocalAttribute(String ident)
      Utility: Search for an attribute named 'ident'
      Parameters:
      ident - argument
      Returns:
      a ProcedureDeclaration when it was found, otherwise null
    • findLocalProcedure

      ProcedureDeclaration findLocalProcedure(String ident)
      Utility: Search Declaration-list for a procedure named 'ident'
      Parameters:
      ident - argument
      Returns:
      a ProcedureDeclaration when it was found, otherwise null
    • findRemoteAttributeMeaning

      public Meaning findRemoteAttributeMeaning(String ident)
      Find Remote Attribute's Meaning.
      Parameters:
      ident - attribute identifier
      Returns:
      the resulting Meaning
    • searchProtectedList

      public ProtectedSpecification searchProtectedList(String ident)
      Utility: Search Protected-list for 'ident'
      Parameters:
      ident - argument
      Returns:
      a ProtectedSpecification when it was found, otherwise null
    • withinScope

      private static boolean withinScope(DeclarationScope otherScope)
      Checks if the other scope is this scope or any of the prefixes.
      Parameters:
      otherScope - the other scope
      Returns:
      true if the other scope is this scope or any of the prefixes
    • findVisibleAttributeMeaning

      public Meaning findVisibleAttributeMeaning(String ident)
      Description copied from class: DeclarationScope
      Find visible attribute's Meaning
      Overrides:
      findVisibleAttributeMeaning in class DeclarationScope
      Parameters:
      ident - attribute identifier
      Returns:
      the resulting Meaning
    • searchHiddenList

      HiddenSpecification searchHiddenList(String ident)
      Utility: Search Hidden-list for 'ident'
      Parameters:
      ident - argument
      Returns:
      a HiddenSpecification when it was found, otherwise null
    • getPrefixClass

      public ClassDeclaration getPrefixClass()
      Returns the prefix ClassDeclaration or null.
      Returns:
      the prefix ClassDeclaration or null
    • hasNoRealPrefix

      private boolean hasNoRealPrefix()
      Check if this class has a real prefix.
      Returns:
      true if this class has a real prefix, otherwise false.
    • isDetachUsed

      public boolean isDetachUsed()
      Returns true if detach is called in/on this class.
      Returns:
      true if detach is called in/on this class
    • parameterIterator

      public Iterator<Parameter> parameterIterator()
      Iterates through all class parameters.
      Returns:
      a ClassParameterIterator
    • doJavaCoding

      public void doJavaCoding()
      Description copied from class: SyntaxClass
      Output Java code.
      Overrides:
      doJavaCoding in class SyntaxClass
    • doCodeConstructor

      private void doCodeConstructor()
      Coding Utility: Code the constructor.
    • edFormalParameterList

      protected String edFormalParameterList()
      Edit the formal parameter list

      Also used by subclass PrefixedBlockDeclaration.

      Returns:
      the resulting Java code
    • hasLabel

      protected boolean hasLabel()
      Description copied from class: BlockDeclaration
      Returns true if this block has one ore more labels.
      Overrides:
      hasLabel in class BlockDeclaration
      Returns:
      true if this block has one ore more labels.
    • codeStatements

      public void codeStatements()
      Description copied from class: BlockDeclaration
      Coding utility: Code statements
      Overrides:
      codeStatements in class BlockDeclaration
    • writeCode1

      protected void writeCode1()
      Coding utility: writeCode1 -- Write code before inner
    • writeCode2

      protected void writeCode2()
      Coding utility: writeCode2 -- Write code after inner
    • codeClassStatements

      protected void codeClassStatements()
      Coding utility: Code class statements.
    • edCompleteParameterList

      protected String edCompleteParameterList()
      Coding Utility: Edit the complete parameter list including all prefixes.
      Returns:
      the resulting Java code
    • print

      public void print(int indent)
      Description copied from class: SyntaxClass
      Utility print method.
      Overrides:
      print in class SyntaxClass
      Parameters:
      indent - number of spaces leading the line
    • printTree

      public void printTree(int indent)
      Description copied from class: SyntaxClass
      Utility print syntax tree method.
      Overrides:
      printTree in class SyntaxClass
      Parameters:
      indent - number of spaces leading the lines
    • toString

      public String toString()
      Overrides:
      toString in class BlockDeclaration
    • writeExternal

      public void writeExternal(ObjectOutput oupt) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput inpt) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException