diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-04-07 14:42:30 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-04-07 14:47:14 -0400 |
| commit | 53af55a6d5966df5353b06b2791bb35da31b5dba (patch) | |
| tree | 7ed7fc7f17aa6ee6dd0c079f87e10f1a1acd04b2 | |
| parent | b179dd09b1349b8a43a8ca888f317e98601d8c23 (diff) | |
Basic system functions in JS VM
| -rwxr-xr-x | docs/bqn.js | 7 | ||||
| -rw-r--r-- | docs/repl.js | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/docs/bqn.js b/docs/bqn.js index 4c5bd51f..afbc451d 100755 --- a/docs/bqn.js +++ b/docs/bqn.js @@ -262,7 +262,9 @@ let compile = run( ,[[0,1,0,32],[1,0,464,5],[1,1,483,5],[0,0,607,49],[0,0,2304,22],[0,0,3111,119],[0,0,8011,15],[0,0,8162,3],[0,0,8170,3],[0,0,8210,3],[0,0,8229,3],[0,0,8252,3],[1,1,8274,4],[0,0,8336,3],[2,1,8360,3],[0,0,8396,6],[2,1,8533,3],[0,0,8602,3],[0,0,8652,3],[0,0,8674,3],[0,0,8704,3],[0,0,8762,3],[0,0,8824,4],[0,0,8876,3],[0,0,8898,3],[2,1,8923,3]] ); runtime[42] = rtAssert; -let bqn = src => run.apply(null,compile(str(src),runtime)); +let system = (x,w) => list([x[0],table(s=>sysvals[s.join("")])(x[1])]); +let rt_sys = list([runtime, system]); +let bqn = src => run.apply(null,compile(str(src),rt_sys)); // Formatter let fmtnum = x => str(x==Infinity ? "∞" : x==-Infinity ? "¯∞" @@ -295,6 +297,9 @@ let fmtErr = (s,e) => { return [w].concat(loc).join('\n'); } +let sysvals = {bqn, type, glyph, decompose, fmt:fmt1, listsys:0}; +sysvals.listsys = list(Object.keys(sysvals).map(str)); + if (typeof module!=='undefined') { bqn.fmt=fmt; bqn.fmtErr=fmtErr; bqn.compile=compile; bqn.run=run; module.exports=bqn; diff --git a/docs/repl.js b/docs/repl.js index 0627d87e..4bdb653f 100644 --- a/docs/repl.js +++ b/docs/repl.js @@ -26,7 +26,7 @@ let repl = ()=>{ setcount(s); setTimeout(() => { try { - let c=compile(src,runtime); + let c=compile(src,rt_sys); setExplain(src,c); doc.rslt.textContent=fmt(run.apply(null,c)); } catch(e) { |
