diff options
Diffstat (limited to 'src/jvm')
35 files changed, 606 insertions, 614 deletions
diff --git a/src/jvm/clojure/lang/AFn.java b/src/jvm/clojure/lang/AFn.java index bf406969..e2646ade 100644 --- a/src/jvm/clojure/lang/AFn.java +++ b/src/jvm/clojure/lang/AFn.java @@ -12,7 +12,6 @@ package clojure.lang; -import java.util.Comparator; import java.io.Serializable; public abstract class AFn extends Obj implements IFn, Serializable{ @@ -174,273 +173,273 @@ static public Object applyToHelper(IFn ifn, ISeq arglist) throws Exception{ return ifn.invoke(arglist.first()); case 2: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() ); case 3: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 4: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 5: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 6: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 7: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 8: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 9: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 10: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 11: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 12: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 13: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 14: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 15: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 16: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 17: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 18: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 19: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); case 20: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() ); default: return ifn.invoke(arglist.first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , (arglist = arglist.rest()).first() - , RT.seqToArray(arglist.rest())); + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , (arglist = arglist.next()).first() + , RT.seqToArray(arglist.next())); } } diff --git a/src/jvm/clojure/lang/APersistentMap.java b/src/jvm/clojure/lang/APersistentMap.java index 4d8bc8f7..743f4480 100644 --- a/src/jvm/clojure/lang/APersistentMap.java +++ b/src/jvm/clojure/lang/APersistentMap.java @@ -44,7 +44,7 @@ public IPersistentCollection cons(Object o){ }
IPersistentMap ret = this;
- for(ISeq es = RT.seq(o); es != null; es = es.rest())
+ for(ISeq es = RT.seq(o); es != null; es = es.next())
{
Map.Entry e = (Map.Entry) es.first();
ret = ret.assoc(e.getKey(), e.getValue());
@@ -60,7 +60,7 @@ public boolean equals(Object obj){ if(m.size() != size() || m.hashCode() != hashCode())
return false;
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
Map.Entry e = (Map.Entry) s.first();
boolean found = m.containsKey(e.getKey());
@@ -80,7 +80,7 @@ public boolean equiv(Object obj){ if(m.size() != size())
return false;
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
Map.Entry e = (Map.Entry) s.first();
boolean found = m.containsKey(e.getKey());
@@ -96,7 +96,7 @@ public int hashCode(){ {
//int hash = count();
int hash = 0;
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
Map.Entry e = (Map.Entry) s.first();
hash += (e.getKey() == null ? 0 : e.getKey().hashCode()) ^
@@ -130,8 +130,8 @@ static public class KeySeq extends ASeq{ return ((Map.Entry) seq.first()).getKey();
}
- public ISeq rest(){
- return create(seq.rest());
+ public ISeq next(){
+ return create(seq.next());
}
public KeySeq withMeta(IPersistentMap meta){
@@ -161,8 +161,8 @@ static public class ValSeq extends ASeq{ return ((Map.Entry) seq.first()).getValue();
}
- public ISeq rest(){
- return create(seq.rest());
+ public ISeq next(){
+ return create(seq.next());
}
public ValSeq withMeta(IPersistentMap meta){
diff --git a/src/jvm/clojure/lang/APersistentSet.java b/src/jvm/clojure/lang/APersistentSet.java index 36063276..d6e815e9 100644 --- a/src/jvm/clojure/lang/APersistentSet.java +++ b/src/jvm/clojure/lang/APersistentSet.java @@ -80,7 +80,7 @@ public int hashCode(){ { //int hash = count(); int hash = 0; - for(ISeq s = seq(); s != null; s = s.rest()) + for(ISeq s = seq(); s != null; s = s.next()) { Object e = s.first(); // hash = Util.hashCombine(hash, Util.hash(e)); @@ -132,7 +132,7 @@ public Object[] toArray(Object[] a){ if(a.length >= count()) { ISeq s = seq(); - for(int i = 0; s != null; ++i, s = s.rest()) + for(int i = 0; s != null; ++i, s = s.next()) { a[i] = s.first(); } diff --git a/src/jvm/clojure/lang/APersistentVector.java b/src/jvm/clojure/lang/APersistentVector.java index 4cb753a8..a8017688 100644 --- a/src/jvm/clojure/lang/APersistentVector.java +++ b/src/jvm/clojure/lang/APersistentVector.java @@ -73,7 +73,7 @@ static boolean doEquals(IPersistentVector v, Object obj){ if(!(obj instanceof Sequential)) return false; ISeq ms = RT.seq(obj); - for(int i = 0; i < v.count(); i++, ms = ms.rest()) + for(int i = 0; i < v.count(); i++, ms = ms.next()) { if(ms == null || !Util.equals(v.nth(i), ms.first())) return false; @@ -116,7 +116,7 @@ static boolean doEquiv(IPersistentVector v, Object obj){ if(!(obj instanceof Sequential)) return false; ISeq ms = RT.seq(obj); - for(int i = 0; i < v.count(); i++, ms = ms.rest()) + for(int i = 0; i < v.count(); i++, ms = ms.next()) { if(ms == null || !Util.equiv(v.nth(i), ms.first())) return false; @@ -357,7 +357,7 @@ public Object[] toArray(Object[] a){ if(a.length >= count()) { ISeq s = seq(); - for(int i = 0; s != null; ++i, s = s.rest()) + for(int i = 0; s != null; ++i, s = s.next()) { a[i] = s.first(); } @@ -378,7 +378,7 @@ public boolean isEmpty(){ } public boolean contains(Object o){ - for(ISeq s = seq(); s != null; s = s.rest()) + for(ISeq s = seq(); s != null; s = s.next()) { if(Util.equiv(s.first(), o)) return true; @@ -438,7 +438,7 @@ public IStream stream() throws Exception { return v.nth(i); } - public ISeq rest(){ + public ISeq next(){ if(i + 1 < v.count()) return new APersistentVector.Seq(v, i + 1); return null; @@ -469,7 +469,7 @@ public IStream stream() throws Exception { ret = f.invoke(ret, v.nth(x)); return ret; } -} + } static class RSeq extends ASeq implements IndexedSeq{ final IPersistentVector v; @@ -490,7 +490,7 @@ static class RSeq extends ASeq implements IndexedSeq{ return v.nth(i); } - public ISeq rest(){ + public ISeq next(){ if(i > 0) return new APersistentVector.RSeq(v, i - 1); return null; diff --git a/src/jvm/clojure/lang/ARef.java b/src/jvm/clojure/lang/ARef.java index c165db9f..dd60752f 100644 --- a/src/jvm/clojure/lang/ARef.java +++ b/src/jvm/clojure/lang/ARef.java @@ -102,7 +102,7 @@ public abstract class ARef extends AReference implements IRef { if (ws != null) { ISeq args = new Cons(this, null); - for (ISeq s = RT.seq(ws); s != null; s = s.rest()) + for (ISeq s = RT.seq(ws); s != null; s = s.next()) { Map.Entry e = (Map.Entry) s.first(); Object[] a = (Object[]) e.getValue(); diff --git a/src/jvm/clojure/lang/ASeq.java b/src/jvm/clojure/lang/ASeq.java index 31faa021..fdd41c78 100644 --- a/src/jvm/clojure/lang/ASeq.java +++ b/src/jvm/clojure/lang/ASeq.java @@ -36,7 +36,7 @@ public boolean equiv(Object obj){ if(!(obj instanceof Sequential || obj instanceof List))
return false;
ISeq ms = RT.seq(obj);
- for(ISeq s = seq(); s != null; s = s.rest(), ms = ms.rest())
+ for(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())
{
if(ms == null || !Util.equiv(s.first(), ms.first()))
return false;
@@ -50,7 +50,7 @@ public boolean equals(Object obj){ if(!(obj instanceof Sequential || obj instanceof List))
return false;
ISeq ms = RT.seq(obj);
- for(ISeq s = seq(); s != null; s = s.rest(), ms = ms.rest())
+ for(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())
{
if(ms == null || !Util.equals(s.first(), ms.first()))
return false;
@@ -63,7 +63,7 @@ public int hashCode(){ if(_hash == -1)
{
int hash = 1;
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
hash = 31 * hash + (s.first() == null ? 0 : s.first().hashCode());
}
@@ -97,7 +97,7 @@ public int hashCode(){ public int count(){
int i = 1;
- for(ISeq s = rest(); s != null; s = s.rest(), i++)
+ for(ISeq s = next(); s != null; s = s.next(), i++)
;
return i;
}
@@ -111,9 +111,9 @@ public ISeq cons(Object o){ }
public Sequence more(){
- ISeq s = rest();
+ ISeq s = next();
if(s == null)
- return PersistentList.EMPTY;
+ return LazySeq.EMPTY;
return s;
}
@@ -167,7 +167,7 @@ public Object[] toArray(Object[] a){ if(a.length >= count())
{
ISeq s = seq();
- for(int i = 0; s != null; ++i, s = s.rest())
+ for(int i = 0; s != null; ++i, s = s.next())
{
a[i] = s.first();
}
@@ -188,7 +188,7 @@ public boolean isEmpty(){ }
public boolean contains(Object o){
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
if(Util.equiv(s.first(), o))
return true;
@@ -218,7 +218,7 @@ public IStream stream() throws Exception { if(s != null)
{
Object ret = s.first();
- s = s.rest();
+ s = s.next();
return ret;
}
return RT.eos();
@@ -245,7 +245,7 @@ public Object remove(int index){ public int indexOf(Object o){
ISeq s = seq();
- for(int i = 0; s != null; s = s.rest(), i++)
+ for(int i = 0; s != null; s = s.next(), i++)
{
if(Util.equiv(s.first(), o))
return i;
diff --git a/src/jvm/clojure/lang/ArraySeq.java b/src/jvm/clojure/lang/ArraySeq.java index bbe3b199..0373dd43 100644 --- a/src/jvm/clojure/lang/ArraySeq.java +++ b/src/jvm/clojure/lang/ArraySeq.java @@ -65,7 +65,7 @@ public Object first(){ return Reflector.prepRet(Array.get(array, i)); } -public ISeq rest(){ +public ISeq next(){ if(oa != null) { if(i + 1 < oa.length) @@ -138,7 +138,7 @@ static public class ArraySeq_int extends ASeq implements IndexedSeq, IReduce{ return array[i]; } - public ISeq rest(){ + public ISeq next(){ if(i + 1 < array.length) return new ArraySeq_int(meta(), array, i + 1); return null; @@ -186,7 +186,7 @@ static public class ArraySeq_float extends ASeq implements IndexedSeq, IReduce{ return array[i]; } - public ISeq rest(){ + public ISeq next(){ if(i + 1 < array.length) return new ArraySeq_float(meta(), array, i + 1); return null; @@ -233,7 +233,7 @@ static public class ArraySeq_double extends ASeq implements IndexedSeq, IReduce{ return array[i]; } - public ISeq rest(){ + public ISeq next(){ if(i + 1 < array.length) return new ArraySeq_double(meta(), array, i + 1); return null; @@ -280,7 +280,7 @@ static public class ArraySeq_long extends ASeq implements IndexedSeq, IReduce{ return array[i]; } - public ISeq rest(){ + public ISeq next(){ if(i + 1 < array.length) return new ArraySeq_long(meta(), array, i + 1); return null; diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java index b29876f7..820223bc 100644 --- a/src/jvm/clojure/lang/Compiler.java +++ b/src/jvm/clojure/lang/Compiler.java @@ -749,12 +749,12 @@ static public abstract class HostExpr implements Expr, MaybePrimitiveExpr{ } else { - ISeq call = (ISeq) ((RT.third(form) instanceof ISeq) ? RT.third(form) : RT.rest(RT.rest(form))); + ISeq call = (ISeq) ((RT.third(form) instanceof ISeq) ? RT.third(form) : RT.next(RT.next(form))); if(!(RT.first(call) instanceof Symbol)) throw new IllegalArgumentException("Malformed member expression"); Symbol sym = (Symbol) RT.first(call); PersistentVector args = PersistentVector.EMPTY; - for(ISeq s = RT.rest(call); s != null; s = s.rest()) + for(ISeq s = RT.next(call); s != null; s = s.next()) args = args.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, s.first())); if(c != null) return new StaticMethodExpr(source, line, c, sym.name, args); @@ -1804,7 +1804,7 @@ public static class TryExpr implements Expr{ int retLocal = getAndIncLocalNum(); int finallyLocal = getAndIncLocalNum(); - for(ISeq fs = form.rest(); fs != null; fs = fs.rest()) + for(ISeq fs = form.next(); fs != null; fs = fs.next()) { Object f = fs.first(); Object op = (f instanceof ISeq) ? ((ISeq) f).first() : null; @@ -1837,7 +1837,7 @@ public static class TryExpr implements Expr{ LocalBinding lb = registerLocal(sym, (Symbol) (RT.second(f) instanceof Symbol ? RT.second(f) : null), null); - Expr handler = (new BodyExpr.Parser()).parse(context, RT.rest(RT.rest(RT.rest(f)))); + Expr handler = (new BodyExpr.Parser()).parse(context, RT.next(RT.next(RT.next(f)))); catches = catches.cons(new CatchClause(c, lb, handler)); } finally @@ -1848,12 +1848,12 @@ public static class TryExpr implements Expr{ } else //finally { - if(fs.rest() != null) + if(fs.next() != null) throw new Exception("finally clause must be last in try expression"); try { Var.pushThreadBindings(RT.map(IN_CATCH_FINALLY, RT.T)); - finallyExpr = (new BodyExpr.Parser()).parse(C.STATEMENT, RT.rest(f)); + finallyExpr = (new BodyExpr.Parser()).parse(C.STATEMENT, RT.next(f)); } finally { @@ -2026,7 +2026,7 @@ static int getMatchingParams(String methodName, ArrayList<Class[]> paramlists, I { boolean match = true; ISeq aseq = argexprs.seq(); - for(int p = 0; match && p < argexprs.count() && aseq != null; ++p, aseq = aseq.rest()) + for(int p = 0; match && p < argexprs.count() && aseq != null; ++p, aseq = aseq.next()) { Expr arg = (Expr) aseq.first(); Class aclass = arg.hasJavaClass() ? arg.getJavaClass() : Object.class; @@ -2162,7 +2162,7 @@ public static class NewExpr implements Expr{ if(c == null) throw new IllegalArgumentException("Unable to resolve classname: " + RT.second(form)); PersistentVector args = PersistentVector.EMPTY; - for(ISeq s = RT.rest(RT.rest(form)); s != null; s = s.rest()) + for(ISeq s = RT.next(RT.next(form)); s != null; s = s.next()) args = args.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, s.first())); return new NewExpr(c, args, line); } @@ -2562,7 +2562,7 @@ public static class MapExpr implements Expr{ static public Expr parse(C context, IPersistentMap form) throws Exception{ IPersistentVector keyvals = PersistentVector.EMPTY; - for(ISeq s = RT.seq(form); s != null; s = s.rest()) + for(ISeq s = RT.seq(form); s != null; s = s.next()) { IMapEntry e = (IMapEntry) s.first(); keyvals = (IPersistentVector) keyvals.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, e.key())); @@ -2611,7 +2611,7 @@ public static class SetExpr implements Expr{ static public Expr parse(C context, IPersistentSet form) throws Exception{ IPersistentVector keys = PersistentVector.EMPTY; - for(ISeq s = RT.seq(form); s != null; s = s.rest()) + for(ISeq s = RT.seq(form); s != null; s = s.next()) { Object e = s.first(); keys = (IPersistentVector) keys.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, e)); @@ -2747,7 +2747,7 @@ static class InvokeExpr implements Expr{ context = C.EXPRESSION; Expr fexpr = analyze(context, form.first()); PersistentVector args = PersistentVector.EMPTY; - for(ISeq s = RT.seq(form.rest()); s != null; s = s.rest()) + for(ISeq s = RT.seq(form.next()); s != null; s = s.next()) { args = args.cons(analyze(context, s.first())); } @@ -2929,17 +2929,17 @@ static public class FnExpr implements Expr{ if(RT.second(form) instanceof Symbol) { fn.thisName = ((Symbol) RT.second(form)).name; - form = RT.cons(FN, RT.rest(RT.rest(form))); + form = RT.cons(FN, RT.next(RT.next(form))); } //now (fn [args] body...) or (fn ([args] body...) ([args2] body2...) ...) //turn former into latter if(RT.second(form) instanceof IPersistentVector) - form = RT.list(FN, RT.rest(form)); + form = RT.list(FN, RT.next(form)); fn.line = (Integer) LINE.get(); FnMethod[] methodArray = new FnMethod[MAX_POSITIONAL_ARITY + 1]; FnMethod variadicMethod = null; - for(ISeq s = RT.rest(form); s != null; s = RT.rest(s)) + for(ISeq s = RT.next(form); s != null; s = RT.next(s)) { FnMethod f = FnMethod.parse(fn, (ISeq) RT.first(s)); if(f.isVariadic()) @@ -2994,7 +2994,7 @@ static public class FnExpr implements Expr{ if(closes.count() == 0) return ARG_TYPES[0]; PersistentVector tv = PersistentVector.EMPTY; - for(ISeq s = RT.keys(closes); s != null; s = s.rest()) + for(ISeq s = RT.keys(closes); s != null; s = s.next()) { LocalBinding lb = (LocalBinding) s.first(); if(lb.getPrimitiveType() != null) @@ -3089,7 +3089,7 @@ static public class FnExpr implements Expr{ clinitgen.endMethod(); // clinitgen.visitMaxs(1, 1); //instance fields for closed-overs - for(ISeq s = RT.keys(closes); s != null; s = s.rest()) + for(ISeq s = RT.keys(closes); s != null; s = s.next()) { LocalBinding lb = (LocalBinding) s.first(); if(lb.getPrimitiveType() != null) @@ -3124,7 +3124,7 @@ static public class FnExpr implements Expr{ else ctorgen.invokeConstructor(aFnType, afnctor); int a = 1; - for(ISeq s = RT.keys(closes); s != null; s = s.rest(), ++a) + for(ISeq s = RT.keys(closes); s != null; s = s.next(), ++a) { LocalBinding lb = (LocalBinding) s.first(); ctorgen.loadThis(); @@ -3164,7 +3164,7 @@ static public class FnExpr implements Expr{ ctorgen.endMethod(); //override of invoke/doInvoke for each method - for(ISeq s = RT.seq(methods); s != null; s = s.rest()) + for(ISeq s = RT.seq(methods); s != null; s = s.next()) { FnMethod method = (FnMethod) s.first(); method.emit(this, cv); @@ -3227,7 +3227,7 @@ static public class FnExpr implements Expr{ void emitClearCloses(GeneratorAdapter gen){ int a = 1; - for(ISeq s = RT.keys(closes); s != null; s = s.rest(), ++a) + for(ISeq s = RT.keys(closes); s != null; s = s.next(), ++a) { LocalBinding lb = (LocalBinding) s.first(); Class primc = lb.getPrimitiveType(); @@ -3269,7 +3269,7 @@ static public class FnExpr implements Expr{ getCompiledClass(); gen.newInstance(fntype); gen.dup(); - for(ISeq s = RT.keys(closes); s != null; s = s.rest()) + for(ISeq s = RT.keys(closes); s != null; s = s.next()) { LocalBinding lb = (LocalBinding) s.first(); if(lb.getPrimitiveType() != null) @@ -3443,7 +3443,7 @@ public static class FnMethod{ private static FnMethod parse(FnExpr fn, ISeq form) throws Exception{ //([args] body...) IPersistentVector parms = (IPersistentVector) RT.first(form); - ISeq body = RT.rest(form); + ISeq body = RT.next(form); try { FnMethod method = new FnMethod(fn, (FnMethod) METHOD.get()); @@ -3527,7 +3527,7 @@ public static class FnMethod{ body.emit(C.RETURN, fn, gen); Label end = gen.mark(); gen.visitLocalVariable("this", "Ljava/lang/Object;", null, loopLabel, end, 0); - for(ISeq lbs = argLocals.seq(); lbs != null; lbs = lbs.rest()) + for(ISeq lbs = argLocals.seq(); lbs != null; lbs = lbs.next()) { LocalBinding lb = (LocalBinding) lbs.first(); gen.visitLocalVariable(lb.name, "Ljava/lang/Object;", null, loopLabel, end, lb.idx); @@ -3661,12 +3661,12 @@ public static class BodyExpr implements Expr{ public Expr parse(C context, Object frms) throws Exception{ ISeq forms = (ISeq) frms; if(Util.equals(RT.first(forms), DO)) - forms = RT.rest(forms); + forms = RT.next(forms); PersistentVector exprs = PersistentVector.EMPTY; - for(; forms != null; forms = forms.rest()) + for(; forms != null; forms = forms.next()) { Expr e = (context != C.EVAL && - (context == C.STATEMENT || forms.rest() != null)) ? + (context == C.STATEMENT || forms.next() != null)) ? analyze(C.STATEMENT, forms.first()) : analyze(context, forms.first()); @@ -3752,7 +3752,7 @@ public static class LetExpr implements Expr{ if((bindings.count() % 2) != 0) throw new IllegalArgumentException("Bad binding form, expected matched symbol expression pairs"); - ISeq body = RT.rest(RT.rest(form)); + ISeq body = RT.next(RT.next(form)); if(context == C.EVAL || (context == C.EXPRESSION && isLoop)) @@ -3835,7 +3835,7 @@ public static class LetExpr implements Expr{ body.emit(context, fn, gen); Label end = gen.mark(); // gen.visitLocalVariable("this", "Ljava/lang/Object;", null, loopLabel, end, 0); - for(ISeq bis = bindingInits.seq(); bis != null; bis = bis.rest()) + for(ISeq bis = bindingInits.seq(); bis != null; bis = bis.next()) { BindingInit bi = (BindingInit) bis.first(); String lname = bi.binding.name; @@ -3931,7 +3931,7 @@ public static class RecurExpr implements Expr{ if(IN_CATCH_FINALLY.get() != null) throw new UnsupportedOperationException("Cannot recur from catch/finally"); PersistentVector args = PersistentVector.EMPTY; - for(ISeq s = RT.seq(form.rest()); s != null; s = s.rest()) + for(ISeq s = RT.seq(form.next()); s != null; s = s.next()) { args = args.cons(analyze(C.EXPRESSION, s.first())); } @@ -4090,7 +4090,7 @@ public static Object macroexpand1(Object x) throws Exception{ try { Var.pushThreadBindings(RT.map(RT.MACRO_META, RT.meta(form))); - return v.applyTo(form.rest()); + return v.applyTo(form.next()); } finally { @@ -4115,7 +4115,7 @@ public static Object macroexpand1(Object x) throws Exception{ { target = RT.list(IDENTITY, target); } - return RT.listStar(DOT, target, meth, form.rest().rest()); + return RT.listStar(DOT, target, meth, form.next().next()); } else if(namesStaticMember(sym)) { @@ -4124,7 +4124,7 @@ public static Object macroexpand1(Object x) throws Exception{ if(c != null) { Symbol meth = Symbol.intern(sym.name); - return RT.listStar(DOT, target, meth, form.rest()); + return RT.listStar(DOT, target, meth, form.next()); } } else @@ -4141,7 +4141,7 @@ public static Object macroexpand1(Object x) throws Exception{ //(StringBuilder. "foo") => (new StringBuilder "foo") //else if(idx == sname.length() - 1) - return RT.listStar(NEW, Symbol.intern(sname.substring(0, idx)), form.rest()); + return RT.listStar(NEW, Symbol.intern(sname.substring(0, idx)), form.next()); } } } @@ -4164,9 +4164,9 @@ private static Expr analyzeSeq(C context, ISeq form, String name) throws Excepti Object op = RT.first(form); if(op == null) throw new IllegalArgumentException("Can't call nil"); - IFn inline = isInline(op, RT.count(RT.rest(form))); + IFn inline = isInline(op, RT.count(RT.next(form))); if(inline != null) - return analyze(context, inline.applyTo(RT.rest(form))); + return analyze(context, inline.applyTo(RT.next(form))); IParser p; if(op.equals(FN)) return FnExpr.parse(context, form, name); diff --git a/src/jvm/clojure/lang/Cons.java b/src/jvm/clojure/lang/Cons.java index a7fb5c09..9606094e 100644 --- a/src/jvm/clojure/lang/Cons.java +++ b/src/jvm/clojure/lang/Cons.java @@ -33,13 +33,13 @@ public Object first(){ return _first; } -public ISeq rest(){ +public ISeq next(){ return more().seq(); } public Sequence more(){ if(_more == null) - return PersistentList.EMPTY; + return LazySeq.EMPTY; return _more; } diff --git a/src/jvm/clojure/lang/Delay.java b/src/jvm/clojure/lang/Delay.java index 53569e43..cfaad693 100644 --- a/src/jvm/clojure/lang/Delay.java +++ b/src/jvm/clojure/lang/Delay.java @@ -56,7 +56,7 @@ public class Delay { public int count() { int c = 0; - for (ISeq s = seq(); s != null; s = s.rest()) + for (ISeq s = seq(); s != null; s = s.next()) ++c; return c; } @@ -127,7 +127,7 @@ public class Delay { if (a.length >= count()) { ISeq s = seq(); - for (int i = 0; s != null; ++i, s = s.rest()) + for (int i = 0; s != null; ++i, s = s.next()) { a[i] = s.first(); } @@ -148,7 +148,7 @@ public class Delay { } public boolean contains(Object o) { - for (ISeq s = seq(); s != null; s = s.rest()) + for (ISeq s = seq(); s != null; s = s.next()) { if (Util.equiv(s.first(), o)) return true; @@ -179,7 +179,7 @@ public class Delay { public int indexOf(Object o) { ISeq s = seq(); - for (int i = 0; s != null; s = s.rest(), i++) + for (int i = 0; s != null; s = s.next(), i++) { if (Util.equiv(s.first(), o)) return i; diff --git a/src/jvm/clojure/lang/EnumerationSeq.java b/src/jvm/clojure/lang/EnumerationSeq.java index 7c579651..33485e40 100644 --- a/src/jvm/clojure/lang/EnumerationSeq.java +++ b/src/jvm/clojure/lang/EnumerationSeq.java @@ -18,7 +18,7 @@ public class EnumerationSeq extends ASeq{ final Enumeration iter; final State state; -static class State{ + static class State{ volatile Object val; volatile Object _rest; } @@ -52,7 +52,7 @@ public Object first(){ return state.val; } -public ISeq rest(){ +public ISeq next(){ if(state._rest == state) synchronized(state) { diff --git a/src/jvm/clojure/lang/ISeq.java b/src/jvm/clojure/lang/ISeq.java index e608bbf7..6637b0bf 100644 --- a/src/jvm/clojure/lang/ISeq.java +++ b/src/jvm/clojure/lang/ISeq.java @@ -20,7 +20,7 @@ public interface ISeq extends Sequence{ Object first();
-ISeq rest();
+ISeq next();
Sequence more();
diff --git a/src/jvm/clojure/lang/IteratorSeq.java b/src/jvm/clojure/lang/IteratorSeq.java index 4a5ab80c..a510d53f 100644 --- a/src/jvm/clojure/lang/IteratorSeq.java +++ b/src/jvm/clojure/lang/IteratorSeq.java @@ -16,7 +16,7 @@ public class IteratorSeq extends ASeq{ final Iterator iter;
final State state;
-static class State{
+ static class State{
volatile Object val;
volatile Object _rest;
}
@@ -50,7 +50,7 @@ public Object first(){ return state.val;
}
-public ISeq rest(){
+public ISeq next(){
if(state._rest == state)
synchronized(state)
{
diff --git a/src/jvm/clojure/lang/LazyCons.java b/src/jvm/clojure/lang/LazyCons.java index ee60a891..515cd2e9 100644 --- a/src/jvm/clojure/lang/LazyCons.java +++ b/src/jvm/clojure/lang/LazyCons.java @@ -49,7 +49,7 @@ public Object first(){ final synchronized -public ISeq rest(){ +public ISeq next(){ if(_rest == sentinel) { try @@ -72,7 +72,7 @@ public LazyCons withMeta(IPersistentMap meta){ if(meta == meta()) return this; //force before copying - rest(); + next(); return new LazyCons(meta, _first, _rest); } } diff --git a/src/jvm/clojure/lang/LazySeq.java b/src/jvm/clojure/lang/LazySeq.java index f06faed5..05d8f030 100644 --- a/src/jvm/clojure/lang/LazySeq.java +++ b/src/jvm/clojure/lang/LazySeq.java @@ -16,8 +16,17 @@ import java.util.*; public class LazySeq extends AFn implements List, Sequence { static final ISeq DUMMY = new Cons(null, null); + static final LazySeq EMPTY = new LazySeq(null); - private ISeq s = DUMMY; + private ISeq s; + + public LazySeq() { + this(DUMMY); + } + + LazySeq(ISeq s) { + this.s = s; + } final synchronized public ISeq seq() { if(s == DUMMY) @@ -36,7 +45,7 @@ public class LazySeq extends AFn implements List, Sequence { public int count() { int c = 0; - for (ISeq s = seq(); s != null; s = s.rest()) + for (ISeq s = seq(); s != null; s = s.next()) ++c; return c; } @@ -107,7 +116,7 @@ public class LazySeq extends AFn implements List, Sequence { if (a.length >= count()) { ISeq s = seq(); - for (int i = 0; s != null; ++i, s = s.rest()) + for (int i = 0; s != null; ++i, s = s.next()) { a[i] = s.first(); } @@ -128,7 +137,7 @@ public class LazySeq extends AFn implements List, Sequence { } public boolean contains(Object o) { - for (ISeq s = seq(); s != null; s = s.rest()) + for (ISeq s = seq(); s != null; s = s.next()) { if (Util.equiv(s.first(), o)) return true; @@ -159,7 +168,7 @@ public class LazySeq extends AFn implements List, Sequence { public int indexOf(Object o) { ISeq s = seq(); - for (int i = 0; s != null; s = s.rest(), i++) + for (int i = 0; s != null; s = s.next(), i++) { if (Util.equiv(s.first(), o)) return i; diff --git a/src/jvm/clojure/lang/LispReader.java b/src/jvm/clojure/lang/LispReader.java index 49400339..ecca2b32 100644 --- a/src/jvm/clojure/lang/LispReader.java +++ b/src/jvm/clojure/lang/LispReader.java @@ -744,7 +744,7 @@ public static class SyntaxQuoteReader extends AFn{ private static ISeq sqExpandList(ISeq seq) throws Exception{
PersistentVector ret = PersistentVector.EMPTY;
- for(; seq != null; seq = seq.rest())
+ for(; seq != null; seq = seq.next())
{
Object item = seq.first();
if(isUnquote(item))
@@ -759,7 +759,7 @@ public static class SyntaxQuoteReader extends AFn{ private static IPersistentVector flattenMap(Object form){
IPersistentVector keyvals = PersistentVector.EMPTY;
- for(ISeq s = RT.seq(form); s != null; s = s.rest())
+ for(ISeq s = RT.seq(form); s != null; s = s.next())
{
IMapEntry e = (IMapEntry) s.first();
keyvals = (IPersistentVector) keyvals.cons(e.key());
@@ -915,18 +915,18 @@ public static class EvalReader extends AFn{ }
if(fs.name.endsWith("."))
{
- Object[] args = RT.toArray(RT.rest(o));
+ Object[] args = RT.toArray(RT.next(o));
return Reflector.invokeConstructor(RT.classForName(fs.name.substring(0, fs.name.length() - 1)), args);
}
if(Compiler.namesStaticMember(fs))
{
- Object[] args = RT.toArray(RT.rest(o));
+ Object[] args = RT.toArray(RT.next(o));
return Reflector.invokeStaticMethod(fs.ns, fs.name, args);
}
Object v = Compiler.maybeResolveIn(Compiler.currentNS(), fs);
if(v instanceof Var)
{
- return ((IFn) v).applyTo(RT.rest(o));
+ return ((IFn) v).applyTo(RT.next(o));
}
throw new Exception("Can't resolve " + fs);
}
diff --git a/src/jvm/clojure/lang/MultiFn.java b/src/jvm/clojure/lang/MultiFn.java index bb818da4..f144a59d 100644 --- a/src/jvm/clojure/lang/MultiFn.java +++ b/src/jvm/clojure/lang/MultiFn.java @@ -65,12 +65,12 @@ private boolean prefers(Object x, Object y) throws Exception{ IPersistentSet xprefs = (IPersistentSet) getPreferTable().valAt(x); if(xprefs != null && xprefs.contains(y)) return true; - for(ISeq ps = RT.seq(parents.invoke(y)); ps != null; ps = ps.rest()) + for(ISeq ps = RT.seq(parents.invoke(y)); ps != null; ps = ps.next()) { if(prefers(x, ps.first())) return true; } - for(ISeq ps = RT.seq(parents.invoke(x)); ps != null; ps = ps.rest()) + for(ISeq ps = RT.seq(parents.invoke(x)); ps != null; ps = ps.next()) { if(prefers(ps.first(), y)) return true; diff --git a/src/jvm/clojure/lang/Numbers.java b/src/jvm/clojure/lang/Numbers.java index 4a49c8cb..c1f2b830 100644 --- a/src/jvm/clojure/lang/Numbers.java +++ b/src/jvm/clojure/lang/Numbers.java @@ -15,12 +15,6 @@ package clojure.lang; import java.math.BigInteger; import java.math.BigDecimal; import java.math.MathContext; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.LinkedList; -import java.util.Arrays; public class Numbers{ @@ -1422,7 +1416,7 @@ static BitOps bitOps(Object x){ else { ISeq s = RT.seq(init); - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).floatValue(); } return ret; @@ -1436,7 +1430,7 @@ static BitOps bitOps(Object x){ ISeq s = RT.seq(sizeOrSeq); int size = s.count(); float[] ret = new float[size]; - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).floatValue(); return ret; } @@ -1453,7 +1447,7 @@ static public double[] double_array(int size, Object init){ else { ISeq s = RT.seq(init); - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).doubleValue(); } return ret; @@ -1467,7 +1461,7 @@ static public double[] double_array(Object sizeOrSeq){ ISeq s = RT.seq(sizeOrSeq); int size = s.count(); double[] ret = new double[size]; - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).doubleValue(); return ret; } @@ -1484,7 +1478,7 @@ static public int[] int_array(int size, Object init){ else { ISeq s = RT.seq(init); - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).intValue(); } return ret; @@ -1498,7 +1492,7 @@ static public int[] int_array(Object sizeOrSeq){ ISeq s = RT.seq(sizeOrSeq); int size = s.count(); int[] ret = new int[size]; - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).intValue(); return ret; } @@ -1515,7 +1509,7 @@ static public long[] long_array(int size, Object init){ else { ISeq s = RT.seq(init); - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).longValue(); } return ret; @@ -1529,7 +1523,7 @@ static public long[] long_array(Object sizeOrSeq){ ISeq s = RT.seq(sizeOrSeq); int size = s.count(); long[] ret = new long[size]; - for(int i = 0; i < size && s != null; i++, s = s.rest()) + for(int i = 0; i < size && s != null; i++, s = s.next()) ret[i] = ((Number) s.first()).longValue(); return ret; } diff --git a/src/jvm/clojure/lang/PersistentArrayMap.java b/src/jvm/clojure/lang/PersistentArrayMap.java index d8fbd354..6f212b9b 100644 --- a/src/jvm/clojure/lang/PersistentArrayMap.java +++ b/src/jvm/clojure/lang/PersistentArrayMap.java @@ -216,7 +216,7 @@ static class Seq extends ASeq{ return new MapEntry(array[i],array[i+1]);
}
- public ISeq rest(){
+ public ISeq next(){
if(i + 2 < array.length)
return new Seq(array, i + 2);
return null;
diff --git a/src/jvm/clojure/lang/PersistentHashMap.java b/src/jvm/clojure/lang/PersistentHashMap.java index d696cd5a..0705ffd7 100644 --- a/src/jvm/clojure/lang/PersistentHashMap.java +++ b/src/jvm/clojure/lang/PersistentHashMap.java @@ -93,9 +93,9 @@ public static PersistentHashMap create(List init){ static public PersistentHashMap create(ISeq items){ IPersistentMap ret = EMPTY; - for(; items != null; items = items.rest().rest()) + for(; items != null; items = items.next().next()) { - if(items.rest() == null) + if(items.next() == null) throw new IllegalArgumentException(String.format("No value supplied for key: %s", items.first())); ret = ret.assoc(items.first(), RT.second(items)); } @@ -349,8 +349,8 @@ final static class FullNode implements INode{ return s.first(); } - public ISeq rest(){ - ISeq nexts = s.rest(); + public ISeq next(){ + ISeq nexts = s.next(); if(nexts != null) return new Seq(nexts, i, node); return create(node, i + 1); @@ -359,7 +359,7 @@ final static class FullNode implements INode{ public Seq withMeta(IPersistentMap meta){ return new Seq(meta, s, i, node); } - } + } } @@ -507,8 +507,8 @@ final static class BitmapIndexedNode implements INode{ return s.first(); } - public ISeq rest(){ - ISeq nexts = s.rest(); + public ISeq next(){ + ISeq nexts = s.next(); if(nexts != null) return new Seq(nexts, i, node); return create(node, i + 1); @@ -517,7 +517,7 @@ final static class BitmapIndexedNode implements INode{ public Seq withMeta(IPersistentMap meta){ return new Seq(meta, s, i, node); } - } + } } diff --git a/src/jvm/clojure/lang/PersistentHashSet.java b/src/jvm/clojure/lang/PersistentHashSet.java index a06b826c..35c6fa95 100644 --- a/src/jvm/clojure/lang/PersistentHashSet.java +++ b/src/jvm/clojure/lang/PersistentHashSet.java @@ -13,8 +13,6 @@ package clojure.lang; import java.util.List; -import java.util.Iterator; -import java.util.Collection; public class PersistentHashSet extends APersistentSet{ @@ -40,7 +38,7 @@ public static PersistentHashSet create(List init){ static public PersistentHashSet create(ISeq items){ PersistentHashSet ret = EMPTY; - for(; items != null; items = items.rest()) + for(; items != null; items = items.next()) { ret = (PersistentHashSet) ret.cons(items.first()); } diff --git a/src/jvm/clojure/lang/PersistentList.java b/src/jvm/clojure/lang/PersistentList.java index fabe5e1e..f6efd69a 100644 --- a/src/jvm/clojure/lang/PersistentList.java +++ b/src/jvm/clojure/lang/PersistentList.java @@ -29,7 +29,7 @@ public static IFn creator = new RestFn(0){ return ret;
}
LinkedList list = new LinkedList();
- for(ISeq s = RT.seq(args); s != null; s = s.rest())
+ for(ISeq s = RT.seq(args); s != null; s = s.next())
list.add(s.first());
return create(list);
}
@@ -64,7 +64,7 @@ public Object first(){ return _first;
}
-public ISeq rest(){
+public ISeq next(){
if(_count == 1)
return null;
return (ISeq) _rest;
@@ -100,21 +100,20 @@ public PersistentList withMeta(IPersistentMap meta){ public Object reduce(IFn f) throws Exception{
Object ret = first();
- for(ISeq s = rest(); s != null; s = s.rest())
+ for(ISeq s = next(); s != null; s = s.next())
ret = f.invoke(ret, s.first());
return ret;
}
public Object reduce(IFn f, Object start) throws Exception{
Object ret = f.invoke(start, first());
- for(ISeq s = rest(); s != null; s = s.rest())
+ for(ISeq s = next(); s != null; s = s.next())
ret = f.invoke(ret, s.first());
return ret;
}
-
-static class EmptyList extends Obj implements IPersistentList, List, Sequence{
+ static class EmptyList extends Obj implements IPersistentList, List, Sequence{
public int hashCode(){
return 1;
@@ -249,7 +248,7 @@ static class EmptyList extends Obj implements IPersistentList, List, Sequence{ public int indexOf(Object o){
ISeq s = seq();
- for(int i = 0; s != null; s = s.rest(), i++)
+ for(int i = 0; s != null; s = s.next(), i++)
{
if(Util.equiv(s.first(), o))
return i;
diff --git a/src/jvm/clojure/lang/PersistentQueue.java b/src/jvm/clojure/lang/PersistentQueue.java index 552cdb42..655b3e41 100644 --- a/src/jvm/clojure/lang/PersistentQueue.java +++ b/src/jvm/clojure/lang/PersistentQueue.java @@ -42,12 +42,12 @@ public boolean equiv(Object obj){ if(!(obj instanceof Sequential))
return false;
ISeq ms = RT.seq(obj);
- for(ISeq s = seq(); s != null; s = s.rest(), ms = ms.rest())
+ for(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())
{
if(ms == null || !Util.equiv(s.first(), ms.first()))
return false;
}
- return ms.rest() == null;
+ return ms.next() == null;
}
@@ -56,12 +56,12 @@ public boolean equals(Object obj){ if(!(obj instanceof Sequential))
return false;
ISeq ms = RT.seq(obj);
- for(ISeq s = seq(); s != null; s = s.rest(), ms = ms.rest())
+ for(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())
{
if(ms == null || !Util.equals(s.first(), ms.first()))
return false;
}
- return ms.rest() == null;
+ return ms.next() == null;
}
@@ -69,7 +69,7 @@ public int hashCode(){ if(_hash == -1)
{
int hash = 0;
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
hash = Util.hashCombine(hash, Util.hash(s.first()));
}
@@ -86,7 +86,7 @@ public PersistentQueue pop(){ if(f == null) //hmmm... pop of empty queue -> empty queue?
return this;
//throw new IllegalStateException("popping empty queue");
- ISeq f1 = f.rest();
+ ISeq f1 = f.next();
PersistentVector r1 = r;
if(f1 == null)
{
@@ -140,8 +140,8 @@ static class Seq extends ASeq{ return f.first();
}
- public ISeq rest(){
- ISeq f1 = f.rest();
+ public ISeq next(){
+ ISeq f1 = f.next();
ISeq r1 = rseq;
if(f1 == null)
{
@@ -205,7 +205,7 @@ public Object[] toArray(Object[] a){ if(a.length >= count())
{
ISeq s = seq();
- for(int i = 0; s != null; ++i, s = s.rest())
+ for(int i = 0; s != null; ++i, s = s.next())
{
a[i] = s.first();
}
@@ -226,7 +226,7 @@ public boolean isEmpty(){ }
public boolean contains(Object o){
- for(ISeq s = seq(); s != null; s = s.rest())
+ for(ISeq s = seq(); s != null; s = s.next())
{
if(Util.equiv(s.first(), o))
return true;
diff --git a/src/jvm/clojure/lang/PersistentStructMap.java b/src/jvm/clojure/lang/PersistentStructMap.java index 01e86346..3ce43073 100644 --- a/src/jvm/clojure/lang/PersistentStructMap.java +++ b/src/jvm/clojure/lang/PersistentStructMap.java @@ -37,7 +37,7 @@ static public Def createSlotMap(ISeq keys){ throw new IllegalArgumentException("Must supply keys"); PersistentHashMap ret = PersistentHashMap.EMPTY; int i = 0; - for(ISeq s = keys; s != null; s = s.rest(), i++) + for(ISeq s = keys; s != null; s = s.next(), i++) { ret = (PersistentHashMap) ret.assoc(s.first(), i); } @@ -47,9 +47,9 @@ static public Def createSlotMap(ISeq keys){ static public PersistentStructMap create(Def def, ISeq keyvals){ Object[] vals = new Object[def.keyslots.count()]; IPersistentMap ext = PersistentHashMap.EMPTY; - for(; keyvals != null; keyvals = keyvals.rest().rest()) + for(; keyvals != null; keyvals = keyvals.next().next()) { - if(keyvals.rest() == null) + if(keyvals.next() == null) throw new IllegalArgumentException(String.format("No value supplied for key: %s", keyvals.first())); Object k = keyvals.first(); Object v = RT.second(keyvals); @@ -65,7 +65,7 @@ static public PersistentStructMap create(Def def, ISeq keyvals){ static public PersistentStructMap construct(Def def, ISeq valseq){ Object[] vals = new Object[def.keyslots.count()]; IPersistentMap ext = PersistentHashMap.EMPTY; - for(int i = 0; i < vals.length && valseq != null; valseq = valseq.rest(), i++) + for(int i = 0; i < vals.length && valseq != null; valseq = valseq.next(), i++) { vals[i] = valseq.first(); } @@ -216,9 +216,9 @@ static class Seq extends ASeq{ return new MapEntry(keys.first(), vals[i]); } - public ISeq rest(){ + public ISeq next(){ if(i + 1 < vals.length) - return new Seq(_meta, keys.rest(), vals, i + 1, ext); + return new Seq(_meta, keys.next(), vals, i + 1, ext); return ext.seq(); } } diff --git a/src/jvm/clojure/lang/PersistentTreeMap.java b/src/jvm/clojure/lang/PersistentTreeMap.java index 1cd40969..5a5a9bee 100644 --- a/src/jvm/clojure/lang/PersistentTreeMap.java +++ b/src/jvm/clojure/lang/PersistentTreeMap.java @@ -69,9 +69,9 @@ PersistentTreeMap(IPersistentMap meta, Comparator comp, Node tree, int _count){ static public PersistentTreeMap create(ISeq items){ IPersistentMap ret = EMPTY; - for(; items != null; items = items.rest().rest()) + for(; items != null; items = items.next().next()) { - if(items.rest() == null) + if(items.next() == null) throw new IllegalArgumentException(String.format("No value supplied for key: %s", items.first())); ret = ret.assoc(items.first(), RT.second(items)); } @@ -80,9 +80,9 @@ static public PersistentTreeMap create(ISeq items){ static public PersistentTreeMap create(Comparator comp, ISeq items){ IPersistentMap ret = new PersistentTreeMap(comp); - for(; items != null; items = items.rest().rest()) + for(; items != null; items = items.next().next()) { - if(items.rest() == null) + if(items.next() == null) throw new IllegalArgumentException(String.format("No value supplied for key: %s", items.first())); ret = ret.assoc(items.first(), RT.second(items)); } @@ -781,9 +781,9 @@ static public class Seq extends ASeq{ return stack.first(); } - public ISeq rest(){ + public ISeq next(){ Node t = (Node) stack.first(); - ISeq nextstack = push(asc ? t.right() : t.left(), stack.rest(), asc); + ISeq nextstack = push(asc ? t.right() : t.left(), stack.next(), asc); if(nextstack != null) { return new Seq(nextstack, asc, cnt - 1); diff --git a/src/jvm/clojure/lang/PersistentTreeSet.java b/src/jvm/clojure/lang/PersistentTreeSet.java index 3fca1c68..f6f50125 100644 --- a/src/jvm/clojure/lang/PersistentTreeSet.java +++ b/src/jvm/clojure/lang/PersistentTreeSet.java @@ -13,9 +13,7 @@ package clojure.lang; import java.util.List; -import java.util.Iterator; import java.util.Comparator; -import java.util.Collection; public class PersistentTreeSet extends APersistentSet implements Reversible, Sorted{ static public final PersistentTreeSet EMPTY = new PersistentTreeSet(null, PersistentTreeMap.EMPTY); @@ -40,7 +38,7 @@ public static PersistentTreeSet create(List init){ static public PersistentTreeSet create(ISeq items){ PersistentTreeSet ret = EMPTY; - for(; items != null; items = items.rest()) + for(; items != null; items = items.next()) { ret = (PersistentTreeSet) ret.cons(items.first()); } diff --git a/src/jvm/clojure/lang/PersistentVector.java b/src/jvm/clojure/lang/PersistentVector.java index 2a0256f1..9b8e40da 100644 --- a/src/jvm/clojure/lang/PersistentVector.java +++ b/src/jvm/clojure/lang/PersistentVector.java @@ -37,7 +37,6 @@ package clojure.lang; import java.util.List; -import java.util.Collection; public class PersistentVector extends APersistentVector{ final int cnt; @@ -50,7 +49,7 @@ public final static PersistentVector EMPTY = new PersistentVector(0, 5, RT.EMPTY static public PersistentVector create(ISeq items){ PersistentVector ret = EMPTY; - for(; items != null; items = items.rest()) + for(; items != null; items = items.next()) ret = ret.cons(items.first()); return ret; } diff --git a/src/jvm/clojure/lang/RT.java b/src/jvm/clojure/lang/RT.java index ab7e7938..1c8b30f5 100644 --- a/src/jvm/clojure/lang/RT.java +++ b/src/jvm/clojure/lang/RT.java @@ -560,24 +560,24 @@ static public Object first(Object x){ } static public Object second(Object x){ - return first(rest(x)); + return first(next(x)); } static public Object third(Object x){ - return first(rest(rest(x))); + return first(next(next(x))); } static public Object fourth(Object x){ - return first(rest(rest(rest(x)))); + return first(next(next(next(x)))); } -static public ISeq rest(Object x){ +static public ISeq next(Object x){ if(x instanceof ISeq) - return ((ISeq) x).rest(); + return ((ISeq) x).next(); ISeq seq = seq(x); if(seq == null) return null; - return seq.rest(); + return seq.next(); } static public Sequence more(Object x){ @@ -585,7 +585,7 @@ static public Sequence more(Object x){ return ((ISeq) x).more(); ISeq seq = seq(x); if(seq == null) - return PersistentList.EMPTY; + return LazySeq.EMPTY; return seq.more(); } @@ -606,10 +606,6 @@ static public Sequence more(Object x){ // return ret; //} -static public ISeq rrest(Object x){ - return rest(rest(x)); -} - static public Object peek(Object x){ if(x == null) return null; @@ -722,12 +718,12 @@ static public Object find(Object coll, Object key){ static public ISeq findKey(Keyword key, ISeq keyvals) throws Exception{ while(keyvals != null) { - ISeq r = keyvals.rest(); + ISeq r = keyvals.next(); if(r == null) throw new Exception("Malformed keyword argslist"); if(keyvals.first() == key) return r; - keyvals = r.rest(); + keyvals = r.next(); } return null; } @@ -766,7 +762,7 @@ static public Object nth(Object coll, int n){ { ISeq seq = RT.seq(coll); coll = null; - for(int i = 0; i <= n && seq != null; ++i, seq = seq.rest()) + for(int i = 0; i <= n && seq != null; ++i, seq = seq.next()) { if(i == n) return seq.first(); @@ -829,7 +825,7 @@ static public Object nth(Object coll, int n, Object notFound){ { ISeq seq = RT.seq(coll); coll = null; - for(int i = 0; i <= n && seq != null; ++i, seq = seq.rest()) + for(int i = 0; i <= n && seq != null; ++i, seq = seq.next()) { if(i == n) return seq.first(); @@ -1106,7 +1102,7 @@ static public Object[] toArray(Object coll) throws Exception{ { ISeq s = (seq(coll)); Object[] ret = new Object[count(s)]; - for(int i = 0; i < ret.length; i++, s = s.rest()) + for(int i = 0; i < ret.length; i++, s = s.next()) ret[i] = s.first(); return ret; } @@ -1117,7 +1113,7 @@ static public Object[] toArray(Object coll) throws Exception{ static public Object[] seqToArray(ISeq seq){ int len = length(seq); Object[] ret = new Object[len]; - for(int i = 0; seq != null; ++i, seq = seq.rest()) + for(int i = 0; seq != null; ++i, seq = seq.next()) ret[i] = seq.first(); return ret; } @@ -1129,14 +1125,14 @@ static public Object seqToTypedArray(ISeq seq) throws Exception{ static public Object seqToTypedArray(Class type, ISeq seq) throws Exception{ Object ret = Array.newInstance(type, length(seq)); - for(int i = 0; seq != null; ++i, seq = seq.rest()) + for(int i = 0; seq != null; ++i, seq = seq.next()) Array.set(ret, i, seq.first()); return ret; } static public int length(ISeq list){ int i = 0; - for(ISeq c = list; c != null; c = c.rest()) + for(ISeq c = list; c != null; c = c.next()) { i++; } @@ -1145,7 +1141,7 @@ static public int length(ISeq list){ static public int boundedLength(ISeq list, int limit) throws Exception{ int i = 0; - for(ISeq c = list; c != null && i <= limit; c = c.rest()) + for(ISeq c = list; c != null && i <= limit; c = c.next()) { i++; } @@ -1309,13 +1305,13 @@ static public void print(Object x, Writer w) throws Exception{ else if(x instanceof IPersistentMap) { w.write('{'); - for(ISeq s = seq(x); s != null; s = s.rest()) + for(ISeq s = seq(x); s != null; s = s.next()) { IMapEntry e = (IMapEntry) s.first(); print(e.key(), w); w.write(' '); print(e.val(), w); - if(s.rest() != null) + if(s.next() != null) w.write(", "); } w.write('}'); @@ -1335,10 +1331,10 @@ static public void print(Object x, Writer w) throws Exception{ else if(x instanceof IPersistentSet) { w.write("#{"); - for(ISeq s = seq(x); s != null; s = s.rest()) + for(ISeq s = seq(x); s != null; s = s.next()) { print(s.first(), w); - if(s.rest() != null) + if(s.next() != null) w.write(" "); } w.write('}'); @@ -1397,10 +1393,10 @@ static public void print(Object x, Writer w) throws Exception{ } private static void printInnerSeq(ISeq x, Writer w) throws Exception{ - for(ISeq s = x; s != null; s = s.rest()) + for(ISeq s = x; s != null; s = s.next()) { print(s.first(), w); - if(s.rest() != null) + if(s.next() != null) w.write(' '); } } @@ -1484,13 +1480,13 @@ static public ISeq doFormat(Writer w, String s, ISeq args) throws Exception{ if(args == null) throw new IllegalArgumentException("Missing argument"); RT.formatAesthetic(w, RT.first(args)); - args = RT.rest(args); + args = RT.next(args); break; case 's': if(args == null) throw new IllegalArgumentException("Missing argument"); RT.formatStandard(w, RT.first(args)); - args = RT.rest(args); + args = RT.next(args); break; case '{': int j = s.indexOf("~}", i); //note - does not nest @@ -1499,7 +1495,7 @@ static public ISeq doFormat(Writer w, String s, ISeq args) throws Exception{ String subs = s.substring(i, j); for(ISeq sargs = RT.seq(RT.first(args)); sargs != null;) sargs = doFormat(w, subs, sargs); - args = RT.rest(args); + args = RT.next(args); i = j + 2; //skip ~} break; case '^': diff --git a/src/jvm/clojure/lang/Range.java b/src/jvm/clojure/lang/Range.java index 226a77ba..8976e852 100644 --- a/src/jvm/clojure/lang/Range.java +++ b/src/jvm/clojure/lang/Range.java @@ -39,7 +39,7 @@ public Object first(){ return n; } -public ISeq rest(){ +public ISeq next(){ if(n < end-1) return new Range(_meta, n + 1, end); return null; diff --git a/src/jvm/clojure/lang/RestFn.java b/src/jvm/clojure/lang/RestFn.java index f9ea3ed7..4e15f799 100644 --- a/src/jvm/clojure/lang/RestFn.java +++ b/src/jvm/clojure/lang/RestFn.java @@ -142,254 +142,254 @@ public Object applyTo(ISeq args) throws Exception{ return doInvoke(args);
case 1:
return doInvoke(args.first()
- , args.rest());
+ , args.next());
case 2:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , args.next());
case 3:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 4:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 5:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 6:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 7:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 8:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 9:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 10:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 11:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 12:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 13:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 14:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 15:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 16:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 17:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 18:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 19:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
case 20:
return doInvoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , (args = args.next()).first()
+ , args.next());
}
return throwArity();
@@ -1324,9 +1324,9 @@ protected static ISeq findKey(Object key, ISeq args){ while(args != null)
{
if(key == args.first())
- return args.rest();
- args = RT.rest(args);
- args = RT.rest(args);
+ return args.next();
+ args = RT.next(args);
+ args = RT.next(args);
}
return null;
}
diff --git a/src/jvm/clojure/lang/SeqEnumeration.java b/src/jvm/clojure/lang/SeqEnumeration.java index 42b7f198..bdff3a17 100644 --- a/src/jvm/clojure/lang/SeqEnumeration.java +++ b/src/jvm/clojure/lang/SeqEnumeration.java @@ -27,7 +27,7 @@ public boolean hasMoreElements(){ public Object nextElement(){ Object ret = RT.first(seq); - seq = RT.rest(seq); + seq = RT.next(seq); return ret; } } diff --git a/src/jvm/clojure/lang/SeqIterator.java b/src/jvm/clojure/lang/SeqIterator.java index 6a09c5c1..ea8b7a25 100644 --- a/src/jvm/clojure/lang/SeqIterator.java +++ b/src/jvm/clojure/lang/SeqIterator.java @@ -31,7 +31,7 @@ public Object next() throws NoSuchElementException { if(seq == null) throw new NoSuchElementException(); Object ret = RT.first(seq); - seq = RT.rest(seq); + seq = RT.next(seq); return ret; } diff --git a/src/jvm/clojure/lang/StreamSeq.java b/src/jvm/clojure/lang/StreamSeq.java index 44cfe28c..fca82d7a 100644 --- a/src/jvm/clojure/lang/StreamSeq.java +++ b/src/jvm/clojure/lang/StreamSeq.java @@ -41,7 +41,7 @@ public class StreamSeq extends ASeq { return _first; } - synchronized public ISeq rest() { + synchronized public ISeq next() { if (stream != null) { try { _rest = create(stream); @@ -56,7 +56,7 @@ public class StreamSeq extends ASeq { public Obj withMeta(IPersistentMap meta) { if(meta != this.meta()) { - rest(); + next(); return new StreamSeq(meta, _first, _rest); } return this; diff --git a/src/jvm/clojure/lang/StringSeq.java b/src/jvm/clojure/lang/StringSeq.java index cf370224..b5622903 100644 --- a/src/jvm/clojure/lang/StringSeq.java +++ b/src/jvm/clojure/lang/StringSeq.java @@ -38,7 +38,7 @@ public Object first(){ return Character.valueOf(s.charAt(i)); } -public ISeq rest(){ +public ISeq next(){ if(i + 1 < s.length()) return new StringSeq(_meta, s, i + 1); return null; diff --git a/src/jvm/clojure/lang/Var.java b/src/jvm/clojure/lang/Var.java index dfc0436c..a900e5da 100644 --- a/src/jvm/clojure/lang/Var.java +++ b/src/jvm/clojure/lang/Var.java @@ -264,7 +264,7 @@ synchronized public Object alterRoot(IFn fn, ISeq args) throws Exception{ public static void pushThreadBindings(Associative bindings){ Frame f = dvals.get(); Associative bmap = f.bindings; - for(ISeq bs = bindings.seq(); bs != null; bs = bs.rest()) + for(ISeq bs = bindings.seq(); bs != null; bs = bs.next()) { IMapEntry e = (IMapEntry) bs.first(); Var v = (Var) e.key(); @@ -279,7 +279,7 @@ public static void popThreadBindings(){ Frame f = dvals.get(); if(f.prev == null) throw new IllegalStateException("Pop without matching push"); - for(ISeq bs = RT.keys(f.frameBindings); bs != null; bs = bs.rest()) + for(ISeq bs = RT.keys(f.frameBindings); bs != null; bs = bs.next()) { Var v = (Var) bs.first(); v.count.decrementAndGet(); @@ -291,7 +291,7 @@ public static void releaseThreadBindings(){ Frame f = dvals.get(); if(f.prev == null) throw new IllegalStateException("Release without full unwind"); - for(ISeq bs = RT.keys(f.bindings); bs != null; bs = bs.rest()) + for(ISeq bs = RT.keys(f.bindings); bs != null; bs = bs.next()) { Var v = (Var) bs.first(); v.count.decrementAndGet(); |