firefly-compiler 0.4.68 → 0.4.70

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/core/Float.ff CHANGED
@@ -27,130 +27,142 @@ extend self: Float {
27
27
  target js sync "return self_.toFixed(digits_)"
28
28
 
29
29
  min(that: Float): Float
30
- target js sync "return Math.min(self, that)"
30
+ target js sync "return Math.min(self_, that_)"
31
31
 
32
32
  max(that: Float): Float
33
- target js sync "return Math.max(self, that)"
33
+ target js sync "return Math.max(self_, that_)"
34
34
 
35
- clamp(from: Float, to: Float): Float {
36
- if(self <= from) {from} elseIf {self >= to} {to} else {self}
35
+ clamp(from: Float, to: Float): Float
36
+ target js sync "return Math.min(Math.max(self_, from_), to_)"
37
+
38
+ lerp(that: Float, factor: Float): Float {
39
+ self + factor * (that - self)
40
+ }
41
+
42
+ smoothstep(that: Float, factor: Float): Float {
43
+ let t = ((factor - self) / (that - self)).clamp(0.0, 1.0)
44
+ t * t * (3.0 - 2.0 * t)
45
+ }
46
+
47
+ expDecay(that: Float, decay: Float, factor: Float): Float {
48
+ that + (self - that) * (-decay * factor).exp()
37
49
  }
38
50
 
39
- acos()
51
+ acos(): Float
40
52
  target js sync """
41
- return Math.acos(self);
53
+ return Math.acos(self_);
42
54
  """
43
55
 
44
- acosh()
56
+ acosh(): Float
45
57
  target js sync """
46
- return Math.acosh(self);
58
+ return Math.acosh(self_);
47
59
  """
48
60
 
49
- asin()
61
+ asin(): Float
50
62
  target js sync """
51
- return Math.asin(self);
63
+ return Math.asin(self_);
52
64
  """
53
65
 
54
- asinh()
66
+ asinh(): Float
55
67
  target js sync """
56
- return Math.asinh(self);
68
+ return Math.asinh(self_);
57
69
  """
58
70
 
59
- atan()
71
+ atan(): Float
60
72
  target js sync """
61
- return Math.atan(self);
73
+ return Math.atan(self_);
62
74
  """
63
75
 
64
- atan2(that: Float)
76
+ atan2(that: Float): Float
65
77
  target js sync """
66
- return Math.atan2(self, that);
78
+ return Math.atan2(self_, that_);
67
79
  """
68
80
 
69
- atanh()
81
+ atanh(): Float
70
82
  target js sync """
71
- return Math.atanh(self);
83
+ return Math.atanh(self_);
72
84
  """
73
85
 
74
- cbrt()
86
+ cbrt(): Float
75
87
  target js sync """
76
- return Math.cbrt(self);
88
+ return Math.cbrt(self_);
77
89
  """
78
90
 
79
- cos()
91
+ cos(): Float
80
92
  target js sync """
81
- return Math.cos(self);
93
+ return Math.cos(self_);
82
94
  """
83
95
 
84
- cosh()
96
+ cosh(): Float
85
97
  target js sync """
86
- return Math.cosh(self);
98
+ return Math.cosh(self_);
87
99
  """
88
100
 
89
- exp()
101
+ exp(): Float
90
102
  target js sync """
91
- return Math.exp(self);
103
+ return Math.exp(self_);
92
104
  """
93
105
 
94
- expm1()
106
+ expm1(): Float
95
107
  target js sync """
96
- return Math.expm1(self);
108
+ return Math.expm1(self_);
97
109
  """
98
110
 
99
- log(that: Float)
111
+ log(that: Float): Float
100
112
  target js sync """
101
- return Math.log2(self) / Math.log2(that);
113
+ return Math.log2(self_) / Math.log2(that_);
102
114
  """
103
115
 
104
- log10()
116
+ log10(): Float
105
117
  target js sync """
106
- return Math.log10(self);
118
+ return Math.log10(self_);
107
119
  """
108
120
 
109
- log2()
121
+ log2(): Float
110
122
  target js sync """
111
- return Math.log2(self);
123
+ return Math.log2(self_);
112
124
  """
113
125
 
114
- ln()
126
+ ln(): Float
115
127
  target js sync """
116
- return Math.log(self);
128
+ return Math.log(self_);
117
129
  """
118
130
 
119
- ln1p()
131
+ ln1p(): Float
120
132
  target js sync """
121
- return Math.log1p(self);
133
+ return Math.log1p(self_);
122
134
  """
123
135
 
124
- sin()
136
+ sin(): Float
125
137
  target js sync """
126
- return Math.sin(self);
138
+ return Math.sin(self_);
127
139
  """
128
140
 
129
- sinh()
141
+ sinh(): Float
130
142
  target js sync """
131
- return Math.sinh(self);
143
+ return Math.sinh(self_);
132
144
  """
133
145
 
134
- sqrt()
146
+ sqrt(): Float
135
147
  target js sync """
136
- return Math.sqrt(self);
148
+ return Math.sqrt(self_);
137
149
  """
138
150
 
139
- tan()
151
+ tan(): Float
140
152
  target js sync """
141
- return Math.tan(self);
153
+ return Math.tan(self_);
142
154
  """
143
155
 
144
- tanh()
156
+ tanh(): Float
145
157
  target js sync """
146
- return Math.tanh(self);
158
+ return Math.tanh(self_);
147
159
  """
148
160
 
149
161
  }
150
162
 
151
163
  hypot(values: List[Float]): Float
152
164
  target js sync """
153
- return Math.hypot(...values);
165
+ return Math.hypot(...values_);
154
166
  """
155
167
 
156
168
  e(): Float
package/core/Int.ff CHANGED
@@ -26,6 +26,9 @@ extend self: Int {
26
26
  bitRight(bits: Int, signed: Bool = True): Int
27
27
  target js sync "return signed_ ? self_ >> bits_ : self_ >>> bits_;"
28
28
 
29
+ bitLeadingZeros(): Int
30
+ target js sync "return Math.clz32(self_);"
31
+
29
32
  to(inclusiveEnd: Int): List[Int] {
30
33
  let result = Array.new()
31
34
  mutable n = self
@@ -46,17 +49,14 @@ extend self: Int {
46
49
  result.drain()
47
50
  }
48
51
 
49
- min(that: Int): Int {
50
- if(self < that) {self} else {that}
51
- }
52
+ min(that: Int): Int
53
+ target js sync "return Math.min(self_, that_)"
52
54
 
53
- max(that: Int): Int {
54
- if(self > that) {self} else {that}
55
- }
55
+ max(that: Int): Int
56
+ target js sync "return Math.max(self_, that_)"
56
57
 
57
- clamp(from: Int, to: Int): Int {
58
- if(self <= from) {from} elseIf {self >= to} {to} else {self}
59
- }
58
+ clamp(from: Int, to: Int): Int
59
+ target js sync "return Math.min(Math.max(self_, from_), to_)"
60
60
 
61
61
  pad(padding: String): String {
62
62
  ("" + self).padStart(padding.size(), padding)
@@ -97,7 +97,7 @@ import * as ff_core_Unit from "../../ff/core/Unit.mjs"
97
97
 
98
98
  export function hypot_(values_) {
99
99
 
100
- return Math.hypot(...values);
100
+ return Math.hypot(...values_);
101
101
 
102
102
  }
103
103
 
@@ -218,152 +218,159 @@ return self_.toFixed(digits_)
218
218
  }
219
219
 
220
220
  export function Float_min(self_, that_) {
221
- return Math.min(self, that)
221
+ return Math.min(self_, that_)
222
222
  }
223
223
 
224
224
  export function Float_max(self_, that_) {
225
- return Math.max(self, that)
225
+ return Math.max(self_, that_)
226
226
  }
227
227
 
228
228
  export function Float_clamp(self_, from_, to_) {
229
- if((self_ <= from_)) {
230
- return from_
231
- } else if((self_ >= to_)) {
232
- return to_
233
- } else {
234
- return self_
229
+ return Math.min(Math.max(self_, from_), to_)
235
230
  }
231
+
232
+ export function Float_lerp(self_, that_, factor_) {
233
+ return (self_ + (factor_ * (that_ - self_)))
234
+ }
235
+
236
+ export function Float_smoothstep(self_, that_, factor_) {
237
+ const t_ = ff_core_Float.Float_clamp(((factor_ - self_) / (that_ - self_)), 0.0, 1.0);
238
+ return ((t_ * t_) * (3.0 - (2.0 * t_)))
239
+ }
240
+
241
+ export function Float_expDecay(self_, that_, decay_, factor_) {
242
+ return (that_ + ((self_ - that_) * ff_core_Float.Float_exp(((-decay_) * factor_))))
236
243
  }
237
244
 
238
245
  export function Float_acos(self_) {
239
246
 
240
- return Math.acos(self);
247
+ return Math.acos(self_);
241
248
 
242
249
  }
243
250
 
244
251
  export function Float_acosh(self_) {
245
252
 
246
- return Math.acosh(self);
253
+ return Math.acosh(self_);
247
254
 
248
255
  }
249
256
 
250
257
  export function Float_asin(self_) {
251
258
 
252
- return Math.asin(self);
259
+ return Math.asin(self_);
253
260
 
254
261
  }
255
262
 
256
263
  export function Float_asinh(self_) {
257
264
 
258
- return Math.asinh(self);
265
+ return Math.asinh(self_);
259
266
 
260
267
  }
261
268
 
262
269
  export function Float_atan(self_) {
263
270
 
264
- return Math.atan(self);
271
+ return Math.atan(self_);
265
272
 
266
273
  }
267
274
 
268
275
  export function Float_atan2(self_, that_) {
269
276
 
270
- return Math.atan2(self, that);
277
+ return Math.atan2(self_, that_);
271
278
 
272
279
  }
273
280
 
274
281
  export function Float_atanh(self_) {
275
282
 
276
- return Math.atanh(self);
283
+ return Math.atanh(self_);
277
284
 
278
285
  }
279
286
 
280
287
  export function Float_cbrt(self_) {
281
288
 
282
- return Math.cbrt(self);
289
+ return Math.cbrt(self_);
283
290
 
284
291
  }
285
292
 
286
293
  export function Float_cos(self_) {
287
294
 
288
- return Math.cos(self);
295
+ return Math.cos(self_);
289
296
 
290
297
  }
291
298
 
292
299
  export function Float_cosh(self_) {
293
300
 
294
- return Math.cosh(self);
301
+ return Math.cosh(self_);
295
302
 
296
303
  }
297
304
 
298
305
  export function Float_exp(self_) {
299
306
 
300
- return Math.exp(self);
307
+ return Math.exp(self_);
301
308
 
302
309
  }
303
310
 
304
311
  export function Float_expm1(self_) {
305
312
 
306
- return Math.expm1(self);
313
+ return Math.expm1(self_);
307
314
 
308
315
  }
309
316
 
310
317
  export function Float_log(self_, that_) {
311
318
 
312
- return Math.log2(self) / Math.log2(that);
319
+ return Math.log2(self_) / Math.log2(that_);
313
320
 
314
321
  }
315
322
 
316
323
  export function Float_log10(self_) {
317
324
 
318
- return Math.log10(self);
325
+ return Math.log10(self_);
319
326
 
320
327
  }
321
328
 
322
329
  export function Float_log2(self_) {
323
330
 
324
- return Math.log2(self);
331
+ return Math.log2(self_);
325
332
 
326
333
  }
327
334
 
328
335
  export function Float_ln(self_) {
329
336
 
330
- return Math.log(self);
337
+ return Math.log(self_);
331
338
 
332
339
  }
333
340
 
334
341
  export function Float_ln1p(self_) {
335
342
 
336
- return Math.log1p(self);
343
+ return Math.log1p(self_);
337
344
 
338
345
  }
339
346
 
340
347
  export function Float_sin(self_) {
341
348
 
342
- return Math.sin(self);
349
+ return Math.sin(self_);
343
350
 
344
351
  }
345
352
 
346
353
  export function Float_sinh(self_) {
347
354
 
348
- return Math.sinh(self);
355
+ return Math.sinh(self_);
349
356
 
350
357
  }
351
358
 
352
359
  export function Float_sqrt(self_) {
353
360
 
354
- return Math.sqrt(self);
361
+ return Math.sqrt(self_);
355
362
 
356
363
  }
357
364
 
358
365
  export function Float_tan(self_) {
359
366
 
360
- return Math.tan(self);
367
+ return Math.tan(self_);
361
368
 
362
369
  }
363
370
 
364
371
  export function Float_tanh(self_) {
365
372
 
366
- return Math.tanh(self);
373
+ return Math.tanh(self_);
367
374
 
368
375
  }
369
376
 
@@ -408,13 +415,20 @@ throw new Error('Function Float_max is missing on this target in async context.'
408
415
  }
409
416
 
410
417
  export async function Float_clamp$(self_, from_, to_, $task) {
411
- if((self_ <= from_)) {
412
- return from_
413
- } else if((self_ >= to_)) {
414
- return to_
415
- } else {
416
- return self_
418
+ throw new Error('Function Float_clamp is missing on this target in async context.');
417
419
  }
420
+
421
+ export async function Float_lerp$(self_, that_, factor_, $task) {
422
+ return (self_ + (factor_ * (that_ - self_)))
423
+ }
424
+
425
+ export async function Float_smoothstep$(self_, that_, factor_, $task) {
426
+ const t_ = ff_core_Float.Float_clamp(((factor_ - self_) / (that_ - self_)), 0.0, 1.0);
427
+ return ((t_ * t_) * (3.0 - (2.0 * t_)))
428
+ }
429
+
430
+ export async function Float_expDecay$(self_, that_, decay_, factor_, $task) {
431
+ return (that_ + ((self_ - that_) * ff_core_Float.Float_exp(((-decay_) * factor_))))
418
432
  }
419
433
 
420
434
  export async function Float_acos$(self_, $task) {
@@ -131,6 +131,10 @@ export function Int_bitRight(self_, bits_, signed_ = true) {
131
131
  return signed_ ? self_ >> bits_ : self_ >>> bits_;
132
132
  }
133
133
 
134
+ export function Int_bitLeadingZeros(self_) {
135
+ return Math.clz32(self_);
136
+ }
137
+
134
138
  export function Int_to(self_, inclusiveEnd_) {
135
139
  const result_ = ff_core_Array.new_();
136
140
  let n_ = self_;
@@ -152,29 +156,15 @@ return ff_core_Array.Array_drain(result_)
152
156
  }
153
157
 
154
158
  export function Int_min(self_, that_) {
155
- if((self_ < that_)) {
156
- return self_
157
- } else {
158
- return that_
159
- }
159
+ return Math.min(self_, that_)
160
160
  }
161
161
 
162
162
  export function Int_max(self_, that_) {
163
- if((self_ > that_)) {
164
- return self_
165
- } else {
166
- return that_
167
- }
163
+ return Math.max(self_, that_)
168
164
  }
169
165
 
170
166
  export function Int_clamp(self_, from_, to_) {
171
- if((self_ <= from_)) {
172
- return from_
173
- } else if((self_ >= to_)) {
174
- return to_
175
- } else {
176
- return self_
177
- }
167
+ return Math.min(Math.max(self_, from_), to_)
178
168
  }
179
169
 
180
170
  export function Int_pad(self_, padding_) {
@@ -221,6 +211,10 @@ export async function Int_bitRight$(self_, bits_, signed_ = true, $task) {
221
211
  throw new Error('Function Int_bitRight is missing on this target in async context.');
222
212
  }
223
213
 
214
+ export async function Int_bitLeadingZeros$(self_, $task) {
215
+ throw new Error('Function Int_bitLeadingZeros is missing on this target in async context.');
216
+ }
217
+
224
218
  export async function Int_to$(self_, inclusiveEnd_, $task) {
225
219
  const result_ = ff_core_Array.new_();
226
220
  let n_ = self_;
@@ -242,29 +236,15 @@ return ff_core_Array.Array_drain(result_)
242
236
  }
243
237
 
244
238
  export async function Int_min$(self_, that_, $task) {
245
- if((self_ < that_)) {
246
- return self_
247
- } else {
248
- return that_
249
- }
239
+ throw new Error('Function Int_min is missing on this target in async context.');
250
240
  }
251
241
 
252
242
  export async function Int_max$(self_, that_, $task) {
253
- if((self_ > that_)) {
254
- return self_
255
- } else {
256
- return that_
257
- }
243
+ throw new Error('Function Int_max is missing on this target in async context.');
258
244
  }
259
245
 
260
246
  export async function Int_clamp$(self_, from_, to_, $task) {
261
- if((self_ <= from_)) {
262
- return from_
263
- } else if((self_ >= to_)) {
264
- return to_
265
- } else {
266
- return self_
267
- }
247
+ throw new Error('Function Int_clamp is missing on this target in async context.');
268
248
  }
269
249
 
270
250
  export async function Int_pad$(self_, padding_, $task) {
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.68",
7
+ "version": "0.4.70",
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.68",
7
+ "version": "0.4.70",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"