firefly-compiler 0.5.44 → 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/bin/firefly.mjs CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  import * as firefly from '../output/js/ff/compiler/Main.mjs';
@@ -32,11 +32,21 @@ extend self: Inference {
32
32
  let environment = Environment.new(module, otherModules, alreadyFlat = False)
33
33
 
34
34
  let errors = Array.new()
35
- let traits = catchManyInto(errors, module.traits) {self.inferTraitDefinition(environment, _)}
36
- let instances = catchManyInto(errors, module.instances) {self.inferInstanceDefinition(environment, _)}
37
- let lets = catchManyInto(errors, module.lets) {self.inferLetDefinition(environment, _)}
38
- let functions = catchManyInto(errors, module.functions) {self.inferFunctionDefinition(environment, _)}
39
- let extends = catchManyInto(errors, module.extends) {self.inferExtendDefinition(environment, _)}
35
+ let traits = Syntax.catchManyInto(errors, module.traits) {
36
+ self.inferTraitDefinition(environment, _)
37
+ }
38
+ let instances = Syntax.catchManyInto(errors, module.instances) {
39
+ self.inferInstanceDefinition(environment, _)
40
+ }
41
+ let lets = Syntax.catchManyInto(errors, module.lets) {
42
+ self.inferLetDefinition(environment, _)
43
+ }
44
+ let functions = Syntax.catchManyInto(errors, module.functions) {
45
+ self.inferFunctionDefinition(environment, _)
46
+ }
47
+ let extends = Syntax.catchManyInto(errors, module.extends) {
48
+ self.inferExtendDefinition(environment, _)
49
+ }
40
50
  errors.drain().{
41
51
  | [] =>
42
52
  | [Pair(_, error)] => error.rethrow()
@@ -96,7 +106,7 @@ extend self: Inference {
96
106
  }
97
107
 
98
108
  definition.DInstance(
99
- methods = catchMany(definition.methods) {instanceFunction =>
109
+ methods = Syntax.catchMany(definition.methods) {instanceFunction =>
100
110
  let methodName = instanceFunction.signature.name
101
111
  let traitMethodName = traitName.reverse().dropWhile {_ != '.'}.reverse() + methodName
102
112
  let traitMethodScheme = environment.symbols.get(traitMethodName).else {
@@ -150,7 +160,7 @@ extend self: Inference {
150
160
  valueType = definition.type
151
161
  default = None
152
162
  )
153
- let functions = catchMany(definition.methods) {method =>
163
+ let functions = Syntax.catchMany(definition.methods) {method =>
154
164
  let signature = method.signature.Signature(
155
165
  generics = [...definition.generics, ...method.signature.generics]
156
166
  constraints = [...definition.constraints, ...method.signature.constraints]
@@ -1223,30 +1233,3 @@ constraintsToInstances(constraints: List[Constraint]): Map[InstanceKey, Instance
1223
1233
  )
1224
1234
  }.toMap()
1225
1235
  }
1226
-
1227
- catchMany[T](list: List[T], body: T => T): List[T] {
1228
- let errors = Array.new()
1229
- let result = catchManyInto(errors, list, body)
1230
- errors.drain().{
1231
- | [] => result
1232
- | [Pair(_, error)] => error.rethrow()
1233
- | allErrors => throw(CompileErrors(allErrors.map {_.first}))
1234
- }
1235
- }
1236
-
1237
- catchManyInto[T](errors: Array[Pair[CompileError, Error]], list: List[T], body: T => T): List[T] {
1238
- let result = list.map {x =>
1239
- try {
1240
- body(x)
1241
- } tryCatch {| CompileError(at, message), error =>
1242
- errors.push(Pair(CompileError(at, message), error))
1243
- x
1244
- } catch {| CompileErrors(compileErrors), error =>
1245
- compileErrors.each {compileError =>
1246
- errors.push(Pair(compileError, error))
1247
- }
1248
- x
1249
- }
1250
- }
1251
- if(errors.isEmpty()) {result} else {[]}
1252
- }
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
+ }
@@ -58,16 +58,27 @@ extend self: Resolver {
58
58
  module.file.replace("\\", "/").reverse().takeWhile {_ != '/'}.reverse().takeWhile {_ != '.'}
59
59
  let self2 = self.processImports(module.imports, otherModules)
60
60
  let self3 = self2.processDefinitions(module, None)
61
+
62
+ let errors = Array.new()
61
63
  let module2 = module.Module(
62
- types = checkDuplicates(module.types.map {self3.resolveTypeDefinition(_)}) {_.name} {_.at}
63
- traits = checkDuplicates(module.traits.map {self3.resolveTraitDefinition(_)}) {_.name} {_.at}
64
- instances = module.instances.map {self3.resolveInstanceDefinition(_)}
65
- extends = module.extends.map {self3.resolveExtendDefinition(_)}
66
- lets = checkDuplicates(module.lets.map {self3.resolveLetDefinition(_, True)}) {_.name} {_.at}
67
- functions = checkDuplicates(
68
- module.functions.map {self3.resolveFunctionDefinition(_, True, False)}
69
- ) {_.signature.name} {_.at}
64
+ types = Syntax.catchManyInto(errors, module.types) {self3.resolveTypeDefinition(_)}
65
+ traits = Syntax.catchManyInto(errors, module.traits) {self3.resolveTraitDefinition(_)}
66
+ instances = Syntax.catchManyInto(errors, module.instances) {self3.resolveInstanceDefinition(_)}
67
+ extends = Syntax.catchManyInto(errors, module.extends) {self3.resolveExtendDefinition(_)}
68
+ lets = Syntax.catchManyInto(errors, module.lets) {self3.resolveLetDefinition(_, True)}
69
+ functions = Syntax.catchManyInto(errors, module.functions) {
70
+ self3.resolveFunctionDefinition(_, True, False)
71
+ }
70
72
  )
73
+ errors.drain().{
74
+ | [] =>
75
+ | [Pair(_, error)] => error.rethrow()
76
+ | allErrors => throw(CompileErrors(allErrors.map {_.first}))
77
+ }
78
+ checkDuplicates(module2.types) {_.name} {_.at}
79
+ checkDuplicates(module2.traits) {_.name} {_.at}
80
+ checkDuplicates(module2.lets) {_.name} {_.at}
81
+ checkDuplicates(module2.functions) {_.signature.name} {_.at}
71
82
  let groupedExtendMethods = module2.extends.map {x =>
72
83
  Pair(x.type.show([]).takeWhile {_.isAsciiLetterOrDigit()}, x.methods)
73
84
  }.group()
@@ -283,3 +283,30 @@ extend self: Type {
283
283
  go(self)
284
284
  }
285
285
  }
286
+
287
+ catchMany[T](list: List[T], body: T => T): List[T] {
288
+ let errors = Array.new()
289
+ let result = catchManyInto(errors, list, body)
290
+ errors.drain().{
291
+ | [] => result
292
+ | [Pair(_, error)] => error.rethrow()
293
+ | allErrors => throw(CompileErrors(allErrors.map {_.first}))
294
+ }
295
+ }
296
+
297
+ catchManyInto[T](errors: Array[Pair[CompileError, Error]], list: List[T], body: T => T): List[T] {
298
+ let result = list.map {x =>
299
+ try {
300
+ body(x)
301
+ } tryCatch {| CompileError(at, message), error =>
302
+ errors.push(Pair(CompileError(at, message), error))
303
+ x
304
+ } catch {| CompileErrors(compileErrors), error =>
305
+ compileErrors.each {compileError =>
306
+ errors.push(Pair(compileError, error))
307
+ }
308
+ x
309
+ }
310
+ }
311
+ if(errors.isEmpty()) {result} else {[]}
312
+ }
@@ -142,59 +142,6 @@ return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_
142
142
  })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey)
143
143
  }
144
144
 
145
- export function catchMany_(list_, body_) {
146
- const errors_ = ff_core_Array.new_();
147
- const result_ = ff_compiler_Inference.catchManyInto_(errors_, list_, body_);
148
- {
149
- const _1 = ff_core_Array.Array_drain(errors_);
150
- if(_1.length === 0) {
151
- return result_
152
- }
153
- if(_1.length === 1) {
154
- const error_ = _1[0].second_;
155
- return ff_core_Error.Error_rethrow(error_)
156
- }
157
- {
158
- const allErrors_ = _1;
159
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
160
- return _w1.first_
161
- }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
162
- return
163
- }
164
- }
165
- }
166
-
167
- export function catchManyInto_(errors_, list_, body_) {
168
- const result_ = ff_core_List.List_map(list_, ((x_) => {
169
- return ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch(ff_core_Core.try_((() => {
170
- return body_(x_)
171
- })), ((_1, _2) => {
172
- {
173
- const at_ = _1.at_;
174
- const message_ = _1.message_;
175
- const error_ = _2;
176
- errors_.array.push(ff_core_Pair.Pair(ff_compiler_Syntax.CompileError(at_, message_), error_));
177
- return x_
178
- }
179
- }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
180
- {
181
- const compileErrors_ = _1.errors_;
182
- const error_ = _2;
183
- for(let for_a = compileErrors_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
184
- const compileError_ = for_a[for_i];
185
- errors_.array.push(ff_core_Pair.Pair(compileError_, error_))
186
- };
187
- return x_
188
- }
189
- }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
190
- }));
191
- if(ff_core_Array.Array_isEmpty(errors_)) {
192
- return result_
193
- } else {
194
- return []
195
- }
196
- }
197
-
198
145
  export async function new_$(modules_, lspHook_, $task) {
199
146
  return ff_compiler_Inference.Inference(ff_compiler_Unification.new_(modules_, ff_compiler_LspHook.LspHook_isEnabled(lspHook_)), ff_core_StringMap.new_(), lspHook_)
200
147
  }
@@ -224,75 +171,22 @@ return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_
224
171
  })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey)
225
172
  }
226
173
 
227
- export async function catchMany_$(list_, body_, $task) {
228
- const errors_ = ff_core_Array.new_();
229
- const result_ = (await ff_compiler_Inference.catchManyInto_$(errors_, list_, body_, $task));
230
- {
231
- const _1 = ff_core_Array.Array_drain(errors_);
232
- if(_1.length === 0) {
233
- return result_
234
- }
235
- if(_1.length === 1) {
236
- const error_ = _1[0].second_;
237
- return ff_core_Error.Error_rethrow(error_)
238
- }
239
- {
240
- const allErrors_ = _1;
241
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
242
- return _w1.first_
243
- }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
244
- return
245
- }
246
- }
247
- }
248
-
249
- export async function catchManyInto_$(errors_, list_, body_, $task) {
250
- const result_ = (await ff_core_List.List_map$(list_, (async (x_, $task) => {
251
- return ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch((await ff_core_Core.try_$((async ($task) => {
252
- return (await body_(x_, $task))
253
- }), $task)), ((_1, _2) => {
254
- {
255
- const at_ = _1.at_;
256
- const message_ = _1.message_;
257
- const error_ = _2;
258
- errors_.array.push(ff_core_Pair.Pair(ff_compiler_Syntax.CompileError(at_, message_), error_));
259
- return x_
260
- }
261
- }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
262
- {
263
- const compileErrors_ = _1.errors_;
264
- const error_ = _2;
265
- for(let for_a = compileErrors_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
266
- const compileError_ = for_a[for_i];
267
- errors_.array.push(ff_core_Pair.Pair(compileError_, error_))
268
- };
269
- return x_
270
- }
271
- }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
272
- }), $task));
273
- if(ff_core_Array.Array_isEmpty(errors_)) {
274
- return result_
275
- } else {
276
- return []
277
- }
278
- }
279
-
280
174
  export function Inference_inferModule(self_, module_, otherModules_) {
281
175
  const environment_ = ff_compiler_Environment.new_(module_, otherModules_, false);
282
176
  const errors_ = ff_core_Array.new_();
283
- const traits_ = ff_compiler_Inference.catchManyInto_(errors_, module_.traits_, ((_w1) => {
177
+ const traits_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.traits_, ((_w1) => {
284
178
  return ff_compiler_Inference.Inference_inferTraitDefinition(self_, environment_, _w1)
285
179
  }));
286
- const instances_ = ff_compiler_Inference.catchManyInto_(errors_, module_.instances_, ((_w1) => {
180
+ const instances_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.instances_, ((_w1) => {
287
181
  return ff_compiler_Inference.Inference_inferInstanceDefinition(self_, environment_, _w1)
288
182
  }));
289
- const lets_ = ff_compiler_Inference.catchManyInto_(errors_, module_.lets_, ((_w1) => {
183
+ const lets_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.lets_, ((_w1) => {
290
184
  return ff_compiler_Inference.Inference_inferLetDefinition(self_, environment_, _w1)
291
185
  }));
292
- const functions_ = ff_compiler_Inference.catchManyInto_(errors_, module_.functions_, ((_w1) => {
186
+ const functions_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.functions_, ((_w1) => {
293
187
  return ff_compiler_Inference.Inference_inferFunctionDefinition(self_, environment_, _w1)
294
188
  }));
295
- const extends_ = ff_compiler_Inference.catchManyInto_(errors_, module_.extends_, ((_w1) => {
189
+ const extends_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.extends_, ((_w1) => {
296
190
  return ff_compiler_Inference.Inference_inferExtendDefinition(self_, environment_, _w1)
297
191
  }));
298
192
  do {
@@ -361,7 +255,7 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
361
255
  const _1 = definition_;
362
256
  {
363
257
  const _c = _1;
364
- return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_compiler_Inference.catchMany_(definition_.methods_, ((instanceFunction_) => {
258
+ return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_compiler_Syntax.catchMany_(definition_.methods_, ((instanceFunction_) => {
365
259
  const methodName_ = instanceFunction_.signature_.name_;
366
260
  const traitMethodName_ = (ff_core_String.String_reverse(ff_core_String.String_dropWhile(ff_core_String.String_reverse(traitName_), ((_w1) => {
367
261
  return (_w1 !== 46)
@@ -420,7 +314,7 @@ return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, value_)
420
314
 
421
315
  export function Inference_inferExtendDefinition(self_, environment_, definition_) {
422
316
  const selfParameter_ = ff_compiler_Syntax.Parameter(definition_.at_, false, definition_.name_, definition_.type_, ff_core_Option.None());
423
- const functions_ = ff_compiler_Inference.catchMany_(definition_.methods_, ((method_) => {
317
+ const functions_ = ff_compiler_Syntax.catchMany_(definition_.methods_, ((method_) => {
424
318
  const signature_ = (((_c) => {
425
319
  return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, [...definition_.generics_, ...method_.signature_.generics_], [...definition_.constraints_, ...method_.signature_.constraints_], [selfParameter_, ...method_.signature_.parameters_], _c.returnType_, _c.effect_)
426
320
  }))(method_.signature_);
@@ -2197,19 +2091,19 @@ return instantiated_
2197
2091
  export async function Inference_inferModule$(self_, module_, otherModules_, $task) {
2198
2092
  const environment_ = ff_compiler_Environment.new_(module_, otherModules_, false);
2199
2093
  const errors_ = ff_core_Array.new_();
2200
- const traits_ = ff_compiler_Inference.catchManyInto_(errors_, module_.traits_, ((_w1) => {
2094
+ const traits_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.traits_, ((_w1) => {
2201
2095
  return ff_compiler_Inference.Inference_inferTraitDefinition(self_, environment_, _w1)
2202
2096
  }));
2203
- const instances_ = ff_compiler_Inference.catchManyInto_(errors_, module_.instances_, ((_w1) => {
2097
+ const instances_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.instances_, ((_w1) => {
2204
2098
  return ff_compiler_Inference.Inference_inferInstanceDefinition(self_, environment_, _w1)
2205
2099
  }));
2206
- const lets_ = ff_compiler_Inference.catchManyInto_(errors_, module_.lets_, ((_w1) => {
2100
+ const lets_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.lets_, ((_w1) => {
2207
2101
  return ff_compiler_Inference.Inference_inferLetDefinition(self_, environment_, _w1)
2208
2102
  }));
2209
- const functions_ = ff_compiler_Inference.catchManyInto_(errors_, module_.functions_, ((_w1) => {
2103
+ const functions_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.functions_, ((_w1) => {
2210
2104
  return ff_compiler_Inference.Inference_inferFunctionDefinition(self_, environment_, _w1)
2211
2105
  }));
2212
- const extends_ = ff_compiler_Inference.catchManyInto_(errors_, module_.extends_, ((_w1) => {
2106
+ const extends_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.extends_, ((_w1) => {
2213
2107
  return ff_compiler_Inference.Inference_inferExtendDefinition(self_, environment_, _w1)
2214
2108
  }));
2215
2109
  do {
@@ -2278,7 +2172,7 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
2278
2172
  const _1 = definition_;
2279
2173
  {
2280
2174
  const _c = _1;
2281
- return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_compiler_Inference.catchMany_(definition_.methods_, ((instanceFunction_) => {
2175
+ return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_compiler_Syntax.catchMany_(definition_.methods_, ((instanceFunction_) => {
2282
2176
  const methodName_ = instanceFunction_.signature_.name_;
2283
2177
  const traitMethodName_ = (ff_core_String.String_reverse(ff_core_String.String_dropWhile(ff_core_String.String_reverse(traitName_), ((_w1) => {
2284
2178
  return (_w1 !== 46)
@@ -2337,7 +2231,7 @@ return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, value_)
2337
2231
 
2338
2232
  export async function Inference_inferExtendDefinition$(self_, environment_, definition_, $task) {
2339
2233
  const selfParameter_ = ff_compiler_Syntax.Parameter(definition_.at_, false, definition_.name_, definition_.type_, ff_core_Option.None());
2340
- const functions_ = ff_compiler_Inference.catchMany_(definition_.methods_, ((method_) => {
2234
+ const functions_ = ff_compiler_Syntax.catchMany_(definition_.methods_, ((method_) => {
2341
2235
  const signature_ = (((_c) => {
2342
2236
  return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, [...definition_.generics_, ...method_.signature_.generics_], [...definition_.constraints_, ...method_.signature_.constraints_], [selfParameter_, ...method_.signature_.parameters_], _c.returnType_, _c.effect_)
2343
2237
  }))(method_.signature_);
@@ -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
  }
@@ -163,37 +163,60 @@ return (_w1 !== 46)
163
163
  }));
164
164
  const self2_ = ff_compiler_Resolver.Resolver_processImports(self_, module_.imports_, otherModules_);
165
165
  const self3_ = ff_compiler_Resolver.Resolver_processDefinitions(self2_, module_, ff_core_Option.None());
166
+ const errors_ = ff_core_Array.new_();
166
167
  const module2_ = (((_c) => {
167
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.types_, ((_w1) => {
168
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_compiler_Syntax.catchManyInto_(errors_, module_.types_, ((_w1) => {
168
169
  return ff_compiler_Resolver.Resolver_resolveTypeDefinition(self3_, _w1)
169
- })), ((_w1) => {
170
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.traits_, ((_w1) => {
171
+ return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
172
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.instances_, ((_w1) => {
173
+ return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
174
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.extends_, ((_w1) => {
175
+ return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
176
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.lets_, ((_w1) => {
177
+ return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
178
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.functions_, ((_w1) => {
179
+ return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
180
+ })))
181
+ }))(module_);
182
+ do {
183
+ const _1 = ff_core_Array.Array_drain(errors_);
184
+ if(_1.length === 0) {
185
+
186
+ break
187
+ }
188
+ if(_1.length === 1) {
189
+ const error_ = _1[0].second_;
190
+ ff_core_Error.Error_rethrow(error_)
191
+ break
192
+ }
193
+ {
194
+ const allErrors_ = _1;
195
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
196
+ return _w1.first_
197
+ }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
198
+ }
199
+ } while(false);
200
+ ff_compiler_Resolver.checkDuplicates_(module2_.types_, ((_w1) => {
170
201
  return _w1.name_
171
202
  }), ((_w1) => {
172
203
  return _w1.at_
173
- })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.traits_, ((_w1) => {
174
- return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
175
- })), ((_w1) => {
204
+ }));
205
+ ff_compiler_Resolver.checkDuplicates_(module2_.traits_, ((_w1) => {
176
206
  return _w1.name_
177
207
  }), ((_w1) => {
178
208
  return _w1.at_
179
- })), ff_core_List.List_map(module_.instances_, ((_w1) => {
180
- return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
181
- })), ff_core_List.List_map(module_.extends_, ((_w1) => {
182
- return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
183
- })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.lets_, ((_w1) => {
184
- return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
185
- })), ((_w1) => {
209
+ }));
210
+ ff_compiler_Resolver.checkDuplicates_(module2_.lets_, ((_w1) => {
186
211
  return _w1.name_
187
212
  }), ((_w1) => {
188
213
  return _w1.at_
189
- })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.functions_, ((_w1) => {
190
- return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
191
- })), ((_w1) => {
214
+ }));
215
+ ff_compiler_Resolver.checkDuplicates_(module2_.functions_, ((_w1) => {
192
216
  return _w1.signature_.name_
193
217
  }), ((_w1) => {
194
218
  return _w1.at_
195
- })))
196
- }))(module_);
219
+ }));
197
220
  const groupedExtendMethods_ = ff_core_List.List_group(ff_core_List.List_map(module2_.extends_, ((x_) => {
198
221
  return ff_core_Pair.Pair(ff_core_String.String_takeWhile(ff_compiler_Syntax.Type_show(x_.type_, []), ((_w1) => {
199
222
  return ff_core_Char.Char_isAsciiLetterOrDigit(_w1)
@@ -1141,37 +1164,60 @@ return (_w1 !== 46)
1141
1164
  }));
1142
1165
  const self2_ = ff_compiler_Resolver.Resolver_processImports(self_, module_.imports_, otherModules_);
1143
1166
  const self3_ = ff_compiler_Resolver.Resolver_processDefinitions(self2_, module_, ff_core_Option.None());
1167
+ const errors_ = ff_core_Array.new_();
1144
1168
  const module2_ = (((_c) => {
1145
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.types_, ((_w1) => {
1169
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_compiler_Syntax.catchManyInto_(errors_, module_.types_, ((_w1) => {
1146
1170
  return ff_compiler_Resolver.Resolver_resolveTypeDefinition(self3_, _w1)
1147
- })), ((_w1) => {
1171
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.traits_, ((_w1) => {
1172
+ return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
1173
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.instances_, ((_w1) => {
1174
+ return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
1175
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.extends_, ((_w1) => {
1176
+ return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
1177
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.lets_, ((_w1) => {
1178
+ return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
1179
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.functions_, ((_w1) => {
1180
+ return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
1181
+ })))
1182
+ }))(module_);
1183
+ do {
1184
+ const _1 = ff_core_Array.Array_drain(errors_);
1185
+ if(_1.length === 0) {
1186
+
1187
+ break
1188
+ }
1189
+ if(_1.length === 1) {
1190
+ const error_ = _1[0].second_;
1191
+ ff_core_Error.Error_rethrow(error_)
1192
+ break
1193
+ }
1194
+ {
1195
+ const allErrors_ = _1;
1196
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
1197
+ return _w1.first_
1198
+ }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
1199
+ }
1200
+ } while(false);
1201
+ ff_compiler_Resolver.checkDuplicates_(module2_.types_, ((_w1) => {
1148
1202
  return _w1.name_
1149
1203
  }), ((_w1) => {
1150
1204
  return _w1.at_
1151
- })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.traits_, ((_w1) => {
1152
- return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
1153
- })), ((_w1) => {
1205
+ }));
1206
+ ff_compiler_Resolver.checkDuplicates_(module2_.traits_, ((_w1) => {
1154
1207
  return _w1.name_
1155
1208
  }), ((_w1) => {
1156
1209
  return _w1.at_
1157
- })), ff_core_List.List_map(module_.instances_, ((_w1) => {
1158
- return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
1159
- })), ff_core_List.List_map(module_.extends_, ((_w1) => {
1160
- return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
1161
- })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.lets_, ((_w1) => {
1162
- return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
1163
- })), ((_w1) => {
1210
+ }));
1211
+ ff_compiler_Resolver.checkDuplicates_(module2_.lets_, ((_w1) => {
1164
1212
  return _w1.name_
1165
1213
  }), ((_w1) => {
1166
1214
  return _w1.at_
1167
- })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.functions_, ((_w1) => {
1168
- return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
1169
- })), ((_w1) => {
1215
+ }));
1216
+ ff_compiler_Resolver.checkDuplicates_(module2_.functions_, ((_w1) => {
1170
1217
  return _w1.signature_.name_
1171
1218
  }), ((_w1) => {
1172
1219
  return _w1.at_
1173
- })))
1174
- }))(module_);
1220
+ }));
1175
1221
  const groupedExtendMethods_ = ff_core_List.List_group(ff_core_List.List_map(module2_.extends_, ((x_) => {
1176
1222
  return ff_core_Pair.Pair(ff_core_String.String_takeWhile(ff_compiler_Syntax.Type_show(x_.type_, []), ((_w1) => {
1177
1223
  return ff_core_Char.Char_isAsciiLetterOrDigit(_w1)
@@ -358,9 +358,111 @@ return {at_, major_, minor_, patch_};
358
358
 
359
359
 
360
360
 
361
+ export function catchMany_(list_, body_) {
362
+ const errors_ = ff_core_Array.new_();
363
+ const result_ = ff_compiler_Syntax.catchManyInto_(errors_, list_, body_);
364
+ {
365
+ const _1 = ff_core_Array.Array_drain(errors_);
366
+ if(_1.length === 0) {
367
+ return result_
368
+ }
369
+ if(_1.length === 1) {
370
+ const error_ = _1[0].second_;
371
+ return ff_core_Error.Error_rethrow(error_)
372
+ }
373
+ {
374
+ const allErrors_ = _1;
375
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
376
+ return _w1.first_
377
+ }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
378
+ return
379
+ }
380
+ }
381
+ }
361
382
 
383
+ export function catchManyInto_(errors_, list_, body_) {
384
+ const result_ = ff_core_List.List_map(list_, ((x_) => {
385
+ return ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch(ff_core_Core.try_((() => {
386
+ return body_(x_)
387
+ })), ((_1, _2) => {
388
+ {
389
+ const at_ = _1.at_;
390
+ const message_ = _1.message_;
391
+ const error_ = _2;
392
+ errors_.array.push(ff_core_Pair.Pair(ff_compiler_Syntax.CompileError(at_, message_), error_));
393
+ return x_
394
+ }
395
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
396
+ {
397
+ const compileErrors_ = _1.errors_;
398
+ const error_ = _2;
399
+ for(let for_a = compileErrors_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
400
+ const compileError_ = for_a[for_i];
401
+ errors_.array.push(ff_core_Pair.Pair(compileError_, error_))
402
+ };
403
+ return x_
404
+ }
405
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
406
+ }));
407
+ if(ff_core_Array.Array_isEmpty(errors_)) {
408
+ return result_
409
+ } else {
410
+ return []
411
+ }
412
+ }
362
413
 
414
+ export async function catchMany_$(list_, body_, $task) {
415
+ const errors_ = ff_core_Array.new_();
416
+ const result_ = (await ff_compiler_Syntax.catchManyInto_$(errors_, list_, body_, $task));
417
+ {
418
+ const _1 = ff_core_Array.Array_drain(errors_);
419
+ if(_1.length === 0) {
420
+ return result_
421
+ }
422
+ if(_1.length === 1) {
423
+ const error_ = _1[0].second_;
424
+ return ff_core_Error.Error_rethrow(error_)
425
+ }
426
+ {
427
+ const allErrors_ = _1;
428
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
429
+ return _w1.first_
430
+ }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
431
+ return
432
+ }
433
+ }
434
+ }
363
435
 
436
+ export async function catchManyInto_$(errors_, list_, body_, $task) {
437
+ const result_ = (await ff_core_List.List_map$(list_, (async (x_, $task) => {
438
+ return ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch((await ff_core_Core.try_$((async ($task) => {
439
+ return (await body_(x_, $task))
440
+ }), $task)), ((_1, _2) => {
441
+ {
442
+ const at_ = _1.at_;
443
+ const message_ = _1.message_;
444
+ const error_ = _2;
445
+ errors_.array.push(ff_core_Pair.Pair(ff_compiler_Syntax.CompileError(at_, message_), error_));
446
+ return x_
447
+ }
448
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
449
+ {
450
+ const compileErrors_ = _1.errors_;
451
+ const error_ = _2;
452
+ for(let for_a = compileErrors_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
453
+ const compileError_ = for_a[for_i];
454
+ errors_.array.push(ff_core_Pair.Pair(compileError_, error_))
455
+ };
456
+ return x_
457
+ }
458
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
459
+ }), $task));
460
+ if(ff_core_Array.Array_isEmpty(errors_)) {
461
+ return result_
462
+ } else {
463
+ return []
464
+ }
465
+ }
364
466
 
365
467
  export function Location_show(self_) {
366
468
  return (((((("in " + self_.file_) + " ") + "at line ") + self_.line_) + ", column ") + self_.column_)
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.44",
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.44",
7
+ "version": "0.5.46",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"