Example #1
0
    def create_context(self, args):
        # Keep these import statements here so that they are executed only
        # after the coverage computation actually started.
        from langkit.compile_context import ADA_BODY, CompileCtx, LibraryEntity
        from ada.lexer import ada_lexer
        from ada.grammar import ada_grammar
        from ada.documentation import libadalang_docs

        ctx = CompileCtx(
            lang_name='Ada',
            short_name='LAL',
            lexer=ada_lexer,
            grammar=ada_grammar,
            default_charset='iso-8859-1',
            verbosity=args.verbosity,
            default_unit_provider=LibraryEntity(
                'Libadalang.Internal_Default_Provider', 'Create'),
            symbol_canonicalizer=LibraryEntity('Libadalang.Sources',
                                               'Canonicalize'),
            documentations=libadalang_docs,
        )

        # Internals need to access environment hooks and the symbolizer
        ctx.add_with_clause('Implementation',
                            ADA_BODY,
                            'Libadalang.Env_Hooks',
                            use_clause=True)
        ctx.add_with_clause('Implementation',
                            ADA_BODY,
                            'Libadalang.Sources',
                            use_clause=False)

        # Bind Libadalang's custom iterators to the public API
        ctx.add_with_clause('Iterators', ADA_BODY,
                            'Libadalang.Iterators.Extensions')

        # LAL.Analysis.Is_Keyword is implemented using LAL.Lexer's
        ctx.add_with_clause('Analysis', ADA_BODY, 'Libadalang.Lexer')

        ctx.post_process_ada = ada.copyright.format_ada
        ctx.post_process_cpp = ada.copyright.format_c
        ctx.post_process_python = ada.copyright.format_python

        # Register our custom exception types
        ctx.register_exception_type(
            package=[names.Name("GNATCOLL"),
                     names.Name("Projects")],
            name=names.Name("Invalid_Project"),
            doc_section="libadalang.project_provider",
        )
        ctx.register_exception_type(
            package=[names.Name("Libadalang"),
                     names.Name("Project_Provider")],
            name=names.Name("Unsupported_View_Error"),
            doc_section="libadalang.project_provider",
        )

        return ctx
Example #2
0
    def create_context(self, args):
        # Keep these import statements here so that they are executed only
        # after the coverage computation actually started.
        from langkit.compile_context import (ADA_BODY, ADA_SPEC, CompileCtx,
                                             LibraryEntity)
        from language.lexer import ada_lexer
        from language.grammar import ada_grammar
        from language.documentation import libadalang_docs

        ctx = CompileCtx(
            lang_name='Ada',
            short_name='LAL',
            lexer=ada_lexer,
            grammar=ada_grammar,
            default_charset='iso-8859-1',
            verbosity=args.verbosity,
            env_hook_subprogram=LibraryEntity(
                'Libadalang.Env_Hooks',
                'Env_Hook'
            ),
            default_unit_provider=LibraryEntity('Libadalang.Unit_Files',
                                                'Default_Provider'),
            symbol_canonicalizer=LibraryEntity('Libadalang.Sources',
                                               'Canonicalize'),
            documentations=libadalang_docs,
        )

        for unit in ('GNATCOLL.Projects', 'GNATCOLL.VFS',
                     'Libadalang.Project_Provider',
                     'Libadalang.Auto_Provider'):
            ctx.add_with_clause('Implementation.C', ADA_BODY, unit,
                                use_clause=True)

        ctx.add_with_clause('Implementation',
                            ADA_BODY, 'Libadalang.Env_Hooks',
                            use_clause=True)

        # Libadalang needs access to the static expression evaluator, for name
        # resolution of aggregates.
        ctx.add_with_clause('Implementation',
                            ADA_BODY, 'Libadalang.Expr_Eval',
                            use_clause=False)

        ctx.add_with_clause('Implementation',
                            ADA_BODY, 'Libadalang.Doc_Utils',
                            use_clause=False)

        # It also needs access to the literal decoders
        ctx.add_with_clause('Implementation',
                            ADA_BODY, 'Libadalang.Sources',
                            use_clause=False)
        ctx.add_with_clause('Implementation',
                            ADA_BODY, 'Ada.Containers.Hashed_Maps',
                            use_clause=False)

        # Our iterators are implemented using internal data structures
        ctx.add_with_clause('Iterators',
                            ADA_SPEC, 'Libadalang.Common',
                            is_private=True)
        ctx.add_with_clause('Iterators',
                            ADA_BODY, 'Libadalang.Implementation',
                            use_clause=True)
        ctx.add_with_clause('Iterators',
                            ADA_BODY, 'Libadalang.Converters',
                            use_clause=True)

        # LAL.Analysis.Is_Keyword is implemented using LAL.Lexer's
        ctx.add_with_clause('Analysis',
                            ADA_BODY, 'Libadalang.Lexer')

        ctx.post_process_ada = copyright.format_ada
        ctx.post_process_cpp = copyright.format_c
        ctx.post_process_python = copyright.format_python

        return ctx