public abstract class Function extends Expression
Modifier and Type | Field and Description |
---|---|
protected java.util.List<Expression> |
expressions
The operands of this function.
|
protected int |
maxOperands
The maximum number of operands, initially inactive when set to -1.
|
factory, type
Constructor and Description |
---|
Function()
Creates a default functional expression.
|
Function(java.lang.String name)
Creates a named functional expression.
|
Function(java.lang.String name,
java.lang.String type)
Creates a named and typed functional expression.
|
Modifier and Type | Method and Description |
---|---|
Function |
addExpression(Expression expression)
Adds an expression as an operand to this functional expression.
|
void |
assign(java.lang.Object value)
Reports an attempt to assign to this Function as an error.
|
boolean |
equals(java.lang.Object other)
Reports whether this function is equal to another object.
|
java.util.List<Expression> |
getExpressions()
Returns a list of the operand expressions governed by this functional
expression.
|
java.lang.String |
getType()
Returns the result type of this Function.
|
int |
hashCode()
Returns a quasi-unique hash code for this function.
|
boolean |
isAssignable()
Reports whether this Function is re-assignable.
|
boolean |
isBound()
Reports whether this Function expression is bound.
|
protected abstract void |
nameCheck()
Checks the chosen name for this Function and sets the maximum number
of operands.
|
Expression |
operand(int index)
Returns the given operand Expression at an index.
|
void |
rebind()
Rebinds the unbound operands of this Function.
|
Function |
resolve(Scope scope)
Causes this Function to resolve its global/local Parameter references.
|
Function |
setName(java.lang.String name)
Sets the name of this Function.
|
java.lang.String |
toString()
Converts this function to a printable string.
|
protected abstract void |
typeCheck()
Checks that the operand types and result type are consistent, for
this kind of Function.
|
void |
unbind()
Unbinds the operands of this Function.
|
evaluate, getName, isBottom, isOrdered, rebind, setType
safeEquals, safeHashCode, semanticError
protected int maxOperands
protected java.util.List<Expression> expressions
public Function()
public Function(java.lang.String name)
name
- the name of the function.public Function(java.lang.String name, java.lang.String type)
name
- the name of this functional expression.type
- the type of this functional expression.protected abstract void nameCheck() throws SemanticError
SemanticError
- if the name is illegal.protected abstract void typeCheck() throws SemanticError
SemanticError
- if a type inconsistency is detected.public boolean equals(java.lang.Object other)
equals
in class Expression
other
- the other object.public int hashCode()
hashCode
in class Expression
public Function setName(java.lang.String name)
public java.lang.String getType()
getType
in class Expression
SemanticError
- if no type can be inferred.public boolean isAssignable()
isAssignable
in class Expression
public Function addExpression(Expression expression) throws SemanticError
expression
- the operand expression.SemanticError
public java.util.List<Expression> getExpressions()
public Expression operand(int index)
index
- the index.public void assign(java.lang.Object value)
assign
in class Expression
value
- the value to assign.public boolean isBound()
isBound
in class Expression
public void unbind()
unbind
in class Expression
public void rebind()
rebind
in class Expression
public Function resolve(Scope scope)
resolve
in class Expression
scope
- a table of global and local Parameters.public java.lang.String toString()