Stabel

Check-in [f7ed530f30]
Login
Overview
Comment:Fix issues found with elm-review.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f7ed530f309a483f1c04c0eec864ecfc9d2628e665f80776a9ca4f378dbe5bc0
User & Date: robin.hansen on 2021-09-01 05:19:49
Other Links: manifest | tags
Context
2021-09-06
20:39
String literals. [3fac68d49a]. check-in: fc3b105833 user: robin.hansen tags: trunk
2021-09-03
18:23
Parser now understands basic strings. check-in: 70148502b3 user: robin.hansen tags: strings
2021-09-01
05:19
Fix issues found with elm-review. check-in: f7ed530f30 user: robin.hansen tags: trunk
04:29
Add array literals and a few builtins. [ccf0c23cc5] [839b5c7d9a] check-in: 7aabb3c813 user: robin.hansen tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified package.json from [f3b5f9d3dd] to [2a5aa33f3e].

25
26
27
28
29
30
31


32
33
34
35
36
37
38
    "terser": "^5.7.1"
  },
  "scripts": {
    "test": "npm run test:elm && npm run test:wasm",
    "test:elm": "elm-test",
    "test:elm:watch": "elm-test --watch",
    "test:wasm": "elm make src/TestCompiler.elm --optimize --output wasm_tests/compiler.js && jest",


    "build": "elm make src/CLI.elm --optimize --output bin/compiler.js",
    "prepublishOnly": "npm run build && terser bin/compiler.js -c -m -o bin/compiler.js"
  },
  "bin": {
    "stabel": "bin/cli.js"
  }
}







>
>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    "terser": "^5.7.1"
  },
  "scripts": {
    "test": "npm run test:elm && npm run test:wasm",
    "test:elm": "elm-test",
    "test:elm:watch": "elm-test --watch",
    "test:wasm": "elm make src/TestCompiler.elm --optimize --output wasm_tests/compiler.js && jest",
    "code-review": "elm-review",
    "code-review:fix": "elm-review --fix",
    "build": "elm make src/CLI.elm --optimize --output bin/compiler.js",
    "prepublishOnly": "npm run build && terser bin/compiler.js -c -m -o bin/compiler.js"
  },
  "bin": {
    "stabel": "bin/cli.js"
  }
}

Modified review/elm.json from [4ac8f091ea] to [27171b8343].

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
        "src"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "elm/core": "1.0.5",
            "jfmengels/elm-review": "2.5.0",
            "jfmengels/elm-review-simplify": "2.0.4",
            "jfmengels/elm-review-unused": "1.1.15",
            "stil4m/elm-syntax": "7.2.6"
        },
        "indirect": {
            "elm/html": "1.0.0",
            "elm/json": "1.1.3",
            "elm/parser": "1.1.0",
            "elm/project-metadata-utils": "1.0.2",
            "elm/random": "1.0.0",
            "elm/time": "1.0.0",
            "elm/virtual-dom": "1.0.2",
            "elm-community/list-extra": "8.3.1",
            "elm-explorations/test": "1.2.2",
            "miniBill/elm-unicode": "1.0.2",
            "rtfeldman/elm-hex": "1.0.0",
            "stil4m/structured-writer": "1.0.3"
        }
    },
    "test-dependencies": {
        "direct": {
            "elm-explorations/test": "1.2.2"
        },
        "indirect": {}
    }
}







|
|
|









|













4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
        "src"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "elm/core": "1.0.5",
            "jfmengels/elm-review": "2.5.0",
            "jfmengels/elm-review-simplify": "2.0.7",
            "jfmengels/elm-review-unused": "1.1.16",
            "stil4m/elm-syntax": "7.2.7"
        },
        "indirect": {
            "elm/html": "1.0.0",
            "elm/json": "1.1.3",
            "elm/parser": "1.1.0",
            "elm/project-metadata-utils": "1.0.2",
            "elm/random": "1.0.0",
            "elm/time": "1.0.0",
            "elm/virtual-dom": "1.0.2",
            "elm-community/list-extra": "8.4.0",
            "elm-explorations/test": "1.2.2",
            "miniBill/elm-unicode": "1.0.2",
            "rtfeldman/elm-hex": "1.0.0",
            "stil4m/structured-writer": "1.0.3"
        }
    },
    "test-dependencies": {
        "direct": {
            "elm-explorations/test": "1.2.2"
        },
        "indirect": {}
    }
}

Modified src/Stabel/TypeChecker.elm from [ae014cff34] to [cb83d58fcb].

765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
...
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
        joinSplitFunctionType ( firstType, functionType ) =
            { functionType | input = firstType :: functionType.input }
    in
    List.filterMap splitFirstInputType functionTypes
        |> List.foldr
            (\( firstType, functionType ) ( typeAcc, functionTypeAcc ) -> ( firstType :: typeAcc, functionType :: functionTypeAcc ))
            ( [], [] )
        |> Tuple.mapSecond (\lobotomizedFunctionTypes -> equalizeWhenTypesHelper lobotomizedFunctionTypes Dict.empty [])
        |> (\( firstTypes, equalizedWhenTypes ) -> List.map2 Tuple.pair firstTypes equalizedWhenTypes)
        |> List.map joinSplitFunctionType


equalizeWhenTypesHelper : List FunctionType -> Dict String Type -> List FunctionType -> List FunctionType
equalizeWhenTypesHelper types remappedGenerics acc =
    case types of
        [] ->
            List.reverse acc

        lastType :: [] ->
            List.reverse (lastType :: acc)

................................................................................
                newSecondType =
                    { input = unzippedSecondInputs
                    , output = secondType.output
                    }
            in
            equalizeWhenTypesHelper
                remaining
                remappedGenerics
                (newSecondType :: newFirstType :: acc)


unionOfTypeMatches : List ( Qualifier.TypeMatch, a ) -> Type
unionOfTypeMatches whenBranches =
    let
        uniqueTypes =







|




|
|







 







<







765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
...
816
817
818
819
820
821
822

823
824
825
826
827
828
829
        joinSplitFunctionType ( firstType, functionType ) =
            { functionType | input = firstType :: functionType.input }
    in
    List.filterMap splitFirstInputType functionTypes
        |> List.foldr
            (\( firstType, functionType ) ( typeAcc, functionTypeAcc ) -> ( firstType :: typeAcc, functionType :: functionTypeAcc ))
            ( [], [] )
        |> Tuple.mapSecond (\lobotomizedFunctionTypes -> equalizeWhenTypesHelper lobotomizedFunctionTypes [])
        |> (\( firstTypes, equalizedWhenTypes ) -> List.map2 Tuple.pair firstTypes equalizedWhenTypes)
        |> List.map joinSplitFunctionType


equalizeWhenTypesHelper : List FunctionType -> List FunctionType -> List FunctionType
equalizeWhenTypesHelper types acc =
    case types of
        [] ->
            List.reverse acc

        lastType :: [] ->
            List.reverse (lastType :: acc)

................................................................................
                newSecondType =
                    { input = unzippedSecondInputs
                    , output = secondType.output
                    }
            in
            equalizeWhenTypesHelper
                remaining

                (newSecondType :: newFirstType :: acc)


unionOfTypeMatches : List ( Qualifier.TypeMatch, a ) -> Type
unionOfTypeMatches whenBranches =
    let
        uniqueTypes =

Modified src/Stabel/Wasm.elm from [f1b8bdee1a] to [00f148bec4].

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
...
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385

type Instruction
    = Batch (List Instruction)
    | Block (List Instruction)
    | Loop (List Instruction)
    | Break Int
    | BreakIf Int
    | If (List Instruction) (List Instruction)
    | Return
    | Call Int String
    | CallIndirect
    | Local_Get Int
    | Local_Set Int
    | Local_Tee Int
    | I32_Const Int
................................................................................

        Break num ->
            Str <| "(br " ++ String.fromInt num ++ ")"

        BreakIf num ->
            Str <| "(br_if " ++ String.fromInt num ++ ")"

        If thenIns elseIns ->
            if List.isEmpty elseIns then
                BatchFormat
                    [ Str "(if (then"
                    , Indent <| List.map formatInstruction thenIns
                    , Str "))"
                    ]

            else
                BatchFormat
                    [ Str "(if (then"
                    , Indent <| List.map formatInstruction thenIns
                    , Str ")"
                    , Str "(else"
                    , Indent <| List.map formatInstruction elseIns
                    , Str "))"
                    ]

        Return ->
            Str "return"

        Call id fnName ->
            Str <| "(call " ++ String.fromInt id ++ ") ;; $" ++ fnName

        CallIndirect ->







<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







75
76
77
78
79
80
81

82
83
84
85
86
87
88
...
353
354
355
356
357
358
359


















360
361
362
363
364
365
366

type Instruction
    = Batch (List Instruction)
    | Block (List Instruction)
    | Loop (List Instruction)
    | Break Int
    | BreakIf Int

    | Return
    | Call Int String
    | CallIndirect
    | Local_Get Int
    | Local_Set Int
    | Local_Tee Int
    | I32_Const Int
................................................................................

        Break num ->
            Str <| "(br " ++ String.fromInt num ++ ")"

        BreakIf num ->
            Str <| "(br_if " ++ String.fromInt num ++ ")"



















        Return ->
            Str "return"

        Call id fnName ->
            Str <| "(call " ++ String.fromInt id ++ ") ;; $" ++ fnName

        CallIndirect ->