Class VariableExpression
Variable.
Simula Standard: 3.1 Variables Simula Standard: 3.1.3. Array elements Simula Standard: 3.1.4. Function designators variable = simple-variable | subscripted-variable | simple-object-expression . variable simple-object-expression = NONE | variable | function-designator | object-generator | local-object | qualified-object | ( object-expression ) simple-variable = identifier subscripted-variable = function-designator | array-element function-designator = procedure-identifier ( [ actual-parameter-part ] ) actual-parameter-part = actual-parameter { , actual-parameter } actual-parameter = expression | array-identifier1 | switch-identifier1 | procedure-identifier1 identifier1 = identifier | remote-identifier remote-identifier = simple-object-expression . attribute-identifier | text-primary . attribute-identifier array-element = array-identifier [ subscript-list ] subscript-list = arithmetic-expression { , arithmetic-expression }
Function designators:
A function designator defines a value which results through the application of a given set of rules defined by a procedure declaration (see 5.4) to a fixed set of actual parameters. The rules governing specification of actual parameters are given in 4.6.
Note: Not every procedure declaration defines rules for determining the value of a function designator (cf. 5.4.1).
Array elements:
Subscripted variables designate values which are components of multi- dimensional arrays. Each arithmetic expression of the subscript list occupies one subscript position of the subscripted variable and is called a subscript. The complete list of subscripts is enclosed by the subscript parentheses ( ). The array component referred to by a subscripted variable is specified by the actual value of its subscripts.
Each subscript position acts like a variable of type integer and the evaluation of the subscript is understood to be equivalent to an assignment to this fictitious variable. The value of the subscripted variable is defined only if the actual integer value of each subscript expression is within the associated subscript bounds of the array. A subscript expression value outside its associated bounds causes a run time error.
Link to GitHub: Source File.
- Author:
- SIMULA Standards Group, Øystein Myhre Andersen
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe checked parameters set by doChecking.The variable's identifier.The meaning of this variable.(package private) Vector
<Expression> The parsed parameters.private boolean
Indicates that this variable is remotely accessed.Fields inherited from class simula.compiler.syntaxClass.expression.Expression
backLink, type
Fields inherited from class simula.compiler.syntaxClass.SyntaxClass
CHECKED, lineNumber, OBJECT_SEQU
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor used by Attribute File I/O.VariableExpression
(String identifier) Create a new Variable. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
buildEvaluateParameter
(Parameter par, Expression inspectedVariable, Expression rightPart, CodeBuilder codeBuilder) ClassFile Coding Utility: Build this Parameter.void
buildEvaluation
(Expression rightPart, CodeBuilder codeBuilder) ClassFile Coding Utility: Build this Variable.void
buildIdentifierAccess
(boolean destination, CodeBuilder codeBuilder) ClassFile Coding Utility: Edit identifier access.void
Perform semantic checking.doGetELEMENT
(String var) Java coding utility: doGetELEMENT.doPutELEMENT
(String var, String rightPart) Java coding utility: doPutELEMENT.edIdentifierAccess
(boolean destination) Java coding utility: Edit identifier access.private String
edIdentifierAccess
(String id, boolean destination) Java Coding Utility: Edit identifier access.private String
editVariable
(String rightPart) Java Coding Utility: Edit this Variable.static VariableExpression
expectVariable
(String ident) Parse Utility: Expect Variable.get()
Generate code for getting the value of this ExpressionClassFile Coding Utility: Return the field ref entry for this variable.Returns a suitable java identifier for this variable.Returns the meaning.Get a writeable variable.boolean
Returns true if this variable has arguments.boolean
Returns true if this expression may be used as a statement.void
Utility print syntax tree method.Generate code for putting the value into this Expressionstatic VariableExpression
Read and return a VariableExpression object.(package private) void
setRemotelyAccessed
(Meaning meaning) This variable is remotely accessed through 'meaning'.Generate Java code for this Syntax Class.toString()
void
Write a SyntaxClass object to a AttributeOutputStream.Methods inherited from class simula.compiler.syntaxClass.expression.Expression
acceptExpression, checkCompatibility, evaluate, expectExpression, getInt, getNumber, getQualification
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
-
identifier
The variable's identifier. -
meaning
The meaning of this variable. -
remotelyAccessed
private boolean remotelyAccessedIndicates that this variable is remotely accessed. -
params
Vector<Expression> paramsThe parsed parameters. -
checkedParams
The checked parameters set by doChecking.
-
-
Constructor Details
-
VariableExpression
Create a new Variable.- Parameters:
identifier
- the variable's identifier
-
VariableExpression
public VariableExpression()Default constructor used by Attribute File I/O.
-
-
Method Details
-
hasArguments
public boolean hasArguments()Returns true if this variable has arguments.- Returns:
- true if this variable has arguments
-
getJavaIdentifier
Returns a suitable java identifier for this variable.- Returns:
- a suitable java identifier
-
setRemotelyAccessed
This variable is remotely accessed through 'meaning'.- Parameters:
meaning
- before dot
-
getMeaning
Returns the meaning.
If meaning is not set by setRemotelyAccessed then meaning by identifier will be set.
- Returns:
- the meaning
-
expectVariable
Parse Utility: Expect Variable.
Variable = Identifier | SubscriptedVariable SubscriptedVariable = Identifier "(" Expression { , Expression } ")"
Precondition: Identifier is already read.
- Parameters:
ident
- the variable identifier- Returns:
- the created Variable
-
getWriteableVariable
Description copied from class:Expression
Get a writeable variable.
This method is redefined in Variable, RemoteVariable and TypeConversion.
- Overrides:
getWriteableVariable
in classExpression
- Returns:
- a writeable variable or null
-
doChecking
public void doChecking()Description copied from class:SyntaxClass
Perform semantic checking.
This must be redefined in every subclass.
- Overrides:
doChecking
in classSyntaxClass
-
maybeStatement
public boolean maybeStatement()Description copied from class:Expression
Returns true if this expression may be used as a statement.- Specified by:
maybeStatement
in classExpression
- Returns:
- true if this expression may be used as a statement
-
toJavaCode
Description copied from class:SyntaxClass
Generate Java code for this Syntax Class.- Overrides:
toJavaCode
in classSyntaxClass
- Returns:
- Java code
-
doGetELEMENT
-
doPutELEMENT
-
put
Description copied from class:Expression
Generate code for putting the value into this Expression- Overrides:
put
in classExpression
- Parameters:
rightPart
- a evaluated expression.- Returns:
- the resulting Java code
-
get
Description copied from class:Expression
Generate code for getting the value of this Expression- Overrides:
get
in classExpression
- Returns:
- the resulting Java code
-
editVariable
-
edIdentifierAccess
Java coding utility: Edit identifier access.- Parameters:
destination
- true if this variable is a destination- Returns:
- a suitable java code
-
edIdentifierAccess
-
buildIdentifierAccess
ClassFile Coding Utility: Edit identifier access.- Parameters:
destination
- true if destinationcodeBuilder
- the CodeBuilder
-
buildEvaluation
ClassFile Coding Utility: Build this Variable.- Specified by:
buildEvaluation
in classExpression
- Parameters:
rightPart
- When destination, this is the right part of the assignmentcodeBuilder
- the CodeBuilder
-
getFieldRefEntry
ClassFile Coding Utility: Return the field ref entry for this variable.- Parameters:
pool
- the ConstantPoolBuilder to use.- Returns:
- the field ref entry for this variable.
-
buildEvaluateParameter
private void buildEvaluateParameter(Parameter par, Expression inspectedVariable, Expression rightPart, CodeBuilder codeBuilder) ClassFile Coding Utility: Build this Parameter.- Parameters:
par
- the ParameterinspectedVariable
- then inspected variable or nullrightPart
- When destination, this is the right part of the assignmentcodeBuilder
- the CodeBuilder
-
printTree
Description copied from class:SyntaxClass
Utility print syntax tree method.- Overrides:
printTree
in classExpression
- Parameters:
indent
- number of spaces leading the lineshead
- the head of the tree.
-
toString
- Overrides:
toString
in classExpression
-
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 a VariableExpression object.- Parameters:
inpt
- the AttributeInputStream to read from- Returns:
- the VariableExpression object read from the stream.
- Throws:
IOException
- if something went wrong.
-