diff options
| author | Joel Martin <github@martintribe.org> | 2014-12-18 20:33:49 -0600 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2015-01-09 16:16:50 -0600 |
| commit | b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c (patch) | |
| tree | f4d977ed220e9a3f665cfbf4f68770a81e4c2095 /vb/step8_macros.vb | |
| parent | aaba249304b184e12e2445ab22d66df1f39a51a5 (diff) | |
| download | mal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.tar.gz mal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.zip | |
All: add keywords.
Also, fix nth and count to match cloure.
Diffstat (limited to 'vb/step8_macros.vb')
| -rw-r--r-- | vb/step8_macros.vb | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/vb/step8_macros.vb b/vb/step8_macros.vb index 1a7f211..400dbe7 100644 --- a/vb/step8_macros.vb +++ b/vb/step8_macros.vb @@ -52,8 +52,8 @@ Namespace Mal If TypeOf ast Is MalList Then Dim a0 As MalVal = DirectCast(ast,MalList)(0) If TypeOf a0 Is MalSymbol AndAlso _ - env.find(DirectCast(a0,MalSymbol).getName()) IsNot Nothing Then - Dim mac As MalVal = env.do_get(DirectCast(a0,MalSymbol).getName()) + env.find(DirectCast(a0,MalSymbol)) IsNot Nothing Then + Dim mac As MalVal = env.do_get(DirectCast(a0,MalSymbol)) If TypeOf mac Is MalFunc AndAlso _ DirectCast(mac,MalFunc).isMacro() Then return True @@ -66,7 +66,7 @@ Namespace Mal Shared Function macroexpand(ast As MalVal, env As MalEnv) As MalVal While is_macro_call(ast, env) Dim a0 As MalSymbol = DirectCast(DirectCast(ast,MalList)(0),MalSymbol) - Dim mac As MalFunc = DirectCast(env.do_get(a0.getName()),MalFunc) + Dim mac As MalFunc = DirectCast(env.do_get(a0),MalFunc) ast = mac.apply(DirectCast(ast,MalList).rest()) End While return ast @@ -74,8 +74,7 @@ Namespace Mal Shared Function eval_ast(ast As MalVal, env As MalEnv) As MalVal If TypeOf ast Is MalSymbol Then - Dim sym As MalSymbol = DirectCast(ast, MalSymbol) - return env.do_get(sym.getName()) + return env.do_get(DirectCast(ast, MalSymbol)) Else If TypeOf ast Is MalList Then Dim old_lst As MalList = DirectCast(ast, MalList) Dim new_lst As MalList @@ -143,7 +142,7 @@ Namespace Mal Dim a1 As MalVal = ast(1) Dim a2 As MalVal = ast(2) Dim res As MalVal = EVAL(a2, env) - env.do_set(DirectCast(a1,MalSymbol).getName(), res) + env.do_set(DirectCast(a1,MalSymbol), res) return res Case "let*" Dim a1 As MalVal = ast(1) @@ -154,7 +153,7 @@ Namespace Mal For i As Integer = 0 To (DirectCast(a1,MalList)).size()-1 Step 2 key = DirectCast(DirectCast(a1,MalList)(i),MalSymbol) val = DirectCast(a1,MalList)(i+1) - let_env.do_set(key.getName(), EVAL(val, let_env)) + let_env.do_set(key, EVAL(val, let_env)) Next orig_ast = a2 env = let_env @@ -167,7 +166,7 @@ Namespace Mal Dim a2 As MalVal = ast(2) Dim res As MalVal = EVAL(a2, env) DirectCast(res,MalFunc).setMacro() - env.do_set(DirectCast(a1,MalSymbol).getName(), res) + env.do_set(DirectCast(a1,MalSymbol), res) return res Case "macroexpand" Dim a1 As MalVal = ast(1) @@ -237,9 +236,9 @@ Namespace Mal ' core.vb: defined using VB.NET For Each entry As KeyValuePair(Of String,MalVal) In core.ns() - repl_env.do_set(entry.Key, entry.Value) + repl_env.do_set(new MalSymbol(entry.Key), entry.Value) Next - repl_env.do_set("eval", new MalFunc(AddressOf do_eval)) + repl_env.do_set(new MalSymbol("eval"), new MalFunc(AddressOf do_eval)) Dim fileIdx As Integer = 1 If args.Length > 1 AndAlso args(1) = "--raw" Then Mal.readline.SetMode(Mal.readline.Modes.Raw) @@ -249,7 +248,7 @@ Namespace Mal For i As Integer = fileIdx+1 To args.Length-1 argv.conj_BANG(new MalString(args(i))) Next - repl_env.do_set("*ARGV*", argv) + repl_env.do_set(new MalSymbol("*ARGV*"), argv) ' core.mal: defined using the language itself REP("(def! not (fn* (a) (if a false true)))") |
