fez-lisp 1.4.17 → 1.4.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 CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "fez-lisp",
3
3
  "description": "Lisp interpreted & compiled to JavaScript",
4
4
  "author": "AT290690",
5
- "version": "1.4.17",
5
+ "version": "1.4.19",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
@@ -16,7 +16,7 @@ export const keywords = {
16
16
  [KEYWORDS.LOOP]: (args, env) => {
17
17
  if (args.length != 2)
18
18
  throw new RangeError(`Wrong number of args to ${KEYWORDS.LOOP}`)
19
- while (evaluate(args[0], env) !== FALSE) evaluate(args[1], env)
19
+ while (evaluate(args[0], env) === TRUE) evaluate(args[1], env)
20
20
  return FALSE
21
21
  },
22
22
  [KEYWORDS.ADDITION]: (args, env) => {
package/src/keywords.js CHANGED
@@ -56,6 +56,7 @@ export const RUNTIME_TYPES = {
56
56
  export const DEBUG = {
57
57
  LOG: 'log',
58
58
  ASSERT: 'assert',
59
+ SIGNATURE: '?',
59
60
  CALLSTACK: '(CALLSTACK)' // so that you can't use it in the code
60
61
  }
61
62
 
package/src/utils.js CHANGED
@@ -290,6 +290,23 @@ export const debug = (ast, onSuccess = compile) => {
290
290
  const debugEnv = {
291
291
  ...keywords,
292
292
  [DEBUG.CALLSTACK]: [KEYWORDS.BLOCK],
293
+ [DEBUG.SIGNATURE]: (args, env) => {
294
+ if (args.length !== 1)
295
+ throw new RangeError(
296
+ `Invalid number of arguments to (${DEBUG.SIGNATURE}) (= 1) (${
297
+ DEBUG.SIGNATURE
298
+ } ${stringifyArgs(args)})`
299
+ )
300
+ const name = args[0][VALUE]
301
+ const signatures = std[0][1][1].filter(
302
+ (x) =>
303
+ x[0][TYPE] === APPLY &&
304
+ x[0][VALUE] === KEYWORDS.DEFINE_VARIABLE &&
305
+ x[1][TYPE] === WORD &&
306
+ x[1][VALUE].toString().includes(name)
307
+ )
308
+ return signatures.map(LISP.source).join('\n\n')
309
+ },
293
310
  [DEBUG.LOG]: (args, env) => {
294
311
  if (args.length !== 1 && args.length !== 2)
295
312
  throw new RangeError(