firefly-compiler 0.4.88 → 0.4.90

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.
@@ -1184,7 +1184,40 @@ extend self: Parser {
1184
1184
  }
1185
1185
 
1186
1186
  parseDynamicMember(record: Term): Term {
1187
- self.skip(LArrowThin)
1187
+ let token = self.skip(LArrowThin)
1188
+ if(self.current().rawIs("(")) {
1189
+ let arguments = self.parseFunctionArguments(token.at(), trailing = False)
1190
+ let effect = self.freshUnificationVariable(record.at)
1191
+ arguments.first.indexWhere {!_.name.isEmpty()}.{
1192
+ | None =>
1193
+ let target = DynamicCall(EField(token.at(), False, record, "new" + arguments.first.size()), False)
1194
+ ECall(record.at, target, effect, [], arguments.first, [])
1195
+ | Some(0) =>
1196
+ let objectTarget = DynamicCall(EField(token.at(), False, record, "object"), False)
1197
+ mutable result = ECall(record.at, objectTarget, effect, [], [], [])
1198
+ arguments.first.each {argument =>
1199
+ if(argument.name.isEmpty()) {
1200
+ throw(CompileError(argument.at, "Expected a named argument"))
1201
+ }
1202
+ let target = DynamicCall(EField(token.at(), False, record, "with"), False)
1203
+ result = ECall(record.at, target, effect, [], [
1204
+ Argument(argument.at, None, EString(argument.at, argument.name.grab()))
1205
+ argument
1206
+ ], [])
1207
+ }
1208
+ result
1209
+ | Some(i) =>
1210
+ throw(CompileError(arguments.first.grab(i).at, "Unexpected named argument"))
1211
+ }
1212
+ } elseIf {self.current().rawIs("{")} {
1213
+ let lambda = self.parseLambda()
1214
+ let effect = self.freshUnificationVariable(record.at)
1215
+ let arguments = lambda.cases.grabFirst().patterns.size()
1216
+ let target = DynamicCall(EField(token.at(), False, record, "function" + arguments), False)
1217
+ ECall(record.at, target, effect, [], [
1218
+ Argument(lambda.at, None, ELambda(lambda.at, lambda))
1219
+ ], [])
1220
+ } else:
1188
1221
  let token = if(self.current().is(LLower)) {
1189
1222
  self.skip(LLower)
1190
1223
  } elseIf {self.current().is(LUpper)} {
@@ -1195,6 +1228,9 @@ extend self: Parser {
1195
1228
  let member = EString(token.at(), if(token.is(LString)) {token.raw()} else {"\"" + token.raw() + "\""})
1196
1229
  if(self.current().rawIs("(")) {
1197
1230
  let arguments = self.parseFunctionArguments(record.at, False)
1231
+ arguments.first.find {!_.name.isEmpty()}.each {argument =>
1232
+ throw(CompileError(argument.at, "Unexpected named argument"))
1233
+ }
1198
1234
  let effect = self.freshUnificationVariable(record.at)
1199
1235
  let target = DynamicCall(EField(token.at(), False, record, "call" + arguments.first.size()), False)
1200
1236
  ECall(record.at, target, effect, [], [
@@ -4,24 +4,29 @@ capability Compression {}
4
4
 
5
5
  extend self: Compression {
6
6
 
7
- compressBrotli(uncompressed: Buffer, level: Int = 4): Buffer
7
+ compressBrotli(uncompressed: Buffer, level: Int = 4): Buffer {
8
+ internalCompress("brotli", level, uncompressed)
9
+ }
8
10
 
9
- decompressBrotli(compressed: Buffer): Buffer
11
+ decompressBrotli(compressed: Buffer): Buffer {
12
+
13
+ }
10
14
 
11
- compressGzip(uncompressed: Buffer, level: Int = 6): Buffer
15
+ compressGzip(uncompressed: Buffer, level: Int = 6): Buffer {
16
+ internalCompress("gzip", level, uncompressed)
17
+ }
12
18
 
13
- decompressGzip(compressed: Buffer): Buffer
14
- target js async """
15
- async function DecompressBlob(blob) {
16
- const ds = new DecompressionStream("gzip");
17
- const decompressedStream = blob.stream().pipeThrough(ds);
18
- return await new Response(decompressedStream).blob();
19
- }
20
- """
19
+ decompressGzip(compressed: Buffer): Buffer {
20
+
21
+ }
21
22
 
22
- compressDeflate(uncompressed: Buffer, level: Int = 6): Buffer
23
+ compressDeflate(uncompressed: Buffer, level: Int = 6): Buffer {
24
+ internalCompress("deflate", level, uncompressed)
25
+ }
23
26
 
24
- decompressDeflate(compressed: Buffer): Buffer
27
+ decompressDeflate(compressed: Buffer): Buffer {
28
+
29
+ }
25
30
 
26
31
  }
27
32
 
@@ -34,17 +39,17 @@ newForNodeSystem(nodeSystem: NodeSystem): Compression
34
39
  internalCompress(algorithm: String, level: Int, buffer: Buffer): Buffer {
35
40
  let js = UnsafeJs.jsSystem()
36
41
  let dataView = UnsafeJs.toJsValue(buffer)
37
- let uint8Array = js->"Uint8Array".new3(dataView->buffer, dataView->byteOffset, dataView->byteLength)
38
- let stream = js->"ReadableStream".new1(js.object().with("start",
39
- js.function1 {controller =>
42
+ let uint8Array = js->Uint8Array->(dataView->buffer, dataView->byteOffset, dataView->byteLength)
43
+ let stream = js->ReadableStream->(js->(
44
+ start = js->{controller =>
40
45
  controller->enqueue(uint8Array)
41
46
  controller->close()
42
47
  }
43
48
  ))
44
- let ds = js->"DecompressionStream".new1(algorithm)
49
+ let ds = js->DecompressionStream->(algorithm)
45
50
  let decompressedStream = stream->pipeThrough(ds)
46
- let response = UnsafeJs.await {js->"Response".new1(decompressedStream)}
51
+ let response = UnsafeJs.await {js->Response->(decompressedStream)}
47
52
  let decompressedData = UnsafeJs.await {response->arrayBuffer()}
48
- js->"DataView".new1(decompressedData).grabBuffer()
53
+ js->DataView->(decompressedData).grabBuffer()
49
54
  }
50
55
 
@@ -1539,7 +1539,42 @@ return result_
1539
1539
  }
1540
1540
 
1541
1541
  export function Parser_parseDynamicMember(self_, record_) {
1542
- ff_compiler_Parser.Parser_skip(self_, ff_compiler_Token.LArrowThin());
1542
+ const token_ = ff_compiler_Parser.Parser_skip(self_, ff_compiler_Token.LArrowThin());
1543
+ if(ff_compiler_Token.Token_rawIs(ff_compiler_Parser.Parser_current(self_), "(")) {
1544
+ const arguments_ = ff_compiler_Parser.Parser_parseFunctionArguments(self_, ff_compiler_Token.Token_at(token_), false);
1545
+ const effect_ = ff_compiler_Parser.Parser_freshUnificationVariable(self_, record_.at_);
1546
+ {
1547
+ const _1 = ff_core_List.List_indexWhere(arguments_.first_, ((_w1) => {
1548
+ return (!ff_core_Option.Option_isEmpty(_w1.name_))
1549
+ }));
1550
+ if(_1.None) {
1551
+ const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_compiler_Token.Token_at(token_), false, record_, ("new" + ff_core_List.List_size(arguments_.first_))), false);
1552
+ return ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], arguments_.first_, [])
1553
+ }
1554
+ if(_1.Some && _1.value_ === 0) {
1555
+ const objectTarget_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_compiler_Token.Token_at(token_), false, record_, "object"), false);
1556
+ let result_ = ff_compiler_Syntax.ECall(record_.at_, objectTarget_, effect_, [], [], []);
1557
+ ff_core_List.List_each(arguments_.first_, ((argument_) => {
1558
+ if(ff_core_Option.Option_isEmpty(argument_.name_)) {
1559
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(argument_.at_, "Expected a named argument"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1560
+ };
1561
+ const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_compiler_Token.Token_at(token_), false, record_, "with"), false);
1562
+ result_ = ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], [ff_compiler_Syntax.Argument(argument_.at_, ff_core_Option.None(), ff_compiler_Syntax.EString(argument_.at_, ff_core_Option.Option_grab(argument_.name_))), argument_], [])
1563
+ }));
1564
+ return result_
1565
+ }
1566
+ if(_1.Some) {
1567
+ const i_ = _1.value_;
1568
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_core_List.List_grab(arguments_.first_, i_).at_, "Unexpected named argument"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1569
+ }
1570
+ }
1571
+ } else if(ff_compiler_Token.Token_rawIs(ff_compiler_Parser.Parser_current(self_), "{")) {
1572
+ const lambda_ = ff_compiler_Parser.Parser_parseLambda(self_, 0, false, false);
1573
+ const effect_ = ff_compiler_Parser.Parser_freshUnificationVariable(self_, record_.at_);
1574
+ const arguments_ = ff_core_List.List_size(ff_core_List.List_grabFirst(lambda_.cases_).patterns_);
1575
+ const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_compiler_Token.Token_at(token_), false, record_, ("function" + arguments_)), false);
1576
+ return ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], [ff_compiler_Syntax.Argument(lambda_.at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(lambda_.at_, lambda_))], [])
1577
+ } else {
1543
1578
  const token_ = (ff_compiler_Token.Token_is(ff_compiler_Parser.Parser_current(self_), ff_compiler_Token.LLower())
1544
1579
  ? ff_compiler_Parser.Parser_skip(self_, ff_compiler_Token.LLower())
1545
1580
  : ff_compiler_Token.Token_is(ff_compiler_Parser.Parser_current(self_), ff_compiler_Token.LUpper())
@@ -1550,6 +1585,11 @@ const member_ = ff_compiler_Syntax.EString(ff_compiler_Token.Token_at(token_), (
1550
1585
  : (("\"" + ff_compiler_Token.Token_raw(token_)) + "\"")));
1551
1586
  if(ff_compiler_Token.Token_rawIs(ff_compiler_Parser.Parser_current(self_), "(")) {
1552
1587
  const arguments_ = ff_compiler_Parser.Parser_parseFunctionArguments(self_, record_.at_, false);
1588
+ ff_core_Option.Option_each(ff_core_List.List_find(arguments_.first_, ((_w1) => {
1589
+ return (!ff_core_Option.Option_isEmpty(_w1.name_))
1590
+ })), ((argument_) => {
1591
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(argument_.at_, "Unexpected named argument"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1592
+ }));
1553
1593
  const effect_ = ff_compiler_Parser.Parser_freshUnificationVariable(self_, record_.at_);
1554
1594
  const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_compiler_Token.Token_at(token_), false, record_, ("call" + ff_core_List.List_size(arguments_.first_))), false);
1555
1595
  return ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], [ff_compiler_Syntax.Argument(member_.at_, ff_core_Option.None(), member_), ...arguments_.first_], [])
@@ -1578,6 +1618,7 @@ const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_comp
1578
1618
  return ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], [ff_compiler_Syntax.Argument(member_.at_, ff_core_Option.None(), member_)], [])
1579
1619
  }
1580
1620
  }
1621
+ }
1581
1622
 
1582
1623
  export function Parser_parseAtom(self_) {
1583
1624
  if(ff_compiler_Token.Token_is(ff_compiler_Parser.Parser_current(self_), ff_compiler_Token.LString())) {
@@ -3108,7 +3149,42 @@ return result_
3108
3149
  }
3109
3150
 
3110
3151
  export async function Parser_parseDynamicMember$(self_, record_, $task) {
3111
- ff_compiler_Parser.Parser_skip(self_, ff_compiler_Token.LArrowThin());
3152
+ const token_ = ff_compiler_Parser.Parser_skip(self_, ff_compiler_Token.LArrowThin());
3153
+ if(ff_compiler_Token.Token_rawIs(ff_compiler_Parser.Parser_current(self_), "(")) {
3154
+ const arguments_ = ff_compiler_Parser.Parser_parseFunctionArguments(self_, ff_compiler_Token.Token_at(token_), false);
3155
+ const effect_ = ff_compiler_Parser.Parser_freshUnificationVariable(self_, record_.at_);
3156
+ {
3157
+ const _1 = ff_core_List.List_indexWhere(arguments_.first_, ((_w1) => {
3158
+ return (!ff_core_Option.Option_isEmpty(_w1.name_))
3159
+ }));
3160
+ if(_1.None) {
3161
+ const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_compiler_Token.Token_at(token_), false, record_, ("new" + ff_core_List.List_size(arguments_.first_))), false);
3162
+ return ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], arguments_.first_, [])
3163
+ }
3164
+ if(_1.Some && _1.value_ === 0) {
3165
+ const objectTarget_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_compiler_Token.Token_at(token_), false, record_, "object"), false);
3166
+ let result_ = ff_compiler_Syntax.ECall(record_.at_, objectTarget_, effect_, [], [], []);
3167
+ ff_core_List.List_each(arguments_.first_, ((argument_) => {
3168
+ if(ff_core_Option.Option_isEmpty(argument_.name_)) {
3169
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(argument_.at_, "Expected a named argument"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
3170
+ };
3171
+ const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_compiler_Token.Token_at(token_), false, record_, "with"), false);
3172
+ result_ = ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], [ff_compiler_Syntax.Argument(argument_.at_, ff_core_Option.None(), ff_compiler_Syntax.EString(argument_.at_, ff_core_Option.Option_grab(argument_.name_))), argument_], [])
3173
+ }));
3174
+ return result_
3175
+ }
3176
+ if(_1.Some) {
3177
+ const i_ = _1.value_;
3178
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(ff_core_List.List_grab(arguments_.first_, i_).at_, "Unexpected named argument"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
3179
+ }
3180
+ }
3181
+ } else if(ff_compiler_Token.Token_rawIs(ff_compiler_Parser.Parser_current(self_), "{")) {
3182
+ const lambda_ = ff_compiler_Parser.Parser_parseLambda(self_, 0, false, false);
3183
+ const effect_ = ff_compiler_Parser.Parser_freshUnificationVariable(self_, record_.at_);
3184
+ const arguments_ = ff_core_List.List_size(ff_core_List.List_grabFirst(lambda_.cases_).patterns_);
3185
+ const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_compiler_Token.Token_at(token_), false, record_, ("function" + arguments_)), false);
3186
+ return ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], [ff_compiler_Syntax.Argument(lambda_.at_, ff_core_Option.None(), ff_compiler_Syntax.ELambda(lambda_.at_, lambda_))], [])
3187
+ } else {
3112
3188
  const token_ = (ff_compiler_Token.Token_is(ff_compiler_Parser.Parser_current(self_), ff_compiler_Token.LLower())
3113
3189
  ? ff_compiler_Parser.Parser_skip(self_, ff_compiler_Token.LLower())
3114
3190
  : ff_compiler_Token.Token_is(ff_compiler_Parser.Parser_current(self_), ff_compiler_Token.LUpper())
@@ -3119,6 +3195,11 @@ const member_ = ff_compiler_Syntax.EString(ff_compiler_Token.Token_at(token_), (
3119
3195
  : (("\"" + ff_compiler_Token.Token_raw(token_)) + "\"")));
3120
3196
  if(ff_compiler_Token.Token_rawIs(ff_compiler_Parser.Parser_current(self_), "(")) {
3121
3197
  const arguments_ = ff_compiler_Parser.Parser_parseFunctionArguments(self_, record_.at_, false);
3198
+ ff_core_Option.Option_each(ff_core_List.List_find(arguments_.first_, ((_w1) => {
3199
+ return (!ff_core_Option.Option_isEmpty(_w1.name_))
3200
+ })), ((argument_) => {
3201
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(argument_.at_, "Unexpected named argument"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
3202
+ }));
3122
3203
  const effect_ = ff_compiler_Parser.Parser_freshUnificationVariable(self_, record_.at_);
3123
3204
  const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_compiler_Token.Token_at(token_), false, record_, ("call" + ff_core_List.List_size(arguments_.first_))), false);
3124
3205
  return ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], [ff_compiler_Syntax.Argument(member_.at_, ff_core_Option.None(), member_), ...arguments_.first_], [])
@@ -3147,6 +3228,7 @@ const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_comp
3147
3228
  return ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], [ff_compiler_Syntax.Argument(member_.at_, ff_core_Option.None(), member_)], [])
3148
3229
  }
3149
3230
  }
3231
+ }
3150
3232
 
3151
3233
  export async function Parser_parseAtom$(self_, $task) {
3152
3234
  if(ff_compiler_Token.Token_is(ff_compiler_Parser.Parser_current(self_), ff_compiler_Token.LString())) {
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.4.88",
7
+ "version": "0.4.90",
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.4.88",
7
+ "version": "0.4.90",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"