Class ExpressionTranslator<I extends VariableDeclaration,R extends Resolver<I>,E extends ExpressionStatement>
- java.lang.Object
-
- net.ssehub.easy.dslCore.translation.MessageReceiver
-
- net.ssehub.easy.dslCore.translation.ExpressionTranslator
-
- de.uni_hildesheim.sse.vil.expressions.translation.ExpressionTranslator<I,R,E>
-
- All Implemented Interfaces:
IMessageReceiver,ResolutionListener,StringResolver.IExpressionTranslator<I,R>
- Direct Known Subclasses:
ExpressionTranslator,ExpressionTranslator
public abstract class ExpressionTranslator<I extends VariableDeclaration,R extends Resolver<I>,E extends ExpressionStatement> extends ExpressionTranslator implements ResolutionListener, StringResolver.IExpressionTranslator<I,R>
Implements the translation from the expression DSL to the expression model in the instantiator core.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classExpressionTranslator.CallTypeDefines basic VIL call types.
-
Field Summary
Fields Modifier and Type Field Description private IvmlMessageAdapterivmlMessageAdapterprivate VarModelIdentifierExpressionlastVarModelIdentifierEx
-
Constructor Summary
Constructors Constructor Description ExpressionTranslator()Creates an expression translator (to be used within this package only).
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ExpressionassertBooleanExpression(Expression expression, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature)Asserts the given expression to be of Boolean type.protected abstract java.lang.StringcannotAssignHint()A hint if an assignment is not allowed.protected AbstractCallExpressioncheckCallExpression(AbstractCallExpression callEx, ExpressionTranslator.CallType type, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Call call)Performs generic call expression checks after creation.private voidcheckOclEnumCompliance(java.lang.String name, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature)Checks the given enumeration literal name for OCL compliance.protected VilExceptioncheckSemantics(Expression expr)Checks the semantics of a potential call candidate.protected booleancontinueResolution(VilException semanticException)Returns whether resolution shall be continued in case of multiple similar call expressions.private ExpressionconvertToVersion(java.lang.String text, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Constant arg, R resolver)protected static ExpressioncreateConstant(TypeDescriptor<?> type, java.lang.Object value, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature, TypeRegistry registry)Creates a constant.protected abstract EcreateExpressionStatement(Expression expression, R resolver)Creates an expression statement.protected abstract ExpressionVersionRestrictioncreateExpressionVersionRestriction(Expression expr, VariableDeclaration decl, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature feature)Creates an expression version restriction matching this class.protected abstract IcreateImplicitVariableDeclaration(java.lang.String name, TypeDescriptor<?> type, boolean isConstant, Expression expression, R resolver)Creates a new implicit variable declaration.protected abstract IcreateVariableDeclaration(java.lang.String name, TypeDescriptor<?> type, boolean isConstant, Expression expression, R resolver)Creates a new variable declaration.voidenactIvmlWarnings()Enacts the IVML warnings not resolved by "function pointers" so far.voiderror(AbstractException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature)Turns a buildlang exception into a xText error.IvmlMessageAdaptergetIvmlMessageAdapter()Returns the IVML message adapter.private static java.lang.StringgetName(org.eclipse.emf.ecore.EObject cause)Tries to obtain the name ofcause.private voidivmlWarning(java.lang.String name, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature)Creates a warning due to an unresolved IVML element.private ExpressionnormalizeStringExpression(Expression ex, java.lang.String st)Normalizes a string expression, i.e., ifex(within aCompositeExpressionis not a constant, aStringExpressioncontaining the expression is inserted instead.abstract ExpressionparseExpression(java.lang.String expression, R resolver, java.lang.StringBuilder warnings)Parse the given expression.private FieldAccessExpressionprocess(VariableDeclaration var, FieldAccessExpression last, java.lang.String name, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Constant elt)protected ExpressionprocessAdditiveExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.AdditiveExpression ex, R resolver)Processes an additive expression.CallArgument[]processArguments(de.uni_hildesheim.sse.vil.expressions.expressionDsl.ArgumentList arguments, R resolver)Processes an argument list and translates them into call arguments.ExpressionprocessAssignment(org.eclipse.emf.ecore.EObject cause, TypeDescriptor<?> type, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Expression ex, R resolver)Processes an assignment.protected abstract ExpressionprocessCall(Expression firstParam, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Call call, ExpressionTranslator.CallType type, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Expression arrayEx, R resolver)Processes a function call.protected ExpressionprocessConstant(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Constant arg, R resolver)Processes a constant argument.private ContainerInitializerExpressionprocessContainerInitializer(de.uni_hildesheim.sse.vil.expressions.expressionDsl.ContainerInitializer initializer, R resolver)Processes a container initializer expression.private java.util.ArrayList<I>processDeclarators(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Call call, TypeDescriptor<?> implicitType, java.util.List<CallArgument> arguments, R resolver)Processes a declarator.protected ExpressionprocessEqualityExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.EqualityExpression ex, R resolver)Processes an equality expression.ExpressionprocessExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Expression ex, R resolver)Creates the expression tree for a given expression.EprocessExpressionStatement(de.uni_hildesheim.sse.vil.expressions.expressionDsl.ExpressionStatement expr, R resolver)Processes an expression statement.ExpressionprocessLogicalExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.LogicalExpression ex, R resolver)Processes a logical expression.protected ExpressionprocessMultiplicativeExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.MultiplicativeExpression ex, R resolver)Processes a multiplicative expression.protected ExpressionprocessPostfixExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.PostfixExpression ex, R resolver)Processes a postfix expression.ExpressionprocessPrimaryExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.PrimaryExpression ex, R resolver)Processes a primary expression.protected ExpressionprocessQualifiedValue(java.lang.String name, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Constant arg, org.eclipse.emf.ecore.EStructuralFeature feature, R resolver)Processes a qualified value and creates variable expressions.protected ExpressionprocessRelationalExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.RelationalExpression ex, R resolver)Processes a relational expression.IVersionRestrictionprocessRestriction(java.lang.String name, de.uni_hildesheim.sse.vil.expressions.expressionDsl.VersionSpec spec, R resolver)Processes an import restriction.protected ExpressionprocessSubCalls(Expression firstParam, org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.SubCall> followups, R resolver)Processes sub calls, i.e., calls connected by ".".TypeDescriptor<?>processType(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Type type, R resolver)Processes the given type and tries to resolve it to a VIL type.protected TypeDescriptor<?>[]processTypeParameter(de.uni_hildesheim.sse.vil.expressions.expressionDsl.TypeParameters param, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Type type, R resolver)Processes the type parameter.protected ExpressionprocessUnaryExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.UnaryExpression ex, R resolver)Processes a unary expression.IprocessVariableDeclaration(de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration decl, R resolver)Processes a variable declaration.voidreProcessVariableDeclaration(I decl, R resolver)Re-processes a variable declaration in order to get rid ofDeferredResolvableOperationExpression.private ExpressionresolveCallArgumentExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.NamedArgument param, int paramIndex, java.util.List<I> iterators, java.util.List<CallArgument> arguments, R resolver)Tries to resolve a call argument.protected java.lang.StringresolveCallArguments(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Call call, java.util.List<I> iterators, java.util.List<CallArgument> arguments, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Expression arrayEx, R resolver)Resolves call arguments.voidresolved(VarModelIdentifierExpression ex)Is called ifexwas resolved.protected java.util.List<I>resolveIteratorDeclarations(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Call call, ExpressionTranslator.CallType type, java.util.List<CallArgument> arguments, R resolver)Resolves the iterator declarations.private TypeDescriptor<?>resolveModelType(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Type type, java.lang.String typeName, R resolver)Resolves a model type.IvmlMessageAdaptersetIvmlMessageAdapter(IvmlMessageAdapter adapter)Allows for (temporary) exchange of the IVML message adapter, e.g., to handle warnings differently.private voidthrowVariableCannotBeInitialized(org.eclipse.emf.ecore.EObject cause, java.lang.String name, TypeDescriptor<?> declType, TypeDescriptor<?> initType)Throws aTranslatorExceptionthat a variable cannot be initialized.private ExpressionEvaluatortryIteratorExpression(java.util.List<CallArgument> arguments, de.uni_hildesheim.sse.vil.expressions.expressionDsl.NamedArgument param, R resolver)Tries to compose an iterator expression (ExpressionEvaluator)voidwarning(AbstractException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature)Turns a buildlang exception into a xText warning.voidwarnVersionRestrictions(de.uni_hildesheim.sse.vil.expressions.expressionDsl.VersionSpec spec)Issues implementation warnings about version restrictions.-
Methods inherited from class net.ssehub.easy.dslCore.translation.ExpressionTranslator
clearMessages, clearMessages, collect, error, error, getErrorCount, getMessage, getMessageCount, warning
-
Methods inherited from class net.ssehub.easy.dslCore.translation.MessageReceiver
error
-
-
-
-
Field Detail
-
lastVarModelIdentifierEx
private VarModelIdentifierExpression lastVarModelIdentifierEx
-
ivmlMessageAdapter
private IvmlMessageAdapter ivmlMessageAdapter
-
-
Method Detail
-
setIvmlMessageAdapter
public IvmlMessageAdapter setIvmlMessageAdapter(IvmlMessageAdapter adapter)
Allows for (temporary) exchange of the IVML message adapter, e.g., to handle warnings differently.- Parameters:
adapter- the new message adapter- Returns:
- the old message adapter
-
getIvmlMessageAdapter
public IvmlMessageAdapter getIvmlMessageAdapter()
Returns the IVML message adapter.- Returns:
- the adapter instance
-
processExpression
public Expression processExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Expression ex, R resolver) throws TranslatorException
Creates the expression tree for a given expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression tree
- Throws:
TranslatorException- in case that the translation fails for some reason
-
enactIvmlWarnings
public void enactIvmlWarnings()
Enacts the IVML warnings not resolved by "function pointers" so far.
-
ivmlWarning
private void ivmlWarning(java.lang.String name, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature)Creates a warning due to an unresolved IVML element.- Parameters:
name- the name of the elementcause- the causing ECore elementcausingFeature- the causing ECore feature
-
processExpressionStatement
public E processExpressionStatement(de.uni_hildesheim.sse.vil.expressions.expressionDsl.ExpressionStatement expr, R resolver) throws TranslatorException
Processes an expression statement.- Parameters:
expr- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the expression statement
- Throws:
TranslatorException- in case that the translation fails due to semantic reasons- See Also:
cannotAssignHint()
-
cannotAssignHint
protected abstract java.lang.String cannotAssignHint()
A hint if an assignment is not allowed.- Returns:
- the hint (must not be null)
-
createExpressionStatement
protected abstract E createExpressionStatement(Expression expression, R resolver)
Creates an expression statement.- Parameters:
expression- the expressionresolver- the resolver instance- Returns:
- the expression statement
-
processLogicalExpression
public Expression processLogicalExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.LogicalExpression ex, R resolver) throws TranslatorException
Processes a logical expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason
-
processEqualityExpression
protected Expression processEqualityExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.EqualityExpression ex, R resolver) throws TranslatorException
Processes an equality expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason
-
processRelationalExpression
protected Expression processRelationalExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.RelationalExpression ex, R resolver) throws TranslatorException
Processes a relational expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason
-
processAdditiveExpression
protected Expression processAdditiveExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.AdditiveExpression ex, R resolver) throws TranslatorException
Processes an additive expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason
-
processMultiplicativeExpression
protected Expression processMultiplicativeExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.MultiplicativeExpression ex, R resolver) throws TranslatorException
Processes a multiplicative expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason
-
processUnaryExpression
protected Expression processUnaryExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.UnaryExpression ex, R resolver) throws TranslatorException
Processes a unary expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason
-
processPostfixExpression
protected Expression processPostfixExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.PostfixExpression ex, R resolver) throws TranslatorException
Processes a postfix expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason
-
resolveIteratorDeclarations
protected java.util.List<I> resolveIteratorDeclarations(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Call call, ExpressionTranslator.CallType type, java.util.List<CallArgument> arguments, R resolver) throws TranslatorException
Resolves the iterator declarations. Existence of iterator declarations incallis already checked to be valid.- Parameters:
call- the call holding the iterator declarationstype- the type of the call (not the return type)- Returns:
- the iterator declarations in terms of variable declarations (may be empty if there are none)
- Throws:
TranslatorException- in case that the translation fails for some reason
-
processDeclarators
private java.util.ArrayList<I> processDeclarators(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Call call, TypeDescriptor<?> implicitType, java.util.List<CallArgument> arguments, R resolver) throws TranslatorException
Processes a declarator.- Parameters:
call- the actual callimplicitType- the implicit type of the declarator to check against or to use if no explicit type is given, may be null if the underlying type declares the collection implicitly (see deleteJavaCall). In the latter case, the type must be explicitly given by the declarator.resolver- the resolverarguments- the call arguments (may be changed to enable implicit collection iterators)- Returns:
- a list of resolved declarators (at the moment at maximum 1)
- Throws:
TranslatorException- in case that the translation fails
-
resolveCallArguments
protected java.lang.String resolveCallArguments(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Call call, java.util.List<I> iterators, java.util.List<CallArgument> arguments, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Expression arrayEx, R resolver) throws TranslatorExceptionResolves call arguments.- Parameters:
call- the call to resolve the arguments foriterators- the iterators (may be changed as a side effect)arguments- the arguments created so far (may be the operator, list is modified as a side effect)arrayEx- an array access expression (may be null, but thencallis required)resolver- a resolver instance for resolving variables etc.- Returns:
- the operation name
- Throws:
TranslatorException- in case that the translation fails for some reason
-
resolveCallArgumentExpression
private Expression resolveCallArgumentExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.NamedArgument param, int paramIndex, java.util.List<I> iterators, java.util.List<CallArgument> arguments, R resolver) throws TranslatorException
Tries to resolve a call argument. If it is the first argument of a container iteration and there is no iterator, implicitly try to create an iterator.- Parameters:
param- the parameterparamIndex- the 0-based index ofparamin the call being processediterators- the iterators known so far (may be changed as a side effect)arguments- the call argumentsresolver- the resolver instance- Returns:
- the resolved expression
- Throws:
TranslatorException- in case that resolution fails
-
tryIteratorExpression
private ExpressionEvaluator tryIteratorExpression(java.util.List<CallArgument> arguments, de.uni_hildesheim.sse.vil.expressions.expressionDsl.NamedArgument param, R resolver) throws TranslatorException
Tries to compose an iterator expression (ExpressionEvaluator)- Parameters:
arguments- the arguments to try to construct the expression fromparam- the actual parameter to do the resolution forresolver- a resolver instance for resolving variables etc.- Returns:
- the iterator expression if successful
- Throws:
TranslatorException- in case that the expression cannot be created
-
createVariableDeclaration
protected abstract I createVariableDeclaration(java.lang.String name, TypeDescriptor<?> type, boolean isConstant, Expression expression, R resolver)
Creates a new variable declaration.- Parameters:
name- the name of the variabletype- the type of the variableisConstant- whether this variable is a constantexpression- an expression denoting the initial value (may be null)resolver- the resolver instance
-
createImplicitVariableDeclaration
protected abstract I createImplicitVariableDeclaration(java.lang.String name, TypeDescriptor<?> type, boolean isConstant, Expression expression, R resolver)
Creates a new implicit variable declaration.- Parameters:
name- the name of the variabletype- the type of the variableisConstant- whether this variable is a constantexpression- an expression denoting the initial value (may be null)resolver- the resolver instance
-
processCall
protected abstract Expression processCall(Expression firstParam, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Call call, ExpressionTranslator.CallType type, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Expression arrayEx, R resolver) throws TranslatorException
Processes a function call.- Parameters:
firstParam- the first parameter (may be null)call- the function all (may be null, but thenarrayExis required)arrayEx- an array access expression (may be null, but thencallis required)resolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason
-
checkCallExpression
protected AbstractCallExpression checkCallExpression(AbstractCallExpression callEx, ExpressionTranslator.CallType type, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Call call) throws TranslatorException
Performs generic call expression checks after creation.- Parameters:
callEx- the call expression to be checked (may be null if not resolvable)type- the call typecall- the originating ECore call element- Returns:
callEx- Throws:
TranslatorException- in case of serious problems, e.g.,callExis null
-
checkSemantics
protected VilException checkSemantics(Expression expr)
Checks the semantics of a potential call candidate.- Parameters:
expr- the expression to be checked- Returns:
- the
exprif ok or null
-
processSubCalls
protected Expression processSubCalls(Expression firstParam, org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.SubCall> followups, R resolver) throws TranslatorException
Processes sub calls, i.e., calls connected by ".".- Parameters:
firstParam- the first parameter (the expression before the ".")followups- the follow-up callsresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason
-
processPrimaryExpression
public Expression processPrimaryExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.PrimaryExpression ex, R resolver) throws TranslatorException
Processes a primary expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason
-
processArguments
public CallArgument[] processArguments(de.uni_hildesheim.sse.vil.expressions.expressionDsl.ArgumentList arguments, R resolver) throws TranslatorException
Processes an argument list and translates them into call arguments.- Parameters:
arguments- the arguments to be translatedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason
-
parseExpression
public abstract Expression parseExpression(java.lang.String expression, R resolver, java.lang.StringBuilder warnings) throws VilException
Parse the given expression.- Specified by:
parseExpressionin interfaceStringResolver.IExpressionTranslator<I extends VariableDeclaration,R extends Resolver<I>>- Parameters:
expression- the expression as stringresolver- the resolverwarnings- a collector for warnings- Returns:
- the resulting expression
- Throws:
VilException- if problems occur while parsing / resolving
-
processConstant
protected Expression processConstant(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Constant arg, R resolver) throws TranslatorException
Processes a constant argument.- Parameters:
arg- the constant to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason
-
normalizeStringExpression
private Expression normalizeStringExpression(Expression ex, java.lang.String st) throws VilException
Normalizes a string expression, i.e., ifex(within aCompositeExpressionis not a constant, aStringExpressioncontaining the expression is inserted instead. This allows recursive/nested variable/expression substitution without having the required string quotes being quoted within a string.- Parameters:
ex- the expression to check- Returns:
exor a modifiedex- Throws:
VilException- if creating the modified expression fails
-
convertToVersion
private Expression convertToVersion(java.lang.String text, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Constant arg, R resolver) throws TranslatorException
- Throws:
TranslatorException
-
process
private FieldAccessExpression process(VariableDeclaration var, FieldAccessExpression last, java.lang.String name, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Constant elt) throws TranslatorException
- Throws:
TranslatorException
-
processQualifiedValue
protected Expression processQualifiedValue(java.lang.String name, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Constant arg, org.eclipse.emf.ecore.EStructuralFeature feature, R resolver) throws TranslatorException
Processes a qualified value and creates variable expressions.- Parameters:
name- the qualified namearg- the constant to be processedfeature- the feature corresponding toargresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
TranslatorException- in case that the translation fails for some reason, in particular if ITER cannot be resolved
-
checkOclEnumCompliance
private void checkOclEnumCompliance(java.lang.String name, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature)Checks the given enumeration literal name for OCL compliance.- Parameters:
name- the namecause- the causing objectcauseFeature- the causing feature
-
createConstant
protected static final Expression createConstant(TypeDescriptor<?> type, java.lang.Object value, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature, TypeRegistry registry) throws TranslatorException
Creates a constant.- Parameters:
type- the type of the constantvalue- the value of the constantcause- the Ecore language model element for which the exception was causedcausingFeature- the specific language feature withincausewhich caused the exception- Returns:
- the created constant expression
- Throws:
TranslatorException- in case that type resolution fails
-
processType
public TypeDescriptor<?> processType(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Type type, R resolver) throws TranslatorException
Processes the given type and tries to resolve it to a VIL type.- Parameters:
type- the type to be processedresolver- the resolver instance- Returns:
- the corresponding VIL type
- Throws:
TranslatorException- in case that type resolution fails
-
resolveModelType
private TypeDescriptor<?> resolveModelType(de.uni_hildesheim.sse.vil.expressions.expressionDsl.Type type, java.lang.String typeName, R resolver) throws TranslatorException
Resolves a model type.- Parameters:
type- the type as ECore instancetypeName- the name of the typeresolver- the resolver- Returns:
- the type or null if not resolved
- Throws:
TranslatorException- in case of a serious resolution problem
-
processContainerInitializer
private ContainerInitializerExpression processContainerInitializer(de.uni_hildesheim.sse.vil.expressions.expressionDsl.ContainerInitializer initializer, R resolver) throws TranslatorException
Processes a container initializer expression.- Parameters:
initializer- the container initializer expression as ECore instanceresolver- a resolver instance for resolving variables etc.- Returns:
- the resolved container initializer expression
- Throws:
TranslatorException- in case that type resolution fails
-
processTypeParameter
protected TypeDescriptor<?>[] processTypeParameter(de.uni_hildesheim.sse.vil.expressions.expressionDsl.TypeParameters param, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Type type, R resolver) throws TranslatorException
Processes the type parameter.- Parameters:
param- the ECore instance containing the type parametertype- the type the parameter are assigned toresolver- the resolver instance- Returns:
- the processed parameter in terms of VIL type descriptors
- Throws:
TranslatorException- in case that type resolution fails
-
processAssignment
public Expression processAssignment(org.eclipse.emf.ecore.EObject cause, TypeDescriptor<?> type, de.uni_hildesheim.sse.vil.expressions.expressionDsl.Expression ex, R resolver) throws TranslatorException
Processes an assignment.- Parameters:
decl- the variable declaration to assign totype- the type of the variableex- the expression defining the right side of the assignment (may be null)text- a text describing the left side in case of an errorresolver- the resolver instance- Returns:
- the resolved initialization expression or null if
exwas null - Throws:
TranslatorException- in case that type resolution / compliance fails
-
processVariableDeclaration
public I processVariableDeclaration(de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration decl, R resolver) throws TranslatorException
Processes a variable declaration.- Parameters:
decl- the declarationresolver- a resolver instance for resolving variables etc.- Returns:
- the created model instance
- Throws:
TranslatorException- in case that the translation fails
-
reProcessVariableDeclaration
public void reProcessVariableDeclaration(I decl, R resolver) throws TranslatorException
Re-processes a variable declaration in order to get rid ofDeferredResolvableOperationExpression.- Parameters:
decl- the declarationresolver- the resolver- Throws:
TranslatorException- in case that re-processing fails for some reason
-
throwVariableCannotBeInitialized
private void throwVariableCannotBeInitialized(org.eclipse.emf.ecore.EObject cause, java.lang.String name, TypeDescriptor<?> declType, TypeDescriptor<?> initType) throws TranslatorExceptionThrows aTranslatorExceptionthat a variable cannot be initialized.- Parameters:
cause- the causing ECore objectname- the name of the object (inferred fromcauseif null if possible)declType- the declaration VIL typeinitType- the init expression VIL type- Throws:
TranslatorException- the created exception
-
getName
private static java.lang.String getName(org.eclipse.emf.ecore.EObject cause)
Tries to obtain the name ofcause.- Parameters:
cause- the cause- Returns:
- the name or
"?"
-
continueResolution
protected boolean continueResolution(VilException semanticException)
Returns whether resolution shall be continued in case of multiple similar call expressions.- Parameters:
semanticException- the exception being thrown by the (partial) call resolution- Returns:
trueif resolution shall be continued (there was an exception and it points to a resolution or a semantic problem),falseelse
-
error
public void error(AbstractException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature)
Turns a buildlang exception into a xText error.- Parameters:
exception- the exception to usedcause- the cause (as instance of the EMF grammar model)causeFeature- the cause of the feature as an appropriate constant fromIvmlPackage.Literals
-
warning
public void warning(AbstractException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature)
Turns a buildlang exception into a xText warning.- Parameters:
exception- the exception to usedcause- the cause (as instance of the EMF grammar model)causeFeature- the cause of the feature as an appropriate constant fromIvmlPackage.Literals
-
warnVersionRestrictions
public void warnVersionRestrictions(de.uni_hildesheim.sse.vil.expressions.expressionDsl.VersionSpec spec)
Issues implementation warnings about version restrictions.- Parameters:
spec- the version specification (may be null)
-
processRestriction
public IVersionRestriction processRestriction(java.lang.String name, de.uni_hildesheim.sse.vil.expressions.expressionDsl.VersionSpec spec, R resolver) throws TranslatorException
Processes an import restriction.- Parameters:
name- the name of the importspec- the version specification to be processed- Returns:
- the created restriction
- Throws:
TranslatorException- in case of any translation problem
-
createExpressionVersionRestriction
protected abstract ExpressionVersionRestriction createExpressionVersionRestriction(Expression expr, VariableDeclaration decl, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature feature) throws RestrictionEvaluationException
Creates an expression version restriction matching this class.- Parameters:
expr- the expression for the restrictiondecl- the version variablecause- the grammar cause for this callfeature- the causing feature- Returns:
- the created instance
- Throws:
RestrictionEvaluationException- in case of any type related problems
-
resolved
public void resolved(VarModelIdentifierExpression ex)
Description copied from interface:ResolutionListenerIs called ifexwas resolved.- Specified by:
resolvedin interfaceResolutionListener- Parameters:
ex- the resolved expression
-
assertBooleanExpression
public Expression assertBooleanExpression(Expression expression, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) throws TranslatorException
Asserts the given expression to be of Boolean type.- Parameters:
expression- the expression to checkcause- the causing ECore AST objectcausingFeature- the causing feature- Returns:
expressionor a converted expression- Throws:
TranslatorException- thrown if the expression is not of type Boolean
-
-