Module Simula

Class ProcedureDeclaration

All Implemented Interfaces:
Externalizable, Serializable
Direct Known Subclasses:
StandardProcedure, SwitchDeclaration

public sealed class ProcedureDeclaration extends BlockDeclaration implements Externalizable permits StandardProcedure, SwitchDeclaration
Procedure Declaration.
 Simula Standard: 5.4 Procedure declaration
 
      procedure-declaration
          = [ type ] PROCEDURE procedure-heading ; procedure-body
      
            procedure-heading
                = procedure-identifier [ formal-parameter-part ; [ mode-part ] specification-part ] 
                
               procedure-identifier = identifier
                
               formal-parameter-part = "(" formal-parameter { , formal-parameter } ")"
            
                  formal-parameter = identifier
            
               specification-part = specifier identifier-list { ; specifier identifier-list }
            
                  specifier
                      = type [ ARRAY | PROCEDURE ]
                      | LABEL
                      | SWITCH 
                
               mode-part
                   = name-part [ value-part ]
                   | value-part [ name-part ]
            
                  name-part = NAME identifier-list ;
            
                  value-part = VALUE identifier-list ;
            
               identifier-list = identifier { , identifier }
                
            procedure-body = statement
 
This class is prefix to StandardProcedure and SwitchDeclaration.

Link to GitHub: Source File.

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

    • parameterList

      public Vector<Parameter> parameterList
      Parameter list.
    • myVirtual

      public VirtualMatch myVirtual
      Virtual Match indicator.

      If myVirtual != null, this Procedure is a Virtual Match.

      Set during doChecking.

  • Constructor Details

    • ProcedureDeclaration

      protected ProcedureDeclaration(String identifier, Declaration.Kind declarationKind)
      Create a new ProcedureDeclaration.
      Parameters:
      identifier - procedure identifier
      declarationKind - procedure or switch
    • ProcedureDeclaration

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

    • expectProcedureDeclaration

      public static ProcedureDeclaration expectProcedureDeclaration(Type type)
      Parse and build a ProcedureDeclaration.
       Syntax:
       
            procedure-declaration
                = [ type ] PROCEDURE procedure-heading ; procedure-body
            
                  procedure-heading
                      = procedure-identifier [ formal-parameter-part ; [ mode-part ] specification-part ] 
                      
                  procedure-identifier = identifier
       
      Precondition: [ type ] PROCEDURE is already read.
      Parameters:
      type - procedure's type
      Returns:
      a newly created ProcedureDeclaration
    • acceptModePart

      private static boolean acceptModePart(Vector<Parameter> pList)
      Parse Utility: Accept mode-part and set matching parameter's mode.
         mode-part
            = name-part [ value-part ]
            | value-part [ name-part ]
                  
         name-part = NAME identifier-list ;
                  
         value-part = VALUE identifier-list ;
                  
         identifier-list = identifier { , identifier }
       
      Parameters:
      pList - the parameter list
    • expectSpecificationPart

      private static void expectSpecificationPart(ProcedureDeclaration proc)
      Parse Utility: Accept Procedure Parameter specification-part updating Parameter's type and kind.
       Syntax:
       
           specification-part
                 = specifier identifier-list { ; specifier identifier-list }
           
              specifier = Type | [Type] ARRAY | [Type] PROCEDURE ] | LABEL | SWITCH
       
      Parameters:
      proc - the procedure declaration
    • expectProcedureBody

      private static void expectProcedureBody(ProcedureDeclaration proc)
      Parse Utility: Expect procedure-body. In case of a compound-statement, updating the procedure's declaration and statement lists.
       Syntax:
                      
              procedure-body = statement
       
      Parameters:
      proc - the procedure
    • doChecking

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

      This must be redefined in every subclass.

      Overrides:
      doChecking in class SyntaxClass
    • 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
    • doJavaCoding

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

      private void doMethodJavaCoding(String modifier, boolean addStaticLink)
      Generate Inline Method code for Procedure.
      Parameters:
      modifier - mthod modifier: "static " or ""
      addStaticLink - add static link as 0'th parameter
    • edFormalParameterList

      private String edFormalParameterList(boolean isInlineMethod, boolean addStaticLink)
      Edit the formal parameter list
      Parameters:
      isInlineMethod - true if generating an inline method, otherwise false
      addStaticLink - add static link as 0'th parameter
      Returns:
      the resulting Java code
    • doProcedureCoding

      private void doProcedureCoding()
      Generate java source code for this Procedure.
    • doCodeConstructor

      private void doCodeConstructor()
      Generate Java source code for the constructor.
    • doCodePrepareFormal

      private void doCodePrepareFormal()
      Generate Java source code prepared for 'call formal procedure'.
    • codeProcedureBody

      protected void codeProcedureBody()
      Coding Utility: codeProcedureBody. Redefined in SwitchDeclaration.
    • 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