firefly-compiler 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.firefly-workspace +1 -0
- package/.vscode/settings.json +5 -0
- package/LICENSE.txt +21 -0
- package/README.md +96 -0
- package/bin/firefly.mjs +2 -0
- package/compiler/.firefly/package.ff +1 -0
- package/compiler/Builder.ff +218 -0
- package/compiler/Compiler.ff +241 -0
- package/compiler/Dependencies.ff +179 -0
- package/compiler/Deriver.ff +647 -0
- package/compiler/Dictionaries.ff +205 -0
- package/compiler/Environment.ff +166 -0
- package/compiler/Inference.ff +1117 -0
- package/compiler/JsEmitter.ff +861 -0
- package/compiler/JsImporter.ff +56 -0
- package/compiler/LspHook.ff +188 -0
- package/compiler/Main.ff +237 -0
- package/compiler/Parser.ff +1383 -0
- package/compiler/Patterns.ff +111 -0
- package/compiler/Resolver.ff +620 -0
- package/compiler/Substitution.ff +178 -0
- package/compiler/Syntax.ff +299 -0
- package/compiler/Token.ff +180 -0
- package/compiler/Tokenizer.ff +278 -0
- package/compiler/Unification.ff +220 -0
- package/compiler/Wildcards.ff +50 -0
- package/compiler/Workspace.ff +88 -0
- package/core/.firefly/package.ff +2 -0
- package/core/Any.ff +30 -0
- package/core/Array.ff +249 -0
- package/core/AssetSystem.ff +61 -0
- package/core/Atomic.ff +64 -0
- package/core/Bool.ff +13 -0
- package/core/BrowserSystem.ff +14 -0
- package/core/Buffer.ff +211 -0
- package/core/BuildSystem.ff +144 -0
- package/core/Channel.ff +131 -0
- package/core/Char.ff +18 -0
- package/core/Core.ff +58 -0
- package/core/Duration.ff +15 -0
- package/core/Equal.ff +52 -0
- package/core/Error.ff +20 -0
- package/core/FileHandle.ff +41 -0
- package/core/Float.ff +41 -0
- package/core/HttpClient.ff +84 -0
- package/core/Instant.ff +9 -0
- package/core/Int.ff +61 -0
- package/core/IntMap.ff +85 -0
- package/core/JsSystem.ff +66 -0
- package/core/JsValue.ff +240 -0
- package/core/List.ff +440 -0
- package/core/Lock.ff +144 -0
- package/core/Log.ff +24 -0
- package/core/Map.ff +126 -0
- package/core/NodeSystem.ff +88 -0
- package/core/Nothing.ff +1 -0
- package/core/Option.ff +133 -0
- package/core/Ordering.ff +157 -0
- package/core/Pair.ff +55 -0
- package/core/Path.ff +393 -0
- package/core/RbMap.ff +216 -0
- package/core/Serializable.ff +173 -0
- package/core/Set.ff +38 -0
- package/core/Show.ff +43 -0
- package/core/Stack.ff +263 -0
- package/core/Stream.ff +406 -0
- package/core/String.ff +175 -0
- package/core/StringMap.ff +85 -0
- package/core/Task.ff +138 -0
- package/core/Try.ff +81 -0
- package/core/Unit.ff +3 -0
- package/experimental/random/AltGeneric.ff +44 -0
- package/experimental/random/Async.ff +68 -0
- package/experimental/random/Buffer2.ff +77 -0
- package/experimental/random/Cat.ff +12 -0
- package/experimental/random/Dictionary.ff +52 -0
- package/experimental/random/Example.ff +46 -0
- package/experimental/random/Generic.ff +102 -0
- package/experimental/random/HappyEyeballs.ff +40 -0
- package/experimental/random/HashMap.ff +72 -0
- package/experimental/random/IfElseUnit.ff +9 -0
- package/experimental/random/InputOutput.ff +23 -0
- package/experimental/random/ListVsArray.ff +45 -0
- package/experimental/random/Main.ff +44 -0
- package/experimental/random/MapTest.ff +67 -0
- package/experimental/random/OldTaskSystem.ff +210 -0
- package/experimental/random/PatternTest.ff +39 -0
- package/experimental/random/Patterns.ff +226 -0
- package/experimental/random/ReadBytesTest.ff +10 -0
- package/experimental/random/RunLength.ff +65 -0
- package/experimental/random/Scrape.ff +51 -0
- package/experimental/random/Serialization.ff +217 -0
- package/experimental/random/SerializationTest.ff +46 -0
- package/experimental/random/Serializer.ff +36 -0
- package/experimental/random/StdInOutErr.ff +4 -0
- package/experimental/random/Symbols.ff +74 -0
- package/experimental/random/Tag.ff +49 -0
- package/experimental/random/Tensor.ff +52 -0
- package/experimental/random/Try.ff +56 -0
- package/experimental/random/Tsv.ff +9 -0
- package/experimental/random/TypesAreModules.ff +87 -0
- package/experimental/random/blueprints/Blueprint.ff +52 -0
- package/experimental/random/blueprints/Main.ff +11 -0
- package/experimental/random/blueprints/Pretty.ff +58 -0
- package/experimental/random/blueprints/User.ff +64 -0
- package/experimental/random/blueprintsystem/BlueprintSystem.ff +48 -0
- package/experimental/random/blueprintsystem/Deserialize.ff +53 -0
- package/experimental/random/blueprintsystem/ReadJs.ff +13 -0
- package/experimental/random/blueprintsystem/User.ff +2 -0
- package/experimental/random/kahrs/Kahrs.ff +112 -0
- package/experimental/random/kahrs/TestKahrs.ff +22 -0
- package/experimental/random/kahrs/TestMap.ff +18 -0
- package/experimental/random/streaming/Gzip.ff +3 -0
- package/experimental/random/streaming/Main.ff +34 -0
- package/experimental/random/streaming/S3Bucket.ff +11 -0
- package/experimental/random/streaming/Tar.ff +5 -0
- package/experimental/rhymeapp/Main.ff +81 -0
- package/experimental/rhymeapp/index.html +14 -0
- package/firefly.sh +5 -0
- package/fireflysite/Main.ff +13 -0
- package/httpserver/.firefly/package.ff +1 -0
- package/httpserver/HttpServer.ff +184 -0
- package/lsp/.firefly/package.ff +1 -0
- package/lsp/CompletionHandler.ff +814 -0
- package/lsp/Handler.ff +551 -0
- package/lsp/HoverHandler.ff +82 -0
- package/lsp/LanguageServer.ff +229 -0
- package/lsp/SignatureHelpHandler.ff +55 -0
- package/lsp/SymbolHandler.ff +167 -0
- package/output/js/ff/compiler/Builder.mjs +483 -0
- package/output/js/ff/compiler/Compiler.mjs +410 -0
- package/output/js/ff/compiler/Dependencies.mjs +388 -0
- package/output/js/ff/compiler/Deriver.mjs +1166 -0
- package/output/js/ff/compiler/Dictionaries.mjs +1305 -0
- package/output/js/ff/compiler/Environment.mjs +1005 -0
- package/output/js/ff/compiler/Inference.mjs +4264 -0
- package/output/js/ff/compiler/JsEmitter.mjs +5353 -0
- package/output/js/ff/compiler/JsImporter.mjs +262 -0
- package/output/js/ff/compiler/LspHook.mjs +789 -0
- package/output/js/ff/compiler/Main.mjs +1695 -0
- package/output/js/ff/compiler/Parser.mjs +4004 -0
- package/output/js/ff/compiler/Patterns.mjs +923 -0
- package/output/js/ff/compiler/Resolver.mjs +2303 -0
- package/output/js/ff/compiler/Substitution.mjs +1146 -0
- package/output/js/ff/compiler/Syntax.mjs +12430 -0
- package/output/js/ff/compiler/Token.mjs +3092 -0
- package/output/js/ff/compiler/Tokenizer.mjs +589 -0
- package/output/js/ff/compiler/Unification.mjs +1748 -0
- package/output/js/ff/compiler/Wildcards.mjs +604 -0
- package/output/js/ff/compiler/Workspace.mjs +683 -0
- package/output/js/ff/core/Any.mjs +139 -0
- package/output/js/ff/core/Array.mjs +594 -0
- package/output/js/ff/core/AssetSystem.mjs +270 -0
- package/output/js/ff/core/Atomic.mjs +186 -0
- package/output/js/ff/core/Bool.mjs +141 -0
- package/output/js/ff/core/BrowserSystem.mjs +122 -0
- package/output/js/ff/core/Buffer.mjs +467 -0
- package/output/js/ff/core/BuildSystem.mjs +320 -0
- package/output/js/ff/core/Channel.mjs +268 -0
- package/output/js/ff/core/Char.mjs +145 -0
- package/output/js/ff/core/Core.mjs +300 -0
- package/output/js/ff/core/Duration.mjs +112 -0
- package/output/js/ff/core/Equal.mjs +175 -0
- package/output/js/ff/core/Error.mjs +138 -0
- package/output/js/ff/core/FileHandle.mjs +164 -0
- package/output/js/ff/core/Float.mjs +214 -0
- package/output/js/ff/core/HttpClient.mjs +210 -0
- package/output/js/ff/core/Instant.mjs +105 -0
- package/output/js/ff/core/Int.mjs +254 -0
- package/output/js/ff/core/IntMap.mjs +282 -0
- package/output/js/ff/core/JsSystem.mjs +234 -0
- package/output/js/ff/core/JsValue.mjs +678 -0
- package/output/js/ff/core/List.mjs +2335 -0
- package/output/js/ff/core/Lock.mjs +322 -0
- package/output/js/ff/core/Log.mjs +159 -0
- package/output/js/ff/core/Map.mjs +358 -0
- package/output/js/ff/core/NodeSystem.mjs +288 -0
- package/output/js/ff/core/Nothing.mjs +100 -0
- package/output/js/ff/core/Option.mjs +1002 -0
- package/output/js/ff/core/Ordering.mjs +734 -0
- package/output/js/ff/core/Pair.mjs +318 -0
- package/output/js/ff/core/Path.mjs +768 -0
- package/output/js/ff/core/RbMap.mjs +1936 -0
- package/output/js/ff/core/Serializable.mjs +434 -0
- package/output/js/ff/core/Set.mjs +250 -0
- package/output/js/ff/core/Show.mjs +201 -0
- package/output/js/ff/core/Stack.mjs +595 -0
- package/output/js/ff/core/Stream.mjs +1300 -0
- package/output/js/ff/core/String.mjs +433 -0
- package/output/js/ff/core/StringMap.mjs +282 -0
- package/output/js/ff/core/Task.mjs +345 -0
- package/output/js/ff/core/Try.mjs +503 -0
- package/output/js/ff/core/Unit.mjs +103 -0
- package/package.json +29 -0
- package/postgresql/.firefly/include/package-lock.json +250 -0
- package/postgresql/.firefly/include/package.json +5 -0
- package/postgresql/.firefly/include/prepare.sh +2 -0
- package/postgresql/.firefly/package.ff +3 -0
- package/postgresql/Pg.ff +530 -0
- package/unsafejs/.firefly/package.ff +1 -0
- package/unsafejs/UnsafeJs.ff +19 -0
- package/vscode/.vscode/launch.json +18 -0
- package/vscode/.vscode/tasks.json +33 -0
- package/vscode/LICENSE.txt +21 -0
- package/vscode/Prepublish.ff +15 -0
- package/vscode/README.md +17 -0
- package/vscode/client/package-lock.json +544 -0
- package/vscode/client/package.json +22 -0
- package/vscode/client/src/extension.ts +64 -0
- package/vscode/client/tsconfig.json +12 -0
- package/vscode/icons/firefly-icon.png +0 -0
- package/vscode/icons/firefly-icon.svg +10 -0
- package/vscode/icons/firefly-logo-notext.png +0 -0
- package/vscode/icons/firefly-logo.png +0 -0
- package/vscode/language-configuration.json +39 -0
- package/vscode/package-lock.json +3623 -0
- package/vscode/package.json +144 -0
- package/vscode/snippets-none.json +1 -0
- package/vscode/snippets.json +241 -0
- package/vscode/syntaxes/firefly.tmLanguage.json +294 -0
- package/vscode/tsconfig.json +20 -0
|
@@ -0,0 +1,2303 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import * as ff_compiler_Resolver from "../../ff/compiler/Resolver.mjs"
|
|
4
|
+
|
|
5
|
+
import * as ff_compiler_LspHook from "../../ff/compiler/LspHook.mjs"
|
|
6
|
+
|
|
7
|
+
import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
|
|
8
|
+
|
|
9
|
+
import * as ff_core_Any from "../../ff/core/Any.mjs"
|
|
10
|
+
|
|
11
|
+
import * as ff_core_Array from "../../ff/core/Array.mjs"
|
|
12
|
+
|
|
13
|
+
import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
|
|
14
|
+
|
|
15
|
+
import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
|
|
16
|
+
|
|
17
|
+
import * as ff_core_Bool from "../../ff/core/Bool.mjs"
|
|
18
|
+
|
|
19
|
+
import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
|
|
20
|
+
|
|
21
|
+
import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
|
|
22
|
+
|
|
23
|
+
import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
|
|
24
|
+
|
|
25
|
+
import * as ff_core_Channel from "../../ff/core/Channel.mjs"
|
|
26
|
+
|
|
27
|
+
import * as ff_core_Char from "../../ff/core/Char.mjs"
|
|
28
|
+
|
|
29
|
+
import * as ff_core_Core from "../../ff/core/Core.mjs"
|
|
30
|
+
|
|
31
|
+
import * as ff_core_Duration from "../../ff/core/Duration.mjs"
|
|
32
|
+
|
|
33
|
+
import * as ff_core_Equal from "../../ff/core/Equal.mjs"
|
|
34
|
+
|
|
35
|
+
import * as ff_core_Error from "../../ff/core/Error.mjs"
|
|
36
|
+
|
|
37
|
+
import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
|
|
38
|
+
|
|
39
|
+
import * as ff_core_Float from "../../ff/core/Float.mjs"
|
|
40
|
+
|
|
41
|
+
import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
|
|
42
|
+
|
|
43
|
+
import * as ff_core_Instant from "../../ff/core/Instant.mjs"
|
|
44
|
+
|
|
45
|
+
import * as ff_core_Int from "../../ff/core/Int.mjs"
|
|
46
|
+
|
|
47
|
+
import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
|
|
48
|
+
|
|
49
|
+
import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
50
|
+
|
|
51
|
+
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
52
|
+
|
|
53
|
+
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
54
|
+
|
|
55
|
+
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
56
|
+
|
|
57
|
+
import * as ff_core_Log from "../../ff/core/Log.mjs"
|
|
58
|
+
|
|
59
|
+
import * as ff_core_Map from "../../ff/core/Map.mjs"
|
|
60
|
+
|
|
61
|
+
import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
|
|
62
|
+
|
|
63
|
+
import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
|
|
64
|
+
|
|
65
|
+
import * as ff_core_Option from "../../ff/core/Option.mjs"
|
|
66
|
+
|
|
67
|
+
import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
|
|
68
|
+
|
|
69
|
+
import * as ff_core_Pair from "../../ff/core/Pair.mjs"
|
|
70
|
+
|
|
71
|
+
import * as ff_core_Path from "../../ff/core/Path.mjs"
|
|
72
|
+
|
|
73
|
+
import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
|
|
74
|
+
|
|
75
|
+
import * as ff_core_Set from "../../ff/core/Set.mjs"
|
|
76
|
+
|
|
77
|
+
import * as ff_core_Show from "../../ff/core/Show.mjs"
|
|
78
|
+
|
|
79
|
+
import * as ff_core_Stack from "../../ff/core/Stack.mjs"
|
|
80
|
+
|
|
81
|
+
import * as ff_core_Stream from "../../ff/core/Stream.mjs"
|
|
82
|
+
|
|
83
|
+
import * as ff_core_String from "../../ff/core/String.mjs"
|
|
84
|
+
|
|
85
|
+
import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
|
|
86
|
+
|
|
87
|
+
import * as ff_core_Task from "../../ff/core/Task.mjs"
|
|
88
|
+
|
|
89
|
+
import * as ff_core_Try from "../../ff/core/Try.mjs"
|
|
90
|
+
|
|
91
|
+
import * as ff_core_Unit from "../../ff/core/Unit.mjs"
|
|
92
|
+
|
|
93
|
+
// type Resolver
|
|
94
|
+
export function Resolver(variables_, variableLocations_, variants_, types_, typeGenerics_, typeLocations_, asyncTypes_, typeParameters_, traits_, traitLocations_, state_, lspHook_) {
|
|
95
|
+
return {variables_, variableLocations_, variants_, types_, typeGenerics_, typeLocations_, asyncTypes_, typeParameters_, traits_, traitLocations_, state_, lspHook_};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// type ResolverState
|
|
99
|
+
export function ResolverState(nextUnificationVariableIndex_) {
|
|
100
|
+
return {nextUnificationVariableIndex_};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
export function make_(lspHook_) {
|
|
106
|
+
return ff_compiler_Resolver.Resolver(ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_compiler_Resolver.ResolverState(2), lspHook_)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export async function make_$(lspHook_, $task) {
|
|
110
|
+
return ff_compiler_Resolver.Resolver(ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_compiler_Resolver.ResolverState(2), lspHook_)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function Resolver_freshUnificationVariable(self_, at_) {
|
|
114
|
+
const result_ = ff_compiler_Syntax.TVariable(at_, self_.state_.nextUnificationVariableIndex_);
|
|
115
|
+
self_.state_.nextUnificationVariableIndex_ += 3;
|
|
116
|
+
return result_
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function Resolver_resolveModule(self_, module_, otherModules_) {
|
|
120
|
+
const moduleNamespace_ = ff_core_String.String_takeWhile(ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core_String.String_reverse(ff_core_String.String_replace(module_.file_, "\\", "/")), ((_w1) => {
|
|
121
|
+
return (_w1 !== 47)
|
|
122
|
+
}))), ((_w1) => {
|
|
123
|
+
return (_w1 !== 46)
|
|
124
|
+
}));
|
|
125
|
+
const self2_ = ff_compiler_Resolver.Resolver_processImports(self_, module_.imports_, otherModules_);
|
|
126
|
+
const self3_ = ff_compiler_Resolver.Resolver_processDefinitions(self2_, module_, ff_core_Option.None());
|
|
127
|
+
const module2_ = (((_c) => {
|
|
128
|
+
return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_core_List.List_map(module_.types_, ((_w1) => {
|
|
129
|
+
return ff_compiler_Resolver.Resolver_resolveTypeDefinition(self3_, _w1)
|
|
130
|
+
})), ff_core_List.List_map(module_.traits_, ((_w1) => {
|
|
131
|
+
return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
|
|
132
|
+
})), ff_core_List.List_map(module_.instances_, ((_w1) => {
|
|
133
|
+
return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
|
|
134
|
+
})), ff_core_List.List_map(module_.extends_, ((_w1) => {
|
|
135
|
+
return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
|
|
136
|
+
})), ff_core_List.List_map(module_.lets_, ((_w1) => {
|
|
137
|
+
return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
|
|
138
|
+
})), ff_core_List.List_map(module_.functions_, ((_w1) => {
|
|
139
|
+
return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
|
|
140
|
+
})))
|
|
141
|
+
}))(module_);
|
|
142
|
+
ff_core_List.List_each(module2_.instances_, ((_w1) => {
|
|
143
|
+
ff_core_List.List_each(_w1.typeArguments_, ((_w1) => {
|
|
144
|
+
ff_compiler_Resolver.Resolver_checkInstanceType(self3_, _w1)
|
|
145
|
+
}))
|
|
146
|
+
}));
|
|
147
|
+
return module2_
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function Resolver_checkInstanceType(self_, type_) {
|
|
151
|
+
{
|
|
152
|
+
const _1 = type_;
|
|
153
|
+
{
|
|
154
|
+
if(_1.TConstructor) {
|
|
155
|
+
const name_ = _1.name_;
|
|
156
|
+
const typeArguments_ = _1.generics_;
|
|
157
|
+
if(ff_core_Set.Set_contains(self_.asyncTypes_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
|
|
158
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(type_.at_, "Traits must not be instantiated for capability types"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
159
|
+
};
|
|
160
|
+
ff_core_List.List_each(typeArguments_, ((_w1) => {
|
|
161
|
+
ff_compiler_Resolver.Resolver_checkInstanceType(self_, _w1)
|
|
162
|
+
}))
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
{
|
|
167
|
+
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function Resolver_processImports(self_, imports_, modules_) {
|
|
174
|
+
let resolver_ = self_;
|
|
175
|
+
ff_core_List.List_each(imports_, ((import_) => {
|
|
176
|
+
{
|
|
177
|
+
const _1 = ff_core_List.List_find(modules_, ((_w1) => {
|
|
178
|
+
return (ff_core_String.String_dropLast(_w1.file_, 3) === import_.file_)
|
|
179
|
+
}));
|
|
180
|
+
{
|
|
181
|
+
if(_1.Some) {
|
|
182
|
+
const module_ = _1.value_;
|
|
183
|
+
resolver_ = ff_compiler_Resolver.Resolver_processDefinitions(resolver_, module_, ff_core_Option.Some(import_.alias_))
|
|
184
|
+
return
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
{
|
|
188
|
+
if(_1.None) {
|
|
189
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(import_.at_, ("No such module: " + import_.file_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}));
|
|
195
|
+
return resolver_
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function Resolver_processDefinitions(self_, module_, importAlias_) {
|
|
199
|
+
function entry_(name_, unqualified_) {
|
|
200
|
+
const full_ = ((((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") + "/") + ff_core_String.String_dropLast(module_.file_, 3)) + ".") + name_);
|
|
201
|
+
{
|
|
202
|
+
const _1 = importAlias_;
|
|
203
|
+
{
|
|
204
|
+
if(_1.None) {
|
|
205
|
+
return ff_core_List.Link(ff_core_Pair.Pair(name_, full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty()))
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
{
|
|
210
|
+
if(_1.Some) {
|
|
211
|
+
const alias_ = _1.value_;
|
|
212
|
+
const _guard1 = unqualified_;
|
|
213
|
+
if(_guard1) {
|
|
214
|
+
return ff_core_List.Link(ff_core_Pair.Pair(((alias_ + ".") + name_), full_), ff_core_List.Link(ff_core_Pair.Pair(name_, full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty())))
|
|
215
|
+
return
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
{
|
|
220
|
+
if(_1.Some) {
|
|
221
|
+
const alias_ = _1.value_;
|
|
222
|
+
return ff_core_List.Link(ff_core_Pair.Pair(((alias_ + ".") + name_), full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty()))
|
|
223
|
+
return
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const isCore_ = (((module_.packagePair_.group_ === "ff") && (module_.packagePair_.name_ === "core")) && (module_.file_ === "Core.ff"));
|
|
229
|
+
const lets_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.lets_, ((_w1) => {
|
|
230
|
+
return entry_(_w1.name_, isCore_)
|
|
231
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
232
|
+
const letLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.lets_, ((d_) => {
|
|
233
|
+
return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
|
|
234
|
+
return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
|
|
235
|
+
return d_.at_
|
|
236
|
+
}))
|
|
237
|
+
}))
|
|
238
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
239
|
+
const functions_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.functions_, ((_w1) => {
|
|
240
|
+
return entry_(_w1.signature_.name_, isCore_)
|
|
241
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
242
|
+
const functionLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.functions_, ((d_) => {
|
|
243
|
+
return ff_core_List.List_map(entry_(d_.signature_.name_, true), ((_w1) => {
|
|
244
|
+
return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
|
|
245
|
+
return d_.at_
|
|
246
|
+
}))
|
|
247
|
+
}))
|
|
248
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
249
|
+
const traitMethods_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
|
|
250
|
+
return _w1.methods_
|
|
251
|
+
})), ((_w1) => {
|
|
252
|
+
return entry_(_w1.name_, false)
|
|
253
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
254
|
+
const traitMethodLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
|
|
255
|
+
return _w1.methods_
|
|
256
|
+
})), ((d_) => {
|
|
257
|
+
return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
|
|
258
|
+
return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
|
|
259
|
+
return d_.at_
|
|
260
|
+
}))
|
|
261
|
+
}))
|
|
262
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
263
|
+
const traits_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
|
|
264
|
+
return entry_(_w1.name_, true)
|
|
265
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
266
|
+
const traitLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.traits_, ((d_) => {
|
|
267
|
+
return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
|
|
268
|
+
return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
|
|
269
|
+
return d_.at_
|
|
270
|
+
}))
|
|
271
|
+
}))
|
|
272
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
273
|
+
const types_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((_w1) => {
|
|
274
|
+
return entry_(_w1.name_, true)
|
|
275
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
276
|
+
const typeGenerics_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((d_) => {
|
|
277
|
+
return ff_core_List.List_map(entry_(d_.name_, true), ((p_) => {
|
|
278
|
+
return ff_core_Pair.Pair(p_.first_, d_.generics_)
|
|
279
|
+
}))
|
|
280
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
281
|
+
const typeLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((d_) => {
|
|
282
|
+
return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
|
|
283
|
+
return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
|
|
284
|
+
return d_.at_
|
|
285
|
+
}))
|
|
286
|
+
}))
|
|
287
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
288
|
+
const asyncTypes_ = ff_core_List.List_toSet(ff_core_List.List_flatMap(ff_core_List.List_filter(module_.types_, ((_w1) => {
|
|
289
|
+
return ff_core_Option.Option_any(ff_core_List.List_first(_w1.generics_), ((_w1) => {
|
|
290
|
+
return (_w1 === "Q$")
|
|
291
|
+
}))
|
|
292
|
+
})), ((_w1) => {
|
|
293
|
+
return ff_core_List.List_map(entry_(_w1.name_, true), ((_w1) => {
|
|
294
|
+
return _w1.first_
|
|
295
|
+
}))
|
|
296
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
297
|
+
const variants_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.types_, ((_w1) => {
|
|
298
|
+
return _w1.variants_
|
|
299
|
+
})), ((_w1) => {
|
|
300
|
+
return entry_(_w1.name_, true)
|
|
301
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
302
|
+
{
|
|
303
|
+
const _1 = self_;
|
|
304
|
+
{
|
|
305
|
+
const _c = _1;
|
|
306
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(self_.variables_, lets_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), functions_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), traitMethods_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(self_.variableLocations_, letLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), functionLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), traitMethodLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variants_, variants_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.types_, types_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.typeGenerics_, typeGenerics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.typeLocations_, typeLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.asyncTypes_, asyncTypes_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.traits_, traits_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.traitLocations_, traitLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), self_.state_, _c.lspHook_)
|
|
307
|
+
return
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export function Resolver_resolveTypeDefinition(self_, definition_) {
|
|
313
|
+
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_)) {
|
|
314
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
|
|
315
|
+
};
|
|
316
|
+
const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
|
|
317
|
+
return ff_core_Pair.Pair(g_, g_)
|
|
318
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
319
|
+
const self2_ = (((_c) => {
|
|
320
|
+
return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
321
|
+
}))(self_);
|
|
322
|
+
if((!ff_core_Option.Option_any(ff_core_List.List_first(definition_.generics_), ((_w1) => {
|
|
323
|
+
return (_w1 === "Q$")
|
|
324
|
+
})))) {
|
|
325
|
+
ff_core_List.List_each(ff_core_List.List_addAll(definition_.commonFields_, ff_core_List.List_flatMap(definition_.variants_, ((_w1) => {
|
|
326
|
+
return _w1.fields_
|
|
327
|
+
}))), ((f_) => {
|
|
328
|
+
if(ff_compiler_Resolver.Resolver_containsAsyncType(self2_, f_.valueType_)) {
|
|
329
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(f_.at_, "Only capabilities can contain fields of concrete capability types"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
330
|
+
}
|
|
331
|
+
}))
|
|
332
|
+
};
|
|
333
|
+
{
|
|
334
|
+
const _1 = definition_;
|
|
335
|
+
{
|
|
336
|
+
const _c = _1;
|
|
337
|
+
return ff_compiler_Syntax.DType(_c.at_, _c.newtype_, _c.data_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
|
|
338
|
+
return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
|
|
339
|
+
})), ff_core_List.List_map(definition_.commonFields_, ((f_) => {
|
|
340
|
+
const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
|
|
341
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
|
|
342
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, true))
|
|
343
|
+
};
|
|
344
|
+
{
|
|
345
|
+
const _1 = f_;
|
|
346
|
+
{
|
|
347
|
+
const _c = _1;
|
|
348
|
+
return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, valueType_, ff_core_Option.Option_map(f_.default_, ((_w1) => {
|
|
349
|
+
return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true)
|
|
350
|
+
})))
|
|
351
|
+
return
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
})), ff_core_List.List_map(definition_.variants_, ((v_) => {
|
|
355
|
+
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, v_.at_)) {
|
|
356
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(v_.name_, v_.at_, v_.at_), ff_core_Option.None()))
|
|
357
|
+
};
|
|
358
|
+
{
|
|
359
|
+
const _1 = v_;
|
|
360
|
+
{
|
|
361
|
+
const _c = _1;
|
|
362
|
+
return ff_compiler_Syntax.Variant(_c.at_, _c.name_, ff_core_List.List_map(v_.fields_, ((f_) => {
|
|
363
|
+
const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
|
|
364
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
|
|
365
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, false))
|
|
366
|
+
};
|
|
367
|
+
{
|
|
368
|
+
const _1 = f_;
|
|
369
|
+
{
|
|
370
|
+
const _c = _1;
|
|
371
|
+
return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, valueType_, ff_core_Option.Option_map(f_.default_, ((_w1) => {
|
|
372
|
+
return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true)
|
|
373
|
+
})))
|
|
374
|
+
return
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
})))
|
|
378
|
+
return
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
})))
|
|
382
|
+
return
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export function Resolver_resolveTraitDefinition(self_, definition_) {
|
|
388
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, definition_.at_))) {
|
|
389
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
|
|
390
|
+
};
|
|
391
|
+
const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
|
|
392
|
+
return ff_core_Pair.Pair(g_, g_)
|
|
393
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
394
|
+
const self2_ = (((_c) => {
|
|
395
|
+
return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
396
|
+
}))(self_);
|
|
397
|
+
{
|
|
398
|
+
const _1 = definition_;
|
|
399
|
+
{
|
|
400
|
+
const _c = _1;
|
|
401
|
+
return ff_compiler_Syntax.DTrait(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
|
|
402
|
+
return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
|
|
403
|
+
})), _c.generatorParameters_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
|
|
404
|
+
return ff_compiler_Resolver.Resolver_resolveSignature(self2_, _w1, true, false)
|
|
405
|
+
})), ff_core_List.List_map(definition_.methodDefaults_, ((_1) => {
|
|
406
|
+
{
|
|
407
|
+
const name_ = _1.first_;
|
|
408
|
+
const lambda_ = _1.second_;
|
|
409
|
+
const signature_ = ff_core_Option.Option_grab(ff_core_List.List_find(definition_.methods_, ((_w1) => {
|
|
410
|
+
return (_w1.name_ === name_)
|
|
411
|
+
})));
|
|
412
|
+
const function1_ = ff_compiler_Syntax.DFunction(signature_.at_, signature_, ff_compiler_Syntax.FireflyTarget(lambda_));
|
|
413
|
+
const function2_ = ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, function1_, true, false);
|
|
414
|
+
return ff_core_Pair.Pair(name_, (((_1) => {
|
|
415
|
+
{
|
|
416
|
+
if(_1.FireflyTarget) {
|
|
417
|
+
const lambda_ = _1.lambda_;
|
|
418
|
+
return lambda_
|
|
419
|
+
return
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
{
|
|
423
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(signature_.at_, "Internal error: Expected method default to be a lambda"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
424
|
+
return
|
|
425
|
+
}
|
|
426
|
+
}))(function2_.body_))
|
|
427
|
+
return
|
|
428
|
+
}
|
|
429
|
+
})), _c.methodGenerators_)
|
|
430
|
+
return
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export function Resolver_resolveInstanceDefinition(self_, definition_) {
|
|
436
|
+
const traitDefinedAt_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traitLocations_, definition_.traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
437
|
+
return definition_.at_
|
|
438
|
+
}));
|
|
439
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitDefinedAt_))) {
|
|
440
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.traitName_, definition_.at_, traitDefinedAt_), ff_core_Option.None()))
|
|
441
|
+
};
|
|
442
|
+
const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
|
|
443
|
+
return ff_core_Pair.Pair(g_, g_)
|
|
444
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
445
|
+
const self2_ = (((_c) => {
|
|
446
|
+
return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
447
|
+
}))(self_);
|
|
448
|
+
const traitName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self2_.traits_, definition_.traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
449
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ("No such trait: " + definition_.traitName_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
450
|
+
}));
|
|
451
|
+
{
|
|
452
|
+
const _1 = definition_;
|
|
453
|
+
{
|
|
454
|
+
const _c = _1;
|
|
455
|
+
return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
|
|
456
|
+
return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
|
|
457
|
+
})), traitName_, ff_core_List.List_map(definition_.typeArguments_, ((_w1) => {
|
|
458
|
+
return ff_compiler_Resolver.Resolver_resolveType(self2_, _w1, true)
|
|
459
|
+
})), _c.generatorArguments_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
|
|
460
|
+
return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, _w1, true, true)
|
|
461
|
+
})), _c.derived_)
|
|
462
|
+
return
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export function Resolver_resolveExtendDefinition(self_, definition_) {
|
|
468
|
+
const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
|
|
469
|
+
return ff_core_Pair.Pair(g_, g_)
|
|
470
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
471
|
+
const selfWithNoQ_ = (((_c) => {
|
|
472
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_add(self_.variables_, definition_.name_, definition_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_add(self_.variableLocations_, definition_.name_, definition_.at_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
473
|
+
}))(self_);
|
|
474
|
+
const selfWithQ_ = (((_c) => {
|
|
475
|
+
return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_add(selfWithNoQ_.types_, "Q$", "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, ff_core_Set.Set_add(selfWithNoQ_.typeParameters_, "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
476
|
+
}))(selfWithNoQ_);
|
|
477
|
+
{
|
|
478
|
+
const _1 = definition_;
|
|
479
|
+
{
|
|
480
|
+
const _c = _1;
|
|
481
|
+
return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
|
|
482
|
+
return ff_compiler_Resolver.Resolver_resolveConstraint(selfWithQ_, _w1, true)
|
|
483
|
+
})), ff_compiler_Resolver.Resolver_resolveType(selfWithQ_, definition_.type_, true), ff_core_List.List_map(definition_.methods_, ((_w1) => {
|
|
484
|
+
return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(selfWithNoQ_, _w1, true, false)
|
|
485
|
+
})))
|
|
486
|
+
return
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export function Resolver_resolveLetDefinition(self_, definition_, topLevel_) {
|
|
492
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, definition_.at_))) {
|
|
493
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
|
|
494
|
+
};
|
|
495
|
+
{
|
|
496
|
+
const _1 = definition_;
|
|
497
|
+
{
|
|
498
|
+
const _c = _1;
|
|
499
|
+
return ff_compiler_Syntax.DLet(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self_, definition_.variableType_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, definition_.value_, true))
|
|
500
|
+
return
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export function Resolver_resolveTerm(self_, term_, topLevel_) {
|
|
506
|
+
{
|
|
507
|
+
const self_a = self_;
|
|
508
|
+
const term_a = term_;
|
|
509
|
+
const topLevel_a = topLevel_;
|
|
510
|
+
{
|
|
511
|
+
if(term_a.EString) {
|
|
512
|
+
return term_
|
|
513
|
+
return
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
{
|
|
517
|
+
if(term_a.EChar) {
|
|
518
|
+
return term_
|
|
519
|
+
return
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
{
|
|
523
|
+
if(term_a.EInt) {
|
|
524
|
+
return term_
|
|
525
|
+
return
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
{
|
|
529
|
+
if(term_a.EFloat) {
|
|
530
|
+
return term_
|
|
531
|
+
return
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
{
|
|
535
|
+
if(term_a.EVariable) {
|
|
536
|
+
const e_ = term_a;
|
|
537
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
538
|
+
const at_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variableLocations_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
539
|
+
return e_.at_
|
|
540
|
+
}));
|
|
541
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))) {
|
|
542
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(e_.name_, e_.at_, at_), ff_core_Option.None()))
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
return ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Map.Map_get(self_.variables_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_w1) => {
|
|
546
|
+
{
|
|
547
|
+
const _1 = e_;
|
|
548
|
+
{
|
|
549
|
+
const _c = _1;
|
|
550
|
+
return ff_compiler_Syntax.EVariable(_c.at_, _w1)
|
|
551
|
+
return
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
})), (() => {
|
|
555
|
+
return term_
|
|
556
|
+
}))
|
|
557
|
+
return
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
{
|
|
561
|
+
if(term_a.EList) {
|
|
562
|
+
const at_ = term_a.at_;
|
|
563
|
+
const t_ = term_a.elementType_;
|
|
564
|
+
const items_ = term_a.items_;
|
|
565
|
+
return ff_compiler_Syntax.EList(at_, ff_compiler_Resolver.Resolver_resolveType(self_, t_, topLevel_), ff_core_List.List_map(items_, ((_1) => {
|
|
566
|
+
{
|
|
567
|
+
const item_ = _1.first_;
|
|
568
|
+
const spread_ = _1.second_;
|
|
569
|
+
return ff_core_Pair.Pair(ff_compiler_Resolver.Resolver_resolveTerm(self_, item_, topLevel_), spread_)
|
|
570
|
+
return
|
|
571
|
+
}
|
|
572
|
+
})))
|
|
573
|
+
return
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
{
|
|
577
|
+
if(term_a.EVariant) {
|
|
578
|
+
const at_ = term_a.at_;
|
|
579
|
+
const name_ = term_a.name_;
|
|
580
|
+
const typeArguments_ = term_a.typeArguments_;
|
|
581
|
+
const arguments_ = term_a.arguments_;
|
|
582
|
+
return ff_compiler_Syntax.EVariant(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
583
|
+
return name_
|
|
584
|
+
})), ff_core_List.List_map(typeArguments_, ((_w1) => {
|
|
585
|
+
return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
|
|
586
|
+
})), ff_core_Option.Option_map(arguments_, ((_w1) => {
|
|
587
|
+
return ff_core_List.List_map(_w1, ((a_) => {
|
|
588
|
+
{
|
|
589
|
+
const _1 = a_;
|
|
590
|
+
{
|
|
591
|
+
const _c = _1;
|
|
592
|
+
return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, a_.value_, topLevel_))
|
|
593
|
+
return
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}))
|
|
597
|
+
})))
|
|
598
|
+
return
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
{
|
|
602
|
+
if(term_a.EVariantIs) {
|
|
603
|
+
const at_ = term_a.at_;
|
|
604
|
+
const name_ = term_a.name_;
|
|
605
|
+
const typeArguments_ = term_a.typeArguments_;
|
|
606
|
+
return ff_compiler_Syntax.EVariantIs(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
607
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variant: " + name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
608
|
+
})), ff_core_List.List_map(typeArguments_, ((_w1) => {
|
|
609
|
+
return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
|
|
610
|
+
})))
|
|
611
|
+
return
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
{
|
|
615
|
+
if(term_a.ECopy) {
|
|
616
|
+
const at_ = term_a.at_;
|
|
617
|
+
const name_ = term_a.name_;
|
|
618
|
+
const record_ = term_a.record_;
|
|
619
|
+
const arguments_ = term_a.arguments_;
|
|
620
|
+
return ff_compiler_Syntax.ECopy(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
621
|
+
return name_
|
|
622
|
+
})), ff_compiler_Resolver.Resolver_resolveTerm(self_, record_, topLevel_), ff_core_List.List_map(arguments_, ((f_) => {
|
|
623
|
+
{
|
|
624
|
+
const _1 = f_;
|
|
625
|
+
{
|
|
626
|
+
const _c = _1;
|
|
627
|
+
return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, f_.value_, topLevel_))
|
|
628
|
+
return
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
})))
|
|
632
|
+
return
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
{
|
|
636
|
+
if(term_a.EField) {
|
|
637
|
+
const e_ = term_a;
|
|
638
|
+
{
|
|
639
|
+
const _1 = e_;
|
|
640
|
+
{
|
|
641
|
+
const _c = _1;
|
|
642
|
+
return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, ff_compiler_Resolver.Resolver_resolveTerm(self_, e_.record_, topLevel_), _c.field_)
|
|
643
|
+
return
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
return
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
{
|
|
650
|
+
if(term_a.ELambda) {
|
|
651
|
+
const at_ = term_a.at_;
|
|
652
|
+
const lambdaAt_ = term_a.lambda_.at_;
|
|
653
|
+
const cases_ = term_a.lambda_.cases_;
|
|
654
|
+
const effect_ = ff_compiler_Resolver.Resolver_makeEffectArgument(self_, lambdaAt_, topLevel_);
|
|
655
|
+
return ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(lambdaAt_, effect_, ff_core_List.List_map(cases_, ((_w1) => {
|
|
656
|
+
return ff_compiler_Resolver.Resolver_resolveCase(self_, _w1, topLevel_)
|
|
657
|
+
}))))
|
|
658
|
+
return
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
{
|
|
662
|
+
if(term_a.EPipe) {
|
|
663
|
+
const at_ = term_a.at_;
|
|
664
|
+
const value_ = term_a.value_;
|
|
665
|
+
const effect_ = term_a.effect_;
|
|
666
|
+
const function_ = term_a.function_;
|
|
667
|
+
return ff_compiler_Syntax.EPipe(at_, ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_), ff_compiler_Resolver.Resolver_resolveType(self_, effect_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, function_, topLevel_))
|
|
668
|
+
return
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
{
|
|
672
|
+
if(term_a.ECall) {
|
|
673
|
+
const at_ = term_a.at_;
|
|
674
|
+
if(term_a.target_.DynamicCall) {
|
|
675
|
+
const target_ = term_a.target_;
|
|
676
|
+
const effect_ = term_a.effect_;
|
|
677
|
+
const typeArguments_ = term_a.typeArguments_;
|
|
678
|
+
const arguments_ = term_a.arguments_;
|
|
679
|
+
const dictionaries_ = term_a.dictionaries_;
|
|
680
|
+
return ff_compiler_Syntax.ECall(at_, (((_c) => {
|
|
681
|
+
return ff_compiler_Syntax.DynamicCall(ff_compiler_Resolver.Resolver_resolveTerm(self_, target_.function_, topLevel_), _c.tailCall_)
|
|
682
|
+
}))(target_), ff_compiler_Resolver.Resolver_resolveType(self_, effect_, topLevel_), ff_core_List.List_map(typeArguments_, ((_w1) => {
|
|
683
|
+
return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
|
|
684
|
+
})), ff_core_List.List_map(arguments_, ((a_) => {
|
|
685
|
+
{
|
|
686
|
+
const _1 = a_;
|
|
687
|
+
{
|
|
688
|
+
const _c = _1;
|
|
689
|
+
return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, a_.value_, topLevel_))
|
|
690
|
+
return
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
})), dictionaries_)
|
|
694
|
+
return
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
{
|
|
699
|
+
if(term_a.ECall) {
|
|
700
|
+
const at_ = term_a.at_;
|
|
701
|
+
if(term_a.target_.StaticCall) {
|
|
702
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Internal error: Static calls not expected in the Resolver phase"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
703
|
+
return
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
{
|
|
708
|
+
if(term_a.ERecord) {
|
|
709
|
+
const at_ = term_a.at_;
|
|
710
|
+
const fields_ = term_a.fields_;
|
|
711
|
+
return ff_compiler_Syntax.ERecord(at_, ff_core_List.List_map(fields_, ((f_) => {
|
|
712
|
+
{
|
|
713
|
+
const _1 = f_;
|
|
714
|
+
{
|
|
715
|
+
const _c = _1;
|
|
716
|
+
return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, f_.value_, topLevel_))
|
|
717
|
+
return
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
})))
|
|
721
|
+
return
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
{
|
|
725
|
+
if(term_a.EWildcard) {
|
|
726
|
+
const e_ = term_a;
|
|
727
|
+
if((e_.index_ === 0)) {
|
|
728
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Unbound wildcard"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
729
|
+
};
|
|
730
|
+
{
|
|
731
|
+
const _1 = e_;
|
|
732
|
+
{
|
|
733
|
+
const _c = _1;
|
|
734
|
+
return ff_compiler_Syntax.EWildcard(_c.at_, _c.index_)
|
|
735
|
+
return
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
return
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
{
|
|
742
|
+
if(term_a.EFunctions) {
|
|
743
|
+
const at_ = term_a.at_;
|
|
744
|
+
const functions_ = term_a.functions_;
|
|
745
|
+
const body_ = term_a.body_;
|
|
746
|
+
const functionMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(functions_, ((_w1) => {
|
|
747
|
+
return _w1.signature_.name_
|
|
748
|
+
})), ((name_) => {
|
|
749
|
+
return ff_core_Pair.Pair(name_, name_)
|
|
750
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
751
|
+
const locationMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(functions_, ((_w1) => {
|
|
752
|
+
return _w1.signature_
|
|
753
|
+
})), ((s_) => {
|
|
754
|
+
return ff_core_Pair.Pair(s_.name_, s_.at_)
|
|
755
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
756
|
+
const self2_ = (((_c) => {
|
|
757
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, functionMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, locationMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
758
|
+
}))(self_);
|
|
759
|
+
return ff_compiler_Syntax.EFunctions(at_, ff_core_List.List_map(functions_, ((_w1) => {
|
|
760
|
+
return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, _w1, topLevel_, false)
|
|
761
|
+
})), ff_compiler_Resolver.Resolver_resolveTerm(self2_, body_, topLevel_))
|
|
762
|
+
return
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
{
|
|
766
|
+
if(term_a.ELet) {
|
|
767
|
+
const e_ = term_a;
|
|
768
|
+
const self2_ = (((_c) => {
|
|
769
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_add(self_.variables_, e_.name_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_add(self_.variableLocations_, e_.name_, e_.at_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
770
|
+
}))(self_);
|
|
771
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
772
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, e_.at_))) {
|
|
773
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(e_.name_, e_.at_, e_.at_), ff_core_Option.None()))
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
{
|
|
777
|
+
const _1 = e_;
|
|
778
|
+
{
|
|
779
|
+
const _c = _1;
|
|
780
|
+
return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self_, e_.valueType_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, e_.value_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self2_, e_.body_, topLevel_))
|
|
781
|
+
return
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
return
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
{
|
|
788
|
+
if(term_a.ESequential) {
|
|
789
|
+
const at_ = term_a.at_;
|
|
790
|
+
const before_ = term_a.before_;
|
|
791
|
+
const after_ = term_a.after_;
|
|
792
|
+
return ff_compiler_Syntax.ESequential(at_, ff_compiler_Resolver.Resolver_resolveTerm(self_, before_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, after_, topLevel_))
|
|
793
|
+
return
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
{
|
|
797
|
+
if(term_a.EAssign) {
|
|
798
|
+
const at_ = term_a.at_;
|
|
799
|
+
const operator_ = term_a.operator_;
|
|
800
|
+
const variable_ = term_a.variable_;
|
|
801
|
+
const value_ = term_a.value_;
|
|
802
|
+
return ff_compiler_Syntax.EAssign(at_, operator_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variables_, variable_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
803
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variable: " + variable_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
804
|
+
})), ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_))
|
|
805
|
+
return
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
{
|
|
809
|
+
if(term_a.EAssignField) {
|
|
810
|
+
const at_ = term_a.at_;
|
|
811
|
+
const operator_ = term_a.operator_;
|
|
812
|
+
const record_ = term_a.record_;
|
|
813
|
+
const field_ = term_a.field_;
|
|
814
|
+
const value_ = term_a.value_;
|
|
815
|
+
return ff_compiler_Syntax.EAssignField(at_, operator_, ff_compiler_Resolver.Resolver_resolveTerm(self_, record_, topLevel_), field_, ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_))
|
|
816
|
+
return
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
export function Resolver_resolveType(self_, type_, topLevel_) {
|
|
823
|
+
{
|
|
824
|
+
const self_a = self_;
|
|
825
|
+
const type_a = type_;
|
|
826
|
+
const topLevel_a = topLevel_;
|
|
827
|
+
{
|
|
828
|
+
if(type_a.TVariable) {
|
|
829
|
+
return type_
|
|
830
|
+
return
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
{
|
|
834
|
+
if(type_a.TConstructor) {
|
|
835
|
+
const constructor_ = type_a;
|
|
836
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
837
|
+
const at_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.typeLocations_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
838
|
+
return type_.at_
|
|
839
|
+
}));
|
|
840
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, type_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))) {
|
|
841
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveTypeHook(self_.types_, self_.typeGenerics_, ff_compiler_LspHook.SymbolHook(constructor_.name_, type_.at_, at_), type_))
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
const name_ = (ff_core_String.String_contains(constructor_.name_, "$")
|
|
845
|
+
? constructor_.name_
|
|
846
|
+
: ff_core_Option.Option_else(ff_core_Map.Map_get(self_.types_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
847
|
+
if((!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_))) {
|
|
848
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constructor_.at_, ("No such type: " + constructor_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
849
|
+
} else {
|
|
850
|
+
return constructor_.name_
|
|
851
|
+
}
|
|
852
|
+
})));
|
|
853
|
+
const isFunctionType_ = ff_core_String.String_startsWith(name_, "Function$", 0);
|
|
854
|
+
const effect_ = ((isFunctionType_ || ff_core_Set.Set_contains(self_.asyncTypes_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))
|
|
855
|
+
? ff_core_List.Link(ff_compiler_Resolver.Resolver_makeEffectArgument(self_, constructor_.at_, topLevel_), ff_core_List.Empty())
|
|
856
|
+
: ff_core_List.Empty());
|
|
857
|
+
const generics_ = ff_core_List.List_map(constructor_.generics_, ((_w1) => {
|
|
858
|
+
return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
|
|
859
|
+
}));
|
|
860
|
+
if(isFunctionType_) {
|
|
861
|
+
const arguments_ = ff_core_List.List_dropLast(generics_, 1);
|
|
862
|
+
const returnType_ = ff_core_List.List_grabLast(generics_);
|
|
863
|
+
{
|
|
864
|
+
const _1 = constructor_;
|
|
865
|
+
{
|
|
866
|
+
const _c = _1;
|
|
867
|
+
return ff_compiler_Syntax.TConstructor(_c.at_, name_, ff_core_List.List_addAll(effect_, ff_core_List.List_addAll(arguments_, ff_core_List.Link(returnType_, ff_core_List.Empty()))))
|
|
868
|
+
return
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
} else {
|
|
872
|
+
{
|
|
873
|
+
const _1 = constructor_;
|
|
874
|
+
{
|
|
875
|
+
const _c = _1;
|
|
876
|
+
return ff_compiler_Syntax.TConstructor(_c.at_, name_, ff_core_List.List_addAll(effect_, generics_))
|
|
877
|
+
return
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
return
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
export function Resolver_makeEffectArgument(self_, at_, topLevel_) {
|
|
888
|
+
if(topLevel_) {
|
|
889
|
+
if((!ff_core_Set.Set_contains(self_.typeParameters_, "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))) {
|
|
890
|
+
return ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty())
|
|
891
|
+
} else {
|
|
892
|
+
return ff_compiler_Syntax.TConstructor(at_, "Q$", ff_core_List.Empty())
|
|
893
|
+
}
|
|
894
|
+
} else {
|
|
895
|
+
return ff_compiler_Resolver.Resolver_freshUnificationVariable(self_, at_)
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
export function Resolver_resolveConstraint(self_, constraint_, topLevel_) {
|
|
900
|
+
const traitDefinedAt_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traitLocations_, constraint_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
901
|
+
return constraint_.at_
|
|
902
|
+
}));
|
|
903
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, constraint_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitDefinedAt_))) {
|
|
904
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveConstraintHook(ff_compiler_LspHook.SymbolHook(constraint_.name_, constraint_.at_, traitDefinedAt_), constraint_))
|
|
905
|
+
};
|
|
906
|
+
const name_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traits_, constraint_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
907
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constraint_.at_, ("No such trait: " + constraint_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
908
|
+
}));
|
|
909
|
+
{
|
|
910
|
+
const _1 = constraint_;
|
|
911
|
+
{
|
|
912
|
+
const _c = _1;
|
|
913
|
+
return ff_compiler_Syntax.Constraint(_c.at_, name_, ff_core_List.List_map(constraint_.generics_, ((_w1) => {
|
|
914
|
+
return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
|
|
915
|
+
})))
|
|
916
|
+
return
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
export function Resolver_resolveFunctionDefinition(self_, definition_, topLevel_, isInstanceMethod_) {
|
|
922
|
+
const signature_ = ff_compiler_Resolver.Resolver_resolveSignature(self_, definition_.signature_, topLevel_, isInstanceMethod_);
|
|
923
|
+
const self2_ = ff_compiler_Resolver.Resolver_withSignature(self_, signature_);
|
|
924
|
+
const body_ = ff_compiler_Syntax.Target_mapFirefly(definition_.body_, ((lambda_) => {
|
|
925
|
+
{
|
|
926
|
+
const _1 = lambda_;
|
|
927
|
+
{
|
|
928
|
+
const _c = _1;
|
|
929
|
+
return ff_compiler_Syntax.Lambda(_c.at_, signature_.effect_, ff_core_List.List_map(lambda_.cases_, ((_w1) => {
|
|
930
|
+
return ff_compiler_Resolver.Resolver_resolveCase(self2_, _w1, false)
|
|
931
|
+
})))
|
|
932
|
+
return
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}));
|
|
936
|
+
return ff_compiler_Syntax.DFunction(definition_.at_, signature_, body_)
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
export function Resolver_resolveSignature(self_, signature_, topLevel_, isInstanceMethod_) {
|
|
940
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, signature_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, signature_.at_))) {
|
|
941
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSignatureHook(signature_, isInstanceMethod_))
|
|
942
|
+
};
|
|
943
|
+
const newSignature_ = (topLevel_
|
|
944
|
+
? (((_c) => {
|
|
945
|
+
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, ff_core_List.Link("Q$", signature_.generics_), _c.constraints_, _c.parameters_, _c.returnType_, ff_compiler_Syntax.TConstructor(signature_.at_, "Q$", ff_core_List.Empty()))
|
|
946
|
+
}))(signature_)
|
|
947
|
+
: (((_c) => {
|
|
948
|
+
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, _c.constraints_, _c.parameters_, _c.returnType_, ff_compiler_Resolver.Resolver_freshUnificationVariable(self_, signature_.at_))
|
|
949
|
+
}))(signature_));
|
|
950
|
+
ff_core_Option.Option_each(ff_core_List.List_find(newSignature_.generics_, ((name_) => {
|
|
951
|
+
return ff_core_Set.Set_contains(self_.typeParameters_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
952
|
+
})), ((name_) => {
|
|
953
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(signature_.at_, (("Type parameter " + name_) + " is already in scope")), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
954
|
+
}));
|
|
955
|
+
const self2_ = ff_compiler_Resolver.Resolver_withSignature(self_, newSignature_);
|
|
956
|
+
{
|
|
957
|
+
const _1 = newSignature_;
|
|
958
|
+
{
|
|
959
|
+
const _c = _1;
|
|
960
|
+
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, ff_core_List.List_map(newSignature_.constraints_, ((_w1) => {
|
|
961
|
+
return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, topLevel_)
|
|
962
|
+
})), ff_core_List.List_map(newSignature_.parameters_, ((p_) => {
|
|
963
|
+
{
|
|
964
|
+
const _1 = p_;
|
|
965
|
+
{
|
|
966
|
+
const _c = _1;
|
|
967
|
+
return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self2_, p_.valueType_, topLevel_), ff_core_Option.Option_map(p_.default_, ((_w1) => {
|
|
968
|
+
return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, topLevel_)
|
|
969
|
+
})))
|
|
970
|
+
return
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
})), ff_compiler_Resolver.Resolver_resolveType(self2_, newSignature_.returnType_, topLevel_), _c.effect_)
|
|
974
|
+
return
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
export function Resolver_withSignature(self_, signature_) {
|
|
980
|
+
const variableMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(signature_.parameters_, ((_w1) => {
|
|
981
|
+
return _w1.name_
|
|
982
|
+
})), ((name_) => {
|
|
983
|
+
return ff_core_Pair.Pair(name_, name_)
|
|
984
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
985
|
+
const variableLocationMap_ = ff_core_List.List_toMap(ff_core_List.List_map(signature_.parameters_, ((p_) => {
|
|
986
|
+
return ff_core_Pair.Pair(p_.name_, p_.at_)
|
|
987
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
988
|
+
const typeMap_ = ff_core_List.List_toMap(ff_core_List.List_map(signature_.generics_, ((name_) => {
|
|
989
|
+
return ff_core_Pair.Pair(name_, name_)
|
|
990
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
991
|
+
{
|
|
992
|
+
const _1 = self_;
|
|
993
|
+
{
|
|
994
|
+
const _c = _1;
|
|
995
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, variableMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, variableLocationMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, ff_core_Map.Map_addAll(self_.types_, typeMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(signature_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(signature_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
996
|
+
return
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
export function Resolver_resolveCase(self_, case_, topLevel_) {
|
|
1002
|
+
function findVariables_(pattern_) {
|
|
1003
|
+
{
|
|
1004
|
+
const pattern_a = pattern_;
|
|
1005
|
+
{
|
|
1006
|
+
if(pattern_a.PString) {
|
|
1007
|
+
return ff_core_Map.empty_()
|
|
1008
|
+
return
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
{
|
|
1012
|
+
if(pattern_a.PInt) {
|
|
1013
|
+
return ff_core_Map.empty_()
|
|
1014
|
+
return
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
{
|
|
1018
|
+
if(pattern_a.PChar) {
|
|
1019
|
+
return ff_core_Map.empty_()
|
|
1020
|
+
return
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
{
|
|
1024
|
+
if(pattern_a.PVariable) {
|
|
1025
|
+
const at_ = pattern_a.at_;
|
|
1026
|
+
if(pattern_a.name_.Some) {
|
|
1027
|
+
const name_ = pattern_a.name_.value_;
|
|
1028
|
+
return ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(name_, ff_core_Pair.Pair(at_, name_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
1029
|
+
return
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
{
|
|
1034
|
+
if(pattern_a.PVariable) {
|
|
1035
|
+
if(pattern_a.name_.None) {
|
|
1036
|
+
return ff_core_Map.empty_()
|
|
1037
|
+
return
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
{
|
|
1042
|
+
if(pattern_a.PVariant) {
|
|
1043
|
+
const patterns_ = pattern_a.patterns_;
|
|
1044
|
+
return ff_core_List.List_foldLeft(ff_core_List.List_map(patterns_, ((pattern_) => {
|
|
1045
|
+
return findVariables_(pattern_)
|
|
1046
|
+
})), ff_core_Map.empty_(), ((_w1, _w2) => {
|
|
1047
|
+
return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
1048
|
+
}))
|
|
1049
|
+
return
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
{
|
|
1053
|
+
if(pattern_a.PVariantAs) {
|
|
1054
|
+
const at_ = pattern_a.at_;
|
|
1055
|
+
const variableAt_ = pattern_a.variableAt_;
|
|
1056
|
+
const variable_ = pattern_a.variable_;
|
|
1057
|
+
return ff_core_List.List_toMap(ff_core_List.List_map(ff_core_Option.Option_toList(variable_), ((x_) => {
|
|
1058
|
+
return ff_core_Pair.Pair(x_, ff_core_Pair.Pair(variableAt_, x_))
|
|
1059
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
1060
|
+
return
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
{
|
|
1064
|
+
if(pattern_a.PAlias) {
|
|
1065
|
+
const at_ = pattern_a.at_;
|
|
1066
|
+
const pattern_ = pattern_a.pattern_;
|
|
1067
|
+
const variable_ = pattern_a.variable_;
|
|
1068
|
+
return ff_core_Map.Map_addAll(ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(variable_, ff_core_Pair.Pair(at_, variable_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), findVariables_(pattern_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
1069
|
+
return
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
const variableMap_ = ff_core_List.List_foldLeft(ff_core_List.List_map(case_.patterns_, ((pattern_) => {
|
|
1075
|
+
return findVariables_(pattern_)
|
|
1076
|
+
})), ff_core_Map.empty_(), ((_w1, _w2) => {
|
|
1077
|
+
return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
1078
|
+
}));
|
|
1079
|
+
let guards_ = ff_core_List.Empty();
|
|
1080
|
+
const variableMap2_ = ff_core_List.List_foldLeft(case_.guards_, variableMap_, ((variableMap1_, g_) => {
|
|
1081
|
+
const self2_ = (((_c) => {
|
|
1082
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, ff_core_Map.Map_mapValues(variableMap1_, ((_, p_) => {
|
|
1083
|
+
return p_.second_
|
|
1084
|
+
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, ff_core_Map.Map_mapValues(variableMap1_, ((_, p_) => {
|
|
1085
|
+
return p_.first_
|
|
1086
|
+
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
1087
|
+
}))(self_);
|
|
1088
|
+
const guard_ = (((_c) => {
|
|
1089
|
+
return ff_compiler_Syntax.MatchGuard(_c.at_, ff_compiler_Resolver.Resolver_resolveTerm(self2_, g_.term_, topLevel_), ff_compiler_Resolver.Resolver_resolvePattern(self2_, g_.pattern_))
|
|
1090
|
+
}))(g_);
|
|
1091
|
+
guards_ = ff_core_List.Link(guard_, guards_);
|
|
1092
|
+
return ff_core_Map.Map_addAll(variableMap1_, findVariables_(guard_.pattern_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
1093
|
+
}));
|
|
1094
|
+
const self3_ = (((_c) => {
|
|
1095
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, ff_core_Map.Map_mapValues(variableMap2_, ((_, p_) => {
|
|
1096
|
+
return p_.second_
|
|
1097
|
+
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, ff_core_Map.Map_mapValues(variableMap2_, ((_, p_) => {
|
|
1098
|
+
return p_.first_
|
|
1099
|
+
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
1100
|
+
}))(self_);
|
|
1101
|
+
return ff_compiler_Syntax.MatchCase(case_.at_, ff_core_List.List_map(case_.patterns_, ((_w1) => {
|
|
1102
|
+
return ff_compiler_Resolver.Resolver_resolvePattern(self_, _w1)
|
|
1103
|
+
})), ff_core_List.List_reverse(guards_), ff_compiler_Resolver.Resolver_resolveTerm(self3_, case_.body_, topLevel_))
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
export function Resolver_resolvePattern(self_, pattern_) {
|
|
1107
|
+
{
|
|
1108
|
+
const self_a = self_;
|
|
1109
|
+
const pattern_a = pattern_;
|
|
1110
|
+
{
|
|
1111
|
+
if(pattern_a.PString) {
|
|
1112
|
+
return pattern_
|
|
1113
|
+
return
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
{
|
|
1117
|
+
if(pattern_a.PInt) {
|
|
1118
|
+
return pattern_
|
|
1119
|
+
return
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
{
|
|
1123
|
+
if(pattern_a.PChar) {
|
|
1124
|
+
return pattern_
|
|
1125
|
+
return
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
{
|
|
1129
|
+
if(pattern_a.PVariable) {
|
|
1130
|
+
return pattern_
|
|
1131
|
+
return
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
{
|
|
1135
|
+
if(pattern_a.PVariant) {
|
|
1136
|
+
const at_ = pattern_a.at_;
|
|
1137
|
+
const name_ = pattern_a.name_;
|
|
1138
|
+
const patterns_ = pattern_a.patterns_;
|
|
1139
|
+
const newName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1140
|
+
return name_
|
|
1141
|
+
}));
|
|
1142
|
+
const newPatterns_ = ff_core_List.List_map(patterns_, ((_w1) => {
|
|
1143
|
+
return ff_compiler_Resolver.Resolver_resolvePattern(self_, _w1)
|
|
1144
|
+
}));
|
|
1145
|
+
return ff_compiler_Syntax.PVariant(at_, newName_, newPatterns_)
|
|
1146
|
+
return
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
{
|
|
1150
|
+
if(pattern_a.PVariantAs) {
|
|
1151
|
+
const at_ = pattern_a.at_;
|
|
1152
|
+
const name_ = pattern_a.name_;
|
|
1153
|
+
const variableAt_ = pattern_a.variableAt_;
|
|
1154
|
+
const variable_ = pattern_a.variable_;
|
|
1155
|
+
const newName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1156
|
+
return name_
|
|
1157
|
+
}));
|
|
1158
|
+
return ff_compiler_Syntax.PVariantAs(at_, newName_, variableAt_, variable_)
|
|
1159
|
+
return
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
{
|
|
1163
|
+
if(pattern_a.PAlias) {
|
|
1164
|
+
const at_ = pattern_a.at_;
|
|
1165
|
+
const pattern_ = pattern_a.pattern_;
|
|
1166
|
+
const variable_ = pattern_a.variable_;
|
|
1167
|
+
const newPattern_ = ff_compiler_Resolver.Resolver_resolvePattern(self_, pattern_);
|
|
1168
|
+
return ff_compiler_Syntax.PAlias(at_, newPattern_, variable_)
|
|
1169
|
+
return
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
export function Resolver_containsAsyncType(self_, type_) {
|
|
1176
|
+
{
|
|
1177
|
+
const self_a = self_;
|
|
1178
|
+
const type_a = type_;
|
|
1179
|
+
{
|
|
1180
|
+
if(type_a.TVariable) {
|
|
1181
|
+
return false
|
|
1182
|
+
return
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
{
|
|
1186
|
+
if(type_a.TConstructor) {
|
|
1187
|
+
const constructor_ = type_a;
|
|
1188
|
+
const name_ = (ff_core_String.String_contains(constructor_.name_, "$")
|
|
1189
|
+
? constructor_.name_
|
|
1190
|
+
: ff_core_Option.Option_else(ff_core_Map.Map_get(self_.types_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1191
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1192
|
+
return constructor_.name_
|
|
1193
|
+
} else {
|
|
1194
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constructor_.at_, ("No such type: " + constructor_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1195
|
+
}
|
|
1196
|
+
})));
|
|
1197
|
+
const isFunctionType_ = ff_core_String.String_startsWith(name_, "Function$", 0);
|
|
1198
|
+
return ((isFunctionType_ || ff_core_Set.Set_contains(self_.asyncTypes_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) || ff_core_List.List_any(constructor_.generics_, ((_w1) => {
|
|
1199
|
+
return ff_compiler_Resolver.Resolver_containsAsyncType(self_, _w1)
|
|
1200
|
+
})))
|
|
1201
|
+
return
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
export async function Resolver_freshUnificationVariable$(self_, at_, $task) {
|
|
1208
|
+
const result_ = ff_compiler_Syntax.TVariable(at_, self_.state_.nextUnificationVariableIndex_);
|
|
1209
|
+
self_.state_.nextUnificationVariableIndex_ += 3;
|
|
1210
|
+
return result_
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
export async function Resolver_resolveModule$(self_, module_, otherModules_, $task) {
|
|
1214
|
+
const moduleNamespace_ = ff_core_String.String_takeWhile(ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core_String.String_reverse(ff_core_String.String_replace(module_.file_, "\\", "/")), ((_w1) => {
|
|
1215
|
+
return (_w1 !== 47)
|
|
1216
|
+
}))), ((_w1) => {
|
|
1217
|
+
return (_w1 !== 46)
|
|
1218
|
+
}));
|
|
1219
|
+
const self2_ = ff_compiler_Resolver.Resolver_processImports(self_, module_.imports_, otherModules_);
|
|
1220
|
+
const self3_ = ff_compiler_Resolver.Resolver_processDefinitions(self2_, module_, ff_core_Option.None());
|
|
1221
|
+
const module2_ = (((_c) => {
|
|
1222
|
+
return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_core_List.List_map(module_.types_, ((_w1) => {
|
|
1223
|
+
return ff_compiler_Resolver.Resolver_resolveTypeDefinition(self3_, _w1)
|
|
1224
|
+
})), ff_core_List.List_map(module_.traits_, ((_w1) => {
|
|
1225
|
+
return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
|
|
1226
|
+
})), ff_core_List.List_map(module_.instances_, ((_w1) => {
|
|
1227
|
+
return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
|
|
1228
|
+
})), ff_core_List.List_map(module_.extends_, ((_w1) => {
|
|
1229
|
+
return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
|
|
1230
|
+
})), ff_core_List.List_map(module_.lets_, ((_w1) => {
|
|
1231
|
+
return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
|
|
1232
|
+
})), ff_core_List.List_map(module_.functions_, ((_w1) => {
|
|
1233
|
+
return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
|
|
1234
|
+
})))
|
|
1235
|
+
}))(module_);
|
|
1236
|
+
ff_core_List.List_each(module2_.instances_, ((_w1) => {
|
|
1237
|
+
ff_core_List.List_each(_w1.typeArguments_, ((_w1) => {
|
|
1238
|
+
ff_compiler_Resolver.Resolver_checkInstanceType(self3_, _w1)
|
|
1239
|
+
}))
|
|
1240
|
+
}));
|
|
1241
|
+
return module2_
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
export async function Resolver_checkInstanceType$(self_, type_, $task) {
|
|
1245
|
+
{
|
|
1246
|
+
const _1 = type_;
|
|
1247
|
+
{
|
|
1248
|
+
if(_1.TConstructor) {
|
|
1249
|
+
const name_ = _1.name_;
|
|
1250
|
+
const typeArguments_ = _1.generics_;
|
|
1251
|
+
if(ff_core_Set.Set_contains(self_.asyncTypes_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
|
|
1252
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(type_.at_, "Traits must not be instantiated for capability types"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1253
|
+
};
|
|
1254
|
+
ff_core_List.List_each(typeArguments_, ((_w1) => {
|
|
1255
|
+
ff_compiler_Resolver.Resolver_checkInstanceType(self_, _w1)
|
|
1256
|
+
}))
|
|
1257
|
+
return
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
{
|
|
1261
|
+
|
|
1262
|
+
return
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
export async function Resolver_processImports$(self_, imports_, modules_, $task) {
|
|
1268
|
+
let resolver_ = self_;
|
|
1269
|
+
ff_core_List.List_each(imports_, ((import_) => {
|
|
1270
|
+
{
|
|
1271
|
+
const _1 = ff_core_List.List_find(modules_, ((_w1) => {
|
|
1272
|
+
return (ff_core_String.String_dropLast(_w1.file_, 3) === import_.file_)
|
|
1273
|
+
}));
|
|
1274
|
+
{
|
|
1275
|
+
if(_1.Some) {
|
|
1276
|
+
const module_ = _1.value_;
|
|
1277
|
+
resolver_ = ff_compiler_Resolver.Resolver_processDefinitions(resolver_, module_, ff_core_Option.Some(import_.alias_))
|
|
1278
|
+
return
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
{
|
|
1282
|
+
if(_1.None) {
|
|
1283
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(import_.at_, ("No such module: " + import_.file_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1284
|
+
return
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}));
|
|
1289
|
+
return resolver_
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
export async function Resolver_processDefinitions$(self_, module_, importAlias_, $task) {
|
|
1293
|
+
function entry_(name_, unqualified_) {
|
|
1294
|
+
const full_ = ((((ff_compiler_Syntax.PackagePair_groupName(module_.packagePair_, ":") + "/") + ff_core_String.String_dropLast(module_.file_, 3)) + ".") + name_);
|
|
1295
|
+
{
|
|
1296
|
+
const _1 = importAlias_;
|
|
1297
|
+
{
|
|
1298
|
+
if(_1.None) {
|
|
1299
|
+
return ff_core_List.Link(ff_core_Pair.Pair(name_, full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty()))
|
|
1300
|
+
return
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
{
|
|
1304
|
+
if(_1.Some) {
|
|
1305
|
+
const alias_ = _1.value_;
|
|
1306
|
+
const _guard1 = unqualified_;
|
|
1307
|
+
if(_guard1) {
|
|
1308
|
+
return ff_core_List.Link(ff_core_Pair.Pair(((alias_ + ".") + name_), full_), ff_core_List.Link(ff_core_Pair.Pair(name_, full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty())))
|
|
1309
|
+
return
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
{
|
|
1314
|
+
if(_1.Some) {
|
|
1315
|
+
const alias_ = _1.value_;
|
|
1316
|
+
return ff_core_List.Link(ff_core_Pair.Pair(((alias_ + ".") + name_), full_), ff_core_List.Link(ff_core_Pair.Pair(full_, full_), ff_core_List.Empty()))
|
|
1317
|
+
return
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
const isCore_ = (((module_.packagePair_.group_ === "ff") && (module_.packagePair_.name_ === "core")) && (module_.file_ === "Core.ff"));
|
|
1323
|
+
const lets_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.lets_, ((_w1) => {
|
|
1324
|
+
return entry_(_w1.name_, isCore_)
|
|
1325
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1326
|
+
const letLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.lets_, ((d_) => {
|
|
1327
|
+
return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
|
|
1328
|
+
return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
|
|
1329
|
+
return d_.at_
|
|
1330
|
+
}))
|
|
1331
|
+
}))
|
|
1332
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1333
|
+
const functions_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.functions_, ((_w1) => {
|
|
1334
|
+
return entry_(_w1.signature_.name_, isCore_)
|
|
1335
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1336
|
+
const functionLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.functions_, ((d_) => {
|
|
1337
|
+
return ff_core_List.List_map(entry_(d_.signature_.name_, true), ((_w1) => {
|
|
1338
|
+
return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
|
|
1339
|
+
return d_.at_
|
|
1340
|
+
}))
|
|
1341
|
+
}))
|
|
1342
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1343
|
+
const traitMethods_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
|
|
1344
|
+
return _w1.methods_
|
|
1345
|
+
})), ((_w1) => {
|
|
1346
|
+
return entry_(_w1.name_, false)
|
|
1347
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1348
|
+
const traitMethodLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
|
|
1349
|
+
return _w1.methods_
|
|
1350
|
+
})), ((d_) => {
|
|
1351
|
+
return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
|
|
1352
|
+
return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
|
|
1353
|
+
return d_.at_
|
|
1354
|
+
}))
|
|
1355
|
+
}))
|
|
1356
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1357
|
+
const traits_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.traits_, ((_w1) => {
|
|
1358
|
+
return entry_(_w1.name_, true)
|
|
1359
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1360
|
+
const traitLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.traits_, ((d_) => {
|
|
1361
|
+
return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
|
|
1362
|
+
return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
|
|
1363
|
+
return d_.at_
|
|
1364
|
+
}))
|
|
1365
|
+
}))
|
|
1366
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1367
|
+
const types_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((_w1) => {
|
|
1368
|
+
return entry_(_w1.name_, true)
|
|
1369
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1370
|
+
const typeGenerics_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((d_) => {
|
|
1371
|
+
return ff_core_List.List_map(entry_(d_.name_, true), ((p_) => {
|
|
1372
|
+
return ff_core_Pair.Pair(p_.first_, d_.generics_)
|
|
1373
|
+
}))
|
|
1374
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1375
|
+
const typeLocations_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(module_.types_, ((d_) => {
|
|
1376
|
+
return ff_core_List.List_map(entry_(d_.name_, true), ((_w1) => {
|
|
1377
|
+
return ff_core_Pair.Pair_mapSecond(_w1, ((_) => {
|
|
1378
|
+
return d_.at_
|
|
1379
|
+
}))
|
|
1380
|
+
}))
|
|
1381
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1382
|
+
const asyncTypes_ = ff_core_List.List_toSet(ff_core_List.List_flatMap(ff_core_List.List_filter(module_.types_, ((_w1) => {
|
|
1383
|
+
return ff_core_Option.Option_any(ff_core_List.List_first(_w1.generics_), ((_w1) => {
|
|
1384
|
+
return (_w1 === "Q$")
|
|
1385
|
+
}))
|
|
1386
|
+
})), ((_w1) => {
|
|
1387
|
+
return ff_core_List.List_map(entry_(_w1.name_, true), ((_w1) => {
|
|
1388
|
+
return _w1.first_
|
|
1389
|
+
}))
|
|
1390
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1391
|
+
const variants_ = ff_core_List.List_toMap(ff_core_List.List_flatMap(ff_core_List.List_flatMap(module_.types_, ((_w1) => {
|
|
1392
|
+
return _w1.variants_
|
|
1393
|
+
})), ((_w1) => {
|
|
1394
|
+
return entry_(_w1.name_, true)
|
|
1395
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1396
|
+
{
|
|
1397
|
+
const _1 = self_;
|
|
1398
|
+
{
|
|
1399
|
+
const _c = _1;
|
|
1400
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(self_.variables_, lets_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), functions_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), traitMethods_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(ff_core_Map.Map_addAll(self_.variableLocations_, letLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), functionLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), traitMethodLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variants_, variants_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.types_, types_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.typeGenerics_, typeGenerics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.typeLocations_, typeLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.asyncTypes_, asyncTypes_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet(ff_core_List.Empty(), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.traits_, traits_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.traitLocations_, traitLocations_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), self_.state_, _c.lspHook_)
|
|
1401
|
+
return
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
export async function Resolver_resolveTypeDefinition$(self_, definition_, $task) {
|
|
1407
|
+
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_)) {
|
|
1408
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
|
|
1409
|
+
};
|
|
1410
|
+
const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
|
|
1411
|
+
return ff_core_Pair.Pair(g_, g_)
|
|
1412
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1413
|
+
const self2_ = (((_c) => {
|
|
1414
|
+
return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
1415
|
+
}))(self_);
|
|
1416
|
+
if((!ff_core_Option.Option_any(ff_core_List.List_first(definition_.generics_), ((_w1) => {
|
|
1417
|
+
return (_w1 === "Q$")
|
|
1418
|
+
})))) {
|
|
1419
|
+
ff_core_List.List_each(ff_core_List.List_addAll(definition_.commonFields_, ff_core_List.List_flatMap(definition_.variants_, ((_w1) => {
|
|
1420
|
+
return _w1.fields_
|
|
1421
|
+
}))), ((f_) => {
|
|
1422
|
+
if(ff_compiler_Resolver.Resolver_containsAsyncType(self2_, f_.valueType_)) {
|
|
1423
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(f_.at_, "Only capabilities can contain fields of concrete capability types"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1424
|
+
}
|
|
1425
|
+
}))
|
|
1426
|
+
};
|
|
1427
|
+
{
|
|
1428
|
+
const _1 = definition_;
|
|
1429
|
+
{
|
|
1430
|
+
const _c = _1;
|
|
1431
|
+
return ff_compiler_Syntax.DType(_c.at_, _c.newtype_, _c.data_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
|
|
1432
|
+
return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
|
|
1433
|
+
})), ff_core_List.List_map(definition_.commonFields_, ((f_) => {
|
|
1434
|
+
const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
|
|
1435
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
|
|
1436
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, true))
|
|
1437
|
+
};
|
|
1438
|
+
{
|
|
1439
|
+
const _1 = f_;
|
|
1440
|
+
{
|
|
1441
|
+
const _c = _1;
|
|
1442
|
+
return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, valueType_, ff_core_Option.Option_map(f_.default_, ((_w1) => {
|
|
1443
|
+
return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true)
|
|
1444
|
+
})))
|
|
1445
|
+
return
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
})), ff_core_List.List_map(definition_.variants_, ((v_) => {
|
|
1449
|
+
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, v_.at_)) {
|
|
1450
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(v_.name_, v_.at_, v_.at_), ff_core_Option.None()))
|
|
1451
|
+
};
|
|
1452
|
+
{
|
|
1453
|
+
const _1 = v_;
|
|
1454
|
+
{
|
|
1455
|
+
const _c = _1;
|
|
1456
|
+
return ff_compiler_Syntax.Variant(_c.at_, _c.name_, ff_core_List.List_map(v_.fields_, ((f_) => {
|
|
1457
|
+
const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
|
|
1458
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
|
|
1459
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, false))
|
|
1460
|
+
};
|
|
1461
|
+
{
|
|
1462
|
+
const _1 = f_;
|
|
1463
|
+
{
|
|
1464
|
+
const _c = _1;
|
|
1465
|
+
return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, valueType_, ff_core_Option.Option_map(f_.default_, ((_w1) => {
|
|
1466
|
+
return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true)
|
|
1467
|
+
})))
|
|
1468
|
+
return
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
})))
|
|
1472
|
+
return
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
})))
|
|
1476
|
+
return
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
export async function Resolver_resolveTraitDefinition$(self_, definition_, $task) {
|
|
1482
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, definition_.at_))) {
|
|
1483
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
|
|
1484
|
+
};
|
|
1485
|
+
const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
|
|
1486
|
+
return ff_core_Pair.Pair(g_, g_)
|
|
1487
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1488
|
+
const self2_ = (((_c) => {
|
|
1489
|
+
return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
1490
|
+
}))(self_);
|
|
1491
|
+
{
|
|
1492
|
+
const _1 = definition_;
|
|
1493
|
+
{
|
|
1494
|
+
const _c = _1;
|
|
1495
|
+
return ff_compiler_Syntax.DTrait(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
|
|
1496
|
+
return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
|
|
1497
|
+
})), _c.generatorParameters_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
|
|
1498
|
+
return ff_compiler_Resolver.Resolver_resolveSignature(self2_, _w1, true, false)
|
|
1499
|
+
})), ff_core_List.List_map(definition_.methodDefaults_, ((_1) => {
|
|
1500
|
+
{
|
|
1501
|
+
const name_ = _1.first_;
|
|
1502
|
+
const lambda_ = _1.second_;
|
|
1503
|
+
const signature_ = ff_core_Option.Option_grab(ff_core_List.List_find(definition_.methods_, ((_w1) => {
|
|
1504
|
+
return (_w1.name_ === name_)
|
|
1505
|
+
})));
|
|
1506
|
+
const function1_ = ff_compiler_Syntax.DFunction(signature_.at_, signature_, ff_compiler_Syntax.FireflyTarget(lambda_));
|
|
1507
|
+
const function2_ = ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, function1_, true, false);
|
|
1508
|
+
return ff_core_Pair.Pair(name_, (((_1) => {
|
|
1509
|
+
{
|
|
1510
|
+
if(_1.FireflyTarget) {
|
|
1511
|
+
const lambda_ = _1.lambda_;
|
|
1512
|
+
return lambda_
|
|
1513
|
+
return
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
{
|
|
1517
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(signature_.at_, "Internal error: Expected method default to be a lambda"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1518
|
+
return
|
|
1519
|
+
}
|
|
1520
|
+
}))(function2_.body_))
|
|
1521
|
+
return
|
|
1522
|
+
}
|
|
1523
|
+
})), _c.methodGenerators_)
|
|
1524
|
+
return
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
export async function Resolver_resolveInstanceDefinition$(self_, definition_, $task) {
|
|
1530
|
+
const traitDefinedAt_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traitLocations_, definition_.traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1531
|
+
return definition_.at_
|
|
1532
|
+
}));
|
|
1533
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitDefinedAt_))) {
|
|
1534
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.traitName_, definition_.at_, traitDefinedAt_), ff_core_Option.None()))
|
|
1535
|
+
};
|
|
1536
|
+
const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
|
|
1537
|
+
return ff_core_Pair.Pair(g_, g_)
|
|
1538
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1539
|
+
const self2_ = (((_c) => {
|
|
1540
|
+
return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
1541
|
+
}))(self_);
|
|
1542
|
+
const traitName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self2_.traits_, definition_.traitName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1543
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ("No such trait: " + definition_.traitName_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1544
|
+
}));
|
|
1545
|
+
{
|
|
1546
|
+
const _1 = definition_;
|
|
1547
|
+
{
|
|
1548
|
+
const _c = _1;
|
|
1549
|
+
return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
|
|
1550
|
+
return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
|
|
1551
|
+
})), traitName_, ff_core_List.List_map(definition_.typeArguments_, ((_w1) => {
|
|
1552
|
+
return ff_compiler_Resolver.Resolver_resolveType(self2_, _w1, true)
|
|
1553
|
+
})), _c.generatorArguments_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
|
|
1554
|
+
return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, _w1, true, true)
|
|
1555
|
+
})), _c.derived_)
|
|
1556
|
+
return
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
export async function Resolver_resolveExtendDefinition$(self_, definition_, $task) {
|
|
1562
|
+
const generics_ = ff_core_List.List_toMap(ff_core_List.List_map(definition_.generics_, ((g_) => {
|
|
1563
|
+
return ff_core_Pair.Pair(g_, g_)
|
|
1564
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1565
|
+
const selfWithNoQ_ = (((_c) => {
|
|
1566
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_add(self_.variables_, definition_.name_, definition_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_add(self_.variableLocations_, definition_.name_, definition_.at_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, ff_core_Map.Map_addAll(self_.types_, generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(definition_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
1567
|
+
}))(self_);
|
|
1568
|
+
const selfWithQ_ = (((_c) => {
|
|
1569
|
+
return ff_compiler_Resolver.Resolver(_c.variables_, _c.variableLocations_, _c.variants_, ff_core_Map.Map_add(selfWithNoQ_.types_, "Q$", "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, ff_core_Set.Set_add(selfWithNoQ_.typeParameters_, "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
1570
|
+
}))(selfWithNoQ_);
|
|
1571
|
+
{
|
|
1572
|
+
const _1 = definition_;
|
|
1573
|
+
{
|
|
1574
|
+
const _c = _1;
|
|
1575
|
+
return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
|
|
1576
|
+
return ff_compiler_Resolver.Resolver_resolveConstraint(selfWithQ_, _w1, true)
|
|
1577
|
+
})), ff_compiler_Resolver.Resolver_resolveType(selfWithQ_, definition_.type_, true), ff_core_List.List_map(definition_.methods_, ((_w1) => {
|
|
1578
|
+
return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(selfWithNoQ_, _w1, true, false)
|
|
1579
|
+
})))
|
|
1580
|
+
return
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
export async function Resolver_resolveLetDefinition$(self_, definition_, topLevel_, $task) {
|
|
1586
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, definition_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, definition_.at_))) {
|
|
1587
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(definition_.name_, definition_.at_, definition_.at_), ff_core_Option.None()))
|
|
1588
|
+
};
|
|
1589
|
+
{
|
|
1590
|
+
const _1 = definition_;
|
|
1591
|
+
{
|
|
1592
|
+
const _c = _1;
|
|
1593
|
+
return ff_compiler_Syntax.DLet(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self_, definition_.variableType_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, definition_.value_, true))
|
|
1594
|
+
return
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
export async function Resolver_resolveTerm$(self_, term_, topLevel_, $task) {
|
|
1600
|
+
{
|
|
1601
|
+
const self_a = self_;
|
|
1602
|
+
const term_a = term_;
|
|
1603
|
+
const topLevel_a = topLevel_;
|
|
1604
|
+
{
|
|
1605
|
+
if(term_a.EString) {
|
|
1606
|
+
return term_
|
|
1607
|
+
return
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
{
|
|
1611
|
+
if(term_a.EChar) {
|
|
1612
|
+
return term_
|
|
1613
|
+
return
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
{
|
|
1617
|
+
if(term_a.EInt) {
|
|
1618
|
+
return term_
|
|
1619
|
+
return
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
{
|
|
1623
|
+
if(term_a.EFloat) {
|
|
1624
|
+
return term_
|
|
1625
|
+
return
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
{
|
|
1629
|
+
if(term_a.EVariable) {
|
|
1630
|
+
const e_ = term_a;
|
|
1631
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1632
|
+
const at_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variableLocations_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1633
|
+
return e_.at_
|
|
1634
|
+
}));
|
|
1635
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))) {
|
|
1636
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(e_.name_, e_.at_, at_), ff_core_Option.None()))
|
|
1637
|
+
}
|
|
1638
|
+
};
|
|
1639
|
+
return ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Map.Map_get(self_.variables_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_w1) => {
|
|
1640
|
+
{
|
|
1641
|
+
const _1 = e_;
|
|
1642
|
+
{
|
|
1643
|
+
const _c = _1;
|
|
1644
|
+
return ff_compiler_Syntax.EVariable(_c.at_, _w1)
|
|
1645
|
+
return
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
})), (() => {
|
|
1649
|
+
return term_
|
|
1650
|
+
}))
|
|
1651
|
+
return
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
{
|
|
1655
|
+
if(term_a.EList) {
|
|
1656
|
+
const at_ = term_a.at_;
|
|
1657
|
+
const t_ = term_a.elementType_;
|
|
1658
|
+
const items_ = term_a.items_;
|
|
1659
|
+
return ff_compiler_Syntax.EList(at_, ff_compiler_Resolver.Resolver_resolveType(self_, t_, topLevel_), ff_core_List.List_map(items_, ((_1) => {
|
|
1660
|
+
{
|
|
1661
|
+
const item_ = _1.first_;
|
|
1662
|
+
const spread_ = _1.second_;
|
|
1663
|
+
return ff_core_Pair.Pair(ff_compiler_Resolver.Resolver_resolveTerm(self_, item_, topLevel_), spread_)
|
|
1664
|
+
return
|
|
1665
|
+
}
|
|
1666
|
+
})))
|
|
1667
|
+
return
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
{
|
|
1671
|
+
if(term_a.EVariant) {
|
|
1672
|
+
const at_ = term_a.at_;
|
|
1673
|
+
const name_ = term_a.name_;
|
|
1674
|
+
const typeArguments_ = term_a.typeArguments_;
|
|
1675
|
+
const arguments_ = term_a.arguments_;
|
|
1676
|
+
return ff_compiler_Syntax.EVariant(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1677
|
+
return name_
|
|
1678
|
+
})), ff_core_List.List_map(typeArguments_, ((_w1) => {
|
|
1679
|
+
return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
|
|
1680
|
+
})), ff_core_Option.Option_map(arguments_, ((_w1) => {
|
|
1681
|
+
return ff_core_List.List_map(_w1, ((a_) => {
|
|
1682
|
+
{
|
|
1683
|
+
const _1 = a_;
|
|
1684
|
+
{
|
|
1685
|
+
const _c = _1;
|
|
1686
|
+
return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, a_.value_, topLevel_))
|
|
1687
|
+
return
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
}))
|
|
1691
|
+
})))
|
|
1692
|
+
return
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
{
|
|
1696
|
+
if(term_a.EVariantIs) {
|
|
1697
|
+
const at_ = term_a.at_;
|
|
1698
|
+
const name_ = term_a.name_;
|
|
1699
|
+
const typeArguments_ = term_a.typeArguments_;
|
|
1700
|
+
return ff_compiler_Syntax.EVariantIs(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1701
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variant: " + name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1702
|
+
})), ff_core_List.List_map(typeArguments_, ((_w1) => {
|
|
1703
|
+
return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
|
|
1704
|
+
})))
|
|
1705
|
+
return
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
{
|
|
1709
|
+
if(term_a.ECopy) {
|
|
1710
|
+
const at_ = term_a.at_;
|
|
1711
|
+
const name_ = term_a.name_;
|
|
1712
|
+
const record_ = term_a.record_;
|
|
1713
|
+
const arguments_ = term_a.arguments_;
|
|
1714
|
+
return ff_compiler_Syntax.ECopy(at_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1715
|
+
return name_
|
|
1716
|
+
})), ff_compiler_Resolver.Resolver_resolveTerm(self_, record_, topLevel_), ff_core_List.List_map(arguments_, ((f_) => {
|
|
1717
|
+
{
|
|
1718
|
+
const _1 = f_;
|
|
1719
|
+
{
|
|
1720
|
+
const _c = _1;
|
|
1721
|
+
return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, f_.value_, topLevel_))
|
|
1722
|
+
return
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
})))
|
|
1726
|
+
return
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
{
|
|
1730
|
+
if(term_a.EField) {
|
|
1731
|
+
const e_ = term_a;
|
|
1732
|
+
{
|
|
1733
|
+
const _1 = e_;
|
|
1734
|
+
{
|
|
1735
|
+
const _c = _1;
|
|
1736
|
+
return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, ff_compiler_Resolver.Resolver_resolveTerm(self_, e_.record_, topLevel_), _c.field_)
|
|
1737
|
+
return
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
return
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
{
|
|
1744
|
+
if(term_a.ELambda) {
|
|
1745
|
+
const at_ = term_a.at_;
|
|
1746
|
+
const lambdaAt_ = term_a.lambda_.at_;
|
|
1747
|
+
const cases_ = term_a.lambda_.cases_;
|
|
1748
|
+
const effect_ = ff_compiler_Resolver.Resolver_makeEffectArgument(self_, lambdaAt_, topLevel_);
|
|
1749
|
+
return ff_compiler_Syntax.ELambda(at_, ff_compiler_Syntax.Lambda(lambdaAt_, effect_, ff_core_List.List_map(cases_, ((_w1) => {
|
|
1750
|
+
return ff_compiler_Resolver.Resolver_resolveCase(self_, _w1, topLevel_)
|
|
1751
|
+
}))))
|
|
1752
|
+
return
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
{
|
|
1756
|
+
if(term_a.EPipe) {
|
|
1757
|
+
const at_ = term_a.at_;
|
|
1758
|
+
const value_ = term_a.value_;
|
|
1759
|
+
const effect_ = term_a.effect_;
|
|
1760
|
+
const function_ = term_a.function_;
|
|
1761
|
+
return ff_compiler_Syntax.EPipe(at_, ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_), ff_compiler_Resolver.Resolver_resolveType(self_, effect_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, function_, topLevel_))
|
|
1762
|
+
return
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
{
|
|
1766
|
+
if(term_a.ECall) {
|
|
1767
|
+
const at_ = term_a.at_;
|
|
1768
|
+
if(term_a.target_.DynamicCall) {
|
|
1769
|
+
const target_ = term_a.target_;
|
|
1770
|
+
const effect_ = term_a.effect_;
|
|
1771
|
+
const typeArguments_ = term_a.typeArguments_;
|
|
1772
|
+
const arguments_ = term_a.arguments_;
|
|
1773
|
+
const dictionaries_ = term_a.dictionaries_;
|
|
1774
|
+
return ff_compiler_Syntax.ECall(at_, (((_c) => {
|
|
1775
|
+
return ff_compiler_Syntax.DynamicCall(ff_compiler_Resolver.Resolver_resolveTerm(self_, target_.function_, topLevel_), _c.tailCall_)
|
|
1776
|
+
}))(target_), ff_compiler_Resolver.Resolver_resolveType(self_, effect_, topLevel_), ff_core_List.List_map(typeArguments_, ((_w1) => {
|
|
1777
|
+
return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
|
|
1778
|
+
})), ff_core_List.List_map(arguments_, ((a_) => {
|
|
1779
|
+
{
|
|
1780
|
+
const _1 = a_;
|
|
1781
|
+
{
|
|
1782
|
+
const _c = _1;
|
|
1783
|
+
return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, a_.value_, topLevel_))
|
|
1784
|
+
return
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
})), dictionaries_)
|
|
1788
|
+
return
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
{
|
|
1793
|
+
if(term_a.ECall) {
|
|
1794
|
+
const at_ = term_a.at_;
|
|
1795
|
+
if(term_a.target_.StaticCall) {
|
|
1796
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Internal error: Static calls not expected in the Resolver phase"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1797
|
+
return
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
{
|
|
1802
|
+
if(term_a.ERecord) {
|
|
1803
|
+
const at_ = term_a.at_;
|
|
1804
|
+
const fields_ = term_a.fields_;
|
|
1805
|
+
return ff_compiler_Syntax.ERecord(at_, ff_core_List.List_map(fields_, ((f_) => {
|
|
1806
|
+
{
|
|
1807
|
+
const _1 = f_;
|
|
1808
|
+
{
|
|
1809
|
+
const _c = _1;
|
|
1810
|
+
return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Resolver.Resolver_resolveTerm(self_, f_.value_, topLevel_))
|
|
1811
|
+
return
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
})))
|
|
1815
|
+
return
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
{
|
|
1819
|
+
if(term_a.EWildcard) {
|
|
1820
|
+
const e_ = term_a;
|
|
1821
|
+
if((e_.index_ === 0)) {
|
|
1822
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Unbound wildcard"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1823
|
+
};
|
|
1824
|
+
{
|
|
1825
|
+
const _1 = e_;
|
|
1826
|
+
{
|
|
1827
|
+
const _c = _1;
|
|
1828
|
+
return ff_compiler_Syntax.EWildcard(_c.at_, _c.index_)
|
|
1829
|
+
return
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
return
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
{
|
|
1836
|
+
if(term_a.EFunctions) {
|
|
1837
|
+
const at_ = term_a.at_;
|
|
1838
|
+
const functions_ = term_a.functions_;
|
|
1839
|
+
const body_ = term_a.body_;
|
|
1840
|
+
const functionMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(functions_, ((_w1) => {
|
|
1841
|
+
return _w1.signature_.name_
|
|
1842
|
+
})), ((name_) => {
|
|
1843
|
+
return ff_core_Pair.Pair(name_, name_)
|
|
1844
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1845
|
+
const locationMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(functions_, ((_w1) => {
|
|
1846
|
+
return _w1.signature_
|
|
1847
|
+
})), ((s_) => {
|
|
1848
|
+
return ff_core_Pair.Pair(s_.name_, s_.at_)
|
|
1849
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
1850
|
+
const self2_ = (((_c) => {
|
|
1851
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, functionMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, locationMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
1852
|
+
}))(self_);
|
|
1853
|
+
return ff_compiler_Syntax.EFunctions(at_, ff_core_List.List_map(functions_, ((_w1) => {
|
|
1854
|
+
return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self2_, _w1, topLevel_, false)
|
|
1855
|
+
})), ff_compiler_Resolver.Resolver_resolveTerm(self2_, body_, topLevel_))
|
|
1856
|
+
return
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
{
|
|
1860
|
+
if(term_a.ELet) {
|
|
1861
|
+
const e_ = term_a;
|
|
1862
|
+
const self2_ = (((_c) => {
|
|
1863
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_add(self_.variables_, e_.name_, e_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_add(self_.variableLocations_, e_.name_, e_.at_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
1864
|
+
}))(self_);
|
|
1865
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1866
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, e_.at_))) {
|
|
1867
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(e_.name_, e_.at_, e_.at_), ff_core_Option.None()))
|
|
1868
|
+
}
|
|
1869
|
+
};
|
|
1870
|
+
{
|
|
1871
|
+
const _1 = e_;
|
|
1872
|
+
{
|
|
1873
|
+
const _c = _1;
|
|
1874
|
+
return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self_, e_.valueType_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, e_.value_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self2_, e_.body_, topLevel_))
|
|
1875
|
+
return
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
return
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
{
|
|
1882
|
+
if(term_a.ESequential) {
|
|
1883
|
+
const at_ = term_a.at_;
|
|
1884
|
+
const before_ = term_a.before_;
|
|
1885
|
+
const after_ = term_a.after_;
|
|
1886
|
+
return ff_compiler_Syntax.ESequential(at_, ff_compiler_Resolver.Resolver_resolveTerm(self_, before_, topLevel_), ff_compiler_Resolver.Resolver_resolveTerm(self_, after_, topLevel_))
|
|
1887
|
+
return
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
{
|
|
1891
|
+
if(term_a.EAssign) {
|
|
1892
|
+
const at_ = term_a.at_;
|
|
1893
|
+
const operator_ = term_a.operator_;
|
|
1894
|
+
const variable_ = term_a.variable_;
|
|
1895
|
+
const value_ = term_a.value_;
|
|
1896
|
+
return ff_compiler_Syntax.EAssign(at_, operator_, ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variables_, variable_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1897
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("No such variable: " + variable_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1898
|
+
})), ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_))
|
|
1899
|
+
return
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
{
|
|
1903
|
+
if(term_a.EAssignField) {
|
|
1904
|
+
const at_ = term_a.at_;
|
|
1905
|
+
const operator_ = term_a.operator_;
|
|
1906
|
+
const record_ = term_a.record_;
|
|
1907
|
+
const field_ = term_a.field_;
|
|
1908
|
+
const value_ = term_a.value_;
|
|
1909
|
+
return ff_compiler_Syntax.EAssignField(at_, operator_, ff_compiler_Resolver.Resolver_resolveTerm(self_, record_, topLevel_), field_, ff_compiler_Resolver.Resolver_resolveTerm(self_, value_, topLevel_))
|
|
1910
|
+
return
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
export async function Resolver_resolveType$(self_, type_, topLevel_, $task) {
|
|
1917
|
+
{
|
|
1918
|
+
const self_a = self_;
|
|
1919
|
+
const type_a = type_;
|
|
1920
|
+
const topLevel_a = topLevel_;
|
|
1921
|
+
{
|
|
1922
|
+
if(type_a.TVariable) {
|
|
1923
|
+
return type_
|
|
1924
|
+
return
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
{
|
|
1928
|
+
if(type_a.TConstructor) {
|
|
1929
|
+
const constructor_ = type_a;
|
|
1930
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1931
|
+
const at_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.typeLocations_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1932
|
+
return type_.at_
|
|
1933
|
+
}));
|
|
1934
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, type_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))) {
|
|
1935
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveTypeHook(self_.types_, self_.typeGenerics_, ff_compiler_LspHook.SymbolHook(constructor_.name_, type_.at_, at_), type_))
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
const name_ = (ff_core_String.String_contains(constructor_.name_, "$")
|
|
1939
|
+
? constructor_.name_
|
|
1940
|
+
: ff_core_Option.Option_else(ff_core_Map.Map_get(self_.types_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1941
|
+
if((!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_))) {
|
|
1942
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constructor_.at_, ("No such type: " + constructor_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1943
|
+
} else {
|
|
1944
|
+
return constructor_.name_
|
|
1945
|
+
}
|
|
1946
|
+
})));
|
|
1947
|
+
const isFunctionType_ = ff_core_String.String_startsWith(name_, "Function$", 0);
|
|
1948
|
+
const effect_ = ((isFunctionType_ || ff_core_Set.Set_contains(self_.asyncTypes_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))
|
|
1949
|
+
? ff_core_List.Link(ff_compiler_Resolver.Resolver_makeEffectArgument(self_, constructor_.at_, topLevel_), ff_core_List.Empty())
|
|
1950
|
+
: ff_core_List.Empty());
|
|
1951
|
+
const generics_ = ff_core_List.List_map(constructor_.generics_, ((_w1) => {
|
|
1952
|
+
return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
|
|
1953
|
+
}));
|
|
1954
|
+
if(isFunctionType_) {
|
|
1955
|
+
const arguments_ = ff_core_List.List_dropLast(generics_, 1);
|
|
1956
|
+
const returnType_ = ff_core_List.List_grabLast(generics_);
|
|
1957
|
+
{
|
|
1958
|
+
const _1 = constructor_;
|
|
1959
|
+
{
|
|
1960
|
+
const _c = _1;
|
|
1961
|
+
return ff_compiler_Syntax.TConstructor(_c.at_, name_, ff_core_List.List_addAll(effect_, ff_core_List.List_addAll(arguments_, ff_core_List.Link(returnType_, ff_core_List.Empty()))))
|
|
1962
|
+
return
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
} else {
|
|
1966
|
+
{
|
|
1967
|
+
const _1 = constructor_;
|
|
1968
|
+
{
|
|
1969
|
+
const _c = _1;
|
|
1970
|
+
return ff_compiler_Syntax.TConstructor(_c.at_, name_, ff_core_List.List_addAll(effect_, generics_))
|
|
1971
|
+
return
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
return
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
export async function Resolver_makeEffectArgument$(self_, at_, topLevel_, $task) {
|
|
1982
|
+
if(topLevel_) {
|
|
1983
|
+
if((!ff_core_Set.Set_contains(self_.typeParameters_, "Q$", ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String))) {
|
|
1984
|
+
return ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", ff_core_List.Empty())
|
|
1985
|
+
} else {
|
|
1986
|
+
return ff_compiler_Syntax.TConstructor(at_, "Q$", ff_core_List.Empty())
|
|
1987
|
+
}
|
|
1988
|
+
} else {
|
|
1989
|
+
return ff_compiler_Resolver.Resolver_freshUnificationVariable(self_, at_)
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
export async function Resolver_resolveConstraint$(self_, constraint_, topLevel_, $task) {
|
|
1994
|
+
const traitDefinedAt_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traitLocations_, constraint_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
1995
|
+
return constraint_.at_
|
|
1996
|
+
}));
|
|
1997
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, constraint_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitDefinedAt_))) {
|
|
1998
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveConstraintHook(ff_compiler_LspHook.SymbolHook(constraint_.name_, constraint_.at_, traitDefinedAt_), constraint_))
|
|
1999
|
+
};
|
|
2000
|
+
const name_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.traits_, constraint_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
2001
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constraint_.at_, ("No such trait: " + constraint_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2002
|
+
}));
|
|
2003
|
+
{
|
|
2004
|
+
const _1 = constraint_;
|
|
2005
|
+
{
|
|
2006
|
+
const _c = _1;
|
|
2007
|
+
return ff_compiler_Syntax.Constraint(_c.at_, name_, ff_core_List.List_map(constraint_.generics_, ((_w1) => {
|
|
2008
|
+
return ff_compiler_Resolver.Resolver_resolveType(self_, _w1, topLevel_)
|
|
2009
|
+
})))
|
|
2010
|
+
return
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
export async function Resolver_resolveFunctionDefinition$(self_, definition_, topLevel_, isInstanceMethod_, $task) {
|
|
2016
|
+
const signature_ = ff_compiler_Resolver.Resolver_resolveSignature(self_, definition_.signature_, topLevel_, isInstanceMethod_);
|
|
2017
|
+
const self2_ = ff_compiler_Resolver.Resolver_withSignature(self_, signature_);
|
|
2018
|
+
const body_ = ff_compiler_Syntax.Target_mapFirefly(definition_.body_, ((lambda_) => {
|
|
2019
|
+
{
|
|
2020
|
+
const _1 = lambda_;
|
|
2021
|
+
{
|
|
2022
|
+
const _c = _1;
|
|
2023
|
+
return ff_compiler_Syntax.Lambda(_c.at_, signature_.effect_, ff_core_List.List_map(lambda_.cases_, ((_w1) => {
|
|
2024
|
+
return ff_compiler_Resolver.Resolver_resolveCase(self2_, _w1, false)
|
|
2025
|
+
})))
|
|
2026
|
+
return
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
}));
|
|
2030
|
+
return ff_compiler_Syntax.DFunction(definition_.at_, signature_, body_)
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
export async function Resolver_resolveSignature$(self_, signature_, topLevel_, isInstanceMethod_, $task) {
|
|
2034
|
+
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, signature_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, signature_.at_))) {
|
|
2035
|
+
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSignatureHook(signature_, isInstanceMethod_))
|
|
2036
|
+
};
|
|
2037
|
+
const newSignature_ = (topLevel_
|
|
2038
|
+
? (((_c) => {
|
|
2039
|
+
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, ff_core_List.Link("Q$", signature_.generics_), _c.constraints_, _c.parameters_, _c.returnType_, ff_compiler_Syntax.TConstructor(signature_.at_, "Q$", ff_core_List.Empty()))
|
|
2040
|
+
}))(signature_)
|
|
2041
|
+
: (((_c) => {
|
|
2042
|
+
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, _c.constraints_, _c.parameters_, _c.returnType_, ff_compiler_Resolver.Resolver_freshUnificationVariable(self_, signature_.at_))
|
|
2043
|
+
}))(signature_));
|
|
2044
|
+
ff_core_Option.Option_each(ff_core_List.List_find(newSignature_.generics_, ((name_) => {
|
|
2045
|
+
return ff_core_Set.Set_contains(self_.typeParameters_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2046
|
+
})), ((name_) => {
|
|
2047
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(signature_.at_, (("Type parameter " + name_) + " is already in scope")), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2048
|
+
}));
|
|
2049
|
+
const self2_ = ff_compiler_Resolver.Resolver_withSignature(self_, newSignature_);
|
|
2050
|
+
{
|
|
2051
|
+
const _1 = newSignature_;
|
|
2052
|
+
{
|
|
2053
|
+
const _c = _1;
|
|
2054
|
+
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, ff_core_List.List_map(newSignature_.constraints_, ((_w1) => {
|
|
2055
|
+
return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, topLevel_)
|
|
2056
|
+
})), ff_core_List.List_map(newSignature_.parameters_, ((p_) => {
|
|
2057
|
+
{
|
|
2058
|
+
const _1 = p_;
|
|
2059
|
+
{
|
|
2060
|
+
const _c = _1;
|
|
2061
|
+
return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_Resolver.Resolver_resolveType(self2_, p_.valueType_, topLevel_), ff_core_Option.Option_map(p_.default_, ((_w1) => {
|
|
2062
|
+
return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, topLevel_)
|
|
2063
|
+
})))
|
|
2064
|
+
return
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
})), ff_compiler_Resolver.Resolver_resolveType(self2_, newSignature_.returnType_, topLevel_), _c.effect_)
|
|
2068
|
+
return
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
export async function Resolver_withSignature$(self_, signature_, $task) {
|
|
2074
|
+
const variableMap_ = ff_core_List.List_toMap(ff_core_List.List_map(ff_core_List.List_map(signature_.parameters_, ((_w1) => {
|
|
2075
|
+
return _w1.name_
|
|
2076
|
+
})), ((name_) => {
|
|
2077
|
+
return ff_core_Pair.Pair(name_, name_)
|
|
2078
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
2079
|
+
const variableLocationMap_ = ff_core_List.List_toMap(ff_core_List.List_map(signature_.parameters_, ((p_) => {
|
|
2080
|
+
return ff_core_Pair.Pair(p_.name_, p_.at_)
|
|
2081
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
2082
|
+
const typeMap_ = ff_core_List.List_toMap(ff_core_List.List_map(signature_.generics_, ((name_) => {
|
|
2083
|
+
return ff_core_Pair.Pair(name_, name_)
|
|
2084
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
2085
|
+
{
|
|
2086
|
+
const _1 = self_;
|
|
2087
|
+
{
|
|
2088
|
+
const _c = _1;
|
|
2089
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, variableMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, variableLocationMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, ff_core_Map.Map_addAll(self_.types_, typeMap_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.typeGenerics_, _c.typeLocations_, ff_core_Set.Set_removeAll(self_.asyncTypes_, ff_core_List.List_toSet(signature_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Set.Set_addAll(self_.typeParameters_, ff_core_List.List_toSet(signature_.generics_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
2090
|
+
return
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
export async function Resolver_resolveCase$(self_, case_, topLevel_, $task) {
|
|
2096
|
+
function findVariables_(pattern_) {
|
|
2097
|
+
{
|
|
2098
|
+
const pattern_a = pattern_;
|
|
2099
|
+
{
|
|
2100
|
+
if(pattern_a.PString) {
|
|
2101
|
+
return ff_core_Map.empty_()
|
|
2102
|
+
return
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
{
|
|
2106
|
+
if(pattern_a.PInt) {
|
|
2107
|
+
return ff_core_Map.empty_()
|
|
2108
|
+
return
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
{
|
|
2112
|
+
if(pattern_a.PChar) {
|
|
2113
|
+
return ff_core_Map.empty_()
|
|
2114
|
+
return
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
{
|
|
2118
|
+
if(pattern_a.PVariable) {
|
|
2119
|
+
const at_ = pattern_a.at_;
|
|
2120
|
+
if(pattern_a.name_.Some) {
|
|
2121
|
+
const name_ = pattern_a.name_.value_;
|
|
2122
|
+
return ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(name_, ff_core_Pair.Pair(at_, name_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2123
|
+
return
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
{
|
|
2128
|
+
if(pattern_a.PVariable) {
|
|
2129
|
+
if(pattern_a.name_.None) {
|
|
2130
|
+
return ff_core_Map.empty_()
|
|
2131
|
+
return
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
{
|
|
2136
|
+
if(pattern_a.PVariant) {
|
|
2137
|
+
const patterns_ = pattern_a.patterns_;
|
|
2138
|
+
return ff_core_List.List_foldLeft(ff_core_List.List_map(patterns_, ((pattern_) => {
|
|
2139
|
+
return findVariables_(pattern_)
|
|
2140
|
+
})), ff_core_Map.empty_(), ((_w1, _w2) => {
|
|
2141
|
+
return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2142
|
+
}))
|
|
2143
|
+
return
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
{
|
|
2147
|
+
if(pattern_a.PVariantAs) {
|
|
2148
|
+
const at_ = pattern_a.at_;
|
|
2149
|
+
const variableAt_ = pattern_a.variableAt_;
|
|
2150
|
+
const variable_ = pattern_a.variable_;
|
|
2151
|
+
return ff_core_List.List_toMap(ff_core_List.List_map(ff_core_Option.Option_toList(variable_), ((x_) => {
|
|
2152
|
+
return ff_core_Pair.Pair(x_, ff_core_Pair.Pair(variableAt_, x_))
|
|
2153
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2154
|
+
return
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
{
|
|
2158
|
+
if(pattern_a.PAlias) {
|
|
2159
|
+
const at_ = pattern_a.at_;
|
|
2160
|
+
const pattern_ = pattern_a.pattern_;
|
|
2161
|
+
const variable_ = pattern_a.variable_;
|
|
2162
|
+
return ff_core_Map.Map_addAll(ff_core_List.List_toMap(ff_core_List.Link(ff_core_Pair.Pair(variable_, ff_core_Pair.Pair(at_, variable_)), ff_core_List.Empty()), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), findVariables_(pattern_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2163
|
+
return
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
const variableMap_ = ff_core_List.List_foldLeft(ff_core_List.List_map(case_.patterns_, ((pattern_) => {
|
|
2169
|
+
return findVariables_(pattern_)
|
|
2170
|
+
})), ff_core_Map.empty_(), ((_w1, _w2) => {
|
|
2171
|
+
return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2172
|
+
}));
|
|
2173
|
+
let guards_ = ff_core_List.Empty();
|
|
2174
|
+
const variableMap2_ = ff_core_List.List_foldLeft(case_.guards_, variableMap_, ((variableMap1_, g_) => {
|
|
2175
|
+
const self2_ = (((_c) => {
|
|
2176
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, ff_core_Map.Map_mapValues(variableMap1_, ((_, p_) => {
|
|
2177
|
+
return p_.second_
|
|
2178
|
+
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, ff_core_Map.Map_mapValues(variableMap1_, ((_, p_) => {
|
|
2179
|
+
return p_.first_
|
|
2180
|
+
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
2181
|
+
}))(self_);
|
|
2182
|
+
const guard_ = (((_c) => {
|
|
2183
|
+
return ff_compiler_Syntax.MatchGuard(_c.at_, ff_compiler_Resolver.Resolver_resolveTerm(self2_, g_.term_, topLevel_), ff_compiler_Resolver.Resolver_resolvePattern(self2_, g_.pattern_))
|
|
2184
|
+
}))(g_);
|
|
2185
|
+
guards_ = ff_core_List.Link(guard_, guards_);
|
|
2186
|
+
return ff_core_Map.Map_addAll(variableMap1_, findVariables_(guard_.pattern_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2187
|
+
}));
|
|
2188
|
+
const self3_ = (((_c) => {
|
|
2189
|
+
return ff_compiler_Resolver.Resolver(ff_core_Map.Map_addAll(self_.variables_, ff_core_Map.Map_mapValues(variableMap2_, ((_, p_) => {
|
|
2190
|
+
return p_.second_
|
|
2191
|
+
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Map.Map_addAll(self_.variableLocations_, ff_core_Map.Map_mapValues(variableMap2_, ((_, p_) => {
|
|
2192
|
+
return p_.first_
|
|
2193
|
+
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.variants_, _c.types_, _c.typeGenerics_, _c.typeLocations_, _c.asyncTypes_, _c.typeParameters_, _c.traits_, _c.traitLocations_, _c.state_, _c.lspHook_)
|
|
2194
|
+
}))(self_);
|
|
2195
|
+
return ff_compiler_Syntax.MatchCase(case_.at_, ff_core_List.List_map(case_.patterns_, ((_w1) => {
|
|
2196
|
+
return ff_compiler_Resolver.Resolver_resolvePattern(self_, _w1)
|
|
2197
|
+
})), ff_core_List.List_reverse(guards_), ff_compiler_Resolver.Resolver_resolveTerm(self3_, case_.body_, topLevel_))
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
export async function Resolver_resolvePattern$(self_, pattern_, $task) {
|
|
2201
|
+
{
|
|
2202
|
+
const self_a = self_;
|
|
2203
|
+
const pattern_a = pattern_;
|
|
2204
|
+
{
|
|
2205
|
+
if(pattern_a.PString) {
|
|
2206
|
+
return pattern_
|
|
2207
|
+
return
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
{
|
|
2211
|
+
if(pattern_a.PInt) {
|
|
2212
|
+
return pattern_
|
|
2213
|
+
return
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
{
|
|
2217
|
+
if(pattern_a.PChar) {
|
|
2218
|
+
return pattern_
|
|
2219
|
+
return
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
{
|
|
2223
|
+
if(pattern_a.PVariable) {
|
|
2224
|
+
return pattern_
|
|
2225
|
+
return
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
{
|
|
2229
|
+
if(pattern_a.PVariant) {
|
|
2230
|
+
const at_ = pattern_a.at_;
|
|
2231
|
+
const name_ = pattern_a.name_;
|
|
2232
|
+
const patterns_ = pattern_a.patterns_;
|
|
2233
|
+
const newName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
2234
|
+
return name_
|
|
2235
|
+
}));
|
|
2236
|
+
const newPatterns_ = ff_core_List.List_map(patterns_, ((_w1) => {
|
|
2237
|
+
return ff_compiler_Resolver.Resolver_resolvePattern(self_, _w1)
|
|
2238
|
+
}));
|
|
2239
|
+
return ff_compiler_Syntax.PVariant(at_, newName_, newPatterns_)
|
|
2240
|
+
return
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
{
|
|
2244
|
+
if(pattern_a.PVariantAs) {
|
|
2245
|
+
const at_ = pattern_a.at_;
|
|
2246
|
+
const name_ = pattern_a.name_;
|
|
2247
|
+
const variableAt_ = pattern_a.variableAt_;
|
|
2248
|
+
const variable_ = pattern_a.variable_;
|
|
2249
|
+
const newName_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.variants_, name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
2250
|
+
return name_
|
|
2251
|
+
}));
|
|
2252
|
+
return ff_compiler_Syntax.PVariantAs(at_, newName_, variableAt_, variable_)
|
|
2253
|
+
return
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
{
|
|
2257
|
+
if(pattern_a.PAlias) {
|
|
2258
|
+
const at_ = pattern_a.at_;
|
|
2259
|
+
const pattern_ = pattern_a.pattern_;
|
|
2260
|
+
const variable_ = pattern_a.variable_;
|
|
2261
|
+
const newPattern_ = ff_compiler_Resolver.Resolver_resolvePattern(self_, pattern_);
|
|
2262
|
+
return ff_compiler_Syntax.PAlias(at_, newPattern_, variable_)
|
|
2263
|
+
return
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
export async function Resolver_containsAsyncType$(self_, type_, $task) {
|
|
2270
|
+
{
|
|
2271
|
+
const self_a = self_;
|
|
2272
|
+
const type_a = type_;
|
|
2273
|
+
{
|
|
2274
|
+
if(type_a.TVariable) {
|
|
2275
|
+
return false
|
|
2276
|
+
return
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
{
|
|
2280
|
+
if(type_a.TConstructor) {
|
|
2281
|
+
const constructor_ = type_a;
|
|
2282
|
+
const name_ = (ff_core_String.String_contains(constructor_.name_, "$")
|
|
2283
|
+
? constructor_.name_
|
|
2284
|
+
: ff_core_Option.Option_else(ff_core_Map.Map_get(self_.types_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
|
|
2285
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
2286
|
+
return constructor_.name_
|
|
2287
|
+
} else {
|
|
2288
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(constructor_.at_, ("No such type: " + constructor_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2289
|
+
}
|
|
2290
|
+
})));
|
|
2291
|
+
const isFunctionType_ = ff_core_String.String_startsWith(name_, "Function$", 0);
|
|
2292
|
+
return ((isFunctionType_ || ff_core_Set.Set_contains(self_.asyncTypes_, constructor_.name_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) || ff_core_List.List_any(constructor_.generics_, ((_w1) => {
|
|
2293
|
+
return ff_compiler_Resolver.Resolver_containsAsyncType(self_, _w1)
|
|
2294
|
+
})))
|
|
2295
|
+
return
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
|
|
2302
|
+
|
|
2303
|
+
|