Module Simula

Class Parameter

All Implemented Interfaces:
Externalizable, Serializable

public final class Parameter extends Declaration implements Externalizable
Parameter Declaration.

A parameter models class and procedure parameters.

Link to GitHub: Source File.

Author:
Øystein Myhre Andersen
See Also:
  • Field Details

    • mode

      public Parameter.Mode mode
      Parameter transfer Mode.
    • kind

      public Parameter.Kind kind
      Parameter Kind.
    • nDim

      public int nDim
      Parameter's number of dimension in case of array kind. Set during doChecking
  • Constructor Details

    • Parameter

      Parameter(String identifier)
      Create a new Parameter.
      Parameters:
      identifier - parameter identifier
    • Parameter

      Parameter(String identifier, Type type, Parameter.Kind kind)
      Create a new Parameter.
      Parameters:
      identifier - parameter identifier
      type - parameter type
      kind - parameter kind
    • Parameter

      public Parameter(String identifier, Type type, Parameter.Kind kind, int nDim)
      Create a new Parameter.
      Parameters:
      identifier - parameter identifier
      type - parameter type
      kind - parameter kind
      nDim - parameter's number of dimension in case of array kind.
    • Parameter

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

    • into

      void into(Vector<Parameter> parameterList)
      Add this parameter to the given parameter list.
      Parameters:
      parameterList - the given parameter list
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • setMode

      void setMode(Parameter.Mode mode)
      Utility: Set new parameter mode.
      Parameters:
      mode - the new mode
    • setTypeAndKind

      void setTypeAndKind(Type type, Parameter.Kind kind)
      Utility: Set new type and kind.
      Parameters:
      type - the new type
      kind - the new kind
    • setExternalIdentifier

      void setExternalIdentifier(int prefixLevel)
      Utility: Set new external identifier based on the given prefix level.
      Parameters:
      prefixLevel - the given prefix level
    • doChecking

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

      This must be redefined in every subclass.

      Overrides:
      doChecking in class SyntaxClass
    • legalTransmitionMode

      private boolean legalTransmitionMode()
      Check if the parameter has a legal transmission mode.

      The available transmission modes for the different kinds of parameters to procedures.

           --------------------------------------------------------------
          |                       |         Transmission modes           |
          |   Parameter           | - - - - - - - - - - - - - - - - - - -|
          |                       |  by value | by reference |  by name  |
          |--------------------------------------------------------------|
          |   value type          |     D     |       I      |     O     |
          |   object ref. type    |     I     |       D      |     O     |
          |   text                |     O     |       D      |     O     |
          |   value type array    |     O     |       D      |     O     |
          |   reference type array|     I     |       D      |     O     |
          |   procedure           |     I     |       D      |     O     |
          |   type procedure      |     I     |       D      |     O     |
          |   label               |     I     |       D      |     O     |
          |   switch              |     I     |       D      |     O     |
           --------------------------------------------------------------
      
              D:  default mode       O:  optional mode       I:  illegal
       
      Returns:
      true if the parameter has a legal transmission mode
    • toJavaType

      String toJavaType()
      Coding utility: edit Java code version of this parameter's type.
      Returns:
      the resulting Java code
    • toJavaCode

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

      static String editParameterList(Vector<Parameter> parameterList)
      Printing Utility: edit parameter list.
      Parameters:
      parameterList - the given parameter list
      Returns:
      the resulting string
    • 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 Object
    • 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