├── .gitmodules ├── Clojure ├── Clojure │ ├── Resources │ │ └── version.txt │ ├── Bootstrap │ │ └── version.properties │ ├── app.config │ ├── Lib │ │ ├── WarnBoxedMathAttribute.cs │ │ ├── IType.cs │ │ ├── IRecord.cs │ │ ├── ILookupSite.cs │ │ ├── MapEquivalence.cs │ │ ├── IPersistentList.cs │ │ ├── IExceptionInfo.cs │ │ ├── IPending.cs │ │ ├── ILookupThunk.cs │ │ ├── IKeywordLookup.cs │ │ ├── IEditableCollection.cs │ │ ├── IKVReduce.cs │ │ ├── IBlockingDeref.cs │ │ ├── ITransientAssociative.cs │ │ ├── IHashEq.cs │ │ ├── Sequential.cs │ │ ├── IFnArity.cs │ │ ├── Reduced.cs │ │ ├── Fn.cs │ │ ├── IChunk.cs │ │ ├── ITransientCollection.cs │ │ ├── ITransientVector.cs │ │ ├── IDeref.cs │ │ ├── IMeta.cs │ │ ├── Volatile.cs │ │ ├── ITransientAssociative2.cs │ │ ├── IChunkedSeq.cs │ │ ├── IObj.cs │ │ ├── ITransientSet.cs │ │ ├── ClojureException.cs │ │ ├── IReduce.cs │ │ ├── IndexedSeq.cs │ │ ├── Reversible.cs │ │ ├── IFnClosure.cs │ │ ├── IProxy.cs │ │ ├── Seqable.cs │ │ ├── Counted.cs │ │ ├── IReduceInit.cs │ │ ├── Indexed.cs │ │ ├── IDrop.cs │ │ ├── IPersistentStack.cs │ │ ├── Box.cs │ │ ├── Named.cs │ │ ├── IAtom2.cs │ │ ├── IMapEntry.cs │ │ ├── Settable.cs │ │ ├── ILookup.cs │ │ ├── IMapEnumerable.cs │ │ ├── ChunkBuffer.cs │ │ ├── IAtom.cs │ │ ├── IReference.cs │ │ ├── ITransientMap.cs │ │ └── RecordEnumerable.cs │ ├── CljCompiler │ │ └── Ast │ │ │ ├── IParser.cs │ │ │ ├── AssignableExpr.cs │ │ │ ├── MaybePrimitiveExpr.cs │ │ │ ├── ParseException.cs │ │ │ ├── IdentityHashMap.cs │ │ │ ├── Expr.cs │ │ │ ├── FieldExpr.cs │ │ │ ├── LiteralExpr.cs │ │ │ ├── UntypedExpr.cs │ │ │ ├── NilExpr.cs │ │ │ ├── StringExpr.cs │ │ │ ├── ParseEvalExpr.cs │ │ │ ├── MethodParamExpr.cs │ │ │ ├── BooleanExpr.cs │ │ │ ├── KeywordExpr.cs │ │ │ ├── HostArg.cs │ │ │ ├── UnresolvedVarExpr.cs │ │ │ ├── BindingInit.cs │ │ │ ├── MonitorEnterExpr.cs │ │ │ ├── MonitorExitExpr.cs │ │ │ └── MetaExpr.cs │ ├── package.html │ ├── Runtime │ │ ├── Binding │ │ │ ├── IClojureBinder.cs │ │ │ └── BindingHelpers.cs │ │ ├── ClojureOps.cs │ │ └── ClojureOptions.cs │ └── ClojureBasic.ruleset ├── Build │ ├── Key.snk │ └── Tasks.targets ├── clojure-logo-120b.png ├── Clojure.Main │ ├── clojure-icon.ico │ ├── Properties │ │ └── launchSettings.json │ ├── GlobalSuppressions.cs │ ├── Clojure.Main.csproj │ └── Main.cs ├── Clojure.Main461 │ ├── clojure-icon.ico │ ├── Properties │ │ └── launchSettings.json │ ├── GlobalSuppressions.cs │ └── Clojure.Main461.csproj ├── Clojure.Samples │ └── clojure │ │ └── samples │ │ ├── deftype │ │ └── testprotocol.clj │ │ ├── interop │ │ └── C.dll │ │ ├── attributes │ │ ├── C.dll │ │ ├── C.cs │ │ └── testattribute.clj │ │ ├── await-test.clj │ │ ├── counter.clj │ │ ├── proxy │ │ └── testproxy.clj │ │ ├── genclass │ │ ├── testgenclass2.clj │ │ ├── testmvc.clj │ │ ├── testgenclass3.clj │ │ └── C.cs │ │ └── dm-test.clj ├── Clojure.Source │ ├── GlobalSuppressions.cs │ └── clojure │ │ ├── uuid.clj │ │ ├── pprint │ │ └── print_table.clj │ │ └── edn.clj ├── Clojure.Tests │ └── clojure │ │ ├── test_clojure │ │ ├── repl │ │ │ ├── example.clj │ │ │ └── deps.clj │ │ ├── compilation │ │ │ ├── load_ns.clj │ │ │ └── examples.clj │ │ ├── protocols │ │ │ ├── more_examples.clj │ │ │ └── examples.clj │ │ ├── ns_libs_load_later.clj │ │ ├── clojure_xml.clj │ │ ├── refs.clj │ │ ├── clr │ │ │ ├── added.clj │ │ │ └── process.clj │ │ ├── pprint.clj │ │ ├── clojure_zip.clj │ │ ├── volatiles.clj │ │ ├── pprint │ │ │ └── test_helper.clj │ │ ├── parallel.clj │ │ ├── proxy │ │ │ └── examples.clj │ │ ├── run_single_test.clj │ │ ├── edn.clj │ │ ├── data.clj │ │ ├── keywords.clj │ │ ├── api.clj │ │ └── try_catch.clj │ │ ├── run_test_i.clj │ │ └── run_test.clj ├── Clojure.Tests.Support │ ├── GenericsTest.cs │ ├── AnotherAttribute.cs │ ├── AnAttribute.cs │ └── Clojure.Tests.Support.csproj ├── CurrentVersion.props ├── Clojure.Compile │ ├── Properties │ │ └── launchSettings.json │ └── GlobalSuppressions.cs ├── ConsoleApp1 │ ├── ConsoleApp1.csproj │ └── Program.cs ├── Csharp.Tests │ ├── LibTests │ │ ├── ARefTests.cs │ │ ├── AtomTests.cs │ │ ├── AFnImplTests.cs │ │ ├── AgentTests.cs │ │ ├── DelayTests.cs │ │ ├── LazySeqTests.cs │ │ ├── RefTests.cs │ │ ├── RestFnTests.cs │ │ ├── StreamTests.cs │ │ ├── RestFnImplTests.cs │ │ ├── ArrayStreamTests.cs │ │ ├── CachedSeqTests.cs │ │ ├── EnumeratorSeqTests.cs │ │ ├── IteratorStreamTests.cs │ │ ├── DummyFn.cs │ │ ├── PersistentQueueTests.cs │ │ ├── PersistentStructMapTests.cs │ │ ├── PersistentTreeSetTests.cs │ │ ├── TestTest.cs │ │ ├── ObjTests.cs │ │ └── ISeqTestHelper.cs │ ├── FixtureSetupClass.cs │ └── Csharp.Tests.csproj ├── Directory.Packages.props └── pv.bat ├── docs ├── radix.xlsx ├── ml-backup.png ├── managed-libraries.png ├── dependencies │ ├── all-dependencies.png │ ├── fn-dependencies.png │ ├── seq-dependencies.png │ ├── idref-dependencies.png │ ├── meta-dependencies.png │ ├── seq2-dependencies.png │ ├── compiler-dependencies.png │ ├── reduce-dependencies.png │ ├── defthings-dependencies.png │ ├── transient-dependencies.png │ ├── clojure-dependency-graphs.docx │ ├── do-dots.bat │ ├── defthings-dependencies.dot │ ├── reduce-dependencies.dot │ ├── idref-dependencies.dot │ ├── seq2-dependencies.dot │ ├── fn-dependencies.dot │ ├── meta-dependencies.dot │ ├── transient-dependencies.dot │ └── seq-dependencies.dot ├── build.bat ├── run-some-tests.clj └── managed-libraries.dot └── CONTRIBUTING.md /.gitmodules: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Clojure/Clojure/Resources/version.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Clojure/Clojure/Bootstrap/version.properties: -------------------------------------------------------------------------------- 1 | version=1.12.3-alpha4 -------------------------------------------------------------------------------- /docs/radix.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/radix.xlsx -------------------------------------------------------------------------------- /docs/ml-backup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/ml-backup.png -------------------------------------------------------------------------------- /Clojure/Build/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/Clojure/Build/Key.snk -------------------------------------------------------------------------------- /docs/managed-libraries.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/managed-libraries.png -------------------------------------------------------------------------------- /Clojure/clojure-logo-120b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/Clojure/clojure-logo-120b.png -------------------------------------------------------------------------------- /Clojure/Clojure.Main/clojure-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/Clojure/Clojure.Main/clojure-icon.ico -------------------------------------------------------------------------------- /docs/dependencies/all-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/dependencies/all-dependencies.png -------------------------------------------------------------------------------- /docs/dependencies/fn-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/dependencies/fn-dependencies.png -------------------------------------------------------------------------------- /docs/dependencies/seq-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/dependencies/seq-dependencies.png -------------------------------------------------------------------------------- /Clojure/Clojure.Main461/clojure-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/Clojure/Clojure.Main461/clojure-icon.ico -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/deftype/testprotocol.clj: -------------------------------------------------------------------------------- 1 | (ns clojure.testprotocol) 2 | 3 | (defprotocol P1 (m1 [x])) 4 | 5 | -------------------------------------------------------------------------------- /docs/dependencies/idref-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/dependencies/idref-dependencies.png -------------------------------------------------------------------------------- /docs/dependencies/meta-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/dependencies/meta-dependencies.png -------------------------------------------------------------------------------- /docs/dependencies/seq2-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/dependencies/seq2-dependencies.png -------------------------------------------------------------------------------- /docs/dependencies/compiler-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/dependencies/compiler-dependencies.png -------------------------------------------------------------------------------- /docs/dependencies/reduce-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/dependencies/reduce-dependencies.png -------------------------------------------------------------------------------- /Clojure/Clojure.Source/GlobalSuppressions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/Clojure/Clojure.Source/GlobalSuppressions.cs -------------------------------------------------------------------------------- /docs/dependencies/defthings-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/dependencies/defthings-dependencies.png -------------------------------------------------------------------------------- /docs/dependencies/transient-dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/dependencies/transient-dependencies.png -------------------------------------------------------------------------------- /Clojure/Clojure/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /docs/dependencies/clojure-dependency-graphs.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/docs/dependencies/clojure-dependency-graphs.docx -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/interop/C.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/Clojure/Clojure.Samples/clojure/samples/interop/C.dll -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/attributes/C.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clojure/clojure-clr/master/Clojure/Clojure.Samples/clojure/samples/attributes/C.dll -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/repl/example.clj: -------------------------------------------------------------------------------- 1 | (ns clojure.test-clojure.repl.example) 2 | 3 | ;; sample namespace for repl tests, don't add anything here 4 | (defn foo []) 5 | (defn bar []) 6 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/compilation/load_ns.clj: -------------------------------------------------------------------------------- 1 | (ns clojure.test-clojure.compilation.load-ns) 2 | 3 | (defn a [] 1) 4 | (defprotocol p (f [_])) 5 | (deftype x [] 6 | :load-ns true 7 | p (f [_] (a))) -------------------------------------------------------------------------------- /Clojure/Clojure.Main/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Clojure.Main": { 4 | "commandName": "Project", 5 | "environmentVariables": { 6 | "clojure.compiler.direct-linking": "true" 7 | } 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /Clojure/Clojure.Main461/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Clojure.Main461": { 4 | "commandName": "Project", 5 | "environmentVariables": { 6 | "clojure.compiler.direct-linking": "true" 7 | } 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/protocols/more_examples.clj: -------------------------------------------------------------------------------- 1 | (ns clojure.test-clojure.protocols.more-examples) 2 | 3 | (defprotocol SimpleProtocol 4 | "example protocol used by clojure tests. Note that 5 | foo collides with examples/ExampleProtocol." 6 | 7 | (foo [a] "")) 8 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests.Support/GenericsTest.cs: -------------------------------------------------------------------------------- 1 | namespace Clojure.Tests.Support; 2 | 3 | public class GenericsTest 4 | { 5 | // Zero-arg generic instance method 6 | public T InstanceMethod0() { return default; } 7 | 8 | // Zero-arg static method 9 | public static T StaticMethod0() { return default; } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Clojure/CurrentVersion.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 12 6 | 3 7 | alpha4 8 | 9 | -------------------------------------------------------------------------------- /docs/build.bat: -------------------------------------------------------------------------------- 1 | 2 | dotnet build Clojure 3 | dotnet build Clojure.Main 4 | dotnet build Clojure.Tests 5 | dotnet publish Clojure.Main 6 | dotnet publish Clojure.Tests 7 | xcopy Clojure.Main\bin\Debug\netcoreapp2.1\publish testing /E /Y 8 | xcopy Clojure.Tests\bin\Debug\netstandard2.0\publish testing /E /Y 9 | cd testing 10 | dotnet Clojure.Main.dll 11 | 12 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests.Support/AnotherAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Clojure.Tests.Support; 4 | 5 | [AttributeUsage(AttributeTargets.All)] 6 | public class AnotherAttribute : Attribute 7 | { 8 | public long PrimaryValue { get; private set; } 9 | 10 | 11 | public AnotherAttribute(long primaryValue) 12 | { 13 | PrimaryValue = primaryValue; 14 | } 15 | } -------------------------------------------------------------------------------- /Clojure/Clojure.Tests.Support/AnAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Clojure.Tests.Support; 4 | 5 | [AttributeUsage(AttributeTargets.All)] 6 | public class AnAttribute : Attribute 7 | { 8 | public string SecondaryValue { get; set; } 9 | public string PrimaryValue { get; private set; } 10 | 11 | 12 | public AnAttribute(string primaryValue) 13 | { 14 | PrimaryValue = primaryValue; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/await-test.clj: -------------------------------------------------------------------------------- 1 | ; Simple test for await 2 | ; Eventually should put in test framework 3 | 4 | (def counter (ref 0)) 5 | 6 | (defn work [state] 7 | (System.Threading.Thread/Sleep 1000) 8 | (dosync (commute counter inc)) 9 | true) 10 | 11 | (def agents (for [x (range 10)] (agent nil))) 12 | 13 | (defn doit [] 14 | (doall (map #(send % work) agents)) 15 | (apply await agents) 16 | [@counter (doall (map deref agents))]) 17 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests.Support/Clojure.Tests.Support.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0;net8.0;net9.0;net10.0;net462;net481 5 | 14.0 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/WarnBoxedMathAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace clojure.lang 7 | { 8 | [AttributeUsage(AttributeTargets.Method)] 9 | public sealed class WarnBoxedMathAttribute : Attribute 10 | { 11 | public bool Value { get; private set; } 12 | 13 | public WarnBoxedMathAttribute(bool val) 14 | { 15 | Value = val; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | This is a [Clojure contrib] project. 2 | 3 | Under the Clojure contrib [guidelines], this project cannot accept 4 | pull requests. All patches must be submitted via [JIRA]. 5 | 6 | See [Contributing] on the Clojure website for 7 | more information on how to contribute. 8 | 9 | [Clojure contrib]: https://clojure.org/community/contrib_libs 10 | [Contributing]: https://clojure.org/community/contributing 11 | [JIRA]: https://clojure.atlassian.net/browse/TNS 12 | [guidelines]: https://clojure.org/community/contrib_howto -------------------------------------------------------------------------------- /Clojure/Clojure.Compile/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Clojure.Compile": { 4 | "commandName": "Project", 5 | "commandLineArgs": "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.datafy clojure.instant clojure.uuid clojure.math" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Clojure/ConsoleApp1/ConsoleApp1.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net10.0 6 | enable 7 | enable 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/compilation/examples.clj: -------------------------------------------------------------------------------- 1 | ;; Copyright (c) Rich Hickey. All rights reserved. 2 | ;; The use and distribution terms for this software are covered by the 3 | ;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ;; which can be found in the file epl-v10.html at the root of this distribution. 5 | ;; By using this software in any fashion, you are agreeing to be bound by 6 | ;; the terms of this license. 7 | ;; You must not remove this notice, or any other, from this software. 8 | 9 | (ns clojure.test-clojure.compilation.examples) 10 | 11 | (eval '(deftype X [])) 12 | (deftype T []) -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/protocols/examples.clj: -------------------------------------------------------------------------------- 1 | (ns clojure.test-clojure.protocols.examples) 2 | 3 | (defprotocol ExampleProtocol 4 | "example protocol used by clojure tests" 5 | 6 | (foo [a] "method with one arg") 7 | (bar [a b] "method with two args") 8 | (^String baz [a] [a b] "method with multiple arities") 9 | (with-quux [a] "method name with a hyphen")) 10 | 11 | (defprotocol MarkerProtocol 12 | "a protocol with no methods") 13 | 14 | (defprotocol MarkerProtocol2) 15 | 16 | (definterface ExampleInterface 17 | (hinted [^int i]) 18 | (hinted [^String s])) 19 | 20 | (defprotocol LongsHintedProto 21 | (^longs longs-hinted [_])) 22 | -------------------------------------------------------------------------------- /Clojure/ConsoleApp1/Program.cs: -------------------------------------------------------------------------------- 1 | // See https://aka.ms/new-console-template for more information 2 | //using clojure.lang; 3 | //using System.Reflection; 4 | 5 | //Console.WriteLine("Hello, World!"); 6 | 7 | 8 | //Assembly.LoadFrom("clojure.data.priority-map.dll"); 9 | 10 | //IFn require = clojure.clr.api.Clojure.var("clojure.core", "load"); 11 | //require.invoke("clojure.data.priority-map"); 12 | 13 | 14 | clojure.lang.IPersistentMap pv = clojure.lang.PersistentHashMap.EMPTY; 15 | 16 | for (int i = 0; i <= 500; i++) 17 | { 18 | pv = pv.assoc("a"+i, i); 19 | } 20 | 21 | 22 | ((clojure.lang.PersistentHashMap)pv).PrintContents(); 23 | 24 | Console.ReadLine(); 25 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IType.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | namespace clojure.lang 16 | { 17 | public interface IType 18 | { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IRecord.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | namespace clojure.lang 16 | { 17 | public interface IRecord 18 | { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/ns_libs_load_later.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | ;; used by clojure.test-clojure.ns-libs/require-as-alias-then-load-later 10 | (ns clojure.test-clojure.ns-libs-load-later) 11 | 12 | (defn example [] true) -------------------------------------------------------------------------------- /docs/dependencies/do-dots.bat: -------------------------------------------------------------------------------- 1 | dot -Tpng all-dependencies.dot -o all-dependencies.png 2 | dot -Tpng defthings-dependencies.dot -o defthings-dependencies.png 3 | dot -Tpng fn-dependencies.dot -o fn-dependencies.png 4 | dot -Tpng meta-dependencies.dot -o meta-dependencies.png 5 | dot -Tpng reduce-dependencies.dot -o reduce-dependencies.png 6 | dot -Tpng seq-dependencies.dot -o seq-dependencies.png 7 | dot -Tpng seq2-dependencies.dot -o seq2-dependencies.png 8 | dot -Tpng transient-dependencies.dot -o transient-dependencies.png 9 | dot -Tpng compiler-dependencies.dot -o compiler-dependencies.png 10 | dot -Tpng idref-dependencies.dot -o idref-dependencies.png -------------------------------------------------------------------------------- /docs/dependencies/defthings-dependencies.dot: -------------------------------------------------------------------------------- 1 | strict digraph G { 2 | 3 | rankdir = RL; 4 | 5 | subgraph clusterlookup { 6 | 7 | node [shape=box]; 8 | 9 | ILookupSite; 10 | ILookupThunk; 11 | 12 | node [shape=ellipse]; 13 | 14 | KeywordLookupSite -> { ILookupSite, ILookupThunk }; 15 | } 16 | 17 | subgraph clustertypes { 18 | 19 | node [shape=box]; 20 | 21 | IType; 22 | IProxy; 23 | IRecord; 24 | 25 | node [shape=ellipse]; 26 | 27 | "(deftype ...)" -> IType; 28 | "(proxy ...}" -> IProxy; 29 | "(defrecord ... )" -> IRecord; 30 | } 31 | 32 | subgraph clusterprotocol { 33 | 34 | node [shape=ellipse]; 35 | 36 | MethodImplCache; 37 | 38 | "(defprotocol ...)" -> MethodImplCache 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/clojure_xml.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | ;;Author: Frantisek Sodomka 10 | 11 | 12 | #_(ns clojure.test-clojure.clojure-xml 13 | (:use clojure.test) 14 | (:require [clojure.xml :as xml])) 15 | 16 | 17 | ; parse 18 | 19 | ; emit-element 20 | ; emit 21 | 22 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/IParser.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang.CljCompiler.Ast 17 | { 18 | public interface IParser 19 | { 20 | Expr Parse(ParserContext pcon, object form); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/refs.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | ; Author: Frantisek Sodomka 10 | 11 | 12 | (ns clojure.test-clojure.refs 13 | (:use clojure.test)) 14 | 15 | ; http://clojure.org/refs 16 | 17 | ; ref 18 | ; deref, @-reader-macro 19 | ; dosync io! 20 | ; ensure ref-set alter commute 21 | ; set-validator get-validator 22 | 23 | -------------------------------------------------------------------------------- /docs/dependencies/reduce-dependencies.dot: -------------------------------------------------------------------------------- 1 | strict digraph G { 2 | 3 | rankdir = RL; 4 | concentrate=true; 5 | 6 | /* here start the interfaces */ 7 | 8 | node [shape=box]; 9 | 10 | { 11 | 12 | IKVReduce; 13 | IReduce -> { IReduceInit }; 14 | IReduceInit; 15 | 16 | } 17 | 18 | 19 | { 20 | node [shape=ellipse] 21 | 22 | 23 | Cycle -> { IReduce }; 24 | 25 | Iterate -> { IReduce }; 26 | 27 | LongRange -> { IReduce }; 28 | 29 | 30 | PersistentArrayMap -> { IKVReduce }; 31 | PersistentHashMap -> { IKVReduce }; 32 | 33 | PersistentList -> { IReduce }; 34 | 35 | 36 | PersistentTreeMap -> { IKVReduce }; 37 | 38 | PersistentVector -> { IReduce, IKVReduce }; 39 | Range -> { IReduce }; 40 | 41 | Reduced -> { IDeref }; 42 | Repeat -> { IReduce }; 43 | 44 | 45 | } 46 | 47 | 48 | } -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/ILookupSite.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | 12 | namespace clojure.lang 13 | { 14 | public interface ILookupSite 15 | { 16 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 17 | ILookupThunk fault(object target); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Clojure/Clojure/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | Clojure language implementation. 14 | 15 |

The clojure.lang package holds the implementation for Clojure. 16 | The only class considered part of the public API is 17 | {@link clojure.lang.IFn}. All other classes should be considered 18 | implementation details.

19 | 20 | 21 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/ARefTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | // TODO: Add tests for Aref 23 | class ARefTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/AtomTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | // TODO: Add tests for Atom 23 | class AtomTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/AFnImplTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | // TODO: Add AFnImpl tests 23 | class AFnImplTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/AgentTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | // TODO: Add tests for Agent 23 | class AgentTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/DelayTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | class DelayTests 23 | { 24 | //TODO: Write Delay tests 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/LazySeqTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | // TODO: Add LazySeq tests 23 | class LazySeqTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/RefTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | // TODO: Add tests for Ref 23 | 24 | class RefTests 25 | { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/RestFnTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | // TODO: Add RestFn tests 23 | class RestFnTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/StreamTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | // TODO: add tests for Stream 23 | class StreamTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/RestFnImplTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | //TODO: Add RestFnImpl tests 23 | class RestFnImplTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/MapEquivalence.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | // marker interface 19 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 20 | public interface MapEquivalence 21 | { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/ArrayStreamTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | // TODO: Add ArrayStream tests 23 | class ArrayStreamTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/CachedSeqTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | // TODO: write tests for CachedSeq 23 | class CachedSeqTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/EnumeratorSeqTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests 21 | { 22 | // TODO: Add tests for EnumeratorSeq 23 | class EnumeratorSeqTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/IteratorStreamTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | //TODO: add tests for IteratorStream 23 | class IteratorStreamTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IPersistentList.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents an immutable list. (sequential + stack + collection) 20 | /// 21 | public interface IPersistentList: Sequential, IPersistentStack 22 | { 23 | // empty 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/DummyFn.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using clojure.lang; 6 | 7 | namespace Clojure.Tests.LibTests 8 | { 9 | /// 10 | /// Dummy IFn to use in reduce tests 11 | /// 12 | public static class DummyFn 13 | { 14 | public static IFn CreateForReduce() 15 | { 16 | AFnImpl fn = new AFnImpl(); 17 | fn._fn2 = ( object x, object y ) => { return Numbers.addP(x,y); }; 18 | return fn; 19 | } 20 | 21 | internal static IFn CreateForMetaAlter(IPersistentMap meta) 22 | { 23 | AFnImpl fn = new AFnImpl(); 24 | fn._fn0 = () => { return meta; }; 25 | fn._fn1 = (object x) => { return meta; }; 26 | return fn; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/PersistentQueueTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | // TODO: Add tests for PersistentQueue 23 | class PersistentQueueTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IExceptionInfo.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public interface IExceptionInfo 19 | { 20 | 21 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 22 | IPersistentMap getData(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IPending.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | 17 | 18 | namespace clojure.lang 19 | { 20 | public interface IPending 21 | { 22 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 23 | bool isRealized(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/ILookupThunk.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | 19 | public interface ILookupThunk 20 | { 21 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 22 | object get(object target); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/PersistentStructMapTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Clojure.Tests.LibTests 21 | { 22 | // TODO: Add tests for PersistentStructMap 23 | class PersistentStructMapTests 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IKeywordLookup.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public interface IKeywordLookup 19 | { 20 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 21 | ILookupThunk getLookupThunk(Keyword k); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IEditableCollection.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public interface IEditableCollection 19 | { 20 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 21 | ITransientCollection asTransient(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/attributes/C.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace dm 7 | { 8 | // stolen mostly from the MS docs on System.Attribute 9 | 10 | public enum Pet 11 | { 12 | Unknown, 13 | Dog, 14 | Cat, 15 | Bird 16 | } 17 | 18 | public class PetTypeAttribute : Attribute 19 | { 20 | private Pet _pet; 21 | 22 | protected Pet ThePet 23 | { 24 | get { return _pet; } 25 | set { _pet = value; } 26 | } 27 | 28 | public PetTypeAttribute(Pet pet) 29 | { 30 | _pet = pet; 31 | } 32 | 33 | public override string ToString() 34 | { 35 | return String.Format("", _pet.ToString()); 36 | } 37 | 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/run_test_i.clj: -------------------------------------------------------------------------------- 1 | (assembly-load-from "clojure.tools.reader.dll") 2 | (assembly-load-from "clojure.tools.namespace.dll") 3 | (assembly-load-from "clojure.data.generators.dll") 4 | (assembly-load-from "clojure.test.generative.dll") 5 | (assembly-load-from "clojure.test.check.dll") 6 | 7 | ;;;(System/setProperty "java.awt.headless" "true") 8 | (require 9 | '[clojure.test :as test] 10 | '[clojure.tools.namespace.find :as ns]) 11 | (def namespaces (remove (read-string (or (System.Environment/GetEnvironmentVariable "clojure.test-clojure.exclude-namespaces") "#{}")) ;;; System/getProperty Added the or 12 | (ns/find-namespaces-in-dir (System.IO.DirectoryInfo. "clojure/test_clojure")))) ;;; (java.io.File. "test") 13 | (doseq [ns namespaces] (require ns)) 14 | (let [summary (apply test/run-tests namespaces)] 15 | (print summary)) -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IKVReduce.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /* rich 7/20/15 */ 12 | 13 | /** 14 | * Author: David Miller 15 | **/ 16 | 17 | using System; 18 | 19 | namespace clojure.lang 20 | { 21 | public interface IKVReduce 22 | { 23 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 24 | Object kvreduce(IFn f, Object init); 25 | } 26 | } -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IBlockingDeref.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | 17 | namespace clojure.lang 18 | { 19 | public interface IBlockingDeref 20 | { 21 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 22 | object deref(long ms, Object timeoutValue); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/AssignableExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | namespace clojure.lang.CljCompiler.Ast 12 | { 13 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 14 | public interface AssignableExpr 15 | { 16 | object EvalAssign(Expr val); 17 | void EmitAssign(RHC rhc, ObjExpr objx, CljILGen ilg, Expr val); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/MaybePrimitiveExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | namespace clojure.lang.CljCompiler.Ast 12 | { 13 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 14 | public interface MaybePrimitiveExpr : Expr 15 | { 16 | bool CanEmitPrimitive { get; } 17 | void EmitUnboxed(RHC rhc, ObjExpr objx, CljILGen ilg); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/ParseException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Runtime.Serialization; 6 | 7 | namespace clojure.lang.CljCompiler.Ast 8 | { 9 | /// 10 | /// Exception thrown during parsing 11 | /// 12 | [Serializable] 13 | public class ParseException : Exception 14 | { 15 | public ParseException() 16 | { 17 | } 18 | 19 | public ParseException(string message) 20 | : base(message) 21 | { 22 | } 23 | 24 | public ParseException(string message, Exception innerException) 25 | : base(message, innerException) 26 | { 27 | } 28 | 29 | protected ParseException(SerializationInfo info, StreamingContext context) 30 | : base(info, context) 31 | { 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/ITransientAssociative.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public interface ITransientAssociative : ITransientCollection, ILookup 19 | { 20 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 21 | ITransientAssociative assoc(object key, object val); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IHashEq.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace clojure.lang 21 | { 22 | public interface IHashEq 23 | { 24 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 25 | int hasheq(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/Sequential.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Marks the object as being a sequential collection. 20 | /// 21 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 22 | public interface Sequential 23 | { 24 | //empty 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IFnArity.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace clojure.lang 21 | { 22 | /// 23 | /// Interface supporting an IFn reporting what arities is supports 24 | /// 25 | 26 | public interface IFnArity 27 | { 28 | bool HasArity(int arity); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/Reduced.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | 17 | namespace clojure.lang 18 | { 19 | public sealed class Reduced : IDeref 20 | { 21 | readonly Object _val; 22 | 23 | public Reduced(object val) 24 | { 25 | _val = val; 26 | } 27 | 28 | public object deref() 29 | { 30 | return _val; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/clr/added.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | ;; Tests added for ClojureCLR -- miscellaneoue 10 | 11 | (ns clojure.test-clojure.clr.added 12 | (:use clojure.test 13 | [clojure.test.generative :exclude (is)] 14 | clojure.template) 15 | (:require [clojure.data.generators :as gen] 16 | [clojure.test-helper :as helper])) 17 | 18 | (deftest test-bit-not 19 | (are [x y] (= x y) 20 | -1 (bit-not 0) 21 | Int64/MinValue (bit-not 0x7FFFFFFFFFFFFFFF))) -------------------------------------------------------------------------------- /docs/dependencies/idref-dependencies.dot: -------------------------------------------------------------------------------- 1 | strict digraph G { 2 | 3 | rankdir = RL; 4 | concentrate=true; 5 | 6 | /* here start the interfaces */ 7 | 8 | node [shape=box]; 9 | 10 | { 11 | IAtom; 12 | IAtom2 -> { IAtom }; 13 | IBlockingDeref; 14 | IDeref; 15 | IPending; 16 | IRef -> { IDeref }; 17 | IReference; 18 | Settable; 19 | } 20 | 21 | { 22 | node [shape=egg]; 23 | 24 | ARef -> { AReference, IRef }; 25 | AReference -> { IReference }; 26 | } 27 | 28 | { 29 | node [shape=ellipse] 30 | 31 | Agent -> { ARef }; 32 | 33 | Atom -> { ARef, IAtom2 }; 34 | 35 | Cycle -> { IPending }; 36 | Delay -> { IDeref, IPending }; 37 | Future -> { IDeref, IBlockingDeref, IPending }; 38 | Iterate -> { IPending }; 39 | 40 | LazySeq -> { IPending }; 41 | 42 | Namespace -> { AReference }; 43 | 44 | Reduced -> { IDeref }; 45 | Ref -> { ARef }; 46 | 47 | Var -> { ARef, Settable }; 48 | Volatile -> { IDeref }; 49 | } 50 | 51 | 52 | } -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/counter.clj: -------------------------------------------------------------------------------- 1 | (ns clojure.samples.counter) 2 | 3 | (defn tt [x y] (clojure.lang.Util/identical x y)) 4 | 5 | (def s (apply str (repeat 20 "This is a really long string"))) 6 | 7 | (set! *unchecked-math* true) 8 | 9 | (defn count-num-chars ^long [^String s] 10 | (let [l (.Length s) 11 | c \space] 12 | (loop [i 0 acc 0] 13 | (if (< i l) 14 | (recur (inc i) 15 | (if (identical? (.get_Chars s i) c) acc 16 | (inc acc))) 17 | acc)))) 18 | 19 | 20 | (defn cnc [n] 21 | (dotimes [_ n] (count-num-chars s))) 22 | 23 | (defn f [] 24 | (let [sw (System.Diagnostics.Stopwatch.) 25 | nanosec-per-tick (/ 1000000000 System.Diagnostics.Stopwatch/Frequency)] 26 | (.Start sw) 27 | (dotimes [_ 1000] 28 | (count-num-chars s)) 29 | (.Stop sw) 30 | (println "Time (nsec): " (* (.ElapsedTicks sw) nanosec-per-tick)))) 31 | 32 | (defn g [n] 33 | (time (cnc n))) 34 | 35 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/Fn.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Marks an object that can be used in a functional position in a Clojure form. 20 | /// 21 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM compatability")] 22 | public interface Fn 23 | { 24 | // marker interface 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Clojure.Main/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Diagnostics.CodeAnalysis; 17 | 18 | 19 | // TODO: Determine if we want to make Clojure.dll CLSCompliant 20 | 21 | [assembly: CLSCompliant(false)] 22 | 23 | // TODO: Consider implications of strong-signing (has been requested by people who want to install in the GAC) 24 | [assembly: SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")] 25 | -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/proxy/testproxy.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | ; 9 | ; Author: David Miller 10 | 11 | ; Test of proxy code 12 | ; 13 | ; Place this file in the clojure subdirectory of your main directory. 14 | ; Start Clojure and do: 15 | ; (compile 'clojure.testproxy ') 16 | ; 17 | ; You should then be able to play games such as: 18 | ; 19 | 20 | 21 | 22 | (ns clojure.testproxy) 23 | 24 | (defn cp1 [] 25 | (proxy [Object] [])) 26 | 27 | (defn cp2 [] 28 | (proxy [Object] [] 29 | (ToString [] "abc"))) 30 | 31 | -------------------------------------------------------------------------------- /Clojure/Clojure.Compile/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Diagnostics.CodeAnalysis; 17 | 18 | 19 | // TODO: Determine if we want to make Clojure.dll CLSCompliant 20 | 21 | [assembly: CLSCompliant(false)] 22 | 23 | // TODO: Consider implications of strong-signing (has been requested by people who want to install in the GAC) 24 | [assembly: SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")] 25 | -------------------------------------------------------------------------------- /Clojure/Clojure.Main461/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Diagnostics.CodeAnalysis; 17 | 18 | 19 | // TODO: Determine if we want to make Clojure.dll CLSCompliant 20 | 21 | [assembly: CLSCompliant(false)] 22 | 23 | // TODO: Consider implications of strong-signing (has been requested by people who want to install in the GAC) 24 | [assembly: SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")] 25 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/run_test.clj: -------------------------------------------------------------------------------- 1 | (assembly-load-from "clojure.tools.namespace.dll") 2 | (assembly-load-from "clojure.tools.reader.dll") 3 | (assembly-load-from "clojure.data.generators.dll") 4 | (assembly-load-from "clojure.test.generative.dll") 5 | (assembly-load-from "clojure.test.check.dll") 6 | 7 | ;;;(System/setProperty "java.awt.headless" "true") 8 | (require 9 | '[clojure.test :as test] 10 | '[clojure.tools.namespace.find :as ns]) 11 | (def namespaces (remove (read-string (or (System.Environment/GetEnvironmentVariable "clojure.test-clojure.exclude-namespaces") "#{}")) ;;; System/getProperty Added the or 12 | (ns/find-namespaces-in-dir (System.IO.DirectoryInfo. "clojure/test_clojure")))) ;;; (java.io.File. "test")(doseq [ns namespaces] (require ns)) 13 | (doseq [ns namespaces] (require ns)) 14 | (let [summary (apply test/run-tests namespaces)] 15 | (print summary) 16 | (Environment/Exit (if (test/successful? summary) 0 -1))) ;;; System/exit -------------------------------------------------------------------------------- /Clojure/Clojure.Main461/Clojure.Main461.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net462;net481 6 | 14.0 7 | Clojure.CljMain 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | PreserveNewest 25 | PreserveNewest 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Clojure/Clojure/Runtime/Binding/IClojureBinder.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | using System.Reflection.Emit; 9 | /** 10 | * Copyright (c) Rich Hickey. All rights reserved. 11 | * The use and distribution terms for this software are covered by the 12 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 13 | * which can be found in the file epl-v10.html at the root of this distribution. 14 | * By using this software in any fashion, you are agreeing to be bound by 15 | * the terms of this license. 16 | * You must not remove this notice, or any other, from this software. 17 | **//** 18 | * Author: David Miller 19 | **/ 20 | namespace clojure.lang.Runtime.Binding 21 | { 22 | /// 23 | /// Gets the Clojure-specific binding info that the call site binder is associated with. 24 | /// 25 | internal interface IClojureBinder 26 | { 27 | ClojureContext Context { get; } 28 | void GenerateCreationIL(ILGenerator ilg); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/FixtureSetupClass.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | using NUnit.Framework; 21 | using clojure.lang; 22 | 23 | namespace Clojure.Tests.LibTests 24 | { 25 | 26 | public class FixtureSetupClass 27 | { 28 | [OneTimeSetUp] 29 | public void Setup() 30 | { 31 | RuntimeBootstrapFlag._doRTBootstrap = false; 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /docs/run-some-tests.clj: -------------------------------------------------------------------------------- 1 | (assembly-load-from "clojure.tools.namespace.dll") 2 | (assembly-load-from "clojure.data.generators.dll") 3 | (assembly-load-from "clojure.test.generative.dll") 4 | (assembly-load-from "clojure.test.check.dll") 5 | 6 | ;;;(System/setProperty "java.awt.headless" "true") 7 | (require 8 | '[clojure.test :as test] 9 | '[clojure.tools.namespace.find :as ns]) 10 | 11 | (def excludes #{ 12 | 'clojure.test-clojure.genclass.examples 13 | 'clojure.test-clojure.protocols.examples 14 | 'clojure.test-clojure.attributes 15 | 'clojure.test-clojure.compilation.load-ns 16 | 'clojure.test-clojure.compilation.line-number-examples 17 | 18 | 'clojure.test-clojure.compilation 19 | 'clojure.test-clojure.genclass 20 | }) 21 | 22 | (def namespaces (remove excludes 23 | (ns/find-namespaces-in-dir (System.IO.DirectoryInfo. "clojure/test_clojure")))) 24 | 25 | (doseq [ns namespaces] (print "Loading " (str ns) " ... ") (require ns) (println "done.")) 26 | 27 | (doseq [ns namespaces] (test/run-tests ns)) 28 | -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/genclass/testgenclass2.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | ; 9 | ; 10 | ; Author: David Miller 11 | ; 12 | ; A simple test of the gen-class facility taking defaults for all. 13 | ; 14 | ; 15 | ; Place this file in the clojure subdirectory of your main directory. 16 | ; (compile 'clojure.testgenclass2) 17 | ; 18 | ; You should then find clojure.testgenclass2.exe in your compile path. 19 | ; Executing it should print "Hello, world". 20 | 21 | 22 | (ns clojure.testgenclass2 23 | (:gen-class)) 24 | 25 | 26 | (defn -main [] 27 | (println "Hello, world")) -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IChunk.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public interface IChunk : Indexed 19 | { 20 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 21 | IChunk dropFirst(); 22 | 23 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 24 | object reduce(IFn f, object start); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/IdentityHashMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.Serialization; 4 | 5 | namespace clojure.lang.CljCompiler.Ast 6 | { 7 | [Serializable] 8 | public sealed class IdentityHashMap : Dictionary 9 | { 10 | class RefCmp : IEqualityComparer 11 | { 12 | #region IEqualityComparer Members 13 | 14 | public new bool Equals(Object x, Object y) 15 | { 16 | return Object.ReferenceEquals(x, y); 17 | } 18 | 19 | public int GetHashCode(object obj) 20 | { 21 | return obj.GetHashCode(); 22 | } 23 | 24 | #endregion 25 | } 26 | 27 | public IdentityHashMap() 28 | : base(new RefCmp()) 29 | { 30 | } 31 | 32 | private IdentityHashMap(SerializationInfo info, StreamingContext context) 33 | : base(info, context) 34 | { 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/pprint.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | ;; Author: Tom Faulhaber 10 | 11 | (ns clojure.test-clojure.pprint 12 | (:refer-clojure :exclude [format]) 13 | (:require [clojure.string :as str]) 14 | (:use [clojure.test :only (deftest is are run-tests)] 15 | [clojure.test-helper :only [platform-newlines]] 16 | [clojure.string :only [split]] ;;RJ: Added to include clojure.string/split to replace .Split 17 | clojure.test-clojure.pprint.test-helper 18 | clojure.pprint)) 19 | 20 | (load "pprint/test_cl_format") 21 | (load "pprint/test_pretty") 22 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/Expr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | 17 | namespace clojure.lang.CljCompiler.Ast 18 | { 19 | 20 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 21 | public interface Expr 22 | { 23 | bool HasClrType { get; } 24 | Type ClrType { get; } 25 | 26 | object Eval(); 27 | void Emit(RHC rhc, ObjExpr objx, CljILGen ilg); 28 | 29 | bool HasNormalExit(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/FieldExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | using System; 12 | 13 | namespace clojure.lang.CljCompiler.Ast 14 | { 15 | public abstract class FieldOrPropertyExpr : HostExpr, AssignableExpr 16 | { 17 | #region AssignableExpr Members 18 | 19 | public abstract object EvalAssign(Expr val); 20 | public abstract void EmitAssign(RHC rhc, ObjExpr objx, CljILGen ilg, Expr val); 21 | 22 | #endregion 23 | 24 | #region Other 25 | 26 | protected abstract Type FieldType { get; } 27 | 28 | #endregion 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Clojure/Clojure/Runtime/ClojureOps.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | using Microsoft.Scripting; 20 | 21 | namespace clojure.lang.Runtime 22 | { 23 | /// 24 | /// Contains functions that are called directly from 25 | /// generated code to perform low-level runtime functionality. 26 | /// 27 | public static class ClojureOps 28 | { 29 | // TODO: Scour gen code to find things to move here. 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/ITransientCollection.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public interface ITransientCollection 19 | { 20 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 21 | ITransientCollection conj(object val); 22 | 23 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 24 | IPersistentCollection persistent(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/ITransientVector.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public interface ITransientVector : ITransientAssociative, Indexed 19 | { 20 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 21 | ITransientVector assocN(int i, object val); 22 | 23 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 24 | ITransientVector pop(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IDeref.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents something that can dereference. 20 | /// 21 | public interface IDeref 22 | { 23 | /// 24 | /// Gets the (immutable) value the reference is holding. 25 | /// 26 | /// The value 27 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 28 | object deref(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/clojure_zip.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | ; Author: Frantisek Sodomka 10 | 11 | 12 | (ns clojure.test-clojure.clojure-zip 13 | (:use clojure.test) 14 | (:require [clojure.zip :as zip])) 15 | 16 | 17 | ; zipper 18 | ; 19 | ; seq-zip 20 | ; vector-zip 21 | ; xml-zip 22 | ; 23 | ; node 24 | ; branch? 25 | ; children 26 | ; make-node 27 | ; path 28 | ; lefts 29 | ; rights 30 | ; down 31 | ; up 32 | ; root 33 | ; right 34 | ; rightmost 35 | ; left 36 | ; leftmost 37 | ; 38 | ; insert-left 39 | ; insert-right 40 | ; replace 41 | ; edit 42 | ; insert-child 43 | ; append-child 44 | ; next 45 | ; prev 46 | ; end? 47 | ; remove 48 | 49 | -------------------------------------------------------------------------------- /docs/managed-libraries.dot: -------------------------------------------------------------------------------- 1 | strict digraph G { 2 | 3 | rankdir = RL; 4 | 5 | { 6 | node [shape=box]; 7 | 8 | "clr.test.check"; 9 | "clr.spec.alpha" -> {"clr.test.check"}; 10 | "clr.core.specs.alpha" -> {"clr.spec.alpha"}; 11 | 12 | 13 | "clr.core.async" -> {"tools.analyzer.clr"}; 14 | 15 | "clr.data.priority-map"; 16 | "clr.core.cache" -> {"clr.data.priority-map"}; 17 | "clr.core.memoize" -> {"clr.core.cache"} 18 | 19 | "tools.cli*" 20 | "clr.tools.gitlibs"; 21 | "clr.tools.deps" -> {"clr.tools.gitlibs", "tools.cli*"}; 22 | "clr.tools.deps.cli" -> {"clr.tools.deps"} 23 | 24 | "clr.tools.reader"; 25 | "clr.tools.namespace" -> {"clr.tools.reader"}; 26 | 27 | "clr.data.generators"; 28 | 29 | "clr.test.generative" -> {"clr.tools.namespace", "clr.data.generators"}; 30 | "tools.analyzer.clr" -> {"tools.analyzer*", "clr.core.memoize", "clr.tools.reader"}; 31 | 32 | "clr.cli"; 33 | 34 | "cognitect-labs/test-runner*" -> {"clr.tools.namespace", "tools.cli*"}; 35 | 36 | "tools.analyzer*"; 37 | "clr.tools.analyzer"; 38 | 39 | "clr.data.json"; 40 | "clr.core.logic"; 41 | "clr.tools.nrepl"; 42 | "clr.tools.nuget?"; 43 | 44 | } 45 | } -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/volatiles.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | ;;Author: Alex Miller 10 | 11 | (ns clojure.test-clojure.volatiles 12 | (:use clojure.test)) 13 | 14 | (deftest volatile-basics 15 | (let [vol (volatile! "abc")] 16 | (is (volatile? vol)) 17 | (is (= "abc" @vol)) 18 | (is (= "def" (vreset! vol "def"))) 19 | (is (= "def" @vol)))) 20 | 21 | (deftest volatile-vswap! 22 | (let [vol (volatile! 10)] 23 | (is (= 11 (vswap! vol inc))) 24 | (is (= 11 @vol))) 25 | (let [vol (volatile! 10)] 26 | (is (= 20 (vswap! vol + 10))) 27 | (is (= 20 @vol))) 28 | (let [vol (volatile! 10)] 29 | (is (= 25 (vswap! vol + 10 5))) 30 | (is (= 25 @vol)))) 31 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/LiteralExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | using System; 12 | 13 | namespace clojure.lang.CljCompiler.Ast 14 | { 15 | public abstract class LiteralExpr : Expr 16 | { 17 | public abstract object Val { get; } 18 | 19 | #region Expr Members 20 | 21 | public object Eval() 22 | { 23 | return Val; 24 | } 25 | 26 | public abstract bool HasClrType { get; } 27 | public abstract Type ClrType { get; } 28 | public abstract void Emit(RHC rhc, ObjExpr objx, CljILGen ilg); 29 | 30 | public bool HasNormalExit() { return true; } 31 | 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Clojure/Clojure.Source/clojure/uuid.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns clojure.uuid) 10 | 11 | (defn- default-uuid-reader [form] 12 | (if (string? form) 13 | (System.Guid. ^String form) ;;; (java.util.UUID/fromString form) 14 | (throw (ArgumentException. "#uuid data reader expected string")))) ;;; IllegalArgumentException. 15 | 16 | (defmethod print-method System.Guid [uuid ^System.IO.TextWriter w] ;;; java.util.UUID ^java.io.Writer 17 | (.Write w (str "#uuid \"" (str uuid) "\""))) ;;; .write 18 | 19 | (defmethod print-dup System.Guid [o w] ;;; java.util.UUID 20 | (print-method o w)) -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IMeta.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents an object that can have metadata attached. 20 | /// 21 | public interface IMeta 22 | { 23 | /// 24 | /// Gets the metadata attached to the object. 25 | /// 26 | /// An immutable map representing the object's metadata. 27 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 28 | IPersistentMap meta(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/Csharp.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0;net9.0;net10.0 5 | 14.0 6 | false 7 | true 8 | true 9 | CS8002 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | all 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Clojure/Clojure/ClojureBasic.ruleset: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/Volatile.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public sealed class Volatile : IDeref 19 | { 20 | volatile object _val; 21 | 22 | public Volatile(object val) 23 | { 24 | _val = val; 25 | } 26 | 27 | public object deref() 28 | { 29 | return _val; 30 | } 31 | 32 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 33 | public object reset(object newval) 34 | { 35 | return _val = newval; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/ITransientAssociative2.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace clojure.lang 21 | { 22 | public interface ITransientAssociative2 : ITransientAssociative 23 | { 24 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 25 | bool containsKey(Object key); 26 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 27 | IMapEntry entryAt(Object key); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/repl/deps.clj: -------------------------------------------------------------------------------- 1 | (ns clojure.test-clojure.repl.deps 2 | (:use clojure.test) 3 | (:require [clojure.string :as str] 4 | [clojure.repl.deps :as deps] 5 | [clojure.main :as main])) 6 | 7 | #_(defmacro with-dynamic-loader 8 | "Ensure or install a DynamicClassLoader as the current thread's 9 | context classloader and execute the body." 10 | [& body] 11 | `(let [t# (Thread/currentThread) 12 | cl# (.getContextClassLoader t#)] 13 | (if (instance? ~'clojure.lang.DynamicClassLoader cl#) 14 | (do ~@body) 15 | (try 16 | (.setContextClassLoader t# (clojure.lang.DynamicClassLoader. cl#)) 17 | ~@body 18 | (finally 19 | (.setContextClassLoader t# cl#)))))) 20 | 21 | ;(deftest test-no-add-libs-outside-repl 22 | ; (try 23 | ; (deps/add-lib 'org.clojure/data.json {:mvn/version "2.4.0"}) 24 | ; (is false "add-libs outside repl should throw") 25 | ; (catch Throwable t (str/includes? (ex-message t) "add-libs"))) 26 | ; 27 | ; (with-dynamic-loader 28 | ; (binding [*repl* true] 29 | ; (is (some #{'org.clojure/data.json} (deps/add-lib 'org.clojure/data.json {:mvn/version "2.4.0"}))))) 30 | ; ) -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/UntypedExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | 17 | 18 | namespace clojure.lang.CljCompiler.Ast 19 | { 20 | public abstract class UntypedExpr : Expr 21 | { 22 | #region Expr Members 23 | 24 | public bool HasClrType { get { return false; } } 25 | 26 | public Type ClrType 27 | { 28 | get { throw new InvalidOperationException("Has no CLR type"); } 29 | } 30 | 31 | public virtual bool HasNormalExit() { return true; } 32 | 33 | public abstract object Eval(); 34 | public abstract void Emit(RHC rhc, ObjExpr objx, CljILGen ilg); 35 | 36 | #endregion 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IChunkedSeq.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public interface IChunkedSeq : ISeq, Sequential 19 | { 20 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 21 | IChunk chunkedFirst(); 22 | 23 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 24 | ISeq chunkedNext(); 25 | 26 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 27 | ISeq chunkedMore(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IObj.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents an object that creates a copy with new metadata. 20 | /// 21 | public interface IObj : IMeta 22 | { 23 | /// 24 | /// Create a copy with new metadata. 25 | /// 26 | /// The new metadata. 27 | /// A copy of the object with new metadata attached. 28 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 29 | IObj withMeta(IPersistentMap meta); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/ITransientSet.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public interface ITransientSet : ITransientCollection, Counted 19 | { 20 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 21 | ITransientSet disjoin(object key); 22 | 23 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 24 | bool contains(object key); 25 | 26 | 27 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 28 | object get(object key); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/genclass/testmvc.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | ; 9 | ; Author: David Miller 10 | 11 | ; Test of gen-class facility. 12 | ; 13 | ; Place this file in the clojure subdirectory of your main directory. 14 | ; (compile 'clojure.testmvc) 15 | ; 16 | ; You should then be able to play games such as: 17 | 18 | ; (def v (clojure.testmvc/fy) 19 | ; (.index v) 20 | 21 | 22 | (System.Reflection.Assembly/Load "System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL") 23 | 24 | (ns clojure.testmvc 25 | (:gen-class 26 | :factory fy 27 | :extends System.Web.Mvc.Controller 28 | :methods [ 29 | [index [] System.Web.Mvc.ActionResult] 30 | ])) 31 | 32 | (defn -index [] 33 | (.Content "Hello World, from Clojure Controller")) 34 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/ClojureException.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Runtime.Serialization; 17 | 18 | namespace clojure.lang 19 | { 20 | [Serializable] 21 | public class ClojureException : Exception 22 | { 23 | public ClojureException() 24 | { 25 | } 26 | 27 | public ClojureException(string msg) 28 | : base(msg) 29 | { 30 | } 31 | 32 | public ClojureException(string msg, Exception innerException) 33 | : base(msg, innerException) 34 | { 35 | } 36 | 37 | protected ClojureException(SerializationInfo info, StreamingContext context) 38 | : base(info, context) 39 | { 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IReduce.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents a collection that supports function mapping/reduction. 20 | /// 21 | public interface IReduce : IReduceInit 22 | { 23 | /// 24 | /// Reduce the collection using a function. 25 | /// 26 | /// The function to apply. 27 | /// The reduced value 28 | /// Computes f(...f(f(f(i0,i1),i2),i3),...). 29 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 30 | object reduce(IFn f); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Clojure/Build/Tasks.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | RoslynCodeTaskFactory 9 | 10 | 11 | 12 | 13 | CodeTaskFactory 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IndexedSeq.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Indicates a sequence that has a current index. 20 | /// 21 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM compatability")] 22 | public interface IndexedSeq : ISeq, Sequential, Counted 23 | { 24 | /// 25 | /// Gets the index associated with this sequence. 26 | /// 27 | /// The index associated with this sequence. 28 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 29 | int index(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/Reversible.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents a sequence that can be traversed in reverse. 20 | /// 21 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 22 | public interface Reversible 23 | { 24 | /// 25 | /// Gets an ISeq to travers the sequence in reverse. 26 | /// 27 | /// An ISeq . 28 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 29 | ISeq rseq(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IFnClosure.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | 17 | namespace clojure.lang 18 | { 19 | // This is essentially identical to DLR's System.Runtime.CompilerServices.Closure. 20 | // Because it does the exact same thing. 21 | 22 | [Serializable] 23 | public sealed class Closure 24 | { 25 | public readonly object[] Constants; 26 | 27 | public readonly object[] Locals; 28 | 29 | public Closure(object[] constants, object[] locals) 30 | { 31 | Constants = constants; 32 | Locals = locals; 33 | } 34 | } 35 | 36 | 37 | 38 | 39 | public interface IFnClosure 40 | { 41 | Closure GetClosure(); 42 | void SetClosure(Closure closure); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IProxy.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public interface IProxy 19 | { 20 | 21 | 22 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 23 | void __initClojureFnMappings(IPersistentMap m); 24 | 25 | 26 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 27 | void __updateClojureFnMappings(IPersistentMap m); 28 | 29 | 30 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 31 | IPersistentMap __getClojureFnMappings(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/NilExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | using System; 12 | using System.Reflection.Emit; 13 | 14 | namespace clojure.lang.CljCompiler.Ast 15 | { 16 | public class NilExpr : LiteralExpr 17 | { 18 | #region Data 19 | 20 | public override object Val => null; 21 | 22 | #endregion 23 | 24 | #region Type mangling 25 | 26 | public override bool HasClrType => true; 27 | 28 | public override Type ClrType => null; 29 | 30 | #endregion 31 | 32 | #region Code generation 33 | 34 | public override void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) 35 | { 36 | ilg.Emit(OpCodes.Ldnull); 37 | if (rhc == RHC.Statement) 38 | ilg.Emit(OpCodes.Pop); 39 | } 40 | 41 | #endregion 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/Seqable.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents an object that can produce an . 20 | /// 21 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 22 | public interface Seqable 23 | { 24 | /// 25 | /// Gets an to allow first/rest/next iteration through the collection. 26 | /// 27 | /// An for iteration. 28 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 29 | ISeq seq(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /docs/dependencies/seq2-dependencies.dot: -------------------------------------------------------------------------------- 1 | strict digraph G { 2 | 3 | rankdir = RL; 4 | concentrate=true; 5 | 6 | /* here start the interfaces */ 7 | 8 | 9 | { 10 | node [shape=box]; 11 | 12 | ILookup; 13 | Associative -> { ILookup }; 14 | Counted; 15 | IArraySeq -> { IndexedSeq }; 16 | IChunk -> { Indexed }; 17 | IPersistentMap -> { Associative, Counted }; 18 | IPersistentSet -> { Counted }; 19 | IPersistentVector -> { Associative, IPersistentStack, Reversible, Indexed }; 20 | Indexed -> { Counted }; 21 | IndexedSeq -> { Counted }; 22 | Reversible; 23 | Sorted; 24 | APersistentMap -> { IPersistentMap }; 25 | 26 | } 27 | 28 | 29 | 30 | { 31 | node [shape=ellipse] 32 | 33 | ArrayChunk -> { IChunk }; 34 | ChunkBuffer -> { Counted }; 35 | ChunkedCons -> { IChunkedSeq }; 36 | LongRange -> { Counted, IChunkedSeq }; 37 | PersistentList -> { Counted }; 38 | PersistentQueue -> { Counted }; 39 | PersistentTreeMap -> { Reversible, Sorted }; 40 | PersistentTreeSet -> { Reversible, Sorted }; 41 | Range -> { IChunkedSeq }; 42 | StringSeq -> { IndexedSeq }; 43 | PersistentArrayMap -> { APersistentMap }; 44 | PersistentHashMap -> { APersistentMap}; 45 | PersistentStructMap -> { APersistentMap }; 46 | PersistentTreeMap -> { APersistentMap, Reversible, Sorted }; 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/Counted.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// A promise that the class is a collection that implements a constant-time count(). 20 | /// 21 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 22 | public interface Counted 23 | { 24 | /// 25 | /// Gets the number of items in the collection. 26 | /// 27 | /// The number of items in the collection. 28 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 29 | int count(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Clojure/Clojure/Runtime/Binding/BindingHelpers.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System.Linq.Expressions; 16 | using System.Reflection; 17 | 18 | namespace clojure.lang.Runtime.Binding 19 | { 20 | static class BindingHelpers 21 | { 22 | // TODO: I think I can get rid of this now 23 | static readonly PropertyInfo Property_ClojureContext_Default = typeof(ClojureContext).GetProperty("Default"); 24 | static readonly Expression _contextExpr = Expression.Property(null,Property_ClojureContext_Default); 25 | 26 | public static readonly MethodInfo Method_ClojureContext_GetDefault = typeof(ClojureContext).GetMethod("get_Default"); 27 | 28 | internal static Expression CreateBinderStateExpression() 29 | { 30 | return _contextExpr; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/pprint/test_helper.clj: -------------------------------------------------------------------------------- 1 | ;;; test_helper.clj -- part of the pretty printer for Clojure 2 | 3 | ; Copyright (c) Rich Hickey. All rights reserved. 4 | ; The use and distribution terms for this software are covered by the 5 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 6 | ; which can be found in the file epl-v10.html at the root of this distribution. 7 | ; By using this software in any fashion, you are agreeing to be bound by 8 | ; the terms of this license. 9 | ; You must not remove this notice, or any other, from this software. 10 | 11 | ;; Author: Tom Faulhaber 12 | ;; April 3, 2009 13 | 14 | 15 | ;; This is just a macro to make my tests a little cleaner 16 | 17 | (ns clojure.test-clojure.pprint.test-helper 18 | (:use [clojure.test :only (deftest is)] 19 | [clojure.test-helper :only [platform-newlines]])) 20 | 21 | (defn- back-match [x y] (re-matches y x)) 22 | 23 | (defmacro simple-tests [name & test-pairs] 24 | `(deftest ~name 25 | ~@(for [[x y] (partition 2 test-pairs)] 26 | (cond 27 | (instance? System.Text.RegularExpressions.Regex y) ;;; java.util.regex.Pattern 28 | `(is (#'clojure.test-clojure.pprint.test-helper/back-match ~x ~y)) 29 | (instance? String y) `(is (= ~x (platform-newlines ~y))) 30 | :else `(is (= ~x ~y)))))) 31 | 32 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IReduceInit.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents a collection that supports function mapping/reduction. 20 | /// 21 | public interface IReduceInit 22 | { 23 | /// 24 | /// Reduce the collection using a function. 25 | /// 26 | /// The function to apply. 27 | /// An initial value to get started. 28 | /// The reduced value 29 | /// Computes f(...f(f(f(start,i0),i1),i2),...). 30 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 31 | object reduce(IFn f, object start); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/parallel.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | ; Author: Frantisek Sodomka 10 | 11 | 12 | (ns clojure.test-clojure.parallel 13 | (:use clojure.test)) 14 | 15 | ;; !! Tests for the parallel library will be in a separate file clojure_parallel.clj !! 16 | 17 | ; future-call 18 | ; future 19 | ; pmap 20 | ; pcalls 21 | ; pvalues 22 | 23 | ;;; no pmap yet. 24 | ;; pmap 25 | ;; 26 | (deftest pmap-does-its-thing 27 | ;; regression fixed in r1218; was OutOfMemoryError 28 | (is (= '(1) (pmap inc [0])))) 29 | 30 | (def ^:dynamic *test-value* 1) 31 | 32 | (deftest future-fn-properly-retains-conveyed-bindings 33 | (let [a (atom [])] 34 | (binding [*test-value* 2] 35 | @(future (dotimes [_ 3] 36 | ;; we need some binding to trigger binding pop 37 | (binding [*print-dup* false] 38 | (swap! a conj *test-value*)))) 39 | (is (= [2 2 2] @a))))) -------------------------------------------------------------------------------- /docs/dependencies/fn-dependencies.dot: -------------------------------------------------------------------------------- 1 | strict digraph G { 2 | 3 | rankdir = RL; 4 | 5 | /* here start the interfaces */ 6 | 7 | node [shape=box]; 8 | 9 | subgraph clusterinterface { 10 | 11 | node [shape=ellipse]; 12 | 13 | Fn; 14 | IFn; 15 | IFnArity; 16 | IFnClosure; 17 | AFn -> { IFn, IFnArity }; 18 | AFunction -> { AFn, Fn }; 19 | RestFn -> { AFunction }; 20 | } 21 | 22 | 23 | subgraph clusterabstract 24 | { 25 | node [shape=egg]; 26 | 27 | APersistentMap -> { AFn }; 28 | APersistentSet -> { AFn }; 29 | APersistentVector -> { AFn }; 30 | ATransientMap -> { AFn }; 31 | ATransientSet -> { AFn }; 32 | 33 | } 34 | 35 | subgraph clusterclass { 36 | 37 | node [shape=ellipse] 38 | 39 | AFnImpl -> { AFunction, IFnClosure }; 40 | Keyword -> { AFn}; 41 | MultiFn -> { AFn }; 42 | Symbol -> { AFn }; 43 | Var -> { IFn }; 44 | PersistentArrayMap -> { APersistentMap }; 45 | PersistentHashMap -> { APersistentMap }; 46 | PersistentHashSet -> { APersistentSet}; 47 | PersistentStructMap -> { APersistentMap}; 48 | PersistentTreeMap -> { APersistentMap }; 49 | PersistentTreeSet -> { APersistentSet}; 50 | PersistentVector -> { APersistentVector }; 51 | "PersistentArrayMap.TransientArrayMap" -> ATransientMap; 52 | "PersistentHashMap.TransientArrayMap" -> ATransientMap; 53 | "PersistentHashSet.TransientArraySet" -> ATransientSet; 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /Clojure/Directory.Packages.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/Indexed.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM compatability")] 19 | public interface Indexed : Counted 20 | { 21 | /// 22 | /// Returns the n-th item. 23 | /// 24 | /// Index of the item to access 25 | /// The item at the given index 26 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 27 | object nth(int i); 28 | 29 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 30 | object nth(int i, object notFound); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/proxy/examples.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns ^{:doc "Test proxy classes that are AOT-compiled for the tests in 10 | clojure.test-clojure.java-interop." 11 | :author "Ambrose Bonnaire-Sergeant"} 12 | clojure.test-clojure.proxy.examples) 13 | 14 | (definterface A 15 | (^int a [^String x]) 16 | (^boolean a [^System.IO.File x]) ;;; java.io.File 17 | (^boolean a [^System.Threading.Thread x]) ;;; Runnable 18 | (a [^Boolean x]) 19 | (^int a [^Boolean x ^String y]) 20 | (^int a [^String x ^String y]) 21 | (^boolean a [^String x ^System.IO.File y]) ;;; java.io.File 22 | (^boolean a [^String x ^System.Threading.Thread y]) ;;; Runnable 23 | (b [^String x]) 24 | (c [^String x]) 25 | (d [^String x])) 26 | 27 | (def ^String proxy1-class-name 28 | (-> (proxy [A] []) 29 | class 30 | .FullName)) ;;; .getName -------------------------------------------------------------------------------- /Clojure/Clojure.Main/Clojure.Main.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0;net8.0;net9.0;net10.0 6 | 14.0 7 | Clojure.CljMain 8 | true 9 | true 10 | true 11 | 12 | 13 | 14 | ClojureCLR-REPL 15 | Standard REPL for ClojureCLR. 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | true 33 | tools\$(TargetFramework)\any\ 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docs/dependencies/meta-dependencies.dot: -------------------------------------------------------------------------------- 1 | strict digraph G { 2 | 3 | rankdir = RL; 4 | concentrate=true; 5 | 6 | /* here start the interfaces */ 7 | 8 | 9 | 10 | { 11 | node [shape=box]; 12 | 13 | IReference -> { IMeta }; 14 | IMeta; 15 | IObj -> { IMeta }; 16 | IArraySeq -> { IObj }; 17 | Named; 18 | } 19 | 20 | { 21 | node [shape=egg]; 22 | 23 | AFunction -> { IObj }; 24 | ARef -> { AReference }; 25 | AReference -> { IReference }; 26 | Obj -> { IObj }; 27 | RestFn -> { AFunction }; 28 | AFnImpl -> { AFunction }; 29 | ASeq -> { Obj };} 30 | 31 | { 32 | node [shape=ellipse] 33 | 34 | Agent -> { ARef }; 35 | Atom -> { ARef}; 36 | ChunkedCons -> { ASeq }; 37 | Cons -> { ASeq }; 38 | Cycle -> { ASeq }; 39 | EnumeratorSeq -> { ASeq }; 40 | Iterate -> { ASeq }; 41 | Keyword -> { Named }; 42 | LazySeq -> { Obj }; 43 | LongRange -> { ASeq }; 44 | Namespace -> { AReference }; 45 | PersistentArrayMap -> { IObj }; 46 | PersistentHashMap -> { IObj }; 47 | PersistentHashSet -> { IObj }; 48 | PersistentList -> { ASeq }; 49 | PersistentQueue -> { Obj }; 50 | PersistentStructMap -> { IObj }; 51 | PersistentTreeMap -> { IObj }; 52 | PersistentTreeSet -> { IObj }; 53 | PersistentVector -> { IObj }; 54 | Range -> { ASeq }; 55 | Ref -> { ARef }; 56 | Repeat -> { ASeq }; 57 | StringSeq -> { ASeq}; 58 | Symbol -> { IObj, Named }; 59 | Var -> { ARef }; 60 | } 61 | 62 | 63 | } -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/StringExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | using System; 12 | 13 | namespace clojure.lang.CljCompiler.Ast 14 | { 15 | public class StringExpr : LiteralExpr 16 | { 17 | #region Data 18 | 19 | readonly string _str; 20 | public override object Val => _str; 21 | 22 | #endregion 23 | 24 | #region Ctors 25 | 26 | public StringExpr(string str) 27 | { 28 | _str = str; 29 | } 30 | 31 | #endregion 32 | 33 | #region Type mangling 34 | 35 | public override bool HasClrType => true; 36 | 37 | public override Type ClrType => typeof(string); 38 | 39 | #endregion 40 | 41 | #region Code generation 42 | 43 | public override void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) 44 | { 45 | if (rhc != RHC.Statement) 46 | ilg.EmitString(_str); 47 | } 48 | 49 | #endregion 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/PersistentTreeSetTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | using NUnit.Framework; 21 | 22 | using clojure.lang; 23 | 24 | 25 | namespace Clojure.Tests.LibTests 26 | { 27 | // TODO: Add tests for PersistentTreeSet 28 | class PersistentTreeSetTests 29 | { 30 | } 31 | 32 | [TestFixture] 33 | public class PersistentTreeSet_IObj_Tests : IObjTests 34 | { 35 | 36 | [SetUp] 37 | public void Setup() 38 | { 39 | IPersistentMap meta = new DummyMeta(); 40 | 41 | PersistentTreeSet m = PersistentTreeSet.create(RT.seq(PersistentVector.create("a", "b"))); 42 | 43 | _objWithNullMeta = (IObj)m; 44 | _obj = _objWithNullMeta.withMeta(meta); 45 | _expectedType = typeof(PersistentTreeSet); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/run_single_test.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns clojure.test-clojure.run-single-test 10 | (:require [clojure.test :refer [is deftest run-test run-tests]] 11 | [clojure.test-helper :refer [with-err-string-writer]] 12 | [clojure.test-clojure.test-fixtures :as tf])) 13 | 14 | (defn not-a-test 15 | []) 16 | 17 | (defmacro should-print-to-err 18 | [re & body] 19 | `(is (re-find ~re (with-err-string-writer ~@body)))) 20 | 21 | (deftest reports-missing-var 22 | (should-print-to-err #"^Unable to resolve .*/function-missing to a test function.*" 23 | (let [result (eval `(run-test function-missing))] 24 | (is (nil? result))))) 25 | 26 | (deftest reports-non-test-var 27 | (should-print-to-err #"^.*/not-a-test is not a test.*" 28 | (let [result (eval `(run-test not-a-test))] 29 | (is (nil? result))))) 30 | 31 | (deftest can-run-test-with-fixtures 32 | (is (= {:test 1, :pass 2, :fail 0, :error 0, :type :summary} 33 | (run-test tf/can-use-once-fixtures)))) -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IDrop.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | using System; 12 | using System.Collections.Generic; 13 | using System.Text; 14 | 15 | namespace clojure.lang 16 | { 17 | /** 18 | * Persistent or algorithmically defined collections can implement IDrop to provide 19 | * a means of dropping N items that is more efficient than sequential walking. 20 | */ 21 | public interface IDrop 22 | { 23 | /** 24 | * Returns a collection that is Sequential, ISeq, and IReduceInit. It is also 25 | * useful if the returned coll implements IDrop for subsequent use in a 26 | * partition-like scenario. 27 | * 28 | * @param n Items to drop, must be > 0 29 | * @return Collection that is Sequential, ISeq, and IReduceInit, or null if past the end 30 | */ 31 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 32 | Sequential drop(int n); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/ParseEvalExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace clojure.lang.CljCompiler.Ast 8 | { 9 | public class ParseEvalExpr : Expr 10 | { 11 | Expr _expr; 12 | 13 | public ParseEvalExpr(Expr expr) 14 | { 15 | _expr = expr; 16 | } 17 | 18 | public bool HasClrType => throw new NotImplementedException(); 19 | 20 | public Type ClrType => throw new NotImplementedException(); 21 | 22 | public sealed class Parser : IParser 23 | { 24 | 25 | 26 | public Expr Parse(ParserContext pcon, object form) 27 | { 28 | // The whole point is just to evaluate the expression during parsing, 29 | // similar to FnExpr doing ObjExpr.Compile during parsing in order to generate the function type. 30 | 31 | var expr = Compiler.Analyze(pcon, RT.second(form)); 32 | expr.Eval(); 33 | return new ParseEvalExpr(expr); 34 | } 35 | } 36 | 37 | public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) 38 | { 39 | Compiler.NilExprInstance.Emit(rhc, objx, ilg); 40 | } 41 | 42 | public object Eval() 43 | { 44 | return null; 45 | } 46 | 47 | public bool HasNormalExit() 48 | { 49 | return true; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IPersistentStack.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents an immutable collection with stack operations. 20 | /// 21 | public interface IPersistentStack: IPersistentCollection 22 | { 23 | /// 24 | /// Peek at the top (first) element in the stack. 25 | /// 26 | /// The top (first) element. 27 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 28 | object peek(); 29 | 30 | /// 31 | /// Returns a new stack with the top element popped. 32 | /// 33 | /// The new stack. 34 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 35 | IPersistentStack pop(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/Box.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | 19 | // TODO: Replace Box: mostly this is used in the Java version in lieu of ref/out parameters. 20 | 21 | /// 22 | /// Boxes any value or reference. 23 | /// 24 | public class Box 25 | { 26 | /// 27 | /// The value being boxed. 28 | /// 29 | private object _val; 30 | 31 | /// 32 | /// Gets the boxed value. 33 | /// 34 | public object Val 35 | { 36 | get { return _val; } 37 | set { _val = value; } 38 | } 39 | 40 | /// 41 | /// Initializes a Box to the given value. 42 | /// 43 | /// 44 | public Box(object val) 45 | { 46 | _val = val; 47 | } 48 | 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/dm-test.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) David Miller. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | 10 | (ns clojure.test) 11 | 12 | ; check generation of boolean test when test is known to be of type bool. 13 | 14 | (defn test-if [i n] ( if (> i n) 'a 'b)) 15 | 16 | ; check generation of boolean test when test type is not known. 17 | 18 | (defn test-if2-test [i n] (> i n)) 19 | (defn test-if2 [i n] (if (test-if2-test i n) 'a 'b)) 20 | 21 | ; check generation of boolean test when return type is not bool. 22 | (defn test-if3 [i n] (if i n 'b)) 23 | 24 | 25 | ; basic check of type tagging from the Clojure docs: 26 | (defn len [x] (. x Length)) 27 | (defn len2 [^String x] (. x Length)) 28 | 29 | (defn test-len [] (time (reduce + (map len (replicate 10000 "asdf"))))) 30 | (defn test-len2 [] (time (reduce + (map len2 (replicate 10000 "asdf"))))) 31 | 32 | ; my first test ever. It still runs slow 33 | (defn f1 [l n] (if (> (count l) n) nil (recur (cons 'a l) n))) 34 | (defn test-f1 [] (time (f1 nil 10000))) 35 | 36 | (defn f-dotimes [n] (dotimes [i n] (list i))) 37 | (defn test-dotimes [] (time (f-dotimes 100000))) 38 | 39 | 40 | -------------------------------------------------------------------------------- /Clojure/Clojure/Runtime/ClojureOptions.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.ObjectModel; 17 | using System.Collections.Generic; 18 | 19 | using Microsoft.Scripting; 20 | 21 | 22 | namespace clojure.lang.Runtime 23 | { 24 | [Serializable] 25 | public sealed class ClojureOptions : LanguageOptions 26 | { 27 | private readonly ReadOnlyCollection _arguments; 28 | 29 | 30 | /// 31 | /// Gets the collection of command line arguments. 32 | /// 33 | public ReadOnlyCollection/*!*/ Arguments 34 | { 35 | get { return _arguments; } 36 | } 37 | 38 | 39 | public ClojureOptions() 40 | : this(null) 41 | { 42 | } 43 | 44 | public ClojureOptions(IDictionary options) 45 | :base(options) 46 | { 47 | _arguments = GetStringCollectionOption(options, "Arguments") ?? EmptyStringCollection; 48 | } 49 | 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/genclass/testgenclass3.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | ; 9 | ; 10 | ; Author: David Miller 11 | ; 12 | ; Simple example testing arguments and returns of value type. 13 | ; 14 | ; Place this file in the clojure subdirectory of your main directory. 15 | ; (compile 'clojure.testgenclass3) 16 | ; 17 | ; Tests: 18 | ; 19 | ; (def v (my.TGC3/fy)) 20 | ; (.add v 12) 21 | ; (.add v 13) 22 | ; (.val v) 23 | ; (.zero v) 24 | ; (.val v) 25 | 26 | 27 | (ns clojure.testgenclass3 28 | (:gen-class 29 | :state state 30 | :init init 31 | :main false 32 | :name my.TGC3 33 | :factory fy 34 | :methods [ 35 | [zero [] Int32] 36 | [add [Int32] Int32] 37 | [val [] Int32] ])) 38 | 39 | 40 | (defn -init [] 41 | [[] (ref 0)]) 42 | 43 | (defn -zero [this] 44 | (dosync 45 | (let [state (.state this) 46 | old @state] 47 | (ref-set state 0) 48 | old))) 49 | 50 | (defn -add [this val] 51 | (print (str this)) 52 | (print (str val)) 53 | (dosync 54 | (commute (.state this) + val))) 55 | 56 | (defn -val [this] 57 | @(.state this)) 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/TestTest.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | 21 | 22 | using NUnit.Framework; 23 | 24 | 25 | namespace Clojure.Tests.LibTests 26 | { 27 | 28 | 29 | //public class BaseTest : AssertionHelper 30 | //{ 31 | // [Test] 32 | // public void Test1() 33 | // { 34 | // Console.WriteLine("T1"); 35 | // } 36 | 37 | // [Test] 38 | // public void Test2() 39 | // { 40 | // Console.WriteLine("T2"); 41 | // } 42 | 43 | //} 44 | 45 | //[TestFixture] 46 | //public class TestTest : BaseTest 47 | //{ 48 | // [Test] 49 | // public void Test3() 50 | // { 51 | // Console.WriteLine("T3"); 52 | // } 53 | //} 54 | 55 | 56 | 57 | //[TestFixture] 58 | //public class TestTest2 : BaseTest 59 | //{ 60 | // [Test] 61 | // public void Test4() 62 | // { 63 | // Console.WriteLine("T4"); 64 | // } 65 | //} 66 | } 67 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/MethodParamExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | using System; 12 | 13 | namespace clojure.lang.CljCompiler.Ast 14 | { 15 | public sealed class MethodParamExpr(Type t) : Expr, MaybePrimitiveExpr 16 | { 17 | 18 | #region Data 19 | public Type Type => t; 20 | 21 | #endregion 22 | 23 | #region C-tors 24 | 25 | #endregion 26 | 27 | #region Type mangling 28 | 29 | public bool HasClrType => t != null; 30 | 31 | public Type ClrType => t; 32 | 33 | #endregion 34 | 35 | #region eval 36 | 37 | public object Eval() => throw new InvalidOperationException("Can't eval"); 38 | 39 | #endregion 40 | 41 | #region Code generation 42 | 43 | public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) => throw new InvalidOperationException("Can't emit"); 44 | 45 | public bool HasNormalExit() => true; 46 | 47 | public bool CanEmitPrimitive => Util.IsPrimitive(t); 48 | 49 | public void EmitUnboxed(RHC rhc, ObjExpr objx, CljILGen ilg) => throw new InvalidOperationException("Can't emit"); 50 | 51 | #endregion 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/edn.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | ; Author: Stuart Halloway 10 | 11 | 12 | (ns clojure.test-clojure.edn 13 | (:require [clojure.test.generative :refer (defspec)] 14 | [clojure.test-clojure.generators :as cgen] 15 | [clojure.edn :as edn])) 16 | 17 | (defn roundtrip 18 | "Print an object and read it back as edn. Returns rather than throws 19 | any exceptions." 20 | [o] 21 | (binding [*print-length* nil 22 | *print-dup* nil 23 | *print-level* nil] 24 | (try 25 | (-> o pr-str edn/read-string) 26 | (catch Exception t t)))) ;;; Throwable 27 | 28 | (defspec types-that-should-roundtrip 29 | roundtrip 30 | [^{:tag cgen/ednable} o] 31 | (when-not (= o %) 32 | (throw (ex-info "Value cannot roundtrip, see ex-data" {:printed o :read %})))) 33 | 34 | (defspec types-that-should-not-roundtrip 35 | roundtrip 36 | [^{:tag cgen/non-ednable} o] 37 | (when-not (instance? Exception %) ;;; Throwable 38 | (throw (ex-info "edn/read should have thrown, see ex-data" {:printed o :read %})))) -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/Named.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents an object that has a namespace/name. 20 | /// 21 | /// Lowercase-named methods for compatibility with the JVM implementation. 22 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 23 | public interface Named 24 | { 25 | /// 26 | /// Gets the namespace name for the object. 27 | /// 28 | /// The namespace name. 29 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 30 | string getNamespace(); 31 | 32 | /// 33 | /// Gets the name of the object 34 | /// 35 | /// The name. 36 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 37 | string getName(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/BooleanExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | using System; 12 | using System.Reflection.Emit; 13 | 14 | namespace clojure.lang.CljCompiler.Ast 15 | { 16 | public class BooleanExpr : LiteralExpr // , MaybePrimitiveExpr TODO: No reason this shouldn't be, but it messes up the RecurExpr emit code. 17 | { 18 | #region Data 19 | 20 | readonly bool _val; 21 | public override object Val => _val; 22 | 23 | #endregion 24 | 25 | #region C-tors 26 | 27 | public BooleanExpr(bool val) 28 | { 29 | _val = val; 30 | } 31 | 32 | #endregion 33 | 34 | #region Type mangling 35 | 36 | public override bool HasClrType => true; 37 | 38 | public override Type ClrType => typeof(bool); 39 | 40 | #endregion 41 | 42 | #region Code generation 43 | 44 | public override void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) 45 | { 46 | ilg.EmitBoolean(_val); 47 | ilg.Emit(OpCodes.Box, typeof(bool)); 48 | if (rhc == RHC.Statement) 49 | ilg.Emit(OpCodes.Pop); 50 | } 51 | 52 | #endregion 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/ObjTests.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | using NUnit.Framework; 21 | 22 | using clojure.lang; 23 | 24 | 25 | namespace Clojure.Tests.LibTests 26 | { 27 | [TestFixture] 28 | public class ObjTests : IObjTests 29 | { 30 | 31 | class MockObj : Obj 32 | { 33 | public MockObj() 34 | { 35 | } 36 | 37 | public MockObj(IPersistentMap meta) 38 | : base(meta) 39 | { 40 | } 41 | 42 | public override IObj withMeta(IPersistentMap meta) 43 | { 44 | return meta == _meta 45 | ? this 46 | : new MockObj(meta); 47 | } 48 | } 49 | 50 | 51 | [SetUp] 52 | public void Setup() 53 | { 54 | IPersistentMap meta = new DummyMeta(); 55 | 56 | _objWithNullMeta = new MockObj(); 57 | _obj = new MockObj(meta); 58 | _expectedType = typeof(MockObj); 59 | } 60 | 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/KeywordExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | using System; 12 | using System.Reflection.Emit; 13 | 14 | namespace clojure.lang.CljCompiler.Ast 15 | { 16 | public class KeywordExpr : LiteralExpr 17 | { 18 | #region Data 19 | 20 | readonly Keyword _kw; 21 | public Keyword Kw => _kw; 22 | 23 | #endregion 24 | 25 | #region Ctors 26 | 27 | public KeywordExpr(Keyword kw) 28 | { 29 | _kw = kw; 30 | } 31 | 32 | #endregion 33 | 34 | #region Type mangling 35 | 36 | public override bool HasClrType => true; 37 | 38 | public override Type ClrType => typeof(Keyword); 39 | 40 | #endregion 41 | 42 | #region Code generation 43 | 44 | public override void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) 45 | { 46 | objx.EmitKeyword(ilg, _kw); 47 | if (rhc == RHC.Statement) 48 | ilg.Emit(OpCodes.Pop); 49 | } 50 | 51 | #endregion 52 | 53 | #region LiteralExpr methods 54 | 55 | public override object Val 56 | { 57 | get { return _kw; } 58 | } 59 | 60 | #endregion 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /docs/dependencies/transient-dependencies.dot: -------------------------------------------------------------------------------- 1 | strict digraph G { 2 | 3 | rankdir = RL; 4 | 5 | /* here start the interfaces */ 6 | 7 | 8 | 9 | subgraph clusterroot { 10 | 11 | node [shape=box]; 12 | 13 | ILookup; 14 | Counted; 15 | Indexed -> { Counted }; 16 | 17 | 18 | 19 | } 20 | 21 | subgraph clusterinterface { 22 | 23 | node [shape=box]; 24 | 25 | ITransientCollection; 26 | ITransientAssociative -> { ITransientCollection, ILookup }; 27 | ITransientAssociative2 -> { ITransientAssociative }; 28 | ITransientMap -> { ITransientAssociative, Counted }; 29 | ITransientSet -> { ITransientCollection, Counted }; 30 | ITransientVector -> { ITransientAssociative, Indexed }; 31 | } 32 | 33 | subgraph clusterabstract { 34 | 35 | node [shape=egg]; 36 | 37 | ATransientMap -> { ITransientMap, ITransientAssociative2 }; 38 | ATransientSet -> { ITransientSet }; 39 | 40 | } 41 | 42 | subgraph clusterconcrete { 43 | 44 | node [shape=ellipse] 45 | 46 | "PersistentArrayMap.TransientArrayMap" -> ATransientMap; 47 | "PersistentHashMap.TransientArrayMap" -> ATransientMap; 48 | "PersistentHashSet.TransientArraySet" -> ATransientSet; 49 | "PersistentVector.TransientVector" -> { ITransientVector, ITransientAssociative2 }; 50 | 51 | } 52 | 53 | subgraph clusterconcrete2 { 54 | 55 | node [shape=box] 56 | 57 | IEditableCollection; 58 | 59 | node [shape=ellipse] 60 | 61 | PersistentArrayMap -> { APersistentMap, IEditableCollection, IMapEnumerable }; 62 | PersistentHashMap -> { APersistentMap, IEditableCollection, IMapEnumerable }; 63 | PersistentHashSet -> { APersistentSet, IEditableCollection }; 64 | PersistentVector -> { APersistentVector, IEditableCollection}; 65 | 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/attributes/testattribute.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | ; 9 | ; Author: David Miller 10 | 11 | ; Test of gen-class facility. 12 | ; 13 | ; Place this file in the clojure subdirectory of your main directory. 14 | ; Compile the file C.cs via: csc /t:library C.cs 15 | ; Place C.dll in your root directory. 16 | ; Start Clojure and do: 17 | ; (System.Reflection.Assembly/LoadFrom "C.dll") 18 | ; (compile 'clojure.testattribute) 19 | ; 20 | ; You should then be able to play games such as: 21 | 22 | (ns clojure.testattribute) 23 | 24 | (def x (dm.Pet/Dog)) 25 | 26 | (gen-interface 27 | :name ^{System.SerializableAttribute {} dm.PetTypeAttribute x} test.I1 28 | :methods [ [m1 [] Object] ]) 29 | 30 | (definterface ^{System.SerializableAttribute {} dm.PetTypeAttribute x} I2 (m2 [])) 31 | 32 | ; (seq (.GetCustomAttributes test.I1 true)) 33 | ; (seq (.GetCustomAttributes I2 true)) 34 | 35 | 36 | (definterface ^{ dm.PetTypeAttribute x } I3 37 | (^{ dm.PetTypeAttribute x } m1 [ x y]) 38 | (m2 [x ^{ dm.PetTypeAttribute x } y])) 39 | 40 | 41 | (deftype ^{System.SerializableAttribute {}} T1 [a ^{ dm.PetTypeAttribute x } b] 42 | I3 43 | (^{ dm.PetTypeAttribute x } m1 [_ p q] p) 44 | (m2 [_ p ^{ dm.PetTypeAttribute x } q] q) 45 | ) -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/HostArg.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | namespace clojure.lang.CljCompiler.Ast 16 | { 17 | public class HostArg 18 | { 19 | #region Enum 20 | 21 | public enum ParameterType 22 | { 23 | Standard, 24 | ByRef 25 | } 26 | 27 | #endregion 28 | 29 | #region Data 30 | 31 | readonly ParameterType _paramType; 32 | 33 | public ParameterType ParamType 34 | { 35 | get { return _paramType; } 36 | } 37 | 38 | readonly Expr _argExpr; 39 | 40 | public Expr ArgExpr 41 | { 42 | get { return _argExpr; } 43 | } 44 | 45 | readonly LocalBinding _localBinding; 46 | 47 | public LocalBinding LocalBinding 48 | { 49 | get { return _localBinding; } 50 | } 51 | 52 | #endregion 53 | 54 | #region C-tors 55 | 56 | public HostArg(ParameterType paramType, Expr argExpr, LocalBinding lb) 57 | { 58 | _paramType = paramType; 59 | _argExpr = argExpr; 60 | _localBinding = lb; 61 | } 62 | 63 | #endregion 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/UnresolvedVarExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | using System; 12 | 13 | namespace clojure.lang.CljCompiler.Ast 14 | { 15 | public class UnresolvedVarExpr : Expr 16 | { 17 | #region Data 18 | 19 | readonly Symbol _symbol; 20 | public Symbol Symbol => _symbol; 21 | 22 | #endregion 23 | 24 | #region Ctors 25 | 26 | public UnresolvedVarExpr(Symbol symbol) 27 | { 28 | _symbol = symbol; 29 | } 30 | 31 | #endregion 32 | 33 | #region Type mangling 34 | 35 | public bool HasClrType => false; 36 | 37 | public Type ClrType => throw new InvalidOperationException("UnresolvedVarExpr has no CLR type"); 38 | 39 | #endregion 40 | 41 | #region eval 42 | 43 | public object Eval() 44 | { 45 | throw new ArgumentException("UnresolvedVarExpr cannot be evalled"); 46 | } 47 | 48 | #endregion 49 | 50 | #region Code generation 51 | 52 | public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) 53 | { 54 | // do nothing 55 | } 56 | 57 | public bool HasNormalExit() { return true; } 58 | 59 | #endregion 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/data.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns clojure.test-clojure.data 10 | (:use clojure.data clojure.test) 11 | ) ;;;(:import java.util.HashSet) 12 | 13 | (deftest diff-test 14 | (are [d x y] (= d (diff x y)) 15 | [nil nil nil] nil nil 16 | [1 2 nil] 1 2 17 | [nil nil [1 2 3]] [1 2 3] '(1 2 3) 18 | [1 [:a :b] nil] 1 [:a :b] 19 | [{:a 1} :b nil] {:a 1} :b 20 | [:team #{:p1 :p2} nil] :team #{:p1 :p2} 21 | [{0 :a} [:a] nil] {0 :a} [:a] 22 | [nil [nil 2] [1]] [1] [1 2] 23 | [nil nil [1 2]] [1 2] (into-array [1 2]) 24 | [#{:a} #{:b} #{:c :d}] #{:a :c :d} #{:b :c :d} 25 | [nil nil {:a 1}] {:a 1} {:a 1} 26 | [{:a #{2}} {:a #{4}} {:a #{3}}] {:a #{2 3}} {:a #{3 4}} 27 | ;;;[#{1} #{3} #{2}] (|System.Collections.Generic.List`1[System.Object]|. [1 2]) (|System.Collections.Generic.List`1[System.Object]|. [2 3]) ;;; HashSet 28 | [nil nil [1 2]] [1 2] (into-array [1 2]) 29 | [nil nil [1 2]] (into-array [1 2]) [1 2] 30 | [{:a {:c [1]}} {:a {:c [0]}} {:a {:c [nil 2] :b 1}}] {:a {:b 1 :c [1 2]}} {:a {:b 1 :c [0 2]}} 31 | [{:a nil} {:a false} {:b nil :c false}] {:a nil :b nil :c false} {:a false :b nil :c false})) 32 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/BindingInit.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | namespace clojure.lang.CljCompiler.Ast 12 | { 13 | public struct BindingInit(LocalBinding binding, Expr init) 14 | { 15 | #region Data 16 | public readonly LocalBinding Binding => binding; 17 | 18 | public readonly Expr Init => init; 19 | 20 | #endregion 21 | 22 | #region Ctors 23 | 24 | #endregion 25 | 26 | #region Object overrides 27 | 28 | public override readonly bool Equals(object obj) 29 | { 30 | if (obj is not BindingInit) 31 | return false; 32 | 33 | BindingInit bi = (BindingInit)obj; 34 | 35 | return binding.Equals(bi.Binding) && init.Equals(bi.Init); 36 | } 37 | 38 | public static bool operator ==(BindingInit b1, BindingInit b2) 39 | { 40 | return b1.Equals(b2); 41 | } 42 | 43 | public static bool operator !=(BindingInit b1, BindingInit b2) 44 | { 45 | return !b1.Equals(b2); 46 | } 47 | 48 | public override readonly int GetHashCode() 49 | { 50 | return Util.hashCombine(binding.GetHashCode(), init.GetHashCode()); 51 | } 52 | 53 | #endregion 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Clojure/Clojure.Samples/clojure/samples/genclass/C.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace dm 7 | { 8 | #pragma warning disable IDE1006 // Naming Styles 9 | #pragma warning disable IDE0051 // Remove unused private members 10 | public class C1 11 | { 12 | protected int x; 13 | protected string y = String.Empty; 14 | 15 | 16 | public void m1(int x) { Message("m1", x.ToString()); } 17 | 18 | 19 | public int m2(int x, string y) { Message("m2", x.ToString(), y); return x + y.Length; } 20 | public int m2(int x) { Message("m2", x.ToString()); return 2 * x; } 21 | 22 | 23 | protected int m3(object y) { Message("m3", y.ToString()); return y.GetHashCode(); } 24 | protected int m3(int x) { Message("m3", x.ToString()); return x + 1; } 25 | 26 | protected int m4(int x) { Message("m4", x.ToString()); return x + 1; } 27 | 28 | private int m5(int x) { Message("m5", x.ToString()); return x + 1; } 29 | 30 | public C1(int x, string y) { Message("ctor1", x.ToString(), y); this.x = x; this.y = y; } 31 | protected C1(string y, int x) { Message("ctor2", y, x.ToString()); this.y = y; this.x = x; } 32 | public C1() { Message("defaultctor"); } 33 | 34 | private static void Message(string name, params string[] strs) 35 | { 36 | Console.WriteLine("In {0}: {1}", name, string.Join(", ", strs)); 37 | } 38 | } 39 | 40 | public interface I1 41 | { 42 | object m5(object x); 43 | int m2(string x); 44 | int m2(int x); 45 | } 46 | 47 | #pragma warning restore IDE1006 // Naming Styles 48 | #pragma warning restore IDE0051 // Remove unused private members 49 | } 50 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IAtom2.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace clojure.lang 21 | { 22 | public interface IAtom2 : IAtom 23 | { 24 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 25 | IPersistentVector swapVals(IFn f); 26 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 27 | IPersistentVector swapVals(IFn f, Object arg); 28 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 29 | IPersistentVector swapVals(IFn f, Object arg1, Object arg2); 30 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 31 | IPersistentVector swapVals(IFn f, Object x, Object y, ISeq args); 32 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 33 | IPersistentVector resetVals(Object newv); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IMapEntry.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Defines a key/value pair. Immutable. 20 | /// 21 | /// 22 | /// Lowercase-named methods for JVM compatibility. 23 | /// In JVM version, this interface extends Map.Entry. The equivalent BCL type is either KeyValuePair 24 | /// or DictionaryEntry 25 | /// both of which are structs and hence can't be derived from. 26 | /// 27 | public interface IMapEntry 28 | { 29 | /// 30 | /// Get the key in a key/value pair. 31 | /// 32 | /// The key. 33 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 34 | object key(); 35 | 36 | /// 37 | /// Get the value in a key/value pair. 38 | /// 39 | /// The value. 40 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 41 | object val(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/Settable.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents an object with a value that can be set. 20 | /// 21 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 22 | public interface Settable 23 | { 24 | /// 25 | /// Sets the value. 26 | /// 27 | /// The new value 28 | /// The new value. 29 | /// Can only be called in a transaction or with a binding on the stack, else throws an exception. 30 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 31 | object doSet(object val); 32 | 33 | /// 34 | /// Sets the root value. 35 | /// 36 | /// The new value 37 | /// The new value. 38 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 39 | object doReset(object val); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/ILookup.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents an object that supports value lookup by key. 20 | /// 21 | public interface ILookup 22 | { 23 | /// 24 | /// Gets the value associated with a key. 25 | /// 26 | /// The key to look up. 27 | /// The associated value. (Throws an exception if key is not present.) 28 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 29 | object valAt(object key); 30 | 31 | /// 32 | /// Gets the value associated with a key. 33 | /// 34 | /// The key to look up. 35 | /// The value to return if the key is not present. 36 | /// The associated value (or notFound if the key is not present. 37 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 38 | object valAt(object key, object notFound); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IMapEnumerable.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections; 17 | using System.Collections.Generic; 18 | 19 | namespace clojure.lang 20 | { 21 | /// 22 | /// Indicate a map can provide more efficient key and val iterators. 23 | /// 24 | /// 25 | /// Equivalent to IMapIterable in ClojureJVM. 26 | /// 27 | public interface IMapEnumerable 28 | { 29 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 30 | IEnumerator keyEnumerator(); 31 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 32 | IEnumerator valEnumerator(); 33 | } 34 | 35 | public interface IMapEnumerableTyped 36 | { 37 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 38 | IEnumerator tkeyEnumerator(); 39 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 40 | IEnumerator tvalEnumerator(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/clr/process.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns clojure.test-clojure.clr.process 10 | (:require 11 | [clojure.test :refer :all] 12 | [clojure.clr.process :as p] ;;; clojure.java.process 13 | [clojure.string :as str])) 14 | 15 | (deftest test-stderr-redirect 16 | ;; capture to stdout and return string 17 | (is (not (str/blank? (p/exec {:redirect-out true} "bash" "-c" "ls")))) ;;; added options map 18 | 19 | ;; print to stderr, capture nil 20 | (is (str/blank? (p/exec {:redirect-out true} "bash" "-c" "ls >&2"))) 21 | 22 | ;; redirect, then capture to string 23 | #_(is (not (str/blank? (p/exec {:err :stdout} "bash" "-c" "ls >&2"))))) ;;; as far as I know, there is no way to redirect StandardError to StandardOutput directly. 24 | 25 | (deftest test-process-deref 26 | (is (zero? @(p/exit-ref (p/start "powershell.exe" "Start-Sleep -Seconds 1")))) ;;; (p/start "sleep" "1") 27 | (is (zero? (deref (p/exit-ref (p/start "powershell.exe" "Start-Sleep -Seconds 1")) 2500 :timeout))) ;;; (p/start "sleep" "1") 28 | (is (= :timeout (deref (p/exit-ref (p/start "powershell.exe" "Start-Sleep -Seconds 1")) 1 :timeout)))) ;;; (p/start "sleep" "1") -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/ChunkBuffer.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public sealed class ChunkBuffer : Counted 19 | { 20 | #region Data 21 | 22 | object[] _buffer; 23 | int _end; 24 | 25 | #endregion 26 | 27 | #region C-tors 28 | 29 | public ChunkBuffer(int capacity) 30 | { 31 | _buffer = new object[capacity]; 32 | _end = 0; 33 | } 34 | 35 | #endregion 36 | 37 | #region Other 38 | 39 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 40 | public void add(object o) 41 | { 42 | _buffer[_end++] = o; 43 | } 44 | 45 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 46 | public IChunk chunk() 47 | { 48 | ArrayChunk ret = new ArrayChunk(_buffer, 0, _end); 49 | _buffer = null; 50 | return ret; 51 | } 52 | 53 | #endregion 54 | 55 | #region Counted Members 56 | 57 | public int count() 58 | { 59 | return _end; 60 | } 61 | 62 | #endregion 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IAtom.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | using System.Diagnostics.CodeAnalysis; 17 | namespace clojure.lang 18 | { 19 | public interface IAtom 20 | { 21 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 22 | object swap(IFn f); 23 | 24 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 25 | object swap(IFn f, object arg); 26 | 27 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 28 | object swap(IFn f, object arg1, object arg2); 29 | 30 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 31 | object swap(IFn f, object x, object y, ISeq args); 32 | 33 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 34 | bool compareAndSet(object oldv, object newv); 35 | 36 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 37 | object reset(object newval); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/IReference.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | /// 19 | /// Represents an object with settable metadata. 20 | /// 21 | public interface IReference : IMeta 22 | { 23 | /// 24 | /// Alter the metadata on the object. 25 | /// 26 | /// A function to apply to generate the new metadata 27 | /// Arguments to apply the function to. 28 | /// The new metadata map. 29 | /// The new value will be the result of (apply alter (cons currentMeta args)). 30 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 31 | IPersistentMap alterMeta(IFn alter, ISeq args); 32 | 33 | /// 34 | /// Set the metadata of the object. 35 | /// 36 | /// The new metadata map 37 | /// The new metadata map. 38 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 39 | IPersistentMap resetMeta(IPersistentMap m); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Clojure/Clojure.Source/clojure/pprint/print_table.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (in-ns 'clojure.pprint) 10 | 11 | (defn print-table 12 | "Prints a collection of maps in a textual table. Prints table headings 13 | ks, and then a line of output for each row, corresponding to the keys 14 | in ks. If ks are not specified, use the keys of the first item in rows." 15 | {:added "1.3"} 16 | ([ks rows] 17 | (when (seq rows) 18 | (let [widths (map 19 | (fn [k] 20 | (apply max (count (str k)) (map #(count (str (get % k))) rows))) 21 | ks) 22 | spacers (map #(apply str (repeat % "-")) widths) 23 | fmts (map #(str "%" % "s") widths) 24 | fmt-row (fn [leader divider trailer row] 25 | (str leader 26 | (apply str (interpose divider 27 | (for [[col fmt] (map vector (map #(get row %) ks) fmts)] 28 | (format fmt (str col))))) 29 | trailer))] 30 | (println) 31 | (println (fmt-row "| " " | " " |" (zipmap ks ks))) 32 | (println (fmt-row "|-" "-+-" "-|" (zipmap ks spacers))) 33 | (doseq [row rows] 34 | (println (fmt-row "| " " | " " |" row)))))) 35 | ([rows] (print-table (keys (first rows)) rows))) 36 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/keywords.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns clojure.test-clojure.keywords 10 | (:use clojure.test)) 11 | 12 | (let [this-ns (str (.Name *ns*))] ;;; .name 13 | (deftest test-find-keyword 14 | :foo 15 | ::foo 16 | (let [absent-keyword-sym (gensym "absent-keyword-sym")] 17 | (are [result lookup] (= result (find-keyword lookup)) 18 | :foo :foo 19 | :foo 'foo 20 | :foo "foo" 21 | nil absent-keyword-sym 22 | nil (str absent-keyword-sym)) 23 | (are [result lookup] (= result (find-keyword this-ns lookup)) 24 | ::foo "foo" 25 | nil (str absent-keyword-sym))))) 26 | 27 | (deftest arity-exceptions 28 | (is (thrown-with-msg? ArgumentException #"Wrong number of args \(0\) passed to: :kw" (:kw))) ;;; IllegalArgumentException 29 | (is (thrown-with-msg? ArgumentException #"Wrong number of args \(20\) passed to: :foo/bar" (apply :foo/bar (range 20)))) ;;;IllegalArgumentException 30 | (is (thrown-with-msg? clojure.lang.ArityException #"Wrong number of args \(> 20\) passed to: :foo/bar" (apply :foo/bar (range 21)))) ;;;IllegalArgumentException 31 | (is (thrown-with-msg? clojure.lang.ArityException #"Wrong number of args \(> 20\) passed to: :foo/bar" (apply :foo/bar (range 22))))) ;;;IllegalArgumentException -------------------------------------------------------------------------------- /Clojure/Csharp.Tests/LibTests/ISeqTestHelper.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using static NExpect.Expectations; 18 | using clojure.lang; 19 | using NExpect; 20 | 21 | namespace Clojure.Tests.LibTests 22 | { 23 | public class ISeqTestHelper 24 | { 25 | public void VerifyISeqContents(ISeq s, IList values) 26 | { 27 | int i=0; 28 | 29 | for (; s != null; s = s.next(), i++) 30 | Expect(s.first()).To.Equal(values[i]); 31 | 32 | Expect(i).To.Equal(values.Count); 33 | } 34 | 35 | public void VerifyISeqCons(ISeq s, object newVal, IList values) 36 | { 37 | ISeq newSeq = s.cons(newVal); 38 | 39 | Expect(newSeq.first()).To.Equal(newVal); 40 | VerifyISeqContents(newSeq.next(), values); 41 | } 42 | 43 | public void VerifyISeqRestTypes(ISeq s, Type type) 44 | { 45 | for ( ; s.next() != null; s = s.next()) 46 | Expect(s.next().GetType()).To.Equal(type); 47 | } 48 | 49 | public void VerifyISeqRestMaintainsMeta(ISeq s) 50 | { 51 | IPersistentMap meta = ((IMeta)s).meta(); 52 | 53 | for (; s.next() != null; s = s.next()) 54 | Expect(((IMeta)s.next()).meta()).To.Equal(meta); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/ITransientMap.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | 16 | namespace clojure.lang 17 | { 18 | public interface ITransientMap : ITransientAssociative, Counted 19 | { 20 | /// 21 | /// Add a new key/value pair. 22 | /// 23 | /// The key 24 | /// The value 25 | /// A new map with key+value added. 26 | /// Overwrites an exising value for the , if present. 27 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 28 | new ITransientMap assoc(object key, object val); 29 | 30 | /// 31 | /// Remove a key entry. 32 | /// 33 | /// The key to remove 34 | /// A new map with the key removed (or the same map if the key is not contained). 35 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 36 | ITransientMap without(object key); 37 | 38 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 39 | new IPersistentMap persistent(); 40 | 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/MonitorEnterExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | using System; 12 | 13 | namespace clojure.lang.CljCompiler.Ast 14 | { 15 | public class MonitorEnterExpr : UntypedExpr 16 | { 17 | #region Data 18 | 19 | readonly Expr _target; 20 | public Expr Target => _target; 21 | #endregion 22 | 23 | #region Ctors 24 | 25 | public MonitorEnterExpr(Expr target) 26 | { 27 | _target = target; 28 | } 29 | 30 | #endregion 31 | 32 | #region Parsing 33 | 34 | public sealed class Parser : IParser 35 | { 36 | public Expr Parse(ParserContext pcon, object form) 37 | { 38 | return new MonitorEnterExpr(Compiler.Analyze(pcon.SetRhc(RHC.Expression), RT.second(form))); 39 | } 40 | } 41 | 42 | #endregion 43 | 44 | #region eval 45 | 46 | public override object Eval() 47 | { 48 | throw new InvalidOperationException("Can't eval monitor-enter"); 49 | } 50 | 51 | #endregion 52 | 53 | #region Code generation 54 | 55 | public override void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) 56 | { 57 | _target.Emit(RHC.Expression, objx, ilg); 58 | ilg.EmitCall(Compiler.Method_Monitor_Enter); 59 | Compiler.NilExprInstance.Emit(rhc, objx, ilg); 60 | } 61 | 62 | #endregion 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/MonitorExitExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | using System; 12 | 13 | namespace clojure.lang.CljCompiler.Ast 14 | { 15 | public class MonitorExitExpr : UntypedExpr 16 | { 17 | #region Data 18 | 19 | readonly Expr _target; 20 | public Expr Target => _target; 21 | 22 | #endregion 23 | 24 | #region Ctors 25 | 26 | public MonitorExitExpr(Expr target) 27 | { 28 | _target = target; 29 | } 30 | 31 | #endregion 32 | 33 | #region Parsing 34 | 35 | public sealed class Parser : IParser 36 | { 37 | public Expr Parse(ParserContext pcon, object form) 38 | { 39 | return new MonitorExitExpr(Compiler.Analyze(pcon.SetRhc(RHC.Expression), RT.second(form))); 40 | } 41 | } 42 | 43 | #endregion 44 | 45 | #region eval 46 | 47 | public override object Eval() 48 | { 49 | throw new InvalidOperationException("Can't eval monitor-exit"); 50 | } 51 | 52 | #endregion 53 | 54 | #region Code generation 55 | 56 | public override void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) 57 | { 58 | _target.Emit(RHC.Expression, objx, ilg); 59 | ilg.EmitCall(Compiler.Method_Monitor_Exit); 60 | Compiler.NilExprInstance.Emit(rhc, objx, ilg); 61 | } 62 | 63 | #endregion 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Clojure/Clojure.Source/clojure/edn.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns ^{:doc "edn reading." 10 | :author "Rich Hickey"} 11 | clojure.edn 12 | (:refer-clojure :exclude [read read-string])) 13 | 14 | (defn read 15 | "Reads the next object from stream, which must be an instance of 16 | java.io.PushbackReader or some derivee. stream defaults to the 17 | current value of *in*. 18 | 19 | Reads data in the edn format (subset of Clojure data): 20 | http://edn-format.org 21 | 22 | opts is a map that can include the following keys: 23 | :eof - value to return on end-of-file. When not supplied, eof throws an exception. 24 | :readers - a map of tag symbols to data-reader functions to be considered before default-data-readers. 25 | When not supplied, only the default-data-readers will be used. 26 | :default - A function of two args, that will, if present and no reader is found for a tag, 27 | be called with the tag and the value." 28 | 29 | {:added "1.5"} 30 | ([] 31 | (read *in*)) 32 | ([stream] 33 | (read {} stream)) 34 | ([opts stream] 35 | (clojure.lang.EdnReader/read stream opts))) 36 | 37 | (defn read-string 38 | "Reads one object from the string s. Returns nil when s is nil or empty. 39 | 40 | Reads data in the edn format (subset of Clojure data): 41 | http://edn-format.org 42 | 43 | opts is a map as per clojure.edn/read" 44 | {:added "1.5"} 45 | ([s] (read-string {:eof nil} s)) 46 | ([opts s] (when s (clojure.lang.EdnReader/readString s opts)))) -------------------------------------------------------------------------------- /Clojure/Clojure/Lib/RecordEnumerable.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | */ 10 | 11 | /* ghadi shayban Sep 24, 2014 */ 12 | 13 | /** 14 | * Author: David Miller 15 | **/ 16 | 17 | using System; 18 | using System.Collections; 19 | using System.Collections.Generic; 20 | 21 | namespace clojure.lang 22 | { 23 | public sealed class RecordEnumerable: IEnumerable, IEnumerable 24 | { 25 | 26 | #region Data 27 | 28 | readonly int _basecnt; 29 | readonly ILookup _rec; 30 | readonly IPersistentVector _baseFields; 31 | readonly IEnumerator _extmap; 32 | 33 | #endregion 34 | 35 | #region Ctors and factories 36 | 37 | public RecordEnumerable(ILookup rec, IPersistentVector baseFields, IEnumerator extmap) 38 | { 39 | _rec = rec; 40 | _baseFields = baseFields; 41 | _basecnt = baseFields.count(); 42 | _extmap = extmap; 43 | } 44 | 45 | #endregion 46 | 47 | public IEnumerator GetEnumerator() 48 | { 49 | for (int i = 0; i < _basecnt; i++) 50 | { 51 | object k = _baseFields.nth(i); 52 | yield return MapEntry.create(k,_rec.valAt(k)); 53 | } 54 | 55 | while (_extmap.MoveNext()) 56 | yield return _extmap.Current; 57 | 58 | } 59 | 60 | IEnumerator IEnumerable.GetEnumerator() 61 | { 62 | return GetEnumerator(); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/api.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns clojure.test-clojure.api 10 | (:require [clojure.test.generative :refer (defspec)] 11 | [clojure.test-clojure.generators :as cgen]) 12 | (:import clojure.lang.IFn 13 | clojure.clr.api.Clojure ;;; clojure.java.api.Clojure 14 | clojure.lang.Var)) 15 | 16 | (set! *warn-on-reflection* true) 17 | 18 | (defn roundtrip 19 | "Print an object and read it back with Clojure/read" 20 | [o] 21 | (binding [*print-length* nil 22 | *print-dup* nil 23 | *print-level* nil] 24 | (Clojure/read (pr-str o)))) 25 | 26 | (defn api-var-str 27 | [^Var v] 28 | (Clojure/var (str (.Name (.ns v))) ;;; .name 29 | (str (.sym v)))) 30 | 31 | (defn api-var 32 | [^Var v] 33 | (Clojure/var (.Name (.ns v)) ;;; .name 34 | (.sym v))) 35 | 36 | (defspec api-can-read 37 | roundtrip 38 | [^{:tag cgen/ednable} o] 39 | (when-not (= o %) 40 | (throw (ex-info "Value cannot roundtrip with Clojure/read" {:printed o :read %})))) 41 | 42 | (defspec api-can-find-var 43 | api-var 44 | [^{:tag cgen/var} v] 45 | (when-not (= v %) 46 | (throw (ex-info "Var cannot roundtrip through Clojure/var" {:from v :to %})))) 47 | 48 | (defspec api-can-find-var-str 49 | api-var-str 50 | [^{:tag cgen/var} v] 51 | (when-not (= v %) 52 | (throw (ex-info "Var cannot roundtrip strings through Clojure/var" {:from v :to %})))) 53 | 54 | -------------------------------------------------------------------------------- /docs/dependencies/seq-dependencies.dot: -------------------------------------------------------------------------------- 1 | strict digraph G { 2 | 3 | rankdir = RL; 4 | 5 | /* here start the interfaces */ 6 | 7 | 8 | 9 | subgraph clusterinterface { 10 | 11 | node [shape=box]; 12 | 13 | Seqable; 14 | IPersistentCollection -> { Seqable }; 15 | ISeq -> { IPersistentCollection }; 16 | Sequential; 17 | ILookup; 18 | IMapEnumerable; 19 | Associative -> { IPersistentCollection, ILookup }; 20 | IArraySeq -> { ISeq }; 21 | } 22 | 23 | subgraph clusterinterface2 { 24 | 25 | IPersistentList -> { Sequential, IPersistentStack }; 26 | IPersistentMap -> { Associative}; 27 | IPersistentSet -> { IPersistentCollection }; 28 | IPersistentStack -> { IPersistentCollection }; 29 | IPersistentVector -> { Associative, Sequential, IPersistentStack }; 30 | 31 | 32 | 33 | 34 | 35 | 36 | node [shape=egg]; 37 | 38 | AMapEntry -> { APersistentVector }; 39 | APersistentMap -> { IPersistentMap }; 40 | APersistentSet -> { IPersistentSet}; 41 | APersistentVector -> { IPersistentVector}; 42 | } 43 | 44 | 45 | subgraph clusterclassP { 46 | node [shape=ellipse] 47 | PersistentArrayMap -> { APersistentMap, IMapEnumerable }; 48 | PersistentHashMap -> { APersistentMap, IMapEnumerable }; 49 | PersistentHashSet -> { APersistentSet }; 50 | 51 | PersistentQueue -> { IPersistentList }; 52 | PersistentStructMap -> { APersistentMap }; 53 | PersistentTreeMap -> { APersistentMap }; 54 | PersistentTreeSet -> { APersistentSet }; 55 | PersistentVector -> { APersistentVector }; 56 | } 57 | 58 | subgraph clusterclass { 59 | 60 | node [shape=box] 61 | 62 | 63 | 64 | 65 | node [shape=egg] 66 | 67 | 68 | ASeq -> { ISeq, Sequential }; 69 | 70 | node [shape=ellipse] 71 | 72 | 73 | PersistentList -> { ASeq, IPersistentList }; 74 | ChunkedCons -> { ASeq }; 75 | Cons -> { ASeq }; 76 | Cycle -> { ASeq }; 77 | 78 | EnumeratorSeq -> { ASeq }; 79 | 80 | Iterate -> { ASeq }; 81 | 82 | LazySeq -> { ISeq, Sequential}; 83 | LongRange -> { ASeq }; 84 | 85 | 86 | Range -> { ASeq }; 87 | Repeat -> { ASeq }; 88 | StringSeq -> { ASeq }; 89 | } 90 | 91 | } -------------------------------------------------------------------------------- /Clojure/pv.bat: -------------------------------------------------------------------------------- 1 | peverify /verbose clojure.clr.io.clj.dll 2 | peverify /verbose clojure.clr.shell.clj.dll 3 | peverify /verbose clojure.core.clj.dll 4 | peverify /verbose clojure.core.protocols.clj.dll 5 | peverify /verbose clojure.core_clr.clj.dll 6 | peverify /verbose clojure.core_deftype.clj.dll 7 | peverify /verbose clojure.core_print.clj.dll 8 | peverify /verbose clojure.core_proxy.clj.dll 9 | peverify /verbose clojure.data.clj.dll 10 | peverify /verbose clojure.data.generators.dll 11 | peverify /verbose clojure.edn.clj.dll 12 | peverify /verbose clojure.genclass.clj.dll 13 | peverify /verbose clojure.gvec.clj.dll 14 | peverify /verbose clojure.instant.clj.dll 15 | peverify /verbose clojure.main.clj.dll 16 | peverify /verbose clojure.pprint.clj.dll 17 | peverify /verbose clojure.pprint.cl_format.clj.dll 18 | peverify /verbose clojure.pprint.column_writer.clj.dll 19 | peverify /verbose clojure.pprint.dispatch.clj.dll 20 | peverify /verbose clojure.pprint.pprint_base.clj.dll 21 | peverify /verbose clojure.pprint.pretty_writer.clj.dll 22 | peverify /verbose clojure.pprint.print_table.clj.dll 23 | peverify /verbose clojure.pprint.utilities.clj.dll 24 | peverify /verbose clojure.reflect.clj.dll 25 | peverify /verbose clojure.reflect.clr.clj.dll 26 | peverify /verbose clojure.repl.clj.dll 27 | peverify /verbose clojure.set.clj.dll 28 | peverify /verbose clojure.stacktrace.clj.dll 29 | peverify /verbose clojure.string.clj.dll 30 | peverify /verbose clojure.template.clj.dll 31 | peverify /verbose clojure.test.check.dll 32 | peverify /verbose clojure.test.clj.dll 33 | peverify /verbose clojure.test.generative.dll 34 | peverify /verbose clojure.test.junit.clj.dll 35 | peverify /verbose clojure.test.tap.clj.dll 36 | peverify /verbose clojure.test_clojure.attributes.clj.dll 37 | peverify /verbose clojure.test_clojure.genclass.examples.clj.dll 38 | peverify /verbose clojure.test_clojure.genclass.examples.ExampleClass.dll 39 | peverify /verbose clojure.test_clojure.protocols.examples.clj.dll 40 | peverify /verbose clojure.tools.namespace.dll 41 | peverify /verbose clojure.uuid.clj.dll 42 | peverify /verbose clojure.walk.clj.dll 43 | peverify /verbose clojure.zip.clj.dll -------------------------------------------------------------------------------- /Clojure/Clojure/CljCompiler/Ast/MetaExpr.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | using System; 12 | using System.Reflection.Emit; 13 | 14 | namespace clojure.lang.CljCompiler.Ast 15 | { 16 | public class MetaExpr : Expr 17 | { 18 | #region Data 19 | 20 | readonly Expr _expr; 21 | public Expr Expr => _expr; 22 | 23 | readonly Expr _meta; 24 | public Expr Meta => _meta; 25 | 26 | #endregion 27 | 28 | #region Ctors 29 | 30 | public MetaExpr(Expr expr, Expr meta) 31 | { 32 | _expr = expr; 33 | _meta = meta; 34 | } 35 | 36 | #endregion 37 | 38 | #region Type mangling 39 | 40 | public bool HasClrType => _expr.HasClrType; 41 | 42 | public Type ClrType => _expr.ClrType; 43 | 44 | #endregion 45 | 46 | #region eval 47 | 48 | public object Eval() 49 | { 50 | return ((IObj)_expr.Eval()).withMeta((IPersistentMap)_meta.Eval()); 51 | } 52 | 53 | #endregion 54 | 55 | #region Code generation 56 | 57 | public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) 58 | { 59 | _expr.Emit(RHC.Expression, objx, ilg); 60 | ilg.Emit(OpCodes.Castclass, typeof(IObj)); 61 | _meta.Emit(RHC.Expression, objx, ilg); 62 | ilg.Emit(OpCodes.Castclass, typeof(IPersistentMap)); 63 | ilg.EmitCall(Compiler.Method_IObj_withMeta); 64 | if (rhc == RHC.Statement) 65 | ilg.Emit(OpCodes.Pop); 66 | } 67 | 68 | public bool HasNormalExit() { return true; } 69 | 70 | #endregion 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Clojure/Clojure.Tests/clojure/test_clojure/try_catch.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | ; Author: Paul M Bauer 10 | (assembly-load-from "Clojure.Tests.dll") ;;; DM: Added 11 | (ns clojure.test-clojure.try-catch 12 | (:use clojure.test) 13 | (:import [clojure.test ReflectorTryCatchFixture 14 | ReflectorTryCatchFixture+Cookies])) ;;; ReflectorTryCatchFixture$Cookies 15 | 16 | (defn- get-exception [expression] 17 | (try (eval expression) 18 | nil 19 | (catch System.Exception t ;;; java.lang.Throwable 20 | t))) 21 | 22 | (deftest catch-receives-checked-exception 23 | (are [expression expected-exception] (= expected-exception 24 | (type (get-exception expression))) 25 | "Eh, I'm pretty safe" nil 26 | '(System.IO.StreamReader. "CAFEBABEx0/idonotexist") System.IO.DirectoryNotFoundException)) ;;; java.io.FileReader. java.io.FileNotFoundException 27 | 28 | 29 | (defn fail [x] 30 | (ReflectorTryCatchFixture/fail x)) 31 | 32 | (defn make-instance [] 33 | (ReflectorTryCatchFixture.)) 34 | 35 | (deftest catch-receives-checked-exception-from-reflective-call 36 | (is (thrown-with-msg? ReflectorTryCatchFixture+Cookies #"Long" (fail 1))) ;;; ReflectorTryCatchFixture$Cookies 37 | (is (thrown-with-msg? ReflectorTryCatchFixture+Cookies #"Double" (fail 1.0))) ;;; ReflectorTryCatchFixture$Cookies 38 | (is (thrown-with-msg? ReflectorTryCatchFixture+Cookies #"Wrapped" ;;; ReflectorTryCatchFixture$Cookies 39 | (.failWithCause (make-instance) 1.0)))) -------------------------------------------------------------------------------- /Clojure/Clojure.Main/Main.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Rich Hickey. All rights reserved. 3 | * The use and distribution terms for this software are covered by the 4 | * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 5 | * which can be found in the file epl-v10.html at the root of this distribution. 6 | * By using this software in any fashion, you are agreeing to be bound by 7 | * the terms of this license. 8 | * You must not remove this notice, or any other, from this software. 9 | **/ 10 | 11 | /** 12 | * Author: David Miller 13 | **/ 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Text; 19 | using clojure.lang; 20 | 21 | namespace Clojure 22 | { 23 | public static class CljMain 24 | { 25 | private static readonly Symbol CLOJURE_MAIN = Symbol.intern("clojure.main"); 26 | private static readonly Var REQUIRE = RT.var("clojure.core", "require"); 27 | private static readonly Var LEGACY_REPL = RT.var("clojure.main", "legacy-repl"); 28 | private static readonly Var LEGACY_SCRIPT = RT.var("clojure.main", "legacy-script"); 29 | private static readonly Var MAIN = RT.var("clojure.main", "main"); 30 | 31 | static void Main(string[] args) 32 | { 33 | RT.Init(); 34 | REQUIRE.invoke(CLOJURE_MAIN); 35 | MAIN.applyTo(RT.seq(args)); 36 | } 37 | 38 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 39 | public static void legacy_repl(string[] args) 40 | { 41 | RT.Init(); 42 | REQUIRE.invoke(CLOJURE_MAIN); 43 | LEGACY_REPL.invoke(RT.seq(args)); 44 | 45 | } 46 | 47 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "ClojureJVM name match")] 48 | public static void legacy_script(string[] args) 49 | { 50 | RT.Init(); 51 | REQUIRE.invoke(CLOJURE_MAIN); 52 | LEGACY_SCRIPT.invoke(RT.seq(args)); 53 | } 54 | 55 | 56 | } 57 | } 58 | --------------------------------------------------------------------------------