force-lang 0.0.13 → 0.1.0
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/.eslintrc.cjs +54 -0
- package/README.md +19 -14
- package/doc/force-lang.1 +33 -35
- package/doc/force.1 +33 -35
- package/examples/cli-args.j +2 -2
- package/examples/nodejs-js-interaction.j +2 -1
- package/examples/testjs.js +2 -2
- package/examples/web_scrap.j +3 -0
- package/force +88 -88
- package/force-lang-0.1.0.tgz +0 -0
- package/package.json +17 -15
- package/src/BKlib.j +51 -0
- package/src/env.js +221 -162
- package/src/error.js +71 -59
- package/src/eval.js +454 -319
- package/src/force-lang.js +38 -34
- package/src/lib.j +11 -0
- package/src/load-file.js +62 -62
- package/src/native_lib.js +1702 -1458
- package/src/obj_utils.js +20 -18
- package/src/read.js +431 -309
- package/src/stack.js +113 -72
- package/src/token-stream.js +34 -28
- package/tests/pippo.j +1 -1
- package/tests/test-js-require.js +13 -9
- package/tests/test.j +1 -1
- package/tests/unit_tests.j +1 -1
- package/.eslintrc.js +0 -60
package/src/native_lib.js
CHANGED
|
@@ -1,1458 +1,1702 @@
|
|
|
1
|
-
|
|
2
|
-
//const request = require('request-promise-native');
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
|
|
1
|
+
import log from 'bunny-logger';
|
|
2
|
+
// const request = require('request-promise-native');
|
|
3
|
+
import JSON5 from 'json5';
|
|
4
|
+
import { vsprintf } from 'sprintf-js';
|
|
5
|
+
import * as cheerio from 'cheerio';
|
|
6
|
+
import { execSync } from 'child_process';
|
|
7
|
+
import got from 'got';
|
|
8
|
+
import env from './env.js';
|
|
9
|
+
import err from './error.js';
|
|
10
|
+
import evalx from './eval.js';
|
|
11
|
+
import loadfile from './load-file.js';
|
|
12
|
+
import obj_utils from './obj_utils.js';
|
|
13
|
+
|
|
14
|
+
class NativeLib {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.populate();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
make_func_obj(func_name) {
|
|
20
|
+
return {
|
|
21
|
+
_type: 'TC_COMP_FUNC',
|
|
22
|
+
_datum: func_name,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
test_func() {
|
|
27
|
+
log.info('...hai detto pippo?');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
bye_func() {
|
|
31
|
+
process.exit(0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
noop_func() {
|
|
35
|
+
// do nothing (no operation)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
print_stack_func() {
|
|
39
|
+
env.print_stack();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
print_env_func() {
|
|
43
|
+
env.print_debug();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
print_words_func() {
|
|
47
|
+
const x = env._dict;
|
|
48
|
+
// x=x.filter(item => item._type == 'TC_NATIVE_FUNC');
|
|
49
|
+
for (const item of x) {
|
|
50
|
+
if (item._datum._type == 'TC_NATIVE_FUNC' || item._datum._type == 'TC_COMP_FUNC') {
|
|
51
|
+
// log.info(`${item._name} `);
|
|
52
|
+
process.stdout.write(`${item._name} `);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
log.info('');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
emit_func() {
|
|
59
|
+
const x = env.s.pop();
|
|
60
|
+
// log.info(x);
|
|
61
|
+
if (x._type === 'TC_NUM') {
|
|
62
|
+
process.stdout.write(String.fromCharCode(x._datum));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
env.s.push(err.throw(`unknown item type ${x._type} of ${x._datum}`));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
see_func(func_name) {
|
|
69
|
+
const x = env.lookup(func_name);
|
|
70
|
+
if (!x) {
|
|
71
|
+
log.info('no word found...');
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
switch (x._datum._type) {
|
|
75
|
+
case 'TC_NATIVE_FUNC':
|
|
76
|
+
log.info(`: ${x._name}`);
|
|
77
|
+
log.info('<native func> ;');
|
|
78
|
+
break;
|
|
79
|
+
case 'TC_COMP_FUNC':
|
|
80
|
+
log.info(`: ${x._name}`);
|
|
81
|
+
process.stdout.write(` `);
|
|
82
|
+
for (const n of x._datum._datum) {
|
|
83
|
+
process.stdout.write(`${n._datum} `);
|
|
84
|
+
}
|
|
85
|
+
log.info('');
|
|
86
|
+
break;
|
|
87
|
+
default:
|
|
88
|
+
log.info('not a word...');
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
print_tos_func() {
|
|
94
|
+
const x = env.s.pop();
|
|
95
|
+
if (!x) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// log.info(x);
|
|
99
|
+
switch (x._type) {
|
|
100
|
+
case 'TC_NUM':
|
|
101
|
+
case 'TC_STR':
|
|
102
|
+
case 'TC_BOOL':
|
|
103
|
+
log.info(x._datum);
|
|
104
|
+
break;
|
|
105
|
+
case 'TC_JSON':
|
|
106
|
+
log.info(obj_utils.stringify(x._datum));
|
|
107
|
+
break;
|
|
108
|
+
case 'TC_FUNC_JS':
|
|
109
|
+
log.info('#-<js func>');
|
|
110
|
+
break;
|
|
111
|
+
case 'TC_LAMBDA_FUNC':
|
|
112
|
+
log.info('#-<lambda func>');
|
|
113
|
+
break;
|
|
114
|
+
case 'TC_VAR':
|
|
115
|
+
log.info(x._name);
|
|
116
|
+
break;
|
|
117
|
+
case 'TC_ERR':
|
|
118
|
+
log.info(`ERR: ${x._datum.msg}`);
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
log.info(`unknown: { ${x._type} ${x._datum} }`);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
print_debug_tos_func() {
|
|
127
|
+
const x = env.s.pop();
|
|
128
|
+
if (!x) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// log.info(x);
|
|
132
|
+
switch (x._type) {
|
|
133
|
+
case 'TC_NUM':
|
|
134
|
+
case 'TC_STR':
|
|
135
|
+
case 'TC_BOOL':
|
|
136
|
+
log.info(`{ ${x._type} ${x._datum} }`);
|
|
137
|
+
break;
|
|
138
|
+
case 'TC_JSON':
|
|
139
|
+
log.info(`{ ${x._type} ${obj_utils.stringify(x._datum)} }`);
|
|
140
|
+
break;
|
|
141
|
+
case 'TC_FUNC_JS':
|
|
142
|
+
log.info('#-<js func>');
|
|
143
|
+
break;
|
|
144
|
+
case 'TC_LAMBDA_FUNC':
|
|
145
|
+
log.info('#-<lambda func>');
|
|
146
|
+
break;
|
|
147
|
+
case 'TC_VAR':
|
|
148
|
+
log.info(`{ ${x._type} ${x._name} ${obj_utils.stringify(x._datum._datum)} }`);
|
|
149
|
+
break;
|
|
150
|
+
case 'TC_ERR':
|
|
151
|
+
log.info(`ERR: ${x._datum.msg}`);
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
log.info(`unknown: { ${x._type} ${x._datum} }`);
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
assign_var_func() {
|
|
160
|
+
const varx = env.s.pop();
|
|
161
|
+
const val = env.s.pop();
|
|
162
|
+
if (!varx || !val) {
|
|
163
|
+
env.s.push(err.throw('no items on top 2 elements of the stack... aborting'));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
// log.info(varx);
|
|
167
|
+
// log.info(val);
|
|
168
|
+
switch (val._type) {
|
|
169
|
+
case 'TC_NUM':
|
|
170
|
+
case 'TC_STR':
|
|
171
|
+
case 'TC_JSON':
|
|
172
|
+
case 'TC_BOOL':
|
|
173
|
+
case 'TC_PROMISE':
|
|
174
|
+
varx._datum = val;
|
|
175
|
+
// env.set(varx._name, val, varx._type, varx._where);
|
|
176
|
+
break;
|
|
177
|
+
default:
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
read_var_func() {
|
|
183
|
+
const varx = env.s.pop();
|
|
184
|
+
if (!varx) {
|
|
185
|
+
env.s.push(err.throw('no element on top of the stack... aborting'));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
// log.info(varx);
|
|
189
|
+
switch (varx._datum._type) {
|
|
190
|
+
case 'TC_NUM':
|
|
191
|
+
case 'TC_STR':
|
|
192
|
+
case 'TC_JSON':
|
|
193
|
+
case 'TC_BOOL':
|
|
194
|
+
case 'TC_PROMISE':
|
|
195
|
+
env.s.push(varx._datum);
|
|
196
|
+
break;
|
|
197
|
+
default:
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
not_func() {
|
|
203
|
+
if (!env.is_bool(env.TOS())) {
|
|
204
|
+
env.s.push(err.throw('TOS is not a bool. aborting operation...'));
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const x = env.get_bool_val(env.s.pop());
|
|
208
|
+
env.s.push(env.set_bool_val(!x));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
and_func() {
|
|
212
|
+
if (!env.is_bool(env.TOS())) {
|
|
213
|
+
env.s.push(err.throw('TOS is not a bool. aborting operation...'));
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (!env.is_bool(env.TOS2())) {
|
|
217
|
+
env.s.push(err.throw('TOS" is not a bool. aborting operation...'));
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const a = env.get_bool_val(env.s.pop());
|
|
221
|
+
const b = env.get_bool_val(env.s.pop());
|
|
222
|
+
env.s.push(env.set_bool_val(a && b));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
or_func() {
|
|
226
|
+
if (!env.is_bool(env.TOS())) {
|
|
227
|
+
env.s.push(err.throw('TOS is not a bool. aborting operation...'));
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (!env.is_bool(env.TOS2())) {
|
|
231
|
+
env.s.push(err.throw('TOS2 is not a bool. aborting operation...'));
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const a = env.get_bool_val(env.s.pop());
|
|
235
|
+
const b = env.get_bool_val(env.s.pop());
|
|
236
|
+
env.s.push(env.set_bool_val(a || b));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
is_num_func() {
|
|
240
|
+
if (env.is_num(env.s.pop())) {
|
|
241
|
+
env.s.push(env.true_obj());
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
env.s.push(env.false_obj());
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
is_string_func() {
|
|
248
|
+
if (env.is_string(env.s.pop())) {
|
|
249
|
+
env.s.push(env.true_obj());
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
env.s.push(env.false_obj());
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
is_list_func() {
|
|
256
|
+
if (env.is_list(env.s.pop())) {
|
|
257
|
+
env.s.push(env.true_obj());
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
env.s.push(env.false_obj());
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
is_falsy_func() {
|
|
264
|
+
const x = env.s.pop();
|
|
265
|
+
if (x) {
|
|
266
|
+
switch (x._type) {
|
|
267
|
+
case 'TC_NUM':
|
|
268
|
+
if (x._datum == 0) {
|
|
269
|
+
return env.s.push(env.true_obj());
|
|
270
|
+
}
|
|
271
|
+
return env.s.push(env.false_obj());
|
|
272
|
+
break;
|
|
273
|
+
case 'TC_STR':
|
|
274
|
+
if (x._datum == '') {
|
|
275
|
+
return env.s.push(env.true_obj());
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
case 'TC_BOOL':
|
|
279
|
+
if (env.is_false(x)) {
|
|
280
|
+
return env.s.push(env.true_obj());
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
case 'TC_JLIST':
|
|
284
|
+
case 'TC_JOBJ':
|
|
285
|
+
default:
|
|
286
|
+
return env.s.push(env.false_obj());
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return env.s.push(env.true_obj());
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
dup_func() {
|
|
294
|
+
env.s.push(env.TOS());
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
swap_func() {
|
|
298
|
+
if (env.TOS() && env.TOS2()) {
|
|
299
|
+
const x = env.s.pop();
|
|
300
|
+
const y = env.s.pop();
|
|
301
|
+
env.s.push(x);
|
|
302
|
+
env.s.push(y);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
env.s.push(err.throw('not 2 elemets in the stack... aborting...'));
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
drop_func() {
|
|
309
|
+
env.s.pop();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
ndrop_func() {
|
|
313
|
+
if (env.TOS() && env.TOS()._type === 'TC_NUM') {
|
|
314
|
+
try {
|
|
315
|
+
let n = env.s.pop()._datum;
|
|
316
|
+
while (n > 0) {
|
|
317
|
+
env.s.pop();
|
|
318
|
+
n--;
|
|
319
|
+
}
|
|
320
|
+
return;
|
|
321
|
+
} catch (e) {
|
|
322
|
+
env.s.push(err.throw(e));
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
env.s.push(err.throw('invalid arguments type. TOS is not a number.'));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
nbye_func() {
|
|
330
|
+
if (env.TOS() && env.TOS()._type == 'TC_NUM') {
|
|
331
|
+
process.exit(env.s.pop()._datum);
|
|
332
|
+
}
|
|
333
|
+
env.s.push(err.throw('TOS not a number... aborting'));
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
over_func() {
|
|
337
|
+
env.s.push(env.s.look_at(1));
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
num_plus_func() {
|
|
341
|
+
if (env.TOS() && env.TOS()._type == 'TC_NUM' && env.TOS2() && env.TOS2()._type == 'TC_NUM') {
|
|
342
|
+
env.s.push({
|
|
343
|
+
_type: 'TC_NUM',
|
|
344
|
+
_datum: env.s.pop()._datum + env.s.pop()._datum,
|
|
345
|
+
});
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
env.s.push(err.throw('no numbers on top 2 elements of the stack... aborting'));
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
num_minus_func() {
|
|
352
|
+
if (env.TOS() && env.TOS()._type == 'TC_NUM' && env.TOS2() && env.TOS2()._type == 'TC_NUM') {
|
|
353
|
+
const x = env.s.pop()._datum;
|
|
354
|
+
const y = env.s.pop()._datum;
|
|
355
|
+
env.s.push({ _type: 'TC_NUM', _datum: y - x });
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
env.s.push(err.throw('no numbers on top 2 elements of the stack... aborting'));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
num_times_func() {
|
|
362
|
+
if (env.TOS() && env.TOS()._type == 'TC_NUM' && env.TOS2() && env.TOS2()._type == 'TC_NUM') {
|
|
363
|
+
env.s.push({
|
|
364
|
+
_type: 'TC_NUM',
|
|
365
|
+
_datum: env.s.pop()._datum * env.s.pop()._datum,
|
|
366
|
+
});
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
env.s.push(err.throw('no numbers on top 2 elements of the stack... aborting'));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
num_div_func() {
|
|
373
|
+
if (env.TOS() && env.TOS()._type == 'TC_NUM' && env.TOS2() && env.TOS2()._type == 'TC_NUM') {
|
|
374
|
+
const x = env.s.pop()._datum;
|
|
375
|
+
const y = env.s.pop()._datum;
|
|
376
|
+
env.s.push({ _type: 'TC_NUM', _datum: y / x });
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
env.s.push(err.throw('no numbers on top 2 elements of the stack... aborting'));
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
async plus_func() {
|
|
383
|
+
await evalx.eval('f+');
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
async minus_func() {
|
|
387
|
+
await evalx.eval('n:-');
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
async times_func() {
|
|
391
|
+
await evalx.eval('n:*');
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
async division_func() {
|
|
395
|
+
await evalx.eval('n:/');
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
async module_func() {
|
|
399
|
+
await evalx.eval('n:%');
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
string_plus_func() {
|
|
403
|
+
if (env.is_string(env.TOS()) || env.is_string(env.TOS2())) {
|
|
404
|
+
if (env.is_num(env.TOS()) || env.is_num(env.TOS2()) || env.is_string(env.TOS()) || env.is_string(env.TOS2())) {
|
|
405
|
+
const x = env.s.pop();
|
|
406
|
+
const y = env.s.pop();
|
|
407
|
+
env.s.push({ _type: 'TC_STR', _datum: y._datum + x._datum });
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
env.s.push(err.throw('invalid arguments type'));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
array_plus_func() {
|
|
415
|
+
if (env.is_list(env.TOS()) || env.is_list(env.TOS2())) {
|
|
416
|
+
const x = env.s.pop();
|
|
417
|
+
const y = env.s.pop();
|
|
418
|
+
env.s.push({ _type: 'TC_JSON', _datum: y._datum.concat(x._datum) });
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
env.s.push(err.throw('invalid arguments type'));
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
array_at_func() {
|
|
425
|
+
if (env.is_num(env.TOS()) && env.is_list(env.TOS2())) {
|
|
426
|
+
try {
|
|
427
|
+
let index = env.s.pop()._datum;
|
|
428
|
+
const arr = env.s.pop()._datum;
|
|
429
|
+
if (index < 0) {
|
|
430
|
+
index = arr.length + index;
|
|
431
|
+
}
|
|
432
|
+
if (index >= arr.length || index < 0) {
|
|
433
|
+
env.s.push(err.throw('invalid index bound'));
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
const value = arr[index];
|
|
437
|
+
const xval = env.adj_bool_val(value);
|
|
438
|
+
env.s.push({ _type: env.guess_type(value), _datum: xval });
|
|
439
|
+
return;
|
|
440
|
+
} catch (e) {
|
|
441
|
+
env.s.push(err.throw(e));
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
env.s.push(err.throw('invalid arguments type'));
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
array_set_at_func() {
|
|
449
|
+
if (env.TOS() && env.is_num(env.TOS2()) && env.is_list(env.s.look_at(2))) {
|
|
450
|
+
try {
|
|
451
|
+
const value = env.s.pop()._datum;
|
|
452
|
+
let index = env.s.pop()._datum;
|
|
453
|
+
const arr = env.s.pop()._datum;
|
|
454
|
+
if (index < 0) {
|
|
455
|
+
index = arr.length + index;
|
|
456
|
+
}
|
|
457
|
+
if (index >= arr.length || index < 0) {
|
|
458
|
+
env.s.push(err.throw('invalid index bound'));
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
arr[index] = value;
|
|
462
|
+
env.s.push({ _type: 'TC_JSON', _datum: arr });
|
|
463
|
+
return;
|
|
464
|
+
} catch (e) {
|
|
465
|
+
env.s.push(err.throw(e));
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
env.s.push(err.throw('invalid arguments type'));
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
object_at_func() {
|
|
473
|
+
if (env.is_string(env.TOS()) && env.is_obj(env.TOS2())) {
|
|
474
|
+
try {
|
|
475
|
+
const key = env.s.pop()._datum;
|
|
476
|
+
const obj = env.s.pop()._datum;
|
|
477
|
+
const value = obj[key];
|
|
478
|
+
if (value) {
|
|
479
|
+
const xval = env.adj_bool_val(value);
|
|
480
|
+
env.s.push({ _type: env.guess_type(value), _datum: xval });
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
// env.s.push(err.throw("invalid object key"));
|
|
484
|
+
env.s.push({ _type: 'TC_UNDEF', _datum: 'undefined' });
|
|
485
|
+
return;
|
|
486
|
+
} catch (e) {
|
|
487
|
+
env.s.push(err.throw(e));
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
env.s.push(err.throw('invalid arguments type'));
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
object_set_at_func() {
|
|
495
|
+
if (env.TOS() && env.is_string(env.TOS2()) && env.is_obj(env.s.look_at(2))) {
|
|
496
|
+
try {
|
|
497
|
+
const value = env.s.pop()._datum;
|
|
498
|
+
const key = env.s.pop()._datum;
|
|
499
|
+
const obj = env.s.pop()._datum;
|
|
500
|
+
obj[key] = value;
|
|
501
|
+
env.s.push({ _type: 'TC_JSON', _datum: obj });
|
|
502
|
+
return;
|
|
503
|
+
} catch (e) {
|
|
504
|
+
env.s.push(err.throw(e));
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
env.s.push(err.throw('invalid arguments type'));
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
array_length_func() {
|
|
512
|
+
if (env.is_list(env.TOS())) {
|
|
513
|
+
try {
|
|
514
|
+
const x = env.s.pop()._datum.length;
|
|
515
|
+
env.s.push({ _type: 'TC_NUM', _datum: x });
|
|
516
|
+
return;
|
|
517
|
+
} catch (e) {
|
|
518
|
+
env.s.push(err.throw(e));
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
env.s.push(err.throw('invalid arguments type. TOS not a list'));
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
array_push_func() {
|
|
526
|
+
if (env.is_list(env.TOS2()) && env.TOS()) {
|
|
527
|
+
try {
|
|
528
|
+
const value = env.s.pop()._datum;
|
|
529
|
+
const arr = env.s.pop()._datum;
|
|
530
|
+
arr.push(value);
|
|
531
|
+
env.s.push({ _type: 'TC_JSON', _datum: arr });
|
|
532
|
+
return;
|
|
533
|
+
} catch (e) {
|
|
534
|
+
env.s.push(err.throw(e));
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
array_pop_func() {
|
|
542
|
+
if (env.is_list(env.TOS())) {
|
|
543
|
+
try {
|
|
544
|
+
const value = env.s.pop()._datum.pop();
|
|
545
|
+
const xval = env.adj_bool_val(value);
|
|
546
|
+
env.s.push({ _type: env.guess_type(value), _datum: xval });
|
|
547
|
+
return;
|
|
548
|
+
} catch (e) {
|
|
549
|
+
env.s.push(err.throw(e));
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
env.s.push(err.throw('invalid arguments type. TOS not a list'));
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
object_keys_func() {
|
|
557
|
+
if (env.is_obj(env.TOS())) {
|
|
558
|
+
try {
|
|
559
|
+
const x = env.s.pop()._datum;
|
|
560
|
+
env.s.push({ _type: 'TC_JSON', _datum: Object.keys(x) });
|
|
561
|
+
return;
|
|
562
|
+
} catch (e) {
|
|
563
|
+
env.s.push(err.throw(e));
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
object_values_func() {
|
|
571
|
+
if (env.is_obj(env.TOS())) {
|
|
572
|
+
try {
|
|
573
|
+
const x = env.s.pop()._datum;
|
|
574
|
+
env.s.push({ _type: 'TC_JSON', _datum: Object.values(x) });
|
|
575
|
+
return;
|
|
576
|
+
} catch (e) {
|
|
577
|
+
env.s.push(err.throw(e));
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
string_split_func() {
|
|
585
|
+
if (env.TOS() && env.is_string(env.TOS2())) {
|
|
586
|
+
try {
|
|
587
|
+
const x = env.s.pop();
|
|
588
|
+
const y = env.s.pop()._datum;
|
|
589
|
+
let z;
|
|
590
|
+
if (env.is_string(x)) {
|
|
591
|
+
z = y.split(x._datum);
|
|
592
|
+
}
|
|
593
|
+
if (env.is_obj(x)) {
|
|
594
|
+
z = y.split(x._datum.separator, x._datum.limit);
|
|
595
|
+
}
|
|
596
|
+
if (z) {
|
|
597
|
+
env.s.push({ _type: 'TC_JSON', _datum: z });
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
} catch (e) {
|
|
601
|
+
env.s.push(err.throw(e));
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
string_join_func() {
|
|
609
|
+
if (env.is_string(env.TOS()) && env.is_list(env.TOS2())) {
|
|
610
|
+
try {
|
|
611
|
+
const separator = env.s.pop()._datum;
|
|
612
|
+
const list = env.s.pop()._datum;
|
|
613
|
+
env.s.push({ _type: 'TC_STR', _datum: list.join(separator) });
|
|
614
|
+
return;
|
|
615
|
+
} catch (e) {
|
|
616
|
+
env.s.push(err.throw(e));
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
json_stringify_func() {
|
|
624
|
+
if (env.is_json(env.TOS())) {
|
|
625
|
+
try {
|
|
626
|
+
env.s.push({
|
|
627
|
+
_type: 'TC_STR',
|
|
628
|
+
_datum: JSON5.stringify(env.s.pop()._datum),
|
|
629
|
+
});
|
|
630
|
+
} catch (e) {
|
|
631
|
+
env.s.push(err.throw(e));
|
|
632
|
+
}
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
json_parse_func() {
|
|
639
|
+
if (env.is_string(env.TOS())) {
|
|
640
|
+
try {
|
|
641
|
+
env.s.push({
|
|
642
|
+
_type: 'TC_JSON',
|
|
643
|
+
_datum: JSON5.parse(env.s.pop()._datum),
|
|
644
|
+
});
|
|
645
|
+
} catch (e) {
|
|
646
|
+
env.s.push(err.throw(e));
|
|
647
|
+
}
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
string_at_func() {
|
|
654
|
+
if (env.is_num(env.TOS()) && env.is_string(env.TOS2())) {
|
|
655
|
+
try {
|
|
656
|
+
let index = env.s.pop()._datum;
|
|
657
|
+
const str = env.s.pop()._datum;
|
|
658
|
+
if (index < 0) {
|
|
659
|
+
index = str.length + index;
|
|
660
|
+
}
|
|
661
|
+
env.s.push({ _type: 'TC_STR', _datum: str[index] });
|
|
662
|
+
} catch (e) {
|
|
663
|
+
env.s.push(err.throw(e));
|
|
664
|
+
}
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
string_set_at_func() {
|
|
671
|
+
if (env.is_string(env.TOS()) && env.is_num(env.TOS2()) && env.is_string(env.s.look_at(2))) {
|
|
672
|
+
try {
|
|
673
|
+
const replacement = env.s.pop()._datum;
|
|
674
|
+
let index = env.s.pop()._datum;
|
|
675
|
+
const str = env.s.pop()._datum;
|
|
676
|
+
if (index < 0) {
|
|
677
|
+
index = str.length + index;
|
|
678
|
+
}
|
|
679
|
+
const result = str.substr(0, index) + replacement + str.substr(index + replacement.length);
|
|
680
|
+
env.s.push({ _type: 'TC_STR', _datum: result });
|
|
681
|
+
} catch (e) {
|
|
682
|
+
env.s.push(err.throw(e));
|
|
683
|
+
}
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
equal_func() {
|
|
690
|
+
if (env.TOS() && env.TOS2()) {
|
|
691
|
+
try {
|
|
692
|
+
const x = env.s.pop()._datum;
|
|
693
|
+
const y = env.s.pop()._datum;
|
|
694
|
+
env.s.push({ _type: 'TC_BOOL', _datum: y === x ? 'T' : 'F' });
|
|
695
|
+
} catch (e) {
|
|
696
|
+
env.s.push(err.throw(e));
|
|
697
|
+
}
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
eq_func() {
|
|
704
|
+
if (env.TOS() && env.TOS2()) {
|
|
705
|
+
try {
|
|
706
|
+
const x = env.s.pop()._datum;
|
|
707
|
+
const y = env.s.pop()._datum;
|
|
708
|
+
env.s.push({ _type: 'TC_BOOL', _datum: y == x ? 'T' : 'F' });
|
|
709
|
+
} catch (e) {
|
|
710
|
+
env.s.push(err.throw(e));
|
|
711
|
+
}
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
num_minor_func() {
|
|
718
|
+
if (env.is_num(env.TOS()) && env.is_num(env.TOS2())) {
|
|
719
|
+
try {
|
|
720
|
+
const x = env.s.pop()._datum;
|
|
721
|
+
const y = env.s.pop()._datum;
|
|
722
|
+
env.s.push({ _type: 'TC_BOOL', _datum: y < x ? 'T' : 'F' });
|
|
723
|
+
} catch (e) {
|
|
724
|
+
env.s.push(err.throw(e));
|
|
725
|
+
}
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
num_major_func() {
|
|
732
|
+
if (env.is_num(env.TOS()) && env.is_num(env.TOS2())) {
|
|
733
|
+
try {
|
|
734
|
+
const x = env.s.pop()._datum;
|
|
735
|
+
const y = env.s.pop()._datum;
|
|
736
|
+
env.s.push({ _type: 'TC_BOOL', _datum: y > x ? 'T' : 'F' });
|
|
737
|
+
} catch (e) {
|
|
738
|
+
env.s.push(err.throw(e));
|
|
739
|
+
}
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
num_min_eq_func() {
|
|
746
|
+
if (env.is_num(env.TOS()) && env.is_num(env.TOS2())) {
|
|
747
|
+
try {
|
|
748
|
+
const x = env.s.pop()._datum;
|
|
749
|
+
const y = env.s.pop()._datum;
|
|
750
|
+
env.s.push({ _type: 'TC_BOOL', _datum: y <= x ? 'T' : 'F' });
|
|
751
|
+
} catch (e) {
|
|
752
|
+
env.s.push(err.throw(e));
|
|
753
|
+
}
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
num_maj_eq_func() {
|
|
760
|
+
if (env.is_num(env.TOS()) && env.is_num(env.TOS2())) {
|
|
761
|
+
try {
|
|
762
|
+
const x = env.s.pop()._datum;
|
|
763
|
+
const y = env.s.pop()._datum;
|
|
764
|
+
env.s.push({ _type: 'TC_BOOL', _datum: y >= x ? 'T' : 'F' });
|
|
765
|
+
} catch (e) {
|
|
766
|
+
env.s.push(err.throw(e));
|
|
767
|
+
}
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
delete_dict_func() {
|
|
774
|
+
if (env.TOS() && env.TOS()._type == 'TC_STR') {
|
|
775
|
+
try {
|
|
776
|
+
env.delete(env.s.pop()._datum);
|
|
777
|
+
} catch (e) {
|
|
778
|
+
env.s.push(err.throw(e));
|
|
779
|
+
}
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
async net_request_func() {
|
|
786
|
+
// async....
|
|
787
|
+
if (env.is_obj(env.TOS())) {
|
|
788
|
+
try {
|
|
789
|
+
// //let resp= await request(env.s.pop()._datum);
|
|
790
|
+
const x = env.s.pop()._datum;
|
|
791
|
+
const { url } = x;
|
|
792
|
+
delete x.url;
|
|
793
|
+
// let resp= request(x.method,x.url,x);
|
|
794
|
+
const resp = await got(url, x).text();
|
|
795
|
+
// //env.s.push({"_type":"TC_STR","_datum":resp});
|
|
796
|
+
// env.s.push({"_type":"TC_STR","_datum":resp.body.toString('utf8')});
|
|
797
|
+
env.s.push({ _type: env.guess_type(resp), _datum: resp });
|
|
798
|
+
} catch (e) {
|
|
799
|
+
const errObj = {
|
|
800
|
+
code: e.response?.statusCode,
|
|
801
|
+
body: e.response?.body,
|
|
802
|
+
error: { name: e.name, code: e.code, msg: e.message },
|
|
803
|
+
};
|
|
804
|
+
// env.s.push({"_type":env.guess_type(errObj),"_datum":errObj});
|
|
805
|
+
env.s.push(err.throw(JSON.stringify(errObj)));
|
|
806
|
+
}
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
env.s.push(err.throw('invalid arguments type.'));
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
async included_func() {
|
|
813
|
+
if (env.is_string(env.TOS())) {
|
|
814
|
+
try {
|
|
815
|
+
const arg = env.s.pop()._datum;
|
|
816
|
+
const filename = loadfile.resolve_path(arg);
|
|
817
|
+
const x = loadfile.loadsync(filename);
|
|
818
|
+
await evalx.eval(x);
|
|
819
|
+
return;
|
|
820
|
+
} catch (e) {
|
|
821
|
+
env.s.push(err.throw(e));
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
env.s.push(err.throw('invalid arguments type'));
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
file_slurp_func() {
|
|
829
|
+
if (env.is_string(env.TOS())) {
|
|
830
|
+
try {
|
|
831
|
+
const arg = env.s.pop()._datum;
|
|
832
|
+
const filename = loadfile.resolve_path(arg);
|
|
833
|
+
const x = loadfile.loadsync(filename);
|
|
834
|
+
env.s.push({ _type: 'TC_STR', _datum: x });
|
|
835
|
+
return;
|
|
836
|
+
} catch (e) {
|
|
837
|
+
env.s.push(err.throw(e));
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
env.s.push(err.throw('invalid arguments type'));
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
file_write_func() {
|
|
845
|
+
if (env.TOS() && env.TOS2() && env.is_string(env.TOS()) && env.is_string(env.TOS2())) {
|
|
846
|
+
try {
|
|
847
|
+
const arg = env.s.pop()._datum;
|
|
848
|
+
const filename = loadfile.resolve_path(arg);
|
|
849
|
+
const data = env.s.pop()._datum;
|
|
850
|
+
loadfile.writesync(filename, data);
|
|
851
|
+
return;
|
|
852
|
+
} catch (e) {
|
|
853
|
+
env.s.push(err.throw(e));
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
env.s.push(err.throw('invalid arguments type. 2 Strings are expected.'));
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
file_append_func() {
|
|
861
|
+
if (env.TOS() && env.TOS2() && env.is_string(env.TOS()) && env.is_string(env.TOS2())) {
|
|
862
|
+
try {
|
|
863
|
+
const arg = env.s.pop()._datum;
|
|
864
|
+
const filename = loadfile.resolve_path(arg);
|
|
865
|
+
const data = env.s.pop()._datum;
|
|
866
|
+
loadfile.appendsync(filename, data);
|
|
867
|
+
return;
|
|
868
|
+
} catch (e) {
|
|
869
|
+
env.s.push(err.throw(e));
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
env.s.push(err.throw('invalid arguments type. 2 Strings are expected.'));
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
file_exists_func() {
|
|
877
|
+
if (env.TOS() && env.is_string(env.TOS())) {
|
|
878
|
+
try {
|
|
879
|
+
const arg = env.s.pop()._datum;
|
|
880
|
+
const filename = loadfile.resolve_path(arg);
|
|
881
|
+
const exists = loadfile.existssync(filename);
|
|
882
|
+
env.s.push(env.set_bool_val(exists));
|
|
883
|
+
return;
|
|
884
|
+
} catch (e) {
|
|
885
|
+
env.s.push(err.throw(e));
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
env.s.push(err.throw('invalid arguments type. a String is expected.'));
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
throw_func() {
|
|
893
|
+
if (env.TOS() && env.TOS()._type == 'TC_STR') {
|
|
894
|
+
env.s.push(err.throw(env.s.pop()._datum));
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
if (env.TOS() && env.TOS()._type == 'TC_JSON') {
|
|
898
|
+
const err_arg = env.s.pop();
|
|
899
|
+
env.s.push(err.throw(err_arg._datum.msg, err_arg._datum.code));
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
env.s.push(err.throw('invalid throw argument in TOS'));
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
require_js_func() {
|
|
906
|
+
if (env.TOS() && env.TOS()._type == 'TC_STR') {
|
|
907
|
+
try {
|
|
908
|
+
const arg = env.s.pop()._datum;
|
|
909
|
+
const filename = loadfile.resolve_path(arg);
|
|
910
|
+
const js = import(filename);
|
|
911
|
+
env.s.push({ _type: env.guess_type(js), _datum: js });
|
|
912
|
+
return;
|
|
913
|
+
} catch (e) {
|
|
914
|
+
env.s.push(err.throw(e));
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
env.s.push(err.throw('invalid request-js argument type'));
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
async funcjs_exec_func() {
|
|
922
|
+
try {
|
|
923
|
+
if (env.TOS() && env.TOS()._type == 'TC_LAMBDA_FUNC') {
|
|
924
|
+
await evalx.eval_parsed(env.s.pop()._datum);
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
if (env.TOS() && env.TOS()._type == 'TC_FUNC_JS') {
|
|
928
|
+
var x = env.s.pop()._datum;
|
|
929
|
+
var arity = x.length;
|
|
930
|
+
var args = [];
|
|
931
|
+
// log.info(arity);
|
|
932
|
+
while (arity > 0) {
|
|
933
|
+
args.unshift(env.s.pop()._datum);
|
|
934
|
+
arity--;
|
|
935
|
+
}
|
|
936
|
+
// log.info(args);
|
|
937
|
+
var y = x.apply(null, args);
|
|
938
|
+
// log.info(y);
|
|
939
|
+
if (y) {
|
|
940
|
+
env.s.push({ _type: env.guess_type(y), _datum: y });
|
|
941
|
+
}
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
if (env.TOS() && env.TOS()._type == 'TC_STR' && env.TOS2() && env.TOS2()._type == 'TC_JSON') {
|
|
945
|
+
const method = env.s.pop()._datum;
|
|
946
|
+
const method_list = method.split('.');
|
|
947
|
+
var x = env.s.pop()._datum;
|
|
948
|
+
let funcall = x;
|
|
949
|
+
for (const item of method_list) {
|
|
950
|
+
funcall = funcall[item];
|
|
951
|
+
}
|
|
952
|
+
// log.info(funcall);
|
|
953
|
+
var arity = funcall.length;
|
|
954
|
+
var args = [];
|
|
955
|
+
// log.info(arity);
|
|
956
|
+
while (arity > 0) {
|
|
957
|
+
args.unshift(env.s.pop()._datum);
|
|
958
|
+
arity--;
|
|
959
|
+
}
|
|
960
|
+
// log.info(args);
|
|
961
|
+
var y = funcall.apply(x, args);
|
|
962
|
+
// log.info(y);
|
|
963
|
+
if (y) {
|
|
964
|
+
env.s.push({ _type: env.guess_type(y), _datum: y });
|
|
965
|
+
}
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
env.s.push(err.throw('invalid funcall-js argument type'));
|
|
969
|
+
} catch (e) {
|
|
970
|
+
env.s.push(err.throw(e));
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
handle_repl_func() {
|
|
975
|
+
err.handle_repl();
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
handle_standard_func() {
|
|
979
|
+
err.handle_standard();
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
regex_test_func() {
|
|
983
|
+
try {
|
|
984
|
+
if (env.is_obj(env.TOS()) && env.is_string(env.TOS2())) {
|
|
985
|
+
const rex_obj = env.s.pop();
|
|
986
|
+
let _datum;
|
|
987
|
+
var str = env.s.pop()._datum;
|
|
988
|
+
var my_rex = new RegExp(rex_obj.rex, rex_obj.flags);
|
|
989
|
+
const result = my_rex.test(str);
|
|
990
|
+
env.s.push(result ? env.true_obj() : env.false_obj());
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
if (env.is_string(env.TOS()) && env.is_string(env.TOS2())) {
|
|
994
|
+
const rex = env.s.pop()._datum;
|
|
995
|
+
var str = env.s.pop()._datum;
|
|
996
|
+
var my_rex = new RegExp(rex);
|
|
997
|
+
const result = my_rex.test(str);
|
|
998
|
+
env.s.push(result ? env.true_obj() : env.false_obj());
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
env.s.push(err.throw('invalid regex test argument type'));
|
|
1002
|
+
} catch (e) {
|
|
1003
|
+
env.s.push(err.throw(e));
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
regex_exec_func() {
|
|
1008
|
+
try {
|
|
1009
|
+
if (env.is_obj(env.TOS()) && env.is_string(env.TOS2())) {
|
|
1010
|
+
const rex_obj = env.s.pop();
|
|
1011
|
+
let _datum;
|
|
1012
|
+
var str = env.s.pop()._datum;
|
|
1013
|
+
var my_rex = new RegExp(rex_obj.rex, rex_obj.flags);
|
|
1014
|
+
const result = my_rex.exec(str);
|
|
1015
|
+
env.s.push(result ? { _type: 'TC_JSON', _datum: result } : 0);
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
if (env.is_string(env.TOS()) && env.is_string(env.TOS2())) {
|
|
1019
|
+
const rex = env.s.pop()._datum;
|
|
1020
|
+
var str = env.s.pop()._datum;
|
|
1021
|
+
var my_rex = new RegExp(rex);
|
|
1022
|
+
const result = my_rex.exec(str);
|
|
1023
|
+
env.s.push(result ? { _type: 'TC_JSON', _datum: result } : 0);
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
env.s.push(err.throw('invalid regex exec argument type'));
|
|
1027
|
+
} catch (e) {
|
|
1028
|
+
env.s.push(err.throw(e));
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
regex_match_func() {
|
|
1033
|
+
try {
|
|
1034
|
+
if (env.is_obj(env.TOS()) && env.is_string(env.TOS2())) {
|
|
1035
|
+
const rex_obj = env.s.pop();
|
|
1036
|
+
let _datum;
|
|
1037
|
+
var str = env.s.pop()._datum;
|
|
1038
|
+
var my_rex = new RegExp(rex_obj.rex, rex_obj.flags);
|
|
1039
|
+
const result = str.match(my_rex);
|
|
1040
|
+
env.s.push(result ? { _type: 'TC_JSON', _datum: result } : 0);
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
if (env.is_string(env.TOS()) && env.is_string(env.TOS2())) {
|
|
1044
|
+
const rex = env.s.pop()._datum;
|
|
1045
|
+
var str = env.s.pop()._datum;
|
|
1046
|
+
var my_rex = new RegExp(rex);
|
|
1047
|
+
const result = str.match(my_rex);
|
|
1048
|
+
env.s.push(result ? { _type: 'TC_JSON', _datum: result } : 0);
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
env.s.push(err.throw('invalid regex match argument type'));
|
|
1052
|
+
} catch (e) {
|
|
1053
|
+
env.s.push(err.throw(e));
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
regex_search_func() {
|
|
1058
|
+
try {
|
|
1059
|
+
if (env.is_obj(env.TOS()) && env.is_string(env.TOS2())) {
|
|
1060
|
+
const rex_obj = env.s.pop();
|
|
1061
|
+
let _datum;
|
|
1062
|
+
var str = env.s.pop()._datum;
|
|
1063
|
+
var my_rex = new RegExp(rex_obj.rex, rex_obj.flags);
|
|
1064
|
+
const result = str.search(my_rex);
|
|
1065
|
+
env.s.push({ _type: 'TC_NUM', _datum: result });
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
if (env.is_string(env.TOS()) && env.is_string(env.TOS2())) {
|
|
1069
|
+
const rex = env.s.pop()._datum;
|
|
1070
|
+
var str = env.s.pop()._datum;
|
|
1071
|
+
var my_rex = new RegExp(rex);
|
|
1072
|
+
const result = str.search(my_rex);
|
|
1073
|
+
env.s.push({ _type: 'TC_NUM', _datum: result });
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
env.s.push(err.throw('invalid regex search argument type'));
|
|
1077
|
+
} catch (e) {
|
|
1078
|
+
env.s.push(err.throw(e));
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
regex_replace_func() {
|
|
1083
|
+
try {
|
|
1084
|
+
if (env.is_obj(env.TOS()) && env.is_string(env.TOS2()) && env.is_string(env.s.look_at(2))) {
|
|
1085
|
+
const rex_obj = env.s.pop();
|
|
1086
|
+
let _datum;
|
|
1087
|
+
var replace = env.s.pop()._datum;
|
|
1088
|
+
var str = env.s.pop()._datum;
|
|
1089
|
+
var my_rex = new RegExp(rex_obj.rex, rex_obj.flags);
|
|
1090
|
+
const result = str.replace(my_rex, replace);
|
|
1091
|
+
env.s.push({ _type: 'TC_JSON', _datum: result });
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
if (env.is_string(env.TOS()) && env.is_string(env.TOS2()) && env.is_string(env.s.look_at(2))) {
|
|
1095
|
+
const rex = env.s.pop()._datum;
|
|
1096
|
+
var replace = env.s.pop()._datum;
|
|
1097
|
+
var str = env.s.pop()._datum;
|
|
1098
|
+
var my_rex = new RegExp(rex);
|
|
1099
|
+
const result = str.replace(my_rex, replace);
|
|
1100
|
+
env.s.push({ _type: 'TC_STR', _datum: result });
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
env.s.push(err.throw('invalid regex replace argument type'));
|
|
1104
|
+
} catch (e) {
|
|
1105
|
+
env.s.push(err.throw(e));
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
array_shift_func() {
|
|
1110
|
+
try {
|
|
1111
|
+
if (env.is_list(env.TOS())) {
|
|
1112
|
+
const value = env.s.pop()._datum.shift();
|
|
1113
|
+
const xval = env.adj_bool_val(value);
|
|
1114
|
+
env.s.push({ _type: env.guess_type(value), _datum: xval });
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
env.s.push(err.throw('invalid operation. TOS is not an list'));
|
|
1118
|
+
} catch (e) {
|
|
1119
|
+
env.s.push(err.throw(e));
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
array_unshift_func() {
|
|
1124
|
+
try {
|
|
1125
|
+
if (env.TOS() && env.is_list(env.TOS2())) {
|
|
1126
|
+
const value = env.s.pop()._datum;
|
|
1127
|
+
const array = env.s.pop()._datum;
|
|
1128
|
+
array.unshift(value);
|
|
1129
|
+
env.s.push({ _type: 'TC_JSON', _datum: array });
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
env.s.push(err.throw('invalid operation. TOS2 is not an list'));
|
|
1133
|
+
} catch (e) {
|
|
1134
|
+
env.s.push(err.throw(e));
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
async array_each_func() {
|
|
1139
|
+
try {
|
|
1140
|
+
if (env.TOS() && env.TOS()._type == 'TC_LAMBDA_FUNC' && env.is_list(env.TOS2())) {
|
|
1141
|
+
const funcall = env.s.pop()._datum;
|
|
1142
|
+
const array = env.s.pop()._datum;
|
|
1143
|
+
// Vx€array, !!funcall
|
|
1144
|
+
while (array.length > 0) {
|
|
1145
|
+
const value = array.shift();
|
|
1146
|
+
const xval = env.adj_bool_val(value);
|
|
1147
|
+
env.s.push({ _type: env.guess_type(value), _datum: xval });
|
|
1148
|
+
await evalx.eval_parsed(funcall);
|
|
1149
|
+
}
|
|
1150
|
+
return;
|
|
1151
|
+
}
|
|
1152
|
+
env.s.push(err.throw('invalid arguments. TOS should be a LAMBDA function and TOS2 should be a list'));
|
|
1153
|
+
} catch (e) {
|
|
1154
|
+
env.s.push(err.throw(e));
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
parse_args_func() {
|
|
1159
|
+
try {
|
|
1160
|
+
if (env.is_list(env.TOS())) {
|
|
1161
|
+
const rx_double_dash = /^\-\-[a-zA-Z0-9]+/;
|
|
1162
|
+
const rx_single_dash = /^\-[a-zA-Z0-9]+/;
|
|
1163
|
+
const rx_no_dash = /^[^\-]/;
|
|
1164
|
+
const rx_two_dashes = /^\-\-/;
|
|
1165
|
+
const args = { argv: [] };
|
|
1166
|
+
const params_data = env.s.pop()._datum;
|
|
1167
|
+
// log.info(params_data);
|
|
1168
|
+
let param_found = false;
|
|
1169
|
+
let test_col;
|
|
1170
|
+
let is_dash;
|
|
1171
|
+
const argv = env.lookup('os:argv')._datum._datum;
|
|
1172
|
+
argv.shift();
|
|
1173
|
+
argv.shift();
|
|
1174
|
+
argv.shift();
|
|
1175
|
+
// log.info(argv);
|
|
1176
|
+
while (argv.length > 0) {
|
|
1177
|
+
const item = argv.shift();
|
|
1178
|
+
is_dash = 0;
|
|
1179
|
+
// log.info(item);
|
|
1180
|
+
// if(rx_double_dash.test(item)){
|
|
1181
|
+
// test_col= 1;
|
|
1182
|
+
// is_dash = true;
|
|
1183
|
+
// }
|
|
1184
|
+
// if(rx_single_dash.test(item)) {
|
|
1185
|
+
// test_col = 0;
|
|
1186
|
+
// is_dash = true;
|
|
1187
|
+
// }
|
|
1188
|
+
|
|
1189
|
+
// if(is_dash) {
|
|
1190
|
+
// param_found = false;
|
|
1191
|
+
// for(var param_item of params_data){
|
|
1192
|
+
// log.info(param_item[test_col]);
|
|
1193
|
+
// if(param_item[test_col]=== (test_col === 0)? item.match(rx_single_dash)[0] : item.match(rx_double_dash[0])){
|
|
1194
|
+
// log.info('d: ',param_item);
|
|
1195
|
+
// param_found = true;
|
|
1196
|
+
// break;
|
|
1197
|
+
// }
|
|
1198
|
+
// }
|
|
1199
|
+
// //if ! invalid parameter
|
|
1200
|
+
// if(!param_found) log.info(`invalid parameter ${item}`);
|
|
1201
|
+
// }
|
|
1202
|
+
|
|
1203
|
+
if (rx_double_dash.test(item)) {
|
|
1204
|
+
param_found = false;
|
|
1205
|
+
for (var param_item of params_data) {
|
|
1206
|
+
if (param_item[1] === item.match(rx_double_dash)[0]) {
|
|
1207
|
+
// log.info('dd: ',param_item);
|
|
1208
|
+
param_found = true;
|
|
1209
|
+
switch (param_item[2]) {
|
|
1210
|
+
case 'y':
|
|
1211
|
+
// log.info('ha param');
|
|
1212
|
+
if (argv[0] && rx_no_dash.test(argv[0])) {
|
|
1213
|
+
args[param_item[1].replace(rx_two_dashes, '')] = argv.shift();
|
|
1214
|
+
} else {
|
|
1215
|
+
log.info(`error, parameter ${item} needs value...`);
|
|
1216
|
+
// error needs param...
|
|
1217
|
+
}
|
|
1218
|
+
break;
|
|
1219
|
+
case 'n':
|
|
1220
|
+
// log.info('no param');
|
|
1221
|
+
args[param_item[1].replace(rx_two_dashes, '')] = true;
|
|
1222
|
+
break;
|
|
1223
|
+
case '?':
|
|
1224
|
+
// log.info('opt param');
|
|
1225
|
+
if (argv[0] && rx_no_dash.test(argv[0])) {
|
|
1226
|
+
args[param_item[1].replace(rx_two_dashes, '')] = argv[0];
|
|
1227
|
+
} else {
|
|
1228
|
+
args[param_item[1].replace(rx_two_dashes, '')] = true;
|
|
1229
|
+
}
|
|
1230
|
+
break;
|
|
1231
|
+
default:
|
|
1232
|
+
break;
|
|
1233
|
+
}
|
|
1234
|
+
break;
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
// if ! invalid parameter
|
|
1238
|
+
if (!param_found) {
|
|
1239
|
+
log.info(`invalid parameter ${item}`);
|
|
1240
|
+
}
|
|
1241
|
+
} else if (rx_single_dash.test(item)) {
|
|
1242
|
+
param_found = false;
|
|
1243
|
+
for (var param_item of params_data) {
|
|
1244
|
+
if (param_item[0] === item.match(rx_single_dash)[0]) {
|
|
1245
|
+
// log.info('sd: ',param_item);
|
|
1246
|
+
param_found = true;
|
|
1247
|
+
switch (param_item[2]) {
|
|
1248
|
+
case 'y':
|
|
1249
|
+
// log.info('ha param');
|
|
1250
|
+
if (argv[0] && rx_no_dash.test(argv[0])) {
|
|
1251
|
+
args[param_item[1].replace(rx_two_dashes, '')] = argv.shift();
|
|
1252
|
+
} else {
|
|
1253
|
+
log.info(`error, parameter ${item} needs value...`);
|
|
1254
|
+
// error needs param...
|
|
1255
|
+
}
|
|
1256
|
+
break;
|
|
1257
|
+
case 'n':
|
|
1258
|
+
// log.info('no param');
|
|
1259
|
+
args[param_item[1].replace(rx_two_dashes, '')] = true;
|
|
1260
|
+
break;
|
|
1261
|
+
case '?':
|
|
1262
|
+
// log.info('opt param');
|
|
1263
|
+
if (argv[0] && rx_no_dash.test(argv[0])) {
|
|
1264
|
+
args[param_item[1].replace(rx_two_dashes, '')] = argv[0];
|
|
1265
|
+
} else {
|
|
1266
|
+
args[param_item[1].replace(rx_two_dashes, '')] = true;
|
|
1267
|
+
}
|
|
1268
|
+
break;
|
|
1269
|
+
default:
|
|
1270
|
+
break;
|
|
1271
|
+
}
|
|
1272
|
+
break;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
if (!param_found) {
|
|
1276
|
+
log.info(`invalid parameter ${item}`);
|
|
1277
|
+
}
|
|
1278
|
+
} else {
|
|
1279
|
+
// else{
|
|
1280
|
+
// normal argv...
|
|
1281
|
+
args.argv.push(item);
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
// log.info(args);
|
|
1285
|
+
env.s.push({ _type: 'TC_JSON', _datum: args });
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
env.s.push(err.throw('invalid arguments. TOS should be a list'));
|
|
1289
|
+
} catch (e) {
|
|
1290
|
+
env.s.push(err.throw(e));
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
async await_func() {
|
|
1295
|
+
if (env.TOS() && env.TOS()._type === 'TC_PROMISE') {
|
|
1296
|
+
try {
|
|
1297
|
+
const x = await env.s.pop()._datum;
|
|
1298
|
+
env.s.push({ _type: env.guess_type(x), _datum: x });
|
|
1299
|
+
// env.s.pop()._datum.then(x => {
|
|
1300
|
+
// env.s.push({"_type":env.guess_type(x), "_datum":x});
|
|
1301
|
+
// });
|
|
1302
|
+
return;
|
|
1303
|
+
} catch (e) {
|
|
1304
|
+
env.s.push(err.throw(e));
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
env.s.push(err.throw('invalid arguments type. a Promise was expected.'));
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
string_format_func() {
|
|
1312
|
+
if (env.TOS() && env.TOS2() && env.is_string(env.TOS2()) && env.is_list(env.TOS())) {
|
|
1313
|
+
try {
|
|
1314
|
+
const args_list = env.s.pop()._datum;
|
|
1315
|
+
const fmt = env.s.pop()._datum;
|
|
1316
|
+
env.s.push({ _type: 'TC_STR', _datum: vsprintf(fmt, args_list) });
|
|
1317
|
+
return;
|
|
1318
|
+
} catch (e) {
|
|
1319
|
+
env.s.push(err.throw(e));
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
env.s.push(err.throw('invalid arguments type. a String and a List in TOS and TOS2 was expected.'));
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
string_length_func() {
|
|
1327
|
+
if (env.TOS() && env.is_string(env.TOS())) {
|
|
1328
|
+
try {
|
|
1329
|
+
const str = env.s.pop()._datum;
|
|
1330
|
+
env.s.push({ _type: 'TC_NUM', _datum: str.length });
|
|
1331
|
+
return;
|
|
1332
|
+
} catch (e) {
|
|
1333
|
+
env.s.push(err.throw(e));
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
env.s.push(err.throw('invalid arguments type. a String was expected.'));
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
string_to_upper_func() {
|
|
1341
|
+
if (env.TOS() && env.is_string(env.TOS())) {
|
|
1342
|
+
try {
|
|
1343
|
+
const str = env.s.pop()._datum;
|
|
1344
|
+
env.s.push({ _type: 'TC_STR', _datum: str.toUpperCase() });
|
|
1345
|
+
return;
|
|
1346
|
+
} catch (e) {
|
|
1347
|
+
env.s.push(err.throw(e));
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
env.s.push(err.throw('invalid arguments type. a String was expected.'));
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
string_to_lower_func() {
|
|
1355
|
+
if (env.TOS() && env.is_string(env.TOS())) {
|
|
1356
|
+
try {
|
|
1357
|
+
const str = env.s.pop()._datum;
|
|
1358
|
+
env.s.push({ _type: 'TC_STR', _datum: str.toLowerCase() });
|
|
1359
|
+
return;
|
|
1360
|
+
} catch (e) {
|
|
1361
|
+
env.s.push(err.throw(e));
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
env.s.push(err.throw('invalid arguments type. a String was expected.'));
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
xml_load_func() {
|
|
1369
|
+
if (env.TOS() && env.is_string(env.TOS())) {
|
|
1370
|
+
try {
|
|
1371
|
+
const str = env.s.pop()._datum;
|
|
1372
|
+
const $ = cheerio.load(str);
|
|
1373
|
+
env.s.push({ _type: env.guess_type($), _datum: $ });
|
|
1374
|
+
return;
|
|
1375
|
+
} catch (e) {
|
|
1376
|
+
env.s.push(err.throw(e));
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
env.s.push(err.throw('invalid arguments type. a String was expected.'));
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
xml_loadXML_func() {
|
|
1384
|
+
if (env.TOS() && env.is_string(env.TOS())) {
|
|
1385
|
+
try {
|
|
1386
|
+
const str = env.s.pop()._datum;
|
|
1387
|
+
const $ = cheerio.load(str, { xmlMode: true });
|
|
1388
|
+
env.s.push({ _type: env.guess_type($), _datum: $ });
|
|
1389
|
+
return;
|
|
1390
|
+
} catch (e) {
|
|
1391
|
+
env.s.push(err.throw(e));
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
env.s.push(err.throw('invalid arguments type. a String was expected.'));
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
xml_select_func() {
|
|
1399
|
+
if (env.TOS() && env.TOS2() && env.TOS2()._type == 'TC_FUNC_JS' && env.is_string(env.TOS())) {
|
|
1400
|
+
try {
|
|
1401
|
+
const arg = env.s.pop()._datum;
|
|
1402
|
+
const $ = env.s.pop()._datum;
|
|
1403
|
+
const resp = $(arg);
|
|
1404
|
+
env.s.push({ _type: env.guess_type(resp), _datum: resp });
|
|
1405
|
+
return;
|
|
1406
|
+
} catch (e) {
|
|
1407
|
+
env.s.push(err.throw(e));
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
env.s.push(err.throw('invalid arguments type. a XML object was expected.'));
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
xml_get_text_func() {
|
|
1415
|
+
if (env.TOS() && env.is_json(env.TOS())) {
|
|
1416
|
+
try {
|
|
1417
|
+
const $ = env.s.pop()._datum;
|
|
1418
|
+
const resp = $.text();
|
|
1419
|
+
env.s.push({ _type: env.guess_type(resp), _datum: resp });
|
|
1420
|
+
return;
|
|
1421
|
+
} catch (e) {
|
|
1422
|
+
env.s.push(err.throw(e));
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
env.s.push(err.throw('invalid arguments type. a JSON object was expected.'));
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
xml_get_html_func() {
|
|
1430
|
+
if (env.TOS() && env.is_json(env.TOS())) {
|
|
1431
|
+
try {
|
|
1432
|
+
const $ = env.s.pop()._datum;
|
|
1433
|
+
const resp = $.html();
|
|
1434
|
+
env.s.push({ _type: env.guess_type(resp), _datum: resp });
|
|
1435
|
+
return;
|
|
1436
|
+
} catch (e) {
|
|
1437
|
+
env.s.push(err.throw(e));
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
env.s.push(err.throw('invalid arguments type. a JSON object was expected.'));
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
xml_get_attr_func() {
|
|
1445
|
+
if (env.TOS() && env.is_string(env.TOS()) && env.TOS2() && env.is_json(env.TOS2())) {
|
|
1446
|
+
try {
|
|
1447
|
+
const attr = env.s.pop()._datum;
|
|
1448
|
+
const $ = env.s.pop()._datum;
|
|
1449
|
+
const resp = $.attr(attr);
|
|
1450
|
+
env.s.push({ _type: env.guess_type(resp), _datum: resp });
|
|
1451
|
+
return;
|
|
1452
|
+
} catch (e) {
|
|
1453
|
+
env.s.push(err.throw(e));
|
|
1454
|
+
return;
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
env.s.push(err.throw('invalid arguments type. a JSON object was expected.'));
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
xml_has_class_func() {
|
|
1461
|
+
if (env.TOS() && env.is_string(env.TOS()) && env.TOS2() && env.is_json(env.TOS2())) {
|
|
1462
|
+
try {
|
|
1463
|
+
const attr = env.s.pop()._datum;
|
|
1464
|
+
const $ = env.s.pop()._datum;
|
|
1465
|
+
const resp = $.hasClass(attr);
|
|
1466
|
+
env.s.push(env.set_bool_val(resp));
|
|
1467
|
+
return;
|
|
1468
|
+
} catch (e) {
|
|
1469
|
+
env.s.push(err.throw(e));
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
env.s.push(err.throw('invalid arguments type. a JSON object was expected.'));
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
xml_get_val_func() {
|
|
1477
|
+
if (env.TOS() && env.is_json(env.TOS())) {
|
|
1478
|
+
try {
|
|
1479
|
+
const $ = env.s.pop()._datum;
|
|
1480
|
+
const resp = $.val();
|
|
1481
|
+
env.s.push({ _type: env.guess_type(resp), _datum: resp });
|
|
1482
|
+
return;
|
|
1483
|
+
} catch (e) {
|
|
1484
|
+
env.s.push(err.throw(e));
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
env.s.push(err.throw('invalid arguments type. a JSON object was expected.'));
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
os_exec() {
|
|
1492
|
+
if (env.TOS() && env.is_string(env.TOS())) {
|
|
1493
|
+
try {
|
|
1494
|
+
const str = env.s.pop()._datum;
|
|
1495
|
+
const output = execSync(str).toString();
|
|
1496
|
+
env.s.push({ _type: env.guess_type(output), _datum: output });
|
|
1497
|
+
return;
|
|
1498
|
+
} catch (e) {
|
|
1499
|
+
env.s.push(err.throw(e));
|
|
1500
|
+
return;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
env.s.push(err.throw('invalid arguments type. a String was expected.'));
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
os_exec_i() {
|
|
1507
|
+
if (env.TOS() && env.is_string(env.TOS())) {
|
|
1508
|
+
try {
|
|
1509
|
+
const str = env.s.pop()._datum;
|
|
1510
|
+
execSync(str, { stdio: 'inherit' });
|
|
1511
|
+
return;
|
|
1512
|
+
} catch (e) {
|
|
1513
|
+
env.s.push(err.throw(e));
|
|
1514
|
+
return;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
env.s.push(err.throw('invalid arguments type. a String was expected.'));
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
put_r_stack() {
|
|
1521
|
+
if (env.TOS()) {
|
|
1522
|
+
try {
|
|
1523
|
+
const element = env.s.pop();
|
|
1524
|
+
env.s.rpush(element);
|
|
1525
|
+
return;
|
|
1526
|
+
} catch (e) {
|
|
1527
|
+
env.s.push(err.throw(e));
|
|
1528
|
+
return;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
env.s.push(err.throw('empty stack. Cannot move to r-stack.'));
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
get_r_stack() {
|
|
1535
|
+
if (env.RTOS()) {
|
|
1536
|
+
try {
|
|
1537
|
+
const element = env.s.rpop();
|
|
1538
|
+
env.s.push(element);
|
|
1539
|
+
return;
|
|
1540
|
+
} catch (e) {
|
|
1541
|
+
env.s.push(err.throw(e));
|
|
1542
|
+
return;
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
env.s.push(err.throw('empty r-stack. Cannot move to stack.'));
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
list_head() {
|
|
1549
|
+
if (env.is_list(env.TOS())) {
|
|
1550
|
+
try {
|
|
1551
|
+
const value = env.s.pop()._datum[0];
|
|
1552
|
+
const xval = env.adj_bool_val(value);
|
|
1553
|
+
env.s.push({ _type: env.guess_type(value), _datum: xval });
|
|
1554
|
+
return;
|
|
1555
|
+
} catch (e) {
|
|
1556
|
+
env.s.push(err.throw(e));
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
env.s.push(err.throw('invalid arguments type. TOS not a list'));
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
list_tail() {
|
|
1564
|
+
if (env.is_list(env.TOS())) {
|
|
1565
|
+
try {
|
|
1566
|
+
const value = env.s.pop()._datum;
|
|
1567
|
+
value.shift();
|
|
1568
|
+
// const xval=env.adj_bool_val(value);
|
|
1569
|
+
env.s.push({ _type: env.guess_type(value), _datum: value });
|
|
1570
|
+
return;
|
|
1571
|
+
} catch (e) {
|
|
1572
|
+
env.s.push(err.throw(e));
|
|
1573
|
+
return;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
env.s.push(err.throw('invalid arguments type. TOS not a list'));
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
string_to_number_func() {
|
|
1580
|
+
if (env.is_string(env.TOS())) {
|
|
1581
|
+
try {
|
|
1582
|
+
let value = env.s.pop()._datum;
|
|
1583
|
+
value = Number(value);
|
|
1584
|
+
if (isNaN(value)) {
|
|
1585
|
+
throw 'NaN';
|
|
1586
|
+
}
|
|
1587
|
+
env.s.push({ _type: env.guess_type(value), _datum: value });
|
|
1588
|
+
return;
|
|
1589
|
+
} catch (e) {
|
|
1590
|
+
env.s.push(err.throw(e));
|
|
1591
|
+
return;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
env.s.push(err.throw('invalid arguments type. TOS not a string'));
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
populate_repl() {
|
|
1598
|
+
env.set('handle', { _type: 'TC_NATIVE_FUNC', _datum: this.handle_repl_func }, 'TC_WORD');
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
populate() {
|
|
1602
|
+
env.set('pippo', { _type: 'TC_NATIVE_FUNC', _datum: this.test_func }, 'TC_WORD');
|
|
1603
|
+
env.set('bye', { _type: 'TC_NATIVE_FUNC', _datum: this.bye_func }, 'TC_WORD');
|
|
1604
|
+
env.set('noop', { _type: 'TC_NATIVE_FUNC', _datum: this.noop_func }, 'TC_WORD');
|
|
1605
|
+
env.set('.s', { _type: 'TC_NATIVE_FUNC', _datum: this.print_stack_func }, 'TC_WORD');
|
|
1606
|
+
env.set('.e', { _type: 'TC_NATIVE_FUNC', _datum: this.print_env_func }, 'TC_WORD');
|
|
1607
|
+
env.set('words', { _type: 'TC_NATIVE_FUNC', _datum: this.print_words_func }, 'TC_WORD');
|
|
1608
|
+
env.set('emit', { _type: 'TC_NATIVE_FUNC', _datum: this.emit_func }, 'TC_WORD');
|
|
1609
|
+
env.set('.', { _type: 'TC_NATIVE_FUNC', _datum: this.print_tos_func }, 'TC_WORD');
|
|
1610
|
+
env.set('.?', { _type: 'TC_NATIVE_FUNC', _datum: this.print_debug_tos_func }, 'TC_WORD');
|
|
1611
|
+
env.set('!', { _type: 'TC_NATIVE_FUNC', _datum: this.assign_var_func }, 'TC_WORD');
|
|
1612
|
+
env.set('@', { _type: 'TC_NATIVE_FUNC', _datum: this.read_var_func }, 'TC_WORD');
|
|
1613
|
+
env.set('not', { _type: 'TC_NATIVE_FUNC', _datum: this.not_func }, 'TC_WORD');
|
|
1614
|
+
env.set('and', { _type: 'TC_NATIVE_FUNC', _datum: this.and_func }, 'TC_WORD');
|
|
1615
|
+
env.set('or', { _type: 'TC_NATIVE_FUNC', _datum: this.or_func }, 'TC_WORD');
|
|
1616
|
+
env.set('is_num', { _type: 'TC_NATIVE_FUNC', _datum: this.is_num_func }, 'TC_WORD');
|
|
1617
|
+
env.set('is_string', { _type: 'TC_NATIVE_FUNC', _datum: this.is_string_func }, 'TC_WORD');
|
|
1618
|
+
env.set('is_list', { _type: 'TC_NATIVE_FUNC', _datum: this.is_list_func }, 'TC_WORD');
|
|
1619
|
+
env.set('is_falsy', { _type: 'TC_NATIVE_FUNC', _datum: this.is_falsy_func }, 'TC_WORD');
|
|
1620
|
+
env.set('dup', { _type: 'TC_NATIVE_FUNC', _datum: this.dup_func }, 'TC_WORD');
|
|
1621
|
+
env.set('swap', { _type: 'TC_NATIVE_FUNC', _datum: this.swap_func }, 'TC_WORD');
|
|
1622
|
+
env.set('drop', { _type: 'TC_NATIVE_FUNC', _datum: this.drop_func }, 'TC_WORD');
|
|
1623
|
+
env.set('ndrop', { _type: 'TC_NATIVE_FUNC', _datum: this.ndrop_func }, 'TC_WORD');
|
|
1624
|
+
env.set('nbye', { _type: 'TC_NATIVE_FUNC', _datum: this.nbye_func }, 'TC_WORD');
|
|
1625
|
+
env.set('over', { _type: 'TC_NATIVE_FUNC', _datum: this.over_func }, 'TC_WORD');
|
|
1626
|
+
env.set('n:+', { _type: 'TC_NATIVE_FUNC', _datum: this.num_plus_func }, 'TC_WORD');
|
|
1627
|
+
env.set('n:-', { _type: 'TC_NATIVE_FUNC', _datum: this.num_minus_func }, 'TC_WORD');
|
|
1628
|
+
env.set('n:*', { _type: 'TC_NATIVE_FUNC', _datum: this.num_times_func }, 'TC_WORD');
|
|
1629
|
+
env.set('n:/', { _type: 'TC_NATIVE_FUNC', _datum: this.num_div_func }, 'TC_WORD');
|
|
1630
|
+
env.set('+', { _type: 'TC_NATIVE_FUNC', _datum: this.plus_func }, 'TC_WORD');
|
|
1631
|
+
env.set('-', { _type: 'TC_NATIVE_FUNC', _datum: this.minus_func }, 'TC_WORD');
|
|
1632
|
+
env.set('*', { _type: 'TC_NATIVE_FUNC', _datum: this.times_func }, 'TC_WORD');
|
|
1633
|
+
env.set('/', { _type: 'TC_NATIVE_FUNC', _datum: this.division_func }, 'TC_WORD');
|
|
1634
|
+
env.set('%', { _type: 'TC_NATIVE_FUNC', _datum: this.module_func }, 'TC_WORD');
|
|
1635
|
+
env.set('handle', { _type: 'TC_NATIVE_FUNC', _datum: this.handle_standard_func }, 'TC_WORD');
|
|
1636
|
+
env.set('throw', { _type: 'TC_NATIVE_FUNC', _datum: this.throw_func }, 'TC_WORD');
|
|
1637
|
+
env.set('s:+', { _type: 'TC_NATIVE_FUNC', _datum: this.string_plus_func }, 'TC_WORD');
|
|
1638
|
+
env.set('a:+', { _type: 'TC_NATIVE_FUNC', _datum: this.array_plus_func }, 'TC_WORD');
|
|
1639
|
+
env.set('included', { _type: 'TC_NATIVE_FUNC', _datum: this.included_func }, 'TC_WORD');
|
|
1640
|
+
env.set('a:@', { _type: 'TC_NATIVE_FUNC', _datum: this.array_at_func }, 'TC_WORD');
|
|
1641
|
+
env.set('a:!', { _type: 'TC_NATIVE_FUNC', _datum: this.array_set_at_func }, 'TC_WORD');
|
|
1642
|
+
env.set('m:@', { _type: 'TC_NATIVE_FUNC', _datum: this.object_at_func }, 'TC_WORD');
|
|
1643
|
+
env.set('m:!', { _type: 'TC_NATIVE_FUNC', _datum: this.object_set_at_func }, 'TC_WORD');
|
|
1644
|
+
env.set('a:len', { _type: 'TC_NATIVE_FUNC', _datum: this.array_length_func }, 'TC_WORD');
|
|
1645
|
+
env.set('a:push', { _type: 'TC_NATIVE_FUNC', _datum: this.array_push_func }, 'TC_WORD');
|
|
1646
|
+
env.set('a:pop', { _type: 'TC_NATIVE_FUNC', _datum: this.array_pop_func }, 'TC_WORD');
|
|
1647
|
+
env.set('m:keys', { _type: 'TC_NATIVE_FUNC', _datum: this.object_keys_func }, 'TC_WORD');
|
|
1648
|
+
env.set('m:values', { _type: 'TC_NATIVE_FUNC', _datum: this.object_values_func }, 'TC_WORD');
|
|
1649
|
+
env.set('s:split', { _type: 'TC_NATIVE_FUNC', _datum: this.string_split_func }, 'TC_WORD');
|
|
1650
|
+
env.set('s:join', { _type: 'TC_NATIVE_FUNC', _datum: this.string_join_func }, 'TC_WORD');
|
|
1651
|
+
env.set('j:stringify', { _type: 'TC_NATIVE_FUNC', _datum: this.json_stringify_func }, 'TC_WORD');
|
|
1652
|
+
env.set('j:parse', { _type: 'TC_NATIVE_FUNC', _datum: this.json_parse_func }, 'TC_WORD');
|
|
1653
|
+
env.set('s:@', { _type: 'TC_NATIVE_FUNC', _datum: this.string_at_func }, 'TC_WORD');
|
|
1654
|
+
env.set('s:!', { _type: 'TC_NATIVE_FUNC', _datum: this.string_set_at_func }, 'TC_WORD');
|
|
1655
|
+
env.set('=', { _type: 'TC_NATIVE_FUNC', _datum: this.equal_func }, 'TC_WORD');
|
|
1656
|
+
env.set('===', { _type: 'TC_NATIVE_FUNC', _datum: this.equal_func }, 'TC_WORD');
|
|
1657
|
+
env.set('==', { _type: 'TC_NATIVE_FUNC', _datum: this.eq_func }, 'TC_WORD');
|
|
1658
|
+
env.set('<', { _type: 'TC_NATIVE_FUNC', _datum: this.num_minor_func }, 'TC_WORD');
|
|
1659
|
+
env.set('>', { _type: 'TC_NATIVE_FUNC', _datum: this.num_major_func }, 'TC_WORD');
|
|
1660
|
+
env.set('<=', { _type: 'TC_NATIVE_FUNC', _datum: this.num_min_eq_func }, 'TC_WORD');
|
|
1661
|
+
env.set('>=', { _type: 'TC_NATIVE_FUNC', _datum: this.num_maj_eq_func }, 'TC_WORD');
|
|
1662
|
+
env.set('f:slurp', { _type: 'TC_NATIVE_FUNC', _datum: this.file_slurp_func }, 'TC_WORD');
|
|
1663
|
+
env.set('f:write', { _type: 'TC_NATIVE_FUNC', _datum: this.file_write_func }, 'TC_WORD');
|
|
1664
|
+
env.set('f:append', { _type: 'TC_NATIVE_FUNC', _datum: this.file_append_func }, 'TC_WORD');
|
|
1665
|
+
env.set('f:exists', { _type: 'TC_NATIVE_FUNC', _datum: this.file_exists_func }, 'TC_WORD');
|
|
1666
|
+
env.set('net:request', { _type: 'TC_NATIVE_FUNC', _datum: this.net_request_func }, 'TC_WORD');
|
|
1667
|
+
env.set('j:require-js', { _type: 'TC_NATIVE_FUNC', _datum: this.require_js_func }, 'TC_WORD');
|
|
1668
|
+
env.set('!!', { _type: 'TC_NATIVE_FUNC', _datum: this.funcjs_exec_func }, 'TC_WORD');
|
|
1669
|
+
env.set('G:delete', { _type: 'TC_NATIVE_FUNC', _datum: this.delete_dict_func }, 'TC_WORD');
|
|
1670
|
+
env.set('rx:test', { _type: 'TC_NATIVE_FUNC', _datum: this.regex_test_func }, 'TC_WORD');
|
|
1671
|
+
env.set('rx:exec', { _type: 'TC_NATIVE_FUNC', _datum: this.regex_exec_func }, 'TC_WORD');
|
|
1672
|
+
env.set('rx:match', { _type: 'TC_NATIVE_FUNC', _datum: this.regex_match_func }, 'TC_WORD');
|
|
1673
|
+
env.set('rx:search', { _type: 'TC_NATIVE_FUNC', _datum: this.regex_search_func }, 'TC_WORD');
|
|
1674
|
+
env.set('rx:replace', { _type: 'TC_NATIVE_FUNC', _datum: this.regex_replace_func }, 'TC_WORD');
|
|
1675
|
+
env.set('a:shift', { _type: 'TC_NATIVE_FUNC', _datum: this.array_shift_func }, 'TC_WORD');
|
|
1676
|
+
env.set('a:unshift', { _type: 'TC_NATIVE_FUNC', _datum: this.array_unshift_func }, 'TC_WORD');
|
|
1677
|
+
env.set('a:each', { _type: 'TC_NATIVE_FUNC', _datum: this.array_each_func }, 'TC_WORD');
|
|
1678
|
+
env.set('os:parse-args', { _type: 'TC_NATIVE_FUNC', _datum: this.parse_args_func }, 'TC_WORD');
|
|
1679
|
+
env.set('await', { _type: 'TC_NATIVE_FUNC', _datum: this.await_func }, 'TC_WORD');
|
|
1680
|
+
env.set('s:format', { _type: 'TC_NATIVE_FUNC', _datum: this.string_format_func }, 'TC_WORD');
|
|
1681
|
+
env.set('s:len', { _type: 'TC_NATIVE_FUNC', _datum: this.string_length_func }, 'TC_WORD');
|
|
1682
|
+
env.set('s:to_upper', { _type: 'TC_NATIVE_FUNC', _datum: this.string_to_upper_func }, 'TC_WORD');
|
|
1683
|
+
env.set('s:to_lower', { _type: 'TC_NATIVE_FUNC', _datum: this.string_to_lower_func }, 'TC_WORD');
|
|
1684
|
+
env.set('xml:loadDOM', { _type: 'TC_NATIVE_FUNC', _datum: this.xml_load_func }, 'TC_WORD');
|
|
1685
|
+
env.set('xml:loadXML', { _type: 'TC_NATIVE_FUNC', _datum: this.xml_loadXML_func }, 'TC_WORD');
|
|
1686
|
+
env.set('xml:$', { _type: 'TC_NATIVE_FUNC', _datum: this.xml_select_func }, 'TC_WORD');
|
|
1687
|
+
env.set('xml:get_text', { _type: 'TC_NATIVE_FUNC', _datum: this.xml_get_text_func }, 'TC_WORD');
|
|
1688
|
+
env.set('xml:get_html', { _type: 'TC_NATIVE_FUNC', _datum: this.xml_get_html_func }, 'TC_WORD');
|
|
1689
|
+
env.set('xml:get_attr', { _type: 'TC_NATIVE_FUNC', _datum: this.xml_get_attr_func }, 'TC_WORD');
|
|
1690
|
+
env.set('xml:has_class', { _type: 'TC_NATIVE_FUNC', _datum: this.xml_has_class_func }, 'TC_WORD');
|
|
1691
|
+
env.set('xml:get_val', { _type: 'TC_NATIVE_FUNC', _datum: this.xml_get_val_func }, 'TC_WORD');
|
|
1692
|
+
env.set('os:exec', { _type: 'TC_NATIVE_FUNC', _datum: this.os_exec }, 'TC_WORD');
|
|
1693
|
+
env.set('os:exec-i', { _type: 'TC_NATIVE_FUNC', _datum: this.os_exec_i }, 'TC_WORD');
|
|
1694
|
+
env.set('>r', { _type: 'TC_NATIVE_FUNC', _datum: this.put_r_stack }, 'TC_WORD');
|
|
1695
|
+
env.set('r>', { _type: 'TC_NATIVE_FUNC', _datum: this.get_r_stack }, 'TC_WORD');
|
|
1696
|
+
env.set('a:head', { _type: 'TC_NATIVE_FUNC', _datum: this.list_head }, 'TC_WORD');
|
|
1697
|
+
env.set('a:tail', { _type: 'TC_NATIVE_FUNC', _datum: this.list_tail }, 'TC_WORD');
|
|
1698
|
+
env.set('s:to_num', { _type: 'TC_NATIVE_FUNC', _datum: this.string_to_number_func }, 'TC_WORD');
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
export default new NativeLib();
|