firefly-compiler 0.4.6 → 0.4.8

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.
Files changed (90) hide show
  1. package/compiler/Compiler.ff +2 -0
  2. package/compiler/Deriver.ff +7 -0
  3. package/core/Array.ff +17 -4
  4. package/core/AssetSystem.ff +1 -1
  5. package/core/BrowserSystem.ff +27 -0
  6. package/core/List.ff +4 -0
  7. package/core/Lock.ff +2 -2
  8. package/core/Random.ff +148 -0
  9. package/core/SourceLocation.ff +27 -0
  10. package/core/Task.ff +3 -0
  11. package/core/WebSocket.ff +127 -0
  12. package/httpserver/HttpServer.ff +1 -1
  13. package/lux/Css.ff +648 -0
  14. package/lux/CssTest.ff +48 -0
  15. package/lux/Lux.ff +33 -18
  16. package/lux/Main.ff +4 -1
  17. package/output/js/ff/compiler/Builder.mjs +448 -444
  18. package/output/js/ff/compiler/Compiler.mjs +420 -416
  19. package/output/js/ff/compiler/Dependencies.mjs +393 -389
  20. package/output/js/ff/compiler/Deriver.mjs +1178 -1170
  21. package/output/js/ff/compiler/Dictionaries.mjs +1315 -1309
  22. package/output/js/ff/compiler/Environment.mjs +1025 -1015
  23. package/output/js/ff/compiler/Inference.mjs +4272 -4268
  24. package/output/js/ff/compiler/JsEmitter.mjs +5405 -5391
  25. package/output/js/ff/compiler/JsImporter.mjs +270 -266
  26. package/output/js/ff/compiler/LspHook.mjs +799 -793
  27. package/output/js/ff/compiler/Main.mjs +1691 -1675
  28. package/output/js/ff/compiler/Parser.mjs +4016 -4008
  29. package/output/js/ff/compiler/Patterns.mjs +935 -927
  30. package/output/js/ff/compiler/Resolver.mjs +2311 -2307
  31. package/output/js/ff/compiler/Substitution.mjs +1154 -1150
  32. package/output/js/ff/compiler/Syntax.mjs +12566 -12434
  33. package/output/js/ff/compiler/Token.mjs +3152 -3096
  34. package/output/js/ff/compiler/Tokenizer.mjs +597 -593
  35. package/output/js/ff/compiler/Unification.mjs +1762 -1752
  36. package/output/js/ff/compiler/Wildcards.mjs +612 -608
  37. package/output/js/ff/compiler/Workspace.mjs +695 -687
  38. package/output/js/ff/core/Any.mjs +147 -143
  39. package/output/js/ff/core/Array.mjs +573 -547
  40. package/output/js/ff/core/AssetSystem.mjs +278 -274
  41. package/output/js/ff/core/Atomic.mjs +158 -154
  42. package/output/js/ff/core/Bool.mjs +156 -152
  43. package/output/js/ff/core/Box.mjs +116 -112
  44. package/output/js/ff/core/BrowserSystem.mjs +181 -126
  45. package/output/js/ff/core/Buffer.mjs +399 -395
  46. package/output/js/ff/core/BuildSystem.mjs +300 -296
  47. package/output/js/ff/core/Channel.mjs +193 -189
  48. package/output/js/ff/core/Char.mjs +153 -149
  49. package/output/js/ff/core/Core.mjs +304 -300
  50. package/output/js/ff/core/Duration.mjs +120 -116
  51. package/output/js/ff/core/Equal.mjs +183 -179
  52. package/output/js/ff/core/Error.mjs +146 -142
  53. package/output/js/ff/core/FileHandle.mjs +154 -150
  54. package/output/js/ff/core/Float.mjs +229 -225
  55. package/output/js/ff/core/HttpClient.mjs +195 -191
  56. package/output/js/ff/core/Instant.mjs +113 -109
  57. package/output/js/ff/core/Int.mjs +269 -265
  58. package/output/js/ff/core/IntMap.mjs +284 -280
  59. package/output/js/ff/core/JsSystem.mjs +242 -238
  60. package/output/js/ff/core/JsValue.mjs +712 -708
  61. package/output/js/ff/core/List.mjs +2346 -2334
  62. package/output/js/ff/core/Lock.mjs +235 -231
  63. package/output/js/ff/core/Log.mjs +167 -163
  64. package/output/js/ff/core/Map.mjs +366 -362
  65. package/output/js/ff/core/NodeSystem.mjs +298 -294
  66. package/output/js/ff/core/Nothing.mjs +108 -104
  67. package/output/js/ff/core/Option.mjs +1023 -1015
  68. package/output/js/ff/core/Ordering.mjs +734 -730
  69. package/output/js/ff/core/Pair.mjs +337 -331
  70. package/output/js/ff/core/Path.mjs +549 -545
  71. package/output/js/ff/core/Random.mjs +340 -0
  72. package/output/js/ff/core/RbMap.mjs +1944 -1940
  73. package/output/js/ff/core/Serializable.mjs +432 -428
  74. package/output/js/ff/core/Set.mjs +258 -254
  75. package/output/js/ff/core/Show.mjs +209 -205
  76. package/output/js/ff/core/SourceLocation.mjs +273 -229
  77. package/output/js/ff/core/Stack.mjs +533 -529
  78. package/output/js/ff/core/Stream.mjs +1308 -1304
  79. package/output/js/ff/core/String.mjs +369 -365
  80. package/output/js/ff/core/StringMap.mjs +284 -280
  81. package/output/js/ff/core/Task.mjs +325 -319
  82. package/output/js/ff/core/Try.mjs +511 -507
  83. package/output/js/ff/core/Unit.mjs +155 -151
  84. package/output/js/ff/core/WebSocket.mjs +198 -0
  85. package/package.json +1 -1
  86. package/vscode/package.json +1 -1
  87. package/webserver/.firefly/include/package-lock.json +16 -0
  88. package/webserver/.firefly/include/package.json +5 -0
  89. package/webserver/.firefly/package.ff +2 -0
  90. package/webserver/WebServer.ff +608 -0
@@ -1,416 +1,420 @@
1
-
2
-
3
- import * as ff_compiler_Compiler from "../../ff/compiler/Compiler.mjs"
4
-
5
- import * as ff_compiler_Dependencies from "../../ff/compiler/Dependencies.mjs"
6
-
7
- import * as ff_compiler_Deriver from "../../ff/compiler/Deriver.mjs"
8
-
9
- import * as ff_compiler_Dictionaries from "../../ff/compiler/Dictionaries.mjs"
10
-
11
- import * as ff_compiler_Inference from "../../ff/compiler/Inference.mjs"
12
-
13
- import * as ff_compiler_JsEmitter from "../../ff/compiler/JsEmitter.mjs"
14
-
15
- import * as ff_compiler_LspHook from "../../ff/compiler/LspHook.mjs"
16
-
17
- import * as ff_compiler_Parser from "../../ff/compiler/Parser.mjs"
18
-
19
- import * as ff_compiler_Resolver from "../../ff/compiler/Resolver.mjs"
20
-
21
- import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
22
-
23
- import * as ff_compiler_Tokenizer from "../../ff/compiler/Tokenizer.mjs"
24
-
25
- import * as ff_core_Any from "../../ff/core/Any.mjs"
26
-
27
- import * as ff_core_Array from "../../ff/core/Array.mjs"
28
-
29
- import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
30
-
31
- import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
32
-
33
- import * as ff_core_Bool from "../../ff/core/Bool.mjs"
34
-
35
- import * as ff_core_Box from "../../ff/core/Box.mjs"
36
-
37
- import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
38
-
39
- import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
40
-
41
- import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
42
-
43
- import * as ff_core_Channel from "../../ff/core/Channel.mjs"
44
-
45
- import * as ff_core_Char from "../../ff/core/Char.mjs"
46
-
47
- import * as ff_core_Core from "../../ff/core/Core.mjs"
48
-
49
- import * as ff_core_Duration from "../../ff/core/Duration.mjs"
50
-
51
- import * as ff_core_Equal from "../../ff/core/Equal.mjs"
52
-
53
- import * as ff_core_Error from "../../ff/core/Error.mjs"
54
-
55
- import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
56
-
57
- import * as ff_core_Float from "../../ff/core/Float.mjs"
58
-
59
- import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
60
-
61
- import * as ff_core_Instant from "../../ff/core/Instant.mjs"
62
-
63
- import * as ff_core_Int from "../../ff/core/Int.mjs"
64
-
65
- import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
66
-
67
- import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
68
-
69
- import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
70
-
71
- import * as ff_core_List from "../../ff/core/List.mjs"
72
-
73
- import * as ff_core_Lock from "../../ff/core/Lock.mjs"
74
-
75
- import * as ff_core_Log from "../../ff/core/Log.mjs"
76
-
77
- import * as ff_core_Map from "../../ff/core/Map.mjs"
78
-
79
- import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
80
-
81
- import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
82
-
83
- import * as ff_core_Option from "../../ff/core/Option.mjs"
84
-
85
- import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
86
-
87
- import * as ff_core_Pair from "../../ff/core/Pair.mjs"
88
-
89
- import * as ff_core_Path from "../../ff/core/Path.mjs"
90
-
91
- import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
92
-
93
- import * as ff_core_Set from "../../ff/core/Set.mjs"
94
-
95
- import * as ff_core_Show from "../../ff/core/Show.mjs"
96
-
97
- import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
98
-
99
- import * as ff_core_Stack from "../../ff/core/Stack.mjs"
100
-
101
- import * as ff_core_Stream from "../../ff/core/Stream.mjs"
102
-
103
- import * as ff_core_String from "../../ff/core/String.mjs"
104
-
105
- import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
106
-
107
- import * as ff_core_Task from "../../ff/core/Task.mjs"
108
-
109
- import * as ff_core_Try from "../../ff/core/Try.mjs"
110
-
111
- import * as ff_core_Unit from "../../ff/core/Unit.mjs"
112
-
113
- // type Compiler
114
- export function Compiler(emitTarget_, task_, compilerModulePath_, jsOutputPath_, packagePaths_, singleFilePackages_, virtualFiles_, lspHook_, parsedModules_, resolvedModules_, derivedModules_, inferredModules_, emittedModules_, phaseDurations_, phaseDurationDelta_) {
115
- return {emitTarget_, task_, compilerModulePath_, jsOutputPath_, packagePaths_, singleFilePackages_, virtualFiles_, lspHook_, parsedModules_, resolvedModules_, derivedModules_, inferredModules_, emittedModules_, phaseDurations_, phaseDurationDelta_};
116
- }
117
-
118
- export const coreImports_ = ff_core_List.List_map(ff_core_List.Link("Any", ff_core_List.Link("Array", ff_core_List.Link("AssetSystem", ff_core_List.Link("Atomic", ff_core_List.Link("Bool", ff_core_List.Link("Box", ff_core_List.Link("BrowserSystem", ff_core_List.Link("Buffer", ff_core_List.Link("BuildSystem", ff_core_List.Link("Channel", ff_core_List.Link("Char", ff_core_List.Link("Core", ff_core_List.Link("Duration", ff_core_List.Link("Equal", ff_core_List.Link("Error", ff_core_List.Link("FileHandle", ff_core_List.Link("Float", ff_core_List.Link("HttpClient", ff_core_List.Link("Instant", ff_core_List.Link("Int", ff_core_List.Link("IntMap", ff_core_List.Link("JsValue", ff_core_List.Link("JsSystem", ff_core_List.Link("List", ff_core_List.Link("Lock", ff_core_List.Link("Log", ff_core_List.Link("Map", ff_core_List.Link("NodeSystem", ff_core_List.Link("Nothing", ff_core_List.Link("Option", ff_core_List.Link("Ordering", ff_core_List.Link("Pair", ff_core_List.Link("Path", ff_core_List.Link("Serializable", ff_core_List.Link("Set", ff_core_List.Link("Show", ff_core_List.Link("SourceLocation", ff_core_List.Link("Stack", ff_core_List.Link("Stream", ff_core_List.Link("String", ff_core_List.Link("StringMap", ff_core_List.Link("Task", ff_core_List.Link("Try", ff_core_List.Link("Unit", ff_core_List.Empty())))))))))))))))))))))))))))))))))))))))))))), ((moduleName_) => {
119
- return ff_compiler_Syntax.DImport(ff_compiler_Syntax.Location("<prelude>", 1, 1), moduleName_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_core_List.Empty(), moduleName_)
120
- }));
121
-
122
- export function make_(emitTarget_, task_, compilerModulePath_, jsOutputPath_, resolvedDependencies_, virtualFiles_, lspHook_) {
123
- return ff_compiler_Compiler.Compiler(emitTarget_, task_, compilerModulePath_, jsOutputPath_, resolvedDependencies_.packagePaths_, resolvedDependencies_.singleFilePackages_, virtualFiles_, lspHook_, ff_core_Map.empty_(), ff_core_Map.empty_(), ff_core_Map.empty_(), ff_core_Map.empty_(), ff_core_Set.empty_(), ff_core_List.Empty(), 0.0)
124
- }
125
-
126
- export function fail_(at_, message_) {
127
- return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
128
- }
129
-
130
- export async function make_$(emitTarget_, task_, compilerModulePath_, jsOutputPath_, resolvedDependencies_, virtualFiles_, lspHook_, $task) {
131
- return ff_compiler_Compiler.Compiler(emitTarget_, task_, compilerModulePath_, jsOutputPath_, resolvedDependencies_.packagePaths_, resolvedDependencies_.singleFilePackages_, virtualFiles_, lspHook_, ff_core_Map.empty_(), ff_core_Map.empty_(), ff_core_Map.empty_(), ff_core_Map.empty_(), ff_core_Set.empty_(), ff_core_List.Empty(), 0.0)
132
- }
133
-
134
- export async function fail_$(at_, message_, $task) {
135
- return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
136
- }
137
-
138
- export function Compiler_measure(self_, phase_, packagePair_, moduleName_, body_) {
139
- const start_ = (ff_core_Task.Task_elapsed(self_.task_) - self_.phaseDurationDelta_);
140
- const result_ = body_();
141
- const stop_ = (ff_core_Task.Task_elapsed(self_.task_) - self_.phaseDurationDelta_);
142
- const duration_ = (stop_ - start_);
143
- self_.phaseDurationDelta_ = (self_.phaseDurationDelta_ + duration_);
144
- const text_ = ((((phase_ + " ") + ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":")) + "/") + moduleName_);
145
- self_.phaseDurations_ = ff_core_List.Link(ff_core_Pair.Pair(text_, duration_), self_.phaseDurations_);
146
- return result_
147
- }
148
-
149
- export function Compiler_printMeasurements(self_) {
150
- const worst_ = ff_core_List.List_reverse(ff_core_List.List_takeLast(ff_core_List.List_sortBy(self_.phaseDurations_, ((_w1) => {
151
- return ((_w1.second_ + 1000000.0) + "")
152
- }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), 5));
153
- ff_core_List.List_each(worst_, ((_1) => {
154
- {
155
- const text_ = _1.first_;
156
- const duration_ = _1.second_;
157
- ff_core_Log.debug_(((text_ + ":\t") + ff_core_Duration.Duration_show(duration_, 3)))
158
- return
159
- }
160
- }))
161
- }
162
-
163
- export function Compiler_parse(self_, packagePair_, moduleName_, importedAt_) {
164
- const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
165
- return ff_core_Option.Option_else(ff_core_Map.Map_get(self_.parsedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
166
- return ff_compiler_Compiler.Compiler_measure(self_, "Parse", packagePair_, moduleName_, (() => {
167
- const packagePath_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.packagePaths_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), (() => {
168
- return ff_core_Core.panic_(("Internal error - package path missing: " + ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":")))
169
- }));
170
- const file_ = (moduleName_ + ".ff");
171
- const path_ = ff_core_Path.Path_slash(packagePath_, file_);
172
- const code_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.virtualFiles_, ff_core_Path.Path_absolute(path_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
173
- ff_core_Option.Option_each(importedAt_, ((at_) => {
174
- if((!ff_core_Path.Path_exists(path_, false, false, false))) {
175
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Imported module not found: " + packageName_) + "/") + moduleName_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
176
- }
177
- }));
178
- return ff_core_Path.Path_readText(path_)
179
- }));
180
- const completionAt_ = ((ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_) && self_.lspHook_.insertIdentifier_)
181
- ? ff_core_Option.Some(self_.lspHook_.at_)
182
- : ff_core_Option.None());
183
- const tokens_ = ff_compiler_Tokenizer.tokenize_(ff_core_Path.Path_absolute(path_), code_, completionAt_, ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_));
184
- const parser_ = ff_compiler_Parser.make_(packagePair_, file_, tokens_, ff_core_Equal.notEquals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser(), ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget), self_.lspHook_);
185
- const module_ = (ff_core_Set.Set_contains(self_.singleFilePackages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
186
- ? ff_compiler_Parser.Parser_parseModuleWithPackageInfo(parser_).module_
187
- : ff_compiler_Parser.Parser_parseModuleWithoutPackageInfo(parser_));
188
- const result_ = (((_c) => {
189
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, ff_core_List.List_addAll(ff_compiler_Compiler.coreImports_, module_.imports_), _c.types_, _c.traits_, _c.instances_, _c.extends_, _c.lets_, _c.functions_)
190
- }))(module_);
191
- self_.parsedModules_ = ff_core_Map.Map_add(self_.parsedModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
192
- return result_
193
- }))
194
- }))
195
- }
196
-
197
- export function Compiler_imports(self_, module_) {
198
- return ff_core_List.List_map(module_.imports_, ((import_) => {
199
- const newPackagePair_ = import_.package_;
200
- const newModuleName_ = (ff_core_List.List_join(ff_core_List.List_map(import_.directory_, ((_w1) => {
201
- return (_w1 + "/")
202
- })), "") + import_.file_);
203
- if((!ff_core_Map.Map_contains(self_.packagePaths_, newPackagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))) {
204
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(import_.at_, ("Missing dependency declaration for: " + ff_compiler_Syntax.PackagePair_groupName(newPackagePair_, ":"))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
205
- };
206
- return ff_compiler_Compiler.Compiler_parse(self_, newPackagePair_, newModuleName_, ff_core_Option.Some(import_.at_))
207
- }))
208
- }
209
-
210
- export function Compiler_resolve(self_, packagePair_, moduleName_) {
211
- const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
212
- return ff_core_Option.Option_else(ff_core_Map.Map_get(self_.resolvedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
213
- return ff_compiler_Compiler.Compiler_measure(self_, "Resolve", packagePair_, moduleName_, (() => {
214
- const module_ = ff_compiler_Compiler.Compiler_parse(self_, packagePair_, moduleName_, ff_core_Option.None());
215
- const otherModules_ = ff_compiler_Compiler.Compiler_imports(self_, module_);
216
- const resolver_ = ff_compiler_Resolver.make_(packagePair_, moduleName_, self_.lspHook_);
217
- const result_ = ff_compiler_Resolver.Resolver_resolveModule(resolver_, module_, otherModules_);
218
- self_.resolvedModules_ = ff_core_Map.Map_add(self_.resolvedModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
219
- return result_
220
- }))
221
- }))
222
- }
223
-
224
- export function Compiler_derive(self_, packagePair_, moduleName_) {
225
- const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
226
- return ff_core_Option.Option_else(ff_core_Map.Map_get(self_.derivedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
227
- return ff_compiler_Compiler.Compiler_measure(self_, "Derive", packagePair_, moduleName_, (() => {
228
- const module_ = ff_compiler_Compiler.Compiler_resolve(self_, packagePair_, moduleName_);
229
- const result_ = ff_compiler_Deriver.Deriver_deriveModule(ff_compiler_Deriver.make_(), module_);
230
- self_.derivedModules_ = ff_core_Map.Map_add(self_.derivedModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
231
- return result_
232
- }))
233
- }))
234
- }
235
-
236
- export function Compiler_infer(self_, packagePair_, moduleName_) {
237
- const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
238
- return ff_core_Option.Option_else(ff_core_Map.Map_get(self_.inferredModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
239
- return ff_compiler_Compiler.Compiler_measure(self_, "Infer", packagePair_, moduleName_, (() => {
240
- const module_ = ff_compiler_Compiler.Compiler_derive(self_, packagePair_, moduleName_);
241
- const otherModules_ = ff_core_List.List_map(ff_compiler_Compiler.Compiler_imports(self_, module_), ((i_) => {
242
- return ff_compiler_Compiler.Compiler_derive(self_, i_.packagePair_, ff_core_String.String_dropLast(i_.file_, ff_core_String.String_size(".ff")))
243
- }));
244
- const inference_ = ff_compiler_Inference.make_(ff_core_List.Link(module_, otherModules_), self_.lspHook_);
245
- const inferredModule_ = ff_compiler_Inference.Inference_inferModule(inference_, module_, otherModules_);
246
- const result_ = ff_compiler_Dictionaries.Dictionaries_processModule(ff_compiler_Dictionaries.make_(ff_core_List.Link(module_, otherModules_)), inferredModule_, otherModules_);
247
- self_.inferredModules_ = ff_core_Map.Map_add(self_.inferredModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
248
- return result_
249
- }))
250
- }))
251
- }
252
-
253
- export function Compiler_emit(self_, packagePair_, moduleName_, isMainModule_) {
254
- const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
255
- if(ff_core_Set.Set_contains(self_.emittedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
256
-
257
- } else {
258
- ff_compiler_Compiler.Compiler_measure(self_, "Emit", packagePair_, moduleName_, (() => {
259
- self_.emittedModules_ = ff_core_Set.Set_add(self_.emittedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
260
- const module_ = ff_compiler_Compiler.Compiler_infer(self_, packagePair_, moduleName_);
261
- const otherModules_ = ff_core_List.List_map(ff_compiler_Compiler.Compiler_imports(self_, module_), ((i_) => {
262
- const newModuleName_ = ff_core_String.String_dropLast(i_.file_, ff_core_String.String_size(".ff"));
263
- ff_compiler_Compiler.Compiler_emit(self_, i_.packagePair_, newModuleName_, false);
264
- return ff_compiler_Compiler.Compiler_infer(self_, i_.packagePair_, newModuleName_)
265
- }));
266
- const allModules_ = ff_core_List.Link(module_, otherModules_);
267
- const js_ = ff_compiler_JsEmitter.JsEmitter_emitModule(ff_compiler_JsEmitter.make_(allModules_, self_.emitTarget_, isMainModule_, self_.compilerModulePath_, packagePair_, moduleName_), packagePair_, module_);
268
- const jsPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(self_.jsOutputPath_, packagePair_.group_), packagePair_.name_);
269
- const jsFile_ = ff_core_Path.Path_slash(jsPath_, (moduleName_ + ".mjs"));
270
- ff_core_Path.Path_createDirectory(jsPath_, true);
271
- return ff_core_Path.Path_writeText(jsFile_, js_)
272
- }))
273
- }
274
- }
275
-
276
- export async function Compiler_measure$(self_, phase_, packagePair_, moduleName_, body_, $task) {
277
- const start_ = ((await ff_core_Task.Task_elapsed$(self_.task_, $task)) - self_.phaseDurationDelta_);
278
- const result_ = (await body_($task));
279
- const stop_ = ((await ff_core_Task.Task_elapsed$(self_.task_, $task)) - self_.phaseDurationDelta_);
280
- const duration_ = (stop_ - start_);
281
- self_.phaseDurationDelta_ = (self_.phaseDurationDelta_ + duration_);
282
- const text_ = ((((phase_ + " ") + ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":")) + "/") + moduleName_);
283
- self_.phaseDurations_ = ff_core_List.Link(ff_core_Pair.Pair(text_, duration_), self_.phaseDurations_);
284
- return result_
285
- }
286
-
287
- export async function Compiler_printMeasurements$(self_, $task) {
288
- const worst_ = ff_core_List.List_reverse(ff_core_List.List_takeLast(ff_core_List.List_sortBy(self_.phaseDurations_, ((_w1) => {
289
- return ((_w1.second_ + 1000000.0) + "")
290
- }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), 5));
291
- ff_core_List.List_each(worst_, ((_1) => {
292
- {
293
- const text_ = _1.first_;
294
- const duration_ = _1.second_;
295
- ff_core_Log.debug_(((text_ + ":\t") + ff_core_Duration.Duration_show(duration_, 3)))
296
- return
297
- }
298
- }))
299
- }
300
-
301
- export async function Compiler_parse$(self_, packagePair_, moduleName_, importedAt_, $task) {
302
- const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
303
- return (await ff_core_Option.Option_else$(ff_core_Map.Map_get(self_.parsedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async ($task) => {
304
- return (await ff_compiler_Compiler.Compiler_measure$(self_, "Parse", packagePair_, moduleName_, (async ($task) => {
305
- const packagePath_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.packagePaths_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), (() => {
306
- return ff_core_Core.panic_(("Internal error - package path missing: " + ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":")))
307
- }));
308
- const file_ = (moduleName_ + ".ff");
309
- const path_ = (await ff_core_Path.Path_slash$(packagePath_, file_, $task));
310
- const code_ = (await ff_core_Option.Option_else$(ff_core_Map.Map_get(self_.virtualFiles_, (await ff_core_Path.Path_absolute$(path_, $task)), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async ($task) => {
311
- (await ff_core_Option.Option_each$(importedAt_, (async (at_, $task) => {
312
- if((!(await ff_core_Path.Path_exists$(path_, false, false, false, $task)))) {
313
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Imported module not found: " + packageName_) + "/") + moduleName_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
314
- }
315
- }), $task));
316
- return (await ff_core_Path.Path_readText$(path_, $task))
317
- }), $task));
318
- const completionAt_ = ((ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_) && self_.lspHook_.insertIdentifier_)
319
- ? ff_core_Option.Some(self_.lspHook_.at_)
320
- : ff_core_Option.None());
321
- const tokens_ = ff_compiler_Tokenizer.tokenize_((await ff_core_Path.Path_absolute$(path_, $task)), code_, completionAt_, ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_));
322
- const parser_ = ff_compiler_Parser.make_(packagePair_, file_, tokens_, ff_core_Equal.notEquals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser(), ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget), self_.lspHook_);
323
- const module_ = (ff_core_Set.Set_contains(self_.singleFilePackages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
324
- ? ff_compiler_Parser.Parser_parseModuleWithPackageInfo(parser_).module_
325
- : ff_compiler_Parser.Parser_parseModuleWithoutPackageInfo(parser_));
326
- const result_ = (((_c) => {
327
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, ff_core_List.List_addAll(ff_compiler_Compiler.coreImports_, module_.imports_), _c.types_, _c.traits_, _c.instances_, _c.extends_, _c.lets_, _c.functions_)
328
- }))(module_);
329
- self_.parsedModules_ = ff_core_Map.Map_add(self_.parsedModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
330
- return result_
331
- }), $task))
332
- }), $task))
333
- }
334
-
335
- export async function Compiler_imports$(self_, module_, $task) {
336
- return (await ff_core_List.List_map$(module_.imports_, (async (import_, $task) => {
337
- const newPackagePair_ = import_.package_;
338
- const newModuleName_ = (ff_core_List.List_join(ff_core_List.List_map(import_.directory_, ((_w1) => {
339
- return (_w1 + "/")
340
- })), "") + import_.file_);
341
- if((!ff_core_Map.Map_contains(self_.packagePaths_, newPackagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))) {
342
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(import_.at_, ("Missing dependency declaration for: " + ff_compiler_Syntax.PackagePair_groupName(newPackagePair_, ":"))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
343
- };
344
- return (await ff_compiler_Compiler.Compiler_parse$(self_, newPackagePair_, newModuleName_, ff_core_Option.Some(import_.at_), $task))
345
- }), $task))
346
- }
347
-
348
- export async function Compiler_resolve$(self_, packagePair_, moduleName_, $task) {
349
- const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
350
- return (await ff_core_Option.Option_else$(ff_core_Map.Map_get(self_.resolvedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async ($task) => {
351
- return (await ff_compiler_Compiler.Compiler_measure$(self_, "Resolve", packagePair_, moduleName_, (async ($task) => {
352
- const module_ = (await ff_compiler_Compiler.Compiler_parse$(self_, packagePair_, moduleName_, ff_core_Option.None(), $task));
353
- const otherModules_ = (await ff_compiler_Compiler.Compiler_imports$(self_, module_, $task));
354
- const resolver_ = ff_compiler_Resolver.make_(packagePair_, moduleName_, self_.lspHook_);
355
- const result_ = ff_compiler_Resolver.Resolver_resolveModule(resolver_, module_, otherModules_);
356
- self_.resolvedModules_ = ff_core_Map.Map_add(self_.resolvedModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
357
- return result_
358
- }), $task))
359
- }), $task))
360
- }
361
-
362
- export async function Compiler_derive$(self_, packagePair_, moduleName_, $task) {
363
- const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
364
- return (await ff_core_Option.Option_else$(ff_core_Map.Map_get(self_.derivedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async ($task) => {
365
- return (await ff_compiler_Compiler.Compiler_measure$(self_, "Derive", packagePair_, moduleName_, (async ($task) => {
366
- const module_ = (await ff_compiler_Compiler.Compiler_resolve$(self_, packagePair_, moduleName_, $task));
367
- const result_ = ff_compiler_Deriver.Deriver_deriveModule(ff_compiler_Deriver.make_(), module_);
368
- self_.derivedModules_ = ff_core_Map.Map_add(self_.derivedModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
369
- return result_
370
- }), $task))
371
- }), $task))
372
- }
373
-
374
- export async function Compiler_infer$(self_, packagePair_, moduleName_, $task) {
375
- const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
376
- return (await ff_core_Option.Option_else$(ff_core_Map.Map_get(self_.inferredModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async ($task) => {
377
- return (await ff_compiler_Compiler.Compiler_measure$(self_, "Infer", packagePair_, moduleName_, (async ($task) => {
378
- const module_ = (await ff_compiler_Compiler.Compiler_derive$(self_, packagePair_, moduleName_, $task));
379
- const otherModules_ = (await ff_core_List.List_map$((await ff_compiler_Compiler.Compiler_imports$(self_, module_, $task)), (async (i_, $task) => {
380
- return (await ff_compiler_Compiler.Compiler_derive$(self_, i_.packagePair_, ff_core_String.String_dropLast(i_.file_, ff_core_String.String_size(".ff")), $task))
381
- }), $task));
382
- const inference_ = ff_compiler_Inference.make_(ff_core_List.Link(module_, otherModules_), self_.lspHook_);
383
- const inferredModule_ = ff_compiler_Inference.Inference_inferModule(inference_, module_, otherModules_);
384
- const result_ = ff_compiler_Dictionaries.Dictionaries_processModule(ff_compiler_Dictionaries.make_(ff_core_List.Link(module_, otherModules_)), inferredModule_, otherModules_);
385
- self_.inferredModules_ = ff_core_Map.Map_add(self_.inferredModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
386
- return result_
387
- }), $task))
388
- }), $task))
389
- }
390
-
391
- export async function Compiler_emit$(self_, packagePair_, moduleName_, isMainModule_, $task) {
392
- const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
393
- if(ff_core_Set.Set_contains(self_.emittedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
394
-
395
- } else {
396
- (await ff_compiler_Compiler.Compiler_measure$(self_, "Emit", packagePair_, moduleName_, (async ($task) => {
397
- self_.emittedModules_ = ff_core_Set.Set_add(self_.emittedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
398
- const module_ = (await ff_compiler_Compiler.Compiler_infer$(self_, packagePair_, moduleName_, $task));
399
- const otherModules_ = (await ff_core_List.List_map$((await ff_compiler_Compiler.Compiler_imports$(self_, module_, $task)), (async (i_, $task) => {
400
- const newModuleName_ = ff_core_String.String_dropLast(i_.file_, ff_core_String.String_size(".ff"));
401
- (await ff_compiler_Compiler.Compiler_emit$(self_, i_.packagePair_, newModuleName_, false, $task));
402
- return (await ff_compiler_Compiler.Compiler_infer$(self_, i_.packagePair_, newModuleName_, $task))
403
- }), $task));
404
- const allModules_ = ff_core_List.Link(module_, otherModules_);
405
- const js_ = (await ff_compiler_JsEmitter.JsEmitter_emitModule$((await ff_compiler_JsEmitter.make_$(allModules_, self_.emitTarget_, isMainModule_, self_.compilerModulePath_, packagePair_, moduleName_, $task)), packagePair_, module_, $task));
406
- const jsPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(self_.jsOutputPath_, packagePair_.group_, $task)), packagePair_.name_, $task));
407
- const jsFile_ = (await ff_core_Path.Path_slash$(jsPath_, (moduleName_ + ".mjs"), $task));
408
- (await ff_core_Path.Path_createDirectory$(jsPath_, true, $task));
409
- return (await ff_core_Path.Path_writeText$(jsFile_, js_, $task))
410
- }), $task))
411
- }
412
- }
413
-
414
-
415
-
416
-
1
+
2
+
3
+ import * as ff_compiler_Compiler from "../../ff/compiler/Compiler.mjs"
4
+
5
+ import * as ff_compiler_Dependencies from "../../ff/compiler/Dependencies.mjs"
6
+
7
+ import * as ff_compiler_Deriver from "../../ff/compiler/Deriver.mjs"
8
+
9
+ import * as ff_compiler_Dictionaries from "../../ff/compiler/Dictionaries.mjs"
10
+
11
+ import * as ff_compiler_Inference from "../../ff/compiler/Inference.mjs"
12
+
13
+ import * as ff_compiler_JsEmitter from "../../ff/compiler/JsEmitter.mjs"
14
+
15
+ import * as ff_compiler_LspHook from "../../ff/compiler/LspHook.mjs"
16
+
17
+ import * as ff_compiler_Parser from "../../ff/compiler/Parser.mjs"
18
+
19
+ import * as ff_compiler_Resolver from "../../ff/compiler/Resolver.mjs"
20
+
21
+ import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
22
+
23
+ import * as ff_compiler_Tokenizer from "../../ff/compiler/Tokenizer.mjs"
24
+
25
+ import * as ff_core_Any from "../../ff/core/Any.mjs"
26
+
27
+ import * as ff_core_Array from "../../ff/core/Array.mjs"
28
+
29
+ import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
30
+
31
+ import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
32
+
33
+ import * as ff_core_Bool from "../../ff/core/Bool.mjs"
34
+
35
+ import * as ff_core_Box from "../../ff/core/Box.mjs"
36
+
37
+ import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
38
+
39
+ import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
40
+
41
+ import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
42
+
43
+ import * as ff_core_Channel from "../../ff/core/Channel.mjs"
44
+
45
+ import * as ff_core_Char from "../../ff/core/Char.mjs"
46
+
47
+ import * as ff_core_Core from "../../ff/core/Core.mjs"
48
+
49
+ import * as ff_core_Duration from "../../ff/core/Duration.mjs"
50
+
51
+ import * as ff_core_Equal from "../../ff/core/Equal.mjs"
52
+
53
+ import * as ff_core_Error from "../../ff/core/Error.mjs"
54
+
55
+ import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
56
+
57
+ import * as ff_core_Float from "../../ff/core/Float.mjs"
58
+
59
+ import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
60
+
61
+ import * as ff_core_Instant from "../../ff/core/Instant.mjs"
62
+
63
+ import * as ff_core_Int from "../../ff/core/Int.mjs"
64
+
65
+ import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
66
+
67
+ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
68
+
69
+ import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
70
+
71
+ import * as ff_core_List from "../../ff/core/List.mjs"
72
+
73
+ import * as ff_core_Lock from "../../ff/core/Lock.mjs"
74
+
75
+ import * as ff_core_Log from "../../ff/core/Log.mjs"
76
+
77
+ import * as ff_core_Map from "../../ff/core/Map.mjs"
78
+
79
+ import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
80
+
81
+ import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
82
+
83
+ import * as ff_core_Option from "../../ff/core/Option.mjs"
84
+
85
+ import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
86
+
87
+ import * as ff_core_Pair from "../../ff/core/Pair.mjs"
88
+
89
+ import * as ff_core_Path from "../../ff/core/Path.mjs"
90
+
91
+ import * as ff_core_Random from "../../ff/core/Random.mjs"
92
+
93
+ import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
94
+
95
+ import * as ff_core_Set from "../../ff/core/Set.mjs"
96
+
97
+ import * as ff_core_Show from "../../ff/core/Show.mjs"
98
+
99
+ import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
100
+
101
+ import * as ff_core_Stack from "../../ff/core/Stack.mjs"
102
+
103
+ import * as ff_core_Stream from "../../ff/core/Stream.mjs"
104
+
105
+ import * as ff_core_String from "../../ff/core/String.mjs"
106
+
107
+ import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
108
+
109
+ import * as ff_core_Task from "../../ff/core/Task.mjs"
110
+
111
+ import * as ff_core_Try from "../../ff/core/Try.mjs"
112
+
113
+ import * as ff_core_Unit from "../../ff/core/Unit.mjs"
114
+
115
+ import * as ff_core_WebSocket from "../../ff/core/WebSocket.mjs"
116
+
117
+ // type Compiler
118
+ export function Compiler(emitTarget_, task_, compilerModulePath_, jsOutputPath_, packagePaths_, singleFilePackages_, virtualFiles_, lspHook_, parsedModules_, resolvedModules_, derivedModules_, inferredModules_, emittedModules_, phaseDurations_, phaseDurationDelta_) {
119
+ return {emitTarget_, task_, compilerModulePath_, jsOutputPath_, packagePaths_, singleFilePackages_, virtualFiles_, lspHook_, parsedModules_, resolvedModules_, derivedModules_, inferredModules_, emittedModules_, phaseDurations_, phaseDurationDelta_};
120
+ }
121
+
122
+ export const coreImports_ = ff_core_List.List_map(ff_core_List.Link("Any", ff_core_List.Link("Array", ff_core_List.Link("AssetSystem", ff_core_List.Link("Atomic", ff_core_List.Link("Bool", ff_core_List.Link("Box", ff_core_List.Link("BrowserSystem", ff_core_List.Link("Buffer", ff_core_List.Link("BuildSystem", ff_core_List.Link("Channel", ff_core_List.Link("Char", ff_core_List.Link("Core", ff_core_List.Link("Duration", ff_core_List.Link("Equal", ff_core_List.Link("Error", ff_core_List.Link("FileHandle", ff_core_List.Link("Float", ff_core_List.Link("HttpClient", ff_core_List.Link("Instant", ff_core_List.Link("Int", ff_core_List.Link("IntMap", ff_core_List.Link("JsValue", ff_core_List.Link("JsSystem", ff_core_List.Link("List", ff_core_List.Link("Lock", ff_core_List.Link("Log", ff_core_List.Link("Map", ff_core_List.Link("NodeSystem", ff_core_List.Link("Nothing", ff_core_List.Link("Option", ff_core_List.Link("Ordering", ff_core_List.Link("Pair", ff_core_List.Link("Path", ff_core_List.Link("Random", ff_core_List.Link("Serializable", ff_core_List.Link("Set", ff_core_List.Link("Show", ff_core_List.Link("SourceLocation", ff_core_List.Link("Stack", ff_core_List.Link("Stream", ff_core_List.Link("String", ff_core_List.Link("StringMap", ff_core_List.Link("Task", ff_core_List.Link("Try", ff_core_List.Link("Unit", ff_core_List.Link("WebSocket", ff_core_List.Empty())))))))))))))))))))))))))))))))))))))))))))))), ((moduleName_) => {
123
+ return ff_compiler_Syntax.DImport(ff_compiler_Syntax.Location("<prelude>", 1, 1), moduleName_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_core_List.Empty(), moduleName_)
124
+ }));
125
+
126
+ export function make_(emitTarget_, task_, compilerModulePath_, jsOutputPath_, resolvedDependencies_, virtualFiles_, lspHook_) {
127
+ return ff_compiler_Compiler.Compiler(emitTarget_, task_, compilerModulePath_, jsOutputPath_, resolvedDependencies_.packagePaths_, resolvedDependencies_.singleFilePackages_, virtualFiles_, lspHook_, ff_core_Map.empty_(), ff_core_Map.empty_(), ff_core_Map.empty_(), ff_core_Map.empty_(), ff_core_Set.empty_(), ff_core_List.Empty(), 0.0)
128
+ }
129
+
130
+ export function fail_(at_, message_) {
131
+ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
132
+ }
133
+
134
+ export async function make_$(emitTarget_, task_, compilerModulePath_, jsOutputPath_, resolvedDependencies_, virtualFiles_, lspHook_, $task) {
135
+ return ff_compiler_Compiler.Compiler(emitTarget_, task_, compilerModulePath_, jsOutputPath_, resolvedDependencies_.packagePaths_, resolvedDependencies_.singleFilePackages_, virtualFiles_, lspHook_, ff_core_Map.empty_(), ff_core_Map.empty_(), ff_core_Map.empty_(), ff_core_Map.empty_(), ff_core_Set.empty_(), ff_core_List.Empty(), 0.0)
136
+ }
137
+
138
+ export async function fail_$(at_, message_, $task) {
139
+ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
140
+ }
141
+
142
+ export function Compiler_measure(self_, phase_, packagePair_, moduleName_, body_) {
143
+ const start_ = (ff_core_Task.Task_elapsed(self_.task_) - self_.phaseDurationDelta_);
144
+ const result_ = body_();
145
+ const stop_ = (ff_core_Task.Task_elapsed(self_.task_) - self_.phaseDurationDelta_);
146
+ const duration_ = (stop_ - start_);
147
+ self_.phaseDurationDelta_ = (self_.phaseDurationDelta_ + duration_);
148
+ const text_ = ((((phase_ + " ") + ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":")) + "/") + moduleName_);
149
+ self_.phaseDurations_ = ff_core_List.Link(ff_core_Pair.Pair(text_, duration_), self_.phaseDurations_);
150
+ return result_
151
+ }
152
+
153
+ export function Compiler_printMeasurements(self_) {
154
+ const worst_ = ff_core_List.List_reverse(ff_core_List.List_takeLast(ff_core_List.List_sortBy(self_.phaseDurations_, ((_w1) => {
155
+ return ((_w1.second_ + 1000000.0) + "")
156
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), 5));
157
+ ff_core_List.List_each(worst_, ((_1) => {
158
+ {
159
+ const text_ = _1.first_;
160
+ const duration_ = _1.second_;
161
+ ff_core_Log.debug_(((text_ + ":\t") + ff_core_Duration.Duration_show(duration_, 3)))
162
+ return
163
+ }
164
+ }))
165
+ }
166
+
167
+ export function Compiler_parse(self_, packagePair_, moduleName_, importedAt_) {
168
+ const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
169
+ return ff_core_Option.Option_else(ff_core_Map.Map_get(self_.parsedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
170
+ return ff_compiler_Compiler.Compiler_measure(self_, "Parse", packagePair_, moduleName_, (() => {
171
+ const packagePath_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.packagePaths_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), (() => {
172
+ return ff_core_Core.panic_(("Internal error - package path missing: " + ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":")))
173
+ }));
174
+ const file_ = (moduleName_ + ".ff");
175
+ const path_ = ff_core_Path.Path_slash(packagePath_, file_);
176
+ const code_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.virtualFiles_, ff_core_Path.Path_absolute(path_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
177
+ ff_core_Option.Option_each(importedAt_, ((at_) => {
178
+ if((!ff_core_Path.Path_exists(path_, false, false, false))) {
179
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Imported module not found: " + packageName_) + "/") + moduleName_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
180
+ }
181
+ }));
182
+ return ff_core_Path.Path_readText(path_)
183
+ }));
184
+ const completionAt_ = ((ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_) && self_.lspHook_.insertIdentifier_)
185
+ ? ff_core_Option.Some(self_.lspHook_.at_)
186
+ : ff_core_Option.None());
187
+ const tokens_ = ff_compiler_Tokenizer.tokenize_(ff_core_Path.Path_absolute(path_), code_, completionAt_, ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_));
188
+ const parser_ = ff_compiler_Parser.make_(packagePair_, file_, tokens_, ff_core_Equal.notEquals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser(), ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget), self_.lspHook_);
189
+ const module_ = (ff_core_Set.Set_contains(self_.singleFilePackages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
190
+ ? ff_compiler_Parser.Parser_parseModuleWithPackageInfo(parser_).module_
191
+ : ff_compiler_Parser.Parser_parseModuleWithoutPackageInfo(parser_));
192
+ const result_ = (((_c) => {
193
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, ff_core_List.List_addAll(ff_compiler_Compiler.coreImports_, module_.imports_), _c.types_, _c.traits_, _c.instances_, _c.extends_, _c.lets_, _c.functions_)
194
+ }))(module_);
195
+ self_.parsedModules_ = ff_core_Map.Map_add(self_.parsedModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
196
+ return result_
197
+ }))
198
+ }))
199
+ }
200
+
201
+ export function Compiler_imports(self_, module_) {
202
+ return ff_core_List.List_map(module_.imports_, ((import_) => {
203
+ const newPackagePair_ = import_.package_;
204
+ const newModuleName_ = (ff_core_List.List_join(ff_core_List.List_map(import_.directory_, ((_w1) => {
205
+ return (_w1 + "/")
206
+ })), "") + import_.file_);
207
+ if((!ff_core_Map.Map_contains(self_.packagePaths_, newPackagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))) {
208
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(import_.at_, ("Missing dependency declaration for: " + ff_compiler_Syntax.PackagePair_groupName(newPackagePair_, ":"))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
209
+ };
210
+ return ff_compiler_Compiler.Compiler_parse(self_, newPackagePair_, newModuleName_, ff_core_Option.Some(import_.at_))
211
+ }))
212
+ }
213
+
214
+ export function Compiler_resolve(self_, packagePair_, moduleName_) {
215
+ const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
216
+ return ff_core_Option.Option_else(ff_core_Map.Map_get(self_.resolvedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
217
+ return ff_compiler_Compiler.Compiler_measure(self_, "Resolve", packagePair_, moduleName_, (() => {
218
+ const module_ = ff_compiler_Compiler.Compiler_parse(self_, packagePair_, moduleName_, ff_core_Option.None());
219
+ const otherModules_ = ff_compiler_Compiler.Compiler_imports(self_, module_);
220
+ const resolver_ = ff_compiler_Resolver.make_(packagePair_, moduleName_, self_.lspHook_);
221
+ const result_ = ff_compiler_Resolver.Resolver_resolveModule(resolver_, module_, otherModules_);
222
+ self_.resolvedModules_ = ff_core_Map.Map_add(self_.resolvedModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
223
+ return result_
224
+ }))
225
+ }))
226
+ }
227
+
228
+ export function Compiler_derive(self_, packagePair_, moduleName_) {
229
+ const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
230
+ return ff_core_Option.Option_else(ff_core_Map.Map_get(self_.derivedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
231
+ return ff_compiler_Compiler.Compiler_measure(self_, "Derive", packagePair_, moduleName_, (() => {
232
+ const module_ = ff_compiler_Compiler.Compiler_resolve(self_, packagePair_, moduleName_);
233
+ const result_ = ff_compiler_Deriver.Deriver_deriveModule(ff_compiler_Deriver.make_(), module_);
234
+ self_.derivedModules_ = ff_core_Map.Map_add(self_.derivedModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
235
+ return result_
236
+ }))
237
+ }))
238
+ }
239
+
240
+ export function Compiler_infer(self_, packagePair_, moduleName_) {
241
+ const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
242
+ return ff_core_Option.Option_else(ff_core_Map.Map_get(self_.inferredModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (() => {
243
+ return ff_compiler_Compiler.Compiler_measure(self_, "Infer", packagePair_, moduleName_, (() => {
244
+ const module_ = ff_compiler_Compiler.Compiler_derive(self_, packagePair_, moduleName_);
245
+ const otherModules_ = ff_core_List.List_map(ff_compiler_Compiler.Compiler_imports(self_, module_), ((i_) => {
246
+ return ff_compiler_Compiler.Compiler_derive(self_, i_.packagePair_, ff_core_String.String_dropLast(i_.file_, ff_core_String.String_size(".ff")))
247
+ }));
248
+ const inference_ = ff_compiler_Inference.make_(ff_core_List.Link(module_, otherModules_), self_.lspHook_);
249
+ const inferredModule_ = ff_compiler_Inference.Inference_inferModule(inference_, module_, otherModules_);
250
+ const result_ = ff_compiler_Dictionaries.Dictionaries_processModule(ff_compiler_Dictionaries.make_(ff_core_List.Link(module_, otherModules_)), inferredModule_, otherModules_);
251
+ self_.inferredModules_ = ff_core_Map.Map_add(self_.inferredModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
252
+ return result_
253
+ }))
254
+ }))
255
+ }
256
+
257
+ export function Compiler_emit(self_, packagePair_, moduleName_, isMainModule_) {
258
+ const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
259
+ if(ff_core_Set.Set_contains(self_.emittedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
260
+
261
+ } else {
262
+ ff_compiler_Compiler.Compiler_measure(self_, "Emit", packagePair_, moduleName_, (() => {
263
+ self_.emittedModules_ = ff_core_Set.Set_add(self_.emittedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
264
+ const module_ = ff_compiler_Compiler.Compiler_infer(self_, packagePair_, moduleName_);
265
+ const otherModules_ = ff_core_List.List_map(ff_compiler_Compiler.Compiler_imports(self_, module_), ((i_) => {
266
+ const newModuleName_ = ff_core_String.String_dropLast(i_.file_, ff_core_String.String_size(".ff"));
267
+ ff_compiler_Compiler.Compiler_emit(self_, i_.packagePair_, newModuleName_, false);
268
+ return ff_compiler_Compiler.Compiler_infer(self_, i_.packagePair_, newModuleName_)
269
+ }));
270
+ const allModules_ = ff_core_List.Link(module_, otherModules_);
271
+ const js_ = ff_compiler_JsEmitter.JsEmitter_emitModule(ff_compiler_JsEmitter.make_(allModules_, self_.emitTarget_, isMainModule_, self_.compilerModulePath_, packagePair_, moduleName_), packagePair_, module_);
272
+ const jsPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(self_.jsOutputPath_, packagePair_.group_), packagePair_.name_);
273
+ const jsFile_ = ff_core_Path.Path_slash(jsPath_, (moduleName_ + ".mjs"));
274
+ ff_core_Path.Path_createDirectory(jsPath_, true);
275
+ return ff_core_Path.Path_writeText(jsFile_, js_)
276
+ }))
277
+ }
278
+ }
279
+
280
+ export async function Compiler_measure$(self_, phase_, packagePair_, moduleName_, body_, $task) {
281
+ const start_ = ((await ff_core_Task.Task_elapsed$(self_.task_, $task)) - self_.phaseDurationDelta_);
282
+ const result_ = (await body_($task));
283
+ const stop_ = ((await ff_core_Task.Task_elapsed$(self_.task_, $task)) - self_.phaseDurationDelta_);
284
+ const duration_ = (stop_ - start_);
285
+ self_.phaseDurationDelta_ = (self_.phaseDurationDelta_ + duration_);
286
+ const text_ = ((((phase_ + " ") + ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":")) + "/") + moduleName_);
287
+ self_.phaseDurations_ = ff_core_List.Link(ff_core_Pair.Pair(text_, duration_), self_.phaseDurations_);
288
+ return result_
289
+ }
290
+
291
+ export async function Compiler_printMeasurements$(self_, $task) {
292
+ const worst_ = ff_core_List.List_reverse(ff_core_List.List_takeLast(ff_core_List.List_sortBy(self_.phaseDurations_, ((_w1) => {
293
+ return ((_w1.second_ + 1000000.0) + "")
294
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), 5));
295
+ ff_core_List.List_each(worst_, ((_1) => {
296
+ {
297
+ const text_ = _1.first_;
298
+ const duration_ = _1.second_;
299
+ ff_core_Log.debug_(((text_ + ":\t") + ff_core_Duration.Duration_show(duration_, 3)))
300
+ return
301
+ }
302
+ }))
303
+ }
304
+
305
+ export async function Compiler_parse$(self_, packagePair_, moduleName_, importedAt_, $task) {
306
+ const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
307
+ return (await ff_core_Option.Option_else$(ff_core_Map.Map_get(self_.parsedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async ($task) => {
308
+ return (await ff_compiler_Compiler.Compiler_measure$(self_, "Parse", packagePair_, moduleName_, (async ($task) => {
309
+ const packagePath_ = ff_core_Option.Option_else(ff_core_Map.Map_get(self_.packagePaths_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), (() => {
310
+ return ff_core_Core.panic_(("Internal error - package path missing: " + ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":")))
311
+ }));
312
+ const file_ = (moduleName_ + ".ff");
313
+ const path_ = (await ff_core_Path.Path_slash$(packagePath_, file_, $task));
314
+ const code_ = (await ff_core_Option.Option_else$(ff_core_Map.Map_get(self_.virtualFiles_, (await ff_core_Path.Path_absolute$(path_, $task)), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async ($task) => {
315
+ (await ff_core_Option.Option_each$(importedAt_, (async (at_, $task) => {
316
+ if((!(await ff_core_Path.Path_exists$(path_, false, false, false, $task)))) {
317
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ((("Imported module not found: " + packageName_) + "/") + moduleName_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
318
+ }
319
+ }), $task));
320
+ return (await ff_core_Path.Path_readText$(path_, $task))
321
+ }), $task));
322
+ const completionAt_ = ((ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_) && self_.lspHook_.insertIdentifier_)
323
+ ? ff_core_Option.Some(self_.lspHook_.at_)
324
+ : ff_core_Option.None());
325
+ const tokens_ = ff_compiler_Tokenizer.tokenize_((await ff_core_Path.Path_absolute$(path_, $task)), code_, completionAt_, ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_));
326
+ const parser_ = ff_compiler_Parser.make_(packagePair_, file_, tokens_, ff_core_Equal.notEquals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser(), ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget), self_.lspHook_);
327
+ const module_ = (ff_core_Set.Set_contains(self_.singleFilePackages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
328
+ ? ff_compiler_Parser.Parser_parseModuleWithPackageInfo(parser_).module_
329
+ : ff_compiler_Parser.Parser_parseModuleWithoutPackageInfo(parser_));
330
+ const result_ = (((_c) => {
331
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, ff_core_List.List_addAll(ff_compiler_Compiler.coreImports_, module_.imports_), _c.types_, _c.traits_, _c.instances_, _c.extends_, _c.lets_, _c.functions_)
332
+ }))(module_);
333
+ self_.parsedModules_ = ff_core_Map.Map_add(self_.parsedModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
334
+ return result_
335
+ }), $task))
336
+ }), $task))
337
+ }
338
+
339
+ export async function Compiler_imports$(self_, module_, $task) {
340
+ return (await ff_core_List.List_map$(module_.imports_, (async (import_, $task) => {
341
+ const newPackagePair_ = import_.package_;
342
+ const newModuleName_ = (ff_core_List.List_join(ff_core_List.List_map(import_.directory_, ((_w1) => {
343
+ return (_w1 + "/")
344
+ })), "") + import_.file_);
345
+ if((!ff_core_Map.Map_contains(self_.packagePaths_, newPackagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))) {
346
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(import_.at_, ("Missing dependency declaration for: " + ff_compiler_Syntax.PackagePair_groupName(newPackagePair_, ":"))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
347
+ };
348
+ return (await ff_compiler_Compiler.Compiler_parse$(self_, newPackagePair_, newModuleName_, ff_core_Option.Some(import_.at_), $task))
349
+ }), $task))
350
+ }
351
+
352
+ export async function Compiler_resolve$(self_, packagePair_, moduleName_, $task) {
353
+ const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
354
+ return (await ff_core_Option.Option_else$(ff_core_Map.Map_get(self_.resolvedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async ($task) => {
355
+ return (await ff_compiler_Compiler.Compiler_measure$(self_, "Resolve", packagePair_, moduleName_, (async ($task) => {
356
+ const module_ = (await ff_compiler_Compiler.Compiler_parse$(self_, packagePair_, moduleName_, ff_core_Option.None(), $task));
357
+ const otherModules_ = (await ff_compiler_Compiler.Compiler_imports$(self_, module_, $task));
358
+ const resolver_ = ff_compiler_Resolver.make_(packagePair_, moduleName_, self_.lspHook_);
359
+ const result_ = ff_compiler_Resolver.Resolver_resolveModule(resolver_, module_, otherModules_);
360
+ self_.resolvedModules_ = ff_core_Map.Map_add(self_.resolvedModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
361
+ return result_
362
+ }), $task))
363
+ }), $task))
364
+ }
365
+
366
+ export async function Compiler_derive$(self_, packagePair_, moduleName_, $task) {
367
+ const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
368
+ return (await ff_core_Option.Option_else$(ff_core_Map.Map_get(self_.derivedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async ($task) => {
369
+ return (await ff_compiler_Compiler.Compiler_measure$(self_, "Derive", packagePair_, moduleName_, (async ($task) => {
370
+ const module_ = (await ff_compiler_Compiler.Compiler_resolve$(self_, packagePair_, moduleName_, $task));
371
+ const result_ = ff_compiler_Deriver.Deriver_deriveModule(ff_compiler_Deriver.make_(), module_);
372
+ self_.derivedModules_ = ff_core_Map.Map_add(self_.derivedModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
373
+ return result_
374
+ }), $task))
375
+ }), $task))
376
+ }
377
+
378
+ export async function Compiler_infer$(self_, packagePair_, moduleName_, $task) {
379
+ const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
380
+ return (await ff_core_Option.Option_else$(ff_core_Map.Map_get(self_.inferredModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async ($task) => {
381
+ return (await ff_compiler_Compiler.Compiler_measure$(self_, "Infer", packagePair_, moduleName_, (async ($task) => {
382
+ const module_ = (await ff_compiler_Compiler.Compiler_derive$(self_, packagePair_, moduleName_, $task));
383
+ const otherModules_ = (await ff_core_List.List_map$((await ff_compiler_Compiler.Compiler_imports$(self_, module_, $task)), (async (i_, $task) => {
384
+ return (await ff_compiler_Compiler.Compiler_derive$(self_, i_.packagePair_, ff_core_String.String_dropLast(i_.file_, ff_core_String.String_size(".ff")), $task))
385
+ }), $task));
386
+ const inference_ = ff_compiler_Inference.make_(ff_core_List.Link(module_, otherModules_), self_.lspHook_);
387
+ const inferredModule_ = ff_compiler_Inference.Inference_inferModule(inference_, module_, otherModules_);
388
+ const result_ = ff_compiler_Dictionaries.Dictionaries_processModule(ff_compiler_Dictionaries.make_(ff_core_List.Link(module_, otherModules_)), inferredModule_, otherModules_);
389
+ self_.inferredModules_ = ff_core_Map.Map_add(self_.inferredModules_, ((packageName_ + ":") + moduleName_), result_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
390
+ return result_
391
+ }), $task))
392
+ }), $task))
393
+ }
394
+
395
+ export async function Compiler_emit$(self_, packagePair_, moduleName_, isMainModule_, $task) {
396
+ const packageName_ = ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":");
397
+ if(ff_core_Set.Set_contains(self_.emittedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
398
+
399
+ } else {
400
+ (await ff_compiler_Compiler.Compiler_measure$(self_, "Emit", packagePair_, moduleName_, (async ($task) => {
401
+ self_.emittedModules_ = ff_core_Set.Set_add(self_.emittedModules_, ((packageName_ + ":") + moduleName_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
402
+ const module_ = (await ff_compiler_Compiler.Compiler_infer$(self_, packagePair_, moduleName_, $task));
403
+ const otherModules_ = (await ff_core_List.List_map$((await ff_compiler_Compiler.Compiler_imports$(self_, module_, $task)), (async (i_, $task) => {
404
+ const newModuleName_ = ff_core_String.String_dropLast(i_.file_, ff_core_String.String_size(".ff"));
405
+ (await ff_compiler_Compiler.Compiler_emit$(self_, i_.packagePair_, newModuleName_, false, $task));
406
+ return (await ff_compiler_Compiler.Compiler_infer$(self_, i_.packagePair_, newModuleName_, $task))
407
+ }), $task));
408
+ const allModules_ = ff_core_List.Link(module_, otherModules_);
409
+ const js_ = (await ff_compiler_JsEmitter.JsEmitter_emitModule$((await ff_compiler_JsEmitter.make_$(allModules_, self_.emitTarget_, isMainModule_, self_.compilerModulePath_, packagePair_, moduleName_, $task)), packagePair_, module_, $task));
410
+ const jsPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(self_.jsOutputPath_, packagePair_.group_, $task)), packagePair_.name_, $task));
411
+ const jsFile_ = (await ff_core_Path.Path_slash$(jsPath_, (moduleName_ + ".mjs"), $task));
412
+ (await ff_core_Path.Path_createDirectory$(jsPath_, true, $task));
413
+ return (await ff_core_Path.Path_writeText$(jsFile_, js_, $task))
414
+ }), $task))
415
+ }
416
+ }
417
+
418
+
419
+
420
+