firefly-compiler 0.4.69 → 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 +37 -29
- package/core/Int.ff +9 -9
- package/output/js/ff/core/Float.mjs +47 -41
- package/output/js/ff/core/Int.mjs +14 -34
- package/package.json +1 -1
- package/vscode/package.json +1 -1
package/core/Float.ff
CHANGED
|
@@ -27,134 +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(
|
|
30
|
+
target js sync "return Math.min(self_, that_)"
|
|
31
31
|
|
|
32
32
|
max(that: Float): Float
|
|
33
|
-
target js sync "return Math.max(
|
|
33
|
+
target js sync "return Math.max(self_, that_)"
|
|
34
34
|
|
|
35
|
-
clamp(from: Float, to: Float): Float
|
|
36
|
-
|
|
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)
|
|
37
45
|
}
|
|
38
46
|
|
|
39
|
-
expDecay(that: Float, decay: Float,
|
|
40
|
-
that + (self - that) * (-decay *
|
|
47
|
+
expDecay(that: Float, decay: Float, factor: Float): Float {
|
|
48
|
+
that + (self - that) * (-decay * factor).exp()
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
acos(): Float
|
|
44
52
|
target js sync """
|
|
45
|
-
return Math.acos(
|
|
53
|
+
return Math.acos(self_);
|
|
46
54
|
"""
|
|
47
55
|
|
|
48
56
|
acosh(): Float
|
|
49
57
|
target js sync """
|
|
50
|
-
return Math.acosh(
|
|
58
|
+
return Math.acosh(self_);
|
|
51
59
|
"""
|
|
52
60
|
|
|
53
61
|
asin(): Float
|
|
54
62
|
target js sync """
|
|
55
|
-
return Math.asin(
|
|
63
|
+
return Math.asin(self_);
|
|
56
64
|
"""
|
|
57
65
|
|
|
58
66
|
asinh(): Float
|
|
59
67
|
target js sync """
|
|
60
|
-
return Math.asinh(
|
|
68
|
+
return Math.asinh(self_);
|
|
61
69
|
"""
|
|
62
70
|
|
|
63
71
|
atan(): Float
|
|
64
72
|
target js sync """
|
|
65
|
-
return Math.atan(
|
|
73
|
+
return Math.atan(self_);
|
|
66
74
|
"""
|
|
67
75
|
|
|
68
76
|
atan2(that: Float): Float
|
|
69
77
|
target js sync """
|
|
70
|
-
return Math.atan2(
|
|
78
|
+
return Math.atan2(self_, that_);
|
|
71
79
|
"""
|
|
72
80
|
|
|
73
81
|
atanh(): Float
|
|
74
82
|
target js sync """
|
|
75
|
-
return Math.atanh(
|
|
83
|
+
return Math.atanh(self_);
|
|
76
84
|
"""
|
|
77
85
|
|
|
78
86
|
cbrt(): Float
|
|
79
87
|
target js sync """
|
|
80
|
-
return Math.cbrt(
|
|
88
|
+
return Math.cbrt(self_);
|
|
81
89
|
"""
|
|
82
90
|
|
|
83
91
|
cos(): Float
|
|
84
92
|
target js sync """
|
|
85
|
-
return Math.cos(
|
|
93
|
+
return Math.cos(self_);
|
|
86
94
|
"""
|
|
87
95
|
|
|
88
96
|
cosh(): Float
|
|
89
97
|
target js sync """
|
|
90
|
-
return Math.cosh(
|
|
98
|
+
return Math.cosh(self_);
|
|
91
99
|
"""
|
|
92
100
|
|
|
93
101
|
exp(): Float
|
|
94
102
|
target js sync """
|
|
95
|
-
return Math.exp(
|
|
103
|
+
return Math.exp(self_);
|
|
96
104
|
"""
|
|
97
105
|
|
|
98
106
|
expm1(): Float
|
|
99
107
|
target js sync """
|
|
100
|
-
return Math.expm1(
|
|
108
|
+
return Math.expm1(self_);
|
|
101
109
|
"""
|
|
102
110
|
|
|
103
111
|
log(that: Float): Float
|
|
104
112
|
target js sync """
|
|
105
|
-
return Math.log2(
|
|
113
|
+
return Math.log2(self_) / Math.log2(that_);
|
|
106
114
|
"""
|
|
107
115
|
|
|
108
116
|
log10(): Float
|
|
109
117
|
target js sync """
|
|
110
|
-
return Math.log10(
|
|
118
|
+
return Math.log10(self_);
|
|
111
119
|
"""
|
|
112
120
|
|
|
113
121
|
log2(): Float
|
|
114
122
|
target js sync """
|
|
115
|
-
return Math.log2(
|
|
123
|
+
return Math.log2(self_);
|
|
116
124
|
"""
|
|
117
125
|
|
|
118
126
|
ln(): Float
|
|
119
127
|
target js sync """
|
|
120
|
-
return Math.log(
|
|
128
|
+
return Math.log(self_);
|
|
121
129
|
"""
|
|
122
130
|
|
|
123
131
|
ln1p(): Float
|
|
124
132
|
target js sync """
|
|
125
|
-
return Math.log1p(
|
|
133
|
+
return Math.log1p(self_);
|
|
126
134
|
"""
|
|
127
135
|
|
|
128
136
|
sin(): Float
|
|
129
137
|
target js sync """
|
|
130
|
-
return Math.sin(
|
|
138
|
+
return Math.sin(self_);
|
|
131
139
|
"""
|
|
132
140
|
|
|
133
141
|
sinh(): Float
|
|
134
142
|
target js sync """
|
|
135
|
-
return Math.sinh(
|
|
143
|
+
return Math.sinh(self_);
|
|
136
144
|
"""
|
|
137
145
|
|
|
138
146
|
sqrt(): Float
|
|
139
147
|
target js sync """
|
|
140
|
-
return Math.sqrt(
|
|
148
|
+
return Math.sqrt(self_);
|
|
141
149
|
"""
|
|
142
150
|
|
|
143
151
|
tan(): Float
|
|
144
152
|
target js sync """
|
|
145
|
-
return Math.tan(
|
|
153
|
+
return Math.tan(self_);
|
|
146
154
|
"""
|
|
147
155
|
|
|
148
156
|
tanh(): Float
|
|
149
157
|
target js sync """
|
|
150
|
-
return Math.tanh(
|
|
158
|
+
return Math.tanh(self_);
|
|
151
159
|
"""
|
|
152
160
|
|
|
153
161
|
}
|
|
154
162
|
|
|
155
163
|
hypot(values: List[Float]): Float
|
|
156
164
|
target js sync """
|
|
157
|
-
return Math.hypot(...
|
|
165
|
+
return Math.hypot(...values_);
|
|
158
166
|
"""
|
|
159
167
|
|
|
160
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
|
-
|
|
51
|
-
}
|
|
52
|
+
min(that: Int): Int
|
|
53
|
+
target js sync "return Math.min(self_, that_)"
|
|
52
54
|
|
|
53
|
-
max(that: Int): Int
|
|
54
|
-
|
|
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
|
-
|
|
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(...
|
|
100
|
+
return Math.hypot(...values_);
|
|
101
101
|
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -218,156 +218,159 @@ return self_.toFixed(digits_)
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
export function Float_min(self_, that_) {
|
|
221
|
-
return Math.min(
|
|
221
|
+
return Math.min(self_, that_)
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
export function Float_max(self_, that_) {
|
|
225
|
-
return Math.max(
|
|
225
|
+
return Math.max(self_, that_)
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
export function Float_clamp(self_, from_, to_) {
|
|
229
|
-
|
|
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_)))
|
|
236
239
|
}
|
|
237
240
|
|
|
238
|
-
export function Float_expDecay(self_, that_, decay_,
|
|
239
|
-
return (that_ + ((self_ - that_) * ff_core_Float.Float_exp(((-decay_) *
|
|
241
|
+
export function Float_expDecay(self_, that_, decay_, factor_) {
|
|
242
|
+
return (that_ + ((self_ - that_) * ff_core_Float.Float_exp(((-decay_) * factor_))))
|
|
240
243
|
}
|
|
241
244
|
|
|
242
245
|
export function Float_acos(self_) {
|
|
243
246
|
|
|
244
|
-
return Math.acos(
|
|
247
|
+
return Math.acos(self_);
|
|
245
248
|
|
|
246
249
|
}
|
|
247
250
|
|
|
248
251
|
export function Float_acosh(self_) {
|
|
249
252
|
|
|
250
|
-
return Math.acosh(
|
|
253
|
+
return Math.acosh(self_);
|
|
251
254
|
|
|
252
255
|
}
|
|
253
256
|
|
|
254
257
|
export function Float_asin(self_) {
|
|
255
258
|
|
|
256
|
-
return Math.asin(
|
|
259
|
+
return Math.asin(self_);
|
|
257
260
|
|
|
258
261
|
}
|
|
259
262
|
|
|
260
263
|
export function Float_asinh(self_) {
|
|
261
264
|
|
|
262
|
-
return Math.asinh(
|
|
265
|
+
return Math.asinh(self_);
|
|
263
266
|
|
|
264
267
|
}
|
|
265
268
|
|
|
266
269
|
export function Float_atan(self_) {
|
|
267
270
|
|
|
268
|
-
return Math.atan(
|
|
271
|
+
return Math.atan(self_);
|
|
269
272
|
|
|
270
273
|
}
|
|
271
274
|
|
|
272
275
|
export function Float_atan2(self_, that_) {
|
|
273
276
|
|
|
274
|
-
return Math.atan2(
|
|
277
|
+
return Math.atan2(self_, that_);
|
|
275
278
|
|
|
276
279
|
}
|
|
277
280
|
|
|
278
281
|
export function Float_atanh(self_) {
|
|
279
282
|
|
|
280
|
-
return Math.atanh(
|
|
283
|
+
return Math.atanh(self_);
|
|
281
284
|
|
|
282
285
|
}
|
|
283
286
|
|
|
284
287
|
export function Float_cbrt(self_) {
|
|
285
288
|
|
|
286
|
-
return Math.cbrt(
|
|
289
|
+
return Math.cbrt(self_);
|
|
287
290
|
|
|
288
291
|
}
|
|
289
292
|
|
|
290
293
|
export function Float_cos(self_) {
|
|
291
294
|
|
|
292
|
-
return Math.cos(
|
|
295
|
+
return Math.cos(self_);
|
|
293
296
|
|
|
294
297
|
}
|
|
295
298
|
|
|
296
299
|
export function Float_cosh(self_) {
|
|
297
300
|
|
|
298
|
-
return Math.cosh(
|
|
301
|
+
return Math.cosh(self_);
|
|
299
302
|
|
|
300
303
|
}
|
|
301
304
|
|
|
302
305
|
export function Float_exp(self_) {
|
|
303
306
|
|
|
304
|
-
return Math.exp(
|
|
307
|
+
return Math.exp(self_);
|
|
305
308
|
|
|
306
309
|
}
|
|
307
310
|
|
|
308
311
|
export function Float_expm1(self_) {
|
|
309
312
|
|
|
310
|
-
return Math.expm1(
|
|
313
|
+
return Math.expm1(self_);
|
|
311
314
|
|
|
312
315
|
}
|
|
313
316
|
|
|
314
317
|
export function Float_log(self_, that_) {
|
|
315
318
|
|
|
316
|
-
return Math.log2(
|
|
319
|
+
return Math.log2(self_) / Math.log2(that_);
|
|
317
320
|
|
|
318
321
|
}
|
|
319
322
|
|
|
320
323
|
export function Float_log10(self_) {
|
|
321
324
|
|
|
322
|
-
return Math.log10(
|
|
325
|
+
return Math.log10(self_);
|
|
323
326
|
|
|
324
327
|
}
|
|
325
328
|
|
|
326
329
|
export function Float_log2(self_) {
|
|
327
330
|
|
|
328
|
-
return Math.log2(
|
|
331
|
+
return Math.log2(self_);
|
|
329
332
|
|
|
330
333
|
}
|
|
331
334
|
|
|
332
335
|
export function Float_ln(self_) {
|
|
333
336
|
|
|
334
|
-
return Math.log(
|
|
337
|
+
return Math.log(self_);
|
|
335
338
|
|
|
336
339
|
}
|
|
337
340
|
|
|
338
341
|
export function Float_ln1p(self_) {
|
|
339
342
|
|
|
340
|
-
return Math.log1p(
|
|
343
|
+
return Math.log1p(self_);
|
|
341
344
|
|
|
342
345
|
}
|
|
343
346
|
|
|
344
347
|
export function Float_sin(self_) {
|
|
345
348
|
|
|
346
|
-
return Math.sin(
|
|
349
|
+
return Math.sin(self_);
|
|
347
350
|
|
|
348
351
|
}
|
|
349
352
|
|
|
350
353
|
export function Float_sinh(self_) {
|
|
351
354
|
|
|
352
|
-
return Math.sinh(
|
|
355
|
+
return Math.sinh(self_);
|
|
353
356
|
|
|
354
357
|
}
|
|
355
358
|
|
|
356
359
|
export function Float_sqrt(self_) {
|
|
357
360
|
|
|
358
|
-
return Math.sqrt(
|
|
361
|
+
return Math.sqrt(self_);
|
|
359
362
|
|
|
360
363
|
}
|
|
361
364
|
|
|
362
365
|
export function Float_tan(self_) {
|
|
363
366
|
|
|
364
|
-
return Math.tan(
|
|
367
|
+
return Math.tan(self_);
|
|
365
368
|
|
|
366
369
|
}
|
|
367
370
|
|
|
368
371
|
export function Float_tanh(self_) {
|
|
369
372
|
|
|
370
|
-
return Math.tanh(
|
|
373
|
+
return Math.tanh(self_);
|
|
371
374
|
|
|
372
375
|
}
|
|
373
376
|
|
|
@@ -412,17 +415,20 @@ throw new Error('Function Float_max is missing on this target in async context.'
|
|
|
412
415
|
}
|
|
413
416
|
|
|
414
417
|
export async function Float_clamp$(self_, from_, to_, $task) {
|
|
415
|
-
|
|
416
|
-
return from_
|
|
417
|
-
} else if((self_ >= to_)) {
|
|
418
|
-
return to_
|
|
419
|
-
} else {
|
|
420
|
-
return self_
|
|
418
|
+
throw new Error('Function Float_clamp is missing on this target in async context.');
|
|
421
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_)))
|
|
422
428
|
}
|
|
423
429
|
|
|
424
|
-
export async function Float_expDecay$(self_, that_, decay_,
|
|
425
|
-
return (that_ + ((self_ - that_) * ff_core_Float.Float_exp(((-decay_) *
|
|
430
|
+
export async function Float_expDecay$(self_, that_, decay_, factor_, $task) {
|
|
431
|
+
return (that_ + ((self_ - that_) * ff_core_Float.Float_exp(((-decay_) * factor_))))
|
|
426
432
|
}
|
|
427
433
|
|
|
428
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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