firefly-compiler 0.5.27 → 0.5.29

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.
@@ -73,7 +73,9 @@ processNodeModules(system: NodeSystem, jsPathFile: Path, packagePath: Path, info
73
73
  let packageJson = includePath.slash("package.json")
74
74
  if(!nodeModules.exists() && packageJson.exists()) {
75
75
  system.writeErrorLine("Running npm install --no-package-lock --no-bin-links in " + includePath.absolute())
76
- system.execute("npm", ["install", "--no-package-lock", "--no-bin-links"], directory = Some(includePath))
76
+ system.execute("npm", [
77
+ "install", "--no-package-lock", "--no-bin-links"
78
+ ], directory = Some(includePath), shell = True)
77
79
  }
78
80
  }
79
81
  }
@@ -173,6 +173,23 @@ tokenize(file: String, code: String, completionAt: Option[Location], attemptFixe
173
173
 
174
174
  } elseIf {code.grab(i).isAsciiDigit()} {
175
175
 
176
+ if(i + 2 < code.size() && code.grab(i) == '0' && (
177
+ code.grab(i + 1) == 'x' || code.grab(i + 1) == 'X'
178
+ )) {
179
+ i += 2
180
+ while {i < code.size() && (code.grab(i).isAsciiDigit() || (
181
+ code.grab(i) >= 'a' && code.grab(i) <= 'f'
182
+ ) || (
183
+ code.grab(i) >= 'A' && code.grab(i) <= 'F'
184
+ ))} {
185
+ i += 1
186
+ }
187
+ if(start == i - 2) {
188
+ throwError("Unexpected character: " + Show.show(code.grab(start + 2)))
189
+ }
190
+ emitToken(LInt, start, i)
191
+ } else:
192
+
176
193
  mutable dot = False
177
194
  mutable exponent = False
178
195
  while {i < code.size() && code.grab(i).isAsciiDigit()} {
package/core/Any.ff CHANGED
@@ -1,30 +1,30 @@
1
- data Any {}
2
- data AnyTag[T] {}
3
-
4
- trait T: HasAnyTag {
5
- anyTag(): AnyTag[T]
6
- }
7
-
8
- toAny[T: HasAnyTag](value: T): Any
9
- target js sync """
10
- const anyTag = ff_core_Any_HasAnyTag$T.anyTag_()
11
- return {anyTag: anyTag, value: value_}
12
- """
13
-
14
- fromAny[T: HasAnyTag](any: Any): Option[T]
15
- target js sync """
16
- const anyTag = ff_core_Any_HasAnyTag$T.anyTag_()
17
- return any_.anyTag === anyTag ? ff_core_Option.Some(any_.value) : ff_core_Option.None()
18
- """
19
-
20
- extend self[T]: AnyTag[T] {
21
- show(): String
22
- target js sync """
23
- return self_
24
- """
25
- }
26
-
27
- internalAnyTag[T](tag: String): AnyTag[T]
28
- target js sync """
29
- return tag_
30
- """
1
+ data Any {}
2
+ data AnyTag[T] {}
3
+
4
+ trait T: HasAnyTag {
5
+ anyTag(): AnyTag[T]
6
+ }
7
+
8
+ toAny[T: HasAnyTag](value: T): Any
9
+ target js sync """
10
+ const anyTag = ff_core_Any_HasAnyTag$T.anyTag_()
11
+ return {anyTag: anyTag, value: value_}
12
+ """
13
+
14
+ fromAny[T: HasAnyTag](any: Any): Option[T]
15
+ target js sync """
16
+ const anyTag = ff_core_Any_HasAnyTag$T.anyTag_()
17
+ return any_.anyTag === anyTag ? ff_core_Option.Some(any_.value) : ff_core_Option.None()
18
+ """
19
+
20
+ extend self[T]: AnyTag[T] {
21
+ show(): String
22
+ target js sync """
23
+ return self_
24
+ """
25
+ }
26
+
27
+ internalAnyTag[T](tag: String): AnyTag[T]
28
+ target js sync """
29
+ return tag_
30
+ """
@@ -107,6 +107,7 @@ extend self: NodeSystem {
107
107
  maxBuffer: Int = 16777216
108
108
  killSignal: Int = 9
109
109
  windowsWhere: Bool = True
110
+ shell: Bool = False
110
111
  ): ProcessResult
111
112
  target node async """
112
113
  import * as childProcess from 'node:child_process';
@@ -130,6 +131,7 @@ extend self: NodeSystem {
130
131
  signal: $task.controller.signal,
131
132
  killSignal: killSignal_,
132
133
  env: environment,
134
+ shell: shell_
133
135
  });
134
136
 
135
137
  let size = 0;
@@ -1,65 +1,65 @@
1
- main(system: NodeSystem) {
2
- let inBuffers = 1.to(100).map {_ => Buffer.fromByteList([5, 5, 3, 1, 2].toArray())}
3
- let inStream = inBuffers.toStream()
4
- let outStream = toRunLength(inStream, 3)
5
- printRunLength(outStream)
6
- }
7
-
8
- printRunLength(outStream: Stream[Buffer]) {
9
- let buffer = Buffer.fromBufferList(outStream.toArray())
10
- Log.debug(buffer.toHex())
11
- let stack = Stack.make()
12
- mutable i = 0
13
- while {i < buffer.size()} {
14
- 1.to(buffer.grabUint8(i)).each {_ => stack.push(buffer.grabUint8(i + 1))}
15
- i += 2
16
- }
17
- Log.debug(Buffer.fromByteList(stack.drain()).toHex())
18
- }
19
-
20
- toRunLength(stream: Stream[Buffer], bufferSize: Int = 65536): Stream[Buffer] {
21
- mutable outBuffer = Buffer.new(bufferSize)
22
- mutable outOffset = 0
23
- let outBuffers = Stack.make()
24
- function writeByte(byte: Int): Unit {
25
- if(outOffset >= outBuffer.size()) {
26
- outBuffers.push(outBuffer)
27
- outBuffer = Buffer.new(bufferSize)
28
- outOffset = 0
29
- }
30
- outBuffer.setUint8(outOffset, byte)
31
- outOffset += 1
32
- }
33
- mutable extraCount = 0
34
- mutable value = 0
35
- let result = stream.flatMap {inBuffer =>
36
- mutable i = 0
37
- while {i < inBuffer.size()} {
38
- value = if(extraCount > 0) {value} else {inBuffer.grabUint8(i)}
39
- mutable j = if(extraCount > 0) {-1} else {0}
40
- doWhile {
41
- j += 1
42
- j + extraCount < 256 && i + j < inBuffer.size() && inBuffer.grabUint8(i + j) == value
43
- }
44
- i += j
45
- if(i < inBuffer.size() || j + extraCount == 256) {
46
- writeByte(j + extraCount)
47
- writeByte(value)
48
- extraCount = 0
49
- } else {
50
- extraCount += j
51
- }
52
- }
53
- outBuffers.drain().toStream()
54
- }
55
- result.addAll(Stream.init {
56
- if(extraCount > 0) {
57
- writeByte(extraCount)
58
- writeByte(value)
59
- }
60
- if(outOffset > 0) {
61
- outBuffers.push(outBuffer.view(0, outOffset))
62
- }
63
- outBuffers.drain().toStream()
64
- })
65
- }
1
+ main(system: NodeSystem) {
2
+ let inBuffers = 1.to(100).map {_ => Buffer.fromByteList([5, 5, 3, 1, 2].toArray())}
3
+ let inStream = inBuffers.toStream()
4
+ let outStream = toRunLength(inStream, 3)
5
+ printRunLength(outStream)
6
+ }
7
+
8
+ printRunLength(outStream: Stream[Buffer]) {
9
+ let buffer = Buffer.fromBufferList(outStream.toArray())
10
+ Log.debug(buffer.toHex())
11
+ let stack = Stack.make()
12
+ mutable i = 0
13
+ while {i < buffer.size()} {
14
+ 1.to(buffer.grabUint8(i)).each {_ => stack.push(buffer.grabUint8(i + 1))}
15
+ i += 2
16
+ }
17
+ Log.debug(Buffer.fromByteList(stack.drain()).toHex())
18
+ }
19
+
20
+ toRunLength(stream: Stream[Buffer], bufferSize: Int = 65536): Stream[Buffer] {
21
+ mutable outBuffer = Buffer.new(bufferSize)
22
+ mutable outOffset = 0
23
+ let outBuffers = Stack.make()
24
+ function writeByte(byte: Int): Unit {
25
+ if(outOffset >= outBuffer.size()) {
26
+ outBuffers.push(outBuffer)
27
+ outBuffer = Buffer.new(bufferSize)
28
+ outOffset = 0
29
+ }
30
+ outBuffer.setUint8(outOffset, byte)
31
+ outOffset += 1
32
+ }
33
+ mutable extraCount = 0
34
+ mutable value = 0
35
+ let result = stream.flatMap {inBuffer =>
36
+ mutable i = 0
37
+ while {i < inBuffer.size()} {
38
+ value = if(extraCount > 0) {value} else {inBuffer.grabUint8(i)}
39
+ mutable j = if(extraCount > 0) {-1} else {0}
40
+ doWhile {
41
+ j += 1
42
+ j + extraCount < 256 && i + j < inBuffer.size() && inBuffer.grabUint8(i + j) == value
43
+ }
44
+ i += j
45
+ if(i < inBuffer.size() || j + extraCount == 256) {
46
+ writeByte(j + extraCount)
47
+ writeByte(value)
48
+ extraCount = 0
49
+ } else {
50
+ extraCount += j
51
+ }
52
+ }
53
+ outBuffers.drain().toStream()
54
+ }
55
+ result.addAll(Stream.init {
56
+ if(extraCount > 0) {
57
+ writeByte(extraCount)
58
+ writeByte(value)
59
+ }
60
+ if(outOffset > 0) {
61
+ outBuffers.push(outBuffer.view(0, outOffset))
62
+ }
63
+ outBuffers.drain().toStream()
64
+ })
65
+ }
@@ -172,7 +172,7 @@ const nodeModules_ = ff_core_Path.Path_slash(includePath_, "node_modules");
172
172
  const packageJson_ = ff_core_Path.Path_slash(includePath_, "package.json");
173
173
  if(((!ff_core_Path.Path_exists(nodeModules_, false, false, false)) && ff_core_Path.Path_exists(packageJson_, false, false, false))) {
174
174
  ff_core_NodeSystem.NodeSystem_writeErrorLine(system_, ("Running npm install --no-package-lock --no-bin-links in " + ff_core_Path.Path_absolute(includePath_)));
175
- ff_core_NodeSystem.NodeSystem_execute(system_, "npm", ["install", "--no-package-lock", "--no-bin-links"], ff_core_Buffer.new_(0, false), ff_core_Option.Some(includePath_), ff_core_Option.None(), 16777216, 9, true)
175
+ ff_core_NodeSystem.NodeSystem_execute(system_, "npm", ["install", "--no-package-lock", "--no-bin-links"], ff_core_Buffer.new_(0, false), ff_core_Option.Some(includePath_), ff_core_Option.None(), 16777216, 9, true, true)
176
176
  }
177
177
  }
178
178
  }
@@ -386,7 +386,7 @@ const nodeModules_ = (await ff_core_Path.Path_slash$(includePath_, "node_modules
386
386
  const packageJson_ = (await ff_core_Path.Path_slash$(includePath_, "package.json", $task));
387
387
  if(((!(await ff_core_Path.Path_exists$(nodeModules_, false, false, false, $task))) && (await ff_core_Path.Path_exists$(packageJson_, false, false, false, $task)))) {
388
388
  (await ff_core_NodeSystem.NodeSystem_writeErrorLine$(system_, ("Running npm install --no-package-lock --no-bin-links in " + (await ff_core_Path.Path_absolute$(includePath_, $task))), $task));
389
- (await ff_core_NodeSystem.NodeSystem_execute$(system_, "npm", ["install", "--no-package-lock", "--no-bin-links"], ff_core_Buffer.new_(0, false), ff_core_Option.Some(includePath_), ff_core_Option.None(), 16777216, 9, true, $task))
389
+ (await ff_core_NodeSystem.NodeSystem_execute$(system_, "npm", ["install", "--no-package-lock", "--no-bin-links"], ff_core_Buffer.new_(0, false), ff_core_Option.Some(includePath_), ff_core_Option.None(), 16777216, 9, true, true, $task))
390
390
  }
391
391
  }
392
392
  }
@@ -254,6 +254,16 @@ emitToken_(ff_compiler_Token.LNamespace(), start_, i_)
254
254
  emitToken_(kind_, start_, i_)
255
255
  }
256
256
  } else if(ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_))) {
257
+ if(((((i_ + 2) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 48)) && ((ff_core_String.String_grab(code_, (i_ + 1)) === 120) || (ff_core_String.String_grab(code_, (i_ + 1)) === 88)))) {
258
+ i_ += 2;
259
+ while(((i_ < ff_core_String.String_size(code_)) && ((ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_)) || ((ff_core_String.String_grab(code_, i_) >= 97) && (ff_core_String.String_grab(code_, i_) <= 102))) || ((ff_core_String.String_grab(code_, i_) >= 65) && (ff_core_String.String_grab(code_, i_) <= 70))))) {
260
+ i_ += 1
261
+ };
262
+ if((start_ === (i_ - 2))) {
263
+ throwError_(("Unexpected character: " + ff_core_Show.ff_core_Show_Show$ff_core_Char_Char.show_(ff_core_String.String_grab(code_, (start_ + 2)))))
264
+ };
265
+ emitToken_(ff_compiler_Token.LInt(), start_, i_)
266
+ } else {
257
267
  let dot_ = false;
258
268
  let exponent_ = false;
259
269
  while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_)))) {
@@ -274,6 +284,7 @@ dot_ = true
274
284
  emitToken_(((dot_ || exponent_)
275
285
  ? ff_compiler_Token.LFloat()
276
286
  : ff_compiler_Token.LInt()), start_, i_)
287
+ }
277
288
  } else if((ff_core_String.String_grab(code_, i_) === 95)) {
278
289
  i_ += 1;
279
290
  emitToken_(ff_compiler_Token.LWildcard(), start_, i_)
@@ -501,6 +512,16 @@ emitToken_(ff_compiler_Token.LNamespace(), start_, i_)
501
512
  emitToken_(kind_, start_, i_)
502
513
  }
503
514
  } else if(ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_))) {
515
+ if(((((i_ + 2) < ff_core_String.String_size(code_)) && (ff_core_String.String_grab(code_, i_) === 48)) && ((ff_core_String.String_grab(code_, (i_ + 1)) === 120) || (ff_core_String.String_grab(code_, (i_ + 1)) === 88)))) {
516
+ i_ += 2;
517
+ while(((i_ < ff_core_String.String_size(code_)) && ((ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_)) || ((ff_core_String.String_grab(code_, i_) >= 97) && (ff_core_String.String_grab(code_, i_) <= 102))) || ((ff_core_String.String_grab(code_, i_) >= 65) && (ff_core_String.String_grab(code_, i_) <= 70))))) {
518
+ i_ += 1
519
+ };
520
+ if((start_ === (i_ - 2))) {
521
+ throwError_(("Unexpected character: " + ff_core_Show.ff_core_Show_Show$ff_core_Char_Char.show_(ff_core_String.String_grab(code_, (start_ + 2)))))
522
+ };
523
+ emitToken_(ff_compiler_Token.LInt(), start_, i_)
524
+ } else {
504
525
  let dot_ = false;
505
526
  let exponent_ = false;
506
527
  while(((i_ < ff_core_String.String_size(code_)) && ff_core_Char.Char_isAsciiDigit(ff_core_String.String_grab(code_, i_)))) {
@@ -521,6 +542,7 @@ dot_ = true
521
542
  emitToken_(((dot_ || exponent_)
522
543
  ? ff_compiler_Token.LFloat()
523
544
  : ff_compiler_Token.LInt()), start_, i_)
545
+ }
524
546
  } else if((ff_core_String.String_grab(code_, i_) === 95)) {
525
547
  i_ += 1;
526
548
  emitToken_(ff_compiler_Token.LWildcard(), start_, i_)
@@ -101,22 +101,22 @@ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
101
101
 
102
102
 
103
103
  export function toAny_(value_, ff_core_Any_HasAnyTag$T) {
104
-
105
- const anyTag = ff_core_Any_HasAnyTag$T.anyTag_()
106
- return {anyTag: anyTag, value: value_}
104
+
105
+ const anyTag = ff_core_Any_HasAnyTag$T.anyTag_()
106
+ return {anyTag: anyTag, value: value_}
107
107
 
108
108
  }
109
109
 
110
110
  export function fromAny_(any_, ff_core_Any_HasAnyTag$T) {
111
-
112
- const anyTag = ff_core_Any_HasAnyTag$T.anyTag_()
113
- return any_.anyTag === anyTag ? ff_core_Option.Some(any_.value) : ff_core_Option.None()
111
+
112
+ const anyTag = ff_core_Any_HasAnyTag$T.anyTag_()
113
+ return any_.anyTag === anyTag ? ff_core_Option.Some(any_.value) : ff_core_Option.None()
114
114
 
115
115
  }
116
116
 
117
117
  export function internalAnyTag_(tag_) {
118
-
119
- return tag_
118
+
119
+ return tag_
120
120
 
121
121
  }
122
122
 
@@ -133,8 +133,8 @@ throw new Error('Function internalAnyTag is missing on this target in async cont
133
133
  }
134
134
 
135
135
  export function AnyTag_show(self_) {
136
-
137
- return self_
136
+
137
+ return self_
138
138
 
139
139
  }
140
140
 
@@ -135,7 +135,7 @@ return ((ff_core_Char.Char_isAsciiLetterOrDigit(c_) || (c_ === 95)) || (c_ === 4
135
135
  })))) {
136
136
  return ff_core_Option.None()
137
137
  } else {
138
- const out_ = ff_core_NodeSystem.NodeSystem_execute(system_, cmd_, ["/c", "where", command_], ff_core_Buffer.new_(0, false), directory_, environment_, 16777216, 9, false);
138
+ const out_ = ff_core_NodeSystem.NodeSystem_execute(system_, cmd_, ["/c", "where", command_], ff_core_Buffer.new_(0, false), directory_, environment_, 16777216, 9, false, false);
139
139
  return ff_core_List.List_first(ff_core_List.List_filter(ff_core_String.String_lines(ff_core_Buffer.Buffer_toString(out_.standardOut_, "utf8")), ((line_) => {
140
140
  return ((out_.exitCode_ === 0) && ff_core_Option.Option_any(ff_core_List.List_last(ff_core_String.String_split(line_, 92)), ((_w1) => {
141
141
  return ff_core_String.String_contains(_w1, ".")
@@ -171,7 +171,7 @@ return ((ff_core_Char.Char_isAsciiLetterOrDigit(c_) || (c_ === 95)) || (c_ === 4
171
171
  })))) {
172
172
  return ff_core_Option.None()
173
173
  } else {
174
- const out_ = (await ff_core_NodeSystem.NodeSystem_execute$(system_, cmd_, ["/c", "where", command_], ff_core_Buffer.new_(0, false), directory_, environment_, 16777216, 9, false, $task));
174
+ const out_ = (await ff_core_NodeSystem.NodeSystem_execute$(system_, cmd_, ["/c", "where", command_], ff_core_Buffer.new_(0, false), directory_, environment_, 16777216, 9, false, false, $task));
175
175
  return ff_core_List.List_first(ff_core_List.List_filter(ff_core_String.String_lines(ff_core_Buffer.Buffer_toString(out_.standardOut_, "utf8")), ((line_) => {
176
176
  return ((out_.exitCode_ === 0) && ff_core_Option.Option_any(ff_core_List.List_last(ff_core_String.String_split(line_, 92)), ((_w1) => {
177
177
  return ff_core_String.String_contains(_w1, ".")
@@ -276,7 +276,7 @@ export function NodeSystem_environment(self_) {
276
276
  throw new Error('Function NodeSystem_environment is missing on this target in sync context.');
277
277
  }
278
278
 
279
- export function NodeSystem_execute(self_, command_, arguments_, standardIn_ = ff_core_Buffer.new_(0), directory_ = ff_core_Option.None(), environment_ = ff_core_Option.None(), maxBuffer_ = 16777216, killSignal_ = 9, windowsWhere_ = true) {
279
+ export function NodeSystem_execute(self_, command_, arguments_, standardIn_ = ff_core_Buffer.new_(0), directory_ = ff_core_Option.None(), environment_ = ff_core_Option.None(), maxBuffer_ = 16777216, killSignal_ = 9, windowsWhere_ = true, shell_ = false) {
280
280
  throw new Error('Function NodeSystem_execute is missing on this target in sync context.');
281
281
  }
282
282
 
@@ -390,7 +390,7 @@ export async function NodeSystem_environment$(self_, $task) {
390
390
 
391
391
  }
392
392
 
393
- export async function NodeSystem_execute$(self_, command_, arguments_, standardIn_ = ff_core_Buffer.new_(0), directory_ = ff_core_Option.None(), environment_ = ff_core_Option.None(), maxBuffer_ = 16777216, killSignal_ = 9, windowsWhere_ = true, $task) {
393
+ export async function NodeSystem_execute$(self_, command_, arguments_, standardIn_ = ff_core_Buffer.new_(0), directory_ = ff_core_Option.None(), environment_ = ff_core_Option.None(), maxBuffer_ = 16777216, killSignal_ = 9, windowsWhere_ = true, shell_ = false, $task) {
394
394
 
395
395
  const childProcess = import$3;
396
396
  const environment = environment_.value_ !== void 0 ? {} : process.env;
@@ -413,6 +413,7 @@ export async function NodeSystem_execute$(self_, command_, arguments_, standardI
413
413
  signal: $task.controller.signal,
414
414
  killSignal: killSignal_,
415
415
  env: environment,
416
+ shell: shell_
416
417
  });
417
418
 
418
419
  let size = 0;
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.27",
7
+ "version": "0.5.29",
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.27",
7
+ "version": "0.5.29",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"