Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: pjstadig/clojure
...
head fork: pjstadig/clojure
  • 12 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
14 .classpath
View
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="test/java" output="target/test-classes" including="**/*.java"/>
+ <classpathentry kind="src" path="src/jvm" including="**/*.java"/>
+ <classpathentry kind="src" path="src/resources" excluding="**/*.java"/>
+ <classpathentry kind="src" path="src/clj" excluding="**/*.java"/>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="var" path="M2_REPO/name/stadig/clojure-lang/0.1.0-SNAPSHOT/clojure-lang-0.1.0-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/codehaus/jsr166-mirror/jsr166y/1.7.0/jsr166y-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/clojure/test.generative/0.2.0/test.generative-0.2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/clojure/tools.namespace/0.1.1/tools.namespace-0.1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/clojure/java.classpath/0.1.1/java.classpath-0.1.1.jar"/>
+</classpath>
14 .project
View
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>clojure</name>
+ <comment>Clojure core environment and runtime library. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
10 .settings/org.eclipse.jdt.core.prefs
View
@@ -0,0 +1,10 @@
+#Sun Feb 03 20:52:24 EST 2013
+encoding/src/resources=UTF-8
+org.eclipse.jdt.core.compiler.compliance=1.5
+encoding/src/main/java=UTF-8
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+encoding/test/java=UTF-8
+eclipse.preferences.version=1
+encoding/src/test/resources=UTF-8
+org.eclipse.jdt.core.compiler.source=1.5
+encoding/src/clj=UTF-8
2  build.xml
View
@@ -86,7 +86,7 @@
<javac srcdir="${jtestsrc}" destdir="${test-classes}" includeJavaRuntime="yes"
debug="true" source="1.6" target="1.6" includeantruntime="no"/>
<java classname="clojure.lang.Compile"
- classpath="${test-classes}:${test}:${build}:${cljsrc}"
+ classpath="${maven.test.classpath}:${test-classes}:${test}:${build}:${cljsrc}"
failonerror="true"
fork="true">
<sysproperty key="clojure.compile.path" value="${test-classes}"/>
10 pom.xml
View
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.clojure</groupId>
+ <groupId>name.stadig</groupId>
<artifactId>clojure</artifactId>
<name>clojure</name>
<packaging>jar</packaging>
- <version>1.7.0-master-SNAPSHOT</version>
+ <version>1.7.0-clinc-SNAPSHOT</version>
<url>http://clojure.org/</url>
<description>Clojure core environment and runtime library.</description>
@@ -33,9 +33,9 @@
</parent>
<scm>
- <connection>scm:git:git@github.com:clojure/clojure.git</connection>
- <developerConnection>scm:git:git@github.com:clojure/clojure.git</developerConnection>
- <url>git@github.com:clojure/clojure.git</url>
+ <connection>scm:git:git@github.com:pjstadig/clojure.git</connection>
+ <developerConnection>scm:git:git@github.com:pjstadig/clojure.git</developerConnection>
+ <url>git@github.com:pjstadig/clojure.git</url>
</scm>
<dependencies>
10 src/clj/clojure/core.clj
View
@@ -6268,6 +6268,16 @@
(load "genclass")
(load "core_deftype")
(load "core/protocols")
+
+(defn first [s]
+ (clojure.core.protocols/first s))
+
+(defn rest [s]
+ (clojure.core.protocols/more s))
+
+(defn next [s]
+ (clojure.core.protocols/next s))
+
(load "gvec")
(load "instant")
(load "uuid")
23 src/clj/clojure/core/protocols.clj
View
@@ -10,6 +10,29 @@
(set! *warn-on-reflection* true)
+(defprotocol ISeq
+ (first [this])
+ (more [this])
+ (next [this]))
+
+(extend-protocol ISeq
+ nil
+ (first [this] nil)
+ (more [this] nil)
+ (next [this] nil)
+ clojure.lang.ISeq
+ (first [this] (.first this))
+ (more [this] (.more this))
+ (next [this] (.next this))
+ clojure.lang.Seqable
+ (first [this] (first (.seq this)))
+ (more [this] (more (.seq this)))
+ (next [this] (next (.seq this)))
+ String
+ (first [this] (first (clojure.lang.StringSeq/create this)))
+ (more [this] (more (clojure.lang.StringSeq/create this)))
+ (next [this] (next (clojure.lang.StringSeq/create this))))
+
(defprotocol CollReduce
"Protocol for collection types that can implement reduce faster than
first/next recursion. Called by clojure.core/reduce. Baseline
262 src/clj/clojure/core_deftype.clj
View
@@ -466,23 +466,6 @@
;;;;;;;;;;;;;;;;;;;;;;; protocols ;;;;;;;;;;;;;;;;;;;;;;;;
-(defn- expand-method-impl-cache [^clojure.lang.MethodImplCache cache c f]
- (if (.map cache)
- (let [cs (assoc (.map cache) c (clojure.lang.MethodImplCache$Entry. c f))]
- (clojure.lang.MethodImplCache. (.protocol cache) (.methodk cache) cs))
- (let [cs (into1 {} (remove (fn [[c e]] (nil? e)) (map vec (partition 2 (.table cache)))))
- cs (assoc cs c (clojure.lang.MethodImplCache$Entry. c f))]
- (if-let [[shift mask] (maybe-min-hash (map hash (keys cs)))]
- (let [table (make-array Object (* 2 (inc mask)))
- table (reduce1 (fn [^objects t [c e]]
- (let [i (* 2 (int (shift-mask shift mask (hash c))))]
- (aset t i c)
- (aset t (inc i) e)
- t))
- table cs)]
- (clojure.lang.MethodImplCache. (.protocol cache) (.methodk cache) shift mask table))
- (clojure.lang.MethodImplCache. (.protocol cache) (.methodk cache) cs)))))
-
(defn- super-chain [^Class c]
(when c
(cons c (super-chain (.getSuperclass c)))))
@@ -493,19 +476,226 @@
([^Class a ^Class b]
(if (.isAssignableFrom a b) b a)))
-(defn find-protocol-impl [protocol x]
- (if (instance? (:on-interface protocol) x)
- x
- (let [c (class x)
- impl #(get (:impls protocol) %)]
- (or (impl c)
- (and c (or (first (remove nil? (map impl (butlast (super-chain c)))))
- (when-let [t (reduce1 pref (filter impl (disj (supers c) Object)))]
- (impl t))
- (impl Object)))))))
-
-(defn find-protocol-method [protocol methodk x]
- (get (find-protocol-impl protocol x) methodk))
+(letfn [(first [s]
+ (when-let [s (seq s)]
+ (.first s)))
+ (next [s]
+ (when s
+ (.next s)))
+ (rest [s]
+ (when s
+ (.more s)))
+ (conj [s x]
+ (.cons s x))
+ (seq [s]
+ (when s
+ (if (.isArray (.getClass s))
+ (clojure.lang.ArraySeq/createFromObject s)
+ (.seq s))))
+ (every? [pred coll]
+ (cond
+ (nil? (seq coll)) true
+ (pred (first coll)) (recur pred (next coll))
+ :else false))
+ (spread [arglist]
+ (cond
+ (nil? arglist) nil
+ (nil? (next arglist)) (seq (first arglist))
+ :else (cons (first arglist) (spread (next arglist)))))
+ (apply
+ ([^clojure.lang.IFn f args]
+ (. f (applyTo (seq args))))
+ ([^clojure.lang.IFn f x args]
+ (. f (applyTo (list* x args))))
+ ([^clojure.lang.IFn f x y args]
+ (. f (applyTo (list* x y args))))
+ ([^clojure.lang.IFn f x y z args]
+ (. f (applyTo (list* x y z args))))
+ ([^clojure.lang.IFn f a b c d & args]
+ (. f (applyTo (cons a (cons b (cons c (cons d (spread args)))))))))
+ (list*
+ ([args] (seq args))
+ ([a args] (cons a args))
+ ([a b args] (cons a (cons b args)))
+ ([a b c args] (cons a (cons b (cons c args))))
+ ([a b c d & more]
+ (cons a (cons b (cons c (cons d (spread more)))))))
+ (map
+ ([f coll]
+ (when-let [s (seq coll)]
+ (cons (f (first s)) (map f (rest s)))))
+ ([f c1 c2]
+ (let [s1 (seq c1) s2 (seq c2)]
+ (when (and s1 s2)
+ (cons (f (first s1) (first s2))
+ (map f (rest s1) (rest s2))))))
+ ([f c1 c2 c3]
+ (let [s1 (seq c1) s2 (seq c2) s3 (seq c3)]
+ (when (and s1 s2 s3)
+ (cons (f (first s1) (first s2) (first s3))
+ (map f (rest s1) (rest s2) (rest s3))))))
+ ([f c1 c2 c3 & colls]
+ (let [step (fn step [cs]
+ (let [ss (map seq cs)]
+ (when (every? identity ss)
+ (cons (map first ss) (step (map rest ss))))))]
+ (map #(apply f %) (step (conj colls c3 c2 c1))))))
+ (range
+ ([] (range 0 Double/POSITIVE_INFINITY 1))
+ ([end] (range 0 end 1))
+ ([start end] (range start end 1))
+ ([start end step]
+ (lazy-seq
+ (let [comp (if (pos? step) < >)]
+ (when (comp start end)
+ (cons start (range (+ start step) end step)))))))
+ (maybe-min-hash [hashes]
+ (first
+ (filter (fn [[s m]]
+ (apply distinct? (map #(shift-mask s m %) hashes)))
+ (apply concat (map (fn [mask]
+ (map (fn [shift]
+ [shift mask])
+ (range 0 31)))
+ (map #(dec (bit-shift-left 1 %))
+ (range 1 (inc max-mask-bits))))))))
+ (concat
+ ([] (lazy-seq nil))
+ ([x] (lazy-seq x))
+ ([x y]
+ (lazy-seq
+ (let [s (seq x)]
+ (if s
+ (cons (first s) (concat (rest s) y))
+ y))))
+ ([x y & zs]
+ (let [cat (fn cat [xys zs]
+ (lazy-seq
+ (let [xys (seq xys)]
+ (if xys
+ (cons (first xys) (cat (rest xys) zs))
+ (when zs
+ (cat (first zs) (next zs)))))))]
+ (cat (concat x y) zs))))
+ (remove [pred coll]
+ (filter (complement pred) coll))
+ (filter [pred coll]
+ (when-let [s (seq coll)]
+ (let [f (first s) r (rest s)]
+ (if (pred f)
+ (cons f (filter pred r))
+ (filter pred r)))))
+ (partition
+ ([n coll]
+ (partition n n coll))
+ ([n step coll]
+ (lazy-seq
+ (when-let [s (seq coll)]
+ (let [p (doall (take n s))]
+ (when (= n (count p))
+ (cons p (partition n step (nthrest s step))))))))
+ ([n step pad coll]
+ (lazy-seq
+ (when-let [s (seq coll)]
+ (let [p (doall (take n s))]
+ (if (= n (count p))
+ (cons p (partition n step pad (nthrest s step)))
+ (list (take n (concat p pad)))))))))
+ (doall
+ ([coll]
+ (dorun coll)
+ coll)
+ ([n coll]
+ (dorun n coll)
+ coll))
+ (dorun
+ ([coll]
+ (when (seq coll)
+ (recur (next coll))))
+ ([n coll]
+ (when (and (seq coll) (pos? n))
+ (recur (dec n) (next coll)))))
+ (butlast [s]
+ (loop [ret [] s s]
+ (if (next s)
+ (recur (conj ret (first s)) (next s))
+ (seq ret))))
+ (supers [class]
+ (loop [ret (set (bases class)) cs ret]
+ (if (seq cs)
+ (let [c (first cs) bs (bases c)]
+ (recur (into1 ret bs) (into1 (disj cs c) bs)))
+ (not-empty ret))))
+ (into1 [to from]
+ (reduce1 conj to from))
+ (reduce1
+ ([f coll]
+ (let [s (seq coll)]
+ (if s
+ (reduce1 f (first s) (next s))
+ (f))))
+ ([f val coll]
+ (let [s (seq coll)]
+ (if s
+ (recur f (f val (first s)) (next s))
+ val))))
+ (distinct?
+ ([x] true)
+ ([x y] (not (= x y)))
+ ([x y & more]
+ (if (not= x y)
+ (loop [s #{x y} xs more]
+ (let [x (first xs)
+ etc (next xs)]
+ (if xs
+ (if (contains? s x)
+ false
+ (recur (conj s x) etc))
+ true)))
+ false)))]
+ (defn- expand-method-impl-cache [^clojure.lang.MethodImplCache cache c f]
+ (if (.map cache)
+ (let [cs (assoc (.map cache) c (clojure.lang.MethodImplCache$Entry. c f))]
+ (clojure.lang.MethodImplCache. (.protocol cache) (.methodk cache) cs))
+ (let [table (.table cache)
+ cs (into1 {} (remove (fn [[c e]] (nil? e)) (map vec (partition 2 (.table cache)))))
+ cs (assoc cs c (clojure.lang.MethodImplCache$Entry. c f))]
+ (if-let [[shift mask] (maybe-min-hash (map hash (keys cs)))]
+ (let [table (make-array Object (* 2 (inc mask)))
+ table (reduce1 (fn [^objects t [c e]]
+ (let [i (* 2 (int (shift-mask shift mask (hash c))))]
+ (aset t i c)
+ (aset t (inc i) e)
+ t))
+ table cs)]
+ (clojure.lang.MethodImplCache. (.protocol cache) (.methodk cache) shift mask table))
+ (clojure.lang.MethodImplCache. (.protocol cache) (.methodk cache) cs)))))
+
+ (defn find-protocol-impl [protocol x]
+ (if (instance? (:on-interface protocol) x)
+ x
+ (let [c (class x)
+ impl #(get (:impls protocol) %)]
+ (or (impl c)
+ (and c (or (first (remove nil? (map impl (butlast (super-chain c)))))
+ (when-let [t (reduce1 pref (filter impl (disj (supers c) Object)))]
+ (impl t))
+ (impl Object)))))))
+
+ (defn find-protocol-method [protocol methodk x]
+ (get (find-protocol-impl protocol x) methodk))
+
+ (defn -cache-protocol-fn [^clojure.lang.AFunction pf x ^Class c ^clojure.lang.IFn interf]
+ (let [cache (.__methodImplCache pf)
+ f (if (.isInstance c x)
+ interf
+ (find-protocol-method (.protocol cache) (.methodk cache) x))]
+ (when-not f
+ (throw (IllegalArgumentException. (str "No implementation of method: " (.methodk cache)
+ " of protocol: " (:var (.protocol cache))
+ " found for class: " (if (nil? x) "nil" (.getName (class x)))))))
+ (set! (.__methodImplCache pf) (expand-method-impl-cache cache (class x) f))
+ f)))
(defn- protocol?
[maybe-p]
@@ -533,18 +723,6 @@
[protocol x]
(boolean (find-protocol-impl protocol x)))
-(defn -cache-protocol-fn [^clojure.lang.AFunction pf x ^Class c ^clojure.lang.IFn interf]
- (let [cache (.__methodImplCache pf)
- f (if (.isInstance c x)
- interf
- (find-protocol-method (.protocol cache) (.methodk cache) x))]
- (when-not f
- (throw (IllegalArgumentException. (str "No implementation of method: " (.methodk cache)
- " of protocol: " (:var (.protocol cache))
- " found for class: " (if (nil? x) "nil" (.getName (class x)))))))
- (set! (.__methodImplCache pf) (expand-method-impl-cache cache (class x) f))
- f))
-
(defn- emit-method-builder [on-interface method on-method arglists]
(let [methodk (keyword method)
gthis (with-meta (gensym) {:tag 'clojure.lang.AFunction})
2  src/jvm/clojure/lang/ArraySeq.java
View
@@ -29,7 +29,7 @@ static public ArraySeq create(Object... array){
return new ArraySeq(array, 0);
}
-static ISeq createFromObject(Object array){
+public static ISeq createFromObject(Object array){
if(array == null || Array.getLength(array) == 0)
return null;
Class aclass = array.getClass();

No commit comments for this range

Something went wrong with that request. Please try again.