fez-lisp 1.5.17 → 1.5.19
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/package.json +1 -1
- package/src/check.js +47 -9
package/package.json
CHANGED
package/src/check.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import {
|
2
2
|
APPLY,
|
3
3
|
ATOM,
|
4
|
+
DEBUG,
|
4
5
|
KEYWORDS,
|
5
6
|
PLACEHOLDER,
|
6
7
|
PREDICATE_SUFFIX,
|
@@ -40,6 +41,32 @@ const toTypeNames = (type) => {
|
|
40
41
|
}
|
41
42
|
export const typeCheck = (ast) => {
|
42
43
|
const root = {
|
44
|
+
[DEBUG.LOG]: {
|
45
|
+
[STATS]: {
|
46
|
+
type: APPLY,
|
47
|
+
[ARGS]: [
|
48
|
+
[UNKNOWN, PLACEHOLDER],
|
49
|
+
[APPLY, PLACEHOLDER]
|
50
|
+
],
|
51
|
+
[ARGS_COUNT]: new Set([2]),
|
52
|
+
[RETURNS]: UNKNOWN
|
53
|
+
}
|
54
|
+
},
|
55
|
+
[DEBUG.STRING]: {
|
56
|
+
[STATS]: { type: APPLY, [ARGS_COUNT]: VARIADIC, [RETURNS]: APPLY }
|
57
|
+
},
|
58
|
+
[DEBUG.ASSERT]: {
|
59
|
+
[STATS]: { type: APPLY, [ARGS_COUNT]: VARIADIC, [RETURNS]: UNKNOWN }
|
60
|
+
},
|
61
|
+
[DEBUG.SIGNATURE]: {
|
62
|
+
[STATS]: { type: APPLY, [ARGS_COUNT]: VARIADIC, [RETURNS]: UNKNOWN }
|
63
|
+
},
|
64
|
+
[DEBUG.LIST_THEMES]: {
|
65
|
+
[STATS]: { type: APPLY, [ARGS_COUNT]: VARIADIC, [RETURNS]: UNKNOWN }
|
66
|
+
},
|
67
|
+
[DEBUG.SET_THEME]: {
|
68
|
+
[STATS]: { type: APPLY, [ARGS_COUNT]: VARIADIC, [RETURNS]: UNKNOWN }
|
69
|
+
},
|
43
70
|
[SCOPE_NAME]: performance.now().toString().replace('.', 0),
|
44
71
|
[KEYWORDS.BLOCK]: {
|
45
72
|
[STATS]: { type: APPLY, [ARGS_COUNT]: VARIADIC, [RETURNS]: UNKNOWN }
|
@@ -412,8 +439,10 @@ export const typeCheck = (ast) => {
|
|
412
439
|
}
|
413
440
|
}
|
414
441
|
}
|
415
|
-
|
416
|
-
|
442
|
+
// if (env[SCOPE_NAME]) {
|
443
|
+
// const key = withScope(name, scope)
|
444
|
+
// if (errorStack.has(key)) errorStack.delete(key)
|
445
|
+
// }
|
417
446
|
check(rest.at(-1), env, scope)
|
418
447
|
}
|
419
448
|
}
|
@@ -491,7 +520,9 @@ export const typeCheck = (ast) => {
|
|
491
520
|
args[i][STATS].type === APPLY &&
|
492
521
|
env[rest[i][VALUE]] &&
|
493
522
|
env[rest[i][VALUE]][STATS] &&
|
494
|
-
env[rest[i][VALUE]][STATS][ARGS_COUNT]
|
523
|
+
env[rest[i][VALUE]][STATS][ARGS_COUNT] &&
|
524
|
+
args[i][STATS][ARGS_COUNT] !== VARIADIC &&
|
525
|
+
env[rest[i][VALUE]][STATS][ARGS_COUNT] !== VARIADIC
|
495
526
|
) {
|
496
527
|
const argCount = [...args[i][STATS][ARGS_COUNT]]
|
497
528
|
if (
|
@@ -667,11 +698,14 @@ export const typeCheck = (ast) => {
|
|
667
698
|
)})`
|
668
699
|
)
|
669
700
|
} else {
|
701
|
+
// env[rest[i][VALUE]][STATS] THiss SHOULD BE
|
702
|
+
const retry = env[rest[i][VALUE]]
|
670
703
|
if (
|
671
|
-
|
704
|
+
retry &&
|
705
|
+
!retry.retried &&
|
672
706
|
args[i][STATS].type === UNKNOWN
|
673
707
|
) {
|
674
|
-
|
708
|
+
retry.retried = true
|
675
709
|
if (!scope[SCOPE_NAME])
|
676
710
|
scope[SCOPE_NAME] = scope[1][VALUE]
|
677
711
|
stack.unshift(() => check(exp, env, scope))
|
@@ -704,10 +738,12 @@ export const typeCheck = (ast) => {
|
|
704
738
|
)
|
705
739
|
} else {
|
706
740
|
if (
|
741
|
+
rest[i].length &&
|
742
|
+
env[rest[i][0][VALUE]] &&
|
707
743
|
args[i][STATS].type === UNKNOWN &&
|
708
|
-
!
|
744
|
+
!env[rest[i][0][VALUE]].retried
|
709
745
|
) {
|
710
|
-
|
746
|
+
env[rest[i][0][VALUE]].retried = true
|
711
747
|
if (!scope[SCOPE_NAME])
|
712
748
|
scope[SCOPE_NAME] = scope[1][VALUE]
|
713
749
|
stack.unshift(() => check(exp, env, scope))
|
@@ -725,8 +761,10 @@ export const typeCheck = (ast) => {
|
|
725
761
|
}
|
726
762
|
}
|
727
763
|
}
|
728
|
-
|
764
|
+
const copy = JSON.parse(JSON.stringify(ast))
|
765
|
+
check(copy, root, copy)
|
729
766
|
while (stack.length) stack.pop()()
|
730
|
-
if (errorStack.size)
|
767
|
+
if (errorStack.size)
|
768
|
+
throw new TypeError([...new Set(errorStack.values())].join('\n'))
|
731
769
|
return ast
|
732
770
|
}
|