firefly-compiler 0.4.5 → 0.4.6

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 (78) hide show
  1. package/.hintrc +4 -4
  2. package/README.md +1 -1
  3. package/core/HttpClient.ff +1 -1
  4. package/lsp/LanguageServer.ff +32 -7
  5. package/lsp/stderr.txt +1 -0
  6. package/lsp/stdin.txt +11 -0
  7. package/lsp/stdout.txt +41 -0
  8. package/lux/Main.ff +56 -2
  9. package/meetup/AutoCompletion.ff +6 -0
  10. package/output/js/ff/compiler/Builder.mjs +444 -444
  11. package/output/js/ff/compiler/Compiler.mjs +416 -416
  12. package/output/js/ff/compiler/Dependencies.mjs +389 -389
  13. package/output/js/ff/compiler/Deriver.mjs +1170 -1170
  14. package/output/js/ff/compiler/Dictionaries.mjs +1309 -1309
  15. package/output/js/ff/compiler/Environment.mjs +1015 -1015
  16. package/output/js/ff/compiler/Inference.mjs +4268 -4268
  17. package/output/js/ff/compiler/JsEmitter.mjs +5391 -5391
  18. package/output/js/ff/compiler/JsImporter.mjs +266 -266
  19. package/output/js/ff/compiler/LspHook.mjs +793 -793
  20. package/output/js/ff/compiler/Main.mjs +1675 -1675
  21. package/output/js/ff/compiler/Parser.mjs +4008 -4008
  22. package/output/js/ff/compiler/Patterns.mjs +927 -927
  23. package/output/js/ff/compiler/Resolver.mjs +2307 -2307
  24. package/output/js/ff/compiler/Substitution.mjs +1150 -1150
  25. package/output/js/ff/compiler/Syntax.mjs +12434 -12434
  26. package/output/js/ff/compiler/Token.mjs +3096 -3096
  27. package/output/js/ff/compiler/Tokenizer.mjs +593 -593
  28. package/output/js/ff/compiler/Unification.mjs +1752 -1752
  29. package/output/js/ff/compiler/Wildcards.mjs +608 -608
  30. package/output/js/ff/compiler/Workspace.mjs +687 -687
  31. package/output/js/ff/core/Any.mjs +143 -143
  32. package/output/js/ff/core/Array.mjs +547 -547
  33. package/output/js/ff/core/AssetSystem.mjs +274 -274
  34. package/output/js/ff/core/Atomic.mjs +154 -154
  35. package/output/js/ff/core/Bool.mjs +152 -152
  36. package/output/js/ff/core/Box.mjs +112 -112
  37. package/output/js/ff/core/BrowserSystem.mjs +126 -126
  38. package/output/js/ff/core/Buffer.mjs +395 -395
  39. package/output/js/ff/core/BuildSystem.mjs +296 -296
  40. package/output/js/ff/core/Channel.mjs +189 -189
  41. package/output/js/ff/core/Char.mjs +149 -149
  42. package/output/js/ff/core/Core.mjs +300 -300
  43. package/output/js/ff/core/Duration.mjs +116 -116
  44. package/output/js/ff/core/Equal.mjs +179 -179
  45. package/output/js/ff/core/Error.mjs +142 -142
  46. package/output/js/ff/core/FileHandle.mjs +150 -150
  47. package/output/js/ff/core/Float.mjs +225 -225
  48. package/output/js/ff/core/HttpClient.mjs +190 -190
  49. package/output/js/ff/core/Instant.mjs +109 -109
  50. package/output/js/ff/core/Int.mjs +265 -265
  51. package/output/js/ff/core/IntMap.mjs +280 -280
  52. package/output/js/ff/core/JsSystem.mjs +238 -238
  53. package/output/js/ff/core/JsValue.mjs +708 -708
  54. package/output/js/ff/core/List.mjs +2334 -2334
  55. package/output/js/ff/core/Lock.mjs +229 -229
  56. package/output/js/ff/core/Log.mjs +163 -163
  57. package/output/js/ff/core/Map.mjs +362 -362
  58. package/output/js/ff/core/NodeSystem.mjs +294 -294
  59. package/output/js/ff/core/Nothing.mjs +104 -104
  60. package/output/js/ff/core/Option.mjs +1015 -1015
  61. package/output/js/ff/core/Ordering.mjs +730 -730
  62. package/output/js/ff/core/Pair.mjs +331 -331
  63. package/output/js/ff/core/Path.mjs +545 -545
  64. package/output/js/ff/core/RbMap.mjs +1940 -1940
  65. package/output/js/ff/core/Serializable.mjs +428 -428
  66. package/output/js/ff/core/Set.mjs +254 -254
  67. package/output/js/ff/core/Show.mjs +205 -205
  68. package/output/js/ff/core/SourceLocation.mjs +229 -229
  69. package/output/js/ff/core/Stack.mjs +529 -529
  70. package/output/js/ff/core/Stream.mjs +1304 -1304
  71. package/output/js/ff/core/String.mjs +365 -365
  72. package/output/js/ff/core/StringMap.mjs +280 -280
  73. package/output/js/ff/core/Task.mjs +320 -320
  74. package/output/js/ff/core/Try.mjs +507 -507
  75. package/output/js/ff/core/Unit.mjs +151 -151
  76. package/package.json +29 -29
  77. package/vscode/package-lock.json +5 -5
  78. package/vscode/package.json +1 -1
@@ -1,416 +1,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_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_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
+