Class Resolver<M extends IResolvableModel<V,​M>,​O extends IResolvableOperation<V>,​E extends ModelCallExpression<V,​M,​O>,​V extends IMetaParameterDeclaration>

    • Constructor Detail

      • Resolver

        public Resolver​(TypeRegistry registry)
        Creates a new resolver instance.
        Parameters:
        registry - a specific (local) registry
      • Resolver

        public Resolver​(IRuntimeEnvironment environment)
        Creates a new resolver considering the runtime environment. (for expression resolution only).
        Parameters:
        environment - the runtime environment
    • Method Detail

      • pushModel

        public void pushModel​(M model)
        Adds a model instance for resolution.
        Parameters:
        model - the model instance
      • enumerateImports

        public void enumerateImports​(M model)
        Enumerates the imports and adds relevant model elements such as qualified variable declarations to this resolver.
        Parameters:
        model - the model to add the imports for
      • addImportedVariables

        private void addImportedVariables​(M model,
                                          java.lang.String path,
                                          java.util.Set<M> done)
        Adds imported variables with their qualified name.
        Parameters:
        model - the model to add the variables for
        path - the qualified name path collected so far
        done - already processed models (cycle prevention)
      • popModel

        public void popModel()
        Removes the top-level model instance from resolution.
      • createCallExpression

        protected abstract E createCallExpression​(M model,
                                                  boolean isSuper,
                                                  java.lang.String name,
                                                  CallArgument... arguments)
                                           throws VilException
        Creates a new model call expression.
        Parameters:
        model - the actual model to resolve the operation on
        isSuper - this is a super call
        name - the name of the operation
        arguments - the actual arguments
        Returns:
        the created expression
        Throws:
        VilException - in case of an erroneously qualified name
      • determineQualifiedModel

        private M determineQualifiedModel​(M model,
                                          java.lang.String name)
                                   throws VilException
        Determines the model denoted by a qualified name.
        Parameters:
        model - the model to start search for, may be the first segment of a qualified name or provider of imports
        name - (qualified) name
        Returns:
        null if name is not qualified, the qualified model else
        Throws:
        VilException - if qualified and cannot be resolved or qualified super call
      • determineQualifiedModel

        private M determineQualifiedModel​(M model,
                                          boolean isSuper,
                                          java.lang.String name)
                                   throws VilException
        Determines the model denoted by a qualified name.
        Parameters:
        model - the model to start search for, may be the first segment of a qualified name or provider of imports
        isSuper - is it a super call?
        name - (qualified) name
        Returns:
        null if name is not qualified, the qualified model else
        Throws:
        VilException - if qualified and cannot be resolved or qualified super call
      • createCallExpression

        public E createCallExpression​(boolean isSuper,
                                      java.lang.String name,
                                      CallArgument... arguments)
                               throws VilException
        Creates a call to a IResolvableOperation for one of the current model instances. Uses the default call expression tester.
        Parameters:
        name - the name of the function to be called
        isSuper - is it a super call?
        arguments - the arguments of the call
        Returns:
        the resolved expression
        Throws:
        VilException - in case that the function cannot be resolved.
      • createCallExpression

        public E createCallExpression​(boolean isSuper,
                                      java.lang.String name,
                                      ICallExpressionTester<M,​O,​E,​V> tester,
                                      CallArgument... arguments)
                               throws VilException
        Creates a call to a IResolvableOperation for one of the current model instances.
        Parameters:
        name - the name of the function to be called
        isSuper - is it a super call?
        tester - the call expression tester
        arguments - the arguments of the call
        Returns:
        the resolved expression
        Throws:
        VilException - in case that the function cannot be resolved.
      • createExtensionCallExpression

        public CallExpression createExtensionCallExpression​(java.lang.String name,
                                                            CallArgument... arguments)
                                                     throws VilException
        Creates an extension call expression to functions provided by extension types (see IResolvableModel.getExtensionType(int)). This method works only on the top-level model!
        Parameters:
        name - the name of the function to be called
        arguments - the arguments to that function
        Returns:
        the resolved function
        Throws:
        VilException - in case that the function cannot be resolved.
      • resolveType

        private TypeDescriptor<?> resolveType​(M model,
                                              java.lang.String name)
        Resolves a type within the given model, i.e., looks for model-specific type definitions.
        Parameters:
        model - the model to resolve name as type on
        name - the name of the type
        Returns:
        the type or null for unknown