aboutsummaryrefslogtreecommitdiff
path: root/coffee/stepA_interop.coffee
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-12-18 20:33:49 -0600
committerJoel Martin <github@martintribe.org>2015-01-09 16:16:50 -0600
commitb8ee29b22fbaa7a01f2754b4d6dd9af52e02017c (patch)
treef4d977ed220e9a3f665cfbf4f68770a81e4c2095 /coffee/stepA_interop.coffee
parentaaba249304b184e12e2445ab22d66df1f39a51a5 (diff)
downloadmal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.tar.gz
mal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.zip
All: add keywords.
Also, fix nth and count to match cloure.
Diffstat (limited to 'coffee/stepA_interop.coffee')
-rw-r--r--coffee/stepA_interop.coffee20
1 files changed, 10 insertions, 10 deletions
diff --git a/coffee/stepA_interop.coffee b/coffee/stepA_interop.coffee
index aa9c5cc..751f9ad 100644
--- a/coffee/stepA_interop.coffee
+++ b/coffee/stepA_interop.coffee
@@ -21,17 +21,17 @@ quasiquote = (ast) ->
is_macro_call = (ast, env) ->
return types._list_Q(ast) && types._symbol_Q(ast[0]) &&
- env.find(ast[0].name) && env.get(ast[0].name).__ismacro__
+ env.find(ast[0]) && env.get(ast[0]).__ismacro__
macroexpand = (ast, env) ->
while is_macro_call(ast, env)
- ast = env.get(ast[0].name)(ast[1..]...)
+ ast = env.get(ast[0])(ast[1..]...)
ast
eval_ast = (ast, env) ->
- if types._symbol_Q(ast) then env.get ast.name
+ if types._symbol_Q(ast) then env.get ast
else if types._list_Q(ast) then ast.map((a) -> EVAL(a, env))
else if types._vector_Q(ast)
types._vector(ast.map((a) -> EVAL(a, env))...)
@@ -53,11 +53,11 @@ EVAL = (ast, env) ->
[a0, a1, a2, a3] = ast
switch a0.name
when "def!"
- return env.set(a1.name, EVAL(a2, env))
+ return env.set(a1, EVAL(a2, env))
when "let*"
let_env = new Env(env)
for k,i in a1 when i %% 2 == 0
- let_env.set(a1[i].name, EVAL(a1[i+1], let_env))
+ let_env.set(a1[i], EVAL(a1[i+1], let_env))
ast = a2
env = let_env
when "quote"
@@ -67,7 +67,7 @@ EVAL = (ast, env) ->
when "defmacro!"
f = EVAL(a2, env)
f.__ismacro__ = true
- return env.set(a1.name, f)
+ return env.set(a1, f)
when "macroexpand"
return macroexpand(a1, env)
when "try*"
@@ -112,9 +112,9 @@ repl_env = new Env()
rep = (str) -> PRINT(EVAL(READ(str), repl_env))
# core.coffee: defined using CoffeeScript
-repl_env.set k, v for k,v of core.ns
-repl_env.set 'eval', (ast) -> EVAL(ast, repl_env)
-repl_env.set '*ARGV*', []
+repl_env.set types._symbol(k), v for k,v of core.ns
+repl_env.set types._symbol('eval'), (ast) -> EVAL(ast, repl_env)
+repl_env.set types._symbol('*ARGV*'), []
# core.mal: defined using the language itself
rep("(def! *host-language* \"CoffeeScript\")")
@@ -124,7 +124,7 @@ rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (
rep("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
if process? && process.argv.length > 2
- repl_env.set '*ARGV*', process.argv[3..]
+ repl_env.set types._symbol('*ARGV*'), process.argv[3..]
rep('(load-file "' + process.argv[2] + '")')
process.exit 0