diff --git a/.gitignore b/.gitignore
index a8a3b1b06..189376cf1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -172,3 +172,4 @@ $RECYCLE.BIN/
# Mono
*.userprefs
+/dist/
diff --git a/Clojure/Clojure.Compile/Clojure.Compile.csproj b/Clojure/Clojure.Compile/Clojure.Compile.csproj
index eda0a5226..af9e18d2f 100644
--- a/Clojure/Clojure.Compile/Clojure.Compile.csproj
+++ b/Clojure/Clojure.Compile/Clojure.Compile.csproj
@@ -125,19 +125,21 @@
-
- mono "$(TargetPath)" clojure.core clojure.core.protocols clojure.core.reducers clojure.main clojure.set clojure.zip clojure.walk clojure.stacktrace clojure.template clojure.test clojure.test.tap clojure.test.junit clojure.pprint clojure.clr.io clojure.repl clojure.clr.shell clojure.string clojure.data clojure.reflect clojure.edn
- "$(TargetPath)" clojure.core clojure.core.protocols clojure.core.reducers clojure.main clojure.set clojure.zip clojure.walk clojure.stacktrace clojure.template clojure.test clojure.test.tap clojure.test.junit clojure.pprint clojure.clr.io clojure.repl clojure.clr.shell clojure.string clojure.data clojure.reflect clojure.edn
+ mono "$(TargetPath)" clojure.core clojure.core.protocols clojure.core.server clojure.core.reducers clojure.main clojure.set clojure.zip clojure.walk clojure.stacktrace clojure.template clojure.test clojure.test.tap clojure.test.junit clojure.pprint clojure.clr.io clojure.repl clojure.clr.shell clojure.string clojure.data clojure.reflect clojure.edn
+ "$(TargetPath)" clojure.core clojure.core.protocols clojure.core.server clojure.core.reducers clojure.main clojure.set clojure.zip clojure.walk clojure.stacktrace clojure.template clojure.test clojure.test.tap clojure.test.junit clojure.pprint clojure.clr.io clojure.repl clojure.clr.shell clojure.string clojure.data clojure.reflect clojure.edn
- set clojure.compiler.direct-linking=$(DirectLinking)
-$(TargetPath) clojure.core clojure.core.protocols clojure.core.server clojure.core.reducers clojure.main clojure.set clojure.zip clojure.walk clojure.stacktrace clojure.template clojure.test clojure.test.tap clojure.test.junit clojure.pprint clojure.clr.io clojure.repl clojure.clr.shell clojure.string clojure.data clojure.reflect clojure.edn
+ CLOJURE_COMPILER_DIRECT_LINKING=$(DirectLinking)
+$(TargetPath) clojure.core clojure.core.protocols clojure.core.server clojure.core.reducers clojure.main clojure.set clojure.zip clojure.walk clojure.stacktrace clojure.template clojure.test clojure.test.tap clojure.test.junit clojure.pprint clojure.clr.io clojure.repl clojure.clr.shell clojure.string clojure.data clojure.reflect clojure.edn
+ set clojure.compiler.direct-linking=$(DirectLinking)
+$(TargetPath) clojure.core clojure.core.protocols clojure.core.server clojure.core.reducers clojure.main clojure.set clojure.zip clojure.walk clojure.stacktrace clojure.template clojure.test clojure.test.tap clojure.test.junit clojure.pprint clojure.clr.io clojure.repl clojure.clr.shell clojure.string clojure.data clojure.reflect clojure.edn
\ No newline at end of file
diff --git a/Clojure/Clojure.Source/Clojure.Source.csproj b/Clojure/Clojure.Source/Clojure.Source.csproj
index 5ca5be1eb..980cd1963 100644
--- a/Clojure/Clojure.Source/Clojure.Source.csproj
+++ b/Clojure/Clojure.Source/Clojure.Source.csproj
@@ -263,6 +263,17 @@
PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
RT.load({0})", relativePath);
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
string cljname = relativePath + ".clj";
string assemblyname = relativePath.Replace('/', '.') + ".clj.dll";
@@ -3434,19 +3396,30 @@ public static void load(String relativePath, Boolean failIfNotFound)
finally
{
Var.popThreadBindings();
+ sw.Stop();
+ Console.WriteLine(string.Concat(Enumerable.Repeat(" ", loadNesting).ToArray()) + "<-- RT.load({0}) LoadAssembly - {1} milliseconds.", relativePath, sw.ElapsedMilliseconds);
+ --loadNesting;
}
}
if (cljInfo != null)
{
- if (booleanCast(Compiler.CompileFilesVar.deref()))
+ if (booleanCast(Compiler.CompileFilesVar.deref())) {
Compile(cljInfo, cljname);
- else
+ sw.Stop();
+ Console.WriteLine(string.Concat(Enumerable.Repeat(" ", loadNesting).ToArray()) + "<-- RT.load({0} Compile - {1} milliseconds.", relativePath, sw.ElapsedMilliseconds);
+ } else {
LoadScript(cljInfo, cljname);
+ sw.Stop();
+ Console.WriteLine(string.Concat(Enumerable.Repeat(" ", loadNesting).ToArray()) + "<-- RT.load({0} LoadScript - {1} milliseconds.", relativePath, sw.ElapsedMilliseconds);
+ }
+ --loadNesting;
return;
}
}
+ var swit = new Stopwatch();
+ swit.Start();
try
{
Var.pushThreadBindings(RT.map(CurrentNSVar, CurrentNSVar.deref(),
@@ -3458,17 +3431,29 @@ public static void load(String relativePath, Boolean failIfNotFound)
finally
{
Var.popThreadBindings();
+ swit.Stop();
+ Console.WriteLine(string.Concat(Enumerable.Repeat(" ", loadNesting).ToArray()) + " RT.load({0} TryLoadInitType - {1} milliseconds.", relativePath, swit.ElapsedMilliseconds);
}
+ var swer = new Stopwatch();
+ swer.Start();
bool loaded = TryLoadFromEmbeddedResource(relativePath, assemblyname);
+ Console.WriteLine(string.Concat(Enumerable.Repeat(" ", loadNesting).ToArray()) + " RT.load({0} TryLoadFromEmbeddedResource - {1} milliseconds.", relativePath, swer.ElapsedMilliseconds);
- if (!loaded && failIfNotFound)
+ if (!loaded && failIfNotFound) {
+ --loadNesting;
+ sw.Stop();
+ Console.WriteLine(string.Concat(Enumerable.Repeat(" ", loadNesting).ToArray()) + "<-- RT.load({0} ERROR - {1} milliseconds.", relativePath, sw.ElapsedMilliseconds);
throw new FileNotFoundException(String.Format("Could not locate {0} or {1} on load path.{2}",
assemblyname,
cljname,
relativePath.Contains("_") ? " Please check that namespaces with dashes use underscores in the Clojure file name." : ""));
+ }
+ sw.Stop();
+ Console.WriteLine(string.Concat(Enumerable.Repeat(" ", loadNesting).ToArray()) + "<-- RT.load({0} - {1} milliseconds.", relativePath, sw.ElapsedMilliseconds);
+ --loadNesting;
}
private static bool TryLoadFromEmbeddedResource(string relativePath, string assemblyname)
@@ -3512,12 +3497,12 @@ private static void MaybeLoadCljScript(string cljname)
LoadCljScript(cljname, false);
}
- static void LoadCljScript(string cljname)
+ public static void LoadCljScript(string cljname)
{
LoadCljScript(cljname, true);
}
- static void LoadCljScript(string cljname, bool failIfNotFound)
+ public static void LoadCljScript(string cljname, bool failIfNotFound)
{
FileInfo cljInfo = FindFile(cljname);
if (cljInfo != null)
@@ -3564,8 +3549,8 @@ public static IEnumerable GetFindFilePaths()
static IEnumerable GetFindFilePathsRaw()
{
- yield return System.AppDomain.CurrentDomain.BaseDirectory;
- yield return Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "bin");
+ yield return System.Environment.CurrentDirectory;
+ yield return Path.Combine(System.Environment.CurrentDirectory, "bin");
yield return Directory.GetCurrentDirectory();
yield return Path.GetDirectoryName(typeof(RT).Assembly.Location);
diff --git a/Clojure/Clojure/Lib/Ref.cs b/Clojure/Clojure/Lib/Ref.cs
index 20c4f5239..5cc0f200b 100644
--- a/Clojure/Clojure/Lib/Ref.cs
+++ b/Clojure/Clojure/Lib/Ref.cs
@@ -96,7 +96,7 @@ public TVal Next
///
/// Construct a TVal, linked to a previous TVal.
- ///
+ ///
public TVal(object val, long point, TVal prior)
{
_val = val;
@@ -109,7 +109,7 @@ public TVal(object val, long point, TVal prior)
///
/// Construct a TVal, linked to itself.
- ///
+ ///
public TVal(object val, long point)
{
_val = val;
@@ -126,7 +126,7 @@ public TVal(object val, long point)
/// Set the value/point.
///
///
- ///
+ ///
public void SetValue(object val, long point)
{
_val = val;
@@ -141,19 +141,19 @@ public void SetValue(object val, long point)
#region Data
///
- /// Values at points in time for this reference.
+ /// Values at points in time for this reference.
///
TVal _tvals;
///
- /// Values at points in time for this reference.
- ///
- internal TVal TVals
- {
- get { return _tvals; }
- }
-
- ///
+ /// Values at points in time for this reference.
+ ///
+ internal TVal TVals
+ {
+ get { return _tvals; }
+ }
+
+ ///
/// Number of faults for the reference.
///
readonly AtomicInteger _faults;
@@ -161,7 +161,7 @@ internal TVal TVals
///
/// Reader/writer lock for the reference.
///
- readonly ReaderWriterLockSlim _lock;
+ readonly ReaderWriterLock _lock;
///
/// Info on the transaction locking this ref.
@@ -196,8 +196,8 @@ public int MinHistory
{
get { return _minHistory; }
set { _minHistory = value; }
- }
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "set")]
+ }
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "set")]
public Ref setMinHistory(int minHistory)
{
_minHistory = minHistory;
@@ -210,8 +210,8 @@ public int MaxHistory
{
get { return _maxHistory; }
set { _maxHistory = value; }
- }
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "set")]
+ }
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "set")]
public Ref setMaxHistory(int maxHistory)
{
_maxHistory = maxHistory;
@@ -222,8 +222,8 @@ public Ref setMaxHistory(int maxHistory)
///
/// Used to generate unique ids.
///
- static readonly AtomicLong _ids = new AtomicLong();
-
+ static readonly AtomicLong _ids = new AtomicLong();
+
bool _disposed = false;
#endregion
@@ -250,7 +250,7 @@ public Ref(object initval, IPersistentMap meta)
{
_id = _ids.getAndIncrement();
_faults = new AtomicInteger();
- _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
+ _lock = new ReaderWriterLock();
_tvals = new TVal(initval, 0);
}
@@ -291,9 +291,9 @@ public Ref(object initval, IPersistentMap meta)
#endregion
- #region History counts
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "get")]
+ #region History counts
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "get")]
public int getHistoryCount()
{
try
@@ -337,21 +337,21 @@ public override object deref()
//Console.WriteLine("Thr {0}, {1}: No-trans get => {2}", Thread.CurrentThread.ManagedThreadId,DebugStr(), ret);
return ret;
}
- return t.DoGet(this);
+ return t.DoGet(this);
}
object currentVal()
{
try
{
- _lock.EnterReadLock();
+ _lock.AcquireReaderLock(-1);
if (_tvals != null)
return _tvals.Val;
throw new InvalidOperationException(String.Format("{0} is unbound.", ToString()));
}
finally
{
- _lock.ExitReadLock();
+ _lock.ReleaseReaderLock();
}
}
@@ -364,7 +364,7 @@ object currentVal()
///
internal void EnterReadLock()
{
- _lock.EnterReadLock();
+ _lock.AcquireReaderLock(-1);
}
///
@@ -372,7 +372,7 @@ internal void EnterReadLock()
///
internal void ExitReadLock()
{
- _lock.ExitReadLock();
+ _lock.ReleaseReaderLock();
}
///
@@ -380,7 +380,7 @@ internal void ExitReadLock()
///
internal void EnterWriteLock()
{
- _lock.EnterWriteLock();
+ _lock.AcquireWriterLock(-1);
}
@@ -389,7 +389,13 @@ internal void EnterWriteLock()
///
internal bool TryEnterWriteLock(int msecTimeout)
{
- return _lock.TryEnterWriteLock(msecTimeout);
+ try {
+ _lock.AcquireWriterLock(msecTimeout);
+ return true;
+
+ } catch(ApplicationException) {
+ return false;
+ }
}
///
@@ -397,7 +403,7 @@ internal bool TryEnterWriteLock(int msecTimeout)
///
internal void ExitWriteLock()
{
- _lock.ExitWriteLock();
+ _lock.ReleaseWriterLock();
}
///
@@ -457,8 +463,8 @@ internal void SetValue(object val, long commitPoint)
/// Set the value (must be in a transaction).
///
/// The new value.
- /// The new value.
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "set")]
+ /// The new value.
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "set")]
public object set(object val)
{
return LockingTransaction.GetEx().DoSet(this, val);
@@ -469,8 +475,8 @@ public object set(object val)
///
/// The function to apply to the current state and additional arguments.
/// Additional arguments.
- /// The computed value.
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "commute")]
+ /// The computed value.
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "commute")]
public object commute(IFn fn, ISeq args)
{
return LockingTransaction.GetEx().DoCommute(this, fn, args);
@@ -481,18 +487,18 @@ public object commute(IFn fn, ISeq args)
///
/// The function to apply to the current state and additional arguments.
/// Additional arguments.
- /// The computed value.
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "alter")]
+ /// The computed value.
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "alter")]
public object alter(IFn fn, ISeq args)
{
LockingTransaction t = LockingTransaction.GetEx();
- return t.DoSet(this, fn.applyTo(RT.cons(t.DoGet(this), args)));
+ return t.DoSet(this, fn.applyTo(RT.cons(t.DoGet(this), args)));
}
///
/// Touch the reference. (Add to the tracking list in the current transaction.)
- ///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "touch")]
+ ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "touch")]
public void touch()
{
LockingTransaction.GetEx().DoEnsure(this);
@@ -500,10 +506,10 @@ public void touch()
#endregion
- #region IFn Members
-
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "fn")]
+ #region IFn Members
+
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "fn")]
public IFn fn()
{
return (IFn)deref();
@@ -669,92 +675,86 @@ public int CompareTo(Ref other)
return _id.CompareTo(other._id);
}
- #endregion
-
- #region object overrides
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(this, obj))
- return true;
-
- Ref r = obj as Ref;
- if (ReferenceEquals(r,null))
- return false;
-
- return _id == r._id;
- }
-
- public override int GetHashCode()
- {
- return _id.GetHashCode();
- }
- #endregion
-
- #region operator overrides
-
- public static bool operator ==(Ref x, Ref y)
- {
- if (ReferenceEquals(x, y))
- return true;
-
- if (ReferenceEquals(x,null))
- return false;
-
- return x.CompareTo(y) == 0;
- }
-
- public static bool operator !=(Ref x, Ref y)
- {
- return !(x == y);
- }
-
- public static bool operator <(Ref x, Ref y)
- {
- if (ReferenceEquals(x, y))
- return false;
-
- if ( ReferenceEquals(x,null) )
- throw new ArgumentException("Cannot compare null","x");
-
- return x.CompareTo(y) < 0;
- }
-
- public static bool operator >(Ref x, Ref y)
- {
- if (ReferenceEquals(x, y))
- return false;
-
- if ( ReferenceEquals(x,null) )
- throw new ArgumentException("Cannot compare null","x");
-
- return x.CompareTo(y) > 0;
- }
-
- #endregion
-
- #region IDisposable
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (!_disposed)
- {
- if (disposing)
- {
- if ( _lock != null )
- _lock.Dispose();
- }
-
- _disposed = true;
- }
- }
-
- #endregion
+ #endregion
+
+ #region object overrides
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(this, obj))
+ return true;
+
+ Ref r = obj as Ref;
+ if (ReferenceEquals(r,null))
+ return false;
+
+ return _id == r._id;
+ }
+
+ public override int GetHashCode()
+ {
+ return _id.GetHashCode();
+ }
+ #endregion
+
+ #region operator overrides
+
+ public static bool operator ==(Ref x, Ref y)
+ {
+ if (ReferenceEquals(x, y))
+ return true;
+
+ if (ReferenceEquals(x,null))
+ return false;
+
+ return x.CompareTo(y) == 0;
+ }
+
+ public static bool operator !=(Ref x, Ref y)
+ {
+ return !(x == y);
+ }
+
+ public static bool operator <(Ref x, Ref y)
+ {
+ if (ReferenceEquals(x, y))
+ return false;
+
+ if ( ReferenceEquals(x,null) )
+ throw new ArgumentException("Cannot compare null","x");
+
+ return x.CompareTo(y) < 0;
+ }
+
+ public static bool operator >(Ref x, Ref y)
+ {
+ if (ReferenceEquals(x, y))
+ return false;
+
+ if ( ReferenceEquals(x,null) )
+ throw new ArgumentException("Cannot compare null","x");
+
+ return x.CompareTo(y) > 0;
+ }
+
+ #endregion
+
+ #region IDisposable
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ _disposed = true;
+ }
+ }
+
+ #endregion
}
}
diff --git a/Clojure/Clojure/Runtime/Reflector.cs b/Clojure/Clojure/Runtime/Reflector.cs
index cfa3d83e4..0b0c70f55 100644
--- a/Clojure/Clojure/Runtime/Reflector.cs
+++ b/Clojure/Clojure/Runtime/Reflector.cs
@@ -177,6 +177,13 @@ public static MethodInfo GetMatchingMethod(IPersistentMap spanMap, Expr target,
method = GetMatchingMethodAux(targetType, args, methods, methodName, false);
hasMethods = methods.Count > 0;
}
+ else
+ {
+ Type targetType = typeof(object);
+ IList methods = GetMethods(targetType, methodName, typeArgs, args.Count, false);
+ method = GetMatchingMethodAux(targetType, args, methods, methodName, false);
+ hasMethods = methods.Count > 0;
+ }
MaybeReflectionWarn(spanMap, (target.HasClrType ? target.ClrType : null), false, hasMethods, method, methodName, args);
return (MethodInfo)method;
@@ -286,7 +293,7 @@ private static MethodBase GetMatchingMethodAux(Type targetType, IList a
foreach (HostArg ha in args)
{
Expr e = ha.ArgExpr;
- Type argType = e.HasClrType ? (e.ClrType ?? typeof(object)) : typeof(Object);
+ Type argType = e.HasClrType ? (e.ClrType ?? typeof(object)) : typeof(object);
Type t;
diff --git a/Clojure/Csharp.Tests/Csharp.Tests.csproj b/Clojure/Csharp.Tests/Csharp.Tests.csproj
index 197fb5592..67c799d24 100644
--- a/Clojure/Csharp.Tests/Csharp.Tests.csproj
+++ b/Clojure/Csharp.Tests/Csharp.Tests.csproj
@@ -12,7 +12,7 @@
Csharp.Tests
512
..\
- true
+ true
true
@@ -153,11 +153,11 @@
-
\ No newline at end of file
diff --git a/Clojure/DlrConsole/DlrConsole.csproj b/Clojure/DlrConsole/DlrConsole.csproj
index fb1610b54..fb6173656 100644
--- a/Clojure/DlrConsole/DlrConsole.csproj
+++ b/Clojure/DlrConsole/DlrConsole.csproj
@@ -15,7 +15,7 @@
512
..\
- true
+ true
true
@@ -98,11 +98,11 @@
-
\ No newline at end of file
diff --git a/Clojure/build.proj b/Clojure/build.proj
index 29cef78b6..b5fbcc328 100644
--- a/Clojure/build.proj
+++ b/Clojure/build.proj
@@ -36,7 +36,7 @@
+ Properties="RestorePackages=$(RestorePackages);Runtime=$(Runtime);PlatformSym=$(PlatformSym);DirectLinking=$(DirectLinking)"/>
diff --git a/unity-build.sh b/unity-build.sh
new file mode 100755
index 000000000..8272c6304
--- /dev/null
+++ b/unity-build.sh
@@ -0,0 +1,2 @@
+rm -fr dist bin
+RestorePackages=false xbuild Clojure/build.proj /target:"Dist" /p:Runtime="Mono" /p:Configuration="Release 3.5" /p:Platform="Any CPU"
diff --git a/unity-install.sh b/unity-install.sh
new file mode 100755
index 000000000..21f150982
--- /dev/null
+++ b/unity-install.sh
@@ -0,0 +1,10 @@
+echo "copy infrastructure"
+cp bin/3.5/Release/{Clojure,Microsoft.{Dynamic,Scripting,Scripting.{Core,Metadata}}}.dll $1/Infrastructure
+
+echo "copy clojure source"
+rm -fr $1/Source/clojure
+cp -r bin/3.5/Release/clojure $1/Source
+rm -fr $1/Source/clojure/*samples*
+rm -fr $1/Source/clojure/*run_test*
+rm -fr $1/Source/clojure/*dm-test*
+rm -fr $1/Source/clojure/*test_*