Stabel

Check-in [d2e7b4771d]
Login
Overview
Comment:Qualify nodes in an array.
Timelines: family | ancestors | descendants | both | arrays
Files: files | file ages | folders
SHA3-256: d2e7b4771d1bcf59499ac782e3500bf4a7c70909e3ae5c2080b6a3ea9d6ad95a
User & Date: robin.hansen on 2021-08-20 17:09:36
Other Links: branch diff | manifest | tags
Context
2021-08-21
11:03
Refactor in preperation to type check array literals. check-in: e023dcfecb user: robin.hansen tags: arrays
2021-08-20
17:09
Qualify nodes in an array. check-in: d2e7b4771d user: robin.hansen tags: arrays
2021-08-18
18:05
Parser now understands array literals. check-in: e702dc606e user: robin.hansen tags: arrays
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Stabel/Qualifier.elm from [7b4d8df174] to [8b735a46e7].

93
94
95
96
97
98
99

100
101
102
103
104
105
106
....
1409
1410
1411
1412
1413
1414
1415
1416













1417







1418
1419
1420
1421
1422
1423
1424
    | FunctionRef SourceLocationRange FunctionDefinition
    | Recurse SourceLocationRange
    | Cycle SourceLocationRange CycleData
    | Builtin SourceLocationRange Builtin
    | ConstructType TypeDefinition
    | GetMember TypeDefinition String Int Type
    | SetMember TypeDefinition String Int Type



type alias ModuleReferences =
    { aliases : Dict String String
    , imports : Dict String (List String)
    }

................................................................................
                                |> Set.union qualifyNodeResult.inlineFunctionNames
                                |> Set.insert inlineFuncName
                    }

                Err err ->
                    { acc | qualifiedNodes = Err err :: acc.qualifiedNodes }

        Parser.ArrayLiteral _ _ ->













            acc









isMultiFunction : Parser.FunctionDefinition -> Bool
isMultiFunction def =
    case def.implementation of
        Parser.SoloImpl _ ->
            False







>







 







|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
....
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
    | FunctionRef SourceLocationRange FunctionDefinition
    | Recurse SourceLocationRange
    | Cycle SourceLocationRange CycleData
    | Builtin SourceLocationRange Builtin
    | ConstructType TypeDefinition
    | GetMember TypeDefinition String Int Type
    | SetMember TypeDefinition String Int Type
    | ArrayLiteral SourceLocationRange (List Node)


type alias ModuleReferences =
    { aliases : Dict String String
    , imports : Dict String (List String)
    }

................................................................................
                                |> Set.union qualifyNodeResult.inlineFunctionNames
                                |> Set.insert inlineFuncName
                    }

                Err err ->
                    { acc | qualifiedNodes = Err err :: acc.qualifiedNodes }

        Parser.ArrayLiteral loc nodes ->
            let
                qualifyNodeResult =
                    initQualifyNode
                        config
                        acc.qualifiedTypes
                        acc.qualifiedFunctions
                        currentDefName
                        acc.modRefs
                        acc.currentlyParsing
                        nodes
            in
            case qualifyNodeResult.qualifiedNodes of
                Ok qualifiedNodes ->
                    { acc
                        | qualifiedNodes =
                            Ok (ArrayLiteral (mapLoc loc) qualifiedNodes)
                                :: acc.qualifiedNodes
                    }

                Err err ->
                    { acc | qualifiedNodes = Err err :: acc.qualifiedNodes }


isMultiFunction : Parser.FunctionDefinition -> Bool
isMultiFunction def =
    case def.implementation of
        Parser.SoloImpl _ ->
            False

Modified src/Stabel/TypeChecker.elm from [2a153ab55d] to [cff285070a].

305
306
307
308
309
310
311




312
313
314
315
316
317
318
....
1263
1264
1265
1266
1267
1268
1269



1270
1271
1272
1273
1274
1275
1276

        Qualifier.SetMember typeDef memberName memberIndex memberType ->
            SetMember typeDef memberName memberIndex memberType

        Qualifier.GetMember typeDef memberName memberIndex memberType ->
            GetMember typeDef memberName memberIndex memberType






resolveGenericsInFunctionType : Int -> Context -> FunctionType -> FunctionType
resolveGenericsInFunctionType idx context wt =
    let
        replaceGenericWithBoundValue t =
            let
                boundType =
................................................................................
                functionTypeToStackEffects
                    { input = [ typeInQuestion ]
                    , output = [ memberType ]
                    }

        Qualifier.Builtin _ builtin ->
            addStackEffect context <| functionTypeToStackEffects <| Builtin.functionType builtin





getStructMembers : TypeDefinition -> List ( String, Type )
getStructMembers typeDef =
    case typeDef.members of
        Qualifier.StructMembers members ->
            members







>
>
>
>







 







>
>
>







305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
....
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283

        Qualifier.SetMember typeDef memberName memberIndex memberType ->
            SetMember typeDef memberName memberIndex memberType

        Qualifier.GetMember typeDef memberName memberIndex memberType ->
            GetMember typeDef memberName memberIndex memberType

        Qualifier.ArrayLiteral range _ ->
            -- TODO: Just get this to compile
            Recurse range


resolveGenericsInFunctionType : Int -> Context -> FunctionType -> FunctionType
resolveGenericsInFunctionType idx context wt =
    let
        replaceGenericWithBoundValue t =
            let
                boundType =
................................................................................
                functionTypeToStackEffects
                    { input = [ typeInQuestion ]
                    , output = [ memberType ]
                    }

        Qualifier.Builtin _ builtin ->
            addStackEffect context <| functionTypeToStackEffects <| Builtin.functionType builtin

        Qualifier.ArrayLiteral _ _ ->
            context


getStructMembers : TypeDefinition -> List ( String, Type )
getStructMembers typeDef =
    case typeDef.members of
        Qualifier.StructMembers members ->
            members

Modified tests/Test/Qualifier/Util.elm from [ab2d8b6fc6] to [8fae3ca458].

146
147
148
149
150
151
152



153
154
155
156
157
158
159

        AST.GetMember td n i t ->
            AST.GetMember (stripTypeLocation td) n i t

        AST.SetMember td n i t ->
            AST.SetMember (stripTypeLocation td) n i t





stripMultiWordBranchLocation : ( TypeMatch, List Node ) -> ( TypeMatch, List Node )
stripMultiWordBranchLocation ( typeMatch, nodes ) =
    ( stripTypeMatchLocation typeMatch
    , List.map stripNodeLocation nodes
    )








>
>
>







146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162

        AST.GetMember td n i t ->
            AST.GetMember (stripTypeLocation td) n i t

        AST.SetMember td n i t ->
            AST.SetMember (stripTypeLocation td) n i t

        AST.ArrayLiteral _ nodes ->
            AST.ArrayLiteral emptyRange nodes


stripMultiWordBranchLocation : ( TypeMatch, List Node ) -> ( TypeMatch, List Node )
stripMultiWordBranchLocation ( typeMatch, nodes ) =
    ( stripTypeMatchLocation typeMatch
    , List.map stripNodeLocation nodes
    )