Class Parameter
java.lang.Object
simula.compiler.syntaxClass.SyntaxClass
simula.compiler.syntaxClass.declaration.Declaration
simula.compiler.syntaxClass.declaration.Parameter
Parameter Declaration.
A parameter models class and procedure parameters.
Link to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Procedure parameter Kind.class
Procedure parameter transfer Mode. -
Field Summary
FieldsModifier and TypeFieldDescriptionint
Parameter Kind.int
Parameter transfer Mode.int
Parameter's number of dimension in case of array kind.Fields inherited from class simula.compiler.syntaxClass.declaration.Declaration
declarationKind, declaredIn, externalIdent, identifier, isProtected, type
Fields inherited from class simula.compiler.syntaxClass.SyntaxClass
CHECKED, lineNumber, OBJECT_SEQU
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Default constructor used by Attribute File I/O(package private)
Create a new Parameter.(package private)
Create a new Parameter.Create a new Parameter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildDeclaration
(ClassBuilder classBuilder, BlockDeclaration encloser) ClassFile coding utility: buildDeclaration of this Parameter.private static void
buildNameParam
(CodeBuilder codeBuilder, Parameter par, Expression expr) ClassFile coding utility: buildNameParamstatic void
buildNameParam
(CodeBuilder codeBuilder, Expression expr) ClassFile coding utility: buildNameParamvoid
buildParamCode
(CodeBuilder codeBuilder, Expression expr) ClassFile coding utility: buildParamCodevoid
Perform semantic checking.static String
editParameterList
(Vector<Parameter> parameterList) Printing Utility: edit parameter list.static String
edKind
(int kind) Utility: edKindstatic String
edMode
(int mode) Utility: edModeboolean
ClassFile coding utility: get getFieldIdentifier of this Parameter.ClassFile coding utility: get FieldRefEntry of this Parameter.(package private) void
Add this parameter to the given parameter list.private boolean
Check if the parameter has a legal transmission mode.void
loadParameter
(CodeBuilder codeBuilder, int ofst) ClassFile coding utility: generate load instruction dependent of type.void
Utility print syntax tree method.static SyntaxClass
Read and return an object.(package private) void
setExternalIdentifier
(int prefixLevel) Utility: Set new external identifier based on the given prefix level.(package private) void
setMode
(int mode) Utility: Set new parameter mode.(package private) void
setTypeAndKind
(Type type, int kind) Utility: Set new type and kind.Generate Java code for this Syntax Class.(package private) String
Java coding utility: edit Java code version of this parameter's type.toString()
ClassFile coding utility: Parameter type toClassDesc.void
Write a SyntaxClass object to a AttributeOutputStream.Methods inherited from class simula.compiler.syntaxClass.declaration.Declaration
acceptDeclaration, buildDeclarationCode, buildInitAttribute, checkAlreadyDefined, getJavaIdentifier, isCompatibleClasses, verifyTree
Methods inherited from class simula.compiler.syntaxClass.SyntaxClass
ASSERT_SEMANTICS_CHECKED, buildByteCode, doDeclarationCoding, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, SET_SEMANTICS_CHECKED, setLineNumber
-
Field Details
-
mode
public int modeParameter transfer Mode. -
kind
public int kindParameter Kind. -
nDim
public int nDimParameter's number of dimension in case of array kind. Set during doChecking
-
-
Constructor Details
-
Parameter
-
Parameter
-
Parameter
-
Parameter
private Parameter()Default constructor used by Attribute File I/O
-
-
Method Details
-
edMode
Utility: edMode- Parameters:
mode
- a mode code- Returns:
- the resulting String
-
edKind
Utility: edKind- Parameters:
kind
- a kind code- Returns:
- the resulting String
-
into
-
equals
-
setMode
void setMode(int mode) Utility: Set new parameter mode.- Parameters:
mode
- the new mode
-
setTypeAndKind
Utility: Set new type and kind.- Parameters:
type
- the new typekind
- 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 classSyntaxClass
-
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()Java coding utility: edit Java code version of this parameter's type.- Returns:
- the resulting Java code
-
toJavaCode
Description copied from class:SyntaxClass
Generate Java code for this Syntax Class.- Overrides:
toJavaCode
in classSyntaxClass
- Returns:
- Java code
-
buildParamCode
ClassFile coding utility: buildParamCode- Parameters:
codeBuilder
- the codeBuilder to useexpr
- parameter value expression
-
buildNameParam
ClassFile coding utility: buildNameParam- Parameters:
codeBuilder
- to useexpr
- the Thunk expression to be evaluated.
-
buildNameParam
ClassFile coding utility: buildNameParam- Parameters:
codeBuilder
- to usepar
- the parameter used decide parameter kindexpr
- the Thunk expression to be evaluated.
-
getFieldRefEntry
ClassFile coding utility: get FieldRefEntry of this Parameter.- Parameters:
pool
- the ConstantPoolBuilder to use.- Returns:
- the FieldRefEntry of this Parameter.
-
getFieldIdentifier
ClassFile coding utility: get getFieldIdentifier of this Parameter.- Overrides:
getFieldIdentifier
in classDeclaration
- Returns:
- the resulting String.
-
buildDeclaration
ClassFile coding utility: buildDeclaration of this Parameter.- Overrides:
buildDeclaration
in classDeclaration
- Parameters:
classBuilder
- the classBuilder to use.encloser
- the owning block.
-
type_toClassDesc
ClassFile coding utility: Parameter type toClassDesc.- Returns:
- the resulting CalssDesc
-
loadParameter
ClassFile coding utility: generate load instruction dependent of type.- Parameters:
codeBuilder
- the codeBuilder to useofst
- the parameter offset.
-
editParameterList
-
printTree
Description copied from class:SyntaxClass
Utility print syntax tree method.- Overrides:
printTree
in classSyntaxClass
- Parameters:
indent
- number of spaces leading the lineshead
- the head of the tree.
-
toString
-
writeObject
Description copied from class:SyntaxClass
Write a SyntaxClass object to a AttributeOutputStream.- Overrides:
writeObject
in classSyntaxClass
- Parameters:
oupt
- the AttributeOutputStream to write to.- Throws:
IOException
- if something went wrong.
-
readObject
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.
-