Class ModelTranslator<M extends IModel,​I extends VariableDeclaration,​R extends Resolver<I>,​S extends ExpressionStatement,​E extends ExpressionTranslator<I,​R,​S>>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private R resolver  
    • Constructor Summary

      Constructors 
      Constructor Description
      ModelTranslator​(E expressionTranslator, R resolver)
      Creates a new model translator.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      private void addImportedVariablesToResolver​(M model, boolean addModel, java.util.Set<M> done)
      Adds (transitively) imported variables to the actual resolver.
      protected abstract void addVisibleDeclarationsToResolver​(M model, R resolver)
      Adds visible declarations of model to resolver.
      private void buildLocalTypeRegistry​(Advice advice)
      Builds a local type registry for advice.
      static Version convert​(de.uni_hildesheim.sse.vil.expressions.expressionDsl.VersionStmt versionStatement)
      Converts a grammar version statement into a model version object.
      protected abstract I[] createArray​(int len)
      Creates an array of .
      protected abstract Compound createCompound​(CompoundTypeDescriptor type)
      Creates a compound object.
      protected abstract Typedef createTypedef​(java.lang.String name, TypeDescriptor<?> type)
      Creates a typdef object.
      protected ModelImport<M> getExtensionImport​(java.lang.String name, Imports<M> imports, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature)
      Returns an extension import (super script, super template).
      protected abstract ModelManagement<M> getManagementInstance()
      Returns the management instance.
      protected R getResolver()
      Returns the resolver instance.
      protected java.util.List<IMessage> postResolveImports​(M model, java.net.URI uri, java.util.List<IMessage> resolutionMessages)
      Is called in case of resolution problems.
      protected Advice[] processAdvices​(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Advice> advices, java.net.URI modelURI)
      Processes the advices (of a script).
      protected void processCompoundContents​(java.util.List<org.eclipse.emf.ecore.EObject> elts, ICompoundReceiver receiver)
      Processes the compounds in elts.
      protected void processCompounds​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Compound> cmps, ICompoundReceiver receiver)
      Processes the given compounds.
      private void processCompounds​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Compound> cmps, ICompoundReceiver receiver, boolean force)
      Processes the given typedefs.
      protected Imports<M> processImports​(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Import> imports)
      Processes the imports and returns an summarizing instance.
      protected void processTypedefContents​(java.util.List<org.eclipse.emf.ecore.EObject> elts, ITypedefReceiver receiver)
      Processes the typedefs in elts.
      protected void processTypedefs​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.TypeDef> defs, ITypedefReceiver receiver)
      Processes the given typedefs.
      private void processTypedefs​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.TypeDef> defs, ITypedefReceiver receiver, boolean force)
      Processes the given typedefs.
      protected void processVariableDeclarations​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration> decls, IVariableDeclarationReceiver<I> receiver)
      Processes all variable declarations considering dependencies and terminates with an error if not all can be resolved.
      protected void processVariableDeclarations​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration> decls, IVariableDeclarationReceiver<I> receiver, boolean addToResolver)
      Processes all variable declarations considering dependencies and terminates with an error if not all can be resolved.
      private void processVariableDeclarations​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration> decls, IVariableDeclarationReceiver<I> receiver, boolean force, boolean addToResolver)
      Processes a set of variable declarations and adds successfully processed ones to the current resolver level.
      protected void resolveImports​(de.uni_hildesheim.sse.vil.expressions.expressionDsl.LanguageUnit input, org.eclipse.emf.ecore.EStructuralFeature inputFeature, M model, java.net.URI uri, java.util.List<? extends de.uni_hildesheim.sse.vil.expressions.expressionDsl.LanguageUnit> inProgress, ImportResolver<M> impResolver)
      Resolves the imports.
      protected I[] resolveParameters​(de.uni_hildesheim.sse.vil.expressions.expressionDsl.ParameterList pList, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature paramListFeature, R resolver)
      Resolves the parameters in pList.
      protected I[] resolveParameters​(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Parameter> parameters, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature paramListFeature, R resolver)
      Resolves the parameters in parameters.
      protected void warnVersionRestrictions​(de.uni_hildesheim.sse.vil.expressions.expressionDsl.VersionSpec spec)
      Issues implementation warnings about version restrictions.
      • Methods inherited from class java.lang.Object

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

      • resolver

        private R extends Resolver<I> resolver
    • Constructor Detail

      • ModelTranslator

        public ModelTranslator​(E expressionTranslator,
                               R resolver)
        Creates a new model translator.
        Parameters:
        expressionTranslator - the expression translator instance
        resolver - the resolver instance
    • Method Detail

      • getResolver

        protected R getResolver()
        Returns the resolver instance.
        Returns:
        the resolver
      • processImports

        protected Imports<M> processImports​(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Import> imports)
                                     throws TranslatorException
        Processes the imports and returns an summarizing instance.
        Parameters:
        imports - the imports to be processed
        Returns:
        the summarizing instance
        Throws:
        TranslatorException - in case that processing the imports fails
      • getExtensionImport

        protected ModelImport<M> getExtensionImport​(java.lang.String name,
                                                    Imports<M> imports,
                                                    org.eclipse.emf.ecore.EObject cause,
                                                    org.eclipse.emf.ecore.EStructuralFeature causingFeature)
                                             throws TranslatorException
        Returns an extension import (super script, super template).
        Parameters:
        name - the name of the model
        imports - the known imports
        cause - the causing ECore element (in case of throwing an exception)
        causingFeature - the causing feature (in case of throwing an exception)
        Returns:
        the found import
        Throws:
        TranslatorException - in case that the import cannot be found
      • processTypedefContents

        protected void processTypedefContents​(java.util.List<org.eclipse.emf.ecore.EObject> elts,
                                              ITypedefReceiver receiver)
        Processes the typedefs in elts.
        Parameters:
        elts - the elements
        receiver - the typedef receiver
      • processCompoundContents

        protected void processCompoundContents​(java.util.List<org.eclipse.emf.ecore.EObject> elts,
                                               ICompoundReceiver receiver)
        Processes the compounds in elts.
        Parameters:
        elts - the elements
        receiver - the compound receiver
      • processTypedefs

        protected void processTypedefs​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.TypeDef> defs,
                                       ITypedefReceiver receiver)
        Processes the given typedefs.
        Parameters:
        defs - the typedefs
        receiver - the typedef receiver
      • processCompounds

        protected void processCompounds​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Compound> cmps,
                                        ICompoundReceiver receiver)
        Processes the given compounds.
        Parameters:
        defs - the compounds
        receiver - the compozbd receiver
      • processTypedefs

        private void processTypedefs​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.TypeDef> defs,
                                     ITypedefReceiver receiver,
                                     boolean force)
        Processes the given typedefs.
        Parameters:
        defs - the typedefs
        receiver - the typedef receiver
        force - force processing typedefs not resolved so far
      • processCompounds

        private void processCompounds​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Compound> cmps,
                                      ICompoundReceiver receiver,
                                      boolean force)
        Processes the given typedefs.
        Parameters:
        defs - the typedefs
        receiver - the typedef receiver
        force - force processing typedefs not resolved so far
      • createTypedef

        protected abstract Typedef createTypedef​(java.lang.String name,
                                                 TypeDescriptor<?> type)
                                          throws VilException
        Creates a typdef object.
        Parameters:
        name - the name of the typdef/alias
        type - the the type
        Returns:
        the typedef
        Throws:
        VilException
      • processVariableDeclarations

        protected void processVariableDeclarations​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration> decls,
                                                   IVariableDeclarationReceiver<I> receiver)
        Processes all variable declarations considering dependencies and terminates with an error if not all can be resolved.
        Parameters:
        decls - the declarations to be processed
        receiver - a receiver for the created instances
      • processVariableDeclarations

        protected void processVariableDeclarations​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration> decls,
                                                   IVariableDeclarationReceiver<I> receiver,
                                                   boolean addToResolver)
        Processes all variable declarations considering dependencies and terminates with an error if not all can be resolved.
        Parameters:
        decls - the declarations to be processed
        receiver - a receiver for the created instances
        addToResolver - add the newly created variables to the resolver instance
      • processVariableDeclarations

        private void processVariableDeclarations​(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration> decls,
                                                 IVariableDeclarationReceiver<I> receiver,
                                                 boolean force,
                                                 boolean addToResolver)
        Processes a set of variable declarations and adds successfully processed ones to the current resolver level.
        Parameters:
        decls - the declarations to be processed (successfully processed declarations will be removed, may be modified as a side effect)
        receiver - a receiver for the created instances
        force - if true a failing variable creation will be recorded as an error, false failing creations will be ignored
        addToResolver - add the newly created variable to the resolver instance
      • processAdvices

        protected Advice[] processAdvices​(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Advice> advices,
                                          java.net.URI modelURI)
        Processes the advices (of a script).
        Parameters:
        advices - the advices to be processed
        modelURI - the URI to the model being processed
        Returns:
        the processed advices
      • buildLocalTypeRegistry

        private void buildLocalTypeRegistry​(Advice advice)
        Builds a local type registry for advice.
        Parameters:
        advice - the advice to build the local type registry for
      • warnVersionRestrictions

        protected 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)
      • resolveParameters

        protected I[] resolveParameters​(de.uni_hildesheim.sse.vil.expressions.expressionDsl.ParameterList pList,
                                        org.eclipse.emf.ecore.EObject cause,
                                        org.eclipse.emf.ecore.EStructuralFeature paramListFeature,
                                        R resolver)
                                 throws TranslatorException
        Resolves the parameters in pList.
        Parameters:
        pList - the parameter list to be resolved
        cause - the causing object containing the parameters
        paramListFeature - the param list feature on cause
        resolver - the resolver instance
        Returns:
        the resolved parameters (may actually be less then in pList in case of name or type failures
        Throws:
        TranslatorException - in case that a problem occurred
      • resolveParameters

        protected I[] resolveParameters​(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Parameter> parameters,
                                        org.eclipse.emf.ecore.EObject cause,
                                        org.eclipse.emf.ecore.EStructuralFeature paramListFeature,
                                        R resolver)
                                 throws TranslatorException
        Resolves the parameters in parameters.
        Parameters:
        parameters - the parameters to be resolved
        cause - the causing object containing the parameters
        paramListFeature - the param list feature on cause
        resolver - the resolver instance
        Returns:
        the resolved parameters (may actually be less then in pList in case of name or type failures
        Throws:
        TranslatorException - in case that a problem occurred
      • createArray

        protected abstract I[] createArray​(int len)
        Creates an array of .
        Parameters:
        len - the length of the array
        Returns:
        the array
      • convert

        public static Version convert​(de.uni_hildesheim.sse.vil.expressions.expressionDsl.VersionStmt versionStatement)
        Converts a grammar version statement into a model version object.
        Parameters:
        versionStatement - the version statement to be converts
        Returns:
        the resulting model version object
      • getManagementInstance

        protected abstract ModelManagement<M> getManagementInstance()
        Returns the management instance.
        Returns:
        the management instance
      • resolveImports

        protected void resolveImports​(de.uni_hildesheim.sse.vil.expressions.expressionDsl.LanguageUnit input,
                                      org.eclipse.emf.ecore.EStructuralFeature inputFeature,
                                      M model,
                                      java.net.URI uri,
                                      java.util.List<? extends de.uni_hildesheim.sse.vil.expressions.expressionDsl.LanguageUnit> inProgress,
                                      ImportResolver<M> impResolver)
        Resolves the imports.
        Parameters:
        input - the input language element
        inputFeature - the EMF feature this resolution happens on
        model - the model being created
        uri - the physical URI of the project
        inProgress - the other projects being resolved at once (in order to avoid loops)
      • addImportedVariablesToResolver

        private void addImportedVariablesToResolver​(M model,
                                                    boolean addModel,
                                                    java.util.Set<M> done)
        Adds (transitively) imported variables to the actual resolver.
        Parameters:
        model - the model to consider
        addModel - whether the variables of model shall be added (true) or whether only its imports shall be traversed
        done - collects models that are already processed
        See Also:
        addVisibleDeclarationsToResolver(IModel, Resolver)
      • addVisibleDeclarationsToResolver

        protected abstract void addVisibleDeclarationsToResolver​(M model,
                                                                 R resolver)
        Adds visible declarations of model to resolver. This method shall not consider imports as it is called by addImportedVariablesToResolver(IModel, boolean, Set).
        Parameters:
        model - the model to consider
        resolver - the resolver to add variables to
      • postResolveImports

        protected java.util.List<IMessage> postResolveImports​(M model,
                                                              java.net.URI uri,
                                                              java.util.List<IMessage> resolutionMessages)
        Is called in case of resolution problems.
        Parameters:
        model - the model to be resolved
        uri - the physical URI of the project
        resolutionMessages - the messages collected so far
        Returns:
        the new resolution messages