11use crate :: namespace:: { Namespace , Namespaces } ;
2+ use crate :: repl;
23use crate :: rust_core;
4+ use crate :: symbol:: Symbol ;
35use crate :: value:: { ToValue , Value } ;
4- use crate :: Symbol ;
5- use crate :: repl;
66
77use std:: cell:: RefCell ;
88use std:: collections:: HashMap ;
@@ -68,21 +68,21 @@ impl Environment {
6868 }
6969 pub fn clojure_core_environment ( ) -> Rc < Environment > {
7070 // Register our macros / functions ahead of time
71- let add_fn = rust_core:: AddFn { } ;
72- let str_fn = rust_core:: StrFn { } ;
73- let do_fn = rust_core:: DoFn { } ;
74- let nth_fn = rust_core:: NthFn { } ;
75- let do_macro = rust_core:: DoMacro { } ;
76- let concat_fn = rust_core:: ConcatFn { } ;
77- let print_string_fn = rust_core:: PrintStringFn { } ;
78- // Hardcoded fns
79- let lexical_eval_fn = Value :: LexicalEvalFn { } ;
80- // Hardcoded macros
81- let let_macro = Value :: LetMacro { } ;
82- let quote_macro = Value :: QuoteMacro { } ;
83- let def_macro = Value :: DefMacro { } ;
84- let fn_macro = Value :: FnMacro { } ;
85- let defmacro_macro = Value :: DefmacroMacro { } ;
71+ let add_fn = rust_core:: AddFn { } ;
72+ let str_fn = rust_core:: StrFn { } ;
73+ let do_fn = rust_core:: DoFn { } ;
74+ let nth_fn = rust_core:: NthFn { } ;
75+ let do_macro = rust_core:: DoMacro { } ;
76+ let concat_fn = rust_core:: ConcatFn { } ;
77+ let print_string_fn = rust_core:: PrintStringFn { } ;
78+ // Hardcoded fns
79+ let lexical_eval_fn = Value :: LexicalEvalFn { } ;
80+ // Hardcoded macros
81+ let let_macro = Value :: LetMacro { } ;
82+ let quote_macro = Value :: QuoteMacro { } ;
83+ let def_macro = Value :: DefMacro { } ;
84+ let fn_macro = Value :: FnMacro { } ;
85+ let defmacro_macro = Value :: DefmacroMacro { } ;
8686 let environment = Rc :: new ( Environment :: new_main_environment ( ) ) ;
8787
8888 let eval_fn = rust_core:: EvalFn :: new ( Rc :: clone ( & environment) ) ;
@@ -96,33 +96,33 @@ impl Environment {
9696 environment. insert ( Symbol :: intern ( "defmacro" ) , defmacro_macro. to_rc_value ( ) ) ;
9797 environment. insert ( Symbol :: intern ( "eval" ) , eval_fn. to_rc_value ( ) ) ;
9898
99- environment. insert ( Symbol :: intern ( "+" ) , add_fn. to_rc_value ( ) ) ;
100- environment. insert ( Symbol :: intern ( "let" ) , let_macro. to_rc_value ( ) ) ;
101- environment. insert ( Symbol :: intern ( "str" ) , str_fn. to_rc_value ( ) ) ;
102- environment. insert ( Symbol :: intern ( "quote" ) , quote_macro. to_rc_value ( ) ) ;
103- environment. insert ( Symbol :: intern ( "do-fn*" ) , do_fn. to_rc_value ( ) ) ;
104- environment. insert ( Symbol :: intern ( "do" ) , do_macro. to_rc_value ( ) ) ;
105- environment. insert ( Symbol :: intern ( "def" ) , def_macro. to_rc_value ( ) ) ;
106- environment. insert ( Symbol :: intern ( "fn" ) , fn_macro. to_rc_value ( ) ) ;
107- environment. insert ( Symbol :: intern ( "defmacro" ) , defmacro_macro. to_rc_value ( ) ) ;
108- environment. insert ( Symbol :: intern ( "eval" ) , eval_fn. to_rc_value ( ) ) ;
109- environment. insert (
99+ environment. insert ( Symbol :: intern ( "+" ) , add_fn. to_rc_value ( ) ) ;
100+ environment. insert ( Symbol :: intern ( "let" ) , let_macro. to_rc_value ( ) ) ;
101+ environment. insert ( Symbol :: intern ( "str" ) , str_fn. to_rc_value ( ) ) ;
102+ environment. insert ( Symbol :: intern ( "quote" ) , quote_macro. to_rc_value ( ) ) ;
103+ environment. insert ( Symbol :: intern ( "do-fn*" ) , do_fn. to_rc_value ( ) ) ;
104+ environment. insert ( Symbol :: intern ( "do" ) , do_macro. to_rc_value ( ) ) ;
105+ environment. insert ( Symbol :: intern ( "def" ) , def_macro. to_rc_value ( ) ) ;
106+ environment. insert ( Symbol :: intern ( "fn" ) , fn_macro. to_rc_value ( ) ) ;
107+ environment. insert ( Symbol :: intern ( "defmacro" ) , defmacro_macro. to_rc_value ( ) ) ;
108+ environment. insert ( Symbol :: intern ( "eval" ) , eval_fn. to_rc_value ( ) ) ;
109+ environment. insert (
110110 Symbol :: intern ( "lexical-eval" ) ,
111111 lexical_eval_fn. to_rc_value ( ) ,
112- ) ;
112+ ) ;
113113
114- environment. insert ( Symbol :: intern ( "nth" ) , nth_fn. to_rc_value ( ) ) ;
115- environment. insert ( Symbol :: intern ( "concat" ) , concat_fn. to_rc_value ( ) ) ;
116- environment. insert (
114+ environment. insert ( Symbol :: intern ( "nth" ) , nth_fn. to_rc_value ( ) ) ;
115+ environment. insert ( Symbol :: intern ( "concat" ) , concat_fn. to_rc_value ( ) ) ;
116+ environment. insert (
117117 Symbol :: intern ( "print-string" ) ,
118118 print_string_fn. to_rc_value ( ) ,
119- ) ;
119+ ) ;
120+
121+ //
122+ // Read in clojure.core
123+ //
124+ let _ = repl:: try_eval_file ( & environment, "./src/clojure/core.clj" ) ;
120125
121- //
122- // Read in clojure.core
123- //
124- let _ = repl:: try_eval_file ( & environment, "./src/clojure/core.clj" ) ;
125-
126- environment
126+ environment
127127 }
128128}
0 commit comments