Class ExpressionTranslator<I extends net.ssehub.easy.instantiation.core.model.common.VariableDeclaration,R extends net.ssehub.easy.instantiation.core.model.expressions.Resolver<I>,E extends net.ssehub.easy.instantiation.core.model.common.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:
net.ssehub.easy.dslCore.translation.IMessageReceiver, net.ssehub.easy.instantiation.core.model.expressions.ResolutionListener, net.ssehub.easy.instantiation.core.model.expressions.StringResolver.IExpressionTranslator<I,R>

public abstract class ExpressionTranslator<I extends net.ssehub.easy.instantiation.core.model.common.VariableDeclaration,R extends net.ssehub.easy.instantiation.core.model.expressions.Resolver<I>,E extends net.ssehub.easy.instantiation.core.model.common.ExpressionStatement> extends net.ssehub.easy.dslCore.translation.ExpressionTranslator implements net.ssehub.easy.instantiation.core.model.expressions.ResolutionListener, net.ssehub.easy.instantiation.core.model.expressions.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 enum 
    Defines basic VIL call types.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    private net.ssehub.easy.instantiation.core.model.expressions.VarModelIdentifierExpression
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an expression translator (to be used within this package only).
  • Method Summary

    Modifier and Type
    Method
    Description
    net.ssehub.easy.instantiation.core.model.expressions.Expression
    assertBooleanExpression(net.ssehub.easy.instantiation.core.model.expressions.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 String
    A hint if an assignment is not allowed.
    protected net.ssehub.easy.instantiation.core.model.expressions.AbstractCallExpression
    checkCallExpression(net.ssehub.easy.instantiation.core.model.expressions.AbstractCallExpression callEx, ExpressionTranslator.CallType type, Call call)
    Performs generic call expression checks after creation.
    private void
    checkOclEnumCompliance(String name, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature)
    Checks the given enumeration literal name for OCL compliance.
    protected net.ssehub.easy.instantiation.core.model.common.VilException
    checkSemantics(net.ssehub.easy.instantiation.core.model.expressions.Expression expr)
    Checks the semantics of a potential call candidate.
    protected boolean
    continueResolution(net.ssehub.easy.instantiation.core.model.common.VilException semanticException)
    Returns whether resolution shall be continued in case of multiple similar call expressions.
    private net.ssehub.easy.instantiation.core.model.expressions.Expression
    convertToVersion(String text, Constant arg, R resolver)
     
    protected static final net.ssehub.easy.instantiation.core.model.expressions.Expression
    createConstant(net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, Object value, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature, net.ssehub.easy.instantiation.core.model.vilTypes.TypeRegistry registry)
    Creates a constant.
    protected abstract E
    createExpressionStatement(net.ssehub.easy.instantiation.core.model.expressions.Expression expression, R resolver)
    Creates an expression statement.
    protected abstract net.ssehub.easy.instantiation.core.model.expressions.ExpressionVersionRestriction
    createExpressionVersionRestriction(net.ssehub.easy.instantiation.core.model.expressions.Expression expr, net.ssehub.easy.instantiation.core.model.common.VariableDeclaration decl, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature feature)
    Creates an expression version restriction matching this class.
    protected abstract I
    createImplicitVariableDeclaration(String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, boolean isConstant, net.ssehub.easy.instantiation.core.model.expressions.Expression expression, R resolver)
    Creates a new implicit variable declaration.
    protected abstract I
    createVariableDeclaration(String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, boolean isConstant, net.ssehub.easy.instantiation.core.model.expressions.Expression expression, R resolver)
    Creates a new variable declaration.
    void
    Enacts the IVML warnings not resolved by "function pointers" so far.
    void
    error(net.ssehub.easy.basics.messages.AbstractException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature)
    Turns a buildlang exception into a xText error.
    Returns the IVML message adapter.
    private static String
    getName(org.eclipse.emf.ecore.EObject cause)
    Tries to obtain the name of cause.
    private void
    ivmlWarning(String name, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature)
    Creates a warning due to an unresolved IVML element.
    private net.ssehub.easy.instantiation.core.model.expressions.Expression
    normalizeStringExpression(net.ssehub.easy.instantiation.core.model.expressions.Expression ex, String st)
    Normalizes a string expression, i.e., if ex (within a CompositeExpression is not a constant, a StringExpression containing the expression is inserted instead.
    abstract net.ssehub.easy.instantiation.core.model.expressions.Expression
    parseExpression(String expression, R resolver, StringBuilder warnings)
    Parse the given expression.
    private net.ssehub.easy.instantiation.core.model.expressions.FieldAccessExpression
    process(net.ssehub.easy.instantiation.core.model.common.VariableDeclaration var, net.ssehub.easy.instantiation.core.model.expressions.FieldAccessExpression last, String name, Constant elt)
     
    protected net.ssehub.easy.instantiation.core.model.expressions.Expression
    Processes an additive expression.
    net.ssehub.easy.instantiation.core.model.expressions.CallArgument[]
    processArguments(ArgumentList arguments, R resolver)
    Processes an argument list and translates them into call arguments.
    net.ssehub.easy.instantiation.core.model.expressions.Expression
    processAssignment(org.eclipse.emf.ecore.EObject cause, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, Expression ex, R resolver)
    Processes an assignment.
    protected abstract net.ssehub.easy.instantiation.core.model.expressions.Expression
    processCall(net.ssehub.easy.instantiation.core.model.expressions.Expression firstParam, Call call, ExpressionTranslator.CallType type, Expression arrayEx, R resolver)
    Processes a function call.
    protected net.ssehub.easy.instantiation.core.model.expressions.Expression
    processConstant(Constant arg, R resolver)
    Processes a constant argument.
    private net.ssehub.easy.instantiation.core.model.expressions.ContainerInitializerExpression
    Processes a container initializer expression.
    private ArrayList<I>
    processDeclarators(Call call, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> implicitType, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, R resolver)
    Processes a declarator.
    protected net.ssehub.easy.instantiation.core.model.expressions.Expression
    Processes an equality expression.
    net.ssehub.easy.instantiation.core.model.expressions.Expression
    Creates the expression tree for a given expression.
    Processes an expression statement.
    net.ssehub.easy.instantiation.core.model.expressions.Expression
    Processes a logical expression.
    protected net.ssehub.easy.instantiation.core.model.expressions.Expression
    Processes a multiplicative expression.
    protected net.ssehub.easy.instantiation.core.model.expressions.Expression
    Processes a postfix expression.
    net.ssehub.easy.instantiation.core.model.expressions.Expression
    Processes a primary expression.
    protected net.ssehub.easy.instantiation.core.model.expressions.Expression
    processQualifiedValue(String name, Constant arg, org.eclipse.emf.ecore.EStructuralFeature feature, R resolver)
    Processes a qualified value and creates variable expressions.
    protected net.ssehub.easy.instantiation.core.model.expressions.Expression
    Processes a relational expression.
    net.ssehub.easy.basics.modelManagement.IVersionRestriction
    processRestriction(String name, VersionSpec spec, R resolver)
    Processes an import restriction.
    protected net.ssehub.easy.instantiation.core.model.expressions.Expression
    processSubCall(net.ssehub.easy.instantiation.core.model.expressions.Expression result, SubCall call, ExpressionTranslator.CallType callType, R resolver)
    Processes a single sub call, i.e., calls connected by ".".
    protected net.ssehub.easy.instantiation.core.model.expressions.Expression
    processSubCalls(net.ssehub.easy.instantiation.core.model.expressions.Expression firstParam, org.eclipse.emf.common.util.EList<SubCall> followups, R resolver)
    Processes sub calls, i.e., calls connected by ".".
    net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?>
    processType(Type type, R resolver)
    Processes the given type and tries to resolve it to a VIL type.
    protected net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?>[]
    processTypeParameter(TypeParameters param, Type type, R resolver)
    Processes the type parameter.
    protected net.ssehub.easy.instantiation.core.model.expressions.Expression
    Processes a unary expression.
    Processes a variable declaration.
    void
    reProcessVariableDeclaration(I decl, R resolver)
    Re-processes a variable declaration in order to get rid of DeferredResolvableOperationExpression.
    private net.ssehub.easy.instantiation.core.model.expressions.Expression
    resolveCallArgumentExpression(NamedArgument param, int paramIndex, List<I> iterators, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, R resolver)
    Tries to resolve a call argument.
    protected String
    resolveCallArguments(Call call, List<I> iterators, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, Expression arrayEx, R resolver)
    Resolves call arguments.
    void
    resolved(net.ssehub.easy.instantiation.core.model.expressions.VarModelIdentifierExpression ex)
     
    protected List<I>
    resolveIteratorDeclarations(Call call, ExpressionTranslator.CallType type, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, R resolver)
    Resolves the iterator declarations.
    private net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?>
    resolveModelType(Type type, String typeName, R resolver)
    Resolves a model type.
    Allows for (temporary) exchange of the IVML message adapter, e.g., to handle warnings differently.
    private void
    throwVariableCannotBeInitialized(org.eclipse.emf.ecore.EObject cause, String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> declType, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> initType)
    Throws a TranslatorException that a variable cannot be initialized.
    private net.ssehub.easy.instantiation.core.model.expressions.ExpressionEvaluator
    tryIteratorExpression(List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, NamedArgument param, R resolver)
    Tries to compose an iterator expression (ExpressionEvaluator)
    void
    warning(net.ssehub.easy.basics.messages.AbstractException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature)
    Turns a buildlang exception into a xText warning.
    void
    Issues implementation warnings about version restrictions.

    Methods inherited from class net.ssehub.easy.dslCore.translation.ExpressionTranslator

    addMessage, clearMessages, clearMessages, collect, error, error, getErrorCount, getMessage, getMessageCount, warning

    Methods inherited from class net.ssehub.easy.dslCore.translation.MessageReceiver

    error

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • lastVarModelIdentifierEx

      private net.ssehub.easy.instantiation.core.model.expressions.VarModelIdentifierExpression lastVarModelIdentifierEx
    • ivmlMessageAdapter

      private IvmlMessageAdapter ivmlMessageAdapter
  • Constructor Details

    • ExpressionTranslator

      public ExpressionTranslator()
      Creates an expression translator (to be used within this package only).
  • Method Details

    • 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 net.ssehub.easy.instantiation.core.model.expressions.Expression processExpression(Expression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Creates the expression tree for a given expression.
      Parameters:
      ex - the expression to be processed
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression tree
      Throws:
      net.ssehub.easy.dslCore.translation.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(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 element
      cause - the causing ECore element
      causingFeature - the causing ECore feature
    • processExpressionStatement

      public E processExpressionStatement(ExpressionStatement expr, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes an expression statement.
      Parameters:
      expr - the expression to be processed
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the expression statement
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails due to semantic reasons
      See Also:
    • cannotAssignHint

      protected abstract String cannotAssignHint()
      A hint if an assignment is not allowed.
      Returns:
      the hint (must not be null)
    • createExpressionStatement

      protected abstract E createExpressionStatement(net.ssehub.easy.instantiation.core.model.expressions.Expression expression, R resolver)
      Creates an expression statement.
      Parameters:
      expression - the expression
      resolver - the resolver instance
      Returns:
      the expression statement
    • processLogicalExpression

      public net.ssehub.easy.instantiation.core.model.expressions.Expression processLogicalExpression(LogicalExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a logical expression.
      Parameters:
      ex - the expression to be processed
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • processEqualityExpression

      protected net.ssehub.easy.instantiation.core.model.expressions.Expression processEqualityExpression(EqualityExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes an equality expression.
      Parameters:
      ex - the expression to be processed
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • processRelationalExpression

      protected net.ssehub.easy.instantiation.core.model.expressions.Expression processRelationalExpression(RelationalExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a relational expression.
      Parameters:
      ex - the expression to be processed
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • processAdditiveExpression

      protected net.ssehub.easy.instantiation.core.model.expressions.Expression processAdditiveExpression(AdditiveExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes an additive expression.
      Parameters:
      ex - the expression to be processed
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • processMultiplicativeExpression

      protected net.ssehub.easy.instantiation.core.model.expressions.Expression processMultiplicativeExpression(MultiplicativeExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a multiplicative expression.
      Parameters:
      ex - the expression to be processed
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • processUnaryExpression

      protected net.ssehub.easy.instantiation.core.model.expressions.Expression processUnaryExpression(UnaryExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a unary expression.
      Parameters:
      ex - the expression to be processed
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • processPostfixExpression

      protected net.ssehub.easy.instantiation.core.model.expressions.Expression processPostfixExpression(PostfixExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a postfix expression.
      Parameters:
      ex - the expression to be processed
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • resolveIteratorDeclarations

      protected List<I> resolveIteratorDeclarations(Call call, ExpressionTranslator.CallType type, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Resolves the iterator declarations. Existence of iterator declarations in call is already checked to be valid.
      Parameters:
      call - the call holding the iterator declarations
      type - 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:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • processDeclarators

      private ArrayList<I> processDeclarators(Call call, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> implicitType, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a declarator.
      Parameters:
      call - the actual call
      implicitType - 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.
      arguments - the call arguments (may be changed to enable implicit collection iterators)
      resolver - the resolver
      Returns:
      a list of resolved declarators (at the moment at maximum 1)
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails
    • resolveCallArguments

      protected String resolveCallArguments(Call call, List<I> iterators, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, Expression arrayEx, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Resolves call arguments.
      Parameters:
      call - the call to resolve the arguments for
      iterators - 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 then call is required)
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the operation name
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • resolveCallArgumentExpression

      private net.ssehub.easy.instantiation.core.model.expressions.Expression resolveCallArgumentExpression(NamedArgument param, int paramIndex, List<I> iterators, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, R resolver) throws net.ssehub.easy.dslCore.translation.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 parameter
      paramIndex - the 0-based index of param in the call being processed
      iterators - the iterators known so far (may be changed as a side effect)
      arguments - the call arguments
      resolver - the resolver instance
      Returns:
      the resolved expression
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that resolution fails
    • tryIteratorExpression

      private net.ssehub.easy.instantiation.core.model.expressions.ExpressionEvaluator tryIteratorExpression(List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, NamedArgument param, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Tries to compose an iterator expression (ExpressionEvaluator)
      Parameters:
      arguments - the arguments to try to construct the expression from
      param - the actual parameter to do the resolution for
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the iterator expression if successful
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the expression cannot be created
    • createVariableDeclaration

      protected abstract I createVariableDeclaration(String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, boolean isConstant, net.ssehub.easy.instantiation.core.model.expressions.Expression expression, R resolver)
      Creates a new variable declaration.
      Parameters:
      name - the name of the variable
      type - the type of the variable
      isConstant - whether this variable is a constant
      expression - an expression denoting the initial value (may be null)
      resolver - the resolver instance
    • createImplicitVariableDeclaration

      protected abstract I createImplicitVariableDeclaration(String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, boolean isConstant, net.ssehub.easy.instantiation.core.model.expressions.Expression expression, R resolver)
      Creates a new implicit variable declaration.
      Parameters:
      name - the name of the variable
      type - the type of the variable
      isConstant - whether this variable is a constant
      expression - an expression denoting the initial value (may be null)
      resolver - the resolver instance
    • processCall

      protected abstract net.ssehub.easy.instantiation.core.model.expressions.Expression processCall(net.ssehub.easy.instantiation.core.model.expressions.Expression firstParam, Call call, ExpressionTranslator.CallType type, Expression arrayEx, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a function call.
      Parameters:
      firstParam - the first parameter (may be null)
      call - the function all (may be null, but then arrayEx is required)
      arrayEx - an array access expression (may be null, but then call is required)
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • checkCallExpression

      protected net.ssehub.easy.instantiation.core.model.expressions.AbstractCallExpression checkCallExpression(net.ssehub.easy.instantiation.core.model.expressions.AbstractCallExpression callEx, ExpressionTranslator.CallType type, Call call) throws net.ssehub.easy.dslCore.translation.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 type
      call - the originating ECore call element
      Returns:
      callEx
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case of serious problems, e.g., callEx is null
    • checkSemantics

      protected net.ssehub.easy.instantiation.core.model.common.VilException checkSemantics(net.ssehub.easy.instantiation.core.model.expressions.Expression expr)
      Checks the semantics of a potential call candidate.
      Parameters:
      expr - the expression to be checked
      Returns:
      the expr if ok or null
    • processSubCalls

      protected net.ssehub.easy.instantiation.core.model.expressions.Expression processSubCalls(net.ssehub.easy.instantiation.core.model.expressions.Expression firstParam, org.eclipse.emf.common.util.EList<SubCall> followups, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes sub calls, i.e., calls connected by ".".
      Parameters:
      firstParam - the first parameter (the expression before the ".")
      followups - the follow-up calls
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • processSubCall

      protected net.ssehub.easy.instantiation.core.model.expressions.Expression processSubCall(net.ssehub.easy.instantiation.core.model.expressions.Expression result, SubCall call, ExpressionTranslator.CallType callType, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a single sub call, i.e., calls connected by ".".
      Parameters:
      result - the expression created so far, to connect to
      call - the subCall
      callType - the call type
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • processPrimaryExpression

      public net.ssehub.easy.instantiation.core.model.expressions.Expression processPrimaryExpression(PrimaryExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a primary expression.
      Parameters:
      ex - the expression to be processed
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • processArguments

      public net.ssehub.easy.instantiation.core.model.expressions.CallArgument[] processArguments(ArgumentList arguments, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes an argument list and translates them into call arguments.
      Parameters:
      arguments - the arguments to be translated
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • parseExpression

      public abstract net.ssehub.easy.instantiation.core.model.expressions.Expression parseExpression(String expression, R resolver, StringBuilder warnings) throws net.ssehub.easy.instantiation.core.model.common.VilException
      Parse the given expression.
      Specified by:
      parseExpression in interface net.ssehub.easy.instantiation.core.model.expressions.StringResolver.IExpressionTranslator<I extends net.ssehub.easy.instantiation.core.model.common.VariableDeclaration,R extends net.ssehub.easy.instantiation.core.model.expressions.Resolver<I>>
      Parameters:
      expression - the expression as string
      resolver - the resolver
      warnings - a collector for warnings
      Returns:
      the resulting expression
      Throws:
      net.ssehub.easy.instantiation.core.model.common.VilException - if problems occur while parsing / resolving
    • processConstant

      protected net.ssehub.easy.instantiation.core.model.expressions.Expression processConstant(Constant arg, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a constant argument.
      Parameters:
      arg - the constant to be processed
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason
    • normalizeStringExpression

      private net.ssehub.easy.instantiation.core.model.expressions.Expression normalizeStringExpression(net.ssehub.easy.instantiation.core.model.expressions.Expression ex, String st) throws net.ssehub.easy.instantiation.core.model.common.VilException
      Normalizes a string expression, i.e., if ex (within a CompositeExpression is not a constant, a StringExpression containing 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:
      ex or a modified ex
      Throws:
      net.ssehub.easy.instantiation.core.model.common.VilException - if creating the modified expression fails
    • convertToVersion

      private net.ssehub.easy.instantiation.core.model.expressions.Expression convertToVersion(String text, Constant arg, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException
    • process

      private net.ssehub.easy.instantiation.core.model.expressions.FieldAccessExpression process(net.ssehub.easy.instantiation.core.model.common.VariableDeclaration var, net.ssehub.easy.instantiation.core.model.expressions.FieldAccessExpression last, String name, Constant elt) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException
    • processQualifiedValue

      protected net.ssehub.easy.instantiation.core.model.expressions.Expression processQualifiedValue(String name, Constant arg, org.eclipse.emf.ecore.EStructuralFeature feature, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a qualified value and creates variable expressions.
      Parameters:
      name - the qualified name
      arg - the constant to be processed
      feature - the feature corresponding to arg
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resulting expression node
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails for some reason, in particular if ITER cannot be resolved
    • checkOclEnumCompliance

      private void checkOclEnumCompliance(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 name
      cause - the causing object
      causeFeature - the causing feature
    • createConstant

      protected static final net.ssehub.easy.instantiation.core.model.expressions.Expression createConstant(net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, Object value, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature, net.ssehub.easy.instantiation.core.model.vilTypes.TypeRegistry registry) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Creates a constant.
      Parameters:
      type - the type of the constant
      value - the value of the constant
      cause - the Ecore language model element for which the exception was caused
      causingFeature - the specific language feature within cause which caused the exception
      Returns:
      the created constant expression
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that type resolution fails
    • processType

      public net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> processType(Type type, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes the given type and tries to resolve it to a VIL type.
      Parameters:
      type - the type to be processed
      resolver - the resolver instance
      Returns:
      the corresponding VIL type
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that type resolution fails
    • resolveModelType

      private net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> resolveModelType(Type type, String typeName, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Resolves a model type.
      Parameters:
      type - the type as ECore instance
      typeName - the name of the type
      resolver - the resolver
      Returns:
      the type or null if not resolved
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case of a serious resolution problem
    • processContainerInitializer

      private net.ssehub.easy.instantiation.core.model.expressions.ContainerInitializerExpression processContainerInitializer(ContainerInitializer initializer, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a container initializer expression.
      Parameters:
      initializer - the container initializer expression as ECore instance
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the resolved container initializer expression
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that type resolution fails
    • processTypeParameter

      protected net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?>[] processTypeParameter(TypeParameters param, Type type, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes the type parameter.
      Parameters:
      param - the ECore instance containing the type parameter
      type - the type the parameter are assigned to
      resolver - the resolver instance
      Returns:
      the processed parameter in terms of VIL type descriptors
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that type resolution fails
    • processAssignment

      public net.ssehub.easy.instantiation.core.model.expressions.Expression processAssignment(org.eclipse.emf.ecore.EObject cause, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, Expression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes an assignment.
      Parameters:
      type - the type of the variable
      ex - the expression defining the right side of the assignment (may be null)
      resolver - the resolver instance
      decl - the variable declaration to assign to
      text - a text describing the left side in case of an error
      Returns:
      the resolved initialization expression or null if ex was null
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that type resolution / compliance fails
    • processVariableDeclaration

      public I processVariableDeclaration(VariableDeclaration decl, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a variable declaration.
      Parameters:
      decl - the declaration
      resolver - a resolver instance for resolving variables etc.
      Returns:
      the created model instance
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails
    • reProcessVariableDeclaration

      public void reProcessVariableDeclaration(I decl, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Re-processes a variable declaration in order to get rid of DeferredResolvableOperationExpression.
      Parameters:
      decl - the declaration
      resolver - the resolver
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that re-processing fails for some reason
    • throwVariableCannotBeInitialized

      private void throwVariableCannotBeInitialized(org.eclipse.emf.ecore.EObject cause, String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> declType, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> initType) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Throws a TranslatorException that a variable cannot be initialized.
      Parameters:
      cause - the causing ECore object
      name - the name of the object (inferred from cause if null if possible)
      declType - the declaration VIL type
      initType - the init expression VIL type
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - the created exception
    • getName

      private static String getName(org.eclipse.emf.ecore.EObject cause)
      Tries to obtain the name of cause.
      Parameters:
      cause - the cause
      Returns:
      the name or "?"
    • continueResolution

      protected boolean continueResolution(net.ssehub.easy.instantiation.core.model.common.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:
      true if resolution shall be continued (there was an exception and it points to a resolution or a semantic problem), false else
    • error

      public void error(net.ssehub.easy.basics.messages.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 used
      cause - the cause (as instance of the EMF grammar model)
      causeFeature - the cause of the feature as an appropriate constant from IvmlPackage.Literals
    • warning

      public void warning(net.ssehub.easy.basics.messages.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 used
      cause - the cause (as instance of the EMF grammar model)
      causeFeature - the cause of the feature as an appropriate constant from IvmlPackage.Literals
    • warnVersionRestrictions

      public void warnVersionRestrictions(VersionSpec spec)
      Issues implementation warnings about version restrictions.
      Parameters:
      spec - the version specification (may be null)
    • processRestriction

      public net.ssehub.easy.basics.modelManagement.IVersionRestriction processRestriction(String name, VersionSpec spec, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes an import restriction.
      Parameters:
      name - the name of the import
      spec - the version specification to be processed
      Returns:
      the created restriction
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case of any translation problem
    • createExpressionVersionRestriction

      protected abstract net.ssehub.easy.instantiation.core.model.expressions.ExpressionVersionRestriction createExpressionVersionRestriction(net.ssehub.easy.instantiation.core.model.expressions.Expression expr, net.ssehub.easy.instantiation.core.model.common.VariableDeclaration decl, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature feature) throws net.ssehub.easy.basics.modelManagement.RestrictionEvaluationException
      Creates an expression version restriction matching this class.
      Parameters:
      expr - the expression for the restriction
      decl - the version variable
      cause - the grammar cause for this call
      feature - the causing feature
      Returns:
      the created instance
      Throws:
      net.ssehub.easy.basics.modelManagement.RestrictionEvaluationException - in case of any type related problems
    • resolved

      public void resolved(net.ssehub.easy.instantiation.core.model.expressions.VarModelIdentifierExpression ex)
      Specified by:
      resolved in interface net.ssehub.easy.instantiation.core.model.expressions.ResolutionListener
    • assertBooleanExpression

      public net.ssehub.easy.instantiation.core.model.expressions.Expression assertBooleanExpression(net.ssehub.easy.instantiation.core.model.expressions.Expression expression, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Asserts the given expression to be of Boolean type.
      Parameters:
      expression - the expression to check
      cause - the causing ECore AST object
      causingFeature - the causing feature
      Returns:
      expression or a converted expression
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - thrown if the expression is not of type Boolean