Skip to content
Browse files

import*

  • Loading branch information...
1 parent 60875f5 commit 8a261065aba7fbf262cf04d1f6ee4715eddb6ae8 @hiredman committed Aug 25, 2010
Showing with 17 additions and 11 deletions.
  1. +3 −4 project.clj
  2. +13 −6 src/arkham/core.clj
  3. +1 −1 test/arkham/core_test.clj
View
7 project.clj
@@ -1,6 +1,5 @@
(defproject Arkham "1.0.0-SNAPSHOT"
:description "lisp interpreter with clojure like semantics"
- :dependencies []
- :dev-dependencies [[swank-clojure "1.2.1"]
- [org.clojure/clojure "1.2.0-RC2"]
- [org.clojure/clojure-contrib "1.2.0-SNAPSHOT"]])
+ :dependencies [[org.clojure/clojure "1.2.0"]
+ [org.clojure/clojure-contrib "1.2.0"]]
+ :dev-dependencies [[swank-clojure "1.2.1"]])
View
19 src/arkham/core.clj
@@ -18,18 +18,22 @@
(defmethod meval :default [[stack exp]]
[stack exp])
+(defn find-frame [stack exp]
+ (->> stack
+ (remove special-frame?)
+ (map #(if (instance? IDeref %) @% %))
+ (filter #(contains? % exp))
+ first))
+
(defmethod meval Symbol [[stack exp]]
+ (println "@meval Symbol" exp)
[stack
(if (= exp '*STACK*)
stack
- (if-let [bound (->> stack
- (remove special-frame?)
- (map #(if (instance? IDeref %) @% %))
- (filter #(contains? % exp))
- first)]
+ (if-let [bound (find-frame stack exp)]
(get bound exp)
(if (ns-resolve *ns* exp)
- @(get-var (ns-resolve *ns* exp) exp)
+ (deref (get-var (ns-resolve *ns* exp) exp))
(static-field (ns-resolve *ns* (symbol (namespace exp)))
(symbol (name exp))))))])
@@ -249,6 +253,9 @@
(deliver (first stack1) table)
(meval [stack1 (cons 'do body)])))
+(defmethod eval-seq 'clojure.core/import* [[stack exp]]
+ [stack (.importClass *ns* (Class/forName (second exp)))])
+
(defn evil [exp]
(second (meval [() (mexpand-all exp)])))
View
2 test/arkham/core_test.clj
@@ -12,7 +12,7 @@
(is (= 3 (evil '(binding [* +] (* 1 2))))))
(testing "special forms"
;; TODO:
- ;; set!
+ ;; set! import*
;; deftype* case* reify*
;; DONE:
;; . if let* do quote var new throw loop/recur def fn*

0 comments on commit 8a26106

Please sign in to comment.
Something went wrong with that request. Please try again.