Class CallExpression
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.Expression
-
- net.ssehub.easy.instantiation.core.model.expressions.AbstractCallExpression
-
- net.ssehub.easy.instantiation.core.model.expressions.CallExpression
-
- All Implemented Interfaces:
IArgumentProvider
- Direct Known Subclasses:
ConstructorCallExpression,StrategyCallExpression
public class CallExpression extends AbstractCallExpression implements IArgumentProvider
Represents a call to an operation of aTypeDescriptor. Please note that dot expressions shall be represented as nested call expressions, i.e., call(a).call(b).call(c) shall be represented as call(call(call(a), b), c) (setdotRightin the constructor).- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCallExpression.CallTypeDefines some basic call types.
-
Field Summary
Fields Modifier and Type Field Description private CallArgument[]argumentsprivate CallExpression.CallTypecallTypeprivate booleandotRightprivate java.lang.Objectparentprivate OperationDescriptorresolvedprivate TypeDescriptor<?>type
-
Constructor Summary
Constructors Modifier Constructor Description protectedCallExpression()Constructor for serialization.CallExpression(java.lang.Object parent, java.lang.String name, boolean dotRight, CallArgument... arguments)Creates a new call expression which may be part of a dot expression.CallExpression(java.lang.Object parent, java.lang.String name, CallArgument... arguments)Creates a new (undotted) call expression.CallExpression(java.lang.Object parent, java.lang.String name, Expression... arguments)Creates a new (undotted) call expression.CallExpression(IMetaOperation operation, CallArgument... param)Creates a new transparent call expression from a conversion or optimization operation.CallExpression(OperationDescriptor operation, CallArgument arg)Creates a new transparent call expression from a conversion or optimization operation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectaccept(IExpressionVisitor visitor)Visits the expression.protected booleancheckMetaForFirstArgField()Returns whether the field meta type shall be checked in#resolveOperation().private TypeDescriptor<?>[]checkUseParameter()Checks whether one of the parameter / argument types shall be used.private TypeDescriptor<?>considerIteratorResult(TypeDescriptor<?> result)Considers the potential explicit result type of an iterator.private TypeDescriptor<?>considerReturnGenerics(TypeDescriptor<?> type, TypeDescriptor<?>[] returnGenerics)Considers the return generics ontype.protected TypeDescriptor<?>determineOperand()Determines the operand for searching operations on.protected booleandoZeroArgumentTest()Returns whether the zero argument test shall be applied.CallArgumentgetArgument(int index)Returns the specified argument.intgetArgumentsCount()Returns the number of arguments.CallExpression.CallTypegetCallType()Returns the call type.java.lang.ObjectgetParent()Returns the parent language unit.OperationDescriptorgetResolved()Returns the resolved operation.java.lang.StringgetVilSignature()Returns the VIL signature of the resolved operation.TypeDescriptor<?>inferType()Infers the type of this expression including the type of the contained sub-expressions.booleanisDotRightExpression()Returns whether this expression occurred on the right side of a dot expression (decompose while writing).booleanisIteratingCollectionOperation()Returns whether this operation is a collection-iterator operation.booleanisIteratorCall()Returns whether this call is an iterator call.booleanisOclCompliant()Returns whether this operation is OCL compliant or flagged as not compliant.booleanisPlaceholder()Returns whether this operation is a placeholder, i.e., either the resolved operation is aplaceholder, its signature or its return type does contain aplaceholder type.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.AbstractCallExpression
dynamicDispatch, getName, getParameterType, getPrefix, getQualifiedName, getSignature, getVilSignature, isPlaceholder, resolveOperation, resolveOperation, resolveResolvableOperation
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.Expression
replaceEmptyLine
-
-
-
-
Field Detail
-
parent
private java.lang.Object parent
-
arguments
private CallArgument[] arguments
-
resolved
private OperationDescriptor resolved
-
type
private TypeDescriptor<?> type
-
callType
private CallExpression.CallType callType
-
dotRight
private boolean dotRight
-
-
Constructor Detail
-
CallExpression
protected CallExpression() throws VilExceptionConstructor for serialization.- Throws:
VilException- shall not occur
-
CallExpression
public CallExpression(java.lang.Object parent, java.lang.String name, Expression... arguments) throws VilExceptionCreates a new (undotted) call expression.- Parameters:
parent- the parent language unit (if given used as optional parameter during calls)name- the name of the callarguments- the arguments for the call- Throws:
VilException- in case that no argument is given
-
CallExpression
public CallExpression(java.lang.Object parent, java.lang.String name, CallArgument... arguments) throws VilExceptionCreates a new (undotted) call expression.- Parameters:
parent- the parent language unit (if given used as optional parameter during calls)name- the name of the call.arguments- the arguments for the call- Throws:
VilException- in case that no argument is given
-
CallExpression
public CallExpression(java.lang.Object parent, java.lang.String name, boolean dotRight, CallArgument... arguments) throws VilExceptionCreates a new call expression which may be part of a dot expression.- Parameters:
parent- the parent language unit (if given used as optional parameter during calls)name- the name of the calldotRight- if this expression occurred on the right side of a "."arguments- the arguments for the call- Throws:
VilException- in case that no argument is given
-
CallExpression
public CallExpression(OperationDescriptor operation, CallArgument arg) throws VilException
Creates a new transparent call expression from a conversion or optimization operation.- Parameters:
operation- the operation to be consideredarg- the one and only argument- Throws:
VilException- in case that the operation does not exactly take one argument and provide a result
-
CallExpression
public CallExpression(IMetaOperation operation, CallArgument... param) throws VilException
Creates a new transparent call expression from a conversion or optimization operation.- Parameters:
operation- the operation to be consideredparam- the one and only parameter- Throws:
VilException- in case that the operation does not exactly take one argument and provide a result
-
-
Method Detail
-
getParent
public java.lang.Object getParent()
Returns the parent language unit.- Returns:
- the parent language unit (may be null if not given or implicit operation)
-
doZeroArgumentTest
protected boolean doZeroArgumentTest()
Returns whether the zero argument test shall be applied.- Returns:
trueif the test shall be applied,falseelse
-
isDotRightExpression
public boolean isDotRightExpression()
Returns whether this expression occurred on the right side of a dot expression (decompose while writing).- Returns:
trueif it appeared on the right side,falseelse
-
getResolved
public OperationDescriptor getResolved()
Returns the resolved operation.- Returns:
- the resolved operation
-
getCallType
public CallExpression.CallType getCallType()
Returns the call type.- Returns:
- the call type
-
determineOperand
protected TypeDescriptor<?> determineOperand() throws VilException
Determines the operand for searching operations on. Is called byinferType().- Returns:
- the operand
- Throws:
VilException- in case that determining the operand fails
-
checkMetaForFirstArgField
protected boolean checkMetaForFirstArgField()
Returns whether the field meta type shall be checked in#resolveOperation().- Returns:
true
-
checkUseParameter
private TypeDescriptor<?>[] checkUseParameter() throws VilException
Checks whether one of the parameter / argument types shall be used.- Returns:
- the parameter type or null
- Throws:
VilException- in case of type problems
-
inferType
public TypeDescriptor<?> inferType() throws VilException
Description copied from class:ExpressionInfers the type of this expression including the type of the contained sub-expressions.- Specified by:
inferTypein classExpression- Returns:
- the type of this expression
- Throws:
VilException- in case that inferring the type fails
-
considerReturnGenerics
private TypeDescriptor<?> considerReturnGenerics(TypeDescriptor<?> type, TypeDescriptor<?>[] returnGenerics)
Considers the return generics ontype.- Parameters:
type- the type to consider the generics forreturnGenerics- the return generics (may be null)- Returns:
- the resulting descriptor or
typeif no return generics are given
-
getArgumentsCount
public int getArgumentsCount()
Returns the number of arguments.- Specified by:
getArgumentsCountin interfaceIArgumentProvider- Specified by:
getArgumentsCountin classAbstractCallExpression- Returns:
- the number of arguments
-
getArgument
public CallArgument getArgument(int index)
Returns the specified argument.- Specified by:
getArgumentin interfaceIArgumentProvider- Specified by:
getArgumentin classAbstractCallExpression- Parameters:
index- the index of the argument to be returned- Returns:
- the argument
- Throws:
java.lang.IndexOutOfBoundsException- in case ofindex < 0 || index >=.getArgumentsCount()
-
isPlaceholder
public boolean isPlaceholder()
Description copied from class:AbstractCallExpressionReturns whether this operation is a placeholder, i.e., either the resolved operation is aplaceholder, its signature or its return type does contain aplaceholder type.- Specified by:
isPlaceholderin classAbstractCallExpression- Returns:
trueif this operation is a placeholder and cannot be executed,falseelse
-
accept
public java.lang.Object accept(IExpressionVisitor visitor) throws VilException
Description copied from class:ExpressionVisits the expression.- Specified by:
acceptin classExpression- Parameters:
visitor- the visitor- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
getVilSignature
public java.lang.String getVilSignature()
Description copied from class:AbstractCallExpressionReturns the VIL signature of the resolved operation.- Specified by:
getVilSignaturein classAbstractCallExpression- Returns:
- the VIL signature
-
isIteratorCall
public boolean isIteratorCall()
Returns whether this call is an iterator call.- Returns:
trueif it is an iterator call,falseelse
-
considerIteratorResult
private TypeDescriptor<?> considerIteratorResult(TypeDescriptor<?> result) throws VilException
Considers the potential explicit result type of an iterator.- Parameters:
result- the result type so far- Returns:
- the result type
- Throws:
VilException- if aggregation shall be applied to a non-aggregating iterator operation
-
isOclCompliant
public boolean isOclCompliant()
Description copied from class:AbstractCallExpressionReturns whether this operation is OCL compliant or flagged as not compliant.- Overrides:
isOclCompliantin classAbstractCallExpression- Returns:
truefor compliant,falseelse
-
isIteratingCollectionOperation
public boolean isIteratingCollectionOperation()
Description copied from class:AbstractCallExpressionReturns whether this operation is a collection-iterator operation.- Overrides:
isIteratingCollectionOperationin classAbstractCallExpression- Returns:
truefor collection-iterator,falseelse
-
-