aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-23 21:59:50 -0500
committerJoel Martin <github@martintribe.org>2014-04-23 21:59:50 -0500
commit6301e0b6374cecc5599665be14d6ddc6a31ce1e8 (patch)
treedbf1dc2ff6c682fd87c72a7907e7f6e59c8d4c03 /js
parent89bd4de1e2704c1bc562788b2c5e4fc08b71a538 (diff)
downloadmal-6301e0b6374cecc5599665be14d6ddc6a31ce1e8.tar.gz
mal-6301e0b6374cecc5599665be14d6ddc6a31ce1e8.zip
All: TCO let* and quasiquote.
Diffstat (limited to 'js')
-rw-r--r--js/core.js2
-rw-r--r--js/step5_tco.js4
-rw-r--r--js/step6_file.js4
-rw-r--r--js/step7_quote.js7
-rw-r--r--js/step8_macros.js7
-rw-r--r--js/step9_interop.js7
-rw-r--r--js/stepA_more.js7
-rw-r--r--js/types.js3
8 files changed, 29 insertions, 12 deletions
diff --git a/js/core.js b/js/core.js
index f9e478e..b5a52e0 100644
--- a/js/core.js
+++ b/js/core.js
@@ -193,9 +193,9 @@ var ns = {'type': types._obj_type,
'rest': rest,
'empty?': empty_Q,
'count': count,
- 'conj': conj,
'apply': apply,
'map': map,
+ 'conj': conj,
'with-meta': with_meta,
'meta': meta,
diff --git a/js/step5_tco.js b/js/step5_tco.js
index 9335aa8..7640327 100644
--- a/js/step5_tco.js
+++ b/js/step5_tco.js
@@ -52,7 +52,9 @@ function _EVAL(ast, env) {
for (var i=0; i < a1.length; i+=2) {
let_env.set(a1[i].value, EVAL(a1[i+1], let_env));
}
- return EVAL(a2, let_env);
+ ast = a2;
+ env = let_env;
+ break;
case "do":
eval_ast(ast.slice(1, -1), env);
ast = ast[ast.length-1];
diff --git a/js/step6_file.js b/js/step6_file.js
index 85de49e..0dfe71e 100644
--- a/js/step6_file.js
+++ b/js/step6_file.js
@@ -52,7 +52,9 @@ function _EVAL(ast, env) {
for (var i=0; i < a1.length; i+=2) {
let_env.set(a1[i].value, EVAL(a1[i+1], let_env));
}
- return EVAL(a2, let_env);
+ ast = a2;
+ env = let_env;
+ break;
case "do":
eval_ast(ast.slice(1, -1), env);
ast = ast[ast.length-1];
diff --git a/js/step7_quote.js b/js/step7_quote.js
index 8676d07..067d68e 100644
--- a/js/step7_quote.js
+++ b/js/step7_quote.js
@@ -72,11 +72,14 @@ function _EVAL(ast, env) {
for (var i=0; i < a1.length; i+=2) {
let_env.set(a1[i].value, EVAL(a1[i+1], let_env));
}
- return EVAL(a2, let_env);
+ ast = a2;
+ env = let_env;
+ break;
case "quote":
return a1;
case "quasiquote":
- return EVAL(quasiquote(a1), env);
+ ast = quasiquote(a1);
+ break;
case "do":
eval_ast(ast.slice(1, -1), env);
ast = ast[ast.length-1];
diff --git a/js/step8_macros.js b/js/step8_macros.js
index dca7beb..2ddb56c 100644
--- a/js/step8_macros.js
+++ b/js/step8_macros.js
@@ -90,11 +90,14 @@ function _EVAL(ast, env) {
for (var i=0; i < a1.length; i+=2) {
let_env.set(a1[i].value, EVAL(a1[i+1], let_env));
}
- return EVAL(a2, let_env);
+ ast = a2;
+ env = let_env;
+ break;
case "quote":
return a1;
case "quasiquote":
- return EVAL(quasiquote(a1), env);
+ ast = quasiquote(a1);
+ break;
case 'defmacro!':
var func = EVAL(a2, env);
func._ismacro_ = true;
diff --git a/js/step9_interop.js b/js/step9_interop.js
index e95b4ca..3988da1 100644
--- a/js/step9_interop.js
+++ b/js/step9_interop.js
@@ -90,11 +90,14 @@ function _EVAL(ast, env) {
for (var i=0; i < a1.length; i+=2) {
let_env.set(a1[i].value, EVAL(a1[i+1], let_env));
}
- return EVAL(a2, let_env);
+ ast = a2;
+ env = let_env;
+ break;
case "quote":
return a1;
case "quasiquote":
- return EVAL(quasiquote(a1), env);
+ ast = quasiquote(a1);
+ break;
case 'defmacro!':
var func = EVAL(a2, env);
func._ismacro_ = true;
diff --git a/js/stepA_more.js b/js/stepA_more.js
index 58840eb..6058da1 100644
--- a/js/stepA_more.js
+++ b/js/stepA_more.js
@@ -90,11 +90,14 @@ function _EVAL(ast, env) {
for (var i=0; i < a1.length; i+=2) {
let_env.set(a1[i].value, EVAL(a1[i+1], let_env));
}
- return EVAL(a2, let_env);
+ ast = a2;
+ env = let_env;
+ break;
case "quote":
return a1;
case "quasiquote":
- return EVAL(quasiquote(a1), env);
+ ast = quasiquote(a1);
+ break;
case 'defmacro!':
var func = EVAL(a2, env);
func._ismacro_ = true;
diff --git a/js/types.js b/js/types.js
index 889e154..d288231 100644
--- a/js/types.js
+++ b/js/types.js
@@ -107,6 +107,7 @@ function _function(Eval, Env, ast, env, params) {
fn.__meta__ = null;
fn.__ast__ = ast;
fn.__gen_env__ = function(args) { return new Env(env, params, args); };
+ fn._ismacro_ = false;
return fn;
}
function _function_Q(obj) { return typeof obj == "function"; }
@@ -131,7 +132,7 @@ function _vector() {
v.__isvector__ = true;
return v;
}
-function _vector_Q(obj) { return Array.isArray(obj) && obj.__isvector__; }
+function _vector_Q(obj) { return Array.isArray(obj) && !!obj.__isvector__; }