diff options
| author | Rich Hickey <richhickey@gmail.com> | 2007-09-22 22:32:46 +0000 |
|---|---|---|
| committer | Rich Hickey <richhickey@gmail.com> | 2007-09-22 22:32:46 +0000 |
| commit | b6db84aea2db2ddebcef58918971258464cbf46f (patch) | |
| tree | a02f6e2d758da84f1358c2e647464ff563a7f00c /src/cli | |
| parent | 07060b8e569c6fd9073da42bcb80f3ab26251195 (diff) | |
refactoring dumping unused classes
Diffstat (limited to 'src/cli')
62 files changed, 0 insertions, 9534 deletions
diff --git a/src/cli/TypeDump/Program.cs b/src/cli/TypeDump/Program.cs deleted file mode 100644 index 755a62e8..00000000 --- a/src/cli/TypeDump/Program.cs +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/
-
-using System;
-using System.IO;
-using System.Reflection;
-
-namespace TypeDump
- {
- class Program
- {
- static void Main(string[] args)
- {
- if (args.Length < 2)
- {
- Console.Error.WriteLine("usage: typedump assembly namespace [namespace ...]");
- return;
- }
- Assembly a = Assembly.Load(new AssemblyName(args[0]));
- Console.WriteLine('(');
- foreach (Type t in a.GetExportedTypes())
- {
- if(Array.IndexOf(args,t.Namespace,1) >= 0
- //we don't deal with generics
- && !(t.IsGenericTypeDefinition || t.IsGenericType))
- dumpType(t, Console.Out);
- }
- Console.WriteLine(')');
- }
-
- static bool hasGenericOrRefParam(ParameterInfo[] args)
- {
- return Array.Find(args, delegate(ParameterInfo pi)
- {
- Type pit = pi.ParameterType;
- return pit.IsGenericTypeDefinition || pit.IsGenericType ||pit.IsByRef;
- })
- != null;
- }
-
- static void dumpType(Type t, TextWriter p)
- {
- p.Write('(');
- p.Write("(:name \"" + t + "\")");
- if(t.BaseType != null)
- p.Write(" (:super \"" + t.BaseType + "\")");
-
- Type[] interfaces = t.GetInterfaces();
- if (interfaces.Length > 0)
- {
- p.WriteLine();
- p.Write(" (:interfaces");
- foreach (Type it in interfaces)
- {
- if (!(it.IsGenericTypeDefinition || it.IsGenericType))
- p.Write(" \"" + it + "\"");
-
- }
- p.Write(')');
- }
- foreach (ConstructorInfo ci in t.GetConstructors(BindingFlags.Public|BindingFlags.Instance))
- {
- //this should filter for pointer args etc
- Object[] clsattr = ci.GetCustomAttributes(typeof(CLSCompliantAttribute), false);
- if (clsattr.Length > 0 && !((CLSCompliantAttribute)clsattr[0]).IsCompliant)
- continue;
- ParameterInfo[] args = ci.GetParameters();
- //we don't deal with generics
- if (hasGenericOrRefParam(args))
- continue;
- p.WriteLine();
- p.Write(" (:ctor (:arity " + args.Length + ")");
- if (args.Length > 0
- && args[args.Length - 1].GetCustomAttributes(typeof(ParamArrayAttribute), false).Length > 0)
- {
- p.Write("(:varargs t)");
- }
- if (args.Length > 0)
- {
- p.WriteLine();
- p.Write(" (:args");
- foreach (ParameterInfo pi in args)
- {
- p.Write(" \"" + pi.ParameterType + "\"");
- }
- p.Write(')');
- }
- p.Write(')');
- }
- foreach (MethodInfo mi in t.GetMethods(BindingFlags.Public | BindingFlags.Instance |BindingFlags.Static))
- {
- //this should filter for pointer args etc
- Object[] clsattr = mi.GetCustomAttributes(typeof(CLSCompliantAttribute), false);
- if (clsattr.Length > 0 && !((CLSCompliantAttribute)clsattr[0]).IsCompliant)
- continue;
- ParameterInfo[] args = mi.GetParameters();
- //we don't deal with generics
- if (hasGenericOrRefParam(args) ||mi.ReturnType.IsGenericType)
- continue;
- p.WriteLine();
- p.Write(" (:method (:name \"" + mi.Name + "\") (:arity " + args.Length + ")(:ret \"" + mi.ReturnType + "\")");
- if (mi.IsStatic)
- {
- p.Write(" (:static t)");
- }
- if (args.Length > 0
- && args[args.Length - 1].GetCustomAttributes(typeof(ParamArrayAttribute), false).Length > 0)
- {
- p.Write(" (:varargs t)");
- }
- if (mi.IsSpecialName)
- {
- p.Write(" (:special t)");
- }
- if (args.Length > 0)
- {
- p.WriteLine();
- p.Write(" (:args");
- foreach (ParameterInfo pi in args)
- {
- p.Write(" \"" + pi.ParameterType + "\"");
- }
- p.Write(')');
- }
- p.Write(')');
- }
- foreach (FieldInfo fi in t.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static))
- {
- p.WriteLine();
- p.Write(" (:field (:name \"");
- p.Write(fi.Name);
- p.Write("\") (:type \"");
- p.Write(fi.FieldType);
- p.Write("\")");
- if (fi.IsStatic)
- {
- p.Write(" (:static t)");
- if (fi.IsLiteral)
- {
- Object v = fi.GetRawConstantValue();
- p.Write(" (:const-value ");
- if (v is String)
- p.Write('"');
- p.Write(v);
- if (v is String)
- p.Write('"');
- p.Write(")");
-
- }
- }
- if (fi.IsSpecialName)
- {
- p.Write(" (:special t)");
- }
- p.Write(")");
-
- }
-
- p.WriteLine(')');
- }
- }
- }
diff --git a/src/cli/runtime/AFn.cs b/src/cli/runtime/AFn.cs deleted file mode 100644 index 728a7f19..00000000 --- a/src/cli/runtime/AFn.cs +++ /dev/null @@ -1,407 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 25, 2006 4:05:37 PM */ - -using System;
- -namespace clojure.lang
-{ - -public class AFn : Obj , IFn
- { - -virtual public Object invoke()
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19)
- {
- return throwArity();
- }
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20)
- {
- return throwArity();
- }
-
-virtual public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20,
- params Object[] args)
- {
- return throwArity();
- } - -virtual public Object applyTo( ISeq arglist) -{ -return applyToHelper(this,arglist); -} - -static public Object applyToHelper(IFn ifn, ISeq arglist) {
- switch (RT.boundedLength(arglist, 20))
- {
- case 0:
- return ifn.invoke();
- case 1:
- return ifn.invoke(arglist.first());
- case 2:
- return ifn.invoke(arglist.first()
- , (arglist = arglist.rest()).first()
- );
- case 3:
- return ifn.invoke(arglist.first()
- , (arglist = arglist.rest()).first()
- , (arglist = arglist.rest()).first()
- );
- case 4:
- return ifn.invoke(arglist.first()
- , (arglist = arglist.rest()).first()
- , (arglist = arglist.rest()).first()
- , (arglist = arglist.rest()).first()
- );
- case 5:
- return ifn.invoke(arglist.first()
- , (arglist = arglist.rest()).first()
- , (arglist = arglist.rest()).first()
- , (arglist = arglist.rest()).first()
- , (arglist = arglist.rest()).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()
- );
- 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()
- );
- 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()
- );
- 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()
- );
- 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()
- );
- 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()
- );
- 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()
- );
- 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()
- );
- 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()
- );
- 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()
- );
- 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()
- );
- 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()
- );
- 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()
- );
- 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()
- );
- 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()
- );
- 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()));
- }
-}
- - -static public Object throwArity() - { - throw new Exception("Wrong number of args passed"); - } - -public override Obj withMeta(IPersistentMap meta){
- Obj ret = (Obj) MemberwiseClone();
- ret._meta = meta;
- return ret;
}
-} -}
\ No newline at end of file diff --git a/src/cli/runtime/APersistentArray.cs b/src/cli/runtime/APersistentArray.cs deleted file mode 100644 index b78f502d..00000000 --- a/src/cli/runtime/APersistentArray.cs +++ /dev/null @@ -1,139 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-using System.Collections;
-
-namespace clojure.lang
-{
-public abstract class APersistentArray : Obj, IPersistentArray {
-int _hash = -1;
-
-public virtual IPersistentCollection cons(Object o) {
- PersistentArrayList ret = new PersistentArrayList(this, this.count() + 10);
- ret = (PersistentArrayList)ret.cons(o);
- ret._meta = _meta;
- return ret;
-}
-
- public override Obj withMeta(IPersistentMap meta)
- {
- if(_meta == meta)
- return this;
- Obj ret = (Obj)MemberwiseClone();
- ret._meta = meta;
- return ret;
- }
-
-override public bool Equals(Object obj) {
- if(obj is IPersistentArray)
- {
- IPersistentArray ma = (IPersistentArray) obj;
- if (ma.count() != count() || ma.GetHashCode() != GetHashCode())
- return false;
- for(int i=0;i<count();i++)
- {
- if(!RT.equal(nth(i),ma.nth(i)))
- return false;
- }
- }
- else
- {
- if(!(obj is Sequential))
- return false;
- ISeq ms = ((IPersistentCollection)obj).seq();
- for (int i = 0; i < count(); i++, ms = ms.rest())
- {
- if (ms == null || !RT.equal(nth(i), ms.first()))
- return false;
- }
- if(ms.rest() != null)
- return false;
- }
-
- return true;
-}
-
-override public int GetHashCode() {
- if(_hash == -1)
- {
- int hash = 0;
- for(int i=0;i<count();i++)
- {
- hash = RT.hashCombine(hash, RT.hash(nth(i)));
- }
- this._hash = hash;
- }
- return _hash;
-}
-
- #region IArray Members
-
- abstract public int length();
-
- abstract public object nth(int i);
-
- abstract public IPersistentArray assocN(int i, object val);
-
- #endregion
-
- #region IPersistentCollection Members
-
- abstract public int count();
-
- abstract public ISeq seq();
-
- #endregion
-
-public bool contains(Object key) {
- try{
- int i = Convert.ToInt32(key);
- return i >= 0 && i < count();
- }
- catch(Exception)
- {
- return false;
- }
-}
-
-public IMapEntry find(Object key) {
- try
- {
- int i = Convert.ToInt32(key);
- if(i >= 0 && i < count())
- return new MapEntry(key,nth(i));
- }
- catch(Exception)
- {
- }
- return null;
-}
-
-public Associative assoc(Object key, Object val) {
- int i = Convert.ToInt32(key);
- return (Associative)assocN(i, val);
-}
-
-public Object get(Object key) {
- try
- {
- int i = Convert.ToInt32(key);
- if(i >= 0 && i < count())
- return nth(i);
- }
- catch (Exception)
- {
- }
- return null;
- }
-
-}
-
-}
diff --git a/src/cli/runtime/APersistentMap.cs b/src/cli/runtime/APersistentMap.cs deleted file mode 100644 index e96cdad0..00000000 --- a/src/cli/runtime/APersistentMap.cs +++ /dev/null @@ -1,149 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-using System.Threading;
-using System.Collections;
-
-namespace clojure.lang
-{
-public abstract class APersistentMap : Obj, IPersistentMap{
- int _hash = -1;
-
- public override Obj withMeta(IPersistentMap meta)
- {
- if(_meta == meta)
- return this;
- Obj ret = (Obj)MemberwiseClone();
- ret._meta = meta;
- return ret;
- }
-
-override public bool Equals(Object obj) {
- IPersistentMap m = obj as IPersistentMap;
- if(obj == null)
- return false;
-
- if(m.count() != count() || m.GetHashCode() != GetHashCode())
- return false;
-
- for(ISeq s = seq();s!=null;s = s.rest())
- {
- IMapEntry e = (IMapEntry) s.first();
- IMapEntry me = m.find(e.key());
-
- if(me == null || !RT.equal(e.val(),me.val()))
- return false;
- }
-
- return true;
-}
-
-override public int GetHashCode() {
- if(_hash == -1)
- {
- int hash = count();
- for(ISeq s = seq();s!=null;s = s.rest())
- {
- IMapEntry e = (IMapEntry) s.first();
- hash ^= RT.hashCombine(RT.hash(e.key()), RT.hash(e.val()));
- }
- this._hash = hash;
- }
- return _hash;
-}
- #region IPersistentMap Members
-
- abstract public IPersistentMap assocEx(object key, object val);
-
-
- abstract public IPersistentMap without(object key);
-
-
- public class KeySeq : ASeq{
- ISeq _seq;
-
- static public KeySeq create(ISeq seq){
- if(seq == null)
- return null;
- return new KeySeq(seq);
- }
-
- private KeySeq(ISeq seq) {
- this._seq = seq;
- }
-
- public override Object first() {
- return ((IMapEntry)_seq.first()).key();
- }
-
- public override ISeq rest() {
- return create(_seq.rest());
- }
-}
-
-public class ValSeq : ASeq{
- ISeq _seq;
-
- static public ValSeq create(ISeq seq){
- if(seq == null)
- return null;
- return new ValSeq(seq);
- }
-
- private ValSeq(ISeq seq) {
- this._seq = seq;
- }
-
- public override Object first() {
- return ((IMapEntry)_seq.first()).val();
- }
-
- public override ISeq rest() {
- return create(_seq.rest());
- }
-}
-
- #endregion
-
- #region Associative Members
-
- abstract public bool contains(object key);
-
- abstract public IMapEntry find(object key);
-
- abstract public object get(object key);
-
- abstract public Associative assoc(object key, object val);
-
- #endregion
-
- #region IEnumerable Members
-
- abstract public IEnumerator GetEnumerator();
-
- #endregion
-
- #region IPersistentCollection Members
-
- abstract public int count();
-
- abstract public ISeq seq();
-
- public IPersistentCollection cons(Object o)
- {
- IMapEntry e = (IMapEntry)o;
- return (IPersistentCollection)assoc(e.key(), e.val());
- }
-
- #endregion
- }
-
-}
diff --git a/src/cli/runtime/ASeq.cs b/src/cli/runtime/ASeq.cs deleted file mode 100644 index 112c9f73..00000000 --- a/src/cli/runtime/ASeq.cs +++ /dev/null @@ -1,84 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-
-namespace clojure.lang
- {
-
-public abstract class ASeq : Obj, ISeq{
-int _hash = -1;
-
- public override Obj withMeta(IPersistentMap meta)
- {
- if(_meta == meta)
- return this;
- Obj ret = (Obj)MemberwiseClone();
- ret._meta = meta;
- return ret;
- }
-
-override public bool Equals(Object obj) {
- if(!(obj is Sequential))
- return false;
- ISeq ms = ((IPersistentCollection)obj).seq();
- for(ISeq s = seq();s!=null;s = s.rest(), ms = ms.rest())
- {
- if(ms == null || !RT.equal(s.first(),ms.first()))
- return false;
- }
- if(ms.rest() != null)
- return false;
- return true;
-}
-
-override public int GetHashCode() {
- if(_hash == -1)
- {
- int hash = 0;
- for(ISeq s = seq();s!=null;s = s.rest())
- {
- hash = RT.hashCombine(hash, RT.hash(s.first()));
- }
- this._hash = hash;
- }
- return _hash;
-}
-
-public virtual Object peek() {
- return first();
-}
-
-public virtual IPersistentList pop() {
- return rest();
-}
-
-public virtual int count() {
- return 1 + RT.count(rest());
-}
-
-public virtual ISeq seq() {
- return this;
-}
-
-public virtual IPersistentCollection cons(Object o) {
- return new Cons(o, this);
-}
-
-#region ISeq Members
-
-abstract public object first();
-
-abstract public ISeq rest();
-
-#endregion
- }
-
-}
diff --git a/src/cli/runtime/ArraySeq.cs b/src/cli/runtime/ArraySeq.cs deleted file mode 100644 index 3fb91560..00000000 --- a/src/cli/runtime/ArraySeq.cs +++ /dev/null @@ -1,66 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-/* rich Jun 19, 2006 */
-
-using System;
- -namespace clojure.lang
-{ -
-public class ArraySeq : ASeq, IndexedSeq{
-readonly Object[] array;
-readonly int i;
-//ISeq _rest;
-
-static public ArraySeq create(){
- return null;
-}
-
-static public ArraySeq create(params Object[] array){
- if(array.Length == 0)
- return null;
- return new ArraySeq(array, 0);
-}
-
-ArraySeq(Object[] array, int i){
- this.array = array;
- this.i = i;
-// this._rest = this;
-}
-
-override public Object first() {
- return array[i];
-}
-
-override public ISeq rest() {
- if (i + 1 < array.Length)
- return new ArraySeq(array, i + 1);
- return null;
-
-// if(_rest == this)
-// {
-// if(i+1 < array.Length)
-// _rest = new ArraySeq(array, i + 1);
-// _rest = null;
-// }
-// return _rest;
-}
-
-public override int count() {
- return array.Length - i;
-}
-
-public int index(){
- return i;
-}
-}
-
-}
diff --git a/src/cli/runtime/Associative.cs b/src/cli/runtime/Associative.cs deleted file mode 100644 index 57b4cd56..00000000 --- a/src/cli/runtime/Associative.cs +++ /dev/null @@ -1,21 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- */
-
-using System;
-namespace clojure.lang
- {
- public interface Associative : IPersistentCollection
- {
- bool contains(object key);
- IMapEntry find(object key);
- object get(object key);
- Associative assoc(object key, object val);
- }
- }
diff --git a/src/cli/runtime/BigNum.cs b/src/cli/runtime/BigNum.cs deleted file mode 100644 index 9bde7116..00000000 --- a/src/cli/runtime/BigNum.cs +++ /dev/null @@ -1,225 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 28, 2006 10:08:33 AM */ - -using System;
-using java.math; - -namespace clojure.lang
-{ - - -public class BigNum : IntegerNum{ -public BigInteger val; - -override public Boolean Equals(Object arg0) - { - return arg0 != null - && arg0 is BigNum - && ((BigNum) arg0).val == val; - } - -override public int GetHashCode() - { - return val.GetHashCode(); - } - -override public String ToString() - { - return val.ToString(); - } - -public BigNum(long val) - { - this.val = BigInteger.valueOf(val); - } - -public BigNum(BigInteger val) - { - this.val = val; - } - -override public double doubleValue() - { - return val.doubleValue(); - } - -override public float floatValue() - { - return val.floatValue(); - } - -override public int intValue() - { - return val.intValue(); - } - -override public long longValue() - { - return val.longValue(); - } - -override public Boolean equiv(Num rhs) - { - return rhs.equivTo(val); - } - -override public Boolean equivTo(BigInteger x) - { - return x.Equals(val); - } - -override public Boolean equivTo(int x) - { - //must be outside of range of int or would be one itself - return false; - } - -override public Boolean equivTo(RatioNum x) - { - //wouldn't still be a RatioNum if it was an integer - return false; - } - -override public Boolean lt(Num rhs) - { - return rhs.gt(val); - } - -override public Boolean gt(BigInteger x) - { - return x.compareTo(val) < 0; - } - -override public Boolean gt(int x) - { - return BigInteger.valueOf(x).compareTo(val) < 0; - } - -override public Boolean gt(RatioNum x) - { - return x.numerator.lt(x.denominator.multiply(val)); - } - -override public Num add(Num rhs) - { - return rhs.addTo(val); - } - -override public Num addTo(BigInteger x) - { - return Num.from(x.add(val)); - } - -override public Num addTo(int x) - { - return Num.from(val.add(BigInteger.valueOf(x))); - } - -override public Num addTo(RatioNum x) - { - return x.addTo(val); - } - -override public Num subtractFrom(Num x) - { - return x.addTo(val.negate()); - } - -override public Num multiplyBy(Num rhs) - { - return rhs.multiply(val); - } - -override public Num multiply(BigInteger x) - { - return Num.from(x.multiply(val)); - } - -override public Num multiply(int x) - { - return Num.from(val.multiply(BigInteger.valueOf(x))); - } - -override public Num multiply(RatioNum x) - { - return x.multiply(val); - } - -override public Num divideBy(Num rhs) - { - return rhs.divide(val); - } - -override public Num divide(BigInteger n) - { - return Num.divide(n, val); - } - -override public Num divide(int n) - { - return Num.divide(BigInteger.valueOf(n), val); - } - -override public Num divide(RatioNum x) - { - return Num.divide(x.numerator, x.denominator.multiply(val)); - } - -override public Object truncateDivide( Num num) - { - return num.truncateBy( val); - } - -override public Object truncateBy( int div) - { - return Num.truncateBigints( val, BigInteger.valueOf(div)); - } - -override public Object truncateBy( BigInteger div) - { - return Num.truncateBigints( val, div); - } - -override public Object truncateBy( RatioNum div) - { - Num q = (Num) Num.truncate( div.denominator.multiply(val), div.numerator); - return RT.setValues( q, q.multiplyBy(div).subtractFrom(this)); - } - -override public Num negate() - { - return Num.from(val.negate()); - } - -override public Boolean minusp() - { - return val.signum() < 0; - } - -override public Boolean plusp() - { - return val.signum() > 0; - } - - -override public Num oneMinus() - { - return Num.from(val.subtract(BIG_ONE)); - } - -override public Num onePlus() - { - return Num.from(val.add(BIG_ONE)); - } -} -} - diff --git a/src/cli/runtime/Binding.cs b/src/cli/runtime/Binding.cs deleted file mode 100644 index c8c8d6f3..00000000 --- a/src/cli/runtime/Binding.cs +++ /dev/null @@ -1,29 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-
-namespace clojure.lang
-{
-public class Binding {
-public Object val;
-public Binding rest;
-
-public Binding(Object val) {
- this.val = val;
-}
-
-public Binding(Object val, Binding rest) {
- this.val = val;
- this.rest = rest;
-}
-}
-
-}
diff --git a/src/cli/runtime/Box.cs b/src/cli/runtime/Box.cs deleted file mode 100644 index d751786d..00000000 --- a/src/cli/runtime/Box.cs +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 27, 2006 8:40:19 PM */ - -using System;
-
-namespace clojure.lang
-{ - -public class Box
-{ - -public Object val; - -public Box(Object val) - { - this.val = val; - } -} -} diff --git a/src/cli/runtime/ClassSymbol.cs b/src/cli/runtime/ClassSymbol.cs deleted file mode 100644 index 484ce488..00000000 --- a/src/cli/runtime/ClassSymbol.cs +++ /dev/null @@ -1,24 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
- -namespace clojure.lang
-{ -
-public class ClassSymbol :HostSymbol {
-readonly public String className;
-
-public ClassSymbol(String className) : base(className) {
-this.className = className.Substring(0, className.Length - 2); //strip trailing dot
-}
-}
-
-}
diff --git a/src/cli/runtime/Cons.cs b/src/cli/runtime/Cons.cs deleted file mode 100644 index 823c3fd8..00000000 --- a/src/cli/runtime/Cons.cs +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 25, 2006 11:01:29 AM */ - -using System;
- -namespace clojure.lang
-{ - -public class Cons : ASeq
- { - -private readonly Object _first; -private readonly ISeq _rest; - -public Cons(Object first, ISeq rest) - { - this._first = first; - this._rest = rest; - }
-
-
-#region ISeq Members
-
-override public object first()
- {
- return _first;
- }
-
-override public ISeq rest()
- {
- return _rest;
- }
-
-#endregion
-
- } - -} diff --git a/src/cli/runtime/DoubleNum.cs b/src/cli/runtime/DoubleNum.cs deleted file mode 100644 index ef9f3f75..00000000 --- a/src/cli/runtime/DoubleNum.cs +++ /dev/null @@ -1,242 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 28, 2006 10:13:45 AM */ - -using System;
-using java.math;
-
-namespace clojure.lang
-{ - -public class DoubleNum : FloatNum{ -double val; - -public DoubleNum(double val) - { - this.val = val; - } - -override public double doubleValue() - { - return val; - } - -override public float floatValue() - { - return (float) val; - } - -override public int intValue() - { - return (int) val; - } - -override public long longValue() - { - return (long) val; - } - - -public Num toRational() - { - BigDecimal d = new BigDecimal(val); - return Num.divide(d.movePointRight(d.scale()).toBigInteger(), BIGTEN.pow(d.scale())); - } - -override public Boolean equiv(Num rhs) - { - if(rhs is RatioNum) - return equivTo((RatioNum) rhs); - return val == rhs.doubleValue(); - } - -override public Boolean equivTo(BigInteger x) - { - return val == x.doubleValue(); - } - -override public Boolean equivTo(int x) - { - return x == val; - } - -override public Boolean equivTo(RatioNum x) - { - return toRational().equivTo(x); - } - -override public Boolean lt(Num rhs) - { - if(rhs is RatioNum) - return toRational().lt(rhs); - return val < rhs.doubleValue(); - } - -override public Boolean gt(BigInteger x) - { - return val > x.doubleValue(); - } - -override public Boolean gt(int x) - { - return val > x; - } - -override public Boolean gt(RatioNum x) - { - return toRational().gt(x); - } - -override public Num add(Num rhs) - { - return Num.from(val + rhs.doubleValue()); - } - -override public Num addTo(int x) - { - return Num.from(val + x); - } - -override public Num addTo(BigInteger x) - { - return Num.from(val + x.doubleValue()); - } - -override public Num addTo(RatioNum x) - { - return Num.from(val + x.doubleValue()); - } - -override public Num subtractFrom(Num x) - { - return Num.from(x.doubleValue() - val); - } - -override public Num multiplyBy(Num rhs) - { - return Num.from(val * rhs.doubleValue()); - } - -override public Num multiply(int x) - { - return Num.from(val * x); - } - -override public Num multiply(BigInteger x) - { - return Num.from(val * x.doubleValue()); - } - -override public Num multiply(RatioNum x) - { - return Num.from(val * x.doubleValue()); - } - -override public Num divideBy(Num rhs) - { - return Num.from(val / rhs.doubleValue()); - } - -override public Num divide(int x) - { - return Num.from(x / val); - } - -override public Num divide(BigInteger x) - { - return Num.from(x.doubleValue() / val); - } - -override public Num divide(RatioNum x) - { - return Num.from(x.doubleValue() / val); - } - -static Object truncate( double n, double d) - { - double q = n / d; - if(q <= Int32.MaxValue && q >= Int32.MinValue) - { - return RT.setValues( Num.from((int) q), - Num.from(n - ((int) q) * d)); - } - else - { //bigint quotient - Num bq = Num.from(new BigDecimal(q).toBigInteger()); - return RT.setValues( bq, - Num.from(n - bq.doubleValue() * d)); - } - } - -override public Object truncateBy( BigInteger x) - { - return truncate( val, x.doubleValue()); - } - -override public Object truncateBy( int x) - { - return truncate( val, x); - } - -override public Object truncateBy( RatioNum x) - { - return truncate( val, x.doubleValue()); - } - -override public Object truncateDivide( Num num) - { - return truncate( num.doubleValue(), val); - } - -override public Num negate() - { - return Num.from(-val); - } - -override public Boolean Equals(Object arg0) - { - return arg0 != null - && arg0 is DoubleNum - &&((DoubleNum) arg0).val.Equals(val); - } - -override public int GetHashCode() - { - return val.GetHashCode(); - } - -override public String ToString() - { - return val.ToString(); - } - -override public Boolean minusp() - { - return val < 0; - } - -override public Boolean plusp() - { - return val > 0; - } - -override public Num oneMinus() - { - return Num.from(val - 1); - } - -override public Num onePlus() - { - return Num.from(val + 1); - } - -} -} diff --git a/src/cli/runtime/EnumeratorIter.cs b/src/cli/runtime/EnumeratorIter.cs deleted file mode 100644 index 2fb66c11..00000000 --- a/src/cli/runtime/EnumeratorIter.cs +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ -
-
-using System;
-using System.Collections;
-
-namespace clojure.lang
- {
- internal class EnumeratorIter:Iter
- {
- IEnumerator e;
-
- //presumes that e has already been successfully MovedNext()ed
- internal EnumeratorIter(IEnumerator e)
- {
- this.e = e;
- }
-
- #region Iter Members
-
- public object get()
- {
- return e.Current;
- }
-
- public Iter iterate()
- {
- if (e.MoveNext())
- return this;
- return null;
- }
-
- #endregion
- }
- }
diff --git a/src/cli/runtime/EnumeratorSeq.cs b/src/cli/runtime/EnumeratorSeq.cs deleted file mode 100644 index cd42d42a..00000000 --- a/src/cli/runtime/EnumeratorSeq.cs +++ /dev/null @@ -1,47 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-using System.Collections;
- -namespace clojure.lang
-{
- public class EnumeratorSeq : ASeq
- {
- IEnumerator e;
- ISeq _rest;
-
- public static EnumeratorSeq create(IEnumerator e) {
- if (e.MoveNext())
- return new EnumeratorSeq(e);
- return null;
- }
-
- EnumeratorSeq(IEnumerator e) {
- this.e = e;
- this._rest = this;
- }
-
- override public Object first() {
- return e.Current;
- }
-
- override public ISeq rest() {
- lock (this)
- {
- if (_rest == this)
- {
- _rest = create(e);
- }
- return _rest;
- }
- }
- }
-}
\ No newline at end of file diff --git a/src/cli/runtime/FixNum.cs b/src/cli/runtime/FixNum.cs deleted file mode 100644 index 6b0d6759..00000000 --- a/src/cli/runtime/FixNum.cs +++ /dev/null @@ -1,243 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 28, 2006 10:09:27 AM */ - -using System;
-using java.math;
- -namespace clojure.lang
-{ - - -public class FixNum : IntegerNum{ -public int val; - -override public Boolean Equals(Object arg0) - { - return arg0 != null - && arg0 is FixNum - && ((FixNum) arg0).val == val; - } - -override public int GetHashCode() - { - return val; - } - -override public String ToString() - { - return val.ToString(); - } - -public FixNum(int val) - { - this.val = val; - } - -override public double doubleValue() - { - return (double) val; - } - -override public float floatValue() - { - return (float) val; - } - -override public int intValue() - { - return val; - } - -override public long longValue() - { - return (long) val; - } - -override public Boolean equiv(Num rhs) - { - return rhs.equivTo(val); - } - -override public Boolean equivTo(BigInteger x) - { - //wouldn't still be a BigInteger if it fit in int - return false; - } - -override public Boolean equivTo(int x) - { - return x == val; - } - -override public Boolean equivTo(RatioNum x) - { - //wouldn't still be a RatioNum if it was an integer - return false; - } - -override public Boolean lt(Num rhs) - { - return rhs.gt(val); - } - -override public Boolean gt(BigInteger x) - { - return x.compareTo(BigInteger.valueOf(val)) < 0; - } - -override public Boolean gt(int x) - { - return x < val; - } - -override public Boolean gt(RatioNum x) - { - return x.numerator.lt(x.denominator.multiply(val)); - } - -override public Num add(Num rhs) - { - return rhs.addTo(val); - } - -override public Num addTo(BigInteger x) - { - return Num.from(x.add(BigInteger.valueOf(val))); - } - -override public Num addTo(int x) - { - return Num.from((long) x + val); - } - -override public Num addTo(RatioNum x) - { - return x.addTo(val); - } - -override public Num subtractFrom(Num x) - { - return x.addTo(-val); - } - -override public Num multiplyBy(Num rhs) - { - return rhs.multiply(val); - } - -override public Num multiply(BigInteger x) - { - return Num.from(x.multiply(BigInteger.valueOf(val))); - } - -override public Num multiply(int x) - { - return Num.from((long) x * val); - } - -override public Num multiply(RatioNum x) - { - return x.multiply(val); - } - -override public Object truncateDivide( Num num) - { - return num.truncateBy( val); - } - -override public Object truncateBy( int div) - { - return RT.setValues( Num.from(val / div), Num.from(val % div)); - } - -override public Object truncateBy( BigInteger div) - { - return Num.truncateBigints( BigInteger.valueOf(val), div); - } - -override public Object truncateBy( RatioNum div) - { - Num q = (Num) Num.truncate( div.denominator.multiply(val), div.numerator); - return RT.setValues( q, q.multiplyBy(div).subtractFrom(this)); - } - -override public Num divideBy(Num rhs) - { - return rhs.divide(val); - } - -override public Num divide(BigInteger n) - { - return Num.divide(n, BigInteger.valueOf(val)); - } - -static int gcdf(int u, int v) - { - while(v != 0) - { - int r = u % v; - u = v; - v = r; - } - return u; - } - -override public Num divide(int n) - { - int gcd = gcdf(n, val); - if(gcd == 0) - return Num.ZERO; - - n = n / gcd; - int d = val / gcd; - if(d == 1) - return Num.from(n); - if(d < 0) - { - n = -n; - d = -d; - } - return new RatioNum((IntegerNum) Num.from(n), (IntegerNum) Num.from(d)); - } - -override public Num divide(RatioNum x) - { - return Num.divide(x.numerator, x.denominator.multiply(val)); - } - -override public Num negate() - { - return Num.from(-val); - } - -override public Boolean minusp() - { - return val < 0; - } - -override public Boolean plusp() - { - return val > 0; - } - -override public Num oneMinus() - { - return Num.from(val - 1); - } - -override public Num onePlus() - { - return Num.from(val + 1); - } - -} -} diff --git a/src/cli/runtime/FloatNum.cs b/src/cli/runtime/FloatNum.cs deleted file mode 100644 index 6b709c2b..00000000 --- a/src/cli/runtime/FloatNum.cs +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 28, 2006 10:17:21 AM */ - -using System;
-
-namespace clojure.lang
-{ - -public abstract class FloatNum : RealNum { - -} -} diff --git a/src/cli/runtime/FnSeq.cs b/src/cli/runtime/FnSeq.cs deleted file mode 100644 index 27374eea..00000000 --- a/src/cli/runtime/FnSeq.cs +++ /dev/null @@ -1,46 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
- -namespace clojure.lang
-{ -
-public class FnSeq : ASeq{
-
-Object _first;
-IFn restFn;
-volatile ISeq _rest;
-
-public FnSeq(Object first, IFn restFn) {
- this._first = first;
- this.restFn = restFn;
- this._rest = this;
- }
-
-override public Object first() {
- return _first;
-}
-
-override public ISeq rest() {
- if(_rest != this)
- return _rest;
- lock(this){
- if(_rest == this)
- {
- _rest = (ISeq) restFn.invoke();
- restFn = null;
- }
- return _rest;
- }
- }
-}
-
-}
diff --git a/src/cli/runtime/HostSymbol.cs b/src/cli/runtime/HostSymbol.cs deleted file mode 100644 index 29d951c3..00000000 --- a/src/cli/runtime/HostSymbol.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace clojure.lang
- {
- public class HostSymbol : Symbol
- {
- public HostSymbol(string name) : base(name) {
- }
- }
- }
diff --git a/src/cli/runtime/IFn.cs b/src/cli/runtime/IFn.cs deleted file mode 100644 index a915ee9a..00000000 --- a/src/cli/runtime/IFn.cs +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/
-
-/* rich Mar 25, 2006 3:54:03 PM */
-
-using System;
-
-namespace clojure.lang
- {
- public interface IFn
- {
-
- Object invoke();
- Object invoke(Object arg1);
- Object invoke(Object arg1, Object arg2);
- Object invoke(Object arg1, Object arg2, Object arg3);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19);
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20);
-
- Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20,
- params Object[] args);
-
- Object applyTo(ISeq arglist) /*throws Exception*/;
- }
- }
diff --git a/src/cli/runtime/IMapEntry.cs b/src/cli/runtime/IMapEntry.cs deleted file mode 100644 index 4a173c81..00000000 --- a/src/cli/runtime/IMapEntry.cs +++ /dev/null @@ -1,23 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- */
-
-using System;
-
-namespace clojure.lang
-
-{
-
-public interface IMapEntry {
-Object key();
-
-Object val();
-}
-
-}
diff --git a/src/cli/runtime/IObj.cs b/src/cli/runtime/IObj.cs deleted file mode 100644 index 9e8d0d93..00000000 --- a/src/cli/runtime/IObj.cs +++ /dev/null @@ -1,26 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-namespace clojure.lang
- {
- interface IObj
- {
- Object putAttr(Object key, Object val);
-
- Object getAttr(Object key);
-
- bool hasAttr(Object key);
-
- IPersistentMap attrs();
-
- void removeAttr(Object key);
- }
- }
diff --git a/src/cli/runtime/IPersistentArray.cs b/src/cli/runtime/IPersistentArray.cs deleted file mode 100644 index 77e6290c..00000000 --- a/src/cli/runtime/IPersistentArray.cs +++ /dev/null @@ -1,24 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- */
-
-using System;
- -namespace clojure.lang
-{ -
-public interface IPersistentArray : Associative, Sequential {
-int length();
-
-Object nth(int i);
-
-IPersistentArray assocN(int i,Object val);
-}
-
-}
diff --git a/src/cli/runtime/IPersistentCollection.cs b/src/cli/runtime/IPersistentCollection.cs deleted file mode 100644 index 929a419e..00000000 --- a/src/cli/runtime/IPersistentCollection.cs +++ /dev/null @@ -1,25 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- */
-using System;
-
-
-namespace clojure.lang
- {
-
- public interface IPersistentCollection
- {
-
- int count();
-
- ISeq seq();
-
- IPersistentCollection cons(Object o);
- }
- }
diff --git a/src/cli/runtime/IPersistentList.cs b/src/cli/runtime/IPersistentList.cs deleted file mode 100644 index a5093471..00000000 --- a/src/cli/runtime/IPersistentList.cs +++ /dev/null @@ -1,23 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- */
-
-using System;
- -namespace clojure.lang
-{
-public interface IPersistentList : IPersistentCollection, Sequential {
-
- Object peek();
-
- IPersistentList pop();
-
-}
-
-}
diff --git a/src/cli/runtime/IPersistentMap.cs b/src/cli/runtime/IPersistentMap.cs deleted file mode 100644 index b1f9ef94..00000000 --- a/src/cli/runtime/IPersistentMap.cs +++ /dev/null @@ -1,26 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- */
-
-using System;
-using System.Collections;
-
-namespace clojure.lang
-{
-
-public interface IPersistentMap : Associative, IEnumerable{
-
-
-IPersistentMap assocEx(Object key, Object val);
-
-IPersistentMap without(Object key);
-
-}
-
-}
diff --git a/src/cli/runtime/ISeq.cs b/src/cli/runtime/ISeq.cs deleted file mode 100644 index 4cd7feea..00000000 --- a/src/cli/runtime/ISeq.cs +++ /dev/null @@ -1,22 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- */
-
-using System;
-
-namespace clojure.lang
- {
- public interface ISeq : IPersistentList
- {
-
- Object first();
-
- ISeq rest();
- }
- }
diff --git a/src/cli/runtime/IndexedSeq.cs b/src/cli/runtime/IndexedSeq.cs deleted file mode 100644 index 49b5a297..00000000 --- a/src/cli/runtime/IndexedSeq.cs +++ /dev/null @@ -1,21 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- */
-
-using System;
- -namespace clojure.lang
-{ -
-public interface IndexedSeq : ISeq{
-
-int index();
-}
-
-}
\ No newline at end of file diff --git a/src/cli/runtime/Indexer.cs b/src/cli/runtime/Indexer.cs deleted file mode 100644 index 8b2cb535..00000000 --- a/src/cli/runtime/Indexer.cs +++ /dev/null @@ -1,18 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-
-namespace clojure.lang
-{
- public class Indexer :AFn
- {
- }
-}
diff --git a/src/cli/runtime/InstanceMemberSymbol.cs b/src/cli/runtime/InstanceMemberSymbol.cs deleted file mode 100644 index d14cd528..00000000 --- a/src/cli/runtime/InstanceMemberSymbol.cs +++ /dev/null @@ -1,181 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
- -namespace clojure.lang
-{ -
-public class InstanceMemberSymbol :HostSymbol, IFn {
-readonly public String className;
-readonly public String memberName;
-
-public InstanceMemberSymbol(String name) : base(name) {
-int lastDot = name.LastIndexOf('.');
-if (lastDot == 0)
- this.className = null;
-else
- this.className = name.Substring(1, lastDot-1);
-this.memberName = name.Substring(lastDot + 1);
-}
-
-public Object invoke() /**/ {
-return AFn.throwArity();
- }
-
-
-public Object invoke(Object obj) //
- {
-
- return Reflector.invokeInstanceMember(memberName, obj);
- }
-
-public Object invoke(Object obj, Object val) //
- {
-
- return Reflector.invokeInstanceMember(memberName, obj, val);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11)
- {
- return Reflector
- .invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14, arg15);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14, arg15, arg16);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14, arg15, arg16, arg17);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18, Object arg19)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19);
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20)
- {
- return Reflector.invokeInstanceMember(memberName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20);
- }
-
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20
- , params Object[] args)
- {
- throw new InvalidOperationException("Can't call functions of more than 20 arguments");
- }
-
-
-public Object applyTo(ISeq arglist) /**/ {
-return AFn.applyToHelper(this, arglist);
- } -
-}
-
-}
diff --git a/src/cli/runtime/IntegerNum.cs b/src/cli/runtime/IntegerNum.cs deleted file mode 100644 index 5e58a514..00000000 --- a/src/cli/runtime/IntegerNum.cs +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 28, 2006 10:11:55 AM */ - -using System;
- -namespace clojure.lang
-{ - -public abstract class IntegerNum : RationalNum { - -} -}
\ No newline at end of file diff --git a/src/cli/runtime/Iter.cs b/src/cli/runtime/Iter.cs deleted file mode 100644 index 605d2d61..00000000 --- a/src/cli/runtime/Iter.cs +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/
-
-using System;
-
-namespace clojure.lang
- {
- public interface Iter
- {
-/**
- * * Multiple calls to get() are allowed prior to calling iterate()
- * * @return the currently referenced item/element/value
- * */
- Object get();
-
- /**
- * * This may destroy or otherwise invalidate the object it is called upon
- * * so always capture and use the return value (even though sometimes you may find it is the same object)
- * * @return The next iter to use, or null if at end of sequence
- * */
- Iter iterate();
- }
- }
diff --git a/src/cli/runtime/Keyword.cs b/src/cli/runtime/Keyword.cs deleted file mode 100644 index 432b4ac6..00000000 --- a/src/cli/runtime/Keyword.cs +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 29, 2006 10:39:05 AM */ - -using System;
-
- -namespace clojure.lang
-{ - -public class Keyword : Symbol, IFn{ - - -internal Keyword(String name):base(name)
{
}
public Object invoke() /*throws Exception*/ {
- return AFn.throwArity();
-}
/**
* Indexer implements IFn for attr access
* This single arg version is the getter
* @param tld
* @param obj - must be AMap
* @return the value of the attr or nil if not found
*/
public Object invoke( Object obj) /*throws Exception*/
{
- if (obj == null)
- return null;
- return ((IPersistentMap)obj).get(this);
}
/**
* Indexer implements IFn for attr access
* This two arg version is the setter
* @param tld
* @param obj - must be AMap
* @param val
* @return val
*/
public Object invoke( Object obj, Object val) /*throws Exception*/
{
- return RT.assoc(this, val,obj);
} - -public Object invoke(Object arg1, Object arg2, Object arg3)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19)
- {
- return AFn.throwArity();
- }
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20)
- {
- return AFn.throwArity();
- }
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20
- , params Object[] args)
- {
- return AFn.throwArity();
- }
-
-public Object applyTo( ISeq arglist) /*throws Exception*/ {
- return AFn.applyToHelper(this, arglist);
-} -} -}
\ No newline at end of file diff --git a/src/cli/runtime/LineNumberingTextReader.cs b/src/cli/runtime/LineNumberingTextReader.cs deleted file mode 100644 index 71f05e8d..00000000 --- a/src/cli/runtime/LineNumberingTextReader.cs +++ /dev/null @@ -1,75 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-using System.IO;
-
-namespace clojure.lang
- {
-
-
-public class LineNumberingTextReader : TextReader, IDisposable
- {
- TextReader impl;
- int line = 0;
- int unreadChar;
- bool haveUnread = false;
-
- public LineNumberingTextReader(TextReader r){
- this.impl = r;
- }
-
- public int getLineNumber(){
- return line;
- }
-
- override public int Read(){
- int ret;
- if(haveUnread)
- {
- ret = unreadChar;
- haveUnread = false;
- }
- else
- ret = impl.Read();
- if(ret == '\n')
- ++line;
- return ret;
- }
-
- public void unread(int ch){
- if(haveUnread)
- throw new InvalidOperationException("Can't unread more than once in a row");
- unreadChar = ch;
- haveUnread = true;
- if (ch == '\n')
- --line;
- }
-
- override public int Peek(){
- return impl.Peek();
- }
-
- public override void Close()
- {
- base.Close();
- impl.Close();
- }
-
- void IDisposable.Dispose()
- {
- base.Dispose();
- impl.Dispose();
- }
-
- }
-
-
- }
diff --git a/src/cli/runtime/LispReader.cs b/src/cli/runtime/LispReader.cs deleted file mode 100644 index e1fcf36d..00000000 --- a/src/cli/runtime/LispReader.cs +++ /dev/null @@ -1,439 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-using System.IO;
-using System.Text.RegularExpressions;
-using java.math;
-using System.Text;
-using System.Collections;
- -namespace clojure.lang
-{ -
-
-public class LispReader {
-
-static Symbol QUOTE = Symbol.intern("quote");
-static Symbol BACKQUOTE = Symbol.intern("backquote");
-static Symbol UNQUOTE = Symbol.intern("unquote");
-static Symbol UNQUOTE_SPLICING = Symbol.intern("unquote-splicing");
-
-static IFn[] macros = new IFn[256];
-static Regex symbolPat = new Regex("[:]?[\\D-[:\\.]][^:\\.]*",RegexOptions.Compiled);
- static Regex varPat = new Regex("([\\D-[:\\.]][^:\\.]*):([\\D-[:\\.]][^:\\.]*)", RegexOptions.Compiled);
- static Regex intPat = new Regex("[-+]?[0-9]+\\.?", RegexOptions.Compiled);
- static Regex ratioPat = new Regex("([-+]?[0-9]+)/([0-9]+)", RegexOptions.Compiled);
- static Regex floatPat = new Regex("[-+]?[0-9]+(\\.[0-9]+)?([eE][-+]?[0-9]+)?", RegexOptions.Compiled);
-
- static Regex accessorPat = new Regex("\\.[a-zA-Z_]\\w*", RegexOptions.Compiled);
- static Regex instanceMemberPat = new Regex("\\.([a-zA-Z_][\\w\\.]*)\\.([a-zA-Z_]\\w*)", RegexOptions.Compiled);
- static Regex staticMemberPat = new Regex("([a-zA-Z_][\\w\\.]*)\\.([a-zA-Z_]\\w*)", RegexOptions.Compiled);
- static Regex classNamePat = new Regex("([a-zA-Z_][\\w\\.]*)\\.", RegexOptions.Compiled);
-
-static LispReader(){
-macros['"'] = new StringReader();
-macros[';'] = new CommentReader();
-macros['\''] = new QuoteReader();
-macros['`'] = new BackquoteReader();
-macros[','] = new UnquoteReader();
-macros['('] = new ListReader();
-macros[')'] = new UnmatchedDelimiterReader();
-macros['\\'] = new CharacterReader();
-}
-
-static public Object read(LineNumberingTextReader r, bool eofIsError, Object eofValue, bool isRecursive)
- {
-
- for (; ;)
- {
- int ch = r.Read();
-
- while (Char.IsWhiteSpace((char)ch))
- ch = r.Read();
-
- if (ch == -1)
- {
- if (eofIsError)
- throw new Exception("EOF while reading");
- return eofValue;
- }
-
- if (Char.IsDigit((char)ch))
- {
- Object n = readNumber(r, (char)ch);
- if (RT.suppressRead())
- return null;
- return n;
- }
-
- IFn macroFn = getMacro(ch);
- if (macroFn != null)
- {
- Object ret = macroFn.invoke(r, (char)ch);
- if(RT.suppressRead())
- return null;
- //no op macros return the reader
- if (ret == r)
- continue;
- return ret;
- }
-
- if (ch == '+' || ch == '-')
- {
- int ch2 = r.Read();
- if (Char.IsDigit((char)ch2))
- {
- r.unread(ch2);
- Object n = readNumber(r, (char)ch);
- if (RT.suppressRead())
- return null;
- return n;
- }
- r.unread(ch2);
- }
-
- String token = readToken(r,(char)ch);
- if (RT.suppressRead())
- return null;
- return interpretToken(token);
- }
-}
-
-static private String readToken(LineNumberingTextReader r, char initch) {
- StringBuilder sb = new StringBuilder();
- sb.Append(initch);
-
- for(;;)
- {
- int ch = r.Read();
- if(ch == -1 || Char.IsWhiteSpace((char)ch) || isMacro(ch))
- {
- r.unread(ch);
- return sb.ToString();
- }
- sb.Append((char)ch);
- }
-}
-
-static private Object readNumber(LineNumberingTextReader r, char initch){
- StringBuilder sb = new StringBuilder();
- sb.Append(initch);
-
- for(;;)
- {
- int ch = r.Read();
- if(ch == -1 || Char.IsWhiteSpace((char)ch) || isMacro(ch))
- {
- r.unread(ch);
- break;
- }
- sb.Append((char)ch);
- }
-
- String s = sb.ToString();
- Object n = matchNumber(s);
- if(n == null)
- throw new InvalidDataException("Invalid number: " + s);
- return n;
-}
-
-/*
-static private Object readSymbol(LineNumberingTextReader r, char initch) {
- StringBuilder sb = new StringBuilder();
- sb.Append(initch);
-
- for(;;)
- {
- int ch = r.Read();
- if(ch == -1 || Char.IsWhiteSpace((char)ch) || isMacro(ch))
- {
- r.unread(ch);
- return Symbol.intern(sb.ToString());
- }
- else if(ch == '.')
- {
- r.unread(ch);
- Object ret = Symbol.intern(sb.ToString());
- Object mem = null;
- while((mem = readMember(r)) != null)
- {
- //x.foo ==> (.foo x)
- if(mem is Symbol)
- ret = RT.list(mem, ret);
- else //x.foo(y z) ==> (.foo x y z)
- {
- ISeq rseq = RT.seq(mem);
- ret = RT.cons(rseq.first(), RT.cons(ret, RT.rest(rseq)));
- }
- }
- return ret;
- }
- sb.Append((char)ch);
- }
-}
-*/
-static private Object interpretToken(String s) {
- if (s.Equals("null"))
- {
- return null;
- }
- Object ret = null;
-
- ret = matchVar(s);
- if(ret != null)
- return ret;
-
- return Symbol.intern(s);
-}
-
-/*
-private static Object matchHostName(String s) {
- Match m = accessorPat.Match(s);
- if(m.Success && m.Length == s.Length)
- return new Accessor(s);
- m = classNamePat.Match(s);
- if(m.Success && m.Length == s.Length)
- return new ClassName(RT.resolveClassNameInContext(m.Groups[1].Value));
- m = instanceMemberPat.Match(s);
- if(m.Success && m.Length == s.Length)
- return new InstanceMemberName(RT.resolveClassNameInContext(m.Groups[1].Value),m.Groups[2].Value);
- m = staticMemberPat.Match(s);
- if(m.Success && m.Length == s.Length)
- return new StaticMemberName(RT.resolveClassNameInContext(m.Groups[1].Value),m.Groups[2].Value);
-
- return null;
-}
-
-private static Object matchSymbol(String s) {
- Match m = symbolPat.Match(s);
- if(m.Success && m.Length == s.Length)
- return Symbol.intern(s);
- return null;
-}
-*/
-
-private static Object matchVar(String s) {
- Match m = varPat.Match(s);
- if(m.Success && m.Length == s.Length)
- return Module.intern(m.Groups[1].Value,m.Groups[2].Value);
- return null;
-}
-
-private static Object matchNumber(String s) {
- Match m = intPat.Match(s);
- if(m.Success && m.Length == s.Length)
- return Num.from(new BigInteger(s));
- m = floatPat.Match(s);
- if(m.Success && m.Length == s.Length)
- return Num.from(Double.Parse(s));
- m = ratioPat.Match(s);
- if(m.Success && m.Length == s.Length)
- {
- return Num.divide(new BigInteger(m.Groups[1].Value),new BigInteger(m.Groups[2].Value));
- }
- return null;
-}
-
-static private IFn getMacro(int ch) {
- if (ch < macros.Length)
- return macros[ch];
- return null;
-}
-
-static private bool isMacro(int ch) {
- return (ch < macros.Length && macros[ch] != null);
-}
-
-
-class StringReader : AFn{
- override public Object invoke(Object reader, Object doublequote) {
- StringBuilder sb = new StringBuilder();
- LineNumberingTextReader r = (LineNumberingTextReader) reader;
-
- for(int ch = r.Read();ch != '"';ch = r.Read())
- {
- if(ch == -1)
- throw new Exception("EOF while reading string");
- if(ch == '\\') //escape
- {
- ch = r.Read();
- if(ch == -1)
- throw new Exception("EOF while reading string");
- switch(ch)
- {
- case 't':
- ch = '\t';
- break;
- case 'r':
- ch = '\r';
- break;
- case 'n':
- ch = '\n';
- break;
- case '\\':
- break;
- case '"':
- break;
- default:
- throw new Exception("Unsupported escape character: \\" + (char)ch);
- }
- }
- sb.Append((char)ch);
- }
- return sb.ToString();
- }
-
-}
-class CommentReader : AFn{
- override public Object invoke(Object reader, Object semicolon)
- {
- LineNumberingTextReader r = (LineNumberingTextReader) reader;
- int ch;
- do
- {
- ch = r.Read();
- } while (ch != -1 && ch != '\n' && ch != '\r');
- return r;
- }
-
-}
-
-class QuoteReader : AFn{
- override public Object invoke(Object reader, Object quote) {
- LineNumberingTextReader r = (LineNumberingTextReader)reader;
- Object o = read(r, true, null, true);
- return RT.list(QUOTE, o);
- }
-}
-
-class BackquoteReader : AFn{
- override public Object invoke(Object reader, Object backquote) {
- LineNumberingTextReader r = (LineNumberingTextReader)reader;
- Object o = read(r, true, null, true);
- return RT.list(BACKQUOTE, o);
- }
-}
-
-class UnquoteReader : AFn{
- override public Object invoke(Object reader, Object comma) {
- LineNumberingTextReader r = (LineNumberingTextReader)reader;
- int ch = r.Read();
- if(ch == -1)
- throw new Exception("EOF while reading character");
- if(ch == '^')
- {
- Object o = read(r, true, null, true);
- return RT.list(UNQUOTE_SPLICING, o);
- }
- else
- {
- r.unread(ch);
- Object o = read(r, true, null, true);
- return RT.list(UNQUOTE, o);
- }
- }
-}
-class CharacterReader : AFn{
- override public Object invoke(Object reader, Object backslash)
- {
- LineNumberingTextReader r = (LineNumberingTextReader) reader;
- int ch = r.Read();
- if(ch == -1)
- throw new Exception("EOF while reading character");
- String token = readToken(r,(char)ch);
- if(token.Length == 1)
- return token[0];
- else if(token.Equals("newline"))
- return '\n';
- else if(token.Equals("space"))
- return ' ';
- else if(token.Equals("tab"))
- return '\t';
- throw new Exception("Unsupported character: \\" + token);
- }
-
-}
-class ListReader : AFn{
- override public Object invoke(Object reader, Object leftparen) {
- LineNumberingTextReader r = (LineNumberingTextReader) reader;
- return readDelimitedList(')', r, true);
- }
-
-}
-class UnmatchedDelimiterReader : AFn{
- override public Object invoke(Object reader, Object rightdelim) {
- throw new Exception("Unmatched delimiter: " + rightdelim);
- }
-
-}
-public static ISeq readDelimitedList(char delim, LineNumberingTextReader r, bool isRecursive) {
- ArrayList a = new ArrayList();
-
- for (; ;)
- {
- int ch = r.Read();
-
- while (Char.IsWhiteSpace((char)ch))
- ch = r.Read();
-
- if (ch == -1)
- throw new Exception("EOF while reading");
-
- if(ch == delim)
- break;
-
- IFn macroFn = getMacro(ch);
- if (macroFn != null)
- {
- Object mret = macroFn.invoke(r, (char)ch);
- //no op macros return the reader
- if (mret != r)
- a.Add(mret);
- }
- else
- {
- r.unread(ch);
-
- Object o = read(r, true, null, isRecursive);
- if (o != r)
- a.Add(o);
- }
- }
-
- return RT.seq(a);
-}
-
-/*
-public static void Main(String[] args){
- LineNumberingTextReader r = new LineNumberingTextReader(Console.In);
- TextWriter w = Console.Out;
- Object ret = null;
- try{
- for(;;)
- {
- ret = LispReader.read(r, true, null, false);
- RT.print(ret, w);
- w.Write('\n');
- w.Flush();
- }
- }
- catch(Exception e)
- {
- //e.printStackTrace();
- Console.Error.WriteLine(e.StackTrace);
- }
-}
-//*/
-
-}
-
-}
-
diff --git a/src/cli/runtime/MapEntry.cs b/src/cli/runtime/MapEntry.cs deleted file mode 100644 index 1ff7f93a..00000000 --- a/src/cli/runtime/MapEntry.cs +++ /dev/null @@ -1,135 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-using System.Collections;
-
-namespace clojure.lang
-{
-public class MapEntry : APersistentMap , IMapEntry{
-readonly Object _key;
-readonly Object _val;
-
-public MapEntry(Object key, Object val) {
- this._key = key;
- this._val = val;
-}
-
-public Object key() {
- return _key;
-}
-
-public Object val() {
- return _val;
-}
-
-override public bool contains(Object key) {
- return RT.equal(_key, key);
-}
-
-override public IMapEntry find(Object key) {
- return RT.equal(_key, key)?this:null;
-}
-
-override public Associative assoc(Object key, Object val) {
- if(RT.equal(_key, key))
- {
- if(_val == val)
- return this;
- return (MapEntry) new MapEntry(key, val).withMeta(_meta);
- }
- return (IPersistentMap) new PersistentArrayMap(_key,_val,key,val).withMeta(_meta);
-}
-
-override public Object get(Object key) {
- return RT.equal(_key, key)?_val:null;
-}
-
-override public IPersistentMap assocEx(Object key, Object val) {
- if(RT.equal(_key, key))
- throw new Exception("Key already present");
- return (IPersistentMap)assoc(key, val);
-}
-
-override public IPersistentMap without(Object key) {
- if(RT.equal(_key, key))
- return (IPersistentMap) PersistentArrayMap.EMPTY.withMeta(_meta);
- return this;
-}
-
-override public int count() {
- return 1;
-}
-
-override public IEnumerator GetEnumerator() {
- return new Iter(this);
-}
-
-class Iter : IEnumerator{
- MapEntry e;
- bool first = true;
-
- public Iter(MapEntry e) {
- this.e = e;
- }
-
-#region IEnumerator Members
-
-public object Current
- {
- get {return e;}
- }
-
-public bool MoveNext()
- {
- if(first)
- {
- first = false;
- return true;
- }
- return false;
- }
-
-public void Reset()
- {
- throw new Exception("The method or operation is not implemented.");
- }
-
-#endregion
- }
-
-
-override public ISeq seq() {
- return new Seq(this);
-}
-
-class Seq : ASeq{
- readonly MapEntry e;
-
- public Seq(MapEntry e) {
- this.e = e;
- }
-
- override public Object first() {
- return e;
- }
-
- override public ISeq rest() {
- return null;
- }
-
- override public int count(){
- return 1;
- }
-
-}
-}
-
-}
diff --git a/src/cli/runtime/Module.cs b/src/cli/runtime/Module.cs deleted file mode 100644 index 3e396783..00000000 --- a/src/cli/runtime/Module.cs +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 27, 2006 1:29:39 PM */ - -using System;
-using System.Collections.Specialized;
- -namespace clojure.lang
-{ - -public class Module
-{ - -/** - * String->Module - */ -static public HybridDictionary table = new HybridDictionary(); - -/** - * Symbol->Var - */
-public HybridDictionary vars = new HybridDictionary();
-public String name; - - -Module(String name) - { - this.name = name; - table.Add(name, this); - } - -static public Module find(String name) - { - return (Module) table[name]; - } - -static public Module findOrCreate(String name) - { - lock(table) - { - Module ns = find(name); - if(ns == null) - table.Add(name,ns = new Module(name)); - return ns; - } - }
-
-public Var find(Symbol sym){
- lock(vars)
- {
- return (Var) vars[sym];
- }
-}
-
-static public Var intern(String ns, String name)
- {
- return findOrCreate(ns).intern(Symbol.intern(name));
- }
-
-public Var intern(Symbol sym)
{
lock(vars)
{
Var var = (Var) vars[sym];
if(var == null)
vars.Add(sym,var = new Var(sym, this));
return var;
}
}
-} -} diff --git a/src/cli/runtime/Num.cs b/src/cli/runtime/Num.cs deleted file mode 100644 index 6058ab93..00000000 --- a/src/cli/runtime/Num.cs +++ /dev/null @@ -1,351 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 28, 2006 10:07:33 AM */ - -using System;
-using java.math;
-
-namespace clojure.lang
-{ - -public abstract class Num : IComparable , IConvertible
- { - -public static Num ZERO = from(0); -public static Num ONE = from(1); - -static public Num from(int val) - { - //todo - cache a bunch of small fixnums - return new FixNum(val); - } - -static public Num from(double val) - { - return new DoubleNum(val); - } - -static public Num from(long val) - { - if(val <= Int32.MaxValue && val >= Int32.MinValue) - return from((int) val); - else - return new BigNum(val); - } - -static public Num from(BigInteger val) - { - if(val.bitLength() < 32) - return from(val.intValue()); - else - return new BigNum(val); - } - - internal static BigInteger BIGTEN = BigInteger.valueOf(10); - -static public Num from(Object x) - { - if(x is Num) - return (Num) x; - else - { - IConvertible c = x as IConvertible; - if(c != null) - { - switch(c.GetTypeCode()) - { - case TypeCode.Int32: - return Num.from((Int32) x); - case TypeCode.Double: - case TypeCode.Single: - return Num.from(Convert.ToDouble(x)); - case TypeCode.Int64: - return Num.from((Int64) x); - //TODO: Decimal w/o string conversion - case TypeCode.Decimal: - BigDecimal d = new BigDecimal(x.ToString()); - return Num.divide(d.movePointRight(d.scale()).toBigInteger(), - BIGTEN.pow(d.scale())); - default: - return Num.from(Convert.ToInt32(x)); - } - } - else if(x is BigInteger) - return Num.from((BigInteger) x); - else - throw new ArgumentException("Cannot convert argument: " + x + " to Num"); - } - }
-
-
- virtual public byte byteValue()
- {
- return checked((byte)intValue());
- }
-
- virtual public short shortValue()
- {
- return checked((short)intValue());
- } - - abstract public double doubleValue(); - - abstract public float floatValue(); - - abstract public int intValue(); - - abstract public long longValue(); - -static public Num add(Object x, Object y) - { - //if(x instanceof Num && y instanceof Num) - //return ((Num)x).add((Num) y); - return Num.from(x).add(Num.from(y)); - } - -abstract public Num add(Num rhs); - -abstract public Num addTo(int x); - -abstract public Num addTo(BigInteger x); - -abstract public Num addTo(RatioNum x); - -static public Num subtract(Object x, Object y) - { - return Num.from(y).subtractFrom(Num.from(x)); - } - -//this double-dispatches to addTo(-self) -abstract public Num subtractFrom(Num rhs); - -static public Num multiply(Object x, Object y) - { - return Num.from(x).multiplyBy(Num.from(y)); - } - -abstract public Num multiplyBy(Num rhs); - -abstract public Num multiply(int x); - -abstract public Num multiply(BigInteger x); - -abstract public Num multiply(RatioNum x); - -static public Num divide(Object x, Object y) - { - return Num.from(x).divideBy(Num.from(y)); - } - -abstract public Num divideBy(Num rhs); - -abstract public Num divide(int x); - -abstract public Num divide(BigInteger x); - -abstract public Num divide(RatioNum x); - -static public Object truncate( Object num, Object div) - { - return Num.from(div).truncateDivide( Num.from(num)); - } - -abstract public Object truncateDivide( Num rhs); - -abstract public Object truncateBy( int x); - -abstract public Object truncateBy( BigInteger x); - -abstract public Object truncateBy( RatioNum x); - -static public Object truncateBigints( BigInteger n, BigInteger d) - { - BigInteger[] result = n.divideAndRemainder(d); - return RT.setValues( Num.from(result[0]), Num.from(result[1])); - } - - internal static BigInteger BIG_ONE = BigInteger.valueOf(1); - internal static BigInteger BIG_ZERO = BigInteger.valueOf(0); - -static public Num divide(BigInteger n, BigInteger d) - { - BigInteger gcd = n.gcd(d); - if(gcd.Equals(BIG_ZERO)) - return Num.ZERO; - n = n.divide(gcd); - d = d.divide(gcd); - if(d.Equals(BIG_ONE)) - return Num.from(n); - return new RatioNum((IntegerNum) Num.from(d.signum() < 0 ? n.negate() : n), - (IntegerNum) Num.from(d.signum() < 0 ? d.negate() : d)); - } - -static public Boolean equiv(Object x, Object y) - { - return Num.from(x).equiv(Num.from(y)); - } - -abstract public Boolean equiv(Num rhs); - -abstract public Boolean equivTo(int x); - -abstract public Boolean equivTo(BigInteger x); - -abstract public Boolean equivTo(RatioNum x); - -static public Boolean lt(Object x, Object y) - { - return Num.from(x).lt(Num.from(y)); - } - -static public Boolean lte(Object x, Object y) - { - Num lx = Num.from(x); - Num ly = Num.from(y); - return lx.lt(ly) || lx.equiv(ly); - } - -static public Boolean gt(Object x, Object y) - { - return Num.from(y).lt(Num.from(x)); - } - -static public Boolean gte(Object x, Object y) - { - Num lx = Num.from(x); - Num ly = Num.from(y); - return ly.lt(lx) || lx.equiv(ly); - } - -abstract public Boolean lt(Num rhs); - -abstract public Boolean gt(int x); - -abstract public Boolean gt(BigInteger x); - -abstract public Boolean gt(RatioNum x); - -static public Num negate(Object x) - { - return Num.from(x).negate(); - } - -abstract public Num negate(); - -abstract public Boolean minusp(); - -abstract public Boolean plusp(); - -abstract public Num oneMinus(); - -abstract public Num onePlus(); - -public int CompareTo(Object obj) - { - Num other = Num.from(obj); - if(this.equiv(other)) - return 0; - else if(this.lt(other)) - return -1; - else - return 1; - }
-
-#region IConvertible Members
-
-public TypeCode GetTypeCode()
- {
-throw new Exception("The method or operation is not implemented.");
- }
-
-public bool ToBoolean(IFormatProvider provider)
- {
- return true;
- }
-
-public byte ToByte(IFormatProvider provider)
- {
- return checked((byte)intValue());
- }
-
-public char ToChar(IFormatProvider provider)
- {
- return checked((char)intValue());
- }
-
-public DateTime ToDateTime(IFormatProvider provider)
- {
-throw new Exception("The method or operation is not implemented.");
- }
-
-public decimal ToDecimal(IFormatProvider provider)
- {
-throw new Exception("The method or operation is not implemented.");
- }
-
-public double ToDouble(IFormatProvider provider)
- {
- return doubleValue();
- }
-
-public short ToInt16(IFormatProvider provider)
- {
- return checked((short)intValue());
- }
-
-public int ToInt32(IFormatProvider provider)
- {
- return intValue();
- }
-
-public long ToInt64(IFormatProvider provider)
- {
- return longValue();
- }
-
-public sbyte ToSByte(IFormatProvider provider)
- {
- return checked((sbyte)intValue());
- }
-
-public float ToSingle(IFormatProvider provider)
- {
- return floatValue();
- }
-
-public string ToString(IFormatProvider provider)
- {
- return ToString();
- }
-
-public object ToType(Type conversionType, IFormatProvider provider)
- {
-throw new Exception("The method or operation is not implemented.");
- }
-
-public ushort ToUInt16(IFormatProvider provider)
- {
-throw new Exception("The method or operation is not implemented.");
- }
-
-public uint ToUInt32(IFormatProvider provider)
- {
-throw new Exception("The method or operation is not implemented.");
- }
-
-public ulong ToUInt64(IFormatProvider provider)
- {
-throw new Exception("The method or operation is not implemented.");
- }
-
-#endregion
- } -} diff --git a/src/cli/runtime/Obj.cs b/src/cli/runtime/Obj.cs deleted file mode 100644 index ebafc9c4..00000000 --- a/src/cli/runtime/Obj.cs +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 25, 2006 3:44:58 PM */ - -using System;
- -namespace clojure.lang
-{ - -public abstract class Obj{ - -internal volatile IPersistentMap _meta = null;
-
-
-public IPersistentMap meta() {
- return _meta;
-}
-
-abstract public Obj withMeta(IPersistentMap meta);
-
- -} - -}
\ No newline at end of file diff --git a/src/cli/runtime/PerisistentArrayList.cs b/src/cli/runtime/PerisistentArrayList.cs deleted file mode 100644 index 9c27932d..00000000 --- a/src/cli/runtime/PerisistentArrayList.cs +++ /dev/null @@ -1,115 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-using System.Collections;
-
-namespace clojure.lang
-{
-public class PersistentArrayList : PersistentArray, IPersistentList{
-
-int _count;
-
-public PersistentArrayList(int initialCapacity) : base(initialCapacity){
-
- _count = 0;
-}
-
-PersistentArrayList(Master master,int rev,int baseline, BitArray history, int count):base(master,rev,baseline,history){
-
- this._count = count;
-}
-
-PersistentArrayList(int size, Object defaultVal, float loadFactor, int count):base(size, defaultVal, loadFactor) {
-
- this._count = count;
-}
-
-public PersistentArrayList(IPersistentArray init, int initialCapacity):base(init,initialCapacity){
- _count = Math.Min(init.count(),initialCapacity);
-}
-
-override public Object nth(int i) {
- if(i >= _count)
- throw new IndexOutOfRangeException();
-
- return base.nth(i);
-}
-
-override public IPersistentArray assocN(int i,Object val) {
- if(i >= _count)
- throw new IndexOutOfRangeException();
-
- return base.assocN(i, val);
-}
-
-override public int length(){
- return _count;
-}
-
-override public int count(){
- return _count;
-}
-
-override public IPersistentCollection cons(Object val) {
- if(_count == data.master.array.Length) //full
- {
- lock(data.master){
- if(_count == data.master.array.Length) //still full
- grow();
- }
- }
- PersistentArrayList ret = (PersistentArrayList) base.assocN(_count, val);
- ret._count = _count + 1;
- return ret;
-}
-
-public Object peek(){
- if(_count > 0)
- return nth(_count - 1);
- return null;
-}
-
-public IPersistentList pop() {
- if(_count == 0)
- throw new InvalidOperationException();
- PersistentArrayList ret = new PersistentArrayList(data.master, data.rev, data.baseline, data.history, _count - 1);
- ret._meta = _meta;
- return ret;
-}
-
-
-private void grow() {
- //must be called inside lock of master
- if(data.master.next != null) //this master has been trimmed, but this rev is not yet propagated
- trim();
-
- Master newMaster = new Master(data.master.array.Length * 2, data.master.defaultVal, data.master.loadFactor, data.master.basis);
- newMaster.rev = data.master.rev;
- newMaster.load = data.master.load;
- for(int i=0;i<data.master.array.Length;i++)
- newMaster.array[i] = data.master.array[i];
- this.data = new Data(newMaster, data.rev, data.baseline, data.history);
-}
-
-override internal PersistentArray create(Master master,int rev,int baseline, BitArray history){
- PersistentArray ret = new PersistentArrayList(data.master, rev, baseline, history,_count);
- ret._meta = _meta;
- return ret;
- }
-
-override internal PersistentArray create(int size, Object defaultVal, float loadFactor) {
- PersistentArray ret = new PersistentArrayList(size, defaultVal, loadFactor,_count);
- ret._meta = _meta;
- return ret;
- }
-
-}
-}
diff --git a/src/cli/runtime/PersistentArray.cs b/src/cli/runtime/PersistentArray.cs deleted file mode 100644 index 40e1fbc0..00000000 --- a/src/cli/runtime/PersistentArray.cs +++ /dev/null @@ -1,597 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-/* rich Jun 2, 2006 */
-
-using System;
-using System.Collections;
-
-namespace clojure.lang
-{
-/**
- * Note that instances of this class are constant values
- * i.e. set() returns a new array, old one is intact
- *
- * Multiple revisions (thread-safely) share the same master array
- *
- * Constant time most-recent-revision lookups
- * Amortized constant-time sequential revisions (when loadFactor > 1)
- * where a sequential revision is a revision of the most recent revision
- *
- * Non-sequential revisions are O(length), but with a small constant multiplier of 1/32
- * Worst-case O(r) lookups for oldest revs where r is number of revisions
- * at index i since last (automatic or manual) isolate. If set()s are roughly evenly
- * distributed, r should be approximately == loadFactor, i.e. constant
- * In pathological case (all mods to same index), r == (loadFactor * length)
- *
- * (loadFactor * length) old values are retained, even if the array revisions aren't
- * Default loadFactor is 2.1
- * When the load exceeds (loadFactor * length) the next revision is automatically isolated
- * You can determine how many values are in the shared master by calling load()
- * and can trim them by calling isolate() or resize(), which yield a new array with no
- * sharing and no old values
- *
- * See Cohen for basic idea
- * I added hybrid most-recent-sequential-range + shared-bitset idea, multi-thread-safety
- */
-
- public class PersistentArray : APersistentArray, IEnumerable
- {
-
- #region IEnumerable Members
-
- public IEnumerator GetEnumerator()
- {
- return new ValIter(this);
- }
-
- #endregion
-
- override public ISeq seq()
- {
- if (length() > 0)
- return new Seq(this, 0);
- return null;
- }
-
- public ISeq rseq()
- {
- if (count() > 0)
- return new RSeq(this, count() - 1);
- return null;
- }
-
-internal class Master{
- internal readonly Entry[] array;
- internal readonly Object defaultVal;
- internal int rev;
- internal int load;
- internal readonly int maxLoad;
- internal readonly float loadFactor;
- internal readonly int[] basis;
- internal Master next;
-
- internal Master(int size, Object defaultVal, float loadFactor, int[] basis)
- {
- this.array = new Entry[size];
- this.defaultVal = defaultVal;
- this.rev = 0;
- this.load = 0;
- this.maxLoad = (int)(size * loadFactor);
- this.basis = basis;
- this.loadFactor = loadFactor;
- }
- internal Master(Master parent)
- {
- this.array = new Entry[parent.array.Length];
- this.defaultVal = parent.defaultVal;
- this.rev = 0;
- this.load = 0;
- this.maxLoad = parent.maxLoad;
- this.loadFactor = parent.loadFactor;
- this.next = null;
-
- this.basis = new int[parent.array.Length];
- }
- }
-
-internal class Entry
- {
- internal readonly int rev;
- internal readonly Object val;
-
- internal Entry(int rev, Object val)
- {
- this.rev = rev;
- this.val = val;
- }
-
- internal virtual Entry rest()
- {
- return null;
- }
-
- internal static Entry create(int rev, Object val, Entry rest)
- {
- if (rest == null)
- return new Entry(rev, val);
- return new EntryLink(rev, val, rest);
- }
- }
-
-internal class EntryLink : Entry
- {
- internal readonly Entry _rest;
-
- internal EntryLink(int rev, Object val, Entry rest) :base(rev,val)
- {
- this._rest = rest;
- }
-
- override internal Entry rest(){
- return _rest;
- }
-}
-
-internal class Seq : ASeq, IndexedSeq{
- readonly PersistentArray p;
- readonly int i;
-
- internal Seq(PersistentArray p, int i){
- this.p = p;
- this.i = i;
- }
-
- override public Object first() {
- return p.nth(i);
- }
-
- override public ISeq rest() {
- if(i+1 < p.length())
- return new Seq(p, i + 1);
- return null;
- }
-
- public override int count() {
- return p.count() - i;
- }
-
-#region IndexedSeq Members
-
-public int index()
- {
- return i;
- }
-
-#endregion
- }
-
-class RSeq : ASeq, IndexedSeq{
- readonly PersistentArray p;
- readonly int i;
-
- internal RSeq(PersistentArray p, int i){
- this.p = p;
- this.i = i;
- }
-
- public override Object first() {
- return p.nth(i);
- }
-
- public override ISeq rest() {
- if(i > 0)
- return new RSeq(p, i - 1);
- return null;
- }
-
- public int index() {
- return i;
- }
-
- public override int count() {
- return i + 1;
- }
-}
-internal class ValIter : IEnumerator
- {
- internal PersistentArray p;
- internal int i;
-
- internal ValIter(PersistentArray p)
- {
- this.p = p;
- this.i = -1;
-}
-
-#region IEnumerator Members
-
-public object Current
- {
- get { return p.nth(i); }
- }
-
-public bool MoveNext()
- {
- ++i;
- return i < p.length();
- }
-
-public void Reset()
- {
- throw new Exception("The method or operation is not implemented.");
- }
-
-#endregion
- }
-
-internal class Data{
- internal readonly Master master;
- internal readonly int rev;
- internal readonly int baseline;
- internal readonly BitArray history;
-
- public Data(Master master, int rev, int baseline, BitArray history)
- {
- this.master = master;
- this.rev = rev;
- this.baseline = baseline;
- this.history = history;
- }
- }
-
-internal volatile Data data;
-
-public PersistentArray(int size)
- : this(size, (Object)null)
- {
- }
-
-public PersistentArray(int size, Object defaultVal)
- :this(size,defaultVal,2.1f)
- {
- }
-
-public PersistentArray(int size, Object defaultVal, float loadFactor){
- this.data = new Data(new Master(size, defaultVal, loadFactor,null), 0, 0, null);
-}
-
- internal PersistentArray(Master master, int rev, int baseline, BitArray history)
- {
- this.data = new Data(master, rev, baseline, history);
-}
-
-public PersistentArray(int size, ISeq seq) : this(size){
- int load = 0;
- for(int i=0;seq != null && i < size;i++, seq=seq.rest())
- {
- data.master.array[i] = new Entry(0,seq.first());
- ++load;
- }
-
- data.master.load = load;
-}
-
-public PersistentArray(IPersistentArray init) :this(init.length()) {
- int load = 0;
- for(int i=0;i < init.length();i++)
- {
- data.master.array[i] = new Entry(0, init.nth(i));
- ++load;
- }
-
- data.master.load = load;
-}
-
-public PersistentArray(IPersistentArray init, int size) :this(size) {
- int load = 0;
- for(int i=0;i < init.length() && i < size;i++)
- {
- data.master.array[i] = new Entry(0,init.nth(i));
- ++load;
- }
-
- data.master.load = load;
-}
-
-override public int count(){
-return data.master.array.Length;
-}
-
-override public int length(){
-return data.master.array.Length;
-}
-
-override public Object nth(int i){
- Entry e = getEntry(i);
- if(e != null)
- return e.val;
- return data.master.defaultVal;
-}
-
-public bool has(int i){
- return getEntry(i) != null;
-}
-
-public PersistentArray resize(int newLength)
- {
- PersistentArray ret = create(newLength, data.master.defaultVal, data.master.loadFactor);
- for (int i = 0; i < Math.Min(length(), newLength); i++)
- {
- Entry e = getEntry(i);
- if (e != null)
- {
- ret.data.master.array[i] = Entry.create(0, e.val, null);
- ++ret.data.master.load;
- }
- }
- return ret;
- }
-
-public int load(){
-return data.master.load;
-}
-
-public void isolate()
- {
- lock(data.master)
- {
- Master nextMaster = new Master(data.master);
- int load = 0;
- for(int i=0;i<length();i++)
- {
- Entry entry = getEntry(i);
- if(entry != null)
- {
- nextMaster.array[i] = new Entry(0,entry.val);
- ++load;
- }
- }
- nextMaster.load = load;
- this.data = new Data(nextMaster, 0, 0, null);
- }
- }
-
-Entry getEntry(int i){
-for (Entry e = data.master.array[i]; e != null; e = e.rest())
- {
- if (e.rev <= data.rev)
- {
- if (e.rev >= data.baseline
- || (data.history != null && e.rev < data.history.Length && data.history.Get(e.rev)))
- return e;
- }
- }
- return null;
-}
-
-override public IPersistentArray assocN(int i,Object val) {
-//if (data.master.load >= data.master.maxLoad)
-// {
-// isolate();
-// //set(i,val);
-// }
- lock (data.master)
- {
- if (data.master.load >= data.master.maxLoad)
- //isolate();
- trim();
- PersistentArray ret = getSetArray();
- ret.doSet(i, val);
- return ret;
- }
-}
-
-protected void trim(){
- //must be called inside lock of master
- if (data.master.next == null) //this master has never been trimmed
- {
- Master nextMaster = new Master(data.master);
- int load = 0;
- for(int i=0;i<length();i++)
- {
- Entry entry = getEntry(i);
- if(entry != null)
- {
- nextMaster.array[i] = new Entry(0,entry.val);
- nextMaster.basis[i] = entry.rev;
- ++load;
- }
- }
- nextMaster.load = load;
- Data nextData = new Data(nextMaster, 0, 0, null);
- data.master.next = nextMaster;
- data = nextData;
- }
- else //this master has been trimmed, but this rev is not yet propagated
- {
- Master nextMaster = data.master.next;
- int diff = 0;
- for(int i=0;i<length();i++)
- {
- Entry e = getEntry(i);
- if(e != null && e.rev != nextMaster.basis[i])
- ++diff;
- }
- if(diff >= length()/2 || nextMaster.load + diff > nextMaster.maxLoad)
- isolate();
- else
- {
- Data nextData;
- lock(nextMaster){
- int rev = ++nextMaster.rev;
- for(int i=0;i<length();i++)
- {
- Entry e = getEntry(i);
- if(e != null && e.rev != nextMaster.basis[i])
- {
- nextMaster.array[i] = Entry.create(rev, e.val, nextMaster.array[i]);
- ++nextMaster.load;
- }
- }
- BitArray history = new BitArray(rev);
- history.Set(0,true);
- nextData = new Data(nextMaster,rev,rev,history);
- }
- this.data = nextData;
- }
- }
-}
-
-override public bool Equals(Object key){
- if(this == key) return true;
- if(key == null || !(key is IPersistentArray)) return false;
-
- IPersistentArray a = (IPersistentArray) key;
-
- if(a.length() != length())
- return false;
-
- for(int i = 0; i < length(); i++)
- {
- if(!equalKey(nth(i),a.nth(i)))
- return false;
- }
-
- return true;
-}
-
-override public int GetHashCode()
- {
- int ret = 0;
- for (int i = 0; i < length(); i++)
- {
- Object o = nth(i);
- if (o != null)
- ret ^= o.GetHashCode();
- }
- return ret;
- }
-
-private bool equalKey(Object k1, Object k2)
- {
- if (k1 == null)
- return k2 == null;
- return k1.Equals(k2);
- }
-
-void doSet(int i, Object val){
- //must now be called inside lock of master
-data.master.array[i] = Entry.create(data.rev, val, data.master.array[i]);
-++data.master.load;
-}
-
-PersistentArray getSetArray(){
- //must now be called inside lock of master
- //is this a sequential update?
-if (data.master.rev == data.rev)
- {
- return create(data.master, ++data.master.rev, data.baseline, data.history);
- }
- else //gap
- {
-
- int nextRev = ++data.master.rev;
- BitArray nextHistory;
- if (data.history != null)
- {
- nextHistory = (BitArray)data.history.Clone();
- nextHistory.Length = data.rev + 1;
- }
- else
- nextHistory = new BitArray(data.rev + 1);
- for (int i = data.baseline; i <= data.rev; i++)
- nextHistory.Set(i,true);
- return create(data.master, nextRev, nextRev, nextHistory);
- }
-}
-
-internal virtual PersistentArray create(Master master, int rev, int baseline, BitArray history)
- {
- PersistentArray ret = new PersistentArray(data.master, rev, baseline, history);
- ret._meta = _meta;
- return ret;
- }
-
-internal virtual PersistentArray create(int size, Object defaultVal, float loadFactor)
- {
- PersistentArray ret = new PersistentArray(size, defaultVal, loadFactor);
- ret._meta = _meta;
- return ret;
- }
-
-
-/*
-[STAThread]
-static public void Main(String[] args){
- if(args.Length != 3)
- {
- Console.Error.WriteLine("Usage: PersistentArray size writes reads");
- return;
- }
- int size = Int32.Parse(args[0]);
- int writes = Int32.Parse(args[1]);
- int reads = Int32.Parse(args[2]);
- ArrayList v = ArrayList.Synchronized(new ArrayList(size));
- //v.setSize(size);
- //IArray p = new PersistentArray(size);
- IPersistentArray p = new PersistentArrayList(size);
-
- for(int i = 0; i < size; i++)
- {
- v.Add(0);
- //p = p.set(i, 0);
- p = (IPersistentArray)((PersistentArrayList)p).cons(0);
- }
-
- Random rand;
-
- rand = new Random(42);
- long tv = 0;
- Console.WriteLine("ArrayList");
- DateTime start = DateTime.Now;
- for(int i = 0; i < writes; i++)
- {
- v[rand.Next(size)] = i;
- }
- for(int i = 0; i < reads; i++)
- {
- tv += (int)v[rand.Next(size)];
- }
-
- Console.WriteLine("Time: " + (DateTime.Now - start));
-
- Console.WriteLine("PersistentArray");
- rand = new Random(42);
- long tp = 0;
- start = DateTime.Now;
- IPersistentArray oldp = p;
- for (int i = 0; i < writes; i++)
- {
- p = p.assocN(rand.Next(size), i);
- //dummy set to force perverse branching
- oldp = oldp.assocN(i%size, i);
- //p.set(i%size, i);
- }
- for(int i = 0; i < reads; i++)
- {
- tp += (int)p.nth(rand.Next(size));
- }
- Console.WriteLine("Time: " + (DateTime.Now - start));
- Console.WriteLine("Done: " + tv + ", " + tp);
-
-
-}
- //*/
-
-
-}
-
-}
diff --git a/src/cli/runtime/PersistentArrayMap.cs b/src/cli/runtime/PersistentArrayMap.cs deleted file mode 100644 index 68d4b2c1..00000000 --- a/src/cli/runtime/PersistentArrayMap.cs +++ /dev/null @@ -1,261 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-using System.Collections;
- -namespace clojure.lang
-{
-
-/**
- * Simple implementation of persistent map on an array
-
- * Note that instances of this class are constant values
- * i.e. add/remove etc return new values
- *
- * Copies array on every change, so only appropriate for _very_small_ maps
- *
- * null keys and values are ok, but you won't be able to distinguish a null value via get - use contains/find
- */
-
-public class PersistentArrayMap : APersistentMap {
-
-internal readonly Object[] array;
-
- public static PersistentArrayMap EMPTY = new PersistentArrayMap();
-
- internal const int HASHTABLE_THRESHOLD = 42;
-
-protected PersistentArrayMap(){
- this.array = new object[]{};
-}
-
-virtual internal PersistentArrayMap create(params Object[] init){
- PersistentArrayMap ret = new PersistentArrayMap(init);
- ret._meta = _meta;
- return ret;
-}
-
-virtual internal IPersistentMap createHT(Object[] init){
- PersistentHashtableMap ret = new PersistentHashtableMap(init);
- ret._meta = _meta;
- return ret;
- }
-
-/**
- * This ctor captures/aliases the passed array, so do not modify later
- * @param init {key1,val1,key2,val2,...}
- */
-public PersistentArrayMap(params Object[] init){
- this.array = init;
-}
-
-override public int count() {
- return array.Length/2;
-}
-
-override public bool contains(Object key){
- return indexOf(key) >= 0;
-}
-
-override public IMapEntry find(Object key) {
- int i = indexOf(key);
- if(i >= 0)
- return new Iter(array,i);
- return null;
-}
-
-override public IPersistentMap assocEx(Object key, Object val) {
- int i = indexOf(key);
- Object[] newArray;
- if(i >= 0)
- {
- throw new Exception("Key already present");
- }
- else //didn't have key, grow
- {
- if (array.Length > HASHTABLE_THRESHOLD)
- return createHT(array).assocEx(key, val);
- newArray = new Object[array.Length + 2];
- if(array.Length > 0)
- Array.Copy(array,0,newArray,2,array.Length);
- newArray[0] = key;
- newArray[1] = val;
- }
- return create(newArray);
- }
-
-override public Associative assoc(Object key, Object val) {
- int i = indexOf(key);
- Object[] newArray;
- if(i >= 0) //already have key, same-sized replacement
- {
- if(array[i+1] == val) //no change, no op
- return this;
- newArray = (Object[])array.Clone();
- newArray[i+1] = val;
- }
- else //didn't have key, grow
- {
- if (array.Length > HASHTABLE_THRESHOLD)
- return createHT(array).assoc(key, val);
- newArray = new Object[array.Length + 2];
- if(array.Length > 0)
- Array.Copy(array,0,newArray,2,array.Length);
- newArray[0] = key;
- newArray[1] = val;
- }
- return create(newArray);
-}
-
-override public IPersistentMap without(Object key) {
- int i = indexOf(key);
- if(i >= 0) //have key, will remove
- {
- int newlen = array.Length - 2;
- if (newlen == 0)
- return empty();
- Object[] newArray = new Object[newlen];
- for(int s=0,d=0;s<array.Length;s += 2)
- {
- if(!equalKey(array[s],key)) //skip removal key
- {
- newArray[d] = array[s];
- newArray[d+1] = array[s+1];
- d += 2;
- }
- }
- return create(newArray);
- }
- //don't have key, no op
- return this;
-}
-
-virtual public IPersistentMap empty() {
- if(_meta == null)
- return EMPTY;
- PersistentArrayMap ret = new PersistentArrayMap();
- ret._meta = _meta;
- return ret;
-}
-
-override public Object get(Object key) {
- int i = indexOf(key);
- if(i >= 0)
- return array[i + 1];
- return null;
-}
-
-public int capacity() {
- return count();
-}
-
-int indexOf(Object key){
- for(int i=0;i<array.Length;i+=2)
- {
- if(equalKey(array[i],key))
- return i;
- }
- return -1;
-}
-
-internal virtual bool equalKey(Object k1,Object k2){
- if(k1 == null)
- return k2 == null;
- return k1.Equals(k2);
-}
-
-override public IEnumerator GetEnumerator() {
- return new Iter(array);
-}
-
-override public ISeq seq() {
- if(array.Length > 0)
- return new Seq(array,0);
- return null;
-}
-
-internal class Seq : ASeq, IMapEntry{
- readonly Object[] array;
- readonly int i;
-
- internal Seq(Object[] array, int i){
- this.array = array;
- this.i = i;
- }
-
- public Object key() {
- return array[i];
- }
-
- public Object val() {
- return array[i+1];
- }
-
- override public Object first() {
- return this;
- }
-
- override public ISeq rest() {
- if(i+2 < array.Length)
- return new Seq(array, i + 2);
- return null;
- }
- override public int count() {
- return (array.Length - i)/2;
- }
-}
-internal class Iter : IEnumerator,IMapEntry{
- Object[] array;
- int i;
-
- //for iterator
- internal Iter(Object[] array): this(array,-2)
- {
- }
-
- //for find
- internal Iter(Object[] array, int i){
- this.array = array;
- this.i = i;
- }
-
- public Object key() {
- return array[i];
- }
-
- public Object val() {
- return array[i+1];
- }
-
-#region IEnumerator Members
-
-public object Current
- {
- get {return this;}
- }
-
-public bool MoveNext()
- {
- i += 2;
- return i < array.Length - 2;
- }
-
-public void Reset()
- {
- throw new Exception("The method or operation is not implemented.");
- }
-
-#endregion
- }
-}
-
-
-}
\ No newline at end of file diff --git a/src/cli/runtime/PersistentHashtableMap.cs b/src/cli/runtime/PersistentHashtableMap.cs deleted file mode 100644 index a14bcc2a..00000000 --- a/src/cli/runtime/PersistentHashtableMap.cs +++ /dev/null @@ -1,304 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-
-using System;
-using System.Collections;
-
-namespace clojure.lang
- {
-
-
-public class PersistentHashtableMap : APersistentMap {
-
-static readonly float FILL_FACTOR = 0.75f;
-
-readonly internal PersistentArray array;
-readonly int _count;
-readonly int growAtCount;
-
-public PersistentHashtableMap(int initialCapacity) {
- array = new PersistentArray(calcPrimeCapacity(initialCapacity));
- _count = 0;
- this.growAtCount = (int) (this.array.length()*FILL_FACTOR);
-}
-
-/**
- * @param init {key1,val1,key2,val2,...}
- */
-public PersistentHashtableMap(Object[] init){
- //start halfway to a rehash
- PersistentArray narray = new PersistentArray(calcPrimeCapacity(init.Length));
- for(int i=0;i<init.Length;i+=2)
- {
- narray = doPut(bucketFor(init[i],narray),init[i], init[i + 1],narray);
- }
- this.array = narray;
- this._count = init.Length/2; //hmmm... presumes no dupe keys in init
- this.growAtCount = (int) (this.array.length()*FILL_FACTOR);
-}
-
-internal PersistentHashtableMap(int count,PersistentArray array) {
- this._count = count;
- this.array = array;
- this.growAtCount = (int) (this.array.length()*FILL_FACTOR);
-}
-
-internal PersistentHashtableMap(int count,PersistentArray array,int growAt) {
- this._count = count;
- this.array = array;
- this.growAtCount = growAt;
-}
-
-int calcPrimeCapacity(int capacity) {
- // No .Net equivalent
- //return BigInteger.valueOf((long) (capacity/FILL_FACTOR)).nextProbablePrime().intValue();
- int ret = (int)(capacity/FILL_FACTOR);
- if(ret%2 == 0)
- ++ret;
- return ret;
-}
-
-override public int count() {
- return _count;
-}
-
-override public bool contains(Object key) {
- IPersistentMap entries = entriesFor(key);
- return entries != null && entries.contains(key);
-}
-
-override public IMapEntry find(Object key) {
- IPersistentMap entries = entriesFor(key);
- if(entries != null)
- return entries.find(key);
- return null;
-}
-
-override public IPersistentMap assocEx(Object key, Object val) {
- if(_count > growAtCount)
- return grow().assocEx(key, val);
- int i = bucketFor(key,array);
- int incr = 1;
- PersistentArray newArray = doAdd(i, key, val, array);
- return create(_count + incr, newArray, growAtCount);
-}
-
-override public Associative assoc(Object key, Object val) {
- if(_count > growAtCount)
- return grow().assoc(key, val);
- int i = bucketFor(key,array);
- int incr = 1;
- PersistentArray newArray = doPut(i, key, val, array);
- if(newArray == array)
- return this;
- if(array.nth(i) != null && ((IPersistentMap)newArray.nth(i)).count() == ((IPersistentMap)array.nth(i)).count()) //key already there, no growth
- incr = 0;
- return create(_count + incr, newArray, growAtCount);
-}
-
-PersistentArray doPut(int i,Object key,Object val,PersistentArray array){
- IPersistentMap entries = (IPersistentMap) array.nth(i);
- IPersistentMap newEntries;
- if (entries != null)
- {
- newEntries = (IPersistentMap)entries.assoc(key, val);
- if(newEntries == entries) //already there with same value, no op
- return array;
- }
- else
- newEntries = createEntryMap(key, val);
- //newEntries = createArrayMap(new Object[]{key, val});
-
- return (PersistentArray)array.assocN(i, newEntries);
-}
-
-PersistentArray doAdd(int i,Object key,Object val,PersistentArray array) {
- IPersistentMap entries = (IPersistentMap) array.nth(i);
- IPersistentMap newEntries;
- if (entries != null)
- {
- newEntries = entries.assocEx(key, val);
- }
- else
- newEntries = createEntryMap(key, val);
-
- return (PersistentArray)array.assocN(i, newEntries);
-}
-override public IPersistentMap without(Object key) {
- int i = bucketFor(key,array);
- IPersistentMap entries = (IPersistentMap) array.nth(i);
- if (entries != null)
- {
- IPersistentMap newEntries = entries.without(key);
- if (newEntries != entries)
- return create(_count - 1, (PersistentArray)array.assocN(i, newEntries));
- }
- //not there, no op
- return this;
-}
-
-override public Object get(Object key) {
- IPersistentMap entries = entriesFor(key);
- if(entries != null)
- return entries.get(key);
- return null;
-}
-
-public int capacity() {
- return array.length();
-}
-
-IPersistentMap grow(){
- PersistentArray newArray = new PersistentArray(calcPrimeCapacity(_count * 2));
- foreach (IMapEntry e in this)
- {
- newArray = doPut(bucketFor(e.key(),newArray),e.key(), e.val(),newArray);
- }
- return create(_count,newArray);
-}
-
-override public IEnumerator GetEnumerator() {
- return new Iter(array);
-}
-
-override public ISeq seq() {
- if(count() == 0)
- return null;
- return Seq.create(array,count());
-}
-
-class Seq : ASeq{
- readonly PersistentArray buckets;
- readonly int b;
- readonly ISeq e;
- readonly int cnt;
-
-
- static public Seq create(PersistentArray buckets,int cnt) {
- return next(buckets, -1, null,cnt);
- }
-
- static Seq next(PersistentArray buckets, int b, ISeq e, int cnt)
- {
- if(e != null && e.rest() != null)
- return new Seq(buckets,b,e.rest(),cnt);
- for(b = b+1;b<buckets.length();b++)
- {
- IPersistentCollection a = (IPersistentCollection) buckets.nth(b);
- if(a != null && a.seq() != null)
- return new Seq(buckets,b,a.seq(),cnt);
- }
- return null;
- }
-
- Seq(PersistentArray buckets, int b, ISeq e, int cnt)
- {
- this.buckets = buckets;
- this.b = b;
- this.e = e;
- this.cnt = cnt;
- }
-
- override public Object first() {
- return e.first();
- }
-
- override public ISeq rest() {
- return next(buckets,b,e,cnt-1);
- }
-
- public override int count()
- {
- return cnt;
- }
-}
-
-internal class Iter : IEnumerator{
- PersistentArray buckets;
- int b;
- ISeq e;
-
- internal Iter(PersistentArray buckets){
- this.buckets = buckets;
- this.b = -1;
- }
-
- private void nextBucket() {
- e = null;
- for(b = b+1;b<buckets.length();b++)
- {
- IPersistentCollection a = (IPersistentCollection)buckets.nth(b);
- if(a != null && a.seq() != null)
- {
- e = a.seq();
- break;
- }
- }
- }
-
-#region IEnumerator Members
-
-public object Current
- {
- get { return e.first(); }
- }
-
-public bool MoveNext()
- {
- if (e == null || (e = e.rest()) == null)
- nextBucket();
- return e != null;
- }
-
-public void Reset()
- {
- throw new Exception("The method or operation is not implemented.");
- }
-
-#endregion
- }
-
-IPersistentMap entriesFor(Object key){
- return (IPersistentMap) array.nth(bucketFor(key,array));
-}
-
-static int bucketFor(Object key, PersistentArray array) {
- return (RT.hash(key) & 0x7fffffff) % array.length();
-}
-
-virtual internal IPersistentMap create(int capacity) {
- PersistentHashtableMap ret = new PersistentHashtableMap(capacity);
- ret._meta = _meta;
- return ret;
-}
-
-virtual internal IPersistentMap create(int count,PersistentArray array) {
- PersistentHashtableMap ret = new PersistentHashtableMap(count, array);
- ret._meta = _meta;
- return ret;
- }
-
-virtual internal IPersistentMap create(int i, PersistentArray newArray, int growAtCount){
- PersistentHashtableMap ret = new PersistentHashtableMap(i, newArray, growAtCount);
- ret._meta = _meta;
- return ret;
- }
-
-
-virtual internal IPersistentMap createEntryMap(Object key, Object val){
- return new MapEntry(key, val);
-//return PersistentListMap.create(key, val);
-}
-
-}
-
-
-}
\ No newline at end of file diff --git a/src/cli/runtime/PersistentList.cs b/src/cli/runtime/PersistentList.cs deleted file mode 100644 index b29c0908..00000000 --- a/src/cli/runtime/PersistentList.cs +++ /dev/null @@ -1,55 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
- -namespace clojure.lang
-{ -
-public class PersistentList : ASeq {
-
-private readonly Object _first;
-private readonly PersistentList _rest;
-private readonly int _count;
-
-public PersistentList(Object first) {
- this._first = first;
- this._rest = null;
-
- this._count = 1;
-}
-
-internal PersistentList(Object first, PersistentList rest) {
- this._first = first;
- this._rest = rest;
-
- this._count = 1 + rest.count();
- this._meta = rest._meta;
-}
-
-override public Object first() {
- return _first;
-}
-
-override public ISeq rest() {
- return _rest;
-}
-
-override public int count() {
- return _count;
-}
-
-override public IPersistentCollection cons(Object o) {
- return new PersistentList(o,this);
-}
-
-}
-
-}
diff --git a/src/cli/runtime/PersistentQueue.cs b/src/cli/runtime/PersistentQueue.cs deleted file mode 100644 index 78635448..00000000 --- a/src/cli/runtime/PersistentQueue.cs +++ /dev/null @@ -1,214 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-using System.Collections;
-
-namespace clojure.lang
- {
-
-/**
- * conses onto rear, peeks/pops from front
- * See Okasaki's Batched Queues
- * This differs in that it uses a PersistentArrayList as the rear, which is in-order,
- * so no reversing or suspensions required for persistent use
- */
-
-public class PersistentQueue : Obj, IPersistentList {
-
-readonly public static PersistentQueue EMPTY = new PersistentQueue(null,null,null);
-
-readonly ISeq f;
-readonly PersistentArrayList r;
-static readonly int INITIAL_REAR_SIZE = 4;
-int _hash = -1;
-
-
-PersistentQueue(ISeq f, PersistentArrayList r, IPersistentMap meta) {
- this.f = f;
- this.r = r;
- this._meta = meta;
-}
-
-override public bool Equals(Object obj)
- {
- if (!(obj is Sequential))
- return false;
- ISeq ms = ((IPersistentCollection)obj).seq();
- for (ISeq s = seq(); s != null; s = s.rest(), ms = ms.rest())
- {
- if (ms == null || !RT.equal(s.first(), ms.first()))
- return false;
- }
- return ms.rest() == null;
- }
-
-override public int GetHashCode()
- {
- if (_hash == -1)
- {
- int hash = 0;
- for (ISeq s = seq(); s != null; s = s.rest())
- {
- hash = RT.hashCombine(hash, RT.hash(s.first()));
- }
- this._hash = hash;
- }
- return _hash;
- }
-
-public Object peek() {
- return RT.first(f);
-}
-
-public IPersistentList pop() {
- if(f == null) //hmmm... pop of empty queue -> empty queue?
- return this;
- //throw new IllegalStateException("popping empty queue");
- ISeq f1 = f.rest();
- PersistentArrayList r1 = r;
- if(f1 == null)
- {
- f1 = RT.seq(r);
- r1 = null;
- }
- return new PersistentQueue(f1, r1,_meta);
-}
-
-public int count() {
- return RT.count(f) + RT.count(r);
-}
-
-public ISeq seq() {
- if(f == null)
- return null;
- return new Seq(f, RT.seq(r));
-}
-
-public IPersistentCollection cons(Object o) {
- if(f == null) //empty
- return new PersistentQueue(RT.list(o), null,_meta);
- else
- return new PersistentQueue(f,
- (PersistentArrayList) (r != null ? r : new PersistentArrayList(INITIAL_REAR_SIZE)).cons(o),
- _meta);
-}
-
-public override Obj withMeta(IPersistentMap meta)
- {
- if(_meta == meta)
- return this;
- Obj ret = (Obj)MemberwiseClone();
- ret._meta = meta;
- return ret;
- }
-
-class Seq : ASeq {
- readonly ISeq f;
- readonly ISeq rseq;
-
- internal Seq(ISeq f, ISeq rseq) {
- this.f = f;
- this.rseq = rseq;
- }
-
- public override Object first() {
- return f.first();
- }
-
- public override ISeq rest() {
- ISeq f1 = f.rest();
- ISeq r1 = rseq;
- if (f1 == null)
- {
- if (rseq == null)
- return null;
- f1 = rseq;
- r1 = null;
- }
- return new Seq(f1, r1);
- }
- public override int count() {
- return RT.count(f) + RT.count(rseq);
- }
-}
-
-/*
-public static void Main(String[] args) {
- if (args.Length != 1)
- {
- Console.Error.WriteLine("Usage: PersistentQueue n");
- return;
- }
- int n = Int32.Parse(args[0]);
-
-
- Random rand;
-
- rand = new Random(42);
-
- DateTime startTime;
- TimeSpan estimatedTime;
-
- //Queue list = new LinkedList();
- Queue list = Queue.Synchronized(new Queue());
- Console.WriteLine("Queue");
- startTime = DateTime.Now;
- for (int i = 0; i < n; i++)
- {
- list.Enqueue(i);
- list.Enqueue(i);
- list.Dequeue();
- }
- for (int i = 0; i < n - 10; i++)
- {
- list.Dequeue();
- }
- estimatedTime = DateTime.Now - startTime;
- Console.WriteLine("time: " + estimatedTime.Ticks / 10000);
- Console.WriteLine("peek: " + list.Peek());
-
-
- PersistentQueue q = PersistentQueue.EMPTY;
- Console.WriteLine("PersistentQueue");
- startTime = DateTime.Now;
- for (int i = 0; i < n; i++)
- {
- q = (PersistentQueue) q.cons(i);
- q = (PersistentQueue) q.cons(i);
- q = (PersistentQueue) q.pop();
- }
- IPersistentList lastq = null;
- IPersistentList lastq2;
- for (int i = 0; i < n - 10; i++)
- {
- //lastq2 = lastq;
- //lastq = q;
- q = (PersistentQueue) q.pop();
- }
- estimatedTime = DateTime.Now - startTime;
- Console.WriteLine("time: " + estimatedTime.Ticks / 10000);
- Console.WriteLine("peek: " + q.peek());
-
- IPersistentList q2 = q;
- for (int i = 0; i < 10; i++)
- {
- q2 = (IPersistentList) q2.cons(i);
- }
-// for(ISeq s = q.seq();s != null;s = s.rest())
-// Console.WriteLine("q: " + s.first());
-// for(ISeq s = q2.seq();s != null;s = s.rest())
-// Console.WriteLine("q2: " + s.first());
-}
-//*/
-
-}
-
- }
diff --git a/src/cli/runtime/PersistentTreeMap.cs b/src/cli/runtime/PersistentTreeMap.cs deleted file mode 100644 index 743cb06d..00000000 --- a/src/cli/runtime/PersistentTreeMap.cs +++ /dev/null @@ -1,869 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich May 20, 2006 */ - -using System;
-using System.Collections;
-using System.Collections.Specialized;
- -namespace clojure.lang
-{ - -/** - * Persistent Red Black Tree - * Note that instances of this class are constant values - * i.e. add/remove etc return new values - * <p/> - * See Okasaki, Kahrs, Larsen et al - */ - -public class PersistentTreeMap : APersistentMap{ - -public readonly IComparer comp; -public readonly Node tree; -public readonly int _count; - -public PersistentTreeMap():this(null){ -} - -public PersistentTreeMap(IComparer comp){ - this.comp = comp; - tree = null; - _count = 0; -} - -override public int count(){ - return _count; - } - -override public bool contains(Object key){ - return find(key) != null; -}
-
-override public IPersistentMap assocEx(Object key,Object val){ - Box found = new Box(null); - Node t = add(tree, key, val, found); - if(t == null) //null == already contains key - { - throw new Exception("Key already present");
- } - return new PersistentTreeMap(comp, t.blacken(), _count + 1, _meta); -} - -override public Associative assoc(Object key, Object val){ - Box found = new Box(null); - Node t = add(tree, key, val, found); - if(t == null) //null == already contains key - { - Node foundNode = (Node) found.val; - if(foundNode.val() == val) //note only get same collection on identity of val, not equals() - return this;
- return new PersistentTreeMap(comp, replace(tree, key, val), _count, _meta); - }
- return new PersistentTreeMap(comp, t.blacken(), _count + 1, _meta); -} - - -override public IPersistentMap without(Object key){ - Box found = new Box(null); - Node t = remove(tree, key, found); - if(t == null) - { - if(found.val == null)//null == doesn't contain key - return this; - //empty
- PersistentTreeMap ret = new PersistentTreeMap(comp);
- ret._meta = _meta;
- return ret;
- }
- return new PersistentTreeMap(comp, t.blacken(), _count - 1, _meta); -} - -override public ISeq seq() {
- if(_count > 0)
- return Seq.create(tree, true,_count);
- return null;
-} - -public ISeq rseq() {
- if(_count > 0)
- return Seq.create(tree, false,_count);
- return null;
-} - -override public IEnumerator GetEnumerator(){ - return new NodeIEnumerator(tree, true); -} - -public NodeIEnumerator reverseIEnumerator(){ - return new NodeIEnumerator(tree, false); -} - -public IEnumerator keys(){
-return keys((NodeIEnumerator)GetEnumerator()); -} - -public IEnumerator vals(){
-return vals((NodeIEnumerator)GetEnumerator()); -} - -public IEnumerator keys(NodeIEnumerator it){ - return new KeyIEnumerator(it); -} - -public IEnumerator vals(NodeIEnumerator it){ - return new ValIEnumerator(it); -} - -public Object minKey(){ - Node t = min(); - return t!=null?t._key:null; -} - -public Node min(){ - Node t = tree; - if(t != null) - { - while(t.left() != null) - t = t.left(); - } - return t; -} - -public Object maxKey(){ - Node t = max(); - return t!=null?t._key:null; -} - -public Node max(){ - Node t = tree; - if(t != null) - { - while(t.right() != null) - t = t.right(); - } - return t; -} - -public int depth(){ - return depth(tree); -} - -int depth(Node t){ - if(t == null) - return 0; - return 1 + Math.Max(depth(t.left()), depth(t.right())); -} - -override public Object get(Object key){ - Node n = (Node)find(key); - return (n != null) ? n.val() : null; -} - -override public IMapEntry find(Object key){ - Node t = tree; - while(t != null) - { - int c = compare(key, t._key); - if(c == 0) - return t; - else if(c < 0) - t = t.left(); - else - t = t.right(); - } - return t; -} - -int compare(Object k1, Object k2){ - if(comp != null) - return comp.Compare(k1, k2); - return ((IComparable) k1).CompareTo(k2); -} - -Node add(Node t, Object key, Object val, Box found){ - if(t == null) - { - if(val == null) - return new Red(key); - return new RedVal(key, val); - } - int c = compare(key, t._key); - if(c == 0) - { - found.val = t; - return null; - } - Node ins = c < 0 ? add(t.left(), key, val, found) : add(t.right(), key, val, found); - if(ins == null) //found below - return null; - if(c < 0) - return t.addLeft(ins); - return t.addRight(ins); -} - -Node remove(Node t, Object key, Box found){ - if(t == null) - return null; //not found indicator - int c = compare(key, t._key); - if(c == 0) - { - found.val = t; - return append(t.left(), t.right()); - } - Node del = c < 0 ? remove(t.left(), key, found) : remove(t.right(), key, found); - if(del == null && found.val == null) //not found below - return null; - if(c < 0) - { - if(t.left() is Black) - return balanceLeftDel(t._key, t.val(), del, t.right()); - else - return red(t._key, t.val(), del, t.right()); - } - if(t.right() is Black) - return balanceRightDel(t._key, t.val(), t.left(), del); - return red(t._key, t.val(), t.left(), del); -// return t.removeLeft(del); -// return t.removeRight(del); -} - -static Node append(Node left, Node right){ - if(left == null) - return right; - else if(right == null) - return left; - else if(left is Red) - { - if(right is Red) - { - Node app = append(left.right(), right.left()); - if(app is Red) - return red(app._key, app.val(), - red(left._key, left.val(), left.left(), app.left()), - red(right._key, right.val(), app.right(), right.right())); - else - return red(left._key, left.val(), left.left(), red(right._key, right.val(), app, right.right())); - } - else - return red(left._key, left.val(), left.left(), append(left.right(), right)); - } - else if(right is Red) - return red(right._key, right.val(), append(left, right.left()), right.right()); - else //black/black - { - Node app = append(left.right(), right.left()); - if(app is Red) - return red(app._key, app.val(), - black(left._key, left.val(), left.left(), app.left()), - black(right._key, right.val(), app.right(), right.right())); - else - return balanceLeftDel(left._key, left.val(), left.left(), black(right._key, right.val(), app, right.right())); - } -} - -static Node balanceLeftDel(Object key, Object val, Node del, Node right){ - if(del is Red) - return red(key, val, del.blacken(), right); - else if(right is Black) - return rightBalance(key, val, del, right.redden()); - else if(right is Red && right.left() is Black) - return red(right.left()._key, right.left().val(), - black(key, val, del, right.left().left()), - rightBalance(right._key, right.val(), right.left().right(), right.right().redden())); - else - throw new InvalidOperationException("Invariant violation"); -} - -static Node balanceRightDel(Object key, Object val, Node left, Node del){ - if(del is Red) - return red(key, val, left, del.blacken()); - else if(left is Black) - return leftBalance(key, val, left.redden(), del); - else if(left is Red && left.right() is Black) - return red(left.right()._key, left.right().val(), - leftBalance(left._key, left.val(), left.left().redden(), left.right().left()), - black(key, val, left.right().right(), del)); - else - throw new InvalidOperationException("Invariant violation"); -} - -static Node leftBalance(Object key, Object val, Node ins, Node right){ - if(ins is Red && ins.left() is Red) - return red(ins._key, ins.val(), ins.left().blacken(), black(key, val, ins.right(), right)); - else if(ins is Red && ins.right() is Red) - return red(ins.right()._key, ins.right().val(), - black(ins._key, ins.val(), ins.left(), ins.right().left()), - black(key, val, ins.right().right(), right)); - else - return black(key, val, ins, right); -} - - -static Node rightBalance(Object key, Object val, Node left, Node ins){ - if(ins is Red && ins.right() is Red) - return red(ins._key, ins.val(), black(key, val, left, ins.left()), ins.right().blacken()); - else if(ins is Red && ins.left() is Red) - return red(ins.left()._key, ins.left().val(), - black(key, val, left, ins.left().left()), - black(ins._key, ins.val(), ins.left().right(), ins.right())); - else - return black(key, val, left, ins); -} - -Node replace(Node t, Object key, Object val){ - int c = compare(key, t._key); - return t.replace(t._key, - c == 0 ? val : t.val(), - c < 0 ? replace(t.left(), key, val) : t.left(), - c > 0 ? replace(t.right(), key, val) : t.right()); -} - -PersistentTreeMap(IComparer comp, Node tree, int count,IPersistentMap meta){ - this.comp = comp; - this.tree = tree; - this._count = count; - this._meta = meta; -} - -static Red red(Object key, Object val, Node left, Node right){ - if(left == null && right == null) - { - if(val == null) - return new Red(key); - return new RedVal(key, val); - } - if(val == null) - return new RedBranch(key, left, right); - return new RedBranchVal(key, val, left, right); -} - -static Black black(Object key, Object val, Node left, Node right){ - if(left == null && right == null) - { - if(val == null) - return new Black(key); - return new BlackVal(key, val); - } - if(val == null) - return new BlackBranch(key, left, right); - return new BlackBranchVal(key, val, left, right); -} - - -public abstract class Node : IMapEntry{ - internal readonly Object _key; - - internal Node(Object key){ - this._key = key; - } - - public Object key(){ - return _key; - } - - virtual public Object val(){ - return null; - }
-
- internal virtual Node left()
- { - return null; - }
-
- internal virtual Node right()
- { - return null; - } - - internal abstract Node addLeft(Node ins);
-
- internal abstract Node addRight(Node ins);
-
- internal abstract Node removeLeft(Node del);
-
- internal abstract Node removeRight(Node del);
-
- internal abstract Node blacken();
-
- internal abstract Node redden();
-
- internal virtual Node balanceLeft(Node parent)
- { - return black(parent._key, parent.val(), this, parent.right()); - }
-
- internal virtual Node balanceRight(Node parent)
- { - return black(parent._key, parent.val(), parent.left(), this); - }
-
- internal abstract Node replace(Object key, Object val, Node left, Node right); -} - -class Black : Node{ - public Black(Object key):base(key){ - } - - internal override Node addLeft(Node ins){ - return ins.balanceLeft(this); - }
-
- internal override Node addRight(Node ins)
- { - return ins.balanceRight(this); - }
-
- internal override Node removeLeft(Node del)
- { - return balanceLeftDel(_key, val(), del, right()); - }
-
- internal override Node removeRight(Node del)
- { - return balanceRightDel(_key, val(), left(), del); - }
-
- internal override Node blacken()
- { - return this; - }
-
- internal override Node redden()
- { - return new Red(_key); - }
-
- internal override Node replace(Object key, Object val, Node left, Node right)
- { - return black(key, val, left, right); - } -} - -class BlackVal : Black{ - readonly Object _val; - - public BlackVal(Object key, Object val):base(key){ - this._val = val; - } - - override public Object val(){ - return _val; - }
-
- internal override Node redden()
- { - return new RedVal(_key, _val); - } - -} - -class BlackBranch : Black{ - internal readonly Node _left; - internal readonly Node _right; - - public BlackBranch(Object key, Node left, Node right):base(key){ - this._left = left; - this._right = right; - }
-
- internal override Node left()
- { - return _left; - }
-
- internal override Node right()
- { - return _right; - }
-
- internal override Node redden()
- { - return new RedBranch(_key, _left, _right); - } - -} - -class BlackBranchVal : BlackBranch{ - readonly Object _val; - - public BlackBranchVal(Object key, Object val, Node left, Node right): base(key, left, right){ - this._val = val; - } - - override public Object val(){ - return _val; - }
-
- internal override Node redden()
- { - return new RedBranchVal(_key, _val, _left, _right); - } - -} - -class Red : Node{ - public Red(Object key):base(key){ - }
-
- internal override Node addLeft(Node ins)
- { - return red(_key, val(), ins, right()); - }
-
- internal override Node addRight(Node ins)
- { - return red(_key, val(), left(), ins); - }
-
- internal override Node removeLeft(Node del)
- { - return red(_key, val(), del, right()); - }
-
- internal override Node removeRight(Node del)
- { - return red(_key, val(), left(), del); - }
-
- internal override Node blacken()
- { - return new Black(_key); - }
-
- internal override Node redden()
- { - throw new InvalidOperationException("Invariant violation"); - }
-
- internal override Node replace(Object key, Object val, Node left, Node right)
- { - return red(key, val, left, right); - } -} - -class RedVal : Red{ - readonly Object _val; - - public RedVal(Object key, Object val):base(key){ - this._val = val; - } - - override public Object val(){ - return _val; - }
-
- internal override Node blacken()
- { - return new BlackVal(_key, _val); - } -} - -class RedBranch : Red{ - internal readonly Node _left; - internal readonly Node _right; - - public RedBranch(Object key, Node left, Node right):base(key){ - this._left = left; - this._right = right; - }
-
- internal override Node left()
- { - return _left; - }
-
- internal override Node right()
- { - return _right; - }
-
- internal override Node balanceLeft(Node parent)
- { - if(_left is Red) - return red(_key, val(), _left.blacken(), black(parent._key, parent.val(), _right, parent.right())); - else if(_right is Red) - return red(_right._key, _right.val(), black(_key, val(), _left, _right.left()), - black(parent._key, parent.val(), _right.right(), parent.right())); - else - return base.balanceLeft(parent); - - }
-
- internal override Node balanceRight(Node parent)
- { - if(_right is Red) - return red(_key, val(), black(parent._key, parent.val(), parent.left(), _left), _right.blacken()); - else if(_left is Red) - return red(_left._key, _left.val(), black(parent._key, parent.val(), parent.left(), _left.left()), - black(_key, val(), _left.right(), _right)); - else - return base.balanceRight(parent); - }
-
- internal override Node blacken()
- { - return new BlackBranch(_key, _left, _right); - } -} - -class RedBranchVal : RedBranch{ - readonly Object _val; - - public RedBranchVal(Object key, Object val, Node left, Node right):base(key, left, right){ - - this._val = val; - } - - override public Object val(){ - return _val; - }
-
- internal override Node blacken()
- { - return new BlackBranchVal(_key, _val, _left, _right); - } -} - -public class Seq : ASeq{
- readonly ISeq stack;
- readonly bool asc;
- readonly int cnt;
-
- Seq(ISeq stack, bool asc, int cnt) {
- this.stack = stack;
- this.asc = asc;
- this.cnt = cnt;
- }
-
- internal static Seq create(Node t, bool asc,int cnt){
- return new Seq(push(t, null, asc),asc,cnt);
- }
-
- static ISeq push(Node t, ISeq stack, bool asc){
- while(t != null)
- {
- stack = RT.cons(t,stack);
- t = asc ? t.left() : t.right();
- }
- return stack;
- }
-
- override public Object first() {
- return stack.first();
- }
-
- override public ISeq rest() {
- Node t = (Node)stack.first();
- ISeq nextstack = push(asc ? t.right() : t.left(), stack.rest(), asc);
- if(nextstack != null)
- {
- return new Seq(nextstack,asc,cnt-1);
- }
- return null;
- }
-
- public override int count()
- {
- return cnt;
- }
-}
- - -public class NodeIEnumerator : IEnumerator{ - Stack stack = new Stack(); - bool asc;
- object curr; - - internal NodeIEnumerator(Node t, bool asc){ - this.asc = asc; - push(t); - } - - void push(Node t){ - while(t != null) - { - stack.Push(t); - t = asc ? t.left() : t.right(); - } - } - - bool hasNext(){ - return !(stack.Count == 0); - } - - Object next(){ - Node t = (Node) stack.Pop(); - push(asc ? t.right() : t.left()); - return t; - } - - public void remove(){ - throw new InvalidOperationException(); - }
-
-#region IEnumerator Members
-
-public object Current
- {
- get { return curr; }
- }
-
-public bool MoveNext()
- {
- if (hasNext())
- {
- curr = next();
- return true;
- }
- return false;
- }
-
-public void Reset()
- {
- throw new Exception("The method or operation is not implemented.");
- }
-
-#endregion
- } - -class KeyIEnumerator : IEnumerator{ - NodeIEnumerator it; - - internal KeyIEnumerator(NodeIEnumerator it){ - this.it = it; - } -
-#region IEnumerator Members
-
-public object Current
-{
-get { return ((Node)it.Current)._key; }
-}
-
-public bool MoveNext()
-{
-return it.MoveNext();
-}
-
-public void Reset()
-{
- throw new Exception("The method or operation is not implemented.");
-}
-
-#endregion
-} - -class ValIEnumerator : IEnumerator{ - NodeIEnumerator it; - - internal ValIEnumerator(NodeIEnumerator it){ - this.it = it; - }
-
-#region IEnumerator Members
-
-public object Current
- {
- get { return ((Node)it.Current).val(); }
- }
-
-public bool MoveNext()
- {
- return it.MoveNext();
- }
-
-public void Reset()
- {
- throw new Exception("The method or operation is not implemented.");
- }
-
-#endregion
- } - - //*
- [STAThread] -static public void Main(String[] args){ - if(args.Length != 1)
- Console.Error.WriteLine("Usage: PersistentTree n"); - int n = Int32.Parse(args[0]); - Object[] ints = new Object[n]; - for(int i = 0; i < ints.Length; i++) - { - ints[i] = i; - } - //Collections.shuffle(Arrays.asList(ints));
- Array.Reverse(ints); - Console.WriteLine("Building set");
- //IPersistentMap set = new PersistentTree();
- //IPersistentMap set = new PersistentArrayMap();
- //IPersistentMap set = new PersistentListMap();
- IPersistentMap set = new PersistentHashtableMap(1001);
- //IPersistentMap set = new PersistentHybridMap(1001); - //for(int i = 0; i < ints.Length; i++) - // { - // Object anInt = ints[i]; - // set = set.add(anInt); - // }
- DateTime start = DateTime.Now;
- for (int i = 0; i < ints.Length; i++) - { - Object anInt = ints[i]; - set = (IPersistentMap) set.assoc(anInt, anInt); - }
-
- foreach(IMapEntry e in set) - { - if(!set.contains(e.key())) - Console.Error.WriteLine("Can't find: " + e.key()); - //else if(n < 2000) - // Console.Write(e.key().ToString() + ","); - } - - for(int i = 0; i < ints.Length/2; i++) - { - Object anInt = ints[i]; - set = set.without(anInt); - }
-
- Console.WriteLine("Time: " + (DateTime.Now - start));
- Console.Error.WriteLine("count = " + set.count());
-
- Console.WriteLine("Building Hashtable");
- Hashtable od = Hashtable.Synchronized(new Hashtable(1001));
- start = DateTime.Now;
- for (int i = 0; i < ints.Length; i++)
- {
- Object anInt = ints[i];
- od.Add(anInt, anInt);
- }
-
- foreach (DictionaryEntry e in od)
- {
- if (!od.Contains(e.Key))
- Console.Error.WriteLine("Can't find: " + e.Key);
- //else if (n < 2000)
- // Console.Write(e.key().ToString() + ",");
- }
-
- for (int i = 0; i < ints.Length / 2; i++)
- {
- Object anInt = ints[i];
- od.Remove(anInt);
- }
-
- Console.WriteLine("Time: " + (DateTime.Now - start));
- Console.Error.WriteLine("count = " + od.Count);
- -} - //*/ -} - } diff --git a/src/cli/runtime/RT.cs b/src/cli/runtime/RT.cs deleted file mode 100644 index 75659413..00000000 --- a/src/cli/runtime/RT.cs +++ /dev/null @@ -1,682 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-/* rich Mar 25, 2006 4:28:27 PM */
-
-using System;
-using System.Collections;
-using System.IO;
-using System.Threading;
-
-namespace clojure.lang
-{
-
-public class RT
-{
-
- public static Symbol T = Symbol.intern(":t");
- static public Var OUT = Module.intern("clojure", "^out");
- static public Var _CT_MODULE = Module.intern("clojure", "^module");
- public static Object[] EMPTY_ARRAY = new Object[0];
-
-
- static public readonly Object[] chars;
-
- static int id = 1;
- static public int nextID()
- {
- return Interlocked.Increment(ref id);
- }
-
- static RT(){
- chars = new Object[256];
- for(int i=0;i<chars.Length;i++)
- chars[i] = (char)i;
- OUT.bind(Console.Out);
- _CT_MODULE.bind((Module.findOrCreate("clj-user")));
- }
-
-static public bool equal(Object k1,Object k2){
- return k1 == k2 ||
- (k1 != null && k1.Equals(k2));
-}
- static public Object eq(Object arg1, Object arg2) {
- return (arg1 == arg2)?T:null;
- }
-
- static public Object eql(Object arg1, Object arg2) {
- if(arg1 == arg2)
- return T;
- if(arg1 == null || arg2 == null)
- return null;
- if(arg1 is Num
- && arg1.GetType() == arg2.GetType()
- && arg1.Equals(arg2))
- return T;
- if(arg1 is Char
- && arg2 is Char
- && arg1.Equals(arg2))
- return T;
- return null;
- }
-
- //static public Object equal(Object arg1, Object arg2) {
- // if(arg1 == null)
- // return arg2 == null ? T : null;
- // else if(arg2 == null)
- // return null;
- // return (eql(arg1,arg2) != null
- // || (arg1 is Cons
- // && arg2 is Cons
- // && equal(((Cons)arg1).first(),((Cons)arg2).first())!=null
- // && equal(((Cons)arg1).rest(),((Cons)arg2).rest())!=null))
- // ?T:null;
- // }
-
-static public int hash(Object o){
- if(o == null)
- return 0;
- return o.GetHashCode();
-}
-
-static public int hashCombine(int seed, int hash){
- //a la boost
- seed ^= (int)(hash + 0x9e3779b9 + (seed << 6) + (seed >> 2));
- return seed;
-}
-
-static public ISeq seq(Object coll) {
- if(coll == null)
- return null;
- else if(coll is IPersistentCollection)
- return ((IPersistentCollection) coll).seq();
- else if (coll is IEnumerable)
- return EnumeratorSeq.create(((IEnumerable)coll).GetEnumerator());
- else if(coll is Object[])
- return ArraySeq.create((Object[]) coll);
- else
- throw new ArgumentException("Don't know how to create ISeq from arg");
-}
-
-static public ISeq keys(Object coll)
- {
- return APersistentMap.KeySeq.create(seq(coll));
- }
-
-static public ISeq vals(Object coll)
- {
- return APersistentMap.ValSeq.create(seq(coll));
- }
-
-static public Object meta(Object x)
- {
- if (x == null)
- return null;
- return ((Obj)x).meta();
- }
-
-public static int count(Object o)
- {
- if (o == null)
- return 0;
- return ((IPersistentCollection)o).count();
- }
-
-static public IPersistentCollection cons(Object x, IPersistentCollection y)
- {
- if (y == null)
- return new PersistentList(x);
- return y.cons(x);
- }
-
-static public ISeq cons(Object x, ISeq y)
- {
- if (y == null)
- return new PersistentList(x);
- return (ISeq)y.cons(x);
- }
-
-static public Object first(Object x)
- {
- if (x == null)
- return null;
- return seq(x).first();
- }
-
-static public Object second(Object x)
- {
- return first(rest(x));
- }
-
-static public Object third(Object x)
- {
- return first(rest(rest(x)));
- }
-
-static public Object fourth(Object x) {
- return first(rest(rest(rest(x))));
-}
-
-static public ISeq rest(Object x)
- {
- if (x == null)
- return null;
- return seq(x).rest();
- }
-
-static public ISeq rrest(Object x) {
- return rest(rest(x));
-}
-
-static public Object peek(Object x)
- {
- if (x == null)
- return null;
- return ((IPersistentList)x).peek();
- }
-
-static public Object pop(Object x)
- {
- if (x == null)
- return null;
- return ((IPersistentList)x).pop();
- }
-
-static public Object get(Object key, Object coll)
- {
- if (coll == null)
- return null;
- return ((Associative)coll).get(key);
- }
-
-static public Object assoc(Object key, Object val, Object coll)
- {
- if (coll == null)
- return new MapEntry(key, val);
- return ((Associative)coll).assoc(key, val);
- }
-
-static public Object contains(Object key, Object coll)
- {
- if (coll == null)
- return false;
- return ((Associative)coll).contains(key);
- }
-
-static public Object find(Object key, Object coll)
- {
- if (coll == null)
- return null;
- return ((Associative)coll).find(key);
- }
-
- //takes a seq of key,val,key,val
-//returns tail starting at val of matching key if found, else null
-static public ISeq findKey(Keyword key,ISeq keyvals) {
- while(keyvals != null)
- {
- ISeq r = keyvals.rest();
- if (r == null)
- throw new Exception("Malformed keyword argslist");
- if (keyvals.first() == key)
- return r;
- keyvals = r.rest();
- }
- return null;
-}
-
-static public Object without(Object key, Object coll)
- {
- if (coll == null)
- return null;
- return ((IPersistentMap)coll).without(key);
- }
-
-static public Object nth(int n, Object coll) {
- if(coll == null)
- return null;
- else if(coll is IPersistentArray)
- return ((IPersistentArray)coll).nth(n);
- else if(coll is Object[])
- return ((Object[])coll)[n];
- else if(coll is Sequential)
- {
- ISeq seq = ((IPersistentCollection) coll).seq();
- for(int i=0;i<=n && seq != null;++i, seq = seq.rest())
- {
- if(i == n)
- return seq.first();
- }
- return null;
- }
- else
- return null;
-}
-
-static public Object assocN(int n, Object val, Object coll) {
- if(coll == null)
- return null;
- else if(coll is IPersistentArray)
- return ((IPersistentArray)coll).assocN(n,val);
- else if(coll is Object[])
- {
- //hmm... this is not persistent
- Object[] array = ((Object[])coll);
- array[n] = val;
- return array;
- }
- else
- return null;
-}
-
- static public Iter iter(Object coll)
- {
- if (coll == null || coll is Iter)
- return (Iter)coll;
- else if (coll is IEnumerable)
- {
- IEnumerator e = ((IEnumerable)coll).GetEnumerator();
- if (e.MoveNext())
- return new EnumeratorIter(e);
- return null;
- }
- else
- {
- throw new ArgumentException("Don't know how to create Iter from arg");
- }
-
- }
-
- static public Object box(Object x)
- {
- return x;
- }
-
- static public Object box(char x)
- {
- if (x < chars.Length)
- return chars[x];
- return x;
- }
-
- static public Object box(bool x)
- {
- return x ? T : null;
- }
-
- static public Num box(byte x)
- {
- return Num.from(x);
- }
-
- static public Num box(short x)
- {
- return Num.from(x);
- }
-
- static public Num box(int x)
- {
- return Num.from(x);
- }
-
- static public Num box(long x)
- {
- return Num.from(x);
- }
-
- static public Num box(float x)
- {
- return Num.from(x);
- }
-
- static public Num box(double x)
- {
- return Num.from(x);
- }
-
- static public char charCast(Object x)
{
return Convert.ToChar(x);
}
-
- static public bool booleanCast(Object x)
{
if(x is Boolean)
- return (bool)x; ;
return x != null;
}
-
- static public byte byteCast(Object x)
- {
- return Convert.ToByte(x);
- }
-
- static public short shortCast(Object x)
- {
- return Convert.ToInt16(x);
}
-
- static public int intCast(Object x)
- {
- return Convert.ToInt32(x);
- }
-
- static public long longCast(Object x)
- {
- return Convert.ToInt64(x);
- }
-
- static public float floatCast(Object x)
- {
- return Convert.ToSingle(x);
- }
-
- static public double doubleCast(Object x)
- {
- return Convert.ToDouble(x);
- }
-
-static public ISeq list()
- {
- return null;
- }
-
-static public ISeq list(Object arg1)
- {
- return new PersistentList(arg1);
- }
-
-static public ISeq list(Object arg1, Object arg2)
- {
- return listStar(arg1, arg2, null);
- }
-
-static public ISeq list(Object arg1, Object arg2, Object arg3)
- {
- return listStar(arg1, arg2, arg3, null);
- }
-
-static public ISeq list(Object arg1, Object arg2, Object arg3, Object arg4)
- {
- return listStar(arg1, arg2, arg3, arg4, null);
- }
-
-static public ISeq list(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
- {
- return listStar(arg1, arg2, arg3, arg4, arg5, null);
- }
-
-static public ISeq listStar(Object arg1, ISeq rest)
- {
- return cons(arg1, rest);
- }
-
-static public ISeq listStar(Object arg1, Object arg2, ISeq rest)
- {
- return cons(arg1, cons(arg2, rest));
- }
-
-static public ISeq listStar(Object arg1, Object arg2, Object arg3, ISeq rest)
- {
- return cons(arg1, cons(arg2, cons(arg3, rest)));
- }
-
-static public ISeq listStar(Object arg1, Object arg2, Object arg3, Object arg4, ISeq rest)
- {
- return cons(arg1, cons(arg2, cons(arg3, cons(arg4, rest))));
- }
-
-static public ISeq listStar(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, ISeq rest)
- {
- return cons(arg1, cons(arg2, cons(arg3, cons(arg4, cons(arg5, rest)))));
- }
-
-static public ISeq arrayToList(Object[] a)
- {
- ISeq ret = null;
- for (int i = a.Length - 1; i >= 0; --i)
- ret = cons(a[i], ret);
- return ret;
- }
-
-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())
- ret[i] = seq.first();
- return ret;
-}
-
-static public int length(ISeq list)
- {
- int i = 0;
- for(ISeq c = list; c != null; c = c.rest())
- {
- i++;
- }
- return i;
- }
-
-static public int boundedLength(ISeq list, int limit)
- {
- int i = 0;
- for(ISeq c = list; c != null && i <= limit; c = c.rest())
- {
- i++;
- }
- return i;
- }
-
-
-///////////////////////////////// reader support ////////////////////////////////
-
-static Object readRet(int ret){
- if(ret == -1)
- return null;
- return box((char) ret);
-}
-
-static public Object readChar(TextReader r) {
- int ret = r.Read();
- return readRet(ret);
-}
-
-static public Object peekChar(TextReader r) {
- return readRet(r.Peek());
-}
-
-static public int getLineNumber(TextReader r)
- {
- if (r is LineNumberingTextReader)
- return ((LineNumberingTextReader)r).getLineNumber();
- return 0;
- }
-
-static public TextReader getLineNumberingReader(TextReader r)
- {
- if (isLineNumberingReader(r))
- return r;
- return new LineNumberingTextReader(r);
- }
-
-static public bool isLineNumberingReader(TextReader r)
- {
- return r is LineNumberingTextReader;
- }
-
-
-static public String resolveClassNameInContext(String className) {
- //todo - look up in context var
- return className;
-}
-
-static public bool suppressRead(){
- //todo - look up in suppress-read var
- return false;
-}
-
-static public void print(Object x, TextWriter w) {
- //todo - make extensible
- if(x == null)
- w.Write("null");
- else if(x is ISeq)
- {
- w.Write('(');
- for(ISeq s = (ISeq)x;s != null;s = s.rest())
- {
- print(s.first(), w);
- if(s.rest()!=null)
- w.Write(' ');
- }
- w.Write(')');
- }
- else if(x is String)
- {
- w.Write('"');
- w.Write(x.ToString());
- w.Write('"');
- }
- else if(x is Char)
- {
- w.Write('\\');
- char c = (char)x;
- switch(c){
- case '\n':
- w.Write("newline");
- break;
- case '\t':
- w.Write("tab");
- break;
- case ' ':
- w.Write("space");
- break;
- default:
- w.Write(c);
- break;
- }
- }
- else w.Write(x.ToString());
-}
-
-static public void formatAesthetic(TextWriter w, Object obj) {
- if(obj == null)
- w.Write("null");
- else
- w.Write(obj.ToString());
-}
-
-static public void formatStandard(TextWriter w,Object obj) {
- if(obj == null)
- w.Write("null");
- else if(obj is String)
- {
- w.Write('"');
- w.Write((String)obj);
- w.Write('"');
- }
- else if(obj is Char)
- {
- w.Write('\\');
- char c = (Char)obj;
- switch(c){
- case '\n':
- w.Write("newline");
- break;
- case '\t':
- w.Write("tab");
- break;
- case ' ':
- w.Write("space");
- break;
- default:
- w.Write(c);
- break;
- }
- }
- else
- w.Write(obj.ToString());
-}
-
-static public Object format(Object o, String s, params Object[] args) {
- TextWriter w;
- if(o == null)
- w = new StringWriter();
- else if(equal(o,T))
- w = (TextWriter)OUT.getValue();
- else
- w = (TextWriter)o;
- doFormat(w,s,ArraySeq.create(args));
- if(o == null)
- return w.ToString();
- return null;
-}
-
-static public ISeq doFormat(TextWriter w, String s, ISeq args) {
- for (int i = 0; i < s.Length;)
- {
- char c = s[i++];
- switch (Char.ToLower(c))
- {
- case '~':
- char d = s[i++];
- switch (Char.ToLower(d))
- {
- case '%':
- w.Write('\n');
- break;
- case 't':
- w.Write('\t');
- break;
- case 'a':
- if(args == null)
- throw new Exception("Missing argument");
- RT.formatAesthetic(w, RT.first(args));
- args = RT.rest(args);
- break;
- case 's':
- if(args == null)
- throw new Exception("Missing argument");
- RT.formatStandard(w, RT.first(args));
- args = RT.rest(args);
- break;
- case '{':
- int j = s.IndexOf("~}", i); //note - does not nest
- if(j == -1)
- throw new Exception("Missing ~}");
- String subs = s.Substring(i, j-i);
- for (ISeq sargs = RT.seq(RT.first(args)); sargs != null; )
- sargs = doFormat(w, subs, sargs);
- args = RT.rest(args);
- i = j+2; //skip ~}
- break;
- case '^':
- if(args == null)
- return null;
- break;
- case '~':
- w.Write('~');
- break;
- default:
- throw new Exception("Unsupported ~ directive: " + d);
- break;
- }
- break;
- default:
- w.Write(c);
- break;
- }
- }
- return args;
-}
-
-/*-------------------------------- values --------------*/
-
-static public Object setValues(params Object[] vals)
- {
- ThreadLocalData.setValues(vals);
- if(vals.Length > 0)
- return vals[0];
- return null;
- }
-
-}
-}
\ No newline at end of file diff --git a/src/cli/runtime/RatioNum.cs b/src/cli/runtime/RatioNum.cs deleted file mode 100644 index 7838b84c..00000000 --- a/src/cli/runtime/RatioNum.cs +++ /dev/null @@ -1,229 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 28, 2006 10:14:44 AM */ - -using System;
-using java.math;
- -namespace clojure.lang
-{ - -public class RatioNum : RationalNum{ -override public Boolean Equals(Object arg0) - { - return arg0 != null - && arg0 is RatioNum - && ((RatioNum) arg0).numerator.Equals(numerator) - && ((RatioNum) arg0).denominator.Equals(denominator); - } - -override public int GetHashCode() - { - return numerator.GetHashCode() ^ denominator.GetHashCode(); - } - -override public String ToString() - { - return numerator.ToString() + "/" + denominator.ToString(); - } - -public IntegerNum numerator; -public IntegerNum denominator; - -public RatioNum(IntegerNum n, IntegerNum d) - { - this.numerator = n; - this.denominator = d; - } - -override public double doubleValue() - { - return numerator.doubleValue() / denominator.doubleValue(); - } - -override public float floatValue() - { - return (float) doubleValue(); - } - -override public int intValue() - { - return (int) doubleValue(); - } - -override public long longValue() - { - return (long) doubleValue(); - } - -override public Boolean equiv(Num rhs) - { - return rhs.equivTo(this); - } - -override public Boolean equivTo(BigInteger x) - { - return false; - } - -override public Boolean equivTo(int x) - { - return false; - } - -override public Boolean equivTo(RatioNum x) - { - return numerator.equiv(x.numerator) && denominator.equiv(x.denominator); - } - -override public Boolean lt(Num rhs) - { - return rhs.gt(this); - } - -override public Boolean gt(BigInteger x) - { - return denominator.multiply(x).lt(numerator); - } - -override public Boolean gt(int x) - { - return denominator.multiply(x).lt(numerator); - } - -override public Boolean gt(RatioNum x) - { - return x.numerator.multiplyBy(denominator).lt(numerator.multiplyBy(x.denominator)); - } - -override public Num add(Num rhs) - { - return rhs.addTo(this); - } - -override public Num addTo(BigInteger x) - { - return Num.divide(numerator.add(denominator.multiply(x)), denominator); - } - -override public Num addTo(int x) - { - return Num.divide(numerator.add(denominator.multiply(x)), denominator); - } - -override public Num addTo(RatioNum x) - { - return Num.divide(numerator.multiplyBy(x.denominator) - .add(x.numerator.multiplyBy(denominator)) - , denominator.multiplyBy(x.denominator)); - } - -override public Num subtractFrom(Num x) - { - return x.add(this.multiply(-1)); - } - -override public Num multiplyBy(Num rhs) - { - return rhs.multiply(this); - } - -override public Num multiply(BigInteger x) - { - return Num.divide(numerator.multiply(x), denominator); - } - -override public Num multiply(int x) - { - return Num.divide(numerator.multiply(x), denominator); - } - -override public Num multiply(RatioNum x) - { - return Num.divide(numerator.multiplyBy(x.numerator) - , denominator.multiplyBy(x.denominator)); - } - -override public Num divideBy(Num rhs) - { - return rhs.divide(this); - } - -override public Num divide(BigInteger n) - { - return Num.divide(denominator.multiply(n), numerator); - } - -override public Num divide(int n) - { - return Num.divide(denominator.multiply(n), numerator); - } - -override public Num divide(RatioNum n) - { - return Num.divide(denominator.multiplyBy(n.numerator) - , numerator.multiplyBy(n.denominator)); - } - - -override public Object truncateDivide( Num num) - { - return num.truncateBy( this); - } - -override public Object truncateBy( int div) - { - Num q = (Num) Num.truncate( numerator, denominator.multiply(div)); - return RT.setValues( q, q.multiply(div).subtractFrom(this)); - } - -override public Object truncateBy( BigInteger div) - { - Num q = (Num) Num.truncate( numerator, denominator.multiply(div)); - return RT.setValues( q, q.multiply(div).subtractFrom(this)); - } - -override public Object truncateBy( RatioNum div) - { - Num q = (Num) Num.truncate( numerator.multiplyBy(div.denominator), - denominator.multiplyBy(div.numerator)); - return RT.setValues( q, q.multiplyBy(div).subtractFrom(this)); - } - - -override public Num negate() - { - return Num.divide(numerator.negate(), denominator); - } - -override public Boolean minusp() - { - return numerator.minusp(); - } - -override public Boolean plusp() - { - return numerator.plusp(); - } - -override public Num oneMinus() - { - return addTo(-1); - } - -override public Num onePlus() - { - return addTo(1); - } - -} -} - diff --git a/src/cli/runtime/RationalNum.cs b/src/cli/runtime/RationalNum.cs deleted file mode 100644 index fb5398d1..00000000 --- a/src/cli/runtime/RationalNum.cs +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 28, 2006 10:12:30 AM */ - -using System;
- -namespace clojure.lang
-{ - -public abstract class RationalNum : RealNum { - -} -} diff --git a/src/cli/runtime/RealNum.cs b/src/cli/runtime/RealNum.cs deleted file mode 100644 index d29a404b..00000000 --- a/src/cli/runtime/RealNum.cs +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 28, 2006 10:13:00 AM */ - -using System;
- -namespace clojure.lang
-{ - -public abstract class RealNum : Num { - -} -}
\ No newline at end of file diff --git a/src/cli/runtime/Reflector.cs b/src/cli/runtime/Reflector.cs deleted file mode 100644 index 483c4029..00000000 --- a/src/cli/runtime/Reflector.cs +++ /dev/null @@ -1,168 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-using System.Reflection;
-using System.Collections;
-
-namespace clojure.lang
-{
-public class Reflector{
-
-public static Object invokeInstanceMethod(String name, Object target, Object[] args) //throws Exception
{
Type t = target.GetType();
IList methods = getMethods(t, args.Length, name,false);
- return invokeMatchingMethod(name, target, args, t, methods,false);
- }
-
- private static object invokeMatchingMethod(String name, Object target, Object[] args, Type t, IList methods, bool statics)
- {
- if (methods.Count == 0)
- {
- throw new InvalidOperationException("No matching field or method found");
- }
- else if (methods.Count == 1)
- {
- MethodInfo m = (MethodInfo)methods[0];
- return prepRet(m.Invoke(target, boxArgs(m.GetParameters(), args)));
- }
- else //overloaded w/same arity, let reflection choose most specific match
- {
- return prepRet(t.InvokeMember(name, BindingFlags.Public | (statics ? BindingFlags.Static : BindingFlags.Instance)
- | BindingFlags.FlattenHierarchy | BindingFlags.InvokeMethod,
- null, target, args));
- }
- }
-
-public static Object invokeConstructor(Type t, Object[] args) //throws Exception
- {
- ConstructorInfo[] allctors = t.GetConstructors();
- ArrayList ctors = new ArrayList();
- foreach (ConstructorInfo ctor in allctors)
- {
- if (ctor.GetParameters().Length == args.Length)
- ctors.Add(ctor);
- }
- if (ctors.Count == 0)
- {
- throw new InvalidOperationException("No matching ctor found");
- }
- else if (ctors.Count == 1)
- {
- ConstructorInfo ctor = (ConstructorInfo)ctors[0];
- return ctor.Invoke(boxArgs(ctor.GetParameters(), args));
- }
- else //overloaded w/same arity, let reflection choose most specific match
- {
- return t.InvokeMember(null, BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance,
- null, null, args);
- }
- }
-public static Object invokeStaticMethod(String name, String className, params Object[] args) //throws Exception
- {
- Type t = Type.GetType(className);
- if (name.Equals("new"))
- return invokeConstructor(t, args);
- IList methods = getMethods(t, args.Length, name, true);
- return invokeMatchingMethod(name, null, args, t, methods,true);
- }
-
-public static Object getStaticField(String name, String className) //throws Exception
- {
- //check for field first
- Type t = Type.GetType(className);
- FieldInfo f = getField(t, name, true);
- if (f != null) //field get
- {
- return prepRet(f.GetValue(null));
- }
- PropertyInfo p = getProperty(t, name, true);
- if (p != null)
- {
- return prepRet(p.GetValue(null, null));
- }
- throw new InvalidOperationException("No matching field or property found");
- }
-
-public static Object setStaticField(String name, String className, Object arg1) //throws Exception
- {
- //check for field first
- Type t = Type.GetType(className);
- FieldInfo f = getField(t, name, true);
- if (f != null) //field get
- {
- f.SetValue(null, boxArg(f.FieldType, arg1));
- return arg1;
- }
- PropertyInfo p = getProperty(t, name, true);
- if (p != null)
- {
- p.SetValue(null, boxArg(p.PropertyType, arg1), null);
- return arg1;
- }
- throw new InvalidOperationException("No matching field or property found");
- }
-
-public static Object invokeInstanceMember(String name, Object target) //throws Exception
{
//check for field first
Type t = target.GetType();
FieldInfo f = getField(t, name,false);
if(f != null) //field get
{
return prepRet(f.GetValue(target));
}
- PropertyInfo p = getProperty(t, name,false);
- if (p != null)
- {
- return prepRet(p.GetValue(target, null));
- }
return invokeInstanceMethod(name, target, RT.EMPTY_ARRAY);
}
public static Object invokeInstanceMember(String name, Object target, Object arg1) //throws Exception
{
//check for field first
Type t = target.GetType();
FieldInfo f = getField(t, name,false);
- if (f != null) //field get
- {
- f.SetValue(target,boxArg(f.FieldType,arg1));
- return arg1;
- }
- PropertyInfo p = getProperty(t, name,false);
- if (p != null)
- {
- //could be indexed property, which we otherwise aren't dealing with yet
- if(p.GetIndexParameters() != null && p.GetIndexParameters().Length == 1)
- return prepRet(p.GetValue(target, new Object[]{boxArg(p.GetIndexParameters()[0].ParameterType,arg1)}));
- p.SetValue(target,boxArg(p.PropertyType,arg1),null);
- return arg1;
- }
return invokeInstanceMethod(name, target, new Object[]{arg1});
}
public static Object invokeInstanceMember(String name, Object target, params Object[] args) //throws Exception
{
return invokeInstanceMethod(name, target, args);
}
-
- public static FieldInfo getField(Type t, string name,bool statics)
- {
- return t.GetField(name, BindingFlags.Public | (statics ? BindingFlags.Static : BindingFlags.Instance) | BindingFlags.FlattenHierarchy);
- }
- public static PropertyInfo getProperty(Type t, string name, bool statics)
- {
- return t.GetProperty(name, BindingFlags.Public | (statics ? BindingFlags.Static : BindingFlags.Instance) | BindingFlags.FlattenHierarchy);
- }
-
- static public IList getMethods(Type t, int arity, String name, bool getStatics)
- {
- MethodInfo[] allmethods = t.GetMethods(BindingFlags.Public | (getStatics?BindingFlags.Static : BindingFlags.Instance)
- | BindingFlags.FlattenHierarchy);
- ArrayList methods = new ArrayList();
- for (int i = 0; i < allmethods.Length; i++)
- {
- if (name.Equals(allmethods[i].Name)
- && allmethods[i].GetParameters().Length == arity)
- {
- methods.Add(allmethods[i]);
- }
- }
- return methods;
- }
-
-static Object boxArg(Type paramType, Object arg)
{
Type argType = arg.GetType();
if(paramType == argType)
return arg;
if(paramType == typeof(bool))
{
return arg != null;
}
else if(paramType.IsPrimitive && arg is Num)
{
Num n = (Num) arg;
if(paramType == typeof(int))
return n.intValue();
else if(paramType == typeof(float))
return n.floatValue();
else if(paramType == typeof(double))
return n.doubleValue();
else if(paramType == typeof(long))
return n.longValue();
else if(paramType == typeof(char))
return (char) n.intValue();
else if(paramType == typeof(short))
return n.shortValue();
else if(paramType == typeof(byte))
return n.byteValue();
else
throw new ArgumentException("Cannot convert to primitive type: " + paramType.Name);
}
else
return arg;
}
static Object[] boxArgs(ParameterInfo[] parms, Object[] args)
{
if(parms.Length == 0)
return null;
Object[] ret = new Object[parms.Length];
for(int i = 0; i < parms.Length; i++)
{
Object arg = args[i];
Type paramType = parms[i].ParameterType;
ret[i] = boxArg(paramType, arg);
}
return ret;
}
-
-static Object prepRet(Object x)
- {
- if(x is Boolean)
- return ((Boolean)x)?RT.T:null;
- return x;
- }
-
-
- }
-}
diff --git a/src/cli/runtime/RestFn.cs b/src/cli/runtime/RestFn.cs deleted file mode 100644 index b83bf057..00000000 --- a/src/cli/runtime/RestFn.cs +++ /dev/null @@ -1,1336 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-using System;
-
-namespace clojure.lang
-{
-public abstract class RestFn : AFn {
-
-protected int reqArity;
-
-public RestFn(int reqArity) {
- this.reqArity = reqArity;
-}
-
-protected virtual Object doInvoke(ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, ISeq args)
- {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, ISeq args)
- {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, ISeq args)
- {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,
- Object arg14, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,
- Object arg14, Object arg15, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,
- Object arg14, Object arg15, Object arg16, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,
- Object arg14, Object arg15, Object arg16, Object arg17, ISeq args) {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,
- Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, ISeq args)
- {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,
- Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, ISeq args)
- {
- return null;
-}
-
-protected virtual Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,
- Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19,
- Object arg20, ISeq args) {
- return null;
-}
-
-
-
-override public Object applyTo(ISeq args) {
- if (RT.boundedLength(args, reqArity) <= reqArity)
- {
- return applyToHelper(this, args);
- }
- switch (reqArity)
- {
- case 0:
- return invoke(args);
- case 1:
- return invoke(args.first()
- , args.rest());
- case 2:
- return invoke(args.first()
- , (args = args.rest()).first()
- , args.rest());
- case 3:
- return invoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
- case 4:
- return invoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
- case 5:
- return invoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
- case 6:
- return invoke(args.first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , (args = args.rest()).first()
- , args.rest());
- case 7:
- return invoke(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());
- case 8:
- return invoke(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());
- case 9:
- return invoke(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());
- case 10:
- return invoke(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());
- case 11:
- return invoke(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());
- case 12:
- return invoke(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());
- case 13:
- return invoke(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());
- case 14:
- return invoke(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());
- case 15:
- return invoke(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());
- case 16:
- return invoke(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());
- case 17:
- return invoke(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());
- case 18:
- return invoke(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());
- case 19:
- return invoke(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());
- case 20:
- return invoke(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());
-
- }
- return throwArity();
-}
-
-override public Object invoke() {
- switch (reqArity)
- {
- case 0:
- return doInvoke(null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1));
- case 1:
- return doInvoke(arg1, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2));
- case 2:
- return doInvoke(arg1, arg2, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3));
- case 3:
- return doInvoke(arg1, arg2, arg3, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5, arg6));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, ArraySeq.create(arg6));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)
- {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6, arg7));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5, arg6, arg7));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, ArraySeq.create(arg6, arg7));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, ArraySeq.create(arg7));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6, arg7, arg8));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5, arg6, arg7, arg8));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, ArraySeq.create(arg6, arg7, arg8));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, ArraySeq.create(arg7, arg8));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, ArraySeq.create(arg8));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8, arg9));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6, arg7, arg8, arg9));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5, arg6, arg7, arg8, arg9));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, ArraySeq.create(arg6, arg7, arg8, arg9));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, ArraySeq.create(arg7, arg8, arg9));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, ArraySeq.create(arg8, arg9));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, ArraySeq.create(arg9));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6, arg7, arg8, arg9, arg10));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5, arg6, arg7, arg8, arg9, arg10));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, ArraySeq.create(arg6, arg7, arg8, arg9, arg10));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, ArraySeq.create(arg7, arg8, arg9, arg10));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, ArraySeq.create(arg8, arg9, arg10));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, ArraySeq.create(arg9, arg10));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, ArraySeq.create(arg10));
- case 10:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5, arg6, arg7, arg8, arg9, arg10, arg11));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, ArraySeq.create(arg6, arg7, arg8, arg9, arg10, arg11));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, ArraySeq.create(arg7, arg8, arg9, arg10, arg11));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, ArraySeq.create(arg8, arg9, arg10, arg11));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, ArraySeq.create(arg9, arg10, arg11));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, ArraySeq.create(arg10, arg11));
- case 10:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, ArraySeq.create(arg11));
- case 11:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, ArraySeq.create(arg6, arg7, arg8, arg9, arg10, arg11, arg12));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, ArraySeq.create(arg7, arg8, arg9, arg10, arg11, arg12));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, ArraySeq.create(arg8, arg9, arg10, arg11, arg12));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, ArraySeq.create(arg9, arg10, arg11, arg12));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, ArraySeq.create(arg10, arg11, arg12));
- case 10:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, ArraySeq.create(arg11, arg12));
- case 11:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, ArraySeq.create(arg12));
- case 12:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13)
- {
- switch (reqArity)
- {
- case 0:
- return doInvoke(
- ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13));
- case 2:
- return doInvoke(arg1, arg2,
- ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13));
- case 3:
- return doInvoke(arg1, arg2, arg3,
- ArraySeq.create(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4,
- ArraySeq.create(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5,
- ArraySeq.create(arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6,
- ArraySeq.create(arg7, arg8, arg9, arg10, arg11, arg12, arg13));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7,
- ArraySeq.create(arg8, arg9, arg10, arg11, arg12, arg13));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8,
- ArraySeq.create(arg9, arg10, arg11, arg12, arg13));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,
- ArraySeq.create(arg10, arg11, arg12, arg13));
- case 10:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- ArraySeq.create(arg11, arg12, arg13));
- case 11:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- ArraySeq.create(arg12, arg13));
- case 12:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- ArraySeq.create(arg13));
- case 13:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)
- {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14));
- case 3:
- return doInvoke(arg1, arg2, arg3,
- ArraySeq.create(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4,
- ArraySeq.create(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5,
- ArraySeq.create(arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6,
- ArraySeq.create(arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7,
- ArraySeq.create(arg8, arg9, arg10, arg11, arg12, arg13, arg14));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8,
- ArraySeq.create(arg9, arg10, arg11, arg12, arg13, arg14));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,
- ArraySeq.create(arg10, arg11, arg12, arg13, arg14));
- case 10:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- ArraySeq.create(arg11, arg12, arg13, arg14));
- case 11:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- ArraySeq.create(arg12, arg13, arg14));
- case 12:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- ArraySeq.create(arg13, arg14));
- case 13:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,
- ArraySeq.create(arg14));
- case 14:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4,
- ArraySeq.create(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5,
- ArraySeq.create(arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6,
- ArraySeq.create(arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7,
- ArraySeq.create(arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8,
- ArraySeq.create(arg9, arg10, arg11, arg12, arg13, arg14, arg15));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,
- ArraySeq.create(arg10, arg11, arg12, arg13, arg14, arg15));
- case 10:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- ArraySeq.create(arg11, arg12, arg13, arg14, arg15));
- case 11:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- ArraySeq.create(arg12, arg13, arg14, arg15));
- case 12:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- ArraySeq.create(arg13, arg14, arg15));
- case 13:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,
- ArraySeq.create(arg14, arg15));
- case 14:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- ArraySeq.create(arg15));
- case 15:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5,
- ArraySeq.create(arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6,
- ArraySeq.create(arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7,
- ArraySeq.create(arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8,
- ArraySeq.create(arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,
- ArraySeq.create(arg10, arg11, arg12, arg13, arg14, arg15, arg16));
- case 10:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- ArraySeq.create(arg11, arg12, arg13, arg14, arg15, arg16));
- case 11:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- ArraySeq.create(arg12, arg13, arg14, arg15, arg16));
- case 12:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- ArraySeq.create(arg13, arg14, arg15, arg16));
- case 13:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,
- ArraySeq.create(arg14, arg15, arg16));
- case 14:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- ArraySeq.create(arg15, arg16));
- case 15:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, ArraySeq.create(arg16));
- case 16:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, ArraySeq.create(arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6,
- ArraySeq.create(arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7,
- ArraySeq.create(arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8,
- ArraySeq.create(arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,
- ArraySeq.create(arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17));
- case 10:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- ArraySeq.create(arg11, arg12, arg13, arg14, arg15, arg16, arg17));
- case 11:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- ArraySeq.create(arg12, arg13, arg14, arg15, arg16, arg17));
- case 12:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- ArraySeq.create(arg13, arg14, arg15, arg16, arg17));
- case 13:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,
- ArraySeq.create(arg14, arg15, arg16, arg17));
- case 14:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- ArraySeq.create(arg15, arg16, arg17));
- case 15:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, ArraySeq.create(arg16, arg17));
- case 16:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, ArraySeq.create(arg17));
- case 17:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, ArraySeq.create(arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, ArraySeq.create(arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17,
- arg18));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7,
- ArraySeq.create(arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8,
- ArraySeq.create(arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,
- ArraySeq.create(arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18));
- case 10:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- ArraySeq.create(arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18));
- case 11:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- ArraySeq.create(arg12, arg13, arg14, arg15, arg16, arg17, arg18));
- case 12:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- ArraySeq.create(arg13, arg14, arg15, arg16, arg17, arg18));
- case 13:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,
- ArraySeq.create(arg14, arg15, arg16, arg17, arg18));
- case 14:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- ArraySeq.create(arg15, arg16, arg17, arg18));
- case 15:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, ArraySeq.create(arg16, arg17, arg18));
- case 16:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, ArraySeq.create(arg17, arg18));
- case 17:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, ArraySeq.create(arg18));
- case 18:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, arg18, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18, Object arg19) {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18, arg19));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18, arg19));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18, arg19));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18, arg19));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18, arg19));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, ArraySeq.create(arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18,
- arg19));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, ArraySeq.create(arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17,
- arg18, arg19));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, ArraySeq.create(arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17,
- arg18, arg19));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, ArraySeq.create(arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16,
- arg17, arg18, arg19));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,
- ArraySeq.create(arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19));
- case 10:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- ArraySeq.create(arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19));
- case 11:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- ArraySeq.create(arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19));
- case 12:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- ArraySeq.create(arg13, arg14, arg15, arg16, arg17, arg18, arg19));
- case 13:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,
- ArraySeq.create(arg14, arg15, arg16, arg17, arg18, arg19));
- case 14:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- ArraySeq.create(arg15, arg16, arg17, arg18, arg19));
- case 15:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, ArraySeq.create(arg16, arg17, arg18, arg19));
- case 16:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, ArraySeq.create(arg17, arg18, arg19));
- case 17:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, ArraySeq.create(arg18, arg19));
- case 18:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, arg18, ArraySeq.create(arg19));
- case 19:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, arg18, arg19, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20)
- {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ArraySeq.create(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 1:
- return doInvoke(arg1, ArraySeq.create(arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 2:
- return doInvoke(arg1, arg2, ArraySeq.create(arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 3:
- return doInvoke(arg1, arg2, arg3, ArraySeq.create(arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ArraySeq.create(arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18, arg19,
- arg20));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, ArraySeq.create(arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17, arg18,
- arg19, arg20));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, ArraySeq.create(arg7, arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17,
- arg18, arg19, arg20));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, ArraySeq.create(arg8, arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16, arg17,
- arg18, arg19, arg20));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, ArraySeq.create(arg9, arg10, arg11, arg12,
- arg13, arg14, arg15, arg16,
- arg17, arg18, arg19,
- arg20));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, ArraySeq.create(arg10, arg11, arg12,
- arg13, arg14, arg15,
- arg16, arg17, arg18,
- arg19, arg20));
- case 10:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- ArraySeq.create(arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 11:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- ArraySeq.create(arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 12:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- ArraySeq.create(arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 13:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,
- ArraySeq.create(arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 14:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- ArraySeq.create(arg15, arg16, arg17, arg18, arg19, arg20));
- case 15:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, ArraySeq.create(arg16, arg17, arg18, arg19, arg20));
- case 16:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, ArraySeq.create(arg17, arg18, arg19, arg20));
- case 17:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, ArraySeq.create(arg18, arg19, arg20));
- case 18:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, arg18, ArraySeq.create(arg19, arg20));
- case 19:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, arg18, arg19, ArraySeq.create(arg20));
- case 20:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, arg18, arg19, arg20, null);
- default:
- return throwArity();
- }
-
-}
-
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20, params Object[] args)
- {
- switch (reqArity)
- {
- case 0:
- return doInvoke(ontoArrayPrepend(args, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 1:
- return doInvoke(arg1, ontoArrayPrepend(args, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 2:
- return doInvoke(arg1, arg2, ontoArrayPrepend(args, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19,
- arg20));
- case 3:
- return doInvoke(arg1, arg2, arg3, ontoArrayPrepend(args, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19,
- arg20));
- case 4:
- return doInvoke(arg1, arg2, arg3, arg4, ontoArrayPrepend(args, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- arg12, arg13, arg14, arg15, arg16, arg17, arg18,
- arg19, arg20));
- case 5:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, ontoArrayPrepend(args, arg6, arg7, arg8, arg9, arg10, arg11,
- arg12, arg13, arg14, arg15, arg16, arg17,
- arg18, arg19, arg20));
- case 6:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, ontoArrayPrepend(args, arg7, arg8, arg9, arg10, arg11,
- arg12, arg13, arg14, arg15, arg16,
- arg17, arg18, arg19, arg20));
- case 7:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, ontoArrayPrepend(args, arg8, arg9, arg10, arg11,
- arg12, arg13, arg14, arg15,
- arg16, arg17, arg18, arg19,
- arg20));
- case 8:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, ontoArrayPrepend(args, arg9, arg10, arg11,
- arg12, arg13, arg14, arg15,
- arg16, arg17, arg18, arg19,
- arg20));
- case 9:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, ontoArrayPrepend(args, arg10, arg11,
- arg12, arg13, arg14,
- arg15, arg16, arg17,
- arg18, arg19,
- arg20));
- case 10:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, ontoArrayPrepend(args, arg11,
- arg12, arg13,
- arg14, arg15,
- arg16, arg17,
- arg18, arg19,
- arg20));
- case 11:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
- ontoArrayPrepend(args, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 12:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12,
- ontoArrayPrepend(args, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 13:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,
- ontoArrayPrepend(args, arg14, arg15, arg16, arg17, arg18, arg19, arg20));
- case 14:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- ontoArrayPrepend(args, arg15, arg16, arg17, arg18, arg19, arg20));
- case 15:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, ontoArrayPrepend(args, arg16, arg17, arg18, arg19, arg20));
- case 16:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, ontoArrayPrepend(args, arg17, arg18, arg19, arg20));
- case 17:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, ontoArrayPrepend(args, arg18, arg19, arg20));
- case 18:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, arg18, ontoArrayPrepend(args, arg19, arg20));
- case 19:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, arg18, arg19, ontoArrayPrepend(args, arg20));
- case 20:
- return doInvoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14,
- arg15, arg16, arg17, arg18, arg19, arg20, ArraySeq.create(args));
- default:
- return throwArity();
- }
-
-}
-
-
-protected static ISeq ontoArrayPrepend(Object[] array, params Object[] args) {
- ISeq ret = ArraySeq.create(array);
- for (int i = args.Length - 1; i >= 0; --i)
- ret = RT.cons(args[i], ret);
- return ret;
-}
-
-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 null;
-}
-}
-
-}
diff --git a/src/cli/runtime/Sequential.cs b/src/cli/runtime/Sequential.cs deleted file mode 100644 index a8b48e96..00000000 --- a/src/cli/runtime/Sequential.cs +++ /dev/null @@ -1,18 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- */
-
-namespace clojure.lang
-{ -
-
-public interface Sequential {
-}
-
-}
diff --git a/src/cli/runtime/StaticMemberSymbol.cs b/src/cli/runtime/StaticMemberSymbol.cs deleted file mode 100644 index 18393f60..00000000 --- a/src/cli/runtime/StaticMemberSymbol.cs +++ /dev/null @@ -1,160 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
- -namespace clojure.lang
-{ -
-public class StaticMemberSymbol : HostSymbol, IFn{
-readonly public String className;
-readonly public String memberName;
-
-public StaticMemberSymbol(String name) : base(name) {
- int lastDot = name.LastIndexOf('.');
- this.className = name.Substring(0,lastDot);
- this.memberName = name.Substring(lastDot + 1);
-}
-
-public Object invoke() {
- return Reflector.invokeStaticMethod(memberName, className );
-}
-
-public Object invoke(Object obj) {
-
- return Reflector.invokeStaticMethod(memberName, className , obj);
-}
-
-public Object invoke(Object obj, Object val) {
-
- return Reflector.invokeStaticMethod(memberName, className , obj, val);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)
- {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11) {
- return Reflector
- .invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13)
- {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)
- {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14, arg15);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14, arg15, arg16);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14, arg15, arg16, arg17);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18, Object arg19) {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19);
-}
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20)
- {
- return Reflector.invokeStaticMethod(memberName, className , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
- arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20);
-}
-
-
-public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,
- Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,
- Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20
- , params Object[] args)
- {
- throw new InvalidOperationException("Can't call functions of more than 20 arguments");
-}
-
-public Object applyTo(ISeq arglist) {
- return AFn.applyToHelper(this, arglist);
-}
-
-}
-
-}
diff --git a/src/cli/runtime/Symbol.cs b/src/cli/runtime/Symbol.cs deleted file mode 100644 index 1a72b60e..00000000 --- a/src/cli/runtime/Symbol.cs +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 25, 2006 11:42:47 AM */ - -using System;
-using System.Collections;
- -namespace clojure.lang
-{ -public class Symbol
-// : Obj, IComparable
-{
-
-static public readonly Hashtable table = new Hashtable(1001);
-//static public readonly Hashtable hashes = new Hashtable(1001); -//static readonly Random rand = new Random(42);
- - -public readonly String name;
-//int hash = 0; - -override public String ToString() - { - return name; - } - -public static Symbol intern(String name)
{
lock(table)
{
Symbol sym = (Symbol) table[name];
- int dot = 0;
- if (sym == null)
- {
- if (name[0] == ':')
- sym = new Keyword(name);
- else if ((dot = name.IndexOf('.')) != -1)
- {
- if (dot == 0)
- sym = new InstanceMemberSymbol(name);
- else if (name.LastIndexOf('.') == name.Length - 1)
- sym = new ClassSymbol(name);
- else
- sym = new StaticMemberSymbol(name);
- }
- else
- sym = new Symbol(name);
if(table[name] != null) //defend against recursive static init
- return (Symbol)table[name];
table.Add(name, sym);
}
return sym;
}
} -/** - * Used by Module.intern() - * @param name - * @param ns - */ -internal Symbol(String name) - { - this.name = name; - } - -/* -public override int GetHashCode()
- {
- if(hash == 0)
- {
- lock (hashes)
- {
- while (hash == 0)
- {
- int h = rand.Next();
- if (h != 0 && !hashes.ContainsKey(h))
- {
- hash = h;
- hashes.Add(h,null);
- }
- }
- }
- }
- return hash;
- }
-
-
-#region IComparable Members
-
-public int CompareTo(object obj)
- {
- return GetHashCode() - ((Symbol)obj).GetHashCode();
- }
-
-#endregion
-
-override public Obj withMeta(IPersistentMap meta) {
- this._meta = meta;
- return this;
-}
-*/
- } -} diff --git a/src/cli/runtime/TObj.cs b/src/cli/runtime/TObj.cs deleted file mode 100644 index 0fe6b471..00000000 --- a/src/cli/runtime/TObj.cs +++ /dev/null @@ -1,51 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-
-namespace clojure.lang
- {
-
-public class TObj : IObj{
-TRef _attrs;
-
-public TObj(){
- this._attrs = Transaction.tref(PersistentArrayMap.EMPTY);
-}
-
-
-public Object putAttr( Object key, Object val) {
- IPersistentMap t = (IPersistentMap) Transaction.get( _attrs);
- t = (IPersistentMap)t.assoc(key, val);
- Transaction.set(_attrs,t);
- return val;
-}
-
-public Object getAttr( Object key) {
- IPersistentMap t = (IPersistentMap) Transaction.get( _attrs);
- return t.get(key);
-}
-
-public bool hasAttr( Object key) {
- IPersistentMap t = (IPersistentMap) Transaction.get( _attrs);
- return t.contains(key);
-}
-
-public IPersistentMap attrs() {
- return (IPersistentMap) Transaction.get(_attrs);
-}
-
-public void removeAttr(Object key) {
- IPersistentMap t = (IPersistentMap) Transaction.get( _attrs);
- t = t.without(key);
- Transaction.set(_attrs,t);
-}
-}
-}
diff --git a/src/cli/runtime/TRef.cs b/src/cli/runtime/TRef.cs deleted file mode 100644 index d749793f..00000000 --- a/src/cli/runtime/TRef.cs +++ /dev/null @@ -1,32 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-/* rich May 30, 2006 */
-
-using System;
-using System.Threading;
-
-namespace clojure.lang
-{
-
-public class TRef : TVal, IComparable{
-static int nextSeq = 0;
-
-readonly int lockSeq;
-
-public TRef() {
- this.lockSeq = Interlocked.Increment(ref nextSeq);
-}
-
-public int CompareTo(Object o){
- return lockSeq - ((TRef) o).lockSeq;
-}
-}
-}
diff --git a/src/cli/runtime/TVal.cs b/src/cli/runtime/TVal.cs deleted file mode 100644 index 26ee74a6..00000000 --- a/src/cli/runtime/TVal.cs +++ /dev/null @@ -1,42 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-/* rich May 30, 2006 */
-
-using System;
-
-namespace clojure.lang
-{
-public class TVal{
-internal volatile Object val;
-internal volatile Transaction.Info tinfo;
-internal volatile TVal prior;
-
-internal TVal(){
-
-}
-
-internal TVal(Object val, Transaction.Info tinfo, TVal prior) {
- this.val = val;
- this.tinfo = tinfo;
- this.prior = prior;
-}
-
-internal void push(Object val,Transaction.Info tinfo) {
- if(tinfo != null) //not newly created, clone tval part
- {
- this.prior = new TVal(this.val,this.tinfo,this.prior);
- }
- this.tinfo = tinfo;
- this.val = val;
-}
-
-}
-}
diff --git a/src/cli/runtime/ThreadLocalData.cs b/src/cli/runtime/ThreadLocalData.cs deleted file mode 100644 index 8d866bda..00000000 --- a/src/cli/runtime/ThreadLocalData.cs +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) Rich Hickey. All rights reserved. - * The use and distribution terms for this software are covered by the - * Common Public License 1.0 (http://opensource.org/licenses/cpl.php) - * which can be found in the file CPL.TXT at the root of this distribution. - * By using this software in any fashion, you are agreeing to be bound by - * the terms of this license. - * You must not remove this notice, or any other, from this software. - **/ - -/* rich Mar 25, 2006 11:45:22 AM */ - -using System;
-using System.Collections.Specialized;
-
-namespace clojure.lang
-{ -public class ThreadLocalData{
-
-[ThreadStatic]
-private static Object[] values;
-
-static public Object[] getValues(){
- return values;
-}
-
-static public void setValues(Object[] vals) {
- values = vals;
-}
-
-
- -} -} diff --git a/src/cli/runtime/Transaction.cs b/src/cli/runtime/Transaction.cs deleted file mode 100644 index b761b9e2..00000000 --- a/src/cli/runtime/Transaction.cs +++ /dev/null @@ -1,267 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-/* rich May 30, 2006 */
-
-using System;
-using System.Threading;
-using System.Collections.Generic;
-
-namespace clojure.lang
-{
-public class Transaction{
-
-public const int COMMITTED = 0;
-public const int WORKING = 1;
-static readonly Object lockObj = new Object();
-[ThreadStatic]
-private static Transaction transaction;
-
-static volatile int tcount = 0;
-
-static Transaction getTransaction()
- {
- if(tcount == 0)
- return null;
- return transaction;
- }
-
-static void setTransaction(Transaction t)
- {
- transaction = t;
- }
-
-
-volatile static int nextSeq = 1;
-
-static int getNextSeq(){
-lock (lockObj)
-{
- return nextSeq++;
- }
-}
-
-public class Info{
-internal int seq;
-internal int status;
-
-
-internal Info(int seq,int status){
- this.seq = seq;
- this.status = status;
-}
-}
-
-static Info bigbang = new Info(0,COMMITTED);
-
-Info info;
-int startSeq;
-
-Dictionary<TRef,Object> sets;
-Dictionary<TRef,ISeq> commutates;
-
-
-static public Object runInTransaction(ThreadLocalData tld,IFn fn) {
- if(getTransaction() != null)
- return fn.invoke(tld);
- Transaction t = new Transaction();
- setTransaction(t);
- Interlocked.Increment(ref tcount);
- try
- {
- return t.run(fn);
- }
- finally{
- setTransaction(null);
- Interlocked.Decrement(ref tcount);
- }
-}
-
-static public TRef tref(Object val) {
- Transaction trans = getTransaction();
- TRef tref = new TRef();
- if(trans == null)
- tref.push(val,bigbang);
- else
- trans.doSet(tref, val);
- return tref;
-}
-
-static public Object get(TRef tref) {
- Transaction trans = getTransaction();
- if(trans != null)
- return trans.doGet(tref);
- return getCurrent(tref).val;
- }
-
-static public Object set(TRef tref, Object val) {
- return getTransaction().doSet(tref,val);
-}
-
-static public void touch(TRef tref) {
- getTransaction().doTouch(tref);
-}
-
-static public void commutate(TRef tref, IFn fn) {
- getTransaction().doCommutate(tref, fn);
-}
-
-
-Object run(IFn fn) {
- bool done = false;
- Object ret = null;
- List<TRef> locks = null;
- List<TRef> locked = null;
-
- while(!done){
- try
- {
- ret = fn.invoke();
- if(locks == null && (sets != null || commutates != null))
- locks = new List<TRef>();
- if(sets != null)
- locks.AddRange(sets.Keys);
- if(commutates != null)
- locks.AddRange(commutates.Keys);
- if(locks != null)
- {
- if(locked == null)
- locked = new List<TRef>(locks.Count);
- //lock in order, to avoid deadlocks
- locks.Sort();
- foreach(TRef tref in locks)
- {
- //will block here
- Monitor.Enter(tref);
- locked.Add(tref);
- if(sets.ContainsKey(tref))
- {
- //try again if the thing we are trying to set has changed since we started
- TVal curr = getCurrent(tref);
- if(curr != null && curr.tinfo.seq > startSeq)
- goto loop;
- }
- }
- }
-
- //at this point all write targets are locked
- //turn commutates into sets
- foreach(KeyValuePair<TRef, ISeq> e in commutates)
- {
- TRef tref = e.Key;
- //note this will npe if tref has never been set, as designed
- Object val = getCurrent(tref).val;
- for(ISeq c = e.Value;c!=null;c = c.rest())
- {
- IFn f = (IFn) c.first();
- val = f.invoke(val);
- }
- sets[tref] = val;
- }
-
- //set the new vals
- foreach(KeyValuePair<TRef, Object> entry in sets)
- {
- TRef tref = entry.Key;
- tref.push(entry.Value, info);
- }
-
- //atomic commit
- lock(lockObj){
- info.seq = getNextSeq();
- info.status = COMMITTED;
- }
-
- done = true;
- loop:
- ;
- }
- finally{
- if(locked != null)
- {
- foreach(TRef tref in locked)
- {
- Monitor.Exit(tref);
- }
- locked.Clear();
- }
- reset();
- if(locks != null)
- locks.Clear();
- }
- }
- return ret;
-}
-
-private void reset(){
- if(sets != null)
- sets.Clear();
- if(commutates != null)
- commutates.Clear();
-
-}
-
-
-Transaction(){
- lock(lockObj){
- int seq = getNextSeq();
- this.info = new Info(seq, WORKING);
- this.startSeq = seq;
- }
-}
-
-Object doGet(TRef tref) {
- if(sets != null && sets.ContainsKey(tref))
- return sets[tref];
-
- for(TVal ver = tref;ver != null;ver = ver.prior)
- {
- //note this will npe if tref has never been set, as designed
- if(ver.tinfo.status == COMMITTED && ver.tinfo.seq <= startSeq)
- return ver.val;
- }
-
- throw new Exception("Version not found");
-}
-
-static TVal getCurrent(TRef tref) {
- for(TVal ver = tref;ver != null;ver = ver.prior)
- {
- if(ver.tinfo != null && ver.tinfo.status == COMMITTED)
- return ver;
- }
- //this return only if no value was ever successfully set
- return null;
-}
-
-Object doSet(TRef tref, Object val) {
- if(sets == null)
- sets = new Dictionary<TRef,Object>();
- if(commutates != null && commutates.ContainsKey(tref))
- throw new Exception("Can't commutate and set a TRef in the same transaction");
-
- sets[tref] =val;
- return val;
- }
-
-void doTouch(TRef tref) {
- doSet(tref, doGet(tref));
- }
-
-void doCommutate(TRef tref, IFn fn) {
- if(commutates == null)
- commutates = new Dictionary<TRef,ISeq>();
- if(sets != null && sets.ContainsKey(tref))
- throw new Exception("Can't commutate and set a TRef in the same transaction");
- commutates[tref] = RT.cons(fn, commutates[tref]);
- }
-
-}
-}
diff --git a/src/cli/runtime/Tuple.cs b/src/cli/runtime/Tuple.cs deleted file mode 100644 index 24f7f760..00000000 --- a/src/cli/runtime/Tuple.cs +++ /dev/null @@ -1,91 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-/* rich Jun 19, 2006 */
-
-using System;
- -namespace clojure.lang
-{ -
-public class Tuple : APersistentArray{
-
-readonly Object[] array;
-
-readonly public static Tuple EMPTY = new Tuple();
-
-/**
- * This ctor captures/aliases the passed array, so do not modify later !
- * @param init {key1,val1,key2,val2,...}
- */
-public Tuple(params Object[] init){
- this.array = init;
-}
-
-override public int count() {
- return array.Length;
-}
-
-override public int length() {
- return array.Length;
-}
-
-override public Object nth(int i){
- return array[i];
-}
-
-
-override public IPersistentArray assocN(int i, Object val) {
- Object[] newArray = (Object[])array.Clone();
- newArray[i] = val;
- return new Tuple(newArray);
-}
-
-override public bool Equals(Object key){
- if(this == key) return true;
- if(key == null || !(key is IPersistentArray)) return false;
-
- IPersistentArray a = (IPersistentArray) key;
-
- if(a.length() != array.Length)
- return false;
-
- for(int i = 0; i < array.Length; i++)
- {
- if(!equalKey(array[i],a.nth(i)))
- return false;
- }
-
- return true;
-}
-
-override public int GetHashCode(){
- int ret = 0;
- for(int i = 0; i < array.Length; i++)
- {
- Object o = array[i];
- if(o != null)
- ret ^= o.GetHashCode();
- }
- return ret;
-}
-
-private bool equalKey(Object k1,Object k2){
- if(k1 == null)
- return k2 == null;
- return k1.Equals(k2);
-}
-
-override public ISeq seq() {
- return ArraySeq.create(array);
-}
-}
-
-}
diff --git a/src/cli/runtime/Var.cs b/src/cli/runtime/Var.cs deleted file mode 100644 index d2fae255..00000000 --- a/src/cli/runtime/Var.cs +++ /dev/null @@ -1,123 +0,0 @@ -/**
- * Copyright (c) Rich Hickey. All rights reserved.
- * The use and distribution terms for this software are covered by the
- * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
- * which can be found in the file CPL.TXT at the root of this distribution.
- * By using this software in any fashion, you are agreeing to be bound by
- * the terms of this license.
- * You must not remove this notice, or any other, from this software.
- **/
-
-using System;
-using System.Threading;
-
-namespace clojure.lang
-{
-public class Var : AFn
- {
-public readonly Symbol name;
public Module module;
public Binding binding;
-public bool hidden = false;
IPersistentMap threadBindings = PersistentArrayMap.EMPTY;
int tcount = 0;
internal Var(Symbol sym, Module ns)
{
if(sym.GetType() != typeof(Symbol))
throw new ArgumentException("Only simple symbols can be var names");
this.module = ns;
this.name = sym;
}
override public String ToString()
{
if(module == null)
return "#:" + name;
return module.name + ":" + name;
}
public Var bind(Object val)
{
lock(this){
if(binding == null)
- binding = new Binding(val);
else
binding.val = val;
-
- return this;
}
}
public Object getValue()
{
- Binding b = getBinding();
if(b != null)
return b.val;
throw new InvalidOperationException(this.ToString() + " is unbound.");
}
public Object setValue(Object val)
{
- Binding b = getThreadBinding();
if(b != null)
return b.val = val;
if(binding == null)
- throw new InvalidOperationException(this.ToString() + " is unbound.");
return binding.val = val;
}
-
-public Binding pushThreadBinding(Object val) {
- Binding ret = new Binding(val, getThreadBinding());
- setThreadBinding(ret);
- Interlocked.Increment(ref tcount);
- return ret;
-}
-
-public void popThreadBinding() {
- setThreadBinding(getThreadBinding().rest);
- Interlocked.Decrement(ref tcount);
-}
-
-Binding getBinding()
{
- Binding b = getThreadBinding();
if(b != null)
return b;
return binding;
}
-Binding getThreadBinding()
{
- if (tcount != 0)
- return (Binding)threadBindings.get(Thread.CurrentThread);
return null;
}
void setThreadBinding(Binding b) {
- Thread thread = Thread.CurrentThread;
- IPersistentMap tb;
- IPersistentMap newtb;
- do
- {
- tb = threadBindings;
- if (b == null)
- newtb = tb.without(thread);
- else
- newtb = (IPersistentMap)tb.assoc(thread, b);
- } while (tb != Interlocked.CompareExchange(ref threadBindings, newtb, tb));
-}
public IFn fn(){
return (IFn)getValue();
}
override public Object invoke(){
- return fn().invoke();
-}
-override public Object invoke(Object arg1){
- return fn().invoke(arg1);
-}
-override public Object invoke(Object arg1, Object arg2){
- return fn().invoke(arg1, arg2);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3){
- return fn().invoke(arg1, arg2, arg3);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4){
- return fn().invoke(arg1, arg2, arg3, arg4);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19);
-}
-override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20);
-}
-
override public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20
- , params Object[] args){
- return fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20,args);
-}
-
}
-}
|
