firefly-compiler 0.5.45 → 0.5.46

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/Main.ff CHANGED
@@ -18,6 +18,7 @@ data MainCommand {
18
18
  BrowserCommand(mainPath: String)
19
19
  BuildCommand(mainPath: String)
20
20
  CheckCommand(filePath: String)
21
+ SymbolsCommand(outPath: String, filePaths: List[String])
21
22
  }
22
23
 
23
24
  data CommandLineError(problem: String)
@@ -143,6 +144,21 @@ main(system: NodeSystem): Unit {
143
144
  printMeasurements = True
144
145
  moduleCache = ModuleCache.new(0)
145
146
  )
147
+
148
+ | SymbolsCommand(outPath, filePaths) =>
149
+ let columns = filePaths.flatMap {filePath =>
150
+ let path = system.path(filePath)
151
+ let code = path.readText()
152
+ let packagePair = PackagePair("script", "script")
153
+ let tokens = Tokenizer.tokenize(path.absolute(), code, None, False)
154
+ let parser = Parser.new(packagePair, path.base(), tokens, True, LspHook.disabled())
155
+ let module = parser.parseModuleWithPackageInfo().module
156
+ makeSymbolColumns(module)
157
+ }
158
+ let rowCount = columns.sortBy {_.size()}.last().map {_.size()}.else {0}
159
+ let tsv = 0.until(rowCount).map {i => columns.map {_.get(i).else {""}}}
160
+ system.path(outPath).writeText(tsv.map {_.join("\t")}.join("\n") + "\n")
161
+
146
162
  }
147
163
 
148
164
  try {
@@ -169,6 +185,7 @@ These are the commands:
169
185
  browser <main-file> Compile the main file for the browser
170
186
  build <main-file> Build the main file
171
187
  check <firefly-file> Check the firefly source file for errors
188
+ symbols <firefly-file> Print a .tsv with the symbols of a firefly source file
172
189
  bootstrap Bootstrap the compiler
173
190
  """
174
191
 
@@ -180,7 +197,7 @@ parseCommandLine(arguments: List[String]): MainCommand {
180
197
  | [mainFile, ...mainArguments] {mainFile.removeLast(".ff") | Some(mainName)} =>
181
198
  RunCommand(mainName, mainArguments)
182
199
  | _ => throw(CommandLineError(
183
- "You must specify a Firefly file (.ff) as first argument to run." + usageString
200
+ "You must specify a Firefly file (.ff) as first argument to run." + usageString
184
201
  ))
185
202
  }
186
203
  | ["browser", ...browserArguments] =>
@@ -188,10 +205,10 @@ parseCommandLine(arguments: List[String]): MainCommand {
188
205
  | [mainFile] {mainFile.removeLast(".ff") | Some(mainName)} =>
189
206
  BrowserCommand(mainName)
190
207
  | [_, _, ...] => throw(CommandLineError(
191
- "You must only specify a single argument to browser." + usageString
208
+ "You must only specify a single argument to browser." + usageString
192
209
  ))
193
210
  | _ => throw(CommandLineError(
194
- "You must specify a Firefly file (.ff) as the argument to browser." + usageString
211
+ "You must specify a Firefly file (.ff) as the argument to browser." + usageString
195
212
  ))
196
213
  }
197
214
  | ["build", ...buildArguments] =>
@@ -199,10 +216,10 @@ parseCommandLine(arguments: List[String]): MainCommand {
199
216
  | [mainFile] {mainFile.removeLast(".ff") | Some(mainName)} =>
200
217
  BuildCommand(mainName)
201
218
  | [_, _, ...] => throw(CommandLineError(
202
- "You must only specify a single argument to build." + usageString
219
+ "You must only specify a single argument to build." + usageString
203
220
  ))
204
221
  | _ => throw(CommandLineError(
205
- "You must specify a Firefly file (.ff) as the argument to build." + usageString
222
+ "You must specify a Firefly file (.ff) as the argument to build." + usageString
206
223
  ))
207
224
  }
208
225
  | ["check", ...checkArguments] =>
@@ -210,10 +227,18 @@ parseCommandLine(arguments: List[String]): MainCommand {
210
227
  | [fileName] =>
211
228
  CheckCommand(fileName)
212
229
  | [_, _, ...] => throw(CommandLineError(
213
- "You must only specify a single argument to check." + usageString
230
+ "You must only specify a single argument to check." + usageString
214
231
  ))
215
232
  | [] => throw(CommandLineError(
216
- "You must specify a Firefly file (.ff) or directory as the argument to check." + usageString
233
+ "You must specify a Firefly file (.ff) or directory as the argument to check." + usageString
234
+ ))
235
+ }
236
+ | ["symbols", ...checkArguments] =>
237
+ checkArguments.{
238
+ | [outName, fileName, ...fileNames] {outName.endsWith(".tsv")} =>
239
+ SymbolsCommand(outName, [fileName, ...fileNames])
240
+ | _ => throw(CommandLineError(
241
+ "You must specify a output file (.tsv) and 1+ Firefly files (.ff) to symbols." + usageString
217
242
  ))
218
243
  }
219
244
  | ["bootstrap", _] =>
@@ -284,3 +309,39 @@ detectFireflyPath(system: NodeSystem): Path {
284
309
  Path(url->fileURLToPath(Js->URL->(moduleUrl->slice(0, -suffix.size())))?)
285
310
  }
286
311
  }
312
+
313
+ makeSymbolColumns(module: Module): List[List[String]] {
314
+ function processSignature(signature: Signature): String {
315
+ let generics = if(signature.generics.isEmpty()) {""} else {"[" + signature.generics.join(", ") + "]"}
316
+ let parameters = "(" + signature.parameters.map {_.name}.join(", ") + ")"
317
+ signature.name + generics + parameters
318
+ }
319
+ let traits = module.traits.map {x =>
320
+ let generics = x.generics.dropFirst()
321
+ let g = x.generics.first().map {_ + ": "}.else {""}
322
+ (name = g + x.name, generics = generics, symbols = x.methods.map {processSignature(_)})
323
+ }
324
+ let types = module.types.map {x =>
325
+ let variants = x.variants.map {variant =>
326
+ let parameters = if(variant.fields.isEmpty() && x.commonFields.isEmpty()) {""} else {
327
+ "(" + [...x.commonFields, ...variant.fields].map {_.name}.join(", ") + ")"
328
+ }
329
+ variant.name + parameters
330
+ }
331
+ let methods = module.extends.filter {_.type.{
332
+ | TConstructor(_, name, _) => name == x.name
333
+ | _ => False
334
+ }}.flatMap {_.methods}.map {_.signature}.map {processSignature(_)}
335
+ (name = x.name, generics = x.generics, symbols = [...variants, ...methods])
336
+ }
337
+ let toplevel = if(module.functions.isEmpty()) {[]} else {
338
+ let functions = module.functions.map {processSignature(_.signature)}
339
+ [(name = "", generics = [], symbols = [...module.lets.map {_.name}, ...functions])]
340
+ }
341
+ let all = [...toplevel, ...types, ...traits]
342
+ all.map {r =>
343
+ let generics = if(r.generics.isEmpty()) {""} else {"[" + r.generics.join(", ") + "]"}
344
+ let header = (module.file + " " + r.name + generics).trim()
345
+ [header, ...r.symbols.sort()]
346
+ }
347
+ }
@@ -139,6 +139,9 @@ return {BuildCommand: true, mainPath_};
139
139
  export function CheckCommand(filePath_) {
140
140
  return {CheckCommand: true, filePath_};
141
141
  }
142
+ export function SymbolsCommand(outPath_, filePaths_) {
143
+ return {SymbolsCommand: true, outPath_, filePaths_};
144
+ }
142
145
 
143
146
  // type CommandLineError
144
147
  export function CommandLineError(problem_) {
@@ -153,6 +156,7 @@ These are the commands:
153
156
  browser <main-file> Compile the main file for the browser
154
157
  build <main-file> Build the main file
155
158
  check <firefly-file> Check the firefly source file for errors
159
+ symbols <firefly-file> Print a .tsv with the symbols of a firefly source file
156
160
  bootstrap Bootstrap the compiler
157
161
  `;
158
162
 
@@ -226,12 +230,43 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
226
230
  }
227
231
  return
228
232
  }
229
- {
233
+ if(command_a.BootstrapCommand) {
230
234
  const workingDirectory_ = ff_core_NodeSystem.NodeSystem_path(system_, ".");
231
235
  const fakeLocation_ = ff_compiler_Syntax.Location("<core>", 0, 0);
232
236
  ff_compiler_Builder.build_(system_, ff_compiler_JsEmitter.EmitNode(), ff_compiler_Syntax.PackagePair("ff", "compiler"), "Main", ff_compiler_Dependencies.ResolvedDependencies(ff_compiler_Syntax.PackagePair("ff", "compiler"), ff_core_List.List_toMap([ff_core_Pair.Pair(ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.PackageInfo(ff_compiler_Syntax.DPackage(fakeLocation_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.Version(fakeLocation_, 0, 0, 0), ff_compiler_Syntax.TargetNames(true, false)), [], [ff_compiler_Syntax.DInclude(fakeLocation_, "node_modules")]))], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toMap([ff_core_Pair.Pair(ff_compiler_Syntax.PackagePair("ff", "compiler"), ff_core_Path.Path_slash(workingDirectory_, "compiler")), ff_core_Pair.Pair(ff_compiler_Syntax.PackagePair("ff", "core"), ff_core_Path.Path_slash(workingDirectory_, "core"))], 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)), ff_core_Option.None(), ff_core_Path.Path_slash(ff_core_Path.Path_slash(workingDirectory_, "output"), "temporary"), ff_core_Path.Path_slash(ff_core_Path.Path_slash(workingDirectory_, "output"), "js"), true, ff_compiler_ModuleCache.new_(0))
233
237
  return
234
238
  }
239
+ {
240
+ const outPath_ = command_a.outPath_;
241
+ const filePaths_ = command_a.filePaths_;
242
+ const columns_ = ff_core_List.List_flatMap(filePaths_, ((filePath_) => {
243
+ const path_ = ff_core_NodeSystem.NodeSystem_path(system_, filePath_);
244
+ const code_ = ff_core_Path.Path_readText(path_);
245
+ const packagePair_ = ff_compiler_Syntax.PackagePair("script", "script");
246
+ const tokens_ = ff_compiler_Tokenizer.tokenize_(ff_core_Path.Path_absolute(path_), code_, ff_core_Option.None(), false);
247
+ const parser_ = ff_compiler_Parser.new_(packagePair_, ff_core_Path.Path_base(path_), tokens_, true, ff_compiler_LspHook.disabled_());
248
+ const module_ = ff_compiler_Parser.Parser_parseModuleWithPackageInfo(parser_).module_;
249
+ return ff_compiler_Main.makeSymbolColumns_(module_)
250
+ }));
251
+ const rowCount_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_List.List_last(ff_core_List.List_sortBy(columns_, ((_w1) => {
252
+ return _w1.length
253
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)), ((_w1) => {
254
+ return _w1.length
255
+ })), (() => {
256
+ return 0
257
+ }));
258
+ const tsv_ = ff_core_List.List_map(ff_core_Int.Int_until(0, rowCount_), ((i_) => {
259
+ return ff_core_List.List_map(columns_, ((_w1) => {
260
+ return ff_core_Option.Option_else(ff_core_List.List_get(_w1, i_), (() => {
261
+ return ""
262
+ }))
263
+ }))
264
+ }));
265
+ ff_core_Path.Path_writeText(ff_core_NodeSystem.NodeSystem_path(system_, outPath_), (ff_core_List.List_join(ff_core_List.List_map(tsv_, ((_w1) => {
266
+ return ff_core_List.List_join(_w1, "\t")
267
+ })), "\n") + "\n"))
268
+ return
269
+ }
235
270
  }
236
271
  ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch(ff_core_Try.Try_tryCatch(ff_core_Core.try_((() => {
237
272
  const command_ = ff_compiler_Main.parseCommandLine_(ff_core_NodeSystem.NodeSystem_arguments(system_));
@@ -355,6 +390,24 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Ma
355
390
  }
356
391
  return
357
392
  }
393
+ if(arguments_a.length >= 1 && arguments_a[0] === "symbols") {
394
+ const checkArguments_ = arguments_a.slice(1);
395
+ {
396
+ const _1 = checkArguments_;
397
+ if(_1.length >= 2) {
398
+ const outName_ = _1[0];
399
+ const fileName_ = _1[1];
400
+ const fileNames_ = _1.slice(2);
401
+ if(ff_core_String.String_endsWith(outName_, ".tsv")) {
402
+ return ff_compiler_Main.SymbolsCommand(outName_, [fileName_, ...fileNames_])
403
+ }
404
+ }
405
+ {
406
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Main.CommandLineError(("You must specify a output file (.tsv) and 1+ Firefly files (.ff) to symbols." + ff_compiler_Main.usageString_)), ff_compiler_Main.ff_core_Any_HasAnyTag$ff_compiler_Main_CommandLineError)})
407
+ }
408
+ }
409
+ return
410
+ }
358
411
  if(arguments_a.length === 2 && arguments_a[0] === "bootstrap") {
359
412
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Main.CommandLineError(("bootstrap takes no arguments" + ff_compiler_Main.usageString_)), ff_compiler_Main.ff_core_Any_HasAnyTag$ff_compiler_Main_CommandLineError)})
360
413
  }
@@ -423,6 +476,88 @@ return ff_core_Path.Path(url_.fileURLToPath((new URL(moduleUrl_.slice(0, (-suffi
423
476
  }
424
477
  }
425
478
 
479
+ export function makeSymbolColumns_(module_) {
480
+ function processSignature_(signature_) {
481
+ const generics_ = (ff_core_List.List_isEmpty(signature_.generics_)
482
+ ? ""
483
+ : (("[" + ff_core_List.List_join(signature_.generics_, ", ")) + "]"));
484
+ const parameters_ = (("(" + ff_core_List.List_join(ff_core_List.List_map(signature_.parameters_, ((_w1) => {
485
+ return _w1.name_
486
+ })), ", ")) + ")");
487
+ return ((signature_.name_ + generics_) + parameters_)
488
+ }
489
+ const traits_ = ff_core_List.List_map(module_.traits_, ((x_) => {
490
+ const generics_ = ff_core_List.List_dropFirst(x_.generics_, 1);
491
+ const g_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_List.List_first(x_.generics_), ((_w1) => {
492
+ return (_w1 + ": ")
493
+ })), (() => {
494
+ return ""
495
+ }));
496
+ return {
497
+ generics_: generics_,
498
+ name_: (g_ + x_.name_),
499
+ symbols_: ff_core_List.List_map(x_.methods_, ((_w1) => {
500
+ return processSignature_(_w1)
501
+ }))
502
+ }
503
+ }));
504
+ const types_ = ff_core_List.List_map(module_.types_, ((x_) => {
505
+ const variants_ = ff_core_List.List_map(x_.variants_, ((variant_) => {
506
+ const parameters_ = ((ff_core_List.List_isEmpty(variant_.fields_) && ff_core_List.List_isEmpty(x_.commonFields_))
507
+ ? ""
508
+ : (("(" + ff_core_List.List_join(ff_core_List.List_map([...x_.commonFields_, ...variant_.fields_], ((_w1) => {
509
+ return _w1.name_
510
+ })), ", ")) + ")"));
511
+ return (variant_.name_ + parameters_)
512
+ }));
513
+ const methods_ = ff_core_List.List_map(ff_core_List.List_map(ff_core_List.List_flatMap(ff_core_List.List_filter(module_.extends_, ((_w1) => {
514
+ {
515
+ const _1 = _w1.type_;
516
+ if(_1.TConstructor) {
517
+ const name_ = _1.name_;
518
+ return (name_ === x_.name_)
519
+ }
520
+ {
521
+ return false
522
+ }
523
+ }
524
+ })), ((_w1) => {
525
+ return _w1.methods_
526
+ })), ((_w1) => {
527
+ return _w1.signature_
528
+ })), ((_w1) => {
529
+ return processSignature_(_w1)
530
+ }));
531
+ return {
532
+ generics_: x_.generics_,
533
+ name_: x_.name_,
534
+ symbols_: [...variants_, ...methods_]
535
+ }
536
+ }));
537
+ const toplevel_ = (ff_core_List.List_isEmpty(module_.functions_)
538
+ ? []
539
+ : (function() {
540
+ const functions_ = ff_core_List.List_map(module_.functions_, ((_w1) => {
541
+ return processSignature_(_w1.signature_)
542
+ }));
543
+ return [{
544
+ generics_: [],
545
+ name_: "",
546
+ symbols_: [...ff_core_List.List_map(module_.lets_, ((_w1) => {
547
+ return _w1.name_
548
+ })), ...functions_]
549
+ }]
550
+ })());
551
+ const all_ = [...toplevel_, ...types_, ...traits_];
552
+ return ff_core_List.List_map(all_, ((r_) => {
553
+ const generics_ = (ff_core_List.List_isEmpty(r_.generics_)
554
+ ? ""
555
+ : (("[" + ff_core_List.List_join(r_.generics_, ", ")) + "]"));
556
+ const header_ = ff_core_String.String_trim((((module_.file_ + " ") + r_.name_) + generics_));
557
+ return [header_, ...ff_core_List.List_sort(r_.symbols_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)]
558
+ }))
559
+ }
560
+
426
561
  export async function main_$(system_, $task) {
427
562
  const fireflyPath_ = (await ff_compiler_Main.detectFireflyPath_$(system_, $task));
428
563
  async function buildScript_$(mainFile_, mainPackagePair_, emitTarget_, resolvedDependencies_, $task) {
@@ -493,12 +628,43 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
493
628
  }
494
629
  return
495
630
  }
496
- {
631
+ if(command_a.BootstrapCommand) {
497
632
  const workingDirectory_ = (await ff_core_NodeSystem.NodeSystem_path$(system_, ".", $task));
498
633
  const fakeLocation_ = ff_compiler_Syntax.Location("<core>", 0, 0);
499
634
  (await ff_compiler_Builder.build_$(system_, ff_compiler_JsEmitter.EmitNode(), ff_compiler_Syntax.PackagePair("ff", "compiler"), "Main", ff_compiler_Dependencies.ResolvedDependencies(ff_compiler_Syntax.PackagePair("ff", "compiler"), ff_core_List.List_toMap([ff_core_Pair.Pair(ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.PackageInfo(ff_compiler_Syntax.DPackage(fakeLocation_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.Version(fakeLocation_, 0, 0, 0), ff_compiler_Syntax.TargetNames(true, false)), [], [ff_compiler_Syntax.DInclude(fakeLocation_, "node_modules")]))], ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toMap([ff_core_Pair.Pair(ff_compiler_Syntax.PackagePair("ff", "compiler"), (await ff_core_Path.Path_slash$(workingDirectory_, "compiler", $task))), ff_core_Pair.Pair(ff_compiler_Syntax.PackagePair("ff", "core"), (await ff_core_Path.Path_slash$(workingDirectory_, "core", $task)))], 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)), ff_core_Option.None(), (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(workingDirectory_, "output", $task)), "temporary", $task)), (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(workingDirectory_, "output", $task)), "js", $task)), true, ff_compiler_ModuleCache.new_(0), $task))
500
635
  return
501
636
  }
637
+ {
638
+ const outPath_ = command_a.outPath_;
639
+ const filePaths_ = command_a.filePaths_;
640
+ const columns_ = (await ff_core_List.List_flatMap$(filePaths_, (async (filePath_, $task) => {
641
+ const path_ = (await ff_core_NodeSystem.NodeSystem_path$(system_, filePath_, $task));
642
+ const code_ = (await ff_core_Path.Path_readText$(path_, $task));
643
+ const packagePair_ = ff_compiler_Syntax.PackagePair("script", "script");
644
+ const tokens_ = ff_compiler_Tokenizer.tokenize_((await ff_core_Path.Path_absolute$(path_, $task)), code_, ff_core_Option.None(), false);
645
+ const parser_ = ff_compiler_Parser.new_(packagePair_, (await ff_core_Path.Path_base$(path_, $task)), tokens_, true, ff_compiler_LspHook.disabled_());
646
+ const module_ = ff_compiler_Parser.Parser_parseModuleWithPackageInfo(parser_).module_;
647
+ return ff_compiler_Main.makeSymbolColumns_(module_)
648
+ }), $task));
649
+ const rowCount_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_List.List_last(ff_core_List.List_sortBy(columns_, ((_w1) => {
650
+ return _w1.length
651
+ }), ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int)), ((_w1) => {
652
+ return _w1.length
653
+ })), (() => {
654
+ return 0
655
+ }));
656
+ const tsv_ = ff_core_List.List_map(ff_core_Int.Int_until(0, rowCount_), ((i_) => {
657
+ return ff_core_List.List_map(columns_, ((_w1) => {
658
+ return ff_core_Option.Option_else(ff_core_List.List_get(_w1, i_), (() => {
659
+ return ""
660
+ }))
661
+ }))
662
+ }));
663
+ (await ff_core_Path.Path_writeText$((await ff_core_NodeSystem.NodeSystem_path$(system_, outPath_, $task)), (ff_core_List.List_join(ff_core_List.List_map(tsv_, ((_w1) => {
664
+ return ff_core_List.List_join(_w1, "\t")
665
+ })), "\n") + "\n"), $task))
666
+ return
667
+ }
502
668
  }
503
669
  ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch(ff_core_Try.Try_tryCatch((await ff_core_Core.try_$((async ($task) => {
504
670
  const command_ = ff_compiler_Main.parseCommandLine_((await ff_core_NodeSystem.NodeSystem_arguments$(system_, $task)));
@@ -622,6 +788,24 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Ma
622
788
  }
623
789
  return
624
790
  }
791
+ if(arguments_a.length >= 1 && arguments_a[0] === "symbols") {
792
+ const checkArguments_ = arguments_a.slice(1);
793
+ {
794
+ const _1 = checkArguments_;
795
+ if(_1.length >= 2) {
796
+ const outName_ = _1[0];
797
+ const fileName_ = _1[1];
798
+ const fileNames_ = _1.slice(2);
799
+ if(ff_core_String.String_endsWith(outName_, ".tsv")) {
800
+ return ff_compiler_Main.SymbolsCommand(outName_, [fileName_, ...fileNames_])
801
+ }
802
+ }
803
+ {
804
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Main.CommandLineError(("You must specify a output file (.tsv) and 1+ Firefly files (.ff) to symbols." + ff_compiler_Main.usageString_)), ff_compiler_Main.ff_core_Any_HasAnyTag$ff_compiler_Main_CommandLineError)})
805
+ }
806
+ }
807
+ return
808
+ }
625
809
  if(arguments_a.length === 2 && arguments_a[0] === "bootstrap") {
626
810
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Main.CommandLineError(("bootstrap takes no arguments" + ff_compiler_Main.usageString_)), ff_compiler_Main.ff_core_Any_HasAnyTag$ff_compiler_Main_CommandLineError)})
627
811
  }
@@ -690,6 +874,88 @@ return ff_core_Path.Path(url_.fileURLToPath((new URL(moduleUrl_.slice(0, (-suffi
690
874
  }
691
875
  }
692
876
 
877
+ export async function makeSymbolColumns_$(module_, $task) {
878
+ function processSignature_(signature_) {
879
+ const generics_ = (ff_core_List.List_isEmpty(signature_.generics_)
880
+ ? ""
881
+ : (("[" + ff_core_List.List_join(signature_.generics_, ", ")) + "]"));
882
+ const parameters_ = (("(" + ff_core_List.List_join(ff_core_List.List_map(signature_.parameters_, ((_w1) => {
883
+ return _w1.name_
884
+ })), ", ")) + ")");
885
+ return ((signature_.name_ + generics_) + parameters_)
886
+ }
887
+ const traits_ = ff_core_List.List_map(module_.traits_, ((x_) => {
888
+ const generics_ = ff_core_List.List_dropFirst(x_.generics_, 1);
889
+ const g_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_List.List_first(x_.generics_), ((_w1) => {
890
+ return (_w1 + ": ")
891
+ })), (() => {
892
+ return ""
893
+ }));
894
+ return {
895
+ generics_: generics_,
896
+ name_: (g_ + x_.name_),
897
+ symbols_: ff_core_List.List_map(x_.methods_, ((_w1) => {
898
+ return processSignature_(_w1)
899
+ }))
900
+ }
901
+ }));
902
+ const types_ = ff_core_List.List_map(module_.types_, ((x_) => {
903
+ const variants_ = ff_core_List.List_map(x_.variants_, ((variant_) => {
904
+ const parameters_ = ((ff_core_List.List_isEmpty(variant_.fields_) && ff_core_List.List_isEmpty(x_.commonFields_))
905
+ ? ""
906
+ : (("(" + ff_core_List.List_join(ff_core_List.List_map([...x_.commonFields_, ...variant_.fields_], ((_w1) => {
907
+ return _w1.name_
908
+ })), ", ")) + ")"));
909
+ return (variant_.name_ + parameters_)
910
+ }));
911
+ const methods_ = ff_core_List.List_map(ff_core_List.List_map(ff_core_List.List_flatMap(ff_core_List.List_filter(module_.extends_, ((_w1) => {
912
+ {
913
+ const _1 = _w1.type_;
914
+ if(_1.TConstructor) {
915
+ const name_ = _1.name_;
916
+ return (name_ === x_.name_)
917
+ }
918
+ {
919
+ return false
920
+ }
921
+ }
922
+ })), ((_w1) => {
923
+ return _w1.methods_
924
+ })), ((_w1) => {
925
+ return _w1.signature_
926
+ })), ((_w1) => {
927
+ return processSignature_(_w1)
928
+ }));
929
+ return {
930
+ generics_: x_.generics_,
931
+ name_: x_.name_,
932
+ symbols_: [...variants_, ...methods_]
933
+ }
934
+ }));
935
+ const toplevel_ = (ff_core_List.List_isEmpty(module_.functions_)
936
+ ? []
937
+ : (await (async function() {
938
+ const functions_ = ff_core_List.List_map(module_.functions_, ((_w1) => {
939
+ return processSignature_(_w1.signature_)
940
+ }));
941
+ return [{
942
+ generics_: [],
943
+ name_: "",
944
+ symbols_: [...ff_core_List.List_map(module_.lets_, ((_w1) => {
945
+ return _w1.name_
946
+ })), ...functions_]
947
+ }]
948
+ })()));
949
+ const all_ = [...toplevel_, ...types_, ...traits_];
950
+ return ff_core_List.List_map(all_, ((r_) => {
951
+ const generics_ = (ff_core_List.List_isEmpty(r_.generics_)
952
+ ? ""
953
+ : (("[" + ff_core_List.List_join(r_.generics_, ", ")) + "]"));
954
+ const header_ = ff_core_String.String_trim((((module_.file_ + " ") + r_.name_) + generics_));
955
+ return [header_, ...ff_core_List.List_sort(r_.symbols_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)]
956
+ }))
957
+ }
958
+
693
959
 
694
960
 
695
961
  export const ff_core_Any_HasAnyTag$ff_compiler_Main_MainCommand = {
@@ -729,10 +995,14 @@ if(value_a.BuildCommand) {
729
995
  const z_ = value_a;
730
996
  return ((("BuildCommand" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.mainPath_)) + ")")
731
997
  }
732
- {
998
+ if(value_a.CheckCommand) {
733
999
  const z_ = value_a;
734
1000
  return ((("CheckCommand" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.filePath_)) + ")")
735
1001
  }
1002
+ {
1003
+ const z_ = value_a;
1004
+ return ((((("SymbolsCommand" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.outPath_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Show.ff_core_Show_Show$ff_core_String_String).show_(z_.filePaths_)) + ")")
1005
+ }
736
1006
  },
737
1007
  async show_$(value_, $task) {
738
1008
  const value_a = value_;
@@ -752,10 +1022,14 @@ if(value_a.BuildCommand) {
752
1022
  const z_ = value_a;
753
1023
  return ((("BuildCommand" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.mainPath_)) + ")")
754
1024
  }
755
- {
1025
+ if(value_a.CheckCommand) {
756
1026
  const z_ = value_a;
757
1027
  return ((("CheckCommand" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.filePath_)) + ")")
758
1028
  }
1029
+ {
1030
+ const z_ = value_a;
1031
+ return ((((("SymbolsCommand" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.outPath_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Show.ff_core_Show_Show$ff_core_String_String).show_(z_.filePaths_)) + ")")
1032
+ }
759
1033
  }
760
1034
  };
761
1035
 
@@ -803,6 +1077,11 @@ const x_ = x_a;
803
1077
  const y_ = y_a;
804
1078
  return (x_.filePath_ === y_.filePath_)
805
1079
  }
1080
+ if(x_a.SymbolsCommand && y_a.SymbolsCommand) {
1081
+ const x_ = x_a;
1082
+ const y_ = y_a;
1083
+ return ((x_.outPath_ === y_.outPath_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String).equals_(x_.filePaths_, y_.filePaths_))
1084
+ }
806
1085
  {
807
1086
  return false
808
1087
  }
@@ -833,6 +1112,11 @@ const x_ = x_a;
833
1112
  const y_ = y_a;
834
1113
  return (x_.filePath_ === y_.filePath_)
835
1114
  }
1115
+ if(x_a.SymbolsCommand && y_a.SymbolsCommand) {
1116
+ const x_ = x_a;
1117
+ const y_ = y_a;
1118
+ return ((x_.outPath_ === y_.outPath_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String).equals_(x_.filePaths_, y_.filePaths_))
1119
+ }
836
1120
  {
837
1121
  return false
838
1122
  }
@@ -918,6 +1202,22 @@ return ff_core_Ordering.OrderingSame()
918
1202
  }
919
1203
  return
920
1204
  }
1205
+ if(x_a.SymbolsCommand && y_a.SymbolsCommand) {
1206
+ const x_ = x_a;
1207
+ const y_ = y_a;
1208
+ const outPathOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.outPath_, y_.outPath_);
1209
+ if((outPathOrdering_ !== ff_core_Ordering.OrderingSame())) {
1210
+ return outPathOrdering_
1211
+ } else {
1212
+ const filePathsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String).compare_(x_.filePaths_, y_.filePaths_);
1213
+ if((filePathsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1214
+ return filePathsOrdering_
1215
+ } else {
1216
+ return ff_core_Ordering.OrderingSame()
1217
+ }
1218
+ }
1219
+ return
1220
+ }
921
1221
  {
922
1222
  function number_(z_) {
923
1223
  const z_a = z_;
@@ -933,9 +1233,12 @@ return 2
933
1233
  if(z_a.BuildCommand) {
934
1234
  return 3
935
1235
  }
936
- {
1236
+ if(z_a.CheckCommand) {
937
1237
  return 4
938
1238
  }
1239
+ {
1240
+ return 5
1241
+ }
939
1242
  }
940
1243
  return ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int.compare_(number_(x_), number_(y_))
941
1244
  }
@@ -995,6 +1298,22 @@ return ff_core_Ordering.OrderingSame()
995
1298
  }
996
1299
  return
997
1300
  }
1301
+ if(x_a.SymbolsCommand && y_a.SymbolsCommand) {
1302
+ const x_ = x_a;
1303
+ const y_ = y_a;
1304
+ const outPathOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.outPath_, y_.outPath_);
1305
+ if((outPathOrdering_ !== ff_core_Ordering.OrderingSame())) {
1306
+ return outPathOrdering_
1307
+ } else {
1308
+ const filePathsOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_List_List(ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String).compare_(x_.filePaths_, y_.filePaths_);
1309
+ if((filePathsOrdering_ !== ff_core_Ordering.OrderingSame())) {
1310
+ return filePathsOrdering_
1311
+ } else {
1312
+ return ff_core_Ordering.OrderingSame()
1313
+ }
1314
+ }
1315
+ return
1316
+ }
998
1317
  {
999
1318
  function number_(z_) {
1000
1319
  const z_a = z_;
@@ -1010,9 +1329,12 @@ return 2
1010
1329
  if(z_a.BuildCommand) {
1011
1330
  return 3
1012
1331
  }
1013
- {
1332
+ if(z_a.CheckCommand) {
1014
1333
  return 4
1015
1334
  }
1335
+ {
1336
+ return 5
1337
+ }
1016
1338
  }
1017
1339
  return ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int.compare_(number_(x_), number_(y_))
1018
1340
  }
@@ -1094,7 +1416,7 @@ serialization_.offset_ += 1;
1094
1416
  ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.mainPath_)
1095
1417
  return
1096
1418
  }
1097
- {
1419
+ if(value_a.CheckCommand) {
1098
1420
  const v_ = value_a;
1099
1421
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 29), 0);
1100
1422
  ff_core_Serializable.Serialization_autoResize(serialization_, 1);
@@ -1103,6 +1425,16 @@ serialization_.offset_ += 1;
1103
1425
  ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.filePath_)
1104
1426
  return
1105
1427
  }
1428
+ {
1429
+ const v_ = value_a;
1430
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 31), 0);
1431
+ ff_core_Serializable.Serialization_autoResize(serialization_, 1);
1432
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 5);
1433
+ serialization_.offset_ += 1;
1434
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.outPath_);
1435
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).serializeUsing_(serialization_, v_.filePaths_)
1436
+ return
1437
+ }
1106
1438
  },
1107
1439
  deserializeUsing_(serialization_) {
1108
1440
  const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
@@ -1129,6 +1461,10 @@ if(_1 === 4) {
1129
1461
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 29), 0);
1130
1462
  return ff_compiler_Main.CheckCommand(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_))
1131
1463
  }
1464
+ if(_1 === 5) {
1465
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 31), 0);
1466
+ return ff_compiler_Main.SymbolsCommand(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).deserializeUsing_(serialization_))
1467
+ }
1132
1468
  {
1133
1469
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
1134
1470
  }
@@ -1173,7 +1509,7 @@ serialization_.offset_ += 1;
1173
1509
  ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.mainPath_)
1174
1510
  return
1175
1511
  }
1176
- {
1512
+ if(value_a.CheckCommand) {
1177
1513
  const v_ = value_a;
1178
1514
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 29), 0);
1179
1515
  ff_core_Serializable.Serialization_autoResize(serialization_, 1);
@@ -1182,6 +1518,16 @@ serialization_.offset_ += 1;
1182
1518
  ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.filePath_)
1183
1519
  return
1184
1520
  }
1521
+ {
1522
+ const v_ = value_a;
1523
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 31), 0);
1524
+ ff_core_Serializable.Serialization_autoResize(serialization_, 1);
1525
+ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 5);
1526
+ serialization_.offset_ += 1;
1527
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.outPath_);
1528
+ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).serializeUsing_(serialization_, v_.filePaths_)
1529
+ return
1530
+ }
1185
1531
  },
1186
1532
  async deserializeUsing_$(serialization_, $task) {
1187
1533
  const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
@@ -1208,6 +1554,10 @@ if(_1 === 4) {
1208
1554
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 29), 0);
1209
1555
  return ff_compiler_Main.CheckCommand(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_))
1210
1556
  }
1557
+ if(_1 === 5) {
1558
+ serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 31), 0);
1559
+ return ff_compiler_Main.SymbolsCommand(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).deserializeUsing_(serialization_))
1560
+ }
1211
1561
  {
1212
1562
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
1213
1563
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly compiler",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.5.45",
7
+ "version": "0.5.46",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly language support",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.5.45",
7
+ "version": "0.5.46",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"