author | Alan Dipert
<alan@dipert.org> 2019-12-29 13:48:24 UTC |
committer | Alan Dipert
<alan@dipert.org> 2019-12-29 13:48:24 UTC |
parent | f30d62614dc0c1be4e06087d1e43f0ed6637f511 |
jacl.js | +35 | -0 |
diff --git a/jacl.js b/jacl.js index bbe9771..3ed7f38 100644 --- a/jacl.js +++ b/jacl.js @@ -1828,6 +1828,41 @@ const emitter = (() => { }; }); +JACLPKG.intern('.') + .setMacro() + .fvalue = (env, form, topic, ...ops) => { + return ops.reduce((form, op) => { + if (op instanceof LispSymbol) { + return Cons.listOf( + JACLPKG.intern("%JS"), + `((~{}).${op.name})`, + form + ); + } else if (op instanceof LispString + || op instanceof String + || (typeof op) === 'string') { + return Cons.listOf( + JACLPKG.intern("%JS"), + `((~{})['${escapeSingle(op.toString())}'])`, + form + ); + } else if (Cons.isProperList(op)) { + const [meth, ...args] = op + return Cons.listOf( + JACLPKG.intern("%CALL"), + Cons.listOf( + JACLPKG.intern("%JS"), + `((~{}).${meth.name})`, + form + ), + ...args + ) + } else { + throw new Error(`Unknown op: ${op}`); + } + }, topic) + }; + let replInputStream = new BufferedStream(), replReader = new Reader(replInputStream);