firefly-compiler 0.4.31 → 0.4.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/bin/Release.ff +6 -0
  2. package/compiler/Builder.ff +15 -7
  3. package/compiler/Compiler.ff +13 -8
  4. package/compiler/Dependencies.ff +24 -17
  5. package/compiler/DependencyLock.ff +17 -0
  6. package/compiler/Deriver.ff +2 -1
  7. package/compiler/Dictionaries.ff +4 -4
  8. package/compiler/Environment.ff +3 -3
  9. package/compiler/Inference.ff +7 -7
  10. package/compiler/JsEmitter.ff +2 -2
  11. package/compiler/JsImporter.ff +2 -2
  12. package/compiler/LspHook.ff +2 -2
  13. package/compiler/Main.ff +22 -8
  14. package/compiler/ModuleCache.ff +6 -6
  15. package/compiler/Parser.ff +36 -36
  16. package/compiler/Resolver.ff +7 -7
  17. package/compiler/Syntax.ff +1 -1
  18. package/compiler/Tokenizer.ff +2 -2
  19. package/compiler/Unification.ff +3 -3
  20. package/compiler/Wildcards.ff +1 -1
  21. package/core/.firefly/include/package-lock.json +96 -96
  22. package/core/.firefly/include/package.json +1 -1
  23. package/core/Array.ff +2 -2
  24. package/core/Atomic.ff +1 -1
  25. package/core/Buffer.ff +1 -1
  26. package/core/Int.ff +2 -2
  27. package/core/IntMap.ff +4 -4
  28. package/core/Json.ff +5 -5
  29. package/core/List.ff +15 -15
  30. package/core/Map.ff +1 -1
  31. package/core/NodeSystem.ff +85 -0
  32. package/core/Option.ff +10 -3
  33. package/core/Random.ff +1 -1
  34. package/core/RbMap.ff +1 -1
  35. package/core/Serializable.ff +2 -2
  36. package/core/Set.ff +2 -2
  37. package/core/Stream.ff +4 -4
  38. package/core/StringMap.ff +4 -4
  39. package/experimental/random/Index.ff +53 -0
  40. package/experimental/random/MapTest.ff +2 -2
  41. package/experimental/random/Process.ff +120 -0
  42. package/experimental/random/RunLength.ff +2 -2
  43. package/experimental/random/Symbols.ff +2 -2
  44. package/lsp/CompletionHandler.ff +3 -6
  45. package/lsp/Handler.ff +45 -24
  46. package/lsp/LanguageServer.ff +13 -3
  47. package/lsp/SymbolHandler.ff +2 -2
  48. package/lsp/TestReferences.ff +2 -2
  49. package/lux/Lux.ff +6 -6
  50. package/output/js/ff/compiler/Builder.mjs +40 -28
  51. package/output/js/ff/compiler/Compiler.mjs +38 -14
  52. package/output/js/ff/compiler/Dependencies.mjs +30 -16
  53. package/output/js/ff/compiler/DependencyLock.mjs +128 -0
  54. package/output/js/ff/compiler/Deriver.mjs +4 -4
  55. package/output/js/ff/compiler/Dictionaries.mjs +8 -8
  56. package/output/js/ff/compiler/Environment.mjs +6 -6
  57. package/output/js/ff/compiler/Inference.mjs +12 -12
  58. package/output/js/ff/compiler/JsEmitter.mjs +4 -4
  59. package/output/js/ff/compiler/JsImporter.mjs +4 -4
  60. package/output/js/ff/compiler/LspHook.mjs +4 -4
  61. package/output/js/ff/compiler/Main.mjs +14 -12
  62. package/output/js/ff/compiler/ModuleCache.mjs +4 -4
  63. package/output/js/ff/compiler/Parser.mjs +72 -72
  64. package/output/js/ff/compiler/Resolver.mjs +14 -14
  65. package/output/js/ff/compiler/Syntax.mjs +2 -2
  66. package/output/js/ff/compiler/Tokenizer.mjs +4 -4
  67. package/output/js/ff/compiler/Unification.mjs +4 -4
  68. package/output/js/ff/compiler/Wildcards.mjs +2 -2
  69. package/output/js/ff/core/Array.mjs +5 -5
  70. package/output/js/ff/core/Atomic.mjs +3 -3
  71. package/output/js/ff/core/Buffer.mjs +3 -3
  72. package/output/js/ff/core/Int.mjs +4 -4
  73. package/output/js/ff/core/IntMap.mjs +9 -9
  74. package/output/js/ff/core/Json.mjs +10 -10
  75. package/output/js/ff/core/List.mjs +31 -31
  76. package/output/js/ff/core/Map.mjs +2 -2
  77. package/output/js/ff/core/NodeSystem.mjs +119 -0
  78. package/output/js/ff/core/Option.mjs +28 -2
  79. package/output/js/ff/core/Random.mjs +2 -2
  80. package/output/js/ff/core/RbMap.mjs +2 -2
  81. package/output/js/ff/core/Serializable.mjs +4 -4
  82. package/output/js/ff/core/Set.mjs +4 -4
  83. package/output/js/ff/core/Stream.mjs +8 -8
  84. package/output/js/ff/core/StringMap.mjs +9 -9
  85. package/package.json +1 -1
  86. package/postgresql/Pg.ff +2 -2
  87. package/rpc/Rpc.ff +3 -3
  88. package/vscode/package.json +1 -1
  89. package/webserver/WebServer.ff +2 -2
  90. package/httpserver/.firefly/package.ff +0 -1
  91. package/httpserver/HttpServer.ff +0 -184
package/bin/Release.ff ADDED
@@ -0,0 +1,6 @@
1
+ nodeMain(system: NodeSystem) {
2
+ let result = system.execute("npm", ["-v"])
3
+ Log.trace("exitCode: " + result.exitCode)
4
+ Log.trace("out: " + result.standardOut.toString())
5
+ Log.trace("err: " + result.standardError.toString())
6
+ }
@@ -8,6 +8,7 @@ import Dependencies
8
8
  import JsEmitter
9
9
  import ModuleCache
10
10
  import LspHook
11
+ import DependencyLock
11
12
 
12
13
  build(
13
14
  system: NodeSystem
@@ -29,13 +30,13 @@ build(
29
30
  jsPathFile.createDirectory(createParentDirectories = True)
30
31
 
31
32
  let success = do {
32
- let compiler = Compiler.make(
33
+ let compiler = Compiler.new(
33
34
  emitTarget
34
35
  system.mainTask()
35
36
  compilerModulePath
36
37
  jsPathFile
37
38
  resolvedDependencies
38
- Map.empty()
39
+ Map.new()
39
40
  moduleCache
40
41
  lspHook = LspHook.disabled()
41
42
  )
@@ -65,7 +66,11 @@ processIncludes(jsPathFile: Path, packagePath: Path, info: PackageInfo): Unit {
65
66
  }
66
67
 
67
68
  buildViaBuildSystem(system: NodeSystem, fireflyPath: Path, mainFile: String, target: String) {
68
- let resolvedDependencies = Dependencies.process(system.httpClient(), system.path(mainFile))
69
+ let resolvedDependencies = Dependencies.process(
70
+ system.httpClient()
71
+ DependencyLock.new(system.mainTask())
72
+ system.path(mainFile)
73
+ )
69
74
  let fixedPackagePaths = if(resolvedDependencies.packagePaths.contains(PackagePair("ff", "core"))) {
70
75
  resolvedDependencies.packagePaths
71
76
  } else {
@@ -84,7 +89,7 @@ buildViaBuildSystem(system: NodeSystem, fireflyPath: Path, mainFile: String, tar
84
89
  tempPath = system.path(".firefly/temporary")
85
90
  jsOutputPath = system.path(".firefly/output").slash(target)
86
91
  printMeasurements = False
87
- moduleCache = ModuleCache.empty(0)
92
+ moduleCache = ModuleCache.new(0)
88
93
  )
89
94
  }
90
95
 
@@ -96,6 +101,7 @@ check(
96
101
  skipFiles: Set[String]
97
102
  virtualFiles: Map[String, String]
98
103
  cache: ModuleCache
104
+ dependencyLock: DependencyLock
99
105
  newVersion: Int
100
106
  lspHook: LspHook
101
107
  infer: Bool
@@ -106,11 +112,11 @@ check(
106
112
  | False {path.endsWith([".firefly", "package.ff"])} => [PackageFiles(path.parent().grab(), Some(path), [])]
107
113
  | False => [PackageFiles(path.parent().grab(), None, [path])]
108
114
  }
109
- let errors = Array.make()
115
+ let errors = Array.new()
110
116
 
111
117
  packages.filter {!_.files.isEmpty()}.each {package =>
112
118
  let firstFile = package.files.grabFirst()
113
- let resolvedDependencies = Dependencies.process(system.httpClient(), firstFile)
119
+ let resolvedDependencies = Dependencies.process(system.httpClient(), dependencyLock, firstFile)
114
120
  let fixedPackagePaths = if(resolvedDependencies.packagePaths.contains(PackagePair("ff", "core"))) {
115
121
  resolvedDependencies.packagePaths
116
122
  } else {
@@ -118,7 +124,7 @@ check(
118
124
  }
119
125
  let fixedResolvedDependencies = resolvedDependencies.ResolvedDependencies(packagePaths = fixedPackagePaths)
120
126
  let newCache = cache.without(newVersion, path)
121
- let compiler = Compiler.make(
127
+ let compiler = Compiler.new(
122
128
  EmitBuild
123
129
  system.mainTask()
124
130
  None
@@ -141,6 +147,8 @@ check(
141
147
  }
142
148
  } catch {| CompileError(_, _) @ c, error =>
143
149
  errors.push(c)
150
+ } catch {| CompileErrors(compileErrors), error =>
151
+ errors.pushList(compileErrors)
144
152
  } grab()
145
153
  }
146
154
  cache.mergeVersions(compiler.cache)
@@ -24,7 +24,7 @@ capability Compiler(
24
24
  phaseDurations: Array[Pair[String, Duration]]
25
25
  )
26
26
 
27
- make(
27
+ new(
28
28
  emitTarget: EmitTarget
29
29
  task: Task
30
30
  compilerModulePath: Option[Path]
@@ -143,7 +143,7 @@ extend self: Compiler {
143
143
  }
144
144
  let completionAt = if(self.lspHook.isEnabled() && self.lspHook.insertIdentifier) {self.lspHook.at}
145
145
  let tokens = Tokenizer.tokenize(path.absolute(), code, completionAt, self.lspHook.isEnabled())
146
- let parser = Parser.make(packagePair, path.base(), tokens, self.emitTarget != EmitBrowser, self.lspHook)
146
+ let parser = Parser.new(packagePair, path.base(), tokens, self.emitTarget != EmitBrowser, self.lspHook)
147
147
  let module = if(self.singleFilePackages.contains(packagePair)) {
148
148
  parser.parseModuleWithPackageInfo().module
149
149
  } else {
@@ -162,7 +162,12 @@ extend self: Compiler {
162
162
  if(!self.packagePaths.contains(newPackagePair)) {
163
163
  throw(CompileError(import.at, "Missing dependency declaration for: " + newPackagePair.groupName()))
164
164
  }
165
- self.parse(newPackagePair, newModuleName, Some(import.at))
165
+ try {
166
+ self.parse(newPackagePair, newModuleName, Some(import.at))
167
+ } catch {| CompileError(_, _) @ e, error =>
168
+ let newError = CompileError(import.at, "Parse error in imported module: " + import.package.groupName() + "/" + newModuleName)
169
+ throw(CompileErrors([e, newError]))
170
+ } grab()
166
171
  }
167
172
  }
168
173
 
@@ -172,7 +177,7 @@ extend self: Compiler {
172
177
 
173
178
  let module = self.parse(packagePair, moduleName, None)
174
179
  let otherModules = self.imports(module)
175
- let resolver = Resolver.make(packagePair, moduleName, self.lspHook)
180
+ let resolver = Resolver.new(packagePair, moduleName, self.lspHook)
176
181
  resolver.resolveModule(module, otherModules)
177
182
  }
178
183
 
@@ -181,7 +186,7 @@ extend self: Compiler {
181
186
  self.measure("Derive", packagePair, moduleName):
182
187
 
183
188
  let module = self.resolve(packagePair, moduleName)
184
- Deriver.make().deriveModule(module)
189
+ Deriver.new().deriveModule(module)
185
190
  }
186
191
 
187
192
  infer(packagePair: PackagePair, moduleName: String): Module {
@@ -192,9 +197,9 @@ extend self: Compiler {
192
197
  let otherModules = self.imports(module).map {i =>
193
198
  self.derive(i.packagePair, i.file.dropLast(".ff".size()))
194
199
  }
195
- let inference = Inference.make([module, ...otherModules], self.lspHook)
200
+ let inference = Inference.new([module, ...otherModules], self.lspHook)
196
201
  let inferredModule = inference.inferModule(module, otherModules)
197
- Dictionaries.make([module, ...otherModules]).processModule(inferredModule, otherModules)
202
+ Dictionaries.new([module, ...otherModules]).processModule(inferredModule, otherModules)
198
203
  }
199
204
 
200
205
  emit(packagePair: PackagePair, moduleName: String, isMainModule: Bool): Unit {
@@ -210,7 +215,7 @@ extend self: Compiler {
210
215
 
211
216
  let allModules = [module, ...otherModules]
212
217
  let js =
213
- JsEmitter.make(allModules, self.emitTarget, isMainModule, self.compilerModulePath, packagePair, moduleName)
218
+ JsEmitter.new(allModules, self.emitTarget, isMainModule, self.compilerModulePath, packagePair, moduleName)
214
219
  .emitModule(packagePair, module)
215
220
  let jsPath = self.jsOutputPath.slash(packagePair.group).slash(packagePair.name)
216
221
  let jsFile = jsPath.slash(moduleName + ".mjs")
@@ -3,6 +3,7 @@ import Syntax
3
3
  import Tokenizer
4
4
  import Workspace
5
5
  import LspHook
6
+ import DependencyLock
6
7
 
7
8
  capability Dependencies(
8
9
  workspace: Workspace
@@ -42,7 +43,7 @@ extend self: Dependencies {
42
43
  code: String
43
44
  ): PackageInfo {
44
45
  let tokens = Tokenizer.tokenize(fileName, code, None, True)
45
- let parser = Parser.make(packagePair, fileName, tokens, False, LspHook.disabled())
46
+ let parser = Parser.new(packagePair, fileName, tokens, False, LspHook.disabled())
46
47
  let info = parser.parsePackageInfo()
47
48
  self.addCoreDependencyIfMissing(info)
48
49
  }
@@ -74,6 +75,7 @@ extend self: Dependencies {
74
75
  fetchDependency(
75
76
  path: Path
76
77
  httpClient: HttpClient
78
+ dependencyLock: DependencyLock
77
79
  dependency: DDependency
78
80
  ): Path {
79
81
  let location = self.workspace.findPackageLocation(dependency.packagePair, dependency.version)
@@ -86,19 +88,23 @@ extend self: Dependencies {
86
88
  let tarGzPath = dependenciesPath.slash(Workspace.tarGzName(packagePair, dependency.version))
87
89
  let donePath = dependenciesPath.slash(Workspace.tarGzName(packagePair, dependency.version) + ".done")
88
90
  if(!donePath.exists()) {
89
- Log.trace("Fetching " + location)
90
- let response = httpClient.fetch(location, throw = False)
91
- if(!response.ok()) {
92
- panic("Could not download dependency: " + location)
91
+ dependencyLock.do(donePath.absolute()) {
92
+ if(!donePath.exists()) {
93
+ Log.trace("Fetching " + location)
94
+ let response = httpClient.fetch(location, throw = False)
95
+ if(!response.ok()) {
96
+ panic("Could not download dependency: " + location)
97
+ }
98
+ let buffer = response.readBuffer()
99
+ if(dependencyPath.exists()) {
100
+ dependencyPath.delete()
101
+ }
102
+ dependencyPath.createDirectory(createParentDirectories = True)
103
+ tarGzPath.writeStream([buffer].toStream())
104
+ internalExtractTarGz(tarGzPath, dependencyPath)
105
+ tarGzPath.renameTo(donePath)
106
+ }
93
107
  }
94
- let buffer = response.readBuffer()
95
- if(dependencyPath.exists()) {
96
- dependencyPath.delete()
97
- }
98
- dependencyPath.createDirectory(createParentDirectories = True)
99
- tarGzPath.writeStream([buffer].toStream())
100
- internalExtractTarGz(tarGzPath, dependencyPath)
101
- tarGzPath.renameTo(donePath)
102
108
  }
103
109
  dependencyPath
104
110
  } else {
@@ -112,11 +118,12 @@ extend self: Dependencies {
112
118
  processDependencies(
113
119
  path: Path
114
120
  httpClient: HttpClient
121
+ dependencyLock: DependencyLock
115
122
  dependencies: List[DDependency]
116
123
  ): Unit {
117
124
  // Remember to check for cycles
118
125
  let packageInfos = dependencies.map {dependency =>
119
- let dependencyPath = self.fetchDependency(path, httpClient, dependency)
126
+ let dependencyPath = self.fetchDependency(path, httpClient, dependencyLock, dependency)
120
127
  self.packagePaths = self.packagePaths.add(dependency.packagePair, dependencyPath)
121
128
  let packageInfo = self.loadPackageInfo(dependency.packagePair, dependencyPath)
122
129
  checkPackagePairs(dependency.packagePair, packageInfo.package.packagePair)
@@ -124,18 +131,18 @@ extend self: Dependencies {
124
131
  }
125
132
  let newDependencies = packageInfos.flatMap {self.processPackageInfo(_)}
126
133
  if(newDependencies != []) {
127
- self.processDependencies(path, httpClient, newDependencies)
134
+ self.processDependencies(path, httpClient, dependencyLock, newDependencies)
128
135
  }
129
136
  }
130
137
 
131
138
  }
132
139
 
133
- process(fetch: HttpClient, path: Path): ResolvedDependencies {
140
+ process(fetch: HttpClient, dependencyLock: DependencyLock, path: Path): ResolvedDependencies {
134
141
  let workspace = Workspace.loadWorkspace(path)
135
142
  let self = Dependencies(workspace, [].toMap(), [].toMap(), [].toSet())
136
143
  let packageInfo = self.loadPackageInfo(PackagePair("script", "script"), path)
137
144
  let newDependencies = self.processPackageInfo(packageInfo)
138
- self.processDependencies(path, fetch, newDependencies)
145
+ self.processDependencies(path, fetch, dependencyLock, newDependencies)
139
146
  let packagePaths = self.packagePaths.add(packageInfo.package.packagePair, findScriptPackageLocation(path))
140
147
  ResolvedDependencies(
141
148
  mainPackagePair = packageInfo.package.packagePair
@@ -0,0 +1,17 @@
1
+ capability DependencyLock(
2
+ doneLocks: StringMap[Lock]
3
+ task: Task
4
+ )
5
+
6
+ new(task: Task): DependencyLock {
7
+ DependencyLock(StringMap.new(), task)
8
+ }
9
+
10
+ extend self: DependencyLock {
11
+ do[T](doneFile: String, body: () => T): T {
12
+ let lock = self.doneLocks.getOrSet(doneFile) {self.task.lock()}
13
+ lock.do(reentrant = False) {
14
+ body()
15
+ }
16
+ }
17
+ }
@@ -2,7 +2,7 @@ import Syntax
2
2
 
3
3
  data Deriver()
4
4
 
5
- make(): Deriver {
5
+ new(): Deriver {
6
6
  Deriver()
7
7
  }
8
8
 
@@ -33,6 +33,7 @@ extend self: Deriver {
33
33
  let coreWhitelist = [
34
34
  "ff:core/Serializable.DeserializationChecksumException"
35
35
  "ff:core/Core.GrabException"
36
+ "ff:core/NodeSystem.ProcessException"
36
37
  "ff:core/Unit.Unit"
37
38
  "ff:core/Pair.Pair"
38
39
  "ff:core/Option.Option"
@@ -6,8 +6,8 @@ data Dictionaries(
6
6
  instances: Map[InstanceKey, InstanceValue]
7
7
  )
8
8
 
9
- make(modules: List[Module]): Dictionaries {
10
- Dictionaries(Unification.make(modules, False).instances)
9
+ new(modules: List[Module]): Dictionaries {
10
+ Dictionaries(Unification.new(modules, False).instances)
11
11
  }
12
12
 
13
13
  fail[T](at: Location, message: String): T {
@@ -17,7 +17,7 @@ fail[T](at: Location, message: String): T {
17
17
  extend self: Dictionaries {
18
18
 
19
19
  processModule(module: Module, otherModules: List[Module]): Module {
20
- let environment = Environment.make(module, otherModules, alreadyFlat = True)
20
+ let environment = Environment.new(module, otherModules, alreadyFlat = True)
21
21
  let functionSignatures = environment.symbols.pairs().collect {
22
22
  | Pair(name, s) {!s.isVariable} => Some(Pair(name, s.signature))
23
23
  | _ => None
@@ -167,7 +167,7 @@ extend self: Dictionaries {
167
167
  constraint: Constraint
168
168
  ): Dictionary {
169
169
  let instantiationMap = typeParameters.zip(typeArguments).toMap()
170
- let unification = Unification.make([], False)
170
+ let unification = Unification.new([], False)
171
171
  let newGenerics = constraint.generics.map {unification.instantiate(instantiationMap, _)}
172
172
  newGenerics.grabFirst().{
173
173
  | TConstructor firstType =>
@@ -22,13 +22,13 @@ data Instantiated(
22
22
  scheme: Scheme
23
23
  )
24
24
 
25
- make(module: Module, otherModules: List[Module], alreadyFlat: Bool): Environment {
25
+ new(module: Module, otherModules: List[Module], alreadyFlat: Bool): Environment {
26
26
  let processed = processModule(module, True, alreadyFlat)
27
27
  let otherProcessed = otherModules.map {processModule(_, False, False)}
28
28
  Environment(
29
29
  modulePrefix = fullName(module, "")
30
- symbols = processed.symbols.addAll(otherProcessed.map {_.symbols}.foldLeft(Map.empty()) {_.addAll(_)})
31
- traits = processed.traits.addAll(otherProcessed.map {_.traits}.foldLeft(Map.empty()) {_.addAll(_)})
30
+ symbols = processed.symbols.addAll(otherProcessed.map {_.symbols}.foldLeft(Map.new()) {_.addAll(_)})
31
+ traits = processed.traits.addAll(otherProcessed.map {_.traits}.foldLeft(Map.new()) {_.addAll(_)})
32
32
  imports = module.imports.map {i => Pair(i.alias, i)}.toMap()
33
33
  effect = TConstructor(Location(module.file, 0, 0), "ff:core/Nothing.Nothing", [])
34
34
  selfVariable = None
@@ -10,10 +10,10 @@ class Inference(
10
10
  lspHook: LspHook
11
11
  )
12
12
 
13
- make(modules: List[Module], lspHook: LspHook): Inference {
13
+ new(modules: List[Module], lspHook: LspHook): Inference {
14
14
  Inference(
15
- unification = Unification.make(modules, attemptFixes = lspHook.isEnabled())
16
- missing = StringMap.make()
15
+ unification = Unification.new(modules, attemptFixes = lspHook.isEnabled())
16
+ missing = StringMap.new()
17
17
  lspHook = lspHook
18
18
  )
19
19
  }
@@ -29,7 +29,7 @@ core(name: String): String {
29
29
  extend self: Inference {
30
30
 
31
31
  inferModule(module: Module, otherModules: List[Module]): Module {
32
- let environment = Environment.make(module, otherModules, alreadyFlat = False)
32
+ let environment = Environment.new(module, otherModules, alreadyFlat = False)
33
33
 
34
34
  let traits = module.traits.map {self.inferTraitDefinition(environment, _)}
35
35
  let instances = module.instances.map {self.inferInstanceDefinition(environment, _)}
@@ -274,7 +274,7 @@ extend self: Inference {
274
274
  }
275
275
  function literal(coreTypeName: String): Map[String, Pair[Location, Type]] {
276
276
  self.unification.unify(pattern.at, expected, TConstructor(pattern.at, core(coreTypeName), []))
277
- Map.empty()
277
+ Map.new()
278
278
  }
279
279
  pattern.{
280
280
  | PString _ =>
@@ -284,7 +284,7 @@ extend self: Inference {
284
284
  | PChar _ =>
285
285
  literal("Char")
286
286
  | PVariable(at, None) =>
287
- Map.empty()
287
+ Map.new()
288
288
  | PVariable(at, Some(name)) =>
289
289
  [Pair(name, Pair(at, expected))].toMap()
290
290
  | PAlias(at, pattern, variable) =>
@@ -328,7 +328,7 @@ extend self: Inference {
328
328
  }
329
329
  patterns.zip(instantiated.scheme.signature.parameters).map {| Pair(pattern, parameter) =>
330
330
  self.inferPattern(environment, parameter.valueType, pattern)
331
- }.foldLeft(Map.empty[String, Pair[Location, Type]]()) {_.addAll(_)}
331
+ }.foldLeft(Map.new[String, Pair[Location, Type]]()) {_.addAll(_)}
332
332
  }
333
333
  }
334
334
 
@@ -21,7 +21,7 @@ data EmitTarget {
21
21
  EmitExecutable
22
22
  }
23
23
 
24
- make(
24
+ new(
25
25
  otherModules: List[Module]
26
26
  emitTarget: EmitTarget
27
27
  isMainModule: Bool
@@ -34,7 +34,7 @@ make(
34
34
  let moduleName = m.packagePair.groupName() + "/" + m.file.dropLast(3)
35
35
  Pair(moduleName, m)
36
36
  }.toMap()
37
- jsImporter = JsImporter.make()
37
+ jsImporter = JsImporter.new()
38
38
  emitTarget = emitTarget
39
39
  isMainModule = isMainModule
40
40
  compilerModulePath = compilerModulePath
@@ -4,8 +4,8 @@ class JsImporter(
4
4
  mutable imports: Map[String, String]
5
5
  )
6
6
 
7
- make(): JsImporter {
8
- JsImporter(Map.empty())
7
+ new(): JsImporter {
8
+ JsImporter(Map.new())
9
9
  }
10
10
 
11
11
  fail[T](at: Location, message: String): T {
@@ -11,10 +11,10 @@ class LspHook(
11
11
  )
12
12
 
13
13
  disabled(): LspHook {
14
- make(None, None, False, False)
14
+ new(None, None, False, False)
15
15
  }
16
16
 
17
- make(at: Option[Location], definedAt: Option[Location], insertIdentifier: Bool, trackSymbols: Bool): LspHook {
17
+ new(at: Option[Location], definedAt: Option[Location], insertIdentifier: Bool, trackSymbols: Bool): LspHook {
18
18
  LspHook( // Default dummy values instead of Option[Location] to speed up location hit check
19
19
  at = at.else {Location("^lsp", -7, -7)}
20
20
  definedAt = definedAt.else {Location("^lsp", -7, -7)}
package/compiler/Main.ff CHANGED
@@ -10,6 +10,7 @@ import JsEmitter
10
10
  import Inference
11
11
  import ModuleCache
12
12
  import LspHook
13
+ import DependencyLock
13
14
 
14
15
  data MainCommand {
15
16
  BootstrapCommand
@@ -55,13 +56,17 @@ main(system: NodeSystem): Unit {
55
56
  tempPath = system.path(".firefly").slash("temporary")
56
57
  jsOutputPath = system.path(".firefly").path("output").path(targetName)
57
58
  printMeasurements = False
58
- moduleCache = ModuleCache.empty(0)
59
+ moduleCache = ModuleCache.new(0)
59
60
  )
60
61
  }
61
62
 
62
63
  function runCommand(command: MainCommand) {
63
64
  | RunCommand(mainFile, arguments) =>
64
- let resolvedDependencies = Dependencies.process(system.httpClient(), system.path(mainFile + ".ff"))
65
+ let resolvedDependencies = Dependencies.process(
66
+ system.httpClient()
67
+ DependencyLock.new(system.mainTask())
68
+ system.path(mainFile + ".ff")
69
+ )
65
70
  prepareFireflyDirectory(system.path("."))
66
71
  let localMainFile = system.path(mainFile).base()
67
72
  buildScript(localMainFile, resolvedDependencies.mainPackagePair, EmitNode, resolvedDependencies)
@@ -71,14 +76,22 @@ main(system: NodeSystem): Unit {
71
76
  }
72
77
 
73
78
  | BrowserCommand(mainFile) =>
74
- let resolvedDependencies = Dependencies.process(system.httpClient(), system.path(mainFile + ".ff"))
79
+ let resolvedDependencies = Dependencies.process(
80
+ system.httpClient()
81
+ DependencyLock.new(system.mainTask())
82
+ system.path(mainFile + ".ff")
83
+ )
75
84
  prepareFireflyDirectory(system.path("."))
76
85
  let localMainFile = system.path(mainFile).base()
77
86
  buildScript(mainFile, resolvedDependencies.mainPackagePair, EmitBrowser, resolvedDependencies)
78
87
  bundleForBrowser(system, resolvedDependencies.mainPackagePair, localMainFile)
79
88
 
80
89
  | BuildCommand(mainFile) =>
81
- let resolvedDependencies = Dependencies.process(system.httpClient(), system.path(mainFile + ".ff"))
90
+ let resolvedDependencies = Dependencies.process(
91
+ system.httpClient()
92
+ DependencyLock.new(system.mainTask())
93
+ system.path(mainFile + ".ff")
94
+ )
82
95
  prepareFireflyDirectory(system.path("."))
83
96
  let localMainFile = system.path(mainFile).base()
84
97
  buildScript(localMainFile, resolvedDependencies.mainPackagePair, EmitBuild, resolvedDependencies)
@@ -92,9 +105,10 @@ main(system: NodeSystem): Unit {
92
105
  fireflyPath = fireflyPath
93
106
  path = system.path(filePath)
94
107
  mustContain = None
95
- skipFiles = Set.empty()
96
- virtualFiles = Map.empty()
97
- cache = ModuleCache.empty(1)
108
+ skipFiles = Set.new()
109
+ virtualFiles = Map.new()
110
+ cache = ModuleCache.new(1)
111
+ dependencyLock = DependencyLock.new(system.mainTask())
98
112
  newVersion = 0
99
113
  lspHook = LspHook.disabled()
100
114
  infer = True
@@ -127,7 +141,7 @@ main(system: NodeSystem): Unit {
127
141
  tempPath = workingDirectory.slash("output").slash("temporary")
128
142
  jsOutputPath = workingDirectory.slash("output").slash("js")
129
143
  printMeasurements = True
130
- moduleCache = ModuleCache.empty(0)
144
+ moduleCache = ModuleCache.new(0)
131
145
  )
132
146
  }
133
147
 
@@ -9,14 +9,14 @@ class ModuleCache(
9
9
  mutable emittedModules: Map[String, Int]
10
10
  )
11
11
 
12
- empty(version: Int): ModuleCache {
12
+ new(version: Int): ModuleCache {
13
13
  ModuleCache(
14
14
  version = version
15
- parsedModules = Map.empty()
16
- resolvedModules = Map.empty()
17
- derivedModules = Map.empty()
18
- inferredModules = Map.empty()
19
- emittedModules = Map.empty()
15
+ parsedModules = Map.new()
16
+ resolvedModules = Map.new()
17
+ derivedModules = Map.new()
18
+ inferredModules = Map.new()
19
+ emittedModules = Map.new()
20
20
  )
21
21
  }
22
22