firefly-compiler 0.4.4
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/.firefly-workspace +1 -0
- package/.vscode/settings.json +5 -0
- package/LICENSE.txt +21 -0
- package/README.md +96 -0
- package/bin/firefly.mjs +2 -0
- package/compiler/.firefly/package.ff +1 -0
- package/compiler/Builder.ff +218 -0
- package/compiler/Compiler.ff +241 -0
- package/compiler/Dependencies.ff +179 -0
- package/compiler/Deriver.ff +647 -0
- package/compiler/Dictionaries.ff +205 -0
- package/compiler/Environment.ff +166 -0
- package/compiler/Inference.ff +1117 -0
- package/compiler/JsEmitter.ff +861 -0
- package/compiler/JsImporter.ff +56 -0
- package/compiler/LspHook.ff +188 -0
- package/compiler/Main.ff +237 -0
- package/compiler/Parser.ff +1383 -0
- package/compiler/Patterns.ff +111 -0
- package/compiler/Resolver.ff +620 -0
- package/compiler/Substitution.ff +178 -0
- package/compiler/Syntax.ff +299 -0
- package/compiler/Token.ff +180 -0
- package/compiler/Tokenizer.ff +278 -0
- package/compiler/Unification.ff +220 -0
- package/compiler/Wildcards.ff +50 -0
- package/compiler/Workspace.ff +88 -0
- package/core/.firefly/package.ff +2 -0
- package/core/Any.ff +30 -0
- package/core/Array.ff +249 -0
- package/core/AssetSystem.ff +61 -0
- package/core/Atomic.ff +64 -0
- package/core/Bool.ff +13 -0
- package/core/BrowserSystem.ff +14 -0
- package/core/Buffer.ff +211 -0
- package/core/BuildSystem.ff +144 -0
- package/core/Channel.ff +131 -0
- package/core/Char.ff +18 -0
- package/core/Core.ff +58 -0
- package/core/Duration.ff +15 -0
- package/core/Equal.ff +52 -0
- package/core/Error.ff +20 -0
- package/core/FileHandle.ff +41 -0
- package/core/Float.ff +41 -0
- package/core/HttpClient.ff +84 -0
- package/core/Instant.ff +9 -0
- package/core/Int.ff +61 -0
- package/core/IntMap.ff +85 -0
- package/core/JsSystem.ff +66 -0
- package/core/JsValue.ff +240 -0
- package/core/List.ff +440 -0
- package/core/Lock.ff +144 -0
- package/core/Log.ff +24 -0
- package/core/Map.ff +126 -0
- package/core/NodeSystem.ff +88 -0
- package/core/Nothing.ff +1 -0
- package/core/Option.ff +133 -0
- package/core/Ordering.ff +157 -0
- package/core/Pair.ff +55 -0
- package/core/Path.ff +393 -0
- package/core/RbMap.ff +216 -0
- package/core/Serializable.ff +173 -0
- package/core/Set.ff +38 -0
- package/core/Show.ff +43 -0
- package/core/Stack.ff +263 -0
- package/core/Stream.ff +406 -0
- package/core/String.ff +175 -0
- package/core/StringMap.ff +85 -0
- package/core/Task.ff +138 -0
- package/core/Try.ff +81 -0
- package/core/Unit.ff +3 -0
- package/experimental/random/AltGeneric.ff +44 -0
- package/experimental/random/Async.ff +68 -0
- package/experimental/random/Buffer2.ff +77 -0
- package/experimental/random/Cat.ff +12 -0
- package/experimental/random/Dictionary.ff +52 -0
- package/experimental/random/Example.ff +46 -0
- package/experimental/random/Generic.ff +102 -0
- package/experimental/random/HappyEyeballs.ff +40 -0
- package/experimental/random/HashMap.ff +72 -0
- package/experimental/random/IfElseUnit.ff +9 -0
- package/experimental/random/InputOutput.ff +23 -0
- package/experimental/random/ListVsArray.ff +45 -0
- package/experimental/random/Main.ff +44 -0
- package/experimental/random/MapTest.ff +67 -0
- package/experimental/random/OldTaskSystem.ff +210 -0
- package/experimental/random/PatternTest.ff +39 -0
- package/experimental/random/Patterns.ff +226 -0
- package/experimental/random/ReadBytesTest.ff +10 -0
- package/experimental/random/RunLength.ff +65 -0
- package/experimental/random/Scrape.ff +51 -0
- package/experimental/random/Serialization.ff +217 -0
- package/experimental/random/SerializationTest.ff +46 -0
- package/experimental/random/Serializer.ff +36 -0
- package/experimental/random/StdInOutErr.ff +4 -0
- package/experimental/random/Symbols.ff +74 -0
- package/experimental/random/Tag.ff +49 -0
- package/experimental/random/Tensor.ff +52 -0
- package/experimental/random/Try.ff +56 -0
- package/experimental/random/Tsv.ff +9 -0
- package/experimental/random/TypesAreModules.ff +87 -0
- package/experimental/random/blueprints/Blueprint.ff +52 -0
- package/experimental/random/blueprints/Main.ff +11 -0
- package/experimental/random/blueprints/Pretty.ff +58 -0
- package/experimental/random/blueprints/User.ff +64 -0
- package/experimental/random/blueprintsystem/BlueprintSystem.ff +48 -0
- package/experimental/random/blueprintsystem/Deserialize.ff +53 -0
- package/experimental/random/blueprintsystem/ReadJs.ff +13 -0
- package/experimental/random/blueprintsystem/User.ff +2 -0
- package/experimental/random/kahrs/Kahrs.ff +112 -0
- package/experimental/random/kahrs/TestKahrs.ff +22 -0
- package/experimental/random/kahrs/TestMap.ff +18 -0
- package/experimental/random/streaming/Gzip.ff +3 -0
- package/experimental/random/streaming/Main.ff +34 -0
- package/experimental/random/streaming/S3Bucket.ff +11 -0
- package/experimental/random/streaming/Tar.ff +5 -0
- package/experimental/rhymeapp/Main.ff +81 -0
- package/experimental/rhymeapp/index.html +14 -0
- package/firefly.sh +5 -0
- package/fireflysite/Main.ff +13 -0
- package/httpserver/.firefly/package.ff +1 -0
- package/httpserver/HttpServer.ff +184 -0
- package/lsp/.firefly/package.ff +1 -0
- package/lsp/CompletionHandler.ff +814 -0
- package/lsp/Handler.ff +551 -0
- package/lsp/HoverHandler.ff +82 -0
- package/lsp/LanguageServer.ff +229 -0
- package/lsp/SignatureHelpHandler.ff +55 -0
- package/lsp/SymbolHandler.ff +167 -0
- package/output/js/ff/compiler/Builder.mjs +483 -0
- package/output/js/ff/compiler/Compiler.mjs +410 -0
- package/output/js/ff/compiler/Dependencies.mjs +388 -0
- package/output/js/ff/compiler/Deriver.mjs +1166 -0
- package/output/js/ff/compiler/Dictionaries.mjs +1305 -0
- package/output/js/ff/compiler/Environment.mjs +1005 -0
- package/output/js/ff/compiler/Inference.mjs +4264 -0
- package/output/js/ff/compiler/JsEmitter.mjs +5353 -0
- package/output/js/ff/compiler/JsImporter.mjs +262 -0
- package/output/js/ff/compiler/LspHook.mjs +789 -0
- package/output/js/ff/compiler/Main.mjs +1695 -0
- package/output/js/ff/compiler/Parser.mjs +4004 -0
- package/output/js/ff/compiler/Patterns.mjs +923 -0
- package/output/js/ff/compiler/Resolver.mjs +2303 -0
- package/output/js/ff/compiler/Substitution.mjs +1146 -0
- package/output/js/ff/compiler/Syntax.mjs +12430 -0
- package/output/js/ff/compiler/Token.mjs +3092 -0
- package/output/js/ff/compiler/Tokenizer.mjs +589 -0
- package/output/js/ff/compiler/Unification.mjs +1748 -0
- package/output/js/ff/compiler/Wildcards.mjs +604 -0
- package/output/js/ff/compiler/Workspace.mjs +683 -0
- package/output/js/ff/core/Any.mjs +139 -0
- package/output/js/ff/core/Array.mjs +594 -0
- package/output/js/ff/core/AssetSystem.mjs +270 -0
- package/output/js/ff/core/Atomic.mjs +186 -0
- package/output/js/ff/core/Bool.mjs +141 -0
- package/output/js/ff/core/BrowserSystem.mjs +122 -0
- package/output/js/ff/core/Buffer.mjs +467 -0
- package/output/js/ff/core/BuildSystem.mjs +320 -0
- package/output/js/ff/core/Channel.mjs +268 -0
- package/output/js/ff/core/Char.mjs +145 -0
- package/output/js/ff/core/Core.mjs +300 -0
- package/output/js/ff/core/Duration.mjs +112 -0
- package/output/js/ff/core/Equal.mjs +175 -0
- package/output/js/ff/core/Error.mjs +138 -0
- package/output/js/ff/core/FileHandle.mjs +164 -0
- package/output/js/ff/core/Float.mjs +214 -0
- package/output/js/ff/core/HttpClient.mjs +210 -0
- package/output/js/ff/core/Instant.mjs +105 -0
- package/output/js/ff/core/Int.mjs +254 -0
- package/output/js/ff/core/IntMap.mjs +282 -0
- package/output/js/ff/core/JsSystem.mjs +234 -0
- package/output/js/ff/core/JsValue.mjs +678 -0
- package/output/js/ff/core/List.mjs +2335 -0
- package/output/js/ff/core/Lock.mjs +322 -0
- package/output/js/ff/core/Log.mjs +159 -0
- package/output/js/ff/core/Map.mjs +358 -0
- package/output/js/ff/core/NodeSystem.mjs +288 -0
- package/output/js/ff/core/Nothing.mjs +100 -0
- package/output/js/ff/core/Option.mjs +1002 -0
- package/output/js/ff/core/Ordering.mjs +734 -0
- package/output/js/ff/core/Pair.mjs +318 -0
- package/output/js/ff/core/Path.mjs +768 -0
- package/output/js/ff/core/RbMap.mjs +1936 -0
- package/output/js/ff/core/Serializable.mjs +434 -0
- package/output/js/ff/core/Set.mjs +250 -0
- package/output/js/ff/core/Show.mjs +201 -0
- package/output/js/ff/core/Stack.mjs +595 -0
- package/output/js/ff/core/Stream.mjs +1300 -0
- package/output/js/ff/core/String.mjs +433 -0
- package/output/js/ff/core/StringMap.mjs +282 -0
- package/output/js/ff/core/Task.mjs +345 -0
- package/output/js/ff/core/Try.mjs +503 -0
- package/output/js/ff/core/Unit.mjs +103 -0
- package/package.json +29 -0
- package/postgresql/.firefly/include/package-lock.json +250 -0
- package/postgresql/.firefly/include/package.json +5 -0
- package/postgresql/.firefly/include/prepare.sh +2 -0
- package/postgresql/.firefly/package.ff +3 -0
- package/postgresql/Pg.ff +530 -0
- package/unsafejs/.firefly/package.ff +1 -0
- package/unsafejs/UnsafeJs.ff +19 -0
- package/vscode/.vscode/launch.json +18 -0
- package/vscode/.vscode/tasks.json +33 -0
- package/vscode/LICENSE.txt +21 -0
- package/vscode/Prepublish.ff +15 -0
- package/vscode/README.md +17 -0
- package/vscode/client/package-lock.json +544 -0
- package/vscode/client/package.json +22 -0
- package/vscode/client/src/extension.ts +64 -0
- package/vscode/client/tsconfig.json +12 -0
- package/vscode/icons/firefly-icon.png +0 -0
- package/vscode/icons/firefly-icon.svg +10 -0
- package/vscode/icons/firefly-logo-notext.png +0 -0
- package/vscode/icons/firefly-logo.png +0 -0
- package/vscode/language-configuration.json +39 -0
- package/vscode/package-lock.json +3623 -0
- package/vscode/package.json +144 -0
- package/vscode/snippets-none.json +1 -0
- package/vscode/snippets.json +241 -0
- package/vscode/syntaxes/firefly.tmLanguage.json +294 -0
- package/vscode/tsconfig.json +20 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import * as ff_compiler_JsImporter from "../../ff/compiler/JsImporter.mjs"
|
|
4
|
+
|
|
5
|
+
import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
|
|
6
|
+
|
|
7
|
+
import * as ff_core_Any from "../../ff/core/Any.mjs"
|
|
8
|
+
|
|
9
|
+
import * as ff_core_Array from "../../ff/core/Array.mjs"
|
|
10
|
+
|
|
11
|
+
import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
|
|
12
|
+
|
|
13
|
+
import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
|
|
14
|
+
|
|
15
|
+
import * as ff_core_Bool from "../../ff/core/Bool.mjs"
|
|
16
|
+
|
|
17
|
+
import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
|
|
18
|
+
|
|
19
|
+
import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
|
|
20
|
+
|
|
21
|
+
import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
|
|
22
|
+
|
|
23
|
+
import * as ff_core_Channel from "../../ff/core/Channel.mjs"
|
|
24
|
+
|
|
25
|
+
import * as ff_core_Char from "../../ff/core/Char.mjs"
|
|
26
|
+
|
|
27
|
+
import * as ff_core_Core from "../../ff/core/Core.mjs"
|
|
28
|
+
|
|
29
|
+
import * as ff_core_Duration from "../../ff/core/Duration.mjs"
|
|
30
|
+
|
|
31
|
+
import * as ff_core_Equal from "../../ff/core/Equal.mjs"
|
|
32
|
+
|
|
33
|
+
import * as ff_core_Error from "../../ff/core/Error.mjs"
|
|
34
|
+
|
|
35
|
+
import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
|
|
36
|
+
|
|
37
|
+
import * as ff_core_Float from "../../ff/core/Float.mjs"
|
|
38
|
+
|
|
39
|
+
import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
|
|
40
|
+
|
|
41
|
+
import * as ff_core_Instant from "../../ff/core/Instant.mjs"
|
|
42
|
+
|
|
43
|
+
import * as ff_core_Int from "../../ff/core/Int.mjs"
|
|
44
|
+
|
|
45
|
+
import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
|
|
46
|
+
|
|
47
|
+
import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
48
|
+
|
|
49
|
+
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
50
|
+
|
|
51
|
+
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
52
|
+
|
|
53
|
+
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
54
|
+
|
|
55
|
+
import * as ff_core_Log from "../../ff/core/Log.mjs"
|
|
56
|
+
|
|
57
|
+
import * as ff_core_Map from "../../ff/core/Map.mjs"
|
|
58
|
+
|
|
59
|
+
import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
|
|
60
|
+
|
|
61
|
+
import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
|
|
62
|
+
|
|
63
|
+
import * as ff_core_Option from "../../ff/core/Option.mjs"
|
|
64
|
+
|
|
65
|
+
import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
|
|
66
|
+
|
|
67
|
+
import * as ff_core_Pair from "../../ff/core/Pair.mjs"
|
|
68
|
+
|
|
69
|
+
import * as ff_core_Path from "../../ff/core/Path.mjs"
|
|
70
|
+
|
|
71
|
+
import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
|
|
72
|
+
|
|
73
|
+
import * as ff_core_Set from "../../ff/core/Set.mjs"
|
|
74
|
+
|
|
75
|
+
import * as ff_core_Show from "../../ff/core/Show.mjs"
|
|
76
|
+
|
|
77
|
+
import * as ff_core_Stack from "../../ff/core/Stack.mjs"
|
|
78
|
+
|
|
79
|
+
import * as ff_core_Stream from "../../ff/core/Stream.mjs"
|
|
80
|
+
|
|
81
|
+
import * as ff_core_String from "../../ff/core/String.mjs"
|
|
82
|
+
|
|
83
|
+
import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
|
|
84
|
+
|
|
85
|
+
import * as ff_core_Task from "../../ff/core/Task.mjs"
|
|
86
|
+
|
|
87
|
+
import * as ff_core_Try from "../../ff/core/Try.mjs"
|
|
88
|
+
|
|
89
|
+
import * as ff_core_Unit from "../../ff/core/Unit.mjs"
|
|
90
|
+
|
|
91
|
+
// type JsImporter
|
|
92
|
+
export function JsImporter(imports_) {
|
|
93
|
+
return {imports_};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
export function make_() {
|
|
99
|
+
return ff_compiler_JsImporter.JsImporter(ff_core_Map.empty_())
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function fail_(at_, message_) {
|
|
103
|
+
return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function make_$($task) {
|
|
107
|
+
return ff_compiler_JsImporter.JsImporter(ff_core_Map.empty_())
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export async function fail_$(at_, message_, $task) {
|
|
111
|
+
return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function JsImporter_add(self_, url_) {
|
|
115
|
+
const importName_ = (((_1) => {
|
|
116
|
+
{
|
|
117
|
+
if(_1.None) {
|
|
118
|
+
const n_ = ("import$" + ff_core_Map.Map_size(self_.imports_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String));
|
|
119
|
+
self_.imports_ = ff_core_Map.Map_add(self_.imports_, url_, n_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
120
|
+
return n_
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
{
|
|
125
|
+
if(_1.Some) {
|
|
126
|
+
const n_ = _1.value_;
|
|
127
|
+
return n_
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}))(ff_core_Map.Map_get(self_.imports_, url_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String));
|
|
132
|
+
return importName_
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function JsImporter_process(self_, at_, code_) {
|
|
136
|
+
const space_ = ff_core_String.String_takeWhile(code_, ((c_) => {
|
|
137
|
+
return (((((c_ === 32) || (c_ === 9)) || (c_ === 13)) || (c_ === 10)) || (c_ === 59))
|
|
138
|
+
}));
|
|
139
|
+
const rest_ = ff_core_String.String_dropFirst(code_, ff_core_String.String_size(space_));
|
|
140
|
+
if((!ff_core_String.String_startsWith(rest_, "import * as ", 0))) {
|
|
141
|
+
return code_
|
|
142
|
+
} else {
|
|
143
|
+
const rest2_ = ff_core_String.String_dropFirst(rest_, ff_core_String.String_size("import * as "));
|
|
144
|
+
const name_ = ff_core_String.String_takeWhile(rest2_, ((_w1) => {
|
|
145
|
+
return ff_core_Char.Char_isAsciiLetterOrDigit(_w1)
|
|
146
|
+
}));
|
|
147
|
+
if((ff_core_String.String_size(name_) === 0)) {
|
|
148
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected alias after \"import * as \""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
149
|
+
};
|
|
150
|
+
const rest3_ = ff_core_String.String_dropFirst(rest2_, ff_core_String.String_size(name_));
|
|
151
|
+
if((!ff_core_String.String_startsWith(rest3_, " from '", 0))) {
|
|
152
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected \" from '\" after \"import * as ...\""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
153
|
+
};
|
|
154
|
+
const rest4_ = ff_core_String.String_dropFirst(rest3_, ff_core_String.String_size(" from '"));
|
|
155
|
+
const url_ = ff_core_String.String_takeWhile(rest4_, ((_w1) => {
|
|
156
|
+
return (_w1 !== 39)
|
|
157
|
+
}));
|
|
158
|
+
if((ff_core_String.String_size(url_) === 0)) {
|
|
159
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected module name after \" from '\""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
160
|
+
};
|
|
161
|
+
if(ff_core_String.String_any(url_, ((_w1) => {
|
|
162
|
+
return (_w1 === 10)
|
|
163
|
+
}))) {
|
|
164
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Unclosed module name string"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
165
|
+
};
|
|
166
|
+
const rest5_ = ff_core_String.String_dropFirst(rest4_, (ff_core_String.String_size(url_) + 1));
|
|
167
|
+
const importName_ = ff_compiler_JsImporter.JsImporter_add(self_, url_);
|
|
168
|
+
return (((((space_ + "const ") + name_) + " = ") + importName_) + ff_compiler_JsImporter.JsImporter_process(self_, at_, rest5_))
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function JsImporter_generateImports(self_, ignoreModules_) {
|
|
173
|
+
return ff_core_List.List_map(ff_core_Map.Map_pairs(self_.imports_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
|
|
174
|
+
{
|
|
175
|
+
const moduleName_ = _1.first_;
|
|
176
|
+
const mangledName_ = _1.second_;
|
|
177
|
+
if(ff_core_Set.Set_contains(ignoreModules_, moduleName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
|
|
178
|
+
return (("const " + mangledName_) + " = void 0; // Ignored import")
|
|
179
|
+
} else {
|
|
180
|
+
return (((("import * as " + mangledName_) + " from '") + moduleName_) + "';")
|
|
181
|
+
}
|
|
182
|
+
return
|
|
183
|
+
}
|
|
184
|
+
}))
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export async function JsImporter_add$(self_, url_, $task) {
|
|
188
|
+
const importName_ = (((_1) => {
|
|
189
|
+
{
|
|
190
|
+
if(_1.None) {
|
|
191
|
+
const n_ = ("import$" + ff_core_Map.Map_size(self_.imports_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String));
|
|
192
|
+
self_.imports_ = ff_core_Map.Map_add(self_.imports_, url_, n_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
193
|
+
return n_
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
{
|
|
198
|
+
if(_1.Some) {
|
|
199
|
+
const n_ = _1.value_;
|
|
200
|
+
return n_
|
|
201
|
+
return
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}))(ff_core_Map.Map_get(self_.imports_, url_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String));
|
|
205
|
+
return importName_
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export async function JsImporter_process$(self_, at_, code_, $task) {
|
|
209
|
+
const space_ = ff_core_String.String_takeWhile(code_, ((c_) => {
|
|
210
|
+
return (((((c_ === 32) || (c_ === 9)) || (c_ === 13)) || (c_ === 10)) || (c_ === 59))
|
|
211
|
+
}));
|
|
212
|
+
const rest_ = ff_core_String.String_dropFirst(code_, ff_core_String.String_size(space_));
|
|
213
|
+
if((!ff_core_String.String_startsWith(rest_, "import * as ", 0))) {
|
|
214
|
+
return code_
|
|
215
|
+
} else {
|
|
216
|
+
const rest2_ = ff_core_String.String_dropFirst(rest_, ff_core_String.String_size("import * as "));
|
|
217
|
+
const name_ = ff_core_String.String_takeWhile(rest2_, ((_w1) => {
|
|
218
|
+
return ff_core_Char.Char_isAsciiLetterOrDigit(_w1)
|
|
219
|
+
}));
|
|
220
|
+
if((ff_core_String.String_size(name_) === 0)) {
|
|
221
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected alias after \"import * as \""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
222
|
+
};
|
|
223
|
+
const rest3_ = ff_core_String.String_dropFirst(rest2_, ff_core_String.String_size(name_));
|
|
224
|
+
if((!ff_core_String.String_startsWith(rest3_, " from '", 0))) {
|
|
225
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected \" from '\" after \"import * as ...\""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
226
|
+
};
|
|
227
|
+
const rest4_ = ff_core_String.String_dropFirst(rest3_, ff_core_String.String_size(" from '"));
|
|
228
|
+
const url_ = ff_core_String.String_takeWhile(rest4_, ((_w1) => {
|
|
229
|
+
return (_w1 !== 39)
|
|
230
|
+
}));
|
|
231
|
+
if((ff_core_String.String_size(url_) === 0)) {
|
|
232
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected module name after \" from '\""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
233
|
+
};
|
|
234
|
+
if(ff_core_String.String_any(url_, ((_w1) => {
|
|
235
|
+
return (_w1 === 10)
|
|
236
|
+
}))) {
|
|
237
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Unclosed module name string"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
238
|
+
};
|
|
239
|
+
const rest5_ = ff_core_String.String_dropFirst(rest4_, (ff_core_String.String_size(url_) + 1));
|
|
240
|
+
const importName_ = ff_compiler_JsImporter.JsImporter_add(self_, url_);
|
|
241
|
+
return (((((space_ + "const ") + name_) + " = ") + importName_) + ff_compiler_JsImporter.JsImporter_process(self_, at_, rest5_))
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export async function JsImporter_generateImports$(self_, ignoreModules_, $task) {
|
|
246
|
+
return ff_core_List.List_map(ff_core_Map.Map_pairs(self_.imports_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
|
|
247
|
+
{
|
|
248
|
+
const moduleName_ = _1.first_;
|
|
249
|
+
const mangledName_ = _1.second_;
|
|
250
|
+
if(ff_core_Set.Set_contains(ignoreModules_, moduleName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
|
|
251
|
+
return (("const " + mangledName_) + " = void 0; // Ignored import")
|
|
252
|
+
} else {
|
|
253
|
+
return (((("import * as " + mangledName_) + " from '") + moduleName_) + "';")
|
|
254
|
+
}
|
|
255
|
+
return
|
|
256
|
+
}
|
|
257
|
+
}))
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|