Stabel

Check-in [7bcedf4cb6]
Login
Overview
Comment:Fixed issue in package loader where modules wouldnt necessary parse in the correct order.
Timelines: family | ancestors | descendants | both | builtin-rewrite
Files: files | file ages | folders
SHA3-256: 7bcedf4cb68dc2780a057aecf4ee7c13374039abf1c2990656d974da55dcda7c
User & Date: robin.hansen on 2021-10-08 17:25:01
Other Links: branch diff | manifest | tags
Context
2021-10-08
19:11
Fixed bug in codegen where multifn conditionals pointed to wrong functions. Leaf check-in: bf76151534 user: robin.hansen tags: builtin-rewrite
17:25
Fixed issue in package loader where modules wouldnt necessary parse in the correct order. check-in: 7bcedf4cb6 user: robin.hansen tags: builtin-rewrite
09:36
Add array module, which I forgot in previous commit. Also change maybe type to not have a generic me... check-in: 421178a365 user: robin.hansen tags: builtin-rewrite
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Stabel/PackageLoader.elm from [54ed1d81c2] to [16584cf5dc].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
...
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665




import Stabel.Data.ModuleName as ModuleName exposing (ModuleName)
import Stabel.Data.PackageMetadata as PackageMetadata exposing (PackageMetadata)
import Stabel.Data.PackageName as PackageName exposing (PackageName)
import Stabel.Data.PackagePath as PackagePath exposing (PackagePath)
import Stabel.Data.SemanticVersion as SemanticVersion exposing (SemanticVersion)
import Stabel.Parser as Parser
import Stabel.Parser.Problem as ParserProblem
import Stabel.Qualifier as Qualifier
import Stabel.Qualifier.Problem as QualifierProblem


type Problem
    = InvalidPackageMetadata String String
    | UnknownMessageForState String
    | UnknownMessageForCompile String
................................................................................

nextCompileStep : List ( PackageInfo, ModuleName ) -> State -> Model
nextCompileStep remainingModules state =
    case remainingModules of
        [] ->
            let
                sortedParsedModules =
                    List.sortWith sortByRequiredModules state.parsedModules

                ( qualifiedAst, errs ) =
                    sortedParsedModules
                        |> List.foldl qualifyAst
                            ( { types = Dict.empty
                              , functions = Dict.empty
                              , referenceableFunctions = Set.empty
................................................................................
                            , PackageName.toString packageMeta.name
                            )
                        )
            )
        |> Dict.fromList


sortByRequiredModules : ParsedModuleInfo -> ParsedModuleInfo -> Order
sortByRequiredModules a b =
    let
        aQualifiedName =
            absoluteModuleName a.packageName a.modulePath

        bQualifiedName =
            absoluteModuleName b.packageName b.modulePath

        aRequiredByB =
            Set.member aQualifiedName b.requiredModules

        bRequiredByA =
            Set.member bQualifiedName a.requiredModules
    in
    case ( aRequiredByB, bRequiredByA ) of
        ( True, False ) ->
            LT

        ( False, True ) ->
            GT

        _ ->
            EQ











|







 







|







 







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
...
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
import Stabel.Data.ModuleName as ModuleName exposing (ModuleName)
import Stabel.Data.PackageMetadata as PackageMetadata exposing (PackageMetadata)
import Stabel.Data.PackageName as PackageName exposing (PackageName)
import Stabel.Data.PackagePath as PackagePath exposing (PackagePath)
import Stabel.Data.SemanticVersion as SemanticVersion exposing (SemanticVersion)
import Stabel.Parser as Parser
import Stabel.Parser.Problem as ParserProblem
import Stabel.Qualifier as Qualifier exposing (requiredModules)
import Stabel.Qualifier.Problem as QualifierProblem


type Problem
    = InvalidPackageMetadata String String
    | UnknownMessageForState String
    | UnknownMessageForCompile String
................................................................................

nextCompileStep : List ( PackageInfo, ModuleName ) -> State -> Model
nextCompileStep remainingModules state =
    case remainingModules of
        [] ->
            let
                sortedParsedModules =
                    sortByRequiredModules state.parsedModules []

                ( qualifiedAst, errs ) =
                    sortedParsedModules
                        |> List.foldl qualifyAst
                            ( { types = Dict.empty
                              , functions = Dict.empty
                              , referenceableFunctions = Set.empty
................................................................................
                            , PackageName.toString packageMeta.name
                            )
                        )
            )
        |> Dict.fromList


sortByRequiredModules : List ParsedModuleInfo -> List ParsedModuleInfo -> List ParsedModuleInfo
sortByRequiredModules unsorted sorted =
    let
        ( depsAreMet, depsAreNotMet ) =
            List.partition (sortByRequiredModulesHelper sorted) unsorted
    in
    case depsAreMet of
        [] ->
            sorted

        _ ->
            sortByRequiredModules depsAreNotMet (sorted ++ depsAreMet)


sortByRequiredModulesHelper : List ParsedModuleInfo -> ParsedModuleInfo -> Bool
sortByRequiredModulesHelper sorted modInfo =
    let
        requiredModules =
            Set.toList modInfo.requiredModules

        sortedModuleNames =
            List.map
                (\mod -> absoluteModuleName mod.packageName mod.modulePath)
                sorted
    in
    List.all
        (\modName -> List.member modName sortedModuleNames)
        requiredModules