firefly-compiler 0.5.63 → 0.5.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/Builder.ff +47 -31
- package/compiler/Compiler.ff +42 -47
- package/compiler/Dependencies.ff +9 -3
- package/compiler/Deriver.ff +2 -2
- package/compiler/Dictionaries.ff +11 -12
- package/compiler/Environment.ff +5 -5
- package/compiler/Inference.ff +1 -2
- package/compiler/JsEmitter.ff +34 -33
- package/compiler/Main.ff +32 -31
- package/compiler/ModuleCache.ff +17 -25
- package/compiler/Parser.ff +7 -11
- package/compiler/Resolver.ff +8 -11
- package/compiler/Syntax.ff +53 -17
- package/compiler/Unification.ff +2 -5
- package/core/BuildSystem.ff +1 -1
- package/core/Path.ff +11 -1
- package/core/SourceLocation.ff +4 -0
- package/experimental/foldertest/.firefly/package.ff +1 -0
- package/experimental/foldertest/Root.ff +10 -0
- package/experimental/foldertest/a/A.ff +3 -0
- package/experimental/foldertest/a/MainA.ff +3 -0
- package/experimental/tests/TestCancel.ff +19 -0
- package/fireflysite/CommunityOverview.ff +0 -2
- package/fireflysite/FrontPage.ff +0 -2
- package/fireflysite/Main.ff +1 -1
- package/fireflysite/PackagesOverview.ff +0 -2
- package/fireflysite/Router.ff +3 -3
- package/fireflysite/{ExamplesOverview.ff → demos/ExamplesOverview.ff} +3 -3
- package/fireflysite/{RouteFront.ff → routes/RouteFront.ff} +2 -3
- package/fireflysite/{RouteNonMarkdown.ff → routes/RouteNonMarkdown.ff} +5 -5
- package/fireflysite/{RouteReference.ff → routes/RouteReference.ff} +2 -3
- package/lsp/CompletionHandler.ff +2 -2
- package/lsp/Handler.ff +14 -13
- package/lsp/LanguageServer.ff +5 -4
- package/output/js/ff/compiler/Builder.mjs +118 -80
- package/output/js/ff/compiler/Compiler.mjs +85 -89
- package/output/js/ff/compiler/Dependencies.mjs +16 -10
- package/output/js/ff/compiler/Deriver.mjs +6 -6
- package/output/js/ff/compiler/Dictionaries.mjs +6 -6
- package/output/js/ff/compiler/Environment.mjs +10 -6
- package/output/js/ff/compiler/Inference.mjs +4 -4
- package/output/js/ff/compiler/JsEmitter.mjs +60 -38
- package/output/js/ff/compiler/Main.mjs +66 -56
- package/output/js/ff/compiler/ModuleCache.mjs +34 -38
- package/output/js/ff/compiler/Parser.mjs +14 -14
- package/output/js/ff/compiler/Resolver.mjs +12 -22
- package/output/js/ff/compiler/Substitution.mjs +2 -2
- package/output/js/ff/compiler/Syntax.mjs +395 -183
- package/output/js/ff/compiler/Unification.mjs +18 -32
- package/output/js/ff/core/BuildSystem.mjs +2 -6
- package/output/js/ff/core/Path.mjs +32 -0
- package/output/js/ff/core/SourceLocation.mjs +12 -0
- package/package.json +1 -1
- package/vscode/package.json +1 -1
- package/vscode/syntaxes/firefly.tmLanguage.json +299 -299
- package/fireflysite/ReferenceIntroduction.ff +0 -11
- /package/fireflysite/{CountingButtonDemo.ff → demos/CountingButtonDemo.ff} +0 -0
- /package/fireflysite/{MatchingPasswordsDemo.ff → demos/MatchingPasswordsDemo.ff} +0 -0
- /package/fireflysite/{PostgresqlDemo.ff → demos/PostgresqlDemo.ff} +0 -0
|
@@ -124,7 +124,7 @@ return {emitTarget_, task_, compilerModulePath_, jsOutputPath_, packagePaths_, s
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
export const coreImports_ = ff_core_List.List_map(["Any", "Array", "AssetSystem", "Atomic", "Bool", "BrowserSystem", "Buffer", "BuildSystem", "Channel", "Char", "Core", "Crypto", "Date", "Duration", "Equal", "Error", "FileHandle", "Float", "HttpClient", "Int", "IntMap", "Json", "JsValue", "JsSystem", "List", "Lock", "Log", "Map", "NodeSystem", "Nothing", "Option", "Ordering", "Pair", "Path", "Queue", "Random", "Serializable", "Set", "Show", "SourceLocation", "Stream", "String", "StringMap", "Task", "Try", "Unit", "Js"], ((moduleName_) => {
|
|
127
|
-
return ff_compiler_Syntax.DImport(ff_compiler_Syntax.Location("<prelude>", 1, 1), moduleName_, ff_compiler_Syntax.PackagePair("ff", "core"), [], moduleName_)
|
|
127
|
+
return ff_compiler_Syntax.DImport(ff_compiler_Syntax.Location("<prelude>", 1, 1), moduleName_, ff_compiler_Syntax.ModuleKey(ff_compiler_Syntax.PackagePair("ff", "core"), [], moduleName_))
|
|
128
128
|
}));
|
|
129
129
|
|
|
130
130
|
export function new_(emitTarget_, task_, compilerModulePath_, jsOutputPath_, resolvedDependencies_, virtualFiles_, cache_, lspHook_) {
|
|
@@ -143,13 +143,13 @@ export async function fail_$(at_, message_, $task) {
|
|
|
143
143
|
return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
export function Compiler_measure(self_, phase_,
|
|
146
|
+
export function Compiler_measure(self_, phase_, moduleKey_, body_) {
|
|
147
147
|
const start_ = (ff_core_Task.Task_elapsed(self_.task_) - self_.phaseDurationDelta_);
|
|
148
148
|
const result_ = body_();
|
|
149
149
|
const stop_ = (ff_core_Task.Task_elapsed(self_.task_) - self_.phaseDurationDelta_);
|
|
150
150
|
const duration_ = (stop_ - start_);
|
|
151
151
|
self_.phaseDurationDelta_ = (self_.phaseDurationDelta_ + duration_);
|
|
152
|
-
const text_ = ((
|
|
152
|
+
const text_ = ((phase_ + " ") + ff_compiler_Syntax.ModuleKey_qualifiedName(moduleKey_));
|
|
153
153
|
self_.phaseDurations_.array.push(ff_core_Pair.Pair(text_, duration_));
|
|
154
154
|
return result_
|
|
155
155
|
}
|
|
@@ -168,17 +168,16 @@ return
|
|
|
168
168
|
}))
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
export function Compiler_parse(self_,
|
|
172
|
-
return ff_compiler_ModuleCache.ModuleCache_cacheParsedModule(self_.cache_, self_.packagePaths_,
|
|
173
|
-
|
|
174
|
-
return ff_compiler_Compiler.Compiler_measure(self_, "Parse", packagePair_, moduleName_, (() => {
|
|
171
|
+
export function Compiler_parse(self_, moduleKey_, importedAt_) {
|
|
172
|
+
return ff_compiler_ModuleCache.ModuleCache_cacheParsedModule(self_.cache_, self_.packagePaths_, moduleKey_, ((path_) => {
|
|
173
|
+
return ff_compiler_Compiler.Compiler_measure(self_, "Parse", moduleKey_, (() => {
|
|
175
174
|
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), (() => {
|
|
176
175
|
{
|
|
177
176
|
const if_o = importedAt_
|
|
178
177
|
if(if_o.Some) {
|
|
179
178
|
const at_ = if_o.value_;
|
|
180
179
|
if((!ff_core_Path.Path_exists(path_, false, false, false))) {
|
|
181
|
-
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, (
|
|
180
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("Imported module not found: " + ff_compiler_Syntax.ModuleKey_importName(moduleKey_))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
182
181
|
}
|
|
183
182
|
}
|
|
184
183
|
};
|
|
@@ -188,12 +187,12 @@ const completionAt_ = ((ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_) &&
|
|
|
188
187
|
? ff_core_Option.Some(self_.lspHook_.at_)
|
|
189
188
|
: ff_core_Option.None());
|
|
190
189
|
const tokens_ = ff_compiler_Tokenizer.tokenize_(ff_core_Path.Path_absolute(path_), code_, completionAt_, ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_));
|
|
191
|
-
const parser_ = ff_compiler_Parser.new_(
|
|
192
|
-
const module_ = (ff_core_Set.Set_contains(self_.singleFilePackages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
|
|
190
|
+
const parser_ = ff_compiler_Parser.new_(moduleKey_, tokens_, ff_core_Equal.notEquals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser(), ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget), self_.lspHook_);
|
|
191
|
+
const module_ = (ff_core_Set.Set_contains(self_.singleFilePackages_, moduleKey_.packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
|
|
193
192
|
? ff_compiler_Parser.Parser_parseModuleWithPackageInfo(parser_).module_
|
|
194
193
|
: ff_compiler_Parser.Parser_parseModuleWithoutPackageInfo(parser_));
|
|
195
194
|
const result_ = (((_c) => {
|
|
196
|
-
return ff_compiler_Syntax.Module(_c.
|
|
195
|
+
return ff_compiler_Syntax.Module(_c.moduleKey_, [...ff_compiler_Compiler.coreImports_, ...module_.imports_], _c.types_, _c.traits_, _c.instances_, _c.extends_, _c.lets_, _c.functions_)
|
|
197
196
|
}))(module_);
|
|
198
197
|
return result_
|
|
199
198
|
}))
|
|
@@ -202,59 +201,56 @@ return result_
|
|
|
202
201
|
|
|
203
202
|
export function Compiler_imports(self_, module_) {
|
|
204
203
|
return ff_core_List.List_map(module_.imports_, ((import_) => {
|
|
205
|
-
const newPackagePair_ = import_.
|
|
206
|
-
const newModuleName_ = (ff_core_List.List_join(ff_core_List.List_map(import_.directory_, ((_w1) => {
|
|
207
|
-
return (_w1 + "/")
|
|
208
|
-
})), "") + import_.file_);
|
|
204
|
+
const newPackagePair_ = import_.moduleKey_.packagePair_;
|
|
209
205
|
if((!ff_core_Map.Map_contains(self_.packagePaths_, newPackagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))) {
|
|
210
206
|
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)})
|
|
211
207
|
};
|
|
212
208
|
return ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch(ff_core_Core.try_((() => {
|
|
213
|
-
return ff_compiler_Compiler.Compiler_parse(self_,
|
|
209
|
+
return ff_compiler_Compiler.Compiler_parse(self_, import_.moduleKey_, ff_core_Option.Some(import_.at_))
|
|
214
210
|
})), ((_1, _2) => {
|
|
215
211
|
{
|
|
216
212
|
const e_ = _1;
|
|
217
213
|
const error_ = _2;
|
|
218
|
-
const newError_ = ff_compiler_Syntax.CompileError(import_.at_, (
|
|
214
|
+
const newError_ = ff_compiler_Syntax.CompileError(import_.at_, ("Parse error in imported module: " + ff_compiler_Syntax.ModuleKey_importName(import_.moduleKey_)));
|
|
219
215
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors([e_, newError_]), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
|
|
220
216
|
}
|
|
221
217
|
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
|
|
222
218
|
{
|
|
223
219
|
const compileErrors_ = _1.errors_;
|
|
224
220
|
const error_ = _2;
|
|
225
|
-
const newError_ = ff_compiler_Syntax.CompileError(import_.at_, (
|
|
221
|
+
const newError_ = ff_compiler_Syntax.CompileError(import_.at_, ("Parse errors in imported module: " + ff_compiler_Syntax.ModuleKey_importName(import_.moduleKey_)));
|
|
226
222
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors([...compileErrors_, newError_]), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
|
|
227
223
|
}
|
|
228
224
|
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
|
|
229
225
|
}))
|
|
230
226
|
}
|
|
231
227
|
|
|
232
|
-
export function Compiler_resolve(self_,
|
|
233
|
-
return ff_compiler_ModuleCache.ModuleCache_cacheResolvedModule(self_.cache_, self_.packagePaths_,
|
|
234
|
-
return ff_compiler_Compiler.Compiler_measure(self_, "Resolve",
|
|
235
|
-
const module_ = ff_compiler_Compiler.Compiler_parse(self_,
|
|
228
|
+
export function Compiler_resolve(self_, moduleKey_) {
|
|
229
|
+
return ff_compiler_ModuleCache.ModuleCache_cacheResolvedModule(self_.cache_, self_.packagePaths_, moduleKey_, ((path_) => {
|
|
230
|
+
return ff_compiler_Compiler.Compiler_measure(self_, "Resolve", moduleKey_, (() => {
|
|
231
|
+
const module_ = ff_compiler_Compiler.Compiler_parse(self_, moduleKey_, ff_core_Option.None());
|
|
236
232
|
const otherModules_ = ff_compiler_Compiler.Compiler_imports(self_, module_);
|
|
237
|
-
const resolver_ = ff_compiler_Resolver.new_(
|
|
233
|
+
const resolver_ = ff_compiler_Resolver.new_(self_.lspHook_);
|
|
238
234
|
return ff_compiler_Resolver.Resolver_resolveModule(resolver_, module_, otherModules_)
|
|
239
235
|
}))
|
|
240
236
|
}))
|
|
241
237
|
}
|
|
242
238
|
|
|
243
|
-
export function Compiler_derive(self_,
|
|
244
|
-
return ff_compiler_ModuleCache.ModuleCache_cacheDerivedModule(self_.cache_, self_.packagePaths_,
|
|
245
|
-
return ff_compiler_Compiler.Compiler_measure(self_, "Derive",
|
|
246
|
-
const module_ = ff_compiler_Compiler.Compiler_resolve(self_,
|
|
239
|
+
export function Compiler_derive(self_, moduleKey_) {
|
|
240
|
+
return ff_compiler_ModuleCache.ModuleCache_cacheDerivedModule(self_.cache_, self_.packagePaths_, moduleKey_, ((path_) => {
|
|
241
|
+
return ff_compiler_Compiler.Compiler_measure(self_, "Derive", moduleKey_, (() => {
|
|
242
|
+
const module_ = ff_compiler_Compiler.Compiler_resolve(self_, moduleKey_);
|
|
247
243
|
return ff_compiler_Deriver.Deriver_deriveModule(ff_compiler_Deriver.new_(), module_)
|
|
248
244
|
}))
|
|
249
245
|
}))
|
|
250
246
|
}
|
|
251
247
|
|
|
252
|
-
export function Compiler_infer(self_,
|
|
253
|
-
return ff_compiler_ModuleCache.ModuleCache_cacheInferredModule(self_.cache_, self_.packagePaths_,
|
|
254
|
-
return ff_compiler_Compiler.Compiler_measure(self_, "Infer",
|
|
255
|
-
const module_ = ff_compiler_Compiler.Compiler_derive(self_,
|
|
248
|
+
export function Compiler_infer(self_, moduleKey_) {
|
|
249
|
+
return ff_compiler_ModuleCache.ModuleCache_cacheInferredModule(self_.cache_, self_.packagePaths_, moduleKey_, ((path_) => {
|
|
250
|
+
return ff_compiler_Compiler.Compiler_measure(self_, "Infer", moduleKey_, (() => {
|
|
251
|
+
const module_ = ff_compiler_Compiler.Compiler_derive(self_, moduleKey_);
|
|
256
252
|
const otherModules_ = ff_core_List.List_map(ff_compiler_Compiler.Compiler_imports(self_, module_), ((i_) => {
|
|
257
|
-
return ff_compiler_Compiler.Compiler_derive(self_, i_.
|
|
253
|
+
return ff_compiler_Compiler.Compiler_derive(self_, i_.moduleKey_)
|
|
258
254
|
}));
|
|
259
255
|
const inference_ = ff_compiler_Inference.new_([module_, ...otherModules_], self_.lspHook_);
|
|
260
256
|
const inferredModule_ = ff_compiler_Inference.Inference_inferModule(inference_, module_, otherModules_);
|
|
@@ -263,28 +259,30 @@ return ff_compiler_Dictionaries.Dictionaries_processModule(ff_compiler_Dictionar
|
|
|
263
259
|
}))
|
|
264
260
|
}
|
|
265
261
|
|
|
266
|
-
export function Compiler_emit(self_,
|
|
267
|
-
ff_compiler_ModuleCache.ModuleCache_cacheEmittedModule(self_.cache_, self_.packagePaths_,
|
|
268
|
-
ff_compiler_Compiler.Compiler_measure(self_, "Emit",
|
|
269
|
-
const module_ = ff_compiler_Compiler.Compiler_infer(self_,
|
|
262
|
+
export function Compiler_emit(self_, moduleKey_, isMainModule_) {
|
|
263
|
+
ff_compiler_ModuleCache.ModuleCache_cacheEmittedModule(self_.cache_, self_.packagePaths_, moduleKey_, isMainModule_, ((path_) => {
|
|
264
|
+
ff_compiler_Compiler.Compiler_measure(self_, "Emit", moduleKey_, (() => {
|
|
265
|
+
const module_ = ff_compiler_Compiler.Compiler_infer(self_, moduleKey_);
|
|
270
266
|
const otherModules_ = ff_core_List.List_map(ff_compiler_Compiler.Compiler_imports(self_, module_), ((i_) => {
|
|
271
|
-
|
|
272
|
-
ff_compiler_Compiler.
|
|
273
|
-
return ff_compiler_Compiler.Compiler_infer(self_, i_.packagePair_, newModuleName_)
|
|
267
|
+
ff_compiler_Compiler.Compiler_emit(self_, i_.moduleKey_, false);
|
|
268
|
+
return ff_compiler_Compiler.Compiler_infer(self_, i_.moduleKey_)
|
|
274
269
|
}));
|
|
275
270
|
const allModules_ = [module_, ...otherModules_];
|
|
276
271
|
const emitter_ = ff_compiler_JsEmitter.new_(allModules_, self_.emitTarget_, isMainModule_, ff_core_Option.Option_map(self_.compilerModulePath_, ((_w1) => {
|
|
277
272
|
return ff_core_Path.Path_url(_w1)
|
|
278
|
-
})),
|
|
279
|
-
const js_ = ff_compiler_JsEmitter.JsEmitter_emitModule(emitter_,
|
|
280
|
-
const
|
|
281
|
-
const
|
|
273
|
+
})), moduleKey_);
|
|
274
|
+
const js_ = ff_compiler_JsEmitter.JsEmitter_emitModule(emitter_, module_);
|
|
275
|
+
const packagePath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(self_.jsOutputPath_, moduleKey_.packagePair_.group_), moduleKey_.packagePair_.name_);
|
|
276
|
+
const jsPath_ = ff_core_List.List_foldLeft(moduleKey_.folders_, packagePath_, ((p_, f_) => {
|
|
277
|
+
return ff_core_Path.Path_slash(p_, f_)
|
|
278
|
+
}));
|
|
279
|
+
const jsFile_ = ff_core_Path.Path_slash(jsPath_, (moduleKey_.name_ + ".mjs"));
|
|
282
280
|
ff_core_Path.Path_createDirectory(jsPath_, true);
|
|
283
281
|
ff_core_Path.Path_writeText(jsFile_, js_);
|
|
284
282
|
if(isMainModule_) {
|
|
285
283
|
return ff_core_Option.Some((function() {
|
|
286
|
-
const runJs_ = ff_compiler_JsEmitter.JsEmitter_emitRun(emitter_,
|
|
287
|
-
const jsRunFile_ = ff_core_Path.Path_slash(jsPath_, (
|
|
284
|
+
const runJs_ = ff_compiler_JsEmitter.JsEmitter_emitRun(emitter_, moduleKey_.name_, module_.functions_, moduleKey_.packagePair_, ((moduleKey_.packagePair_.group_ === "ff") && (moduleKey_.packagePair_.name_ === "compiler")));
|
|
285
|
+
const jsRunFile_ = ff_core_Path.Path_slash(jsPath_, (moduleKey_.name_ + ".run.mjs"));
|
|
288
286
|
return ff_core_Path.Path_writeText(jsRunFile_, ff_core_List.List_join(ff_core_List.List_map(runJs_, ((_w1) => {
|
|
289
287
|
return (_w1 + "\n")
|
|
290
288
|
})), ""))
|
|
@@ -294,13 +292,13 @@ return (_w1 + "\n")
|
|
|
294
292
|
}))
|
|
295
293
|
}
|
|
296
294
|
|
|
297
|
-
export async function Compiler_measure$(self_, phase_,
|
|
295
|
+
export async function Compiler_measure$(self_, phase_, moduleKey_, body_, $task) {
|
|
298
296
|
const start_ = ((await ff_core_Task.Task_elapsed$(self_.task_, $task)) - self_.phaseDurationDelta_);
|
|
299
297
|
const result_ = (await body_($task));
|
|
300
298
|
const stop_ = ((await ff_core_Task.Task_elapsed$(self_.task_, $task)) - self_.phaseDurationDelta_);
|
|
301
299
|
const duration_ = (stop_ - start_);
|
|
302
300
|
self_.phaseDurationDelta_ = (self_.phaseDurationDelta_ + duration_);
|
|
303
|
-
const text_ = ((
|
|
301
|
+
const text_ = ((phase_ + " ") + ff_compiler_Syntax.ModuleKey_qualifiedName(moduleKey_));
|
|
304
302
|
self_.phaseDurations_.array.push(ff_core_Pair.Pair(text_, duration_));
|
|
305
303
|
return result_
|
|
306
304
|
}
|
|
@@ -319,17 +317,16 @@ return
|
|
|
319
317
|
}))
|
|
320
318
|
}
|
|
321
319
|
|
|
322
|
-
export async function Compiler_parse$(self_,
|
|
323
|
-
return (await ff_compiler_ModuleCache.ModuleCache_cacheParsedModule$(self_.cache_, self_.packagePaths_,
|
|
324
|
-
|
|
325
|
-
return (await ff_compiler_Compiler.Compiler_measure$(self_, "Parse", packagePair_, moduleName_, (async ($task) => {
|
|
320
|
+
export async function Compiler_parse$(self_, moduleKey_, importedAt_, $task) {
|
|
321
|
+
return (await ff_compiler_ModuleCache.ModuleCache_cacheParsedModule$(self_.cache_, self_.packagePaths_, moduleKey_, (async (path_, $task) => {
|
|
322
|
+
return (await ff_compiler_Compiler.Compiler_measure$(self_, "Parse", moduleKey_, (async ($task) => {
|
|
326
323
|
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) => {
|
|
327
324
|
{
|
|
328
325
|
const if_o = importedAt_
|
|
329
326
|
if(if_o.Some) {
|
|
330
327
|
const at_ = if_o.value_;
|
|
331
328
|
if((!(await ff_core_Path.Path_exists$(path_, false, false, false, $task)))) {
|
|
332
|
-
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, (
|
|
329
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("Imported module not found: " + ff_compiler_Syntax.ModuleKey_importName(moduleKey_))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
333
330
|
}
|
|
334
331
|
}
|
|
335
332
|
};
|
|
@@ -339,12 +336,12 @@ const completionAt_ = ((ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_) &&
|
|
|
339
336
|
? ff_core_Option.Some(self_.lspHook_.at_)
|
|
340
337
|
: ff_core_Option.None());
|
|
341
338
|
const tokens_ = ff_compiler_Tokenizer.tokenize_((await ff_core_Path.Path_absolute$(path_, $task)), code_, completionAt_, ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_));
|
|
342
|
-
const parser_ = ff_compiler_Parser.new_(
|
|
343
|
-
const module_ = (ff_core_Set.Set_contains(self_.singleFilePackages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
|
|
339
|
+
const parser_ = ff_compiler_Parser.new_(moduleKey_, tokens_, ff_core_Equal.notEquals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser(), ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget), self_.lspHook_);
|
|
340
|
+
const module_ = (ff_core_Set.Set_contains(self_.singleFilePackages_, moduleKey_.packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
|
|
344
341
|
? ff_compiler_Parser.Parser_parseModuleWithPackageInfo(parser_).module_
|
|
345
342
|
: ff_compiler_Parser.Parser_parseModuleWithoutPackageInfo(parser_));
|
|
346
343
|
const result_ = (((_c) => {
|
|
347
|
-
return ff_compiler_Syntax.Module(_c.
|
|
344
|
+
return ff_compiler_Syntax.Module(_c.moduleKey_, [...ff_compiler_Compiler.coreImports_, ...module_.imports_], _c.types_, _c.traits_, _c.instances_, _c.extends_, _c.lets_, _c.functions_)
|
|
348
345
|
}))(module_);
|
|
349
346
|
return result_
|
|
350
347
|
}), $task))
|
|
@@ -353,59 +350,56 @@ return result_
|
|
|
353
350
|
|
|
354
351
|
export async function Compiler_imports$(self_, module_, $task) {
|
|
355
352
|
return (await ff_core_List.List_map$(module_.imports_, (async (import_, $task) => {
|
|
356
|
-
const newPackagePair_ = import_.
|
|
357
|
-
const newModuleName_ = (ff_core_List.List_join(ff_core_List.List_map(import_.directory_, ((_w1) => {
|
|
358
|
-
return (_w1 + "/")
|
|
359
|
-
})), "") + import_.file_);
|
|
353
|
+
const newPackagePair_ = import_.moduleKey_.packagePair_;
|
|
360
354
|
if((!ff_core_Map.Map_contains(self_.packagePaths_, newPackagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))) {
|
|
361
355
|
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)})
|
|
362
356
|
};
|
|
363
357
|
return ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch((await ff_core_Core.try_$((async ($task) => {
|
|
364
|
-
return (await ff_compiler_Compiler.Compiler_parse$(self_,
|
|
358
|
+
return (await ff_compiler_Compiler.Compiler_parse$(self_, import_.moduleKey_, ff_core_Option.Some(import_.at_), $task))
|
|
365
359
|
}), $task)), ((_1, _2) => {
|
|
366
360
|
{
|
|
367
361
|
const e_ = _1;
|
|
368
362
|
const error_ = _2;
|
|
369
|
-
const newError_ = ff_compiler_Syntax.CompileError(import_.at_, (
|
|
363
|
+
const newError_ = ff_compiler_Syntax.CompileError(import_.at_, ("Parse error in imported module: " + ff_compiler_Syntax.ModuleKey_importName(import_.moduleKey_)));
|
|
370
364
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors([e_, newError_]), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
|
|
371
365
|
}
|
|
372
366
|
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
|
|
373
367
|
{
|
|
374
368
|
const compileErrors_ = _1.errors_;
|
|
375
369
|
const error_ = _2;
|
|
376
|
-
const newError_ = ff_compiler_Syntax.CompileError(import_.at_, (
|
|
370
|
+
const newError_ = ff_compiler_Syntax.CompileError(import_.at_, ("Parse errors in imported module: " + ff_compiler_Syntax.ModuleKey_importName(import_.moduleKey_)));
|
|
377
371
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors([...compileErrors_, newError_]), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
|
|
378
372
|
}
|
|
379
373
|
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
|
|
380
374
|
}), $task))
|
|
381
375
|
}
|
|
382
376
|
|
|
383
|
-
export async function Compiler_resolve$(self_,
|
|
384
|
-
return (await ff_compiler_ModuleCache.ModuleCache_cacheResolvedModule$(self_.cache_, self_.packagePaths_,
|
|
385
|
-
return (await ff_compiler_Compiler.Compiler_measure$(self_, "Resolve",
|
|
386
|
-
const module_ = (await ff_compiler_Compiler.Compiler_parse$(self_,
|
|
377
|
+
export async function Compiler_resolve$(self_, moduleKey_, $task) {
|
|
378
|
+
return (await ff_compiler_ModuleCache.ModuleCache_cacheResolvedModule$(self_.cache_, self_.packagePaths_, moduleKey_, (async (path_, $task) => {
|
|
379
|
+
return (await ff_compiler_Compiler.Compiler_measure$(self_, "Resolve", moduleKey_, (async ($task) => {
|
|
380
|
+
const module_ = (await ff_compiler_Compiler.Compiler_parse$(self_, moduleKey_, ff_core_Option.None(), $task));
|
|
387
381
|
const otherModules_ = (await ff_compiler_Compiler.Compiler_imports$(self_, module_, $task));
|
|
388
|
-
const resolver_ = ff_compiler_Resolver.new_(
|
|
382
|
+
const resolver_ = ff_compiler_Resolver.new_(self_.lspHook_);
|
|
389
383
|
return ff_compiler_Resolver.Resolver_resolveModule(resolver_, module_, otherModules_)
|
|
390
384
|
}), $task))
|
|
391
385
|
}), $task))
|
|
392
386
|
}
|
|
393
387
|
|
|
394
|
-
export async function Compiler_derive$(self_,
|
|
395
|
-
return (await ff_compiler_ModuleCache.ModuleCache_cacheDerivedModule$(self_.cache_, self_.packagePaths_,
|
|
396
|
-
return (await ff_compiler_Compiler.Compiler_measure$(self_, "Derive",
|
|
397
|
-
const module_ = (await ff_compiler_Compiler.Compiler_resolve$(self_,
|
|
388
|
+
export async function Compiler_derive$(self_, moduleKey_, $task) {
|
|
389
|
+
return (await ff_compiler_ModuleCache.ModuleCache_cacheDerivedModule$(self_.cache_, self_.packagePaths_, moduleKey_, (async (path_, $task) => {
|
|
390
|
+
return (await ff_compiler_Compiler.Compiler_measure$(self_, "Derive", moduleKey_, (async ($task) => {
|
|
391
|
+
const module_ = (await ff_compiler_Compiler.Compiler_resolve$(self_, moduleKey_, $task));
|
|
398
392
|
return ff_compiler_Deriver.Deriver_deriveModule(ff_compiler_Deriver.new_(), module_)
|
|
399
393
|
}), $task))
|
|
400
394
|
}), $task))
|
|
401
395
|
}
|
|
402
396
|
|
|
403
|
-
export async function Compiler_infer$(self_,
|
|
404
|
-
return (await ff_compiler_ModuleCache.ModuleCache_cacheInferredModule$(self_.cache_, self_.packagePaths_,
|
|
405
|
-
return (await ff_compiler_Compiler.Compiler_measure$(self_, "Infer",
|
|
406
|
-
const module_ = (await ff_compiler_Compiler.Compiler_derive$(self_,
|
|
397
|
+
export async function Compiler_infer$(self_, moduleKey_, $task) {
|
|
398
|
+
return (await ff_compiler_ModuleCache.ModuleCache_cacheInferredModule$(self_.cache_, self_.packagePaths_, moduleKey_, (async (path_, $task) => {
|
|
399
|
+
return (await ff_compiler_Compiler.Compiler_measure$(self_, "Infer", moduleKey_, (async ($task) => {
|
|
400
|
+
const module_ = (await ff_compiler_Compiler.Compiler_derive$(self_, moduleKey_, $task));
|
|
407
401
|
const otherModules_ = (await ff_core_List.List_map$((await ff_compiler_Compiler.Compiler_imports$(self_, module_, $task)), (async (i_, $task) => {
|
|
408
|
-
return (await ff_compiler_Compiler.Compiler_derive$(self_, i_.
|
|
402
|
+
return (await ff_compiler_Compiler.Compiler_derive$(self_, i_.moduleKey_, $task))
|
|
409
403
|
}), $task));
|
|
410
404
|
const inference_ = ff_compiler_Inference.new_([module_, ...otherModules_], self_.lspHook_);
|
|
411
405
|
const inferredModule_ = ff_compiler_Inference.Inference_inferModule(inference_, module_, otherModules_);
|
|
@@ -414,28 +408,30 @@ return ff_compiler_Dictionaries.Dictionaries_processModule(ff_compiler_Dictionar
|
|
|
414
408
|
}), $task))
|
|
415
409
|
}
|
|
416
410
|
|
|
417
|
-
export async function Compiler_emit$(self_,
|
|
418
|
-
(await ff_compiler_ModuleCache.ModuleCache_cacheEmittedModule$(self_.cache_, self_.packagePaths_,
|
|
419
|
-
(await ff_compiler_Compiler.Compiler_measure$(self_, "Emit",
|
|
420
|
-
const module_ = (await ff_compiler_Compiler.Compiler_infer$(self_,
|
|
411
|
+
export async function Compiler_emit$(self_, moduleKey_, isMainModule_, $task) {
|
|
412
|
+
(await ff_compiler_ModuleCache.ModuleCache_cacheEmittedModule$(self_.cache_, self_.packagePaths_, moduleKey_, isMainModule_, (async (path_, $task) => {
|
|
413
|
+
(await ff_compiler_Compiler.Compiler_measure$(self_, "Emit", moduleKey_, (async ($task) => {
|
|
414
|
+
const module_ = (await ff_compiler_Compiler.Compiler_infer$(self_, moduleKey_, $task));
|
|
421
415
|
const otherModules_ = (await ff_core_List.List_map$((await ff_compiler_Compiler.Compiler_imports$(self_, module_, $task)), (async (i_, $task) => {
|
|
422
|
-
|
|
423
|
-
(await ff_compiler_Compiler.
|
|
424
|
-
return (await ff_compiler_Compiler.Compiler_infer$(self_, i_.packagePair_, newModuleName_, $task))
|
|
416
|
+
(await ff_compiler_Compiler.Compiler_emit$(self_, i_.moduleKey_, false, $task));
|
|
417
|
+
return (await ff_compiler_Compiler.Compiler_infer$(self_, i_.moduleKey_, $task))
|
|
425
418
|
}), $task));
|
|
426
419
|
const allModules_ = [module_, ...otherModules_];
|
|
427
420
|
const emitter_ = ff_compiler_JsEmitter.new_(allModules_, self_.emitTarget_, isMainModule_, (await ff_core_Option.Option_map$(self_.compilerModulePath_, (async (_w1, $task) => {
|
|
428
421
|
return (await ff_core_Path.Path_url$(_w1, $task))
|
|
429
|
-
}), $task)),
|
|
430
|
-
const js_ = ff_compiler_JsEmitter.JsEmitter_emitModule(emitter_,
|
|
431
|
-
const
|
|
432
|
-
const
|
|
422
|
+
}), $task)), moduleKey_);
|
|
423
|
+
const js_ = ff_compiler_JsEmitter.JsEmitter_emitModule(emitter_, module_);
|
|
424
|
+
const packagePath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(self_.jsOutputPath_, moduleKey_.packagePair_.group_, $task)), moduleKey_.packagePair_.name_, $task));
|
|
425
|
+
const jsPath_ = (await ff_core_List.List_foldLeft$(moduleKey_.folders_, packagePath_, (async (p_, f_, $task) => {
|
|
426
|
+
return (await ff_core_Path.Path_slash$(p_, f_, $task))
|
|
427
|
+
}), $task));
|
|
428
|
+
const jsFile_ = (await ff_core_Path.Path_slash$(jsPath_, (moduleKey_.name_ + ".mjs"), $task));
|
|
433
429
|
(await ff_core_Path.Path_createDirectory$(jsPath_, true, $task));
|
|
434
430
|
(await ff_core_Path.Path_writeText$(jsFile_, js_, $task));
|
|
435
431
|
if(isMainModule_) {
|
|
436
432
|
return ff_core_Option.Some((await (async function() {
|
|
437
|
-
const runJs_ = ff_compiler_JsEmitter.JsEmitter_emitRun(emitter_,
|
|
438
|
-
const jsRunFile_ = (await ff_core_Path.Path_slash$(jsPath_, (
|
|
433
|
+
const runJs_ = ff_compiler_JsEmitter.JsEmitter_emitRun(emitter_, moduleKey_.name_, module_.functions_, moduleKey_.packagePair_, ((moduleKey_.packagePair_.group_ === "ff") && (moduleKey_.packagePair_.name_ === "compiler")));
|
|
434
|
+
const jsRunFile_ = (await ff_core_Path.Path_slash$(jsPath_, (moduleKey_.name_ + ".run.mjs"), $task));
|
|
439
435
|
return (await ff_core_Path.Path_writeText$(jsRunFile_, ff_core_List.List_join(ff_core_List.List_map(runJs_, ((_w1) => {
|
|
440
436
|
return (_w1 + "\n")
|
|
441
437
|
})), ""), $task))
|
|
@@ -124,7 +124,11 @@ export function process_(fetch_, dependencyLock_, path_) {
|
|
|
124
124
|
const workspace_ = ff_compiler_Workspace.loadWorkspace_(path_);
|
|
125
125
|
const self_ = ff_compiler_Dependencies.Dependencies(workspace_, ff_core_List.List_toMap([], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toMap([], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toSet([], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
|
|
126
126
|
const packageInfo_ = ff_core_Option.Option_else(ff_compiler_Dependencies.Dependencies_loadPackageInfo(self_, ff_compiler_Syntax.PackagePair("script", "script"), path_), (() => {
|
|
127
|
-
|
|
127
|
+
if((!ff_core_Path.Path_exists(path_, false, false, false))) {
|
|
128
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location(ff_core_Path.Path_absolute(path_), 1, 1), "File not found"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
129
|
+
} else {
|
|
130
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location(ff_core_Path.Path_absolute(path_), 1, 1), "Could not load package info"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
131
|
+
}
|
|
128
132
|
}));
|
|
129
133
|
const newDependencies_ = ff_compiler_Dependencies.Dependencies_processPackageInfo(self_, packageInfo_);
|
|
130
134
|
ff_compiler_Dependencies.Dependencies_processDependencies(self_, path_, fetch_, dependencyLock_, newDependencies_);
|
|
@@ -164,7 +168,11 @@ export async function process_$(fetch_, dependencyLock_, path_, $task) {
|
|
|
164
168
|
const workspace_ = (await ff_compiler_Workspace.loadWorkspace_$(path_, $task));
|
|
165
169
|
const self_ = ff_compiler_Dependencies.Dependencies(workspace_, ff_core_List.List_toMap([], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toMap([], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toSet([], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
|
|
166
170
|
const packageInfo_ = (await ff_core_Option.Option_else$((await ff_compiler_Dependencies.Dependencies_loadPackageInfo$(self_, ff_compiler_Syntax.PackagePair("script", "script"), path_, $task)), (async ($task) => {
|
|
167
|
-
|
|
171
|
+
if((!(await ff_core_Path.Path_exists$(path_, false, false, false, $task)))) {
|
|
172
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location((await ff_core_Path.Path_absolute$(path_, $task)), 1, 1), "File not found"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
173
|
+
} else {
|
|
174
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_compiler_Syntax.Location((await ff_core_Path.Path_absolute$(path_, $task)), 1, 1), "Could not load package info"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
175
|
+
}
|
|
168
176
|
}), $task));
|
|
169
177
|
const newDependencies_ = (await ff_compiler_Dependencies.Dependencies_processPackageInfo$(self_, packageInfo_, $task));
|
|
170
178
|
(await ff_compiler_Dependencies.Dependencies_processDependencies$(self_, path_, fetch_, dependencyLock_, newDependencies_, $task));
|
|
@@ -201,9 +209,7 @@ const tar_ = import$0;
|
|
|
201
209
|
}
|
|
202
210
|
|
|
203
211
|
export function Dependencies_loadPackageInfo(self_, packagePair_, path_) {
|
|
204
|
-
const packageDirectory_ =
|
|
205
|
-
? ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_))
|
|
206
|
-
: path_);
|
|
212
|
+
const packageDirectory_ = ff_compiler_Dependencies.findScriptPackageLocation_(path_);
|
|
207
213
|
const sharedPackageFile_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(packageDirectory_, ".firefly"), "package.ff");
|
|
208
214
|
const packageFile_ = (ff_core_Path.Path_exists(sharedPackageFile_, false, false, false)
|
|
209
215
|
? sharedPackageFile_
|
|
@@ -217,7 +223,8 @@ return ff_compiler_Dependencies.Dependencies_parsePackageFile(self_, packagePair
|
|
|
217
223
|
|
|
218
224
|
export function Dependencies_parsePackageFile(self_, packagePair_, fileName_, code_) {
|
|
219
225
|
const tokens_ = ff_compiler_Tokenizer.tokenize_(fileName_, code_, ff_core_Option.None(), true);
|
|
220
|
-
const
|
|
226
|
+
const moduleKey_ = ff_compiler_Syntax.ModuleKey(packagePair_, [], "<package>");
|
|
227
|
+
const parser_ = ff_compiler_Parser.new_(moduleKey_, tokens_, false, ff_compiler_LspHook.disabled_());
|
|
221
228
|
const info_ = ff_compiler_Parser.Parser_parsePackageInfo(parser_);
|
|
222
229
|
return ff_compiler_Dependencies.Dependencies_addCoreDependencyIfMissing(self_, info_)
|
|
223
230
|
}
|
|
@@ -308,9 +315,7 @@ ff_compiler_Dependencies.Dependencies_processDependencies(self_, path_, httpClie
|
|
|
308
315
|
}
|
|
309
316
|
|
|
310
317
|
export async function Dependencies_loadPackageInfo$(self_, packagePair_, path_, $task) {
|
|
311
|
-
const packageDirectory_ = (
|
|
312
|
-
? ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task)))
|
|
313
|
-
: path_);
|
|
318
|
+
const packageDirectory_ = (await ff_compiler_Dependencies.findScriptPackageLocation_$(path_, $task));
|
|
314
319
|
const sharedPackageFile_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(packageDirectory_, ".firefly", $task)), "package.ff", $task));
|
|
315
320
|
const packageFile_ = ((await ff_core_Path.Path_exists$(sharedPackageFile_, false, false, false, $task))
|
|
316
321
|
? sharedPackageFile_
|
|
@@ -324,7 +329,8 @@ return (await ff_compiler_Dependencies.Dependencies_parsePackageFile$(self_, pac
|
|
|
324
329
|
|
|
325
330
|
export async function Dependencies_parsePackageFile$(self_, packagePair_, fileName_, code_, $task) {
|
|
326
331
|
const tokens_ = ff_compiler_Tokenizer.tokenize_(fileName_, code_, ff_core_Option.None(), true);
|
|
327
|
-
const
|
|
332
|
+
const moduleKey_ = ff_compiler_Syntax.ModuleKey(packagePair_, [], "<package>");
|
|
333
|
+
const parser_ = ff_compiler_Parser.new_(moduleKey_, tokens_, false, ff_compiler_LspHook.disabled_());
|
|
328
334
|
const info_ = ff_compiler_Parser.Parser_parsePackageInfo(parser_);
|
|
329
335
|
return (await ff_compiler_Dependencies.Dependencies_addCoreDependencyIfMissing$(self_, info_, $task))
|
|
330
336
|
}
|
|
@@ -123,12 +123,12 @@ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
export function Deriver_deriveModule(self_, module_) {
|
|
126
|
-
const modulePrefix_ =
|
|
126
|
+
const modulePrefix_ = ff_compiler_Syntax.ModuleKey_qualifiedName(module_.moduleKey_);
|
|
127
127
|
{
|
|
128
128
|
const _1 = module_;
|
|
129
129
|
{
|
|
130
130
|
const _c = _1;
|
|
131
|
-
return ff_compiler_Syntax.Module(_c.
|
|
131
|
+
return ff_compiler_Syntax.Module(_c.moduleKey_, _c.imports_, _c.types_, _c.traits_, [...module_.instances_, ...ff_compiler_Deriver.Deriver_makeHasAnyTagInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeShowInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeEqualInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeOrderingInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeSerializableInstances(self_, modulePrefix_, module_)], _c.extends_, _c.lets_, _c.functions_)
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
@@ -495,7 +495,7 @@ return ff_core_Option.None()
|
|
|
495
495
|
}
|
|
496
496
|
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
497
497
|
return ff_core_List.List_filter(module_.types_, ((t_) => {
|
|
498
|
-
return (((((((ff_compiler_Syntax.
|
|
498
|
+
return (((((((!ff_compiler_Syntax.PackagePair_isCore(module_.moduleKey_.packagePair_)) || ff_core_Set.Set_contains(coreWhitelist_, ((modulePrefix_ + ".") + t_.name_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) && (!ff_core_Option.Option_any(ff_core_List.List_first(t_.generics_), ((_w1) => {
|
|
499
499
|
return (_w1 === "Q$")
|
|
500
500
|
})))) && (allowGenerics_ || ff_core_List.List_isEmpty(t_.generics_))) && t_.data_) && (!t_.newtype_)) && (!ff_core_Set.Set_contains(typesWithInstance_, ((modulePrefix_ + ".") + t_.name_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)))
|
|
501
501
|
}))
|
|
@@ -525,12 +525,12 @@ return ff_compiler_Syntax.ECall(at_, ff_compiler_Syntax.DynamicCall(ff_compiler_
|
|
|
525
525
|
}
|
|
526
526
|
|
|
527
527
|
export async function Deriver_deriveModule$(self_, module_, $task) {
|
|
528
|
-
const modulePrefix_ =
|
|
528
|
+
const modulePrefix_ = ff_compiler_Syntax.ModuleKey_qualifiedName(module_.moduleKey_);
|
|
529
529
|
{
|
|
530
530
|
const _1 = module_;
|
|
531
531
|
{
|
|
532
532
|
const _c = _1;
|
|
533
|
-
return ff_compiler_Syntax.Module(_c.
|
|
533
|
+
return ff_compiler_Syntax.Module(_c.moduleKey_, _c.imports_, _c.types_, _c.traits_, [...module_.instances_, ...ff_compiler_Deriver.Deriver_makeHasAnyTagInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeShowInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeEqualInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeOrderingInstances(self_, modulePrefix_, module_), ...ff_compiler_Deriver.Deriver_makeSerializableInstances(self_, modulePrefix_, module_)], _c.extends_, _c.lets_, _c.functions_)
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
536
|
}
|
|
@@ -897,7 +897,7 @@ return ff_core_Option.None()
|
|
|
897
897
|
}
|
|
898
898
|
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
899
899
|
return ff_core_List.List_filter(module_.types_, ((t_) => {
|
|
900
|
-
return (((((((ff_compiler_Syntax.
|
|
900
|
+
return (((((((!ff_compiler_Syntax.PackagePair_isCore(module_.moduleKey_.packagePair_)) || ff_core_Set.Set_contains(coreWhitelist_, ((modulePrefix_ + ".") + t_.name_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) && (!ff_core_Option.Option_any(ff_core_List.List_first(t_.generics_), ((_w1) => {
|
|
901
901
|
return (_w1 === "Q$")
|
|
902
902
|
})))) && (allowGenerics_ || ff_core_List.List_isEmpty(t_.generics_))) && t_.data_) && (!t_.newtype_)) && (!ff_core_Set.Set_contains(typesWithInstance_, ((modulePrefix_ + ".") + t_.name_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)))
|
|
903
903
|
}))
|
|
@@ -129,7 +129,7 @@ const i_ = _1.index_;
|
|
|
129
129
|
return ff_compiler_Dictionaries.fail_(c_.at_, ("Unexpected unification variable: $" + i_))
|
|
130
130
|
}
|
|
131
131
|
}))(ff_core_List.List_grabFirst(c_.generics_));
|
|
132
|
-
return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_), ff_compiler_Unification.InstanceValue([], [], ff_compiler_Syntax.PackagePair("", ""), "", c_.name_, c_.generics_))
|
|
132
|
+
return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_), ff_compiler_Unification.InstanceValue([], [], ff_compiler_Syntax.ModuleKey(ff_compiler_Syntax.PackagePair("", ""), [], ""), c_.name_, c_.generics_))
|
|
133
133
|
})), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey)
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -153,7 +153,7 @@ const i_ = _1.index_;
|
|
|
153
153
|
return ff_compiler_Dictionaries.fail_(c_.at_, ("Unexpected unification variable: $" + i_))
|
|
154
154
|
}
|
|
155
155
|
}))(ff_core_List.List_grabFirst(c_.generics_));
|
|
156
|
-
return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_), ff_compiler_Unification.InstanceValue([], [], ff_compiler_Syntax.PackagePair("", ""), "", c_.name_, c_.generics_))
|
|
156
|
+
return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_), ff_compiler_Unification.InstanceValue([], [], ff_compiler_Syntax.ModuleKey(ff_compiler_Syntax.PackagePair("", ""), [], ""), c_.name_, c_.generics_))
|
|
157
157
|
})), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey)
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -187,7 +187,7 @@ return ff_compiler_Dictionaries.Dictionaries_processInstanceDefinition(self_, fu
|
|
|
187
187
|
const _1 = module_;
|
|
188
188
|
{
|
|
189
189
|
const _c = _1;
|
|
190
|
-
return ff_compiler_Syntax.Module(_c.
|
|
190
|
+
return ff_compiler_Syntax.Module(_c.moduleKey_, _c.imports_, _c.types_, _c.traits_, instances_, extends_, lets_, functions_)
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
}
|
|
@@ -546,7 +546,7 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
|
|
|
546
546
|
const dictionaries_ = ff_core_List.List_map(instance_.constraints_, ((c_) => {
|
|
547
547
|
return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, instance_.generics_, firstType_.generics_, c_)
|
|
548
548
|
}));
|
|
549
|
-
return ff_compiler_Syntax.Dictionary(instance_.
|
|
549
|
+
return ff_compiler_Syntax.Dictionary(instance_.moduleKey_, constraint_.name_, firstType_.name_, dictionaries_)
|
|
550
550
|
}
|
|
551
551
|
{
|
|
552
552
|
const t_ = _1;
|
|
@@ -585,7 +585,7 @@ return ff_compiler_Dictionaries.Dictionaries_processInstanceDefinition(self_, fu
|
|
|
585
585
|
const _1 = module_;
|
|
586
586
|
{
|
|
587
587
|
const _c = _1;
|
|
588
|
-
return ff_compiler_Syntax.Module(_c.
|
|
588
|
+
return ff_compiler_Syntax.Module(_c.moduleKey_, _c.imports_, _c.types_, _c.traits_, instances_, extends_, lets_, functions_)
|
|
589
589
|
}
|
|
590
590
|
}
|
|
591
591
|
}
|
|
@@ -944,7 +944,7 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
|
|
|
944
944
|
const dictionaries_ = ff_core_List.List_map(instance_.constraints_, ((c_) => {
|
|
945
945
|
return ff_compiler_Dictionaries.Dictionaries_makeDictionary(self_, at_, instance_.generics_, firstType_.generics_, c_)
|
|
946
946
|
}));
|
|
947
|
-
return ff_compiler_Syntax.Dictionary(instance_.
|
|
947
|
+
return ff_compiler_Syntax.Dictionary(instance_.moduleKey_, constraint_.name_, firstType_.name_, dictionaries_)
|
|
948
948
|
}
|
|
949
949
|
{
|
|
950
950
|
const t_ = _1;
|
|
@@ -120,6 +120,7 @@ const processed_ = ff_compiler_Environment.processModule_(module_, true, already
|
|
|
120
120
|
const otherProcessed_ = ff_core_List.List_map(otherModules_, ((_w1) => {
|
|
121
121
|
return ff_compiler_Environment.processModule_(_w1, false, false)
|
|
122
122
|
}));
|
|
123
|
+
const modulePath_ = (ff_compiler_Syntax.ModuleKey_importName(module_.moduleKey_) + ".ff");
|
|
123
124
|
return ff_compiler_Environment.Environment(ff_compiler_Environment.fullName_(module_, ""), ff_core_Map.Map_addAll(processed_.symbols_, ff_core_List.List_foldLeft(ff_core_List.List_map(otherProcessed_, ((_w1) => {
|
|
124
125
|
return _w1.symbols_
|
|
125
126
|
})), ff_core_Map.new_(), ((_w1, _w2) => {
|
|
@@ -130,11 +131,11 @@ return _w1.traits_
|
|
|
130
131
|
return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
131
132
|
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.List_map(module_.imports_, ((i_) => {
|
|
132
133
|
return ff_core_Pair.Pair(i_.alias_, i_)
|
|
133
|
-
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_compiler_Syntax.TConstructor(ff_compiler_Syntax.Location(
|
|
134
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_compiler_Syntax.TConstructor(ff_compiler_Syntax.Location(modulePath_, 0, 0), "ff:core/Nothing.Nothing", []), ff_core_Option.None())
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
export function fullName_(module_, name_) {
|
|
137
|
-
return
|
|
138
|
+
return ff_compiler_Syntax.ModuleKey_qualifiedSymbol(module_.moduleKey_, name_)
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
export function fail_(at_, message_) {
|
|
@@ -222,7 +223,8 @@ return ff_core_Pair.Pair(ff_compiler_Environment.fullName_(module_, variant_.nam
|
|
|
222
223
|
const traits_ = ff_core_List.List_map(module_.traits_, ((d_) => {
|
|
223
224
|
return ff_core_Pair.Pair(ff_compiler_Environment.fullName_(module_, d_.name_), d_)
|
|
224
225
|
}));
|
|
225
|
-
const
|
|
226
|
+
const modulePath_ = (ff_compiler_Syntax.ModuleKey_importName(module_.moduleKey_) + ".ff");
|
|
227
|
+
const effect_ = ff_compiler_Syntax.TConstructor(ff_compiler_Syntax.Location(modulePath_, 0, 0), "ff:core/Nothing.Nothing", []);
|
|
226
228
|
return ff_compiler_Environment.Environment("", ff_core_List.List_toMap([...functions_, ...lets_, ...fields_, ...extends_, ...variants_, ...traitMethods_], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(traits_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), effect_, ff_core_Option.None())
|
|
227
229
|
}
|
|
228
230
|
|
|
@@ -231,6 +233,7 @@ const processed_ = ff_compiler_Environment.processModule_(module_, true, already
|
|
|
231
233
|
const otherProcessed_ = ff_core_List.List_map(otherModules_, ((_w1) => {
|
|
232
234
|
return ff_compiler_Environment.processModule_(_w1, false, false)
|
|
233
235
|
}));
|
|
236
|
+
const modulePath_ = (ff_compiler_Syntax.ModuleKey_importName(module_.moduleKey_) + ".ff");
|
|
234
237
|
return ff_compiler_Environment.Environment(ff_compiler_Environment.fullName_(module_, ""), ff_core_Map.Map_addAll(processed_.symbols_, ff_core_List.List_foldLeft(ff_core_List.List_map(otherProcessed_, ((_w1) => {
|
|
235
238
|
return _w1.symbols_
|
|
236
239
|
})), ff_core_Map.new_(), ((_w1, _w2) => {
|
|
@@ -241,11 +244,11 @@ return _w1.traits_
|
|
|
241
244
|
return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
242
245
|
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(ff_core_List.List_map(module_.imports_, ((i_) => {
|
|
243
246
|
return ff_core_Pair.Pair(i_.alias_, i_)
|
|
244
|
-
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_compiler_Syntax.TConstructor(ff_compiler_Syntax.Location(
|
|
247
|
+
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_compiler_Syntax.TConstructor(ff_compiler_Syntax.Location(modulePath_, 0, 0), "ff:core/Nothing.Nothing", []), ff_core_Option.None())
|
|
245
248
|
}
|
|
246
249
|
|
|
247
250
|
export async function fullName_$(module_, name_, $task) {
|
|
248
|
-
return
|
|
251
|
+
return ff_compiler_Syntax.ModuleKey_qualifiedSymbol(module_.moduleKey_, name_)
|
|
249
252
|
}
|
|
250
253
|
|
|
251
254
|
export async function fail_$(at_, message_, $task) {
|
|
@@ -333,7 +336,8 @@ return ff_core_Pair.Pair(ff_compiler_Environment.fullName_(module_, variant_.nam
|
|
|
333
336
|
const traits_ = ff_core_List.List_map(module_.traits_, ((d_) => {
|
|
334
337
|
return ff_core_Pair.Pair(ff_compiler_Environment.fullName_(module_, d_.name_), d_)
|
|
335
338
|
}));
|
|
336
|
-
const
|
|
339
|
+
const modulePath_ = (ff_compiler_Syntax.ModuleKey_importName(module_.moduleKey_) + ".ff");
|
|
340
|
+
const effect_ = ff_compiler_Syntax.TConstructor(ff_compiler_Syntax.Location(modulePath_, 0, 0), "ff:core/Nothing.Nothing", []);
|
|
337
341
|
return ff_compiler_Environment.Environment("", ff_core_List.List_toMap([...functions_, ...lets_, ...fields_, ...extends_, ...variants_, ...traitMethods_], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap(traits_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), effect_, ff_core_Option.None())
|
|
338
342
|
}
|
|
339
343
|
|