Class SimpleVariableDeclaration
java.lang.Object
simula.compiler.syntaxClass.SyntaxClass
simula.compiler.syntaxClass.declaration.Declaration
simula.compiler.syntaxClass.declaration.SimpleVariableDeclaration
- Direct Known Subclasses:
LabelDeclaration
Simple Variable Declaration.
Simula Standard: 5.1 Simple variable declarations simple-variable-declaration = type type-list type-list = type-list-element { , type-list-element } type-list-element = identifier | constant-element constant-element = identifier "=" value-expression | identifier "=" text-expression
Link to GitHub: Source File.
- Author:
- SIMULA Standards Group, Øystein Myhre Andersen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Constant indicator.The constant initial value.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
ConstructorsConstructorDescriptionDefault constructor used by Attribute File I/OSimpleVariableDeclaration
(Type type, String identifier) Create a new SimpleVariableDeclaration.SimpleVariableDeclaration
(Type type, String identifier, boolean constant, Constant constantElement) Create a new SimpleVariableDeclaration. -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildDeclaration
(ClassBuilder classBuilder, BlockDeclaration encloser) Output Java ByteCode.void
buildInitAttribute
(CodeBuilder codeBuilder) Output Java ByteCode.void
Perform semantic checking.void
Output possible declaration Java code.(package private) static void
expectSimpleVariable
(Type type, DeclarationList declarationList) Parse a simple variable declaration.ClassFile coding utility: get getFieldIdentifier.ClassFile coding utility: get FieldRefEntry of this SimpleVariable.boolean
Constant indicator.void
Utility print syntax tree method.static SimpleVariableDeclaration
Read and return an object.Generate Java code for this Syntax Class.toString()
void
Write a SyntaxClass object to a AttributeOutputStream.Methods inherited from class simula.compiler.syntaxClass.declaration.Declaration
acceptDeclaration, buildDeclarationCode, checkAlreadyDefined, getJavaIdentifier, isCompatibleClasses, verifyTree
Methods inherited from class simula.compiler.syntaxClass.SyntaxClass
ASSERT_SEMANTICS_CHECKED, buildByteCode, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, SET_SEMANTICS_CHECKED, setLineNumber
-
Field Details
-
constant
protected boolean constantConstant indicator. Is used to prevent assignment of a new value. -
constantElement
The constant initial value.
-
-
Constructor Details
-
SimpleVariableDeclaration
-
SimpleVariableDeclaration
-
SimpleVariableDeclaration
public SimpleVariableDeclaration()Default constructor used by Attribute File I/O
-
-
Method Details
-
isConstant
public boolean isConstant()Constant indicator. Is used to prevent assignment of a new value.- Returns:
- the constant indicator
-
expectSimpleVariable
Parse a simple variable declaration.
Syntax: simple-variable-declaration = type type-list type-list = type-list-element { , type-list-element } type-list-element = identifier | constant-element constant-element = identifier "=" value-expression | identifier "=" text-expression
Precodition: Type is already read.
- Parameters:
type
- the variable typedeclarationList
- the declaration list to update
-
doChecking
public void doChecking()Description copied from class:SyntaxClass
Perform semantic checking.
This must be redefined in every subclass.
- Overrides:
doChecking
in classSyntaxClass
-
doDeclarationCoding
public void doDeclarationCoding()Description copied from class:SyntaxClass
Output possible declaration Java code.- Overrides:
doDeclarationCoding
in classSyntaxClass
-
toJavaCode
Description copied from class:SyntaxClass
Generate Java code for this Syntax Class.- Overrides:
toJavaCode
in classSyntaxClass
- Returns:
- Java code
-
getFieldRefEntry
ClassFile coding utility: get FieldRefEntry of this SimpleVariable.- Parameters:
pool
- the ConstantPoolBuilder to use.- Returns:
- the FieldRefEntry of this SimpleVariable.
-
getFieldIdentifier
Description copied from class:Declaration
ClassFile coding utility: get getFieldIdentifier.- Overrides:
getFieldIdentifier
in classDeclaration
- Returns:
- the resulting String.
-
buildDeclaration
Description copied from class:Declaration
Output Java ByteCode. Treat Declaration.- Overrides:
buildDeclaration
in classDeclaration
- Parameters:
classBuilder
- the classBuilder to use.encloser
- the owning block.
-
buildInitAttribute
Description copied from class:Declaration
Output Java ByteCode. Build init code for an Attribute.- Overrides:
buildInitAttribute
in classDeclaration
- Parameters:
codeBuilder
- the codeBuilder to use.
-
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.
-