aboutsummaryrefslogtreecommitdiff
path: root/js/step2_eval.js
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-02 22:23:37 -0500
committerJoel Martin <github@martintribe.org>2014-04-02 22:23:37 -0500
commitea81a8087bcd7953b083a2be9db447f75e7ebf56 (patch)
tree6cf47a2dbd55d42efc4a901eaabdec952f40ce89 /js/step2_eval.js
parent1617910ad342a55762f3ddabb975849d843cff85 (diff)
downloadmal-ea81a8087bcd7953b083a2be9db447f75e7ebf56.tar.gz
mal-ea81a8087bcd7953b083a2be9db447f75e7ebf56.zip
All: split types into types, env, printer, core.
- types: low-level mapping to the implementation language. - core: functions on types that are exposed directly to mal. - printer: implementation called by pr-str, str, prn, println. - env: the environment implementation - Also, unindent all TCO while loops so that the diff of step4 and step5 are minimized.
Diffstat (limited to 'js/step2_eval.js')
-rw-r--r--js/step2_eval.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/js/step2_eval.js b/js/step2_eval.js
index f2cb8b1..f5efa2c 100644
--- a/js/step2_eval.js
+++ b/js/step2_eval.js
@@ -1,5 +1,6 @@
var types = require('./types');
var reader = require('./reader');
+var printer = require('./printer');
if (typeof module !== 'undefined') {
var readline = require('./node_readline');
}
@@ -11,15 +12,15 @@ function READ(str) {
// eval
function eval_ast(ast, env) {
- if (types.symbol_Q(ast)) {
+ if (types._symbol_Q(ast)) {
return env[ast];
- } else if (types.list_Q(ast)) {
+ } else if (types._list_Q(ast)) {
return ast.map(function(a) { return EVAL(a, env); });
- } else if (types.vector_Q(ast)) {
+ } else if (types._vector_Q(ast)) {
var v = ast.map(function(a) { return EVAL(a, env); });
v.__isvector__ = true;
return v;
- } else if (types.hash_map_Q(ast)) {
+ } else if (types._hash_map_Q(ast)) {
var new_hm = {};
for (k in ast) {
new_hm[EVAL(k, env)] = EVAL(ast[k], env);
@@ -31,7 +32,7 @@ function eval_ast(ast, env) {
}
function _EVAL(ast, env) {
- if (!types.list_Q(ast)) {
+ if (!types._list_Q(ast)) {
return eval_ast(ast, env);
}
@@ -47,7 +48,7 @@ function EVAL(ast, env) {
// print
function PRINT(exp) {
- return types._pr_str(exp, true);
+ return printer._pr_str(exp, true);
}
// repl