[
  {
    "path": ".gitignore",
    "content": "*.jar\ntarget\nclojure.iws\nclojure.ipr\nnbproject/private/\nmaven-classpath\nmaven-classpath.properties\ncoclojure/*\n.settings/*\n.classpath\n.project\nxcode\n.idea/\n\nsettings.xml\n\nupload-github.sh\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "If you'd like to submit a patch, please follow the [contributing guidelines](http://clojure.org/contributing).\n"
  },
  {
    "path": "KNOWN_ISSUES",
    "content": "- Dividing by zero doesn't throw an exception in objc, it fails with EXC_ARITHMETIC\n- NullPointerException and ClassCastException are not reliable, as they are emulated by j2objc\n- Empty regular expressions throw an exception\n- pr-str a date have a bad Timezone format: https://code.google.com/p/j2objc/issues/detail?id=321"
  },
  {
    "path": "antsetup.sh",
    "content": "#!/bin/bash\n\nmvn -q dependency:build-classpath -Dmdep.outputFile=maven-classpath\ncat <<EOF >maven-classpath.properties \nmaven.compile.classpath=`cat maven-classpath`\nmaven.test.classpath=`cat maven-classpath`\nEOF\necho \"Wrote maven-classpath.properties for standalone ant use\"\n"
  },
  {
    "path": "build.clj",
    "content": "(use '[clojure.java.shell :only [sh with-sh-dir]])\n(use '[clojure.java.io :only [delete-file file]])\n(require '[clojure.string :as st])\n(import '[java.io File])\n\n(def j2objc-home (System/getenv \"J2OBJC_HOME\"))\n(def iphone-os-sdk \"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk\")\n(def iphone-simulator-sdk \"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk\")\n(def frameworks \"-framework UIKit -framework Foundation\")\n(def opts \"-g -miphoneos-version-min=6.1 -fmessage-length=0 -fmacro-backtrace-limit=0 -std=gnu99 -fpascal-strings -O3 -DDEBUG=1 -Wno-unsequenced\")\n\n(let [a (agent nil)]\n  (defn println+ [& other]\n    (send a (fn [_] (apply println other)))))\n\n(defn walk [^File dir]\n  (let [children (.listFiles dir)\n        subdirs (filter #(.isDirectory %) children)\n        files (filter #(.isFile %) children)]\n    (concat files (mapcat walk subdirs))))\n\n(defn find-files [folder extension]\n  (filter #(.endsWith (.getName %) (str \".\" extension)) (walk (file folder))))\n\n(defn sh+ [& args]\n  (let [silent (= :silent (first args))\n        _ (when-not silent\n            (println+ \"Running: \" (reduce str (interpose \" \" args))))\n        args (map #(clojure.string/split % #\" \") \n                  (if silent (next args) args))\n        r (apply sh (flatten args))]\n    (when-not (zero? (:exit r))\n      (println+ \"FAILED\" (:err r)))))\n\n(defn makeoname [f]\n  (str (st/replace f #\"/\" \".\") \".o\"))\n\n(defn clang [id params sdk target f]\n  (println+ id (.getName f))\n  (sh+ :silent \"clang\" \"-x\" \"objective-c\" params opts \"-isysroot\" sdk\n       (str \"-I\" target \"/../src/ffi\")\n       (str \"-I\" target \"/objc\")\n       (str \"-I\" j2objc-home \"/include\")\n       \"-c\" (.getCanonicalPath f) \"-o\" (makeoname (.getPath f))))\n\n(defn build [id params sdk]\n  (let [target (File. \"target\")\n        tcn (.getCanonicalPath target)]\n    (with-sh-dir target\n      (println+ \"Compiling\" id)\n      (sh+ \"rm\" \"-Rf\" id)\n      (sh+ \"mkdir\" id)\n      (with-sh-dir (File. (str \"target/\" id))\n        (doall (pmap (partial clang id params sdk tcn) \n                     (find-files \"target/objc\" \"m\")))\n        (spit (str tcn \"/\" id \"/files.LinkFileList\") (reduce str (interpose \"\\n\" (find-files (str tcn \"/\" id) \"o\"))))\n        (sh+ \"libtool\" \"-static\" \"-syslibroot\" sdk \"-filelist\" \n             \"files.LinkFileList\" frameworks \"-o\" \"libclojure-objc.a\")))))\n\n(sh+ \"mvn\" \"compile\" \"test-compile\")\n(sh+ \"rm\" \"-Rf\" \"target/objc\")\n(sh+ \"mkdir\" \"target/objc\")\n(sh+ \"cp\" \"-R\" \"src/objc/.\" \"target/objc\")\n(sh+ \"cp\" \"-R\" \"src/ffi/.\" \"target/objc\")\n(sh+ \"zip\" \"-r\" \"target/objc.jar\" \"target/gen\" \"src/jvm\" \"test/java\")\n(sh+ (str j2objc-home \"/j2objc\") \"-d\" \"target/objc\" \"--final-methods-as-functions\" \"--batch-translate-max=500\" \"-J-Xmx2G\" \"-classpath\" \n     \"target/classes:target/test-classes\" \n     \"target/objc.jar\")\n\n(let [i (File. \"target/include\")]\n  (when-not (.exists i)\n    (.mkdirs i)))\n\n(with-sh-dir (File. \"target/objc\")\n  (sh \"rsync\" \"-avm\" \"--delete\" \"--include\" \"*.h\" \"-f\" \n       \"hide,! */\" \".\" \"../include\"))\n\n(build \"iphoneos\" \"-arch armv7 -arch armv7s -arch arm64\" iphone-os-sdk)\n(build \"iphonesimulator\" \"-arch i386 -arch x86_64\" iphone-simulator-sdk)\n\n(let [a (File. \"target/libclojure-objc.a\")]\n  (when (.exists a)\n    (.delete a))\n  (sh+ \"lipo\" \"-create\" \"-output\" \"target/libclojure-objc.a\" \"target/iphoneos/libclojure-objc.a\" \"target/iphonesimulator/libclojure-objc.a\"))"
  },
  {
    "path": "build.xml",
    "content": "<project name=\"clojure\" default=\"all\">\n\n\t<description>\n    Build with \"ant\" and then start the\n    REPL with: \"java -cp clojure.jar clojure.main\".\n  </description>\n\n  <property name=\"src\" location=\"src\"/>\n  <property name=\"test\" location=\"test\"/>\n  <property name=\"jsrc\" location=\"${src}/jvm\"/>\n  <property name=\"jtestsrc\" location=\"${test}/java\"/>\n  <property name=\"cljsrc\" location=\"${src}/clj\"/>\n  <property name=\"cljscript\" location=\"${src}/script\"/>\n  <property name=\"test-script\" location=\"${cljscript}/run_test.clj\"/>\n  <property name=\"test-generative-script\" location=\"${cljscript}/run_test_generative.clj\"/>\n  <property name=\"compile-script\" location=\"${cljscript}/bootstrap_compile.clj\"/>\n  <property name=\"target\" location=\"target\"/>\n  <property name=\"build\" location=\"${target}/classes\"/>\n  <property name=\"test-classes\" location=\"${target}/test-classes\"/>\n  <property name=\"dist\" location=\"dist\"/>\n  <property file=\"maven-classpath.properties\"/>\n\n  <!-- Get the version string out of the POM -->\n  <xmlproperty file=\"pom.xml\" prefix=\"pom\"/>\n  <property name=\"clojure.version.label\" value=\"${pom.project.version}\"/>\n  <property name=\"version.properties\" value=\"${build}/clojure/version.properties\"/>\n\n  <property name=\"clojure_jar\" location=\"clojure-${clojure.version.label}.jar\"/>\n  <property name=\"clojure_noversion_jar\" location=\"clojure.jar\"/>\n\n  <target name=\"init\" depends=\"clean\">\n    <tstamp/>\n    <mkdir dir=\"${build}\"/>\n    <mkdir dir=\"${build}/clojure\"/>\n    <echo file=\"${version.properties}\">version=${clojure.version.label}</echo>\n  </target>\n\n  <target name=\"compile-java\" depends=\"init\"\n          description=\"Compile Java sources.\">\n    <javac srcdir=\"${jsrc}\" destdir=\"${build}\" includeJavaRuntime=\"yes\"\n           includeAntRuntime=\"false\"\n           debug=\"true\" source=\"1.6\" target=\"1.6\"/>\n  </target>\n\n  <target name=\"compile-clojure\"\n          description=\"Compile Clojure sources.\">\n    <java classname=\"clojure.lang.Compile\"\n          classpath=\"${maven.compile.classpath}:${build}:${cljsrc}\"\n          failonerror=\"true\"\n          fork=\"true\">\n      <sysproperty key=\"clojure.compile.path\" value=\"${build}\"/>\n      <!-- <sysproperty key=\"clojure.compiler.elide-meta\" value=\"[]\"/>-->\n      <!-- <sysproperty key=\"clojure.compiler.disable-locals-clearing\" value=\"true\"/>-->\n      <!-- <sysproperty key=\"clojure.compile.warn-on-reflection\" value=\"true\"/> -->\n      <sysproperty key=\"java.awt.headless\" value=\"true\"/>\n      <arg value=\"clojure.core\"/>\n      <arg value=\"clojure.core.protocols\"/>\n      <arg value=\"clojure.set\"/>\n      <arg value=\"clojure.edn\"/>\n    \t<arg value=\"clojure.string\"/>\n    \t<arg value=\"clojure.data\"/>\n    \t<arg value=\"clojure.remoterepl\" />\n    \t<arg value=\"clojure.pprint\"/>\n    \t<arg value=\"clojure.java.io\"/>\n    \t<arg value=\"clojure.walk\"/>\n    \t<arg value=\"clojure.zip\"/>\n    \t<arg value=\"clojure.xml\"/>\n    \t<arg value=\"clojure.template\"/>\n    \t<arg value=\"clojure.test\"/>\n    \t<arg value=\"clojure.test.tap\"/>\n    \t<!--arg value=\"clojure.stacktrace\"/>\n    \t<arg value=\"clojure.reflect\" /-->\n    </java>\n  </target>\n\n  <target name=\"compile-tests\" \n          description=\"Compile the subset of tests that require compilation.\"\n          unless=\"maven.test.skip\">\n    <mkdir dir=\"${test-classes}\"/>\n    <javac srcdir=\"${jtestsrc}\" destdir=\"${test-classes}\" includeJavaRuntime=\"yes\"\n           debug=\"true\" source=\"1.6\" target=\"1.6\" includeantruntime=\"no\"/>\n    <java classname=\"clojure.lang.Compile\"\n          classpath=\"${maven.compile.classpath}:${maven.test.classpath}:${test-classes}:${test}:${build}:${cljsrc}\"\n          failonerror=\"true\"\n\t  fork=\"true\">\n      <sysproperty key=\"clojure.compile.path\" value=\"${test-classes}\"/>\n        <!--<sysproperty key=\"clojure.compiler.elide-meta\" value=\"[:doc]\"/>-->\n        <!--<sysproperty key=\"clojure.compiler.disable-locals-clearing\" value=\"true\"/>-->\n      <arg value=\"clojure.test-clojure.protocols.examples\" />\n      <arg value=\"clojure.test-clojure.genclass.examples\" />\n    \t\n    \t<!--arg value=\"clojure.test-clojure.agents\" />\n    \t<arg value=\"clojure.test-clojure.annotations\" />\n    \t<arg value=\"clojure.test-clojure.api\" />\n    \t<arg value=\"clojure.test-clojure.atoms\" />\n    \t<arg value=\"clojure.test-clojure.clojure-set\" />\n    \t<arg value=\"clojure.test-clojure.clojure-walk\" />\n    \t<arg value=\"clojure.test-clojure.clojure-xml\" />\n    \t<arg value=\"clojure.test-clojure.clojure-zip\" />\n    \t<arg value=\"clojure.test-clojure.control\" />\n    \t<arg value=\"clojure.test-clojure.data\" />\n    \t<arg value=\"clojure.test-clojure.data-structures\" />\n    \t<arg value=\"clojure.test-clojure.delays\" />\n    \t<arg value=\"clojure.test-clojure.edn\" />\n    \t<arg value=\"clojure.test-clojure.errors\" />\n    \t<arg value=\"clojure.test-clojure.fn\" />\n    \t<arg value=\"clojure.test-clojure.for\" />\n    \t<arg value=\"clojure.test-clojure.generators\" />\n    \t<arg value=\"clojure.test-clojure.keywords\" />\n    \t<arg value=\"clojure.test-clojure.logic\" />\n    \t<arg value=\"clojure.test-clojure.macros\" />\n    \t<arg value=\"clojure.test-clojure.multimethods\" />\n    \t<arg value=\"clojure.test-clojure.other-functions\" />\n    \t<arg value=\"clojure.test-clojure.parallel\" />\n    \t<arg value=\"clojure.test-clojure.printer\" />\n    \t<arg value=\"clojure.test-clojure.reader\" />\n    \t<arg value=\"clojure.test-clojure.refs\" />\n    \t<arg value=\"clojure.test-clojure.sequences\" />\n    \t<arg value=\"clojure.test-clojure.special\" />\n    \t<arg value=\"clojure.test-clojure.string\" />\n    \t<arg value=\"clojure.test-clojure.test\" />\n    \t<arg value=\"clojure.test-clojure.test-fixtures\" />\n    \t<arg value=\"clojure.test-clojure.transducers\" />\n    \t<arg value=\"clojure.test-clojure.transients\" />\n    \t<arg value=\"clojure.test-clojure.try-catch\" />\n    \t<arg value=\"clojure.test-clojure.vectors\" />\n    \t<arg value=\"clojure.test-clojure.volatiles\" />\n    \t<arg value=\"clojure.test-helper\" /-->\n    </java>\n  </target>\n\n  <target name=\"test-example\"\n          description=\"Run clojure tests without recompiling clojure.\"\n          depends=\"compile-tests\"\n          unless=\"maven.test.skip\">\n    <java classname=\"clojure.main\" failonerror=\"true\" fork=\"true\">\n      <classpath>\n        <pathelement path=\"${maven.test.classpath}\"/>\n        <path location=\"${test-classes}\"/>\n        <path location=\"${test}\"/>\n        <path location=\"${build}\"/>\n\t<path location=\"${cljsrc}\"/>\n      </classpath>\n      <arg value=\"${test-script}\"/>\n    </java>\n  </target>\n\n  <target name=\"test-generative\"\n          description=\"Run test generative tests without recompiling clojure.\"\n          depends=\"compile-tests\"\n          unless=\"maven.test.skip\">\n    <java classname=\"clojure.main\" failonerror=\"true\" fork=\"true\">\n      <classpath>\n        <pathelement path=\"${maven.test.classpath}\"/>\n        <path location=\"${test-classes}\"/>\n        <path location=\"${test}\"/>\n        <path location=\"${build}\"/>\n\t<path location=\"${cljsrc}\"/>\n      </classpath>\n      <arg value=\"${test-generative-script}\"/>\n    </java>\n  </target>\n\n  <target name=\"test\"\n          description=\"Run all the tests\"\n          depends=\"test-example,test-generative\"/>\n\n  <target name=\"build\"\n          description=\"Build Clojure (compilation only, no tests).\"\n          depends=\"compile-java, compile-clojure\"/>\n\n  <target name=\"jar\" depends=\"build\"\n          description=\"Create clojure jar file.\">\n    <jar jarfile=\"${clojure_jar}\" basedir=\"${build}\">\n      <fileset dir=\"${cljsrc}\">\n        <include name=\"**/*.clj\"/>\n      </fileset>\n      <manifest>\n        <attribute name=\"Main-Class\" value=\"clojure.main\"/>\n        <attribute name=\"Class-Path\" value=\".\"/>\n      </manifest>\n    </jar>\n    <copy file=\"${clojure_jar}\" tofile=\"${clojure_noversion_jar}\"/>\n  </target>\n\n  <target name=\"javadoc\"\n\t  description=\"Creates javadoc for Clojure API.\">\n    <copy file=\"src/jvm/clojure/lang/IFn.java\" tofile=\"target/tmpjd/IFn.java\"/>\n    <copy file=\"src/jvm/clojure/lang/package.html\" tofile=\"target/tmpjd/package.html\"/>\n    <replaceregexp file=\"target/tmpjd/IFn.java\" match=\"(static public interface .*})\" replace=\"\" byline=\"true\"/>\n    <javadoc destdir=\"target/javadoc\"\n\t    nodeprecatedlist=\"true\" nohelp=\"true\" nonavbar=\"true\" notree=\"true\"\n\t    link=\"http://docs.oracle.com/javase/7/docs/api/\"\n\t    windowtitle=\"Clojure API\">\n      <classpath>\n        <path location=\"${build}\"/>\n      </classpath>\n      <fileset dir=\"${basedir}\">\n\t<include name=\"src/jvm/clojure/java/api/Clojure.java\"/>\n\t<include name=\"target/tmpjd/IFn.java\"/>\n      </fileset>\n    </javadoc>\n  </target>\n\n  <target name=\"all\" depends=\"build,test,jar\"/>\n\n  <target name=\"clean\"\n          description=\"Remove autogenerated files and directories.\">\n    <delete dir=\"${target}\"/>\n    <delete verbose=\"true\">\n      <fileset dir=\"${basedir}\" includes=\"*.jar\"/>\n      <fileset dir=\"${basedir}\" includes=\"*.zip\"/>\n    </delete>\n  </target>\n\n</project>\n"
  },
  {
    "path": "changes.md",
    "content": "<!-- -*- mode: markdown ; mode: visual-line ; coding: utf-8 -*- -->\n\n# Changes to Clojure in Version 1.7\n\n## 1 Compatibility Notes\n\nPlease be aware of the following issues when upgrading to Clojure 1.7.\n\n### Seqs on Java iterators that return the same mutating object\n\nSeqs are fundamentally incompatible with Java iterators that return\nthe same mutating object on every call to next().  Some Clojure\nlibraries incorrectly rely on calling seq on such iterators.\n\nIn 1.7, iterator-seqs are chunked, which will cause many of these\nincorrect usages to return incorrect results immediately.\n\nThe `seq` and `iterator-seq` docstrings have been updated to include\nan explicit warning. Libraries that incorrectly use `seq` and\n`iterator-seq` will need to be fixed before running against 1.7.\n\n* [CLJ-1669](http://dev.clojure.org/jira/browse/CLJ-1669)\n* [CLJ-1738](http://dev.clojure.org/jira/browse/CLJ-1738)\n\n### Thread owner check removed on transients\n\nPrior to Clojure 1.7, transients would allow modification only from the\nthread that created the transient. This check has been removed. It is\nstill a requirement that transients should be updated by only a single\nthread at a time.\n\nThis constraint was relaxed to allow transients to be used in cases where\ncode is multiplexed across multiple threads in a pool (such as go blocks\nin core.async).\n\n### keys/vals require custom map type to implement Iterable\n\nInvoking `keys` or `vals` on a custom map type that implements IPersistentMap\nwill now use the Iterable iterator() method instead of accessing entries\nvia the seq of the map. There have been no changes in the type hierarchy\n(IPersistentMap has always extended Iterable) but former map-like instances\nmay have skipped implementing this method in the past.\n\n* [CLJ-1602](http://dev.clojure.org/jira/browse/CLJ-1602)\n\n## 2 New and Improved Features\n\n### 2.1 Transducers\n\nTransducers is a new way to decouple algorithmic transformations from their\napplication in different contexts. Transducers are functions that transform\nreducing functions to build up a \"recipe\" for transformation.\n\nAlso see: http://clojure.org/transducers\n\nMany existing sequence functions now have a new arity (one fewer argument\nthan before). This arity will return a transducer that represents the same\nlogic but is independent of lazy sequence processing. Functions included are:\n\n* map\n* mapcat\n* filter\n* remove\n* take\n* take-while\n* drop\n* drop-while\n* take-nth\n* replace\n* partition-by\n* partition-all\n* keep\n* keep-indexed\n* map-indexed\n* distinct\n* interpose\n\nAdditionally some new transducer functions have been added:\n\n* cat - concatenates the contents of each input\n* dedupe - removes consecutive duplicated values\n* random-sample - returns items from coll with random probability\n\nAnd this function can be used to make completing transforms:\n\n* completing\n\nThere are also several new or modified functions that can be used to apply\ntransducers in different ways:\n\n* sequence - takes a transformation and a coll and produces a lazy seq\n* transduce - reduce with a transformation (eager)\n* eduction - returns a reducible/iterable of applications of the transducer to items in coll. Applications are re-performed with every reduce/iterator.\n\nThere have been a number of internal changes to support transducers:\n\n* volatiles - there are a new set of functions (volatile!, vswap!, vreset!, volatile?) to create and use volatile \"boxes\" to hold state in stateful transducers. Volatiles are faster than atoms but give up atomicity guarantees so should only be used with thread isolation.\n* array iterators - added support for iterators over arrays\n* conj can be used as a reducing function and will conj to []\n\nSome related issues addressed during development:\n* [CLJ-1511](http://dev.clojure.org/jira/browse/CLJ-1511)\n* [CLJ-1497](http://dev.clojure.org/jira/browse/CLJ-1497)\n* [CLJ-1549](http://dev.clojure.org/jira/browse/CLJ-1549)\n* [CLJ-1537](http://dev.clojure.org/jira/browse/CLJ-1537)\n* [CLJ-1554](http://dev.clojure.org/jira/browse/CLJ-1554)\n* [CLJ-1601](http://dev.clojure.org/jira/browse/CLJ-1601)\n* [CLJ-1606](http://dev.clojure.org/jira/browse/CLJ-1606)\n* [CLJ-1621](http://dev.clojure.org/jira/browse/CLJ-1621)\n* [CLJ-1600](http://dev.clojure.org/jira/browse/CLJ-1600)\n* [CLJ-1635](http://dev.clojure.org/jira/browse/CLJ-1635)\n* [CLJ-1683](http://dev.clojure.org/jira/browse/CLJ-1683)\n* [CLJ-1669](http://dev.clojure.org/jira/browse/CLJ-1669)\n* [CLJ-1723](http://dev.clojure.org/jira/browse/CLJ-1723)\n\n### 2.2 Reader Conditionals\n\nReader Conditionals are a new capability to support portable code that\ncan run on multiple Clojure platforms with only small changes. In\nparticular, this feature aims to support the increasingly common case\nof libraries targeting both Clojure and ClojureScript.\n\nCode intended to be common across multiple platforms should use a new\nsupported file extension: \".cljc\". When requested to load a namespace,\nthe platform-specific file extension (.clj, .cljs) will be checked\nprior to .cljc.\n\nA new reader form can be used to specify \"reader conditional\" code in\ncljc files (and *only* cljc files). Each platform defines a feature\nidentifying the platform (:clj, :cljs, :cljr). The reader conditional\nspecifies code that is read conditionally based on the feature. The\nREPL also allows reader conditionals.\n\nForm #? takes a list of alternating feature and expression. These are\nchecked like cond and the selected expression is read and returned. Other\nbranches are read but skipped. If no branch is selected, the reader reads\nnothing (not nil, but literally as if reading no form). An optional\n`:default` branch can be used as a fallthrough.\n\nReader conditional with 2 features and a default:\n\n\t#?(:clj     Double/NaN\n\t   :cljs    js/NaN\n\t   :default nil)\n\nThere is also a reader conditional splicing form. The evaluated expression\nshould be sequential and will be spliced into the surrounded code, similar\nto unquote-splicing.\n\nFor example:\n\n   [1 2 #?@(:clj [3 4] :cljs [5 6])]\n\nThis form would read as [1 2 3 4] on Clojure, [1 2 5 6] on ClojureScript,\nand [1 2] on any other platform. Splicing is not allowed at the top level.\n\nAdditionally, the reader can now be invoked with options for the features\nto use and how to interpret reader conditionals. By default, reader conditionals\nare not allowed, but that can be turned on, or a \"preserve\" mode can be used to\npreserve all branches (most likely useful for tooling or source transforms).\n\nIn the preserve mode, the reader conditional itself and any tagged literals\nwithin the unselected branches are returned as tagged literal data.\n\nFor more information, see:\nhttp://dev.clojure.org/display/design/Reader+Conditionals\n\n* [CLJ-1424](http://dev.clojure.org/jira/browse/CLJ-1424)\n* [CLJ-1685](http://dev.clojure.org/jira/browse/CLJ-1685)\n* [CLJ-1698](http://dev.clojure.org/jira/browse/CLJ-1698)\n* [CLJ-1699](http://dev.clojure.org/jira/browse/CLJ-1699)\n* [CLJ-1700](http://dev.clojure.org/jira/browse/CLJ-1700)\n* [CLJ-1728](http://dev.clojure.org/jira/browse/CLJ-1728)\n* [CLJ-1706](http://dev.clojure.org/jira/browse/CLJ-1706)\n\n### 2.3 Keyword and Symbol Construction\n\nIn response to issues raised in [CLJ-1439](http://dev.clojure.org/jira/browse/CLJ-1439),\nseveral changes have been made in symbol and keyword construction:\n\n1) The main bottleneck in construction of symbols (which also occurs inside keywords) was\ninterning of the name and namespace strings. This interning has been removed, resulting\nin a performance increase.\n\n2) Keywords are cached and keyword construction includes a cache check. A change was made\nto only clear the cache reference queue when there is a cache miss.\n\n### 2.4 Warn on Boxed Math\n\nOne source of performance issues is the (unintended) use of arithmetic operations on\nboxed numbers. To make detecting the presence of boxed math easier, a warning will now\nbe emitted about boxed math if \\*unchecked-math* is set to :warn-on-boxed (any truthy\nvalue will enable unchecked-math, only this specific value enables the warning).\n\nExample use:\n\n    user> (defn plus-2 [x] (+ x 2))  ;; no warning, but boxed\n\t#'user/plus-2\n    user> (set! *unchecked-math* :warn-on-boxed)\n\ttrue\n    user> (defn plus-2 [x] (+ x 2)) ;; now we see a warning\n    Boxed math warning, NO_SOURCE_PATH:10:18 - call: public static java.lang.Number\n\tclojure.lang.Numbers.unchecked_add(java.lang.Object,long).\n    #'user/plus-2\n\tuser> (defn plus-2 [^long x] (+ x 2)) ;; use a hint to avoid boxing\n\t#'user/plus-2\n\n* [CLJ-1325](http://dev.clojure.org/jira/browse/CLJ-1325)\n* [CLJ-1535](http://dev.clojure.org/jira/browse/CLJ-1535)\n* [CLJ-1642](http://dev.clojure.org/jira/browse/CLJ-1642)\n\n### 2.5 update - like update-in for first level\n\n`update` is a new function that is like update-in specifically for first-level keys:\n\n    (update m k f args...)\n\nExample use:\n\n    user> (update {:a 1} :a inc)\n\t{:a 2}\n\tuser> (update {:a 1} :a + 2)\n\t{:a 3}\n\tuser> (update {} :a identity)  ;; missing returns nil\n\t{:a nil}\n\n* [CLJ-1251](http://dev.clojure.org/jira/browse/CLJ-1251)\n\n### 2.6 Faster reduce and iterator paths\n\nSeveral important Clojure functions now return sequences that also\ncontain fast reduce() (or in some cases iterator()) paths. In many\ncases, the new implementations are also faster for lazy sequences\n\n* repeat - now implements IReduce\n* cycle - implements IReduceInit\n* iterate - implements IReduceInit\n* range - implements IReduce, specialized case handles common case of all longs\n* keys - iterates directly over the keys of a map, without seq or MapEntry allocation\n* vals - iterates directly over the vals of a map, without seq or MapEntry allocation\n* iterator-seq - creates a chunked sequence when previously it was unchunked\n\nAdditionally, hash-maps and hash-sets now provide iterators that walk\nthe data structure directly rather than via a sequence.\n\nA new interface (IMapIterable) for direct key and val iterators on maps\nwas added. External data structures can use this interface to provide\ndirect key and val iterators via keys and vals.\n\nThese enhancements are particularly effective when used\nin tandem with transducers via transduce, sequence, into, and\neduction.\n\n* [CLJ-1603](http://dev.clojure.org/jira/browse/CLJ-1603)\n* [CLJ-1515](http://dev.clojure.org/jira/browse/CLJ-1515)\n* [CLJ-1602](http://dev.clojure.org/jira/browse/CLJ-1602)\n* [CLJ-1669](http://dev.clojure.org/jira/browse/CLJ-1669)\n* [CLJ-1692](http://dev.clojure.org/jira/browse/CLJ-1692)\n* [CLJ-1694](http://dev.clojure.org/jira/browse/CLJ-1694)\n* [CLJ-1711](http://dev.clojure.org/jira/browse/CLJ-1711)\n* [CLJ-1709](http://dev.clojure.org/jira/browse/CLJ-1709)\n* [CLJ-1713](http://dev.clojure.org/jira/browse/CLJ-1713)\n* [CLJ-1726](http://dev.clojure.org/jira/browse/CLJ-1726)\n* [CLJ-1727](http://dev.clojure.org/jira/browse/CLJ-1727)\n\n### 2.7 Printing as data\n\nThere have been enhancements in how the REPL prints values without a\nprint-method, specifically Throwable and the fallthrough Object case.\nBoth cases now print in a tagged literal data form that can be read\nby the reader.\n\nUnhandled objects print with the class, hash code, and toString:\n\n\tuser=> *ns*\n\t#object[clojure.lang.Namespace 0x55aa628 \"user\"]\n\nThrown exceptions will still be printed in the normal way by the default\nREPL but printing them to a stream will show a different form:\n\n\tuser=> (/ 1 0)\n\tArithmeticException Divide by zero  clojure.lang.Numbers.divide (Numbers.java:158)\n\tuser=> (println *e)\n\t#error {\n\t :cause Divide by zero\n\t :via\n\t [{:type java.lang.ArithmeticException\n\t   :message Divide by zero\n\t   :at [clojure.lang.Numbers divide Numbers.java 158]}]\n\t :trace\n\t [[clojure.lang.Numbers divide Numbers.java 158]\n\t  [clojure.lang.Numbers divide Numbers.java 3808]\n\t  ;; ... elided frames\n\t  ]}\n\nAdditionally, there is a new function available to obtain a Throwable as \nmap data: `Throwable->map`.\n\n* [CLJ-1703](http://dev.clojure.org/jira/browse/CLJ-1703)\n* [CLJ-1716](http://dev.clojure.org/jira/browse/CLJ-1716)\n* [CLJ-1735](http://dev.clojure.org/jira/browse/CLJ-1735)\n\n### 2.8 run!\n\nrun! is a new function that takes a side effect reducing function and runs\nit for all items in a collection via reduce. The accumulator is ignored and\nnil is returned.\n\n    (run! println (range 10))\n\n## 3 Enhancements\n\n### 3.1 Error messages\n\n* [CLJ-1261](http://dev.clojure.org/jira/browse/CLJ-1261)\n  Invalid defrecord results in exception attributed to consuming ns instead of defrecord ns\n* [CLJ-1297](http://dev.clojure.org/jira/browse/CLJ-1297)\n  Give more specific hint if namespace with \"-\" not found to check file uses \"_\"\n\n### 3.2 Documentation strings\n\n* [CLJ-1417](http://dev.clojure.org/jira/browse/CLJ-1417)\n  clojure.java.io/input-stream has incorrect docstring\n* [CLJ-1357](http://dev.clojure.org/jira/browse/CLJ-1357)\n  Fix typo in gen-class doc-string\n* [CLJ-1479](http://dev.clojure.org/jira/browse/CLJ-1479)\n  Fix typo in filterv example\n* [CLJ-1480](http://dev.clojure.org/jira/browse/CLJ-1480)\n  Fix typo in defmulti docstring\n* [CLJ-1477](http://dev.clojure.org/jira/browse/CLJ-1477)\n  Fix typo in deftype docstring\n* [CLJ-1478](http://dev.clojure.org/jira/browse/CLJ-1378)\n  Fix typo in clojure.main usage\n* [CLJ-1738](http://dev.clojure.org/jira/browse/CLJ-1738)\n  Clarify usage on Java iterators in seq and iterator-seq\n\n### 3.3 Performance\n\n* [CLJ-1430](http://dev.clojure.org/jira/browse/CLJ-1430)\n  Improve performance of partial with more unrolling\n* [CLJ-1384](http://dev.clojure.org/jira/browse/CLJ-1384)\n  clojure.core/set should use transients for better performance\n* [CLJ-1429](http://dev.clojure.org/jira/browse/CLJ-1429)\n  Cache unknown multimethod value default dispatch\n* [CLJ-1529](http://dev.clojure.org/jira/browse/CLJ-1529)\n  Reduce compile times by avoiding unnecessary calls to Class.forName()\n* [CLJ-1546](http://dev.clojure.org/jira/browse/CLJ-1546)\n  vec is now faster on almost all inputs\n* [CLJ-1618](http://dev.clojure.org/jira/browse/CLJ-1618)\n  set is now faster on almost all inputs\n* [CLJ-1695](http://dev.clojure.org/jira/browse/CLJ-1695)\n  Fixed reflection call in variadic vector-of constructor\n\n### 3.4 Other enhancements\n\n* [CLJ-1191](http://dev.clojure.org/jira/browse/CLJ-1191)\n  Improve apropos to show some indication of namespace of symbols found\n* [CLJ-1378](http://dev.clojure.org/jira/browse/CLJ-1378)\n  Hints don't work with #() form of function\n* [CLJ-1498](http://dev.clojure.org/jira/browse/CLJ-1498)\n  Removes owner-thread check from transients - this check was preventing some valid usage of transients in core.async where a transient is created on one thread and then used again in another pooled thread (while still maintaining thread isolation).\n* [CLJ-803](http://dev.clojure.org/jira/browse/CLJ-803)\n  Extracted IAtom interface implemented by Atom.\n* [CLJ-1315](http://dev.clojure.org/jira/browse/CLJ-1315)\n  Don't initialize classes when importing them\n* [CLJ-1330](http://dev.clojure.org/jira/browse/CLJ-1330)\n  Class name clash between top-level functions and defn'ed ones\n* [CLJ-1349](http://dev.clojure.org/jira/browse/CLJ-1349)\n  Update to latest test.generative and add dependency on test.check\n* [CLJ-1546](http://dev.clojure.org/jira/browse/CLJ-1546)\n  vec now works with things that only implement Iterable or IReduceInit\n* [CLJ-1618](http://dev.clojure.org/jira/browse/CLJ-1618)\n  set now works with things that only implement Iterable or IReduceInit\n* [CLJ-1633](http://dev.clojure.org/jira/browse/CLJ-1633)\n  PersistentList/creator doesn't handle ArraySeqs correctly\n* [CLJ-1589](http://dev.clojure.org/jira/browse/CLJ-1589)\n  Clean up unused paths in InternalReduce\n* [CLJ-1677](http://dev.clojure.org/jira/browse/CLJ-1677)\n  Add setLineNumber() to LineNumberingPushbackReader\n* [CLJ-1667](http://dev.clojure.org/jira/browse/CLJ-1667)\n  Change test to avoid using hard-coded socket port\n* [CLJ-1683](http://dev.clojure.org/jira/browse/CLJ-1683)\n  Change reduce tests to better catch reduce without init bugs\n\n## 4 Bug Fixes\n\n* [CLJ-1362](http://dev.clojure.org/jira/browse/CLJ-1362)\n  Reduce broken on some primitive vectors\n* [CLJ-1388](http://dev.clojure.org/jira/browse/CLJ-1388)\n  Equality bug on records created with nested calls to map->record\n* [CLJ-1274](http://dev.clojure.org/jira/browse/CLJ-1274)\n  Unable to set compiler options via system properties except for AOT compilation\n* [CLJ-1241](http://dev.clojure.org/jira/browse/CLJ-1241)\n  NPE when AOTing overrided clojure.core functions\n* [CLJ-1185](http://dev.clojure.org/jira/browse/CLJ-1185)\n  reductions does not check for reduced value\n* [CLJ-1039](http://dev.clojure.org/jira/browse/CLJ-1039)\n  Using def with metadata {:type :anything} throws ClassCastException during printing\n* [CLJ-887](http://dev.clojure.org/jira/browse/CLJ-887)\n  Error when calling primitive functions with destructuring in the arg vector\n* [CLJ-823](http://dev.clojure.org/jira/browse/CLJ-823)\n  Piping seque into seque can deadlock\n* [CLJ-738](http://dev.clojure.org/jira/browse/CLJ-738)\n  <= is incorrect when args include Double/NaN\n* [CLJ-1408](http://dev.clojure.org/jira/browse/CLJ-1408)\n  Make cached string value of Keyword and Symbol transient\n* [CLJ-1466](http://dev.clojure.org/jira/browse/CLJ-1466)\n  clojure.core/bean should implement Iterable\n* [CLJ-1578](http://dev.clojure.org/jira/browse/CLJ-1578)\n  Make refer of Clojure core function not throw exception on reload\n* [CLJ-1501](http://dev.clojure.org/jira/browse/CLJ-1501)\n  LazySeq equals() should not use equiv() logic\n* [CLJ-1572](http://dev.clojure.org/jira/browse/CLJ-1572)\n  into (and other fns that rely on reduce) require only IReduceInit\n* [CLJ-1619](http://dev.clojure.org/jira/browse/CLJ-1619)\n  PersistentVector now directly implements reduce without init\n* [CLJ-1580](http://dev.clojure.org/jira/browse/CLJ-1580)\n  Transient collections should guarantee thread visibility\n* [CLJ-1590](http://dev.clojure.org/jira/browse/CLJ-1590)\n  Some IReduce/IReduceInit implementors don't respect reduced\n* [CLJ-979](http://dev.clojure.org/jira/browse/CLJ-979)\n  Clojure resolves to wrong deftype classes when AOT compiling or reloading\n* [CLJ-1636](http://dev.clojure.org/jira/browse/CLJ-1636)\n  Fix intermittent SeqIterator problem by removing use of this as a sentinel\n* [CLJ-1637](http://dev.clojure.org/jira/browse/CLJ-1636)\n  Fix regression from CLJ-1546 that broke vec on MapEntry\n* [CLJ-1663](http://dev.clojure.org/jira/browse/CLJ-1663)\n  Fix regression from CLJ-979 for DynamicClassLoader classloader delegation\n* [CLJ-1604](http://dev.clojure.org/jira/browse/CLJ-1604)\n  Fix error from AOT'ed code defining a var with a clojure.core symbol name\n* [CLJ-1561](http://dev.clojure.org/jira/browse/CLJ-1561)\n  Fix incorrect line number reporting for error locations\n* [CLJ-1568](http://dev.clojure.org/jira/browse/CLJ-1568)\n  Fix incorrect line number reporting for error locations\n* [CLJ-1638](http://dev.clojure.org/jira/browse/CLJ-1638)\n  Fix regression from CLJ-1546 removed PersistentVector.create(List) method\n* [CLJ-1681](http://dev.clojure.org/jira/browse/CLJ-1681)\n  Fix regression from CLJ-1248 (1.6) in reflection warning with literal nil argument\n* [CLJ-1648](http://dev.clojure.org/jira/browse/CLJ-1648)\n  Use equals() instead of == when resolving Symbol\n* [CLJ-1195](http://dev.clojure.org/jira/browse/CLJ-1195)\n  emit-hinted-impl expands to ns-qualified invocation of fn\n* [CLJ-1237](http://dev.clojure.org/jira/browse/CLJ-1237)\n  reduce of sequence that switches between chunked and unchunked many times throws StackOverflow\n\n# Changes to Clojure in Version 1.6\n\n## CONTENTS\n\n## 1 Compatibility and Dependencies\n\n## 1.1 JDK Version Update\n\nClojure now builds with Java SE 1.6 and emits bytecode requiring Java\nSE 1.6 instead of Java SE 1.5. [CLJ-1268]\n\n## 1.2 ASM Library Update\n\nThe embedded version of the ASM bytecode library has been upgraded to\nASM 4.1. [CLJ-713]\n\n## 1.3 Promoted \"Alpha\" Features\n\nThe following features are no longer marked Alpha in Clojure:\n\n* Watches - add-watch, remove-watch\n* Transients - transient, persistent!, conj!, assoc!, dissoc!, pop!, disj!\n* Exception data - ex-info, ex-data\n* Promises - promise, deliver\n* Records - defrecord\n* Types - deftype\n* Pretty-print tables - print-table\n\n## 2 New and Improved Features\n\n### 2.1 Java API\n\nThe clojure.java.api package provides a minimal interface to bootstrap\nClojure access from other JVM languages. It does this by providing:\n1. The ability to use Clojure's namespaces to locate an arbitrary var,\n   returning the var's clojure.lang.IFn interface.\n2. A convenience method read for reading data using Clojure's edn\n   reader.\n\nIFns provide complete access to Clojure's APIs. You can also access\nany other library written in Clojure, after adding either its source\nor compiled form to the classpath.\n\nThe public Java API for Clojure consists of the following classes and interfaces:\n\n* clojure.java.api.Clojure\n* clojure.lang.IFn\n\nAll other Java classes should be treated as implementation details,\nand applications should avoid relying on them.\n\nTo look up and call a Clojure function:\n\n    IFn plus = Clojure.var(\"clojure.core\", \"+\");\n    plus.invoke(1, 2);\n\nFunctions in clojure.core are automatically loaded. Other namespaces\ncan be loaded via require:\n\n    IFn require = Clojure.var(\"clojure.core\", \"require\");\n    require.invoke(Clojure.read(\"clojure.set\"));\n   \nIFns can be passed to higher order functions, e.g. the example below\npasses plus to read:\n\n    IFn map = Clojure.var(\"clojure.core\", \"map\");\n    IFn inc = Clojure.var(\"clojure.core\", \"inc\");\n    map.invoke(inc, Clojure.read(\"[1 2 3]\"));\n\nMost IFns in Clojure refer to functions. A few, however, refer to\nnon-function data values. To access these, use deref instead of fn:\n\n    IFn printLength = Clojure.var(\"clojure.core\", \"*print-length*\");\n    Clojure.var(\"clojure.core\", \"deref\").invoke(printLength);\n\n### 2.2 Map destructuring extended to support namespaced keys\n\n* [CLJ-1318](http://dev.clojure.org/jira/browse/CLJ-1318)\n\nIn the past, map destructuring with :keys and :syms would not work\nwith maps containing namespaced keys or symbols. The :keys and :syms\nforms have been updated to allow them to match namespaced keys and\nbind to a local variable based on the name.\n\nExamples:\n\n    (let [m {:x/a 1, :y/b 2}\n          {:keys [x/a y/b]} m]\n      (+ a b))\n\n    (let [m {'x/a 1, 'y/b 2}\n          {:syms [x/a y/b]} m]\n      (+ a b))\n\nAdditionally, the :keys form can now take keywords instead of symbols.\nThis provides support specifically for auto-resolved keywords:\n\n    (let [m {:x/a 1, :y/b 2}\n          {:keys [:x/a :y/b]} m]\n      (+ a b))\n\n    (let [m {::x 1}\n          {:keys [::x]} m]\n      x)\n\n### 2.3 New \"some\" operations\n\nMany conditional functions rely on logical truth (where \"falsey\"\nvalues are nil or false). Sometimes it is useful to have functions\nthat rely on \"not nilness\" instead. These functions have been added to\nsupport these cases [CLJ-1343]:\n\n* some? - same as (not (nil? x))\n* if-some - like if-let, but checks (some? test) instead of test\n* when-some - like when-let, but checks (some? test) instead of test\n\n### 2.4 Hashing\n\nClojure 1.6 provides new hashing algorithms for primitives and\ncollections, accessible via IHashEq/hasheq (in Java) or the\nclojure.core/hash function (in Clojure). In general, these changes\nshould be transparent to users, except hash codes used inside hashed\ncollections like maps and sets will have better properties.\n\nHash codes returned by the Java .hashCode() method are unchanged and\ncontinue to match Java behavior or conform to the Java specification\nas appropriate.\n\nAny collections implementing IHashEq or wishing to interoperate with\nClojure collections should conform to the hashing algorithms specified\nin http://clojure.org/data_structures#hash and use the new function\n`mix-collection-hash` for the final mixing operation. Alternatively,\nyou may call the helper functions `hash-ordered-coll` and\n`hash-unordered-coll`.\n\nAny details of the current hashing algorithm not specified on that\npage should be considered subject to future change.\n\nRelated tickets for dev and regressions:\n\n* [CLJ-1328](http://dev.clojure.org/jira/browse/CLJ-1328)\n  Make several Clojure tests independent of ordering\n* [CLJ-1331](http://dev.clojure.org/jira/browse/CLJ-1331)\n  Update primitive vectors to use Murmur3 hash\n* [CLJ-1335](http://dev.clojure.org/jira/browse/CLJ-1335)\n  Update hash for empty PersistentList and LazySeq\n* [CLJ-1336](http://dev.clojure.org/jira/browse/CLJ-1336)\n  Make hashing mixing functions available in Clojure\n* [CLJ-1338](http://dev.clojure.org/jira/browse/CLJ-1338)\n  Make Murmur3 class public\n* [CLJ-1344](http://dev.clojure.org/jira/browse/CLJ-1344)\n  Update mapHasheq to call Murmur3 algorithm\n* [CLJ-1348](http://dev.clojure.org/jira/browse/CLJ-1348)\n  Add hash-ordered-coll and hash-unordered-coll\n* [CLJ-1355](http://dev.clojure.org/jira/browse/CLJ-1355)\n  Restore cached hashCode for Symbol and (uncached) hashCode for Keyword\n* [CLJ-1365](http://dev.clojure.org/jira/browse/CLJ-1365)\n  Add type hints for new collection hash functions\n\n### 2.5 bitops\n\n* [CLJ-827](http://dev.clojure.org/jira/browse/CLJ-827) - unsigned-bit-shift-right\n\nA new unsigned-bit-shift-right (Java's >>>) has been added to the core\nlibrary. The shift distance is truncated to the least 6 bits (per the\nJava specification for long >>>).\n\nExamples:\n  (unsigned-bit-shift-right 2r100 1) ;; 2r010\n  (unsigned-bit-shift-right 2r100 2) ;; 2r001\n  (unsigned-bit-shift-right 2r100 3) ;; 2r000\n\n### 2.6 clojure.test\n\n* [CLJ-866](http://dev.clojure.org/jira/browse/CLJ-866) - test-vars\n* [CLJ-1352](http://dev.clojure.org/jira/browse/CLJ-1352) - fix\n  regression in CLJ-866\n\nAdded a new clojure.test/test-vars function that takes a list of vars, groups them by namespace, and\nruns them *with their fixtures*.\n\n## 3 Enhancements\n\n### 3.1 Printing\n\n* [CLJ-908](http://dev.clojure.org/jira/browse/CLJ-908)\n  Print metadata for functions when *print-meta* is true and remove errant space at beginning.\n* [CLJ-937](http://dev.clojure.org/jira/browse/CLJ-937)\n  pprint cl-format now supports E, F, and G formats for ratios.\n\n### 3.2 Error messages\n\n* [CLJ-1248](http://dev.clojure.org/jira/browse/CLJ-1248)\n  Include type information in reflection warning messages\n* [CLJ-1099](http://dev.clojure.org/jira/browse/CLJ-1099)\n  If non-seq passed where seq is needed, error message now is an\n  ExceptionInfo with the instance value, retrievable via ex-data.\n* [CLJ-1083](http://dev.clojure.org/jira/browse/CLJ-1083)\n  Fix error message reporting for \"munged\" function names (like a->b).\n* [CLJ-1056](http://dev.clojure.org/jira/browse/CLJ-1056)\n  Handle more cases and improve error message for errors in defprotocol definitions.\n* [CLJ-1102](http://dev.clojure.org/jira/browse/CLJ-1102)\n  Better handling of exceptions with empty stack traces.\n* [CLJ-939](http://dev.clojure.org/jira/browse/CLJ-939)\n  Exceptions thrown in the top level ns form are reported without file or line number.\n\n### 3.3 Documentation strings\n\n* [CLJ-1164](http://dev.clojure.org/jira/browse/CLJ-1164)\n  Fix typos in clojure.instant/validated and other internal instant functions.\n* [CLJ-1143](http://dev.clojure.org/jira/browse/CLJ-1143)\n  Correct doc string for ns macro.\n* [CLJ-196](http://dev.clojure.org/jira/browse/CLJ-196)\n  Clarify value of *file* is undefined in the REPL.\n* [CLJ-1228](http://dev.clojure.org/jira/browse/CLJ-1228)\n  Fix a number of spelling errors in namespace and doc strings.\n* [CLJ-835](http://dev.clojure.org/jira/browse/CLJ-835)\n  Update defmulti doc to clarify expectations for hierarchy argument.\n* [CLJ-1304](http://dev.clojure.org/jira/browse/CLJ-1304)\n  Fix minor typos in documentation and comments\n* [CLJ-1302](http://dev.clojure.org/jira/browse/CLJ-1302)\n  Mention that keys and vals order are consistent with seq order\n\n### 3.4 Performance\n\n* [CLJ-858](http://dev.clojure.org/jira/browse/CLJ-858)\n  Improve speed of STM by removing System.currentTimeMillis.\n* [CLJ-669](http://dev.clojure.org/jira/browse/CLJ-669)\n  clojure.java.io/do-copy: use java.nio for Files\n* [commit](https://github.com/clojure/clojure/commit/0b73494c3c855e54b1da591eeb687f24f608f346)\n  Reduce overhead of protocol callsites by removing unneeded generated\n  cache fields.\n\n### 3.5 Other enhancements\n\n* [CLJ-908](http://dev.clojure.org/jira/browse/CLJ-908)\n  Make *default-data-reader-fn* set!-able in REPL, similar to *data-readers*.\n* [CLJ-783](http://dev.clojure.org/jira/browse/CLJ-783)\n  Make clojure.inspector/inspect-tree work on sets.\n* [CLJ-896](http://dev.clojure.org/jira/browse/CLJ-896)\n  Make browse-url aware of xdg-open.\n* [CLJ-1160](http://dev.clojure.org/jira/browse/CLJ-1160)\n  Fix clojure.core.reducers/mapcat does not stop on reduced? values.\n* [CLJ-1121](http://dev.clojure.org/jira/browse/CLJ-1121)\n  -> and ->> have been rewritten to work with a broader set of macros.\n* [CLJ-1105](http://dev.clojure.org/jira/browse/CLJ-1105)\n  clojure.walk now supports records.\n* [CLJ-949](http://dev.clojure.org/jira/browse/CLJ-949)\n  Removed all unnecessary cases of sneakyThrow.\n* [CLJ-1238](http://dev.clojure.org/jira/browse/CLJ-1238)\n  Allow EdnReader to read foo// (matches LispReader behavior).\n* [CLJ-1264](http://dev.clojure.org/jira/browse/CLJ-1264)\n  Remove uses of _ as a var in the Java code (causes warning in Java 8).\n* [CLJ-394](http://dev.clojure.org/jira/browse/CLJ-394)\n  Add record? predicate.\n* [CLJ-1200](http://dev.clojure.org/jira/browse/CLJ-1200)\n  ArraySeq dead code cleanup, ArraySeq_short support added.\n* [CLJ-1331](http://dev.clojure.org/jira/browse/CLJ-1331)\n  Primitive vectors should implement hasheq and use new hash algorithm\n* [CLJ-1354](http://dev.clojure.org/jira/browse/CLJ-1354)\n  Make APersistentVector.SubVector public so other collections can access\n* [CLJ-1353](http://dev.clojure.org/jira/browse/CLJ-1353)\n  Make awt run headless during the build process\n\n## 4 Bug Fixes\n\n* [CLJ-1018](http://dev.clojure.org/jira/browse/CLJ-1018)\n  Make range consistently return infinite sequence of start with a step of 0.\n* [CLJ-863](http://dev.clojure.org/jira/browse/CLJ-863)\n  Make interleave return () on 0 args and identity on 1 args.\n* [CLJ-1072](http://dev.clojure.org/jira/browse/CLJ-1072)\n  Update internal usages of the old metadata reader syntax to new syntax.\n* [CLJ-1193](http://dev.clojure.org/jira/browse/CLJ-1193)\n  Make bigint and biginteger functions work on double values outside long range.\n* [CLJ-1154](http://dev.clojure.org/jira/browse/CLJ-1154)\n  Make Compile.java flush but not close stdout so errors can be reported.\n* [CLJ-1161](http://dev.clojure.org/jira/browse/CLJ-1161)\n  Remove bad version.properties from sources jar.\n* [CLJ-1175](http://dev.clojure.org/jira/browse/CLJ-1175)\n  Fix invalid behavior of Delay/deref if an exception is thrown - exception will\n  now be rethrown on subsequent calls and not enter a corrupted state.\n* [CLJ-1171](http://dev.clojure.org/jira/browse/CLJ-1171)\n  Fix several issues with instance? to make it consistent when used with apply.\n* [CLJ-1202](http://dev.clojure.org/jira/browse/CLJ-1202)\n  Protocol fns with dashes may get incorrectly compiled into field accesses.\n* [CLJ-850](http://dev.clojure.org/jira/browse/CLJ-850)\n  Add check to emit invokePrim with return type of double or long if type-hinted.\n* [CLJ-1177](http://dev.clojure.org/jira/browse/CLJ-1177)\n  clojure.java.io URL to File coercion corrupts path containing UTF-8 characters.\n* [CLJ-1234](http://dev.clojure.org/jira/browse/CLJ-1234)\n  Accept whitespace in Record and Type reader forms (similar to data literals).\n* [CLJ-1233](http://dev.clojure.org/jira/browse/CLJ-1233)\n  Allow ** as a valid symbol name without triggering dynamic warnings.\n* [CLJ-1246](http://dev.clojure.org/jira/browse/CLJ-1246)\n  Add support to clojure.reflect for classes with annotations.\n  * [CLJ-1184](http://dev.clojure.org/jira/browse/CLJ-1184)\n  Evaling #{do ...} or [do ...] is treated as do special form.\n* [CLJ-1090](http://dev.clojure.org/jira/browse/CLJ-1090)\n  Indirect function calls through Var instances fail to clear locals.\n* [CLJ-1076](http://dev.clojure.org/jira/browse/CLJ-1076)\n  pprint tests fail on Windows, expecting \\n.\n* [CLJ-766](http://dev.clojure.org/jira/browse/CLJ-766)\n  Make into-array work consistently with short-array and byte-array on\n  bigger types.\n* [CLJ-1285](http://dev.clojure.org/jira/browse/CLJ-1285)\n  Data structure invariants are violated after persistent operations when\n  collision node created by transients.\n* [CLJ-1222](http://dev.clojure.org/jira/browse/CLJ-1222)\n  Multiplication overflow issues around Long/MIN_VALUE\n* [CLJ-1118](http://dev.clojure.org/jira/browse/CLJ-1118)\n  Inconsistent numeric comparison semantics between BigDecimals and other numerics\n* [CLJ-1125](http://dev.clojure.org/jira/browse/CLJ-1125)\n  Clojure can leak memory in a servlet container when using dynamic\n  bindings or STM transactions.\n* [CLJ-1082](http://dev.clojure.org/jira/browse/CLJ-1082)\n  Subvecs of primitve vectors cannot be reduced\n* [CLJ-1301](http://dev.clojure.org/jira/browse/CLJ-1301)\n  Case expressions use a mixture of hashCode and hasheq, potentially\n  leading to missed case matches when these differ.\n* [CLJ-983](http://dev.clojure.org/jira/browse/CLJ-983)\n  proxy-super does not restore original binding if call throws exception\n* [CLJ-1176](http://dev.clojure.org/jira/browse/CLJ-1176)\n  clojure.repl/source errors when *read-eval* bound to :unknown\n* [CLJ-935](http://dev.clojure.org/jira/browse/CLJ-935)\n  clojure.string/trim uses different definition of whitespace than\n  triml and trimr\n* [CLJ-1058](http://dev.clojure.org/jira/browse/CLJ-1058)\n  StackOverflowError on exception in reducef for PersistentHashMap\n  fold\n* [CLJ-1328](http://dev.clojure.org/jira/browse/CLJ-1328)\n  Fix some tests in the Clojure test suite to make their names unique\n  and independent of hashing order\n* [CLJ-1339](http://dev.clojure.org/jira/browse/CLJ-1339)\n  Empty primitive vectors throw NPE on .equals with non-vector\n  sequential types\n* [CLJ-1363](http://dev.clojure.org/jira/browse/CLJ-1363)\n  Field access via .- in reflective case does not work\n* [CLJ-944](http://dev.clojure.org/jira/browse/CLJ-944)\n  Compiler gives constant collections types which mismatch their\n  runtime values\n* [CLJ-1387](http://dev.clojure.org/jira/browse/CLJ-1387)\n  reduce-kv on large hash maps ignores reduced result\n\n# Changes to Clojure in Version 1.5.1\n\n* fix for leak caused by ddc65a96fdb1163b\n\n# Changes to Clojure in Version 1.5\n\n## CONTENTS\n\n<pre>\n 1 Deprecated and Removed Features\n    1.1 Clojure 1.5 reducers library requires Java 6 or later\n 2 New and Improved Features\n    2.1 Reducers\n    2.2 Reader Literals improved\n    2.3 clojure.core/set-agent-send-executor!, set-agent-send-off-executor!, and send-via\n    2.4 New threading macros\n    2.5 Column metadata captured by reader\n    2.6 gen-class improvements\n    2.7 Support added for marker protocols\n    2.8 clojure.pprint/print-table output compatible with Emacs Org mode\n    2.9 clojure.string/replace and replace-first handle special characters more predictably\n    2.10 Set and map constructor functions allow duplicates\n    2.11 More functions preserve metadata\n    2.12 New edn reader, improvements to *read-eval*\n 3 Performance Enhancements\n 4 Improved error messages\n 5 Improved documentation strings\n 6 Bug Fixes\n 7 Binary Compatibility Notes\n</pre>\n\n## 1 Deprecated and Removed Features\n\n### 1.1 Clojure 1.5 reducers library requires Java 6 or later\n\nThe new reducers library (see below) requires Java 6 plus a ForkJoin\nlibrary, or Java 7 or later.  Clojure 1.5 can still be compiled and\nrun with Java 5.  The only limitations with Java 5 are that the new\nreducers library will not work, and building Clojure requires skipping\nthe test suite (e.g. by using the command \"ant jar\").\n\n\n## 2 New and Improved Features\n\n### 2.1 Reducers\n\nReducers provide a set of high performance functions for working with collections. The actual fold/reduce algorithms are specified via the collection being reduced. This allows each collection to define the most efficient way to reduce its contents.\n\nThe implementation details of reducers are available at the  [Clojure blog](http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html) and therefore won't be repeated in these change notes. However, as a summary:\n\n* There is a new namespace: clojure.core.reducers\n* It contains new versions of map, filter etc based upon transforming reducing functions - reducers\n* It contains a new function, fold, which is a parallel reduce+combine\nfold uses fork/join when working with (the existing!) Clojure vectors and maps\n* Your new parallel code has exactly the same shape as your existing seq-based code\n* The reducers are composable\n* Reducer implementations are primarily functional - no iterators\n* The model uses regular data structures, not 'parallel collections' or other OO malarkey\n* It's fast, and can become faster still\n* This is work-in-progress\n\nExamples:\n\n\tuser=> (require '[clojure.core.reducers :as r])\n\tuser=> (reduce + (r/filter even? (r/map inc [1 1 1 2])))\n\t;=> 6\n\n\n\t;;red is a reducer awaiting a collection\n\tuser=> (def red (comp (r/filter even?) (r/map inc)))\n\tuser=> (reduce + (red [1 1 1 2]))\n\t;=> 6\n\n\tuser=> (into #{} (r/filter even? (r/map inc [1 1 1 2])))\n\t;=> #{2}\n\n### 2.2 Reader Literals improved\n\n* [CLJ-1034](http://dev.clojure.org/jira/browse/CLJ-1034)\n  \"Conflicting data-reader mapping\" should no longer be thrown where there really isn't a conflict. Until this patch, having data_readers.clj on the classpath twice would cause the above exception.\n\n* [CLJ-927](http://dev.clojure.org/jira/browse/CLJ-927)\n  Added `*default-data-reader-fn*` to clojure.core. When no data reader is found for a tag and `*default-data-reader-fn*`is non-nil, it will be called with two arguments, the tag and the value.  If `*default-data-reader-fn*` is nil (the default), an exception will be thrown for the unknown tag.\n\n### 2.3 clojure.core/set-agent-send-executor!, set-agent-send-off-executor!, and send-via\n\nAdded two new functions:\n\n* clojure.core/set-agent-send-executor!\n\n  Allows the user to set the `java.util.concurrent.Executor` used when calling `clojure.core/send`. Defaults to a fixed thread pool of size: (numCores + 2)\n\n* clojure.core/set-agent-send-off-executor!\n\n \tAllows the user to set the `java.util.concurrent.Executor` used when calling `clojure.core/send-off`. Defaults to a cached thread pool.\n\n* clojure.core/send-via\n\n\tLike `send`, and `send-off`, except the first argument to this function is an executor to use when sending.\n\n\n\n\n### 2.4 New threading macros\n\n* clojure.core/cond-> [expr & clauses]\n\n\tTakes an expression and a set of test/form pairs. Threads the expression (via ->) through each form for which the corresponding test expression (not threaded) is true.\n\nExample:\n\n\tuser=> (cond-> 1\n\t\t\t\t   true inc\n\t               false (* 42)\n\t               (= 2 2) (* 3))\n\t6\n\n* clojure.core/cond->> [expr & clauses]\n\n\tTakes an expression and a set of test/form pairs. Threads expr (via ->>)\n  through each form for which the corresponding test expression (not threaded) is true.\n\nExample:\n\n\tuser=> (def d [0 1 2 3])\n\t#'user/d\n\tuser=> (cond->> d\n\t\t\t\t    true (map inc)\n\t\t\t\t\t(seq? d) (map dec)\n\t\t\t\t\t(= (count d) 4) (reduce +)) ;; no threading in the test expr\n\t\t\t\t\t                            ;; so d must be passed in explicitly\n\t10\n\n\n* clojure.core/as-> [expr name & forms]\n\nBinds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form\n\nNote: this form does not actually perform any threading. Instead it allows the user to assign a name and lexical context to a value created by a parent threading form.\n\nExample:\n\n\tuser=> (-> 84\n\t    \t   (/ 4)\n\t    \t   (as-> twenty-one          ;; uses the value from ->\n\t           \t\t  (* 2 twenty-one)))  ;; no threading here\n\t42\n\n* clojure.core/some-> [expr & forms]\n\n\nWhen expr is not nil, threads it into the first form (via ->),\n and when that result is not nil, through the next etc.\n\nExample:\n\n\tuser=> (defn die [x] (assert false))\n\t#'user/die\n\tuser=> (-> 1 inc range next next next die)\n\tAssertionError Assert failed: false  user/die (NO_SOURCE_FILE:65)\n\tuser=> (some-> 1 inc range next next next die)\n\tnil\n\n\n\n* clojure.core/some->> [expr & forms]\n\n  When expr is not nil, threads it into the first form (via ->>),\n  and when that result is not nil, through the next etc.\n\n  Same as some-> except the value is threaded as the last argument in each form.\n\n### 2.5 Column metadata captured by reader\n\n* [CLJ-960](http://dev.clojure.org/jira/browse/CLJ-960)\n  Data read by the clojure reader is now tagged with :column in addition to :line.\n\n\n### 2.6 gen-class improvements\n\n* [CLJ-745](http://dev.clojure.org/jira/browse/CLJ-745)\n  It is now possible to expose protected final methods via `:exposes-methods` in `gen-class`. This allows Clojure classes created via gen-class to access protected methods of its parent class.\n\nExample:\n\n\t(gen-class :name clojure.test_clojure.genclass.examples.ProtectedFinalTester\n    \t       :extends java.lang.ClassLoader\n        \t   :main false\n           \t   :prefix \"pf-\"\n           \t   :exposes-methods {findSystemClass superFindSystemClass})\n\n* [CLJ-948](http://dev.clojure.org/jira/browse/CLJ-948)\n  It is now possible to annotate constructors via `gen-class`.\n\nExample:\n\n\t(gen-class :name foo.Bar\n    \t       :extends clojure.lang.Box\n        \t   :constructors {^{Deprecated true} [Object] [Object]}\n           \t   :init init\n           \t   :prefix \"foo\")\n\n### 2.7 Support added for marker protocols\n\n* [CLJ-966](http://dev.clojure.org/jira/browse/CLJ-966)\n  `defprotocol` no longer requires that at least one method be given in the definition of the protocol. This allows for marker protocols, whose sole reason of existence is to allow `satisfies?` to be true for a given type.\n\n\nExample:\n\n\tuser=> (defprotocol P (hi [_]))\n    P\n    user=> (defprotocol M) ; marker protocol\n    M\n    user=> (deftype T [a] M P (hi [_] \"hi there\"))\n    user.T\n    user=> (satisfies? P (T. 1))\n    true\n    user=> (satisfies? M (T. 1))\n    true\n    user=> (hi (T. 1))\n    \"hi there\"\n    user=> (defprotocol M2 \"marker for 2\") ; marker protocol again\n    M2\n    user=> (extend-type T M2)\n    nil\n    user=> (satisfies? M2 (T. 1))\n    true\n\n\n### 2.8 clojure.pprint/print-table output compatible with Emacs Org mode\n\nFor the convenience of those that use Emacs Org mode,\n`clojure.pprint/print-table` now prints tables in the form used by\nthat mode.  Emacs Org mode has features to make it easy to edit such\ntables, and even to do spreadsheet-like calculations on their\ncontents.  See the [Org mode documentation on\ntables](http://orgmode.org/manual/Tables.html) for details.\n\n    user=> (clojure.pprint/print-table [:name :initial-impression]\n               [{:name \"Rich\" :initial-impression \"rock star\"}\n                {:name \"Andy\" :initial-impression \"engineer\"}])\n    | :name | :initial-impression |\n    |-------+---------------------|\n    |  Rich |           rock star |\n    |  Andy |            engineer |\n\n\n### 2.9 clojure.string/replace and replace-first handle special characters more predictably\n\n`clojure.string/replace` and `clojure.string/replace-first` are now\nconsistent in the way that they handle the replacement strings: all\ncharacters in the replacement strings are treated literally, including\nbackslash and dollar sign characters.\n\n    user=> (require '[clojure.string :as s])\n\n    user=> (s/replace-first \"munge.this\" \".\" \"$\")\n    ;=> \"munge$this\"\n\n    user=> (s/replace \"/my/home/dir\" #\"/\" (fn [s] \"\\\\\"))\n    ;=> \"\\\\my\\\\home\\\\dir\"\n\nThere is one exception, which is described in the doc strings.  If you\ncall these functions with a regex to search for and a string as the\nreplacement, then dollar sign and backslash characters in the\nreplacement string are treated specially.  Occurrences of `$1` in the\nreplacement string are replaced with the string that matched the first\nparenthesized subexpression of the regex, occurrences of `$2` are\nreplaced with the match of the second parenthesized subexpression,\netc.\n\n    user=> (s/replace \"x12, b4\" #\"([a-z]+)([0-9]+)\" \"$1 <- $2\")\n    ;=> \"x <- 12, b <- 4\"\n\nIndividual occurrences of `$` or `\\` in the replacement string that\nyou wish to be treated literally can be escaped by prefixing them with\na `\\`.  If you wish your replacement string to be treated literally\nand its contents are unknown to you at compile time (or you don't wish\nto tarnish your constant string with lots of backslashes), you can use\nthe new function `clojure.string/re-quote-replacement` to do the\nnecessary escaping of special characters for you.\n\n    user=> (s/replace \"x12, b4\" #\"([a-z]+)([0-9]+)\"\n                         (s/re-quote-replacement \"$1 <- $2\"))\n    ;=> \"$1 <- $2, $1 <- $2\"\n\n\n### 2.10 Set and map constructor functions allow duplicates\n\nAll of the functions that construct sets such as `set` and\n`sorted-set` allow duplicate elements to appear in their arguments,\nand they are documented to treat this case as if by repeated uses of\n`conj`.\n\nSimilarly, all map constructor functions such as `hash-map`,\n`array-map`, and `sorted-map` allow duplicate keys, and are documented\nto treat this case as if by repeated uses of `assoc`.\n\nAs before, literal sets, e.g. `#{1 2 3}`, do not allow duplicate\nelements, and while elements can be expressions evaluated at run time\nsuch as `#{(inc x) (dec y)}`, this leads to a check for duplicates at\nrun time whenever the set needs to be constructed, throwing an\nexception if any duplicates are found.\n\nSimilarly, literal maps do not allow duplicate keys.  New to Clojure\n1.5 is a performance optimization: if all keys are compile time\nconstants but one or more values are expressions requiring evaluation\nat run time, duplicate keys are checked for once at compile time only,\nnot each time a map is constructed at run time.\n\n* [CLJ-1065](http://dev.clojure.org/jira/browse/CLJ-1065)\n  Allow duplicate set elements and map keys for all set and map constructors\n\n\n### 2.11 More functions preserve metadata\n\nMost functions that take a collection and return a \"modified\" version\nof that collection preserve the metadata that was on the input\ncollection, e.g. `conj`, `assoc`, `dissoc`, etc.  One notable\nexception was `into`, which would return a collection with metadata\n`nil` for several common types of input collections.\n\nNow the functions `into`, `select-keys`, `clojure.set/project`, and\n`clojure.set/rename` return collections with the same metadata as\ntheir input collections.\n\n### 2.12 New edn reader, improvements to `*read-eval*`\n\nThe new `clojure.edn` namespace reads edn (http://edn-format.org) data,\nand should be used for reading data from untrusted sources.\n\nClojure's core read* functions can evaluate code, and should not be\nused to read data from untrusted sources. As of 1.5, `*read-eval*`\nsupports a documented set of thread-local bindings, see the doc string\nfor details.\n\n`*read-eval*`'s default can be set to false by setting a system property:\n\n    -Dclojure.read.eval=false\n\n## 3 Performance and Memory Enhancements\n\n* [CLJ-988](http://dev.clojure.org/jira/browse/CLJ-988)\n  Multimethod tables are now protected by a read/write lock instead of a synchronized method. This should result in a performance boost for multithreaded code using multimethods.\n* [CLJ-1061](http://dev.clojure.org/jira/browse/CLJ-1061)\n  `when-first` now evaluates its expression only once.\n* [CLJ-1084](http://dev.clojure.org/jira/browse/CLJ-1084)\n  `PersistentVector$ChunkedSeq` now implements `Counted` interface, to avoid some cases where vector elements were being counted by iterating over their elements.\n* [CLJ-867](http://dev.clojure.org/jira/browse/CLJ-867)\n  Records with same fields and field values, but different types, now usually hash to different values.\n* [CLJ-1000](http://dev.clojure.org/jira/browse/CLJ-1000)\n  Cache hasheq() for seqs, sets, vectors, maps and queues\n* (no ticket) array-map perf tweaks\n* [CLJ-1111](http://dev.clojure.org/jira/browse/CLJ-1111)\n  Allows loop to evaluate to primitive values\n* (no ticket) Move loop locals into same clearing context as loop body\n\n\n## 4 Improved error messages\n\n* [CLJ-103](http://dev.clojure.org/jira/browse/CLJ-103)\n  Improved if-let error message when form has a improperly defined body.\n* [CLJ-897](http://dev.clojure.org/jira/browse/CLJ-897)\n  Don't use destructuring in defrecord/deftype arglists to get a slightly better error message when forgetting to specify the fields vector\n* [CLJ-788](http://dev.clojure.org/jira/browse/CLJ-788)\n  Add source and line members and getters to CompilerException\n* [CLJ-157](http://dev.clojure.org/jira/browse/CLJ-157)\n  Better error messages for syntax errors w/ defn and fn\n* [CLJ-940](http://dev.clojure.org/jira/browse/CLJ-940)\n  Passing a non-sequence to refer :only results in uninformative exception\n* [CLJ-1052](http://dev.clojure.org/jira/browse/CLJ-1052)\n  `assoc` now throws an exception if the last key argument is missing a value.\n\n\n## 5 Improved documentation strings\n\n* [CLJ-893](http://dev.clojure.org/jira/browse/CLJ-893)\n  Document that vec will alias Java arrays\n* [CLJ-892](http://dev.clojure.org/jira/browse/CLJ-892)\n  Clarify doc strings of sort and sort-by: they will modify Java array arguments\n* [CLJ-1019](http://dev.clojure.org/jira/browse/CLJ-1019)\n  ns-resolve doc has a typo\n* [CLJ-1038](http://dev.clojure.org/jira/browse/CLJ-1038)\n  Docstring for deliver doesn't match behavior\n* [CLJ-1055](http://dev.clojure.org/jira/browse/CLJ-1055)\n  \"be come\" should be \"become\"\n* [CLJ-917](http://dev.clojure.org/jira/browse/CLJ-917)\n  clojure.core/definterface is not included in the API docs\n* (no ticket) clojure.core/read, read-string, and *read-eval* all have more extensive documentation.\n\n\n## 6 Bug Fixes\n\n* [CLJ-962](http://dev.clojure.org/jira/browse/CLJ-962)\n  Vectors returned by subvec allow access at negative indices\n* [CLJ-952](http://dev.clojure.org/jira/browse/CLJ-952)\n  bigdec does not properly convert a clojure.lang.BigInt\n* [CLJ-975](http://dev.clojure.org/jira/browse/CLJ-975)\n  inconsistent destructuring behaviour when using nested maps\n* [CLJ-954](http://dev.clojure.org/jira/browse/CLJ-954)\n  TAP support in clojure.test.tap Needs Updating\n* [CLJ-881](http://dev.clojure.org/jira/browse/CLJ-881)\n  exception when cl-format is given some ~f directive/value combinations\n* [CLJ-763](http://dev.clojure.org/jira/browse/CLJ-763)\n  Do not check for duplicates in destructuring map creation\n* [CLJ-667](http://dev.clojure.org/jira/browse/CLJ-667)\n  Allow loops fully nested in catch/finally\n* [CLJ-768](http://dev.clojure.org/jira/browse/CLJ-768)\n  cl-format bug in ~f formatting\n* [CLJ-844](http://dev.clojure.org/jira/browse/CLJ-844)\n  NPE calling keyword on map from bean\n* [CLJ-934](http://dev.clojure.org/jira/browse/CLJ-934)\n  disj! Throws exception when attempting to remove multiple items in one call\n* [CLJ-943](http://dev.clojure.org/jira/browse/CLJ-943)\n  When load-lib fails, a namespace is still created\n* [CLJ-981](http://dev.clojure.org/jira/browse/CLJ-981)\n  clojure.set/rename-keys deletes keys when there's a collision\n* [CLJ-961](http://dev.clojure.org/jira/browse/CLJ-961)\n  with-redefs loses a Var's root binding if the Var is thread-bound\n* [CLJ-1032](http://dev.clojure.org/jira/browse/CLJ-1032)\n  seque leaks threads from the send-off pool\n* [CLJ-1041](http://dev.clojure.org/jira/browse/CLJ-1041)\n  reduce-kv on sorted maps should stop on seeing a Reduced value\n* [CLJ-1011](http://dev.clojure.org/jira/browse/CLJ-1011)\n  clojure.data/diff should cope with null and false values in maps\n* [CLJ-977](http://dev.clojure.org/jira/browse/CLJ-977)\n  (int \\a) returns a value, (long \\a) throws an exception\n* [CLJ-964](http://dev.clojure.org/jira/browse/CLJ-964)\n  test-clojure/rt.clj has undeclared dependency on clojure.set\n* [CLJ-923](http://dev.clojure.org/jira/browse/CLJ-923)\n  Reading ratios prefixed by + is not working\n* [CLJ-1012](http://dev.clojure.org/jira/browse/CLJ-1012)\n  partial function should also accept 1 arg (just f)\n* [CLJ-932](http://dev.clojure.org/jira/browse/CLJ-932)\n  contains? Should throw exception on non-keyed collections\n* [CLJ-730](http://dev.clojure.org/jira/browse/CLJ-730) Create test suite for functional fns (e.g. juxt, comp, partial, etc.)\n* [CLJ-757](http://dev.clojure.org/jira/browse/CLJ-757)\n  Empty transient maps/sets return wrong value for .contains\n* [CLJ-828](http://dev.clojure.org/jira/browse/CLJ-828)\n  clojure.core/bases returns a cons when passed a class and a Java array when passed an interface\n* [CLJ-1062](http://dev.clojure.org/jira/browse/CLJ-1062)\n  CLJ-940 breaks compilation of namespaces that don't have any public functions\n* [CLJ-1070](http://dev.clojure.org/jira/browse/CLJ-1070)\n  PersistentQueue's hash function does not match its equality\n* [CLJ-987](http://dev.clojure.org/jira/browse/CLJ-987)\n  pprint doesn't flush the underlying stream\n* [CLJ-963](http://dev.clojure.org/jira/browse/CLJ-963)\n  Support pretty printing namespace declarations under code-dispatch\n* [CLJ-902](http://dev.clojure.org/jira/browse/CLJ-902)\n  doc macro broken for namespaces\n* [CLJ-909](http://dev.clojure.org/jira/browse/CLJ-909) Make LineNumberingPushbackReader's buffer size configurable\n* [CLJ-910](http://dev.clojure.org/jira/browse/CLJ-910) Allow for type-hinting the method receiver in memfn\n* [CLJ-1048](http://dev.clojure.org/jira/browse/CLJ-1048) add test.generative to Clojure's tests\n* [CLJ-1071](http://dev.clojure.org/jira/browse/CLJ-1071) ExceptionInfo does no abstraction\n* [CLJ-1085](http://dev.clojure.org/jira/browse/CLJ-1085) clojure.main/repl unconditionally refers REPL utilities into `*ns*`\n* (no ticket) Rich Hickey fix: syntax-quote was walking records, returning maps\n* [CLJ-1116](http://dev.clojure.org/jira/browse/CLJ-1116) More REPL-friendly 'ns macro\n* (no ticket) Rich Hickey fix: deref any j.u.c.Future\n* [CLJ-1092](http://dev.clojure.org/jira/browse/CLJ-1092) New function re-quote-replacement has incorrect :added metadata\n* [CLJ-1098](http://dev.clojure.org/jira/browse/CLJ-1098) Implement IKVReduce and CollFold for nil\n* (no ticket) Rich Hickey fix: impose once semantics on fabricated closures for e.g. loops\n* [CLJ-1140](http://dev.clojure.org/jira/browse/CLJ-1140) Restore {:as x} destructuring for empty lists\n* [CLJ-1150](http://dev.clojure.org/jira/browse/CLJ-1150) Make some PersistentVector's and APersistentVector.SubVector's internals public\n* (no ticket) Rich Hickey fix: use non-loading classForName\n* [CLJ-1106](http://dev.clojure.org/jira/browse/CLJ-1106) Fixing set equality\n\n## 7 Binary Compatibility Notes\n\n* `public static inner class LispReader.ReaderException(int line, Throwable cause)`\n  Constructor changed to `ReaderException(int line, int column, Throwable cause)`\n* `public Object clojure.lang.Agent.dispatch(IFn fn, ISeq args, boolean solo)`\n  Replaced with `dispatch(IFn fn, ISeq args, Executor exec)`\n\n# Changes to Clojure in Version 1.4\n\n## CONTENTS\n\n<pre>\n 1 Deprecated and Removed Features\n    1.1 Fields that Start With a Dash Can No Longer Be Accessed Using Dot Syntax\n 2 New/Improved Features\n    2.1 Reader Literals\n    2.2 clojure.core/mapv\n    2.3 clojure.core/filterv\n    2.4 clojure.core/ex-info and clojure.core/ex-data\n    2.5 clojure.core/reduce-kv\n    2.6 clojure.core/contains? Improved\n    2.7 clojure.core/min and clojure.core/max prefer NaN\n    2.8 clojure.java.io/as-file and clojure.java.io/as-url Handle URL-Escaping Better\n    2.9 New Dot Syntax for Record and Type Field Access\n    2.10 Record Factory Methods Available Inside defrecord\n    2.11 assert-args Displays Namespace and Line Number on Errors\n    2.12 File and Line Number Added to Earmuff Dynamic Warning\n    2.13 require Can Take a :refer Option\n    2.14 *compiler-options* Var\n    2.15 Improved Reporting of Invalid Characters in Unicode String Literals\n    2.16 clojure.core/hash No Longer Relies on .hashCode\n    2.17 Java 7 Documentation\n    2.18 loadLibrary Loads Library Using System ClassLoader\n    2.19 Java int is boxed as java.lang.Integer\n 3 Performance Enhancements\n 4 Bug Fixes\n</pre>\n\n## 1 Deprecated and Removed Features\n\n### 1.1 Record and Type Fields that Start With a Dash Can No Longer Be Accessed Using Dot Syntax\n\nClojure 1.4 introduces a field accessor syntax for the dot special form that aligns Clojure field lookup syntax with ClojureScript's.\n\nFor example, in Clojure 1.3, one can declare a record with a field starting with dash and access it like this:\n\n    (defrecord Bar [-a]) ;=> user.Bar\n    (.-a (Bar. 10)) ;=> 10\n\nIn 1.4, the above code results in `IllegalArgumentException No matching field found: a for class user.Bar`\n\nHowever, the field may still be accessed as a keyword:\n\n    (:-a (Bar. 10)) ;=> 10\n\n## 2 New and Improved Features\n\n### 2.1 Reader Literals\n\nClojure 1.4 supports reader literals, which are data structures tagged\nby a symbol to denote how they will be read.\n\nWhen Clojure starts, it searches for files named `data_readers.clj`\nat the root of the classpath. Each such file must contain a Clojure\nmap of symbols, like this:\n\n    {foo/bar my.project.foo/bar\n     foo/baz my.project/baz}\n\nThe key in each pair is a tag that will be recognized by\nthe Clojure reader. The value in the pair is the\nfully-qualified name of a Var which will be invoked by the reader to\nparse the form following the tag. For example, given the\ndata_readers.clj file above, the Clojure reader would parse this\nform:\n\n    #foo/bar [1 2 3]\n\nby invoking the Var `#'my.project.foo/bar` on the vector `[1 2 3]`. The\ndata reader function is invoked on the form AFTER it has been read\nas a normal Clojure data structure by the reader.\n\nReader tags without namespace qualifiers are reserved for Clojure. Default\nreader tags are defined in `clojure.core/default-data-readers` but may be\noverridden in `data_readers.clj` or by rebinding `*data-readers*`.\n\n#### 2.1.1 Instant Literals\n\nClojure supports literals for instants in the form\n`#inst \"yyyy-mm-ddThh:mm:ss.fff+hh:mm\"`. These literals are parsed as `java.util.Date`s\nby default. They can be parsed as `java.util.Calendar`s or `java.util.Timestamp`s\nby binding `*data-readers*` to use `clojure.instant/read-instant-calendar` or\n`clojure.instant/read-instant-timestamp`.\n\n    (def instant \"#inst \\\"@2010-11-12T13:14:15.666\\\"\")\n\n    ; Instants are read as java.util.Date by default\n    (= java.util.Date (class (read-string instant)))\n    ;=> true\n\n    ; Instants can be read as java.util.Calendar or java.util.Timestamp\n\n    (binding [*data-readers* {'inst read-instant-calendar}]\n      (= java.util.Calendar (class (read-string instant))))\n    ;=> true\n\n    (binding [*data-readers* {'inst read-instant-timestamp}]\n      (= java.util.Timestamp (class (read-string instant))))\n    ;=> true\n\n#### 2.1.2 UUID Literals\n\nClojure supports literals for UUIDs in the form `#uuid \"uuid-string\"`. These\nliterals are parsed as `java.util.UUID`s.\n\n### 2.2 clojure.core/mapv\n\n`mapv` takes a function `f` and one or more collections and returns a\nvector consisting of the result of applying `f` to the set of first items of\neach collection, followed by applying `f` to the set of second items in each\ncollection, until any one of the collections is exhausted. Any remaining\nitems in other collections are ignored. `f` should accept a number of arguments\nequal to the number of collections.\n\n    (= [1 2 3] (mapv + [1 2 3]))\n    ;=> true\n\n    (= [2 3 4] (mapv + [1 2 3] (repeat 1)))\n    ;=> true\n\n### 2.3 clojure.core/filterv\n\n`filterv` takes a predicate `pred` and a collection and returns a vector\nof the items in the collection for which `(pred item)` returns true. `pred`\nmust be free of side-effects.\n\n    (= [] (filterv even? [1 3 5]))\n    ;=> true\n\n    (= [2 4] (filterv even? [1 2 3 4 5]))\n    ;=> true\n\n### 2.4 clojure.core/ex-info and clojure.core/ex-data\n\n`ex-info` creates an instance of `ExceptionInfo`. `ExceptionInfo` is a\n`RuntimeException` subclass that takes a string `msg` and a map of data.\n\n    (ex-info \"Invalid use of robots\" {:robots false})\n    ;=> #<ExceptionInfo clojure.lang.ExceptionInfo: Invalid use of robots {:robots false}>\n\n`ex-data` is called with an exception and will retrieve that map of data\nif the exception is an instance of `ExceptionInfo`.\n\n    (ex-data (ex-info \"Invalid use of robots\" {:robots false}))\n    ;=> {:robots false}\n\n### 2.5 clojure.core/reduce-kv\n\n`reduce-kv` reduces an associative collection. It takes a function `f`,\nan initial value `init` and an associative collection `coll`. `f` should\nbe a function of 3 arguments. Returns the result of applying `f` to `init`,\nthe first key and the first value in `coll`, then applying `f` to that result\nand the 2nd key and value, etc. If `coll` contains no entries, returns `init`\nand f is not called. Note that `reduce-kv` is supported on vectors,\nwhere the keys will be the ordinals.\n\n    (reduce-kv str \"Hello \" {:w \\o :r \\l :d \\!})\n    ;=> \"Hello :rl:d!:wo\"\n    (reduce-kv str \"Hello \" [\\w \\o \\r \\l \\d \\!])\n    ;=> \"Hello 0w1o2r3l4d5!\"\n\n### 2.6 clojure.core/contains? Improved\n\n`contains?` now works with `java.util.Set`.\n\n### 2.7 clojure.core/min and clojure.core/max prefer NaN\n\n`min` and `max` now give preference to returning NaN if either of their\narguments is NaN.\n\n### 2.8 clojure.java.io/as-file and clojure.java.io/as-url Handle URL-Escaping Better\n\n`as-file` and `as-url` now handle URL-escaping in both directions.\n\n### 2.9 New Dot Syntax for Record and Type Field Access\n\nClojure 1.4 introduces a field accessor syntax for the dot special\nform that aligns Clojure field lookup syntax with ClojureScript's.\n\nIn 1.4, to declare a record type and access its property `x`, one can\nwrite:\n\n    (defrecord Foo [x]) ;=> user.Foo\n    (.-x (Foo. 10)) ;=> 10\n\nThis addition makes it easier to write code that will run as expected\nin both Clojure and ClojureScript.\n\n### 2.10 Record Factory Methods Available Inside defrecord\n\nPrior to 1.4, you could not use the factory functions (`->RecordClass`\nand `map->RecordClass`) to construct a new record from inside a\n`defrecord` definition.\n\nThe following example did not work prior to 1.4, but is now\nvalid. This example makes use of `->Mean` which would have not yet\nbeen available.\n\n    (defrecord Mean [last-winner]\n      Player\n      (choose [_] (if last-winner last-winner (random-choice)))\n      (update-strategy [_ me you] (->Mean (when (iwon? me you) me))))\n\n### 2.11 assert-args Displays Namespace and Line Number on Errors\n\n`assert-args` now uses &form to report the namespace and line number where\nmacro syntax errors occur.\n\n### 2.12 File and Line Number Added to Earmuff Dynamic Warning\n\nWhen a variable is defined using earmuffs but is not declared dynamic,\nClojure emits a warning. That warning now includes the file and line\nnumber.\n\n### 2.13 require Can Take a :refer Option\n\n`require` can now take a `:refer` option. `:refer` takes a list of symbols\nto refer from the namespace or `:all` to bring in all public vars.\n\n### 2.14 \\*compiler-options\\* Var\n\nThe dynamic var `*compiler-options*` contains a map of options to send\nto the Clojure compiler.\n\nSupported options:\n\n* `:elide-meta`: Have certain metadata elided during compilation. This\nshould be set to a collection of keywords.\n* `:disable-locals-clearing`: Set to true to disable clearing. Useful for\nusing a debugger.\n\nThe main function of the Clojure compiler sets the\n`*compiler-options*` from properties prefixed by `clojure.compiler`,\ne.g.\n\n    java -Dclojure.compiler.elide-meta='[:doc :file :line]'\n\n### 2.15 Improved Reporting of Invalid Characters in Unicode String Literals\n\nWhen the reader finds an invalid character in a Unicode string literal, it\nnow reports the character instead of its numerical representation.\n\n### 2.16 clojure.core/hash No Longer Relies on .hashCode\n\n`hash` no longer directly uses .hashCode() to return the hash of a Clojure\ndata structure. It calls `clojure.lang.Util.hasheq`, which has its own implementation\nfor Integer, Short, Byte, and Clojure collections. This ensures that the hash code\nreturned is consistent with `=`.\n\n### 2.17 Java 7 Documentation\n\n`*core-java-api*` will now return the URL for the Java 7 Javadoc when you are\nrunning Java 7.\n\n### 2.18 loadLibrary Loads Library Using System ClassLoader\n\nA static method, `loadLibrary`, was added to `clojure.lang.RT` to load a\nlibrary using the system ClassLoader instead of Clojure's class loader.\n\n### 2.19 Java int is Boxed As java.lang.Integer\n\nJava `int`s are now boxed as `java.lang.Integer`s. See\n[the discussion on clojure-dev](https://groups.google.com/forum/#!msg/clojure/7-hARL5c1lI/ntnnOweEGfUJ)\nfor more information.\n\n## 3 Performance Enhancements\n\n* `(= char char)` is now optimized\n* `equiv` is inlined in variadic =\n* `toString` cached on keywords and symbols\n\n## 4 Bug Fixes\n\n* [CLJ-829](http://dev.clojure.org/jira/browse/CLJ-829)\n  Transient hashmaps mishandle hash collisions\n* [CLJ-773](http://dev.clojure.org/jira/browse/CLJ-773)\n  Macros that are expanded away still have their vars referenced in the emitted byte code\n* [CLJ-837](http://dev.clojure.org/jira/browse/CLJ-837)\n  java.lang.VerifyError when compiling deftype or defrecord with argument name starting with double underscore characters\n* [CLJ-369](http://dev.clojure.org/jira/browse/CLJ-369)\n  Check for invalid interface method names\n* [CLJ-845](http://dev.clojure.org/jira/browse/CLJ-845)\n  Unexpected interaction between protocol extension and namespaced method keyword/symbols\n  * Ignoring namespace portion of symbols used to name methods in extend-type and extend-protocol\n* [CLJ-852](http://dev.clojure.org/jira/browse/CLJ-852)\n  IllegalArgumentException thrown when defining a var whose value is calculated with a primitive fn\n* [CLJ-855](http://dev.clojure.org/jira/browse/CLJ-855)\n  catch receives a RuntimeException rather than the expected checked exception\n* [CLJ-876](http://dev.clojure.org/jira/browse/CLJ-876)\n  #^:dynamic vars declared in a nested form are not immediately dynamic\n* [CLJ-886](http://dev.clojure.org/jira/browse/CLJ-886)\n  java.io/do-copy can garble multibyte characters\n* [CLJ-895](http://dev.clojure.org/jira/browse/CLJ-895)\n  Collection.toArray implementations do not conform to Java API docs\n  * obey contract for toArray return type\n* [CLJ-898](http://dev.clojure.org/jira/browse/CLJ-898)\n  Agent sends consume heap\n  * Only capture a shallow copy of the current Frame in binding-conveyor-fn, so that sends in agent actions don't build infinite Frame stacks\n* [CLJ-928](http://dev.clojure.org/jira/browse/CLJ-928)\n  Instant literal for Date and Timestamp should print in UTC\n* [CLJ-931](http://dev.clojure.org/jira/browse/CLJ-933)\n  Syntactically broken clojure.test/are tests succeed\n* [CLJ-933](http://dev.clojure.org/jira/browse/CLJ-933)\n  Compiler warning on clojure.test-clojure.require-scratch\n\n# Changes to Clojure in Version 1.3\n\n## CONTENTS\n<pre>\n 1 Deprecated and Removed Features\n    1.1 Earmuffed Vars are No Longer Automatically Considered Dynamic\n    1.2 ISeq No Longer Inherits from Sequential\n    1.3 Removed Bit Operation Support for Boxed Numbers\n    1.4 Ancillary Namespaces No Longer Auto-Load on Startup\n    1.5 Replicate Deprecated\n 2 New/Improved Features\n    2.1 Enhanced Primitive Support\n    2.2 defrecord and deftype Improvements\n    2.3 Better Exception Reporting\n    2.4 clojure.reflect/reflect\n    2.5 clojure.data/diff\n    2.6 clojure.core/every-pred and clojure.core/some-fn Combinators\n    2.7 clojure.core/realized?\n    2.8 clojure.core/with-redefs-fn & with-redefs\n    2.9 clojure.core/find-keyword\n    2.10 clojure.repl/pst\n    2.11 clojure.pprint/print-table\n    2.12 pprint respects *print-length*\n    2.13 compilation and deployment via Maven\n    2.14 internal keyword map uses weak refs\n    2.15 ^:const defs\n    2.16 Message Bearing Assert\n    2.17 Error Checking for defmulti Options\n    2.18 Removed Checked Exceptions\n    2.19 vector-of Takes Multiple Arguments\n    2.20 deref with timeout\n    2.21 Walk Support for sorted-by Collections\n    2.22 string.join Enhanced to Work with Sets\n    2.23 clojure.test-helper\n    2.24 Newline outputs platform-specific newline sequence\n    2.25 init-proxy and update-proxy return proxy\n    2.26 doc & find-doc moved to REPL\n    2.27 clojure.java.shell/sh accepts as input anything that clojure.java.io/copy does\n    2.28 InterruptedHandler Promoted to clojure.repl\n    2.29 Add support for running -main namespaces from clojure.main\n    2.30 Set thread names on agent thread pools\n    2.31 Add docstring support to def\n    2.32 Comp function returns identity when called with zero arity\n    2.33 Type hints can be applied to arg vectors\n    2.34 Binding Conveyance\n 3 Performance Enhancements\n 4 Bug Fixes\n 5 Modular Contrib\n</pre>\n\n## 1 Deprecated and Removed Features\n\n### 1.1 Earmuffed Vars Are No Longer Automatically Considered Dynamic.\n\n    (def *fred*)\n    => Warning: *fred* not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic ** or change the name.\n\n### 1.2 ISeq No Longer Inherits From Sequential\n\nThis allows ISeq implementers to be in the map or set equality partition.\n\n### 1.3 Removed Bit Operation Support for Boxed Numbers\n\nBit Operations map directly to primitive operations\n\n### 1.4 Ancillary Namespaces No Longer Auto-Load on Startup\n\nThe following namespaces are no longer loaded on startup: clojure.set, clojure.xml, clojure.zip\n\n### 1.5 Replicate Deprecated\n\nUse repeat instead.\n\n## 2 New/Improved Features\n\n### 2.1 Enhanced Primitive Support\n\nFull details here:\n\n - [Enhanced Primitive Support][EPS]\n - [Documentation for 1.3 Numerics][NUM]\n\n[EPS]: http://dev.clojure.org/display/doc/Enhanced+Primitive+Support\n[NUM]: http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics\n\n### 2.2 defrecord and deftype Improvements\n\nDetails here: [Defrecord Improvements](http://dev.clojure.org/display/design/defrecord+improvements)\n\n### 2.3 Better Exception Reporting\n\nDetails here: [Error Handling](http://dev.clojure.org/display/design/Error+Handling)\n\nAdditionally:\n\nBetter error messages:\n\n * When calling macros with arity\n * For Invalid Map Literals\n * For alias function if using unknown namespace\n * In the REPL\n * Add \"starting at <line>\" to EOF while reading exceptions\n * Better compilation error reporting\n\n### 2.4 clojure.reflect/reflect\n\nFull details here: [Reflection API](http://dev.clojure.org/display/design/Reflection+API)\n\n### 2.5 clojure.data/diff\n\nRecursively compares a and b, returning a tuple of [things-only-in-a things-only-in-b things-in-both]\n\n    (diff {:a 1 :b 2} {:a 1 :b 22 :c 3})\n    => ({:b 2} {:c 3, :b 22} {:a 1})\n\n### 2.6 clojure.core/every-pred and clojure.core/some-fn Combinators\n\nevery-pred takes a set of predicates and returns a function f that returns true if all of its composing predicates return a logical true value against all of its arguments, else it returns false.\n\n    ((every-pred even?) 2 4 6)\n    => true\n\n    ((every-pred even?) 2 4 5)\n    =>false\n\nsome-fn takes a set of predicates and returns a function f that returns the first logical true value  returned by one of its composing predicates against any of its arguments, else it returns logical false.\n\n    ((some-fn even?) 2 4 5)\n    => true\n    ((some-fn odd?) 2 4 6)\n    => false\n\n### 2.7 clojure.core/realized?\n\nReturns true if a value has been produced for a promise, delay, future or lazy sequence.\n\n    (let [x (range 5)]\n      (println (realized? x))\n      (first x)\n      (println (realized? x)))\n    => false\n    => true\n\n### 2.8 clojure.core/with-redefs-fn & clojure.core/with-redefs\n\nwith-redefs-fn temporarily redefines Vars during a call to func. with-redefs temporarily redefines Vars while executing the body.\n\n    (with-redefs [nil? :temp] (println nil?))\n    => :temp\n\n### 2.9 clojure.core/find-keyword\n\nReturns a Keyword with the given namespace and name if one already exists.\n\n    (find-keyword \"def\")\n    => :def\n    (find-keyword \"fred\")\n    => nil\n\n### 2.10 clojure.repl/pst\n\nPrints a stack trace of the exception\n\n\n    (pst (IllegalArgumentException.))\n\n    IllegalArgumentException\n        user/eval27 (NO_SOURCE_FILE:18)\n        clojure.lang.Compiler.eval (Compiler.java:6355)\n        clojure.lang.Compiler.eval (Compiler.java:6322)\n        clojure.core/eval (core.clj:2699)\n        clojure.main/repl/read-eval-print--5906 (main.clj:244)\n        clojure.main/repl/fn--5911 (main.clj:265)\n        clojure.main/repl (main.clj:265)\n        clojure.main/repl-opt (main.clj:331)\n        clojure.main/main (main.clj:427)\n        clojure.lang.Var.invoke (Var.java:397)\n        clojure.lang.Var.applyTo (Var.java:518)\n        clojure.main.main (main.java:37)\n\n### 2.11 clojure.pprint/print-table\n\nPrints a collection of maps in a textual table.\n\n    (print-table [:fred :barney]\n                 [{:fred \"ethel\"}\n                  {:fred \"wilma\" :barney \"betty\"}])\n\n    ===============\n    :fred | :barney\n    ===============\n    ethel |\n    wilma | betty\n    ===============\n\n### 2.12 pprint respects \\*print-length\\*\n\nAssigning \\*print-length\\* now affects output of pprint\n\n### 2.13 compilation and deployment via Maven\n\nSee the following pages for more information:\n\n - [Maven Settings and Repositories][MSR]\n - [Why Maven?][WM]\n - [Common Contrib Build][CCB]\n - [How to Make Releases][HMR]\n\n [MSR]: http://dev.clojure.org/display/doc/Maven+Settings+and+Repositories\n [WM]: http://dev.clojure.org/pages/viewpage.action?pageId=950842\n [CCB]: http://dev.clojure.org/display/design/Common+Contrib+Build\n [HMR]:http://dev.clojure.org/display/design/How+to+Make+Releases\n\n### 2.14 internal keyword map uses weak refs\n\n### 2.15 ^:const defs\n\n^:const lets you name primitive values with speedier reference.\n\n    (def constants\n     {:pi 3.14\n      :e 2.71})\n\n    (def ^:const pi (:pi constants))\n    (def ^:const e (:e constants))\n\nThe overhead of looking up :e and :pi in the map happens at compile time, as (:pi constants) and (:e constants) are evaluated when their parent def forms are evaluated.\n\n### 2.16 Message Bearing Assert\n\nAssert can take a second argument which will be printed when the assert fails\n\n    (assert (= 1 2) \"1 is not equal to 2\")\n    => AssertionError Assert failed: 1 is not equal to 2\n\n### 2.17 Error Checking for defmulti Options\n\ndefmulti will check to verify that its options are valid. For example, the following code will throw an exception:\n\n    (defmulti fred :ethel :lucy :ricky)\n    => IllegalArgumentException\n\n### 2.18 Removed Checked Exceptions\n\nClojure does not throw checked exceptions\n\n### 2.19 vector-of Takes Multiple Args\n\nvector-of takes multiple args used to populate the array\n\n    (vector-of :int 1 2 3)\n    => [1 2 3]\n\n### 2.20 deref with timeout\n\nderef now takes a timeout option - when given with a blocking reference, will return the timeout-val if the timeout (in milliseconds) is reached before value is available.\n\n    (deref (promise) 10 :ethel)\n    => :ethel\n\n### 2.21 Walk Support for sorted-by Collections\n\nWalk modified to work on sorted-by collections\n\n    let [x (sorted-set-by > 1 2 3)] (walk inc reverse x))\n    => (2 3 4)\n\n### 2.22 string.join Enhanced to Work with Sets\n\nJust like join works on other collections\n\n    (join \" and \" #{:fred :ethel :lucy})\n    => \":lucy and :fred and :ethel\"\n\n### 2.23 clojure.test-helper\n\nAll test helpers moved into clojure.test-helper\n\n### 2.24 Newline outputs platform-specific newline sequence\n\nNewline sequence is output as \\r\\n on Windows now.\n\n### 2.25 init-proxy and update-proxy return proxy\n\nNow you can chain calls on the proxy\n\n### 2.26 doc & find-doc moved to REPL\n\nAdds special form docs to the REPL\n\n### 2.27 clojure.java.shell/sh accepts as input anything that clojure.java.io/copy does\n\nThis adds InputStream, Reader, File, byte[] to the list of inputs for clojure.java.shell/sh\n\n### 2.28 Interrupt Handler Promoted to clojure.repl\n\nPromoting this library eliminates the need for a dependency on old contrib.\n\n### 2.29 Add support for running -main namespaces from clojure.main\n\nThis patch allows clojure.main to accept an argument pointing to a namespace to look for a -main function in. This allows users to write -main functions that will work the same whether the code is AOT-compiled for use in an executable jar or just run from source.\n\n### 2.30 Set thread names on agent thread pools\n\nIt's a best practice to name the threads in an executor thread pool with a custom ThreadFactory so that the purpose of these threads is clear in thread dumps and other runtime operational tools.\n\nPatch causes thread names like:\n\n    clojure-agent-send-pool-%d     (should be fixed # of threads)\n    clojure-agent-send-off-pool-%d (will be added and removed over time)\n\n### 2.31 Add docstring support to def\n\nA def can now have a docstring between name and value.\n\n    (def foo \"a foo\" :foo)\n\n### 2.32 Comp function returns identity when called with zero arity\n\n    (= (comp) identity)\n    => true\n\n### 2.33 Type hints can be applied to arg vectors\n\nYou can hint different arities separately:\n\n    (defn hinted\n      (^String [])\n      (^Integer [a])\n      (^java.util.List [a & args]))\n\nThis is preferred over hinting the function name. Hinting the function name is still allowed for backward compatibility, but will likely be deprecated in a future release.\n\n### 2.34 Binding Conveyance\n\nClojure APIs that pass work off to other threads (e.g. send, send-off, pmap, future) now convey the dynamic bindings of the calling thread:\n\n    (def ^:dynamic *num* 1)\n    (binding [*num* 2] (future (println *num*)))\n    ;; prints \"2\", not \"1\"\n\n## 3 Performance Enhancements\n\n  * Code path for using vars is now much faster for the common case\n  * Improved startup time\n  * Fix performance on some numeric overloads\n    See [CLJ-380](http://dev.clojure.org/jira/browse/CLJ-5) for more information\n  * Promises are lock free\n  * Functions only get metadata support code when metadata explicitly supplied\n  * definterface/gen-interface accepts array type hints\n  * inline nil?\n  * inline bit-functions & math ops\n  * inline n-ary min & max\n  * PersistentQueue count is now O(1)\n  * Intrinsics: unchecked math operators now emit bytecodes directly where possible\n\n## 4 Bug Fixes\n\n[Complete list of Tickets for 1.3 Release][ISSUES].\n\n[ISSUES]: http://dev.clojure.org/jira/secure/IssueNavigator.jspa?mode=hide&requestId=10052\n\n * [CLJ-8](http://dev.clojure.org/jira/browse/CLJ-8)\n   detect and report cyclic load dependencies\n    * Patch restore detection of cyclic load dependencies\n\n * [CLJ-31](http://dev.clojure.org/jira/browse/CLJ-31)\n   compiler now correctly rejects attempts to recur across try\n    (fn [x] (try (recur 1)))\n    => CompilerException\n\n * [CLJ-286](http://dev.clojure.org/jira/browse/CLJ-286)\n   \\*out\\* being used as java.io.PrintWriter\n    * Patch fixes using Writer instead of PrintWriter\n    * fix clojure.main to not assume that *err* is a PrintWriter\n\n * [CLJ-292](http://dev.clojure.org/jira/browse/CLJ-292)\n   LazySeq.sval() nests RuntimeExceptions\n    * Patch causes only the original RuntimeException to be thrown\n\n * [CLJ-390](http://dev.clojure.org/jira/browse/CLJ-390)\n   sends from agent error-handlers should be allowed\n    * Patch allows agent error-handler to send successfully\n\n * [CLJ-426](http://dev.clojure.org/jira/browse/CLJ-426)\n   case should handle hash collision\n    * There were situations where a hash collision would occur with case and an exception would be thrown. See [discussion](https://groups.google.com/d/topic/clojure/m4ZDWKSfmfo/discussion) for more details\n\n * [CLJ-430](http://dev.clojure.org/jira/browse/CLJ-430)\n   clojure.java.io URL Coercion throws java.lang.ClassCastException\n    * Patch correct exception to be thrown\n\n * [CLJ-432](http://dev.clojure.org/jira/browse/CLJ-432)\n   deftype does not work if containing ns contains dashes\n    * Patch munges namespaces with dashes properly\n\n * [CLJ-433](http://dev.clojure.org/jira/browse/CLJ-433)\n   munge should not munge $ (which isJavaIdentifierPart), should munge ' (which is not)\n\n * [CLJ-435](http://dev.clojure.org/jira/browse/CLJ-435)\n   stackoverflow exception in printing meta with :type\n    * Patch fixes exception being thrown on certain type metadata\n      (with-meta {:value 2} {:type Object})\n      => No message. [Thrown class java.lang.StackOverflowError]\n\n * [CLJ-437](http://dev.clojure.org/jira/browse/CLJ-437)\n   Bugs in clojure.set/subset? and superset? for sets with false/nil elements\n    * Patch fixes failing on subset? and superset? for sets with false/nil elements\n\n * [CLJ-439](http://dev.clojure.org/jira/browse/CLJ-439)\n   Automatic type translation from Integer to Long\n    * Patch fixes increase coercion from Integer to Long\n\n * [CLJ-444](http://dev.clojure.org/jira/browse/CLJ-444)\n   Infinite recursion in Keyword.intern leads to stack overflow\n    * No more infinite recursion with patch\n\n * [CLJ-673](http://dev.clojure.org/jira/browse/CLJ-673)\n   use system class loader when base loader is null\n    * facilitates placing Clojure on bootclasspath\n\n * [CLJ-678](http://dev.clojure.org/jira/browse/CLJ-678)\n   into-array should work with all primitive types\n\n * [CLJ-680](http://dev.clojure.org/jira/browse/CLJ-680)\n   printing promises should not block\n    * Patch allows printing of promises without blocking\n\n * [CLJ-682](http://dev.clojure.org/jira/browse/CLJ-682)\n   cl-format: ~w throws an exception when not wrapped in a pretty-writer\n    * Patch fixes the following bug in cl-format with ~w:\n\n * [CLJ-693](http://dev.clojure.org/jira/browse/CLJ-693)\n   VerifyError with symbol metadata, macros, and defrecord\n\n * [CLJ-702](http://dev.clojure.org/jira/browse/CLJ-702)\n   case gives NPE when used with nil\n    * Patch allows nil to be used with case\n\n * [CLJ-734](http://dev.clojure.org/jira/browse/CLJ-734)\n   starting scope of let bindings seems incorrect from jdi perspective\n    * Patch fixes local variables table to have the correct code index for let bindings.\n\n * [CLJ-739](http://dev.clojure.org/jira/browse/CLJ-739)\n   version.properties file is not closed\n    * Patch properly closes version.properties file\n\n * [CLJ-751](http://dev.clojure.org/jira/browse/CLJ-751)\n   cl-format: ~( throws an exception with an empty string\n    * Patch fixes the following bug in cl-format when format is nil\n    (cl-format nil \"~:(~a~)\" \"\")\n    => NullPointerException\n\n * [CLJ-780](http://dev.clojure.org/jira/browse/CLJ-780)\n   race condition in reference cache on Java 5\n    * Map.Entry instances can have null values prior to Java 6. This patch provides a workaround.\n\n * floats were being boxed as Doubles, now they are boxed as Floats\n\n * several \"holding onto head\" fixes\n    * Stop top-level defs from hanging onto the head of an expression that uses a lazy seq\n    * Stop multimethods from holding onto heads of their arguments\n\n## 5 Modular Contrib\n\nIn 1.3, the monolithic clojure-contrib.jar has been replaced by a modular system of contrib libraries, so that production systems can include only the code they actually need. This also allows individual contribs to have their own release cycles. Many contribs have moved forward by several point versions already. Documentation for updating applications to use the new contrib libraries is at http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go\n\nImportant Note: Many of the new modular contribs are compatible with both 1.2 and 1.3. This offers an incremental migration path: First, upgrade your contrib libraries while holding Clojure at 1.2, Then, in a separate step, upgrade to Clojure 1.3.\n"
  },
  {
    "path": "clojure.iml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=\"true\" type=\"JAVA_MODULE\" version=\"4\">\n  <component name=\"FacetManager\">\n    <facet type=\"Clojure\" name=\"Clojure\">\n      <configuration />\n    </facet>\n  </component>\n  <component name=\"NewModuleRootManager\" LANGUAGE_LEVEL=\"JDK_1_5\" inherit-compiler-output=\"false\">\n    <output url=\"file://$MODULE_DIR$/target/classes\" />\n    <output-test url=\"file://$MODULE_DIR$/target/test-classes\" />\n    <content url=\"file://$MODULE_DIR$\">\n      <sourceFolder url=\"file://$MODULE_DIR$/src/resources\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/clj\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/jvm\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/test/java\" isTestSource=\"true\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/target\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/test-classes\" />\n    </content>\n    <orderEntry type=\"inheritedJdk\" />\n    <orderEntry type=\"sourceFolder\" forTests=\"false\" />\n    <orderEntry type=\"library\" scope=\"PROVIDED\" name=\"Maven: org.codehaus.jsr166-mirror:jsr166y:1.7.0\" level=\"project\" />\n    <orderEntry type=\"library\" scope=\"TEST\" name=\"Maven: org.clojure:test.generative:0.4.0\" level=\"project\" />\n    <orderEntry type=\"library\" scope=\"TEST\" name=\"Maven: org.clojure:tools.namespace:0.1.1\" level=\"project\" />\n    <orderEntry type=\"library\" scope=\"TEST\" name=\"Maven: org.clojure:java.classpath:0.1.1\" level=\"project\" />\n    <orderEntry type=\"library\" scope=\"TEST\" name=\"Maven: org.clojure:data.generators:0.1.2\" level=\"project\" />\n  </component>\n</module>\n\n"
  },
  {
    "path": "doc/clojure/pprint/CommonLispFormat.markdown",
    "content": "# A Common Lisp-compatible Format Function\ncl-format is an implementation of the incredibly baroque Common Lisp format function as specified \nin [Common Lisp, the Language, 2nd edition, Chapter 22](http://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node200.html#SECTION002633000000000000000).\n\nFormat gives you an easy and powerful way to format text and data for output. It supports rich \nformatting of strings and numbers, loops, conditionals, embedded formats, etc. It is really a \ndomain-specific language for formatting.\n\nThis implementation for clojure has the following goals:\n\n * Support the full feature set of the Common Lisp format function (including the X3J13 extensions) with the only exception being concepts that make no sense or are differently interpreted in Clojure.\n * Make porting code from Common Lisp easier.\n * Provide a more native feeling solution for Clojure programmers than the Java format method and its relatives.\n * Be fast. This includes the ability to precompile formats that are going to be used repetitively.\n * Include useful error handling and comprehensive documentation.\n\n## Why would I use cl-format?\n\nFor some people the answer to this question is that they are used to\nCommon Lisp and, therefore, they already know the syntax of format\nstrings and all the directives.\n\nA more interesting answer is that cl-format provides a way of\nrendering strings that is much more suited to Lisp and its data\nstructures. \n\nBecause iteration and conditionals are built into the directive\nstructure of cl-format, it is possible to render sequences and other\ncomplex data structures directly without having to loop over the data\nstructure. \n\nFor example, to print the elements of a sequence separated by commas,\nyou simply say:\n\n    (cl-format true \"~{~a~^, ~}\" aseq)\n\n(This example is taken from \n[Practical Common Lisp](http://www.gigamonkeys.com/book/)\nby Peter Seibel.)\n\nThe corresponding output using Clojure's Java-based _format_ function\nwould involve a nasty loop/recur with some code to figure out about\nthe commas. Yuck!\n\n## Current Status of cl-format\n\ncl-format is 100% compatible with the Common Lisp standard as\nspecified in CLtLv2.\nThis includes all of the functionality of Common\nLisp's format function including iteration, conditionals, \ntext justification and rich\noptions for displaying real and integer values. It also includes the\ndirectives to support pretty printing structured output.\n\nIf you find a bug in a directive, drop me a line\nwith a chunk of code that exhibits the bug and the version of\ncl-format you found it in and I'll try to get it fixed.\n\nI also intend to have good built-in documentation for the directives,\nbut I haven't built that yet.\n\nThe following directives are\nnot yet supported: ~:T and ~@:T (but all other forms of ~T work) \nand extensions with ~/. \n\nThe pretty printer interface is similar, but not identical to the \ninterface in Common Lisp.\n\nNext up: \n\n * Support for ~/\n * True compiled formats\n * Restructure unit tests into modular chunks.\n * Import tests from CLISP and SBCL.\n * Unit tests for exception conditions.\n * Interactive documentation\n \n## How to use cl-format\n\n### Loading cl-format in your program\n\nOnce cl-format is in your path, adding it to your code is easy:\n\n    (ns your-namespace-here\n      (:use [clojure.pprint :only (cl-format)]))\n\nIf you want to refer to the cl-format function as \"format\" (rather\nthan using the clojure function of that name), you can use this idiom:\n\n    (ns your-namespace-here\n      (:refer-clojure :exclude [format])\n      (:use clojure.pprint))\n\n    (def format cl-format)\n\nYou might want to do this in code that you've ported from Common Lisp,\nfor instance, or maybe just because old habits die hard.\n\nFrom the REPL, you can grab it using (use):\n\n    (use 'clojure.pprint)\n\n### Calling cl-format\n\ncl-format is a standard clojure function that takes a variable number\nof arguments. You call it like this:\n\n    (cl-format stream format args...)\n\n_stream_ can be any Java Writer (that is java.io.Writer) or the values\n_true_, _false_, or _nil_. The argument _true_ is identical to using\n`*`out`*` while _false_ or _nil_ indicate that cl-format should return\nits result as a string rather than writing it to a stream.\n\n_format_ is either a format string or a compiled format (see\nbelow). The format string controls the output that's written in a way\nthat's similar to (but much more powerful than) the standard Clojure\nAPI format function (which is based on Java's\njava.lang.String.Format).\n\nFormat strings consist of characters that are to be written to the\noutput stream plus directives (which are marked by ~) as in \"The\nanswer is ~,2f\". Format strings are documented in detail in \n[*Common Lisp the Language*, 2nd edition, Chapter 22](http://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node200.html#SECTION002633000000000000000).\n\n_args_ is a set of arguments whose use is defined by the format.\n\n## Using column aware streams across format invocations\n\nWriters in Java have no real idea of current column or device page width, so the format\ndirectives that want to work relative to the current position on the\npage have nothing to work with. To deal with this, cl-format contains\nan extension to writer called pretty-writer. A pretty-writer watches the\noutput and keeps track of what column the current output is going to.\n\nWhen you call format and your format includes a directive that cares\nabout what column it's in (~T, ~&, ~<...~>), cl-format will\nautomatically wrap the Writer you passed in with a pretty-writer. This\nmeans that by default all cl-format statements act like they begin on\na fresh line and have a page width of 72.\n\nFor many applications, these assumptions are fine and you need to do\nnothing more. But sometimes you want to use multiple cl-format calls\nthat output partial lines. You may also want to mix cl-format calls\nwith the native clojure calls like print. If you want stay\ncolumn-aware while doing this you need to create a pretty-writer of\nyour own (and possibly bind it to `*`out`*`).\n\nAs an example of this, this function takes a nested list and prints it\nas a table (returning the result as a string):\n\n    (defn list-to-table [aseq column-width]\n      (let [string-writer (java.io.StringWriter.)\n            stream (get-pretty-writer string-writer)]\n        (binding [*out* stream]\n          (doseq [row aseq]\n            (doseq [col row]\n              (cl-format true \"~4D~7,vT\" col column-width))\n            (prn)))\n        (.flush stream)\n        (.toString string-writer)))\n\n(In reality, you'd probably do this as a single call to cl-format.)\n\nThe get-pretty-writer function takes the Writer to wrap and\n(optionally) the page width (in columns) for use with ~<...~>. \n\n## Examples\n\nThe following function uses cl-format to dump a columnized table of the Java system properties:\n\n    (defn show-props [stream]\n      (let [p (mapcat \n    \t       #(vector (key %) (val %)) \n    \t       (sort-by key (System/getProperties)))]\n        (cl-format stream \"~30A~A~%~{~20,,,'-A~10A~}~%~{~30A~S~%~}\" \n    \t           \"Property\" \"Value\" [\"\" \"\" \"\" \"\"] p)))\n    \nThere are some more examples in the pretty print examples gallery at \nhttp://github.com/tomfaulhaber/pprint-examples:\n\n * hexdump - a program that uses cl-format to create a standard formatted hexdump of the requested stream.\n * multiply - a function to show a formatted multiplication table in a very \"first-order\" way.\n * props - the show-props example shown above.\n * show_doc - some utilities for showing documentation from various name spaces.\n\n## Differences from the Common Lisp format function\n\nThe floating point directives that show exponents (~E, ~G) show E for\nthe exponent character in all cases (unless overridden with an\n_exponentchar_).  Clojure does not distinguish between floats and\ndoubles in its printed representation and neither does cl-format.\n\nThe ~A and ~S directives accept the colon prefix, but ignore it since\n() and nil are not equivalent in Clojure.\n\nClojure has 3 different reader syntaxes for characters. The ~@c\ndirective to cl-format has an argument extension to let you choose:\n\n * ~@c (with no argument) prints \"\\c\" (backslash followed by the printed representation of the character or \\newline, \\space, \\tab, \\backspace, \\return)\n * ~'o@c prints \"\\oDDD\" where DDD are the octal digits representing the character. \n * ~'u@c prints \"\\uXXXX\" prints the hex Unicode representation of the character.  \n"
  },
  {
    "path": "doc/clojure/pprint/PrettyPrinting.markdown",
    "content": "# A Pretty Printer for Clojure\n\n## Overview\n\nThis namespace adds a new feature to Clojure: a generalized pretty\nprinter.\n\nThe pretty printer is easy to use:\n\n    user=> (println (for [x (range 10)] (range x)))\n    (() (0) (0 1) (0 1 2) (0 1 2 3) (0 1 2 3 4) (0 1 2 3 4 5) (0 1 2 3 4 5 6) (0 1 2 3 4 5 6 7) (0 1 2 3 4 5 6 7 8))\n    nil\n    user=> (use 'clojure.pprint)             \n    nil\n    user=> (pprint (for [x (range 10)] (range x)))         \n    (()\n     (0)\n     (0 1)\n     (0 1 2)\n     (0 1 2 3)\n     (0 1 2 3 4)\n     (0 1 2 3 4 5)\n     (0 1 2 3 4 5 6)\n     (0 1 2 3 4 5 6 7)\n     (0 1 2 3 4 5 6 7 8))\n    nil\n    user=>\n\nThe pretty printer supports two modes: _code_ which has special\nformatting for special forms and core macros and _simple_ (the\ndefault) which formats the various Clojure data structures as\nappropriate for raw data. In fact, the pretty printer is\nhighly customizable, but basic use is pretty simple.\n\nAll the functions and variables described here are in the\nclojure.pprint namespace. Using them is as simple as adding a \n`(:use clojure.pprint)` to\nyour namespace declarations. Or, better practice would be \n`(:use [clojure.pprint :only (<functions you wish to use>)])`.\n\npprint is being developed by Tom Faulhaber (to mail me you can use\nmy first name at my domain which is infolace.com).\n\nAs with the rest of Clojure, the pretty printer is licensed under the \n[http://opensource.org/licenses/eclipse-1.0.php Eclipse Public License 1.0].\n\nFuture development is guided by those using it, so send feedback about\nwhat's working and not working for you and what you'd like to see in the \npretty printer.\n\n## Pretty Printing Basics\n\nPretty printing is primarily implemented with the function\npprint. pprint takes a single argument and formats it according to the\nsettings of several special variables.\n\nGenerally, the defaults are fine for pretty printing and you can\nsimply use:\n\n    (pprint obj)\n\nto print your object. If you wish to write to\nanother stream besides `*`out`*`, you can use:\n\n    (write obj :pretty true :stream foo)\n\nwhere foo is the stream to which you wish to write. (The write\nfunction has a lot more options which are not yet documented. Stay\ntuned.)\n\nWhen at the REPL, the pp macro pretty prints the last output\nvalue. This is useful when you get something too complex to read\ncomfortably. Just type:\n\n    user=> (pp)\n\nand you'll get a pretty printed version of the last thing output (the\nmagic variable `*`1).\n\n## Dispatch tables and code formatting\n\nThe behavior of the pretty printer can be finely controlled through\nthe use of _dispatch tables_ that contain descriptions for how\ndifferent structures should be formatted. \n\nUsing custom dispatch tables, the pretty printer can create formatted\noutput for data structures that is customized for the\napplication. This allows pretty printing to be baked into any\nstructured output. For information and examples, see below in\n[#Custom_Dispatch_Functions Custom Dispatch Functions].\n\nThe pretty printer comes with two pre-defined dispatch tables to cover\nthe most common situations:\n\n`*`simple-dispatch`*` - supports basic representation of data in various\nClojure structures: seqs, maps, vectors, etc. in a fairly standard\nway. When structures need to be broken across lines, following lines\nare indented to line up with the first element. `*`simple-dispatch`*` is\nthe default and is good for showing the output of most operations.\n\n`*`code-dispatch`*` - has special representation for various structures\nfound in code: defn, condp, binding vectors, anonymous functions,\netc. This dispatch indents following lines of a list one more space as\nappropriate for a function/argument type of list.\n\nAn example formatted with code dispatch:\n\n    user=> (def code '(defn cl-format \n    \"An implementation of a Common Lisp compatible format function\"\n    [stream format-in & args] (let [compiled-format (if (string? format-in) \n    (compile-format format-in) format-in) navigator (init-navigator args)] \n    (execute-format stream compiled-format navigator))))\n    #'user/code\n    user=> (with-pprint-dispatch *code-dispatch* (pprint code))\n    (defn cl-format\n      \"An implementation of a Common Lisp compatible format function\"\n      [stream format-in & args]\n      (let [compiled-format (if (string? format-in)\n                              (compile-format format-in)\n                              format-in)\n            navigator (init-navigator args)]\n        (execute-format stream compiled-format navigator)))\n    nil\n    user=> \n\nThere are three ways to set the current dispatch: set it to a specific\ntable permanently with set-pprint-dispatch, bind it with\nwith-pprint-dispatch (as shown in the example above), or use the\n:dispatch keyword argument to write.\n\n## Control variables\n\nThe operation of pretty printing is also controlled by a set of variables\nthat control general parameters of how the pretty printer makes\ndecisions. The current list is as follows:\n\n*`*`print-pretty`*`*: Default: *true*  \n\nBind to true if you want write to use pretty printing. (pprint and pp automatically \nbind this to true.)\n\n*`*`print-right-margin`*`*: Default: *72*\n\nPretty printing will try to avoid anything going beyond this column.\n\n*`*`print-miser-width`*`*: Default: *40*\n\nThe column at which to enter miser style. Depending on the dispatch table, \nmiser style add newlines in more places to try to keep lines short allowing for further \nlevels of nesting. For example, in the code dispatch table, the pretty printer will \ninsert a newline between the \"if\" and its condition when in miser style.\n\n*`*`print-suppress-namespaces`*`*: Default: *false*\n\nDon't print namespaces with symbols. This is particularly useful when \npretty printing the results of macro expansions\n\n*`*`print-level`*`*: Default: *nil*\n\nAs with the regular Clojure print function, this variable controls the \ndepth of structure that is printed. The argument itself is level 0,\nthe first level of a collection is level 1, etc. When the structure\ngets deeper than the specified `*`print-level`*`, a hash sign (#) is\nprinted.\n\nFor example:\n\n    user=> (binding [*print-level* 2] (pprint '(a b (c d) ((e) ((f d) g)))))\n    (a b (c d) (# #))\n    nil\n    user=> \n\n*`*`print-length`*`*: Default: *nil*\n\nAs with the regular Clojure print function, this variable controls the \nnumber of items that are printed at each layer of structure. When a\nlayer has too many items, ellipses (...) are displayed.\n\nFor example:\n\n    user=> (defn foo [x] (for [i (range x) ] (range 1 (- x (dec i)))))\n    #'user/foo\n    user=> (binding [*print-length* 6] (pprint (foo 10)))\n    ((1 2 3 4 5 6 ...)\n     (1 2 3 4 5 6 ...)\n     (1 2 3 4 5 6 ...)\n     (1 2 3 4 5 6 ...)\n     (1 2 3 4 5 6)\n     (1 2 3 4 5)\n     ...)\n    nil\n    user=>\n\n## Custom Dispatch Functions\n\nUsing custom dispatch, you can easily create your own formatted output\nfor structured data. Examples included with the pretty printer show\nhow to use custom dispatch to translate simple Clojure structures into\nnicely formatted JSON and XML.\n\n### Basic Concepts of Pretty Printing\n\nIn order to create custom dispatch functions, you need to understand\nthe fundamentals of pretty printing. The clojure pretty printer is\nbased on the XP pretty printer algorithm (used in many Lisps including\nCommon Lisp) which supports sophisticated decision-making about line\nbreaking and indentation with reasonable performance even for very\nlarge structures. The XP algorithm is documented in the paper,\n[http://dspace.mit.edu/handle/1721.1/6504 XP. A Common Lisp Pretty\nPrinting System].\n\nThe Clojure implementation of XP is similar in spirit to the Common\nLisp implementation, but the details of the interface are somewhat\ndifferent. The result is that writing custom dispatch in Clojure is\nmore \"Clojure-y.\"\n\nThere are three key concepts to understand when creating custom pretty\nprinting functions: _logical blocks_,  _conditional newlines_, and\n_indentation_.\n\nA _logical block_ marks a set of output that should be thought about\nas a single unit by the pretty printer. Logical blocks can contain\nother logical blocks (that is, they nest). As a simple example, when\nprinting list structure, every sublist will typically be a logical\nblock.\n\n_Conditional newlines_ tell the pretty printer where it can insert\nline breaks and how to make the decisions about when to do it. There\nare four types of conditional newline:\n\n * Linear newlines tell the pretty printer to insert a newline in a\n   place whenever the enclosing logical block won't fit on a single\n   line. Linear newlines are an all-or-nothing proposition; if the\n   logical block doesn't fit on a single line, *all* the linear\n   newlines are emitted as actual newlines.\n * Fill newlines tell the pretty printer that it should fit as many\n   chunks of the logical block as possible on this line and then emit\n   a newline.\n * Mandatory newlines tell the pretty printer to emit a newline\n   regardless of where it is in the output line.  \n * Miser newlines tell the pretty printer to emit a newline if the\n   output column is in the miser region (as defined by the pretty\n   printer variable `*`pprint-miser-width`*`). This allows you to\n   define special behavior as the output gets heavily nested near the\n   right margin.\n\n_Indentation_ commands allow you to specify how wrapped lines should\nbe indented. Indentation can be relative to either the start column of\nthe current logical block or the current column position of the output. \n\n(This section is still incomplete...)\n\n## Current limitations and future plans\n\nThis is an early version release of the pretty printer and there is\nplenty that is yet to come.\n\nHere are some examples:\n\n * Support all the types and forms in Clojure (most of the way there now).\n * Support for limiting pretty printing based on line counts.\n * Support for circular and shared substructure detection.\n * Finishing the integration with the format function (support for ~/ and tabular pretty printing).\n * Performance! (Not much thought has been made to making this go fast, but there are a bunch of pretty obvious speedups to be had.)\n * Handle Java objects intelligently\n\nPlease let me know about anything that's not working right, anything that\nshould work differently, or the feature you think should be at the top\nof my list. \n\n"
  },
  {
    "path": "epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\r\n<title>Eclipse Public License - Version 1.0</title>\r\n<style type=\"text/css\">\r\n  body {\r\n    size: 8.5in 11.0in;\r\n    margin: 0.25in 0.5in 0.25in 0.5in;\r\n    tab-interval: 0.5in;\r\n    }\r\n  p {  \t\r\n    margin-left: auto;\r\n    margin-top:  0.5em;\r\n    margin-bottom: 0.5em;\r\n    }\r\n  p.list {\r\n  \tmargin-left: 0.5in;\r\n    margin-top:  0.05em;\r\n    margin-bottom: 0.05em;\r\n    }\r\n  </style>\r\n\r\n</head>\r\n\r\n<body lang=\"EN-US\">\r\n\r\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\r\n\r\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\r\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\r\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\r\nAGREEMENT.</p>\r\n\r\n<p><b>1. DEFINITIONS</b></p>\r\n\r\n<p>&quot;Contribution&quot; means:</p>\r\n\r\n<p class=\"list\">a) in the case of the initial Contributor, the initial\r\ncode and documentation distributed under this Agreement, and</p>\r\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\r\n<p class=\"list\">i) changes to the Program, and</p>\r\n<p class=\"list\">ii) additions to the Program;</p>\r\n<p class=\"list\">where such changes and/or additions to the Program\r\noriginate from and are distributed by that particular Contributor. A\r\nContribution 'originates' from a Contributor if it was added to the\r\nProgram by such Contributor itself or anyone acting on such\r\nContributor's behalf. Contributions do not include additions to the\r\nProgram which: (i) are separate modules of software distributed in\r\nconjunction with the Program under their own license agreement, and (ii)\r\nare not derivative works of the Program.</p>\r\n\r\n<p>&quot;Contributor&quot; means any person or entity that distributes\r\nthe Program.</p>\r\n\r\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\r\nContributor which are necessarily infringed by the use or sale of its\r\nContribution alone or when combined with the Program.</p>\r\n\r\n<p>&quot;Program&quot; means the Contributions distributed in accordance\r\nwith this Agreement.</p>\r\n\r\n<p>&quot;Recipient&quot; means anyone who receives the Program under\r\nthis Agreement, including all Contributors.</p>\r\n\r\n<p><b>2. GRANT OF RIGHTS</b></p>\r\n\r\n<p class=\"list\">a) Subject to the terms of this Agreement, each\r\nContributor hereby grants Recipient a non-exclusive, worldwide,\r\nroyalty-free copyright license to reproduce, prepare derivative works\r\nof, publicly display, publicly perform, distribute and sublicense the\r\nContribution of such Contributor, if any, and such derivative works, in\r\nsource code and object code form.</p>\r\n\r\n<p class=\"list\">b) Subject to the terms of this Agreement, each\r\nContributor hereby grants Recipient a non-exclusive, worldwide,\r\nroyalty-free patent license under Licensed Patents to make, use, sell,\r\noffer to sell, import and otherwise transfer the Contribution of such\r\nContributor, if any, in source code and object code form. This patent\r\nlicense shall apply to the combination of the Contribution and the\r\nProgram if, at the time the Contribution is added by the Contributor,\r\nsuch addition of the Contribution causes such combination to be covered\r\nby the Licensed Patents. The patent license shall not apply to any other\r\ncombinations which include the Contribution. No hardware per se is\r\nlicensed hereunder.</p>\r\n\r\n<p class=\"list\">c) Recipient understands that although each Contributor\r\ngrants the licenses to its Contributions set forth herein, no assurances\r\nare provided by any Contributor that the Program does not infringe the\r\npatent or other intellectual property rights of any other entity. Each\r\nContributor disclaims any liability to Recipient for claims brought by\r\nany other entity based on infringement of intellectual property rights\r\nor otherwise. As a condition to exercising the rights and licenses\r\ngranted hereunder, each Recipient hereby assumes sole responsibility to\r\nsecure any other intellectual property rights needed, if any. For\r\nexample, if a third party patent license is required to allow Recipient\r\nto distribute the Program, it is Recipient's responsibility to acquire\r\nthat license before distributing the Program.</p>\r\n\r\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\r\nhas sufficient copyright rights in its Contribution, if any, to grant\r\nthe copyright license set forth in this Agreement.</p>\r\n\r\n<p><b>3. REQUIREMENTS</b></p>\r\n\r\n<p>A Contributor may choose to distribute the Program in object code\r\nform under its own license agreement, provided that:</p>\r\n\r\n<p class=\"list\">a) it complies with the terms and conditions of this\r\nAgreement; and</p>\r\n\r\n<p class=\"list\">b) its license agreement:</p>\r\n\r\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\r\nall warranties and conditions, express and implied, including warranties\r\nor conditions of title and non-infringement, and implied warranties or\r\nconditions of merchantability and fitness for a particular purpose;</p>\r\n\r\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\r\nall liability for damages, including direct, indirect, special,\r\nincidental and consequential damages, such as lost profits;</p>\r\n\r\n<p class=\"list\">iii) states that any provisions which differ from this\r\nAgreement are offered by that Contributor alone and not by any other\r\nparty; and</p>\r\n\r\n<p class=\"list\">iv) states that source code for the Program is available\r\nfrom such Contributor, and informs licensees how to obtain it in a\r\nreasonable manner on or through a medium customarily used for software\r\nexchange.</p>\r\n\r\n<p>When the Program is made available in source code form:</p>\r\n\r\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\r\n\r\n<p class=\"list\">b) a copy of this Agreement must be included with each\r\ncopy of the Program.</p>\r\n\r\n<p>Contributors may not remove or alter any copyright notices contained\r\nwithin the Program.</p>\r\n\r\n<p>Each Contributor must identify itself as the originator of its\r\nContribution, if any, in a manner that reasonably allows subsequent\r\nRecipients to identify the originator of the Contribution.</p>\r\n\r\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\r\n\r\n<p>Commercial distributors of software may accept certain\r\nresponsibilities with respect to end users, business partners and the\r\nlike. While this license is intended to facilitate the commercial use of\r\nthe Program, the Contributor who includes the Program in a commercial\r\nproduct offering should do so in a manner which does not create\r\npotential liability for other Contributors. Therefore, if a Contributor\r\nincludes the Program in a commercial product offering, such Contributor\r\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\r\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\r\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\r\narising from claims, lawsuits and other legal actions brought by a third\r\nparty against the Indemnified Contributor to the extent caused by the\r\nacts or omissions of such Commercial Contributor in connection with its\r\ndistribution of the Program in a commercial product offering. The\r\nobligations in this section do not apply to any claims or Losses\r\nrelating to any actual or alleged intellectual property infringement. In\r\norder to qualify, an Indemnified Contributor must: a) promptly notify\r\nthe Commercial Contributor in writing of such claim, and b) allow the\r\nCommercial Contributor to control, and cooperate with the Commercial\r\nContributor in, the defense and any related settlement negotiations. The\r\nIndemnified Contributor may participate in any such claim at its own\r\nexpense.</p>\r\n\r\n<p>For example, a Contributor might include the Program in a commercial\r\nproduct offering, Product X. That Contributor is then a Commercial\r\nContributor. If that Commercial Contributor then makes performance\r\nclaims, or offers warranties related to Product X, those performance\r\nclaims and warranties are such Commercial Contributor's responsibility\r\nalone. Under this section, the Commercial Contributor would have to\r\ndefend claims against the other Contributors related to those\r\nperformance claims and warranties, and if a court requires any other\r\nContributor to pay any damages as a result, the Commercial Contributor\r\nmust pay those damages.</p>\r\n\r\n<p><b>5. NO WARRANTY</b></p>\r\n\r\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\r\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\r\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\r\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\r\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\r\nresponsible for determining the appropriateness of using and\r\ndistributing the Program and assumes all risks associated with its\r\nexercise of rights under this Agreement , including but not limited to\r\nthe risks and costs of program errors, compliance with applicable laws,\r\ndamage to or loss of data, programs or equipment, and unavailability or\r\ninterruption of operations.</p>\r\n\r\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\r\n\r\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\r\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\r\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\r\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\r\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\r\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\r\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\r\n\r\n<p><b>7. GENERAL</b></p>\r\n\r\n<p>If any provision of this Agreement is invalid or unenforceable under\r\napplicable law, it shall not affect the validity or enforceability of\r\nthe remainder of the terms of this Agreement, and without further action\r\nby the parties hereto, such provision shall be reformed to the minimum\r\nextent necessary to make such provision valid and enforceable.</p>\r\n\r\n<p>If Recipient institutes patent litigation against any entity\r\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\r\nProgram itself (excluding combinations of the Program with other\r\nsoftware or hardware) infringes such Recipient's patent(s), then such\r\nRecipient's rights granted under Section 2(b) shall terminate as of the\r\ndate such litigation is filed.</p>\r\n\r\n<p>All Recipient's rights under this Agreement shall terminate if it\r\nfails to comply with any of the material terms or conditions of this\r\nAgreement and does not cure such failure in a reasonable period of time\r\nafter becoming aware of such noncompliance. If all Recipient's rights\r\nunder this Agreement terminate, Recipient agrees to cease use and\r\ndistribution of the Program as soon as reasonably practicable. However,\r\nRecipient's obligations under this Agreement and any licenses granted by\r\nRecipient relating to the Program shall continue and survive.</p>\r\n\r\n<p>Everyone is permitted to copy and distribute copies of this\r\nAgreement, but in order to avoid inconsistency the Agreement is\r\ncopyrighted and may only be modified in the following manner. The\r\nAgreement Steward reserves the right to publish new versions (including\r\nrevisions) of this Agreement from time to time. No one other than the\r\nAgreement Steward has the right to modify this Agreement. The Eclipse\r\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\r\nassign the responsibility to serve as the Agreement Steward to a\r\nsuitable separate entity. Each new version of the Agreement will be\r\ngiven a distinguishing version number. The Program (including\r\nContributions) may always be distributed subject to the version of the\r\nAgreement under which it was received. In addition, after a new version\r\nof the Agreement is published, Contributor may elect to distribute the\r\nProgram (including its Contributions) under the new version. Except as\r\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\r\nrights or licenses to the intellectual property of any Contributor under\r\nthis Agreement, whether expressly, by implication, estoppel or\r\notherwise. All rights in the Program not expressly granted under this\r\nAgreement are reserved.</p>\r\n\r\n<p>This Agreement is governed by the laws of the State of New York and\r\nthe intellectual property laws of the United States of America. No party\r\nto this Agreement will bring a legal action under this Agreement more\r\nthan one year after the cause of action arose. Each party waives its\r\nrights to a jury trial in any resulting litigation.</p>\r\n\r\n</body>\r\n\r\n</html>\r\n"
  },
  {
    "path": "pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\txsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n\t<modelVersion>4.0.0</modelVersion>\n\t<groupId>galdolber</groupId>\n\t<artifactId>clojure-objc</artifactId>\n\t<name>clojure-objc</name>\n\t<packaging>jar</packaging>\n\t<version>1.7.0-RC2</version>\n\t\n\t<distributionManagement>\n    <repository>\n      <id>clojars</id>\n      <name>Clojars repository</name>\n      <url>https://clojars.org/repo</url>\n    </repository>\n  </distributionManagement>\n\n\t<url>http://clojure.org/</url>\n\t<description>Clojure core environment and runtime library.</description>\n\n\t<developers>\n\t\t<developer>\n\t\t\t<name>Rich Hickey</name>\n\t\t\t<email>richhickey@gmail.com</email>\n\t\t\t<timezone>-5</timezone>\n\t\t</developer>\n\t</developers>\n\n\t<licenses>\n\t\t<license>\n\t\t\t<name>Eclipse Public License 1.0</name>\n\t\t\t<url>http://opensource.org/licenses/eclipse-1.0.php</url>\n\t\t\t<distribution>repo</distribution>\n\t\t</license>\n\t</licenses>\n\n\t<scm>\n\t\t<connection>scm:git:git@github.com:galdolber/clojure-objc.git</connection>\n\t\t<developerConnection>scm:git:git@github.com:galdolber/clojure-objc.git</developerConnection>\n\t\t<url>git@github.com:galdolber/clojure-objc.git</url>\n\t</scm>\n\n\t<dependencies>\n\t\t<dependency>\n\t\t\t<groupId>org.codehaus.jsr166-mirror</groupId>\n\t\t\t<artifactId>jsr166y</artifactId>\n\t\t\t<version>1.7.0</version>\n\t\t\t<scope>provided</scope>\n\t\t</dependency>\n\t\t<dependency>\n\t\t\t<groupId>org.clojure</groupId>\n\t\t\t<artifactId>test.generative</artifactId>\n\t\t\t<version>0.5.2</version>\n\t\t\t<scope>test</scope>\n\t\t\t<exclusions>\n\t\t\t\t<exclusion>\n\t\t\t\t\t<groupId>org.clojure</groupId>\n\t\t\t\t\t<artifactId>clojure</artifactId>\n\t\t\t\t</exclusion>\n\t\t\t</exclusions>\n\t\t</dependency>\n\t\t<dependency>\n\t\t\t<groupId>org.clojure</groupId>\n\t\t\t<artifactId>test.check</artifactId>\n\t\t\t<version>0.5.9</version>\n\t\t\t<scope>test</scope>\n\t\t\t<exclusions>\n\t\t\t\t<exclusion>\n\t\t\t\t\t<groupId>org.clojure</groupId>\n\t\t\t\t\t<artifactId>clojure</artifactId>\n\t\t\t\t</exclusion>\n\t\t\t</exclusions>\n\t\t</dependency>\n\t</dependencies>\n\n\t<build>\n\t\t<resources>\n\t\t\t<resource>\n\t\t\t\t<directory>src/resources</directory>\n\t\t\t\t<filtering>true</filtering>\n\t\t\t</resource>\n\t\t\t<resource>\n\t\t\t\t<directory>src/clj</directory>\n\t\t\t</resource>\n\t\t</resources>\n\t\t<testSourceDirectory>test/java</testSourceDirectory>\n\t\t<plugins>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n\t\t\t\t<artifactId>maven-compiler-plugin</artifactId>\n\t\t\t\t<version>2.3.2</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<source>1.6</source>\n\t\t\t\t\t<target>1.6</target>\n\t\t\t\t\t<encoding>${project.build.sourceEncoding}</encoding>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<artifactId>maven-antrun-plugin</artifactId>\n\t\t\t\t<version>1.6</version>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>clojure-compile</id>\n\t\t\t\t\t\t<phase>compile</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>run</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t\t<configuration>\n\t\t\t\t\t\t\t<target>\n\t\t\t\t\t\t\t\t<property name=\"maven.compile.classpath\" refid=\"maven.compile.classpath\" />\n\t\t\t\t\t\t\t\t<ant target=\"compile-clojure\" />\n\t\t\t\t\t\t\t</target>\n\t\t\t\t\t\t</configuration>\n\t\t\t\t\t</execution>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>clojure-test</id>\n\t\t\t\t\t\t<phase>test</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>run</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t\t<configuration>\n\t\t\t\t\t\t\t<target>\n\t\t\t\t\t\t\t\t<property name=\"maven.test.classpath\" refid=\"maven.test.classpath\" />\n\t\t\t\t\t\t\t\t<ant target=\"test\" />\n\t\t\t\t\t\t\t</target>\n\t\t\t\t\t\t</configuration>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<groupId>org.codehaus.mojo</groupId>\n\t\t\t\t<artifactId>build-helper-maven-plugin</artifactId>\n\t\t\t\t<version>1.5</version>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>add-clojure-source-dirs</id>\n\t\t\t\t\t\t<phase>generate-sources</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>add-source</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t\t<configuration>\n\t\t\t\t\t\t\t<sources>\n\t\t\t\t\t\t\t\t<source>src/jvm</source>\n\t\t\t\t\t\t\t</sources>\n\t\t\t\t\t\t</configuration>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<artifactId>maven-assembly-plugin</artifactId>\n\t\t\t\t<version>2.2</version>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>clojure-slim-jar</id>\n\t\t\t\t\t\t<phase>package</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>single</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t\t<configuration>\n\t\t\t\t\t\t\t<descriptors>\n\t\t\t\t\t\t\t\t<descriptor>src/assembly/slim.xml</descriptor>\n\t\t\t\t\t\t\t</descriptors>\n\t\t\t\t\t\t\t<archive>\n\t\t\t\t\t\t\t\t<manifest>\n\t\t\t\t\t\t\t\t\t<mainClass>clojure.main</mainClass>\n\t\t\t\t\t\t\t\t</manifest>\n\t\t\t\t\t\t\t</archive>\n\t\t\t\t\t\t</configuration>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<artifactId>maven-jar-plugin</artifactId>\n\t\t\t\t<version>2.3.1</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<archive>\n\t\t\t\t\t\t<manifest>\n\t\t\t\t\t\t\t<mainClass>clojure.main</mainClass>\n\t\t\t\t\t\t</manifest>\n\t\t\t\t\t</archive>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<artifactId>maven-source-plugin</artifactId>\n\t\t\t\t<version>2.1.2</version>\n\t\t\t\t<executions>\n\t\t\t\t\t<execution>\n\t\t\t\t\t\t<id>sources-jar</id>\n\t\t\t\t\t\t<phase>package</phase>\n\t\t\t\t\t\t<goals>\n\t\t\t\t\t\t\t<goal>jar</goal>\n\t\t\t\t\t\t</goals>\n\t\t\t\t\t\t<configuration>\n\t\t\t\t\t\t\t<excludes>\n\t\t\t\t\t\t\t\t<exclude>clojure/version.properties</exclude>\n\t\t\t\t\t\t\t</excludes>\n\t\t\t\t\t\t</configuration>\n\t\t\t\t\t</execution>\n\t\t\t\t</executions>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<!-- do not push SCM changes to upstream repository; prevents pushing \n\t\t\t\t\ttags/commits for failed releases; instead, push SCM changes in Hudson configuration -->\n\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n\t\t\t\t<artifactId>maven-release-plugin</artifactId>\n\t\t\t\t<version>2.1</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<pushChanges>false</pushChanges>\n\t\t\t\t\t<localCheckout>true</localCheckout>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t\t<plugin>\n\t\t\t\t<!-- disable the Surefire testing plugin -->\n\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n\t\t\t\t<artifactId>maven-surefire-plugin</artifactId>\n\t\t\t\t<version>2.6</version>\n\t\t\t\t<configuration>\n\t\t\t\t\t<skip>true</skip>\n\t\t\t\t</configuration>\n\t\t\t</plugin>\n\t\t</plugins>\n\t</build>\n</project>\n"
  },
  {
    "path": "readme.md",
    "content": "# clojure-objc\n\nA Clojure compiler that targets objc runtimes.\n\n * Write native apps in Clojure\n * Strong iOS support\n * Future proof: shares 99.99% of the code base with clojure for the jvm\n * Distribute clojure-objc libs using maven\n * Most existing Clojure libs should just work\n * ObjC interop\n * C interop\n * ObjC subclassing\n * REPL!\n\n![alt usage guide](https://github.com/galdolber/clojure-objc-sample/raw/master/ios.gif)\n\n## Leiningen plugin\n \n https://github.com/galdolber/lein-objcbuild\n \n## Dependency\n\n[![Clojars Project](http://clojars.org/galdolber/clojure-objc/latest-version.svg)](http://clojars.org/galdolber/clojure-objc)\n \n## Memory management\n \n All generated code manage memory automagically, but if you alloc with interop you need to release!\n \n## ObjC interop\n    \n    ;; calling objc methods\n    (defn say-hi [name]\n      (-> ($ UIAlertView)\n          ($ :alloc)\n          ($ :initWithTitle (str \"Hello \" name)\n             :message \"Hi! from clojure\"\n             :delegate nil\n             :cancelButtonTitle \"Cancelar\"\n             :otherButtonTitles nil)\n          ($ :autorelease)\n          ($ :show)))\n \n    ;; extend objc class\n    (defnstype UIKitController UIViewController\n      ([^:id self :initWith ^:id [view s]]\n         (doto ($$ self :init)\n           ($ :setView ($ view :retain))\n           (objc-set! :scope s)\n           (#(post-notification ($ % :view) :init)))))\n           \n    ;; c interop\n    (defc NSLog :void [:id &]) ; & for variadic\n    (NSLog \"%@ %@ %d\" \"Hello\" \"World\" 13)\n\n    ;; proxy objc class\n    (nsproxy\n      ([^:bool self :textFieldShouldReturn ^:id field]\n        ($ field :resignFirstResponder) \n        true))\n      \n## Presentations\n\nhttp://www.slideshare.net/GalDolber/clojureobjc-47500127\n \n## Discuss\n \n https://groups.google.com/d/forum/clojure-objc-discuss\n \n## How to build dist\n \n lein exec build.clj\n\n## License\n\nPortions of this project derived from Clojure:\nCopyright © 2006-2015 Rich Hickey\n\nOriginal code and Clojure modifications:\nCopyright © 2014-2015 Gal Dolber\n\nBoth are distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.\n"
  },
  {
    "path": "release.sh",
    "content": "export KEEP_META=false\nrm -Rf target/release\nmkdir target/release\ncp target/libclojure-objc.a target/release/\ncp $J2OBJC_HOME/lib/libjre_emul.a target/release/\ncp src/ffi/libffi.a target/release/\nmkdir target/release/include\nrsync -a $J2OBJC_HOME/include target/release\nrsync -a target/include target/release\ncp $J2OBJC_HOME/j2objc target/release/\nmkdir target/release/lib\ncp $J2OBJC_HOME/lib/j2objc_annotations.jar target/release/lib\ncp $J2OBJC_HOME/lib/j2objc.jar target/release/lib\ncp $J2OBJC_HOME/lib/jre_emul.jar target/release/lib\ncd ./target/release\nzip -r ../release.zip .\n"
  },
  {
    "path": "src/assembly/distribution.xml",
    "content": "<assembly>\n  <id>distribution</id>\n  <formats>\n    <format>zip</format>\n  </formats>\n  <fileSets>\n    <fileSet>\n      <directory>src</directory>\n      <outputDirectory>src</outputDirectory>\n    </fileSet>\n    <fileSet>\n      <directory>doc</directory>\n      <outputDirectory>doc</outputDirectory>\n    </fileSet>\n    <fileSet>\n      <directory>test</directory>\n      <outputDirectory>test</outputDirectory>\n    </fileSet>\n    <fileSet>\n      <directory>target</directory>\n      <outputDirectory>/</outputDirectory>\n      <filtered>false</filtered>\n      <includes>\n\t<include>*.jar</include>\n      </includes>\n    </fileSet>\n  </fileSets>\n  <files>\n    <file>\n      <source>pom.xml</source>\n    </file>\n    <file>\n      <source>build.xml</source>\n    </file>\n    <file>\n      <source>readme.txt</source>\n      <filtered>true</filtered>\n    </file>\n    <file>\n      <source>changes.md</source>\n    </file>\n    <file>\n      <source>clojure.iml</source>\n    </file>\n    <file>\n      <source>epl-v10.html</source>\n    </file>\n  </files>\n</assembly>\n"
  },
  {
    "path": "src/assembly/slim.xml",
    "content": "<assembly>\n  <id>slim</id>\n  <formats>\n    <format>jar</format>\n  </formats>\n  <includeBaseDirectory>false</includeBaseDirectory>\n  <fileSets>\n    <fileSet>\n      <directory>src/clj</directory>\n      <outputDirectory>/</outputDirectory>\n    </fileSet>\n    <fileSet>\n      <directory>src/resources</directory>\n      <outputDirectory>/</outputDirectory>\n      <filtered>true</filtered>\n    </fileSet>\n    <fileSet>\n      <directory>target/classes/clojure/asm</directory>\n      <outputDirectory>clojure/asm</outputDirectory>\n    </fileSet>\n    <fileSet>\n      <directory>target/classes/clojure/lang</directory>\n      <outputDirectory>clojure/lang</outputDirectory>\n    </fileSet>\n  </fileSets>\n  <files>\n    <file>\n      <source>target/classes/clojure/main.class</source>\n      <outputDirectory>clojure</outputDirectory>\n    </file>\n  </files>\n</assembly>\n"
  },
  {
    "path": "src/clj/clojure/core/protocols.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns clojure.core.protocols)\n\n(set! *warn-on-reflection* true)\n\n(defprotocol CollReduce\n  \"Protocol for collection types that can implement reduce faster than\n  first/next recursion. Called by clojure.core/reduce. Baseline\n  implementation defined in terms of Iterable.\"\n  (coll-reduce [coll f] [coll f val]))\n\n(defprotocol InternalReduce\n  \"Protocol for concrete seq types that can reduce themselves\n   faster than first/next recursion. Called by clojure.core/reduce.\"\n  (internal-reduce [seq f start]))\n\n(defn- seq-reduce\n  ([coll f]\n     (if-let [s (seq coll)]\n       (internal-reduce (next s) f (first s))\n       (f)))\n  ([coll f val]\n     (let [s (seq coll)]\n       (internal-reduce s f val))))\n\n(defn- iter-reduce\n  ([^java.lang.Iterable coll f]\n   (let [iter (.iterator coll)]\n     (if (.hasNext iter)\n       (loop [ret (.next iter)]\n         (if (.hasNext iter)\n           (let [ret (f ret (.next iter))]\n             (if (reduced? ret)\n               @ret\n               (recur ret)))\n           ret))\n       (f))))\n  ([^java.lang.Iterable coll f val]\n   (let [iter (.iterator coll)]\n     (loop [ret val]\n       (if (.hasNext iter)\n         (let [ret (f ret (.next iter))]\n           (if (reduced? ret)\n             @ret\n             (recur ret)))\n         ret)))))\n\n(defn- naive-seq-reduce\n  \"Reduces a seq, ignoring any opportunities to switch to a more\n  specialized implementation.\"\n  [s f val]\n  (loop [s (seq s)\n         val val]\n    (if s\n      (let [ret (f val (first s))]\n        (if (reduced? ret)\n          @ret\n          (recur (next s) ret)))\n      val)))\n\n(defn- interface-or-naive-reduce\n  \"Reduces via IReduceInit if possible, else naively.\"\n  [coll f val]\n  (if (instance? clojure.lang.IReduceInit coll)\n    (.reduce ^clojure.lang.IReduceInit coll f val)\n    (naive-seq-reduce coll f val)))\n\n(extend-protocol CollReduce\n  nil\n  (coll-reduce\n   ([coll f] (f))\n   ([coll f val] val))\n\n  Object\n  (coll-reduce\n   ([coll f] (seq-reduce coll f))\n   ([coll f val] (seq-reduce coll f val)))\n\n  clojure.lang.IReduceInit\n  (coll-reduce\n    ([coll f] (.reduce ^clojure.lang.IReduce coll f))\n    ([coll f val] (.reduce coll f val)))\n\n  ;;aseqs are iterable, masking internal-reducers\n  clojure.lang.ASeq\n  (coll-reduce\n   ([coll f] (seq-reduce coll f))\n   ([coll f val] (seq-reduce coll f val)))\n\n  ;;for range\n  clojure.lang.LazySeq\n  (coll-reduce\n   ([coll f] (seq-reduce coll f))\n   ([coll f val] (seq-reduce coll f val)))\n\n  ;;vector's chunked seq is faster than its iter\n  clojure.lang.PersistentVector\n  (coll-reduce\n   ([coll f] (seq-reduce coll f))\n   ([coll f val] (seq-reduce coll f val)))\n\n  Iterable\n  (coll-reduce\n   ([coll f] (iter-reduce coll f))\n   ([coll f val] (iter-reduce coll f val)))\n\n  clojure.lang.APersistentMap$KeySeq\n  (coll-reduce\n    ([coll f] (iter-reduce coll f))\n    ([coll f val] (iter-reduce coll f val)))\n\n  clojure.lang.APersistentMap$ValSeq\n  (coll-reduce\n    ([coll f] (iter-reduce coll f))\n    ([coll f val] (iter-reduce coll f val))))\n\n(extend-protocol InternalReduce\n  nil\n  (internal-reduce\n   [s f val]\n   val)\n  \n  ;; handles vectors and ranges\n  clojure.lang.IChunkedSeq\n  (internal-reduce\n   [s f val]\n   (if-let [s (seq s)]\n     (if (chunked-seq? s)\n       (let [ret (.reduce (chunk-first s) f val)]\n         (if (reduced? ret)\n           @ret\n           (recur (chunk-next s)\n                  f\n                  ret)))\n       (interface-or-naive-reduce s f val))\n     val))\n \n  clojure.lang.StringSeq\n  (internal-reduce\n   [str-seq f val]\n   (let [s (.s str-seq)]\n     (loop [i (.i str-seq)\n            val val]\n       (if (< i (.length s))\n         (let [ret (f val (.charAt s i))]\n                (if (reduced? ret)\n                  @ret\n                  (recur (inc i) ret)))\n         val))))\n  \n  java.lang.Object\n  (internal-reduce\n   [s f val]\n   (loop [cls (class s)\n          s s\n          f f\n          val val]\n     (if-let [s (seq s)]\n       (if (identical? (class s) cls)\n         (let [ret (f val (first s))]\n                (if (reduced? ret)\n                  @ret\n                  (recur cls (next s) f ret)))\n         (interface-or-naive-reduce s f val))\n       val))))\n\n(defprotocol IKVReduce\n  \"Protocol for concrete associative types that can reduce themselves\n   via a function of key and val faster than first/next recursion over map\n   entries. Called by clojure.core/reduce-kv, and has same\n   semantics (just different arg order).\"\n  (kv-reduce [amap f init]))\n"
  },
  {
    "path": "src/clj/clojure/core/reducers.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns ^{:doc\n      \"A library for reduction and parallel folding. Alpha and subject\n      to change.  Note that fold and its derivatives require Java 7+ or\n      Java 6 + jsr166y.jar for fork/join support. See Clojure's pom.xml for the\n      dependency info.\"\n      :author \"Rich Hickey\"}\n  clojure.core.reducers\n  (:refer-clojure :exclude [reduce map mapcat filter remove take take-while drop flatten cat])\n  (:require [clojure.walk :as walk]))\n\n(alias 'core 'clojure.core)\n(set! *warn-on-reflection* true)\n\n;;;;;;;;;;;;;; some fj stuff ;;;;;;;;;;\n\n(defmacro ^:private compile-if\n  \"Evaluate `exp` and if it returns logical true and doesn't error, expand to\n  `then`.  Else expand to `else`.\n\n  (compile-if (Class/forName \\\"java.util.concurrent.ForkJoinTask\\\")\n    (do-cool-stuff-with-fork-join)\n    (fall-back-to-executor-services))\"\n  [exp then else]\n  (if (try (eval exp)\n           (catch Throwable _ false))\n    `(do ~then)\n    `(do ~else)))\n\n(compile-if\n (Class/forName \"java.util.concurrent.ForkJoinTask\")\n ;; We're running a JDK 7+\n (do\n   (def pool (delay (java.util.concurrent.ForkJoinPool.)))\n\n   (defn fjtask [^Callable f]\n     (java.util.concurrent.ForkJoinTask/adapt f))\n\n   (defn- fjinvoke [f]\n     (if (java.util.concurrent.ForkJoinTask/inForkJoinPool)\n       (f)\n       (.invoke ^java.util.concurrent.ForkJoinPool @pool ^java.util.concurrent.ForkJoinTask (fjtask f))))\n\n   (defn- fjfork [task] (.fork ^java.util.concurrent.ForkJoinTask task))\n\n   (defn- fjjoin [task] (.join ^java.util.concurrent.ForkJoinTask task)))\n ;; We're running a JDK <7\n (do\n   (def pool (delay (jsr166y.ForkJoinPool.)))\n\n   (defn fjtask [^Callable f]\n     (jsr166y.ForkJoinTask/adapt f))\n\n   (defn- fjinvoke [f]\n     (if (jsr166y.ForkJoinTask/inForkJoinPool)\n       (f)\n       (.invoke ^jsr166y.ForkJoinPool @pool ^jsr166y.ForkJoinTask (fjtask f))))\n\n   (defn- fjfork [task] (.fork ^jsr166y.ForkJoinTask task))\n\n   (defn- fjjoin [task] (.join ^jsr166y.ForkJoinTask task))))\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn reduce\n  \"Like core/reduce except:\n     When init is not provided, (f) is used.\n     Maps are reduced with reduce-kv\"\n  ([f coll] (reduce f (f) coll))\n  ([f init coll]\n     (if (instance? java.util.Map coll)\n       (clojure.core.protocols/kv-reduce coll f init)\n       (clojure.core.protocols/coll-reduce coll f init))))\n\n(defprotocol CollFold\n  (coll-fold [coll n combinef reducef]))\n\n(defn fold\n  \"Reduces a collection using a (potentially parallel) reduce-combine\n  strategy. The collection is partitioned into groups of approximately\n  n (default 512), each of which is reduced with reducef (with a seed\n  value obtained by calling (combinef) with no arguments). The results\n  of these reductions are then reduced with combinef (default\n  reducef). combinef must be associative, and, when called with no\n  arguments, (combinef) must produce its identity element. These\n  operations may be performed in parallel, but the results will\n  preserve order.\"\n  {:added \"1.5\"}\n  ([reducef coll] (fold reducef reducef coll))\n  ([combinef reducef coll] (fold 512 combinef reducef coll))\n  ([n combinef reducef coll]\n     (coll-fold coll n combinef reducef)))\n\n(defn reducer\n  \"Given a reducible collection, and a transformation function xf,\n  returns a reducible collection, where any supplied reducing\n  fn will be transformed by xf. xf is a function of reducing fn to\n  reducing fn.\"\n  {:added \"1.5\"}\n  ([coll xf]\n     (reify\n      clojure.core.protocols/CollReduce\n      (coll-reduce [this f1]\n                   (clojure.core.protocols/coll-reduce this f1 (f1)))\n      (coll-reduce [_ f1 init]\n                   (clojure.core.protocols/coll-reduce coll (xf f1) init)))))\n\n(defn folder\n  \"Given a foldable collection, and a transformation function xf,\n  returns a foldable collection, where any supplied reducing\n  fn will be transformed by xf. xf is a function of reducing fn to\n  reducing fn.\"\n  {:added \"1.5\"}\n  ([coll xf]\n     (reify\n      clojure.core.protocols/CollReduce\n      (coll-reduce [_ f1]\n                   (clojure.core.protocols/coll-reduce coll (xf f1) (f1)))\n      (coll-reduce [_ f1 init]\n                   (clojure.core.protocols/coll-reduce coll (xf f1) init))\n\n      CollFold\n      (coll-fold [_ n combinef reducef]\n                 (coll-fold coll n combinef (xf reducef))))))\n\n(defn- do-curried\n  [name doc meta args body]\n  (let [cargs (vec (butlast args))]\n    `(defn ~name ~doc ~meta\n       (~cargs (fn [x#] (~name ~@cargs x#)))\n       (~args ~@body))))\n\n(defmacro ^:private defcurried\n  \"Builds another arity of the fn that returns a fn awaiting the last\n  param\"\n  [name doc meta args & body]\n  (do-curried name doc meta args body))\n\n(defn- do-rfn [f1 k fkv]\n  `(fn\n     ([] (~f1))\n     ~(clojure.walk/postwalk\n       #(if (sequential? %)\n          ((if (vector? %) vec identity)\n           (core/remove #{k} %))\n          %)\n       fkv)\n     ~fkv))\n\n(defmacro ^:private rfn\n  \"Builds 3-arity reducing fn given names of wrapped fn and key, and k/v impl.\"\n  [[f1 k] fkv]\n  (do-rfn f1 k fkv))\n\n(defcurried map\n  \"Applies f to every value in the reduction of coll. Foldable.\"\n  {:added \"1.5\"}\n  [f coll]\n  (folder coll\n   (fn [f1]\n     (rfn [f1 k]\n          ([ret k v]\n             (f1 ret (f k v)))))))\n\n(defcurried mapcat\n  \"Applies f to every value in the reduction of coll, concatenating the result\n  colls of (f val). Foldable.\"\n  {:added \"1.5\"}\n  [f coll]\n  (folder coll\n   (fn [f1]\n     (let [f1 (fn\n                ([ret v]\n                  (let [x (f1 ret v)] (if (reduced? x) (reduced x) x)))\n                ([ret k v]\n                  (let [x (f1 ret k v)] (if (reduced? x) (reduced x) x))))]\n       (rfn [f1 k]\n            ([ret k v]\n               (reduce f1 ret (f k v))))))))\n\n(defcurried filter\n  \"Retains values in the reduction of coll for which (pred val)\n  returns logical true. Foldable.\"\n  {:added \"1.5\"}\n  [pred coll]\n  (folder coll\n   (fn [f1]\n     (rfn [f1 k]\n          ([ret k v]\n             (if (pred k v)\n               (f1 ret k v)\n               ret))))))\n\n(defcurried remove\n  \"Removes values in the reduction of coll for which (pred val)\n  returns logical true. Foldable.\"\n  {:added \"1.5\"}\n  [pred coll]\n  (filter (complement pred) coll))\n\n(defcurried flatten\n  \"Takes any nested combination of sequential things (lists, vectors,\n  etc.) and returns their contents as a single, flat foldable\n  collection.\"\n  {:added \"1.5\"}\n  [coll]\n  (folder coll\n   (fn [f1]\n     (fn\n       ([] (f1))\n       ([ret v]\n          (if (sequential? v)\n            (clojure.core.protocols/coll-reduce (flatten v) f1 ret)\n            (f1 ret v)))))))\n\n(defcurried take-while\n  \"Ends the reduction of coll when (pred val) returns logical false.\"\n  {:added \"1.5\"}\n  [pred coll]\n  (reducer coll\n   (fn [f1]\n     (rfn [f1 k]\n          ([ret k v]\n             (if (pred k v)\n               (f1 ret k v)\n               (reduced ret)))))))\n\n(defcurried take\n  \"Ends the reduction of coll after consuming n values.\"\n  {:added \"1.5\"}\n  [n coll]\n  (reducer coll\n   (fn [f1]\n     (let [cnt (atom n)]\n       (rfn [f1 k]\n         ([ret k v]\n            (swap! cnt dec)\n            (if (neg? @cnt)\n              (reduced ret)\n              (f1 ret k v))))))))\n\n(defcurried drop\n  \"Elides the first n values from the reduction of coll.\"\n  {:added \"1.5\"}\n  [n coll]\n  (reducer coll\n   (fn [f1]\n     (let [cnt (atom n)]\n       (rfn [f1 k]\n         ([ret k v]\n            (swap! cnt dec)\n            (if (neg? @cnt)\n              (f1 ret k v)\n              ret)))))))\n\n;;do not construct this directly, use cat\n(deftype Cat [cnt left right]\n  clojure.lang.Counted\n  (count [_] cnt)\n\n  clojure.lang.Seqable\n  (seq [_] (concat (seq left) (seq right)))\n\n  clojure.core.protocols/CollReduce\n  (coll-reduce [this f1] (clojure.core.protocols/coll-reduce this f1 (f1)))\n  (coll-reduce\n   [_  f1 init]\n   (clojure.core.protocols/coll-reduce\n    right f1\n    (clojure.core.protocols/coll-reduce left f1 init)))\n\n  CollFold\n  (coll-fold\n   [_ n combinef reducef]\n   (fjinvoke\n    (fn []\n      (let [rt (fjfork (fjtask #(coll-fold right n combinef reducef)))]\n        (combinef\n         (coll-fold left n combinef reducef)\n         (fjjoin rt)))))))\n\n(defn cat\n  \"A high-performance combining fn that yields the catenation of the\n  reduced values. The result is reducible, foldable, seqable and\n  counted, providing the identity collections are reducible, seqable\n  and counted. The single argument version will build a combining fn\n  with the supplied identity constructor. Tests for identity\n  with (zero? (count x)). See also foldcat.\"\n  {:added \"1.5\"}\n  ([] (java.util.ArrayList.))\n  ([ctor]\n     (fn\n       ([] (ctor))\n       ([left right] (cat left right))))\n  ([left right]\n     (cond\n      (zero? (count left)) right\n      (zero? (count right)) left\n      :else\n      (Cat. (+ (count left) (count right)) left right))))\n\n(defn append!\n  \".adds x to acc and returns acc\"\n  {:added \"1.5\"}\n  [^java.util.Collection acc x]\n  (doto acc (.add x)))\n\n(defn foldcat\n  \"Equivalent to (fold cat append! coll)\"\n  {:added \"1.5\"}\n  [coll]\n  (fold cat append! coll))\n\n(defn monoid\n  \"Builds a combining fn out of the supplied operator and identity\n  constructor. op must be associative and ctor called with no args\n  must return an identity value for it.\"\n  {:added \"1.5\"}\n  [op ctor]\n  (fn m\n    ([] (ctor))\n    ([a b] (op a b))))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; fold impls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defn- foldvec\n  [v n combinef reducef]\n  (cond\n   (empty? v) (combinef)\n   (<= (count v) n) (reduce reducef (combinef) v)\n   :else\n   (let [split (quot (count v) 2)\n         v1 (subvec v 0 split)\n         v2 (subvec v split (count v))\n         fc (fn [child] #(foldvec child n combinef reducef))]\n     (fjinvoke\n      #(let [f1 (fc v1)\n             t2 (fjtask (fc v2))]\n         (fjfork t2)\n         (combinef (f1) (fjjoin t2)))))))\n\n(extend-protocol CollFold\n nil\n (coll-fold\n  [coll n combinef reducef]\n  (combinef))\n\n Object\n (coll-fold\n  [coll n combinef reducef]\n  ;;can't fold, single reduce\n  (reduce reducef (combinef) coll))\n\n clojure.lang.IPersistentVector\n (coll-fold\n  [v n combinef reducef]\n  (foldvec v n combinef reducef))\n\n clojure.lang.PersistentHashMap\n (coll-fold\n  [m n combinef reducef]\n  (.fold m n combinef reducef fjinvoke fjtask fjfork fjjoin)))\n"
  },
  {
    "path": "src/clj/clojure/core.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns ^{:doc \"The core Clojure language.\"\n       :author \"Rich Hickey\"}\n  clojure.core)\n\n(def unquote)\n(def unquote-splicing)\n\n(def\n ^{:arglists '([& items])\n   :doc \"Creates a new list containing the items.\"\n   :added \"1.0\"}\n  list (. clojure.lang.PersistentList creator))\n\n(def\n ^{:arglists '([x seq])\n    :doc \"Returns a new seq where x is the first element and seq is\n    the rest.\"\n   :added \"1.0\"\n   :static true}\n\n cons (fn* ^:static cons [x seq] (. clojure.lang.RT (cons x seq))))\n\n;during bootstrap we don't have destructuring let, loop or fn, will redefine later\n(def\n  ^{:macro true\n    :added \"1.0\"}\n  let (fn* let [&form &env & decl] (cons 'let* decl)))\n\n(def\n ^{:macro true\n   :added \"1.0\"}\n loop (fn* loop [&form &env & decl] (cons 'loop* decl)))\n\n(def\n ^{:macro true\n   :added \"1.0\"}\n fn (fn* fn [&form &env & decl] \n         (.withMeta ^clojure.lang.IObj (cons 'fn* decl) \n                    (.meta ^clojure.lang.IMeta &form))))\n\n(def\n ^{:arglists '([coll])\n   :doc \"Returns the first item in the collection. Calls seq on its\n    argument. If coll is nil, returns nil.\"\n   :added \"1.0\"\n   :static true}\n first (fn ^:static first [coll] (. clojure.lang.RT (first coll))))\n\n(def\n ^{:arglists '([coll])\n   :tag clojure.lang.ISeq\n   :doc \"Returns a seq of the items after the first. Calls seq on its\n  argument.  If there are no more items, returns nil.\"\n   :added \"1.0\"\n   :static true}  \n next (fn ^:static next [x] (. clojure.lang.RT (next x))))\n\n(def\n ^{:arglists '([coll])\n   :tag clojure.lang.ISeq\n   :doc \"Returns a possibly empty seq of the items after the first. Calls seq on its\n  argument.\"\n   :added \"1.0\"\n   :static true}  \n rest (fn ^:static rest [x] (. clojure.lang.RT (more x))))\n\n(def\n ^{:arglists '([coll x] [coll x & xs])\n   :doc \"conj[oin]. Returns a new collection with the xs\n    'added'. (conj nil item) returns (item).  The 'addition' may\n    happen at different 'places' depending on the concrete type.\"\n   :added \"1.0\"\n   :static true}\n conj (fn ^:static conj\n        ([] [])\n        ([coll] coll)\n        ([coll x] (. clojure.lang.RT (conj coll x)))\n        ([coll x & xs]\n         (if xs\n           (recur (conj coll x) (first xs) (next xs))\n           (conj coll x)))))\n\n(def\n ^{:doc \"Same as (first (next x))\"\n   :arglists '([x])\n   :added \"1.0\"\n   :static true}\n second (fn ^:static second [x] (first (next x))))\n\n(def\n ^{:doc \"Same as (first (first x))\"\n   :arglists '([x])\n   :added \"1.0\"\n   :static true}\n ffirst (fn ^:static ffirst [x] (first (first x))))\n\n(def\n ^{:doc \"Same as (next (first x))\"\n   :arglists '([x])\n   :added \"1.0\"\n   :static true}\n nfirst (fn ^:static nfirst [x] (next (first x))))\n\n(def\n ^{:doc \"Same as (first (next x))\"\n   :arglists '([x])\n   :added \"1.0\"\n   :static true}\n fnext (fn ^:static fnext [x] (first (next x))))\n\n(def\n ^{:doc \"Same as (next (next x))\"\n   :arglists '([x])\n   :added \"1.0\"\n   :static true}\n nnext (fn ^:static nnext [x] (next (next x))))\n\n(def\n ^{:arglists '(^clojure.lang.ISeq [coll])\n   :doc \"Returns a seq on the collection. If the collection is\n    empty, returns nil.  (seq nil) returns nil. seq also works on\n    Strings, native Java arrays (of reference types) and any objects\n    that implement Iterable. Note that seqs cache values, thus seq\n    should not be used on any Iterable whose iterator repeatedly\n    returns the same mutable object.\"\n   :tag clojure.lang.ISeq\n   :added \"1.0\"\n   :static true}\n seq (fn ^:static seq ^clojure.lang.ISeq [coll] (. clojure.lang.RT (seq coll))))\n\n(def\n ^{:arglists '([^Class c x])\n   :doc \"Evaluates x and tests if it is an instance of the class\n    c. Returns true or false\"\n   :added \"1.0\"}\n instance? (fn instance? [^Class c x] (. c (isInstance x))))\n\n(def\n ^{:arglists '([x])\n   :doc \"Return true if x implements ISeq\"\n   :added \"1.0\"\n   :static true}\n seq? (fn ^:static seq? [x] (instance? clojure.lang.ISeq x)))\n\n(def\n ^{:arglists '([x])\n   :doc \"Return true if x is a Character\"\n   :added \"1.0\"\n   :static true}\n char? (fn ^:static char? [x] (instance? Character x)))\n\n(def\n ^{:arglists '([x])\n   :doc \"Return true if x is a String\"\n   :added \"1.0\"\n   :static true}\n string? (fn ^:static string? [x] (instance? String x)))\n\n(def\n ^{:arglists '([x])\n   :doc \"Return true if x implements IPersistentMap\"\n   :added \"1.0\"\n   :static true}\n map? (fn ^:static map? [x] (instance? clojure.lang.IPersistentMap x)))\n\n(def\n ^{:arglists '([x])\n   :doc \"Return true if x implements IPersistentVector\"\n   :added \"1.0\"\n   :static true}\n vector? (fn ^:static vector? [x] (instance? clojure.lang.IPersistentVector x)))\n\n(def\n ^{:arglists '([map key val] [map key val & kvs])\n   :doc \"assoc[iate]. When applied to a map, returns a new map of the\n    same (hashed/sorted) type, that contains the mapping of key(s) to\n    val(s). When applied to a vector, returns a new vector that\n    contains val at index. Note - index must be <= (count vector).\"\n   :added \"1.0\"\n   :static true}\n assoc\n (fn ^:static assoc\n   ([map key val] (. clojure.lang.RT (assoc map key val)))\n   ([map key val & kvs]\n    (let [ret (assoc map key val)]\n      (if kvs\n        (if (next kvs)\n          (recur ret (first kvs) (second kvs) (nnext kvs))\n          (throw (IllegalArgumentException.\n                  \"assoc expects even number of arguments after map/vector, found odd number\")))\n        ret)))))\n\n;;;;;;;;;;;;;;;;; metadata ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(def\n ^{:arglists '([obj])\n   :doc \"Returns the metadata of obj, returns nil if there is no metadata.\"\n   :added \"1.0\"\n   :static true}\n meta (fn ^:static meta [x]\n        (if (instance? clojure.lang.IMeta x)\n          (. ^clojure.lang.IMeta x (meta)))))\n\n(def\n ^{:arglists '([^clojure.lang.IObj obj m])\n   :doc \"Returns an object of the same type and value as obj, with\n    map m as its metadata.\"\n   :added \"1.0\"\n   :static true}\n with-meta (fn ^:static with-meta [^clojure.lang.IObj x m]\n             (. x (withMeta m))))\n\n(def ^{:private true :dynamic true}\n  assert-valid-fdecl (fn [fdecl]))\n\n(def\n ^{:private true}\n sigs\n (fn [fdecl]\n   (assert-valid-fdecl fdecl)\n   (let [asig\n         (fn [fdecl]\n           (let [arglist (first fdecl)\n                 ;elide implicit macro args\n                 arglist (if (clojure.lang.Util/equals '&form (first arglist))\n                           (clojure.lang.RT/subvec arglist 2 (clojure.lang.RT/count arglist))\n                           arglist)\n                 body (next fdecl)]\n             (if (map? (first body))\n               (if (next body)\n                 (with-meta arglist (conj (if (meta arglist) (meta arglist) {}) (first body)))\n                 arglist)\n               arglist)))]\n     (if (seq? (first fdecl))\n       (loop [ret [] fdecls fdecl]\n         (if fdecls\n           (recur (conj ret (asig (first fdecls))) (next fdecls))\n           (seq ret)))\n       (list (asig fdecl))))))\n\n\n(def \n ^{:arglists '([coll])\n   :doc \"Return the last item in coll, in linear time\"\n   :added \"1.0\"\n   :static true}\n last (fn ^:static last [s]\n        (if (next s)\n          (recur (next s))\n          (first s))))\n\n(def \n ^{:arglists '([coll])\n   :doc \"Return a seq of all but the last item in coll, in linear time\"\n   :added \"1.0\"\n   :static true}\n butlast (fn ^:static butlast [s]\n           (loop [ret [] s s]\n             (if (next s)\n               (recur (conj ret (first s)) (next s))\n               (seq ret)))))\n\n(def \n\n ^{:doc \"Same as (def name (fn [params* ] exprs*)) or (def\n    name (fn ([params* ] exprs*)+)) with any doc-string or attrs added\n    to the var metadata. prepost-map defines a map with optional keys\n    :pre and :post that contain collections of pre or post conditions.\"\n   :arglists '([name doc-string? attr-map? [params*] prepost-map? body]\n                [name doc-string? attr-map? ([params*] prepost-map? body)+ attr-map?])\n   :added \"1.0\"\n   :macro true}\n defn (fn defn [&form &env name & fdecl]\n        ;; Note: Cannot delegate this check to def because of the call to (with-meta name ..)\n        (if (instance? clojure.lang.Symbol name)\n          nil\n          (throw (IllegalArgumentException. \"First argument to defn must be a symbol\")))\n        (let [m (if (string? (first fdecl))\n                  {:doc (first fdecl)}\n                  {})\n              fdecl (if (string? (first fdecl))\n                      (next fdecl)\n                      fdecl)\n              m (if (map? (first fdecl))\n                  (conj m (first fdecl))\n                  m)\n              fdecl (if (map? (first fdecl))\n                      (next fdecl)\n                      fdecl)\n              fdecl (if (vector? (first fdecl))\n                      (list fdecl)\n                      fdecl)\n              m (if (map? (last fdecl))\n                  (conj m (last fdecl))\n                  m)\n              fdecl (if (map? (last fdecl))\n                      (butlast fdecl)\n                      fdecl)\n              m (conj {:arglists (list 'quote (sigs fdecl))} m)\n              m (let [inline (:inline m)\n                      ifn (first inline)\n                      iname (second inline)]\n                  ;; same as: (if (and (= 'fn ifn) (not (symbol? iname))) ...)\n                  (if (if (clojure.lang.Util/equiv 'fn ifn)\n                        (if (instance? clojure.lang.Symbol iname) false true))\n                    ;; inserts the same fn name to the inline fn if it does not have one\n                    (assoc m :inline (cons ifn (cons (clojure.lang.Symbol/intern (.concat (.getName ^clojure.lang.Symbol name) \"__inliner\"))\n                                                     (next inline))))\n                    m))\n              m (conj (if (meta name) (meta name) {}) m)]\n          (list 'def (with-meta name m)\n                ;;todo - restore propagation of fn name\n                ;;must figure out how to convey primitive hints to self calls first\n                (cons `fn fdecl) ))))\n\n(defn to-array\n  \"Returns an array of Objects containing the contents of coll, which\n  can be any Collection.  Maps to java.util.Collection.toArray().\"\n  {:tag \"[Ljava.lang.Object;\"\n   :added \"1.0\"\n   :static true}\n  [coll] (. clojure.lang.RT (toArray coll)))\n\n(defn cast\n  \"Throws a ClassCastException if x is not a c, else returns x.\"\n  {:added \"1.0\"\n   :static true}\n  [^Class c x] \n  (. c (cast x)))\n \n(defn vector\n  \"Creates a new vector containing the args.\"\n  {:added \"1.0\"\n   :static true}\n  ([] [])\n  ([a] [a])\n  ([a b] [a b])\n  ([a b c] [a b c])\n  ([a b c d] [a b c d])\n  ([a b c d & args]\n     (. clojure.lang.LazilyPersistentVector (create (cons a (cons b (cons c (cons d args))))))))\n\n(defn vec\n  \"Creates a new vector containing the contents of coll. Java arrays\n  will be aliased and should not be modified.\"\n  {:added \"1.0\"\n   :static true}\n  ([coll]\n   (if (vector? coll)\n     (if (instance? clojure.lang.IObj coll)\n       (with-meta coll nil)\n       (clojure.lang.LazilyPersistentVector/create coll))\n     (clojure.lang.LazilyPersistentVector/create coll))))\n\n(defn hash-map\n  \"keyval => key val\n  Returns a new hash map with supplied mappings.  If any keys are\n  equal, they are handled as if by repeated uses of assoc.\"\n  {:added \"1.0\"\n   :static true}\n  ([] {})\n  ([& keyvals]\n   (. clojure.lang.PersistentHashMap (create keyvals))))\n\n(defn hash-set\n  \"Returns a new hash set with supplied keys.  Any equal keys are\n  handled as if by repeated uses of conj.\"\n  {:added \"1.0\"\n   :static true}\n  ([] #{})\n  ([& keys]\n   (clojure.lang.PersistentHashSet/create keys)))\n\n(defn sorted-map\n  \"keyval => key val\n  Returns a new sorted map with supplied mappings.  If any keys are\n  equal, they are handled as if by repeated uses of assoc.\"\n  {:added \"1.0\"\n   :static true}\n  ([& keyvals]\n   (clojure.lang.PersistentTreeMap/create keyvals)))\n\n(defn sorted-map-by\n  \"keyval => key val\n  Returns a new sorted map with supplied mappings, using the supplied\n  comparator.  If any keys are equal, they are handled as if by\n  repeated uses of assoc.\"\n  {:added \"1.0\"\n   :static true}\n  ([comparator & keyvals]\n   (clojure.lang.PersistentTreeMap/create comparator keyvals)))\n\n(defn sorted-set\n  \"Returns a new sorted set with supplied keys.  Any equal keys are\n  handled as if by repeated uses of conj.\"\n  {:added \"1.0\"\n   :static true}\n  ([& keys]\n   (clojure.lang.PersistentTreeSet/create keys)))\n\n(defn sorted-set-by\n  \"Returns a new sorted set with supplied keys, using the supplied\n  comparator.  Any equal keys are handled as if by repeated uses of\n  conj.\"\n  {:added \"1.1\"\n   :static true} \n  ([comparator & keys]\n   (clojure.lang.PersistentTreeSet/create comparator keys)))\n\n \n;;;;;;;;;;;;;;;;;;;;\n(defn nil?\n  \"Returns true if x is nil, false otherwise.\"\n  {:tag Boolean\n   :added \"1.0\"\n   :static true\n   :inline (fn [x] (list 'clojure.lang.Util/identical x nil))}\n  [x] (clojure.lang.Util/identical x nil))\n\n(def\n\n ^{:doc \"Like defn, but the resulting function name is declared as a\n  macro and will be used as a macro by the compiler when it is\n  called.\"\n   :arglists '([name doc-string? attr-map? [params*] body]\n                 [name doc-string? attr-map? ([params*] body)+ attr-map?])\n   :added \"1.0\"\n   :macro true}\n defmacro (fn [&form &env\n                name & args]\n             (let [prefix (loop [p (list name) args args]\n                            (let [f (first args)]\n                              (if (string? f)\n                                (recur (cons f p) (next args))\n                                (if (map? f)\n                                  (recur (cons f p) (next args))\n                                  p))))\n                   fdecl (loop [fd args]\n                           (if (string? (first fd))\n                             (recur (next fd))\n                             (if (map? (first fd))\n                               (recur (next fd))\n                               fd)))\n                   fdecl (if (vector? (first fdecl))\n                           (list fdecl)\n                           fdecl)\n                   add-implicit-args (fn [fd]\n                             (let [args (first fd)]\n                               (cons (vec (cons '&form (cons '&env args))) (next fd))))\n                   add-args (fn [acc ds]\n                              (if (nil? ds)\n                                acc\n                                (let [d (first ds)]\n                                  (if (map? d)\n                                    (conj acc d)\n                                    (recur (conj acc (add-implicit-args d)) (next ds))))))\n                   fdecl (seq (add-args [] fdecl))\n                   decl (loop [p prefix d fdecl]\n                          (if p\n                            (recur (next p) (cons (first p) d))\n                            d))\n                   sym (with-meta (first decl) (assoc (meta (first decl)) :macro true))\n                   decl (cons sym (next decl))]\n                (cons `defn decl))))\n\n(defmacro when\n  \"Evaluates test. If logical true, evaluates body in an implicit do.\"\n  {:added \"1.0\"}\n  [test & body]\n  (list 'if test (cons 'do body)))\n\n(defmacro when-not\n  \"Evaluates test. If logical false, evaluates body in an implicit do.\"\n  {:added \"1.0\"}\n  [test & body]\n    (list 'if test nil (cons 'do body)))\n\n(defn false?\n  \"Returns true if x is the value false, false otherwise.\"\n  {:tag Boolean,\n   :added \"1.0\"\n   :static true}\n  [x] (clojure.lang.Util/identical x false))\n\n(defn true?\n  \"Returns true if x is the value true, false otherwise.\"\n  {:tag Boolean,\n   :added \"1.0\"\n   :static true}\n  [x] (clojure.lang.Util/identical x true))\n\n(defn not\n  \"Returns true if x is logical false, false otherwise.\"\n  {:tag Boolean\n   :added \"1.0\"\n   :static true}\n  [x] (if x false true))\n\n(defn some?\n  \"Returns true if x is not nil, false otherwise.\"\n  {:tag Boolean\n   :added \"1.6\"\n   :static true}\n  [x] (not (nil? x)))\n\n(defn str\n  \"With no args, returns the empty string. With one arg x, returns\n  x.toString().  (str nil) returns the empty string. With more than\n  one arg, returns the concatenation of the str values of the args.\"\n  {:tag String\n   :added \"1.0\"\n   :static true}\n  (^String [] \"\")\n  (^String [^Object x]\n   (if (nil? x) \"\" (. x (toString))))\n  (^String [x & ys]\n     ((fn [^StringBuilder sb more]\n          (if more\n            (recur (. sb  (append (str (first more)))) (next more))\n            (str sb)))\n      (new StringBuilder (str x)) ys)))\n\n\n(defn symbol?\n  \"Return true if x is a Symbol\"\n  {:added \"1.0\"\n   :static true}\n  [x] (instance? clojure.lang.Symbol x))\n\n(defn keyword?\n  \"Return true if x is a Keyword\"\n  {:added \"1.0\"\n   :static true}\n  [x] (instance? clojure.lang.Keyword x))\n\n(defn symbol\n  \"Returns a Symbol with the given namespace and name.\"\n  {:tag clojure.lang.Symbol\n   :added \"1.0\"\n   :static true}\n  ([name] (if (symbol? name) name (clojure.lang.Symbol/intern name)))\n  ([ns name] (clojure.lang.Symbol/intern ns name)))\n\n(defn gensym\n  \"Returns a new symbol with a unique name. If a prefix string is\n  supplied, the name is prefix# where # is some unique number. If\n  prefix is not supplied, the prefix is 'G__'.\"\n  {:added \"1.0\"\n   :static true}\n  ([] (gensym \"G__\"))\n  ([prefix-string] (. clojure.lang.Symbol (intern (str prefix-string (str (. clojure.lang.RT (nextID))))))))\n\n(defmacro cond\n  \"Takes a set of test/expr pairs. It evaluates each test one at a\n  time.  If a test returns logical true, cond evaluates and returns\n  the value of the corresponding expr and doesn't evaluate any of the\n  other tests or exprs. (cond) returns nil.\"\n  {:added \"1.0\"}\n  [& clauses]\n    (when clauses\n      (list 'if (first clauses)\n            (if (next clauses)\n                (second clauses)\n                (throw (IllegalArgumentException.\n                         \"cond requires an even number of forms\")))\n            (cons 'clojure.core/cond (next (next clauses))))))\n\n(defn keyword\n  \"Returns a Keyword with the given namespace and name.  Do not use :\n  in the keyword strings, it will be added automatically.\"\n  {:tag clojure.lang.Keyword\n   :added \"1.0\"\n   :static true}\n  ([name] (cond (keyword? name) name\n                (symbol? name) (clojure.lang.Keyword/intern ^clojure.lang.Symbol name)\n                (string? name) (clojure.lang.Keyword/intern ^String name)))\n  ([ns name] (clojure.lang.Keyword/intern ns name)))\n\n(defn find-keyword\n  \"Returns a Keyword with the given namespace and name if one already\n  exists.  This function will not intern a new keyword. If the keyword\n  has not already been interned, it will return nil.  Do not use :\n  in the keyword strings, it will be added automatically.\"\n  {:tag clojure.lang.Keyword\n   :added \"1.3\"\n   :static true}\n  ([name] (cond (keyword? name) name\n                (symbol? name) (clojure.lang.Keyword/find ^clojure.lang.Symbol name)\n                (string? name) (clojure.lang.Keyword/find ^String name)))\n  ([ns name] (clojure.lang.Keyword/find ns name)))\n\n\n(defn spread\n  {:private true\n   :static true}\n  [arglist]\n  (cond\n   (nil? arglist) nil\n   (nil? (next arglist)) (seq (first arglist))\n   :else (cons (first arglist) (spread (next arglist)))))\n\n(defn list*\n  \"Creates a new list containing the items prepended to the rest, the\n  last of which will be treated as a sequence.\"\n  {:added \"1.0\"\n   :static true}\n  ([args] (seq args))\n  ([a args] (cons a args))\n  ([a b args] (cons a (cons b args)))\n  ([a b c args] (cons a (cons b (cons c args))))\n  ([a b c d & more]\n     (cons a (cons b (cons c (cons d (spread more)))))))\n\n(defn apply\n  \"Applies fn f to the argument list formed by prepending intervening arguments to args.\"\n  {:added \"1.0\"\n   :static true}\n  ([^clojure.lang.IFn f args]\n     (. f (applyTo (seq args))))\n  ([^clojure.lang.IFn f x args]\n     (. f (applyTo (list* x args))))\n  ([^clojure.lang.IFn f x y args]\n     (. f (applyTo (list* x y args))))\n  ([^clojure.lang.IFn f x y z args]\n     (. f (applyTo (list* x y z args))))\n  ([^clojure.lang.IFn f a b c d & args]\n     (. f (applyTo (cons a (cons b (cons c (cons d (spread args)))))))))\n\n(defn vary-meta\n \"Returns an object of the same type and value as obj, with\n  (apply f (meta obj) args) as its metadata.\"\n {:added \"1.0\"\n   :static true}\n [obj f & args]\n  (with-meta obj (apply f (meta obj) args)))\n\n(defmacro lazy-seq\n  \"Takes a body of expressions that returns an ISeq or nil, and yields\n  a Seqable object that will invoke the body only the first time seq\n  is called, and will cache the result and return it on all subsequent\n  seq calls. See also - realized?\"\n  {:added \"1.0\"}\n  [& body]\n  (list 'new 'clojure.lang.LazySeq (list* '^{:once true} fn* [] body)))\n\n(defn ^:static ^clojure.lang.ChunkBuffer chunk-buffer ^clojure.lang.ChunkBuffer [capacity]\n  (clojure.lang.ChunkBuffer. capacity))\n\n(defn ^:static chunk-append [^clojure.lang.ChunkBuffer b x]\n  (.add b x))\n\n(defn ^:static ^clojure.lang.IChunk chunk [^clojure.lang.ChunkBuffer b]\n  (.chunk b))\n\n(defn ^:static  ^clojure.lang.IChunk chunk-first ^clojure.lang.IChunk [^clojure.lang.IChunkedSeq s]\n  (.chunkedFirst s))\n\n(defn ^:static ^clojure.lang.ISeq chunk-rest ^clojure.lang.ISeq [^clojure.lang.IChunkedSeq s]\n  (.chunkedMore s))\n\n(defn ^:static ^clojure.lang.ISeq chunk-next ^clojure.lang.ISeq [^clojure.lang.IChunkedSeq s]\n  (.chunkedNext s))\n\n(defn ^:static chunk-cons [chunk rest]\n  (if (clojure.lang.Numbers/isZero (clojure.lang.RT/count chunk))\n    rest\n    (clojure.lang.ChunkedCons. chunk rest)))\n\n(defn ^:static chunked-seq? [s]\n  (instance? clojure.lang.IChunkedSeq s))\n\n(defn concat\n  \"Returns a lazy seq representing the concatenation of the elements in the supplied colls.\"\n  {:added \"1.0\"\n   :static true}\n  ([] (lazy-seq nil))\n  ([x] (lazy-seq x))\n  ([x y]\n    (lazy-seq\n      (let [s (seq x)]\n        (if s\n          (if (chunked-seq? s)\n            (chunk-cons (chunk-first s) (concat (chunk-rest s) y))\n            (cons (first s) (concat (rest s) y)))\n          y))))\n  ([x y & zs]\n     (let [cat (fn cat [xys zs]\n                 (lazy-seq\n                   (let [xys (seq xys)]\n                     (if xys\n                       (if (chunked-seq? xys)\n                         (chunk-cons (chunk-first xys)\n                                     (cat (chunk-rest xys) zs))\n                         (cons (first xys) (cat (rest xys) zs)))\n                       (when zs\n                         (cat (first zs) (next zs)))))))]\n       (cat (concat x y) zs))))\n\n;;;;;;;;;;;;;;;;at this point all the support for syntax-quote exists;;;;;;;;;;;;;;;;;;;;;;\n(defmacro delay\n  \"Takes a body of expressions and yields a Delay object that will\n  invoke the body only the first time it is forced (with force or deref/@), and\n  will cache the result and return it on all subsequent force\n  calls. See also - realized?\"\n  {:added \"1.0\"}\n  [& body]\n    (list 'new 'clojure.lang.Delay (list* `^{:once true} fn* [] body)))\n\n(defn delay?\n  \"returns true if x is a Delay created with delay\"\n  {:added \"1.0\"\n   :static true}\n  [x] (instance? clojure.lang.Delay x))\n\n(defn force\n  \"If x is a Delay, returns the (possibly cached) value of its expression, else returns x\"\n  {:added \"1.0\"\n   :static true}\n  [x] (. clojure.lang.Delay (force x)))\n\n(defmacro if-not\n  \"Evaluates test. If logical false, evaluates and returns then expr,\n  otherwise else expr, if supplied, else nil.\"\n  {:added \"1.0\"}\n  ([test then] `(if-not ~test ~then nil))\n  ([test then else]\n   `(if (not ~test) ~then ~else)))\n\n(defn identical?\n  \"Tests if 2 arguments are the same object\"\n  {:inline (fn [x y] `(. clojure.lang.Util identical ~x ~y))\n   :inline-arities #{2}\n   :added \"1.0\"}\n  ([x y] (clojure.lang.Util/identical x y)))\n\n;equiv-based\n(defn =\n  \"Equality. Returns true if x equals y, false if not. Same as\n  Java x.equals(y) except it also works for nil, and compares\n  numbers and collections in a type-independent manner.  Clojure's immutable data\n  structures define equals() (and thus =) as a value, not an identity,\n  comparison.\"\n  {:inline (fn [x y] `(. clojure.lang.Util equiv ~x ~y))\n   :inline-arities #{2}\n   :added \"1.0\"}\n  ([x] true)\n  ([x y] (clojure.lang.Util/equiv x y))\n  ([x y & more]\n   (if (clojure.lang.Util/equiv x y)\n     (if (next more)\n       (recur y (first more) (next more))\n       (clojure.lang.Util/equiv y (first more)))\n     false)))\n\n;equals-based\n#_(defn =\n  \"Equality. Returns true if x equals y, false if not. Same as Java\n  x.equals(y) except it also works for nil. Boxed numbers must have\n  same type. Clojure's immutable data structures define equals() (and\n  thus =) as a value, not an identity, comparison.\"\n  {:inline (fn [x y] `(. clojure.lang.Util equals ~x ~y))\n   :inline-arities #{2}\n   :added \"1.0\"}\n  ([x] true)\n  ([x y] (clojure.lang.Util/equals x y))\n  ([x y & more]\n   (if (= x y)\n     (if (next more)\n       (recur y (first more) (next more))\n       (= y (first more)))\n     false)))\n\n(defn not=\n  \"Same as (not (= obj1 obj2))\"\n  {:tag Boolean\n   :added \"1.0\"\n   :static true}\n  ([x] false)\n  ([x y] (not (= x y)))\n  ([x y & more]\n   (not (apply = x y more))))\n\n\n\n(defn compare\n  \"Comparator. Returns a negative number, zero, or a positive number\n  when x is logically 'less than', 'equal to', or 'greater than'\n  y. Same as Java x.compareTo(y) except it also works for nil, and\n  compares numbers and collections in a type-independent manner. x\n  must implement Comparable\"\n  {\n   :inline (fn [x y] `(. clojure.lang.Util compare ~x ~y))\n   :added \"1.0\"}\n  [x y] (. clojure.lang.Util (compare x y)))\n\n(defmacro and\n  \"Evaluates exprs one at a time, from left to right. If a form\n  returns logical false (nil or false), and returns that value and\n  doesn't evaluate any of the other expressions, otherwise it returns\n  the value of the last expr. (and) returns true.\"\n  {:added \"1.0\"}\n  ([] true)\n  ([x] x)\n  ([x & next]\n   `(let [and# ~x]\n      (if and# (and ~@next) and#))))\n\n(defmacro or\n  \"Evaluates exprs one at a time, from left to right. If a form\n  returns a logical true value, or returns that value and doesn't\n  evaluate any of the other expressions, otherwise it returns the\n  value of the last expression. (or) returns nil.\"\n  {:added \"1.0\"}\n  ([] nil)\n  ([x] x)\n  ([x & next]\n      `(let [or# ~x]\n         (if or# or# (or ~@next)))))\n\n;;;;;;;;;;;;;;;;;;; sequence fns  ;;;;;;;;;;;;;;;;;;;;;;;\n(defn zero?\n  \"Returns true if num is zero, else false\"\n  {\n   :inline (fn [x] `(. clojure.lang.Numbers (isZero ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers (isZero x)))\n\n(defn count\n  \"Returns the number of items in the collection. (count nil) returns\n  0.  Also works on strings, arrays, and Java Collections and Maps\"\n  {\n   :inline (fn  [x] `(. clojure.lang.RT (count ~x)))\n   :added \"1.0\"}\n  [coll] (clojure.lang.RT/count coll))\n\n(defn int\n  \"Coerce to int\"\n  {\n   :inline (fn  [x] `(. clojure.lang.RT (~(if *unchecked-math* 'uncheckedIntCast 'intCast) ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.RT (intCast x)))\n\n(defn nth\n  \"Returns the value at the index. get returns nil if index out of\n  bounds, nth throws an exception unless not-found is supplied.  nth\n  also works for strings, Java arrays, regex Matchers and Lists, and,\n  in O(n) time, for sequences.\"\n  {:inline (fn  [c i & nf] `(. clojure.lang.RT (nth ~c ~i ~@nf)))\n   :inline-arities #{2 3}\n   :added \"1.0\"}\n  ([coll index] (. clojure.lang.RT (nth coll index)))\n  ([coll index not-found] (. clojure.lang.RT (nth coll index not-found))))\n\n(defn <\n  \"Returns non-nil if nums are in monotonically increasing order,\n  otherwise false.\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (lt ~x ~y)))\n   :inline-arities #{2}\n   :added \"1.0\"}\n  ([x] true)\n  ([x y] (. clojure.lang.Numbers (lt x y)))\n  ([x y & more]\n   (if (< x y)\n     (if (next more)\n       (recur y (first more) (next more))\n       (< y (first more)))\n     false)))\n\n(defn inc'\n  \"Returns a number one greater than num. Supports arbitrary precision.\n  See also: inc\"\n  {:inline (fn [x] `(. clojure.lang.Numbers (incP ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers (incP x)))\n\n(defn inc\n  \"Returns a number one greater than num. Does not auto-promote\n  longs, will throw on overflow. See also: inc'\"\n  {:inline (fn [x] `(. clojure.lang.Numbers (~(if *unchecked-math* 'unchecked_inc 'inc) ~x)))\n   :added \"1.2\"}\n  [x] (. clojure.lang.Numbers (inc x)))\n\n;; reduce is defined again later after InternalReduce loads\n(defn ^:private ^:static\n  reduce1\n       ([f coll]\n             (let [s (seq coll)]\n               (if s\n         (reduce1 f (first s) (next s))\n                 (f))))\n       ([f val coll]\n          (let [s (seq coll)]\n            (if s\n              (if (chunked-seq? s)\n                (recur f\n                       (.reduce (chunk-first s) f val)\n                       (chunk-next s))\n                (recur f (f val (first s)) (next s)))\n         val))))\n\n(defn reverse\n  \"Returns a seq of the items in coll in reverse order. Not lazy.\"\n  {:added \"1.0\"\n   :static true}\n  [coll]\n    (reduce1 conj () coll))\n\n;;math stuff\n(defn ^:private nary-inline\n  ([op] (nary-inline op op))\n  ([op unchecked-op]\n     (fn\n       ([x] (let [op (if *unchecked-math* unchecked-op op)]\n              `(. clojure.lang.Numbers (~op ~x))))\n       ([x y] (let [op (if *unchecked-math* unchecked-op op)]\n                `(. clojure.lang.Numbers (~op ~x ~y))))\n       ([x y & more]\n          (let [op (if *unchecked-math* unchecked-op op)]\n            (reduce1\n             (fn [a b] `(. clojure.lang.Numbers (~op ~a ~b)))\n             `(. clojure.lang.Numbers (~op ~x ~y)) more))))))\n\n(defn ^:private >1? [n] (clojure.lang.Numbers/gt n 1))\n(defn ^:private >0? [n] (clojure.lang.Numbers/gt n 0))\n\n(defn +'\n  \"Returns the sum of nums. (+) returns 0. Supports arbitrary precision.\n  See also: +\"\n  {:inline (nary-inline 'addP)\n   :inline-arities >1?\n   :added \"1.0\"}\n  ([] 0)\n  ([x] (cast Number x))\n  ([x y] (. clojure.lang.Numbers (addP x y)))\n  ([x y & more]\n   (reduce1 +' (+' x y) more)))\n\n(defn +\n  \"Returns the sum of nums. (+) returns 0. Does not auto-promote\n  longs, will throw on overflow. See also: +'\"\n  {:inline (nary-inline 'add 'unchecked_add)\n   :inline-arities >1?\n   :added \"1.2\"}\n  ([] 0)\n  ([x] (cast Number x))\n  ([x y] (. clojure.lang.Numbers (add x y)))\n  ([x y & more]\n     (reduce1 + (+ x y) more)))\n\n(defn *'\n  \"Returns the product of nums. (*) returns 1. Supports arbitrary precision.\n  See also: *\"\n  {:inline (nary-inline 'multiplyP)\n   :inline-arities >1?\n   :added \"1.0\"}\n  ([] 1)\n  ([x] (cast Number x))\n  ([x y] (. clojure.lang.Numbers (multiplyP x y)))\n  ([x y & more]\n   (reduce1 *' (*' x y) more)))\n\n(defn *\n  \"Returns the product of nums. (*) returns 1. Does not auto-promote\n  longs, will throw on overflow. See also: *'\"\n  {:inline (nary-inline 'multiply 'unchecked_multiply)\n   :inline-arities >1?\n   :added \"1.2\"}\n  ([] 1)\n  ([x] (cast Number x))\n  ([x y] (. clojure.lang.Numbers (multiply x y)))\n  ([x y & more]\n     (reduce1 * (* x y) more)))\n\n(defn /\n  \"If no denominators are supplied, returns 1/numerator,\n  else returns numerator divided by all of the denominators.\"\n  {:inline (nary-inline 'divide)\n   :inline-arities >1?\n   :added \"1.0\"}\n  ([x] (/ 1 x))\n  ([x y] (. clojure.lang.Numbers (divide x y)))\n  ([x y & more]\n   (reduce1 / (/ x y) more)))\n\n(defn -'\n  \"If no ys are supplied, returns the negation of x, else subtracts\n  the ys from x and returns the result. Supports arbitrary precision.\n  See also: -\"\n  {:inline (nary-inline 'minusP)\n   :inline-arities >0?\n   :added \"1.0\"}\n  ([x] (. clojure.lang.Numbers (minusP x)))\n  ([x y] (. clojure.lang.Numbers (minusP x y)))\n  ([x y & more]\n   (reduce1 -' (-' x y) more)))\n\n(defn -\n  \"If no ys are supplied, returns the negation of x, else subtracts\n  the ys from x and returns the result. Does not auto-promote\n  longs, will throw on overflow. See also: -'\"\n  {:inline (nary-inline 'minus 'unchecked_minus)\n   :inline-arities >0?\n   :added \"1.2\"}\n  ([x] (. clojure.lang.Numbers (minus x)))\n  ([x y] (. clojure.lang.Numbers (minus x y)))\n  ([x y & more]\n     (reduce1 - (- x y) more)))\n\n(defn <=\n  \"Returns non-nil if nums are in monotonically non-decreasing order,\n  otherwise false.\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (lte ~x ~y)))\n   :inline-arities #{2}\n   :added \"1.0\"}\n  ([x] true)\n  ([x y] (. clojure.lang.Numbers (lte x y)))\n  ([x y & more]\n   (if (<= x y)\n     (if (next more)\n       (recur y (first more) (next more))\n       (<= y (first more)))\n     false)))\n\n(defn >\n  \"Returns non-nil if nums are in monotonically decreasing order,\n  otherwise false.\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (gt ~x ~y)))\n   :inline-arities #{2}\n   :added \"1.0\"}\n  ([x] true)\n  ([x y] (. clojure.lang.Numbers (gt x y)))\n  ([x y & more]\n   (if (> x y)\n     (if (next more)\n       (recur y (first more) (next more))\n       (> y (first more)))\n     false)))\n\n(defn >=\n  \"Returns non-nil if nums are in monotonically non-increasing order,\n  otherwise false.\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (gte ~x ~y)))\n   :inline-arities #{2}\n   :added \"1.0\"}\n  ([x] true)\n  ([x y] (. clojure.lang.Numbers (gte x y)))\n  ([x y & more]\n   (if (>= x y)\n     (if (next more)\n       (recur y (first more) (next more))\n       (>= y (first more)))\n     false)))\n\n(defn ==\n  \"Returns non-nil if nums all have the equivalent\n  value (type-independent), otherwise false\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (equiv ~x ~y)))\n   :inline-arities #{2}\n   :added \"1.0\"}\n  ([x] true)\n  ([x y] (. clojure.lang.Numbers (equiv x y)))\n  ([x y & more]\n   (if (== x y)\n     (if (next more)\n       (recur y (first more) (next more))\n       (== y (first more)))\n     false)))\n\n(defn max\n  \"Returns the greatest of the nums.\"\n  {:added \"1.0\"\n   :inline-arities >1?\n   :inline (nary-inline 'max)}\n  ([x] x)\n  ([x y] (. clojure.lang.Numbers (max x y)))\n  ([x y & more]\n   (reduce1 max (max x y) more)))\n\n(defn min\n  \"Returns the least of the nums.\"\n  {:added \"1.0\"\n   :inline-arities >1?\n   :inline (nary-inline 'min)}\n  ([x] x)\n  ([x y] (. clojure.lang.Numbers (min x y)))\n  ([x y & more]\n   (reduce1 min (min x y) more)))\n\n(defn dec'\n  \"Returns a number one less than num. Supports arbitrary precision.\n  See also: dec\"\n  {:inline (fn [x] `(. clojure.lang.Numbers (decP ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers (decP x)))\n\n(defn dec\n  \"Returns a number one less than num. Does not auto-promote\n  longs, will throw on overflow. See also: dec'\"\n  {:inline (fn [x] `(. clojure.lang.Numbers (~(if *unchecked-math* 'unchecked_dec 'dec) ~x)))\n   :added \"1.2\"}\n  [x] (. clojure.lang.Numbers (dec x)))\n\n(defn unchecked-inc-int\n  \"Returns a number one greater than x, an int.\n  Note - uses a primitive operator subject to overflow.\"\n  {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_int_inc ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers (unchecked_int_inc x)))\n\n(defn unchecked-inc\n  \"Returns a number one greater than x, a long.\n  Note - uses a primitive operator subject to overflow.\"\n  {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_inc ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers (unchecked_inc x)))\n\n(defn unchecked-dec-int\n  \"Returns a number one less than x, an int.\n  Note - uses a primitive operator subject to overflow.\"\n  {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_int_dec ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers (unchecked_int_dec x)))\n\n(defn unchecked-dec\n  \"Returns a number one less than x, a long.\n  Note - uses a primitive operator subject to overflow.\"\n  {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_dec ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers (unchecked_dec x)))\n\n(defn unchecked-negate-int\n  \"Returns the negation of x, an int.\n  Note - uses a primitive operator subject to overflow.\"\n  {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_int_negate ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers (unchecked_int_negate x)))\n\n(defn unchecked-negate\n  \"Returns the negation of x, a long.\n  Note - uses a primitive operator subject to overflow.\"\n  {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_minus ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers (unchecked_minus x)))\n\n(defn unchecked-add-int\n  \"Returns the sum of x and y, both int.\n  Note - uses a primitive operator subject to overflow.\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_int_add ~x ~y)))\n   :added \"1.0\"}\n  [x y] (. clojure.lang.Numbers (unchecked_int_add x y)))\n\n(defn unchecked-add\n  \"Returns the sum of x and y, both long.\n  Note - uses a primitive operator subject to overflow.\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_add ~x ~y)))\n   :added \"1.0\"}\n  [x y] (. clojure.lang.Numbers (unchecked_add x y)))\n\n(defn unchecked-subtract-int\n  \"Returns the difference of x and y, both int.\n  Note - uses a primitive operator subject to overflow.\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_int_subtract ~x ~y)))\n   :added \"1.0\"}\n  [x y] (. clojure.lang.Numbers (unchecked_int_subtract x y)))\n\n(defn unchecked-subtract\n  \"Returns the difference of x and y, both long.\n  Note - uses a primitive operator subject to overflow.\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_minus ~x ~y)))\n   :added \"1.0\"}\n  [x y] (. clojure.lang.Numbers (unchecked_minus x y)))\n\n(defn unchecked-multiply-int\n  \"Returns the product of x and y, both int.\n  Note - uses a primitive operator subject to overflow.\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_int_multiply ~x ~y)))\n   :added \"1.0\"}\n  [x y] (. clojure.lang.Numbers (unchecked_int_multiply x y)))\n\n(defn unchecked-multiply\n  \"Returns the product of x and y, both long.\n  Note - uses a primitive operator subject to overflow.\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_multiply ~x ~y)))\n   :added \"1.0\"}\n  [x y] (. clojure.lang.Numbers (unchecked_multiply x y)))\n\n(defn unchecked-divide-int\n  \"Returns the division of x by y, both int.\n  Note - uses a primitive operator subject to truncation.\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_int_divide ~x ~y)))\n   :added \"1.0\"}\n  [x y] (. clojure.lang.Numbers (unchecked_int_divide x y)))\n\n(defn unchecked-remainder-int\n  \"Returns the remainder of division of x by y, both int.\n  Note - uses a primitive operator subject to truncation.\"\n  {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_int_remainder ~x ~y)))\n   :added \"1.0\"}\n  [x y] (. clojure.lang.Numbers (unchecked_int_remainder x y)))\n\n(defn pos?\n  \"Returns true if num is greater than zero, else false\"\n  {\n   :inline (fn [x] `(. clojure.lang.Numbers (isPos ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers (isPos x)))\n\n(defn neg?\n  \"Returns true if num is less than zero, else false\"\n  {\n   :inline (fn [x] `(. clojure.lang.Numbers (isNeg ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers (isNeg x)))\n\n(defn quot\n  \"quot[ient] of dividing numerator by denominator.\"\n  {:added \"1.0\"\n   :static true\n   :inline (fn [x y] `(. clojure.lang.Numbers (quotient ~x ~y)))}\n  [num div]\n    (. clojure.lang.Numbers (quotient num div)))\n\n(defn rem\n  \"remainder of dividing numerator by denominator.\"\n  {:added \"1.0\"\n   :static true\n   :inline (fn [x y] `(. clojure.lang.Numbers (remainder ~x ~y)))}\n  [num div]\n    (. clojure.lang.Numbers (remainder num div)))\n\n(defn rationalize\n  \"returns the rational value of num\"\n  {:added \"1.0\"\n   :static true}\n  [num]\n  (. clojure.lang.Numbers (rationalize num)))\n\n;;Bit ops\n\n(defn bit-not\n  \"Bitwise complement\"\n  {:inline (fn [x] `(. clojure.lang.Numbers (not ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers not x))\n\n\n(defn bit-and\n  \"Bitwise and\"\n   {:inline (nary-inline 'and)\n    :inline-arities >1?\n    :added \"1.0\"}\n   ([x y] (. clojure.lang.Numbers and x y))\n   ([x y & more]\n      (reduce1 bit-and (bit-and x y) more)))\n\n(defn bit-or\n  \"Bitwise or\"\n  {:inline (nary-inline 'or)\n   :inline-arities >1?\n   :added \"1.0\"}\n  ([x y] (. clojure.lang.Numbers or x y))\n  ([x y & more]\n    (reduce1 bit-or (bit-or x y) more)))\n\n(defn bit-xor\n  \"Bitwise exclusive or\"\n  {:inline (nary-inline 'xor)\n   :inline-arities >1?\n   :added \"1.0\"}\n  ([x y] (. clojure.lang.Numbers xor x y))\n  ([x y & more]\n    (reduce1 bit-xor (bit-xor x y) more)))\n\n(defn bit-and-not\n  \"Bitwise and with complement\"\n  {:inline (nary-inline 'andNot)\n   :inline-arities >1?\n   :added \"1.0\"\n   :static true}\n  ([x y] (. clojure.lang.Numbers andNot x y))\n  ([x y & more]\n    (reduce1 bit-and-not (bit-and-not x y) more)))\n\n\n(defn bit-clear\n  \"Clear bit at index n\"\n  {:added \"1.0\"\n   :static true}\n  [x n] (. clojure.lang.Numbers clearBit x n))\n\n(defn bit-set\n  \"Set bit at index n\"\n  {:added \"1.0\"\n   :static true}\n  [x n] (. clojure.lang.Numbers setBit x n))\n\n(defn bit-flip\n  \"Flip bit at index n\"\n  {:added \"1.0\"\n   :static true}\n  [x n] (. clojure.lang.Numbers flipBit x n))\n\n(defn bit-test\n  \"Test bit at index n\"\n  {:added \"1.0\"\n   :static true}\n  [x n] (. clojure.lang.Numbers testBit x n))\n\n\n(defn bit-shift-left\n  \"Bitwise shift left\"\n  {:inline (fn [x n] `(. clojure.lang.Numbers (shiftLeft ~x ~n)))\n   :added \"1.0\"}\n  [x n] (. clojure.lang.Numbers shiftLeft x n))\n\n(defn bit-shift-right\n  \"Bitwise shift right\"\n  {:inline (fn [x n] `(. clojure.lang.Numbers (shiftRight ~x ~n)))\n   :added \"1.0\"}\n  [x n] (. clojure.lang.Numbers shiftRight x n))\n\n(defn unsigned-bit-shift-right\n  \"Bitwise shift right, without sign-extension.\"\n  {:inline (fn [x n] `(. clojure.lang.Numbers (unsignedShiftRight ~x ~n)))\n   :added \"1.6\"}\n  [x n] (. clojure.lang.Numbers unsignedShiftRight x n))\n\n(defn integer?\n  \"Returns true if n is an integer\"\n  {:added \"1.0\"\n   :static true}\n  [n]\n  (or (instance? Integer n)\n      (instance? Long n)\n      (instance? clojure.lang.BigInt n)\n      (instance? BigInteger n)\n      (instance? Short n)\n      (instance? Byte n)))\n\n(defn even?\n  \"Returns true if n is even, throws an exception if n is not an integer\"\n  {:added \"1.0\"\n   :static true}\n   [n] (if (integer? n)\n        (zero? (bit-and (clojure.lang.RT/uncheckedLongCast n) 1))\n        (throw (IllegalArgumentException. (str \"Argument must be an integer: \" n)))))\n\n(defn odd?\n  \"Returns true if n is odd, throws an exception if n is not an integer\"\n  {:added \"1.0\"\n   :static true}\n  [n] (not (even? n)))\n\n\n;;\n\n(defn complement\n  \"Takes a fn f and returns a fn that takes the same arguments as f,\n  has the same effects, if any, and returns the opposite truth value.\"\n  {:added \"1.0\"\n   :static true}\n  [f]\n  (fn\n    ([] (not (f)))\n    ([x] (not (f x)))\n    ([x y] (not (f x y)))\n    ([x y & zs] (not (apply f x y zs)))))\n\n(defn constantly\n  \"Returns a function that takes any number of arguments and returns x.\"\n  {:added \"1.0\"\n   :static true}\n  [x] (fn [& args] x))\n\n(defn identity\n  \"Returns its argument.\"\n  {:added \"1.0\"\n   :static true}\n  [x] x)\n\n;;Collection stuff\n\n;;list stuff\n(defn peek\n  \"For a list or queue, same as first, for a vector, same as, but much\n  more efficient than, last. If the collection is empty, returns nil.\"\n  {:added \"1.0\"\n   :static true}\n  [coll] (. clojure.lang.RT (peek coll)))\n\n(defn pop\n  \"For a list or queue, returns a new list/queue without the first\n  item, for a vector, returns a new vector without the last item. If\n  the collection is empty, throws an exception.  Note - not the same\n  as next/butlast.\"\n  {:added \"1.0\"\n   :static true}\n  [coll] (. clojure.lang.RT (pop coll)))\n\n;;map stuff\n\n(defn contains?\n  \"Returns true if key is present in the given collection, otherwise\n  returns false.  Note that for numerically indexed collections like\n  vectors and Java arrays, this tests if the numeric key is within the\n  range of indexes. 'contains?' operates constant or logarithmic time;\n  it will not perform a linear search for a value.  See also 'some'.\"\n  {:added \"1.0\"\n   :static true}\n  [coll key] (. clojure.lang.RT (contains coll key)))\n\n(defn get\n  \"Returns the value mapped to key, not-found or nil if key not present.\"\n  {:inline (fn  [m k & nf] `(. clojure.lang.RT (get ~m ~k ~@nf)))\n   :inline-arities #{2 3}\n   :added \"1.0\"}\n  ([map key]\n   (. clojure.lang.RT (get map key)))\n  ([map key not-found]\n   (. clojure.lang.RT (get map key not-found))))\n\n(defn dissoc\n  \"dissoc[iate]. Returns a new map of the same (hashed/sorted) type,\n  that does not contain a mapping for key(s).\"\n  {:added \"1.0\"\n   :static true}\n  ([map] map)\n  ([map key]\n   (. clojure.lang.RT (dissoc map key)))\n  ([map key & ks]\n   (let [ret (dissoc map key)]\n     (if ks\n       (recur ret (first ks) (next ks))\n       ret))))\n\n(defn disj\n  \"disj[oin]. Returns a new set of the same (hashed/sorted) type, that\n  does not contain key(s).\"\n  {:added \"1.0\"\n   :static true}\n  ([set] set)\n  ([^clojure.lang.IPersistentSet set key]\n   (when set\n     (. set (disjoin key))))\n  ([set key & ks]\n   (when set\n     (let [ret (disj set key)]\n       (if ks\n         (recur ret (first ks) (next ks))\n         ret)))))\n\n(defn find\n  \"Returns the map entry for key, or nil if key not present.\"\n  {:added \"1.0\"\n   :static true}\n  [map key] (. clojure.lang.RT (find map key)))\n\n(defn select-keys\n  \"Returns a map containing only those entries in map whose key is in keys\"\n  {:added \"1.0\"\n   :static true}\n  [map keyseq]\n    (loop [ret {} keys (seq keyseq)]\n      (if keys\n        (let [entry (. clojure.lang.RT (find map (first keys)))]\n          (recur\n           (if entry\n             (conj ret entry)\n             ret)\n           (next keys)))\n        (with-meta ret (meta map)))))\n\n(defn keys\n  \"Returns a sequence of the map's keys, in the same order as (seq map).\"\n  {:added \"1.0\"\n   :static true}\n  [map] (. clojure.lang.RT (keys map)))\n\n(defn vals\n  \"Returns a sequence of the map's values, in the same order as (seq map).\"\n  {:added \"1.0\"\n   :static true}\n  [map] (. clojure.lang.RT (vals map)))\n\n(defn key\n  \"Returns the key of the map entry.\"\n  {:added \"1.0\"\n   :static true}\n  [^java.util.Map$Entry e]\n    (. e (getKey)))\n\n(defn val\n  \"Returns the value in the map entry.\"\n  {:added \"1.0\"\n   :static true}\n  [^java.util.Map$Entry e]\n    (. e (getValue)))\n\n(defn rseq\n  \"Returns, in constant time, a seq of the items in rev (which\n  can be a vector or sorted-map), in reverse order. If rev is empty returns nil\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.Reversible rev]\n    (. rev (rseq)))\n\n(defn name\n  \"Returns the name String of a string, symbol or keyword.\"\n  {:tag String\n   :added \"1.0\"\n   :static true}\n  [x]\n  (if (string? x) x (. ^clojure.lang.Named x (getName))))\n\n(defn namespace\n  \"Returns the namespace String of a symbol or keyword, or nil if not present.\"\n  {:tag String\n   :added \"1.0\"\n   :static true}\n  [^clojure.lang.Named x]\n    (. x (getNamespace)))\n\n(defmacro locking\n  \"Executes exprs in an implicit do, while holding the monitor of x.\n  Will release the monitor of x in all circumstances.\"\n  {:added \"1.0\"}\n  [x & body]\n  `(let [lockee# ~x]\n     (try\n      (monitor-enter lockee#)\n      ~@body\n      (finally\n       (monitor-exit lockee#)))))\n\n(defmacro ..\n  \"form => fieldName-symbol or (instanceMethodName-symbol args*)\n\n  Expands into a member access (.) of the first member on the first\n  argument, followed by the next member on the result, etc. For\n  instance:\n\n  (.. System (getProperties) (get \\\"os.name\\\"))\n\n  expands to:\n\n  (. (. System (getProperties)) (get \\\"os.name\\\"))\n\n  but is easier to write, read, and understand.\"\n  {:added \"1.0\"}\n  ([x form] `(. ~x ~form))\n  ([x form & more] `(.. (. ~x ~form) ~@more)))\n\n(defmacro ->\n  \"Threads the expr through the forms. Inserts x as the\n  second item in the first form, making a list of it if it is not a\n  list already. If there are more forms, inserts the first form as the\n  second item in second form, etc.\"\n  {:added \"1.0\"}\n  [x & forms]\n  (loop [x x, forms forms]\n    (if forms\n      (let [form (first forms)\n            threaded (if (seq? form)\n                       (with-meta `(~(first form) ~x ~@(next form)) (meta form))\n                       (list form x))]\n        (recur threaded (next forms)))\n      x)))\n\n(defmacro ->>\n  \"Threads the expr through the forms. Inserts x as the\n  last item in the first form, making a list of it if it is not a\n  list already. If there are more forms, inserts the first form as the\n  last item in second form, etc.\"\n  {:added \"1.1\"}\n  [x & forms]\n  (loop [x x, forms forms]\n    (if forms\n      (let [form (first forms)\n            threaded (if (seq? form)\n              (with-meta `(~(first form) ~@(next form)  ~x) (meta form))\n              (list form x))]\n        (recur threaded (next forms)))\n      x)))\n\n(def map)\n\n(defn ^:private check-valid-options\n  \"Throws an exception if the given option map contains keys not listed\n  as valid, else returns nil.\"\n  [options & valid-keys]\n  (when (seq (apply disj (apply hash-set (keys options)) valid-keys))\n    (throw\n      (IllegalArgumentException.\n       ^String\n        (apply str \"Only these options are valid: \"\n          (first valid-keys)\n          (map #(str \", \" %) (rest valid-keys)))))))\n\n;;multimethods\n(def global-hierarchy)\n\n(defmacro defmulti\n  \"Creates a new multimethod with the associated dispatch function.\n  The docstring and attr-map are optional.\n\n  Options are key-value pairs and may be one of:\n\n  :default\n\n  The default dispatch value, defaults to :default\n\n  :hierarchy\n\n  The value used for hierarchical dispatch (e.g. ::square is-a ::shape)\n\n  Hierarchies are type-like relationships that do not depend upon type\n  inheritance. By default Clojure's multimethods dispatch off of a\n  global hierarchy map.  However, a hierarchy relationship can be\n  created with the derive function used to augment the root ancestor\n  created with make-hierarchy.\n\n  Multimethods expect the value of the hierarchy option to be supplied as\n  a reference type e.g. a var (i.e. via the Var-quote dispatch macro #'\n  or the var special form).\"\n  {:arglists '([name docstring? attr-map? dispatch-fn & options])\n   :added \"1.0\"}\n  [mm-name & options]\n  (let [docstring   (if (string? (first options))\n                      (first options)\n                      nil)\n        options     (if (string? (first options))\n                      (next options)\n                      options)\n        m           (if (map? (first options))\n                      (first options)\n                      {})\n        options     (if (map? (first options))\n                      (next options)\n                      options)\n        dispatch-fn (first options)\n        options     (next options)\n        m           (if docstring\n                      (assoc m :doc docstring)\n                      m)\n        m           (if (meta mm-name)\n                      (conj (meta mm-name) m)\n                      m)]\n    (when (= (count options) 1)\n      (throw (Exception. \"The syntax for defmulti has changed. Example: (defmulti name dispatch-fn :default dispatch-value)\")))\n    (let [options   (apply hash-map options)\n          default   (get options :default :default)\n          hierarchy (get options :hierarchy #'global-hierarchy)]\n      (check-valid-options options :default :hierarchy)\n      `(let [v# (def ~mm-name)]\n         (when-not (and (.hasRoot v#) (instance? clojure.lang.MultiFn (deref v#)))\n           (def ~(with-meta mm-name m)\n                (new clojure.lang.MultiFn ~(name mm-name) ~dispatch-fn ~default ~hierarchy)))))))\n\n(defmacro defmethod\n  \"Creates and installs a new method of multimethod associated with dispatch-value. \"\n  {:added \"1.0\"}\n  [multifn dispatch-val & fn-tail]\n  `(. ~(with-meta multifn {:tag 'clojure.lang.MultiFn}) addMethod ~dispatch-val (fn ~@fn-tail)))\n\n(defn remove-all-methods\n  \"Removes all of the methods of multimethod.\"\n  {:added \"1.2\"\n   :static true}\n [^clojure.lang.MultiFn multifn]\n (.reset multifn))\n\n(defn remove-method\n  \"Removes the method of multimethod associated with dispatch-value.\"\n  {:added \"1.0\"\n   :static true}\n [^clojure.lang.MultiFn multifn dispatch-val]\n (. multifn removeMethod dispatch-val))\n\n(defn prefer-method\n  \"Causes the multimethod to prefer matches of dispatch-val-x over dispatch-val-y\n   when there is a conflict\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.MultiFn multifn dispatch-val-x dispatch-val-y]\n  (. multifn preferMethod dispatch-val-x dispatch-val-y))\n\n(defn methods\n  \"Given a multimethod, returns a map of dispatch values -> dispatch fns\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.MultiFn multifn] (.getMethodTable multifn))\n\n(defn get-method\n  \"Given a multimethod and a dispatch value, returns the dispatch fn\n  that would apply to that value, or nil if none apply and no default\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.MultiFn multifn dispatch-val] (.getMethod multifn dispatch-val))\n\n(defn prefers\n  \"Given a multimethod, returns a map of preferred value -> set of other values\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.MultiFn multifn] (.getPreferTable multifn))\n\n;;;;;;;;; var stuff\n\n(defmacro ^{:private true} assert-args\n  [& pairs]\n  `(do (when-not ~(first pairs)\n         (throw (IllegalArgumentException.\n                  (str (first ~'&form) \" requires \" ~(second pairs) \" in \" ~'*ns* \":\" (:line (meta ~'&form))))))\n     ~(let [more (nnext pairs)]\n        (when more\n          (list* `assert-args more)))))\n\n(defmacro if-let\n  \"bindings => binding-form test\n\n  If test is true, evaluates then with binding-form bound to the value of\n  test, if not, yields else\"\n  {:added \"1.0\"}\n  ([bindings then]\n   `(if-let ~bindings ~then nil))\n  ([bindings then else & oldform]\n   (assert-args\n     (vector? bindings) \"a vector for its binding\"\n     (nil? oldform) \"1 or 2 forms after binding vector\"\n     (= 2 (count bindings)) \"exactly 2 forms in binding vector\")\n   (let [form (bindings 0) tst (bindings 1)]\n     `(let [temp# ~tst]\n        (if temp#\n          (let [~form temp#]\n            ~then)\n          ~else)))))\n\n(defmacro when-let\n  \"bindings => binding-form test\n\n  When test is true, evaluates body with binding-form bound to the value of test\"\n  {:added \"1.0\"}\n  [bindings & body]\n  (assert-args\n     (vector? bindings) \"a vector for its binding\"\n     (= 2 (count bindings)) \"exactly 2 forms in binding vector\")\n   (let [form (bindings 0) tst (bindings 1)]\n    `(let [temp# ~tst]\n       (when temp#\n         (let [~form temp#]\n           ~@body)))))\n\n(defmacro if-some\n  \"bindings => binding-form test\n\n   If test is not nil, evaluates then with binding-form bound to the\n   value of test, if not, yields else\"\n  {:added \"1.6\"}\n  ([bindings then]\n   `(if-some ~bindings ~then nil))\n  ([bindings then else & oldform]\n   (assert-args\n     (vector? bindings) \"a vector for its binding\"\n     (nil? oldform) \"1 or 2 forms after binding vector\"\n     (= 2 (count bindings)) \"exactly 2 forms in binding vector\")\n   (let [form (bindings 0) tst (bindings 1)]\n     `(let [temp# ~tst]\n        (if (nil? temp#)\n          ~else\n          (let [~form temp#]\n            ~then))))))\n\n(defmacro when-some\n  \"bindings => binding-form test\n\n   When test is not nil, evaluates body with binding-form bound to the\n   value of test\"\n  {:added \"1.6\"}\n  [bindings & body]\n  (assert-args\n     (vector? bindings) \"a vector for its binding\"\n     (= 2 (count bindings)) \"exactly 2 forms in binding vector\")\n   (let [form (bindings 0) tst (bindings 1)]\n    `(let [temp# ~tst]\n       (if (nil? temp#)\n         nil\n         (let [~form temp#]\n           ~@body)))))\n\n(defn push-thread-bindings\n  \"WARNING: This is a low-level function. Prefer high-level macros like\n  binding where ever possible.\n\n  Takes a map of Var/value pairs. Binds each Var to the associated value for\n  the current thread. Each call *MUST* be accompanied by a matching call to\n  pop-thread-bindings wrapped in a try-finally!\n\n      (push-thread-bindings bindings)\n      (try\n        ...\n        (finally\n          (pop-thread-bindings)))\"\n  {:added \"1.1\"\n   :static true}\n  [bindings]\n  (clojure.lang.Var/pushThreadBindings bindings))\n\n(defn pop-thread-bindings\n  \"Pop one set of bindings pushed with push-binding before. It is an error to\n  pop bindings without pushing before.\"\n  {:added \"1.1\"\n   :static true}\n  []\n  (clojure.lang.Var/popThreadBindings))\n\n(defn get-thread-bindings\n  \"Get a map with the Var/value pairs which is currently in effect for the\n  current thread.\"\n  {:added \"1.1\"\n   :static true}\n  []\n  (clojure.lang.Var/getThreadBindings))\n\n(defmacro binding\n  \"binding => var-symbol init-expr\n\n  Creates new bindings for the (already-existing) vars, with the\n  supplied initial values, executes the exprs in an implicit do, then\n  re-establishes the bindings that existed before.  The new bindings\n  are made in parallel (unlike let); all init-exprs are evaluated\n  before the vars are bound to their new values.\"\n  {:added \"1.0\"}\n  [bindings & body]\n  (assert-args\n    (vector? bindings) \"a vector for its binding\"\n    (even? (count bindings)) \"an even number of forms in binding vector\")\n  (let [var-ize (fn [var-vals]\n                  (loop [ret [] vvs (seq var-vals)]\n                    (if vvs\n                      (recur  (conj (conj ret `(var ~(first vvs))) (second vvs))\n                             (next (next vvs)))\n                      (seq ret))))]\n    `(let []\n       (push-thread-bindings (hash-map ~@(var-ize bindings)))\n       (try\n         ~@body\n         (finally\n           (pop-thread-bindings))))))\n\n(defn with-bindings*\n  \"Takes a map of Var/value pairs. Installs for the given Vars the associated\n  values as thread-local bindings. Then calls f with the supplied arguments.\n  Pops the installed bindings after f returned. Returns whatever f returns.\"\n  {:added \"1.1\"\n   :static true}\n  [binding-map f & args]\n  (push-thread-bindings binding-map)\n  (try\n    (apply f args)\n    (finally\n      (pop-thread-bindings))))\n\n(defmacro with-bindings\n  \"Takes a map of Var/value pairs. Installs for the given Vars the associated\n  values as thread-local bindings. The executes body. Pops the installed\n  bindings after body was evaluated. Returns the value of body.\"\n  {:added \"1.1\"}\n  [binding-map & body]\n  `(with-bindings* ~binding-map (fn [] ~@body)))\n\n(defn bound-fn*\n  \"Returns a function, which will install the same bindings in effect as in\n  the thread at the time bound-fn* was called and then call f with any given\n  arguments. This may be used to define a helper function which runs on a\n  different thread, but needs the same bindings in place.\"\n  {:added \"1.1\"\n   :static true}\n  [f]\n  (let [bindings (get-thread-bindings)]\n    (fn [& args]\n      (apply with-bindings* bindings f args))))\n\n(defmacro bound-fn\n  \"Returns a function defined by the given fntail, which will install the\n  same bindings in effect as in the thread at the time bound-fn was called.\n  This may be used to define a helper function which runs on a different\n  thread, but needs the same bindings in place.\"\n  {:added \"1.1\"}\n  [& fntail]\n  `(bound-fn* (fn ~@fntail)))\n\n(defn find-var\n  \"Returns the global var named by the namespace-qualified symbol, or\n  nil if no var with that name.\"\n  {:added \"1.0\"\n   :static true}\n  [sym] (. clojure.lang.Var (find sym)))\n\n(defn binding-conveyor-fn\n  {:private true\n   :added \"1.3\"}\n  [f]\n  (let [frame (clojure.lang.Var/cloneThreadBindingFrame)]\n    (fn\n      ([]\n         (clojure.lang.Var/resetThreadBindingFrame frame)\n         (f))\n      ([x]\n         (clojure.lang.Var/resetThreadBindingFrame frame)\n         (f x))\n      ([x y]\n         (clojure.lang.Var/resetThreadBindingFrame frame)\n         (f x y))\n      ([x y z]\n         (clojure.lang.Var/resetThreadBindingFrame frame)\n         (f x y z))\n      ([x y z & args]\n         (clojure.lang.Var/resetThreadBindingFrame frame)\n         (apply f x y z args)))))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Refs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defn ^{:private true}\n  setup-reference [^clojure.lang.ARef r options]\n  (let [opts (apply hash-map options)]\n    (when (:meta opts)\n      (.resetMeta r (:meta opts)))\n    (when (:validator opts)\n      (.setValidator r (:validator opts)))\n    r))\n\n(defn agent\n  \"Creates and returns an agent with an initial value of state and\n  zero or more options (in any order):\n\n  :meta metadata-map\n\n  :validator validate-fn\n\n  :error-handler handler-fn\n\n  :error-mode mode-keyword\n\n  If metadata-map is supplied, it will become the metadata on the\n  agent. validate-fn must be nil or a side-effect-free fn of one\n  argument, which will be passed the intended new state on any state\n  change. If the new state is unacceptable, the validate-fn should\n  return false or throw an exception.  handler-fn is called if an\n  action throws an exception or if validate-fn rejects a new state --\n  see set-error-handler! for details.  The mode-keyword may be either\n  :continue (the default if an error-handler is given) or :fail (the\n  default if no error-handler is given) -- see set-error-mode! for\n  details.\"\n  {:added \"1.0\"\n   :static true\n   }\n  ([state & options]\n     (let [a (new clojure.lang.Agent state)\n           opts (apply hash-map options)]\n       (setup-reference a options)\n       (when (:error-handler opts)\n         (.setErrorHandler a (:error-handler opts)))\n       (.setErrorMode a (or (:error-mode opts)\n                            (if (:error-handler opts) :continue :fail)))\n       a)))\n\n(defn set-agent-send-executor!\n  \"Sets the ExecutorService to be used by send\"\n  {:added \"1.5\"}\n  [executor]\n  (set! clojure.lang.Agent/pooledExecutor executor))\n\n(defn set-agent-send-off-executor!\n  \"Sets the ExecutorService to be used by send-off\"\n  {:added \"1.5\"}\n  [executor]\n  (set! clojure.lang.Agent/soloExecutor executor))\n\n(defn send-via\n  \"Dispatch an action to an agent. Returns the agent immediately.\n  Subsequently, in a thread supplied by executor, the state of the agent\n  will be set to the value of:\n\n  (apply action-fn state-of-agent args)\"\n  {:added \"1.5\"}\n  [executor ^clojure.lang.Agent a f & args]\n  (.dispatch a (binding [*agent* a] (binding-conveyor-fn f)) args executor))\n\n(defn send\n  \"Dispatch an action to an agent. Returns the agent immediately.\n  Subsequently, in a thread from a thread pool, the state of the agent\n  will be set to the value of:\n\n  (apply action-fn state-of-agent args)\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.Agent a f & args]\n  (apply send-via clojure.lang.Agent/pooledExecutor a f args))\n\n(defn send-off\n  \"Dispatch a potentially blocking action to an agent. Returns the\n  agent immediately. Subsequently, in a separate thread, the state of\n  the agent will be set to the value of:\n\n  (apply action-fn state-of-agent args)\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.Agent a f & args]\n  (apply send-via clojure.lang.Agent/soloExecutor a f args))\n\n(defn release-pending-sends\n  \"Normally, actions sent directly or indirectly during another action\n  are held until the action completes (changes the agent's\n  state). This function can be used to dispatch any pending sent\n  actions immediately. This has no impact on actions sent during a\n  transaction, which are still held until commit. If no action is\n  occurring, does nothing. Returns the number of actions dispatched.\"\n  {:added \"1.0\"\n   :static true}\n  [] (clojure.lang.Agent/releasePendingSends))\n\n(defn add-watch\n  \"Adds a watch function to an agent/atom/var/ref reference. The watch\n  fn must be a fn of 4 args: a key, the reference, its old-state, its\n  new-state. Whenever the reference's state might have been changed,\n  any registered watches will have their functions called. The watch fn\n  will be called synchronously, on the agent's thread if an agent,\n  before any pending sends if agent or ref. Note that an atom's or\n  ref's state may have changed again prior to the fn call, so use\n  old/new-state rather than derefing the reference. Note also that watch\n  fns may be called from multiple threads simultaneously. Var watchers\n  are triggered only by root binding changes, not thread-local\n  set!s. Keys must be unique per reference, and can be used to remove\n  the watch with remove-watch, but are otherwise considered opaque by\n  the watch mechanism.\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.IRef reference key fn] (.addWatch reference key fn))\n\n(defn remove-watch\n  \"Removes a watch (set by add-watch) from a reference\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.IRef reference key]\n  (.removeWatch reference key))\n\n(defn agent-error\n  \"Returns the exception thrown during an asynchronous action of the\n  agent if the agent is failed.  Returns nil if the agent is not\n  failed.\"\n  {:added \"1.2\"\n   :static true}\n  [^clojure.lang.Agent a] (.getError a))\n\n(defn restart-agent\n  \"When an agent is failed, changes the agent state to new-state and\n  then un-fails the agent so that sends are allowed again.  If\n  a :clear-actions true option is given, any actions queued on the\n  agent that were being held while it was failed will be discarded,\n  otherwise those held actions will proceed.  The new-state must pass\n  the validator if any, or restart will throw an exception and the\n  agent will remain failed with its old state and error.  Watchers, if\n  any, will NOT be notified of the new state.  Throws an exception if\n  the agent is not failed.\"\n  {:added \"1.2\"\n   :static true\n   }\n  [^clojure.lang.Agent a, new-state & options]\n  (let [opts (apply hash-map options)]\n    (.restart a new-state (if (:clear-actions opts) true false))))\n\n(defn set-error-handler!\n  \"Sets the error-handler of agent a to handler-fn.  If an action\n  being run by the agent throws an exception or doesn't pass the\n  validator fn, handler-fn will be called with two arguments: the\n  agent and the exception.\"\n  {:added \"1.2\"\n   :static true}\n  [^clojure.lang.Agent a, handler-fn]\n  (.setErrorHandler a handler-fn))\n\n(defn error-handler\n  \"Returns the error-handler of agent a, or nil if there is none.\n  See set-error-handler!\"\n  {:added \"1.2\"\n   :static true}\n  [^clojure.lang.Agent a]\n  (.getErrorHandler a))\n\n(defn set-error-mode!\n  \"Sets the error-mode of agent a to mode-keyword, which must be\n  either :fail or :continue.  If an action being run by the agent\n  throws an exception or doesn't pass the validator fn, an\n  error-handler may be called (see set-error-handler!), after which,\n  if the mode is :continue, the agent will continue as if neither the\n  action that caused the error nor the error itself ever happened.\n\n  If the mode is :fail, the agent will become failed and will stop\n  accepting new 'send' and 'send-off' actions, and any previously\n  queued actions will be held until a 'restart-agent'.  Deref will\n  still work, returning the state of the agent before the error.\"\n  {:added \"1.2\"\n   :static true}\n  [^clojure.lang.Agent a, mode-keyword]\n  (.setErrorMode a mode-keyword))\n\n(defn error-mode\n  \"Returns the error-mode of agent a.  See set-error-mode!\"\n  {:added \"1.2\"\n   :static true}\n  [^clojure.lang.Agent a]\n  (.getErrorMode a))\n\n(defn agent-errors\n  \"DEPRECATED: Use 'agent-error' instead.\n  Returns a sequence of the exceptions thrown during asynchronous\n  actions of the agent.\"\n  {:added \"1.0\"\n   :deprecated \"1.2\"}\n  [a]\n  (when-let [e (agent-error a)]\n    (list e)))\n\n(defn clear-agent-errors\n  \"DEPRECATED: Use 'restart-agent' instead.\n  Clears any exceptions thrown during asynchronous actions of the\n  agent, allowing subsequent actions to occur.\"\n  {:added \"1.0\"\n   :deprecated \"1.2\"}\n  [^clojure.lang.Agent a] (restart-agent a (.deref a)))\n\n(defn shutdown-agents\n  \"Initiates a shutdown of the thread pools that back the agent\n  system. Running actions will complete, but no new actions will be\n  accepted\"\n  {:added \"1.0\"\n   :static true}\n  [] (. clojure.lang.Agent shutdown))\n\n(defn ref\n  \"Creates and returns a Ref with an initial value of x and zero or\n  more options (in any order):\n\n  :meta metadata-map\n\n  :validator validate-fn\n\n  :min-history (default 0)\n  :max-history (default 10)\n\n  If metadata-map is supplied, it will become the metadata on the\n  ref. validate-fn must be nil or a side-effect-free fn of one\n  argument, which will be passed the intended new state on any state\n  change. If the new state is unacceptable, the validate-fn should\n  return false or throw an exception. validate-fn will be called on\n  transaction commit, when all refs have their final values.\n\n  Normally refs accumulate history dynamically as needed to deal with\n  read demands. If you know in advance you will need history you can\n  set :min-history to ensure it will be available when first needed (instead\n  of after a read fault). History is limited, and the limit can be set\n  with :max-history.\"\n  {:added \"1.0\"\n   :static true\n   }\n  ([x] (new clojure.lang.Ref x))\n  ([x & options]\n   (let [r  ^clojure.lang.Ref (setup-reference (ref x) options)\n         opts (apply hash-map options)]\n    (when (:max-history opts)\n      (.setMaxHistory r (:max-history opts)))\n    (when (:min-history opts)\n      (.setMinHistory r (:min-history opts)))\n    r)))\n\n(defn ^:private deref-future\n  ([^java.util.concurrent.Future fut]\n     (.get fut))\n  ([^java.util.concurrent.Future fut timeout-ms timeout-val]\n     (try (.get fut timeout-ms java.util.concurrent.TimeUnit/MILLISECONDS)\n          (catch java.util.concurrent.TimeoutException e\n            timeout-val))))\n\n(defn deref\n  \"Also reader macro: @ref/@agent/@var/@atom/@delay/@future/@promise. Within a transaction,\n  returns the in-transaction-value of ref, else returns the\n  most-recently-committed value of ref. When applied to a var, agent\n  or atom, returns its current state. When applied to a delay, forces\n  it if not already forced. When applied to a future, will block if\n  computation not complete. When applied to a promise, will block\n  until a value is delivered.  The variant taking a timeout can be\n  used for blocking references (futures and promises), and will return\n  timeout-val if the timeout (in milliseconds) is reached before a\n  value is available. See also - realized?.\"\n  {:added \"1.0\"\n   :static true}\n  ([ref] (if (instance? clojure.lang.IDeref ref)\n           (.deref ^clojure.lang.IDeref ref)\n           (deref-future ref)))\n  ([ref timeout-ms timeout-val]\n     (if (instance? clojure.lang.IBlockingDeref ref)\n       (.deref ^clojure.lang.IBlockingDeref ref timeout-ms timeout-val)\n       (deref-future ref timeout-ms timeout-val))))\n\n(defn atom\n  \"Creates and returns an Atom with an initial value of x and zero or\n  more options (in any order):\n\n  :meta metadata-map\n\n  :validator validate-fn\n\n  If metadata-map is supplied, it will become the metadata on the\n  atom. validate-fn must be nil or a side-effect-free fn of one\n  argument, which will be passed the intended new state on any state\n  change. If the new state is unacceptable, the validate-fn should\n  return false or throw an exception.\"\n  {:added \"1.0\"\n   :static true}\n  ([x] (new clojure.lang.Atom x))\n  ([x & options] (setup-reference (atom x) options)))\n\n(defn swap!\n  \"Atomically swaps the value of atom to be:\n  (apply f current-value-of-atom args). Note that f may be called\n  multiple times, and thus should be free of side effects.  Returns\n  the value that was swapped in.\"\n  {:added \"1.0\"\n   :static true}\n  ([^clojure.lang.IAtom atom f] (.swap atom f))\n  ([^clojure.lang.IAtom atom f x] (.swap atom f x))\n  ([^clojure.lang.IAtom atom f x y] (.swap atom f x y))\n  ([^clojure.lang.IAtom atom f x y & args] (.swap atom f x y args)))\n\n(defn compare-and-set!\n  \"Atomically sets the value of atom to newval if and only if the\n  current value of the atom is identical to oldval. Returns true if\n  set happened, else false\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.IAtom atom oldval newval] (.compareAndSet atom oldval newval))\n\n(defn reset!\n  \"Sets the value of atom to newval without regard for the\n  current value. Returns newval.\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.IAtom atom newval] (.reset atom newval))\n\n(defn set-validator!\n  \"Sets the validator-fn for a var/ref/agent/atom. validator-fn must be nil or a\n  side-effect-free fn of one argument, which will be passed the intended\n  new state on any state change. If the new state is unacceptable, the\n  validator-fn should return false or throw an exception. If the current state (root\n  value if var) is not acceptable to the new validator, an exception\n  will be thrown and the validator will not be changed.\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.IRef iref validator-fn] (. iref (setValidator validator-fn)))\n\n(defn get-validator\n  \"Gets the validator-fn for a var/ref/agent/atom.\"\n  {:added \"1.0\"\n   :static true}\n [^clojure.lang.IRef iref] (. iref (getValidator)))\n\n(defn alter-meta!\n  \"Atomically sets the metadata for a namespace/var/ref/agent/atom to be:\n\n  (apply f its-current-meta args)\n\n  f must be free of side-effects\"\n  {:added \"1.0\"\n   :static true}\n [^clojure.lang.IReference iref f & args] (.alterMeta iref f args))\n\n(defn reset-meta!\n  \"Atomically resets the metadata for a namespace/var/ref/agent/atom\"\n  {:added \"1.0\"\n   :static true}\n [^clojure.lang.IReference iref metadata-map] (.resetMeta iref metadata-map))\n\n(defn commute\n  \"Must be called in a transaction. Sets the in-transaction-value of\n  ref to:\n\n  (apply fun in-transaction-value-of-ref args)\n\n  and returns the in-transaction-value of ref.\n\n  At the commit point of the transaction, sets the value of ref to be:\n\n  (apply fun most-recently-committed-value-of-ref args)\n\n  Thus fun should be commutative, or, failing that, you must accept\n  last-one-in-wins behavior.  commute allows for more concurrency than\n  ref-set.\"\n  {:added \"1.0\"\n   :static true}\n\n  [^clojure.lang.Ref ref fun & args]\n    (. ref (commute fun args)))\n\n(defn alter\n  \"Must be called in a transaction. Sets the in-transaction-value of\n  ref to:\n\n  (apply fun in-transaction-value-of-ref args)\n\n  and returns the in-transaction-value of ref.\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.Ref ref fun & args]\n    (. ref (alter fun args)))\n\n(defn ref-set\n  \"Must be called in a transaction. Sets the value of ref.\n  Returns val.\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.Ref ref val]\n    (. ref (set val)))\n\n(defn ref-history-count\n  \"Returns the history count of a ref\"\n  {:added \"1.1\"\n   :static true}\n  [^clojure.lang.Ref ref]\n    (.getHistoryCount ref))\n\n(defn ref-min-history\n  \"Gets the min-history of a ref, or sets it and returns the ref\"\n  {:added \"1.1\"\n   :static true}\n  ([^clojure.lang.Ref ref]\n    (.getMinHistory ref))\n  ([^clojure.lang.Ref ref n]\n    (.setMinHistory ref n)))\n\n(defn ref-max-history\n  \"Gets the max-history of a ref, or sets it and returns the ref\"\n  {:added \"1.1\"\n   :static true}\n  ([^clojure.lang.Ref ref]\n    (.getMaxHistory ref))\n  ([^clojure.lang.Ref ref n]\n    (.setMaxHistory ref n)))\n\n(defn ensure\n  \"Must be called in a transaction. Protects the ref from modification\n  by other transactions.  Returns the in-transaction-value of\n  ref. Allows for more concurrency than (ref-set ref @ref)\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.Ref ref]\n    (. ref (touch))\n    (. ref (deref)))\n\n(defmacro sync\n  \"transaction-flags => TBD, pass nil for now\n\n  Runs the exprs (in an implicit do) in a transaction that encompasses\n  exprs and any nested calls.  Starts a transaction if none is already\n  running on this thread. Any uncaught exception will abort the\n  transaction and flow out of sync. The exprs may be run more than\n  once, but any effects on Refs will be atomic.\"\n  {:added \"1.0\"}\n  [flags-ignored-for-now & body]\n  `(. clojure.lang.LockingTransaction\n      (runInTransaction (fn [] ~@body))))\n\n\n(defmacro io!\n  \"If an io! block occurs in a transaction, throws an\n  IllegalStateException, else runs body in an implicit do. If the\n  first expression in body is a literal string, will use that as the\n  exception message.\"\n  {:added \"1.0\"}\n  [& body]\n  (let [message (when (string? (first body)) (first body))\n        body (if message (next body) body)]\n    `(if (clojure.lang.LockingTransaction/isRunning)\n       (throw (new IllegalStateException ~(or message \"I/O in transaction\")))\n       (do ~@body))))\n\n(defn volatile!\n  \"Creates and returns a Volatile with an initial value of val.\"\n  {:added \"1.7\"\n   :tag clojure.lang.Volatile}\n  [val]\n  (clojure.lang.Volatile. val))\n\n(defn vreset!\n  \"Sets the value of volatile to newval without regard for the\n   current value. Returns newval.\"\n  {:added \"1.7\"}\n  [^clojure.lang.Volatile vol newval]\n  (.reset vol newval))\n\n(defmacro vswap!\n  \"Non-atomically swaps the value of the volatile as if:\n   (apply f current-value-of-vol args). Returns the value that\n   was swapped in.\"\n  {:added \"1.7\"}\n  [vol f & args]\n  (let [v (with-meta vol {:tag 'clojure.lang.Volatile})]\n    `(.reset ~v (~f (.deref ~v) ~@args))))\n\n(defn volatile?\n  \"Returns true if x is a volatile.\"\n  {:added \"1.7\"}\n  [x]\n  (instance? clojure.lang.Volatile x))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; fn stuff ;;;;;;;;;;;;;;;;\n\n\n(defn comp\n  \"Takes a set of functions and returns a fn that is the composition\n  of those fns.  The returned fn takes a variable number of args,\n  applies the rightmost of fns to the args, the next\n  fn (right-to-left) to the result, etc.\"\n  {:added \"1.0\"\n   :static true}\n  ([] identity)\n  ([f] f)\n  ([f g]\n     (fn\n       ([] (f (g)))\n       ([x] (f (g x)))\n       ([x y] (f (g x y)))\n       ([x y z] (f (g x y z)))\n       ([x y z & args] (f (apply g x y z args)))))\n  ([f g & fs]\n     (reduce1 comp (list* f g fs))))\n\n(defn juxt\n  \"Takes a set of functions and returns a fn that is the juxtaposition\n  of those fns.  The returned fn takes a variable number of args, and\n  returns a vector containing the result of applying each fn to the\n  args (left-to-right).\n  ((juxt a b c) x) => [(a x) (b x) (c x)]\"\n  {:added \"1.1\"\n   :static true}\n  ([f]\n     (fn\n       ([] [(f)])\n       ([x] [(f x)])\n       ([x y] [(f x y)])\n       ([x y z] [(f x y z)])\n       ([x y z & args] [(apply f x y z args)])))\n  ([f g]\n     (fn\n       ([] [(f) (g)])\n       ([x] [(f x) (g x)])\n       ([x y] [(f x y) (g x y)])\n       ([x y z] [(f x y z) (g x y z)])\n       ([x y z & args] [(apply f x y z args) (apply g x y z args)])))\n  ([f g h]\n     (fn\n       ([] [(f) (g) (h)])\n       ([x] [(f x) (g x) (h x)])\n       ([x y] [(f x y) (g x y) (h x y)])\n       ([x y z] [(f x y z) (g x y z) (h x y z)])\n       ([x y z & args] [(apply f x y z args) (apply g x y z args) (apply h x y z args)])))\n  ([f g h & fs]\n     (let [fs (list* f g h fs)]\n       (fn\n         ([] (reduce1 #(conj %1 (%2)) [] fs))\n         ([x] (reduce1 #(conj %1 (%2 x)) [] fs))\n         ([x y] (reduce1 #(conj %1 (%2 x y)) [] fs))\n         ([x y z] (reduce1 #(conj %1 (%2 x y z)) [] fs))\n         ([x y z & args] (reduce1 #(conj %1 (apply %2 x y z args)) [] fs))))))\n\n(defn partial\n  \"Takes a function f and fewer than the normal arguments to f, and\n  returns a fn that takes a variable number of additional args. When\n  called, the returned function calls f with args + additional args.\"\n  {:added \"1.0\"\n   :static true}\n  ([f] f)\n  ([f arg1]\n   (fn\n     ([] (f arg1))\n     ([x] (f arg1 x))\n     ([x y] (f arg1 x y))\n     ([x y z] (f arg1 x y z))\n     ([x y z & args] (apply f arg1 x y z args))))\n  ([f arg1 arg2]\n   (fn\n     ([] (f arg1 arg2))\n     ([x] (f arg1 arg2 x))\n     ([x y] (f arg1 arg2 x y))\n     ([x y z] (f arg1 arg2 x y z))\n     ([x y z & args] (apply f arg1 arg2 x y z args))))\n  ([f arg1 arg2 arg3]\n   (fn\n     ([] (f arg1 arg2 arg3))\n     ([x] (f arg1 arg2 arg3 x))\n     ([x y] (f arg1 arg2 arg3 x y))\n     ([x y z] (f arg1 arg2 arg3 x y z))\n     ([x y z & args] (apply f arg1 arg2 arg3 x y z args))))\n  ([f arg1 arg2 arg3 & more]\n   (fn [& args] (apply f arg1 arg2 arg3 (concat more args)))))\n\n;;;;;;;;;;;;;;;;;;; sequence fns  ;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn sequence\n  \"Coerces coll to a (possibly empty) sequence, if it is not already\n  one. Will not force a lazy seq. (sequence nil) yields (), When a\n  transducer is supplied, returns a lazy sequence of applications of\n  the transform to the items in coll(s), i.e. to the set of first\n  items of each coll, followed by the set of second\n  items in each coll, until any one of the colls is exhausted.  Any\n  remaining items in other colls are ignored. The transform should accept\n  number-of-colls arguments\"\n  {:added \"1.0\"\n   :static true}\n  ([coll]\n     (if (seq? coll) coll\n         (or (seq coll) ())))\n  ([xform coll]\n     (or (clojure.lang.RT/chunkIteratorSeq\n         (clojure.lang.TransformerIterator/create xform (clojure.lang.RT/iter coll)))\n       ()))\n  ([xform coll & colls]\n     (or (clojure.lang.RT/chunkIteratorSeq\n         (clojure.lang.TransformerIterator/createMulti\n           xform\n           (map #(clojure.lang.RT/iter %) (cons coll colls))))\n       ())))\n\n(defn every?\n  \"Returns true if (pred x) is logical true for every x in coll, else\n  false.\"\n  {:tag Boolean\n   :added \"1.0\"\n   :static true}\n  [pred coll]\n  (cond\n   (nil? (seq coll)) true\n   (pred (first coll)) (recur pred (next coll))\n   :else false))\n\n(def\n ^{:tag Boolean\n   :doc \"Returns false if (pred x) is logical true for every x in\n  coll, else true.\"\n   :arglists '([pred coll])\n   :added \"1.0\"}\n not-every? (comp not every?))\n\n(defn some\n  \"Returns the first logical true value of (pred x) for any x in coll,\n  else nil.  One common idiom is to use a set as pred, for example\n  this will return :fred if :fred is in the sequence, otherwise nil:\n  (some #{:fred} coll)\"\n  {:added \"1.0\"\n   :static true}\n  [pred coll]\n    (when (seq coll)\n      (or (pred (first coll)) (recur pred (next coll)))))\n\n(def\n ^{:tag Boolean\n   :doc \"Returns false if (pred x) is logical true for any x in coll,\n  else true.\"\n   :arglists '([pred coll])\n   :added \"1.0\"}\n not-any? (comp not some))\n\n;will be redefed later with arg checks\n(defmacro dotimes\n  \"bindings => name n\n\n  Repeatedly executes body (presumably for side-effects) with name\n  bound to integers from 0 through n-1.\"\n  {:added \"1.0\"}\n  [bindings & body]\n  (let [i (first bindings)\n        n (second bindings)]\n    `(let [n# (clojure.lang.RT/longCast ~n)]\n       (loop [~i 0]\n         (when (< ~i n#)\n           ~@body\n           (recur (unchecked-inc ~i)))))))\n\n(defn map\n  \"Returns a lazy sequence consisting of the result of applying f to\n  the set of first items of each coll, followed by applying f to the\n  set of second items in each coll, until any one of the colls is\n  exhausted.  Any remaining items in other colls are ignored. Function\n  f should accept number-of-colls arguments. Returns a transducer when\n  no collection is provided.\"\n  {:added \"1.0\"\n   :static true}\n  ([f]\n    (fn [rf]\n      (fn\n        ([] (rf))\n        ([result] (rf result))\n        ([result input]\n           (rf result (f input)))\n        ([result input & inputs]\n           (rf result (apply f input inputs))))))\n  ([f coll]\n   (lazy-seq\n    (when-let [s (seq coll)]\n      (if (chunked-seq? s)\n        (let [c (chunk-first s)\n              size (int (count c))\n              b (chunk-buffer size)]\n          (dotimes [i size]\n              (chunk-append b (f (.nth c i))))\n          (chunk-cons (chunk b) (map f (chunk-rest s))))\n        (cons (f (first s)) (map f (rest s)))))))\n  ([f c1 c2]\n   (lazy-seq\n    (let [s1 (seq c1) s2 (seq c2)]\n      (when (and s1 s2)\n        (cons (f (first s1) (first s2))\n              (map f (rest s1) (rest s2)))))))\n  ([f c1 c2 c3]\n   (lazy-seq\n    (let [s1 (seq c1) s2 (seq c2) s3 (seq c3)]\n      (when (and  s1 s2 s3)\n        (cons (f (first s1) (first s2) (first s3))\n              (map f (rest s1) (rest s2) (rest s3)))))))\n  ([f c1 c2 c3 & colls]\n   (let [step (fn step [cs]\n                 (lazy-seq\n                  (let [ss (map seq cs)]\n                    (when (every? identity ss)\n                      (cons (map first ss) (step (map rest ss)))))))]\n     (map #(apply f %) (step (conj colls c3 c2 c1))))))\n\n(defmacro declare\n  \"defs the supplied var names with no bindings, useful for making forward declarations.\"\n  {:added \"1.0\"}\n  [& names] `(do ~@(map #(list 'def (vary-meta % assoc :declared true)) names)))\n\n(declare cat)\n\n(defn mapcat\n  \"Returns the result of applying concat to the result of applying map\n  to f and colls.  Thus function f should return a collection. Returns\n  a transducer when no collections are provided\"\n  {:added \"1.0\"\n   :static true}\n  ([f] (comp (map f) cat))\n  ([f & colls]\n     (apply concat (apply map f colls))))\n\n(defn filter\n  \"Returns a lazy sequence of the items in coll for which\n  (pred item) returns true. pred must be free of side-effects.\n  Returns a transducer when no collection is provided.\"\n  {:added \"1.0\"\n   :static true}\n  ([pred]\n    (fn [rf]\n      (fn\n        ([] (rf))\n        ([result] (rf result))\n        ([result input]\n           (if (pred input)\n             (rf result input)\n             result)))))\n  ([pred coll]\n   (lazy-seq\n    (when-let [s (seq coll)]\n      (if (chunked-seq? s)\n        (let [c (chunk-first s)\n              size (count c)\n              b (chunk-buffer size)]\n          (dotimes [i size]\n              (let [v (.nth c i)]\n                (when (pred v)\n                  (chunk-append b v))))\n          (chunk-cons (chunk b) (filter pred (chunk-rest s))))\n        (let [f (first s) r (rest s)]\n          (if (pred f)\n            (cons f (filter pred r))\n            (filter pred r))))))))\n\n\n(defn remove\n  \"Returns a lazy sequence of the items in coll for which\n  (pred item) returns false. pred must be free of side-effects.\n  Returns a transducer when no collection is provided.\"\n  {:added \"1.0\"\n   :static true}\n  ([pred] (filter (complement pred)))\n  ([pred coll]\n     (filter (complement pred) coll)))\n\n(defn reduced\n  \"Wraps x in a way such that a reduce will terminate with the value x\"\n  {:added \"1.5\"}\n  [x]\n  (clojure.lang.Reduced. x))\n\n(defn reduced?\n  \"Returns true if x is the result of a call to reduced\"\n  {:inline (fn [x] `(clojure.lang.RT/isReduced ~x ))\n   :inline-arities #{1}\n   :added \"1.5\"}\n  ([x] (clojure.lang.RT/isReduced x)))\n\n(defn ensure-reduced\n  \"If x is already reduced?, returns it, else returns (reduced x)\"\n  {:added \"1.7\"}\n  [x]\n  (if (reduced? x) x (reduced x)))\n\n(defn unreduced\n  \"If x is reduced?, returns (deref x), else returns x\"\n  {:added \"1.7\"}\n  [x]\n  (if (reduced? x) (deref x) x))\n\n(defn take\n  \"Returns a lazy sequence of the first n items in coll, or all items if\n  there are fewer than n.  Returns a stateful transducer when\n  no collection is provided.\"\n  {:added \"1.0\"\n   :static true}\n  ([n]\n     (fn [rf]\n       (let [nv (volatile! n)]\n         (fn\n           ([] (rf))\n           ([result] (rf result))\n           ([result input]\n              (let [n @nv\n                    nn (vswap! nv dec)\n                    result (if (pos? n)\n                             (rf result input)\n                             result)]\n                (if (not (pos? nn))\n                  (ensure-reduced result)\n                  result)))))))\n  ([n coll]\n     (lazy-seq\n      (when (pos? n) \n        (when-let [s (seq coll)]\n          (cons (first s) (take (dec n) (rest s))))))))\n\n(defn take-while\n  \"Returns a lazy sequence of successive items from coll while\n  (pred item) returns true. pred must be free of side-effects.\n  Returns a transducer when no collection is provided.\"\n  {:added \"1.0\"\n   :static true}\n  ([pred]\n     (fn [rf]\n       (fn\n         ([] (rf))\n         ([result] (rf result))\n         ([result input]\n            (if (pred input)\n              (rf result input)\n              (reduced result))))))\n  ([pred coll]\n     (lazy-seq\n      (when-let [s (seq coll)]\n        (when (pred (first s))\n          (cons (first s) (take-while pred (rest s))))))))\n\n(defn drop\n  \"Returns a lazy sequence of all but the first n items in coll.\n  Returns a stateful transducer when no collection is provided.\"\n  {:added \"1.0\"\n   :static true}\n  ([n]\n     (fn [rf]\n       (let [nv (volatile! n)]\n         (fn\n           ([] (rf))\n           ([result] (rf result))\n           ([result input]\n              (let [n @nv]\n                (vswap! nv dec)\n                (if (pos? n)\n                  result\n                  (rf result input))))))))\n  ([n coll]\n     (let [step (fn [n coll]\n                  (let [s (seq coll)]\n                    (if (and (pos? n) s)\n                      (recur (dec n) (rest s))\n                      s)))]\n       (lazy-seq (step n coll)))))\n\n(defn drop-last\n  \"Return a lazy sequence of all but the last n (default 1) items in coll\"\n  {:added \"1.0\"\n   :static true}\n  ([s] (drop-last 1 s))\n  ([n s] (map (fn [x _] x) s (drop n s))))\n\n(defn take-last\n  \"Returns a seq of the last n items in coll.  Depending on the type\n  of coll may be no better than linear time.  For vectors, see also subvec.\"\n  {:added \"1.1\"\n   :static true}\n  [n coll]\n  (loop [s (seq coll), lead (seq (drop n coll))]\n    (if lead\n      (recur (next s) (next lead))\n      s)))\n\n(defn drop-while\n  \"Returns a lazy sequence of the items in coll starting from the\n  first item for which (pred item) returns logical false.  Returns a\n  stateful transducer when no collection is provided.\"\n  {:added \"1.0\"\n   :static true}\n  ([pred]\n     (fn [rf]\n       (let [dv (volatile! true)]\n         (fn\n           ([] (rf))\n           ([result] (rf result))\n           ([result input]\n              (let [drop? @dv]\n                (if (and drop? (pred input))\n                  result\n                  (do\n                    (vreset! dv nil)\n                    (rf result input)))))))))\n  ([pred coll]\n     (let [step (fn [pred coll]\n                  (let [s (seq coll)]\n                    (if (and s (pred (first s)))\n                      (recur pred (rest s))\n                      s)))]\n       (lazy-seq (step pred coll)))))\n\n(defn cycle\n  \"Returns a lazy (infinite!) sequence of repetitions of the items in coll.\"\n  {:added \"1.0\"\n   :static true}\n  [coll] (clojure.lang.Cycle/create (seq coll)))\n\n(defn split-at\n  \"Returns a vector of [(take n coll) (drop n coll)]\"\n  {:added \"1.0\"\n   :static true}\n  [n coll]\n    [(take n coll) (drop n coll)])\n\n(defn split-with\n  \"Returns a vector of [(take-while pred coll) (drop-while pred coll)]\"\n  {:added \"1.0\"\n   :static true}\n  [pred coll]\n    [(take-while pred coll) (drop-while pred coll)])\n\n(defn repeat\n  \"Returns a lazy (infinite!, or length n if supplied) sequence of xs.\"\n  {:added \"1.0\"\n   :static true}\n  ([x] (clojure.lang.Repeat/create x))\n  ([n x] (clojure.lang.Repeat/create n x)))\n\n(defn replicate\n  \"DEPRECATED: Use 'repeat' instead.\n   Returns a lazy seq of n xs.\"\n  {:added \"1.0\"\n   :deprecated \"1.3\"}\n  [n x] (take n (repeat x)))\n\n(defn iterate\n  \"Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects\"\n  {:added \"1.0\"\n   :static true}\n  [f x] (clojure.lang.Iterate/create f x) )\n\n(defn range\n  \"Returns a lazy seq of nums from start (inclusive) to end\n  (exclusive), by step, where start defaults to 0, step to 1, and end to\n  infinity. When step is equal to 0, returns an infinite sequence of\n  start. When start is equal to end, returns empty list.\"\n  {:added \"1.0\"\n   :static true}\n  ([]\n   (iterate inc' 0))\n  ([end]\n   (if (instance? Long end)\n     (clojure.lang.LongRange/create end)\n     (clojure.lang.Range/create end)))\n  ([start end]\n   (if (and (instance? Long start) (instance? Long end))\n     (clojure.lang.LongRange/create start end)\n     (clojure.lang.Range/create start end)))\n  ([start end step]\n   (if (and (instance? Long start) (instance? Long end) (instance? Long step))\n     (clojure.lang.LongRange/create start end step)\n     (clojure.lang.Range/create start end step))))\n\n(defn merge\n  \"Returns a map that consists of the rest of the maps conj-ed onto\n  the first.  If a key occurs in more than one map, the mapping from\n  the latter (left-to-right) will be the mapping in the result.\"\n  {:added \"1.0\"\n   :static true}\n  [& maps]\n  (when (some identity maps)\n    (reduce1 #(conj (or %1 {}) %2) maps)))\n\n(defn merge-with\n  \"Returns a map that consists of the rest of the maps conj-ed onto\n  the first.  If a key occurs in more than one map, the mapping(s)\n  from the latter (left-to-right) will be combined with the mapping in\n  the result by calling (f val-in-result val-in-latter).\"\n  {:added \"1.0\"\n   :static true}\n  [f & maps]\n  (when (some identity maps)\n    (let [merge-entry (fn [m e]\n\t\t\t(let [k (key e) v (val e)]\n\t\t\t  (if (contains? m k)\n\t\t\t    (assoc m k (f (get m k) v))\n\t\t\t    (assoc m k v))))\n          merge2 (fn [m1 m2]\n\t\t   (reduce1 merge-entry (or m1 {}) (seq m2)))]\n      (reduce1 merge2 maps))))\n\n\n\n(defn zipmap\n  \"Returns a map with the keys mapped to the corresponding vals.\"\n  {:added \"1.0\"\n   :static true}\n  [keys vals]\n    (loop [map {}\n           ks (seq keys)\n           vs (seq vals)]\n      (if (and ks vs)\n        (recur (assoc map (first ks) (first vs))\n               (next ks)\n               (next vs))\n        map)))\n\n(defn line-seq\n  \"Returns the lines of text from rdr as a lazy sequence of strings.\n  rdr must implement java.io.BufferedReader.\"\n  {:added \"1.0\"\n   :static true}\n  [^java.io.BufferedReader rdr]\n  (when-let [line (.readLine rdr)]\n    (cons line (lazy-seq (line-seq rdr)))))\n\n(defn comparator\n  \"Returns an implementation of java.util.Comparator based upon pred.\"\n  {:added \"1.0\"\n   :static true}\n  [pred]\n    (fn [x y]\n      (cond (pred x y) -1 (pred y x) 1 :else 0)))\n\n(defn sort\n  \"Returns a sorted sequence of the items in coll. If no comparator is\n  supplied, uses compare.  comparator must implement\n  java.util.Comparator.  If coll is a Java array, it will be modified.\n  To avoid this, sort a copy of the array.\"\n  {:added \"1.0\"\n   :static true}\n  ([coll]\n   (sort compare coll))\n  ([^java.util.Comparator comp coll]\n   (if (seq coll)\n     (let [a (to-array coll)]\n       (. java.util.Arrays (sort a comp))\n       (seq a))\n     ())))\n\n(defn sort-by\n  \"Returns a sorted sequence of the items in coll, where the sort\n  order is determined by comparing (keyfn item).  If no comparator is\n  supplied, uses compare.  comparator must implement\n  java.util.Comparator.  If coll is a Java array, it will be modified.\n  To avoid this, sort a copy of the array.\"\n  {:added \"1.0\"\n   :static true}\n  ([keyfn coll]\n   (sort-by keyfn compare coll))\n  ([keyfn ^java.util.Comparator comp coll]\n   (sort (fn [x y] (. comp (compare (keyfn x) (keyfn y)))) coll)))\n\n(defn dorun\n  \"When lazy sequences are produced via functions that have side\n  effects, any effects other than those needed to produce the first\n  element in the seq do not occur until the seq is consumed. dorun can\n  be used to force any effects. Walks through the successive nexts of\n  the seq, does not retain the head and returns nil.\"\n  {:added \"1.0\"\n   :static true}\n  ([coll]\n   (when-let [s (seq coll)]\n     (recur (next s))))\n  ([n coll]\n   (when (and (seq coll) (pos? n))\n     (recur (dec n) (next coll)))))\n\n(defn doall\n  \"When lazy sequences are produced via functions that have side\n  effects, any effects other than those needed to produce the first\n  element in the seq do not occur until the seq is consumed. doall can\n  be used to force any effects. Walks through the successive nexts of\n  the seq, retains the head and returns it, thus causing the entire\n  seq to reside in memory at one time.\"\n  {:added \"1.0\"\n   :static true}\n  ([coll]\n   (dorun coll)\n   coll)\n  ([n coll]\n   (dorun n coll)\n   coll))\n\n(defn nthnext\n  \"Returns the nth next of coll, (seq coll) when n is 0.\"\n  {:added \"1.0\"\n   :static true}\n  [coll n]\n    (loop [n n xs (seq coll)]\n      (if (and xs (pos? n))\n        (recur (dec n) (next xs))\n        xs)))\n\n(defn nthrest\n  \"Returns the nth rest of coll, coll when n is 0.\"\n  {:added \"1.3\"\n   :static true}\n  [coll n]\n    (loop [n n xs coll]\n      (if-let [xs (and (pos? n) (seq xs))]\n        (recur (dec n) (rest xs))\n        xs)))\n\n(defn partition\n  \"Returns a lazy sequence of lists of n items each, at offsets step\n  apart. If step is not supplied, defaults to n, i.e. the partitions\n  do not overlap. If a pad collection is supplied, use its elements as\n  necessary to complete last partition upto n items. In case there are\n  not enough padding elements, return a partition with less than n items.\"\n  {:added \"1.0\"\n   :static true}\n  ([n coll]\n     (partition n n coll))\n  ([n step coll]\n     (lazy-seq\n       (when-let [s (seq coll)]\n         (let [p (doall (take n s))]\n           (when (= n (count p))\n             (cons p (partition n step (nthrest s step))))))))\n  ([n step pad coll]\n     (lazy-seq\n       (when-let [s (seq coll)]\n         (let [p (doall (take n s))]\n           (if (= n (count p))\n             (cons p (partition n step pad (nthrest s step)))\n             (list (take n (concat p pad)))))))))\n\n;; evaluation\n\n(defn eval\n  \"Evaluates the form data structure (not text!) and returns the result.\"\n  {:added \"1.0\"\n   :static true}\n  [form] (. clojure.lang.Compiler (eval form)))\n\n(defmacro doseq\n  \"Repeatedly executes body (presumably for side-effects) with\n  bindings and filtering as provided by \\\"for\\\".  Does not retain\n  the head of the sequence. Returns nil.\"\n  {:added \"1.0\"}\n  [seq-exprs & body]\n  (assert-args\n     (vector? seq-exprs) \"a vector for its binding\"\n     (even? (count seq-exprs)) \"an even number of forms in binding vector\")\n  (let [step (fn step [recform exprs]\n               (if-not exprs\n                 [true `(do ~@body)]\n                 (let [k (first exprs)\n                       v (second exprs)]\n                   (if (keyword? k)\n                     (let [steppair (step recform (nnext exprs))\n                           needrec (steppair 0)\n                           subform (steppair 1)]\n                       (cond\n                         (= k :let) [needrec `(let ~v ~subform)]\n                         (= k :while) [false `(when ~v\n                                                ~subform\n                                                ~@(when needrec [recform]))]\n                         (= k :when) [false `(if ~v\n                                               (do\n                                                 ~subform\n                                                 ~@(when needrec [recform]))\n                                               ~recform)]))\n                     (let [seq- (gensym \"seq_\")\n                           chunk- (with-meta (gensym \"chunk_\")\n                                             {:tag 'clojure.lang.IChunk})\n                           count- (gensym \"count_\")\n                           i- (gensym \"i_\")\n                           recform `(recur (next ~seq-) nil 0 0)\n                           steppair (step recform (nnext exprs))\n                           needrec (steppair 0)\n                           subform (steppair 1)\n                           recform-chunk\n                             `(recur ~seq- ~chunk- ~count- (unchecked-inc ~i-))\n                           steppair-chunk (step recform-chunk (nnext exprs))\n                           subform-chunk (steppair-chunk 1)]\n                       [true\n                        `(loop [~seq- (seq ~v), ~chunk- nil,\n                                ~count- 0, ~i- 0]\n                           (if (< ~i- ~count-)\n                             (let [~k (.nth ~chunk- ~i-)]\n                               ~subform-chunk\n                               ~@(when needrec [recform-chunk]))\n                             (when-let [~seq- (seq ~seq-)]\n                               (if (chunked-seq? ~seq-)\n                                 (let [c# (chunk-first ~seq-)]\n                                   (recur (chunk-rest ~seq-) c#\n                                          (int (count c#)) (int 0)))\n                                 (let [~k (first ~seq-)]\n                                   ~subform\n                                   ~@(when needrec [recform]))))))])))))]\n    (nth (step nil (seq seq-exprs)) 1)))\n\n(defn await\n  \"Blocks the current thread (indefinitely!) until all actions\n  dispatched thus far, from this thread or agent, to the agent(s) have\n  occurred.  Will block on failed agents.  Will never return if\n  a failed agent is restarted with :clear-actions true.\"\n  {:added \"1.0\"\n   :static true}\n  [& agents]\n  (io! \"await in transaction\"\n    (when *agent*\n      (throw (new Exception \"Can't await in agent action\")))\n    (let [latch (new java.util.concurrent.CountDownLatch (count agents))\n          count-down (fn [agent] (. latch (countDown)) agent)]\n      (doseq [agent agents]\n        (send agent count-down))\n      (. latch (await)))))\n\n(defn ^:static await1 [^clojure.lang.Agent a]\n  (when (pos? (.getQueueCount a))\n    (await a))\n    a)\n\n(defn await-for\n  \"Blocks the current thread until all actions dispatched thus\n  far (from this thread or agent) to the agents have occurred, or the\n  timeout (in milliseconds) has elapsed. Returns logical false if\n  returning due to timeout, logical true otherwise.\"\n  {:added \"1.0\"\n   :static true}\n  [timeout-ms & agents]\n    (io! \"await-for in transaction\"\n     (when *agent*\n       (throw (new Exception \"Can't await in agent action\")))\n     (let [latch (new java.util.concurrent.CountDownLatch (count agents))\n           count-down (fn [agent] (. latch (countDown)) agent)]\n       (doseq [agent agents]\n           (send agent count-down))\n       (. latch (await  timeout-ms (. java.util.concurrent.TimeUnit MILLISECONDS))))))\n\n(defmacro dotimes\n  \"bindings => name n\n\n  Repeatedly executes body (presumably for side-effects) with name\n  bound to integers from 0 through n-1.\"\n  {:added \"1.0\"}\n  [bindings & body]\n  (assert-args\n     (vector? bindings) \"a vector for its binding\"\n     (= 2 (count bindings)) \"exactly 2 forms in binding vector\")\n  (let [i (first bindings)\n        n (second bindings)]\n    `(let [n# (long ~n)]\n       (loop [~i 0]\n         (when (< ~i n#)\n           ~@body\n           (recur (unchecked-inc ~i)))))))\n\n#_(defn into\n  \"Returns a new coll consisting of to-coll with all of the items of\n  from-coll conjoined.\"\n  {:added \"1.0\"}\n  [to from]\n    (let [ret to items (seq from)]\n      (if items\n        (recur (conj ret (first items)) (next items))\n        ret)))\n\n;;;;;;;;;;;;;;;;;;;;; editable collections ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defn transient\n  \"Returns a new, transient version of the collection, in constant time.\"\n  {:added \"1.1\"\n   :static true}\n  [^clojure.lang.IEditableCollection coll]\n  (.asTransient coll))\n\n(defn persistent!\n  \"Returns a new, persistent version of the transient collection, in\n  constant time. The transient collection cannot be used after this\n  call, any such use will throw an exception.\"\n  {:added \"1.1\"\n   :static true}\n  [^clojure.lang.ITransientCollection coll]\n  (.persistent coll))\n\n(defn conj!\n  \"Adds x to the transient collection, and return coll. The 'addition'\n  may happen at different 'places' depending on the concrete type.\"\n  {:added \"1.1\"\n   :static true}\n  ([] (transient []))\n  ([coll] coll)\n  ([^clojure.lang.ITransientCollection coll x]\n     (.conj coll x)))\n\n(defn assoc!\n  \"When applied to a transient map, adds mapping of key(s) to\n  val(s). When applied to a transient vector, sets the val at index.\n  Note - index must be <= (count vector). Returns coll.\"\n  {:added \"1.1\"\n   :static true}\n  ([^clojure.lang.ITransientAssociative coll key val] (.assoc coll key val))\n  ([^clojure.lang.ITransientAssociative coll key val & kvs]\n   (let [ret (.assoc coll key val)]\n     (if kvs\n       (recur ret (first kvs) (second kvs) (nnext kvs))\n       ret))))\n\n(defn dissoc!\n  \"Returns a transient map that doesn't contain a mapping for key(s).\"\n  {:added \"1.1\"\n   :static true}\n  ([^clojure.lang.ITransientMap map key] (.without map key))\n  ([^clojure.lang.ITransientMap map key & ks]\n   (let [ret (.without map key)]\n     (if ks\n       (recur ret (first ks) (next ks))\n       ret))))\n\n(defn pop!\n  \"Removes the last item from a transient vector. If\n  the collection is empty, throws an exception. Returns coll\"\n  {:added \"1.1\"\n   :static true}\n  [^clojure.lang.ITransientVector coll]\n  (.pop coll))\n\n(defn disj!\n  \"disj[oin]. Returns a transient set of the same (hashed/sorted) type, that\n  does not contain key(s).\"\n  {:added \"1.1\"\n   :static true}\n  ([set] set)\n  ([^clojure.lang.ITransientSet set key]\n   (. set (disjoin key)))\n  ([^clojure.lang.ITransientSet set key & ks]\n   (let [ret (. set (disjoin key))]\n     (if ks\n       (recur ret (first ks) (next ks))\n       ret))))\n\n;redef into with batch support\n(defn ^:private into1\n  \"Returns a new coll consisting of to-coll with all of the items of\n  from-coll conjoined.\"\n  {:added \"1.0\"\n   :static true}\n  [to from]\n  (if (instance? clojure.lang.IEditableCollection to)\n    (persistent! (reduce1 conj! (transient to) from))\n    (reduce1 conj to from)))\n\n(defmacro import\n  \"import-list => (package-symbol class-name-symbols*)\n\n  For each name in class-name-symbols, adds a mapping from name to the\n  class named by package.name to the current namespace. Use :import in the ns\n  macro in preference to calling this directly.\"\n  {:added \"1.0\"}\n  [& import-symbols-or-lists]\n  (let [specs (map #(if (and (seq? %) (= 'quote (first %))) (second %) %)\n                   import-symbols-or-lists)]\n    `(do ~@(map #(list 'clojure.core/import* %)\n                (reduce1 (fn [v spec]\n                          (if (symbol? spec)\n                            (conj v (name spec))\n                            (let [p (first spec) cs (rest spec)]\n                              (into1 v (map #(str p \".\" %) cs)))))\n                        [] specs)))))\n\n(defn into-array\n  \"Returns an array with components set to the values in aseq. The array's\n  component type is type if provided, or the type of the first value in\n  aseq if present, or Object. All values in aseq must be compatible with\n  the component type. Class objects for the primitive types can be obtained\n  using, e.g., Integer/TYPE.\"\n  {:added \"1.0\"\n   :static true}\n  ([aseq]\n     (clojure.lang.RT/seqToTypedArray (seq aseq)))\n  ([type aseq]\n     (clojure.lang.RT/seqToTypedArray type (seq aseq))))\n\n(defn ^{:private true}\n  array [& items]\n    (into-array items))\n\n(defn class\n  \"Returns the Class of x\"\n  {:added \"1.0\"\n   :static true}\n  ^Class [^Object x] (if (nil? x) x (. x (getClass))))\n\n(defn type\n  \"Returns the :type metadata of x, or its Class if none\"\n  {:added \"1.0\"\n   :static true}\n  [x]\n  (or (get (meta x) :type) (class x)))\n\n(defn num\n  \"Coerce to Number\"\n  {:tag Number\n   :inline (fn  [x] `(. clojure.lang.Numbers (num ~x)))\n   :added \"1.0\"}\n  [x] (. clojure.lang.Numbers (num x)))\n\n(defn long\n  \"Coerce to long\"\n  {:inline (fn  [x] `(. clojure.lang.RT (longCast ~x)))\n   :added \"1.0\"}\n  [^Number x] (clojure.lang.RT/longCast x))\n\n(defn float\n  \"Coerce to float\"\n  {:inline (fn  [x] `(. clojure.lang.RT (~(if *unchecked-math* 'uncheckedFloatCast 'floatCast) ~x)))\n   :added \"1.0\"}\n  [^Number x] (clojure.lang.RT/floatCast x))\n\n(defn double\n  \"Coerce to double\"\n  {:inline (fn  [x] `(. clojure.lang.RT (doubleCast ~x)))\n   :added \"1.0\"}\n  [^Number x] (clojure.lang.RT/doubleCast x))\n\n(defn short\n  \"Coerce to short\"\n  {:inline (fn  [x] `(. clojure.lang.RT (~(if *unchecked-math* 'uncheckedShortCast 'shortCast) ~x)))\n   :added \"1.0\"}\n  [^Number x] (clojure.lang.RT/shortCast x))\n\n(defn byte\n  \"Coerce to byte\"\n  {:inline (fn  [x] `(. clojure.lang.RT (~(if *unchecked-math* 'uncheckedByteCast 'byteCast) ~x)))\n   :added \"1.0\"}\n  [^Number x] (clojure.lang.RT/byteCast x))\n\n(defn char\n  \"Coerce to char\"\n  {:inline (fn  [x] `(. clojure.lang.RT (~(if *unchecked-math* 'uncheckedCharCast 'charCast) ~x)))\n   :added \"1.1\"}\n  [x] (. clojure.lang.RT (charCast x)))\n\n(defn boolean\n  \"Coerce to boolean\"\n  {\n   :inline (fn  [x] `(. clojure.lang.RT (booleanCast ~x)))\n   :added \"1.0\"}\n  [x] (clojure.lang.RT/booleanCast x))\n\n(defn unchecked-byte\n  \"Coerce to byte. Subject to rounding or truncation.\"\n  {:inline (fn  [x] `(. clojure.lang.RT (uncheckedByteCast ~x)))\n   :added \"1.3\"}\n  [^Number x] (clojure.lang.RT/uncheckedByteCast x))\n\n(defn unchecked-short\n  \"Coerce to short. Subject to rounding or truncation.\"\n  {:inline (fn  [x] `(. clojure.lang.RT (uncheckedShortCast ~x)))\n   :added \"1.3\"}\n  [^Number x] (clojure.lang.RT/uncheckedShortCast x))\n\n(defn unchecked-char\n  \"Coerce to char. Subject to rounding or truncation.\"\n  {:inline (fn  [x] `(. clojure.lang.RT (uncheckedCharCast ~x)))\n   :added \"1.3\"}\n  [x] (. clojure.lang.RT (uncheckedCharCast x)))\n\n(defn unchecked-int\n  \"Coerce to int. Subject to rounding or truncation.\"\n  {:inline (fn  [x] `(. clojure.lang.RT (uncheckedIntCast ~x)))\n   :added \"1.3\"}\n  [^Number x] (clojure.lang.RT/uncheckedIntCast x))\n\n(defn unchecked-long\n  \"Coerce to long. Subject to rounding or truncation.\"\n  {:inline (fn  [x] `(. clojure.lang.RT (uncheckedLongCast ~x)))\n   :added \"1.3\"}\n  [^Number x] (clojure.lang.RT/uncheckedLongCast x))\n\n(defn unchecked-float\n  \"Coerce to float. Subject to rounding.\"\n  {:inline (fn  [x] `(. clojure.lang.RT (uncheckedFloatCast ~x)))\n   :added \"1.3\"}\n  [^Number x] (clojure.lang.RT/uncheckedFloatCast x))\n\n(defn unchecked-double\n  \"Coerce to double. Subject to rounding.\"\n  {:inline (fn  [x] `(. clojure.lang.RT (uncheckedDoubleCast ~x)))\n   :added \"1.3\"}\n  [^Number x] (clojure.lang.RT/uncheckedDoubleCast x))\n\n\n(defn number?\n  \"Returns true if x is a Number\"\n  {:added \"1.0\"\n   :static true}\n  [x]\n  (instance? Number x))\n\n(defn mod\n  \"Modulus of num and div. Truncates toward negative infinity.\"\n  {:added \"1.0\"\n   :static true}\n  [num div]\n  (let [m (rem num div)]\n    (if (or (zero? m) (= (pos? num) (pos? div)))\n      m\n      (+ m div))))\n\n(defn ratio?\n  \"Returns true if n is a Ratio\"\n  {:added \"1.0\"\n   :static true}\n  [n] (instance? clojure.lang.Ratio n))\n\n(defn numerator\n  \"Returns the numerator part of a Ratio.\"\n  {:tag BigInteger\n   :added \"1.2\"\n   :static true}\n  [r]\n  (.numerator ^clojure.lang.Ratio r))\n\n(defn denominator\n  \"Returns the denominator part of a Ratio.\"\n  {:tag BigInteger\n   :added \"1.2\"\n   :static true}\n  [r]\n  (.denominator ^clojure.lang.Ratio r))\n\n(defn decimal?\n  \"Returns true if n is a BigDecimal\"\n  {:added \"1.0\"\n   :static true}\n  [n] (instance? BigDecimal n))\n\n(defn float?\n  \"Returns true if n is a floating point number\"\n  {:added \"1.0\"\n   :static true}\n  [n]\n  (or (instance? Double n)\n      (instance? Float n)))\n\n(defn rational?\n  \"Returns true if n is a rational number\"\n  {:added \"1.0\"\n   :static true}\n  [n]\n  (or (integer? n) (ratio? n) (decimal? n)))\n\n(defn bigint\n  \"Coerce to BigInt\"\n  {:tag clojure.lang.BigInt\n   :static true\n   :added \"1.3\"}\n  [x] (cond\n       (instance? clojure.lang.BigInt x) x\n       (instance? BigInteger x) (clojure.lang.BigInt/fromBigInteger x)\n       (decimal? x) (bigint (.toBigInteger ^BigDecimal x))\n       (float? x)  (bigint (. BigDecimal valueOf (double x)))\n       (ratio? x) (bigint (.bigIntegerValue ^clojure.lang.Ratio x))\n       (number? x) (clojure.lang.BigInt/valueOf (long x))\n       :else (bigint (BigInteger. ^String x))))\n\n(defn biginteger\n  \"Coerce to BigInteger\"\n  {:tag BigInteger\n   :added \"1.0\"\n   :static true}\n  [x] (cond\n       (instance? BigInteger x) x\n       (instance? clojure.lang.BigInt x) (.toBigInteger ^clojure.lang.BigInt x)\n       (decimal? x) (.toBigInteger ^BigDecimal x)\n       (float? x) (.toBigInteger (. BigDecimal valueOf (double x)))\n       (ratio? x) (.bigIntegerValue ^clojure.lang.Ratio x)\n       (number? x) (BigInteger/valueOf (long x))\n       :else (BigInteger. ^String x)))\n\n(defn bigdec\n  \"Coerce to BigDecimal\"\n  {:tag BigDecimal\n   :added \"1.0\"\n   :static true}\n  [x] (cond\n       (decimal? x) x\n       (float? x) (. BigDecimal valueOf (double x))\n       (ratio? x) (/ (BigDecimal. (.numerator ^clojure.lang.Ratio x)) (.denominator ^clojure.lang.Ratio x))\n       (instance? clojure.lang.BigInt x) (.toBigDecimal ^clojure.lang.BigInt x)\n       (instance? BigInteger x) (BigDecimal. ^BigInteger x)\n       (number? x) (BigDecimal/valueOf (long x))\n       :else (BigDecimal. ^String x)))\n\n(def ^:dynamic ^{:private true} print-initialized false)\n\n(defmulti print-method (fn [x writer]\n                         (let [t (get (meta x) :type)]\n                           (if (keyword? t) t (class x)))))\n(defmulti print-dup (fn [x writer] (class x)))\n\n(defn pr-on\n  {:private true\n   :static true}\n  [x w]\n  (if *print-dup*\n    (print-dup x w)\n    (print-method x w))\n  nil)\n\n(defn pr\n  \"Prints the object(s) to the output stream that is the current value\n  of *out*.  Prints the object(s), separated by spaces if there is\n  more than one.  By default, pr and prn print in a way that objects\n  can be read by the reader\"\n  {:dynamic true\n   :added \"1.0\"}\n  ([] nil)\n  ([x]\n     (pr-on x *out*))\n  ([x & more]\n   (pr x)\n   (. *out* (append \\space))\n   (if-let [nmore (next more)]\n     (recur (first more) nmore)\n     (apply pr more))))\n\n(def ^:private ^String system-newline\n     (System/getProperty \"line.separator\"))\n\n(defn newline\n  \"Writes a platform-specific newline to *out*\"\n  {:added \"1.0\"\n   :static true}\n  []\n    (. *out* (append system-newline))\n    nil)\n\n(defn flush\n  \"Flushes the output stream that is the current value of\n  *out*\"\n  {:added \"1.0\"\n   :static true}\n  []\n    (. *out* (flush))\n    nil)\n\n(defn prn\n  \"Same as pr followed by (newline). Observes *flush-on-newline*\"\n  {:added \"1.0\"\n   :static true}\n  [& more]\n    (apply pr more)\n    (newline)\n    (when *flush-on-newline*\n      (flush)))\n\n(defn print\n  \"Prints the object(s) to the output stream that is the current value\n  of *out*.  print and println produce output for human consumption.\"\n  {:added \"1.0\"\n   :static true}\n  [& more]\n    (binding [*print-readably* nil]\n      (apply pr more)))\n\n(defn println\n  \"Same as print followed by (newline)\"\n  {:added \"1.0\"\n   :static true}\n  [& more]\n    (binding [*print-readably* nil]\n      (apply prn more)))\n\n(defn read\n  \"Reads the next object from stream, which must be an instance of\n  java.io.PushbackReader or some derivee.  stream defaults to the\n  current value of *in*.\n\n  Opts is a persistent map with valid keys:\n    :read-cond - :allow to process reader conditionals, or\n                 :preserve to keep all branches\n    :features - persistent set of feature keywords for reader conditionals\n    :eof - on eof, return value unless :eofthrow, then throw.\n           if not specified, will throw\n\n  Note that read can execute code (controlled by *read-eval*),\n  and as such should be used only with trusted sources.\n\n  For data structure interop use clojure.edn/read\"\n  {:added \"1.0\"\n   :static true}\n  ([]\n   (read *in*))\n  ([stream]\n   (read stream true nil))\n  ([stream eof-error? eof-value]\n   (read stream eof-error? eof-value false))\n  ([stream eof-error? eof-value recursive?]\n   (. clojure.lang.LispReader (read stream (boolean eof-error?) eof-value recursive?)))\n  ([opts stream]\n   (. clojure.lang.LispReader (read stream opts))))\n\n(defn read-line\n  \"Reads the next line from stream that is the current value of *in* .\"\n  {:added \"1.0\"\n   :static true}\n  []\n  (if (instance? clojure.lang.LineNumberingPushbackReader *in*)\n    (.readLine ^clojure.lang.LineNumberingPushbackReader *in*)\n    (.readLine ^java.io.BufferedReader *in*)))\n\n(defn read-string\n  \"Reads one object from the string s. Optionally include reader\n  options, as specified in read.\n\n  Note that read-string can execute code (controlled by *read-eval*),\n  and as such should be used only with trusted sources.\n\n  For data structure interop use clojure.edn/read-string\"\n  {:added \"1.0\"\n   :static true}\n  ([s] (clojure.lang.RT/readString s))\n  ([opts s] (clojure.lang.RT/readString s opts)))\n\n(defn subvec\n  \"Returns a persistent vector of the items in vector from\n  start (inclusive) to end (exclusive).  If end is not supplied,\n  defaults to (count vector). This operation is O(1) and very fast, as\n  the resulting vector shares structure with the original and no\n  trimming is done.\"\n  {:added \"1.0\"\n   :static true}\n  ([v start]\n   (subvec v start (count v)))\n  ([v start end]\n   (. clojure.lang.RT (subvec v start end))))\n\n(defmacro with-open\n  \"bindings => [name init ...]\n\n  Evaluates body in a try expression with names bound to the values\n  of the inits, and a finally clause that calls (.close name) on each\n  name in reverse order.\"\n  {:added \"1.0\"}\n  [bindings & body]\n  (assert-args\n     (vector? bindings) \"a vector for its binding\"\n     (even? (count bindings)) \"an even number of forms in binding vector\")\n  (cond\n    (= (count bindings) 0) `(do ~@body)\n    (symbol? (bindings 0)) `(let ~(subvec bindings 0 2)\n                              (try\n                                (with-open ~(subvec bindings 2) ~@body)\n                                (finally\n                                  (. ~(bindings 0) close))))\n    :else (throw (IllegalArgumentException.\n                   \"with-open only allows Symbols in bindings\"))))\n\n(defmacro doto\n  \"Evaluates x then calls all of the methods and functions with the\n  value of x supplied at the front of the given arguments.  The forms\n  are evaluated in order.  Returns x.\n\n  (doto (new java.util.HashMap) (.put \\\"a\\\" 1) (.put \\\"b\\\" 2))\"\n  {:added \"1.0\"}\n  [x & forms]\n    (let [gx (gensym)]\n      `(let [~gx ~x]\n         ~@(map (fn [f]\n                  (if (seq? f)\n                    `(~(first f) ~gx ~@(next f))\n                    `(~f ~gx)))\n                forms)\n         ~gx)))\n\n(defmacro memfn\n  \"Expands into code that creates a fn that expects to be passed an\n  object and any args and calls the named instance method on the\n  object passing the args. Use when you want to treat a Java method as\n  a first-class fn. name may be type-hinted with the method receiver's\n  type in order to avoid reflective calls.\"\n  {:added \"1.0\"}\n  [name & args]\n  (let [t (with-meta (gensym \"target\")\n            (meta name))]\n    `(fn [~t ~@args]\n       (. ~t (~name ~@args)))))\n\n(defmacro time\n  \"Evaluates expr and prints the time it took.  Returns the value of\n expr.\"\n  {:added \"1.0\"}\n  [expr]\n  `(let [start# (. System (nanoTime))\n         ret# ~expr]\n     (prn (str \"Elapsed time: \" (/ (double (- (. System (nanoTime)) start#)) 1000000.0) \" msecs\"))\n     ret#))\n\n\n\n(import '(java.lang.reflect Array))\n\n(defn alength\n  \"Returns the length of the Java array. Works on arrays of all\n  types.\"\n  {:inline (fn [a] `(. clojure.lang.RT (alength ~a)))\n   :added \"1.0\"}\n  [array] (. clojure.lang.RT (alength array)))\n\n(defn aclone\n  \"Returns a clone of the Java array. Works on arrays of known\n  types.\"\n  {:inline (fn [a] `(. clojure.lang.RT (aclone ~a)))\n   :added \"1.0\"}\n  [array] (. clojure.lang.RT (aclone array)))\n\n(defn aget\n  \"Returns the value at the index/indices. Works on Java arrays of all\n  types.\"\n  {:inline (fn [a i] `(. clojure.lang.RT (aget ~a (int ~i))))\n   :inline-arities #{2}\n   :added \"1.0\"}\n  ([array idx]\n   (clojure.lang.Reflector/prepRet (.getComponentType (class array)) (. Array (get array idx))))\n  ([array idx & idxs]\n   (apply aget (aget array idx) idxs)))\n\n(defn aset\n  \"Sets the value at the index/indices. Works on Java arrays of\n  reference types. Returns val.\"\n  {:inline (fn [a i v] `(. clojure.lang.RT (aset ~a (int ~i) ~v)))\n   :inline-arities #{3}\n   :added \"1.0\"}\n  ([array idx val]\n   (. Array (set array idx val))\n   val)\n  ([array idx idx2 & idxv]\n   (apply aset (aget array idx) idx2 idxv)))\n\n(defmacro\n  ^{:private true}\n  def-aset [name method coerce]\n    `(defn ~name\n       {:arglists '([~'array ~'idx ~'val] [~'array ~'idx ~'idx2 & ~'idxv])}\n       ([array# idx# val#]\n        (. Array (~method array# idx# (~coerce val#)))\n        val#)\n       ([array# idx# idx2# & idxv#]\n        (apply ~name (aget array# idx#) idx2# idxv#))))\n\n(def-aset\n  ^{:doc \"Sets the value at the index/indices. Works on arrays of int. Returns val.\"\n    :added \"1.0\"}\n  aset-int setInt int)\n\n(def-aset\n  ^{:doc \"Sets the value at the index/indices. Works on arrays of long. Returns val.\"\n    :added \"1.0\"}\n  aset-long setLong long)\n\n(def-aset\n  ^{:doc \"Sets the value at the index/indices. Works on arrays of boolean. Returns val.\"\n    :added \"1.0\"}\n  aset-boolean setBoolean boolean)\n\n(def-aset\n  ^{:doc \"Sets the value at the index/indices. Works on arrays of float. Returns val.\"\n    :added \"1.0\"}\n  aset-float setFloat float)\n\n(def-aset\n  ^{:doc \"Sets the value at the index/indices. Works on arrays of double. Returns val.\"\n    :added \"1.0\"}\n  aset-double setDouble double)\n\n(def-aset\n  ^{:doc \"Sets the value at the index/indices. Works on arrays of short. Returns val.\"\n    :added \"1.0\"}\n  aset-short setShort short)\n\n(def-aset\n  ^{:doc \"Sets the value at the index/indices. Works on arrays of byte. Returns val.\"\n    :added \"1.0\"}\n  aset-byte setByte byte)\n\n(def-aset\n  ^{:doc \"Sets the value at the index/indices. Works on arrays of char. Returns val.\"\n    :added \"1.0\"}\n  aset-char setChar char)\n\n(defn make-array\n  \"Creates and returns an array of instances of the specified class of\n  the specified dimension(s).  Note that a class object is required.\n  Class objects can be obtained by using their imported or\n  fully-qualified name.  Class objects for the primitive types can be\n  obtained using, e.g., Integer/TYPE.\"\n  {:added \"1.0\"\n   :static true}\n  ([^Class type len]\n   (. Array (newInstance type (int len))))\n  ([^Class type dim & more-dims]\n   (let [dims (cons dim more-dims)\n         ^\"[I\" dimarray (make-array (. Integer TYPE)  (count dims))]\n     (dotimes [i (alength dimarray)]\n       (aset-int dimarray i (nth dims i)))\n     (. Array (newInstance type dimarray)))))\n\n(defn to-array-2d\n  \"Returns a (potentially-ragged) 2-dimensional array of Objects\n  containing the contents of coll, which can be any Collection of any\n  Collection.\"\n  {:tag \"[[Ljava.lang.Object;\"\n   :added \"1.0\"\n   :static true}\n  [^java.util.Collection coll]\n    (let [ret (make-array (. Class (forName \"[Ljava.lang.Object;\")) (. coll (size)))]\n      (loop [i 0 xs (seq coll)]\n        (when xs\n          (aset ret i (to-array (first xs)))\n          (recur (inc i) (next xs))))\n      ret))\n\n(defn macroexpand-1\n  \"If form represents a macro form, returns its expansion,\n  else returns form.\"\n  {:added \"1.0\"\n   :static true}\n  [form]\n    (. clojure.lang.Compiler (macroexpand1 form)))\n\n(defn macroexpand\n  \"Repeatedly calls macroexpand-1 on form until it no longer\n  represents a macro form, then returns it.  Note neither\n  macroexpand-1 nor macroexpand expand macros in subforms.\"\n  {:added \"1.0\"\n   :static true}\n  [form]\n    (let [ex (macroexpand-1 form)]\n      (if (identical? ex form)\n        form\n        (macroexpand ex))))\n\n(defn create-struct\n  \"Returns a structure basis object.\"\n  {:added \"1.0\"\n   :static true}\n  [& keys]\n    (. clojure.lang.PersistentStructMap (createSlotMap keys)))\n\n(defmacro defstruct\n  \"Same as (def name (create-struct keys...))\"\n  {:added \"1.0\"\n   :static true}\n  [name & keys]\n  `(def ~name (create-struct ~@keys)))\n\n(defn struct-map\n  \"Returns a new structmap instance with the keys of the\n  structure-basis. keyvals may contain all, some or none of the basis\n  keys - where values are not supplied they will default to nil.\n  keyvals can also contain keys not in the basis.\"\n  {:added \"1.0\"\n   :static true}\n  [s & inits]\n    (. clojure.lang.PersistentStructMap (create s inits)))\n\n(defn struct\n  \"Returns a new structmap instance with the keys of the\n  structure-basis. vals must be supplied for basis keys in order -\n  where values are not supplied they will default to nil.\"\n  {:added \"1.0\"\n   :static true}\n  [s & vals]\n    (. clojure.lang.PersistentStructMap (construct s vals)))\n\n(defn accessor\n  \"Returns a fn that, given an instance of a structmap with the basis,\n  returns the value at the key.  The key must be in the basis. The\n  returned function should be (slightly) more efficient than using\n  get, but such use of accessors should be limited to known\n  performance-critical areas.\"\n  {:added \"1.0\"\n   :static true}\n  [s key]\n    (. clojure.lang.PersistentStructMap (getAccessor s key)))\n\n(defn load-reader\n  \"Sequentially read and evaluate the set of forms contained in the\n  stream/file\"\n  {:added \"1.0\"\n   :static true}\n  [rdr] (. clojure.lang.Compiler (load rdr)))\n\n(defn load-string\n  \"Sequentially read and evaluate the set of forms contained in the\n  string\"\n  {:added \"1.0\"\n   :static true}\n  [s]\n  (let [rdr (-> (java.io.StringReader. s)\n                (clojure.lang.LineNumberingPushbackReader.))]\n    (load-reader rdr)))\n\n(defn set?\n  \"Returns true if x implements IPersistentSet\"\n  {:added \"1.0\"\n   :static true}\n  [x] (instance? clojure.lang.IPersistentSet x))\n\n(defn set\n  \"Returns a set of the distinct elements of coll.\"\n  {:added \"1.0\"\n   :static true}\n  [coll]\n  (if (set? coll)\n    (with-meta coll nil)\n    (if (instance? clojure.lang.IReduceInit coll)\n      (persistent! (.reduce ^clojure.lang.IReduceInit coll conj! (transient #{})))\n      (persistent! (reduce1 conj! (transient #{}) coll)))))\n\n(defn ^{:private true\n   :static true}\n  filter-key [keyfn pred amap]\n    (loop [ret {} es (seq amap)]\n      (if es\n        (if (pred (keyfn (first es)))\n          (recur (assoc ret (key (first es)) (val (first es))) (next es))\n          (recur ret (next es)))\n        ret)))\n\n(defn find-ns\n  \"Returns the namespace named by the symbol or nil if it doesn't exist.\"\n  {:added \"1.0\"\n   :static true}\n  [sym] (clojure.lang.Namespace/find sym))\n\n(defn create-ns\n  \"Create a new namespace named by the symbol if one doesn't already\n  exist, returns it or the already-existing namespace of the same\n  name.\"\n  {:added \"1.0\"\n   :static true}\n  [sym] (clojure.lang.Namespace/findOrCreate sym))\n\n(defn remove-ns\n  \"Removes the namespace named by the symbol. Use with caution.\n  Cannot be used to remove the clojure namespace.\"\n  {:added \"1.0\"\n   :static true}\n  [sym] (clojure.lang.Namespace/remove sym))\n\n(defn all-ns\n  \"Returns a sequence of all namespaces.\"\n  {:added \"1.0\"\n   :static true}\n  [] (clojure.lang.Namespace/all))\n\n(defn the-ns\n  \"If passed a namespace, returns it. Else, when passed a symbol,\n  returns the namespace named by it, throwing an exception if not\n  found.\"\n  {:added \"1.0\"\n   :static true}\n  ^clojure.lang.Namespace [x]\n  (if (instance? clojure.lang.Namespace x)\n    x\n    (or (find-ns x) (throw (Exception. (str \"No namespace: \" x \" found\"))))))\n\n(defn ns-name\n  \"Returns the name of the namespace, a symbol.\"\n  {:added \"1.0\"\n   :static true}\n  [ns]\n  (.getName (the-ns ns)))\n\n(defn ns-map\n  \"Returns a map of all the mappings for the namespace.\"\n  {:added \"1.0\"\n   :static true}\n  [ns]\n  (.getMappings (the-ns ns)))\n\n(defn ns-unmap\n  \"Removes the mappings for the symbol from the namespace.\"\n  {:added \"1.0\"\n   :static true}\n  [ns sym]\n  (.unmap (the-ns ns) sym))\n\n;(defn export [syms]\n;  (doseq [sym syms]\n;   (.. *ns* (intern sym) (setExported true))))\n\n(defn ns-publics\n  \"Returns a map of the public intern mappings for the namespace.\"\n  {:added \"1.0\"\n   :static true}\n  [ns]\n  (let [ns (the-ns ns)]\n    (filter-key val (fn [^clojure.lang.Var v] (and (instance? clojure.lang.Var v)\n                                 (= ns (.ns v))\n                                 (.isPublic v)))\n                (ns-map ns))))\n\n(defn ns-imports\n  \"Returns a map of the import mappings for the namespace.\"\n  {:added \"1.0\"\n   :static true}\n  [ns]\n  (filter-key val (partial instance? Class) (ns-map ns)))\n\n(defn ns-interns\n  \"Returns a map of the intern mappings for the namespace.\"\n  {:added \"1.0\"\n   :static true}\n  [ns]\n  (let [ns (the-ns ns)]\n    (filter-key val (fn [^clojure.lang.Var v] (and (instance? clojure.lang.Var v)\n                                 (= ns (.ns v))))\n                (ns-map ns))))\n\n(defn refer\n  \"refers to all public vars of ns, subject to filters.\n  filters can include at most one each of:\n\n  :exclude list-of-symbols\n  :only list-of-symbols\n  :rename map-of-fromsymbol-tosymbol\n\n  For each public interned var in the namespace named by the symbol,\n  adds a mapping from the name of the var to the var to the current\n  namespace.  Throws an exception if name is already mapped to\n  something else in the current namespace. Filters can be used to\n  select a subset, via inclusion or exclusion, or to provide a mapping\n  to a symbol different from the var's name, in order to prevent\n  clashes. Use :use in the ns macro in preference to calling this directly.\"\n  {:added \"1.0\"}\n  [ns-sym & filters]\n  (let [ns (or (find-ns ns-sym) (throw (new Exception (str \"No namespace: \" ns-sym))))]\n    (.referNs *ns* ns (apply hash-map filters))))\n\n(defn ns-refers\n  \"Returns a map of the refer mappings for the namespace.\"\n  {:added \"1.0\"\n   :static true}\n  [ns]\n  (let [ns (the-ns ns)]\n    (filter-key val (fn [^clojure.lang.Var v] (and (instance? clojure.lang.Var v)\n                                 (not= ns (.ns v))))\n                (ns-map ns))))\n\n(defn alias\n  \"Add an alias in the current namespace to another\n  namespace. Arguments are two symbols: the alias to be used, and\n  the symbolic name of the target namespace. Use :as in the ns macro in preference\n  to calling this directly.\"\n  {:added \"1.0\"\n   :static true}\n  [alias namespace-sym]\n  (.addAlias *ns* alias (the-ns namespace-sym)))\n\n(defn ns-aliases\n  \"Returns a map of the aliases for the namespace.\"\n  {:added \"1.0\"\n   :static true}\n  [ns]\n  (.getAliases (the-ns ns)))\n\n(defn ns-unalias\n  \"Removes the alias for the symbol from the namespace.\"\n  {:added \"1.0\"\n   :static true}\n  [ns sym]\n  (.removeAlias (the-ns ns) sym))\n\n(defn take-nth\n  \"Returns a lazy seq of every nth item in coll.  Returns a stateful\n  transducer when no collection is provided.\"\n  {:added \"1.0\"\n   :static true}\n  ([n]\n     (fn [rf]\n       (let [iv (volatile! -1)]\n         (fn\n           ([] (rf))\n           ([result] (rf result))\n           ([result input]\n              (let [i (vswap! iv inc)]\n                (if (zero? (rem i n))\n                  (rf result input)\n                  result)))))))\n  ([n coll]\n     (lazy-seq\n      (when-let [s (seq coll)]\n        (cons (first s) (take-nth n (drop n s)))))))\n\n(defn interleave\n  \"Returns a lazy seq of the first item in each coll, then the second etc.\"\n  {:added \"1.0\"\n   :static true}\n  ([] ())\n  ([c1] (lazy-seq c1))\n  ([c1 c2]\n     (lazy-seq\n      (let [s1 (seq c1) s2 (seq c2)]\n        (when (and s1 s2)\n          (cons (first s1) (cons (first s2)\n                                 (interleave (rest s1) (rest s2))))))))\n  ([c1 c2 & colls]\n     (lazy-seq\n      (let [ss (map seq (conj colls c2 c1))]\n        (when (every? identity ss)\n          (concat (map first ss) (apply interleave (map rest ss))))))))\n\n(defn var-get\n  \"Gets the value in the var object\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.Var x] (. x (get)))\n\n(defn var-set\n  \"Sets the value in the var object to val. The var must be\n thread-locally bound.\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.Var x val] (. x (set val)))\n\n(defmacro with-local-vars\n  \"varbinding=> symbol init-expr\n\n  Executes the exprs in a context in which the symbols are bound to\n  vars with per-thread bindings to the init-exprs.  The symbols refer\n  to the var objects themselves, and must be accessed with var-get and\n  var-set\"\n  {:added \"1.0\"}\n  [name-vals-vec & body]\n  (assert-args\n     (vector? name-vals-vec) \"a vector for its binding\"\n     (even? (count name-vals-vec)) \"an even number of forms in binding vector\")\n  `(let [~@(interleave (take-nth 2 name-vals-vec)\n                       (repeat '(.. clojure.lang.Var create setDynamic)))]\n     (. clojure.lang.Var (pushThreadBindings (hash-map ~@name-vals-vec)))\n     (try\n      ~@body\n      (finally (. clojure.lang.Var (popThreadBindings))))))\n\n(defn ns-resolve\n  \"Returns the var or Class to which a symbol will be resolved in the\n  namespace (unless found in the environment), else nil.  Note that\n  if the symbol is fully qualified, the var/Class to which it resolves\n  need not be present in the namespace.\"\n  {:added \"1.0\"\n   :static true}\n  ([ns sym]\n    (ns-resolve ns nil sym))\n  ([ns env sym]\n    (when-not (contains? env sym)\n      (clojure.lang.Compiler/maybeResolveIn (the-ns ns) sym))))\n\n(defn resolve\n  \"same as (ns-resolve *ns* symbol) or (ns-resolve *ns* &env symbol)\"\n  {:added \"1.0\"\n   :static true}\n  ([sym] (ns-resolve *ns* sym))\n  ([env sym] (ns-resolve *ns* env sym)))\n\n(defn array-map\n  \"Constructs an array-map. If any keys are equal, they are handled as\n  if by repeated uses of assoc.\"\n  {:added \"1.0\"\n   :static true}\n  ([] (. clojure.lang.PersistentArrayMap EMPTY))\n  ([& keyvals]\n     (clojure.lang.PersistentArrayMap/createAsIfByAssoc (to-array keyvals))))\n\n;redefine let and loop  with destructuring\n(defn destructure [bindings]\n  (let [bents (partition 2 bindings)\n        pb (fn pb [bvec b v]\n               (let [pvec\n                     (fn [bvec b val]\n                       (let [gvec (gensym \"vec__\")]\n                         (loop [ret (-> bvec (conj gvec) (conj val))\n                                n 0\n                                bs b\n                                seen-rest? false]\n                           (if (seq bs)\n                             (let [firstb (first bs)]\n                               (cond\n                                (= firstb '&) (recur (pb ret (second bs) (list `nthnext gvec n))\n                                                     n\n                                                     (nnext bs)\n                                                     true)\n                                (= firstb :as) (pb ret (second bs) gvec)\n                                :else (if seen-rest?\n                                        (throw (new Exception \"Unsupported binding form, only :as can follow & parameter\"))\n                                        (recur (pb ret firstb  (list `nth gvec n nil))\n                                               (inc n)\n                                               (next bs)\n                                               seen-rest?))))\n                             ret))))\n                     pmap\n                     (fn [bvec b v]\n                       (let [gmap (gensym \"map__\")\n                             gmapseq (with-meta gmap {:tag 'clojure.lang.ISeq})\n                             defaults (:or b)]\n                         (loop [ret (-> bvec (conj gmap) (conj v)\n                                        (conj gmap) (conj `(if (seq? ~gmap) (clojure.lang.PersistentHashMap/create (seq ~gmapseq)) ~gmap))\n                                        ((fn [ret]\n                                           (if (:as b)\n                                             (conj ret (:as b) gmap)\n                                             ret))))\n                                bes (reduce1\n                                     (fn [bes entry]\n                                       (reduce1 #(assoc %1 %2 ((val entry) %2))\n                                               (dissoc bes (key entry))\n                                               ((key entry) bes)))\n                                     (dissoc b :as :or)\n                                     {:keys #(if (keyword? %) % (keyword (str %))),\n                                      :strs str, :syms #(list `quote %)})]\n                           (if (seq bes)\n                             (let [bb (key (first bes))\n                                   bk (val (first bes))\n                                   has-default (contains? defaults bb)]\n                               (recur (pb ret bb (if has-default\n                                                   (list `get gmap bk (defaults bb))\n                                                   (list `get gmap bk)))\n                                      (next bes)))\n                             ret))))]\n                 (cond\n                  (symbol? b) (-> bvec (conj (if (namespace b) (symbol (name b)) b)) (conj v))\n                  (keyword? b) (-> bvec (conj (symbol (name b))) (conj v))\n                  (vector? b) (pvec bvec b v)\n                  (map? b) (pmap bvec b v)\n                  :else (throw (new Exception (str \"Unsupported binding form: \" b))))))\n        process-entry (fn [bvec b] (pb bvec (first b) (second b)))]\n    (if (every? symbol? (map first bents))\n      bindings\n      (if-let [kwbs (seq (filter #(keyword? (first %)) bents))]\n        (throw (new Exception (str \"Unsupported binding key: \" (ffirst kwbs))))\n        (reduce1 process-entry [] bents)))))\n\n(defmacro let\n  \"binding => binding-form init-expr\n\n  Evaluates the exprs in a lexical context in which the symbols in\n  the binding-forms are bound to their respective init-exprs or parts\n  therein.\"\n  {:added \"1.0\", :special-form true, :forms '[(let [bindings*] exprs*)]}\n  [bindings & body]\n  (assert-args\n     (vector? bindings) \"a vector for its binding\"\n     (even? (count bindings)) \"an even number of forms in binding vector\")\n  `(let* ~(destructure bindings) ~@body))\n\n(defn ^{:private true}\n  maybe-destructured\n  [params body]\n  (if (every? symbol? params)\n    (cons params body)\n    (loop [params params\n           new-params (with-meta [] (meta params))\n           lets []]\n      (if params\n        (if (symbol? (first params))\n          (recur (next params) (conj new-params (first params)) lets)\n          (let [gparam (gensym \"p__\")]\n            (recur (next params) (conj new-params gparam)\n                   (-> lets (conj (first params)) (conj gparam)))))\n        `(~new-params\n          (let ~lets\n            ~@body))))))\n\n;redefine fn with destructuring and pre/post conditions\n(defmacro fn\n  \"params => positional-params* , or positional-params* & next-param\n  positional-param => binding-form\n  next-param => binding-form\n  name => symbol\n\n  Defines a function\"\n  {:added \"1.0\", :special-form true,\n   :forms '[(fn name? [params* ] exprs*) (fn name? ([params* ] exprs*)+)]}\n  [& sigs]\n    (let [name (if (symbol? (first sigs)) (first sigs) nil)\n          sigs (if name (next sigs) sigs)\n          sigs (if (vector? (first sigs))\n                 (list sigs)\n                 (if (seq? (first sigs))\n                   sigs\n                   ;; Assume single arity syntax\n                   (throw (IllegalArgumentException.\n                            ^String\n                            (if (seq sigs)\n                              (str \"Parameter declaration \"\n                                   (first sigs)\n                                   \" should be a vector\")\n                              (str \"Parameter declaration missing\"))))))\n          psig (fn* [sig]\n                 ;; Ensure correct type before destructuring sig\n                 (when (not (seq? sig))\n                   (throw (IllegalArgumentException.\n                            (str \"Invalid signature \" sig\n                                 \" should be a list\"))))\n                 (let [[params & body] sig\n                       _ (when (not (vector? params))\n                           (throw (IllegalArgumentException.\n                                   ^String\n                                    (if (seq? (first sigs))\n                                      (str \"Parameter declaration \" params\n                                           \" should be a vector\")\n                                      (str \"Invalid signature \" sig\n                                           \" should be a list\")))))\n                       conds (when (and (next body) (map? (first body)))\n                                           (first body))\n                       body (if conds (next body) body)\n                       conds (or conds (meta params))\n                       pre (:pre conds)\n                       post (:post conds)\n                       body (if post\n                              `((let [~'% ~(if (< 1 (count body))\n                                            `(do ~@body)\n                                            (first body))]\n                                 ~@(map (fn* [c] `(assert ~c)) post)\n                                 ~'%))\n                              body)\n                       body (if pre\n                              (concat (map (fn* [c] `(assert ~c)) pre)\n                                      body)\n                              body)]\n                   (maybe-destructured params body)))\n          new-sigs (map psig sigs)]\n      (with-meta\n        (if name\n          (list* 'fn* name new-sigs)\n          (cons 'fn* new-sigs))\n        (meta &form))))\n\n(defmacro loop\n  \"Evaluates the exprs in a lexical context in which the symbols in\n  the binding-forms are bound to their respective init-exprs or parts\n  therein. Acts as a recur target.\"\n  {:added \"1.0\", :special-form true, :forms '[(loop [bindings*] exprs*)]}\n  [bindings & body]\n    (assert-args\n      (vector? bindings) \"a vector for its binding\"\n      (even? (count bindings)) \"an even number of forms in binding vector\")\n    (let [db (destructure bindings)]\n      (if (= db bindings)\n        `(loop* ~bindings ~@body)\n        (let [vs (take-nth 2 (drop 1 bindings))\n              bs (take-nth 2 bindings)\n              gs (map (fn [b] (if (symbol? b) b (gensym))) bs)\n              bfs (reduce1 (fn [ret [b v g]]\n                            (if (symbol? b)\n                              (conj ret g v)\n                              (conj ret g v b g)))\n                          [] (map vector bs vs gs))]\n          `(let ~bfs\n             (loop* ~(vec (interleave gs gs))\n               (let ~(vec (interleave bs gs))\n                 ~@body)))))))\n\n(defmacro when-first\n  \"bindings => x xs\n\n  Roughly the same as (when (seq xs) (let [x (first xs)] body)) but xs is evaluated only once\"\n  {:added \"1.0\"}\n  [bindings & body]\n  (assert-args\n     (vector? bindings) \"a vector for its binding\"\n     (= 2 (count bindings)) \"exactly 2 forms in binding vector\")\n  (let [[x xs] bindings]\n    `(when-let [xs# (seq ~xs)]\n       (let [~x (first xs#)]\n           ~@body))))\n\n(defmacro lazy-cat\n  \"Expands to code which yields a lazy sequence of the concatenation\n  of the supplied colls.  Each coll expr is not evaluated until it is\n  needed.\n\n  (lazy-cat xs ys zs) === (concat (lazy-seq xs) (lazy-seq ys) (lazy-seq zs))\"\n  {:added \"1.0\"}\n  [& colls]\n  `(concat ~@(map #(list `lazy-seq %) colls)))\n\n(defmacro for\n  \"List comprehension. Takes a vector of one or more\n   binding-form/collection-expr pairs, each followed by zero or more\n   modifiers, and yields a lazy sequence of evaluations of expr.\n   Collections are iterated in a nested fashion, rightmost fastest,\n   and nested coll-exprs can refer to bindings created in prior\n   binding-forms.  Supported modifiers are: :let [binding-form expr ...],\n   :while test, :when test.\n\n  (take 100 (for [x (range 100000000) y (range 1000000) :while (< y x)] [x y]))\"\n  {:added \"1.0\"}\n  [seq-exprs body-expr]\n  (assert-args\n     (vector? seq-exprs) \"a vector for its binding\"\n     (even? (count seq-exprs)) \"an even number of forms in binding vector\")\n  (let [to-groups (fn [seq-exprs]\n                    (reduce1 (fn [groups [k v]]\n                              (if (keyword? k)\n                                (conj (pop groups) (conj (peek groups) [k v]))\n                                (conj groups [k v])))\n                            [] (partition 2 seq-exprs)))\n        err (fn [& msg] (throw (IllegalArgumentException. ^String (apply str msg))))\n        emit-bind (fn emit-bind [[[bind expr & mod-pairs]\n                                  & [[_ next-expr] :as next-groups]]]\n                    (let [giter (gensym \"iter__\")\n                          gxs (gensym \"s__\")\n                          do-mod (fn do-mod [[[k v :as pair] & etc]]\n                                   (cond\n                                     (= k :let) `(let ~v ~(do-mod etc))\n                                     (= k :while) `(when ~v ~(do-mod etc))\n                                     (= k :when) `(if ~v\n                                                    ~(do-mod etc)\n                                                    (recur (rest ~gxs)))\n                                     (keyword? k) (err \"Invalid 'for' keyword \" k)\n                                     next-groups\n                                      `(let [iterys# ~(emit-bind next-groups)\n                                             fs# (seq (iterys# ~next-expr))]\n                                         (if fs#\n                                           (concat fs# (~giter (rest ~gxs)))\n                                           (recur (rest ~gxs))))\n                                     :else `(cons ~body-expr\n                                                  (~giter (rest ~gxs)))))]\n                      (if next-groups\n                        #_\"not the inner-most loop\"\n                        `(fn ~giter [~gxs]\n                           (lazy-seq\n                             (loop [~gxs ~gxs]\n                               (when-first [~bind ~gxs]\n                                 ~(do-mod mod-pairs)))))\n                        #_\"inner-most loop\"\n                        (let [gi (gensym \"i__\")\n                              gb (gensym \"b__\")\n                              do-cmod (fn do-cmod [[[k v :as pair] & etc]]\n                                        (cond\n                                          (= k :let) `(let ~v ~(do-cmod etc))\n                                          (= k :while) `(when ~v ~(do-cmod etc))\n                                          (= k :when) `(if ~v\n                                                         ~(do-cmod etc)\n                                                         (recur\n                                                           (unchecked-inc ~gi)))\n                                          (keyword? k)\n                                            (err \"Invalid 'for' keyword \" k)\n                                          :else\n                                            `(do (chunk-append ~gb ~body-expr)\n                                                 (recur (unchecked-inc ~gi)))))]\n                          `(fn ~giter [~gxs]\n                             (lazy-seq\n                               (loop [~gxs ~gxs]\n                                 (when-let [~gxs (seq ~gxs)]\n                                   (if (chunked-seq? ~gxs)\n                                     (let [c# (chunk-first ~gxs)\n                                           size# (int (count c#))\n                                           ~gb (chunk-buffer size#)]\n                                       (if (loop [~gi (int 0)]\n                                             (if (< ~gi size#)\n                                               (let [~bind (.nth c# ~gi)]\n                                                 ~(do-cmod mod-pairs))\n                                               true))\n                                         (chunk-cons\n                                           (chunk ~gb)\n                                           (~giter (chunk-rest ~gxs)))\n                                         (chunk-cons (chunk ~gb) nil)))\n                                     (let [~bind (first ~gxs)]\n                                       ~(do-mod mod-pairs)))))))))))]\n    `(let [iter# ~(emit-bind (to-groups seq-exprs))]\n        (iter# ~(second seq-exprs)))))\n\n(defmacro comment\n  \"Ignores body, yields nil\"\n  {:added \"1.0\"}\n  [& body])\n\n(defmacro with-out-str\n  \"Evaluates exprs in a context in which *out* is bound to a fresh\n  StringWriter.  Returns the string created by any nested printing\n  calls.\"\n  {:added \"1.0\"}\n  [& body]\n  `(let [s# (new java.io.StringWriter)]\n     (binding [*out* s#]\n       ~@body\n       (str s#))))\n\n(defmacro with-in-str\n  \"Evaluates body in a context in which *in* is bound to a fresh\n  StringReader initialized with the string s.\"\n  {:added \"1.0\"}\n  [s & body]\n  `(with-open [s# (-> (java.io.StringReader. ~s) clojure.lang.LineNumberingPushbackReader.)]\n     (binding [*in* s#]\n       ~@body)))\n\n(defn pr-str\n  \"pr to a string, returning it\"\n  {:tag String\n   :added \"1.0\"\n   :static true}\n  [& xs]\n    (with-out-str\n     (apply pr xs)))\n\n(defn prn-str\n  \"prn to a string, returning it\"\n  {:tag String\n   :added \"1.0\"\n   :static true}\n  [& xs]\n  (with-out-str\n   (apply prn xs)))\n\n(defn print-str\n  \"print to a string, returning it\"\n  {:tag String\n   :added \"1.0\"\n   :static true}\n  [& xs]\n    (with-out-str\n     (apply print xs)))\n\n(defn println-str\n  \"println to a string, returning it\"\n  {:tag String\n   :added \"1.0\"\n   :static true}\n  [& xs]\n    (with-out-str\n     (apply println xs)))\n\n(import clojure.lang.ExceptionInfo clojure.lang.IExceptionInfo)\n(defn ex-info\n  \"Create an instance of ExceptionInfo, a RuntimeException subclass\n   that carries a map of additional data.\"\n  {:added \"1.4\"}\n  ([msg map]\n     (ExceptionInfo. msg map))\n  ([msg map cause]\n     (ExceptionInfo. msg map cause)))\n\n(defn ex-data\n  \"Returns exception data (a map) if ex is an IExceptionInfo.\n   Otherwise returns nil.\"\n  {:added \"1.4\"}\n  [ex]\n  (when (instance? IExceptionInfo ex)\n    (.getData ^IExceptionInfo ex)))\n\n(defmacro assert\n  \"Evaluates expr and throws an exception if it does not evaluate to\n  logical true.\"\n  {:added \"1.0\"}\n  ([x]\n     (when *assert*\n       `(when-not ~x\n          (throw (new AssertionError (str \"Assert failed: \" (pr-str '~x)))))))\n  ([x message]\n     (when *assert*\n       `(when-not ~x\n          (throw (new AssertionError (str \"Assert failed: \" ~message \"\\n\" (pr-str '~x))))))))\n\n(defn test\n  \"test [v] finds fn at key :test in var metadata and calls it,\n  presuming failure will throw exception\"\n  {:added \"1.0\"}\n  [v]\n    (let [f (:test (meta v))]\n      (if f\n        (do (f) :ok)\n        :no-test)))\n\n(defn re-pattern\n  \"Returns an instance of java.util.regex.Pattern, for use, e.g. in\n  re-matcher.\"\n  {:tag java.util.regex.Pattern\n   :added \"1.0\"\n   :static true}\n  [s] (if (instance? java.util.regex.Pattern s)\n        s\n        (. java.util.regex.Pattern (compile s))))\n\n(defn re-matcher\n  \"Returns an instance of java.util.regex.Matcher, for use, e.g. in\n  re-find.\"\n  {:tag java.util.regex.Matcher\n   :added \"1.0\"\n   :static true}\n  [^java.util.regex.Pattern re s]\n    (. re (matcher s)))\n\n(defn re-groups\n  \"Returns the groups from the most recent match/find. If there are no\n  nested groups, returns a string of the entire match. If there are\n  nested groups, returns a vector of the groups, the first element\n  being the entire match.\"\n  {:added \"1.0\"\n   :static true}\n  [^java.util.regex.Matcher m]\n    (let [gc  (. m (groupCount))]\n      (if (zero? gc)\n        (. m (group))\n        (loop [ret [] c 0]\n          (if (<= c gc)\n            (recur (conj ret (. m (group c))) (inc c))\n            ret)))))\n\n(defn re-seq\n  \"Returns a lazy sequence of successive matches of pattern in string,\n  using java.util.regex.Matcher.find(), each such match processed with\n  re-groups.\"\n  {:added \"1.0\"\n   :static true}\n  [^java.util.regex.Pattern re s]\n  (let [m (re-matcher re s)]\n    ((fn step []\n       (when (. m (find))\n         (cons (re-groups m) (lazy-seq (step))))))))\n\n(defn re-matches\n  \"Returns the match, if any, of string to pattern, using\n  java.util.regex.Matcher.matches().  Uses re-groups to return the\n  groups.\"\n  {:added \"1.0\"\n   :static true}\n  [^java.util.regex.Pattern re s]\n    (let [m (re-matcher re s)]\n      (when (. m (matches))\n        (re-groups m))))\n\n\n(defn re-find\n  \"Returns the next regex match, if any, of string to pattern, using\n  java.util.regex.Matcher.find().  Uses re-groups to return the\n  groups.\"\n  {:added \"1.0\"\n   :static true}\n  ([^java.util.regex.Matcher m]\n   (when (. m (find))\n     (re-groups m)))\n  ([^java.util.regex.Pattern re s]\n   (let [m (re-matcher re s)]\n     (re-find m))))\n\n(defn rand\n  \"Returns a random floating point number between 0 (inclusive) and\n  n (default 1) (exclusive).\"\n  {:added \"1.0\"\n   :static true}\n  ([] (. Math (random)))\n  ([n] (* n (rand))))\n\n(defn rand-int\n  \"Returns a random integer between 0 (inclusive) and n (exclusive).\"\n  {:added \"1.0\"\n   :static true}\n  [n] (int (rand n)))\n\n(defmacro defn-\n  \"same as defn, yielding non-public def\"\n  {:added \"1.0\"}\n  [name & decls]\n    (list* `defn (with-meta name (assoc (meta name) :private true)) decls))\n\n(defn tree-seq\n  \"Returns a lazy sequence of the nodes in a tree, via a depth-first walk.\n   branch? must be a fn of one arg that returns true if passed a node\n   that can have children (but may not).  children must be a fn of one\n   arg that returns a sequence of the children. Will only be called on\n   nodes for which branch? returns true. Root is the root node of the\n  tree.\"\n  {:added \"1.0\"\n   :static true}\n   [branch? children root]\n   (let [walk (fn walk [node]\n                (lazy-seq\n                 (cons node\n                  (when (branch? node)\n                    (mapcat walk (children node))))))]\n     (walk root)))\n\n(defn file-seq\n  \"A tree seq on java.io.Files\"\n  {:added \"1.0\"\n   :static true}\n  [dir]\n    (tree-seq\n     (fn [^java.io.File f] (. f (isDirectory)))\n     (fn [^java.io.File d] (seq (. d (listFiles))))\n     dir))\n\n(defn xml-seq\n  \"A tree seq on the xml elements as per xml/parse\"\n  {:added \"1.0\"\n   :static true}\n  [root]\n    (tree-seq\n     (complement string?)\n     (comp seq :content)\n     root))\n\n(defn special-symbol?\n  \"Returns true if s names a special form\"\n  {:added \"1.0\"\n   :static true}\n  [s]\n    (contains? (. clojure.lang.Compiler specials) s))\n\n(defn var?\n  \"Returns true if v is of type clojure.lang.Var\"\n  {:added \"1.0\"\n   :static true}\n  [v] (instance? clojure.lang.Var v))\n\n(defn subs\n  \"Returns the substring of s beginning at start inclusive, and ending\n  at end (defaults to length of string), exclusive.\"\n  {:added \"1.0\"\n   :static true}\n  (^String [^String s start] (. s (substring start)))\n  (^String [^String s start end] (. s (substring start end))))\n\n(defn max-key\n  \"Returns the x for which (k x), a number, is greatest.\"\n  {:added \"1.0\"\n   :static true}\n  ([k x] x)\n  ([k x y] (if (> (k x) (k y)) x y))\n  ([k x y & more]\n   (reduce1 #(max-key k %1 %2) (max-key k x y) more)))\n\n(defn min-key\n  \"Returns the x for which (k x), a number, is least.\"\n  {:added \"1.0\"\n   :static true}\n  ([k x] x)\n  ([k x y] (if (< (k x) (k y)) x y))\n  ([k x y & more]\n   (reduce1 #(min-key k %1 %2) (min-key k x y) more)))\n\n(defn distinct\n  \"Returns a lazy sequence of the elements of coll with duplicates removed.\n  Returns a stateful transducer when no collection is provided.\"\n  {:added \"1.0\"\n   :static true}\n  ([]\n   (fn [rf]\n     (let [seen (volatile! #{})]\n       (fn\n         ([] (rf))\n         ([result] (rf result))\n         ([result input]\n          (if (contains? @seen input)\n            result\n            (do (vswap! seen conj input)\n                (rf result input))))))))\n  ([coll]\n   (let [step (fn step [xs seen]\n                (lazy-seq\n                  ((fn [[f :as xs] seen]\n                     (when-let [s (seq xs)]\n                       (if (contains? seen f)\n                         (recur (rest s) seen)\n                         (cons f (step (rest s) (conj seen f))))))\n                   xs seen)))]\n     (step coll #{}))))\n\n\n\n(defn replace\n  \"Given a map of replacement pairs and a vector/collection, returns a\n  vector/seq with any elements = a key in smap replaced with the\n  corresponding val in smap.  Returns a transducer when no collection\n  is provided.\"\n  {:added \"1.0\"\n   :static true}\n  ([smap]\n     (map #(if-let [e (find smap %)] (val e) %)))\n  ([smap coll]\n     (if (vector? coll)\n       (reduce1 (fn [v i]\n                  (if-let [e (find smap (nth v i))]\n                    (assoc v i (val e))\n                    v))\n                coll (range (count coll)))\n       (map #(if-let [e (find smap %)] (val e) %) coll))))\n\n(defmacro dosync\n  \"Runs the exprs (in an implicit do) in a transaction that encompasses\n  exprs and any nested calls.  Starts a transaction if none is already\n  running on this thread. Any uncaught exception will abort the\n  transaction and flow out of dosync. The exprs may be run more than\n  once, but any effects on Refs will be atomic.\"\n  {:added \"1.0\"}\n  [& exprs]\n  `(sync nil ~@exprs))\n\n(defmacro with-precision\n  \"Sets the precision and rounding mode to be used for BigDecimal operations.\n\n  Usage: (with-precision 10 (/ 1M 3))\n  or:    (with-precision 10 :rounding HALF_DOWN (/ 1M 3))\n\n  The rounding mode is one of CEILING, FLOOR, HALF_UP, HALF_DOWN,\n  HALF_EVEN, UP, DOWN and UNNECESSARY; it defaults to HALF_UP.\"\n  {:added \"1.0\"}\n  [precision & exprs]\n    (let [[body rm] (if (= (first exprs) :rounding)\n                      [(next (next exprs))\n                       `((. java.math.RoundingMode ~(second exprs)))]\n                      [exprs nil])]\n      `(binding [*math-context* (java.math.MathContext. ~precision ~@rm)]\n         ~@body)))\n\n(defn mk-bound-fn\n  {:private true}\n  [^clojure.lang.Sorted sc test key]\n  (fn [e]\n    (test (.. sc comparator (compare (. sc entryKey e) key)) 0)))\n\n(defn subseq\n  \"sc must be a sorted collection, test(s) one of <, <=, > or\n  >=. Returns a seq of those entries with keys ek for\n  which (test (.. sc comparator (compare ek key)) 0) is true\"\n  {:added \"1.0\"\n   :static true}\n  ([^clojure.lang.Sorted sc test key]\n   (let [include (mk-bound-fn sc test key)]\n     (if (#{> >=} test)\n       (when-let [[e :as s] (. sc seqFrom key true)]\n         (if (include e) s (next s)))\n       (take-while include (. sc seq true)))))\n  ([^clojure.lang.Sorted sc start-test start-key end-test end-key]\n   (when-let [[e :as s] (. sc seqFrom start-key true)]\n     (take-while (mk-bound-fn sc end-test end-key)\n                 (if ((mk-bound-fn sc start-test start-key) e) s (next s))))))\n\n(defn rsubseq\n  \"sc must be a sorted collection, test(s) one of <, <=, > or\n  >=. Returns a reverse seq of those entries with keys ek for\n  which (test (.. sc comparator (compare ek key)) 0) is true\"\n  {:added \"1.0\"\n   :static true}\n  ([^clojure.lang.Sorted sc test key]\n   (let [include (mk-bound-fn sc test key)]\n     (if (#{< <=} test)\n       (when-let [[e :as s] (. sc seqFrom key false)]\n         (if (include e) s (next s)))\n       (take-while include (. sc seq false)))))\n  ([^clojure.lang.Sorted sc start-test start-key end-test end-key]\n   (when-let [[e :as s] (. sc seqFrom end-key false)]\n     (take-while (mk-bound-fn sc start-test start-key)\n                 (if ((mk-bound-fn sc end-test end-key) e) s (next s))))))\n\n(defn repeatedly\n  \"Takes a function of no args, presumably with side effects, and\n  returns an infinite (or length n if supplied) lazy sequence of calls\n  to it\"\n  {:added \"1.0\"\n   :static true}\n  ([f] (lazy-seq (cons (f) (repeatedly f))))\n  ([n f] (take n (repeatedly f))))\n\n(defn add-classpath\n  \"DEPRECATED\n\n  Adds the url (String or URL object) to the classpath per\n  URLClassLoader.addURL\"\n  {:added \"1.0\"\n   :deprecated \"1.1\"}\n  [url]\n  (println \"WARNING: add-classpath is deprecated\")\n  (clojure.lang.RT/addURL url))\n\n\n\n(defn hash\n  \"Returns the hash code of its argument. Note this is the hash code\n  consistent with =, and thus is different than .hashCode for Integer,\n  Short, Byte and Clojure collections.\"\n\n  {:added \"1.0\"\n   :static true}\n  [x] (. clojure.lang.Util (hasheq x)))\n\n\n(defn mix-collection-hash\n  \"Mix final collection hash for ordered or unordered collections.\n   hash-basis is the combined collection hash, count is the number\n   of elements included in the basis. Note this is the hash code\n   consistent with =, different from .hashCode.\n   See http://clojure.org/data_structures#hash for full algorithms.\"\n  {:added \"1.6\"\n   :static true}\n  ^long\n  [^long hash-basis ^long count] (clojure.lang.Murmur3/mixCollHash hash-basis count))\n\n(defn hash-ordered-coll\n  \"Returns the hash code, consistent with =, for an external ordered\n   collection implementing Iterable.\n   See http://clojure.org/data_structures#hash for full algorithms.\"\n  {:added \"1.6\"\n   :static true}\n  ^long\n  [coll] (clojure.lang.Murmur3/hashOrdered coll))\n\n(defn hash-unordered-coll\n  \"Returns the hash code, consistent with =, for an external unordered\n   collection implementing Iterable. For maps, the iterator should\n   return map entries whose hash is computed as\n     (hash-ordered-coll [k v]).\n   See http://clojure.org/data_structures#hash for full algorithms.\"\n  {:added \"1.6\"\n   :static true}\n  ^long\n  [coll] (clojure.lang.Murmur3/hashUnordered coll))\n\n(defn interpose\n  \"Returns a lazy seq of the elements of coll separated by sep.\n  Returns a stateful transducer when no collection is provided.\"\n  {:added \"1.0\"\n   :static true}\n  ([sep]\n   (fn [rf]\n     (let [started (volatile! false)]\n       (fn\n         ([] (rf))\n         ([result] (rf result))\n         ([result input]\n          (if @started\n            (let [sepr (rf result sep)]\n              (if (reduced? sepr)\n                sepr\n                (rf sepr input)))\n            (do\n              (vreset! started true)\n              (rf result input))))))))\n  ([sep coll]\n   (drop 1 (interleave (repeat sep) coll))))\n\n(defmacro definline\n  \"Experimental - like defmacro, except defines a named function whose\n  body is the expansion, calls to which may be expanded inline as if\n  it were a macro. Cannot be used with variadic (&) args.\"\n  {:added \"1.0\"}\n  [name & decl]\n  (let [[pre-args [args expr]] (split-with (comp not vector?) decl)]\n    `(do\n       (defn ~name ~@pre-args ~args ~(apply (eval (list `fn args expr)) args))\n       (alter-meta! (var ~name) assoc :inline (fn ~args ~expr))\n       (var ~name))))\n\n(defn empty\n  \"Returns an empty collection of the same category as coll, or nil\"\n  {:added \"1.0\"\n   :static true}\n  [coll]\n  (when (instance? clojure.lang.IPersistentCollection coll)\n    (.empty ^clojure.lang.IPersistentCollection coll)))\n\n(defmacro amap\n  \"Maps an expression across an array a, using an index named idx, and\n  return value named ret, initialized to a clone of a, then setting\n  each element of ret to the evaluation of expr, returning the new\n  array ret.\"\n  {:added \"1.0\"}\n  [a idx ret expr]\n  `(let [a# ~a\n         ~ret (aclone a#)]\n     (loop  [~idx 0]\n       (if (< ~idx  (alength a#))\n         (do\n           (aset ~ret ~idx ~expr)\n           (recur (unchecked-inc ~idx)))\n         ~ret))))\n\n(defmacro areduce\n  \"Reduces an expression across an array a, using an index named idx,\n  and return value named ret, initialized to init, setting ret to the\n  evaluation of expr at each step, returning ret.\"\n  {:added \"1.0\"}\n  [a idx ret init expr]\n  `(let [a# ~a]\n     (loop  [~idx 0 ~ret ~init]\n       (if (< ~idx  (alength a#))\n         (recur (unchecked-inc ~idx) ~expr)\n         ~ret))))\n\n(defn float-array\n  \"Creates an array of floats\"\n  {:inline (fn [& args] `(. clojure.lang.Numbers float_array ~@args))\n   :inline-arities #{1 2}\n   :added \"1.0\"}\n  ([size-or-seq] (. clojure.lang.Numbers float_array size-or-seq))\n  ([size init-val-or-seq] (. clojure.lang.Numbers float_array size init-val-or-seq)))\n\n(defn boolean-array\n  \"Creates an array of booleans\"\n  {:inline (fn [& args] `(. clojure.lang.Numbers boolean_array ~@args))\n   :inline-arities #{1 2}\n   :added \"1.1\"}\n  ([size-or-seq] (. clojure.lang.Numbers boolean_array size-or-seq))\n  ([size init-val-or-seq] (. clojure.lang.Numbers boolean_array size init-val-or-seq)))\n\n(defn byte-array\n  \"Creates an array of bytes\"\n  {:inline (fn [& args] `(. clojure.lang.Numbers byte_array ~@args))\n   :inline-arities #{1 2}\n   :added \"1.1\"}\n  ([size-or-seq] (. clojure.lang.Numbers byte_array size-or-seq))\n  ([size init-val-or-seq] (. clojure.lang.Numbers byte_array size init-val-or-seq)))\n\n(defn char-array\n  \"Creates an array of chars\"\n  {:inline (fn [& args] `(. clojure.lang.Numbers char_array ~@args))\n   :inline-arities #{1 2}\n   :added \"1.1\"}\n  ([size-or-seq] (. clojure.lang.Numbers char_array size-or-seq))\n  ([size init-val-or-seq] (. clojure.lang.Numbers char_array size init-val-or-seq)))\n\n(defn short-array\n  \"Creates an array of shorts\"\n  {:inline (fn [& args] `(. clojure.lang.Numbers short_array ~@args))\n   :inline-arities #{1 2}\n   :added \"1.1\"}\n  ([size-or-seq] (. clojure.lang.Numbers short_array size-or-seq))\n  ([size init-val-or-seq] (. clojure.lang.Numbers short_array size init-val-or-seq)))\n\n(defn double-array\n  \"Creates an array of doubles\"\n  {:inline (fn [& args] `(. clojure.lang.Numbers double_array ~@args))\n   :inline-arities #{1 2}\n   :added \"1.0\"}\n  ([size-or-seq] (. clojure.lang.Numbers double_array size-or-seq))\n  ([size init-val-or-seq] (. clojure.lang.Numbers double_array size init-val-or-seq)))\n\n(defn object-array\n  \"Creates an array of objects\"\n  {:inline (fn [arg] `(. clojure.lang.RT object_array ~arg))\n   :inline-arities #{1}\n   :added \"1.2\"}\n  ([size-or-seq] (. clojure.lang.RT object_array size-or-seq)))\n\n(defn int-array\n  \"Creates an array of ints\"\n  {:inline (fn [& args] `(. clojure.lang.Numbers int_array ~@args))\n   :inline-arities #{1 2}\n   :added \"1.0\"}\n  ([size-or-seq] (. clojure.lang.Numbers int_array size-or-seq))\n  ([size init-val-or-seq] (. clojure.lang.Numbers int_array size init-val-or-seq)))\n\n(defn long-array\n  \"Creates an array of longs\"\n  {:inline (fn [& args] `(. clojure.lang.Numbers long_array ~@args))\n   :inline-arities #{1 2}\n   :added \"1.0\"}\n  ([size-or-seq] (. clojure.lang.Numbers long_array size-or-seq))\n  ([size init-val-or-seq] (. clojure.lang.Numbers long_array size init-val-or-seq)))\n\n(definline booleans\n  \"Casts to boolean[]\"\n  {:added \"1.1\"}\n  [xs] `(. clojure.lang.Numbers booleans ~xs))\n\n(definline bytes\n  \"Casts to bytes[]\"\n  {:added \"1.1\"}\n  [xs] `(. clojure.lang.Numbers bytes ~xs))\n\n(definline chars\n  \"Casts to chars[]\"\n  {:added \"1.1\"}\n  [xs] `(. clojure.lang.Numbers chars ~xs))\n\n(definline shorts\n  \"Casts to shorts[]\"\n  {:added \"1.1\"}\n  [xs] `(. clojure.lang.Numbers shorts ~xs))\n\n(definline floats\n  \"Casts to float[]\"\n  {:added \"1.0\"}\n  [xs] `(. clojure.lang.Numbers floats ~xs))\n\n(definline ints\n  \"Casts to int[]\"\n  {:added \"1.0\"}\n  [xs] `(. clojure.lang.Numbers ints ~xs))\n\n(definline doubles\n  \"Casts to double[]\"\n  {:added \"1.0\"}\n  [xs] `(. clojure.lang.Numbers doubles ~xs))\n\n(definline longs\n  \"Casts to long[]\"\n  {:added \"1.0\"}\n  [xs] `(. clojure.lang.Numbers longs ~xs))\n\n(import '(java.util.concurrent BlockingQueue LinkedBlockingQueue))\n\n(defn seque\n  \"Creates a queued seq on another (presumably lazy) seq s. The queued\n  seq will produce a concrete seq in the background, and can get up to\n  n items ahead of the consumer. n-or-q can be an integer n buffer\n  size, or an instance of java.util.concurrent BlockingQueue. Note\n  that reading from a seque can block if the reader gets ahead of the\n  producer.\"\n  {:added \"1.0\"\n   :static true}\n  ([s] (seque 100 s))\n  ([n-or-q s]\n   (let [^BlockingQueue q (if (instance? BlockingQueue n-or-q)\n                             n-or-q\n                             (LinkedBlockingQueue. (int n-or-q)))\n         NIL (Object.) ;nil sentinel since LBQ doesn't support nils\n         agt (agent (lazy-seq s)) ; never start with nil; that signifies we've already put eos\n         log-error (fn [q e]\n                     (if (.offer q q)\n                       (throw e)\n                       e))\n         fill (fn [s]\n                (when s\n                  (if (instance? Exception s) ; we failed to .offer an error earlier\n                    (log-error q s)\n                    (try\n                      (loop [[x & xs :as s] (seq s)]\n                        (if s\n                          (if (.offer q (if (nil? x) NIL x))\n                            (recur xs)\n                            s)\n                          (when-not (.offer q q) ; q itself is eos sentinel\n                            ()))) ; empty seq, not nil, so we know to put eos next time\n                      (catch Exception e\n                        (log-error q e))))))\n         drain (fn drain []\n                 (lazy-seq\n                  (let [x (.take q)]\n                    (if (identical? x q) ;q itself is eos sentinel\n                      (do @agt nil)  ;touch agent just to propagate errors\n                      (do\n                        (send-off agt fill)\n                        (release-pending-sends)\n                        (cons (if (identical? x NIL) nil x) (drain)))))))]\n     (send-off agt fill)\n     (drain))))\n\n(defn class?\n  \"Returns true if x is an instance of Class\"\n  {:added \"1.0\"\n   :static true}\n  [x] (instance? Class x))\n\n(defn- is-annotation? [c]\n  (and (class? c)\n       (.isAssignableFrom java.lang.annotation.Annotation c)))\n\n(defn- is-runtime-annotation? [^Class c]\n  (boolean\n   (and (is-annotation? c)\n        (when-let [^java.lang.annotation.Retention r\n                   (.getAnnotation c java.lang.annotation.Retention)]\n          (= (.value r) java.lang.annotation.RetentionPolicy/RUNTIME)))))\n\n(defn- descriptor [^Class c] (clojure.asm.Type/getDescriptor c))\n\n(declare process-annotation)\n(declare process-print-annotation)\n\n(defn- print-annotation-value [v]\n  (cond\n   (vector? v) (str \"{\" (apply str (interpose \", \" (map print-annotation-value v))) \"}\")\n   (symbol? v) (let [ev (eval v)]\n                 (cond\n                  (instance? java.lang.Enum ev) (str (.getCanonicalName (class ev)) \".\" (str ev))\n                  (class? ev) (str (.getCanonicalName ev) \".class\")\n                  :else (throw (IllegalArgumentException.\n                                (str \"Unsupported annotation value: \" v \" of class \" (class ev))))))\n   (seq? v) (let [[nested nv] v\n                  c (resolve nested)]\n              (str \"@\" (.getCanonicalName c) \"(\"\n                   (process-print-annotation nv) \")\"))\n   (string? v) (str \"\\\"\" (clojure.lang.Compiler/escapeString ^String v) \"\\\"\")\n   (nil? v) \"\"\n   :else v))\n\n(defn- add-annotation [^clojure.asm.AnnotationVisitor av name v]\n  (cond\n   (vector? v) (let [avec (.visitArray av name)]\n                 (doseq [vval v]\n                   (add-annotation avec \"value\" vval))\n                 (.visitEnd avec))\n   (symbol? v) (let [ev (eval v)]\n                 (cond\n                  (instance? java.lang.Enum ev)\n                  (.visitEnum av name (descriptor (class ev)) (str ev))\n                  (class? ev) (.visit av name (clojure.asm.Type/getType ev))\n                  :else (throw (IllegalArgumentException.\n                                (str \"Unsupported annotation value: \" v \" of class \" (class ev))))))\n   (seq? v) (let [[nested nv] v\n                  c (resolve nested)\n                  nav (.visitAnnotation av name (descriptor c))]\n              (process-annotation nav nv)\n              (.visitEnd nav))\n   :else\n   (.visit av name v)))\n\n(defn- process-annotation [av v]\n  (if (map? v)\n    (doseq [[k v] v]\n      (add-annotation av (name k) v))\n    (add-annotation av \"value\" v)))\n\n(defn- process-print-annotation [v]\n  (if (map? v)\n    (apply str (interpose \", \" (map (fn [[k v]] (str (name k) \"=\" (print-annotation-value v))) v)))\n    (print-annotation-value v)))\n\n(defn- add-annotations\n  ([visitor m] (add-annotations visitor m nil))\n  ([visitor m i]\n     (doseq [[k v] m]\n       (when (symbol? k)\n         (when-let [c (resolve k)]\n           (when (is-annotation? c)\n                                        ;this is known duck/reflective as no common base of ASM Visitors\n             (let [av (if i\n                        (.visitParameterAnnotation visitor i (descriptor c)\n                                                   (is-runtime-annotation? c))\n                        (.visitAnnotation visitor (descriptor c)\n                                          (is-runtime-annotation? c)))]\n               (clojure.lang.Compiler/emitSource (str \"@\" (.getCanonicalName c)\n                                                      (if (= 0 (count (.getDeclaredMethods c)))\n                                                        \"\"\n                                                        (str \"(\" (process-print-annotation v) \")\"))))\n               (process-annotation av v)\n               (.visitEnd av))))))))\n\n(defn alter-var-root\n  \"Atomically alters the root binding of var v by applying f to its\n  current value plus any args\"\n  {:added \"1.0\"\n   :static true}\n  [^clojure.lang.Var v f & args] (.alterRoot v f args))\n\n(defn bound?\n  \"Returns true if all of the vars provided as arguments have any bound value, root or thread-local.\n   Implies that deref'ing the provided vars will succeed. Returns true if no vars are provided.\"\n  {:added \"1.2\"\n   :static true}\n  [& vars]\n  (every? #(.isBound ^clojure.lang.Var %) vars))\n\n(defn thread-bound?\n  \"Returns true if all of the vars provided as arguments have thread-local bindings.\n   Implies that set!'ing the provided vars will succeed.  Returns true if no vars are provided.\"\n  {:added \"1.2\"\n   :static true}\n  [& vars]\n  (every? #(.getThreadBinding ^clojure.lang.Var %) vars))\n\n(defn make-hierarchy\n  \"Creates a hierarchy object for use with derive, isa? etc.\"\n  {:added \"1.0\"\n   :static true}\n  [] {:parents {} :descendants {} :ancestors {}})\n\n(def ^{:private true}\n     global-hierarchy (make-hierarchy))\n\n(defn not-empty\n  \"If coll is empty, returns nil, else coll\"\n  {:added \"1.0\"\n   :static true}\n  [coll] (when (seq coll) coll))\n\n(defn bases\n  \"Returns the immediate superclass and direct interfaces of c, if any\"\n  {:added \"1.0\"\n   :static true}\n  [^Class c]\n  (when c\n    (let [i (seq (.getInterfaces c))\n          s (.getSuperclass c)]\n      (if s (cons s i) i))))\n\n(defn supers\n  \"Returns the immediate and indirect superclasses and interfaces of c, if any\"\n  {:added \"1.0\"\n   :static true}\n  [^Class class]\n  (loop [ret (set (bases class)) cs ret]\n    (if (seq cs)\n      (let [c (first cs) bs (bases c)]\n        (recur (into1 ret bs) (into1 (disj cs c) bs)))\n      (not-empty ret))))\n\n(defn isa?\n  \"Returns true if (= child parent), or child is directly or indirectly derived from\n  parent, either via a Java type inheritance relationship or a\n  relationship established via derive. h must be a hierarchy obtained\n  from make-hierarchy, if not supplied defaults to the global\n  hierarchy\"\n  {:added \"1.0\"}\n  ([child parent] (isa? global-hierarchy child parent))\n  ([h child parent]\n   (or (= child parent)\n       (and (class? parent) (class? child)\n            (. ^Class parent isAssignableFrom child))\n       (contains? ((:ancestors h) child) parent)\n       (and (class? child) (some #(contains? ((:ancestors h) %) parent) (supers child)))\n       (and (vector? parent) (vector? child)\n            (= (count parent) (count child))\n            (loop [ret true i 0]\n              (if (or (not ret) (= i (count parent)))\n                ret\n                (recur (isa? h (child i) (parent i)) (inc i))))))))\n\n(defn parents\n  \"Returns the immediate parents of tag, either via a Java type\n  inheritance relationship or a relationship established via derive. h\n  must be a hierarchy obtained from make-hierarchy, if not supplied\n  defaults to the global hierarchy\"\n  {:added \"1.0\"}\n  ([tag] (parents global-hierarchy tag))\n  ([h tag] (not-empty\n            (let [tp (get (:parents h) tag)]\n              (if (class? tag)\n                (into1 (set (bases tag)) tp)\n                tp)))))\n\n(defn ancestors\n  \"Returns the immediate and indirect parents of tag, either via a Java type\n  inheritance relationship or a relationship established via derive. h\n  must be a hierarchy obtained from make-hierarchy, if not supplied\n  defaults to the global hierarchy\"\n  {:added \"1.0\"}\n  ([tag] (ancestors global-hierarchy tag))\n  ([h tag] (not-empty\n            (let [ta (get (:ancestors h) tag)]\n              (if (class? tag)\n                (let [superclasses (set (supers tag))]\n                  (reduce1 into1 superclasses\n                    (cons ta\n                          (map #(get (:ancestors h) %) superclasses))))\n                ta)))))\n\n(defn descendants\n  \"Returns the immediate and indirect children of tag, through a\n  relationship established via derive. h must be a hierarchy obtained\n  from make-hierarchy, if not supplied defaults to the global\n  hierarchy. Note: does not work on Java type inheritance\n  relationships.\"\n  {:added \"1.0\"}\n  ([tag] (descendants global-hierarchy tag))\n  ([h tag] (if (class? tag)\n             (throw (java.lang.UnsupportedOperationException. \"Can't get descendants of classes\"))\n             (not-empty (get (:descendants h) tag)))))\n\n(defn derive\n  \"Establishes a parent/child relationship between parent and\n  tag. Parent must be a namespace-qualified symbol or keyword and\n  child can be either a namespace-qualified symbol or keyword or a\n  class. h must be a hierarchy obtained from make-hierarchy, if not\n  supplied defaults to, and modifies, the global hierarchy.\"\n  {:added \"1.0\"}\n  ([tag parent]\n   (assert (namespace parent))\n   (assert (or (class? tag) (and (instance? clojure.lang.Named tag) (namespace tag))))\n\n   (alter-var-root #'global-hierarchy derive tag parent) nil)\n  ([h tag parent]\n   (assert (not= tag parent))\n   (assert (or (class? tag) (instance? clojure.lang.Named tag)))\n   (assert (instance? clojure.lang.Named parent))\n\n   (let [tp (:parents h)\n         td (:descendants h)\n         ta (:ancestors h)\n         tf (fn [m source sources target targets]\n              (reduce1 (fn [ret k]\n                        (assoc ret k\n                               (reduce1 conj (get targets k #{}) (cons target (targets target)))))\n                      m (cons source (sources source))))]\n     (or\n      (when-not (contains? (tp tag) parent)\n        (when (contains? (ta tag) parent)\n          (throw (Exception. (print-str tag \"already has\" parent \"as ancestor\"))))\n        (when (contains? (ta parent) tag)\n          (throw (Exception. (print-str \"Cyclic derivation:\" parent \"has\" tag \"as ancestor\"))))\n        {:parents (assoc (:parents h) tag (conj (get tp tag #{}) parent))\n         :ancestors (tf (:ancestors h) tag td parent ta)\n         :descendants (tf (:descendants h) parent ta tag td)})\n      h))))\n\n(declare flatten)\n\n(defn underive\n  \"Removes a parent/child relationship between parent and\n  tag. h must be a hierarchy obtained from make-hierarchy, if not\n  supplied defaults to, and modifies, the global hierarchy.\"\n  {:added \"1.0\"}\n  ([tag parent] (alter-var-root #'global-hierarchy underive tag parent) nil)\n  ([h tag parent]\n    (let [parentMap (:parents h)\n\t  childsParents (if (parentMap tag)\n\t\t\t  (disj (parentMap tag) parent) #{})\n\t  newParents (if (not-empty childsParents)\n\t\t       (assoc parentMap tag childsParents)\n\t\t       (dissoc parentMap tag))\n\t  deriv-seq (flatten (map #(cons (key %) (interpose (key %) (val %)))\n\t\t\t\t       (seq newParents)))]\n      (if (contains? (parentMap tag) parent)\n\t(reduce1 #(apply derive %1 %2) (make-hierarchy)\n\t\t(partition 2 deriv-seq))\n\th))))\n\n\n(defn distinct?\n  \"Returns true if no two of the arguments are =\"\n  {:tag Boolean\n   :added \"1.0\"\n   :static true}\n  ([x] true)\n  ([x y] (not (= x y)))\n  ([x y & more]\n   (if (not= x y)\n     (loop [s #{x y} [x & etc :as xs] more]\n       (if xs\n         (if (contains? s x)\n           false\n           (recur (conj s x) etc))\n         true))\n     false)))\n\n(comment\n  (defn resultset-seq\n    \"Creates and returns a lazy sequence of structmaps corresponding to\n    the rows in the java.sql.ResultSet rs\"\n    {:added \"1.0\"}\n    [^java.sql.ResultSet rs]\n    (let [rsmeta (. rs (getMetaData))\n          idxs (range 1 (inc (. rsmeta (getColumnCount))))\n          keys (map (comp keyword #(.toLowerCase ^String %))\n                    (map (fn [i] (. rsmeta (getColumnLabel i))) idxs))\n          check-keys\n          (or (apply distinct? keys)\n              (throw (Exception. \"ResultSet must have unique column labels\")))\n          row-struct (apply create-struct keys)\n          row-values (fn [] (map (fn [^Integer i] (. rs (getObject i))) idxs))\n          rows (fn thisfn []\n                 (when (. rs (next))\n                   (cons (apply struct row-struct (row-values)) (lazy-seq (thisfn)))))]\n      (rows))))\n\n(defn iterator-seq\n  \"Returns a seq on a java.util.Iterator. Note that most collections\n  providing iterators implement Iterable and thus support seq directly.\n  Seqs cache values, thus iterator-seq should not be used on any\n  iterator that repeatedly returns the same mutable object.\"\n  {:added \"1.0\"\n   :static true}\n  [iter]\n  (clojure.lang.RT/chunkIteratorSeq iter))\n\n(defn enumeration-seq\n  \"Returns a seq on a java.util.Enumeration\"\n  {:added \"1.0\"\n   :static true}\n  [e]\n  (clojure.lang.EnumerationSeq/create e))\n\n(defn format\n  \"Formats a string using java.lang.String.format, see java.util.Formatter for format\n  string syntax\"\n  {:added \"1.0\"\n   :static true}\n  ^String [fmt & args]\n  (String/format fmt (to-array args)))\n\n(defn printf\n  \"Prints formatted output, as per format\"\n  {:added \"1.0\"\n   :static true}\n  [fmt & args]\n  (print (apply format fmt args)))\n\n(declare gen-class)\n\n(defmacro with-loading-context [& body]\n  `((fn loading# []\n        (. clojure.lang.Var (pushThreadBindings {clojure.lang.Compiler/LOADER\n                                                 (.getClassLoader (.getClass ^Object loading#))}))\n        (try\n         ~@body\n         (finally\n          (. clojure.lang.Var (popThreadBindings)))))))\n\n(defmacro ns\n  \"Sets *ns* to the namespace named by name (unevaluated), creating it\n  if needed.  references can be zero or more of: (:refer-clojure ...)\n  (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class)\n  with the syntax of refer-clojure/require/use/import/load/gen-class\n  respectively, except the arguments are unevaluated and need not be\n  quoted. (:gen-class ...), when supplied, defaults to :name\n  corresponding to the ns name, :main true, :impl-ns same as ns, and\n  :init-impl-ns true. All options of gen-class are\n  supported. The :gen-class directive is ignored when not\n  compiling. If :gen-class is not supplied, when compiled only an\n  nsname__init.class will be generated. If :refer-clojure is not used, a\n  default (refer 'clojure.core) is used.  Use of ns is preferred to\n  individual calls to in-ns/require/use/import:\n\n  (ns foo.bar\n    (:refer-clojure :exclude [ancestors printf])\n    (:require (clojure.contrib sql combinatorics))\n    (:use (my.lib this that))\n    (:import (java.util Date Timer Random)\n             (java.sql Connection Statement)))\"\n  {:arglists '([name docstring? attr-map? references*])\n   :added \"1.0\"}\n  [name & references]\n  (let [process-reference\n        (fn [[kname & args]]\n          `(~(symbol \"clojure.core\" (clojure.core/name kname))\n             ~@(map #(list 'quote %) args)))\n        docstring  (when (string? (first references)) (first references))\n        references (if docstring (next references) references)\n        name (if docstring\n               (vary-meta name assoc :doc docstring)\n               name)\n        metadata   (when (map? (first references)) (first references))\n        references (if metadata (next references) references)\n        name (if metadata\n               (vary-meta name merge metadata)\n               name)\n        gen-class-clause (first (filter #(= :gen-class (first %)) references))\n        gen-class-call\n          (when gen-class-clause\n            (list* `gen-class :name (.replace (str name) \\- \\_) :impl-ns name :main true (next gen-class-clause)))\n        references (remove #(= :gen-class (first %)) references)\n        ;ns-effect (clojure.core/in-ns name)\n        ]\n    `(do\n       (clojure.core/in-ns '~name)\n       (with-loading-context\n        ~@(when gen-class-call (list gen-class-call))\n        ~@(when (and (not= name 'clojure.core) (not-any? #(= :refer-clojure (first %)) references))\n            `((clojure.core/refer '~'clojure.core)))\n        ~@(map process-reference references))\n        (if (.equals '~name 'clojure.core)\n          nil\n          (do (dosync (commute @#'*loaded-libs* conj '~name)) nil)))))\n\n(defmacro refer-clojure\n  \"Same as (refer 'clojure.core <filters>)\"\n  {:added \"1.0\"}\n  [& filters]\n  `(clojure.core/refer '~'clojure.core ~@filters))\n\n(defmacro defonce\n  \"defs name to have the root value of the expr iff the named var has no root value,\n  else expr is unevaluated\"\n  {:added \"1.0\"}\n  [name expr]\n  `(let [v# (def ~name)]\n     (when-not (.hasRoot v#)\n       (def ~name ~expr))))\n\n;;;;;;;;;;; require/use/load, contributed by Stephen C. Gilardi ;;;;;;;;;;;;;;;;;;\n\n(defonce ^:dynamic\n  ^{:private true\n     :doc \"A ref to a sorted set of symbols representing loaded libs\"}\n  *loaded-libs* (ref (sorted-set)))\n\n(defonce ^:dynamic\n  ^{:private true\n     :doc \"A stack of paths currently being loaded by this thread\"}\n  *pending-paths* ())\n\n(defonce ^:dynamic\n  ^{:private true :doc\n     \"True while a verbose load is pending\"}\n  *loading-verbosely* false)\n\n(defn- throw-if\n  \"Throws a CompilerException with a message if pred is true\"\n  [pred fmt & args]\n  (when pred\n    (let [^String message (apply format fmt args)\n          exception (Exception. message)\n          raw-trace (.getStackTrace exception)\n          boring? #(not= (.getMethodName ^StackTraceElement %) \"doInvoke\")\n          trace (into-array (drop 2 (drop-while boring? raw-trace)))]\n      (.setStackTrace exception trace)\n      (throw (clojure.lang.Compiler$CompilerException.\n              *file*\n              (.deref clojure.lang.Compiler/LINE)\n              (.deref clojure.lang.Compiler/COLUMN)\n              exception)))))\n\n(defn- libspec?\n  \"Returns true if x is a libspec\"\n  [x]\n  (or (symbol? x)\n      (and (vector? x)\n           (or\n            (nil? (second x))\n            (keyword? (second x))))))\n\n(defn- prependss\n  \"Prepends a symbol or a seq to coll\"\n  [x coll]\n  (if (symbol? x)\n    (cons x coll)\n    (concat x coll)))\n\n(defn- root-resource\n  \"Returns the root directory path for a lib\"\n  {:tag String}\n  [lib]\n  (str \\/\n       (.. (name lib)\n           (replace \\- \\_)\n           (replace \\. \\/))))\n\n(defn- root-directory\n  \"Returns the root resource path for a lib\"\n  [lib]\n  (let [d (root-resource lib)]\n    (subs d 0 (.lastIndexOf d \"/\"))))\n\n(declare load)\n\n(defn- load-one\n  \"Loads a lib given its name. If need-ns, ensures that the associated\n  namespace exists after loading. If require, records the load so any\n  duplicate loads can be skipped.\"\n  [lib need-ns require]\n  (load (root-resource lib))\n  (throw-if (and need-ns (not (find-ns lib)))\n            \"namespace '%s' not found after loading '%s'\"\n            lib (root-resource lib))\n  (when require\n    (dosync\n     (commute *loaded-libs* conj lib))))\n\n(defn- load-all\n  \"Loads a lib given its name and forces a load of any libs it directly or\n  indirectly loads. If need-ns, ensures that the associated namespace\n  exists after loading. If require, records the load so any duplicate loads\n  can be skipped.\"\n  [lib need-ns require]\n  (dosync\n   (commute *loaded-libs* #(reduce1 conj %1 %2)\n            (binding [*loaded-libs* (ref (sorted-set))]\n              (load-one lib need-ns require)\n              @*loaded-libs*))))\n\n(defn- load-lib\n  \"Loads a lib with options\"\n  [prefix lib & options]\n  (throw-if (and prefix (pos? (.indexOf (name lib) (int \\.))))\n            \"Found lib name '%s' containing period with prefix '%s'.  lib names inside prefix lists must not contain periods\"\n            (name lib) prefix)\n  (let [lib (if prefix (symbol (str prefix \\. lib)) lib)\n        opts (apply hash-map options)\n        {:keys [as reload reload-all require use verbose]} opts\n        loaded (contains? @*loaded-libs* lib)\n        load (cond reload-all\n                   load-all\n                   (or reload (not require) (not loaded))\n                   load-one)\n        need-ns (or as use)\n        filter-opts (select-keys opts '(:exclude :only :rename :refer))\n        undefined-on-entry (not (find-ns lib))]\n    (binding [*loading-verbosely* (or *loading-verbosely* verbose)]\n      (if load\n        (try\n          (load lib need-ns require)\n          (catch Exception e\n            (when undefined-on-entry\n              (remove-ns lib))\n            (throw e)))\n        (throw-if (and need-ns (not (find-ns lib)))\n                  \"namespace '%s' not found\" lib))\n      (when (and need-ns *loading-verbosely*)\n        (printf \"(clojure.core/in-ns '%s)\\n\" (ns-name *ns*)))\n      (when as\n        (when *loading-verbosely*\n          (printf \"(clojure.core/alias '%s '%s)\\n\" as lib))\n        (alias as lib))\n      (when (or use (:refer filter-opts))\n        (when *loading-verbosely*\n          (printf \"(clojure.core/refer '%s\" lib)\n          (doseq [opt filter-opts]\n            (printf \" %s '%s\" (key opt) (print-str (val opt))))\n          (printf \")\\n\"))\n        (apply refer lib (mapcat seq filter-opts))))))\n\n(defn- load-libs\n  \"Loads libs, interpreting libspecs, prefix lists, and flags for\n  forwarding to load-lib\"\n  [& args]\n  (let [flags (filter keyword? args)\n        opts (interleave flags (repeat true))\n        args (filter (complement keyword?) args)]\n    ; check for unsupported options\n    (let [supported #{:as :reload :reload-all :require :use :verbose :refer}\n          unsupported (seq (remove supported flags))]\n      (throw-if unsupported\n                (apply str \"Unsupported option(s) supplied: \"\n                     (interpose \\, unsupported))))\n    ; check a load target was specified\n    (throw-if (not (seq args)) \"Nothing specified to load\")\n    (doseq [arg args]\n      (if (libspec? arg)\n        (apply load-lib nil (prependss arg opts))\n        (let [[prefix & args] arg]\n          (throw-if (nil? prefix) \"prefix cannot be nil\")\n          (doseq [arg args]\n            (apply load-lib prefix (prependss arg opts))))))))\n\n(defn- check-cyclic-dependency\n  \"Detects and rejects non-trivial cyclic load dependencies. The\n  exception message shows the dependency chain with the cycle\n  highlighted. Ignores the trivial case of a file attempting to load\n  itself because that can occur when a gen-class'd class loads its\n  implementation.\"\n  [path]\n  (when (some #{path} (rest *pending-paths*))\n    (let [pending (map #(if (= % path) (str \"[ \" % \" ]\") %)\n                       (cons path *pending-paths*))\n          chain (apply str (interpose \"->\" pending))]\n      (throw-if true \"Cyclic load dependency: %s\" chain))))\n\n;; Public\n\n(defn require\n  \"Loads libs, skipping any that are already loaded. Each argument is\n  either a libspec that identifies a lib, a prefix list that identifies\n  multiple libs whose names share a common prefix, or a flag that modifies\n  how all the identified libs are loaded. Use :require in the ns macro\n  in preference to calling this directly.\n\n  Libs\n\n  A 'lib' is a named set of resources in classpath whose contents define a\n  library of Clojure code. Lib names are symbols and each lib is associated\n  with a Clojure namespace and a Java package that share its name. A lib's\n  name also locates its root directory within classpath using Java's\n  package name to classpath-relative path mapping. All resources in a lib\n  should be contained in the directory structure under its root directory.\n  All definitions a lib makes should be in its associated namespace.\n\n  'require loads a lib by loading its root resource. The root resource path\n  is derived from the lib name in the following manner:\n  Consider a lib named by the symbol 'x.y.z; it has the root directory\n  <classpath>/x/y/, and its root resource is <classpath>/x/y/z.clj. The root\n  resource should contain code to create the lib's namespace (usually by using\n  the ns macro) and load any additional lib resources.\n\n  Libspecs\n\n  A libspec is a lib name or a vector containing a lib name followed by\n  options expressed as sequential keywords and arguments.\n\n  Recognized options:\n  :as takes a symbol as its argument and makes that symbol an alias to the\n    lib's namespace in the current namespace.\n  :refer takes a list of symbols to refer from the namespace or the :all\n    keyword to bring in all public vars.\n\n  Prefix Lists\n\n  It's common for Clojure code to depend on several libs whose names have\n  the same prefix. When specifying libs, prefix lists can be used to reduce\n  repetition. A prefix list contains the shared prefix followed by libspecs\n  with the shared prefix removed from the lib names. After removing the\n  prefix, the names that remain must not contain any periods.\n\n  Flags\n\n  A flag is a keyword.\n  Recognized flags: :reload, :reload-all, :verbose\n  :reload forces loading of all the identified libs even if they are\n    already loaded\n  :reload-all implies :reload and also forces loading of all libs that the\n    identified libs directly or indirectly load via require or use\n  :verbose triggers printing information about each load, alias, and refer\n\n  Example:\n\n  The following would load the libraries clojure.zip and clojure.set\n  abbreviated as 's'.\n\n  (require '(clojure zip [set :as s]))\"\n  {:added \"1.0\"}\n\n  [& args]\n  (apply load-libs :require args))\n\n(defn use\n  \"Like 'require, but also refers to each lib's namespace using\n  clojure.core/refer. Use :use in the ns macro in preference to calling\n  this directly.\n\n  'use accepts additional options in libspecs: :exclude, :only, :rename.\n  The arguments and semantics for :exclude, :only, and :rename are the same\n  as those documented for clojure.core/refer.\"\n  {:added \"1.0\"}\n  [& args] (apply load-libs :require :use args))\n\n(defn loaded-libs\n  \"Returns a sorted set of symbols naming the currently loaded libs\"\n  {:added \"1.0\"}\n  [] @*loaded-libs*)\n\n(defn load\n  \"Loads Clojure code from resources in classpath. A path is interpreted as\n  classpath-relative if it begins with a slash or relative to the root\n  directory for the current namespace otherwise.\"\n  {:added \"1.0\"}\n  [& paths]\n  (doseq [^String path paths]\n    (let [^String path (if (.startsWith path \"/\")\n                          path\n                          (str (root-directory (ns-name *ns*)) \\/ path))]\n      (when *loading-verbosely*\n        (printf \"(clojure.core/load \\\"%s\\\")\\n\" path)\n        (flush))\n      (check-cyclic-dependency path)\n      (when-not (= path (first *pending-paths*))\n        (binding [*pending-paths* (conj *pending-paths* path)]\n          (clojure.lang.RT/load (.substring path 1)))))))\n\n(defn compile\n  \"Compiles the namespace named by the symbol lib into a set of\n  classfiles. The source for the lib must be in a proper\n  classpath-relative directory. The output files will go into the\n  directory specified by *compile-path*, and that directory too must\n  be in the classpath.\"\n  {:added \"1.0\"}\n  [lib]\n  (binding [*compile-files* true\n            *compiler-options* \n            {:elide-meta (if (= \"true\" (System/getenv \"KEEP_META\"))\n                           []\n                           [:arglists :file :line :column\n                            :ns :name :added :static :doc])}]\n    (load-one lib true true))\n  lib)\n\n;;;;;;;;;;;;; nested associative ops ;;;;;;;;;;;\n\n(defn get-in\n  \"Returns the value in a nested associative structure,\n  where ks is a sequence of keys. Returns nil if the key\n  is not present, or the not-found value if supplied.\"\n  {:added \"1.2\"\n   :static true}\n  ([m ks]\n     (reduce1 get m ks))\n  ([m ks not-found]\n     (loop [sentinel (Object.)\n            m m\n            ks (seq ks)]\n       (if ks\n         (let [m (get m (first ks) sentinel)]\n           (if (identical? sentinel m)\n             not-found\n             (recur sentinel m (next ks))))\n         m))))\n\n(defn assoc-in\n  \"Associates a value in a nested associative structure, where ks is a\n  sequence of keys and v is the new value and returns a new nested structure.\n  If any levels do not exist, hash-maps will be created.\"\n  {:added \"1.0\"\n   :static true}\n  [m [k & ks] v]\n  (if ks\n    (assoc m k (assoc-in (get m k) ks v))\n    (assoc m k v)))\n\n(defn update-in\n  \"'Updates' a value in a nested associative structure, where ks is a\n  sequence of keys and f is a function that will take the old value\n  and any supplied args and return the new value, and returns a new\n  nested structure.  If any levels do not exist, hash-maps will be\n  created.\"\n  {:added \"1.0\"\n   :static true}\n  ([m [k & ks] f & args]\n   (if ks\n     (assoc m k (apply update-in (get m k) ks f args))\n     (assoc m k (apply f (get m k) args)))))\n\n(defn update\n  \"'Updates' a value in an associative structure, where k is a\n  key and f is a function that will take the old value\n  and any supplied args and return the new value, and returns a new\n  structure.  If the key does not exist, nil is passed as the old value.\"\n  {:added \"1.7\"\n   :static true}\n  ([m k f]\n   (assoc m k (f (get m k))))\n  ([m k f x]\n   (assoc m k (f (get m k) x)))\n  ([m k f x y]\n   (assoc m k (f (get m k) x y)))\n  ([m k f x y z]\n   (assoc m k (f (get m k) x y z)))\n  ([m k f x y z & more]\n   (assoc m k (apply f (get m k) x y z more))))\n\n(defn empty?\n  \"Returns true if coll has no items - same as (not (seq coll)).\n  Please use the idiom (seq x) rather than (not (empty? x))\"\n  {:added \"1.0\"\n   :static true}\n  [coll] (not (seq coll)))\n\n(defn coll?\n  \"Returns true if x implements IPersistentCollection\"\n  {:added \"1.0\"\n   :static true}\n  [x] (instance? clojure.lang.IPersistentCollection x))\n\n(defn list?\n  \"Returns true if x implements IPersistentList\"\n  {:added \"1.0\"\n   :static true}\n  [x] (instance? clojure.lang.IPersistentList x))\n\n(defn ifn?\n  \"Returns true if x implements IFn. Note that many data structures\n  (e.g. sets and maps) implement IFn\"\n  {:added \"1.0\"\n   :static true}\n  [x] (instance? clojure.lang.IFn x))\n\n(defn fn?\n  \"Returns true if x implements Fn, i.e. is an object created via fn.\"\n  {:added \"1.0\"\n   :static true}\n  [x] (instance? clojure.lang.Fn x))\n\n\n(defn associative?\n \"Returns true if coll implements Associative\"\n {:added \"1.0\"\n  :static true}\n  [coll] (instance? clojure.lang.Associative coll))\n\n(defn sequential?\n \"Returns true if coll implements Sequential\"\n {:added \"1.0\"\n  :static true}\n  [coll] (instance? clojure.lang.Sequential coll))\n\n(defn sorted?\n \"Returns true if coll implements Sorted\"\n {:added \"1.0\"\n   :static true}\n  [coll] (instance? clojure.lang.Sorted coll))\n\n(defn counted?\n \"Returns true if coll implements count in constant time\"\n {:added \"1.0\"\n   :static true}\n  [coll] (instance? clojure.lang.Counted coll))\n\n(defn reversible?\n \"Returns true if coll implements Reversible\"\n {:added \"1.0\"\n   :static true}\n  [coll] (instance? clojure.lang.Reversible coll))\n\n(def ^:dynamic\n ^{:doc \"bound in a repl thread to the most recent value printed\"\n   :added \"1.0\"}\n *1)\n\n(def ^:dynamic\n ^{:doc \"bound in a repl thread to the second most recent value printed\"\n   :added \"1.0\"}\n *2)\n\n(def ^:dynamic\n ^{:doc \"bound in a repl thread to the third most recent value printed\"\n   :added \"1.0\"}\n *3)\n\n(def ^:dynamic\n ^{:doc \"bound in a repl thread to the most recent exception caught by the repl\"\n   :added \"1.0\"}\n *e)\n\n(defn trampoline\n  \"trampoline can be used to convert algorithms requiring mutual\n  recursion without stack consumption. Calls f with supplied args, if\n  any. If f returns a fn, calls that fn with no arguments, and\n  continues to repeat, until the return value is not a fn, then\n  returns that non-fn value. Note that if you want to return a fn as a\n  final value, you must wrap it in some data structure and unpack it\n  after trampoline returns.\"\n  {:added \"1.0\"\n   :static true}\n  ([f]\n     (let [ret (f)]\n       (if (fn? ret)\n         (recur ret)\n         ret)))\n  ([f & args]\n     (trampoline #(apply f args))))\n\n(defn intern\n  \"Finds or creates a var named by the symbol name in the namespace\n  ns (which can be a symbol or a namespace), setting its root binding\n  to val if supplied. The namespace must exist. The var will adopt any\n  metadata from the name symbol.  Returns the var.\"\n  {:added \"1.0\"\n   :static true}\n  ([ns ^clojure.lang.Symbol name]\n     (let [v (clojure.lang.Var/intern (the-ns ns) name)]\n       (when (meta name) (.setMeta v (meta name)))\n       v))\n  ([ns name val]\n     (let [v (clojure.lang.Var/intern (the-ns ns) name val)]\n       (when (meta name) (.setMeta v (meta name)))\n       v)))\n\n(defmacro while\n  \"Repeatedly executes body while test expression is true. Presumes\n  some side-effect will cause test to become false/nil. Returns nil\"\n  {:added \"1.0\"}\n  [test & body]\n  `(loop []\n     (when ~test\n       ~@body\n       (recur))))\n\n(defn memoize\n  \"Returns a memoized version of a referentially transparent function. The\n  memoized version of the function keeps a cache of the mapping from arguments\n  to results and, when calls with the same arguments are repeated often, has\n  higher performance at the expense of higher memory use.\"\n  {:added \"1.0\"\n   :static true}\n  [f]\n  (let [mem (atom {})]\n    (fn [& args]\n      (if-let [e (find @mem args)]\n        (val e)\n        (let [ret (apply f args)]\n          (swap! mem assoc args ret)\n          ret)))))\n\n(def supers (memoize supers))\n(def bases (memoize bases))\n\n(defmacro condp\n  \"Takes a binary predicate, an expression, and a set of clauses.\n  Each clause can take the form of either:\n\n  test-expr result-expr\n\n  test-expr :>> result-fn\n\n  Note :>> is an ordinary keyword.\n\n  For each clause, (pred test-expr expr) is evaluated. If it returns\n  logical true, the clause is a match. If a binary clause matches, the\n  result-expr is returned, if a ternary clause matches, its result-fn,\n  which must be a unary function, is called with the result of the\n  predicate as its argument, the result of that call being the return\n  value of condp. A single default expression can follow the clauses,\n  and its value will be returned if no clause matches. If no default\n  expression is provided and no clause matches, an\n  IllegalArgumentException is thrown.\"\n  {:added \"1.0\"}\n\n  [pred expr & clauses]\n  (let [gpred (gensym \"pred__\")\n        gexpr (gensym \"expr__\")\n        emit (fn emit [pred expr args]\n               (let [[[a b c :as clause] more]\n                       (split-at (if (= :>> (second args)) 3 2) args)\n                       n (count clause)]\n                 (cond\n                  (= 0 n) `(throw (IllegalArgumentException. (str \"No matching clause: \" ~expr)))\n                  (= 1 n) a\n                  (= 2 n) `(if (~pred ~a ~expr)\n                             ~b\n                             ~(emit pred expr more))\n                  :else `(if-let [p# (~pred ~a ~expr)]\n                           (~c p#)\n                           ~(emit pred expr more)))))\n        gres (gensym \"res__\")]\n    `(let [~gpred ~pred\n           ~gexpr ~expr]\n       ~(emit gpred gexpr clauses))))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; var documentation ;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(alter-meta! #'*agent* assoc :added \"1.0\")\n(alter-meta! #'in-ns assoc :added \"1.0\")\n(alter-meta! #'load-file assoc :added \"1.0\")\n\n(defmacro add-doc-and-meta {:private true} [name docstring meta]\n  `(alter-meta! (var ~name) merge (assoc ~meta :doc ~docstring)))\n\n(add-doc-and-meta *file*\n  \"The path of the file being evaluated, as a String.\n\n  When there is no file, e.g. in the REPL, the value is not defined.\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *command-line-args*\n  \"A sequence of the supplied command line arguments, or nil if\n  none were supplied\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *warn-on-reflection*\n  \"When set to true, the compiler will emit warnings when reflection is\n  needed to resolve Java method calls or field accesses.\n\n  Defaults to false.\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *compile-path*\n  \"Specifies the directory where 'compile' will write out .class\n  files. This directory must be in the classpath for 'compile' to\n  work.\n\n  Defaults to \\\"classes\\\"\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *compile-files*\n  \"Set to true when compiling files, false otherwise.\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *unchecked-math*\n  \"While bound to true, compilations of +, -, *, inc, dec and the\n  coercions will be done without overflow checks. While bound\n  to :warn-on-boxed, same behavior as true, and a warning is emitted\n  when compilation uses boxed math. Default: false.\"\n  {:added \"1.3\"})\n\n(add-doc-and-meta *compiler-options*\n  \"A map of keys to options.\n  Note, when binding dynamically make sure to merge with previous value.\n  Supported options:\n  :elide-meta - a collection of metadata keys to elide during compilation.\n  :disable-locals-clearing - set to true to disable clearing, useful for using a debugger\n  Alpha, subject to change.\"\n  {:added \"1.4\"})\n\n(add-doc-and-meta *ns*\n  \"A clojure.lang.Namespace object representing the current namespace.\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *in*\n  \"A java.io.Reader object representing standard input for read operations.\n\n  Defaults to System/in, wrapped in a LineNumberingPushbackReader\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *out*\n  \"A java.io.Writer object representing standard output for print operations.\n\n  Defaults to System/out, wrapped in an OutputStreamWriter\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *err*\n  \"A java.io.Writer object representing standard error for print operations.\n\n  Defaults to System/err, wrapped in a PrintWriter\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *flush-on-newline*\n  \"When set to true, output will be flushed whenever a newline is printed.\n\n  Defaults to true.\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *print-meta*\n  \"If set to logical true, when printing an object, its metadata will also\n  be printed in a form that can be read back by the reader.\n\n  Defaults to false.\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *print-dup*\n  \"When set to logical true, objects will be printed in a way that preserves\n  their type when read in later.\n\n  Defaults to false.\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *print-readably*\n  \"When set to logical false, strings and characters will be printed with\n  non-alphanumeric characters converted to the appropriate escape sequences.\n\n  Defaults to true\"\n  {:added \"1.0\"})\n\n(add-doc-and-meta *read-eval*\n \"Defaults to true (or value specified by system property, see below)\n  ***This setting implies that the full power of the reader is in play,\n  including syntax that can cause code to execute. It should never be\n  used with untrusted sources. See also: clojure.edn/read.***\n\n  When set to logical false in the thread-local binding,\n  the eval reader (#=) and record/type literal syntax are disabled in read/load.\n  Example (will fail): (binding [*read-eval* false] (read-string \\\"#=(* 2 21)\\\"))\n\n  The default binding can be controlled by the system property\n  'clojure.read.eval' System properties can be set on the command line\n  like this:\n\n  java -Dclojure.read.eval=false ...\n\n  The system property can also be set to 'unknown' via\n  -Dclojure.read.eval=unknown, in which case the default binding\n  is :unknown and all reads will fail in contexts where *read-eval*\n  has not been explicitly bound to either true or false. This setting\n  can be a useful diagnostic tool to ensure that all of your reads\n  occur in considered contexts. You can also accomplish this in a\n  particular scope by binding *read-eval* to :unknown\n  \"\n  {:added \"1.0\"})\n\n(defn future?\n  \"Returns true if x is a future\"\n  {:added \"1.1\"\n   :static true}\n  [x] (instance? java.util.concurrent.Future x))\n\n(defn future-done?\n  \"Returns true if future f is done\"\n  {:added \"1.1\"\n   :static true}\n  [^java.util.concurrent.Future f] (.isDone f))\n\n\n(defmacro letfn\n  \"fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+)\n\n  Takes a vector of function specs and a body, and generates a set of\n  bindings of functions to their names. All of the names are available\n  in all of the definitions of the functions, as well as the body.\"\n  {:added \"1.0\", :forms '[(letfn [fnspecs*] exprs*)],\n   :special-form true, :url nil}\n  [fnspecs & body]\n  `(letfn* ~(vec (interleave (map first fnspecs)\n                             (map #(cons `fn %) fnspecs)))\n           ~@body))\n\n(defn fnil\n  \"Takes a function f, and returns a function that calls f, replacing\n  a nil first argument to f with the supplied value x. Higher arity\n  versions can replace arguments in the second and third\n  positions (y, z). Note that the function f can take any number of\n  arguments, not just the one(s) being nil-patched.\"\n  {:added \"1.2\"\n   :static true}\n  ([f x]\n   (fn\n     ([a] (f (if (nil? a) x a)))\n     ([a b] (f (if (nil? a) x a) b))\n     ([a b c] (f (if (nil? a) x a) b c))\n     ([a b c & ds] (apply f (if (nil? a) x a) b c ds))))\n  ([f x y]\n   (fn\n     ([a b] (f (if (nil? a) x a) (if (nil? b) y b)))\n     ([a b c] (f (if (nil? a) x a) (if (nil? b) y b) c))\n     ([a b c & ds] (apply f (if (nil? a) x a) (if (nil? b) y b) c ds))))\n  ([f x y z]\n   (fn\n     ([a b] (f (if (nil? a) x a) (if (nil? b) y b)))\n     ([a b c] (f (if (nil? a) x a) (if (nil? b) y b) (if (nil? c) z c)))\n     ([a b c & ds] (apply f (if (nil? a) x a) (if (nil? b) y b) (if (nil? c) z c) ds)))))\n\n\n;;;;;;; case ;;;;;;;;;;;;;\n(defn- shift-mask [shift mask x]\n  (-> x (bit-shift-right shift) (bit-and mask)))\n\n(def ^:private max-mask-bits 13)\n(def ^:private max-switch-table-size (bit-shift-left 1 max-mask-bits))\n\n(defn- maybe-min-hash\n  \"takes a collection of hashes and returns [shift mask] or nil if none found\"\n  [hashes]\n  (first\n    (filter (fn [[s m]]\n              (apply distinct? (map #(shift-mask s m %) hashes)))\n            (for [mask (map #(dec (bit-shift-left 1 %)) (range 1 (inc max-mask-bits)))\n                  shift (range 0 31)]\n              [shift mask]))))\n\n(defn- case-map\n  \"Transforms a sequence of test constants and a corresponding sequence of then\n  expressions into a sorted map to be consumed by case*. The form of the map\n  entries are {(case-f test) [(test-f test) then]}.\"\n  [case-f test-f tests thens]\n  (into1 (sorted-map)\n    (zipmap (map case-f tests)\n            (map vector\n              (map test-f tests)\n              thens))))\n\n(defn- fits-table?\n  \"Returns true if the collection of ints can fit within the\n  max-table-switch-size, false otherwise.\"\n  [ints]\n  (< (- (apply max (seq ints)) (apply min (seq ints))) max-switch-table-size))\n\n(defn- prep-ints\n  \"Takes a sequence of int-sized test constants and a corresponding sequence of\n  then expressions. Returns a tuple of [shift mask case-map switch-type] where\n  case-map is a map of int case values to [test then] tuples, and switch-type\n  is either :sparse or :compact.\"\n  [tests thens]\n  (if (fits-table? tests)\n    ; compact case ints, no shift-mask\n    [0 0 (case-map int int tests thens) :compact]\n    (let [[shift mask] (or (maybe-min-hash (map int tests)) [0 0])]\n      (if (zero? mask)\n        ; sparse case ints, no shift-mask\n        [0 0 (case-map int int tests thens) :sparse]\n        ; compact case ints, with shift-mask\n        [shift mask (case-map #(shift-mask shift mask (int %)) int tests thens) :compact]))))\n\n(defn- merge-hash-collisions\n  \"Takes a case expression, default expression, and a sequence of test constants\n  and a corresponding sequence of then expressions. Returns a tuple of\n  [tests thens skip-check-set] where no tests have the same hash. Each set of\n  input test constants with the same hash is replaced with a single test\n  constant (the case int), and their respective thens are combined into:\n  (condp = expr\n    test-1 then-1\n    ...\n    test-n then-n\n    default).\n  The skip-check is a set of case ints for which post-switch equivalence\n  checking must not be done (the cases holding the above condp thens).\"\n  [expr-sym default tests thens]\n  (let [buckets (loop [m {} ks tests vs thens]\n                  (if (and ks vs)\n                    (recur\n                      (update m (clojure.lang.Util/hash (first ks)) (fnil conj []) [(first ks) (first vs)])\n                      (next ks) (next vs))\n                    m))\n        assoc-multi (fn [m h bucket]\n                      (let [testexprs (apply concat bucket)\n                            expr `(condp = ~expr-sym ~@testexprs ~default)]\n                        (assoc m h expr)))\n        hmap (reduce1\n               (fn [m [h bucket]]\n                 (if (== 1 (count bucket))\n                   (assoc m (ffirst bucket) (second (first bucket)))\n                   (assoc-multi m h bucket)))\n               {} buckets)\n        skip-check (->> buckets\n                     (filter #(< 1 (count (second %))))\n                     (map first)\n                     (into1 #{}))]\n    [(keys hmap) (vals hmap) skip-check]))\n\n(defn- prep-hashes\n  \"Takes a sequence of test constants and a corresponding sequence of then\n  expressions. Returns a tuple of [shift mask case-map switch-type skip-check]\n  where case-map is a map of int case values to [test then] tuples, switch-type\n  is either :sparse or :compact, and skip-check is a set of case ints for which\n  post-switch equivalence checking must not be done (occurs with hash\n  collisions).\"\n  [expr-sym default tests thens]\n  (let [hashcode #(clojure.lang.Util/hash %)\n        hashes (into1 #{} (map hashcode tests))]\n    (if (== (count tests) (count hashes))\n      (if (fits-table? hashes)\n        ; compact case ints, no shift-mask\n        [0 0 (case-map hashcode identity tests thens) :compact]\n        (let [[shift mask] (or (maybe-min-hash hashes) [0 0])]\n          (if (zero? mask)\n            ; sparse case ints, no shift-mask\n            [0 0 (case-map hashcode identity tests thens) :sparse]\n            ; compact case ints, with shift-mask\n            [shift mask (case-map #(shift-mask shift mask (hashcode %)) identity tests thens) :compact])))\n      ; resolve hash collisions and try again\n      (let [[tests thens skip-check] (merge-hash-collisions expr-sym default tests thens)\n            [shift mask case-map switch-type] (prep-hashes expr-sym default tests thens)\n            skip-check (if (zero? mask)\n                         skip-check\n                         (into1 #{} (map #(shift-mask shift mask %) skip-check)))]\n        [shift mask case-map switch-type skip-check]))))\n\n(defmacro case\n  \"Takes an expression, and a set of clauses.\n\n  Each clause can take the form of either:\n\n  test-constant result-expr\n\n  (test-constant1 ... test-constantN)  result-expr\n\n  The test-constants are not evaluated. They must be compile-time\n  literals, and need not be quoted.  If the expression is equal to a\n  test-constant, the corresponding result-expr is returned. A single\n  default expression can follow the clauses, and its value will be\n  returned if no clause matches. If no default expression is provided\n  and no clause matches, an IllegalArgumentException is thrown.\n\n  Unlike cond and condp, case does a constant-time dispatch, the\n  clauses are not considered sequentially.  All manner of constant\n  expressions are acceptable in case, including numbers, strings,\n  symbols, keywords, and (Clojure) composites thereof. Note that since\n  lists are used to group multiple constants that map to the same\n  expression, a vector can be used to match a list if needed. The\n  test-constants need not be all of the same type.\"\n  {:added \"1.2\"}\n\n  [e & clauses]\n  (let [ge (with-meta (gensym) {:tag Object})\n        default (if (odd? (count clauses))\n                  (last clauses)\n                  `(throw (IllegalArgumentException. (str \"No matching clause: \" ~ge))))]\n    (if (> 2 (count clauses))\n      `(let [~ge ~e] ~default)\n      (let [pairs (partition 2 clauses)\n            assoc-test (fn assoc-test [m test expr]\n                         (if (contains? m test)\n                           (throw (IllegalArgumentException. (str \"Duplicate case test constant: \" test)))\n                           (assoc m test expr)))\n            pairs (reduce1\n                       (fn [m [test expr]]\n                         (if (seq? test)\n                           (reduce1 #(assoc-test %1 %2 expr) m test)\n                           (assoc-test m test expr)))\n                       {} pairs)\n            tests (keys pairs)\n            thens (vals pairs)\n            mode (cond\n                   (every? #(and (integer? %) (<= Integer/MIN_VALUE % Integer/MAX_VALUE)) tests)\n                   :ints\n                   (every? keyword? tests)\n                   :identity\n                   :else :hashes)]\n        (condp = mode\n          :ints\n          (let [[shift mask imap switch-type] (prep-ints tests thens)]\n            `(let [~ge ~e] (case* ~ge ~shift ~mask ~default ~imap ~switch-type :int)))\n          :hashes\n          (let [[shift mask imap switch-type skip-check] (prep-hashes ge default tests thens)]\n            `(let [~ge ~e] (case* ~ge ~shift ~mask ~default ~imap ~switch-type :hash-equiv ~skip-check)))\n          :identity\n          (let [[shift mask imap switch-type skip-check] (prep-hashes ge default tests thens)]\n            `(let [~ge ~e] (case* ~ge ~shift ~mask ~default ~imap ~switch-type :hash-identity ~skip-check))))))))\n\n;; redefine reduce with internal-reduce\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; helper files ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(alter-meta! (find-ns 'clojure.core) assoc :doc \"Fundamental library of the Clojure language\")\n(load \"core_proxy\")\n(load \"core_print\")\n(load \"genclass\")\n(load \"core_deftype\")\n(load \"core/protocols\")\n(load \"gvec\")\n(load \"instant\")\n(load \"uuid\")\n\n(defn reduce\n  \"f should be a function of 2 arguments. If val is not supplied,\n  returns the result of applying f to the first 2 items in coll, then\n  applying f to that result and the 3rd item, etc. If coll contains no\n  items, f must accept no arguments as well, and reduce returns the\n  result of calling f with no arguments.  If coll has only 1 item, it\n  is returned and f is not called.  If val is supplied, returns the\n  result of applying f to val and the first item in coll, then\n  applying f to that result and the 2nd item, etc. If coll contains no\n  items, returns val and f is not called.\"\n  {:added \"1.0\"}\n  ([f coll]\n     (if (instance? clojure.lang.IReduce coll)\n       (.reduce ^clojure.lang.IReduce coll f)\n       (clojure.core.protocols/coll-reduce coll f)))\n  ([f val coll]\n     (if (instance? clojure.lang.IReduceInit coll)\n       (.reduce ^clojure.lang.IReduceInit coll f val)\n       (clojure.core.protocols/coll-reduce coll f val))))\n\n(extend-protocol clojure.core.protocols/IKVReduce\n nil\n (kv-reduce\n  [_ f init]\n  init)\n\n ;;slow path default\n clojure.lang.IPersistentMap\n (kv-reduce\n  [amap f init]\n  (reduce (fn [ret [k v]] (f ret k v)) init amap))\n\n clojure.lang.PersistentHashMap\n (kv-reduce\n  [amap f init]\n  (.kvreduce amap f init))\n\n clojure.lang.PersistentArrayMap\n (kv-reduce\n  [amap f init]\n  (.kvreduce amap f init))\n\n clojure.lang.PersistentTreeMap\n (kv-reduce\n  [amap f init]\n  (.kvreduce amap f init))\n\n clojure.lang.PersistentVector\n (kv-reduce\n  [vec f init]\n  (.kvreduce vec f init)))\n\n(defn reduce-kv\n  \"Reduces an associative collection. f should be a function of 3\n  arguments. Returns the result of applying f to init, the first key\n  and the first value in coll, then applying f to that result and the\n  2nd key and value, etc. If coll contains no entries, returns init\n  and f is not called. Note that reduce-kv is supported on vectors,\n  where the keys will be the ordinals.\"\n  {:added \"1.4\"}\n  ([f init coll]\n     (clojure.core.protocols/kv-reduce coll f init)))\n\n(defn completing\n  \"Takes a reducing function f of 2 args and returns a fn suitable for\n  transduce by adding an arity-1 signature that calls cf (default -\n  identity) on the result argument.\"\n  {:added \"1.7\"}\n  ([f] (completing f identity))\n  ([f cf]\n     (fn\n       ([] (f))\n       ([x] (cf x))\n       ([x y] (f x y)))))\n\n(defn transduce\n  \"reduce with a transformation of f (xf). If init is not\n  supplied, (f) will be called to produce it. f should be a reducing\n  step function that accepts both 1 and 2 arguments, if it accepts\n  only 2 you can add the arity-1 with 'completing'. Returns the result\n  of applying (the transformed) xf to init and the first item in coll,\n  then applying xf to that result and the 2nd item, etc. If coll\n  contains no items, returns init and f is not called. Note that\n  certain transforms may inject or skip items.\"  {:added \"1.7\"}\n  ([xform f coll] (transduce xform f (f) coll))\n  ([xform f init coll]\n     (let [f (xform f)\n           ret (if (instance? clojure.lang.IReduceInit coll)\n                 (.reduce ^clojure.lang.IReduceInit coll f init)\n                 (clojure.core.protocols/coll-reduce coll f init))]\n       (f ret))))\n\n(defn into\n  \"Returns a new coll consisting of to-coll with all of the items of\n  from-coll conjoined. A transducer may be supplied.\"\n  {:added \"1.0\"\n   :static true}\n  ([to from]\n     (if (instance? clojure.lang.IEditableCollection to)\n       (with-meta (persistent! (reduce conj! (transient to) from)) (meta to))\n       (reduce conj to from)))\n  ([to xform from]\n     (if (instance? clojure.lang.IEditableCollection to)\n       (with-meta (persistent! (transduce xform conj! (transient to) from)) (meta to))\n       (transduce xform conj to from))))\n\n(defn mapv\n  \"Returns a vector consisting of the result of applying f to the\n  set of first items of each coll, followed by applying f to the set\n  of second items in each coll, until any one of the colls is\n  exhausted.  Any remaining items in other colls are ignored. Function\n  f should accept number-of-colls arguments.\"\n  {:added \"1.4\"\n   :static true}\n  ([f coll]\n     (-> (reduce (fn [v o] (conj! v (f o))) (transient []) coll)\n         persistent!))\n  ([f c1 c2]\n     (into [] (map f c1 c2)))\n  ([f c1 c2 c3]\n     (into [] (map f c1 c2 c3)))\n  ([f c1 c2 c3 & colls]\n     (into [] (apply map f c1 c2 c3 colls))))\n\n(defn filterv\n  \"Returns a vector of the items in coll for which\n  (pred item) returns true. pred must be free of side-effects.\"\n  {:added \"1.4\"\n   :static true}\n  [pred coll]\n  (-> (reduce (fn [v o] (if (pred o) (conj! v o) v))\n              (transient [])\n              coll)\n      persistent!))\n\n(load \"java/io\")\n\n(defn- normalize-slurp-opts\n  [opts]\n  (if (string? (first opts))\n    (do\n      (println \"WARNING: (slurp f enc) is deprecated, use (slurp f :encoding enc).\")\n      [:encoding (first opts)])\n    opts))\n\n(defn slurp\n  \"Opens a reader on f and reads all its contents, returning a string.\n  See clojure.java.io/reader for a complete list of supported arguments.\"\n  {:added \"1.0\"}\n  ([f & opts]\n     (let [opts (normalize-slurp-opts opts)\n           sb (StringBuilder.)]\n       (with-open [^java.io.Reader r (apply clojure.java.io/reader f opts)]\n         (loop [c (.read r)]\n           (if (neg? c)\n             (str sb)\n             (do\n               (.append sb (char c))\n               (recur (.read r)))))))))\n\n(defn spit\n  \"Opposite of slurp.  Opens f with writer, writes content, then\n  closes f. Options passed to clojure.java.io/writer.\"\n  {:added \"1.2\"}\n  [f content & options]\n  (with-open [^java.io.Writer w (apply clojure.java.io/writer f options)]\n    (.write w (str content))))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; futures (needs proxy);;;;;;;;;;;;;;;;;;\n(defn future-call\n  \"Takes a function of no args and yields a future object that will\n  invoke the function in another thread, and will cache the result and\n  return it on all subsequent calls to deref/@. If the computation has\n  not yet finished, calls to deref/@ will block, unless the variant\n  of deref with timeout is used. See also - realized?.\"\n  {:added \"1.1\"\n   :static true}\n  [f]\n  (let [f (binding-conveyor-fn f)\n        fut (.submit clojure.lang.Agent/soloExecutor ^Callable f)]\n    (reify\n     clojure.lang.IDeref\n     (deref [_] (deref-future fut))\n     clojure.lang.IBlockingDeref\n     (deref\n      [_ timeout-ms timeout-val]\n      (deref-future fut timeout-ms timeout-val))\n     clojure.lang.IPending\n     (isRealized [_] (.isDone fut))\n     java.util.concurrent.Future\n      (get [_] (.get fut))\n      (get [_ timeout unit] (.get fut timeout unit))\n      (isCancelled [_] (.isCancelled fut))\n      (isDone [_] (.isDone fut))\n      (cancel [_ interrupt?] (.cancel fut interrupt?)))))\n\n(defmacro future\n  \"Takes a body of expressions and yields a future object that will\n  invoke the body in another thread, and will cache the result and\n  return it on all subsequent calls to deref/@. If the computation has\n  not yet finished, calls to deref/@ will block, unless the variant of\n  deref with timeout is used. See also - realized?.\"\n  {:added \"1.1\"}\n  [& body] `(future-call (^{:once true} fn* [] ~@body)))\n\n\n(defn future-cancel\n  \"Cancels the future, if possible.\"\n  {:added \"1.1\"\n   :static true}\n  [^java.util.concurrent.Future f] (.cancel f true))\n\n(defn future-cancelled?\n  \"Returns true if future f is cancelled\"\n  {:added \"1.1\"\n   :static true}\n  [^java.util.concurrent.Future f] (.isCancelled f))\n\n(defn pmap\n  \"Like map, except f is applied in parallel. Semi-lazy in that the\n  parallel computation stays ahead of the consumption, but doesn't\n  realize the entire result unless required. Only useful for\n  computationally intensive functions where the time of f dominates\n  the coordination overhead.\"\n  {:added \"1.0\"\n   :static true}\n  ([f coll]\n   (let [n (+ 2 (.. Runtime getRuntime availableProcessors))\n         rets (map #(future (f %)) coll)\n         step (fn step [[x & xs :as vs] fs]\n                (lazy-seq\n                 (if-let [s (seq fs)]\n                   (cons (deref x) (step xs (rest s)))\n                   (map deref vs))))]\n     (step rets (drop n rets))))\n  ([f coll & colls]\n   (let [step (fn step [cs]\n                (lazy-seq\n                 (let [ss (map seq cs)]\n                   (when (every? identity ss)\n                     (cons (map first ss) (step (map rest ss)))))))]\n     (pmap #(apply f %) (step (cons coll colls))))))\n\n(defn pcalls\n  \"Executes the no-arg fns in parallel, returning a lazy sequence of\n  their values\"\n  {:added \"1.0\"\n   :static true}\n  [& fns] (pmap #(%) fns))\n\n(defmacro pvalues\n  \"Returns a lazy sequence of the values of the exprs, which are\n  evaluated in parallel\"\n  {:added \"1.0\"\n   :static true}\n  [& exprs]\n  `(pcalls ~@(map #(list `fn [] %) exprs)))\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; clojure version number ;;;;;;;;;;;;;;;;;;;;;;\n\n;(let [properties (with-open [version-stream (.getResourceAsStream\n;                                             (ClassLoader/getSystemClassLoader)\n;                                             \"clojure/version.properties\")]\n;                   (doto (new java.util.Properties)\n;                     (.load version-stream)))\n;      version-string (.getProperty properties \"version\")\n;      [_ major minor incremental qualifier snapshot]\n;      (re-matches\n;       #\"(\\d+)\\.(\\d+)\\.(\\d+)(?:-([a-zA-Z0-9_]+))?(?:-(SNAPSHOT))?\"\n;       version-string)\n;      clojure-version {:major       (Integer/valueOf ^String major)\n;                       :minor       (Integer/valueOf ^String minor)\n;                       :incremental (Integer/valueOf ^String incremental)\n;                       :qualifier   (if (= qualifier \"SNAPSHOT\") nil qualifier)}]\n;  (def ^:dynamic *clojure-version*\n;    (if (.contains version-string \"SNAPSHOT\")\n;      (clojure.lang.RT/assoc clojure-version :interim true)\n;      clojure-version)))\n\n(def ^:dynamic *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil})\n\n;(add-doc-and-meta *clojure-version*\n;  \"The version info for Clojure core, as a map containing :major :minor\n;  :incremental and :qualifier keys. Feature releases may increment\n;  :minor and/or :major, bugfix releases will increment :incremental.\n;  Possible values of :qualifier include \\\"GA\\\", \\\"SNAPSHOT\\\", \\\"RC-x\\\" \\\"BETA-x\\\"\"\n;  {:added \"1.0\"})\n\n(defn\n  clojure-version\n  \"Returns clojure version as a printable string.\"\n  {:added \"1.0\"}\n  []\n  (str (:major *clojure-version*)\n       \".\"\n       (:minor *clojure-version*)\n       (when-let [i (:incremental *clojure-version*)]\n         (str \".\" i))\n       (when-let [q (:qualifier *clojure-version*)]\n         (when (pos? (count q)) (str \"-\" q)))\n       (when (:interim *clojure-version*)\n         \"-SNAPSHOT\")))\n\n(defn promise\n  \"Returns a promise object that can be read with deref/@, and set,\n  once only, with deliver. Calls to deref/@ prior to delivery will\n  block, unless the variant of deref with timeout is used. All\n  subsequent derefs will return the same delivered value without\n  blocking. See also - realized?.\"\n  {:added \"1.1\"\n   :static true}\n  []\n  (let [d (java.util.concurrent.CountDownLatch. 1)\n        v (atom d)]\n    (reify\n     clojure.lang.IDeref\n       (deref [_] (.await d) @v)\n     clojure.lang.IBlockingDeref\n       (deref\n        [_ timeout-ms timeout-val]\n        (if (.await d timeout-ms java.util.concurrent.TimeUnit/MILLISECONDS)\n          @v\n          timeout-val))\n     clojure.lang.IPending\n      (isRealized [this]\n       (zero? (.getCount d)))\n     clojure.lang.IFn\n     (invoke\n      [this x]\n      (when (and (pos? (.getCount d))\n                 (compare-and-set! v d x))\n        (.countDown d)\n        this)))))\n\n(defn deliver\n  \"Delivers the supplied value to the promise, releasing any pending\n  derefs. A subsequent call to deliver on a promise will have no effect.\"\n  {:added \"1.1\"\n   :static true}\n  [promise val] (promise val))\n\n\n\n(defn flatten\n  \"Takes any nested combination of sequential things (lists, vectors,\n  etc.) and returns their contents as a single, flat sequence.\n  (flatten nil) returns an empty sequence.\"\n  {:added \"1.2\"\n   :static true}\n  [x]\n  (filter (complement sequential?)\n          (rest (tree-seq sequential? seq x))))\n\n(defn group-by\n  \"Returns a map of the elements of coll keyed by the result of\n  f on each element. The value at each key will be a vector of the\n  corresponding elements, in the order they appeared in coll.\"\n  {:added \"1.2\"\n   :static true}\n  [f coll]\n  (persistent!\n   (reduce\n    (fn [ret x]\n      (let [k (f x)]\n        (assoc! ret k (conj (get ret k []) x))))\n    (transient {}) coll)))\n\n(defn partition-by\n  \"Applies f to each value in coll, splitting it each time f returns a\n   new value.  Returns a lazy seq of partitions.  Returns a stateful\n   transducer when no collection is provided.\"\n  {:added \"1.2\"\n   :static true}\n  ([f]\n  (fn [rf]\n    (let [a (java.util.ArrayList.)\n          pv (volatile! ::none)]\n      (fn\n        ([] (rf))\n        ([result]\n           (let [result (if (.isEmpty a)\n                          result\n                          (let [v (vec (.toArray a))]\n                            ;;clear first!\n                            (.clear a)\n                            (unreduced (rf result v))))]\n             (rf result)))\n        ([result input]\n           (let [pval @pv\n                 val (f input)]\n             (vreset! pv val)\n             (if (or (identical? pval ::none)\n                     (= val pval))\n               (do\n                 (.add a input)\n                 result)\n               (let [v (vec (.toArray a))]\n                 (.clear a)\n                 (let [ret (rf result v)]\n                   (when-not (reduced? ret)\n                     (.add a input))\n                   ret)))))))))\n  ([f coll]\n     (lazy-seq\n      (when-let [s (seq coll)]\n        (let [fst (first s)\n              fv (f fst)\n              run (cons fst (take-while #(= fv (f %)) (next s)))]\n          (cons run (partition-by f (seq (drop (count run) s)))))))))\n\n(defn frequencies\n  \"Returns a map from distinct items in coll to the number of times\n  they appear.\"\n  {:added \"1.2\"\n   :static true}\n  [coll]\n  (persistent!\n   (reduce (fn [counts x]\n             (assoc! counts x (inc (get counts x 0))))\n           (transient {}) coll)))\n\n(defn reductions\n  \"Returns a lazy seq of the intermediate values of the reduction (as\n  per reduce) of coll by f, starting with init.\"\n  {:added \"1.2\"}\n  ([f coll]\n     (lazy-seq\n      (if-let [s (seq coll)]\n        (reductions f (first s) (rest s))\n        (list (f)))))\n  ([f init coll]\n     (if (reduced? init)\n       (list @init)\n       (cons init\n             (lazy-seq\n              (when-let [s (seq coll)]\n                (reductions f (f init (first s)) (rest s))))))))\n\n(defn rand-nth\n  \"Return a random element of the (sequential) collection. Will have\n  the same performance characteristics as nth for the given\n  collection.\"\n  {:added \"1.2\"\n   :static true}\n  [coll]\n  (nth coll (rand-int (count coll))))\n\n(defn partition-all\n  \"Returns a lazy sequence of lists like partition, but may include\n  partitions with fewer than n items at the end.  Returns a stateful\n  transducer when no collection is provided.\"\n  {:added \"1.2\"\n   :static true}\n  ([^long n]\n   (fn [rf]\n     (let [a (java.util.ArrayList. n)]\n       (fn\n         ([] (rf))\n         ([result]\n            (let [result (if (.isEmpty a)\n                           result\n                           (let [v (vec (.toArray a))]\n                             ;;clear first!\n                             (.clear a)\n                             (unreduced (rf result v))))]\n              (rf result)))\n         ([result input]\n            (.add a input)\n            (if (= n (.size a))\n              (let [v (vec (.toArray a))]\n                (.clear a)\n                (rf result v))\n              result))))))\n  ([n coll]\n     (partition-all n n coll))\n  ([n step coll]\n     (lazy-seq\n      (when-let [s (seq coll)]\n        (let [seg (doall (take n s))]\n          (cons seg (partition-all n step (nthrest s step))))))))\n\n(defn shuffle\n  \"Return a random permutation of coll\"\n  {:added \"1.2\"\n   :static true}\n  [^java.util.Collection coll]\n  (let [al (java.util.ArrayList. coll)]\n    (java.util.Collections/shuffle al)\n    (clojure.lang.RT/vector (.toArray al))))\n\n(defn map-indexed\n  \"Returns a lazy sequence consisting of the result of applying f to 0\n  and the first item of coll, followed by applying f to 1 and the second\n  item in coll, etc, until coll is exhausted. Thus function f should\n  accept 2 arguments, index and item. Returns a stateful transducer when\n  no collection is provided.\"\n  {:added \"1.2\"\n   :static true}\n  ([f]\n   (fn [rf]\n     (let [i (volatile! -1)]\n       (fn\n         ([] (rf))\n         ([result] (rf result))\n         ([result input]\n          (rf result (f (vswap! i inc) input)))))))\n  ([f coll]\n   (letfn [(mapi [idx coll]\n                 (lazy-seq\n                   (when-let [s (seq coll)]\n                     (if (chunked-seq? s)\n                       (let [c (chunk-first s)\n                             size (int (count c))\n                             b (chunk-buffer size)]\n                         (dotimes [i size]\n                           (chunk-append b (f (+ idx i) (.nth c i))))\n                         (chunk-cons (chunk b) (mapi (+ idx size) (chunk-rest s))))\n                       (cons (f idx (first s)) (mapi (inc idx) (rest s)))))))]\n     (mapi 0 coll))))\n\n(defn keep\n  \"Returns a lazy sequence of the non-nil results of (f item). Note,\n  this means false return values will be included.  f must be free of\n  side-effects.  Returns a transducer when no collection is provided.\"\n  {:added \"1.2\"\n   :static true}\n  ([f]\n   (fn [rf]\n     (fn\n       ([] (rf))\n       ([result] (rf result))\n       ([result input]\n          (let [v (f input)]\n            (if (nil? v)\n              result\n              (rf result v)))))))\n  ([f coll]\n   (lazy-seq\n    (when-let [s (seq coll)]\n      (if (chunked-seq? s)\n        (let [c (chunk-first s)\n              size (count c)\n              b (chunk-buffer size)]\n          (dotimes [i size]\n            (let [x (f (.nth c i))]\n              (when-not (nil? x)\n                (chunk-append b x))))\n          (chunk-cons (chunk b) (keep f (chunk-rest s))))\n        (let [x (f (first s))]\n          (if (nil? x)\n            (keep f (rest s))\n            (cons x (keep f (rest s))))))))))\n\n(defn keep-indexed\n  \"Returns a lazy sequence of the non-nil results of (f index item). Note,\n  this means false return values will be included.  f must be free of\n  side-effects.  Returns a stateful transducer when no collection is\n  provided.\"\n  {:added \"1.2\"\n   :static true}\n  ([f]\n   (fn [rf]\n     (let [iv (volatile! -1)]\n       (fn\n         ([] (rf))\n         ([result] (rf result))\n         ([result input]\n            (let [i (vswap! iv inc)\n                  v (f i input)]\n              (if (nil? v)\n                result\n                (rf result v))))))))\n  ([f coll]\n     (letfn [(keepi [idx coll]\n               (lazy-seq\n                (when-let [s (seq coll)]\n                  (if (chunked-seq? s)\n                    (let [c (chunk-first s)\n                          size (count c)\n                          b (chunk-buffer size)]\n                      (dotimes [i size]\n                        (let [x (f (+ idx i) (.nth c i))]\n                          (when-not (nil? x)\n                            (chunk-append b x))))\n                      (chunk-cons (chunk b) (keepi (+ idx size) (chunk-rest s))))\n                    (let [x (f idx (first s))]\n                      (if (nil? x)\n                        (keepi (inc idx) (rest s))\n                        (cons x (keepi (inc idx) (rest s)))))))))]\n       (keepi 0 coll))))\n\n(defn every-pred\n  \"Takes a set of predicates and returns a function f that returns true if all of its\n  composing predicates return a logical true value against all of its arguments, else it returns\n  false. Note that f is short-circuiting in that it will stop execution on the first\n  argument that triggers a logical false result against the original predicates.\"\n  {:added \"1.3\"}\n  ([p]\n     (fn ep1\n       ([] true)\n       ([x] (boolean (p x)))\n       ([x y] (boolean (and (p x) (p y))))\n       ([x y z] (boolean (and (p x) (p y) (p z))))\n       ([x y z & args] (boolean (and (ep1 x y z)\n                                     (every? p args))))))\n  ([p1 p2]\n     (fn ep2\n       ([] true)\n       ([x] (boolean (and (p1 x) (p2 x))))\n       ([x y] (boolean (and (p1 x) (p1 y) (p2 x) (p2 y))))\n       ([x y z] (boolean (and (p1 x) (p1 y) (p1 z) (p2 x) (p2 y) (p2 z))))\n       ([x y z & args] (boolean (and (ep2 x y z)\n                                     (every? #(and (p1 %) (p2 %)) args))))))\n  ([p1 p2 p3]\n     (fn ep3\n       ([] true)\n       ([x] (boolean (and (p1 x) (p2 x) (p3 x))))\n       ([x y] (boolean (and (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y))))\n       ([x y z] (boolean (and (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y) (p1 z) (p2 z) (p3 z))))\n       ([x y z & args] (boolean (and (ep3 x y z)\n                                     (every? #(and (p1 %) (p2 %) (p3 %)) args))))))\n  ([p1 p2 p3 & ps]\n     (let [ps (list* p1 p2 p3 ps)]\n       (fn epn\n         ([] true)\n         ([x] (every? #(% x) ps))\n         ([x y] (every? #(and (% x) (% y)) ps))\n         ([x y z] (every? #(and (% x) (% y) (% z)) ps))\n         ([x y z & args] (boolean (and (epn x y z)\n                                       (every? #(every? % args) ps))))))))\n\n(defn some-fn\n  \"Takes a set of predicates and returns a function f that returns the first logical true value\n  returned by one of its composing predicates against any of its arguments, else it returns\n  logical false. Note that f is short-circuiting in that it will stop execution on the first\n  argument that triggers a logical true result against the original predicates.\"\n  {:added \"1.3\"}\n  ([p]\n     (fn sp1\n       ([] nil)\n       ([x] (p x))\n       ([x y] (or (p x) (p y)))\n       ([x y z] (or (p x) (p y) (p z)))\n       ([x y z & args] (or (sp1 x y z)\n                           (some p args)))))\n  ([p1 p2]\n     (fn sp2\n       ([] nil)\n       ([x] (or (p1 x) (p2 x)))\n       ([x y] (or (p1 x) (p1 y) (p2 x) (p2 y)))\n       ([x y z] (or (p1 x) (p1 y) (p1 z) (p2 x) (p2 y) (p2 z)))\n       ([x y z & args] (or (sp2 x y z)\n                           (some #(or (p1 %) (p2 %)) args)))))\n  ([p1 p2 p3]\n     (fn sp3\n       ([] nil)\n       ([x] (or (p1 x) (p2 x) (p3 x)))\n       ([x y] (or (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y)))\n       ([x y z] (or (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y) (p1 z) (p2 z) (p3 z)))\n       ([x y z & args] (or (sp3 x y z)\n                           (some #(or (p1 %) (p2 %) (p3 %)) args)))))\n  ([p1 p2 p3 & ps]\n     (let [ps (list* p1 p2 p3 ps)]\n       (fn spn\n         ([] nil)\n         ([x] (some #(% x) ps))\n         ([x y] (some #(or (% x) (% y)) ps))\n         ([x y z] (some #(or (% x) (% y) (% z)) ps))\n         ([x y z & args] (or (spn x y z)\n                             (some #(some % args) ps)))))))\n\n(defn- ^{:dynamic true} assert-valid-fdecl\n  \"A good fdecl looks like (([a] ...) ([a b] ...)) near the end of defn.\"\n  [fdecl]\n  (when (empty? fdecl) (throw (IllegalArgumentException.\n                                \"Parameter declaration missing\")))\n  (let [argdecls (map\n                   #(if (seq? %)\n                      (first %)\n                      (throw (IllegalArgumentException.\n                              ^String\n                        (if (seq? (first fdecl))\n                          (str \"Invalid signature \\\"\"\n                               %\n                               \"\\\" should be a list\")\n                          (str \"Parameter declaration \\\"\"\n                               %\n                               \"\\\" should be a vector\")))))\n                   fdecl)\n        bad-args (seq (remove #(vector? %) argdecls))]\n    (when bad-args\n      (throw (IllegalArgumentException. (str \"Parameter declaration \\\"\" (first bad-args) \n                                             \"\\\" should be a vector\"))))))\n\n(defn with-redefs-fn\n  \"Temporarily redefines Vars during a call to func.  Each val of\n  binding-map will replace the root value of its key which must be\n  a Var.  After func is called with no args, the root values of all\n  the Vars will be set back to their old values.  These temporary\n  changes will be visible in all threads.  Useful for mocking out\n  functions during testing.\"\n  {:added \"1.3\"}\n  [binding-map func]\n  (let [root-bind (fn [m]\n                    (doseq [[a-var a-val] m]\n                      (.bindRoot ^clojure.lang.Var a-var a-val)))\n        old-vals (zipmap (keys binding-map)\n                         (map #(.getRawRoot ^clojure.lang.Var %) (keys binding-map)))]\n    (try\n      (root-bind binding-map)\n      (func)\n      (finally\n        (root-bind old-vals)))))\n\n(defmacro with-redefs\n  \"binding => var-symbol temp-value-expr\n\n  Temporarily redefines Vars while executing the body.  The\n  temp-value-exprs will be evaluated and each resulting value will\n  replace in parallel the root value of its Var.  After the body is\n  executed, the root values of all the Vars will be set back to their\n  old values.  These temporary changes will be visible in all threads.\n  Useful for mocking out functions during testing.\"\n  {:added \"1.3\"}\n  [bindings & body]\n  `(with-redefs-fn ~(zipmap (map #(list `var %) (take-nth 2 bindings))\n                            (take-nth 2 (next bindings)))\n                    (fn [] ~@body)))\n\n(defn realized?\n  \"Returns true if a value has been produced for a promise, delay, future or lazy sequence.\"\n  {:added \"1.3\"}\n  [^clojure.lang.IPending x] (.isRealized x))\n\n(defmacro cond->\n  \"Takes an expression and a set of test/form pairs. Threads expr (via ->)\n  through each form for which the corresponding test\n  expression is true. Note that, unlike cond branching, cond-> threading does\n  not short circuit after the first true test expression.\"\n  {:added \"1.5\"}\n  [expr & clauses]\n  (assert (even? (count clauses)))\n  (let [g (gensym)\n        pstep (fn [[test step]] `(if ~test (-> ~g ~step) ~g))]\n    `(let [~g ~expr\n           ~@(interleave (repeat g) (map pstep (partition 2 clauses)))]\n       ~g)))\n\n(defmacro cond->>\n  \"Takes an expression and a set of test/form pairs. Threads expr (via ->>)\n  through each form for which the corresponding test expression\n  is true.  Note that, unlike cond branching, cond->> threading does not short circuit\n  after the first true test expression.\"\n  {:added \"1.5\"}\n  [expr & clauses]\n  (assert (even? (count clauses)))\n  (let [g (gensym)\n        pstep (fn [[test step]] `(if ~test (->> ~g ~step) ~g))]\n    `(let [~g ~expr\n           ~@(interleave (repeat g) (map pstep (partition 2 clauses)))]\n       ~g)))\n\n(defmacro as->\n  \"Binds name to expr, evaluates the first form in the lexical context\n  of that binding, then binds name to that result, repeating for each\n  successive form, returning the result of the last form.\"\n  {:added \"1.5\"}\n  [expr name & forms]\n  `(let [~name ~expr\n         ~@(interleave (repeat name) forms)]\n     ~name))\n\n(defmacro some->\n  \"When expr is not nil, threads it into the first form (via ->),\n  and when that result is not nil, through the next etc\"\n  {:added \"1.5\"}\n  [expr & forms]\n  (let [g (gensym)\n        pstep (fn [step] `(if (nil? ~g) nil (-> ~g ~step)))]\n    `(let [~g ~expr\n           ~@(interleave (repeat g) (map pstep forms))]\n       ~g)))\n\n(defmacro some->>\n  \"When expr is not nil, threads it into the first form (via ->>),\n  and when that result is not nil, through the next etc\"\n  {:added \"1.5\"}\n  [expr & forms]\n  (let [g (gensym)\n        pstep (fn [step] `(if (nil? ~g) nil (->> ~g ~step)))]\n    `(let [~g ~expr\n           ~@(interleave (repeat g) (map pstep forms))]\n       ~g)))\n\n(defn ^:private preserving-reduced\n  [rf]\n  #(let [ret (rf %1 %2)]\n     (if (reduced? ret)\n       (reduced ret)\n       ret)))\n\n(defn cat\n  \"A transducer which concatenates the contents of each input, which must be a\n  collection, into the reduction.\"\n  {:added \"1.7\"}\n  [rf]\n  (let [rrf (preserving-reduced rf)]  \n    (fn\n      ([] (rf))\n      ([result] (rf result))\n      ([result input]\n         (reduce rrf result input)))))\n\n(defn dedupe\n  \"Returns a lazy sequence removing consecutive duplicates in coll.\n  Returns a transducer when no collection is provided.\"\n  {:added \"1.7\"}\n  ([]\n   (fn [rf]\n     (let [pv (volatile! ::none)]\n       (fn\n         ([] (rf))\n         ([result] (rf result))\n         ([result input]\n            (let [prior @pv]\n              (vreset! pv input)\n              (if (= prior input)\n                result\n                (rf result input))))))))\n  ([coll] (sequence (dedupe) coll)))\n\n(defn random-sample\n  \"Returns items from coll with random probability of prob (0.0 -\n  1.0).  Returns a transducer when no collection is provided.\"\n  {:added \"1.7\"}\n  ([prob]\n     (filter (fn [_] (< (rand) prob))))\n  ([prob coll]\n     (filter (fn [_] (< (rand) prob)) coll)))\n\n(deftype Eduction [xform coll]\n   Iterable\n   (iterator [_]\n     (clojure.lang.TransformerIterator/create xform (clojure.lang.RT/iter coll)))\n\n   clojure.lang.IReduceInit\n   (reduce [_ f init]\n     ;; NB (completing f) isolates completion of inner rf from outer rf\n     (transduce xform (completing f) init coll))\n\n   clojure.lang.Sequential)\n\n(defn eduction\n  \"Returns a reducible/iterable application of the transducers\n  to the items in coll. Transducers are applied in order as if\n  combined with comp. Note that these applications will be\n  performed every time reduce/iterator is called.\"\n  {:arglists '([xform* coll])\n   :added \"1.7\"}\n  [& xforms]\n  (Eduction. (apply comp (butlast xforms)) (last xforms)))\n\n(defmethod print-method Eduction [c, ^Writer w]\n  (if *print-readably*\n    (do\n      (print-sequential \"(\" pr-on \" \" \")\" c w))\n    (print-object c w)))\n\n(defn run!\n  \"Runs the supplied procedure (via reduce), for purposes of side\n  effects, on successive items in the collection. Returns nil\"\n  {:added \"1.7\"}\n  [proc coll]\n  (reduce #(proc %2) nil coll))\n\n\n(defn tagged-literal?\n  \"Return true if the value is the data representation of a tagged literal\"\n  {:added \"1.7\"}\n  [value]\n  (instance? clojure.lang.TaggedLiteral value))\n\n(defn tagged-literal\n  \"Construct a data representation of a tagged literal from a\n  tag symbol and a form.\"\n  {:added \"1.7\"}\n  [^clojure.lang.Symbol tag form]\n  (clojure.lang.TaggedLiteral/create tag form))\n\n(defn reader-conditional?\n  \"Return true if the value is the data representation of a reader conditional\"\n  {:added \"1.7\"}\n  [value]\n  (instance? clojure.lang.ReaderConditional value))\n\n(defn reader-conditional\n  \"Construct a data representation of a reader conditional.\n  If true, splicing? indicates read-cond-splicing.\"\n  {:added \"1.7\"}\n  [form ^Boolean splicing?]\n  (clojure.lang.ReaderConditional/create form splicing?))\n\n\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; data readers ;;;;;;;;;;;;;;;;;;\n\n(def ^{:added \"1.4\"} default-data-readers\n  \"Default map of data reader functions provided by Clojure. May be\n  overridden by binding *data-readers*.\"\n  {'inst #'clojure.instant/read-instant-date\n   'uuid #'clojure.uuid/default-uuid-reader})\n\n(def ^{:added \"1.4\" :dynamic true} *data-readers*\n  \"Map from reader tag symbols to data reader Vars.\n\n  When Clojure starts, it searches for files named 'data_readers.clj'\n  at the root of the classpath. Each such file must contain a literal\n  map of symbols, like this:\n\n      {foo/bar my.project.foo/bar\n       foo/baz my.project/baz}\n\n  The first symbol in each pair is a tag that will be recognized by\n  the Clojure reader. The second symbol in the pair is the\n  fully-qualified name of a Var which will be invoked by the reader to\n  parse the form following the tag. For example, given the\n  data_readers.clj file above, the Clojure reader would parse this\n  form:\n\n      #foo/bar [1 2 3]\n\n  by invoking the Var #'my.project.foo/bar on the vector [1 2 3]. The\n  data reader function is invoked on the form AFTER it has been read\n  as a normal Clojure data structure by the reader.\n\n  Reader tags without namespace qualifiers are reserved for\n  Clojure. Default reader tags are defined in\n  clojure.core/default-data-readers but may be overridden in\n  data_readers.clj or by rebinding this Var.\"\n  {})\n\n(def ^{:added \"1.5\" :dynamic true} *default-data-reader-fn*\n  \"When no data reader is found for a tag and *default-data-reader-fn*\n  is non-nil, it will be called with two arguments,\n  the tag and the value.  If *default-data-reader-fn* is nil (the\n  default), an exception will be thrown for the unknown tag.\"\n  nil)\n\n;(defn- data-reader-urls []\n;  (enumeration-seq\n;   (.getResources (ClassLoader/getSystemClassLoader) \"data_readers.clj\")))\n\n;(defn- data-reader-var [sym]\n;  (intern (create-ns (symbol (namespace sym)))\n;          (symbol (name sym))))\n\n;(defn- load-data-reader-file [mappings ^java.net.URL url]\n;  (with-open [rdr (clojure.lang.LineNumberingPushbackReader.\n;                   (java.io.InputStreamReader.\n;                    (.openStream url) \"UTF-8\"))]\n;    (binding [*file* (.getFile url)]\n;      (let [new-mappings (read rdr false nil)]\n;        (when (not (map? new-mappings))\n;          (throw (ex-info (str \"Not a valid data-reader map\")\n;                          {:url url})))\n;        (reduce\n;         (fn [m [k v]]\n;           (when (not (symbol? k))\n;             (throw (ex-info (str \"Invalid form in data-reader file\")\n;                             {:url url\n;                              :form k})))\n;           (let [v-var (data-reader-var v)]\n;             (when (and (contains? mappings k)\n;                        (not= (mappings k) v-var))\n;               (throw (ex-info \"Conflicting data-reader mapping\"\n;                               {:url url\n;                                :conflict k\n;                                :mappings m})))\n;             (assoc m k v-var)))\n;         mappings\n;         new-mappings)))))\n\n;(defn- load-data-readers []\n;  (alter-var-root #'*data-readers*\n;                  (fn [mappings]\n;                    (reduce load-data-reader-file\n;                            mappings (data-reader-urls)))))\n\n;(try\n; (load-data-readers)\n; (catch Throwable t\n;   (.printStackTrace t)\n;   (throw t)))\n\n(load \"core_objc\")\n"
  },
  {
    "path": "src/clj/clojure/core_deftype.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(in-ns 'clojure.core)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; definterface ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defn namespace-munge\n  \"Convert a Clojure namespace name to a legal Java package name.\"\n  {:added \"1.2\"}\n  [ns]\n  (.replace (str ns) \\- \\_))\n\n;for now, built on gen-interface\n(defmacro definterface\n  \"Creates a new Java interface with the given name and method sigs.\n  The method return types and parameter types may be specified with type hints,\n  defaulting to Object if omitted.\n\n  (definterface MyInterface\n  (^int method1 [x])\n  (^Bar method2 [^Baz b ^Quux q]))\"\n  {:added \"1.2\"} ;; Present since 1.2, but made public in 1.5.\n  [name & sigs]\n  (let [tag (fn [x] (or (:tag (meta x)) Object))\n        psig (fn [[name [& args]]]\n               (vector name (vec (map tag args)) (tag name) (map meta args)))\n        cname (with-meta (symbol (str (namespace-munge *ns*) \".\" (namespace-munge name))) (meta name))]\n    `(do\n       (gen-interface :name ~cname :methods ~(vec (map psig sigs)))\n       (import ~cname))))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; reify/deftype ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn- parse-opts [s]\n  (loop [opts {} [k v & rs :as s] s]\n    (if (keyword? k)\n      (recur (assoc opts k v) rs)\n      [opts s])))\n\n(defn- parse-impls [specs]\n  (loop [ret {} s specs]\n    (if (seq s)\n      (recur (assoc ret (first s) (take-while seq? (next s)))\n             (drop-while seq? (next s)))\n      ret)))\n\n(defn- parse-opts+specs [opts+specs]\n  (let [[opts specs] (parse-opts opts+specs)\n        impls (parse-impls specs)\n        interfaces (-> (map #(if (var? (resolve %))\n                               (:on (deref (resolve %)))\n                               %)\n                            (keys impls))\n                       set\n                       (disj 'Object 'java.lang.Object)\n                       vec)\n        methods (map (fn [[name params & body]]\n                       (cons name (maybe-destructured params body)))\n                     (apply concat (vals impls)))]\n    (when-let [bad-opts (seq (remove #{:no-print} (keys opts)))]\n      (throw (IllegalArgumentException. ^String (apply print-str \"Unsupported option(s) -\" bad-opts))))\n    [interfaces methods opts]))\n\n(defmacro reify\n  \"reify is a macro with the following structure:\n\n  (reify options* specs*)\n\n  Currently there are no options.\n\n  Each spec consists of the protocol or interface name followed by zero\n  or more method bodies:\n\n  protocol-or-interface-or-Object\n  (methodName [args+] body)*\n\n  Methods should be supplied for all methods of the desired\n  protocol(s) and interface(s). You can also define overrides for\n  methods of Object. Note that the first parameter must be supplied to\n  correspond to the target object ('this' in Java parlance). Thus\n  methods for interfaces will take one more argument than do the\n  interface declarations.  Note also that recur calls to the method\n  head should *not* pass the target object, it will be supplied\n  automatically and can not be substituted.\n\n  The return type can be indicated by a type hint on the method name,\n  and arg types can be indicated by a type hint on arg names. If you\n  leave out all hints, reify will try to match on same name/arity\n  method in the protocol(s)/interface(s) - this is preferred. If you\n  supply any hints at all, no inference is done, so all hints (or\n  default of Object) must be correct, for both arguments and return\n  type. If a method is overloaded in a protocol/interface, multiple\n  independent method definitions must be supplied.  If overloaded with\n  same arity in an interface you must specify complete hints to\n  disambiguate - a missing hint implies Object.\n\n  recur works to method heads The method bodies of reify are lexical\n  closures, and can refer to the surrounding local scope:\n\n  (str (let [f \\\"foo\\\"]\n  (reify Object\n  (toString [this] f))))\n  == \\\"foo\\\"\n\n  (seq (let [f \\\"foo\\\"]\n  (reify clojure.lang.Seqable\n  (seq [this] (seq f)))))\n  == (\\\\f \\\\o \\\\o))\n\n  reify always implements clojure.lang.IObj and transfers meta\n  data of the form to the created object.\n\n  (meta ^{:k :v} (reify Object (toString [this] \\\"foo\\\")))\n  == {:k :v}\"\n  {:added \"1.2\"}\n  [& opts+specs]\n  (let [[interfaces methods] (parse-opts+specs opts+specs)]\n    (with-meta `(reify* ~interfaces ~@methods) (meta &form))))\n\n(defn hash-combine [x y]\n  (clojure.lang.Util/hashCombine x (clojure.lang.Util/hash y)))\n\n(defn munge [s]\n  ((if (symbol? s) symbol str) (clojure.lang.Compiler/munge (str s))))\n\n(defn- imap-cons\n  [^IPersistentMap this o]\n  (cond\n   (instance? java.util.Map$Entry o)\n   (let [^java.util.Map$Entry pair o]\n     (.assoc this (.getKey pair) (.getValue pair)))\n   (instance? clojure.lang.IPersistentVector o)\n   (let [^clojure.lang.IPersistentVector vec o]\n     (.assoc this (.nth vec 0) (.nth vec 1)))\n   :else (loop [this this\n                o o]\n           (if (seq o)\n             (let [^java.util.Map$Entry pair (first o)]\n               (recur (.assoc this (.getKey pair) (.getValue pair)) (rest o)))\n             this))))\n\n(defn- emit-defrecord\n  \"Do not use this directly - use defrecord\"\n  {:added \"1.2\"}\n  [tagname name fields interfaces methods]\n  (let [classname (with-meta (symbol (str (namespace-munge *ns*) \".\" (namespace-munge name))) (meta name))\n        interfaces (vec interfaces)\n        interface-set (set (map resolve interfaces))\n        methodname-set (set (map first methods))\n        hinted-fields fields\n        fields (vec (map #(with-meta % nil) fields))\n        base-fields fields\n        fields (conj fields '__meta '__extmap)\n        type-hash (hash classname)]\n    (when (some #{:volatile-mutable :unsynchronized-mutable} (mapcat (comp keys meta) hinted-fields))\n      (throw (IllegalArgumentException. \":volatile-mutable or :unsynchronized-mutable not supported for record fields\")))\n    (let [gs (gensym)]\n    (letfn \n     [(irecord [[i m]]\n        [(conj i 'clojure.lang.IRecord)\n         m])\n      (eqhash [[i m]] \n        [(conj i 'clojure.lang.IHashEq)\n         (conj m\n               `(hasheq [this#] (bit-xor ~type-hash (clojure.lang.APersistentMap/mapHasheq this#)))\n               `(hashCode [this#] (clojure.lang.APersistentMap/mapHash this#))\n               `(equals [this# ~gs] (clojure.lang.APersistentMap/mapEquals this# ~gs)))])\n      (iobj [[i m]] \n            [(conj i 'clojure.lang.IObj)\n             (conj m `(meta [this#] ~'__meta)\n                   `(withMeta [this# ~gs] (new ~tagname ~@(replace {'__meta gs} fields))))])\n      (ilookup [[i m]] \n         [(conj i 'clojure.lang.ILookup 'clojure.lang.IKeywordLookup)\n          (conj m `(valAt [this# k#] (.valAt this# k# nil))\n                `(valAt [this# k# else#] \n                   (case k# ~@(mapcat (fn [fld] [(keyword fld) fld]) \n                                       base-fields)\n                         (get ~'__extmap k# else#)))\n                `(getLookupThunk [this# k#]\n                   (let [~'gclass (class this#)]              \n                     (case k#\n                           ~@(let [hinted-target (with-meta 'gtarget {:tag tagname})] \n                               (mapcat \n                                (fn [fld]\n                                  [(keyword fld)\n                                   `(reify clojure.lang.ILookupThunk\n                                           (get [~'thunk ~'gtarget]\n                                                (if (identical? (class ~'gtarget) ~'gclass)\n                                                  (. ~hinted-target ~(symbol (str \"-\" fld)))\n                                                  ~'thunk)))])\n                                base-fields))\n                           nil))))])\n      (imap [[i m]] \n            [(conj i 'clojure.lang.IPersistentMap)\n             (conj m \n                   `(count [this#] (+ ~(count base-fields) (count ~'__extmap)))\n                   `(empty [this#] (throw (UnsupportedOperationException. (str \"Can't create empty: \" ~(str classname)))))\n                   `(cons [this# e#] ((var imap-cons) this# e#))\n                   `(equiv [this# ~gs] \n                        (boolean \n                         (or (identical? this# ~gs)\n                             (when (identical? (class this#) (class ~gs))\n                               (let [~gs ~(with-meta gs {:tag tagname})]\n                                 (and  ~@(map (fn [fld] `(= ~fld (. ~gs ~(symbol (str \"-\" fld))))) base-fields)\n                                       (= ~'__extmap (. ~gs ~'__extmap))))))))\n                   `(containsKey [this# k#] (not (identical? this# (.valAt this# k# this#))))\n                   `(entryAt [this# k#] (let [v# (.valAt this# k# this#)]\n                                            (when-not (identical? this# v#)\n                                              (clojure.lang.MapEntry. k# v#))))\n                   `(seq [this#] (seq (concat [~@(map #(list `new `clojure.lang.MapEntry (keyword %) %) base-fields)] \n                                              ~'__extmap)))\n                   `(iterator [~gs]\n                        (clojure.lang.RecordIterator. ~gs [~@(map keyword base-fields)] (RT/iter ~'__extmap)))\n                   `(assoc [this# k# ~gs]\n                     (condp identical? k#\n                       ~@(mapcat (fn [fld]\n                                   [(keyword fld) (list* `new tagname (replace {fld gs} fields))])\n                                 base-fields)\n                       (new ~tagname ~@(remove #{'__extmap} fields) (assoc ~'__extmap k# ~gs))))\n                   `(without [this# k#] (if (contains? #{~@(map keyword base-fields)} k#)\n                                            (dissoc (with-meta (into {} this#) ~'__meta) k#)\n                                            (new ~tagname ~@(remove #{'__extmap} fields) \n                                                 (not-empty (dissoc ~'__extmap k#))))))])\n      (ijavamap [[i m]]\n                [(conj i 'java.util.Map 'java.io.Serializable)\n                 (conj m\n                       `(size [this#] (.count this#))\n                       `(isEmpty [this#] (= 0 (.count this#)))\n                       `(containsValue [this# v#] (boolean (some #{v#} (vals this#))))\n                       `(get [this# k#] (.valAt this# k#))\n                       `(put [this# k# v#] (throw (UnsupportedOperationException.)))\n                       `(remove [this# k#] (throw (UnsupportedOperationException.)))\n                       `(putAll [this# m#] (throw (UnsupportedOperationException.)))\n                       `(clear [this#] (throw (UnsupportedOperationException.)))\n                       `(keySet [this#] (set (keys this#)))\n                       `(values [this#] (vals this#))\n                       `(entrySet [this#] (set this#)))])\n      ]\n     (let [[i m] (-> [interfaces methods] irecord eqhash iobj ilookup imap ijavamap)]\n       `(deftype* ~tagname ~classname ~(conj hinted-fields '__meta '__extmap) \n          :implements ~(vec i) \n          ~@m))))))\n\n(defn- build-positional-factory\n  \"Used to build a positional factory for a given type/record.  Because of the\n  limitation of 20 arguments to Clojure functions, this factory needs to be\n  constructed to deal with more arguments.  It does this by building a straight\n  forward type/record ctor call in the <=20 case, and a call to the same\n  ctor pulling the extra args out of the & overage parameter.  Finally, the\n  arity is constrained to the number of expected fields and an ArityException\n  will be thrown at runtime if the actual arg count does not match.\"\n  [nom classname fields]\n  (let [fn-name (symbol (str '-> nom))\n        [field-args over] (split-at 20 fields)\n        field-count (count fields)\n        arg-count (count field-args)\n        over-count (count over)\n        docstring (str \"Positional factory function for class \" classname \".\")]\n    `(defn ~fn-name\n       ~docstring\n       [~@field-args ~@(if (seq over) '[& overage] [])]\n       ~(if (seq over)\n          `(if (= (count ~'overage) ~over-count)\n             (new ~classname\n                  ~@field-args\n                  ~@(for [i (range 0 (count over))]\n                      (list `nth 'overage i)))\n             (throw (clojure.lang.ArityException. (+ ~arg-count (count ~'overage)) (name '~fn-name))))\n          `(new ~classname ~@field-args)))))\n\n(defn- validate-fields\n  \"\"\n  [fields name]\n  (when-not (vector? fields)\n    (throw (AssertionError. \"No fields vector given.\")))\n  (let [specials #{'__meta '__extmap}]\n    (when (some specials fields)\n      (throw (AssertionError. (str \"The names in \" specials \" cannot be used as field names for types or records.\")))))\n  (let [non-syms (remove symbol? fields)]\n    (when (seq non-syms)\n      (throw (clojure.lang.Compiler$CompilerException.\n              *file*\n              (.deref clojure.lang.Compiler/LINE)\n              (.deref clojure.lang.Compiler/COLUMN)\n              (AssertionError.\n               (str \"defrecord and deftype fields must be symbols, \"\n                    *ns* \".\" name \" had: \"\n                    (apply str (interpose \", \" non-syms)))))))))\n\n(defmacro defrecord\n  \"(defrecord name [fields*]  options* specs*)\n\n  Currently there are no options.\n\n  Each spec consists of a protocol or interface name followed by zero\n  or more method bodies:\n\n  protocol-or-interface-or-Object\n  (methodName [args*] body)*\n\n  Dynamically generates compiled bytecode for class with the given\n  name, in a package with the same name as the current namespace, the\n  given fields, and, optionally, methods for protocols and/or\n  interfaces.\n\n  The class will have the (immutable) fields named by\n  fields, which can have type hints. Protocols/interfaces and methods\n  are optional. The only methods that can be supplied are those\n  declared in the protocols/interfaces.  Note that method bodies are\n  not closures, the local environment includes only the named fields,\n  and those fields can be accessed directly.\n\n  Method definitions take the form:\n\n  (methodname [args*] body)\n\n  The argument and return types can be hinted on the arg and\n  methodname symbols. If not supplied, they will be inferred, so type\n  hints should be reserved for disambiguation.\n\n  Methods should be supplied for all methods of the desired\n  protocol(s) and interface(s). You can also define overrides for\n  methods of Object. Note that a parameter must be supplied to\n  correspond to the target object ('this' in Java parlance). Thus\n  methods for interfaces will take one more argument than do the\n  interface declarations. Note also that recur calls to the method\n  head should *not* pass the target object, it will be supplied\n  automatically and can not be substituted.\n\n  In the method bodies, the (unqualified) name can be used to name the\n  class (for calls to new, instance? etc).\n\n  The class will have implementations of several (clojure.lang)\n  interfaces generated automatically: IObj (metadata support) and\n  IPersistentMap, and all of their superinterfaces.\n\n  In addition, defrecord will define type-and-value-based =,\n  and will defined Java .hashCode and .equals consistent with the\n  contract for java.util.Map.\n\n  When AOT compiling, generates compiled bytecode for a class with the\n  given name (a symbol), prepends the current ns as the package, and\n  writes the .class file to the *compile-path* directory.\n\n  Two constructors will be defined, one taking the designated fields\n  followed by a metadata map (nil for none) and an extension field\n  map (nil for none), and one taking only the fields (using nil for\n  meta and extension fields). Note that the field names __meta\n  and __extmap are currently reserved and should not be used when\n  defining your own records.\n\n  Given (defrecord TypeName ...), two factory functions will be\n  defined: ->TypeName, taking positional parameters for the fields,\n  and map->TypeName, taking a map of keywords to field values.\"\n  {:added \"1.2\"\n   :arglists '([name [& fields] & opts+specs])}\n\n  [name fields & opts+specs]\n  (validate-fields fields name)\n  (let [gname (namespace-munge name)\n        [interfaces methods opts] (parse-opts+specs opts+specs)\n        ns-part (namespace-munge *ns*)\n        classname (symbol (str ns-part \".\" gname))\n        hinted-fields fields\n        fields (vec (map #(with-meta % nil) fields))]\n    `(do\n       (declare ~(symbol (str  '-> gname)))\n       (declare ~(symbol (str 'map-> gname)))\n       ~(emit-defrecord name gname (vec hinted-fields) (vec interfaces) methods)\n       (import ~classname)\n       ~(build-positional-factory gname classname fields)\n       (defn ~(symbol (str 'map-> gname))\n         ~(str \"Factory function for class \" classname \", taking a map of keywords to field values.\")\n         ([m#] (~(symbol (str classname \"/create\"))\n                (if (instance? clojure.lang.MapEquivalence m#) m# (into {} m#)))))\n       ~classname)))\n\n(defn record?\n  \"Returns true if x is a record\"\n  {:added \"1.6\"\n   :static true}\n  [x]\n  (instance? clojure.lang.IRecord x))\n\n(defn- emit-deftype*\n  \"Do not use this directly - use deftype\"\n  [tagname name fields interfaces methods]\n  (let [classname (with-meta (symbol (str (namespace-munge *ns*) \".\" (namespace-munge name))) (meta name))\n        interfaces (conj interfaces 'clojure.lang.IType)]\n    `(deftype* ~tagname ~classname ~fields\n       :implements ~interfaces\n       ~@methods)))\n\n(defmacro deftype\n  \"(deftype name [fields*]  options* specs*)\n\n  Currently there are no options.\n\n  Each spec consists of a protocol or interface name followed by zero\n  or more method bodies:\n\n  protocol-or-interface-or-Object\n  (methodName [args*] body)*\n\n  Dynamically generates compiled bytecode for class with the given\n  name, in a package with the same name as the current namespace, the\n  given fields, and, optionally, methods for protocols and/or\n  interfaces.\n\n  The class will have the (by default, immutable) fields named by\n  fields, which can have type hints. Protocols/interfaces and methods\n  are optional. The only methods that can be supplied are those\n  declared in the protocols/interfaces.  Note that method bodies are\n  not closures, the local environment includes only the named fields,\n  and those fields can be accessed directly. Fields can be qualified\n  with the metadata :volatile-mutable true or :unsynchronized-mutable\n  true, at which point (set! afield aval) will be supported in method\n  bodies. Note well that mutable fields are extremely difficult to use\n  correctly, and are present only to facilitate the building of higher\n  level constructs, such as Clojure's reference types, in Clojure\n  itself. They are for experts only - if the semantics and\n  implications of :volatile-mutable or :unsynchronized-mutable are not\n  immediately apparent to you, you should not be using them.\n\n  Method definitions take the form:\n\n  (methodname [args*] body)\n\n  The argument and return types can be hinted on the arg and\n  methodname symbols. If not supplied, they will be inferred, so type\n  hints should be reserved for disambiguation.\n\n  Methods should be supplied for all methods of the desired\n  protocol(s) and interface(s). You can also define overrides for\n  methods of Object. Note that a parameter must be supplied to\n  correspond to the target object ('this' in Java parlance). Thus\n  methods for interfaces will take one more argument than do the\n  interface declarations. Note also that recur calls to the method\n  head should *not* pass the target object, it will be supplied\n  automatically and can not be substituted.\n\n  In the method bodies, the (unqualified) name can be used to name the\n  class (for calls to new, instance? etc).\n\n  When AOT compiling, generates compiled bytecode for a class with the\n  given name (a symbol), prepends the current ns as the package, and\n  writes the .class file to the *compile-path* directory.\n\n  One constructor will be defined, taking the designated fields.  Note\n  that the field names __meta and __extmap are currently reserved and\n  should not be used when defining your own types.\n\n  Given (deftype TypeName ...), a factory function called ->TypeName\n  will be defined, taking positional parameters for the fields\"\n  {:added \"1.2\"\n   :arglists '([name [& fields] & opts+specs])}\n\n  [name fields & opts+specs]\n  (validate-fields fields name)\n  (let [gname (namespace-munge name)\n        [interfaces methods opts] (parse-opts+specs opts+specs)\n        ns-part (namespace-munge *ns*)\n        classname (symbol (str ns-part \".\" gname))\n        hinted-fields fields\n        fields (vec (map #(with-meta % nil) fields))\n        [field-args over] (split-at 20 fields)]\n    `(do\n       ~(emit-deftype* name gname (vec hinted-fields) (vec interfaces) methods)\n       (import ~classname)\n       ~(build-positional-factory gname classname fields)\n       ~classname)))\n\n;;;;;;;;;;;;;;;;;;;;;;; protocols ;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn- expand-method-impl-cache [^clojure.lang.MethodImplCache cache c f]\n  (if (.map cache)\n    (let [cs (assoc (.map cache) c (clojure.lang.MethodImplCache$Entry. c f))]\n      (clojure.lang.MethodImplCache. (.protocol cache) (.methodk cache) cs))\n    (let [cs (into1 {} (remove (fn [[c e]] (nil? e)) (map vec (partition 2 (.table cache)))))\n          cs (assoc cs c (clojure.lang.MethodImplCache$Entry. c f))]\n      (if-let [[shift mask] (maybe-min-hash (map hash (keys cs)))]\n        (let [table (make-array Object (* 2 (inc mask)))\n              table (reduce1 (fn [^objects t [c e]]\n                               (let [i (* 2 (int (shift-mask shift mask (hash c))))]\n                                 (aset t i c)\n                                 (aset t (inc i) e)\n                                 t))\n                             table cs)]\n          (clojure.lang.MethodImplCache. (.protocol cache) (.methodk cache) shift mask table))\n        (clojure.lang.MethodImplCache. (.protocol cache) (.methodk cache) cs)))))\n\n(defn- super-chain [^Class c]\n  (when c\n    (cons c (super-chain (.getSuperclass c)))))\n\n(defn- pref\n  ([] nil)\n  ([a] a)\n  ([^Class a ^Class b]\n   (if (.isAssignableFrom a b) b a)))\n\n(defn find-protocol-impl [protocol x]\n  (if (instance? (:on-interface protocol) x)\n    x\n    (let [c (class x)\n          impl #(get (:impls protocol) %)]\n      (or (impl c)\n          (and c (or (first (remove nil? (map impl (butlast (super-chain c)))))\n                     (when-let [t (reduce1 pref (filter impl (disj (supers c) Object)))]\n                       (impl t))\n                     (impl Object)))))))\n\n(defn find-protocol-method [protocol methodk x]\n  (get (find-protocol-impl protocol x) methodk))\n\n(defn- protocol?\n  [maybe-p]\n  (boolean (:on-interface maybe-p)))\n\n(defn- implements? [protocol atype]\n  (and atype (.isAssignableFrom ^Class (:on-interface protocol) atype)))\n\n(defn extends?\n  \"Returns true if atype extends protocol\"\n  {:added \"1.2\"}\n  [protocol atype]\n  (boolean (or (implements? protocol atype)\n               (get (:impls protocol) atype))))\n\n(defn extenders\n  \"Returns a collection of the types explicitly extending protocol\"\n  {:added \"1.2\"}\n  [protocol]\n  (keys (:impls protocol)))\n\n(defn satisfies?\n  \"Returns true if x satisfies the protocol\"\n  {:added \"1.2\"}\n  [protocol x]\n  (boolean (find-protocol-impl protocol x)))\n\n(defn -cache-protocol-fn [^clojure.lang.AFunction pf x ^Class c ^clojure.lang.IFn interf]\n  (let [cache  (.__methodImplCache pf)\n        f (if (.isInstance c x)\n            interf\n            (find-protocol-method (.protocol cache) (.methodk cache) x))]\n    (when-not f\n      (throw (IllegalArgumentException. (str \"No implementation of method: \" (.methodk cache)\n                                             \" of protocol: \" (:var (.protocol cache))\n                                             \" found for class: \" (if (nil? x) \"nil\" (.getName (class x)))))))\n    (set! (.__methodImplCache pf) (expand-method-impl-cache cache (class x) f))\n    f))\n\n(defn- emit-method-builder [on-interface method on-method arglists]\n  (let [methodk (keyword method)\n        gthis (with-meta (gensym) {:tag 'clojure.lang.AFunction})\n        ginterf (gensym)]\n    `(fn [cache#]\n       (let [~ginterf\n             (fn\n               ~@(map\n                  (fn [args]\n                    (let [gargs (map #(gensym (str \"gf__\" % \"__\")) args)\n                          target (first gargs)]\n                      `([~@gargs]\n                        (. ~(with-meta target {:tag on-interface}) (~(or on-method method) ~@(rest gargs))))))\n                  arglists))\n             ^clojure.lang.AFunction f#\n             (fn ~gthis\n               ~@(map\n                  (fn [args]\n                    (let [gargs (map #(gensym (str \"gf__\" % \"__\")) args)\n                          target (first gargs)]\n                      `([~@gargs]\n                        (let [cache# (.__methodImplCache ~gthis)\n                              f# (.fnFor cache# (clojure.lang.Util/classOf ~target))]\n                          (if f#\n                            (f# ~@gargs)\n                            ((-cache-protocol-fn ~gthis ~target ~on-interface ~ginterf) ~@gargs))))))\n                  arglists))]\n         (set! (.__methodImplCache f#) cache#)\n         f#))))\n\n(defn -reset-methods [protocol]\n  (doseq [[^clojure.lang.Var v build] (:method-builders protocol)]\n    (let [cache (clojure.lang.MethodImplCache. protocol (keyword (.sym v)))]\n      (.bindRoot v (build cache)))))\n\n(defn- assert-same-protocol [protocol-var method-syms]\n  (doseq [m method-syms]\n    (let [^clojure.lang.Var v (resolve m)\n          ^clojure.lang.Var p (:protocol (meta v))]\n      (when (and v (bound? v) (not= protocol-var p))\n        (binding [*out* *err*]\n          (println \"Warning: protocol\" protocol-var \"is overwriting\"\n                   (if p\n                     (str \"method \" (.sym v) \" of protocol \" (.sym p))\n                     (str \"function \" (.sym v)))))))))\n\n(defn- emit-protocol [name opts+sigs]\n  (let [iname (symbol (str (munge (namespace-munge *ns*)) \".\" (munge (namespace-munge name))))\n        [opts sigs]\n        (loop [opts {:on (list 'quote iname) :on-interface iname} sigs opts+sigs]\n          (condp #(%1 %2) (first sigs)\n            string? (recur (assoc opts :doc (first sigs)) (next sigs))\n            keyword? (recur (assoc opts (first sigs) (second sigs)) (nnext sigs))\n            [opts sigs]))\n        sigs (when sigs\n               (reduce1 (fn [m s]\n                          (let [name-meta (meta (first s))\n                                mname (with-meta (first s) nil)\n                                [arglists doc]\n                                (loop [as [] rs (rest s)]\n                                  (if (vector? (first rs))\n                                    (recur (conj as (first rs)) (next rs))\n                                    [(seq as) (first rs)]))]\n                            (when (some #{0} (map count arglists))\n                              (throw (IllegalArgumentException. (str \"Definition of function \" mname \" in protocol \" name \" must take at least one arg.\"))))\n                            (when (m (keyword mname))\n                              (throw (IllegalArgumentException. (str \"Function \" mname \" in protocol \" name \" was redefined. Specify all arities in single definition.\"))))\n                            (assoc m (keyword mname)\n                              (merge name-meta\n                                     {:name (vary-meta mname assoc :doc doc :arglists arglists)\n                                      :arglists arglists\n                                      :doc doc}))))\n                        {} sigs))\n        meths (mapcat (fn [sig]\n                        (let [m (munge (:name sig))]\n                          (map #(vector m (vec (repeat (dec (count %))'Object)) 'Object)\n                               (:arglists sig))))\n                      (vals sigs))]\n    `(do\n       (defonce ~name {})\n       (gen-interface :name ~iname :methods ~meths)\n       (alter-meta! (var ~name) assoc :doc ~(:doc opts))\n       ~(when sigs\n          `(#'assert-same-protocol (var ~name) '~(map :name (vals sigs))))\n       (alter-var-root (var ~name) merge\n                       (assoc ~opts\n                         :sigs '~sigs\n                         :var (var ~name)\n                         :method-map\n                         ~(and (:on opts)\n                               (apply hash-map\n                                      (mapcat\n                                       (fn [s]\n                                         [(keyword (:name s)) (keyword (or (:on s) (:name s)))])\n                                       (vals sigs))))\n                         :method-builders\n                         ~(apply hash-map\n                                 (mapcat\n                                  (fn [s]\n                                    [`(intern *ns* (with-meta '~(:name s) (merge '~s {:protocol (var ~name)})))\n                                     (emit-method-builder (:on-interface opts) (:name s) (:on s) (:arglists s))])\n                                  (vals sigs)))))\n       (-reset-methods ~name)\n       '~name)))\n\n(defmacro defprotocol\n  \"A protocol is a named set of named methods and their signatures:\n  (defprotocol AProtocolName\n\n  ;optional doc string\n  \\\"A doc string for AProtocol abstraction\\\"\n\n  ;method signatures\n  (bar [this a b] \\\"bar docs\\\")\n  (baz [this a] [this a b] [this a b c] \\\"baz docs\\\"))\n\n  No implementations are provided. Docs can be specified for the\n  protocol overall and for each method. The above yields a set of\n  polymorphic functions and a protocol object. All are\n  namespace-qualified by the ns enclosing the definition The resulting\n  functions dispatch on the type of their first argument, which is\n  required and corresponds to the implicit target object ('this' in\n  Java parlance). defprotocol is dynamic, has no special compile-time\n  effect, and defines no new types or classes. Implementations of\n  the protocol methods can be provided using extend.\n\n  defprotocol will automatically generate a corresponding interface,\n  with the same name as the protocol, i.e. given a protocol:\n  my.ns/Protocol, an interface: my.ns.Protocol. The interface will\n  have methods corresponding to the protocol functions, and the\n  protocol will automatically work with instances of the interface.\n\n  Note that you should not use this interface with deftype or\n  reify, as they support the protocol directly:\n\n  (defprotocol P\n  (foo [this])\n  (bar-me [this] [this y]))\n\n  (deftype Foo [a b c]\n  P\n  (foo [this] a)\n  (bar-me [this] b)\n  (bar-me [this y] (+ c y)))\n\n  (bar-me (Foo. 1 2 3) 42)\n  => 45\n\n  (foo\n  (let [x 42]\n  (reify P\n  (foo [this] 17)\n  (bar-me [this] x)\n  (bar-me [this y] x))))\n  => 17\"\n  {:added \"1.2\"}\n  [name & opts+sigs]\n  (emit-protocol name opts+sigs))\n\n(defn- emit-impl [[p fs]]\n  [p (zipmap (map #(-> % first keyword) fs)\n             (map #(cons `fn (drop 1 %)) fs))])\n\n(defn- emit-hinted-impl [c [p fs]]\n  (let [hint (fn [specs]\n               (let [specs (if (vector? (first specs))\n                             (list specs)\n                             specs)]\n                 (map (fn [[[target & args] & body]]\n                        (cons (apply vector (vary-meta target assoc :tag c) args)\n                              body))\n                      specs)))]\n    [p (zipmap (map #(-> % first name keyword) fs)\n               (map #(cons `fn (hint (drop 1 %))) fs))]))\n\n(defn- emit-extend-type [c specs]\n  (let [impls (parse-impls specs)]\n    `(extend ~c\n       ~@(mapcat (partial emit-hinted-impl c) impls))))\n\n(defmacro extend-type\n  \"A macro that expands into an extend call. Useful when you are\n  supplying the definitions explicitly inline, extend-type\n  automatically creates the maps required by extend.  Propagates the\n  class as a type hint on the first argument of all fns.\n\n  (extend-type MyType\n  Countable\n  (cnt [c] ...)\n  Foo\n  (bar [x y] ...)\n  (baz ([x] ...) ([x y & zs] ...)))\n\n  expands into:\n\n  (extend MyType\n  Countable\n  {:cnt (fn [c] ...)}\n  Foo\n  {:baz (fn ([x] ...) ([x y & zs] ...))\n  :bar (fn [x y] ...)})\"\n  {:added \"1.2\"}\n  [t & specs]\n  (emit-extend-type t specs))\n\n(defn- emit-extend-protocol [p specs]\n  (let [impls (parse-impls specs)]\n    `(do\n       ~@(map (fn [[t fs]]\n                `(extend-type ~t ~p ~@fs))\n              impls))))\n\n(defmacro extend-protocol\n  \"Useful when you want to provide several implementations of the same\n  protocol all at once. Takes a single protocol and the implementation\n  of that protocol for one or more types. Expands into calls to\n  extend-type:\n\n  (extend-protocol Protocol\n  AType\n  (foo [x] ...)\n  (bar [x y] ...)\n  BType\n  (foo [x] ...)\n  (bar [x y] ...)\n  AClass\n  (foo [x] ...)\n  (bar [x y] ...)\n  nil\n  (foo [x] ...)\n  (bar [x y] ...))\n\n  expands into:\n\n  (do\n  (clojure.core/extend-type AType Protocol\n  (foo [x] ...)\n  (bar [x y] ...))\n  (clojure.core/extend-type BType Protocol\n  (foo [x] ...)\n  (bar [x y] ...))\n  (clojure.core/extend-type AClass Protocol\n  (foo [x] ...)\n  (bar [x y] ...))\n  (clojure.core/extend-type nil Protocol\n  (foo [x] ...)\n  (bar [x y] ...)))\"\n  {:added \"1.2\"}\n\n  [p & specs]\n  (emit-extend-protocol p specs))\n\n(defn extend\n  \"Implementations of protocol methods can be provided using the extend construct:\n\n  (extend AType\n  AProtocol\n  {:foo an-existing-fn\n  :bar (fn [a b] ...)\n  :baz (fn ([a]...) ([a b] ...)...)}\n  BProtocol\n  {...}\n  ...)\n\n  extend takes a type/class (or interface, see below), and one or more\n  protocol + method map pairs. It will extend the polymorphism of the\n  protocol's methods to call the supplied methods when an AType is\n  provided as the first argument.\n\n  Method maps are maps of the keyword-ized method names to ordinary\n  fns. This facilitates easy reuse of existing fns and fn maps, for\n  code reuse/mixins without derivation or composition. You can extend\n  an interface to a protocol. This is primarily to facilitate interop\n  with the host (e.g. Java) but opens the door to incidental multiple\n  inheritance of implementation since a class can inherit from more\n  than one interface, both of which extend the protocol. It is TBD how\n  to specify which impl to use. You can extend a protocol on nil.\n\n  If you are supplying the definitions explicitly (i.e. not reusing\n  exsting functions or mixin maps), you may find it more convenient to\n  use the extend-type or extend-protocol macros.\n\n  Note that multiple independent extend clauses can exist for the same\n  type, not all protocols need be defined in a single extend call.\n\n  See also:\n  extends?, satisfies?, extenders\"\n  {:added \"1.2\"}\n  [atype & proto+mmaps]\n  (doseq [[proto mmap] (partition 2 proto+mmaps)]\n    (when-not (protocol? proto)\n      (throw (IllegalArgumentException.\n              (str proto \" is not a protocol\"))))\n    (when (implements? proto atype)\n      (throw (IllegalArgumentException.\n              (str atype \" already directly implements \" (:on-interface proto) \" for protocol:\"\n                   (:var proto)))))\n    (-reset-methods (alter-var-root (:var proto) assoc-in [:impls atype] mmap))))\n"
  },
  {
    "path": "src/clj/clojure/core_objc.clj",
    "content": "(in-ns 'clojure.core)\n\n(require 'clojure.string)\n\n(def ^:dynamic dispatch-class)\n\n(def ^:dynamic force-main-thread)\n\n(def objc? (clojure.lang.ObjC/objc))\n\n(when-not objc?\n  (require '[clojure.walk :as walk]))\n\n(defmacro ^{:added \"1.6\"} dispatch-main\n  \"Runs the body with dispatch_sync in the main queue\n\n  dispatch_sync(dispatch_get_main_queue(), ^{\n    ...\n  });\"\n  [& body]\n  `(clojure.lang.RT/dispatchInMainSync\n    (fn [] ~@body)))\n\n(defn ^{:added \"1.6\"} sel\n  \"Creates an objc selector.\n\n  (sel \\\"some:selector:\\\")\"\n  [^String s]\n  (clojure.lang.Selector. s))\n\n(defn ^{:added \"1.6\"} objc-class\n  \"Lookup an objc class by name.\n\n  (objc-class \\\"UIView\\\")\"\n  [s]\n  (RT/objcClass (name s)))\n\n(defmacro ^{:added \"1.6\"} $\n  \"The objc interop macro. Use to lookup a class or to msgSend.\n  \n  [UIView class] -> ($ UIView)\n  [MyObject objectWithString:myString] -> ($ MyObject :objectWithString myString)\n  [@\\\"Hello\\\" description] -> ($ \\\"Hello\\\" :description)\n  [UIView alloc] -> ($ ($ UIView) :alloc)\n  \"\n  [& args]\n  (let [is-class (= 1 (count args))\n        t (first args)]\n    (if is-class\n      `(objc-class '~t)\n      (let [args (vec (next args))\n            has-params (even? (count args))\n            args (partition 2 (if has-params args (conj args nil)))\n            params (mapv second args)\n            selector (str (subs (apply str (map first args)) 1) (if has-params \":\" \"\"))]\n        (if has-params\n          `(clojure.lang.Selector/invokeSelector ~selector ~t ~params)\n          `(clojure.lang.Selector/invokeSelector ~selector ~t))))))\n\n(defmacro ^{:added \"1.6\"} $$\n  \"Like $ but calls super.\n  \n  [super initWithFrame:frame] -> ($$ self :initWithFrame frame)\n  \"\n  [& args]\n  (let [t (first args)\n        dispatch-class (if (bound? #'dispatch-class) dispatch-class nil)\n        args (vec (next args))\n        has-params (even? (count args))\n        args (if has-params (partition 2 args) args)\n        params (if has-params (mapv second args) [])\n        selector (if has-params (str (subs (apply str (map first args)) 1) \":\") (name (first args)))]\n    `($ ($ NSCommon) :invokeSuperSel ~t :withDispatchClass ~dispatch-class :withSelector ~selector :withArgs ~params)))\n\n(def objc-types\n  {:void \\v\n   :float \\f\n   :longlong \\q\n   :long \\l\n   :char \\c\n   :short \\s\n   :int \\i\n   :double \\d\n   :ulonglong \\Q\n   :ulong \\L\n   :uchar \\C\n   :ushort \\S\n   :uint \\I\n   :bool \\b\n   :cgpoint \\P\n   :nsrange \\N\n   :uiedge \\E\n   :cgsize \\Z\n   :cgaffinetransform \\A\n   :catransform3d \\T\n   :uioffset \\O\n   :cgrect \\R\n   :id \\p\n   :pointer \\Y\n   :cgfloat (if ($ ($ NSCommon) :cgfloatIsDouble) \\d \\f)})\n\n(defmethod print-method clojure.lang.RemoteRef\n  [^clojure.lang.RemoteRef r, ^java.io.Writer w]\n  (.write w (str \"#remote-ref \\\"\" (.getId r) \"\\\"\")))\n\n(defmethod print-method clojure.lang.ObjCClass\n  [^clojure.lang.ObjCClass r, ^java.io.Writer w]\n  (.write w (str \"#objc-class \\\"\" (.getName r) \"\\\"\")))\n\n(defn ^{:added \"1.6\"} read-remote-ref [id]\n  (.get (clojure.lang.RemoteRef. id)))\n\n(defn ^{:added \"1.6\"} read-sel [name]\n  (clojure.lang.Selector. name))\n\n(alter-var-root #'*data-readers*\n                (fn [m] (merge m {'sel #'read-sel\n                                  'remote-ref #'read-remote-ref\n                                  'objc-class #'objc-class})))\n\n(defn ^{:added \"1.6\"} class->types\n  \"Lookup a type for a class simple name\"\n  [c] \n  (case c\n    :long :longlong\n    :integer :int\n    :boolean :bool\n    :float :float\n    :double :double\n    :short :short\n    :void :void\n    :character :char\n    :remoteref :pointer\n    (if ($ c :isKindOfClass ($ NSValue))\n      (some #(if (= (val %) ($ ($ NSCommon) :signatureToType ($ c :objCType))) (key %)) objc-types)\n      :id)))\n\n(defn ^{:added \"1.6\"} types-for-vals [vals]\n  (map (comp objc-types class->types keyword clojure.string/lower-case #(.getSimpleName %) class) vals))\n\n(defn ^{:added \"1.6\"} ccall\n  \"The c interop. To use a c function you need to register it in using:\n  \n  #import \\\"NSCommon.h\\\"\n  reg_c(CGRectMake); // From now on you can use CGRectMake in ccall\n  \n  The args are unboxed when necessary and the return is always a boxed value.\n\n  fun: the c function name\n  types: a vector with the return type followed by the parameters types. Types map: clojure.core/objc-types\n  args: the arguments vector\n\n  CGRectMake(1, 2, 3, 4) -> (ccall \\\"CGRectMake\\\" [\\\\R \\\\f \\\\f \\\\f \\\\f] [1 2 3 4])\n  \"\n  [fun types args]\n  ($ ($ NSCommon) :ccall (name fun) :types (vec types) :args (vec args)))\n\n(defmacro ^{:added \"1.6\"} defc\n  \"Defines a c function. Supports variadic functions.\n  Takes the function name, the return type and a vector of the arguments types.\n  \n  (defc CGRectMake :cgrect [:cgfloat :cgfloat :cgfloat :cgfloat])\n  (CGRectMake 12 23 44 55)\n\n  ;; Variadic\n  (defc NSLog :void [:id &])\n  (NSLog \\\"%@ %@ %d\\\" \\\"Hello\\\" \\\"World\\\" 44)\n  \"\n  [n r types]\n  (let [nn (name n)\n        variadic? (= '& (last types))\n        types (if variadic? (drop-last types) types)\n        types (vec (cons r types))]\n    (if variadic?\n      `(defn ~n [& args#] (ccall ~nn (apply conj (mapv objc-types ~types) (types-for-vals (drop (dec (count ~types)) args#))) args#))\n      `(defn ~n [& args#] (ccall ~nn (mapv objc-types ~types) args#)))))\n\n(defmacro ^{:added \"1.6\"} nsproxy\n  \"nsproxy mocks an object. It's intended to implement protocols/delegators.\n\n  (nsproxy\n    ([^id self :doSomething] \n      \\\"I don't do anything\\\")\n    ([^:bool self :textFieldShouldReturn ^:id field]\n      ($ field :resignFirstResponder) \n      true))\n  \"\n  [& methods]\n  (let [objc-meta-type (comp objc-types ffirst meta)\n        has-class (not (list? (first methods)))\n        clazz (when has-class (name (first methods)))\n        methods (if has-class (next methods) methods)\n        i (map (fn [[args & body]]\n                 (let [self-sym (first args)\n                       args (next args)\n                       sel (take-nth 2 args)\n                       fields (take-nth 2 (next args))\n                       types (map objc-meta-type (cons self-sym fields))\n                       sel (if (pos? (count fields))\n                             (reduce str (map #(str (name %) \":\") sel))\n                             (reduce str (map name sel)))]\n                   `[~sel [[~@types] (fn [~self-sym ~@fields] ~@body)]]))\n               methods)\n        i (into {} i)]\n    `($ ($ ($ NSProxyImpl) :alloc) :initWithClass ~clazz :map ~i)))\n\n(defc ^{:added \"1.6\"} objc_setAssociatedObject :void [:id :pointer :id :int])\n\n(defc ^{:added \"1.6\"} objc_getAssociatedObject :id [:id :pointer])\n\n(def objc-keys-map (atom {}))\n\n(defn ^{:added \"1.6\"} objc-tag [tag]\n  (if-let [t (tag @objc-keys-map)]\n    t\n    (let [t ($ (str \"__\" (name tag) \"__\") :UTF8String)]\n      (swap! objc-keys-map assoc tag t)\n      t)))\n\n(defn ^{:added \"1.6\"} objc-set!\n  \"Retains and sets a value into an object.\"\n  [self tag value]\n  (objc_setAssociatedObject self (objc-tag tag) value 1)) ; retain assign\n\n(defn ^{:added \"1.6\"} objc-get\n  \"Gets a value for a tag set with objc-set!.\"\n  [self tag]\n  (objc_getAssociatedObject self (objc-tag tag)))\n\n(defmacro ^{:added \"1.6\"} defnstype\n  \"nstype creates a new objc class.\n Takes a name, a superclass and a list of methods.\n \n The signature on the methods is optional when the method exists\n on the superclass, otherwise is mandatory.\n \n For the list of all available types see: clojure.core/objc-types\n \n (nstype MyTextField UITextField\n  ([self :initWithFrame frame] ; Here the signature is not needed\n   (doto ($$ self :initWithFrame frame)\n    ($ :setDelegate self)))\n  ([^:bool self :textFieldShouldReturn ^:id field]\n   ($ self :resignFirstResponder)\n   true))\n \"\n [na super & methods]\n (let [methods\n       (binding [dispatch-class (name na)]\n         (mapv walk/macroexpand-all methods))\n       na (name na)\n       super (name super)\n       fnsi (map\n             (fn [[args & body]]\n               (let [objc-meta-type (comp objc-types ffirst meta)\n                     self-sym (first args)\n                     args (next args)\n                     sel (take-nth 2 args)\n                     fields-vec (take-nth 2 (next args))\n                     fields (take (count fields-vec) (repeatedly gensym))\n                     fields-let (interleave fields-vec fields)\n                     types (map objc-meta-type\n                                (cons self-sym fields-vec))\n                     types (if (nil? (first types)) nil (vec types))\n                     sel (if (pos? (count fields))\n                           (reduce str (map #(str (name %) \":\") sel))\n                           (reduce str (map name sel)))\n                     fnname (symbol (str na \":\" sel))]\n                 [`(defn ~fnname [~self-sym ~@fields]\n                     (let [~@fields-let] ~@body))\n                  `[~sel [~types ~fnname]]]))\n             methods)\n       fns (map first fnsi)\n       i (into {} (map second fnsi))]\n   `(do\n      ~@fns\n      ($ ($ NSTypeImpl)\n         :makeClassWithName ~na\n         :superclass ~super\n         :map ~i))))\n\n(defn ^{:added \"1.6\"} remote-repl\n  \"Starts a remote repl\"\n  [] (clojure.lang.RemoteRepl/listen))\n"
  },
  {
    "path": "src/clj/clojure/core_print.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(in-ns 'clojure.core)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; printing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(import '(java.io Writer))\n\n(set! *warn-on-reflection* true)\n(def ^:dynamic\n ^{:doc \"*print-length* controls how many items of each collection the\n  printer will print. If it is bound to logical false, there is no\n  limit. Otherwise, it must be bound to an integer indicating the maximum\n  number of items of each collection to print. If a collection contains\n  more items, the printer will print items up to the limit followed by\n  '...' to represent the remaining items. The root binding is nil\n  indicating no limit.\"\n   :added \"1.0\"}\n *print-length* nil)\n\n(def ^:dynamic\n ^{:doc \"*print-level* controls how many levels deep the printer will\n  print nested objects. If it is bound to logical false, there is no\n  limit. Otherwise, it must be bound to an integer indicating the maximum\n  level to print. Each argument to print is at level 0; if an argument is a\n  collection, its items are at level 1; and so on. If an object is a\n  collection and is at a level greater than or equal to the value bound to\n  *print-level*, the printer prints '#' to represent it. The root binding\n  is nil indicating no limit.\"\n   :added \"1.0\"}\n *print-level* nil)\n\n(def ^:dynamic *verbose-defrecords* false)\n\n(defn- print-sequential [^String begin, print-one, ^String sep, ^String end, sequence, ^Writer w]\n  (binding [*print-level* (and (not *print-dup*) *print-level* (dec *print-level*))]\n    (if (and *print-level* (neg? *print-level*))\n      (.write w \"#\")\n      (do\n        (.write w begin)\n        (when-let [xs (seq sequence)]\n          (if (and (not *print-dup*) *print-length*)\n            (loop [[x & xs] xs\n                   print-length *print-length*]\n              (if (zero? print-length)\n                (.write w \"...\")\n                (do\n                  (print-one x w)\n                  (when xs\n                    (.write w sep)\n                    (recur xs (dec print-length))))))\n            (loop [[x & xs] xs]\n              (print-one x w)\n              (when xs\n                (.write w sep)\n                (recur xs)))))\n        (.write w end)))))\n\n(defn- print-meta [o, ^Writer w]\n  (when-let [m (meta o)]\n    (when (and (pos? (count m))\n               (or *print-dup*\n                   (and *print-meta* *print-readably*)))\n      (.write w \"^\")\n      (if (and (= (count m) 1) (:tag m))\n          (pr-on (:tag m) w)\n          (pr-on m w))\n      (.write w \" \"))))\n\n(defn print-simple [o, ^Writer w]\n  (print-meta o w)\n  (.write w (str o)))\n\n(defmethod print-method :default [o, ^Writer w]\n  (if (instance? clojure.lang.IObj o)\n    (print-method (vary-meta o #(dissoc % :type)) w)\n    (print-simple o w)))\n\n(defmethod print-method nil [o, ^Writer w]\n  (.write w \"nil\"))\n\n(defmethod print-dup nil [o w] (print-method o w))\n\n(defn print-ctor [o print-args ^Writer w]\n  (.write w \"#=(\")\n  (.write w (.getName ^Class (class o)))\n  (.write w \". \")\n  (print-args o w)\n  (.write w \")\"))\n\n(defn- print-tagged-object [o rep ^Writer w]\n  (when (instance? clojure.lang.IMeta o)\n    (print-meta o w))\n  (if clojure.lang.RemoteRepl/connected\n    (.write w (str \"#remote-ref \\\"\" (clojure.lang.RemoteRef/register o) \"\\\"\"))\n    (do\n      (.write w \"#object[\")\n  \t  (let [c (class o)]\n        (if (.isArray c)\n          (print-method (.getName c) w)\n          (.write w (.getName c))))\n      (.write w \" \")\n  \t  (.write w (format \"0x%x \" (System/identityHashCode o)))\n  \t  (print-method rep w)\n  \t  (.write w \"]\"))))\n\n(defn- print-object [o, ^Writer w]\n  (if clojure.lang.RemoteRepl/connected\n    (.write w (str \"#remote-ref \\\"\" (clojure.lang.RemoteRef/register o) \"\\\"\"))\n    (print-tagged-object o (str o) w)))\n\n(defmethod print-method Object [o, ^Writer w]\n  (print-object o w))\n\n(defmethod print-method clojure.lang.Keyword [o, ^Writer w]\n  (.write w (str o)))\n\n(defmethod print-dup clojure.lang.Keyword [o w] (print-method o w))\n\n(defmethod print-method clojure.lang.Selector [^clojure.lang.Selector o, ^Writer w]\n  (.write w (str \"#sel \\\"\" (. o sel) \"\\\"\")))\n\n(defmethod print-dup clojure.lang.Selector [o w] (print-method o w))\n\n(defmethod print-method Number [o, ^Writer w]\n  (.write w (str o)))\n\n(defmethod print-dup Number [o, ^Writer w]\n  (print-ctor o\n              (fn [o w]\n                  (print-dup (str o) w))\n              w))\n\n(defmethod print-dup clojure.lang.Fn [o, ^Writer w]\n  (print-ctor o (fn [o w]) w))\n\n(prefer-method print-dup clojure.lang.IPersistentCollection clojure.lang.Fn)\n(prefer-method print-dup java.util.Map clojure.lang.Fn)\n(prefer-method print-dup java.util.Collection clojure.lang.Fn)\n\n(defmethod print-method Boolean [o, ^Writer w]\n  (.write w (str o)))\n\n(defmethod print-dup Boolean [o w] (print-method o w))\n\n(defmethod print-method clojure.lang.Symbol [o, ^Writer w]\n  (print-simple o w))\n\n(defmethod print-dup clojure.lang.Symbol [o w] (print-method o w))\n\n(defmethod print-method clojure.lang.Var [o, ^Writer w]\n  (print-simple o w))\n\n(defmethod print-dup clojure.lang.Var [^clojure.lang.Var o, ^Writer w]\n  (.write w (str \"#=(var \" (.name (.ns o)) \"/\" (.sym o) \")\")))\n\n(defmethod print-method clojure.lang.ISeq [o, ^Writer w]\n  (print-meta o w)\n  (print-sequential \"(\" pr-on \" \" \")\" o w))\n\n(defmethod print-dup clojure.lang.ISeq [o w] (print-method o w))\n(defmethod print-dup clojure.lang.IPersistentList [o w] (print-method o w))\n(prefer-method print-method clojure.lang.ISeq clojure.lang.IPersistentCollection)\n(prefer-method print-dup clojure.lang.ISeq clojure.lang.IPersistentCollection)\n(prefer-method print-method clojure.lang.ISeq java.util.Collection)\n(prefer-method print-dup clojure.lang.ISeq java.util.Collection)\n\n\n\n(defmethod print-dup java.util.Collection [o, ^Writer w]\n (print-ctor o #(print-sequential \"[\" print-dup \" \" \"]\" %1 %2) w))\n\n(defmethod print-dup clojure.lang.IPersistentCollection [o, ^Writer w]\n  (print-meta o w)\n  (.write w \"#=(\")\n  (.write w (.getName ^Class (class o)))\n  (.write w \"/create \")\n  (print-sequential \"[\" print-dup \" \" \"]\" o w)\n  (.write w \")\"))\n\n(prefer-method print-dup clojure.lang.IPersistentCollection java.util.Collection)\n\n(def ^{:tag String\n       :doc \"Returns escape string for char or nil if none\"\n       :added \"1.0\"}\n  char-escape-string\n    {\\newline \"\\\\n\"\n     \\tab  \"\\\\t\"\n     \\return \"\\\\r\"\n     \\\" \"\\\\\\\"\"\n     \\\\  \"\\\\\\\\\"\n     \\formfeed \"\\\\f\"\n     \\backspace \"\\\\b\"})\n\n(defmethod print-method String [^String s, ^Writer w]\n  (if (or *print-dup* *print-readably*)\n    (do (.append w \\\")\n      (dotimes [n (count s)]\n        (let [c (.charAt s n)\n              e (char-escape-string c)]\n          (if e (.write w e) (.append w c))))\n      (.append w \\\"))\n    (.write w s))\n  nil)\n\n(defmethod print-dup String [s w] (print-method s w))\n\n(defmethod print-method clojure.lang.IPersistentVector [v, ^Writer w]\n  (print-meta v w)\n  (print-sequential \"[\" pr-on \" \" \"]\" v w))\n\n(defn- print-map [m print-one w]\n  (print-sequential\n   \"{\"\n   (fn [e  ^Writer w]\n     (do (print-one (key e) w) (.append w \\space) (print-one (val e) w)))\n   \", \"\n   \"}\"\n   (seq m) w))\n\n(defmethod print-method clojure.lang.IPersistentMap [m, ^Writer w]\n  (print-meta m w)\n  (print-map m pr-on w))\n\n(defmethod print-dup java.util.Map [m, ^Writer w]\n  (print-ctor m #(print-map (seq %1) print-dup %2) w))\n\n(defmethod print-dup clojure.lang.IPersistentMap [m, ^Writer w]\n  (print-meta m w)\n  (.write w \"#=(\")\n  (.write w (.getName (class m)))\n  (.write w \"/create \")\n  (print-map m print-dup w)\n  (.write w \")\"))\n\n;; java.util\n(prefer-method print-method clojure.lang.IPersistentCollection java.util.Collection)\n(prefer-method print-method clojure.lang.IPersistentCollection java.util.RandomAccess)\n(prefer-method print-method java.util.RandomAccess java.util.List)\n(prefer-method print-method clojure.lang.IPersistentCollection java.util.Map)\n\n(defmethod print-method java.util.List [c, ^Writer w]\n  (if *print-readably*\n    (do\n      (print-meta c w)\n      (print-sequential \"(\" pr-on \" \" \")\" c w))\n    (print-object c w)))\n\n(defmethod print-method java.util.RandomAccess [v, ^Writer w]\n  (if *print-readably*\n    (do\n      (print-meta v w)\n      (print-sequential \"[\" pr-on \" \" \"]\" v w))\n    (print-object v w)))\n\n(defmethod print-method java.util.Map [m, ^Writer w]\n  (if *print-readably*\n    (do\n      (print-meta m w)\n      (print-map m pr-on w))\n    (print-object m w)))\n\n(defmethod print-method java.util.Set [s, ^Writer w]\n  (if *print-readably*\n    (do\n      (print-meta s w)\n      (print-sequential \"#{\" pr-on \" \" \"}\" (seq s) w))\n    (print-object s w)))\n\n;; Records\n\n(defmethod print-method clojure.lang.IRecord [r, ^Writer w]\n  (print-meta r w)\n  (.write w \"#\")\n  (.write w (.getName (class r)))\n  (print-map r pr-on w))\n\n(defmethod print-dup clojure.lang.IRecord [r, ^Writer w]\n  (print-meta r w)\n  (.write w \"#\")\n  (.write w (.getName (class r)))\n  (if *verbose-defrecords*\n    (print-map r print-dup w)\n    (print-sequential \"[\" pr-on \", \" \"]\" (vals r) w)))\n\n(prefer-method print-method clojure.lang.IRecord java.util.Map)\n(prefer-method print-method clojure.lang.IRecord clojure.lang.IPersistentMap)\n(prefer-method print-dup clojure.lang.IRecord clojure.lang.IPersistentMap)\n(prefer-method print-dup clojure.lang.IPersistentCollection java.util.Map)\n(prefer-method print-dup clojure.lang.IRecord clojure.lang.IPersistentCollection)\n(prefer-method print-dup clojure.lang.IRecord java.util.Map)\n\n(defmethod print-method clojure.lang.IPersistentSet [s, ^Writer w]\n  (print-meta s w)\n  (print-sequential \"#{\" pr-on \" \" \"}\" (seq s) w))\n\n(def ^{:tag String\n       :doc \"Returns name string for char or nil if none\"\n       :added \"1.0\"}\n char-name-string\n   {\\newline \"newline\"\n    \\tab \"tab\"\n    \\space \"space\"\n    \\backspace \"backspace\"\n    \\formfeed \"formfeed\"\n    \\return \"return\"})\n\n(defmethod print-method java.lang.Character [^Character c, ^Writer w]\n  (if (or *print-dup* *print-readably*)\n    (do (.append w \\\\)\n        (let [n (char-name-string c)]\n          (if n (.write w n) (.append w c))))\n    (.append w c))\n  nil)\n\n(defmethod print-dup java.lang.Character [c w] (print-method c w))\n(defmethod print-dup java.lang.Long [o w] (print-method o w))\n(defmethod print-dup java.lang.Double [o w] (print-method o w))\n(defmethod print-dup clojure.lang.Ratio [o w] (print-method o w))\n(defmethod print-dup java.math.BigDecimal [o w] (print-method o w))\n(defmethod print-dup clojure.lang.BigInt [o w] (print-method o w))\n(defmethod print-dup clojure.lang.PersistentHashMap [o w] (print-method o w))\n(defmethod print-dup clojure.lang.PersistentHashSet [o w] (print-method o w))\n(defmethod print-dup clojure.lang.PersistentVector [o w] (print-method o w))\n(defmethod print-dup clojure.lang.LazilyPersistentVector [o w] (print-method o w))\n\n(def primitives-classnames\n  {Float/TYPE \"Float/TYPE\"\n   Integer/TYPE \"Integer/TYPE\"\n   Long/TYPE \"Long/TYPE\"\n   Boolean/TYPE \"Boolean/TYPE\"\n   Character/TYPE \"Character/TYPE\"\n   Double/TYPE \"Double/TYPE\"\n   Byte/TYPE \"Byte/TYPE\"\n   Short/TYPE \"Short/TYPE\"})\n\n(defmethod print-method Class [^Class c, ^Writer w]\n  (.write w (.getName c)))\n\n(defmethod print-dup Class [^Class c, ^Writer w]\n  (cond\n    (.isPrimitive c) (do\n                       (.write w \"#=(identity \")\n                       (.write w ^String (primitives-classnames c))\n                       (.write w \")\"))\n    (.isArray c) (do\n                   (.write w \"#=(java.lang.Class/forName \\\"\")\n                   (.write w (.getName c))\n                   (.write w \"\\\")\"))\n    :else (do\n            (.write w \"#=\")\n            (.write w (.getName c)))))\n\n(defmethod print-method java.math.BigDecimal [b, ^Writer w]\n  (.write w (str b))\n  (.write w \"M\"))\n\n(defmethod print-method clojure.lang.BigInt [b, ^Writer w]\n  (.write w (str b))\n  (.write w \"N\"))\n\n(defmethod print-method java.util.regex.Pattern [p ^Writer w]\n  (.write w \"#\\\"\")\n  (loop [[^Character c & r :as s] (seq (.pattern ^java.util.regex.Pattern p))\n         qmode false]\n    (when s\n      (cond\n        (= c \\\\) (let [[^Character c2 & r2] r]\n                   (.append w \\\\)\n                   (.append w c2)\n                   (if qmode\n                      (recur r2 (not= c2 \\E))\n                      (recur r2 (= c2 \\Q))))\n        (= c \\\") (do\n                   (if qmode\n                     (.write w \"\\\\E\\\\\\\"\\\\Q\")\n                     (.write w \"\\\\\\\"\"))\n                   (recur r qmode))\n        :else    (do\n                   (.append w c)\n                   (recur r qmode)))))\n  (.append w \\\"))\n\n(defmethod print-dup java.util.regex.Pattern [p ^Writer w] (print-method p w))\n\n(defmethod print-dup clojure.lang.Namespace [^clojure.lang.Namespace n ^Writer w]\n  (.write w \"#=(find-ns \")\n  (print-dup (.name n) w)\n  (.write w \")\"))\n\n(defn- deref-as-map [^clojure.lang.IDeref o]\n  (let [pending (and (instance? clojure.lang.IPending o)\n                     (not (.isRealized ^clojure.lang.IPending o)))\n        [ex val]\n        (when-not pending\n          (try [false (deref o)]\n               (catch Throwable e\n                 [true e])))]\n    {:status\n     (cond\n      (or ex\n          (and (instance? clojure.lang.Agent o)\n               (agent-error o)))\n      :failed\n\n      pending\n      :pending\n\n      :else\n      :ready)\n\n     :val val}))\n\n(defmethod print-method clojure.lang.IDeref [o ^Writer w]\n  (print-tagged-object o (deref-as-map o) w))\n\n(defmethod print-method StackTraceElement [^StackTraceElement o ^Writer w]\n  (print-method [(symbol (.getClassName o)) (symbol (.getMethodName o)) (.getFileName o) (.getLineNumber o)] w))\n\n(defn Throwable->map\n  \"Constructs a data representation for a Throwable.\"\n  {:added \"1.7\"}\n  [^Throwable o]\n  (let [base (fn [^Throwable t]\n               (let [m {:type (class t)\n                        :message (.getLocalizedMessage t)\n                        :at (get (.getStackTrace t) 0)}\n                     data (ex-data t)]\n                 (if data\n                   (assoc m :data data)\n                   m)))\n        via (loop [via [], ^Throwable t o]\n              (if t\n                (recur (conj via t) (.getCause t))\n                via))\n        ^Throwable root (peek via)\n        m {:cause (.getLocalizedMessage root)\n           :via (vec (map base via))\n           :trace (vec (.getStackTrace ^Throwable (or root o)))}\n        data (ex-data root)]\n    (if data\n      (assoc m :data data)\n      m)))\n\n(defn- print-throwable [^Throwable o ^Writer w]\n  (.write w \"#error {\\n :cause \")\n  (let [{:keys [cause data via trace]} (Throwable->map o)\n        print-via #(do (.write w \"{:type \")\n\t\t               (print-method (:type %) w)\n\t\t\t\t\t   (.write w \"\\n   :message \")\n\t\t\t\t\t   (print-method (:message %) w)\n             (when-let [data (:data %)]\n               (.write w \"\\n   :data \")\n               (print-method data w))\n\t\t\t\t\t   (.write w \"\\n   :at \")\n\t\t\t\t\t   (print-method (:at %) w)\n\t\t\t\t\t   (.write w \"}\"))]\n    (print-method cause w)\n    (when data\n      (.write w \"\\n :data \")\n      (print-method data w))\n    (when via\n      (.write w \"\\n :via\\n [\")\n      (when-let [fv (first via)]\n\t    (print-via fv)\n        (doseq [v (rest via)]\n          (.write w \"\\n  \")\n\t\t  (print-via v)))\n      (.write w \"]\"))\n    (when trace\n      (.write w \"\\n :trace\\n [\")\n      (when-let [ft (first trace)]\n        (print-method ft w)\n        (doseq [t (rest trace)]\n          (.write w \"\\n  \")\n          (print-method t w)))\n      (.write w \"]\")))\n  (.write w \"}\"))\n\n(defmethod print-method Throwable [^Throwable o ^Writer w]\n  (print-throwable o w))\n\n(defmethod print-method clojure.lang.TaggedLiteral [o ^Writer w]\n  (.write w \"#\")\n  (print-method (:tag o) w)\n  (.write w \" \")\n  (print-method (:form o) w))\n\n(defmethod print-method clojure.lang.ReaderConditional [o ^Writer w]\n  (.write w \"#?\")\n  (when (:splicing? o) (.write w \"@\"))\n  (print-method (:form o) w))\n\n(def ^{:private true} print-initialized true)\n"
  },
  {
    "path": "src/clj/clojure/core_proxy.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(in-ns 'clojure.core)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; proxy ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(import\n '(clojure.asm ClassWriter ClassVisitor Opcodes Type)\n '(java.lang.reflect Modifier Constructor)\n '(clojure.asm.commons Method GeneratorAdapter)\n '(clojure.lang Var IProxy Reflector DynamicClassLoader Compiler IPersistentMap PersistentHashMap RT))\n\n(defn method-sig [^java.lang.reflect.Method meth]\n  [(. meth (getName)) (seq (. meth (getParameterTypes))) (. meth getReturnType)])\n\n(defn- most-specific [rtypes]\n  (or (some (fn [t] (when (every? #(isa? t %) rtypes) t)) rtypes)\n    (throw (Exception. \"Incompatible return types\"))))\n\n(defn- group-by-sig\n \"takes a collection of [msig meth] and returns a seq of maps from return-types to meths.\"\n  [coll]\n  (vals (reduce1 (fn [m [msig meth]]\n                  (let [rtype (peek msig)\n                        argsig (pop msig)]\n                    (assoc m argsig (assoc (m argsig {}) rtype meth))))\n          {} coll)))\n\n(defn proxy-name\n {:tag String}\n [^Class super interfaces]\n  (let [inames (into1 (sorted-set) (map #(.getName ^Class %) interfaces))]\n    (apply str (.replace (str *ns*) \\- \\_) \".proxy\"\n      (interleave (repeat \"$\")\n        (concat\n          [(.getName super)]\n          (map #(subs % (inc (.lastIndexOf ^String % \".\"))) inames)\n          [(Integer/toHexString (hash inames))])))))\n\n(defn- generate-proxy [^Class super interfaces]\n  (let [cv (new ClassWriter (. ClassWriter COMPUTE_MAXS))]\n    (binding [*source-writer* (.getSc cv)]\n      (let [sname (proxy-name super interfaces)\n            cname (.replace sname \\. \\/) ;(str \"clojure/lang/\" (gensym \"Proxy__\"))\n            ctype (. Type (getObjectType cname))\n            lastdot (.lastIndexOf sname \".\")\n            classname (subs sname (inc lastdot))\n            packagename (subs sname 0 lastdot)\n            iname (fn [^Class c] (.. Type (getType c) (getInternalName)))\n            fmap \"__clojureFnMap\"\n            totype (fn [^Class c] (. Type (getType c)))\n            to-types (fn [cs] (if (pos? (count cs))\n                                (into-array (map totype cs))\n                                (make-array Type 0)))\n            super-type ^Type (totype super)\n            imap-type ^Type (totype IPersistentMap)\n            ifn-type (totype clojure.lang.IFn)\n            obj-type (totype Object)\n            sym-type (totype clojure.lang.Symbol)\n            rt-type  (totype clojure.lang.RT)\n            ex-type  (totype java.lang.UnsupportedOperationException)\n            gen-bridge\n            (fn [^java.lang.reflect.Method meth ^java.lang.reflect.Method dest]\n              (let [pclasses (. meth (getParameterTypes))\n                    ptypes (to-types pclasses)\n                    rclass (. meth (getReturnType))\n                    rtype ^Type (totype rclass)\n                    mname (. meth (getName))\n                    m (new Method mname rtype ptypes)\n                    dtype (totype (.getDeclaringClass dest))\n                    dm (new Method (. dest (getName)) (totype (. dest (getReturnType))) (to-types (. dest (getParameterTypes))))\n                    gen (new GeneratorAdapter (bit-or (. Opcodes ACC_PUBLIC) (. Opcodes ACC_BRIDGE)) m nil nil cv)]\n                (comment (Compiler/emitSource (str \"public \" (.getCanonicalName rclass) \" \" mname \"(\"\n                                                   (apply str (interpose \", \" (map #(str (.getCanonicalName (nth pclasses %)) \" p\" %) (range (count pclasses))))) \") {\"))\n                         (Compiler/tab))\n                (. gen (visitCode))\n                (. gen (loadThis))\n                (dotimes [i (count ptypes)]\n                  (. gen (loadArg i)))\n                (if (-> dest .getDeclaringClass .isInterface)\n                  (. gen (invokeInterface dtype dm))\n                  (. gen (invokeVirtual dtype dm)))\n                (comment (Compiler/emitSource (str (if (= (.getCanonicalName rclass) \"void\") \"\" \"return \")\n                                                   \"super.\" mname \"(\" (apply str (interpose \", \" (map #(str \"p\" %) (range (count pclasses))))) \");\"))\n                         (Compiler/untab)\n                         (Compiler/emitSource \"}\"))\n                (. gen (returnValue))\n                (. gen (endMethod))))\n            gen-method\n            (fn [^java.lang.reflect.Method meth else-gen]\n              (let [pclasses (. meth (getParameterTypes))\n                    abstract? (Modifier/isAbstract (.getModifiers meth))\n                    ptypes (to-types pclasses)\n                    rclass (. meth (getReturnType))\n                    extypes (. meth (getExceptionTypes))\n                    exdecl (reduce1 str (interpose \", \" (map #(.getCanonicalName %) extypes)))\n                    rcanonical (.getCanonicalName rclass)\n                    rtype ^Type (totype rclass)\n                    mname (. meth (getName))\n                    m (new Method mname rtype ptypes)\n                    gen (new GeneratorAdapter (. Opcodes ACC_PUBLIC) m nil nil cv)\n                    else-label (. gen (newLabel))\n                    end-label (. gen (newLabel))\n                    decl-type (. Type (getType (. meth (getDeclaringClass))))]\n                (. gen (visitCode))\n                (Compiler/emitSource (str \"public \" (.getCanonicalName rclass) \" \" mname  \"(\"\n                                          (apply str (interpose \", \" (map #(str (.getCanonicalName (nth pclasses %)) \" p\" %) (range (count pclasses))))) \")\"\n                                          (if (empty? exdecl) \"\" (str \" throws \" exdecl \" \")) \" {\"))\n                (Compiler/tab)\n                (if (> (count pclasses) 18)\n                  (else-gen gen m)\n                  (do\n                    (. gen (loadThis))\n                    (. gen (getField ctype fmap imap-type))\n\n                    (. gen (push mname))\n                                        ;lookup fn in map\n                    (Compiler/emitSource (str \"final Object value = RT.get(this.__clojureFnMap, \\\"\" mname \"\\\");\"))\n                    (. gen (invokeStatic rt-type (. Method (getMethod \"Object get(Object, Object)\"))))\n                    (. gen (dup))\n                    (. gen (ifNull else-label))\n                                        ;if found\n                    (.checkCast gen ifn-type)\n                    (. gen (loadThis))\n                                        ;box args\n                    (dotimes [i (count ptypes)]\n                      (. gen (loadArg i))\n                      (. clojure.lang.Compiler$HostExpr (emitBoxReturn nil gen (nth pclasses i) \"\")))\n                                        ;call fn\n                    (. gen (invokeInterface ifn-type (new Method \"invoke\" obj-type\n                                                          (into-array (cons obj-type\n                                                                            (replicate (count ptypes) obj-type))))))\n                                        ;unbox return\n                    ;return (value != null) ? ((IMapEntry)((IFn)value).invoke(this, o)) : super.entryAt(o);\n                    (let [param-list (apply str (interpose \", \" (map #(str \"p\" %) (range (count pclasses)))))]\n                      (if (= rcanonical \"void\")\n                        (Compiler/emitSource (str \"if (value != null) {\" \"((IFn)value).invoke(this\"\n                                                  (if (empty? param-list) \"\" \", \") param-list \"); } \" (if abstract? \"\" (str \"else { super.\" mname \"(\" param-list \"); }\"))))\n                        (Compiler/emitSource (str \"return (value != null) ? \"  \"(\" rcanonical \")\"\n                                                  (. gen (unbox rtype (str \"((IFn)value).invoke(this\" (if (empty? param-list) \"\" \", \") param-list \")\")))\n                                                  \" : \" (if abstract? \"null;\" (str \"super.\" mname \"(\" param-list \");\"))))))\n                    (. gen (unbox rtype))\n                    (when (= (. rtype (getSort)) (. Type VOID))\n                      (. gen (pop)))\n                    (. gen (goTo end-label))\n\n                                        ;else call supplied alternative generator\n                    (Var/pushThreadBindings {Compiler/STOP_EMIT_SOURCE true})\n                    (. gen (mark else-label))\n\n                    (. gen (pop))\n\n                    (else-gen gen m)\n                    (Var/popThreadBindings)\n\n                    (. gen (mark end-label))))\n                (Compiler/untab)\n                (Compiler/emitSource \"}\")\n                (. gen (returnValue))\n                (. gen (endMethod))))]\n\n        (Compiler/emitSource (str \"package \" packagename \";\"))\n        (Compiler/emitSource)\n        (Compiler/emitSource \"import java.util.*;\")\n        (Compiler/emitSource \"import clojure.lang.*;\")\n        (Compiler/emitSource)\n        (Compiler/emitSource (str \"public class \" classname \" extends \" (.getCanonicalName super)  \" implements \"\n                                  (apply str (interpose \", \" (cons \"IProxy\" (map #(.getCanonicalName %) interfaces)))) \" {\"))\n        (Compiler/tab)\n\n        (Compiler/emitSource)\n        (Compiler/emitSource \"private volatile IPersistentMap __clojureFnMap;\")\n        (Compiler/emitSource)\n                                        ;start class definition\n        (. cv (visit (. Opcodes V1_5) (+ (. Opcodes ACC_PUBLIC) (. Opcodes ACC_SUPER))\n                     cname nil (iname super)\n                     (into-array (map iname (cons IProxy interfaces)))))\n                                        ;add field for fn mappings\n        (. cv (visitField (+ (. Opcodes ACC_PRIVATE) (. Opcodes ACC_VOLATILE))\n                          fmap (. imap-type (getDescriptor)) nil nil))\n                                        ;add ctors matching/calling super's\n        (doseq [^Constructor ctor (. super (getDeclaredConstructors))]\n          (when-not (. Modifier (isPrivate (. ctor (getModifiers))))\n            (let [pclasses (. ctor (getParameterTypes))\n                  ptypes (to-types pclasses)\n                  m (new Method \"<init>\" (. Type VOID_TYPE) ptypes)\n                  gen (new GeneratorAdapter (. Opcodes ACC_PUBLIC) m nil nil cv)]\n              (. gen (visitCode))\n              (Compiler/emitSource (str \"public \" classname \"(\"\n                                        (apply str (interpose \", \" (map #(str (.getCanonicalName (nth pclasses %)) \" p\" %) (range (count pclasses))))) \") {\"))\n              (Compiler/tab)\n                                        ;call super ctor\n              (. gen (loadThis))\n              (. gen (dup))\n              (. gen (loadArgs))\n              (. gen (invokeConstructor super-type m))\n              (Compiler/emitSource (str \"super(\" (apply str (interpose \", \" (map #(str \"p\" %) (range (count pclasses))))) \");\"))\n\n              (Compiler/untab)\n              (Compiler/emitSource \"}\")\n\n              (. gen (returnValue))\n              (. gen (endMethod)))))\n                                        ;add IProxy methods\n        (let [m (. Method (getMethod \"void __initClojureFnMappings(clojure.lang.IPersistentMap)\"))\n              gen (new GeneratorAdapter (. Opcodes ACC_PUBLIC) m nil nil cv)]\n          (. gen (visitCode))\n          (. gen (loadThis))\n          (. gen (loadArgs))\n          (. gen (putField ctype fmap imap-type))\n\n          (. gen (returnValue))\n          (. gen (endMethod)))\n\n        (Compiler/emitSource (str \"public void __initClojureFnMappings(final IPersistentMap _clojureFnMap) {\"))\n        (Compiler/tab)\n        (Compiler/emitSource \"this.__clojureFnMap = _clojureFnMap;\")\n        (Compiler/untab)\n        (Compiler/emitSource (str \"}\"))\n\n        (let [m (. Method (getMethod \"void __updateClojureFnMappings(clojure.lang.IPersistentMap)\"))\n              gen (new GeneratorAdapter (. Opcodes ACC_PUBLIC) m nil nil cv)]\n          (. gen (visitCode))\n          (. gen (loadThis))\n          (. gen (dup))\n          (. gen (getField ctype fmap imap-type))\n          (.checkCast gen (totype clojure.lang.IPersistentCollection))\n          (. gen (loadArgs))\n          (. gen (invokeInterface (totype clojure.lang.IPersistentCollection)\n                                  (. Method (getMethod \"clojure.lang.IPersistentCollection cons(Object)\"))))\n          (. gen (checkCast imap-type))\n          (. gen (putField ctype fmap imap-type))\n\n          (. gen (returnValue))\n          (. gen (endMethod)))\n\n        (Compiler/emitSource (str \"public void __updateClojureFnMappings(final IPersistentMap persistentMap) {\"))\n        (Compiler/tab)\n        (Compiler/emitSource \"this.__clojureFnMap = (IPersistentMap)((IPersistentCollection)this.__clojureFnMap).cons(persistentMap);\")\n        (Compiler/untab)\n        (Compiler/emitSource (str \"}\"))\n\n        (let [m (. Method (getMethod \"clojure.lang.IPersistentMap __getClojureFnMappings()\"))\n              gen (new GeneratorAdapter (. Opcodes ACC_PUBLIC) m nil nil cv)]\n          (. gen (visitCode))\n          (. gen (loadThis))\n          (. gen (getField ctype fmap imap-type))\n          (. gen (returnValue))\n          (. gen (endMethod)))\n\n        (Compiler/emitSource (str \"public IPersistentMap __getClojureFnMappings() {\"))\n        (Compiler/tab)\n        (Compiler/emitSource \"return this.__clojureFnMap;\")\n        (Compiler/untab)\n        (Compiler/emitSource (str \"}\"))\n\n                                        ;calc set of supers' non-private instance methods\n        (let [[mm considered]\n              (loop [mm {} considered #{} c super]\n                (if c\n                  (let [[mm considered]\n                        (loop [mm mm\n                               considered considered\n                               meths (concat\n                                      (seq (. c (getDeclaredMethods)))\n                                      (seq (. c (getMethods))))]\n                          (if (seq meths)\n                            (let [^java.lang.reflect.Method meth (first meths)\n                                  mods (. meth (getModifiers))\n                                  mk (method-sig meth)]\n                              (if (or (considered mk)\n                                      (not (or (Modifier/isPublic mods) (Modifier/isProtected mods)))\n                                        ;(. Modifier (isPrivate mods))\n                                      (. Modifier (isStatic mods))\n                                      (. Modifier (isFinal mods))\n                                      (= \"finalize\" (.getName meth)))\n                                (recur mm (conj considered mk) (next meths))\n                                (recur (assoc mm mk meth) (conj considered mk) (next meths))))\n                            [mm considered]))]\n                    (recur mm considered (. c (getSuperclass))))\n                  [mm considered]))\n              ifaces-meths (into1 {}\n                                  (for [^Class iface interfaces meth (. iface (getMethods))\n                                        :let [msig (method-sig meth)] :when (not (considered msig))]\n                                    {msig meth}))\n              mgroups (group-by-sig (concat mm ifaces-meths))\n              rtypes (map #(most-specific (keys %)) mgroups)\n              mb (map #(vector (%1 %2) (vals (dissoc %1 %2))) mgroups rtypes)\n              bridge? (reduce1 into1 #{} (map second mb))\n              ifaces-meths (remove bridge? (vals ifaces-meths))\n              mm (remove bridge? (vals mm))]\n                                        ;add methods matching supers', if no mapping -> call super\n          (doseq [[^java.lang.reflect.Method dest bridges] mb\n                  ^java.lang.reflect.Method meth bridges]\n            (gen-bridge meth dest))\n          (doseq [^java.lang.reflect.Method meth mm]\n            (gen-method meth\n                        (fn [^GeneratorAdapter gen ^Method m]\n                          (. gen (loadThis))\n                                        ;push args\n                          (. gen (loadArgs))\n                                        ;call super\n                          (Compiler/emitSource (str \"return \" \"super.\" (. meth (getName)) \"(\"\n                                                    (apply str (interpose \", \" (map #(str \"p\" %) (range (count (. meth (getParameterTypes)))))))  \");\"))\n                          (. gen (visitMethodInsn (. Opcodes INVOKESPECIAL)\n                                                  (. super-type (getInternalName))\n                                                  (. m (getName))\n                                                  (. m (getDescriptor)))))))\n\n                                        ;add methods matching interfaces', if no mapping -> throw\n          (doseq [^java.lang.reflect.Method meth ifaces-meths]\n            (gen-method meth\n                        (fn [^GeneratorAdapter gen ^Method m]\n                          (. gen (throwException ex-type (. m (getName))))))))\n\n                                        ;finish class def\n        (. cv (visitEnd))\n        (Compiler/untab)\n        (Compiler/emitSource \"}\")\n        (when *compile-files*\n          (Compiler/writeSourceFile cname (str *source-writer*)))\n        [cname (. cv toByteArray)]))))\n\n(defn- get-super-and-interfaces [bases]\n  (if (. ^Class (first bases) (isInterface))\n    [Object bases]\n    [(first bases) (next bases)]))\n\n(defn get-proxy-class\n  \"Takes an optional single class followed by zero or more\n  interfaces. If not supplied class defaults to Object.  Creates an\n  returns an instance of a proxy class derived from the supplied\n  classes. The resulting value is cached and used for any subsequent\n  requests for the same class set. Returns a Class object.\"\n  {:added \"1.0\"}\n  [& bases]\n    (let [[super interfaces] (get-super-and-interfaces bases)\n          pname (proxy-name super interfaces)]\n      (or (RT/loadClassForName pname)\n          (let [[cname bytecode] (generate-proxy super interfaces)]\n            (. ^DynamicClassLoader (deref clojure.lang.Compiler/LOADER) (defineClass pname bytecode [super interfaces]))))))\n\n(defn construct-proxy\n  \"Takes a proxy class and any arguments for its superclass ctor and\n  creates and returns an instance of the proxy.\"\n  {:added \"1.0\"}\n  [c & ctor-args]\n    (. Reflector (invokeConstructor c (to-array ctor-args))))\n\n(defn init-proxy\n  \"Takes a proxy instance and a map of strings (which must\n  correspond to methods of the proxy superclass/superinterfaces) to\n  fns (which must take arguments matching the corresponding method,\n  plus an additional (explicit) first arg corresponding to this, and\n  sets the proxy's fn map.  Returns the proxy.\"\n  {:added \"1.0\"}\n  [^IProxy proxy mappings]\n    (. proxy (__initClojureFnMappings mappings))\n    proxy)\n\n(defn update-proxy\n  \"Takes a proxy instance and a map of strings (which must\n  correspond to methods of the proxy superclass/superinterfaces) to\n  fns (which must take arguments matching the corresponding method,\n  plus an additional (explicit) first arg corresponding to this, and\n  updates (via assoc) the proxy's fn map. nil can be passed instead of\n  a fn, in which case the corresponding method will revert to the\n  default behavior. Note that this function can be used to update the\n  behavior of an existing instance without changing its identity.\n  Returns the proxy.\"\n  {:added \"1.0\"}\n  [^IProxy proxy mappings]\n    (. proxy (__updateClojureFnMappings mappings))\n    proxy)\n\n(defn proxy-mappings\n  \"Takes a proxy instance and returns the proxy's fn map.\"\n  {:added \"1.0\"}\n  [^IProxy proxy]\n    (. proxy (__getClojureFnMappings)))\n\n(defmacro proxy\n  \"class-and-interfaces - a vector of class names\n\n  args - a (possibly empty) vector of arguments to the superclass\n  constructor.\n\n  f => (name [params*] body) or\n  (name ([params*] body) ([params+] body) ...)\n\n  Expands to code which creates a instance of a proxy class that\n  implements the named class/interface(s) by calling the supplied\n  fns. A single class, if provided, must be first. If not provided it\n  defaults to Object.\n\n  The interfaces names must be valid interface types. If a method fn\n  is not provided for a class method, the superclass methd will be\n  called. If a method fn is not provided for an interface method, an\n  UnsupportedOperationException will be thrown should it be\n  called. Method fns are closures and can capture the environment in\n  which proxy is called. Each method fn takes an additional implicit\n  first arg, which is bound to 'this. Note that while method fns can\n  be provided to override protected methods, they have no other access\n  to protected members, nor to super, as these capabilities cannot be\n  proxied.\"\n  {:added \"1.0\"}\n  [class-and-interfaces args & fs]\n   (let [bases (map #(or (resolve %) (throw (Exception. (str \"Can't resolve: \" %))))\n                    class-and-interfaces)\n         [super interfaces] (get-super-and-interfaces bases)\n         compile-effect (when *compile-files*\n                          (let [[cname bytecode] (generate-proxy super interfaces)]\n                            (clojure.lang.Compiler/writeClassFile cname bytecode)))\n         pc-effect (apply get-proxy-class bases)\n         pname (proxy-name super interfaces)]\n     ;remember the class to prevent it from disappearing before use\n     (intern *ns* (symbol pname) pc-effect)\n     `(let [;pc# (get-proxy-class ~@class-and-interfaces)\n            p# (new ~(symbol pname) ~@args)] ;(construct-proxy pc# ~@args)]\n        (init-proxy p#\n         ~(loop [fmap {} fs fs]\n            (if fs\n              (let [[sym & meths] (first fs)\n                    meths (if (vector? (first meths))\n                            (list meths)\n                            meths)\n                    meths (map (fn [[params & body]]\n                                   (cons (apply vector 'this params) body))\n                               meths)]\n                (if-not (contains? fmap (name sym))\n                (recur (assoc fmap (name sym) (cons `fn meths)) (next fs))\n\t\t           (throw (IllegalArgumentException.\n\t\t\t              (str \"Method '\" (name sym) \"' redefined\")))))\n              fmap)))\n        p#)))\n\n(defn proxy-call-with-super [call this meth]\n (let [m (proxy-mappings this)]\n    (update-proxy this (assoc m meth nil))\n    (try\n      (call)\n      (finally (update-proxy this m)))))\n\n(defmacro proxy-super\n  \"Use to call a superclass method in the body of a proxy method.\n  Note, expansion captures 'this\"\n  {:added \"1.0\"}\n  [meth & args]\n `(proxy-call-with-super (fn [] (. ~'this ~meth ~@args))  ~'this ~(name meth)))\n\n(comment\n(defn bean\n  \"Takes a Java object and returns a read-only implementation of the\n  map abstraction based upon its JavaBean properties.\"\n  {:added \"1.0\"}\n  [^Object x]\n  (let [c (. x (getClass))\n\tpmap (reduce1 (fn [m ^java.beans.PropertyDescriptor pd]\n\t\t\t (let [name (. pd (getName))\n\t\t\t       method (. pd (getReadMethod))]\n\t\t\t   (if (and method (zero? (alength (. method (getParameterTypes)))))\n\t\t\t     (assoc m (keyword name) (fn [] (clojure.lang.Reflector/prepRet (.getPropertyType pd) (. method (invoke x nil)))))\n\t\t\t     m)))\n\t\t     {}\n\t\t     (seq (.. java.beans.Introspector\n\t\t\t      (getBeanInfo c)\n\t\t\t      (getPropertyDescriptors))))\n\tv (fn [k] ((pmap k)))\n        snapshot (fn []\n                   (reduce1 (fn [m e]\n                             (assoc m (key e) ((val e))))\n                           {} (seq pmap)))]\n    (proxy [clojure.lang.APersistentMap]\n           []\n      (iterator [] (.iterator ^Iterable pmap))\n      (containsKey [k] (contains? pmap k))\n      (entryAt [k] (when (contains? pmap k) (new clojure.lang.MapEntry k (v k))))\n      (valAt ([k] (when (contains? pmap k) (v k)))\n\t     ([k default] (if (contains? pmap k) (v k) default)))\n      (cons [m] (conj (snapshot) m))\n      (count [] (count pmap))\n      (assoc [k v] (assoc (snapshot) k v))\n      (without [k] (dissoc (snapshot) k))\n      (seq [] ((fn thisfn [plseq]\n\t\t  (lazy-seq\n                   (when-let [pseq (seq plseq)]\n                     (cons (new clojure.lang.MapEntry (first pseq) (v (first pseq)))\n                           (thisfn (rest pseq)))))) (keys pmap)))))))"
  },
  {
    "path": "src/clj/clojure/data.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns \n  ^{:author \"Stuart Halloway\",\n    :doc \"Non-core data functions.\"}\n  clojure.data\n  (:require [clojure.set :as set]))\n\n(declare diff)\n\n(defn- atom-diff\n  \"Internal helper for diff.\"\n  [a b]\n  (if (= a b) [nil nil a] [a b nil]))\n\n;; for big things a sparse vector class would be better\n(defn- vectorize\n  \"Convert an associative-by-numeric-index collection into\n   an equivalent vector, with nil for any missing keys\"\n  [m]\n  (when (seq m)\n    (reduce\n     (fn [result [k v]] (assoc result k v))\n     (vec (repeat (apply max (keys m))  nil))\n     m)))\n\n(defn- diff-associative-key\n  \"Diff associative things a and b, comparing only the key k.\"\n  [a b k]\n  (let [va (get a k)\n        vb (get b k)\n        [a* b* ab] (diff va vb)\n        in-a (contains? a k)\n        in-b (contains? b k)\n        same (and in-a in-b\n                  (or (not (nil? ab))\n                      (and (nil? va) (nil? vb))))]\n    [(when (and in-a (or (not (nil? a*)) (not same))) {k a*})\n     (when (and in-b (or (not (nil? b*)) (not same))) {k b*})\n     (when same {k ab})\n     ]))\n\n(defn- diff-associative\n  \"Diff associative things a and b, comparing only keys in ks.\"\n  [a b ks]\n  (reduce\n   (fn [diff1 diff2]\n     (doall (map merge diff1 diff2)))\n   [nil nil nil]\n   (map\n    (partial diff-associative-key a b)\n    ks)))\n\n(defn- diff-sequential\n  [a b]\n  (vec (map vectorize (diff-associative\n                       (if (vector? a) a (vec a))\n                       (if (vector? b) b (vec b))\n                       (range (max (count a) (count b)))))))\n\n(defprotocol ^{:added \"1.3\"} EqualityPartition\n  \"Implementation detail. Subject to change.\"\n  (^{:added \"1.3\"} equality-partition [x] \"Implementation detail. Subject to change.\"))\n\n(defprotocol ^{:added \"1.3\"} Diff\n  \"Implementation detail. Subject to change.\"\n  (^{:added \"1.3\"} diff-similar [a b] \"Implementation detail. Subject to change.\"))\n\n(extend nil\n        Diff\n        {:diff-similar atom-diff})\n\n(extend Object\n        Diff\n        {:diff-similar (fn [a b] ((if (.. a getClass isArray) diff-sequential atom-diff) a b))}\n        EqualityPartition\n        {:equality-partition (fn [x] (if (.. x getClass isArray) :sequential :atom))})\n\n(extend-protocol EqualityPartition\n  nil\n  (equality-partition [x] :atom)\n  \n  java.util.Set\n  (equality-partition [x] :set)\n\n  java.util.List\n  (equality-partition [x] :sequential)\n  \n  java.util.Map\n  (equality-partition [x] :map))\n\n(defn- as-set-value\n  [s]\n  (if (set? s) s (into #{} s)))\n\n(extend-protocol Diff\n  java.util.Set\n  (diff-similar\n   [a b]\n   (let [aval (as-set-value a)\n         bval (as-set-value b)]\n     [(not-empty (set/difference aval bval))\n      (not-empty (set/difference bval aval))\n      (not-empty (set/intersection aval bval))]))\n  \n  java.util.List\n  (diff-similar [a b]\n    (diff-sequential a b))\n  \n  java.util.Map\n  (diff-similar [a b]\n    (diff-associative a b (set/union (keys a) (keys b)))))\n\n(defn diff\n  \"Recursively compares a and b, returning a tuple of\n  [things-only-in-a things-only-in-b things-in-both].\n  Comparison rules:\n\n  * For equal a and b, return [nil nil a].\n  * Maps are subdiffed where keys match and values differ.\n  * Sets are never subdiffed.\n  * All sequential things are treated as associative collections\n    by their indexes, with results returned as vectors.\n  * Everything else (including strings!) is treated as\n    an atom and compared for equality.\"\n  {:added \"1.3\"}\n  [a b]\n  (if (= a b)\n    [nil nil a]\n    (if (= (equality-partition a) (equality-partition b))\n      (diff-similar a b)\n      (atom-diff a b))))\n  \n"
  },
  {
    "path": "src/clj/clojure/edn.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns ^{:doc \"edn reading.\"\n      :author \"Rich Hickey\"}\n  clojure.edn\n  (:refer-clojure :exclude [read read-string]))\n\n(defn read\n  \"Reads the next object from stream, which must be an instance of\n  java.io.PushbackReader or some derivee.  stream defaults to the\n  current value of *in*.\n\n  Reads data in the edn format (subset of Clojure data):\n  http://edn-format.org\n\n  opts is a map that can include the following keys:\n  :eof - value to return on end-of-file. When not supplied, eof throws an exception.\n  :readers  - a map of tag symbols to data-reader functions to be considered before default-data-readers.\n              When not supplied, only the default-data-readers will be used.\n  :default - A function of two args, that will, if present and no reader is found for a tag,\n             be called with the tag and the value.\"\n  \n  {:added \"1.5\"}\n  ([]\n   (read *in*))\n  ([stream]\n   (read {} stream))\n  ([opts stream]\n     (clojure.lang.EdnReader/read stream opts)))\n\n(defn read-string\n  \"Reads one object from the string s. Returns nil when s is nil or empty.\n\n  Reads data in the edn format (subset of Clojure data):\n  http://edn-format.org\n\n  opts is a map as per clojure.edn/read\"\n  {:added \"1.5\"}\n  ([s] (read-string {:eof nil} s))\n  ([opts s] (when s (clojure.lang.EdnReader/readString s opts))))"
  },
  {
    "path": "src/clj/clojure/genclass.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(in-ns 'clojure.core)\n\n(import '(java.lang.reflect Modifier Constructor)\n        '(clojure.asm ClassWriter ClassVisitor Opcodes Type)\n        '(clojure.asm.commons Method GeneratorAdapter)\n        '(clojure.lang IPersistentMap Compiler Compiler$HostExpr))\n\n;(defn method-sig [^java.lang.reflect.Method meth]\n;  [(. meth (getName)) (seq (. meth (getParameterTypes)))])\n\n(defn- filter-methods [^Class c invalid-method?]\n  (loop [mm {}\n         considered #{}\n         c c]\n    (if c\n      (let [[mm considered]\n            (loop [mm mm\n                   considered considered\n                   meths (seq (concat\n                                (seq (. c (getDeclaredMethods)))\n                                (seq (. c (getMethods)))))]\n              (if meths\n                (let [^java.lang.reflect.Method meth (first meths)\n                      mods (. meth (getModifiers))\n                      mk (method-sig meth)]\n                  (if (or (considered mk)\n                          (invalid-method? meth))\n                    (recur mm (conj considered mk) (next meths))\n                    (recur (assoc mm mk meth) (conj considered mk) (next meths))))\n                [mm considered]))]\n        (recur mm considered (. c (getSuperclass))))\n      mm)))\n\n(defn- non-private-methods [^Class c]\n  (let [not-overridable? (fn [^java.lang.reflect.Method meth]\n                           (let [mods (. meth (getModifiers))]\n                             (or (not (or (Modifier/isPublic mods) (Modifier/isProtected mods)))\n                                 (. Modifier (isStatic mods))\n                                 (. Modifier (isFinal mods))\n                                 (= \"finalize\" (.getName meth)))))]\n    (filter-methods c not-overridable?)))\n\n(defn- protected-final-methods [^Class c]\n  (let [not-exposable? (fn [^java.lang.reflect.Method meth]\n                         (let [mods (. meth (getModifiers))]\n                           (not (and (Modifier/isProtected mods)\n                                     (Modifier/isFinal mods)\n                                     (not (Modifier/isStatic mods))))))]\n    (filter-methods c not-exposable?)))\n\n(defn- ctor-sigs [^Class super]\n  (for [^Constructor ctor (. super (getDeclaredConstructors))\n        :when (not (. Modifier (isPrivate (. ctor (getModifiers)))))]\n    (apply vector (. ctor (getParameterTypes)))))\n\n(defn- escape-class-name [^Class c]\n  (.. (.getSimpleName c) \n      (replace \"[]\" \"<>\")))\n\n(defn- overload-name [mname pclasses]\n  (if (seq pclasses)\n    (apply str mname (interleave (repeat \\-) \n                                 (map escape-class-name pclasses)))\n    (str mname \"-void\")))\n\n(defn- ^java.lang.reflect.Field find-field [^Class c f]\n  (let [start-class c]\n    (loop [c c]\n      (if (= c Object)\n        (throw (new Exception (str \"field, \" f \", not defined in class, \" start-class \", or its ancestors\")))\n        (let [dflds (.getDeclaredFields c)\n              rfld (first (filter #(= f (.getName ^java.lang.reflect.Field %)) dflds))]\n          (or rfld (recur (.getSuperclass c))))))))\n\n;(distinct (map first(keys (mapcat non-private-methods [Object IPersistentMap]))))\n\n(def ^{:private true} prim->class\n     {'int Integer/TYPE\n      'ints (Class/forName \"[I\")\n      'long Long/TYPE\n      'longs (Class/forName \"[J\")\n      'float Float/TYPE\n      'floats (Class/forName \"[F\")\n      'double Double/TYPE\n      'doubles (Class/forName \"[D\")\n      'void Void/TYPE\n      'short Short/TYPE\n      'shorts (Class/forName \"[S\")\n      'boolean Boolean/TYPE\n      'booleans (Class/forName \"[Z\")\n      'byte Byte/TYPE\n      'bytes (Class/forName \"[B\")\n      'char Character/TYPE\n      'chars (Class/forName \"[C\")})\n\n(defn- ^Class the-class [x] \n  (cond \n   (class? x) x\n   (contains? prim->class x) (prim->class x)\n   :else (let [strx (str x)]\n           (clojure.lang.RT/classForName \n            (if (some #{\\. \\[} strx)\n              strx\n              (str \"java.lang.\" strx))))))\n\n;; someday this can be made codepoint aware\n(defn- valid-java-method-name\n  [^String s]\n  (= s (clojure.lang.Compiler/munge s)))\n\n(defn- validate-generate-class-options\n  [{:keys [methods]}]\n  (let [[mname] (remove valid-java-method-name (map (comp str first) methods))]\n    (when mname (throw (IllegalArgumentException. (str \"Not a valid method name: \" mname))))))\n\n(defn- generate-class [options-map]\n  (validate-generate-class-options options-map)\n  (let [default-options {:prefix \"-\" :load-impl-ns true :impl-ns (ns-name *ns*)}\n        {:keys [name extends implements constructors methods main factory state init exposes \n                exposes-methods prefix load-impl-ns impl-ns post-init]} \n          (merge default-options options-map)\n        name-meta (meta name)\n        name (str name)\n        package-name (subs name 0 (.lastIndexOf name \".\"))\n        class-name (subs name (inc (.lastIndexOf name \".\")))\n        super (if extends (the-class extends) Object)\n        interfaces (map the-class implements)\n        supers (cons super interfaces)\n        ctor-sig-map (or constructors (zipmap (ctor-sigs super) (ctor-sigs super)))\n        cv (new ClassWriter (. ClassWriter COMPUTE_MAXS))\n        cname (. name (replace \".\" \"/\"))\n        pkg-name name\n        impl-pkg-name (str impl-ns)\n        impl-cname (.. impl-pkg-name (replace \".\" \"/\") (replace \\- \\_))\n        ctype (. Type (getObjectType cname))\n        iname (fn [^Class c] (.. Type (getType c) (getInternalName)))\n        totype (fn [^Class c] (. Type (getType c)))\n        to-types (fn [cs] (if (pos? (count cs))\n                            (into-array (map totype cs))\n                            (make-array Type 0)))\n        obj-type ^Type (totype Object)\n        arg-types (fn [n] (if (pos? n)\n                            (into-array (replicate n obj-type))\n                            (make-array Type 0)))\n        super-type ^Type (totype super)\n        init-name (str init)\n        post-init-name (str post-init)\n        factory-name (str factory)\n        state-name (str state)\n        main-name \"main\"\n        var-name (fn [s] (clojure.lang.Compiler/munge (str s \"__var\")))\n        class-type  (totype Class)\n        rt-type  (totype clojure.lang.RT)\n        var-type ^Type (totype clojure.lang.Var)\n        ifn-type (totype clojure.lang.IFn)\n        iseq-type (totype clojure.lang.ISeq)\n        ex-type  (totype java.lang.UnsupportedOperationException)\n        all-sigs (distinct (concat (map #(let[[m p] (key %)] {m [p]}) (mapcat non-private-methods supers))\n                                   (map (fn [[m p]] {(str m) [p]}) methods)))\n        sigs-by-name (apply merge-with concat {} all-sigs)\n        overloads (into1 {} (filter (fn [[m s]] (next s)) sigs-by-name))\n        var-fields (concat (when init [init-name]) \n                           (when post-init [post-init-name])\n                           (when main [main-name])\n                           ;(when exposes-methods (map str (vals exposes-methods)))\n                           (distinct (concat (keys sigs-by-name)\n                                             (mapcat (fn [[m s]] (map #(overload-name m (map the-class %)) s)) overloads)\n                                             (mapcat (comp (partial map str) vals val) exposes))))\n        emit-get-var (fn [^GeneratorAdapter gen v]\n                       (let [false-label (. gen newLabel)\n                             end-label (. gen newLabel)]\n                         (. gen getStatic ctype (var-name v) var-type)\n                         (. gen dup)\n                         (. gen invokeVirtual var-type (. Method (getMethod \"boolean isBound()\")))\n                         (. gen ifZCmp (. GeneratorAdapter EQ) false-label)\n                         (. gen invokeVirtual var-type (. Method (getMethod \"Object get()\")))\n                         (. gen goTo end-label)\n                         (. gen mark false-label)\n                         (. gen pop)\n                         (. gen visitInsn (. Opcodes ACONST_NULL))\n                         (. gen mark end-label)\n                         (Compiler/emitSource \"value = null;\")\n                         (Compiler/emitSource (str \"if (\" (var-name v) \".isBound()) {\"))\n                         (Compiler/tab)\n                         (Compiler/emitSource (str \"value = \" (var-name v) \".get();\"))\n                         (Compiler/untab)\n                         (Compiler/emitSource \"}\")))\n        emit-unsupported (fn [^GeneratorAdapter gen ^Method m]\n                           (let [msg (str (. m (getName)) \" (\"\n                                          impl-pkg-name \"/\" prefix (.getName m)\n                                          \" not defined?)\")]\n                             (Compiler/emitSource (str \"throw new \" (Compiler/printClass ex-type) \"(\\\"\" msg \"\\\");\"))\n                             (. gen (throwException ex-type msg))))\n        emit-forwarding-method\n        (fn [name pclasses rclass exclasses as-static else-gen]\n          (let [mname (str name)\n                pmetas (map meta pclasses)\n                pclasses (map the-class pclasses)\n                rclass (the-class rclass)\n                ptypes (to-types pclasses)\n                rtype ^Type (totype rclass)\n                m (new Method mname rtype ptypes)\n                is-overload (seq (overloads mname))\n                gen (new GeneratorAdapter (+ (. Opcodes ACC_PUBLIC) (if as-static (. Opcodes ACC_STATIC) 0))\n                         m nil nil cv)\n                found-label (. gen (newLabel))\n                else-label (. gen (newLabel))\n                end-label (. gen (newLabel))\n                rvoid (= (. rtype (getSort)) (. Type VOID))]\n            (add-annotations gen (meta name))\n            (dotimes [i (count pmetas)]\n              (add-annotations gen (nth pmetas i) i))\n            (Compiler/emitSource (str \"public \" (if as-static \"static \" \"\") (Compiler/printClass rclass) \" \" mname\n                                      \"(\" (reduce1 str (interpose \", \" (map #(str (Compiler/printClass\n                                                                                   (nth pclasses %)) \" p\" %) (range (count pclasses)))))\n                                      \")\" (if (empty? exclasses) \"\" (str \" throws \"\n                                                                         (reduce1 str (interpose \", \"\n                                                                                                 (map #(Compiler/printClass %) exclasses))))) \" {\"))\n            (Compiler/tab)\n            (. gen (visitCode))\n            (Compiler/emitSource \"Object value = null;\")\n            (if (> (count pclasses) 18)\n              (else-gen gen m)\n              (do\n                (when is-overload\n                                        ; TODO ?\n                  (emit-get-var gen (overload-name mname pclasses))\n                  (. gen (dup))\n                  (. gen (ifNonNull found-label))\n                  (. gen (pop)))\n                (emit-get-var gen mname)\n                (. gen (dup))\n                (Compiler/emitSource (str \"if (value != null) {\"))\n                (Compiler/tab)\n                (. gen (ifNull else-label))\n                (when is-overload\n                  (. gen (mark found-label)))\n                ;if found\n                (.checkCast gen ifn-type)\n                (when-not as-static\n                  (. gen (loadThis)))\n                ;box args\n                (Compiler/emitSource (str (if rvoid \"\" \"return \")\n                                          (Compiler/unboxVal\n                                           rclass (str \"((IFn)value).invoke(\"\n                                                       (reduce1\n                                                        str (interpose\n                                                             \", \"\n                                                             (map #(do\n                                                                     (. gen (loadArg %))\n                                                                     (. clojure.lang.Compiler$HostExpr (emitBoxReturn nil gen (nth pclasses %) (str \"p\" %))))\n                                                                  (range (count ptypes))))) \")\")) \";\"))\n\n                ;call fn\n                (. gen (invokeInterface ifn-type (new Method \"invoke\" obj-type\n                                                      (to-types (replicate (+ (count ptypes)\n                                                                              (if as-static 0 1))\n                                                                           Object)))))\n                ;(into-array (cons obj-type\n                ;                 (replicate (count ptypes) obj-type))))))\n                ;unbox return\n                (. gen (unbox rtype))\n                (when rvoid\n                  (. gen (pop)))\n                (. gen (goTo end-label))\n\n                ;else call supplied alternative generator\n                (. gen (mark else-label))\n                (. gen (pop))\n                (Compiler/untab)\n                (Compiler/emitSource \"} else {\")\n                (Compiler/tab)\n\n                (else-gen gen m)\n\n                (Compiler/untab)\n                (Compiler/emitSource \"}\")\n\n                (. gen (mark end-label))))\n            (Compiler/untab)\n            (Compiler/emitSource \"}\")\n            (. gen (returnValue))\n            (. gen (endMethod))))\n        ]\n    (binding [*source-writer* (.getSc cv)]\n      (Compiler/emitSource (str \"package \" package-name \";\"))\n      (Compiler/emitSource)\n      (Compiler/emitSource (str \"import clojure.lang.*;\"))\n      (Compiler/emitSource)\n                                        ;start class definition\n      (. cv (visit (. Opcodes V1_5) (+ (. Opcodes ACC_PUBLIC) (. Opcodes ACC_SUPER))\n                   cname nil (iname super)\n                   (when-let [ifc (seq interfaces)]\n                     (into-array (map iname ifc)))))\n\n                                        ; class annotations\n      (add-annotations cv name-meta)\n      (Compiler/emitSource (str \"public class \" class-name \" extends \" (Compiler/printClass super)\n                                (if (empty? interfaces) \"\" (str \" implements \" (apply str (interpose \", \" (map #(Compiler/printClass %) interfaces))))) \" {\"))\n      (Compiler/tab)\n\n                                        ;static fields for vars\n      (doseq [v var-fields]\n        (. cv (visitField (+ (. Opcodes ACC_PRIVATE) (. Opcodes ACC_FINAL) (. Opcodes ACC_STATIC))\n                          (var-name v)\n                          (. var-type getDescriptor)\n                          nil nil))\n        (Compiler/emitSource (str \"private final static Var \" (var-name v) \";\")))\n\n                                        ;instance field for state\n      (when state\n        (. cv (visitField (+ (. Opcodes ACC_PUBLIC) (. Opcodes ACC_FINAL))\n                          state-name\n                          (. obj-type getDescriptor)\n                          nil nil))\n        (Compiler/emitSource (str \"public final Object \" state-name \";\")))\n\n                                        ;static init to set up var fields and load init\n      (let [gen (new GeneratorAdapter (+ (. Opcodes ACC_PUBLIC) (. Opcodes ACC_STATIC))\n                     (. Method getMethod \"void <clinit> ()\")\n                     nil nil cv)]\n        (Compiler/emitSource \"static {\")\n        (Compiler/tab)\n        (. gen (visitCode))\n        (doseq [v var-fields]\n          (. gen push impl-pkg-name)\n          (. gen push (str prefix v))\n          (. gen (invokeStatic var-type (. Method (getMethod \"clojure.lang.Var internPrivate(String,String)\"))))\n          (. gen putStatic ctype (var-name v) var-type)\n          (Compiler/emitSource (str (var-name v) \" = Var.internPrivate(\\\"\" impl-pkg-name \"\\\", \\\"\" (str prefix v) \"\\\");\")))\n\n        (when load-impl-ns\n          (. gen push \"clojure.core\")\n          (. gen push \"load\")\n          (. gen (invokeStatic rt-type (. Method (getMethod \"clojure.lang.Var var(String,String)\"))))\n          (. gen push (str \"/\" impl-cname))\n          (. gen (invokeInterface ifn-type (new Method \"invoke\" obj-type (to-types [Object]))))\n                                        ;        (. gen push (str (.replace impl-pkg-name \\- \\_) \"__init\"))\n                                        ;        (. gen (invokeStatic class-type (. Method (getMethod \"Class forName(String)\"))))\n          (. gen pop)\n          (Compiler/emitSource (str \"RT.var(\\\"clojure.core\\\", \" \"\\\"load\\\").invoke(\\\"\" (str \"/\" impl-cname) \"\\\");\")))\n\n        (Compiler/untab)\n        (Compiler/emitSource \"}\")\n        (. gen (returnValue))\n        (. gen (endMethod)))\n\n                                        ;ctors\n      (doseq [[pclasses super-pclasses] ctor-sig-map]\n        (let [constructor-annotations (meta pclasses)\n              pclasses (map the-class pclasses)\n              super-pclasses (map the-class super-pclasses)\n              ptypes (to-types pclasses)\n              super-ptypes (to-types super-pclasses)\n              m (new Method \"<init>\" (. Type VOID_TYPE) ptypes)\n              super-m (new Method \"<init>\" (. Type VOID_TYPE) super-ptypes)\n              gen (new GeneratorAdapter (. Opcodes ACC_PUBLIC) m nil nil cv)\n              _ (add-annotations gen constructor-annotations)\n              no-init-label (. gen newLabel)\n              end-label (. gen newLabel)\n              no-post-init-label (. gen newLabel)\n              end-post-init-label (. gen newLabel)\n              nth-method (. Method (getMethod \"Object nth(Object,int)\"))\n              local (. gen newLocal obj-type)]\n          (. gen (visitCode))\n          (Compiler/emitSource (str \"public \" class-name \"(\"\n                                    (reduce1 str (interpose \", \" (map #(str (Compiler/printClass\n                                                                             (nth pclasses %)) \" p\" %) (range (count pclasses))))) \") {\"))\n          ; TODO init and post-init\n          (comment (Compiler/tab)\n            (Compiler/emitSource \"Object value = null;\"))\n          (if init\n            (do\n              (Compiler/emitSource \"{\")\n              (Compiler/tab)\n              (emit-get-var gen init-name)\n              (. gen dup)\n              (. gen ifNull no-init-label)\n              (Compiler/emitSource \"if (value != null) {\")\n              (Compiler/tab)\n              (.checkCast gen ifn-type)\n                                        ;box init args\n              (Compiler/emitSource\n               (str \"final Object found = RT.nth(((IFn)value).invoke(\"\n                    (reduce1 str\n                             (interpose \", \"\n                                        (map #(do\n                                                (. gen (loadArg %))\n                                                (. clojure.lang.Compiler$HostExpr\n                                                   (emitBoxReturn nil gen (nth pclasses %) (str \"p\" %))))\n                                             (range (count pclasses))))) \"), 0);\"))\n                                        ;call init fn\n              (. gen (invokeInterface ifn-type (new Method \"invoke\" obj-type\n                                                    (arg-types (count ptypes)))))\n                                        ;expecting [[super-ctor-args] state] returned\n              (. gen dup)\n              (. gen push (int 0))\n              (. gen (invokeStatic rt-type nth-method))\n              (. gen storeLocal local)\n\n              (. gen (loadThis))\n              (. gen dupX1)\n              (Compiler/emitSource\n               (str \"super(\"\n                (reduce1 str\n                         (interpose \", \"\n                                    (map #(do\n                                            (. gen loadLocal local)\n                                            (. gen push (int %))\n                                            (. gen (invokeStatic rt-type nth-method))\n                                            (. clojure.lang.Compiler$HostExpr (emitUnboxArg nil gen (nth super-pclasses %)\n                                                                                            (str \"RT.nth(\" \"found\" \", \" % \")\"))))\n                                         (range (count super-pclasses))))) \");\"))\n              (. gen (invokeConstructor super-type super-m))\n\n              (if state\n                (do\n                  (Compiler/emitSource (str state-name \" = RT.nth(\" \"found\" \", 1);\"))\n                  (. gen push (int 1))\n                  (. gen (invokeStatic rt-type nth-method))\n                  (. gen (putField ctype state-name obj-type)))\n                (. gen pop))\n\n              (. gen goTo end-label)\n                                        ;no init found\n              (Compiler/untab)\n              (Compiler/emitSource \"} else {\")\n              (Compiler/tab)\n              (. gen mark no-init-label)\n              (let [msg (str impl-pkg-name \"/\" prefix init-name \" not defined\")]\n                (. gen (throwException ex-type msg))\n                (Compiler/emitSource (str \"throw new \" (Compiler/printClass ex-type) \"(\\\"\" msg \"\\\");\")))\n              (. gen mark end-label)\n              (Compiler/untab)\n              (Compiler/emitSource \"}\")\n              (Compiler/untab)\n              (Compiler/emitSource \"}\"))\n            (if (= pclasses super-pclasses)\n              (do\n                (. gen (loadThis))\n                (. gen (loadArgs))\n                (. gen (invokeConstructor super-type super-m))\n                (Compiler/emitSource (str \"super(\" (reduce1 str (interpose \", \" (map #(str \"p\" %) (range (count pclasses))))) \");\")))\n              (throw (new Exception \":init not specified, but ctor and super ctor args differ\"))))\n\n          (when post-init\n            (Compiler/emitSource \"{\")\n            (Compiler/tab)\n            (emit-get-var gen post-init-name)\n            (. gen dup)\n            (Compiler/emitSource \"if (value != null) {\")\n            (Compiler/tab)\n            (. gen ifNull no-post-init-label)\n            (.checkCast gen ifn-type)\n            (. gen (loadThis))\n                                        ;box init args\n            (Compiler/emitSource\n             (str \"((IFn)value).invoke(\"\n                  (reduce1 str\n                           (interpose \", \"\n                                      (map #(do\n                                              (. gen (loadArg %))\n                                              (. clojure.lang.Compiler$HostExpr (emitBoxReturn nil gen (nth pclasses %) (str \"p\" %))))\n                                           (range (count pclasses))))) \")\"))\n                                        ;call init fn\n            (. gen (invokeInterface ifn-type (new Method \"invoke\" obj-type\n                                                  (arg-types (inc (count ptypes))))))\n            (. gen pop)\n            (. gen goTo end-post-init-label)\n                                        ;no init found\n            (. gen mark no-post-init-label)\n            (Compiler/untab)\n            (Compiler/emitSource \"} else {\")\n            (let [msg (str impl-pkg-name \"/\" prefix post-init-name \" not defined\")]\n              (Compiler/emitSource (str \"throw new \" (Compiler/printClass ex-type) \"(\\\"\" msg \"\\\");\"))\n              (. gen (throwException ex-type msg)))\n            (Compiler/untab)\n            (Compiler/emitSource \"}\")\n            (Compiler/untab)\n            (Compiler/emitSource \"}\")\n            (. gen mark end-post-init-label))\n\n          (. gen (returnValue))\n          (. gen (endMethod))\n          (Compiler/untab)\n          (Compiler/emitSource \"}\")\n                                        ;factory\n          (when factory\n            (let [fm (new Method factory-name ctype ptypes)\n                  gen (new GeneratorAdapter (+ (. Opcodes ACC_PUBLIC) (. Opcodes ACC_STATIC))\n                           fm nil nil cv)]\n              (Compiler/emitSource (str \"public static \" (Compiler/printClass ctype) \" \" factory-name \"(\"\n                                        (reduce1 str (interpose \", \" (map #(str (Compiler/printClass\n                                                                                 (nth pclasses %)) \" p\" %) (range (count pclasses)))))\n                                        \") {\"))\n              (Compiler/tab)\n              (. gen (visitCode))\n              (. gen newInstance ctype)\n              (. gen dup)\n              (. gen (loadArgs))\n              (. gen (invokeConstructor ctype m))\n              (Compiler/emitSource (str \"return new \" (Compiler/printClass ctype) \"(\"\n                                        (reduce1 str (interpose \", \" (map #(str \"p\" %) (range (count pclasses))))) \");\"))\n              (Compiler/untab)\n              (Compiler/emitSource \"}\")\n              (. gen (returnValue))\n              (. gen (endMethod))))))\n\n                                        ;add methods matching supers', if no fn -> call super\n      (let [mm (non-private-methods super)]\n        (doseq [^java.lang.reflect.Method meth (vals mm)]\n          (emit-forwarding-method (.getName meth) (.getParameterTypes meth) (.getReturnType meth) (.getExceptionTypes meth) false\n                                  (fn [^GeneratorAdapter gen ^Method m]\n                                    (. gen (loadThis))\n                                        ;push args\n                                    (. gen (loadArgs))\n                                        ;call super\n                                    (. gen (visitMethodInsn (. Opcodes INVOKESPECIAL)\n                                                            (. super-type (getInternalName))\n                                                            (. m (getName))\n                                                            (. m (getDescriptor))))\n                                    (let [pclasses (map the-class (.getParameterTypes meth))\n                                          rclass (the-class (.getReturnType meth))\n                                          rtype ^Type (totype rclass)\n                                          rvoid (= (. rtype (getSort)) (. Type VOID))]\n                                      (Compiler/emitSource (str (if rvoid \"\" \"return \") \"super.\" (.getName m)\n                                                                \"(\" (reduce1 str (interpose \", \" (map #(str \"p\" %) (range (count pclasses))))) \");\"))))))\n                                        ;add methods matching interfaces', if no fn -> throw\n        (reduce1 (fn [mm ^java.lang.reflect.Method meth]\n                   (if (contains? mm (method-sig meth))\n                     mm\n                     (do\n                       (emit-forwarding-method (.getName meth) (.getParameterTypes meth) (.getReturnType meth) (.getExceptionTypes meth) false\n                                               emit-unsupported)\n                       (assoc mm (method-sig meth) meth))))\n                 mm (mapcat #(.getMethods ^Class %) interfaces))\n                                        ;extra methods\n        (doseq [[mname pclasses rclass :as msig] methods]\n          (emit-forwarding-method mname pclasses rclass nil (:static (meta msig))\n                                  emit-unsupported))\n                                        ;expose specified overridden superclass methods\n        (doseq [[local-mname ^java.lang.reflect.Method m] (reduce1 (fn [ms [[name _ _] m]]\n                                                                     (if (contains? exposes-methods (symbol name))\n                                                                       (conj ms [((symbol name) exposes-methods) m])\n                                                                       ms)) [] (concat (seq mm)\n                                                                                       (seq (protected-final-methods super))))]\n          (let [pclasses (.getParameterTypes m)\n                ptypes (to-types pclasses)\n                rtype (totype (.getReturnType m))\n                rvoid (= (. rtype (getSort)) (. Type VOID))\n                exposer-m (new Method (str local-mname) rtype ptypes)\n                target-m (new Method (.getName m) rtype ptypes)\n                gen (new GeneratorAdapter (. Opcodes ACC_PUBLIC) exposer-m nil nil cv)]\n            (Compiler/emitSource (str \"public \" (Compiler/printClass rtype) \" \" (.getName m) \"(\"\n                                      (reduce1 str (interpose \", \" (map #(str (Compiler/printClass\n                                                                               (nth pclasses %)) \" p\" %) (range (count pclasses))))) \") {\"))\n            (Compiler/tab)\n            (. gen (loadThis))\n            (. gen (loadArgs))\n            (. gen (visitMethodInsn (. Opcodes INVOKESPECIAL)\n                                    (. super-type (getInternalName))\n                                    (. target-m (getName))\n                                    (. target-m (getDescriptor))))\n            (Compiler/emitSource (str (if rvoid \"\" \"return \") \"super.\" (.getName target-m) \"(\"\n                                      (reduce1 str (interpose \", \" (map #(str \"p\" %) (range (count pclasses))))) \");\"))\n            (. gen (returnValue))\n            (Compiler/untab)\n            (Compiler/emitSource \"}\")\n            (. gen (endMethod)))))\n                                        ;main\n      (when main\n        (let [m (. Method getMethod \"void main (String[])\")\n              gen (new GeneratorAdapter (+ (. Opcodes ACC_PUBLIC) (. Opcodes ACC_STATIC))\n                       m nil nil cv)\n              no-main-label (. gen newLabel)\n              end-label (. gen newLabel)]\n          (. gen (visitCode))\n          (Compiler/emitSource (str \"public static void main(String[] args) {\"))\n          (Compiler/tab)\n          (Compiler/emitSource \"Object value = null;\")\n          (emit-get-var gen main-name)\n\n          (Compiler/emitSource (str \"if (value != null) {\"))\n          (Compiler/tab)\n          (Compiler/emitSource (str \"((IFn)value).applyTo(RT.seq(args));\"))\n          (Compiler/emitSource \"return;\")\n          (Compiler/untab)\n          (Compiler/emitSource \"}\")\n          (. gen dup)\n          (. gen ifNull no-main-label)\n          (.checkCast gen ifn-type)\n          (. gen loadArgs)\n          (. gen (invokeStatic rt-type (. Method (getMethod \"clojure.lang.ISeq seq(Object)\"))))\n          (. gen (invokeInterface ifn-type (new Method \"applyTo\" obj-type\n                                                (into-array [iseq-type]))))\n          (. gen pop)\n          (. gen goTo end-label)\n                                        ;no main found\n          (. gen mark no-main-label)\n          (let [msg (str impl-pkg-name \"/\" prefix main-name \" not defined\")]\n            (Compiler/emitSource (str \"throw new \" (Compiler/printClass ex-type) \"(\\\"\" msg \"\\\");\"))\n            (. gen (throwException ex-type msg)))\n          (. gen mark end-label)\n          (. gen (returnValue))\n          (Compiler/untab)\n          (Compiler/emitSource \"}\")\n          (. gen (endMethod))))\n                                        ;field exposers\n      (doseq [[f {getter :get setter :set}] exposes]\n        (let [fld (find-field super (str f))\n              ftype (totype (.getType fld))\n              static? (Modifier/isStatic (.getModifiers fld))\n              acc (+ Opcodes/ACC_PUBLIC (if static? Opcodes/ACC_STATIC 0))]\n          (when getter\n            (let [m (new Method (str getter) ftype (to-types []))\n                  gen (new GeneratorAdapter acc m nil nil cv)]\n              (Compiler/emitSource (str \"public \" (if static? \"static \" \"\") (Compiler/printClass ftype) \" \" (str getter) \"() {\"))\n              (Compiler/tab)\n              (. gen (visitCode))\n              (Compiler/emitSource (str \"return \" f \";\"))\n              (if static?\n                (. gen getStatic ctype (str f) ftype)\n                (do\n                  (. gen loadThis)\n                  (. gen getField ctype (str f) ftype)))\n              (Compiler/untab)\n              (Compiler/emitSource \"}\")\n              (. gen (returnValue))\n              (. gen (endMethod))))\n          (when setter\n            (let [m (new Method (str setter) Type/VOID_TYPE (into-array [ftype]))\n                  gen (new GeneratorAdapter acc m nil nil cv)]\n              (Compiler/emitSource (str \"public \" (if static? \"static \" \"\") \"void \" (str setter) \"(\" (Compiler/printClass ftype) \" value) {\"))\n              (Compiler/tab)\n              (. gen (visitCode))\n              (if static?\n                (do\n                  (Compiler/emitSource (str (Compiler/printClass ctype) \".\" f \" = value;\"))\n                  (. gen loadArgs)\n                  (. gen putStatic ctype (str f) ftype))\n                (do\n                  (Compiler/emitSource (str \"this.\" f \" = value;\"))\n                  (. gen loadThis)\n                  (. gen loadArgs)\n                  (. gen putField ctype (str f) ftype)))\n              (Compiler/untab)\n              (Compiler/emitSource \"}\")\n              (. gen (returnValue))\n              (. gen (endMethod))))))\n                                        ;finish class def\n      (. cv (visitEnd))\n      (Compiler/untab)\n      (Compiler/emitSource \"}\")\n      (Compiler/writeSourceFile cname (str *source-writer*))\n      [cname (. cv (toByteArray))])))\n\n(defmacro gen-class\n  \"When compiling, generates compiled bytecode for a class with the\n  given package-qualified :name (which, as all names in these\n  parameters, can be a string or symbol), and writes the .class file\n  to the *compile-path* directory.  When not compiling, does\n  nothing. The gen-class construct contains no implementation, as the\n  implementation will be dynamically sought by the generated class in\n  functions in an implementing Clojure namespace. Given a generated\n  class org.mydomain.MyClass with a method named mymethod, gen-class\n  will generate an implementation that looks for a function named by\n  (str prefix mymethod) (default prefix: \\\"-\\\") in a\n  Clojure namespace specified by :impl-ns\n  (defaults to the current namespace). All inherited methods,\n  generated methods, and init and main functions (see :methods, :init,\n  and :main below) will be found similarly prefixed. By default, the\n  static initializer for the generated class will attempt to load the\n  Clojure support code for the class as a resource from the classpath,\n  e.g. in the example case, ``org/mydomain/MyClass__init.class``. This\n  behavior can be controlled by :load-impl-ns\n\n  Note that methods with a maximum of 18 parameters are supported.\n\n  In all subsequent sections taking types, the primitive types can be\n  referred to by their Java names (int, float etc), and classes in the\n  java.lang package can be used without a package qualifier. All other\n  classes must be fully qualified.\n\n  Options should be a set of key/value pairs, all except for :name are optional:\n\n  :name aname\n\n  The package-qualified name of the class to be generated\n\n  :extends aclass\n\n  Specifies the superclass, the non-private methods of which will be\n  overridden by the class. If not provided, defaults to Object.\n\n  :implements [interface ...]\n\n  One or more interfaces, the methods of which will be implemented by the class.\n\n  :init name\n\n  If supplied, names a function that will be called with the arguments\n  to the constructor. Must return [ [superclass-constructor-args] state]\n  If not supplied, the constructor args are passed directly to\n  the superclass constructor and the state will be nil\n\n  :constructors {[param-types] [super-param-types], ...}\n\n  By default, constructors are created for the generated class which\n  match the signature(s) of the constructors for the superclass. This\n  parameter may be used to explicitly specify constructors, each entry\n  providing a mapping from a constructor signature to a superclass\n  constructor signature. When you supply this, you must supply an :init\n  specifier.\n\n  :post-init name\n\n  If supplied, names a function that will be called with the object as\n  the first argument, followed by the arguments to the constructor.\n  It will be called every time an object of this class is created,\n  immediately after all the inherited constructors have completed.\n  Its return value is ignored.\n\n  :methods [ [name [param-types] return-type], ...]\n\n  The generated class automatically defines all of the non-private\n  methods of its superclasses/interfaces. This parameter can be used\n  to specify the signatures of additional methods of the generated\n  class. Static methods can be specified with ^{:static true} in the\n  signature's metadata. Do not repeat superclass/interface signatures\n  here.\n\n  :main boolean\n\n  If supplied and true, a static public main function will be generated. It will\n  pass each string of the String[] argument as a separate argument to\n  a function called (str prefix main).\n\n  :factory name\n\n  If supplied, a (set of) public static factory function(s) will be\n  created with the given name, and the same signature(s) as the\n  constructor(s).\n\n  :state name\n\n  If supplied, a public final instance field with the given name will be\n  created. You must supply an :init function in order to provide a\n  value for the state. Note that, though final, the state can be a ref\n  or agent, supporting the creation of Java objects with transactional\n  or asynchronous mutation semantics.\n\n  :exposes {protected-field-name {:get name :set name}, ...}\n\n  Since the implementations of the methods of the generated class\n  occur in Clojure functions, they have no access to the inherited\n  protected fields of the superclass. This parameter can be used to\n  generate public getter/setter methods exposing the protected field(s)\n  for use in the implementation.\n\n  :exposes-methods {super-method-name exposed-name, ...}\n\n  It is sometimes necessary to call the superclass' implementation of an\n  overridden method.  Those methods may be exposed and referred in\n  the new method implementation by a local name.\n\n  :prefix string\n\n  Default: \\\"-\\\" Methods called e.g. Foo will be looked up in vars called\n  prefixFoo in the implementing ns.\n\n  :impl-ns name\n\n  Default: the name of the current ns. Implementations of methods will be\n  looked up in this namespace.\n\n  :load-impl-ns boolean\n\n  Default: true. Causes the static initializer for the generated class\n  to reference the load code for the implementing namespace. Should be\n  true when implementing-ns is the default, false if you intend to\n  load the code via some other method.\"\n  {:added \"1.0\"}\n\n  [& options]\n  (when *compile-files*\n    (let [options-map (into1 {} (map vec (partition 2 options)))\n          [cname bytecode] (generate-class options-map)]\n      (Compiler/writeClassFile cname bytecode))))\n\n;;;;;;;;;;;;;;;;;;;; gen-interface ;;;;;;;;;;;;;;;;;;;;;;\n;; based on original contribution by Chris Houser\n\n(defn- ^Type asm-type\n  \"Returns an asm Type object for c, which may be a primitive class\n  (such as Integer/TYPE), any other class (such as Double), or a\n  fully-qualified class name given as a string or symbol\n  (such as 'java.lang.String)\"\n  [c]\n  (if (or (instance? Class c) (prim->class c))\n    (Type/getType (the-class c))\n    (let [strx (str c)]\n      (Type/getObjectType\n       (.replace (if (some #{\\. \\[} strx)\n                   strx\n                   (str \"java.lang.\" strx))\n                 \".\" \"/\")))))\n\n(defn- generate-interface\n  [{:keys [name extends methods]}]\n  (when (some #(-> % first clojure.core/name (.contains \"-\")) methods)\n    (throw\n     (IllegalArgumentException. \"Interface methods must not contain '-'\")))\n  (let [sname (str name)\n        iname (.replace sname \".\" \"/\")\n        cv (ClassWriter. ClassWriter/COMPUTE_MAXS)\n        lastdot (.lastIndexOf sname \".\")\n        classname (subs sname (inc lastdot))\n        packagename (subs sname 0 lastdot)]\n    (binding [*source-writer* (.getSc cv)]\n      (Compiler/emitSource (str \"package \" packagename \";\"))\n      (Compiler/emitSource)\n      (Compiler/emitSource (str \"public interface \" classname \" {\"))\n      (Compiler/tab)\n      (. cv visit Opcodes/V1_5 (+ Opcodes/ACC_PUBLIC\n                                  Opcodes/ACC_ABSTRACT\n                                  Opcodes/ACC_INTERFACE)\n         iname nil \"java/lang/Object\"\n         (when (seq extends)\n           (into-array (map #(.getInternalName (asm-type %)) extends))))\n      (add-annotations cv (meta name))\n      (doseq [[mname pclasses rclass pmetas] methods]\n        (Compiler/emitSource (str\n                              (Compiler$HostExpr/tagToCanonical rclass)\n                              \" \" (str mname) \"(\"\n                              (let [names (map #(str (let [c (nth pclasses %)]\n                                                       (Compiler$HostExpr/tagToCanonical c)) \" p\" %) (range (count pclasses)))]\n                                    (apply str (interpose \", \" names)))\n                                  \");\"))\n        (let [mv (. cv visitMethod (+ Opcodes/ACC_PUBLIC Opcodes/ACC_ABSTRACT)\n                    (str mname)\n                    (Type/getMethodDescriptor (asm-type rclass)\n                                              (if pclasses\n                                                (into-array Type (map asm-type pclasses))\n                                                (make-array Type 0)))\n                    nil nil)]\n          (add-annotations mv (meta mname))\n          (dotimes [i (count pmetas)]\n            (add-annotations mv (nth pmetas i) i))\n          (. mv visitEnd)))\n      (. cv visitEnd)\n      (Compiler/untab)\n      (Compiler/emitSource \"}\")\n      (when *compile-files*\n        (Compiler/writeSourceFile iname (str *source-writer*)))\n      [iname (. cv toByteArray)])))\n\n(defmacro gen-interface\n  \"When compiling, generates compiled bytecode for an interface with\n  the given package-qualified :name (which, as all names in these\n  parameters, can be a string or symbol), and writes the .class file\n  to the *compile-path* directory.  When not compiling, does nothing.\n\n  In all subsequent sections taking types, the primitive types can be\n  referred to by their Java names (int, float etc), and classes in the\n  java.lang package can be used without a package qualifier. All other\n  classes must be fully qualified.\n\n  Options should be a set of key/value pairs, all except for :name are\n  optional:\n\n  :name aname\n\n  The package-qualified name of the class to be generated\n\n  :extends [interface ...]\n\n  One or more interfaces, which will be extended by this interface.\n\n  :methods [ [name [param-types] return-type], ...]\n\n  This parameter is used to specify the signatures of the methods of\n  the generated interface.  Do not repeat superinterface signatures\n  here.\"\n  {:added \"1.0\"}\n\n  [& options]\n    (let [options-map (apply hash-map options)\n          [cname bytecode] (generate-interface options-map)]\n      (when *compile-files*\n        (clojure.lang.Compiler/writeClassFile cname bytecode))\n      (.defineClass ^DynamicClassLoader (deref clojure.lang.Compiler/LOADER)\n                    (str (:name options-map)) bytecode options)))\n\n(comment\n\n  (defn gen-and-load-class\n    \"Generates and immediately loads the bytecode for the specified\n    class. Note that a class generated this way can be loaded only once\n    - the JVM supports only one class with a given name per\n    classloader. Subsequent to generation you can import it into any\n    desired namespaces just like any other class. See gen-class for a\n    description of the options.\"\n    {:added \"1.0\"}\n\n    [& options]\n    (let [options-map (apply hash-map options)\n          [cname bytecode] (generate-class options-map)]\n      (.. (clojure.lang.RT/getRootClassLoader) (defineClass cname bytecode options))))\n\n  )\n"
  },
  {
    "path": "src/clj/clojure/gvec.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;;; a generic vector implementation for vectors of primitives\n\n(in-ns 'clojure.core)\n\n(import '(clojure.lang Murmur3))\n\n(set! *warn-on-reflection* true)\n\n(deftype VecNode [edit arr])\n\n(def EMPTY-NODE (VecNode. nil (object-array 32)))\n\n(definterface IVecImpl\n  (^int tailoff [])\n  (arrayFor [^int i])\n  (pushTail [^int level ^clojure.core.VecNode parent ^clojure.core.VecNode tailnode])\n  (popTail [^int level node])\n  (newPath [edit ^int level node])\n  (doAssoc [^int level node ^int i val]))\n\n(definterface ArrayManager\n  (array [^int size])\n  (^int alength [arr])\n  (aclone [arr])\n  (aget [arr ^int i])\n  (aset [arr ^int i val]))\n\n(deftype ArrayChunk [^clojure.core.ArrayManager am arr ^int off ^int end]\n  \n  clojure.lang.Indexed\n  (nth [_ i] (.aget am arr (+ off i)))\n  \n  (count [_] (- end off))\n\n  clojure.lang.IChunk\n  (dropFirst [_]\n    (if (= off end)\n      (throw (IllegalStateException. \"dropFirst of empty chunk\"))\n      (new ArrayChunk am arr (inc off) end)))\n  \n  (reduce [_ f init]\n    (loop [ret init i off]\n      (if (< i end)\n        (let [ret (f ret (.aget am arr i))]\n          (if (reduced? ret)\n            ret\n            (recur ret (inc i))))\n        ret))))\n\n(deftype VecSeq [^clojure.core.ArrayManager am ^clojure.core.IVecImpl vec anode ^int i ^int offset] \n  :no-print true\n\n  clojure.core.protocols.InternalReduce\n  (internal-reduce\n   [_ f val]\n   (loop [result val\n          aidx (+ i offset)]\n     (if (< aidx (count vec))\n       (let [node (.arrayFor vec aidx)\n             result (loop [result result\n                           node-idx (bit-and 0x1f aidx)]\n                      (if (< node-idx (.alength am node))\n                        (let [result (f result (.aget am node node-idx))]\n                          (if (reduced? result)\n                            result\n                            (recur result (inc node-idx))))\n                        result))]\n         (if (reduced? result)\n           @result\n           (recur result (bit-and 0xffe0 (+ aidx 32)))))\n       result)))\n  \n  clojure.lang.ISeq\n  (first [_] (.aget am anode offset))\n  (next [this] \n    (if (< (inc offset) (.alength am anode))\n      (new VecSeq am vec anode i (inc offset))\n      (.chunkedNext this)))\n  (more [this]\n    (let [s (.next this)]\n      (or s (clojure.lang.PersistentList/EMPTY))))\n  (cons [this o]\n    (clojure.lang.Cons. o this))\n  (count [this]\n    (loop [i 1\n           s (next this)]\n      (if s\n        (if (instance? clojure.lang.Counted s)\n          (+ i (.count s))\n          (recur (inc i) (next s)))\n        i)))\n  (equiv [this o]\n    (cond\n     (identical? this o) true\n     (or (instance? clojure.lang.Sequential o) (instance? java.util.List o))\n     (loop [me this\n            you (seq o)]\n       (if (nil? me)\n         (nil? you)\n         (and (clojure.lang.Util/equiv (first me) (first you))\n              (recur (next me) (next you)))))\n     :else false))\n  (empty [_]\n    clojure.lang.PersistentList/EMPTY)\n\n\n  clojure.lang.Seqable\n  (seq [this] this)\n\n  clojure.lang.IChunkedSeq\n  (chunkedFirst [_] (ArrayChunk. am anode offset (.alength am anode)))\n  (chunkedNext [_] \n   (let [nexti (+ i (.alength am anode))]\n     (when (< nexti (count vec))\n       (new VecSeq am vec (.arrayFor vec nexti) nexti 0))))\n  (chunkedMore [this]\n    (let [s (.chunkedNext this)]\n      (or s (clojure.lang.PersistentList/EMPTY)))))\n\n(defmethod print-method ::VecSeq [v w]\n  ((get (methods print-method) clojure.lang.ISeq) v w))\n\n(deftype Vec [^clojure.core.ArrayManager am ^int cnt ^int shift ^clojure.core.VecNode root tail _meta]\n  Object\n  (equals [this o]\n    (cond \n     (identical? this o) true\n     (or (instance? clojure.lang.IPersistentVector o) (instance? java.util.RandomAccess o))\n       (and (= cnt (count o))\n            (loop [i (int 0)]\n              (cond\n               (= i cnt) true\n               (.equals (.nth this i) (nth o i)) (recur (inc i))\n               :else false)))\n     (or (instance? clojure.lang.Sequential o) (instance? java.util.List o))\n       (if-let [st (seq this)]\n         (.equals st (seq o))\n         (nil? (seq o)))\n     :else false))\n\n  ;todo - cache\n  (hashCode [this]\n    (loop [hash (int 1) i (int 0)]\n      (if (= i cnt)\n        hash\n        (let [val (.nth this i)]\n          (recur (unchecked-add-int (unchecked-multiply-int 31 hash) \n                                (clojure.lang.Util/hash val)) \n                 (inc i))))))\n\n  ;todo - cache\n  clojure.lang.IHashEq\n  (hasheq [this]\n    (Murmur3/hashOrdered this))\n\n  clojure.lang.Counted\n  (count [_] cnt)\n\n  clojure.lang.IMeta\n  (meta [_] _meta)\n\n  clojure.lang.IObj\n  (withMeta [_ m] (new Vec am cnt shift root tail m))\n\n  clojure.lang.Indexed\n  (nth [this i]\n    (let [a (.arrayFor this i)]\n      (.aget am a (bit-and i (int 0x1f)))))\n  (nth [this i not-found]\n       (let [z (int 0)]\n         (if (and (>= i z) (< i (.count this)))\n           (.nth this i)\n           not-found)))\n\n  clojure.lang.IPersistentCollection\n  (cons [this val]\n     (if (< (- cnt (.tailoff this)) (int 32))\n      (let [new-tail (.array am (inc (.alength am tail)))]\n        (System/arraycopy tail 0 new-tail 0 (.alength am tail))\n        (.aset am new-tail (.alength am tail) val)\n        (new Vec am (inc cnt) shift root new-tail (meta this)))\n      (let [tail-node (VecNode. (.edit root) tail)] \n        (if (> (bit-shift-right cnt (int 5)) (bit-shift-left (int 1) shift)) ;overflow root?\n          (let [new-root (VecNode. (.edit root) (object-array 32))]\n            (doto ^objects (.arr new-root)\n              (aset 0 root)\n              (aset 1 (.newPath this (.edit root) shift tail-node)))\n            (new Vec am (inc cnt) (+ shift (int 5)) new-root (let [tl (.array am 1)] (.aset am  tl 0 val) tl) (meta this)))\n          (new Vec am (inc cnt) shift (.pushTail this shift root tail-node) \n                 (let [tl (.array am 1)] (.aset am  tl 0 val) tl) (meta this))))))\n\n  (empty [_] (new Vec am 0 5 EMPTY-NODE (.array am 0) nil))                             \n  (equiv [this o]\n    (cond \n     (or (instance? clojure.lang.IPersistentVector o) (instance? java.util.RandomAccess o))\n       (and (= cnt (count o))\n            (loop [i (int 0)]\n              (cond\n               (= i cnt) true\n               (= (.nth this i) (nth o i)) (recur (inc i))\n               :else false)))\n     (or (instance? clojure.lang.Sequential o) (instance? java.util.List o))\n       (clojure.lang.Util/equiv (seq this) (seq o))\n     :else false))\n\n  clojure.lang.IPersistentStack\n  (peek [this]\n    (when (> cnt (int 0)) \n      (.nth this (dec cnt))))\n\n  (pop [this]\n   (cond\n    (zero? cnt) \n      (throw (IllegalStateException. \"Can't pop empty vector\"))\n    (= 1 cnt) \n      (new Vec am 0 5 EMPTY-NODE (.array am 0) (meta this))\n    (> (- cnt (.tailoff this)) 1)\n      (let [new-tail (.array am (dec (.alength am tail)))]\n        (System/arraycopy tail 0 new-tail 0 (.alength am new-tail))\n        (new Vec am (dec cnt) shift root new-tail (meta this)))\n    :else\n      (let [new-tail (.arrayFor this (- cnt 2))\n            new-root ^clojure.core.VecNode (.popTail this shift root)]\n        (cond\n         (nil? new-root) \n           (new Vec am (dec cnt) shift EMPTY-NODE new-tail (meta this))\n         (and (> shift 5) (nil? (aget ^objects (.arr new-root) 1)))\n           (new Vec am (dec cnt) (- shift 5) (aget ^objects (.arr new-root) 0) new-tail (meta this))\n         :else\n           (new Vec am (dec cnt) shift new-root new-tail (meta this))))))\n\n  clojure.lang.IPersistentVector\n  (assocN [this i val]\n    (cond \n     (and (<= (int 0) i) (< i cnt))\n       (if (>= i (.tailoff this))\n         (let [new-tail (.array am (.alength am tail))]\n           (System/arraycopy tail 0 new-tail 0 (.alength am tail))\n           (.aset am new-tail (bit-and i (int 0x1f)) val)\n           (new Vec am cnt shift root new-tail (meta this)))\n         (new Vec am cnt shift (.doAssoc this shift root i val) tail (meta this)))\n     (= i cnt) (.cons this val)\n     :else (throw (IndexOutOfBoundsException.))))\n  \n  clojure.lang.Reversible\n  (rseq [this]\n        (if (> (.count this) 0)\n          (clojure.lang.APersistentVector$RSeq. this (dec (.count this)))\n          nil))\n  \n  clojure.lang.Associative\n  (assoc [this k v]\n    (if (clojure.lang.Util/isInteger k)\n      (.assocN this k v)\n      (throw (IllegalArgumentException. \"Key must be integer\"))))\n  (containsKey [this k]\n    (and (clojure.lang.Util/isInteger k)\n         (<= 0 (int k))\n         (< (int k) cnt)))\n  (entryAt [this k]\n    (if (.containsKey this k)\n      (clojure.lang.MapEntry. k (.nth this (int k)))\n      nil))\n\n  clojure.lang.ILookup\n  (valAt [this k not-found]\n    (if (clojure.lang.Util/isInteger k)\n      (let [i (int k)]\n        (if (and (>= i 0) (< i cnt))\n          (.nth this i)\n          not-found))\n      not-found))\n\n  (valAt [this k] (.valAt this k nil))\n\n  clojure.lang.IFn\n  (invoke [this k]\n    (if (clojure.lang.Util/isInteger k)\n      (let [i (int k)]\n        (if (and (>= i 0) (< i cnt))\n          (.nth this i)\n          (throw (IndexOutOfBoundsException.))))\n      (throw (IllegalArgumentException. \"Key must be integer\"))))\n\n  \n  clojure.lang.Seqable\n  (seq [this] \n    (if (zero? cnt) \n      nil\n      (VecSeq. am this (.arrayFor this 0) 0 0)))\n\n  clojure.lang.Sequential ;marker, no methods\n\n  clojure.core.IVecImpl\n  (tailoff [_] \n    (- cnt (.alength am tail)))\n\n  (arrayFor [this i]\n    (if (and  (<= (int 0) i) (< i cnt))\n      (if (>= i (.tailoff this))\n        tail\n        (loop [node root level shift]\n          (if (zero? level)\n            (.arr node)\n            (recur (aget ^objects (.arr node) (bit-and (bit-shift-right i level) (int 0x1f))) \n                   (- level (int 5))))))\n      (throw (IndexOutOfBoundsException.))))\n\n  (pushTail [this level parent tailnode]\n    (let [subidx (bit-and (bit-shift-right (dec cnt) level) (int 0x1f))\n          parent ^clojure.core.VecNode parent\n          ret (VecNode. (.edit parent) (aclone ^objects (.arr parent)))\n          node-to-insert (if (= level (int 5))\n                           tailnode\n                           (let [child (aget ^objects (.arr parent) subidx)]\n                             (if child\n                               (.pushTail this (- level (int 5)) child tailnode)\n                               (.newPath this (.edit root) (- level (int 5)) tailnode))))]\n      (aset ^objects (.arr ret) subidx node-to-insert)\n      ret))\n\n  (popTail [this level node]\n    (let [node ^clojure.core.VecNode node\n          subidx (bit-and (bit-shift-right (- cnt (int 2)) level) (int 0x1f))]\n      (cond\n       (> level 5) \n         (let [new-child (.popTail this (- level 5) (aget ^objects (.arr node) subidx))]\n           (if (and (nil? new-child) (zero? subidx))\n             nil\n             (let [arr (aclone ^objects (.arr node))]\n               (aset arr subidx new-child)\n               (VecNode. (.edit root) arr))))\n       (zero? subidx) nil\n       :else (let [arr (aclone ^objects (.arr node))]\n               (aset arr subidx nil)\n               (VecNode. (.edit root) arr)))))\n\n  (newPath [this edit ^int level node]\n    (if (zero? level)\n      node\n      (let [ret (VecNode. edit (object-array 32))]\n        (aset ^objects (.arr ret) 0 (.newPath this edit (- level (int 5)) node))\n        ret)))\n\n  (doAssoc [this level node i val]\n    (let [node ^clojure.core.VecNode node]       \n      (if (zero? level)\n        ;on this branch, array will need val type\n        (let [arr (.aclone am (.arr node))]\n          (.aset am arr (bit-and i (int 0x1f)) val)\n          (VecNode. (.edit node) arr))\n        (let [arr (aclone ^objects (.arr node))\n              subidx (bit-and (bit-shift-right i level) (int 0x1f))]\n          (aset arr subidx (.doAssoc this (- level (int 5)) (aget arr subidx) i val))\n          (VecNode. (.edit node) arr)))))\n\n  java.lang.Comparable\n  (compareTo [this o]\n    (if (identical? this o)\n      0\n      (let [^clojure.lang.IPersistentVector v (cast clojure.lang.IPersistentVector o)\n            vcnt (.count v)]\n        (cond\n          (< cnt vcnt) -1\n          (> cnt vcnt) 1\n          :else\n            (loop [i (int 0)]\n              (if (= i cnt)\n                0\n                (let [comp (clojure.lang.Util/compare (.nth this i) (.nth v i))]\n                  (if (= 0 comp)\n                    (recur (inc i))\n                    comp))))))))\n\n  java.lang.Iterable\n  (iterator [this]\n    (let [i (java.util.concurrent.atomic.AtomicInteger. 0)]\n      (reify java.util.Iterator\n        (hasNext [_] (< (.get i) cnt))\n        (next [_] (.nth this (dec (.incrementAndGet i))))\n        (remove [_] (throw (UnsupportedOperationException.))))))\n\n  java.util.Collection\n  (contains [this o] (boolean (some #(= % o) this)))\n  (containsAll [this c] (every? #(.contains this %) c))\n  (isEmpty [_] (zero? cnt))\n  (toArray [this] (into-array Object this))\n  (toArray [this arr]\n    (if (>= (count arr) cnt)\n      (do\n        (dotimes [i cnt]\n          (aset arr i (.nth this i)))\n        arr)\n      (into-array Object this)))\n  (size [_] cnt)\n  (add [_ o] (throw (UnsupportedOperationException.)))\n  (addAll [_ c] (throw (UnsupportedOperationException.)))\n  (clear [_] (throw (UnsupportedOperationException.)))\n  (^boolean remove [_ o] (throw (UnsupportedOperationException.)))\n  (removeAll [_ c] (throw (UnsupportedOperationException.)))\n  (retainAll [_ c] (throw (UnsupportedOperationException.)))\n\n  java.util.List\n  (get [this i] (.nth this i))\n  (indexOf [this o]\n    (loop [i (int 0)]\n      (cond\n        (== i cnt) -1\n        (= o (.nth this i)) i\n        :else (recur (inc i)))))\n  (lastIndexOf [this o]\n    (loop [i (dec cnt)]\n      (cond\n        (< i 0) -1\n        (= o (.nth this i)) i\n        :else (recur (dec i)))))\n  (listIterator [this] (.listIterator this 0))\n  (listIterator [this i]\n    (let [i (java.util.concurrent.atomic.AtomicInteger. i)]\n      (reify java.util.ListIterator\n        (hasNext [_] (< (.get i) cnt))\n        (hasPrevious [_] (pos? i))\n        (next [_] (.nth this (dec (.incrementAndGet i))))\n        (nextIndex [_] (.get i))\n        (previous [_] (.nth this (.decrementAndGet i)))\n        (previousIndex [_] (dec (.get i)))\n        (add [_ e] (throw (UnsupportedOperationException.)))\n        (remove [_] (throw (UnsupportedOperationException.)))\n        (set [_ e] (throw (UnsupportedOperationException.))))))\n  (subList [this a z] (subvec this a z))\n  (add [_ i o] (throw (UnsupportedOperationException.)))\n  (addAll [_ i c] (throw (UnsupportedOperationException.)))\n  (^Object remove [_ ^int i] (throw (UnsupportedOperationException.)))\n  (set [_ i e] (throw (UnsupportedOperationException.)))\n)\n\n(defmethod print-method ::Vec [v w]\n  ((get (methods print-method) clojure.lang.IPersistentVector) v w))\n\n(defmacro mk-am {:private true} [t]\n  (let [garr (gensym)\n        tgarr (with-meta garr {:tag (symbol (str t \"s\"))})]\n    `(reify clojure.core.ArrayManager\n            (array [_ size#] (~(symbol (str t \"-array\")) size#))\n            (alength [_ ~garr] (alength ~tgarr))\n            (aclone [_ ~garr] (aclone ~tgarr))\n            (aget [_ ~garr i#] (aget ~tgarr i#))\n            (aset [_ ~garr i# val#] (aset ~tgarr i# (~t val#))))))\n\n(def ^{:private true} ams\n     {:int (mk-am int)\n      :long (mk-am long)\n      :float (mk-am float)\n      :double (mk-am double)\n      :byte (mk-am byte)\n      :short (mk-am short)\n      :char (mk-am char)\n      :boolean (mk-am boolean)})\n\n(defn vector-of \n  \"Creates a new vector of a single primitive type t, where t is one\n  of :int :long :float :double :byte :short :char or :boolean. The\n  resulting vector complies with the interface of vectors in general,\n  but stores the values unboxed internally.\n\n  Optionally takes one or more elements to populate the vector.\"\n  {:added \"1.2\"\n   :arglists '([t] [t & elements])}\n  ([t]\n   (let [am ^clojure.core.ArrayManager (ams t)]\n     (Vec. am 0 5 EMPTY-NODE (.array am 0) nil)))\n  ([t x1]\n   (let [am ^clojure.core.ArrayManager (ams t)\n         arr (.array am 1)]\n     (.aset am arr 0 x1)\n     (Vec. am 1 5 EMPTY-NODE arr nil)))\n  ([t x1 x2]\n   (let [am ^clojure.core.ArrayManager (ams t)\n         arr (.array am 2)]\n     (.aset am arr 0 x1)\n     (.aset am arr 1 x2)\n     (Vec. am 2 5 EMPTY-NODE arr nil)))\n  ([t x1 x2 x3]\n   (let [am ^clojure.core.ArrayManager (ams t)\n         arr (.array am 3)]\n     (.aset am arr 0 x1)\n     (.aset am arr 1 x2)\n     (.aset am arr 2 x3)\n     (Vec. am 3 5 EMPTY-NODE arr nil)))\n  ([t x1 x2 x3 x4]\n   (let [am ^clojure.core.ArrayManager (ams t)\n         arr (.array am 4)]\n     (.aset am arr 0 x1)\n     (.aset am arr 1 x2)\n     (.aset am arr 2 x3)\n     (.aset am arr 3 x4)\n     (Vec. am 4 5 EMPTY-NODE arr nil)))\n  ([t x1 x2 x3 x4 & xn]\n   (loop [v  (vector-of t x1 x2 x3 x4)\n          xn xn]\n     (if xn\n       (recur (conj v (first xn)) (next xn))\n       v))))\n"
  },
  {
    "path": "src/clj/clojure/inspector.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns ^{:doc \"Graphical object inspector for Clojure data structures.\"\n       :author \"Rich Hickey\"}\n    clojure.inspector\n    (:import\n     (java.awt BorderLayout)\n     (java.awt.event ActionEvent ActionListener)\n     (javax.swing.tree TreeModel)\n     (javax.swing.table TableModel AbstractTableModel)\n     (javax.swing JPanel JTree JTable JScrollPane JFrame JToolBar JButton SwingUtilities)))\n\n(defn atom? [x]\n  (not (coll? x)))\n\n(defn collection-tag [x]\n  (cond \n   (instance? java.util.Map$Entry x) :entry\n   (instance? java.util.Map x) :seqable\n   (instance? java.util.Set x) :seqable\n   (sequential? x) :seq\n   (instance? clojure.lang.Seqable x) :seqable\n   :else :atom))\n\n(defmulti is-leaf collection-tag)\n(defmulti get-child (fn [parent index] (collection-tag parent)))\n(defmulti get-child-count collection-tag)\n\n(defmethod is-leaf :default [node]\n  (atom? node))\n(defmethod get-child :default [parent index]\n  (nth parent index))\n(defmethod get-child-count :default [parent]\n  (count parent))\n\n(defmethod is-leaf :entry [e]\n  (is-leaf (val e)))\n(defmethod get-child :entry [e index]\n  (get-child (val e) index))\n(defmethod get-child-count :entry [e]\n  (count (val e)))\n\n(defmethod is-leaf :seqable [parent]\n  false)\n(defmethod get-child :seqable [parent index]\n  (nth (seq parent) index))\n(defmethod get-child-count :seqable [parent]\n  (count (seq parent)))\n\n(defn tree-model [data]\n  (proxy [TreeModel] []\n    (getRoot [] data)\n    (addTreeModelListener [treeModelListener])\n    (getChild [parent index]\n      (get-child parent index))\n    (getChildCount [parent]\n       (get-child-count parent))\n    (isLeaf [node]\n      (is-leaf node))\n    (valueForPathChanged [path newValue])\n    (getIndexOfChild [parent child]\n      -1)\n    (removeTreeModelListener [treeModelListener])))\n\n\n(defn old-table-model [data]\n  (let [row1 (first data)\n\tcolcnt (count row1)\n\tcnt (count data)\n\tvals (if (map? row1) vals identity)]\n    (proxy [TableModel] []\n      (addTableModelListener [tableModelListener])\n      (getColumnClass [columnIndex] Object)\n      (getColumnCount [] colcnt)\n      (getColumnName [columnIndex]\n\t(if (map? row1)\n\t  (name (nth (keys row1) columnIndex))\n\t  (str columnIndex)))\n      (getRowCount [] cnt)\n      (getValueAt [rowIndex columnIndex]\n\t(nth (vals (nth data rowIndex)) columnIndex))\n      (isCellEditable [rowIndex columnIndex] false)\n      (removeTableModelListener [tableModelListener]))))\n      \n(defn inspect-tree \n  \"creates a graphical (Swing) inspector on the supplied hierarchical data\"\n  {:added \"1.0\"}\n  [data]\n  (doto (JFrame. \"Clojure Inspector\")\n    (.add (JScrollPane. (JTree. (tree-model data))))\n    (.setSize 400 600)\n    (.setVisible true)))\n\n(defn inspect-table \n  \"creates a graphical (Swing) inspector on the supplied regular\n  data, which must be a sequential data structure of data structures\n  of equal length\"\n  {:added \"1.0\"}\n    [data]\n  (doto (JFrame. \"Clojure Inspector\")\n    (.add (JScrollPane. (JTable. (old-table-model data))))\n    (.setSize 400 600)\n    (.setVisible true)))\n\n\n(defmulti list-provider class)\n\n(defmethod list-provider :default [x]\n  {:nrows 1 :get-value (fn [i] x) :get-label (fn [i] (.getName (class x)))})\n\n(defmethod list-provider java.util.List [c]\n  (let [v (if (vector? c) c (vec c))]\n    {:nrows (count v) \n     :get-value (fn [i] (v i)) \n     :get-label (fn [i] i)}))\n\n(defmethod list-provider java.util.Map [c]\n  (let [v (vec (sort (map (fn [[k v]] (vector k v)) c)))]\n    {:nrows (count v) \n     :get-value (fn [i] ((v i) 1)) \n     :get-label (fn [i] ((v i) 0))}))\n\n(defn list-model [provider]\n  (let [{:keys [nrows get-value get-label]} provider]\n    (proxy [AbstractTableModel] []\n      (getColumnCount [] 2)\n      (getRowCount [] nrows)\n      (getValueAt [rowIndex columnIndex]\n        (cond \n         (= 0 columnIndex) (get-label rowIndex)\n         (= 1 columnIndex) (print-str (get-value rowIndex)))))))\n\n(defmulti table-model class)\n\n(defmethod table-model :default [x]\n  (proxy [AbstractTableModel] []\n    (getColumnCount [] 2)\n    (getRowCount [] 1)\n    (getValueAt [rowIndex columnIndex]\n      (if (zero? columnIndex)\n        (class x)\n        x))))\n\n;(defn make-inspector [x]\n;  (agent {:frame frame :data x :parent nil :index 0}))\n\n\n(defn inspect\n  \"creates a graphical (Swing) inspector on the supplied object\"\n  {:added \"1.0\"}\n  [x]\n  (doto (JFrame. \"Clojure Inspector\")\n    (.add\n      (doto (JPanel. (BorderLayout.))\n        (.add (doto (JToolBar.)\n                (.add (JButton. \"Back\"))\n                (.addSeparator)\n                (.add (JButton. \"List\"))\n                (.add (JButton. \"Table\"))\n                (.add (JButton. \"Bean\"))\n                (.add (JButton. \"Line\"))\n                (.add (JButton. \"Bar\"))\n                (.addSeparator)\n                (.add (JButton. \"Prev\"))\n                (.add (JButton. \"Next\")))\n              BorderLayout/NORTH)\n        (.add\n          (JScrollPane. \n            (doto (JTable. (list-model (list-provider x)))\n              (.setAutoResizeMode JTable/AUTO_RESIZE_LAST_COLUMN)))\n          BorderLayout/CENTER)))\n    (.setSize 400 400)\n    (.setVisible true)))\n\n\n(comment\n\n(load-file \"src/inspector.clj\")\n(refer 'inspector)\n(inspect-tree {:a 1 :b 2 :c [1 2 3 {:d 4 :e 5 :f [6 7 8]}]})\n(inspect-table [[1 2 3][4 5 6][7 8 9][10 11 12]])\n\n)\n"
  },
  {
    "path": "src/clj/clojure/instant.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns clojure.instant\n  (:import [java.util Calendar Date GregorianCalendar TimeZone]\n           [java.sql Timestamp]))\n\n\n;;; ------------------------------------------------------------------------\n;;; convenience macros\n\n(defmacro ^:private fail\n  [msg]\n  `(throw (RuntimeException. ~msg)))\n\n(defmacro ^:private verify\n  ([test msg] `(when-not ~test (fail ~msg)))\n  ([test] `(verify ~test ~(str \"failed: \" (pr-str test)))))\n\n(defn- divisible?\n  [num div]\n  (zero? (mod num div)))\n\n(defn- indivisible?\n  [num div]\n  (not (divisible? num div)))\n\n\n;;; ------------------------------------------------------------------------\n;;; parser implementation\n\n(defn- parse-int [^String s]\n  (Long/parseLong s))\n\n(defn- zero-fill-right [^String s width]\n  (cond (= width (count s)) s\n        (< width (count s)) (.substring s 0 width)\n        :else (loop [b (StringBuilder. s)]\n                (if (< (.length b) width)\n                  (recur (.append b \\0))\n                  (.toString b)))))\n\n(def parse-timestamp\n     \"Parse a string containing an RFC3339-like like timestamp.\n\nThe function new-instant is called with the following arguments.\n\n                min  max           default\n                ---  ------------  -------\n  years          0           9999      N/A (s must provide years)\n  months         1             12        1\n  days           1             31        1 (actual max days depends\n  hours          0             23        0  on month and year)\n  minutes        0             59        0\n  seconds        0             60        0 (though 60 is only valid\n  nanoseconds    0      999999999        0  when minutes is 59)\n  offset-sign   -1              1        0\n  offset-hours   0             23        0\n  offset-minutes 0             59        0\n\nThese are all integers and will be non-nil. (The listed defaults\nwill be passed if the corresponding field is not present in s.)\n\nGrammar (of s):\n\n  date-fullyear   = 4DIGIT\n  date-month      = 2DIGIT  ; 01-12\n  date-mday       = 2DIGIT  ; 01-28, 01-29, 01-30, 01-31 based on\n                            ; month/year\n  time-hour       = 2DIGIT  ; 00-23\n  time-minute     = 2DIGIT  ; 00-59\n  time-second     = 2DIGIT  ; 00-58, 00-59, 00-60 based on leap second\n                            ; rules\n  time-secfrac    = '.' 1*DIGIT\n  time-numoffset  = ('+' / '-') time-hour ':' time-minute\n  time-offset     = 'Z' / time-numoffset\n\n  time-part       = time-hour [ ':' time-minute [ ':' time-second\n                    [time-secfrac] [time-offset] ] ]\n\n  timestamp       = date-year [ '-' date-month [ '-' date-mday\n                    [ 'T' time-part ] ] ]\n\nUnlike RFC3339:\n\n  - we only parse the timestamp format\n  - timestamp can elide trailing components\n  - time-offset is optional (defaults to +00:00)\n\nThough time-offset is syntactically optional, a missing time-offset\nwill be treated as if the time-offset zero (+00:00) had been\nspecified.\n\"\n     (let [timestamp #\"(\\d\\d\\d\\d)(?:-(\\d\\d)(?:-(\\d\\d)(?:[T](\\d\\d)(?::(\\d\\d)(?::(\\d\\d)(?:[.](\\d+))?)?)?)?)?)?(?:[Z]|([-+])(\\d\\d):(\\d\\d))?\"]\n\n       (fn [new-instant ^CharSequence cs]\n         (if-let [[_ years months days hours minutes seconds fraction\n                   offset-sign offset-hours offset-minutes]\n                  (re-matches timestamp cs)]\n           (new-instant\n            (parse-int years)\n            (if-not months   1 (parse-int months))\n            (if-not days     1 (parse-int days))\n            (if-not hours    0 (parse-int hours))\n            (if-not minutes  0 (parse-int minutes))\n            (if-not seconds  0 (parse-int seconds))\n            (if-not fraction 0 (parse-int (zero-fill-right fraction 9)))\n            (cond (= \"-\" offset-sign) -1\n                  (= \"+\" offset-sign)  1\n                  :else                0)\n            (if-not offset-hours   0 (parse-int offset-hours))\n            (if-not offset-minutes 0 (parse-int offset-minutes)))\n           (fail (str \"Unrecognized date/time syntax: \" cs))))))\n\n\n;;; ------------------------------------------------------------------------\n;;; Verification of Extra-Grammatical Restrictions from RFC3339\n\n(defn- leap-year?\n  [year]\n  (and (divisible? year 4)\n       (or (indivisible? year 100)\n           (divisible? year 400))))\n\n(def ^:private days-in-month\n     (let [dim-norm [nil 31 28 31 30 31 30 31 31 30 31 30 31]\n           dim-leap [nil 31 29 31 30 31 30 31 31 30 31 30 31]]\n       (fn [month leap-year?]\n         ((if leap-year? dim-leap dim-norm) month))))\n\n(defn validated\n  \"Return a function which constructs and instant by calling constructor\nafter first validating that those arguments are in range and otherwise\nplausible. The resulting function will throw an exception if called\nwith invalid arguments.\"\n  [new-instance]\n  (fn [years months days hours minutes seconds nanoseconds\n       offset-sign offset-hours offset-minutes]\n    (verify (<= 1 months 12))\n    (verify (<= 1 days (days-in-month months (leap-year? years))))\n    (verify (<= 0 hours 23))\n    (verify (<= 0 minutes 59))\n    (verify (<= 0 seconds (if (= minutes 59) 60 59)))\n    (verify (<= 0 nanoseconds 999999999))\n    (verify (<= -1 offset-sign 1))\n    (verify (<= 0 offset-hours 23))\n    (verify (<= 0 offset-minutes 59))\n    (new-instance years months days hours minutes seconds nanoseconds\n                  offset-sign offset-hours offset-minutes)))\n\n\n;;; ------------------------------------------------------------------------\n;;; print integration\n\n(def ^{:private true\n       :tag ThreadLocal} thread-local-utc-date-format\n  ;; SimpleDateFormat is not thread-safe, so we use a ThreadLocal proxy for access.\n  ;; http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4228335\n  (proxy [ThreadLocal] []\n    (initialValue []\n      (doto (java.text.SimpleDateFormat. \"yyyy-MM-dd'T'HH:mm:ss.SSS-00:00\")\n        ;; RFC3339 says to use -00:00 when the timezone is unknown (+00:00 implies a known GMT)\n        (.setTimeZone (java.util.TimeZone/getTimeZone \"GMT\"))))))\n\n(defn- print-date\n  \"Print a java.util.Date as RFC3339 timestamp, always in UTC.\"\n  [^java.util.Date d, ^java.io.Writer w]\n  (let [^java.text.SimpleDateFormat utc-format (.get thread-local-utc-date-format)]\n    (.write w \"#inst \\\"\")\n    (.write w (.format utc-format d))\n    (.write w \"\\\"\")))\n\n(defmethod print-method java.util.Date\n  [^java.util.Date d, ^java.io.Writer w]\n  (print-date d w))\n\n(defmethod print-dup java.util.Date\n  [^java.util.Date d, ^java.io.Writer w]\n  (print-date d w))\n\n(defn- print-calendar\n  \"Print a java.util.Calendar as RFC3339 timestamp, preserving timezone.\"\n  [^java.util.Calendar c, ^java.io.Writer w]\n  (let [calstr (format \"%1$tFT%1$tT.%1$tL%1$tz\" c)\n        offset-minutes (- (.length calstr) 2)]\n    ;; calstr is almost right, but is missing the colon in the offset\n    (.write w \"#inst \\\"\")\n    (.write w calstr 0 offset-minutes)\n    (.write w \":\")\n    (.write w calstr offset-minutes 2)\n    (.write w \"\\\"\")))\n\n(defmethod print-method java.util.Calendar\n  [^java.util.Calendar c, ^java.io.Writer w]\n  (print-calendar c w))\n\n(defmethod print-dup java.util.Calendar\n  [^java.util.Calendar c, ^java.io.Writer w]\n  (print-calendar c w))\n\n\n(def ^{:private true\n       :tag ThreadLocal} thread-local-utc-timestamp-format\n  ;; SimpleDateFormat is not thread-safe, so we use a ThreadLocal proxy for access.\n  ;; http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4228335\n  (proxy [ThreadLocal] []\n    (initialValue []\n      (doto (java.text.SimpleDateFormat. \"yyyy-MM-dd'T'HH:mm:ss\")\n        (.setTimeZone (java.util.TimeZone/getTimeZone \"GMT\"))))))\n\n(defn- print-timestamp\n  \"Print a java.sql.Timestamp as RFC3339 timestamp, always in UTC.\"\n  [^java.sql.Timestamp ts, ^java.io.Writer w]\n  (let [^java.text.SimpleDateFormat utc-format (.get thread-local-utc-timestamp-format)]\n    (.write w \"#inst \\\"\")\n    (.write w (.format utc-format ts))\n    ;; add on nanos and offset\n    ;; RFC3339 says to use -00:00 when the timezone is unknown (+00:00 implies a known GMT)\n    (.write w (format \".%09d-00:00\" (.getNanos ts)))\n    (.write w \"\\\"\")))\n\n(defmethod print-method java.sql.Timestamp\n  [^java.sql.Timestamp ts, ^java.io.Writer w]\n  (print-timestamp ts w))\n\n(defmethod print-dup java.sql.Timestamp\n  [^java.sql.Timestamp ts, ^java.io.Writer w]\n  (print-timestamp ts w))\n\n\n;;; ------------------------------------------------------------------------\n;;; reader integration\n\n(defn- construct-calendar\n  \"Construct a java.util.Calendar, preserving the timezone\noffset, but truncating the subsecond fraction to milliseconds.\"\n  ^GregorianCalendar\n  [years months days hours minutes seconds nanoseconds\n   offset-sign offset-hours offset-minutes]\n  (doto (GregorianCalendar. years (dec months) days hours minutes seconds)\n    (.set Calendar/MILLISECOND (quot nanoseconds 1000000))\n    (.setTimeZone (TimeZone/getTimeZone\n                   (format \"GMT%s%02d:%02d\"\n                           (if (neg? offset-sign) \"-\" \"+\")\n                           offset-hours offset-minutes)))))\n\n(defn- construct-date\n  \"Construct a java.util.Date, which expresses the original instant as\nmilliseconds since the epoch, UTC.\"\n  [years months days hours minutes seconds nanoseconds\n   offset-sign offset-hours offset-minutes]\n  (.getTime (construct-calendar years months days\n                                hours minutes seconds nanoseconds\n                                offset-sign offset-hours offset-minutes)))\n\n(defn- construct-timestamp\n  \"Construct a java.sql.Timestamp, which has nanosecond precision.\"\n  [years months days hours minutes seconds nanoseconds\n   offset-sign offset-hours offset-minutes]\n  (doto (Timestamp.\n         (.getTimeInMillis\n          (construct-calendar years months days\n                              hours minutes seconds 0\n                              offset-sign offset-hours offset-minutes)))\n    ;; nanos must be set separately, pass 0 above for the base calendar\n    (.setNanos nanoseconds)))\n\n(def read-instant-date\n  \"To read an instant as a java.util.Date, bind *data-readers* to a map with\nthis var as the value for the 'inst key. The timezone offset will be used\nto convert into UTC.\"\n  (partial parse-timestamp (validated construct-date)))\n\n(def read-instant-calendar\n  \"To read an instant as a java.util.Calendar, bind *data-readers* to a map with\nthis var as the value for the 'inst key.  Calendar preserves the timezone\noffset.\"\n  (partial parse-timestamp (validated construct-calendar)))\n\n(def read-instant-timestamp\n  \"To read an instant as a java.sql.Timestamp, bind *data-readers* to a\nmap with this var as the value for the 'inst key. Timestamp preserves\nfractional seconds with nanosecond precision. The timezone offset will\nbe used to convert into UTC.\"\n  (partial parse-timestamp (validated construct-timestamp)))\n\n"
  },
  {
    "path": "src/clj/clojure/java/browse.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns\n  ^{:author \"Christophe Grand\",\n    :doc \"Start a web browser from Clojure\"}\n  clojure.java.browse\n  (:require [clojure.java.shell :as sh]\n            [clojure.string :as str])\n  (:import (java.net URI)))\n\n(defn- macosx? []\n  (-> \"os.name\" System/getProperty .toLowerCase\n    (.startsWith \"mac os x\")))\n\n(defn- xdg-open-loc []\n  ;; try/catch needed to mask exception on Windows without Cygwin\n  (let [which-out (try (:out (sh/sh \"which\" \"xdg-open\"))\n                       (catch Exception e \"\"))]\n    (if (= which-out \"\")\n      nil\n      (str/trim-newline which-out))))\n\n(defn- open-url-script-val []\n  (if (macosx?)\n    \"/usr/bin/open\"\n    (xdg-open-loc)))\n\n;; We could assign (open-url-script-val) to *open-url-script* right\n;; away in the def below, but clojure.java.shell/sh creates a future\n;; that causes a long wait for the JVM to exit during Clojure compiles\n;; (unless we can somehow here make it call (shutdown-agents) later).\n;; Better to initialize it when we first need it, in browse-url.\n\n(def ^:dynamic *open-url-script* (atom :uninitialized))\n\n(defn- open-url-in-browser\n  \"Opens url (a string) in the default system web browser.  May not\n  work on all platforms.  Returns url on success, nil if not\n  supported.\"\n  [url]\n  (try\n    (when (clojure.lang.Reflector/invokeStaticMethod \"java.awt.Desktop\"\n      \"isDesktopSupported\" (to-array nil))\n      (-> (clojure.lang.Reflector/invokeStaticMethod \"java.awt.Desktop\"\n            \"getDesktop\" (to-array nil))\n        (.browse (URI. url)))\n      url)\n    (catch Exception e\n      nil)))\n\n(defn- open-url-in-swing\n \"Opens url (a string) in a Swing window.\"\n [url]\n  ; the implementation of this function resides in another namespace to be loaded \"on demand\"\n  ; this fixes a bug on mac os x where the process turns into a GUI app\n  ; see http://code.google.com/p/clojure-contrib/issues/detail?id=32\n  (require 'clojure.java.browse-ui)\n  ((find-var 'clojure.java.browse-ui/open-url-in-swing) url))\n\n(defn browse-url\n  \"Open url in a browser\"\n  {:added \"1.2\"}\n  [url]\n  (let [script @*open-url-script*\n        script (if (= :uninitialized script)\n                 (reset! *open-url-script* (open-url-script-val))\n                 script)]\n    (or (when script (sh/sh script (str url)) true)\n        (open-url-in-browser url)\n        (open-url-in-swing url))))\n"
  },
  {
    "path": "src/clj/clojure/java/browse_ui.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns\n    ^{:author \"Christophe Grand\",\n      :doc \"Helper namespace for clojure.java.browse.\n            Prevents console apps from becoming GUI unnecessarily.\"}\n  clojure.java.browse-ui)\n\n(defn- open-url-in-swing\n  [url]\n  (let [htmlpane (javax.swing.JEditorPane. url)]\n    (.setEditable htmlpane false)\n    (.addHyperlinkListener htmlpane\n      (proxy [javax.swing.event.HyperlinkListener] []\n        (hyperlinkUpdate [^javax.swing.event.HyperlinkEvent e]\n          (when (= (.getEventType e) (. javax.swing.event.HyperlinkEvent$EventType ACTIVATED))\n            (if (instance? javax.swing.text.html.HTMLFrameHyperlinkEvent e)\n              (-> htmlpane .getDocument (.processHTMLFrameHyperlinkEvent e))\n              (.setPage htmlpane (.getURL e)))))))\n    (doto (javax.swing.JFrame.)\n      (.setContentPane (javax.swing.JScrollPane. htmlpane))\n      (.setBounds 32 32 700 900)\n      (.show))))\n      \n"
  },
  {
    "path": "src/clj/clojure/java/io.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns \n  ^{:author \"Stuart Sierra, Chas Emerick, Stuart Halloway\",\n     :doc \"This file defines polymorphic I/O utility functions for Clojure.\"}\n    clojure.java.io\n    (:require clojure.string)\n    (:import \n     (java.io Reader InputStream InputStreamReader PushbackReader\n              BufferedReader File OutputStream\n              OutputStreamWriter BufferedWriter Writer\n              FileInputStream FileOutputStream ByteArrayOutputStream\n              StringReader ByteArrayInputStream\n              BufferedInputStream BufferedOutputStream\n              CharArrayReader Closeable)\n     (java.net URI URL MalformedURLException Socket URLDecoder URLEncoder)))\n\n(def\n    ^{:doc \"Type object for a Java primitive byte array.\"\n      :private true\n      }\n byte-array-type (class (make-array Byte/TYPE 0)))\n\n(def\n    ^{:doc \"Type object for a Java primitive char array.\"\n      :private true}\n char-array-type (class (make-array Character/TYPE 0)))\n\n(defprotocol ^{:added \"1.2\"} Coercions\n  \"Coerce between various 'resource-namish' things.\"\n  (^{:tag java.io.File, :added \"1.2\"} as-file [x] \"Coerce argument to a file.\")\n  (^{:tag java.net.URL, :added \"1.2\"} as-url [x] \"Coerce argument to a URL.\"))\n\n(defn- escaped-utf8-urlstring->str [s]\n  (-> (clojure.string/replace s \"+\" (URLEncoder/encode \"+\" \"UTF-8\"))\n      (URLDecoder/decode \"UTF-8\")))\n\n(extend-protocol Coercions\n  nil\n  (as-file [_] nil)\n  (as-url [_] nil)\n  \n  String\n  (as-file [s] (File. s))\n  (as-url [s] (URL. s))  \n  \n  File\n  (as-file [f] f)\n  (as-url [f] (.toURL (.toURI f)))\n\n  URL\n  (as-url [u] u)\n  (as-file [u]\n    (if (= \"file\" (.getProtocol u))\n      (as-file (escaped-utf8-urlstring->str\n                (.replace (.getFile u) \\/ File/separatorChar)))\n      (throw (IllegalArgumentException. (str \"Not a file: \" u)))))\n\n  URI\n  (as-url [u] (.toURL u))\n  (as-file [u] (as-file (as-url u))))\n\n(defprotocol ^{:added \"1.2\"} IOFactory\n  \"Factory functions that create ready-to-use, buffered versions of\n   the various Java I/O stream types, on top of anything that can\n   be unequivocally converted to the requested kind of stream.\n\n   Common options include\n   \n     :append    true to open stream in append mode\n     :encoding  string name of encoding to use, e.g. \\\"UTF-8\\\".\n\n   Callers should generally prefer the higher level API provided by\n   reader, writer, input-stream, and output-stream.\"\n  (^{:added \"1.2\"} make-reader [x opts] \"Creates a BufferedReader. See also IOFactory docs.\")\n  (^{:added \"1.2\"} make-writer [x opts] \"Creates a BufferedWriter. See also IOFactory docs.\")\n  (^{:added \"1.2\"} make-input-stream [x opts] \"Creates a BufferedInputStream. See also IOFactory docs.\")\n  (^{:added \"1.2\"} make-output-stream [x opts] \"Creates a BufferedOutputStream. See also IOFactory docs.\"))\n\n(defn ^Reader reader\n  \"Attempts to coerce its argument into an open java.io.Reader.\n   Default implementations always return a java.io.BufferedReader.\n\n   Default implementations are provided for Reader, BufferedReader,\n   InputStream, File, URI, URL, Socket, byte arrays, character arrays,\n   and String.\n\n   If argument is a String, it tries to resolve it first as a URI, then\n   as a local file name.  URIs with a 'file' protocol are converted to\n   local file names.\n\n   Should be used inside with-open to ensure the Reader is properly\n   closed.\"\n  {:added \"1.2\"}\n  [x & opts]\n  (make-reader x (when opts (apply hash-map opts))))\n\n(defn ^Writer writer\n  \"Attempts to coerce its argument into an open java.io.Writer.\n   Default implementations always return a java.io.BufferedWriter.\n\n   Default implementations are provided for Writer, BufferedWriter,\n   OutputStream, File, URI, URL, Socket, and String.\n\n   If the argument is a String, it tries to resolve it first as a URI, then\n   as a local file name.  URIs with a 'file' protocol are converted to\n   local file names.\n\n   Should be used inside with-open to ensure the Writer is properly\n   closed.\"\n  {:added \"1.2\"}\n  [x & opts]\n  (make-writer x (when opts (apply hash-map opts))))\n\n(defn ^InputStream input-stream\n  \"Attempts to coerce its argument into an open java.io.InputStream.\n   Default implementations always return a java.io.BufferedInputStream.\n\n   Default implementations are defined for InputStream, File, URI, URL,\n   Socket, byte array, and String arguments.\n\n   If the argument is a String, it tries to resolve it first as a URI, then\n   as a local file name.  URIs with a 'file' protocol are converted to\n   local file names.\n\n   Should be used inside with-open to ensure the InputStream is properly\n   closed.\"\n  {:added \"1.2\"}\n  [x & opts]\n  (make-input-stream x (when opts (apply hash-map opts))))\n\n(defn ^OutputStream output-stream\n  \"Attempts to coerce its argument into an open java.io.OutputStream.\n   Default implementations always return a java.io.BufferedOutputStream.\n\n   Default implementations are defined for OutputStream, File, URI, URL,\n   Socket, and String arguments.\n\n   If the argument is a String, it tries to resolve it first as a URI, then\n   as a local file name.  URIs with a 'file' protocol are converted to\n   local file names.\n\n   Should be used inside with-open to ensure the OutputStream is\n   properly closed.\"\n  {:added \"1.2\"}\n  [x & opts]\n  (make-output-stream x (when opts (apply hash-map opts))))\n\n(defn- ^Boolean append? [opts]\n  (boolean (:append opts)))\n\n(defn- ^String encoding [opts]\n  (or (:encoding opts) \"UTF-8\"))\n\n(defn- buffer-size [opts]\n  (or (:buffer-size opts) 1024))\n\n(def default-streams-impl\n  {:make-reader (fn [x opts] (make-reader (make-input-stream x opts) opts))\n   :make-writer (fn [x opts] (make-writer (make-output-stream x opts) opts))\n   :make-input-stream (fn [x opts]\n                        (throw (IllegalArgumentException.\n                                (str \"Cannot open <\" (pr-str x) \"> as an InputStream.\"))))\n   :make-output-stream (fn [x opts]\n                         (throw (IllegalArgumentException.\n                                 (str \"Cannot open <\" (pr-str x) \"> as an OutputStream.\"))))})\n\n(defn- inputstream->reader\n  [^InputStream is opts]\n  (make-reader (InputStreamReader. is (encoding opts)) opts))\n\n(defn- outputstream->writer\n  [^OutputStream os opts]\n  (make-writer (OutputStreamWriter. os (encoding opts)) opts))\n\n(extend BufferedInputStream\n  IOFactory\n  (assoc default-streams-impl\n    :make-input-stream (fn [x opts] x)\n    :make-reader inputstream->reader))\n\n(extend InputStream\n  IOFactory\n  (assoc default-streams-impl\n    :make-input-stream (fn [x opts] (BufferedInputStream. x))\n    :make-reader inputstream->reader))\n\n(extend Reader\n  IOFactory\n  (assoc default-streams-impl\n    :make-reader (fn [x opts] (BufferedReader. x))))\n\n(extend BufferedReader\n  IOFactory\n  (assoc default-streams-impl\n    :make-reader (fn [x opts] x)))\n\n(extend Writer\n  IOFactory\n  (assoc default-streams-impl\n    :make-writer (fn [x opts] (BufferedWriter. x))))\n\n(extend BufferedWriter\n  IOFactory\n  (assoc default-streams-impl\n    :make-writer (fn [x opts] x)))\n\n(extend OutputStream\n  IOFactory\n  (assoc default-streams-impl\n    :make-output-stream (fn [x opts] (BufferedOutputStream. x))\n    :make-writer outputstream->writer))\n\n(extend BufferedOutputStream\n  IOFactory\n  (assoc default-streams-impl\n    :make-output-stream (fn [x opts] x)\n    :make-writer outputstream->writer))\n\n(extend File\n  IOFactory\n  (assoc default-streams-impl\n    :make-input-stream (fn [^File x opts] (make-input-stream (FileInputStream. x) opts))\n    :make-output-stream (fn [^File x opts] (make-output-stream (FileOutputStream. x (append? opts)) opts))))\n\n(extend URL\n  IOFactory\n  (assoc default-streams-impl\n    :make-input-stream (fn [^URL x opts]\n                         (make-input-stream\n                          (if (= \"file\" (.getProtocol x))\n                            (FileInputStream. (as-file x))\n                            (.openStream x)) opts))\n    :make-output-stream (fn [^URL x opts]\n                          (if (= \"file\" (.getProtocol x))\n                            (make-output-stream (as-file x) opts)\n                            (throw (IllegalArgumentException. (str \"Can not write to non-file URL <\" x \">\")))))))\n\n(extend URI\n  IOFactory\n  (assoc default-streams-impl\n    :make-input-stream (fn [^URI x opts] (make-input-stream (.toURL x) opts))\n    :make-output-stream (fn [^URI x opts] (make-output-stream (.toURL x) opts))))\n\n(extend String\n  IOFactory\n  (assoc default-streams-impl\n    :make-input-stream (fn [^String x opts]\n                         (try\n                          (make-input-stream (URL. x) opts)\n                          (catch MalformedURLException e\n                            (make-input-stream (File. x) opts))))\n    :make-output-stream (fn [^String x opts]\n                          (try\n                           (make-output-stream (URL. x) opts)\n                           (catch MalformedURLException err\n                             (make-output-stream (File. x) opts))))))\n\n(extend Socket\n  IOFactory\n  (assoc default-streams-impl\n    :make-input-stream (fn [^Socket x opts] (make-input-stream (.getInputStream x) opts))\n    :make-output-stream (fn [^Socket x opts] (make-output-stream (.getOutputStream x) opts))))\n\n(extend byte-array-type\n  IOFactory\n  (assoc default-streams-impl\n    :make-input-stream (fn [x opts] (make-input-stream (ByteArrayInputStream. x) opts))))\n\n(extend char-array-type\n  IOFactory\n  (assoc default-streams-impl\n    :make-reader (fn [x opts] (make-reader (CharArrayReader. x) opts))))\n\n(extend Object\n  IOFactory\n  default-streams-impl)\n\n(defmulti\n  ^{:doc \"Internal helper for copy\"\n     :private true\n     :arglists '([input output opts])}\n  do-copy\n  (fn [input output opts] [(type input) (type output)]))\n\n(defmethod do-copy [InputStream OutputStream] [^InputStream input ^OutputStream output opts]\n  (let [buffer (make-array Byte/TYPE (buffer-size opts))]\n    (loop []\n      (let [size (.read input buffer)]\n        (when (pos? size)\n          (do (.write output buffer 0 size)\n              (recur)))))))\n\n(defmethod do-copy [InputStream Writer] [^InputStream input ^Writer output opts]\n  (let [^\"[C\" buffer (make-array Character/TYPE (buffer-size opts))\n        in (InputStreamReader. input (encoding opts))]\n    (loop []\n      (let [size (.read in buffer 0 (alength buffer))]\n        (if (pos? size)\n          (do (.write output buffer 0 size)\n              (recur)))))))\n\n(defmethod do-copy [InputStream File] [^InputStream input ^File output opts]\n  (with-open [out (FileOutputStream. output)]\n    (do-copy input out opts)))\n\n(defmethod do-copy [Reader OutputStream] [^Reader input ^OutputStream output opts]\n  (let [^\"[C\" buffer (make-array Character/TYPE (buffer-size opts))\n        out (OutputStreamWriter. output (encoding opts))]\n    (loop []\n      (let [size (.read input buffer)]\n        (if (pos? size)\n          (do\n            (.write out buffer 0 size)\n            (recur))\n          (.flush out))))))\n\n(defmethod do-copy [Reader Writer] [^Reader input ^Writer output opts]\n  (let [^\"[C\" buffer (make-array Character/TYPE (buffer-size opts))]\n    (loop []\n      (let [size (.read input buffer)]\n        (when (pos? size)\n          (do (.write output buffer 0 size)\n              (recur)))))))\n\n(defmethod do-copy [Reader File] [^Reader input ^File output opts]\n  (with-open [out (FileOutputStream. output)]\n    (do-copy input out opts)))\n\n(defmethod do-copy [File OutputStream] [^File input ^OutputStream output opts]\n  (with-open [in (FileInputStream. input)]\n    (do-copy in output opts)))\n\n(defmethod do-copy [File Writer] [^File input ^Writer output opts]\n  (with-open [in (FileInputStream. input)]\n    (do-copy in output opts)))\n\n(defmethod do-copy [File File] [^File input ^File output opts]\n  (with-open [in (-> input FileInputStream. .getChannel)\n              out (-> output FileOutputStream. .getChannel)]\n    (let [sz (.size in)]\n      (loop [pos 0]\n        (let [bytes-xferred (.transferTo in pos (- sz pos) out)\n              pos (+ pos bytes-xferred)]\n          (when (< pos sz)\n            (recur pos)))))))\n\n(defmethod do-copy [String OutputStream] [^String input ^OutputStream output opts]\n  (do-copy (StringReader. input) output opts))\n\n(defmethod do-copy [String Writer] [^String input ^Writer output opts]\n  (do-copy (StringReader. input) output opts))\n\n(defmethod do-copy [String File] [^String input ^File output opts]\n  (do-copy (StringReader. input) output opts))\n\n(defmethod do-copy [char-array-type OutputStream] [input ^OutputStream output opts]\n  (do-copy (CharArrayReader. input) output opts))\n\n(defmethod do-copy [char-array-type Writer] [input ^Writer output opts]\n  (do-copy (CharArrayReader. input) output opts))\n\n(defmethod do-copy [char-array-type File] [input ^File output opts]\n  (do-copy (CharArrayReader. input) output opts))\n\n(defmethod do-copy [byte-array-type OutputStream] [^\"[B\" input ^OutputStream output opts]\n  (do-copy (ByteArrayInputStream. input) output opts))\n\n(defmethod do-copy [byte-array-type Writer] [^\"[B\" input ^Writer output opts]\n  (do-copy (ByteArrayInputStream. input) output opts))\n\n(defmethod do-copy [byte-array-type File] [^\"[B\" input ^Writer output opts]\n  (do-copy (ByteArrayInputStream. input) output opts))\n\n(defn copy\n  \"Copies input to output.  Returns nil or throws IOException.\n  Input may be an InputStream, Reader, File, byte[], or String.\n  Output may be an OutputStream, Writer, or File.\n\n  Options are key/value pairs and may be one of\n\n    :buffer-size  buffer size to use, default is 1024.\n    :encoding     encoding to use if converting between\n                  byte and char streams.   \n\n  Does not close any streams except those it opens itself \n  (on a File).\"\n  {:added \"1.2\"}\n  [input output & opts]\n  (do-copy input output (when opts (apply hash-map opts))))\n\n(defn ^String as-relative-path\n  \"Take an as-file-able thing and return a string if it is\n   a relative path, else IllegalArgumentException.\"\n  {:added \"1.2\"}\n  [x]\n  (let [^File f (as-file x)]\n    (if (.isAbsolute f)\n      (throw (IllegalArgumentException. (str f \" is not a relative path\")))\n      (.getPath f))))\n\n(defn ^File file\n  \"Returns a java.io.File, passing each arg to as-file.  Multiple-arg\n   versions treat the first argument as parent and subsequent args as\n   children relative to the parent.\"\n  {:added \"1.2\"}\n  ([arg]                      \n     (as-file arg))\n  ([parent child]             \n     (File. ^File (as-file parent) ^String (as-relative-path child)))\n  ([parent child & more]\n     (reduce file (file parent child) more)))\n\n(defn delete-file\n  \"Delete file f. Raise an exception if it fails unless silently is true.\"\n  {:added \"1.2\"}\n  [f & [silently]]\n  (or (.delete (file f))\n      silently\n      (throw (java.io.IOException. (str \"Couldn't delete \" f)))))\n\n(defn make-parents\n  \"Given the same arg(s) as for file, creates all parent directories of\n   the file they represent.\"\n  {:added \"1.2\"}\n  [f & more]\n  (when-let [parent (.getParentFile ^File (apply file f more))]\n    (.mkdirs parent)))\n\n(defn ^URL resource\n  \"Returns the URL for a named resource. Use the context class loader\n   if no loader is specified.\"\n  {:added \"1.2\"}\n  ([n] (resource n (.getContextClassLoader (Thread/currentThread))))\n  ([n ^ClassLoader loader] (.getResource loader n)))\n"
  },
  {
    "path": "src/clj/clojure/java/javadoc.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n(ns \n  ^{:author \"Christophe Grand, Stuart Sierra\",\n     :doc \"A repl helper to quickly open javadocs.\"}\n  clojure.java.javadoc\n  (:use [clojure.java.browse :only (browse-url)] )\n  (:import\n   (java.io File)))\n\n(def ^:dynamic *feeling-lucky-url* \"http://www.google.com/search?btnI=I%27m%20Feeling%20Lucky&q=allinurl:\")\n(def ^:dynamic *feeling-lucky* true)\n\n(def ^:dynamic *local-javadocs* (ref (list)))\n \n(def ^:dynamic *core-java-api*\n  (case (System/getProperty \"java.specification.version\")\n    \"1.6\" \"http://java.sun.com/javase/6/docs/api/\"\n    \"http://java.sun.com/javase/7/docs/api/\"))\n\n(def ^:dynamic *remote-javadocs*\n (ref (sorted-map\n       \"java.\" *core-java-api*\n       \"javax.\" *core-java-api*\n       \"org.ietf.jgss.\" *core-java-api*\n       \"org.omg.\" *core-java-api*\n       \"org.w3c.dom.\" *core-java-api*\n       \"org.xml.sax.\" *core-java-api*\n       \"org.apache.commons.codec.\" \"http://commons.apache.org/codec/api-release/\"\n       \"org.apache.commons.io.\" \"http://commons.apache.org/io/api-release/\"\n       \"org.apache.commons.lang.\" \"http://commons.apache.org/lang/api-release/\")))\n\n(defn add-local-javadoc\n  \"Adds to the list of local Javadoc paths.\"\n  {:added \"1.2\"}\n  [path]\n  (dosync (commute *local-javadocs* conj path)))\n\n(defn add-remote-javadoc\n  \"Adds to the list of remote Javadoc URLs.  package-prefix is the\n  beginning of the package name that has docs at this URL.\"\n  {:added \"1.2\"}\n  [package-prefix url]\n  (dosync (commute *remote-javadocs* assoc package-prefix url)))\n\n(defn- javadoc-url\n  \"Searches for a URL for the given class name.  Tries\n  *local-javadocs* first, then *remote-javadocs*.  Returns a string.\"\n  {:tag String,\n   :added \"1.2\"}\n  [^String classname]\n  (let [file-path (.replace classname \\. File/separatorChar)\n        url-path (.replace classname \\. \\/)]\n    (if-let [file ^File (first\n                           (filter #(.exists ^File %)\n                             (map #(File. (str %) (str file-path \".html\"))\n                               @*local-javadocs*)))]\n      (-> file .toURI str)\n      ;; If no local file, try remote URLs:\n      (or (some (fn [[prefix url]]\n                  (when (.startsWith classname prefix)\n                    (str url url-path \".html\")))\n            @*remote-javadocs*)\n        ;; if *feeling-lucky* try a web search\n        (when *feeling-lucky* (str *feeling-lucky-url* url-path \".html\"))))))\n\n(defn javadoc\n  \"Opens a browser window displaying the javadoc for the argument.\n  Tries *local-javadocs* first, then *remote-javadocs*.\"\n  {:added \"1.2\"}\n  [class-or-object]\n  (let [^Class c (if (instance? Class class-or-object) \n                    class-or-object \n                    (class class-or-object))]\n    (if-let [url (javadoc-url (.getName c))]\n      (browse-url url)\n      (println \"Could not find Javadoc for\" c))))\n"
  },
  {
    "path": "src/clj/clojure/java/shell.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns \n  ^{:author \"Chris Houser, Stuart Halloway\",\n    :doc \"Conveniently launch a sub-process providing its stdin and\ncollecting its stdout\"}\n  clojure.java.shell\n  (:use [clojure.java.io :only (as-file copy)])\n  (:import (java.io ByteArrayOutputStream StringWriter)\n           (java.nio.charset Charset)))\n\n(def ^:dynamic *sh-dir* nil)\n(def ^:dynamic *sh-env* nil)\n\n(defmacro with-sh-dir\n  \"Sets the directory for use with sh, see sh for details.\"\n  {:added \"1.2\"}\n  [dir & forms]\n  `(binding [*sh-dir* ~dir]\n     ~@forms))\n\n(defmacro with-sh-env\n  \"Sets the environment for use with sh, see sh for details.\"\n  {:added \"1.2\"}\n  [env & forms]\n  `(binding [*sh-env* ~env]\n     ~@forms))\n     \n(defn- aconcat\n  \"Concatenates arrays of given type.\"\n  [type & xs]\n  (let [target (make-array type (apply + (map count xs)))]\n    (loop [i 0 idx 0]\n      (when-let [a (nth xs i nil)]\n        (System/arraycopy a 0 target idx (count a))\n        (recur (inc i) (+ idx (count a)))))\n    target))\n\n(defn- parse-args\n  [args]\n  (let [default-encoding \"UTF-8\" ;; see sh doc string\n        default-opts {:out-enc default-encoding :in-enc default-encoding :dir *sh-dir* :env *sh-env*}\n        [cmd opts] (split-with string? args)]\n    [cmd (merge default-opts (apply hash-map opts))]))\n\n(defn- ^\"[Ljava.lang.String;\" as-env-strings \n  \"Helper so that callers can pass a Clojure map for the :env to sh.\"\n  [arg]\n  (cond\n   (nil? arg) nil\n   (map? arg) (into-array String (map (fn [[k v]] (str (name k) \"=\" v)) arg))\n   true arg))\n\n(defn- stream-to-bytes\n  [in]\n  (with-open [bout (ByteArrayOutputStream.)]\n    (copy in bout)\n    (.toByteArray bout)))\n\n(defn- stream-to-string\n  ([in] (stream-to-string in (.name (Charset/defaultCharset))))\n  ([in enc]\n     (with-open [bout (StringWriter.)]\n       (copy in bout :encoding enc)\n       (.toString bout))))\n\n(defn- stream-to-enc\n  [stream enc]\n  (if (= enc :bytes)\n    (stream-to-bytes stream)\n    (stream-to-string stream enc)))\n\n(defn sh\n  \"Passes the given strings to Runtime.exec() to launch a sub-process.\n\n  Options are\n\n  :in      may be given followed by any legal input source for\n           clojure.java.io/copy, e.g. InputStream, Reader, File, byte[],\n           or String, to be fed to the sub-process's stdin.\n  :in-enc  option may be given followed by a String, used as a character\n           encoding name (for example \\\"UTF-8\\\" or \\\"ISO-8859-1\\\") to\n           convert the input string specified by the :in option to the\n           sub-process's stdin.  Defaults to UTF-8.\n           If the :in option provides a byte array, then the bytes are passed\n           unencoded, and this option is ignored.\n  :out-enc option may be given followed by :bytes or a String. If a\n           String is given, it will be used as a character encoding\n           name (for example \\\"UTF-8\\\" or \\\"ISO-8859-1\\\") to convert\n           the sub-process's stdout to a String which is returned.\n           If :bytes is given, the sub-process's stdout will be stored\n           in a byte array and returned.  Defaults to UTF-8.\n  :env     override the process env with a map (or the underlying Java\n           String[] if you are a masochist).\n  :dir     override the process dir with a String or java.io.File.\n\n  You can bind :env or :dir for multiple operations using with-sh-env\n  and with-sh-dir.\n\n  sh returns a map of\n    :exit => sub-process's exit code\n    :out  => sub-process's stdout (as byte[] or String)\n    :err  => sub-process's stderr (String via platform default encoding)\"\n  {:added \"1.2\"}\n  [& args]\n  (let [[cmd opts] (parse-args args)\n        proc (.exec (Runtime/getRuntime) \n               ^\"[Ljava.lang.String;\" (into-array cmd)\n               (as-env-strings (:env opts))\n               (as-file (:dir opts)))\n        {:keys [in in-enc out-enc]} opts]\n    (if in\n      (future\n        (with-open [os (.getOutputStream proc)]\n          (copy in os :encoding in-enc)))\n      (.close (.getOutputStream proc)))\n    (with-open [stdout (.getInputStream proc)\n                stderr (.getErrorStream proc)]\n      (let [out (future (stream-to-enc stdout out-enc))\n            err (future (stream-to-string stderr))\n            exit-code (.waitFor proc)]\n        {:exit exit-code :out @out :err @err}))))\n\n(comment\n\n(println (sh \"ls\" \"-l\"))\n(println (sh \"ls\" \"-l\" \"/no-such-thing\"))\n(println (sh \"sed\" \"s/[aeiou]/oo/g\" :in \"hello there\\n\"))\n(println (sh \"sed\" \"s/[aeiou]/oo/g\" :in (java.io.StringReader. \"hello there\\n\")))\n(println (sh \"cat\" :in \"x\\u25bax\\n\"))\n(println (sh \"echo\" \"x\\u25bax\"))\n(println (sh \"echo\" \"x\\u25bax\" :out-enc \"ISO-8859-1\")) ; reads 4 single-byte chars\n(println (sh \"cat\" \"myimage.png\" :out-enc :bytes)) ; reads binary file into bytes[]\n(println (sh \"cmd\" \"/c dir 1>&2\"))\n\n)\n"
  },
  {
    "path": "src/clj/clojure/main.clj",
    "content": ";; Copyright (c) Rich Hickey All rights reserved. The use and\n;; distribution terms for this software are covered by the Eclipse Public\n;; License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can be found\n;; in the file epl-v10.html at the root of this distribution. By using this\n;; software in any fashion, you are agreeing to be bound by the terms of\n;; this license. You must not remove this notice, or any other, from this\n;; software.\n\n;; Originally contributed by Stephen C. Gilardi\n\n(ns ^{:doc \"Top-level main function for Clojure REPL and scripts.\"\n       :author \"Stephen C. Gilardi and Rich Hickey\"}\n  clojure.main\n  (:refer-clojure :exclude [with-bindings])\n  (:import (clojure.lang Compiler Compiler$CompilerException\n                         LineNumberingPushbackReader RT))\n  ;;(:use [clojure.repl :only (demunge root-cause stack-element-str)])\n  )\n\n(declare main)\n\n;;;;;;;;;;;;;;;;;;; redundantly copied from clojure.repl to avoid dep ;;;;;;;;;;;;;;\n#_(defn root-cause [x] x)\n#_(defn stack-element-str\n  \"Returns a (possibly unmunged) string representation of a StackTraceElement\"\n  {:added \"1.3\"}\n  [^StackTraceElement el]\n  (.getClassName el))\n\n(defn demunge\n  \"Given a string representation of a fn class,\n  as in a stack trace element, returns a readable version.\"\n  {:added \"1.3\"}\n  [fn-name]\n  (clojure.lang.Compiler/demunge fn-name))\n\n(defn root-cause\n  \"Returns the initial cause of an exception or error by peeling off all of\n  its wrappers\"\n  {:added \"1.3\"}\n  [^Throwable t]\n  (loop [cause t]\n    (if (and (instance? clojure.lang.Compiler$CompilerException cause)\n             (not= (.source ^clojure.lang.Compiler$CompilerException cause) \"NO_SOURCE_FILE\"))\n      cause\n      (if-let [cause (.getCause cause)]\n        (recur cause)\n        cause))))\n\n(defn stack-element-str\n  \"Returns a (possibly unmunged) string representation of a StackTraceElement\"\n  {:added \"1.3\"}\n  [^StackTraceElement el]\n  (let [file (.getFileName el)\n        clojure-fn? (and file (or (.endsWith file \".clj\")\n                                  (.endsWith file \".cljc\")\n                                  (= file \"NO_SOURCE_FILE\")))]\n    (str (if clojure-fn?\n           (demunge (.getClassName el))\n           (str (.getClassName el) \".\" (.getMethodName el)))\n         \" (\" (.getFileName el) \":\" (.getLineNumber el) \")\")))\n;;;;;;;;;;;;;;;;;;; end of redundantly copied from clojure.repl to avoid dep ;;;;;;;;;;;;;;\n\n\n(defmacro with-bindings\n  \"Executes body in the context of thread-local bindings for several vars\n  that often need to be set!: *ns* *warn-on-reflection* *math-context*\n  *print-meta* *print-length* *print-level* *compile-path*\n  *command-line-args* *1 *2 *3 *e\"\n  [& body]\n  `(binding [*ns* *ns*\n             *warn-on-reflection* *warn-on-reflection*\n             *math-context* *math-context*\n             *print-meta* *print-meta*\n             *print-length* *print-length*\n             *print-level* *print-level*\n             *data-readers* *data-readers*\n             *default-data-reader-fn* *default-data-reader-fn*\n             *compile-path* (System/getProperty \"clojure.compile.path\" \"classes\")\n             *command-line-args* *command-line-args*\n             *unchecked-math* *unchecked-math*\n             *assert* *assert*\n             *1 nil\n             *2 nil\n             *3 nil\n             *e nil]\n     ~@body))\n\n(defn repl-prompt\n  \"Default :prompt hook for repl\"\n  []\n  (printf \"%s=> \" (ns-name *ns*)))\n\n(defn skip-if-eol\n  \"If the next character on stream s is a newline, skips it, otherwise\n  leaves the stream untouched. Returns :line-start, :stream-end, or :body\n  to indicate the relative location of the next character on s. The stream\n  must either be an instance of LineNumberingPushbackReader or duplicate\n  its behavior of both supporting .unread and collapsing all of CR, LF, and\n  CRLF to a single \\\\newline.\"\n  [s]\n  (let [c (.read s)]\n    (cond\n     (= c (int \\newline)) :line-start\n     (= c -1) :stream-end\n     :else (do (.unread s c) :body))))\n\n(defn skip-whitespace\n  \"Skips whitespace characters on stream s. Returns :line-start, :stream-end,\n  or :body to indicate the relative location of the next character on s.\n  Interprets comma as whitespace and semicolon as comment to end of line.\n  Does not interpret #! as comment to end of line because only one\n  character of lookahead is available. The stream must either be an\n  instance of LineNumberingPushbackReader or duplicate its behavior of both\n  supporting .unread and collapsing all of CR, LF, and CRLF to a single\n  \\\\newline.\"\n  [s]\n  (loop [c (.read s)]\n    (cond\n     (= c (int \\newline)) :line-start\n     (= c -1) :stream-end\n     (= c (int \\;)) (do (.readLine s) :line-start)\n     (or (Character/isWhitespace (char c)) (= c (int \\,))) (recur (.read s))\n     :else (do (.unread s c) :body))))\n\n(defn repl-read\n  \"Default :read hook for repl. Reads from *in* which must either be an\n  instance of LineNumberingPushbackReader or duplicate its behavior of both\n  supporting .unread and collapsing all of CR, LF, and CRLF into a single\n  \\\\newline. repl-read:\n    - skips whitespace, then\n      - returns request-prompt on start of line, or\n      - returns request-exit on end of stream, or\n      - reads an object from the input stream, then\n        - skips the next input character if it's end of line, then\n        - returns the object.\"\n  [request-prompt request-exit]\n  (or ({:line-start request-prompt :stream-end request-exit}\n       (skip-whitespace *in*))\n      (let [input (read {:read-cond :allow} *in*)]\n        (skip-if-eol *in*)\n        input)))\n\n(defn repl-exception\n  \"Returns the root cause of throwables\"\n  [throwable]\n  (root-cause throwable))\n\n(defn repl-caught\n  \"Default :caught hook for repl\"\n  [e]\n  (let [ex (repl-exception e)\n        tr (.getStackTrace ex)\n        el (when-not (zero? (count tr)) (aget tr 0))]\n    (binding [*out* *err*]\n      (println (str (-> ex class .getSimpleName)\n                    \" \" (.getMessage ex) \" \"\n                    (when-not (instance? clojure.lang.Compiler$CompilerException ex)\n                      (str \" \" (if el (stack-element-str el) \"[trace missing]\"))))))))\n\n(def ^{:doc \"A sequence of lib specs that are applied to `require`\nby default when a new command-line REPL is started.\"} repl-requires\n  '[[clojure.repl :refer (source apropos dir pst doc find-doc)]\n    [clojure.java.javadoc :refer (javadoc)]\n    [clojure.pprint :refer (pp pprint)]])\n\n(defmacro with-read-known\n  \"Evaluates body with *read-eval* set to a \\\"known\\\" value,\n   i.e. substituting true for :unknown if necessary.\"\n  [& body]\n  `(binding [*read-eval* (if (= :unknown *read-eval*) true *read-eval*)]\n     ~@body))\n\n(defn repl\n  \"Generic, reusable, read-eval-print loop. By default, reads from *in*,\n  writes to *out*, and prints exception summaries to *err*. If you use the\n  default :read hook, *in* must either be an instance of\n  LineNumberingPushbackReader or duplicate its behavior of both supporting\n  .unread and collapsing CR, LF, and CRLF into a single \\\\newline. Options\n  are sequential keyword-value pairs. Available options and their defaults:\n\n     - :init, function of no arguments, initialization hook called with\n       bindings for set!-able vars in place.\n       default: #()\n\n     - :need-prompt, function of no arguments, called before each\n       read-eval-print except the first, the user will be prompted if it\n       returns true.\n       default: (if (instance? LineNumberingPushbackReader *in*)\n                  #(.atLineStart *in*)\n                  #(identity true))\n\n     - :prompt, function of no arguments, prompts for more input.\n       default: repl-prompt\n\n     - :flush, function of no arguments, flushes output\n       default: flush\n\n     - :read, function of two arguments, reads from *in*:\n         - returns its first argument to request a fresh prompt\n           - depending on need-prompt, this may cause the repl to prompt\n             before reading again\n         - returns its second argument to request an exit from the repl\n         - else returns the next object read from the input stream\n       default: repl-read\n\n     - :eval, function of one argument, returns the evaluation of its\n       argument\n       default: eval\n\n     - :print, function of one argument, prints its argument to the output\n       default: prn\n\n     - :caught, function of one argument, a throwable, called when\n       read, eval, or print throws an exception or error\n       default: repl-caught\"\n  [& options]\n  (let [cl (.getContextClassLoader (Thread/currentThread))]\n    (.setContextClassLoader (Thread/currentThread) (clojure.lang.DynamicClassLoader. cl)))\n  (let [{:keys [init need-prompt prompt flush read eval print caught]\n         :or {init        #()\n              need-prompt (if (instance? LineNumberingPushbackReader *in*)\n                            #(.atLineStart ^LineNumberingPushbackReader *in*)\n                            #(identity true))\n              prompt      repl-prompt\n              flush       flush\n              read        repl-read\n              eval        eval\n              print       prn\n              caught      repl-caught}}\n        (apply hash-map options)\n        request-prompt (Object.)\n        request-exit (Object.)\n        read-eval-print\n        (fn []\n          (try\n            (let [read-eval *read-eval*\n                  input (with-read-known (read request-prompt request-exit))]\n             (or (#{request-prompt request-exit} input)\n                 (let [value (binding [*read-eval* read-eval] (eval input))]\n                   (print value)\n                   (set! *3 *2)\n                   (set! *2 *1)\n                   (set! *1 value))))\n           (catch Throwable e\n             (caught e)\n             (set! *e e))))]\n    (with-bindings\n     (try\n      (init)\n      (catch Throwable e\n        (caught e)\n        (set! *e e)))\n     (prompt)\n     (flush)\n     (loop []\n       (when-not \n       \t (try (identical? (read-eval-print) request-exit)\n\t  (catch Throwable e\n\t   (caught e)\n\t   (set! *e e)\n\t   nil))\n         (when (need-prompt)\n           (prompt)\n           (flush))\n         (recur))))))\n\n(defn load-script\n  \"Loads Clojure source from a file or resource given its path. Paths\n  beginning with @ or @/ are considered relative to classpath.\"\n  [^String path]\n  (if (.startsWith path \"@\")\n    (RT/loadResourceScript\n     (.substring path (if (.startsWith path \"@/\") 2 1)))\n    (Compiler/loadFile path)))\n\n(defn- init-opt\n  \"Load a script\"\n  [path]\n  (load-script path))\n\n(defn- eval-opt\n  \"Evals expressions in str, prints each non-nil result using prn\"\n  [str]\n  (let [eof (Object.)\n        reader (LineNumberingPushbackReader. (java.io.StringReader. str))]\n      (loop [input (with-read-known (read reader false eof))]\n        (when-not (= input eof)\n          (let [value (eval input)]\n            (when-not (nil? value)\n              (prn value))\n            (recur (with-read-known (read reader false eof))))))))\n\n(defn- init-dispatch\n  \"Returns the handler associated with an init opt\"\n  [opt]\n  ({\"-i\"     init-opt\n    \"--init\" init-opt\n    \"-e\"     eval-opt\n    \"--eval\" eval-opt} opt))\n\n(defn- initialize\n  \"Common initialize routine for repl, script, and null opts\"\n  [args inits]\n  (in-ns 'user)\n  (set! *command-line-args* args)\n  (doseq [[opt arg] inits]\n    ((init-dispatch opt) arg)))\n\n(defn- main-opt\n  \"Call the -main function from a namespace with string arguments from\n  the command line.\"\n  [[_ main-ns & args] inits]\n  (with-bindings\n    (initialize args inits)\n    (apply (ns-resolve (doto (symbol main-ns) require) '-main) args)))\n\n(defn- repl-opt\n  \"Start a repl with args and inits. Print greeting if no eval options were\n  present\"\n  [[_ & args] inits]\n  (when-not (some #(= eval-opt (init-dispatch (first %))) inits)\n    (println \"Clojure\" (clojure-version)))\n  (repl :init (fn []\n                (initialize args inits)\n                (apply require repl-requires)))\n  (prn)\n  (System/exit 0))\n\n(defn- script-opt\n  \"Run a script from a file, resource, or standard in with args and inits\"\n  [[path & args] inits]\n  (with-bindings\n    (initialize args inits)\n    (if (= path \"-\")\n      (load-reader *in*)\n      (load-script path))))\n\n(defn- null-opt\n  \"No repl or script opt present, just bind args and run inits\"\n  [args inits]\n  (with-bindings\n    (initialize args inits)))\n\n(defn- help-opt\n  \"Print help text for main\"\n  [_ _]\n  (println (:doc (meta (var main)))))\n\n(defn- main-dispatch\n  \"Returns the handler associated with a main option\"\n  [opt]\n  (or\n   ({\"-r\"     repl-opt\n     \"--repl\" repl-opt\n     \"-m\"     main-opt\n     \"--main\" main-opt\n     nil      null-opt\n     \"-h\"     help-opt\n     \"--help\" help-opt\n     \"-?\"     help-opt} opt)\n   script-opt))\n\n(defn- legacy-repl\n  \"Called by the clojure.lang.Repl.main stub to run a repl with args\n  specified the old way\"\n  [args]\n  (println \"WARNING: clojure.lang.Repl is deprecated.\nInstead, use clojure.main like this:\njava -cp clojure.jar clojure.main -i init.clj -r args...\")\n  (let [[inits [sep & args]] (split-with (complement #{\"--\"}) args)]\n    (repl-opt (concat [\"-r\"] args) (map vector (repeat \"-i\") inits))))\n\n(defn- legacy-script\n  \"Called by the clojure.lang.Script.main stub to run a script with args\n  specified the old way\"\n  [args]\n  (println \"WARNING: clojure.lang.Script is deprecated.\nInstead, use clojure.main like this:\njava -cp clojure.jar clojure.main -i init.clj script.clj args...\")\n  (let [[inits [sep & args]] (split-with (complement #{\"--\"}) args)]\n    (null-opt args (map vector (repeat \"-i\") inits))))\n\n(defn main\n  \"Usage: java -cp clojure.jar clojure.main [init-opt*] [main-opt] [arg*]\n\n  With no options or args, runs an interactive Read-Eval-Print Loop\n\n  init options:\n    -i, --init path     Load a file or resource\n    -e, --eval string   Evaluate expressions in string; print non-nil values\n\n  main options:\n    -m, --main ns-name  Call the -main function from a namespace with args\n    -r, --repl          Run a repl\n    path                Run a script from a file or resource\n    -                   Run a script from standard input\n    -h, -?, --help      Print this help message and exit\n\n  operation:\n\n    - Establishes thread-local bindings for commonly set!-able vars\n    - Enters the user namespace\n    - Binds *command-line-args* to a seq of strings containing command line\n      args that appear after any main option\n    - Runs all init options in order\n    - Calls a -main function or runs a repl or script if requested\n\n  The init options may be repeated and mixed freely, but must appear before\n  any main option. The appearance of any eval option before running a repl\n  suppresses the usual repl greeting message: \\\"Clojure ~(clojure-version)\\\".\n\n  Paths may be absolute or relative in the filesystem or relative to\n  classpath. Classpath-relative paths have prefix of @ or @/\"\n  [& args]\n  (try\n   (if args\n     (loop [[opt arg & more :as args] args inits []]\n       (if (init-dispatch opt)\n         (recur more (conj inits [opt arg]))\n         ((main-dispatch opt) args inits)))\n     (repl-opt nil nil))\n   (finally \n     (flush))))\n\n"
  },
  {
    "path": "src/clj/clojure/parallel.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns ^{:doc \"DEPRECATED Wrapper of the ForkJoin library (JSR-166).\"\n       :author \"Rich Hickey\"}\n    clojure.parallel)\n(alias 'parallel 'clojure.parallel)\n\n(comment \"\nThe parallel library wraps the ForkJoin library scheduled for inclusion in JDK 7:\n\nhttp://gee.cs.oswego.edu/dl/concurrency-interest/index.html\n\nYou'll need jsr166y.jar in your classpath in order to use this\nlibrary.  The basic idea is that Clojure collections, and most\nefficiently vectors, can be turned into parallel arrays for use by\nthis library with the function par, although most of the functions\ntake collections and will call par if needed, so normally you will\nonly need to call par explicitly in order to attach bound/filter/map\nops. Parallel arrays support the attachment of bounds, filters and\nmapping functions prior to realization/calculation, which happens as\nthe result of any of several operations on the\narray (pvec/psort/pfilter-nils/pfilter-dupes). Rather than perform\ncomposite operations in steps, as would normally be done with\nsequences, maps and filters are instead attached and thus composed by\nproviding ops to par. Note that there is an order sensitivity to the\nattachments - bounds precede filters precede mappings.  All operations\nthen happen in parallel, using multiple threads and a sophisticated\nwork-stealing system supported by fork-join, either when the array is\nrealized, or to perform aggregate operations like preduce/pmin/pmax\netc. A parallel array can be realized into a Clojure vector using\npvec.\n\")\n\n(import '(jsr166y.forkjoin ParallelArray ParallelArrayWithBounds ParallelArrayWithFilter \n                           ParallelArrayWithMapping \n                           Ops$Op Ops$BinaryOp Ops$Reducer Ops$Predicate Ops$BinaryPredicate \n                           Ops$IntAndObjectPredicate Ops$IntAndObjectToObject))\n\n(defn- op [f]\n  (proxy [Ops$Op] []\n    (op [x] (f x))))\n\n(defn- binary-op [f]\n  (proxy [Ops$BinaryOp] []\n    (op [x y] (f x y))))\n\n(defn- int-and-object-to-object [f]\n  (proxy [Ops$IntAndObjectToObject] []\n    (op [i x] (f x i))))\n\n(defn- reducer [f]\n  (proxy [Ops$Reducer] []\n    (op [x y] (f x y))))\n\n(defn- predicate [f]\n  (proxy [Ops$Predicate] []\n    (op [x] (boolean (f x)))))\n\n(defn- binary-predicate [f]\n  (proxy [Ops$BinaryPredicate] []\n    (op [x y] (boolean (f x y)))))\n\n(defn- int-and-object-predicate [f]\n  (proxy [Ops$IntAndObjectPredicate] []\n    (op [i x] (boolean (f x i)))))\n\n(defn par\n  \"Creates a parallel array from coll. ops, if supplied, perform\n  on-the-fly filtering or transformations during parallel realization\n  or calculation. ops form a chain, and bounds must precede filters,\n  must precede maps. ops must be a set of keyword value pairs of the\n  following forms:\n\n     :bound [start end] \n\n  Only elements from start (inclusive) to end (exclusive) will be\n  processed when the array is realized.\n\n     :filter pred \n\n  Filter preds remove elements from processing when the array is realized. pred\n  must be a function of one argument whose return will be processed\n  via boolean.\n\n     :filter-index pred2 \n\n  pred2 must be a function of two arguments, which will be an element\n  of the collection and the corresponding index, whose return will be\n  processed via boolean.\n\n     :filter-with [pred2 coll2] \n\n  pred2 must be a function of two arguments, which will be\n  corresponding elements of the 2 collections.\n\n     :map f \n\n  Map fns will be used to transform elements when the array is\n  realized. f must be a function of one argument.\n\n     :map-index f2 \n\n  f2 must be a function of two arguments, which will be an element of\n  the collection and the corresponding index.\n\n     :map-with [f2 coll2]\n\n  f2 must be a function of two arguments, which will be corresponding\n  elements of the 2 collections.\"\n\n  ([coll] \n     (if (instance? ParallelArrayWithMapping coll)\n       coll\n       (. ParallelArray createUsingHandoff  \n        (to-array coll) \n        (. ParallelArray defaultExecutor))))\n  ([coll & ops]\n     (reduce (fn [pa [op args]] \n                 (cond\n                  (= op :bound) (. pa withBounds (args 0) (args 1))\n                  (= op :filter) (. pa withFilter (predicate args))\n                  (= op :filter-with) (. pa withFilter (binary-predicate (args 0)) (par (args 1)))\n                  (= op :filter-index) (. pa withIndexedFilter (int-and-object-predicate args))\n                  (= op :map) (. pa withMapping (parallel/op args))\n                  (= op :map-with) (. pa withMapping (binary-op (args 0)) (par (args 1)))\n                  (= op :map-index) (. pa withIndexedMapping (int-and-object-to-object args))\n                  :else (throw (Exception. (str \"Unsupported par op: \" op)))))\n             (par coll) \n             (partition 2 ops))))\n\n;;;;;;;;;;;;;;;;;;;;; aggregate operations ;;;;;;;;;;;;;;;;;;;;;;\n(defn pany\n  \"Returns some (random) element of the coll if it satisfies the bound/filter/map\"\n  [coll] \n  (. (par coll) any))\n\n(defn pmax\n  \"Returns the maximum element, presuming Comparable elements, unless\n  a Comparator comp is supplied\"\n  ([coll] (. (par coll) max))\n  ([coll comp] (. (par coll) max comp)))\n\n(defn pmin\n  \"Returns the minimum element, presuming Comparable elements, unless\n  a Comparator comp is supplied\"\n  ([coll] (. (par coll) min))\n  ([coll comp] (. (par coll) min comp)))\n\n(defn- summary-map [s]\n  {:min (.min s) :max (.max s) :size (.size s) :min-index (.indexOfMin s) :max-index (.indexOfMax s)})\n\n(defn psummary \n  \"Returns a map of summary statistics (min. max, size, min-index, max-index, \n  presuming Comparable elements, unless a Comparator comp is supplied\"\n  ([coll] (summary-map (. (par coll) summary)))\n  ([coll comp] (summary-map (. (par coll) summary comp))))\n\n(defn preduce \n  \"Returns the reduction of the realized elements of coll\n  using function f. Note f will not necessarily be called\n  consecutively, and so must be commutative. Also note that \n  (f base an-element) might be performed many times, i.e. base is not\n  an initial value as with sequential reduce.\"\n  [f base coll]\n  (. (par coll) (reduce (reducer f) base)))\n\n;;;;;;;;;;;;;;;;;;;;; collection-producing operations ;;;;;;;;;;;;;;;;;;;;;;\n\n(defn- pa-to-vec [pa]\n  (vec (. pa getArray)))\n\n(defn- pall\n  \"Realizes a copy of the coll as a parallel array, with any bounds/filters/maps applied\"\n  [coll]\n  (if (instance? ParallelArrayWithMapping coll)\n    (. coll all)\n    (par coll)))\n\n(defn pvec \n  \"Returns the realized contents of the parallel array pa as a Clojure vector\"\n  [pa] (pa-to-vec (pall pa)))\n\n(defn pdistinct\n  \"Returns a parallel array of the distinct elements of coll\"\n  [coll]\n  (pa-to-vec (. (pall coll) allUniqueElements)))\n\n;this doesn't work, passes null to reducer?\n(defn- pcumulate [coll f init]\n  (.. (pall coll) (precumulate (reducer f) init)))\n\n(defn psort \n  \"Returns a new vector consisting of the realized items in coll, sorted, \n  presuming Comparable elements, unless a Comparator comp is supplied\"\n  ([coll] (pa-to-vec (. (pall coll) sort)))\n  ([coll comp] (pa-to-vec (. (pall coll) sort comp))))\n\n(defn pfilter-nils\n  \"Returns a vector containing the non-nil (realized) elements of coll\"\n  [coll]\n  (pa-to-vec (. (pall coll) removeNulls)))\n\n(defn pfilter-dupes \n  \"Returns a vector containing the (realized) elements of coll, \n  without any consecutive duplicates\"\n  [coll]\n  (pa-to-vec (. (pall coll) removeConsecutiveDuplicates)))\n\n\n(comment\n(load-file \"src/parallel.clj\")\n(refer 'parallel)\n(pdistinct [1 2 3 2 1])\n;(pcumulate [1 2 3 2 1] + 0) ;broken, not exposed\n(def a (make-array Object 1000000))\n(dotimes i (count a)\n  (aset a i (rand-int i)))\n(time (reduce + 0 a))\n(time (preduce + 0 a))\n(time (count (distinct a)))\n(time (count (pdistinct a)))\n\n(preduce + 0 [1 2 3 2 1])\n(preduce + 0 (psort a))\n(pvec (par [11 2 3 2] :filter-index (fn [x i] (> i x))))\n(pvec (par [11 2 3 2] :filter-with [(fn [x y] (> y x)) [110 2 33 2]]))\n\n(psummary ;or pvec/pmax etc\n (par [11 2 3 2] \n      :filter-with [(fn [x y] (> y x)) \n                    [110 2 33 2]]\n      :map #(* % 2)))\n\n(preduce + 0\n  (par [11 2 3 2] \n       :filter-with [< [110 2 33 2]]))\n\n(time (reduce + 0 (map #(* % %) (range 1000000))))\n(time (preduce + 0 (par (range 1000000) :map-index *)))\n(def v (range 1000000))\n(time (preduce + 0 (par v :map-index *)))\n(time (preduce + 0 (par v :map  #(* % %))))\n(time (reduce + 0 (map #(* % %) v)))\n)"
  },
  {
    "path": "src/clj/clojure/pprint/cl_format.clj",
    "content": ";;; cl_format.clj -- part of the pretty printer for Clojure\n\n;   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Tom Faulhaber\n;; April 3, 2009\n\n\n;; This module implements the Common Lisp compatible format function as documented\n;; in \"Common Lisp the Language, 2nd edition\", Chapter 22 (available online at:\n;; http://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node200.html#SECTION002633000000000000000)\n\n(in-ns 'clojure.pprint)\n\n;;; Forward references\n(declare compile-format)\n(declare execute-format)\n(declare init-navigator)\n;;; End forward references\n\n(defn cl-format \n  \"An implementation of a Common Lisp compatible format function. cl-format formats its\narguments to an output stream or string based on the format control string given. It \nsupports sophisticated formatting of structured data.\n\nWriter is an instance of java.io.Writer, true to output to *out* or nil to output \nto a string, format-in is the format control string and the remaining arguments \nare the data to be formatted.\n\nThe format control string is a string to be output with embedded 'format directives' \ndescribing how to format the various arguments passed in.\n\nIf writer is nil, cl-format returns the formatted result string. Otherwise, cl-format \nreturns nil.\n\nFor example:\n (let [results [46 38 22]]\n        (cl-format true \\\"There ~[are~;is~:;are~]~:* ~d result~:p: ~{~d~^, ~}~%\\\" \n                   (count results) results))\n\nPrints to *out*:\n There are 3 results: 46, 38, 22\n\nDetailed documentation on format control strings is available in the \\\"Common Lisp the \nLanguage, 2nd edition\\\", Chapter 22 (available online at:\nhttp://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node200.html#SECTION002633000000000000000) \nand in the Common Lisp HyperSpec at \nhttp://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm\n\"\n  {:added \"1.2\",\n   :see-also [[\"http://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node200.html#SECTION002633000000000000000\" \n               \"Common Lisp the Language\"]\n              [\"http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm\"\n               \"Common Lisp HyperSpec\"]]}\n  [writer format-in & args]\n  (let [compiled-format (if (string? format-in) (compile-format format-in) format-in)\n        navigator (init-navigator args)]\n    (execute-format writer compiled-format navigator)))\n\n(def ^:dynamic ^{:private true} *format-str* nil)\n\n(defn- format-error [message offset] \n  (let [full-message (str message \\newline *format-str* \\newline \n                           (apply str (repeat offset \\space)) \"^\" \\newline)]\n    (throw (RuntimeException. full-message))))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Argument navigators manage the argument list\n;;; as the format statement moves through the list\n;;; (possibly going forwards and backwards as it does so)\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defstruct ^{:private true}\n  arg-navigator :seq :rest :pos )\n\n(defn- init-navigator \n  \"Create a new arg-navigator from the sequence with the position set to 0\"\n  {:skip-wiki true}\n  [s]\n  (let [s (seq s)]\n    (struct arg-navigator s s 0)))\n\n;; TODO call format-error with offset\n(defn- next-arg [ navigator ]\n  (let [ rst (:rest navigator) ]\n    (if rst\n      [(first rst) (struct arg-navigator (:seq navigator ) (next rst) (inc (:pos navigator)))]\n     (throw (new Exception  \"Not enough arguments for format definition\")))))\n\n(defn- next-arg-or-nil [navigator]\n  (let [rst (:rest navigator)]\n    (if rst\n      [(first rst) (struct arg-navigator (:seq navigator ) (next rst) (inc (:pos navigator)))]\n      [nil navigator])))\n\n;; Get an argument off the arg list and compile it if it's not already compiled\n(defn- get-format-arg [navigator]\n  (let [[raw-format navigator] (next-arg navigator)\n        compiled-format (if (instance? String raw-format) \n                               (compile-format raw-format)\n                               raw-format)]\n    [compiled-format navigator]))\n\n(declare relative-reposition)\n\n(defn- absolute-reposition [navigator position]\n  (if (>= position (:pos navigator))\n    (relative-reposition navigator (- (:pos navigator) position))\n    (struct arg-navigator (:seq navigator) (drop position (:seq navigator)) position)))\n\n(defn- relative-reposition [navigator position]\n  (let [newpos (+ (:pos navigator) position)]\n    (if (neg? position)\n      (absolute-reposition navigator newpos)\n      (struct arg-navigator (:seq navigator) (drop position (:rest navigator)) newpos))))\n\n(defstruct ^{:private true}\n  compiled-directive :func :def :params :offset)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; When looking at the parameter list, we may need to manipulate\n;;; the argument list as well (for 'V' and '#' parameter types).\n;;; We hide all of this behind a function, but clients need to\n;;; manage changing arg navigator\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n;; TODO: validate parameters when they come from arg list\n(defn- realize-parameter [[param [raw-val offset]] navigator]\n  (let [[real-param new-navigator]\n        (cond \n         (contains? #{ :at :colon } param) ;pass flags through unchanged - this really isn't necessary\n         [raw-val navigator]\n\n         (= raw-val :parameter-from-args) \n         (next-arg navigator)\n\n         (= raw-val :remaining-arg-count) \n         [(count (:rest navigator)) navigator]\n\n         true \n         [raw-val navigator])]\n    [[param [real-param offset]] new-navigator]))\n         \n(defn- realize-parameter-list [parameter-map navigator]\n  (let [[pairs new-navigator] \n        (map-passing-context realize-parameter navigator parameter-map)]\n    [(into {} pairs) new-navigator]))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Functions that support individual directives\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Common handling code for ~A and ~S\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(declare opt-base-str)\n\n(def ^{:private true}\n     special-radix-markers {2 \"#b\" 8 \"#o\", 16 \"#x\"})\n\n(defn- format-simple-number [n]\n  (cond \n    (integer? n) (if (= *print-base* 10)\n                   (str n (if *print-radix* \".\"))\n                   (str\n                    (if *print-radix* (or (get special-radix-markers *print-base*) (str \"#\" *print-base* \"r\")))\n                    (opt-base-str *print-base* n)))\n    (ratio? n) (str\n                (if *print-radix* (or (get special-radix-markers *print-base*) (str \"#\" *print-base* \"r\")))\n                (opt-base-str *print-base* (.numerator n))\n                \"/\"\n                (opt-base-str *print-base* (.denominator n)))\n    :else nil))\n\n(defn- format-ascii [print-func params arg-navigator offsets]\n  (let [ [arg arg-navigator] (next-arg arg-navigator) \n         ^String base-output (or (format-simple-number arg) (print-func arg))\n         base-width (.length base-output)\n         min-width (+ base-width (:minpad params))\n         width (if (>= min-width (:mincol params)) \n                 min-width\n                 (+ min-width \n                    (* (+ (quot (- (:mincol params) min-width 1) \n                                (:colinc params) )\n                          1)\n                       (:colinc params))))\n         chars (apply str (repeat (- width base-width) (:padchar params)))]\n    (if (:at params)\n      (print (str chars base-output))\n      (print (str base-output chars)))\n    arg-navigator))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Support for the integer directives ~D, ~X, ~O, ~B and some\n;;; of ~R\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn- integral?\n  \"returns true if a number is actually an integer (that is, has no fractional part)\"\n  [x]\n  (cond\n   (integer? x) true\n   (decimal? x) (>= (.ulp (.stripTrailingZeros (bigdec 0))) 1) ; true iff no fractional part\n   (float? x)   (= x (Math/floor x))\n   (ratio? x)   (let [^clojure.lang.Ratio r x]\n                  (= 0 (rem (.numerator r) (.denominator r))))\n   :else        false))\n\n(defn- remainders\n  \"Return the list of remainders (essentially the 'digits') of val in the given base\"\n  [base val]\n  (reverse \n   (first \n    (consume #(if (pos? %) \n                [(rem % base) (quot % base)] \n                [nil nil]) \n             val))))\n\n;;; TODO: xlated-val does not seem to be used here.\n(defn- base-str\n  \"Return val as a string in the given base\"\n  [base val]\n  (if (zero? val)\n    \"0\"\n    (let [xlated-val (cond\n                       (float? val) (bigdec val)\n                       (ratio? val) (let [^clojure.lang.Ratio r val] \n                                      (/ (.numerator r) (.denominator r)))\n                       :else val)] \n      (apply str \n             (map \n              #(if (< % 10) (char (+ (int \\0) %)) (char (+ (int \\a) (- % 10)))) \n              (remainders base val))))))\n\n(def ^{:private true}\n     java-base-formats {8 \"%o\", 10 \"%d\", 16 \"%x\"})\n\n(defn- opt-base-str\n  \"Return val as a string in the given base, using clojure.core/format if supported\nfor improved performance\"\n  [base val]\n  (let [format-str (get java-base-formats base)]\n    (if (and format-str (integer? val) (not (instance? clojure.lang.BigInt val)))\n      (clojure.core/format format-str val)\n      (base-str base val))))\n\n(defn- group-by* [unit lis]\n  (reverse\n   (first\n    (consume (fn [x] [(seq (reverse (take unit x))) (seq (drop unit x))]) (reverse lis)))))\n\n(defn- format-integer [base params arg-navigator offsets]\n  (let [[arg arg-navigator] (next-arg arg-navigator)]\n    (if (integral? arg)\n      (let [neg (neg? arg)\n            pos-arg (if neg (- arg) arg)\n            raw-str (opt-base-str base pos-arg)\n            group-str (if (:colon params)\n                        (let [groups (map #(apply str %) (group-by* (:commainterval params) raw-str))\n                              commas (repeat (count groups) (:commachar params))]\n                          (apply str (next (interleave commas groups))))\n                        raw-str)\n            ^String signed-str (cond\n                                  neg (str \"-\" group-str)\n                                  (:at params) (str \"+\" group-str)\n                                  true group-str)\n            padded-str (if (< (.length signed-str) (:mincol params))\n                         (str (apply str (repeat (- (:mincol params) (.length signed-str)) \n                                                 (:padchar params)))\n                              signed-str)\n                         signed-str)]\n        (print padded-str))\n      (format-ascii print-str {:mincol (:mincol params) :colinc 1 :minpad 0 \n                               :padchar (:padchar params) :at true} \n                    (init-navigator [arg]) nil))\n    arg-navigator))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Support for english formats (~R and ~:R)\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(def ^{:private true}\n     english-cardinal-units \n     [\"zero\" \"one\" \"two\" \"three\" \"four\" \"five\" \"six\" \"seven\" \"eight\" \"nine\"\n      \"ten\" \"eleven\" \"twelve\" \"thirteen\" \"fourteen\"\n      \"fifteen\" \"sixteen\" \"seventeen\" \"eighteen\" \"nineteen\"])\n\n(def ^{:private true}\n     english-ordinal-units \n     [\"zeroth\" \"first\" \"second\" \"third\" \"fourth\" \"fifth\" \"sixth\" \"seventh\" \"eighth\" \"ninth\"\n      \"tenth\" \"eleventh\" \"twelfth\" \"thirteenth\" \"fourteenth\"\n      \"fifteenth\" \"sixteenth\" \"seventeenth\" \"eighteenth\" \"nineteenth\"])\n\n(def ^{:private true}\n     english-cardinal-tens\n     [\"\" \"\" \"twenty\" \"thirty\" \"forty\" \"fifty\" \"sixty\" \"seventy\" \"eighty\" \"ninety\"])\n\n(def ^{:private true}\n     english-ordinal-tens\n     [\"\" \"\" \"twentieth\" \"thirtieth\" \"fortieth\" \"fiftieth\"\n      \"sixtieth\" \"seventieth\" \"eightieth\" \"ninetieth\"])\n\n;; We use \"short scale\" for our units (see http://en.wikipedia.org/wiki/Long_and_short_scales)\n;; Number names from http://www.jimloy.com/math/billion.htm\n;; We follow the rules for writing numbers from the Blue Book\n;; (http://www.grammarbook.com/numbers/numbers.asp)\n(def ^{:private true}\n     english-scale-numbers \n     [\"\" \"thousand\" \"million\" \"billion\" \"trillion\" \"quadrillion\" \"quintillion\" \n      \"sextillion\" \"septillion\" \"octillion\" \"nonillion\" \"decillion\" \n      \"undecillion\" \"duodecillion\" \"tredecillion\" \"quattuordecillion\" \n      \"quindecillion\" \"sexdecillion\" \"septendecillion\" \n      \"octodecillion\" \"novemdecillion\" \"vigintillion\"])\n\n(defn- format-simple-cardinal\n  \"Convert a number less than 1000 to a cardinal english string\"\n  [num]\n  (let [hundreds (quot num 100)\n        tens (rem num 100)]\n    (str\n     (if (pos? hundreds) (str (nth english-cardinal-units hundreds) \" hundred\"))\n     (if (and (pos? hundreds) (pos? tens)) \" \")\n     (if (pos? tens) \n       (if (< tens 20) \n         (nth english-cardinal-units tens)\n         (let [ten-digit (quot tens 10)\n               unit-digit (rem tens 10)]\n           (str\n            (if (pos? ten-digit) (nth english-cardinal-tens ten-digit))\n            (if (and (pos? ten-digit) (pos? unit-digit)) \"-\")\n            (if (pos? unit-digit) (nth english-cardinal-units unit-digit)))))))))\n\n(defn- add-english-scales\n  \"Take a sequence of parts, add scale numbers (e.g., million) and combine into a string\noffset is a factor of 10^3 to multiply by\"\n  [parts offset]\n  (let [cnt (count parts)]\n    (loop [acc []\n           pos (dec cnt)\n           this (first parts)\n           remainder (next parts)]\n      (if (nil? remainder)\n        (str (apply str (interpose \", \" acc))\n             (if (and (not (empty? this)) (not (empty? acc))) \", \")\n             this\n             (if (and (not (empty? this)) (pos? (+ pos offset)))\n               (str \" \" (nth english-scale-numbers (+ pos offset)))))\n        (recur \n         (if (empty? this)\n           acc\n           (conj acc (str this \" \" (nth english-scale-numbers (+ pos offset)))))\n         (dec pos)\n         (first remainder)\n         (next remainder))))))\n\n(defn- format-cardinal-english [params navigator offsets]\n  (let [[arg navigator] (next-arg navigator)]\n    (if (= 0 arg)\n      (print \"zero\")\n      (let [abs-arg (if (neg? arg) (- arg) arg) ; some numbers are too big for Math/abs\n            parts (remainders 1000 abs-arg)]\n        (if (<= (count parts) (count english-scale-numbers))\n          (let [parts-strs (map format-simple-cardinal parts)\n                full-str (add-english-scales parts-strs 0)]\n            (print (str (if (neg? arg) \"minus \") full-str)))\n          (format-integer ;; for numbers > 10^63, we fall back on ~D\n           10\n           { :mincol 0, :padchar \\space, :commachar \\, :commainterval 3, :colon true}\n           (init-navigator [arg])\n           { :mincol 0, :padchar 0, :commachar 0 :commainterval 0}))))\n    navigator))\n\n(defn- format-simple-ordinal\n  \"Convert a number less than 1000 to a ordinal english string\nNote this should only be used for the last one in the sequence\"\n  [num]\n  (let [hundreds (quot num 100)\n        tens (rem num 100)]\n    (str\n     (if (pos? hundreds) (str (nth english-cardinal-units hundreds) \" hundred\"))\n     (if (and (pos? hundreds) (pos? tens)) \" \")\n     (if (pos? tens) \n       (if (< tens 20) \n         (nth english-ordinal-units tens)\n         (let [ten-digit (quot tens 10)\n               unit-digit (rem tens 10)]\n           (if (and (pos? ten-digit) (not (pos? unit-digit)))\n             (nth english-ordinal-tens ten-digit)\n             (str\n              (if (pos? ten-digit) (nth english-cardinal-tens ten-digit))\n              (if (and (pos? ten-digit) (pos? unit-digit)) \"-\")\n              (if (pos? unit-digit) (nth english-ordinal-units unit-digit))))))\n       (if (pos? hundreds) \"th\")))))\n\n(defn- format-ordinal-english [params navigator offsets]\n  (let [[arg navigator] (next-arg navigator)]\n    (if (= 0 arg)\n      (print \"zeroth\")\n      (let [abs-arg (if (neg? arg) (- arg) arg) ; some numbers are too big for Math/abs\n            parts (remainders 1000 abs-arg)]\n        (if (<= (count parts) (count english-scale-numbers))\n          (let [parts-strs (map format-simple-cardinal (drop-last parts))\n                head-str (add-english-scales parts-strs 1)\n                tail-str (format-simple-ordinal (last parts))]\n            (print (str (if (neg? arg) \"minus \") \n                        (cond \n                         (and (not (empty? head-str)) (not (empty? tail-str))) \n                         (str head-str \", \" tail-str)\n                         \n                         (not (empty? head-str)) (str head-str \"th\")\n                         :else tail-str))))\n          (do (format-integer ;; for numbers > 10^63, we fall back on ~D\n               10\n               { :mincol 0, :padchar \\space, :commachar \\, :commainterval 3, :colon true}\n               (init-navigator [arg])\n               { :mincol 0, :padchar 0, :commachar 0 :commainterval 0})\n              (let [low-two-digits (rem arg 100)\n                    not-teens (or (< 11 low-two-digits) (> 19 low-two-digits))\n                    low-digit (rem low-two-digits 10)]\n                (print (cond \n                        (and (== low-digit 1) not-teens) \"st\"\n                        (and (== low-digit 2) not-teens) \"nd\"\n                        (and (== low-digit 3) not-teens) \"rd\"\n                        :else \"th\")))))))\n    navigator))\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Support for roman numeral formats (~@R and ~@:R)\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(def ^{:private true}\n     old-roman-table\n     [[ \"I\" \"II\" \"III\" \"IIII\" \"V\" \"VI\" \"VII\" \"VIII\" \"VIIII\"]\n      [ \"X\" \"XX\" \"XXX\" \"XXXX\" \"L\" \"LX\" \"LXX\" \"LXXX\" \"LXXXX\"]\n      [ \"C\" \"CC\" \"CCC\" \"CCCC\" \"D\" \"DC\" \"DCC\" \"DCCC\" \"DCCCC\"]\n      [ \"M\" \"MM\" \"MMM\"]])\n\n(def ^{:private true}\n     new-roman-table\n     [[ \"I\" \"II\" \"III\" \"IV\" \"V\" \"VI\" \"VII\" \"VIII\" \"IX\"]\n      [ \"X\" \"XX\" \"XXX\" \"XL\" \"L\" \"LX\" \"LXX\" \"LXXX\" \"XC\"]\n      [ \"C\" \"CC\" \"CCC\" \"CD\" \"D\" \"DC\" \"DCC\" \"DCCC\" \"CM\"]\n      [ \"M\" \"MM\" \"MMM\"]])\n\n(defn- format-roman\n  \"Format a roman numeral using the specified look-up table\"\n  [table params navigator offsets]\n  (let [[arg navigator] (next-arg navigator)]\n    (if (and (number? arg) (> arg 0) (< arg 4000))\n      (let [digits (remainders 10 arg)]\n        (loop [acc []\n               pos (dec (count digits))\n               digits digits]\n          (if (empty? digits)\n            (print (apply str acc))\n            (let [digit (first digits)]\n              (recur (if (= 0 digit) \n                       acc \n                       (conj acc (nth (nth table pos) (dec digit))))\n                     (dec pos)\n                     (next digits))))))\n      (format-integer ;; for anything <= 0 or > 3999, we fall back on ~D\n           10\n           { :mincol 0, :padchar \\space, :commachar \\, :commainterval 3, :colon true}\n           (init-navigator [arg])\n           { :mincol 0, :padchar 0, :commachar 0 :commainterval 0}))\n    navigator))\n\n(defn- format-old-roman [params navigator offsets]\n  (format-roman old-roman-table params navigator offsets))\n\n(defn- format-new-roman [params navigator offsets]\n  (format-roman new-roman-table params navigator offsets))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Support for character formats (~C)\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(def ^{:private true} \n     special-chars { 8 \"Backspace\", 9 \"Tab\",  10 \"Newline\", 13 \"Return\", 32 \"Space\"})\n\n(defn- pretty-character [params navigator offsets]\n  (let [[c navigator] (next-arg navigator)\n        as-int (int c)\n        base-char (bit-and as-int 127)\n        meta (bit-and as-int 128)\n        special (get special-chars base-char)]\n    (if (> meta 0) (print \"Meta-\"))\n    (print (cond\n            special special\n            (< base-char 32) (str \"Control-\" (char (+ base-char 64)))\n            (= base-char 127) \"Control-?\"\n            :else (char base-char)))\n    navigator))\n\n(defn- readable-character [params navigator offsets]\n  (let [[c navigator] (next-arg navigator)]\n    (condp = (:char-format params)\n      \\o (cl-format true \"\\\\o~3,'0o\" (int c))\n      \\u (cl-format true \"\\\\u~4,'0x\" (int c))\n      nil (pr c))\n    navigator))\n\n(defn- plain-character [params navigator offsets]\n  (let [[char navigator] (next-arg navigator)]\n    (print char)\n    navigator))\n\n;; Check to see if a result is an abort (~^) construct\n;; TODO: move these funcs somewhere more appropriate\n(defn- abort? [context]\n  (let [token (first context)]\n    (or (= :up-arrow token) (= :colon-up-arrow token))))\n\n;; Handle the execution of \"sub-clauses\" in bracket constructions\n(defn- execute-sub-format [format args base-args]\n  (second\n   (map-passing-context \n    (fn [element context]\n      (if (abort? context)\n        [nil context] ; just keep passing it along\n        (let [[params args] (realize-parameter-list (:params element) context)\n              [params offsets] (unzip-map params)\n              params (assoc params :base-args base-args)]\n          [nil (apply (:func element) [params args offsets])])))\n    args\n    format)))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Support for real number formats\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n;; TODO - return exponent as int to eliminate double conversion\n(defn- float-parts-base\n  \"Produce string parts for the mantissa (normalized 1-9) and exponent\"\n  [^Object f]\n  (let [^String s (.toLowerCase (.toString f))\n        exploc (.indexOf s (int \\e))\n        dotloc (.indexOf s (int \\.))]\n    (if (neg? exploc)\n      (if (neg? dotloc)\n        [s (str (dec (count s)))]\n        [(str (subs s 0 dotloc) (subs s (inc dotloc))) (str (dec dotloc))])\n      (if (neg? dotloc)\n        [(subs s 0 exploc) (subs s (inc exploc))]\n        [(str (subs s 0 1) (subs s 2 exploc)) (subs s (inc exploc))]))))\n\n\n(defn- float-parts\n  \"Take care of leading and trailing zeros in decomposed floats\"\n  [f]\n  (let [[m ^String e] (float-parts-base f)\n        m1 (rtrim m \\0)\n        m2 (ltrim m1 \\0)\n        delta (- (count m1) (count m2))\n        ^String e (if (and (pos? (count e)) (= (nth e 0) \\+)) (subs e 1) e)]\n    (if (empty? m2)\n      [\"0\" 0]\n      [m2 (- (Integer/valueOf e) delta)])))\n\n(defn- ^String inc-s\n  \"Assumption: The input string consists of one or more decimal digits,\nand no other characters.  Return a string containing one or more\ndecimal digits containing a decimal number one larger than the input\nstring.  The output string will always be the same length as the input\nstring, or one character longer.\"\n  [^String s]\n  (let [len-1 (dec (count s))]\n    (loop [i (int len-1)]\n      (cond\n       (neg? i) (apply str \"1\" (repeat (inc len-1) \"0\"))\n       (= \\9 (.charAt s i)) (recur (dec i))\n       :else (apply str (subs s 0 i)\n                    (char (inc (int (.charAt s i))))\n                    (repeat (- len-1 i) \"0\"))))))\n\n(defn- round-str [m e d w]\n  (if (or d w)\n    (let [len (count m)\n          ;; Every formatted floating point number should include at\n          ;; least one decimal digit and a decimal point.\n          w (if w (max 2 w))\n          round-pos (cond\n                     ;; If d was given, that forces the rounding\n                     ;; position, regardless of any width that may\n                     ;; have been specified.\n                     d (+ e d 1)\n                     ;; Otherwise w was specified, so pick round-pos\n                     ;; based upon that.\n                     ;; If e>=0, then abs value of number is >= 1.0,\n                     ;; and e+1 is number of decimal digits before the\n                     ;; decimal point when the number is written\n                     ;; without scientific notation.  Never round the\n                     ;; number before the decimal point.\n                     (>= e 0) (max (inc e) (dec w))\n                     ;; e < 0, so number abs value < 1.0\n                     :else (+ w e))\n          [m1 e1 round-pos len] (if (= round-pos 0) \n                                  [(str \"0\" m) (inc e) 1 (inc len)]\n                                  [m e round-pos len])]\n      (if round-pos\n        (if (neg? round-pos)\n          [\"0\" 0 false]\n          (if (> len round-pos)\n            (let [round-char (nth m1 round-pos)\n                  ^String result (subs m1 0 round-pos)]\n              (if (>= (int round-char) (int \\5))\n                (let [round-up-result (inc-s result)\n                      expanded (> (count round-up-result) (count result))]\n                  [(if expanded\n                     (subs round-up-result 0 (dec (count round-up-result)))\n                     round-up-result)\n                   e1 expanded])\n                [result e1 false]))\n            [m e false]))\n        [m e false]))\n    [m e false]))\n\n(defn- expand-fixed [m e d]\n  (let [[m1 e1] (if (neg? e)\n                  [(str (apply str (repeat (dec (- e)) \\0)) m) -1]\n                  [m e])\n        len (count m1)\n        target-len (if d (+ e1 d 1) (inc e1))]\n    (if (< len target-len) \n      (str m1 (apply str (repeat (- target-len len) \\0))) \n      m1)))\n\n(defn- insert-decimal\n  \"Insert the decimal point at the right spot in the number to match an exponent\"\n  [m e]\n  (if (neg? e)\n    (str \".\" m)\n    (let [loc (inc e)]\n      (str (subs m 0 loc) \".\" (subs m loc)))))\n\n(defn- get-fixed [m e d]\n  (insert-decimal (expand-fixed m e d) e))\n\n(defn- insert-scaled-decimal\n  \"Insert the decimal point at the right spot in the number to match an exponent\"\n  [m k]\n  (if (neg? k)\n    (str \".\" m)\n    (str (subs m 0 k) \".\" (subs m k))))\n\n(defn- convert-ratio [x]\n  (if (ratio? x)\n    ;; Usually convert to a double, only resorting to the slower\n    ;; bigdec conversion if the result does not fit within the range\n    ;; of a double.\n    (let [d (double x)]\n      (if (== d 0.0)\n        (if (not= x 0)\n          (bigdec x)\n          d)\n        (if (or (== d Double/POSITIVE_INFINITY) (== d Double/NEGATIVE_INFINITY))\n          (bigdec x)\n          d)))\n    x))\n\n;; the function to render ~F directives\n;; TODO: support rationals. Back off to ~D/~A is the appropriate cases\n(defn- fixed-float [params navigator offsets]\n  (let [w (:w params)\n        d (:d params)\n        [arg navigator] (next-arg navigator)\n        [sign abs] (if (neg? arg) [\"-\" (- arg)] [\"+\" arg])\n        abs (convert-ratio abs)\n        [mantissa exp] (float-parts abs)\n        scaled-exp (+ exp (:k params))\n        add-sign (or (:at params) (neg? arg))\n        append-zero (and (not d) (<= (dec (count mantissa)) scaled-exp))\n        [rounded-mantissa scaled-exp expanded] (round-str mantissa scaled-exp \n                                                          d (if w (- w (if add-sign 1 0))))\n        fixed-repr (get-fixed rounded-mantissa (if expanded (inc scaled-exp) scaled-exp) d)\n        fixed-repr (if (and w d\n                            (>= d 1)\n                            (= (.charAt fixed-repr 0) \\0)\n                            (= (.charAt fixed-repr 1) \\.)\n                            (> (count fixed-repr) (- w (if add-sign 1 0))))\n                     (subs fixed-repr 1)  ; chop off leading 0\n                     fixed-repr)\n        prepend-zero (= (first fixed-repr) \\.)]\n    (if w\n      (let [len (count fixed-repr)\n            signed-len (if add-sign (inc len) len)\n            prepend-zero (and prepend-zero (not (>= signed-len w)))\n            append-zero (and append-zero (not (>= signed-len w)))\n            full-len (if (or prepend-zero append-zero)\n                       (inc signed-len) \n                       signed-len)]\n        (if (and (> full-len w) (:overflowchar params))\n          (print (apply str (repeat w (:overflowchar params))))\n          (print (str\n                  (apply str (repeat (- w full-len) (:padchar params)))\n                  (if add-sign sign) \n                  (if prepend-zero \"0\")\n                  fixed-repr\n                  (if append-zero \"0\")))))\n      (print (str\n              (if add-sign sign) \n              (if prepend-zero \"0\")\n              fixed-repr\n              (if append-zero \"0\"))))\n    navigator))\n\n\n;; the function to render ~E directives\n;; TODO: support rationals. Back off to ~D/~A is the appropriate cases\n;; TODO: define ~E representation for Infinity\n(defn- exponential-float [params navigator offsets]\n  (let [[arg navigator] (next-arg navigator)\n        arg (convert-ratio arg)]\n    (loop [[mantissa exp] (float-parts (if (neg? arg) (- arg) arg))]\n      (let [w (:w params)\n            d (:d params)\n            e (:e params)\n            k (:k params)\n            expchar (or (:exponentchar params) \\E)\n            add-sign (or (:at params) (neg? arg))\n            prepend-zero (<= k 0)\n            ^Integer scaled-exp (- exp (dec k))\n            scaled-exp-str (str (Math/abs scaled-exp))\n            scaled-exp-str (str expchar (if (neg? scaled-exp) \\- \\+) \n                                (if e (apply str \n                                             (repeat \n                                              (- e \n                                                 (count scaled-exp-str)) \n                                              \\0))) \n                                scaled-exp-str)\n            exp-width (count scaled-exp-str)\n            base-mantissa-width (count mantissa)\n            scaled-mantissa (str (apply str (repeat (- k) \\0))\n                                 mantissa\n                                 (if d \n                                   (apply str \n                                          (repeat \n                                           (- d (dec base-mantissa-width)\n                                              (if (neg? k) (- k) 0)) \\0))))\n            w-mantissa (if w (- w exp-width))\n            [rounded-mantissa _ incr-exp] (round-str \n                                           scaled-mantissa 0\n                                           (cond\n                                            (= k 0) (dec d)\n                                            (pos? k) d\n                                            (neg? k) (dec d))\n                                           (if w-mantissa \n                                             (- w-mantissa (if add-sign 1 0))))\n            full-mantissa (insert-scaled-decimal rounded-mantissa k)\n            append-zero (and (= k (count rounded-mantissa)) (nil? d))]\n        (if (not incr-exp)\n          (if w\n            (let [len (+ (count full-mantissa) exp-width)\n                  signed-len (if add-sign (inc len) len)\n                  prepend-zero (and prepend-zero (not (= signed-len w)))\n                  full-len (if prepend-zero (inc signed-len) signed-len)\n                  append-zero (and append-zero (< full-len w))]\n              (if (and (or (> full-len w) (and e (> (- exp-width 2) e)))\n                       (:overflowchar params))\n                (print (apply str (repeat w (:overflowchar params))))\n                (print (str\n                        (apply str \n                               (repeat \n                                (- w full-len (if append-zero 1 0) )\n                                (:padchar params)))\n                        (if add-sign (if (neg? arg) \\- \\+)) \n                        (if prepend-zero \"0\")\n                        full-mantissa\n                        (if append-zero \"0\")\n                        scaled-exp-str))))\n            (print (str\n                    (if add-sign (if (neg? arg) \\- \\+)) \n                    (if prepend-zero \"0\")\n                    full-mantissa\n                    (if append-zero \"0\")\n                    scaled-exp-str)))\n          (recur [rounded-mantissa (inc exp)]))))\n    navigator))\n\n;; the function to render ~G directives\n;; This just figures out whether to pass the request off to ~F or ~E based \n;; on the algorithm in CLtL.\n;; TODO: support rationals. Back off to ~D/~A is the appropriate cases\n;; TODO: refactor so that float-parts isn't called twice\n(defn- general-float [params navigator offsets]\n  (let [[arg _] (next-arg navigator)\n        arg (convert-ratio arg)\n        [mantissa exp] (float-parts (if (neg? arg) (- arg) arg))\n        w (:w params)\n        d (:d params)\n        e (:e params)\n        n (if (= arg 0.0) 0 (inc exp))\n        ee (if e (+ e 2) 4)\n        ww (if w (- w ee))\n        d (if d d (max (count mantissa) (min n 7)))\n        dd (- d n)]\n    (if (<= 0 dd d)\n      (let [navigator (fixed-float {:w ww, :d dd, :k 0, \n                                    :overflowchar (:overflowchar params),\n                                    :padchar (:padchar params), :at (:at params)} \n                                   navigator offsets)]\n        (print (apply str (repeat ee \\space)))\n        navigator)\n      (exponential-float params navigator offsets))))\n\n;; the function to render ~$ directives\n;; TODO: support rationals. Back off to ~D/~A is the appropriate cases\n(defn- dollar-float [params navigator offsets]\n  (let [[^Double arg navigator] (next-arg navigator)\n        [mantissa exp] (float-parts (Math/abs arg))\n        d (:d params) ; digits after the decimal\n        n (:n params) ; minimum digits before the decimal\n        w (:w params) ; minimum field width\n        add-sign (or (:at params) (neg? arg))\n        [rounded-mantissa scaled-exp expanded] (round-str mantissa exp d nil)\n        ^String fixed-repr (get-fixed rounded-mantissa (if expanded (inc scaled-exp) scaled-exp) d)\n        full-repr (str (apply str (repeat (- n (.indexOf fixed-repr (int \\.))) \\0)) fixed-repr)\n        full-len (+ (count full-repr) (if add-sign 1 0))]\n    (print (str\n            (if (and (:colon params) add-sign) (if (neg? arg) \\- \\+))\n            (apply str (repeat (- w full-len) (:padchar params)))\n            (if (and (not (:colon params)) add-sign) (if (neg? arg) \\- \\+))\n            full-repr))\n    navigator))\n        \n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Support for the '~[...~]' conditional construct in its\n;;; different flavors\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n;; ~[...~] without any modifiers chooses one of the clauses based on the param or \n;; next argument\n;; TODO check arg is positive int\n(defn- choice-conditional [params arg-navigator offsets]\n  (let [arg (:selector params)\n        [arg navigator] (if arg [arg arg-navigator] (next-arg arg-navigator))\n        clauses (:clauses params)\n        clause (if (or (neg? arg) (>= arg (count clauses)))\n                 (first (:else params))\n                 (nth clauses arg))]\n    (if clause\n      (execute-sub-format clause navigator (:base-args params))\n      navigator)))\n\n;; ~:[...~] with the colon reads the next argument treating it as a truth value\n(defn- boolean-conditional [params arg-navigator offsets]\n  (let [[arg navigator] (next-arg arg-navigator)\n        clauses (:clauses params)\n        clause (if arg\n                 (second clauses)\n                 (first clauses))]\n    (if clause\n      (execute-sub-format clause navigator (:base-args params))\n      navigator)))\n\n;; ~@[...~] with the at sign executes the conditional if the next arg is not\n;; nil/false without consuming the arg\n(defn- check-arg-conditional [params arg-navigator offsets]\n  (let [[arg navigator] (next-arg arg-navigator)\n        clauses (:clauses params)\n        clause (if arg (first clauses))]\n    (if arg\n      (if clause\n        (execute-sub-format clause arg-navigator (:base-args params))\n        arg-navigator)\n      navigator)))\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Support for the '~{...~}' iteration construct in its\n;;; different flavors\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n\n;; ~{...~} without any modifiers uses the next argument as an argument list that \n;; is consumed by all the iterations\n(defn- iterate-sublist [params navigator offsets]\n  (let [max-count (:max-iterations params)\n        param-clause (first (:clauses params))\n        [clause navigator] (if (empty? param-clause) \n                             (get-format-arg navigator)\n                             [param-clause navigator]) \n        [arg-list navigator] (next-arg navigator)\n        args (init-navigator arg-list)]\n    (loop [count 0\n           args args\n           last-pos (num -1)]\n      (if (and (not max-count) (= (:pos args) last-pos) (> count 1))\n        ;; TODO get the offset in here and call format exception\n        (throw (RuntimeException. \"%{ construct not consuming any arguments: Infinite loop!\")))\n      (if (or (and (empty? (:rest args))\n                   (or (not (:colon (:right-params params))) (> count 0)))\n              (and max-count (>= count max-count)))\n        navigator\n        (let [iter-result (execute-sub-format clause args (:base-args params))] \n          (if (= :up-arrow (first iter-result))\n            navigator\n            (recur (inc count) iter-result (:pos args))))))))\n\n;; ~:{...~} with the colon treats the next argument as a list of sublists. Each of the\n;; sublists is used as the arglist for a single iteration.\n(defn- iterate-list-of-sublists [params navigator offsets]\n  (let [max-count (:max-iterations params)\n        param-clause (first (:clauses params))\n        [clause navigator] (if (empty? param-clause) \n                             (get-format-arg navigator)\n                             [param-clause navigator]) \n        [arg-list navigator] (next-arg navigator)]\n    (loop [count 0\n           arg-list arg-list]\n      (if (or (and (empty? arg-list)\n                   (or (not (:colon (:right-params params))) (> count 0)))\n              (and max-count (>= count max-count)))\n        navigator\n        (let [iter-result (execute-sub-format \n                           clause \n                           (init-navigator (first arg-list))\n                           (init-navigator (next arg-list)))]\n          (if (= :colon-up-arrow (first iter-result))\n            navigator\n            (recur (inc count) (next arg-list))))))))\n\n;; ~@{...~} with the at sign uses the main argument list as the arguments to the iterations\n;; is consumed by all the iterations\n(defn- iterate-main-list [params navigator offsets]\n  (let [max-count (:max-iterations params)\n        param-clause (first (:clauses params))\n        [clause navigator] (if (empty? param-clause) \n                             (get-format-arg navigator)\n                             [param-clause navigator])]\n    (loop [count 0\n           navigator navigator\n           last-pos (num -1)]\n      (if (and (not max-count) (= (:pos navigator) last-pos) (> count 1))\n        ;; TODO get the offset in here and call format exception\n        (throw (RuntimeException. \"%@{ construct not consuming any arguments: Infinite loop!\")))\n      (if (or (and (empty? (:rest navigator))\n                   (or (not (:colon (:right-params params))) (> count 0)))\n              (and max-count (>= count max-count)))\n        navigator\n        (let [iter-result (execute-sub-format clause navigator (:base-args params))] \n          (if (= :up-arrow (first iter-result))\n            (second iter-result)\n            (recur \n             (inc count) iter-result (:pos navigator))))))))\n\n;; ~@:{...~} with both colon and at sign uses the main argument list as a set of sublists, one\n;; of which is consumed with each iteration\n(defn- iterate-main-sublists [params navigator offsets]\n  (let [max-count (:max-iterations params)\n        param-clause (first (:clauses params))\n        [clause navigator] (if (empty? param-clause) \n                             (get-format-arg navigator)\n                             [param-clause navigator]) \n        ]\n    (loop [count 0\n           navigator navigator]\n      (if (or (and (empty? (:rest navigator))\n                   (or (not (:colon (:right-params params))) (> count 0)))\n              (and max-count (>= count max-count)))\n        navigator\n        (let [[sublist navigator] (next-arg-or-nil navigator)\n              iter-result (execute-sub-format clause (init-navigator sublist) navigator)]\n          (if (= :colon-up-arrow (first iter-result))\n            navigator\n            (recur (inc count) navigator)))))))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; The '~< directive has two completely different meanings\n;;; in the '~<...~>' form it does justification, but with\n;;; ~<...~:>' it represents the logical block operation of the\n;;; pretty printer.\n;;; \n;;; Unfortunately, the current architecture decides what function\n;;; to call at form parsing time before the sub-clauses have been\n;;; folded, so it is left to run-time to make the decision.\n;;; \n;;; TODO: make it possible to make these decisions at compile-time.\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(declare format-logical-block)\n(declare justify-clauses)\n\n(defn- logical-block-or-justify [params navigator offsets]\n  (if (:colon (:right-params params))\n    (format-logical-block params navigator offsets)\n    (justify-clauses params navigator offsets)))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Support for the '~<...~>' justification directive\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn- render-clauses [clauses navigator base-navigator]\n  (loop [clauses clauses\n         acc []\n         navigator navigator]\n    (if (empty? clauses)\n      [acc navigator]\n      (let [clause (first clauses)\n            [iter-result result-str] (binding [*out* (java.io.StringWriter.)]\n                                       [(execute-sub-format clause navigator base-navigator) \n                                        (.toString *out*)])]\n        (if (= :up-arrow (first iter-result))\n          [acc (second iter-result)]\n          (recur (next clauses) (conj acc result-str) iter-result))))))\n\n;; TODO support for ~:; constructions\n(defn- justify-clauses [params navigator offsets]\n  (let [[[eol-str] new-navigator] (when-let [else (:else params)]\n                                    (render-clauses else navigator (:base-args params)))\n        navigator (or new-navigator navigator)\n        [else-params new-navigator] (when-let [p (:else-params params)]\n                                      (realize-parameter-list p navigator))\n        navigator (or new-navigator navigator)\n        min-remaining (or (first (:min-remaining else-params)) 0)\n        max-columns (or (first (:max-columns else-params))\n                        (get-max-column *out*))\n        clauses (:clauses params)\n        [strs navigator] (render-clauses clauses navigator (:base-args params))\n        slots (max 1\n                   (+ (dec (count strs)) (if (:colon params) 1 0) (if (:at params) 1 0)))\n        chars (reduce + (map count strs))\n        mincol (:mincol params)\n        minpad (:minpad params)\n        colinc (:colinc params)\n        minout (+ chars (* slots minpad))\n        result-columns (if (<= minout mincol) \n                         mincol\n                         (+ mincol (* colinc\n                                      (+ 1 (quot (- minout mincol 1) colinc)))))\n        total-pad (- result-columns chars)\n        pad (max minpad (quot total-pad slots))\n        extra-pad (- total-pad (* pad slots))\n        pad-str (apply str (repeat pad (:padchar params)))]\n    (if (and eol-str (> (+ (get-column (:base @@*out*)) min-remaining result-columns) \n                        max-columns))\n      (print eol-str))\n    (loop [slots slots\n           extra-pad extra-pad\n           strs strs\n           pad-only (or (:colon params)\n                        (and (= (count strs) 1) (not (:at params))))]\n      (if (seq strs)\n        (do\n          (print (str (if (not pad-only) (first strs))\n                      (if (or pad-only (next strs) (:at params)) pad-str)\n                      (if (pos? extra-pad) (:padchar params))))\n          (recur \n           (dec slots)\n           (dec extra-pad)\n           (if pad-only strs (next strs))\n           false))))\n    navigator))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Support for case modification with ~(...~).\n;;; We do this by wrapping the underlying writer with\n;;; a special writer to do the appropriate modification. This\n;;; allows us to support arbitrary-sized output and sources\n;;; that may block.\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn- downcase-writer \n  \"Returns a proxy that wraps writer, converting all characters to lower case\"\n  [^java.io.Writer writer]\n  (proxy [java.io.Writer] []\n    (close [] (.close writer))\n    (flush [] (.flush writer))\n    (write ([^chars cbuf ^Integer off ^Integer len] \n              (.write writer cbuf off len))\n           ([x]\n              (condp = (class x)\n\t\tString \n\t\t(let [s ^String x]\n\t\t  (.write writer (.toLowerCase s)))\n\n\t\tInteger\n\t\t(let [c ^Character x]\n\t\t  (.write writer (int (Character/toLowerCase (char c))))))))))\n\n(defn- upcase-writer \n  \"Returns a proxy that wraps writer, converting all characters to upper case\"\n  [^java.io.Writer writer]\n  (proxy [java.io.Writer] []\n    (close [] (.close writer))\n    (flush [] (.flush writer))\n    (write ([^chars cbuf ^Integer off ^Integer len] \n              (.write writer cbuf off len))\n           ([x]\n              (condp = (class x)\n\t\tString \n\t\t(let [s ^String x]\n\t\t  (.write writer (.toUpperCase s)))\n\n\t\tInteger\n\t\t(let [c ^Character x]\n\t\t  (.write writer (int (Character/toUpperCase (char c))))))))))\n\n(defn- capitalize-string\n  \"Capitalizes the words in a string. If first? is false, don't capitalize the \n                                      first character of the string even if it's a letter.\"\n  [s first?]\n  (let [^Character f (first s) \n        s (if (and first? f (Character/isLetter f))\n            (str (Character/toUpperCase f) (subs s 1))\n            s)]\n    (apply str \n           (first\n            (consume\n             (fn [s]\n               (if (empty? s)\n                 [nil nil]\n                 (let [m (re-matcher #\"\\W\\w\" s)\n                       match (re-find m)\n                       offset (and match (inc (.start m)))]\n                   (if offset\n                     [(str (subs s 0 offset) \n                           (Character/toUpperCase ^Character (nth s offset)))\n                      (subs s (inc offset))]\n                     [s nil]))))\n             s)))))\n\n(defn- capitalize-word-writer\n  \"Returns a proxy that wraps writer, capitalizing all words\"\n  [^java.io.Writer writer]\n  (let [last-was-whitespace? (ref true)] \n    (proxy [java.io.Writer] []\n      (close [] (.close writer))\n      (flush [] (.flush writer))\n      (write \n       ([^chars cbuf ^Integer off ^Integer len] \n          (.write writer cbuf off len))\n       ([x]\n          (condp = (class x)\n            String \n            (let [s ^String x]\n              (.write writer \n                      ^String (capitalize-string (.toLowerCase s) @last-was-whitespace?))\n              (when (pos? (.length s))\n                (dosync \n                 (ref-set last-was-whitespace? \n                          (Character/isWhitespace \n                           ^Character (nth s (dec (count s))))))))\n\n            Integer\n            (let [c (char x)]\n              (let [mod-c (if @last-was-whitespace? (Character/toUpperCase (char x)) c)]\n                (.write writer (int mod-c))\n                (dosync (ref-set last-was-whitespace? (Character/isWhitespace (char x))))))))))))\n\n(defn- init-cap-writer\n  \"Returns a proxy that wraps writer, capitalizing the first word\"\n  [^java.io.Writer writer]\n  (let [capped (ref false)] \n    (proxy [java.io.Writer] []\n      (close [] (.close writer))\n      (flush [] (.flush writer))\n      (write ([^chars cbuf ^Integer off ^Integer len] \n                (.write writer cbuf off len))\n             ([x]\n                (condp = (class x)\n                 String \n                 (let [s (.toLowerCase ^String x)]\n                   (if (not @capped) \n                     (let [m (re-matcher #\"\\S\" s)\n                           match (re-find m)\n                           offset (and match (.start m))]\n                       (if offset\n                         (do (.write writer \n                                   (str (subs s 0 offset) \n                                        (Character/toUpperCase ^Character (nth s offset))\n                                        (.toLowerCase ^String (subs s (inc offset)))))\n                           (dosync (ref-set capped true)))\n                         (.write writer s))) \n                     (.write writer (.toLowerCase s))))\n\n                 Integer\n                 (let [c ^Character (char x)]\n                   (if (and (not @capped) (Character/isLetter c))\n                     (do\n                       (dosync (ref-set capped true))\n                       (.write writer (int (Character/toUpperCase c))))\n                     (.write writer (int (Character/toLowerCase c)))))))))))\n\n(defn- modify-case [make-writer params navigator offsets]\n  (let [clause (first (:clauses params))]\n    (binding [*out* (make-writer *out*)] \n      (execute-sub-format clause navigator (:base-args params)))))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; If necessary, wrap the writer in a PrettyWriter object\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn get-pretty-writer \n  \"Returns the java.io.Writer passed in wrapped in a pretty writer proxy, unless it's \nalready a pretty writer. Generally, it is unnecessary to call this function, since pprint,\nwrite, and cl-format all call it if they need to. However if you want the state to be \npreserved across calls, you will want to wrap them with this. \n\nFor example, when you want to generate column-aware output with multiple calls to cl-format, \ndo it like in this example:\n\n    (defn print-table [aseq column-width]\n      (binding [*out* (get-pretty-writer *out*)]\n        (doseq [row aseq]\n          (doseq [col row]\n            (cl-format true \\\"~4D~7,vT\\\" col column-width))\n          (prn))))\n\nNow when you run:\n\n    user> (print-table (map #(vector % (* % %) (* % % %)) (range 1 11)) 8)\n\nIt prints a table of squares and cubes for the numbers from 1 to 10:\n\n       1      1       1    \n       2      4       8    \n       3      9      27    \n       4     16      64    \n       5     25     125    \n       6     36     216    \n       7     49     343    \n       8     64     512    \n       9     81     729    \n      10    100    1000\"\n  {:added \"1.2\"}\n  [writer]\n  (if (pretty-writer? writer) \n    writer\n    (pretty-writer writer *print-right-margin* *print-miser-width*)))\n \n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Support for column-aware operations ~&, ~T\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn fresh-line\n  \"Make a newline if *out* is not already at the beginning of the line. If *out* is\nnot a pretty writer (which keeps track of columns), this function always outputs a newline.\"\n  {:added \"1.2\"}\n  []\n  (if (instance? clojure.lang.IDeref *out*)\n    (if (not (= 0 (get-column (:base @@*out*))))\n      (prn))\n    (prn)))\n\n(defn- absolute-tabulation [params navigator offsets]\n  (let [colnum (:colnum params) \n        colinc (:colinc params)\n        current (get-column (:base @@*out*))\n        space-count (cond\n                     (< current colnum) (- colnum current)\n                     (= colinc 0) 0\n                     :else (- colinc (rem (- current colnum) colinc)))]\n    (print (apply str (repeat space-count \\space))))\n  navigator)\n\n(defn- relative-tabulation [params navigator offsets]\n  (let [colrel (:colnum params) \n        colinc (:colinc params)\n        start-col (+ colrel (get-column (:base @@*out*)))\n        offset (if (pos? colinc) (rem start-col colinc) 0)\n        space-count (+ colrel (if (= 0 offset) 0 (- colinc offset)))]\n    (print (apply str (repeat space-count \\space))))\n  navigator)\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Support for accessing the pretty printer from a format\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n;; TODO: support ~@; per-line-prefix separator\n;; TODO: get the whole format wrapped so we can start the lb at any column\n(defn- format-logical-block [params navigator offsets]\n  (let [clauses (:clauses params)\n        clause-count (count clauses)\n        prefix (cond\n                (> clause-count 1) (:string (:params (first (first clauses))))\n                (:colon params) \"(\")\n        body (nth clauses (if (> clause-count 1) 1 0))\n        suffix (cond\n                (> clause-count 2) (:string (:params (first (nth clauses 2))))\n                (:colon params) \")\")\n        [arg navigator] (next-arg navigator)]\n    (pprint-logical-block :prefix prefix :suffix suffix\n      (execute-sub-format \n       body \n       (init-navigator arg)\n       (:base-args params)))\n    navigator))\n\n(defn- set-indent [params navigator offsets]\n  (let [relative-to (if (:colon params) :current :block)]\n    (pprint-indent relative-to (:n params))\n    navigator))\n\n;;; TODO: support ~:T section options for ~T\n\n(defn- conditional-newline [params navigator offsets]\n  (let [kind (if (:colon params) \n               (if (:at params) :mandatory :fill)\n               (if (:at params) :miser :linear))]\n    (pprint-newline kind)\n    navigator))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; The table of directives we support, each with its params,\n;;; properties, and the compilation function\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n;; We start with a couple of helpers\n(defn- process-directive-table-element [ [ char params flags bracket-info & generator-fn ] ]\n  [char, \n   {:directive char,\n    :params `(array-map ~@params),\n    :flags flags,\n    :bracket-info bracket-info,\n    :generator-fn (concat '(fn [ params offset]) generator-fn) }])\n\n(defmacro ^{:private true}\n  defdirectives \n  [ & directives ]\n  `(def ^{:private true}\n        directive-table (hash-map ~@(mapcat process-directive-table-element directives))))\n\n(defdirectives \n  (\\A \n   [ :mincol [0 Integer] :colinc [1 Integer] :minpad [0 Integer] :padchar [\\space Character] ] \n   #{ :at :colon :both} {}\n   #(format-ascii print-str %1 %2 %3))\n\n  (\\S \n   [ :mincol [0 Integer] :colinc [1 Integer] :minpad [0 Integer] :padchar [\\space Character] ] \n   #{ :at :colon :both} {}\n   #(format-ascii pr-str %1 %2 %3))\n\n  (\\D\n   [ :mincol [0 Integer] :padchar [\\space Character] :commachar [\\, Character] \n    :commainterval [ 3 Integer]]\n   #{ :at :colon :both } {}\n   #(format-integer 10 %1 %2 %3))\n\n  (\\B\n   [ :mincol [0 Integer] :padchar [\\space Character] :commachar [\\, Character] \n    :commainterval [ 3 Integer]]\n   #{ :at :colon :both } {}\n   #(format-integer 2 %1 %2 %3))\n\n  (\\O\n   [ :mincol [0 Integer] :padchar [\\space Character] :commachar [\\, Character] \n    :commainterval [ 3 Integer]]\n   #{ :at :colon :both } {}\n   #(format-integer 8 %1 %2 %3))\n\n  (\\X\n   [ :mincol [0 Integer] :padchar [\\space Character] :commachar [\\, Character] \n    :commainterval [ 3 Integer]]\n   #{ :at :colon :both } {}\n   #(format-integer 16 %1 %2 %3))\n\n  (\\R\n   [:base [nil Integer] :mincol [0 Integer] :padchar [\\space Character] :commachar [\\, Character] \n    :commainterval [ 3 Integer]]\n   #{ :at :colon :both } {}\n   (do\n     (cond                          ; ~R is overloaded with bizareness\n       (first (:base params))     #(format-integer (:base %1) %1 %2 %3)\n       (and (:at params) (:colon params))   #(format-old-roman %1 %2 %3)\n       (:at params)               #(format-new-roman %1 %2 %3)\n       (:colon params)            #(format-ordinal-english %1 %2 %3)\n       true                       #(format-cardinal-english %1 %2 %3))))\n\n  (\\P\n   [ ]\n   #{ :at :colon :both } {}\n   (fn [params navigator offsets]\n     (let [navigator (if (:colon params) (relative-reposition navigator -1) navigator)\n           strs (if (:at params) [\"y\" \"ies\"] [\"\" \"s\"])\n           [arg navigator] (next-arg navigator)]\n       (print (if (= arg 1) (first strs) (second strs)))\n       navigator)))\n\n  (\\C\n   [:char-format [nil Character]]\n   #{ :at :colon :both } {}\n   (cond\n     (:colon params) pretty-character\n     (:at params) readable-character\n     :else plain-character))\n\n  (\\F\n   [ :w [nil Integer] :d [nil Integer] :k [0 Integer] :overflowchar [nil Character] \n    :padchar [\\space Character] ]\n   #{ :at } {}\n   fixed-float)\n\n  (\\E\n   [ :w [nil Integer] :d [nil Integer] :e [nil Integer] :k [1 Integer] \n    :overflowchar [nil Character] :padchar [\\space Character] \n    :exponentchar [nil Character] ]\n   #{ :at } {}\n   exponential-float)\n\n  (\\G\n   [ :w [nil Integer] :d [nil Integer] :e [nil Integer] :k [1 Integer] \n    :overflowchar [nil Character] :padchar [\\space Character] \n    :exponentchar [nil Character] ]\n   #{ :at } {}\n   general-float)\n\n  (\\$\n   [ :d [2 Integer] :n [1 Integer] :w [0 Integer] :padchar [\\space Character]]\n   #{ :at :colon :both} {}\n   dollar-float)\n\n  (\\% \n   [ :count [1 Integer] ] \n   #{ } {}\n   (fn [params arg-navigator offsets]\n     (dotimes [i (:count params)]\n       (prn))\n     arg-navigator))\n\n  (\\&\n   [ :count [1 Integer] ] \n   #{ :pretty } {}\n   (fn [params arg-navigator offsets]\n     (let [cnt (:count params)]\n       (if (pos? cnt) (fresh-line))\n       (dotimes [i (dec cnt)]\n         (prn)))\n     arg-navigator))\n\n  (\\| \n   [ :count [1 Integer] ] \n   #{ } {}\n   (fn [params arg-navigator offsets]\n     (dotimes [i (:count params)]\n       (print \\formfeed))\n     arg-navigator))\n\n  (\\~ \n   [ :n [1 Integer] ] \n   #{ } {}\n   (fn [params arg-navigator offsets]\n     (let [n (:n params)]\n       (print (apply str (repeat n \\~)))\n       arg-navigator)))\n\n  (\\newline ;; Whitespace supression is handled in the compilation loop\n   [ ] \n   #{:colon :at} {}\n   (fn [params arg-navigator offsets]\n     (if (:at params)\n       (prn))\n     arg-navigator))\n\n  (\\T\n   [ :colnum [1 Integer] :colinc [1 Integer] ] \n   #{ :at :pretty } {}\n   (if (:at params)\n     #(relative-tabulation %1 %2 %3)\n     #(absolute-tabulation %1 %2 %3)))\n\n  (\\* \n   [ :n [1 Integer] ] \n   #{ :colon :at } {}\n   (fn [params navigator offsets]\n     (let [n (:n params)]\n       (if (:at params)\n         (absolute-reposition navigator n)\n         (relative-reposition navigator (if (:colon params) (- n) n)))\n       )))\n\n  (\\? \n   [ ] \n   #{ :at } {}\n   (if (:at params)\n     (fn [params navigator offsets]     ; args from main arg list\n       (let [[subformat navigator] (get-format-arg navigator)]\n         (execute-sub-format subformat navigator  (:base-args params))))\n     (fn [params navigator offsets]     ; args from sub-list\n       (let [[subformat navigator] (get-format-arg navigator)\n             [subargs navigator] (next-arg navigator)\n             sub-navigator (init-navigator subargs)]\n         (execute-sub-format subformat sub-navigator (:base-args params))\n         navigator))))\n       \n\n  (\\(\n   [ ]\n   #{ :colon :at :both} { :right \\), :allows-separator nil, :else nil }\n   (let [mod-case-writer (cond\n                           (and (:at params) (:colon params))\n                           upcase-writer\n\n                           (:colon params)\n                           capitalize-word-writer\n\n                           (:at params)\n                           init-cap-writer\n\n                           :else\n                           downcase-writer)]\n     #(modify-case mod-case-writer %1 %2 %3)))\n\n  (\\) [] #{} {} nil) \n\n  (\\[\n   [ :selector [nil Integer] ]\n   #{ :colon :at } { :right \\], :allows-separator true, :else :last }\n   (cond\n     (:colon params)\n     boolean-conditional\n\n     (:at params)\n     check-arg-conditional\n\n     true\n     choice-conditional))\n\n  (\\; [:min-remaining [nil Integer] :max-columns [nil Integer]] \n   #{ :colon } { :separator true } nil) \n   \n  (\\] [] #{} {} nil) \n\n  (\\{\n   [ :max-iterations [nil Integer] ]\n   #{ :colon :at :both} { :right \\}, :allows-separator false }\n   (cond\n     (and (:at params) (:colon params))\n     iterate-main-sublists\n\n     (:colon params)\n     iterate-list-of-sublists\n\n     (:at params)\n     iterate-main-list\n\n     true\n     iterate-sublist))\n\n   \n  (\\} [] #{:colon} {} nil) \n\n  (\\<\n   [:mincol [0 Integer] :colinc [1 Integer] :minpad [0 Integer] :padchar [\\space Character]]\n   #{:colon :at :both :pretty} { :right \\>, :allows-separator true, :else :first }\n   logical-block-or-justify)\n\n  (\\> [] #{:colon} {} nil) \n\n  ;; TODO: detect errors in cases where colon not allowed\n  (\\^ [:arg1 [nil Integer] :arg2 [nil Integer] :arg3 [nil Integer]] \n   #{:colon} {} \n   (fn [params navigator offsets]\n     (let [arg1 (:arg1 params)\n           arg2 (:arg2 params)\n           arg3 (:arg3 params)\n           exit (if (:colon params) :colon-up-arrow :up-arrow)]\n       (cond\n         (and arg1 arg2 arg3)\n         (if (<= arg1 arg2 arg3) [exit navigator] navigator)\n\n         (and arg1 arg2)\n         (if (= arg1 arg2) [exit navigator] navigator)\n\n         arg1\n         (if (= arg1 0) [exit navigator] navigator)\n\n         true     ; TODO: handle looking up the arglist stack for info\n         (if (if (:colon params) \n               (empty? (:rest (:base-args params)))\n               (empty? (:rest navigator)))\n           [exit navigator] navigator))))) \n\n  (\\W \n   [] \n   #{:at :colon :both :pretty} {}\n   (if (or (:at params) (:colon params))\n     (let [bindings (concat\n                     (if (:at params) [:level nil :length nil] [])\n                     (if (:colon params) [:pretty true] []))]\n       (fn [params navigator offsets]\n         (let [[arg navigator] (next-arg navigator)]\n           (if (apply write arg bindings)\n             [:up-arrow navigator]\n             navigator))))\n     (fn [params navigator offsets]\n       (let [[arg navigator] (next-arg navigator)]\n         (if (write-out arg)\n           [:up-arrow navigator]\n           navigator)))))\n\n  (\\_\n   []\n   #{:at :colon :both} {}\n   conditional-newline)\n\n  (\\I\n   [:n [0 Integer]]\n   #{:colon} {}\n   set-indent)\n  )\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Code to manage the parameters and flags associated with each\n;;; directive in the format string.\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(def ^{:private true}\n     param-pattern #\"^([vV]|#|('.)|([+-]?\\d+)|(?=,))\")\n(def ^{:private true}\n     special-params #{ :parameter-from-args :remaining-arg-count })\n\n(defn- extract-param [[s offset saw-comma]]\n  (let [m (re-matcher param-pattern s)\n        param (re-find m)]\n    (if param\n      (let [token-str (first (re-groups m))\n            remainder (subs s (.end m))\n            new-offset (+ offset (.end m))]\n        (if (not (= \\, (nth remainder 0)))\n          [ [token-str offset] [remainder new-offset false]]\n          [ [token-str offset] [(subs remainder 1) (inc new-offset) true]]))\n      (if saw-comma \n        (format-error \"Badly formed parameters in format directive\" offset)\n        [ nil [s offset]]))))\n\n\n(defn- extract-params [s offset] \n  (consume extract-param [s offset false]))\n\n(defn- translate-param\n  \"Translate the string representation of a param to the internalized\n                                      representation\"\n  [[^String p offset]]\n  [(cond \n    (= (.length p) 0) nil\n    (and (= (.length p) 1) (contains? #{\\v \\V} (nth p 0))) :parameter-from-args\n    (and (= (.length p) 1) (= \\# (nth p 0))) :remaining-arg-count\n    (and (= (.length p) 2) (= \\' (nth p 0))) (nth p 1)\n    true (new Integer p))\n   offset])\n \n(def ^{:private true}\n     flag-defs { \\: :colon, \\@ :at })\n\n(defn- extract-flags [s offset]\n  (consume\n   (fn [[s offset flags]]\n     (if (empty? s)\n       [nil [s offset flags]]\n       (let [flag (get flag-defs (first s))]\n         (if flag\n           (if (contains? flags flag)\n             (format-error \n              (str \"Flag \\\"\" (first s) \"\\\" appears more than once in a directive\")\n              offset)\n             [true [(subs s 1) (inc offset) (assoc flags flag [true offset])]])\n           [nil [s offset flags]]))))\n   [s offset {}]))\n\n(defn- check-flags [def flags]\n  (let [allowed (:flags def)]\n    (if (and (not (:at allowed)) (:at flags))\n      (format-error (str \"\\\"@\\\" is an illegal flag for format directive \\\"\" (:directive def) \"\\\"\")\n                    (nth (:at flags) 1)))\n    (if (and (not (:colon allowed)) (:colon flags))\n      (format-error (str \"\\\":\\\" is an illegal flag for format directive \\\"\" (:directive def) \"\\\"\")\n                    (nth (:colon flags) 1)))\n    (if (and (not (:both allowed)) (:at flags) (:colon flags))\n      (format-error (str \"Cannot combine \\\"@\\\" and \\\":\\\" flags for format directive \\\"\" \n                         (:directive def) \"\\\"\")\n                    (min (nth (:colon flags) 1) (nth (:at flags) 1))))))\n\n(defn- map-params\n  \"Takes a directive definition and the list of actual parameters and\na map of flags and returns a map of the parameters and flags with defaults\nfilled in. We check to make sure that there are the right types and number\nof parameters as well.\"\n  [def params flags offset]\n  (check-flags def flags)\n  (if (> (count params) (count (:params def)))\n    (format-error \n     (cl-format \n      nil \n      \"Too many parameters for directive \\\"~C\\\": ~D~:* ~[were~;was~:;were~] specified but only ~D~:* ~[are~;is~:;are~] allowed\"\n      (:directive def) (count params) (count (:params def)))\n     (second (first params))))\n  (doall\n   (map #(let [val (first %1)]\n           (if (not (or (nil? val) (contains? special-params val) \n                        (instance? (second (second %2)) val)))\n             (format-error (str \"Parameter \" (name (first %2))\n                                \" has bad type in directive \\\"\" (:directive def) \"\\\": \"\n                                (class val))\n                           (second %1))) )\n        params (:params def)))\n     \n  (merge                                ; create the result map\n   (into (array-map) ; start with the default values, make sure the order is right\n         (reverse (for [[name [default]] (:params def)] [name [default offset]])))\n   (reduce #(apply assoc %1 %2) {} (filter #(first (nth % 1)) (zipmap (keys (:params def)) params))) ; add the specified parameters, filtering out nils\n   flags))                                ; and finally add the flags\n\n(defn- compile-directive [s offset]\n  (let [[raw-params [rest offset]] (extract-params s offset)\n        [_ [rest offset flags]] (extract-flags rest offset)\n        directive (first rest)\n        def (get directive-table (Character/toUpperCase ^Character directive))\n        params (if def (map-params def (map translate-param raw-params) flags offset))]\n    (if (not directive)\n      (format-error \"Format string ended in the middle of a directive\" offset))\n    (if (not def)\n      (format-error (str \"Directive \\\"\" directive \"\\\" is undefined\") offset))\n    [(struct compiled-directive ((:generator-fn def) params offset) def params offset)\n     (let [remainder (subs rest 1) \n           offset (inc offset)\n           trim? (and (= \\newline (:directive def))\n                      (not (:colon params)))\n           trim-count (if trim? (prefix-count remainder [\\space \\tab]) 0)\n           remainder (subs remainder trim-count)\n           offset (+ offset trim-count)]\n       [remainder offset])]))\n    \n(defn- compile-raw-string [s offset]\n  (struct compiled-directive (fn [_ a _] (print s) a) nil { :string s } offset))\n\n(defn- right-bracket [this] (:right (:bracket-info (:def this))))\n(defn- separator? [this] (:separator (:bracket-info (:def this))))\n(defn- else-separator? [this] \n  (and (:separator (:bracket-info (:def this)))\n       (:colon (:params this))))\n  \n\n(declare collect-clauses)\n\n(defn- process-bracket [this remainder]\n  (let [[subex remainder] (collect-clauses (:bracket-info (:def this))\n                                           (:offset this) remainder)]\n    [(struct compiled-directive \n             (:func this) (:def this) \n             (merge (:params this) (tuple-map subex (:offset this)))\n             (:offset this))\n     remainder]))\n\n(defn- process-clause [bracket-info offset remainder]\n  (consume \n   (fn [remainder]\n     (if (empty? remainder)\n       (format-error \"No closing bracket found.\" offset)\n       (let [this (first remainder)\n             remainder (next remainder)]\n         (cond\n          (right-bracket this)\n          (process-bracket this remainder)\n\n          (= (:right bracket-info) (:directive (:def this)))\n          [ nil [:right-bracket (:params this) nil remainder]]\n\n          (else-separator? this)\n          [nil [:else nil (:params this) remainder]]\n\n          (separator? this)\n          [nil [:separator nil nil remainder]] ;; TODO: check to make sure that there are no params on ~;\n\n          true\n          [this remainder]))))\n   remainder))\n\n(defn- collect-clauses [bracket-info offset remainder]\n  (second\n   (consume\n    (fn [[clause-map saw-else remainder]]\n      (let [[clause [type right-params else-params remainder]] \n            (process-clause bracket-info offset remainder)]\n        (cond\n         (= type :right-bracket)\n         [nil [(merge-with concat clause-map \n                           {(if saw-else :else :clauses) [clause] \n                            :right-params right-params})\n               remainder]]\n\n         (= type :else)\n         (cond\n          (:else clause-map)\n          (format-error \"Two else clauses (\\\"~:;\\\") inside bracket construction.\" offset)\n         \n          (not (:else bracket-info))\n          (format-error \"An else clause (\\\"~:;\\\") is in a bracket type that doesn't support it.\" \n                        offset)\n\n          (and (= :first (:else bracket-info)) (seq (:clauses clause-map)))\n          (format-error\n           \"The else clause (\\\"~:;\\\") is only allowed in the first position for this directive.\" \n           offset)\n         \n          true         ; if the ~:; is in the last position, the else clause\n                                        ; is next, this was a regular clause\n          (if (= :first (:else bracket-info))\n            [true [(merge-with concat clause-map { :else [clause] :else-params else-params})\n                   false remainder]]\n            [true [(merge-with concat clause-map { :clauses [clause] })\n                   true remainder]]))\n\n         (= type :separator)\n         (cond\n          saw-else\n          (format-error \"A plain clause (with \\\"~;\\\") follows an else clause (\\\"~:;\\\") inside bracket construction.\" offset)\n         \n          (not (:allows-separator bracket-info))\n          (format-error \"A separator (\\\"~;\\\") is in a bracket type that doesn't support it.\" \n                        offset)\n         \n          true\n          [true [(merge-with concat clause-map { :clauses [clause] })\n                 false remainder]]))))\n    [{ :clauses [] } false remainder])))\n\n(defn- process-nesting\n  \"Take a linearly compiled format and process the bracket directives to give it \n   the appropriate tree structure\"\n  [format]\n  (first\n   (consume \n    (fn [remainder]\n      (let [this (first remainder)\n            remainder (next remainder)\n            bracket (:bracket-info (:def this))]\n        (if (:right bracket)\n          (process-bracket this remainder)\n          [this remainder])))\n    format)))\n\n(defn- compile-format \n  \"Compiles format-str into a compiled format which can be used as an argument\nto cl-format just like a plain format string. Use this function for improved \nperformance when you're using the same format string repeatedly\"\n  [ format-str ]\n;  (prlabel compiling format-str)\n  (binding [*format-str* format-str]\n    (process-nesting\n     (first \n      (consume \n       (fn [[^String s offset]]\n         (if (empty? s)\n           [nil s]\n           (let [tilde (.indexOf s (int \\~))]\n             (cond\n              (neg? tilde) [(compile-raw-string s offset) [\"\" (+ offset (.length s))]]\n              (zero? tilde)  (compile-directive (subs s 1) (inc offset))\n              true \n              [(compile-raw-string (subs s 0 tilde) offset) [(subs s tilde) (+ tilde offset)]]))))\n       [format-str 0])))))\n\n(defn- needs-pretty \n  \"determine whether a given compiled format has any directives that depend on the\ncolumn number or pretty printing\"\n  [format]\n  (loop [format format]\n    (if (empty? format)\n      false\n      (if (or (:pretty (:flags (:def (first format))))\n              (some needs-pretty (first (:clauses (:params (first format)))))\n              (some needs-pretty (first (:else (:params (first format))))))\n        true\n        (recur (next format))))))\n\n(defn- execute-format \n  \"Executes the format with the arguments.\"\n  {:skip-wiki true}\n  ([stream format args]\n     (let [^java.io.Writer real-stream (cond \n                                         (not stream) (java.io.StringWriter.)\n                                         (true? stream) *out*\n                                         :else stream)\n           ^java.io.Writer wrapped-stream (if (and (needs-pretty format) \n                                                    (not (pretty-writer? real-stream)))\n                                             (get-pretty-writer real-stream)\n                                             real-stream)]\n       (binding [*out* wrapped-stream]\n         (try\n          (execute-format format args)\n          (finally\n           (if-not (identical? real-stream wrapped-stream)\n             (.flush wrapped-stream))))\n         (if (not stream) (.toString real-stream)))))\n  ([format args]\n     (map-passing-context \n      (fn [element context]\n        (if (abort? context)\n          [nil context]\n          (let [[params args] (realize-parameter-list \n                               (:params element) context)\n                [params offsets] (unzip-map params)\n                params (assoc params :base-args args)]\n            [nil (apply (:func element) [params args offsets])])))\n      args\n      format)\n     nil))\n\n;;; This is a bad idea, but it prevents us from leaking private symbols\n;;; This should all be replaced by really compiled formats anyway.\n(def ^{:private true} cached-compile (memoize compile-format))\n\n(defmacro formatter\n  \"Makes a function which can directly run format-in. The function is\nfn [stream & args] ... and returns nil unless the stream is nil (meaning \noutput to a string) in which case it returns the resulting string.\n\nformat-in can be either a control string or a previously compiled format.\"\n  {:added \"1.2\"}\n  [format-in]\n  `(let [format-in# ~format-in\n         my-c-c# (var-get (get (ns-interns (the-ns 'clojure.pprint))\n                               '~'cached-compile))\n         my-e-f# (var-get (get (ns-interns (the-ns 'clojure.pprint))\n                               '~'execute-format))\n         my-i-n# (var-get (get (ns-interns (the-ns 'clojure.pprint))\n                               '~'init-navigator))\n         cf# (if (string? format-in#) (my-c-c# format-in#) format-in#)]\n     (fn [stream# & args#]\n       (let [navigator# (my-i-n# args#)]\n         (my-e-f# stream# cf# navigator#)))))\n\n(defmacro formatter-out\n  \"Makes a function which can directly run format-in. The function is\nfn [& args] ... and returns nil. This version of the formatter macro is\ndesigned to be used with *out* set to an appropriate Writer. In particular,\nthis is meant to be used as part of a pretty printer dispatch method.\n\nformat-in can be either a control string or a previously compiled format.\"\n  {:added \"1.2\"}\n  [format-in]\n  `(let [format-in# ~format-in\n         cf# (if (string? format-in#) (#'clojure.pprint/cached-compile format-in#) format-in#)]\n     (fn [& args#]\n       (let [navigator# (#'clojure.pprint/init-navigator args#)]\n         (#'clojure.pprint/execute-format cf# navigator#)))))\n"
  },
  {
    "path": "src/clj/clojure/pprint/column_writer.clj",
    "content": ";;; column_writer.clj -- part of the pretty printer for Clojure\n\n\n;   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Tom Faulhaber\n;; April 3, 2009\n;; Revised to use proxy instead of gen-class April 2010\n\n;; This module implements a column-aware wrapper around an instance of java.io.Writer\n\n(in-ns 'clojure.pprint)\n\n(import [clojure.lang IDeref]\n        [java.io Writer])\n\n(def ^:dynamic ^{:private true} *default-page-width* 72)\n\n(defn- get-field [^Writer this sym]\n  (sym @@this))\n\n(defn- set-field [^Writer this sym new-val] \n  (alter @this assoc sym new-val))\n\n(defn- get-column [this]\n  (get-field this :cur))\n\n(defn- get-line [this]\n  (get-field this :line))\n\n(defn- get-max-column [this]\n  (get-field this :max))\n\n(defn- set-max-column [this new-max]\n  (dosync (set-field this :max new-max))\n  nil)\n\n(defn- get-writer [this]\n  (get-field this :base))\n\n(defn- c-write-char [^Writer this ^Integer c]\n  (dosync (if (= c (int \\newline))\n\t    (do\n              (set-field this :cur 0)\n              (set-field this :line (inc (get-field this :line))))\n\t    (set-field this :cur (inc (get-field this :cur)))))\n  (.write ^Writer (get-field this :base) c))\n\n(defn- column-writer   \n  ([writer] (column-writer writer *default-page-width*))\n  ([writer max-columns]\n     (let [fields (ref {:max max-columns, :cur 0, :line 0 :base writer})]\n       (proxy [Writer IDeref] []\n         (deref [] fields)\n         (flush []\n           (.flush writer))\n         (write\n          ([^chars cbuf ^Integer off ^Integer len] \n             (let [^Writer writer (get-field this :base)] \n               (.write writer cbuf off len)))\n          ([x]\n             (condp = (class x)\n               String \n               (let [^String s x\n                     nl (.lastIndexOf s (int \\newline))]\n                 (dosync (if (neg? nl)\n                           (set-field this :cur (+ (get-field this :cur) (count s)))\n                           (do\n                             (set-field this :cur (- (count s) nl 1))\n                             (set-field this :line (+ (get-field this :line)\n                                                      (count (filter #(= % \\newline) s)))))))\n                 (.write ^Writer (get-field this :base) s))\n\n               Integer\n               (c-write-char this x)\n               Long\n               (c-write-char this x))))))))\n"
  },
  {
    "path": "src/clj/clojure/pprint/dispatch.clj",
    "content": ";; dispatch.clj -- part of the pretty printer for Clojure\n\n;   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Tom Faulhaber\n;; April 3, 2009\n\n\n;; This module implements the default dispatch tables for pretty printing code and\n;; data.\n\n(in-ns 'clojure.pprint)\n\n(defn- use-method\n  \"Installs a function as a new method of multimethod associated with dispatch-value. \"\n  [multifn dispatch-val func]\n  (. multifn addMethod dispatch-val func))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;; Implementations of specific dispatch table entries\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n;;; Handle forms that can be \"back-translated\" to reader macros\n;;; Not all reader macros can be dealt with this way or at all. \n;;; Macros that we can't deal with at all are:\n;;; ;  - The comment character is absorbed by the reader and never is part of the form\n;;; `  - Is fully processed at read time into a lisp expression (which will contain concats\n;;;      and regular quotes).\n;;; ~@ - Also fully eaten by the processing of ` and can't be used outside.\n;;; ,  - is whitespace and is lost (like all other whitespace). Formats can generate commas\n;;;      where they deem them useful to help readability.\n;;; ^  - Adding metadata completely disappears at read time and the data appears to be\n;;;      completely lost.\n;;;\n;;; Most other syntax stuff is dealt with directly by the formats (like (), [], {}, and #{})\n;;; or directly by printing the objects using Clojure's built-in print functions (like\n;;; :keyword, \\char, or \"\"). The notable exception is #() which is special-cased.\n\n(def ^{:private true} reader-macros\n     {'quote \"'\", 'clojure.core/deref \"@\", \n      'var \"#'\", 'clojure.core/unquote \"~\"})\n\n(defn- pprint-reader-macro [alis]\n  (let [^String macro-char (reader-macros (first alis))]\n    (when (and macro-char (= 2 (count alis)))\n      (.write ^java.io.Writer *out* macro-char)\n      (write-out (second alis))\n      true)))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;; Dispatch for the basic data types when interpreted\n;; as data (as opposed to code).\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n;;; TODO: inline these formatter statements into funcs so that we\n;;; are a little easier on the stack. (Or, do \"real\" compilation, a\n;;; la Common Lisp)\n\n;;; (def pprint-simple-list (formatter-out \"~:<~@{~w~^ ~_~}~:>\"))\n(defn- pprint-simple-list [alis]\n  (pprint-logical-block :prefix \"(\" :suffix \")\"\n    (print-length-loop [alis (seq alis)]\n      (when alis\n\t(write-out (first alis))\n\t(when (next alis)\n\t  (.write ^java.io.Writer *out* \" \")\n\t  (pprint-newline :linear)\n\t  (recur (next alis)))))))\n\n(defn- pprint-list [alis]\n  (if-not (pprint-reader-macro alis)\n    (pprint-simple-list alis)))\n\n;;; (def pprint-vector (formatter-out \"~<[~;~@{~w~^ ~_~}~;]~:>\"))\n(defn- pprint-vector [avec]\n  (pprint-logical-block :prefix \"[\" :suffix \"]\"\n    (print-length-loop [aseq (seq avec)]\n      (when aseq\n\t(write-out (first aseq))\n\t(when (next aseq)\n\t  (.write ^java.io.Writer *out* \" \")\n\t  (pprint-newline :linear)\n\t  (recur (next aseq)))))))\n\n(def ^{:private true} pprint-array (formatter-out \"~<[~;~@{~w~^, ~:_~}~;]~:>\"))\n\n;;; (def pprint-map (formatter-out \"~<{~;~@{~<~w~^ ~_~w~:>~^, ~_~}~;}~:>\"))\n(defn- pprint-map [amap]\n  (pprint-logical-block :prefix \"{\" :suffix \"}\"\n    (print-length-loop [aseq (seq amap)]\n      (when aseq\n\t(pprint-logical-block \n          (write-out (ffirst aseq))\n          (.write ^java.io.Writer *out* \" \")\n          (pprint-newline :linear)\n          (set! *current-length* 0)     ; always print both parts of the [k v] pair\n          (write-out (fnext (first aseq))))\n        (when (next aseq)\n          (.write ^java.io.Writer *out* \", \")\n          (pprint-newline :linear)\n          (recur (next aseq)))))))\n\n(def ^{:private true} pprint-set (formatter-out \"~<#{~;~@{~w~^ ~:_~}~;}~:>\"))\n\n(def ^{:private true} \n     type-map {\"core$future_call\" \"Future\",\n               \"core$promise\" \"Promise\"})\n\n(defn- map-ref-type \n  \"Map ugly type names to something simpler\"\n  [name]\n  (or (when-let [match (re-find #\"^[^$]+\\$[^$]+\" name)]\n        (type-map match))\n      name))\n\n(defn- pprint-ideref [o]\n  (let [prefix (format \"#<%s@%x%s: \"\n                       (map-ref-type (.getSimpleName (class o)))\n                       (System/identityHashCode o)\n                       (if (and (instance? clojure.lang.Agent o)\n                                (agent-error o))\n                         \" FAILED\"\n                         \"\"))]\n    (pprint-logical-block  :prefix prefix :suffix \">\"\n                           (pprint-indent :block (-> (count prefix) (- 2) -))\n                           (pprint-newline :linear)\n                           (write-out (cond \n                                       (and (future? o) (not (future-done? o))) :pending\n                                       (and (instance? clojure.lang.IPending o) (not (.isRealized o))) :not-delivered\n                                       :else @o)))))\n\n(def ^{:private true} pprint-pqueue (formatter-out \"~<<-(~;~@{~w~^ ~_~}~;)-<~:>\"))\n\n(defn- pprint-simple-default [obj]\n  (cond \n    (.isArray (class obj)) (pprint-array obj)\n    (and *print-suppress-namespaces* (symbol? obj)) (print (name obj))\n    :else (pr obj)))\n\n\n(defmulti \n  simple-dispatch\n  \"The pretty print dispatch function for simple data structure format.\"\n  {:added \"1.2\" :arglists '[[object]]} \n  class)\n\n(use-method simple-dispatch clojure.lang.ISeq pprint-list)\n(use-method simple-dispatch clojure.lang.IPersistentVector pprint-vector)\n(use-method simple-dispatch clojure.lang.IPersistentMap pprint-map)\n(use-method simple-dispatch clojure.lang.IPersistentSet pprint-set)\n(use-method simple-dispatch clojure.lang.PersistentQueue pprint-pqueue)\n(use-method simple-dispatch clojure.lang.IDeref pprint-ideref)\n(use-method simple-dispatch nil pr)\n(use-method simple-dispatch :default pprint-simple-default)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Dispatch for the code table\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(declare pprint-simple-code-list)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Format the namespace (\"ns\") macro. This is quite complicated because of all the\n;;; different forms supported and because programmers can choose lists or vectors\n;;; in various places.\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn- brackets\n  \"Figure out which kind of brackets to use\"\n  [form]\n  (if (vector? form)\n    [\"[\" \"]\"]\n    [\"(\" \")\"]))\n\n(defn- pprint-ns-reference\n  \"Pretty print a single reference (import, use, etc.) from a namespace decl\"\n  [reference]\n  (if (sequential? reference)\n    (let [[start end] (brackets reference)\n          [keyw & args] reference]\n      (pprint-logical-block :prefix start :suffix end\n        ((formatter-out \"~w~:i\") keyw)\n        (loop [args args]\n          (when (seq args)\n            ((formatter-out \" \"))\n            (let [arg (first args)]\n              (if (sequential? arg)\n                (let [[start end] (brackets arg)]\n                  (pprint-logical-block :prefix start :suffix end\n                    (if (and (= (count arg) 3) (keyword? (second arg)))\n                      (let [[ns kw lis] arg]\n                        ((formatter-out \"~w ~w \") ns kw)\n                        (if (sequential? lis)\n                          ((formatter-out (if (vector? lis)\n                                            \"~<[~;~@{~w~^ ~:_~}~;]~:>\"\n                                            \"~<(~;~@{~w~^ ~:_~}~;)~:>\"))\n                           lis)\n                          (write-out lis)))\n                      (apply (formatter-out \"~w ~:i~@{~w~^ ~:_~}\") arg)))\n                  (when (next args)\n                    ((formatter-out \"~_\"))))\n                (do\n                  (write-out arg)\n                  (when (next args)\n                    ((formatter-out \"~:_\"))))))\n            (recur (next args))))))\n    (write-out reference)))\n\n(defn- pprint-ns\n  \"The pretty print dispatch chunk for the ns macro\"\n  [alis]\n  (if (next alis) \n    (let [[ns-sym ns-name & stuff] alis\n          [doc-str stuff] (if (string? (first stuff))\n                            [(first stuff) (next stuff)]\n                            [nil stuff])\n          [attr-map references] (if (map? (first stuff))\n                                  [(first stuff) (next stuff)]\n                                  [nil stuff])]\n      (pprint-logical-block :prefix \"(\" :suffix \")\"\n        ((formatter-out \"~w ~1I~@_~w\") ns-sym ns-name)\n        (when (or doc-str attr-map (seq references))\n          ((formatter-out \"~@:_\")))\n        (when doc-str\n          (cl-format true \"\\\"~a\\\"~:[~;~:@_~]\" doc-str (or attr-map (seq references))))\n        (when attr-map\n          ((formatter-out \"~w~:[~;~:@_~]\") attr-map (seq references)))\n        (loop [references references]\n          (pprint-ns-reference (first references))\n          (when-let [references (next references)]\n            (pprint-newline :linear)\n            (recur references)))))\n    (write-out alis)))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Format something that looks like a simple def (sans metadata, since the reader\n;;; won't give it to us now).\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(def ^{:private true} pprint-hold-first (formatter-out \"~:<~w~^ ~@_~w~^ ~_~@{~w~^ ~_~}~:>\"))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Format something that looks like a defn or defmacro\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n;;; Format the params and body of a defn with a single arity\n(defn- single-defn [alis has-doc-str?]\n  (if (seq alis)\n    (do\n      (if has-doc-str?\n        ((formatter-out \" ~_\"))\n        ((formatter-out \" ~@_\")))\n      ((formatter-out \"~{~w~^ ~_~}\") alis))))\n\n;;; Format the param and body sublists of a defn with multiple arities\n(defn- multi-defn [alis has-doc-str?]\n  (if (seq alis)\n    ((formatter-out \" ~_~{~w~^ ~_~}\") alis)))\n\n;;; TODO: figure out how to support capturing metadata in defns (we might need a \n;;; special reader)\n(defn- pprint-defn [alis]\n  (if (next alis) \n    (let [[defn-sym defn-name & stuff] alis\n          [doc-str stuff] (if (string? (first stuff))\n                            [(first stuff) (next stuff)]\n                            [nil stuff])\n          [attr-map stuff] (if (map? (first stuff))\n                             [(first stuff) (next stuff)]\n                             [nil stuff])]\n      (pprint-logical-block :prefix \"(\" :suffix \")\"\n        ((formatter-out \"~w ~1I~@_~w\") defn-sym defn-name)\n        (if doc-str\n          ((formatter-out \" ~_~w\") doc-str))\n        (if attr-map\n          ((formatter-out \" ~_~w\") attr-map))\n        ;; Note: the multi-defn case will work OK for malformed defns too\n        (cond\n         (vector? (first stuff)) (single-defn stuff (or doc-str attr-map))\n         :else (multi-defn stuff (or doc-str attr-map)))))\n    (pprint-simple-code-list alis)))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Format something with a binding form\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn- pprint-binding-form [binding-vec]\n  (pprint-logical-block :prefix \"[\" :suffix \"]\"\n    (print-length-loop [binding binding-vec]\n      (when (seq binding)\n        (pprint-logical-block binding\n          (write-out (first binding))\n          (when (next binding)\n            (.write ^java.io.Writer *out* \" \")\n            (pprint-newline :miser)\n            (write-out (second binding))))\n        (when (next (rest binding))\n          (.write ^java.io.Writer *out* \" \")\n          (pprint-newline :linear)\n          (recur (next (rest binding))))))))\n\n(defn- pprint-let [alis]\n  (let [base-sym (first alis)]\n    (pprint-logical-block :prefix \"(\" :suffix \")\"\n      (if (and (next alis) (vector? (second alis)))\n        (do\n          ((formatter-out \"~w ~1I~@_\") base-sym)\n          (pprint-binding-form (second alis))\n          ((formatter-out \" ~_~{~w~^ ~_~}\") (next (rest alis))))\n        (pprint-simple-code-list alis)))))\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Format something that looks like \"if\"\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(def ^{:private true} pprint-if (formatter-out \"~:<~1I~w~^ ~@_~w~@{ ~_~w~}~:>\"))\n\n(defn- pprint-cond [alis]\n  (pprint-logical-block :prefix \"(\" :suffix \")\"\n    (pprint-indent :block 1)\n    (write-out (first alis))\n    (when (next alis)\n      (.write ^java.io.Writer *out* \" \")\n      (pprint-newline :linear)\n     (print-length-loop [alis (next alis)]\n       (when alis\n         (pprint-logical-block alis\n          (write-out (first alis))\n          (when (next alis)\n            (.write ^java.io.Writer *out* \" \")\n            (pprint-newline :miser)\n            (write-out (second alis))))\n         (when (next (rest alis))\n           (.write ^java.io.Writer *out* \" \")\n           (pprint-newline :linear)\n           (recur (next (rest alis)))))))))\n\n(defn- pprint-condp [alis]\n  (if (> (count alis) 3) \n    (pprint-logical-block :prefix \"(\" :suffix \")\"\n      (pprint-indent :block 1)\n      (apply (formatter-out \"~w ~@_~w ~@_~w ~_\") alis)\n      (print-length-loop [alis (seq (drop 3 alis))]\n        (when alis\n          (pprint-logical-block alis\n            (write-out (first alis))\n            (when (next alis)\n              (.write ^java.io.Writer *out* \" \")\n              (pprint-newline :miser)\n              (write-out (second alis))))\n          (when (next (rest alis))\n            (.write ^java.io.Writer *out* \" \")\n            (pprint-newline :linear)\n            (recur (next (rest alis)))))))\n    (pprint-simple-code-list alis)))\n\n;;; The map of symbols that are defined in an enclosing #() anonymous function\n(def ^:dynamic ^{:private true} *symbol-map* {})\n\n(defn- pprint-anon-func [alis]\n  (let [args (second alis)\n        nlis (first (rest (rest alis)))]\n    (if (vector? args)\n      (binding [*symbol-map* (if (= 1 (count args)) \n                               {(first args) \"%\"}\n                               (into {} \n                                     (map \n                                      #(vector %1 (str \\% %2)) \n                                      args \n                                      (range 1 (inc (count args))))))]\n        ((formatter-out \"~<#(~;~@{~w~^ ~_~}~;)~:>\") nlis))\n      (pprint-simple-code-list alis))))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; The master definitions for formatting lists in code (that is, (fn args...) or\n;;; special forms).\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n;;; This is the equivalent of (formatter-out \"~:<~1I~@{~w~^ ~_~}~:>\"), but is\n;;; easier on the stack.\n\n(defn- pprint-simple-code-list [alis]\n  (pprint-logical-block :prefix \"(\" :suffix \")\"\n    (pprint-indent :block 1)\n    (print-length-loop [alis (seq alis)]\n      (when alis\n\t(write-out (first alis))\n\t(when (next alis)\n\t  (.write ^java.io.Writer *out* \" \")\n\t  (pprint-newline :linear)\n\t  (recur (next alis)))))))\n\n;;; Take a map with symbols as keys and add versions with no namespace.\n;;; That is, if ns/sym->val is in the map, add sym->val to the result.\n(defn- two-forms [amap]\n  (into {} \n        (mapcat \n         identity \n         (for [x amap] \n           [x [(symbol (name (first x))) (second x)]]))))\n\n(defn- add-core-ns [amap]\n  (let [core \"clojure.core\"]\n    (into {}\n          (map #(let [[s f] %] \n                  (if (not (or (namespace s) (special-symbol? s)))\n                    [(symbol core (name s)) f]\n                    %))\n               amap))))\n\n(def ^:dynamic ^{:private true} *code-table*\n     (two-forms\n      (add-core-ns\n       {'def pprint-hold-first, 'defonce pprint-hold-first, \n\t'defn pprint-defn, 'defn- pprint-defn, 'defmacro pprint-defn, 'fn pprint-defn,\n        'let pprint-let, 'loop pprint-let, 'binding pprint-let,\n        'with-local-vars pprint-let, 'with-open pprint-let, 'when-let pprint-let,\n\t'if-let pprint-let, 'doseq pprint-let, 'dotimes pprint-let,\n\t'when-first pprint-let,\n        'if pprint-if, 'if-not pprint-if, 'when pprint-if, 'when-not pprint-if,\n        'cond pprint-cond, 'condp pprint-condp,\n        'fn* pprint-anon-func,\n        '. pprint-hold-first, '.. pprint-hold-first, '-> pprint-hold-first,\n        'locking pprint-hold-first, 'struct pprint-hold-first,\n        'struct-map pprint-hold-first, 'ns pprint-ns \n        })))\n\n(defn- pprint-code-list [alis]\n  (if-not (pprint-reader-macro alis) \n    (if-let [special-form (*code-table* (first alis))]\n      (special-form alis)\n      (pprint-simple-code-list alis))))\n\n(defn- pprint-code-symbol [sym] \n  (if-let [arg-num (sym *symbol-map*)]\n    (print arg-num)\n    (if *print-suppress-namespaces* \n      (print (name sym))\n      (pr sym))))\n\n(defmulti \n  code-dispatch\n  \"The pretty print dispatch function for pretty printing Clojure code.\"\n  {:added \"1.2\" :arglists '[[object]]} \n  class)\n\n(use-method code-dispatch clojure.lang.ISeq pprint-code-list)\n(use-method code-dispatch clojure.lang.Symbol pprint-code-symbol)\n\n;; The following are all exact copies of simple-dispatch\n(use-method code-dispatch clojure.lang.IPersistentVector pprint-vector)\n(use-method code-dispatch clojure.lang.IPersistentMap pprint-map)\n(use-method code-dispatch clojure.lang.IPersistentSet pprint-set)\n(use-method code-dispatch clojure.lang.PersistentQueue pprint-pqueue)\n(use-method code-dispatch clojure.lang.IDeref pprint-ideref)\n(use-method code-dispatch nil pr)\n(use-method code-dispatch :default pprint-simple-default)\n\n(set-pprint-dispatch simple-dispatch)\n\n\n;;; For testing\n(comment\n\n(with-pprint-dispatch code-dispatch \n  (pprint \n   '(defn cl-format \n      \"An implementation of a Common Lisp compatible format function\"\n      [stream format-in & args]\n      (let [compiled-format (if (string? format-in) (compile-format format-in) format-in)\n            navigator (init-navigator args)]\n        (execute-format stream compiled-format navigator)))))\n\n(with-pprint-dispatch code-dispatch \n  (pprint \n   '(defn cl-format \n      [stream format-in & args]\n      (let [compiled-format (if (string? format-in) (compile-format format-in) format-in)\n            navigator (init-navigator args)]\n        (execute-format stream compiled-format navigator)))))\n\n(with-pprint-dispatch code-dispatch \n  (pprint\n   '(defn- -write \n      ([this x]\n         (condp = (class x)\n           String \n           (let [s0 (write-initial-lines this x)\n                 s (.replaceFirst s0 \"\\\\s+$\" \"\")\n                 white-space (.substring s0 (count s))\n                 mode (getf :mode)]\n             (if (= mode :writing)\n               (dosync\n                (write-white-space this)\n                (.col_write this s)\n                (setf :trailing-white-space white-space))\n               (add-to-buffer this (make-buffer-blob s white-space))))\n\n           Integer\n           (let [c ^Character x]\n             (if (= (getf :mode) :writing)\n               (do \n                 (write-white-space this)\n                 (.col_write this x))\n               (if (= c (int \\newline))\n                 (write-initial-lines this \"\\n\")\n                 (add-to-buffer this (make-buffer-blob (str (char c)) nil))))))))))\n\n(with-pprint-dispatch code-dispatch \n  (pprint \n   '(defn pprint-defn [writer alis]\n      (if (next alis) \n        (let [[defn-sym defn-name & stuff] alis\n              [doc-str stuff] (if (string? (first stuff))\n                                [(first stuff) (next stuff)]\n                                [nil stuff])\n              [attr-map stuff] (if (map? (first stuff))\n                                 [(first stuff) (next stuff)]\n                                 [nil stuff])]\n          (pprint-logical-block writer :prefix \"(\" :suffix \")\"\n                                (cl-format true \"~w ~1I~@_~w\" defn-sym defn-name)\n                                (if doc-str\n                                  (cl-format true \" ~_~w\" doc-str))\n                                (if attr-map\n                                  (cl-format true \" ~_~w\" attr-map))\n                                ;; Note: the multi-defn case will work OK for malformed defns too\n                                (cond\n                                  (vector? (first stuff)) (single-defn stuff (or doc-str attr-map))\n                                  :else (multi-defn stuff (or doc-str attr-map)))))\n        (pprint-simple-code-list writer alis)))))\n)\nnil\n\n"
  },
  {
    "path": "src/clj/clojure/pprint/pprint_base.clj",
    "content": ";;; pprint_base.clj -- part of the pretty printer for Clojure\n\n;   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Tom Faulhaber\n;; April 3, 2009\n\n\n;; This module implements the generic pretty print functions and special variables\n\n(in-ns 'clojure.pprint)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;; Variables that control the pretty printer\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n;;;\n;;; *print-length*, *print-level* and *print-dup* are defined in clojure.core\n;;; TODO: use *print-dup* here (or is it supplanted by other variables?)\n;;; TODO: make dispatch items like \"(let...\" get counted in *print-length*\n;;; constructs\n\n\n(def ^:dynamic\n ^{:doc \"Bind to true if you want write to use pretty printing\", :added \"1.2\"}\n *print-pretty* true)\n\n(defonce ^:dynamic ; If folks have added stuff here, don't overwrite\n ^{:doc \"The pretty print dispatch function. Use with-pprint-dispatch or set-pprint-dispatch\nto modify.\",\n   :added \"1.2\"}\n *print-pprint-dispatch* nil)\n\n(def ^:dynamic\n ^{:doc \"Pretty printing will try to avoid anything going beyond this column.\nSet it to nil to have pprint let the line be arbitrarily long. This will ignore all \nnon-mandatory newlines.\",\n   :added \"1.2\"}\n *print-right-margin* 72)\n\n(def ^:dynamic\n ^{:doc \"The column at which to enter miser style. Depending on the dispatch table, \nmiser style add newlines in more places to try to keep lines short allowing for further \nlevels of nesting.\",\n   :added \"1.2\"}\n *print-miser-width* 40)\n\n;;; TODO implement output limiting\n(def ^:dynamic\n ^{:private true,\n   :doc \"Maximum number of lines to print in a pretty print instance (N.B. This is not yet used)\"}\n *print-lines* nil)\n\n;;; TODO: implement circle and shared\n(def ^:dynamic\n ^{:private true,\n   :doc \"Mark circular structures (N.B. This is not yet used)\"}\n *print-circle* nil)\n\n;;; TODO: should we just use *print-dup* here?\n(def ^:dynamic\n ^{:private true,\n   :doc \"Mark repeated structures rather than repeat them (N.B. This is not yet used)\"}\n *print-shared* nil)\n\n(def ^:dynamic\n ^{:doc \"Don't print namespaces with symbols. This is particularly useful when \npretty printing the results of macro expansions\"\n   :added \"1.2\"}\n *print-suppress-namespaces* nil)\n\n;;; TODO: support print-base and print-radix in cl-format\n;;; TODO: support print-base and print-radix in rationals\n(def ^:dynamic\n ^{:doc \"Print a radix specifier in front of integers and rationals. If *print-base* is 2, 8, \nor 16, then the radix specifier used is #b, #o, or #x, respectively. Otherwise the \nradix specifier is in the form #XXr where XX is the decimal value of *print-base* \"\n   :added \"1.2\"}\n *print-radix* nil)\n\n(def ^:dynamic\n ^{:doc \"The base to use for printing integers and rationals.\"\n   :added \"1.2\"}\n *print-base* 10)\n\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;; Internal variables that keep track of where we are in the \n;; structure\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(def  ^:dynamic ^{ :private true } *current-level* 0)\n\n(def ^:dynamic ^{ :private true } *current-length* nil)\n\n;; TODO: add variables for length, lines.\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;; Support for the write function\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(declare format-simple-number)\n\n(def ^{:private true} orig-pr pr)\n\n(defn- pr-with-base [x]\n  (if-let [s (format-simple-number x)]\n    (print s)\n    (orig-pr x)))\n\n(def ^{:private true} write-option-table\n     {;:array            *print-array*\n      :base             'clojure.pprint/*print-base*,\n      ;;:case             *print-case*,\n      :circle           'clojure.pprint/*print-circle*,\n      ;;:escape           *print-escape*,\n      ;;:gensym           *print-gensym*,\n      :length           'clojure.core/*print-length*,\n      :level            'clojure.core/*print-level*,\n      :lines            'clojure.pprint/*print-lines*,\n      :miser-width      'clojure.pprint/*print-miser-width*,\n      :dispatch         'clojure.pprint/*print-pprint-dispatch*,\n      :pretty           'clojure.pprint/*print-pretty*,\n      :radix            'clojure.pprint/*print-radix*,\n      :readably         'clojure.core/*print-readably*,\n      :right-margin     'clojure.pprint/*print-right-margin*,\n      :suppress-namespaces 'clojure.pprint/*print-suppress-namespaces*})\n\n\n(defmacro ^{:private true} binding-map [amap & body]\n  (let []\n    `(do\n       (. clojure.lang.Var (pushThreadBindings ~amap))\n       (try\n        ~@body\n        (finally\n         (. clojure.lang.Var (popThreadBindings)))))))\n\n(defn- table-ize [t m] \n  (apply hash-map (mapcat \n                   #(when-let [v (get t (key %))] [(find-var v) (val %)]) \n                   m)))\n\n(defn- pretty-writer? \n  \"Return true iff x is a PrettyWriter\"\n  [x] (and (instance? clojure.lang.IDeref x) (:pretty-writer @@x)))\n\n(defn- make-pretty-writer \n  \"Wrap base-writer in a PrettyWriter with the specified right-margin and miser-width\"\n  [base-writer right-margin miser-width]\n  (pretty-writer base-writer right-margin miser-width))\n\n(defmacro ^{:private true} with-pretty-writer [base-writer & body]\n  `(let [base-writer# ~base-writer\n         new-writer# (not (pretty-writer? base-writer#))]\n     (binding [*out* (if new-writer#\n                      (make-pretty-writer base-writer# *print-right-margin* *print-miser-width*)\n                      base-writer#)]\n       ~@body\n       (.ppflush *out*))))\n\n\n;;;TODO: if pretty print is not set, don't use pr but rather something that respects *print-base*, etc.\n(defn write-out \n  \"Write an object to *out* subject to the current bindings of the printer control \nvariables. Use the kw-args argument to override individual variables for this call (and \nany recursive calls).\n\n*out* must be a PrettyWriter if pretty printing is enabled. This is the responsibility\nof the caller.\n\nThis method is primarily intended for use by pretty print dispatch functions that \nalready know that the pretty printer will have set up their environment appropriately.\nNormal library clients should use the standard \\\"write\\\" interface. \"\n  {:added \"1.2\"}\n  [object]\n  (let [length-reached (and \n                        *current-length*\n                        *print-length*\n                        (>= *current-length* *print-length*))]\n    (if-not *print-pretty*\n      (pr object)\n      (if length-reached\n        (print \"...\")\n        (do\n          (if *current-length* (set! *current-length* (inc *current-length*)))\n          (*print-pprint-dispatch* object))))\n    length-reached))\n\n(defn write \n  \"Write an object subject to the current bindings of the printer control variables.\nUse the kw-args argument to override individual variables for this call (and any \nrecursive calls). Returns the string result if :stream is nil or nil otherwise.\n\nThe following keyword arguments can be passed with values:\n  Keyword              Meaning                              Default value\n  :stream              Writer for output or nil             true (indicates *out*)\n  :base                Base to use for writing rationals    Current value of *print-base*\n  :circle*             If true, mark circular structures    Current value of *print-circle*\n  :length              Maximum elements to show in sublists Current value of *print-length*\n  :level               Maximum depth                        Current value of *print-level*\n  :lines*              Maximum lines of output              Current value of *print-lines*\n  :miser-width         Width to enter miser mode            Current value of *print-miser-width*\n  :dispatch            The pretty print dispatch function   Current value of *print-pprint-dispatch*\n  :pretty              If true, do pretty printing          Current value of *print-pretty*\n  :radix               If true, prepend a radix specifier   Current value of *print-radix*\n  :readably*           If true, print readably              Current value of *print-readably*\n  :right-margin        The column for the right margin      Current value of *print-right-margin*\n  :suppress-namespaces If true, no namespaces in symbols    Current value of *print-suppress-namespaces*\n\n  * = not yet supported\n\"\n  {:added \"1.2\"}\n  [object & kw-args]\n  (let [options (merge {:stream true} (apply hash-map kw-args))]\n    (binding-map (table-ize write-option-table options) \n      (binding-map (if (or (not (= *print-base* 10)) *print-radix*) {#'pr pr-with-base} {}) \n        (let [optval (if (contains? options :stream) \n                       (:stream options)\n                       true) \n              base-writer (condp = optval\n                            nil (java.io.StringWriter.)\n                            true *out*\n                            optval)]\n          (if *print-pretty*\n            (with-pretty-writer base-writer\n              (write-out object))\n            (binding [*out* base-writer]\n              (pr object)))\n          (if (nil? optval) \n            (.toString ^java.io.StringWriter base-writer)))))))\n\n\n(defn pprint \n  \"Pretty print object to the optional output writer. If the writer is not provided, \nprint the object to the currently bound value of *out*.\"\n  {:added \"1.2\"}\n  ([object] (pprint object *out*)) \n  ([object writer]\n     (with-pretty-writer writer\n       (binding [*print-pretty* true]\n         (binding-map (if (or (not (= *print-base* 10)) *print-radix*) {#'pr pr-with-base} {}) \n           (write-out object)))\n       (if (not (= 0 (get-column *out*)))\n         (prn)))))\n\n(defmacro pp \n  \"A convenience macro that pretty prints the last thing output. This is\nexactly equivalent to (pprint *1).\"\n  {:added \"1.2\"}\n  [] `(pprint *1))\n\n(defn set-pprint-dispatch  \n  \"Set the pretty print dispatch function to a function matching (fn [obj] ...)\nwhere obj is the object to pretty print. That function will be called with *out* set\nto a pretty printing writer to which it should do its printing.\n\nFor example functions, see simple-dispatch and code-dispatch in \nclojure.pprint.dispatch.clj.\"\n  {:added \"1.2\"}\n  [function]\n  (let [old-meta (meta #'*print-pprint-dispatch*)]\n    (alter-var-root #'*print-pprint-dispatch* (constantly function))\n    (alter-meta! #'*print-pprint-dispatch* (constantly old-meta)))\n  nil)\n\n(defmacro with-pprint-dispatch \n  \"Execute body with the pretty print dispatch function bound to function.\"\n  {:added \"1.2\"}\n  [function & body]\n  `(binding [*print-pprint-dispatch* ~function]\n     ~@body))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;; Support for the functional interface to the pretty printer\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn- parse-lb-options [opts body]\n  (loop [body body\n         acc []]\n    (if (opts (first body))\n      (recur (drop 2 body) (concat acc (take 2 body)))\n      [(apply hash-map acc) body])))\n\n(defn- check-enumerated-arg [arg choices]\n  (if-not (choices arg)\n          (throw\n           (IllegalArgumentException.\n            ;; TODO clean up choices string\n            (str \"Bad argument: \" arg \". It must be one of \" choices)))))\n\n(defn- level-exceeded []\n  (and *print-level* (>= *current-level* *print-level*)))\n\n(defmacro pprint-logical-block \n  \"Execute the body as a pretty printing logical block with output to *out* which \nmust be a pretty printing writer. When used from pprint or cl-format, this can be \nassumed. \n\nThis function is intended for use when writing custom dispatch functions.\n\nBefore the body, the caller can optionally specify options: :prefix, :per-line-prefix, \nand :suffix.\"\n  {:added \"1.2\", :arglists '[[options* body]]}\n  [& args]\n  (let [[options body] (parse-lb-options #{:prefix :per-line-prefix :suffix} args)]\n    `(do (if (#'clojure.pprint/level-exceeded) \n           (.write ^java.io.Writer *out* \"#\")\n           (do \n             (push-thread-bindings {#'clojure.pprint/*current-level*\n                                    (inc (var-get #'clojure.pprint/*current-level*))\n                                    #'clojure.pprint/*current-length* 0})\n             (try  \n              (#'clojure.pprint/start-block *out*\n                           ~(:prefix options) ~(:per-line-prefix options) ~(:suffix options))\n              ~@body\n              (#'clojure.pprint/end-block *out*)\n              (finally \n               (pop-thread-bindings)))))\n         nil)))\n\n(defn pprint-newline\n  \"Print a conditional newline to a pretty printing stream. kind specifies if the \nnewline is :linear, :miser, :fill, or :mandatory. \n\nThis function is intended for use when writing custom dispatch functions.\n\nOutput is sent to *out* which must be a pretty printing writer.\"\n  {:added \"1.2\"}\n  [kind] \n  (check-enumerated-arg kind #{:linear :miser :fill :mandatory})\n  (nl *out* kind))\n\n(defn pprint-indent \n  \"Create an indent at this point in the pretty printing stream. This defines how \nfollowing lines are indented. relative-to can be either :block or :current depending \nwhether the indent should be computed relative to the start of the logical block or\nthe current column position. n is an offset. \n\nThis function is intended for use when writing custom dispatch functions.\n\nOutput is sent to *out* which must be a pretty printing writer.\"\n  {:added \"1.2\"}\n  [relative-to n] \n  (check-enumerated-arg relative-to #{:block :current})\n  (indent *out* relative-to n))\n\n;; TODO a real implementation for pprint-tab\n(defn pprint-tab \n  \"Tab at this point in the pretty printing stream. kind specifies whether the tab\nis :line, :section, :line-relative, or :section-relative. \n\nColnum and colinc specify the target column and the increment to move the target\nforward if the output is already past the original target.\n\nThis function is intended for use when writing custom dispatch functions.\n\nOutput is sent to *out* which must be a pretty printing writer.\n\nTHIS FUNCTION IS NOT YET IMPLEMENTED.\"\n  {:added \"1.2\"}\n  [kind colnum colinc] \n  (check-enumerated-arg kind #{:line :section :line-relative :section-relative})\n  (throw (UnsupportedOperationException. \"pprint-tab is not yet implemented\")))\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;;\n;;; Helpers for dispatch function writing\n;;;\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn- pll-mod-body [var-sym body]\n  (letfn [(inner [form]\n                 (if (seq? form)\n                   (let [form (macroexpand form)] \n                     (condp = (first form)\n                       'loop* form\n                       'recur (concat `(recur (inc ~var-sym)) (rest form))\n                       (walk inner identity form)))\n                   form))]\n    (walk inner identity body)))\n\n(defmacro print-length-loop\n  \"A version of loop that iterates at most *print-length* times. This is designed \nfor use in pretty-printer dispatch functions.\"\n  {:added \"1.3\"}\n  [bindings & body]\n  (let [count-var (gensym \"length-count\")\n        mod-body (pll-mod-body count-var body)]\n    `(loop ~(apply vector count-var 0 bindings)\n       (if (or (not *print-length*) (< ~count-var *print-length*))\n         (do ~@mod-body)\n         (.write ^java.io.Writer *out* \"...\")))))\n\nnil\n"
  },
  {
    "path": "src/clj/clojure/pprint/pretty_writer.clj",
    "content": ";;; pretty_writer.clj -- part of the pretty printer for Clojure\n\n;   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Tom Faulhaber\n;; April 3, 2009\n;; Revised to use proxy instead of gen-class April 2010\n\n;; This module implements a wrapper around a java.io.Writer which implements the\n;; core of the XP algorithm.\n\n(in-ns 'clojure.pprint)\n\n(import [clojure.lang IDeref]\n        [java.io Writer])\n\n;; TODO: Support for tab directives\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Forward declarations\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(declare get-miser-width)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Macros to simplify dealing with types and classes. These are\n;;; really utilities, but I'm experimenting with them here.\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defmacro ^{:private true} \n  getf \n  \"Get the value of the field a named by the argument (which should be a keyword).\"\n  [sym]\n  `(~sym @@~'this))\n\n(defmacro ^{:private true} \n  setf [sym new-val] \n  \"Set the value of the field SYM to NEW-VAL\"\n  `(alter @~'this assoc ~sym ~new-val))\n\n(defmacro ^{:private true} \n  deftype [type-name & fields]\n  (let [name-str (name type-name)]\n    `(do\n       (defstruct ~type-name :type-tag ~@fields)\n       (alter-meta! #'~type-name assoc :private true)\n       (defn- ~(symbol (str \"make-\" name-str)) \n         [& vals#] (apply struct ~type-name ~(keyword name-str) vals#))\n       (defn- ~(symbol (str name-str \"?\")) [x#] (= (:type-tag x#) ~(keyword name-str))))))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; The data structures used by pretty-writer\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defstruct ^{:private true} logical-block\n           :parent :section :start-col :indent\n           :done-nl :intra-block-nl\n           :prefix :per-line-prefix :suffix\n           :logical-block-callback)\n\n(defn- ancestor? [parent child]\n  (loop [child (:parent child)]\n    (cond \n     (nil? child) false\n     (identical? parent child) true\n     :else (recur (:parent child)))))\n\n(defstruct ^{:private true} section :parent)\n\n(defn- buffer-length [l] \n  (let [l (seq l)]\n    (if l \n      (- (:end-pos (last l)) (:start-pos (first l)))\n      0)))\n\n; A blob of characters (aka a string)\n(deftype buffer-blob :data :trailing-white-space :start-pos :end-pos)\n\n; A newline\n(deftype nl-t :type :logical-block :start-pos :end-pos)\n\n(deftype start-block-t :logical-block :start-pos :end-pos)\n\n(deftype end-block-t :logical-block :start-pos :end-pos)\n\n(deftype indent-t :logical-block :relative-to :offset :start-pos :end-pos)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Functions to write tokens in the output buffer\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(def ^:private pp-newline (memoize #(System/getProperty \"line.separator\")))\n\n(declare emit-nl)\n\n(defmulti ^{:private true} write-token #(:type-tag %2))\n(defmethod write-token :start-block-t [^Writer this token]\n   (when-let [cb (getf :logical-block-callback)] (cb :start))\n   (let [lb (:logical-block token)]\n    (dosync\n     (when-let [^String prefix (:prefix lb)] \n       (.write (getf :base) prefix))\n     (let [col (get-column (getf :base))]\n       (ref-set (:start-col lb) col)\n       (ref-set (:indent lb) col)))))\n\n(defmethod write-token :end-block-t [^Writer this token]\n  (when-let [cb (getf :logical-block-callback)] (cb :end))\n  (when-let [^String suffix (:suffix (:logical-block token))] \n    (.write (getf :base) suffix)))\n\n(defmethod write-token :indent-t [^Writer this token]\n  (let [lb (:logical-block token)]\n    (ref-set (:indent lb) \n             (+ (:offset token)\n                (condp = (:relative-to token)\n\t\t  :block @(:start-col lb)\n\t\t  :current (get-column (getf :base)))))))\n\n(defmethod write-token :buffer-blob [^Writer this token]\n  (.write (getf :base) ^String (:data token)))\n\n(defmethod write-token :nl-t [^Writer this token]\n;  (prlabel wt @(:done-nl (:logical-block token)))\n;  (prlabel wt (:type token) (= (:type token) :mandatory))\n  (if (or (= (:type token) :mandatory)\n           (and (not (= (:type token) :fill))\n                @(:done-nl (:logical-block token))))\n    (emit-nl this token)\n    (if-let [^String tws (getf :trailing-white-space)]\n      (.write (getf :base) tws)))\n  (dosync (setf :trailing-white-space nil)))\n\n(defn- write-tokens [^Writer this tokens force-trailing-whitespace]\n  (doseq [token tokens]\n    (if-not (= (:type-tag token) :nl-t)\n      (if-let [^String tws (getf :trailing-white-space)]\n\t(.write (getf :base) tws)))\n    (write-token this token)\n    (setf :trailing-white-space (:trailing-white-space token)))\n  (let [^String tws (getf :trailing-white-space)] \n    (when (and force-trailing-whitespace tws)\n      (.write (getf :base) tws)\n      (setf :trailing-white-space nil))))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; emit-nl? method defs for each type of new line. This makes\n;;; the decision about whether to print this type of new line.\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n\n(defn- tokens-fit? [^Writer this tokens]\n;;;  (prlabel tf? (get-column (getf :base) (buffer-length tokens))\n  (let [maxcol (get-max-column (getf :base))]\n    (or \n     (nil? maxcol) \n     (< (+ (get-column (getf :base)) (buffer-length tokens)) maxcol))))\n\n(defn- linear-nl? [this lb section]\n;  (prlabel lnl? @(:done-nl lb) (tokens-fit? this section))\n  (or @(:done-nl lb)\n      (not (tokens-fit? this section))))\n\n(defn- miser-nl? [^Writer this lb section]\n  (let [miser-width (get-miser-width this)\n        maxcol (get-max-column (getf :base))]\n    (and miser-width maxcol\n         (>= @(:start-col lb) (- maxcol miser-width))\n         (linear-nl? this lb section))))\n\n(defmulti ^{:private true} emit-nl? (fn [t _ _ _] (:type t)))\n\n(defmethod emit-nl? :linear [newl this section _]\n  (let [lb (:logical-block newl)]\n    (linear-nl? this lb section)))\n\n(defmethod emit-nl? :miser [newl this section _]\n  (let [lb (:logical-block newl)]\n    (miser-nl? this lb section)))\n\n(defmethod emit-nl? :fill [newl this section subsection]\n  (let [lb (:logical-block newl)]\n    (or @(:intra-block-nl lb)\n        (not (tokens-fit? this subsection))\n        (miser-nl? this lb section))))\n\n(defmethod emit-nl? :mandatory [_ _ _ _]\n  true)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Various support functions\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n\n(defn- get-section [buffer]\n  (let [nl (first buffer) \n        lb (:logical-block nl)\n        section (seq (take-while #(not (and (nl-t? %) (ancestor? (:logical-block %) lb)))\n                                 (next buffer)))]\n    [section (seq (drop (inc (count section)) buffer))])) \n\n(defn- get-sub-section [buffer]\n  (let [nl (first buffer) \n        lb (:logical-block nl)\n        section (seq (take-while #(let [nl-lb (:logical-block %)]\n                                    (not (and (nl-t? %) (or (= nl-lb lb) (ancestor? nl-lb lb)))))\n                            (next buffer)))]\n    section)) \n\n(defn- update-nl-state [lb]\n  (dosync\n   (ref-set (:intra-block-nl lb) false)\n   (ref-set (:done-nl lb) true)\n   (loop [lb (:parent lb)]\n     (if lb\n       (do (ref-set (:done-nl lb) true)\n           (ref-set (:intra-block-nl lb) true)\n           (recur (:parent lb)))))))\n\n(defn- emit-nl [^Writer this nl]\n  (.write (getf :base) (pp-newline))\n  (dosync (setf :trailing-white-space nil))\n  (let [lb (:logical-block nl)\n        ^String prefix (:per-line-prefix lb)] \n    (if prefix \n      (.write (getf :base) prefix))\n    (let [^String istr (apply str (repeat (- @(:indent lb) (count prefix))\n\t\t\t\t\t  \\space))] \n      (.write (getf :base) istr))\n    (update-nl-state lb)))\n\n(defn- split-at-newline [tokens]\n  (let [pre (seq (take-while #(not (nl-t? %)) tokens))]\n    [pre (seq (drop (count pre) tokens))]))\n\n;;; Methods for showing token strings for debugging\n\n(defmulti ^{:private true} tok :type-tag)\n(defmethod tok :nl-t [token]\n  (:type token))\n(defmethod tok :buffer-blob [token]\n  (str \\\" (:data token) (:trailing-white-space token) \\\"))\n(defmethod tok :default [token]\n  (:type-tag token))\n(defn- toks [toks] (map tok toks))\n\n;;; write-token-string is called when the set of tokens in the buffer\n;;; is longer than the available space on the line\n\n(defn- write-token-string [this tokens]\n  (let [[a b] (split-at-newline tokens)]\n;;    (prlabel wts (toks a) (toks b))\n    (if a (write-tokens this a false))\n    (if b\n      (let [[section remainder] (get-section b)\n            newl (first b)]\n;;         (prlabel wts (toks section)) (prlabel wts (:type newl)) (prlabel wts (toks remainder)) \n        (let [do-nl (emit-nl? newl this section (get-sub-section b))\n              result (if do-nl \n                       (do\n;;                          (prlabel emit-nl (:type newl))\n                         (emit-nl this newl)\n                         (next b))\n                       b)\n              long-section (not (tokens-fit? this result))\n              result (if long-section\n                       (let [rem2 (write-token-string this section)]\n;;;                              (prlabel recurse (toks rem2))\n                         (if (= rem2 section)\n                           (do ; If that didn't produce any output, it has no nls\n                                        ; so we'll force it\n                             (write-tokens this section false)\n                             remainder)\n                           (into [] (concat rem2 remainder))))\n                       result)\n;;              ff (prlabel wts (toks result))\n              ] \n          result)))))\n\n(defn- write-line [^Writer this]\n  (dosync\n   (loop [buffer (getf :buffer)]\n;;     (prlabel wl1 (toks buffer))\n     (setf :buffer (into [] buffer))\n     (if (not (tokens-fit? this buffer))\n       (let [new-buffer (write-token-string this buffer)]\n;;          (prlabel wl new-buffer)\n         (if-not (identical? buffer new-buffer)\n                 (recur new-buffer)))))))\n\n;;; Add a buffer token to the buffer and see if it's time to start\n;;; writing\n(defn- add-to-buffer [^Writer this token]\n;  (prlabel a2b token)\n  (dosync\n   (setf :buffer (conj (getf :buffer) token))\n   (if (not (tokens-fit? this (getf :buffer)))\n     (write-line this))))\n\n;;; Write all the tokens that have been buffered\n(defn- write-buffered-output [^Writer this]\n  (write-line this)\n  (if-let [buf (getf :buffer)]\n    (do\n      (write-tokens this buf true)\n      (setf :buffer []))))\n\n(defn- write-white-space [^Writer this]\n  (when-let [^String tws (getf :trailing-white-space)]\n    ; (prlabel wws (str \"*\" tws \"*\"))\n    (.write (getf :base) tws)\n    (dosync\n     (setf :trailing-white-space nil))))\n\n;;; If there are newlines in the string, print the lines up until the last newline, \n;;; making the appropriate adjustments. Return the remainder of the string\n(defn- write-initial-lines \n  [^Writer this ^String s] \n  (let [lines (.split s \"\\n\" -1)]\n    (if (= (count lines) 1)\n      s\n      (dosync \n       (let [^String prefix (:per-line-prefix (first (getf :logical-blocks)))\n             ^String l (first lines)] \n         (if (= :buffering (getf :mode))\n           (let [oldpos (getf :pos)\n                 newpos (+ oldpos (count l))]\n             (setf :pos newpos)\n             (add-to-buffer this (make-buffer-blob l nil oldpos newpos))\n             (write-buffered-output this))\n           (do\n             (write-white-space this)\n             (.write (getf :base) l)))\n         (.write (getf :base) (int \\newline))\n         (doseq [^String l (next (butlast lines))]\n           (.write (getf :base) l)\n           (.write (getf :base) (pp-newline))\n           (if prefix\n             (.write (getf :base) prefix)))\n         (setf :buffering :writing)\n         (last lines))))))\n\n\n(defn- p-write-char [^Writer this ^Integer c]\n  (if (= (getf :mode) :writing)\n    (do \n      (write-white-space this)\n      (.write (getf :base) c))\n    (if (= c \\newline)\n      (write-initial-lines this \"\\n\")\n      (let [oldpos (getf :pos)\n            newpos (inc oldpos)]\n        (dosync\n         (setf :pos newpos)\n         (add-to-buffer this (make-buffer-blob (str (char c)) nil oldpos newpos)))))))\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Initialize the pretty-writer instance\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n\n(defn- pretty-writer [writer max-columns miser-width]\n  (let [lb (struct logical-block nil nil (ref 0) (ref 0) (ref false) (ref false))\n        fields (ref {:pretty-writer true\n                     :base (column-writer writer max-columns)\n                     :logical-blocks lb \n                     :sections nil\n                     :mode :writing\n                     :buffer []\n                     :buffer-block lb\n                     :buffer-level 1\n                     :miser-width miser-width\n                     :trailing-white-space nil\n                     :pos 0})]\n    (proxy [Writer IDeref PrettyFlush] []\n      (deref [] fields)\n\n      (write \n       ([x]\n          ;;     (prlabel write x (getf :mode))\n          (condp = (class x)\n            String \n            (let [^String s0 (write-initial-lines this x)\n                  ^String s (.replaceFirst s0 \"\\\\s+$\" \"\")\n                  white-space (.substring s0 (count s))\n                  mode (getf :mode)]\n              (dosync\n               (if (= mode :writing)\n                 (do\n                   (write-white-space this)\n                   (.write (getf :base) s)\n                   (setf :trailing-white-space white-space))\n                 (let [oldpos (getf :pos)\n                       newpos (+ oldpos (count s0))]\n                   (setf :pos newpos)\n                   (add-to-buffer this (make-buffer-blob s white-space oldpos newpos))))))\n\n            Integer\n            (p-write-char this x)\n            Long\n            (p-write-char this x))))\n\n      (ppflush []\n             (if (= (getf :mode) :buffering)\n               (dosync\n                (write-tokens this (getf :buffer) true)\n                (setf :buffer []))\n               (write-white-space this)))\n\n      (flush []\n             (.ppflush this)\n             (.flush (getf :base)))\n\n      (close []\n             (.flush this)))))\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Methods for pretty-writer\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn- start-block \n  [^Writer this \n   ^String prefix ^String per-line-prefix ^String suffix]\n  (dosync \n   (let [lb (struct logical-block (getf :logical-blocks) nil (ref 0) (ref 0)\n                    (ref false) (ref false)\n                    prefix per-line-prefix suffix)]\n     (setf :logical-blocks lb)\n     (if (= (getf :mode) :writing)\n       (do\n         (write-white-space this)\n          (when-let [cb (getf :logical-block-callback)] (cb :start))\n          (if prefix \n           (.write (getf :base) prefix))\n         (let [col (get-column (getf :base))]\n           (ref-set (:start-col lb) col)\n           (ref-set (:indent lb) col)))\n       (let [oldpos (getf :pos)\n             newpos (+ oldpos (if prefix (count prefix) 0))]\n         (setf :pos newpos)\n         (add-to-buffer this (make-start-block-t lb oldpos newpos)))))))\n\n(defn- end-block [^Writer this]\n  (dosync\n   (let [lb (getf :logical-blocks)\n         ^String suffix (:suffix lb)]\n     (if (= (getf :mode) :writing)\n       (do\n         (write-white-space this)\n         (if suffix\n           (.write (getf :base) suffix))\n         (when-let [cb (getf :logical-block-callback)] (cb :end)))\n       (let [oldpos (getf :pos)\n             newpos (+ oldpos (if suffix (count suffix) 0))]\n         (setf :pos newpos)\n         (add-to-buffer this (make-end-block-t lb oldpos newpos))))\n     (setf :logical-blocks (:parent lb)))))\n\n(defn- nl [^Writer this type]\n  (dosync \n   (setf :mode :buffering)\n   (let [pos (getf :pos)]\n     (add-to-buffer this (make-nl-t type (getf :logical-blocks) pos pos)))))\n\n(defn- indent [^Writer this relative-to offset]\n  (dosync \n   (let [lb (getf :logical-blocks)]\n     (if (= (getf :mode) :writing)\n       (do\n         (write-white-space this)\n         (ref-set (:indent lb) \n                  (+ offset (condp = relative-to\n\t\t\t      :block @(:start-col lb)\n\t\t\t      :current (get-column (getf :base))))))\n       (let [pos (getf :pos)]\n         (add-to-buffer this (make-indent-t lb relative-to offset pos pos)))))))\n\n(defn- get-miser-width [^Writer this]\n  (getf :miser-width))\n\n(defn- set-miser-width [^Writer this new-miser-width]\n  (dosync (setf :miser-width new-miser-width)))\n\n(defn- set-logical-block-callback [^Writer this f]\n  (dosync (setf :logical-block-callback f)))\n"
  },
  {
    "path": "src/clj/clojure/pprint/print_table.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(in-ns 'clojure.pprint)\n\n(defn print-table\n  \"Prints a collection of maps in a textual table. Prints table headings\n   ks, and then a line of output for each row, corresponding to the keys\n   in ks. If ks are not specified, use the keys of the first item in rows.\"\n  {:added \"1.3\"}\n  ([ks rows]\n     (when (seq rows)\n       (let [widths (map\n                     (fn [k]\n                       (apply max (count (str k)) (map #(count (str (get % k))) rows)))\n                     ks)\n             spacers (map #(apply str (repeat % \"-\")) widths)\n             fmts (map #(str \"%\" % \"s\") widths)\n             fmt-row (fn [leader divider trailer row]\n                       (str leader\n                            (apply str (interpose divider\n                                                  (for [[col fmt] (map vector (map #(get row %) ks) fmts)]\n                                                    (format fmt (str col)))))\n                            trailer))]\n         (println)\n         (println (fmt-row \"| \" \" | \" \" |\" (zipmap ks ks)))\n         (println (fmt-row \"|-\" \"-+-\" \"-|\" (zipmap ks spacers)))\n         (doseq [row rows]\n           (println (fmt-row \"| \" \" | \" \" |\" row))))))\n  ([rows] (print-table (keys (first rows)) rows)))\n"
  },
  {
    "path": "src/clj/clojure/pprint/utilities.clj",
    "content": ";;; utilities.clj -- part of the pretty printer for Clojure\n\n;   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Tom Faulhaber\n;; April 3, 2009\n\n;; This module implements some utility function used in formatting and pretty\n;; printing. The functions here could go in a more general purpose library,\n;; perhaps.\n\n(in-ns 'clojure.pprint)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; Helper functions for digesting formats in the various\n;;; phases of their lives.\n;;; These functions are actually pretty general.\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn- map-passing-context [func initial-context lis]\n  (loop [context initial-context\n         lis lis\n         acc []]\n    (if (empty? lis)\n      [acc context]\n    (let [this (first lis)\n          remainder (next lis)\n          [result new-context] (apply func [this context])]\n      (recur new-context remainder (conj acc result))))))\n\n(defn- consume [func initial-context]\n  (loop [context initial-context\n         acc []]\n    (let [[result new-context] (apply func [context])]\n      (if (not result)\n        [acc new-context]\n      (recur new-context (conj acc result))))))\n\n(defn- consume-while [func initial-context]\n  (loop [context initial-context\n         acc []]\n    (let [[result continue new-context] (apply func [context])]\n      (if (not continue)\n        [acc context]\n      (recur new-context (conj acc result))))))\n\n(defn- unzip-map [m]\n  \"Take a  map that has pairs in the value slots and produce a pair of maps, \n   the first having all the first elements of the pairs and the second all \n   the second elements of the pairs\"\n  [(into {} (for [[k [v1 v2]] m] [k v1]))\n   (into {} (for [[k [v1 v2]] m] [k v2]))])\n\n(defn- tuple-map [m v1]\n  \"For all the values, v, in the map, replace them with [v v1]\"\n  (into {} (for [[k v] m] [k [v v1]])))\n\n(defn- rtrim [s c]\n  \"Trim all instances of c from the end of sequence s\"\n  (let [len (count s)]\n    (if (and (pos? len) (= (nth s (dec (count s))) c))\n      (loop [n (dec len)]\n        (cond \n         (neg? n) \"\"\n         (not (= (nth s n) c)) (subs s 0 (inc n))\n         true (recur (dec n))))\n      s)))\n\n(defn- ltrim [s c]\n  \"Trim all instances of c from the beginning of sequence s\"\n  (let [len (count s)]\n    (if (and (pos? len) (= (nth s 0) c))\n      (loop [n 0]\n        (if (or (= n len) (not (= (nth s n) c)))\n          (subs s n)\n          (recur (inc n))))\n      s)))\n\n(defn- prefix-count [aseq val]\n  \"Return the number of times that val occurs at the start of sequence aseq, \nif val is a seq itself, count the number of times any element of val occurs at the\nbeginning of aseq\"\n  (let [test (if (coll? val) (set val) #{val})]\n    (loop [pos 0]\n     (if (or (= pos (count aseq)) (not (test (nth aseq pos))))\n       pos\n       (recur (inc pos))))))\n\n(defn- prerr [& args]\n  \"Println to *err*\"\n  (binding [*out* *err*]\n    (apply println args)))\n       \n(defmacro ^{:private true} prlabel [prefix arg & more-args]\n  \"Print args to *err* in name = value format\"\n  `(prerr ~@(cons (list 'quote prefix) (mapcat #(list (list 'quote %) \"=\" %) \n                                                  (cons arg (seq more-args))))))\n\n;; Flush the pretty-print buffer without flushing the underlying stream\n(definterface PrettyFlush\n  (^void ppflush []))\n"
  },
  {
    "path": "src/clj/clojure/pprint.clj",
    "content": ";;; pprint.clj -- Pretty printer and Common Lisp compatible format function (cl-format) for Clojure\n\n;   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Tom Faulhaber\n;; April 3, 2009\n\n(ns \n    ^{:author \"Tom Faulhaber\",\n      :doc \"A Pretty Printer for Clojure\n\nclojure.pprint implements a flexible system for printing structured data\nin a pleasing, easy-to-understand format. Basic use of the pretty printer is \nsimple, just call pprint instead of println. More advanced users can use \nthe building blocks provided to create custom output formats. \n\nOut of the box, pprint supports a simple structured format for basic data \nand a specialized format for Clojure source code. More advanced formats, \nincluding formats that don't look like Clojure data at all like XML and \nJSON, can be rendered by creating custom dispatch functions. \n\nIn addition to the pprint function, this module contains cl-format, a text \nformatting function which is fully compatible with the format function in \nCommon Lisp. Because pretty printing directives are directly integrated with\ncl-format, it supports very concise custom dispatch. It also provides\na more powerful alternative to Clojure's standard format function.\n\nSee documentation for pprint and cl-format for more information or \ncomplete documentation on the the clojure web site on github.\",\n       :added \"1.2\"}\n    clojure.pprint\n    (:refer-clojure :exclude (deftype))\n    (:use [clojure.walk :only [walk]]))\n\n\n(load \"pprint/utilities\")\n(load \"pprint/column_writer\")\n(load \"pprint/pretty_writer\")\n(load \"pprint/pprint_base\")\n(load \"pprint/cl_format\")\n(load \"pprint/dispatch\")\n(load \"pprint/print_table\")\n\nnil\n"
  },
  {
    "path": "src/clj/clojure/reflect/java.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Java-specific parts of clojure.reflect\n(in-ns 'clojure.reflect)\n\n(require '[clojure.set :as set]\n         '[clojure.string :as str])\n(import '[clojure.asm ClassReader ClassVisitor Type Opcodes]\n         '[java.lang.reflect Modifier]\n         java.io.InputStream)\n\n(extend-protocol TypeReference\n  clojure.lang.Symbol\n  (typename [s] (str/replace (str s) \"<>\" \"[]\"))\n  \n  Class\n  ;; neither .getName not .getSimpleName returns the right thing, so best to delegate to Type\n  (typename\n   [c]\n   (typename (Type/getType c)))\n  \n  Type\n  (typename\n   [t]\n   (-> (.getClassName t))))\n\n(defn- typesym\n  \"Given a typeref, create a legal Clojure symbol version of the\n   type's name.\"\n  [t]\n  (-> (typename t)\n      (str/replace \"[]\" \"<>\")\n      (symbol)))\n\n(defn- resource-name\n  \"Given a typeref, return implied resource name. Used by Reflectors\n   such as ASM that need to find and read classbytes from files.\"\n  [typeref]\n  (-> (typename typeref)\n      (str/replace \".\" \"/\")\n      (str \".class\")))\n\n(defn- access-flag\n  [[name flag & contexts]]\n  {:name name :flag flag :contexts (set (map keyword contexts))})\n\n(defn- field-descriptor->class-symbol\n  \"Convert a Java field descriptor to a Clojure class symbol. Field\n   descriptors are described in section 4.3.2 of the JVM spec, 2nd ed.:\n   http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#14152\"\n  [^String d]\n  {:pre [(string? d)]}\n  (typesym (Type/getType d)))\n\n(defn- internal-name->class-symbol\n  \"Convert a Java internal name to a Clojure class symbol. Internal\n   names uses slashes instead of dots, e.g. java/lang/String. See\n   Section 4.2 of the JVM spec, 2nd ed.:\n\n   http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#14757\"\n  [d]\n  {:pre [(string? d)]}\n  (typesym (Type/getObjectType d)))\n\n(def ^{:doc \"The Java access bitflags, along with their friendly names and\nthe kinds of objects to which they can apply.\"}\n  flag-descriptors\n  (vec\n   (map access-flag\n        [[:public 0x0001 :class :field :method]\n         [:private 0x002 :class :field :method]\n         [:protected 0x0004  :class :field :method]\n         [:static 0x0008  :field :method]\n         [:final 0x0010  :class :field :method]\n         ;; :super is ancient history and is unfindable (?) by\n         ;; reflection. skip it\n         #_[:super 0x0020  :class]        \n         [:synchronized 0x0020  :method]\n         [:volatile 0x0040  :field]\n         [:bridge 0x0040  :method]\n         [:varargs 0x0080  :method]\n         [:transient 0x0080  :field]\n         [:native 0x0100  :method]\n         [:interface 0x0200  :class]\n         [:abstract 0x0400  :class :method]\n         [:strict 0x0800  :method]\n         [:synthetic 0x1000  :class :field :method]\n         [:annotation 0x2000  :class]\n         [:enum 0x4000  :class :field :inner]])))\n\n(defn- parse-flags\n  \"Convert reflection bitflags into a set of keywords.\"\n  [flags context]\n  (reduce\n   (fn [result fd]\n     (if (and (get (:contexts fd) context)\n              (not (zero? (bit-and flags (:flag fd)))))\n       (conj result (:name fd))\n       result))\n   #{}\n   flag-descriptors))\n\n(defrecord Constructor\n  [name declaring-class parameter-types exception-types flags])\n\n(defn- constructor->map\n  [^java.lang.reflect.Constructor constructor]\n  (Constructor.\n   (symbol (.getName constructor))\n   (typesym (.getDeclaringClass constructor))\n   (vec (map typesym (.getParameterTypes constructor)))\n   (vec (map typesym (.getExceptionTypes constructor)))\n   (parse-flags (.getModifiers constructor) :method)))\n\n(defn- declared-constructors\n  \"Return a set of the declared constructors of class as a Clojure map.\"\n  [^Class cls]\n  (set (map\n        constructor->map\n        (.getDeclaredConstructors cls))))\n\n(defrecord Method\n  [name return-type declaring-class parameter-types exception-types flags])\n\n(defn- method->map\n  [^java.lang.reflect.Method method]\n  (Method.\n   (symbol (.getName method))\n   (typesym (.getReturnType method))\n   (typesym (.getDeclaringClass method))\n   (vec (map typesym (.getParameterTypes method)))\n   (vec (map typesym (.getExceptionTypes method)))\n   (parse-flags (.getModifiers method) :method)))\n\n(defn- declared-methods\n  \"Return a set of the declared constructors of class as a Clojure map.\"\n  [^Class cls]\n  (set (map\n        method->map\n        (.getDeclaredMethods cls))))\n\n(defrecord Field\n  [name type declaring-class flags])\n\n(defn- field->map\n  [^java.lang.reflect.Field field]\n  (Field.\n   (symbol (.getName field))\n   (typesym (.getType field))\n   (typesym (.getDeclaringClass field))\n   (parse-flags (.getModifiers field) :field)))\n\n(defn- declared-fields\n  \"Return a set of the declared fields of class as a Clojure map.\"\n  [^Class cls]\n  (set (map\n        field->map\n        (.getDeclaredFields cls))))\n\n(deftype JavaReflector [classloader]\n  Reflector\n  (do-reflect [_ typeref]\n           (let [cls (clojure.lang.RT/classForName (typename typeref) false classloader)]\n             {:bases (not-empty (set (map typesym (bases cls))))\n              :flags (parse-flags (.getModifiers cls) :class)\n              :members (set/union (declared-fields cls)\n                                  (declared-methods cls)\n                                  (declared-constructors cls))})))\n\n(def ^:private default-reflector\n     (JavaReflector. (.getContextClassLoader (Thread/currentThread))))\n\n(defn- parse-method-descriptor\n  [^String md]\n  {:parameter-types (vec (map typesym (Type/getArgumentTypes md)))\n   :return-type (typesym (Type/getReturnType md))})\n\n(defprotocol ClassResolver\n  (^InputStream resolve-class [this name]\n                \"Given a class name, return that typeref's class bytes as an InputStream.\"))\n\n(extend-protocol ClassResolver\n  clojure.lang.Fn\n  (resolve-class [this typeref] (this typeref))\n  \n  ClassLoader\n  (resolve-class [this typeref]\n                 (.getResourceAsStream this (resource-name typeref))))\n\n(deftype AsmReflector [class-resolver]\n  Reflector\n  (do-reflect [_ typeref]\n    (with-open [is (resolve-class class-resolver typeref)]\n      (let [class-symbol (typesym typeref)\n            r (ClassReader. is)\n            result (atom {:bases #{} :flags #{} :members #{}})]\n        (.accept\n         r\n         (proxy\n          [ClassVisitor]\n          [Opcodes/ASM4]\n          (visit [version access name signature superName interfaces]\n                 (let [flags (parse-flags access :class)\n                       ;; ignore java.lang.Object on interfaces to match reflection\n                       superName (if (and (flags :interface)\n                                          (= superName \"java/lang/Object\"))\n                                   nil\n                                   superName)\n                       bases (->> (cons superName interfaces)\n                                  (remove nil?)\n                                  (map internal-name->class-symbol)\n                                  (map symbol)\n                                  (set)\n                                  (not-empty))]\n                   (swap! result merge {:bases bases \n                                        :flags flags})))\n          (visitAnnotation [desc visible])\n          (visitSource [name debug])\n          (visitInnerClass [name outerName innerName access])\n          (visitField [access name desc signature value]\n                      (swap! result update :members (fnil conj #{})\n                             (Field. (symbol name)\n                                     (field-descriptor->class-symbol desc)\n                                     class-symbol\n                                     (parse-flags access :field)))\n                      nil)\n          (visitMethod [access name desc signature exceptions]\n                       (when-not (= name \"<clinit>\")\n                         (let [constructor? (= name \"<init>\")]\n                           (swap! result update :members (fnil conj #{})\n                                  (let [{:keys [parameter-types return-type]} (parse-method-descriptor desc)\n                                        flags (parse-flags access :method)]\n                                    (if constructor?\n                                      (Constructor. class-symbol\n                                                    class-symbol\n                                                    parameter-types\n                                                    (vec (map internal-name->class-symbol exceptions))\n                                                    flags)\n                                      (Method. (symbol name)\n                                               return-type\n                                               class-symbol\n                                               parameter-types\n                                               (vec (map internal-name->class-symbol exceptions))\n                                               flags))))))\n                       nil)\n          (visitEnd [])\n          ) 0)\n        @result))))\n\n"
  },
  {
    "path": "src/clj/clojure/reflect.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns ^{:author \"Stuart Halloway\"\n      :added \"1.3\"\n      :doc \"Reflection on Host Types\nAlpha - subject to change.\n\nTwo main entry points: \n\n* type-reflect reflects on something that implements TypeReference.\n* reflect (for REPL use) reflects on the class of an instance, or\n  on a class if passed a class\n\nKey features:\n\n* Exposes the read side of reflection as pure data. Reflecting\n  on a type returns a map with keys :bases, :flags, and :members.\n\n* Canonicalizes class names as Clojure symbols. Types can extend\n  to the TypeReference protocol to indicate that they can be\n  unambiguously resolved as a type name. The canonical format\n  requires one non-Java-ish convention: array brackets are <>\n  instead of [] so they can be part of a Clojure symbol.\n\n* Pluggable Reflectors for different implementations. The default\n  JavaReflector is good when you have a class in hand, or use\n  the AsmReflector for \\\"hands off\\\" reflection without forcing\n  classes to load.\n\nPlatform implementers must:\n\n* Create an implementation of Reflector.\n* Create one or more implementations of TypeReference.\n* def default-reflector to be an instance that satisfies Reflector.\"}\n  clojure.reflect\n  (:require [clojure.set :as set]))\n\n(defprotocol Reflector\n  \"Protocol for reflection implementers.\"\n  (do-reflect [reflector typeref]))\n\n(defprotocol TypeReference\n  \"A TypeReference can be unambiguously converted to a type name on\n   the host platform.\n\n   All typerefs are normalized into symbols. If you need to\n   normalize a typeref yourself, call typesym.\"\n  (typename [o] \"Returns Java name as returned by ASM getClassName, e.g. byte[], java.lang.String[]\"))\n\n(declare default-reflector)\n\n(defn type-reflect\n  \"Alpha - subject to change.\n   Reflect on a typeref, returning a map with :bases, :flags, and\n  :members. In the discussion below, names are always Clojure symbols.\n\n   :bases            a set of names of the type's bases\n   :flags            a set of keywords naming the boolean attributes\n                     of the type.\n   :members          a set of the type's members. Each member is a map\n                     and can be a constructor, method, or field.\n\n   Keys common to all members:\n   :name             name of the type \n   :declaring-class  name of the declarer\n   :flags            keyword naming boolean attributes of the member\n\n   Keys specific to constructors:\n   :parameter-types  vector of parameter type names\n   :exception-types  vector of exception type names\n\n   Key specific to methods:\n   :parameter-types  vector of parameter type names\n   :exception-types  vector of exception type names\n   :return-type      return type name\n\n   Keys specific to fields:\n   :type             type name\n\n   Options:\n\n     :ancestors     in addition to the keys described above, also\n                    include an :ancestors key with the entire set of\n                    ancestors, and add all ancestor members to\n                    :members.\n     :reflector     implementation to use. Defaults to JavaReflector,\n                    AsmReflector is also an option.\"\n  {:added \"1.3\"}\n  [typeref & options]\n  (let [{:keys [ancestors reflector]}\n        (merge {:reflector default-reflector}\n               (apply hash-map options))\n        refl (partial do-reflect reflector)\n        result (refl typeref)]\n    ;; could make simpler loop of two args: names an\n    (if ancestors\n      (let [make-ancestor-map (fn [names]\n                            (zipmap names (map refl names)))]\n        (loop [reflections (make-ancestor-map (:bases result))]\n          (let [ancestors-visited (set (keys reflections))\n                ancestors-to-visit (set/difference (set (mapcat :bases (vals reflections)))\n                                               ancestors-visited)]\n            (if (seq ancestors-to-visit)\n              (recur (merge reflections (make-ancestor-map ancestors-to-visit)))\n              (apply merge-with into result {:ancestors ancestors-visited}\n                     (map #(select-keys % [:members]) (vals reflections)))))))\n      result)))\n\n(defn reflect\n  \"Alpha - subject to change.\n   Reflect on the type of obj (or obj itself if obj is a class).\n   Return value and options are the same as for type-reflect. \"\n  {:added \"1.3\"}\n  [obj & options]\n  (apply type-reflect (if (class? obj) obj (class obj)) options))\n\n(load \"reflect/java\")\n"
  },
  {
    "path": "src/clj/clojure/remoterepl.clj",
    "content": "(ns clojure.remoterepl\n  (:import [java.net ServerSocket Socket]\n           [clojure.lang LineNumberingPushbackReader]\n           [java.io PrintWriter InputStreamReader OutputStreamWriter]))\n\n(defn uuid [] (str (java.util.UUID/randomUUID)))\n\n(def server1 (atom nil))\n(def server2 (atom nil))\n(def repl-main-thread (atom nil))\n(def socket (atom nil))\n(def socket1 (atom nil))\n(def socket2 (atom nil))\n\n(defn socket-println [s d]\n  (let [c (str (count (.getBytes d \"UTF-8\")))]\n    (.println s \n      (str \n        (apply str (for [n (range (- 10 (count c)))] \" \")) \n        c))\n    (.println s d)))\n\n(defn process-msg [out f]\n  (let [[run-in-main id f args] f]\n    (->> [id (binding [force-main-thread true]\n               (apply f args))]\n         pr-str \n         (socket-println out))))\n\n(defn call-remote [sel args]\n  (let [args (vec args)\n        id (keyword (uuid))]\n    (socket-println (:out @socket)\n              (pr-str [(or (= (Thread/currentThread) @repl-main-thread) force-main-thread)\n                       id sel args]))\n    (loop [msg (read (:in @socket))]\n      (if (instance? String msg)\n        (throw (Exception. msg))\n        (if (= 2 (count msg))\n          (let [[rid r] msg]\n            (if (= rid id)\n              r\n              (do\n                (socket-println (:out @socket) (pr-str [:retry id]))\n                                        ; retries until the sender gets the response\n                (recur (read (:in @socket))))))\n          (do\n            (process-msg (:out @socket) msg)\n            (recur (read (:in @socket)))))))))\n\n(defn start-remote-repl []\n  (clojure.lang.RemoteRef/reset)\n  (let [s (.accept @server1)\n        s2 (.accept @server2)\n        out (PrintWriter. (.getOutputStream s) true)\n        in (LineNumberingPushbackReader. (InputStreamReader. (.getInputStream s)))\n        out2 (PrintWriter. (.getOutputStream s2) true)\n        in2 (LineNumberingPushbackReader. (InputStreamReader. (.getInputStream s2)))]\n    (clojure.lang.RemoteRepl/setConnected true)\n    (reset! socket {:out out :in in})\n    (reset! socket1 {:out out :in in})      \n    (reset! socket2 {:out out2 :in in2})\n    (future\n      (try\n        (loop [f (read in2)]\n          (let [s @socket]\n            (reset! socket @socket2)\n            (process-msg out2 f)\n            (reset! socket s))\n          (recur (read in2)))\n        (catch Exception e\n          (println \"REPL DISCONNECTED\")\n          (.printStackTrace e)\n          (.close s)\n          (.close s2)\n          (start-remote-repl))))))\n\n(defn connected? []\n  clojure.lang.RemoteRepl/connected)\n\n(defn listen []\n  (reset! repl-main-thread (Thread/currentThread))\n  (reset! server1 (ServerSocket. 35813))\n  (reset! server2 (ServerSocket. 35814))\n  (start-remote-repl))\n"
  },
  {
    "path": "src/clj/clojure/repl.clj",
    "content": ";   Copyright (c) Chris Houser, Dec 2008. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Common Public License 1.0 (http://opensource.org/licenses/cpl.php)\n;   which can be found in the file CPL.TXT at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Utilities meant to be used interactively at the REPL\n\n(ns\n  ^{:author \"Chris Houser, Christophe Grand, Stephen Gilardi, Michel Salim\"\n    :doc \"Utilities meant to be used interactively at the REPL\"}\n  clojure.repl\n  (:import (java.io LineNumberReader InputStreamReader PushbackReader)\n           (clojure.lang RT Reflector)))\n\n(def ^:private special-doc-map\n  '{. {:url \"java_interop#dot\"\n       :forms [(.instanceMember instance args*)\n               (.instanceMember Classname args*)\n               (Classname/staticMethod args*)\n               Classname/staticField]\n       :doc \"The instance member form works for both fields and methods.\n  They all expand into calls to the dot operator at macroexpansion time.\"}\n    def {:forms [(def symbol doc-string? init?)]\n         :doc \"Creates and interns a global var with the name\n  of symbol in the current namespace (*ns*) or locates such a var if\n  it already exists.  If init is supplied, it is evaluated, and the\n  root binding of the var is set to the resulting value.  If init is\n  not supplied, the root binding of the var is unaffected.\"}\n    do {:forms [(do exprs*)]\n        :doc \"Evaluates the expressions in order and returns the value of\n  the last. If no expressions are supplied, returns nil.\"}\n    if {:forms [(if test then else?)]\n        :doc \"Evaluates test. If not the singular values nil or false,\n  evaluates and yields then, otherwise, evaluates and yields else. If\n  else is not supplied it defaults to nil.\"}\n    monitor-enter {:forms [(monitor-enter x)]\n                   :doc \"Synchronization primitive that should be avoided\n  in user code. Use the 'locking' macro.\"}\n    monitor-exit {:forms [(monitor-exit x)]\n                  :doc \"Synchronization primitive that should be avoided\n  in user code. Use the 'locking' macro.\"}\n    new {:forms [(Classname. args*) (new Classname args*)]\n         :url \"java_interop#new\"\n         :doc \"The args, if any, are evaluated from left to right, and\n  passed to the constructor of the class named by Classname. The\n  constructed object is returned.\"}\n    quote {:forms [(quote form)]\n           :doc \"Yields the unevaluated form.\"}\n    recur {:forms [(recur exprs*)]\n           :doc \"Evaluates the exprs in order, then, in parallel, rebinds\n  the bindings of the recursion point to the values of the exprs.\n  Execution then jumps back to the recursion point, a loop or fn method.\"}\n    set! {:forms[(set! var-symbol expr)\n                 (set! (. instance-expr instanceFieldName-symbol) expr)\n                 (set! (. Classname-symbol staticFieldName-symbol) expr)]\n          :url \"vars#set\"\n          :doc \"Used to set thread-local-bound vars, Java object instance\nfields, and Java class static fields.\"}\n    throw {:forms [(throw expr)]\n           :doc \"The expr is evaluated and thrown, therefore it should\n  yield an instance of some derivee of Throwable.\"}\n    try {:forms [(try expr* catch-clause* finally-clause?)]\n         :doc \"catch-clause => (catch classname name expr*)\n  finally-clause => (finally expr*)\n\n  Catches and handles Java exceptions.\"}\n    var {:forms [(var symbol)]\n         :doc \"The symbol must resolve to a var, and the Var object\nitself (not its value) is returned. The reader macro #'x expands to (var x).\"}})\n\n(defn- special-doc [name-symbol]\n  (assoc (or (special-doc-map name-symbol) (meta (resolve name-symbol)))\n         :name name-symbol\n         :special-form true))\n\n(defn- namespace-doc [nspace]\n  (assoc (meta nspace) :name (ns-name nspace)))\n\n(defn- print-doc [m]\n  (println \"-------------------------\")\n  (println (str (when-let [ns (:ns m)] (str (ns-name ns) \"/\")) (:name m)))\n  (cond\n    (:forms m) (doseq [f (:forms m)]\n                 (print \"  \")\n                 (prn f))\n    (:arglists m) (prn (:arglists m)))\n  (if (:special-form m)\n    (do\n      (println \"Special Form\")\n      (println \" \" (:doc m)) \n      (if (contains? m :url)\n        (when (:url m)\n          (println (str \"\\n  Please see http://clojure.org/\" (:url m))))\n        (println (str \"\\n  Please see http://clojure.org/special_forms#\"\n                      (:name m)))))\n    (do\n      (when (:macro m)\n        (println \"Macro\")) \n      (println \" \" (:doc m)))))\n\n(defn find-doc\n  \"Prints documentation for any var whose documentation or name\n contains a match for re-string-or-pattern\"\n  {:added \"1.0\"}\n  [re-string-or-pattern]\n    (let [re (re-pattern re-string-or-pattern)\n          ms (concat (mapcat #(sort-by :name (map meta (vals (ns-interns %))))\n                             (all-ns))\n                     (map namespace-doc (all-ns))\n                     (map special-doc (keys special-doc-map)))]\n      (doseq [m ms\n              :when (and (:doc m)\n                         (or (re-find (re-matcher re (:doc m)))\n                             (re-find (re-matcher re (str (:name m))))))]\n               (print-doc m))))\n\n(defmacro doc\n  \"Prints documentation for a var or special form given its name\"\n  {:added \"1.0\"}\n  [name]\n  (if-let [special-name ('{& fn catch try finally try} name)]\n    (#'print-doc (#'special-doc special-name))\n    (cond\n      (special-doc-map name) `(#'print-doc (#'special-doc '~name))\n      (find-ns name) `(#'print-doc (#'namespace-doc (find-ns '~name)))\n      (resolve name) `(#'print-doc (meta (var ~name))))))\n\n;; ----------------------------------------------------------------------\n;; Examine Clojure functions (Vars, really)\n\n(defn source-fn\n  \"Returns a string of the source code for the given symbol, if it can\n  find it.  This requires that the symbol resolve to a Var defined in\n  a namespace for which the .clj is in the classpath.  Returns nil if\n  it can't find the source.  For most REPL usage, 'source' is more\n  convenient.\n\n  Example: (source-fn 'filter)\"\n  [x]\n  (when-let [v (resolve x)]\n    (when-let [filepath (:file (meta v))]\n      (when-let [strm (.getResourceAsStream (RT/baseLoader) filepath)]\n        (with-open [rdr (LineNumberReader. (InputStreamReader. strm))]\n          (dotimes [_ (dec (:line (meta v)))] (.readLine rdr))\n          (let [text (StringBuilder.)\n                pbr (proxy [PushbackReader] [rdr]\n                      (read [] (let [i (proxy-super read)]\n                                 (.append text (char i))\n                                 i)))\n                read-opts (if (.endsWith ^String filepath \"cljc\") {:read-cond :allow} {})]\n            (if (= :unknown *read-eval*)\n              (throw (IllegalStateException. \"Unable to read source while *read-eval* is :unknown.\"))\n              (read read-opts (PushbackReader. pbr)))\n            (str text)))))))\n\n(defmacro source\n  \"Prints the source code for the given symbol, if it can find it.\n  This requires that the symbol resolve to a Var defined in a\n  namespace for which the .clj is in the classpath.\n\n  Example: (source filter)\"\n  [n]\n  `(println (or (source-fn '~n) (str \"Source not found\"))))\n\n(defn apropos\n  \"Given a regular expression or stringable thing, return a seq of all\npublic definitions in all currently-loaded namespaces that match the\nstr-or-pattern.\"\n  [str-or-pattern]\n  (let [matches? (if (instance? java.util.regex.Pattern str-or-pattern)\n                   #(re-find str-or-pattern (str %))\n                   #(.contains (str %) (str str-or-pattern)))]\n    (sort (mapcat (fn [ns]\n                    (let [ns-name (str ns)]\n                      (map #(symbol ns-name (str %))\n                           (filter matches? (keys (ns-publics ns))))))\n                  (all-ns)))))\n\n(defn dir-fn\n  \"Returns a sorted seq of symbols naming public vars in\n  a namespace\"\n  [ns]\n  (sort (map first (ns-publics (the-ns ns)))))\n\n(defmacro dir\n  \"Prints a sorted directory of public vars in a namespace\"\n  [nsname]\n  `(doseq [v# (dir-fn '~nsname)]\n     (println v#)))\n\n(defn demunge\n  \"Given a string representation of a fn class,\n  as in a stack trace element, returns a readable version.\"\n  {:added \"1.3\"}\n  [fn-name]\n  (clojure.lang.Compiler/demunge fn-name))\n\n(defn root-cause\n  \"Returns the initial cause of an exception or error by peeling off all of\n  its wrappers\"\n  {:added \"1.3\"}\n  [^Throwable t]\n  (loop [cause t]\n    (if (and (instance? clojure.lang.Compiler$CompilerException cause)\n             (not= (.source ^clojure.lang.Compiler$CompilerException cause) \"NO_SOURCE_FILE\"))\n      cause\n      (if-let [cause (.getCause cause)]\n        (recur cause)\n        cause))))\n\n(defn stack-element-str\n  \"Returns a (possibly unmunged) string representation of a StackTraceElement\"\n  {:added \"1.3\"}\n  [^StackTraceElement el]\n  (let [file (.getFileName el)\n        clojure-fn? (and file (or (.endsWith file \".clj\")\n                                  (.endsWith file \".cljc\")\n                                  (= file \"NO_SOURCE_FILE\")))]\n    (str (if clojure-fn?\n           (demunge (.getClassName el))\n           (str (.getClassName el) \".\" (.getMethodName el)))\n         \" (\" (.getFileName el) \":\" (.getLineNumber el) \")\")))\n\n(defn pst\n  \"Prints a stack trace of the exception, to the depth requested. If none supplied, uses the root cause of the\n  most recent repl exception (*e), and a depth of 12.\"\n  {:added \"1.3\"}\n  ([] (pst 12))\n  ([e-or-depth]\n     (if (instance? Throwable e-or-depth)\n       (pst e-or-depth 12)\n       (when-let [e *e]\n         (pst (root-cause e) e-or-depth))))\n  ([^Throwable e depth]\n     (binding [*out* *err*]\n       (println (str (-> e class .getSimpleName) \" \"\n                     (.getMessage e)\n                     (when-let [info (ex-data e)] (str \" \" (pr-str info)))))\n       (let [st (.getStackTrace e)\n             cause (.getCause e)]\n         (doseq [el (take depth\n                          (remove #(#{\"clojure.lang.RestFn\" \"clojure.lang.AFn\"} (.getClassName %))\n                                  st))]\n           (println (str \\tab (stack-element-str el))))\n         (when cause\n           (println \"Caused by:\")\n           (pst cause (min depth\n                           (+ 2 (- (count (.getStackTrace cause))\n                                   (count st))))))))))\n\n;; ----------------------------------------------------------------------\n;; Handle Ctrl-C keystrokes\n\n(defn thread-stopper\n  \"Returns a function that takes one arg and uses that as an exception message\n  to stop the given thread.  Defaults to the current thread\"\n  ([] (thread-stopper (Thread/currentThread)))\n  ([thread] (fn [msg] (.stop thread (Error. msg)))))\n\n(defn set-break-handler!\n  \"Register INT signal handler.  After calling this, Ctrl-C will cause\n  the given function f to be called with a single argument, the signal.\n  Uses thread-stopper if no function given.\"\n  ([] (set-break-handler! (thread-stopper)))\n  ([f]\n   (sun.misc.Signal/handle\n     (sun.misc.Signal. \"INT\")\n     (proxy [sun.misc.SignalHandler] []\n       (handle [signal]\n         (f (str \"-- caught signal \" signal)))))))\n"
  },
  {
    "path": "src/clj/clojure/set.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns ^{:doc \"Set operations such as union/intersection.\"\n       :author \"Rich Hickey\"}\n       clojure.set)\n\n(defn- bubble-max-key [k coll]\n  \"Move a maximal element of coll according to fn k (which returns a number) \n   to the front of coll.\"\n  (let [max (apply max-key k coll)]\n    (cons max (remove #(identical? max %) coll))))\n\n(defn union\n  \"Return a set that is the union of the input sets\"\n  {:added \"1.0\"}\n  ([] #{})\n  ([s1] s1)\n  ([s1 s2]\n     (if (< (count s1) (count s2))\n       (reduce conj s2 s1)\n       (reduce conj s1 s2)))\n  ([s1 s2 & sets]\n     (let [bubbled-sets (bubble-max-key count (conj sets s2 s1))]\n       (reduce into (first bubbled-sets) (rest bubbled-sets)))))\n\n(defn intersection\n  \"Return a set that is the intersection of the input sets\"\n  {:added \"1.0\"}\n  ([s1] s1)\n  ([s1 s2]\n     (if (< (count s2) (count s1))\n       (recur s2 s1)\n       (reduce (fn [result item]\n                   (if (contains? s2 item)\n\t\t     result\n                     (disj result item)))\n\t       s1 s1)))\n  ([s1 s2 & sets] \n     (let [bubbled-sets (bubble-max-key #(- (count %)) (conj sets s2 s1))]\n       (reduce intersection (first bubbled-sets) (rest bubbled-sets)))))\n\n(defn difference\n  \"Return a set that is the first set without elements of the remaining sets\"\n  {:added \"1.0\"}\n  ([s1] s1)\n  ([s1 s2] \n     (if (< (count s1) (count s2))\n       (reduce (fn [result item] \n                   (if (contains? s2 item) \n                     (disj result item) \n                     result))\n               s1 s1)\n       (reduce disj s1 s2)))\n  ([s1 s2 & sets] \n     (reduce difference s1 (conj sets s2))))\n\n\n(defn select\n  \"Returns a set of the elements for which pred is true\"\n  {:added \"1.0\"}\n  [pred xset]\n    (reduce (fn [s k] (if (pred k) s (disj s k)))\n            xset xset))\n\n(defn project\n  \"Returns a rel of the elements of xrel with only the keys in ks\"\n  {:added \"1.0\"}\n  [xrel ks]\n  (with-meta (set (map #(select-keys % ks) xrel)) (meta xrel)))\n\n(defn rename-keys\n  \"Returns the map with the keys in kmap renamed to the vals in kmap\"\n  {:added \"1.0\"}\n  [map kmap]\n    (reduce \n     (fn [m [old new]]\n       (if (contains? map old)\n         (assoc m new (get map old))\n         m)) \n     (apply dissoc map (keys kmap)) kmap))\n\n(defn rename\n  \"Returns a rel of the maps in xrel with the keys in kmap renamed to the vals in kmap\"\n  {:added \"1.0\"}\n  [xrel kmap]\n  (with-meta (set (map #(rename-keys % kmap) xrel)) (meta xrel)))\n\n(defn index\n  \"Returns a map of the distinct values of ks in the xrel mapped to a\n  set of the maps in xrel with the corresponding values of ks.\"\n  {:added \"1.0\"}\n  [xrel ks]\n    (reduce\n     (fn [m x]\n       (let [ik (select-keys x ks)]\n         (assoc m ik (conj (get m ik #{}) x))))\n     {} xrel))\n   \n(defn map-invert\n  \"Returns the map with the vals mapped to the keys.\"\n  {:added \"1.0\"}\n  [m] (reduce (fn [m [k v]] (assoc m v k)) {} m))\n\n(defn join\n  \"When passed 2 rels, returns the rel corresponding to the natural\n  join. When passed an additional keymap, joins on the corresponding\n  keys.\"\n  {:added \"1.0\"}\n  ([xrel yrel] ;natural join\n   (if (and (seq xrel) (seq yrel))\n     (let [ks (intersection (set (keys (first xrel))) (set (keys (first yrel))))\n           [r s] (if (<= (count xrel) (count yrel))\n                   [xrel yrel]\n                   [yrel xrel])\n           idx (index r ks)]\n       (reduce (fn [ret x]\n                 (let [found (idx (select-keys x ks))]\n                   (if found\n                     (reduce #(conj %1 (merge %2 x)) ret found)\n                     ret)))\n               #{} s))\n     #{}))\n  ([xrel yrel km] ;arbitrary key mapping\n   (let [[r s k] (if (<= (count xrel) (count yrel))\n                   [xrel yrel (map-invert km)]\n                   [yrel xrel km])\n         idx (index r (vals k))]\n     (reduce (fn [ret x]\n               (let [found (idx (rename-keys (select-keys x (keys k)) k))]\n                 (if found\n                   (reduce #(conj %1 (merge %2 x)) ret found)\n                   ret)))\n             #{} s))))\n\n(defn subset? \n  \"Is set1 a subset of set2?\"\n  {:added \"1.2\",\n   :tag Boolean}\n  [set1 set2]\n  (and (<= (count set1) (count set2))\n       (every? #(contains? set2 %) set1)))\n\n(defn superset? \n  \"Is set1 a superset of set2?\"\n  {:added \"1.2\",\n   :tag Boolean}\n  [set1 set2]\n  (and (>= (count set1) (count set2))\n       (every? #(contains? set1 %) set2)))\n\n(comment\n(refer 'set)\n(def xs #{{:a 11 :b 1 :c 1 :d 4}\n         {:a 2 :b 12 :c 2 :d 6}\n         {:a 3 :b 3 :c 3 :d 8 :f 42}})\n\n(def ys #{{:a 11 :b 11 :c 11 :e 5}\n         {:a 12 :b 11 :c 12 :e 3}\n         {:a 3 :b 3 :c 3 :e 7 }})\n\n(join xs ys)\n(join xs (rename ys {:b :yb :c :yc}) {:a :a})\n\n(union #{:a :b :c} #{:c :d :e })\n(difference #{:a :b :c} #{:c :d :e})\n(intersection #{:a :b :c} #{:c :d :e})\n\n(index ys [:b])\n)\n\n"
  },
  {
    "path": "src/clj/clojure/stacktrace.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;;; stacktrace.clj: print Clojure-centric stack traces\n\n;; by Stuart Sierra\n;; January 6, 2009\n\n(ns ^{:doc \"Print stack traces oriented towards Clojure, not Java.\"\n       :author \"Stuart Sierra\"}\n  clojure.stacktrace)\n\n(defn root-cause\n  \"Returns the last 'cause' Throwable in a chain of Throwables.\"\n  {:added \"1.1\"}\n  [^Throwable tr]\n  (if-let [cause (.getCause tr)]\n    (recur cause)\n    tr))\n\n(defn print-trace-element\n  \"Prints a Clojure-oriented view of one element in a stack trace.\"\n  {:added \"1.1\"}\n  [^StackTraceElement e]\n  (let [class (.getClassName e)\n\tmethod (.getMethodName e)]\n    (let [match (re-matches #\"^([A-Za-z0-9_.-]+)\\$(\\w+)__\\d+$\" (str class))]\n      (if (and match (= \"invoke\" method))\n\t(apply printf \"%s/%s\" (rest match))\n\t(printf \"%s.%s\" class method))))\n  (printf \" (%s:%d)\" (or (.getFileName e) \"\") (.getLineNumber e)))\n\n(defn print-throwable\n  \"Prints the class and message of a Throwable.\"\n  {:added \"1.1\"}\n  [^Throwable tr]\n  (printf \"%s: %s\" (.getName (class tr)) (.getMessage tr)))\n\n(defn print-stack-trace\n  \"Prints a Clojure-oriented stack trace of tr, a Throwable.\n  Prints a maximum of n stack frames (default: unlimited).\n  Does not print chained exceptions (causes).\"\n  {:added \"1.1\"}\n  ([tr] (print-stack-trace tr nil))\n  ([^Throwable tr n]\n     (let [^StackTraceElement st (.getStackTrace tr)]\n       (print-throwable tr)\n       (newline)\n       (print \" at \")\n       (if-let [e (first st)]\n         (print-trace-element e)\n         (print \"[empty stack trace]\"))\n       (newline)\n       (doseq [e (if (nil? n)\n\t\t   (rest st)\n\t\t   (take (dec n) (rest st)))]\n\t (print \"    \")\n\t (print-trace-element e)\n\t (newline)))))\n\n(defn print-cause-trace\n  \"Like print-stack-trace but prints chained exceptions (causes).\"\n  {:added \"1.1\"}\n  ([^Throwable tr] (print-cause-trace tr nil))\n  ([^Throwable tr n]\n     (print-stack-trace tr n)\n     (when-let [cause (.getCause tr)]\n       (print \"Caused by: \" )\n       (recur cause n))))\n\n(defn e\n  \"REPL utility.  Prints a brief stack trace for the root cause of the\n  most recent exception.\"\n  {:added \"1.1\"}\n  []\n  (print-stack-trace (root-cause *e) 8))\n"
  },
  {
    "path": "src/clj/clojure/string.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns ^{:doc \"Clojure String utilities\n\nIt is poor form to (:use clojure.string). Instead, use require\nwith :as to specify a prefix, e.g.\n\n(ns your.namespace.here\n  (:require [clojure.string :as str]))\n\nDesign notes for clojure.string:\n\n1. Strings are objects (as opposed to sequences). As such, the\n   string being manipulated is the first argument to a function;\n   passing nil will result in a NullPointerException unless\n   documented otherwise. If you want sequence-y behavior instead,\n   use a sequence.\n\n2. Functions are generally not lazy, and call straight to host\n   methods where those are available and efficient.\n\n3. Functions take advantage of String implementation details to\n   write high-performing loop/recurs instead of using higher-order\n   functions. (This is not idiomatic in general-purpose application\n   code.)\n\n4. When a function is documented to accept a string argument, it\n   will take any implementation of the correct *interface* on the\n   host platform. In Java, this is CharSequence, which is more\n   general than String. In ordinary usage you will almost always\n   pass concrete strings. If you are doing something unusual,\n   e.g. passing a mutable implementation of CharSequence, then\n   thread-safety is your responsibility.\"\n      :author \"Stuart Sierra, Stuart Halloway, David Liebke\"}\n  clojure.string\n  (:refer-clojure :exclude (replace reverse))\n  (:import (java.util.regex Pattern Matcher)\n           clojure.lang.LazilyPersistentVector))\n\n(defn ^String reverse\n  \"Returns s with its characters reversed.\"\n  {:added \"1.2\"}\n  [^CharSequence s]\n  (.toString (.reverse (StringBuilder. s))))\n\n(defn ^String re-quote-replacement\n  \"Given a replacement string that you wish to be a literal\n   replacement for a pattern match in replace or replace-first, do the\n   necessary escaping of special characters in the replacement.\"\n  {:added \"1.5\"}\n  [^CharSequence replacement]\n  (Matcher/quoteReplacement (.toString ^CharSequence replacement)))\n\n(defn- replace-by\n  [^CharSequence s re f]\n  (let [m (re-matcher re s)]\n    (if (.find m)\n      (let [buffer (StringBuffer. (.length s))]\n        (loop [found true]\n          (if found\n            (do (.appendReplacement m buffer (Matcher/quoteReplacement (f (re-groups m))))\n                (recur (.find m)))\n            (do (.appendTail m buffer)\n                (.toString buffer)))))\n      s)))\n\n(defn ^String replace\n  \"Replaces all instance of match with replacement in s.\n\n   match/replacement can be:\n\n   string / string\n   char / char\n   pattern / (string or function of match).\n\n   See also replace-first.\n\n   The replacement is literal (i.e. none of its characters are treated\n   specially) for all cases above except pattern / string.\n\n   For pattern / string, $1, $2, etc. in the replacement string are\n   substituted with the string that matched the corresponding\n   parenthesized group in the pattern.  If you wish your replacement\n   string r to be used literally, use (re-quote-replacement r) as the\n   replacement argument.  See also documentation for\n   java.util.regex.Matcher's appendReplacement method.\n\n   Example:\n   (clojure.string/replace \\\"Almost Pig Latin\\\" #\\\"\\\\b(\\\\w)(\\\\w+)\\\\b\\\" \\\"$2$1ay\\\")\n   -> \\\"lmostAay igPay atinLay\\\"\"\n  {:added \"1.2\"}\n  [^CharSequence s match replacement]\n  (let [s (.toString s)]\n    (cond\n     (instance? Character match) (.replace s ^Character match ^Character replacement)\n     (instance? CharSequence match) (.replace s ^CharSequence match ^CharSequence replacement)\n     (instance? Pattern match) (if (instance? CharSequence replacement)\n                                 (.replaceAll (re-matcher ^Pattern match s)\n                                              (.toString ^CharSequence replacement))\n                                 (replace-by s match replacement))\n     :else (throw (IllegalArgumentException. (str \"Invalid match arg: \" match))))))\n\n(defn- replace-first-by\n  [^CharSequence s ^Pattern re f]\n  (let [m (re-matcher re s)]\n    (if (.find m)\n      (let [buffer (StringBuffer. (.length s))\n            rep (Matcher/quoteReplacement (f (re-groups m)))]\n        (.appendReplacement m buffer rep)\n        (.appendTail m buffer)\n        (str buffer))\n      s)))\n\n(defn- replace-first-char\n  [^CharSequence s ^Character match replace]\n  (let [s (.toString s)\n        i (.indexOf s (int match))]\n    (if (= -1 i)\n      s\n      (str (subs s 0 i) replace (subs s (inc i))))))\n\n(defn- replace-first-str\n  [^CharSequence s ^String match ^String replace]\n  (let [^String s (.toString s)\n        i (.indexOf s match)]\n    (if (= -1 i)\n      s\n      (str (subs s 0 i) replace (subs s (+ i (.length match)))))))\n\n(defn ^String replace-first\n  \"Replaces the first instance of match with replacement in s.\n\n   match/replacement can be:\n\n   char / char\n   string / string\n   pattern / (string or function of match).\n\n   See also replace.\n\n   The replacement is literal (i.e. none of its characters are treated\n   specially) for all cases above except pattern / string.\n\n   For pattern / string, $1, $2, etc. in the replacement string are\n   substituted with the string that matched the corresponding\n   parenthesized group in the pattern.  If you wish your replacement\n   string r to be used literally, use (re-quote-replacement r) as the\n   replacement argument.  See also documentation for\n   java.util.regex.Matcher's appendReplacement method.\n\n   Example:\n   (clojure.string/replace-first \\\"swap first two words\\\"\n                                 #\\\"(\\\\w+)(\\\\s+)(\\\\w+)\\\" \\\"$3$2$1\\\")\n   -> \\\"first swap two words\\\"\"\n  {:added \"1.2\"}\n  [^CharSequence s match replacement]\n  (let [s (.toString s)]\n    (cond\n     (instance? Character match)\n     (replace-first-char s match replacement)\n     (instance? CharSequence match)\n     (replace-first-str s (.toString ^CharSequence match)\n                        (.toString ^CharSequence replacement))\n     (instance? Pattern match)\n     (if (instance? CharSequence replacement)\n       (.replaceFirst (re-matcher ^Pattern match s)\n                      (.toString ^CharSequence replacement))\n       (replace-first-by s match replacement))\n     :else (throw (IllegalArgumentException. (str \"Invalid match arg: \" match))))))\n\n\n(defn ^String join\n  \"Returns a string of all elements in coll, as returned by (seq coll),\n   separated by an optional separator.\"\n  {:added \"1.2\"}\n  ([coll]\n     (apply str coll))\n  ([separator coll]\n     (loop [sb (StringBuilder. (str (first coll)))\n            more (next coll)\n            sep (str separator)]\n       (if more\n         (recur (-> sb (.append sep) (.append (str (first more))))\n                (next more)\n                sep)\n         (str sb)))))\n\n(defn ^String capitalize\n  \"Converts first character of the string to upper-case, all other\n  characters to lower-case.\"\n  {:added \"1.2\"}\n  [^CharSequence s]\n  (let [s (.toString s)]\n    (if (< (count s) 2)\n      (.toUpperCase s)\n      (str (.toUpperCase (subs s 0 1))\n           (.toLowerCase (subs s 1))))))\n\n(defn ^String upper-case\n  \"Converts string to all upper-case.\"\n  {:added \"1.2\"}\n  [^CharSequence s]\n  (.. s toString toUpperCase))\n\n(defn ^String lower-case\n  \"Converts string to all lower-case.\"\n  {:added \"1.2\"}\n  [^CharSequence s]\n  (.. s toString toLowerCase))\n\n(defn split\n  \"Splits string on a regular expression.  Optional argument limit is\n  the maximum number of splits. Not lazy. Returns vector of the splits.\"\n  {:added \"1.2\"}\n  ([^CharSequence s ^Pattern re]\n     (LazilyPersistentVector/createOwning (.split re s)))\n  ([ ^CharSequence s ^Pattern re limit]\n     (LazilyPersistentVector/createOwning (.split re s limit))))\n\n(defn split-lines\n  \"Splits s on \\\\n or \\\\r\\\\n.\"\n  {:added \"1.2\"}\n  [^CharSequence s]\n  (split s #\"\\r?\\n\"))\n\n(defn ^String trim\n  \"Removes whitespace from both ends of string.\"\n  {:added \"1.2\"}\n  [^CharSequence s]\n  (let [len (.length s)]\n    (loop [rindex len]\n      (if (zero? rindex)\n        \"\"\n        (if (Character/isWhitespace (.charAt s (dec rindex)))\n          (recur (dec rindex))\n          ;; there is at least one non-whitespace char in the string,\n          ;; so no need to check for lindex reaching len.\n          (loop [lindex 0]\n            (if (Character/isWhitespace (.charAt s lindex))\n              (recur (inc lindex))\n              (.. s (subSequence lindex rindex) toString))))))))\n\n(defn ^String triml\n  \"Removes whitespace from the left side of string.\"\n  {:added \"1.2\"}\n  [^CharSequence s]\n  (let [len (.length s)]\n    (loop [index 0]\n      (if (= len index)\n        \"\"\n        (if (Character/isWhitespace (.charAt s index))\n          (recur (unchecked-inc index))\n          (.. s (subSequence index len) toString))))))\n\n(defn ^String trimr\n  \"Removes whitespace from the right side of string.\"\n  {:added \"1.2\"}\n  [^CharSequence s]\n  (loop [index (.length s)]\n    (if (zero? index)\n      \"\"\n      (if (Character/isWhitespace (.charAt s (unchecked-dec index)))\n        (recur (unchecked-dec index))\n        (.. s (subSequence 0 index) toString)))))\n\n(defn ^String trim-newline\n  \"Removes all trailing newline \\\\n or return \\\\r characters from\n  string.  Similar to Perl's chomp.\"\n  {:added \"1.2\"}\n  [^CharSequence s]\n  (loop [index (.length s)]\n    (if (zero? index)\n      \"\"\n      (let [ch (.charAt s (dec index))]\n        (if (or (= ch \\newline) (= ch \\return))\n          (recur (dec index))\n          (.. s (subSequence 0 index) toString))))))\n\n(defn blank?\n  \"True if s is nil, empty, or contains only whitespace.\"\n  {:added \"1.2\"}\n  [^CharSequence s]\n  (if s\n    (loop [index (int 0)]\n      (if (= (.length s) index)\n        true\n        (if (Character/isWhitespace (.charAt s index))\n          (recur (inc index))\n          false)))\n    true))\n\n(defn ^String escape\n  \"Return a new string, using cmap to escape each character ch\n   from s as follows:\n\n   If (cmap ch) is nil, append ch to the new string.\n   If (cmap ch) is non-nil, append (str (cmap ch)) instead.\"\n  {:added \"1.2\"}\n  [^CharSequence s cmap]\n  (loop [index (int 0)\n         buffer (StringBuilder. (.length s))]\n    (if (= (.length s) index)\n      (.toString buffer)\n      (let [ch (.charAt s index)]\n        (if-let [replacement (cmap ch)]\n          (.append buffer replacement)\n          (.append buffer ch))\n        (recur (inc index) buffer)))))\n"
  },
  {
    "path": "src/clj/clojure/template.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;;; template.clj - anonymous functions that pre-evaluate sub-expressions\n\n;; By Stuart Sierra\n;; June 23, 2009\n\n;; CHANGE LOG\n;;\n;; June 23, 2009: complete rewrite, eliminated _1,_2,... argument\n;; syntax\n;;\n;; January 20, 2009: added \"template?\" and checks for valid template\n;; expressions.\n;;\n;; December 15, 2008: first version\n\n(ns ^{:doc \"Macros that expand to repeated copies of a template expression.\"\n      :author \"Stuart Sierra\"}\n  clojure.template\n  (:require [clojure.walk :as walk]))\n\n(defn apply-template\n  \"For use in macros.  argv is an argument list, as in defn.  expr is\n  a quoted expression using the symbols in argv.  values is a sequence\n  of values to be used for the arguments.\n\n  apply-template will recursively replace argument symbols in expr\n  with their corresponding values, returning a modified expr.\n\n  Example: (apply-template '[x] '(+ x x) '[2])\n  ;=> (+ 2 2)\"\n  [argv expr values]\n  (assert (vector? argv))\n  (assert (every? symbol? argv))\n  (walk/prewalk-replace (zipmap argv values) expr))\n\n(defmacro do-template\n  \"Repeatedly copies expr (in a do block) for each group of arguments\n  in values.  values are automatically partitioned by the number of\n  arguments in argv, an argument vector as in defn.\n\n  Example: (macroexpand '(do-template [x y] (+ y x) 2 4 3 5))\n  ;=> (do (+ 4 2) (+ 5 3))\"\n  [argv expr & values]\n  (let [c (count argv)]\n    `(do ~@(map (fn [a] (apply-template argv expr a))\n                (partition c values)))))\n"
  },
  {
    "path": "src/clj/clojure/test/junit.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; test/junit.clj: Extension to clojure.test for JUnit-compatible XML output\n\n;; by Jason Sankey\n;; June 2009\n\n;; DOCUMENTATION\n;;\n\n(ns ^{:doc \"clojure.test extension for JUnit-compatible XML output.\n\n  JUnit (http://junit.org/) is the most popular unit-testing library\n  for Java.  As such, tool support for JUnit output formats is\n  common.  By producing compatible output from tests, this tool\n  support can be exploited.\n\n  To use, wrap any calls to clojure.test/run-tests in the\n  with-junit-output macro, like this:\n\n    (use 'clojure.test)\n    (use 'clojure.test.junit)\n\n    (with-junit-output\n      (run-tests 'my.cool.library))\n\n  To write the output to a file, rebind clojure.test/*test-out* to\n  your own PrintWriter (perhaps opened using\n  clojure.java.io/writer).\"\n  :author \"Jason Sankey\"}\n  clojure.test.junit\n  (:require [clojure.stacktrace :as stack]\n            [clojure.test :as t]))\n\n;; copied from clojure.contrib.lazy-xml\n(def ^{:private true}\n     escape-xml-map\n     (zipmap \"'<>\\\"&\" (map #(str \\& % \\;) '[apos lt gt quot amp])))\n(defn- escape-xml [text]\n  (apply str (map #(escape-xml-map % %) text)))\n\n(def ^:dynamic *var-context*)\n(def ^:dynamic *depth*)\n\n(defn indent\n  []\n  (dotimes [n (* *depth* 4)] (print \" \")))\n\n(defn start-element\n  [tag pretty & [attrs]]\n  (if pretty (indent))\n  (print (str \"<\" tag))\n  (if (seq attrs)\n    (doseq [[key value] attrs]\n      (print (str \" \" (name key) \"=\\\"\" (escape-xml value) \"\\\"\"))))\n  (print \">\")\n  (if pretty (println))\n  (set! *depth* (inc *depth*)))\n\n(defn element-content\n  [content]\n  (print (escape-xml content)))\n\n(defn finish-element\n  [tag pretty]\n  (set! *depth* (dec *depth*))\n  (if pretty (indent))\n  (print (str \"</\" tag \">\"))\n  (if pretty (println)))\n\n(defn test-name\n  [vars]\n  (apply str (interpose \".\"\n                        (reverse (map #(:name (meta %)) vars)))))\n\n(defn package-class\n  [name]\n  (let [i (.lastIndexOf name \".\")]\n    (if (< i 0)\n      [nil name]\n      [(.substring name 0 i) (.substring name (+ i 1))])))\n\n(defn start-case\n  [name classname]\n  (start-element 'testcase true {:name name :classname classname}))\n\n(defn finish-case\n  []\n  (finish-element 'testcase true))\n\n(defn suite-attrs\n  [package classname]\n  (let [attrs {:name classname}]\n    (if package\n      (assoc attrs :package package)\n      attrs)))\n\n(defn start-suite\n  [name]\n  (let [[package classname] (package-class name)]\n    (start-element 'testsuite true (suite-attrs package classname))))\n\n(defn finish-suite\n  []\n  (finish-element 'testsuite true))\n\n(defn message-el\n  [tag message expected-str actual-str]\n  (indent)\n  (start-element tag false (if message {:message message} {}))\n  (element-content\n   (let [[file line] (t/file-position 5)\n         detail (apply str (interpose\n                            \"\\n\"\n                            [(str \"expected: \" expected-str)\n                             (str \"  actual: \" actual-str)\n                             (str \"      at: \" file \":\" line)]))]\n     (if message (str message \"\\n\" detail) detail)))\n  (finish-element tag false)\n  (println))\n\n(defn failure-el\n  [message expected actual]\n  (message-el 'failure message (pr-str expected) (pr-str actual)))\n\n(defn error-el\n  [message expected actual]\n  (message-el 'error\n              message\n              (pr-str expected)\n              (if (instance? Throwable actual)\n                (with-out-str (stack/print-cause-trace actual t/*stack-trace-depth*))\n                (prn actual))))\n\n;; This multimethod will override test-is/report\n(defmulti ^:dynamic junit-report :type)\n\n(defmethod junit-report :begin-test-ns [m]\n  (t/with-test-out\n   (start-suite (name (ns-name (:ns m))))))\n\n(defmethod junit-report :end-test-ns [_]\n  (t/with-test-out\n   (finish-suite)))\n\n(defmethod junit-report :begin-test-var [m]\n  (t/with-test-out\n   (let [var (:var m)]\n     (binding [*var-context* (conj *var-context* var)]\n       (start-case (test-name *var-context*) (name (ns-name (:ns (meta var)))))))))\n\n(defmethod junit-report :end-test-var [m]\n  (t/with-test-out\n   (finish-case)))\n\n(defmethod junit-report :pass [m]\n  (t/with-test-out\n   (t/inc-report-counter :pass)))\n\n(defmethod junit-report :fail [m]\n  (t/with-test-out\n   (t/inc-report-counter :fail)\n   (failure-el (:message m)\n               (:expected m)\n               (:actual m))))\n\n(defmethod junit-report :error [m]\n  (t/with-test-out\n   (t/inc-report-counter :error)\n   (error-el (:message m)\n             (:expected m)\n             (:actual m))))\n\n(defmethod junit-report :default [_])\n\n(defmacro with-junit-output\n  \"Execute body with modified test-is reporting functions that write\n  JUnit-compatible XML output.\"\n  {:added \"1.1\"}\n  [& body]\n  `(binding [t/report junit-report\n             *var-context* (list)\n             *depth* 1]\n     (t/with-test-out\n       (println \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\")\n       (println \"<testsuites>\"))\n     (let [result# ~@body]\n       (t/with-test-out (println \"</testsuites>\"))\n       result#)))\n"
  },
  {
    "path": "src/clj/clojure/test/tap.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;;; test_is/tap.clj: Extension to test for TAP output\n\n;; by Stuart Sierra\n;; March 31, 2009\n\n;; Inspired by ClojureCheck by Meikel Brandmeyer:\n;; http://kotka.de/projects/clojure/clojurecheck.html\n\n\n;; DOCUMENTATION\n;;\n\n\n\n(ns ^{:doc \"clojure.test extensions for the Test Anything Protocol (TAP)\n\n  TAP is a simple text-based syntax for reporting test results.  TAP\n  was originally developed for Perl, and now has implementations in\n  several languages.  For more information on TAP, see\n  http://testanything.org/ and\n  http://search.cpan.org/~petdance/TAP-1.0.0/TAP.pm\n\n  To use this library, wrap any calls to\n  clojure.test/run-tests in the with-tap-output macro,\n  like this:\n\n    (use 'clojure.test)\n    (use 'clojure.test.tap)\n\n    (with-tap-output\n     (run-tests 'my.cool.library))\"\n       :author \"Stuart Sierra\"}\n  clojure.test.tap\n  (:require [clojure.test :as t]\n            [clojure.stacktrace :as stack]))\n\n(defn print-tap-plan\n  \"Prints a TAP plan line like '1..n'.  n is the number of tests\"\n  {:added \"1.1\"}\n  [n]\n  (println (str \"1..\" n)))\n\n(defn print-tap-diagnostic\n  \"Prints a TAP diagnostic line.  data is a (possibly multi-line)\n  string.\"\n  {:added \"1.1\"}\n  [data]\n  (doseq [line (.split ^String data \"\\n\")]\n    (println \"#\" line)))\n\n(defn print-tap-pass\n  \"Prints a TAP 'ok' line.  msg is a string, with no line breaks\"\n  {:added \"1.1\"}\n  [msg]\n  (println \"ok\" msg))\n\n(defn print-tap-fail \n  \"Prints a TAP 'not ok' line.  msg is a string, with no line breaks\"\n  {:added \"1.1\"}\n  [msg]\n  (println \"not ok\" msg))\n\n;; This multimethod will override test/report\n(defmulti ^:dynamic tap-report :type)\n\n(defmethod tap-report :default [data]\n  (t/with-test-out\n   (print-tap-diagnostic (pr-str data))))\n\n(defn print-diagnostics [data]\n  (when (seq t/*testing-contexts*)\n    (print-tap-diagnostic (t/testing-contexts-str)))\n  (when (:message data)\n    (print-tap-diagnostic (:message data)))\n  (print-tap-diagnostic (str \"expected:\" (pr-str (:expected data))))\n  (if (= :pass (:type data))\n    (print-tap-diagnostic (str \"  actual:\" (pr-str (:actual data))))\n    (do\n      (print-tap-diagnostic\n       (str \"  actual:\"\n        (with-out-str\n          (if (instance? Throwable (:actual data))\n            (stack/print-cause-trace (:actual data) t/*stack-trace-depth*)\n            (prn (:actual data)))))))))\n\n(defmethod tap-report :pass [data]\n  (t/with-test-out\n   (t/inc-report-counter :pass)\n   (print-tap-pass (t/testing-vars-str data))\n   (print-diagnostics data)))\n\n(defmethod tap-report :error [data]\n  (t/with-test-out\n   (t/inc-report-counter :error)\n   (print-tap-fail (t/testing-vars-str data))\n   (print-diagnostics data)))\n\n(defmethod tap-report :fail [data]\n  (t/with-test-out\n   (t/inc-report-counter :fail)\n   (print-tap-fail (t/testing-vars-str data))\n   (print-diagnostics data)))\n\n(defmethod tap-report :summary [data]\n  (t/with-test-out\n   (print-tap-plan (+ (:pass data) (:fail data) (:error data)))))\n\n\n(defmacro with-tap-output\n  \"Execute body with modified test reporting functions that produce\n  TAP output\"\n  {:added \"1.1\"}\n  [& body]\n  `(binding [t/report tap-report]\n     ~@body))\n"
  },
  {
    "path": "src/clj/clojure/test.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;;; test.clj: test framework for Clojure\n\n;; by Stuart Sierra\n;; March 28, 2009\n\n;; Thanks to Chas Emerick, Allen Rohner, and Stuart Halloway for\n;; contributions and suggestions.\n\n(ns\n  ^{:author \"Stuart Sierra, with contributions and suggestions by\n    Chas Emerick, Allen Rohner, and Stuart Halloway\",\n    :doc \"A unit testing framework.\n\n    ASSERTIONS\n\n    The core of the library is the \\\"is\\\" macro, which lets you make\n    assertions of any arbitrary expression:\n\n    (is (= 4 (+ 2 2)))\n    (is (instance? Integer 256))\n    (is (.startsWith \\\"abcde\\\" \\\"ab\\\"))\n\n    You can type an \\\"is\\\" expression directly at the REPL, which will\n    print a message if it fails.\n\n    user> (is (= 5 (+ 2 2)))\n\n    FAIL in  (:1)\n    expected: (= 5 (+ 2 2))\n    actual: (not (= 5 4))\n    false\n\n    The \\\"expected:\\\" line shows you the original expression, and the\n    \\\"actual:\\\" shows you what actually happened.  In this case, it\n    shows that (+ 2 2) returned 4, which is not = to 5.  Finally, the\n    \\\"false\\\" on the last line is the value returned from the\n    expression.  The \\\"is\\\" macro always returns the result of the\n    inner expression.\n\n    There are two special assertions for testing exceptions.  The\n    \\\"(is (thrown? c ...))\\\" form tests if an exception of class c is\n    thrown:\n\n    (is (thrown? ArithmeticException (/ 1 0)))\n\n    \\\"(is (thrown-with-msg? c re ...))\\\" does the same thing and also\n    tests that the message on the exception matches the regular\n    expression re:\n\n    (is (thrown-with-msg? ArithmeticException #\\\"Divide by zero\\\"\n    (/ 1 0)))\n\n    DOCUMENTING TESTS\n\n    \\\"is\\\" takes an optional second argument, a string describing the\n    assertion.  This message will be included in the error report.\n\n    (is (= 5 (+ 2 2)) \\\"Crazy arithmetic\\\")\n\n    In addition, you can document groups of assertions with the\n    \\\"testing\\\" macro, which takes a string followed by any number of\n    assertions.  The string will be included in failure reports.\n    Calls to \\\"testing\\\" may be nested, and all of the strings will be\n    joined together with spaces in the final report, in a style\n    similar to RSpec <http://rspec.info/>\n\n    (testing \\\"Arithmetic\\\"\n    (testing \\\"with positive integers\\\"\n    (is (= 4 (+ 2 2)))\n    (is (= 7 (+ 3 4))))\n    (testing \\\"with negative integers\\\"\n    (is (= -4 (+ -2 -2)))\n    (is (= -1 (+ 3 -4)))))\n\n    Note that, unlike RSpec, the \\\"testing\\\" macro may only be used\n    INSIDE a \\\"deftest\\\" or \\\"with-test\\\" form (see below).\n\n\n    DEFINING TESTS\n\n    There are two ways to define tests.  The \\\"with-test\\\" macro takes\n    a defn or def form as its first argument, followed by any number\n    of assertions.  The tests will be stored as metadata on the\n    definition.\n\n    (with-test\n    (defn my-function [x y]\n    (+ x y))\n    (is (= 4 (my-function 2 2)))\n    (is (= 7 (my-function 3 4))))\n\n    As of Clojure SVN rev. 1221, this does not work with defmacro.\n    See http://code.google.com/p/clojure/issues/detail?id=51\n\n    The other way lets you define tests separately from the rest of\n    your code, even in a different namespace:\n\n    (deftest addition\n    (is (= 4 (+ 2 2)))\n    (is (= 7 (+ 3 4))))\n\n    (deftest subtraction\n    (is (= 1 (- 4 3)))\n    (is (= 3 (- 7 4))))\n\n    This creates functions named \\\"addition\\\" and \\\"subtraction\\\", which\n    can be called like any other function.  Therefore, tests can be\n    grouped and composed, in a style similar to the test framework in\n    Peter Seibel's \\\"Practical Common Lisp\\\"\n    <http://www.gigamonkeys.com/book/practical-building-a-unit-test-framework.html>\n\n    (deftest arithmetic\n    (addition)\n    (subtraction))\n\n    The names of the nested tests will be joined in a list, like\n    \\\"(arithmetic addition)\\\", in failure reports.  You can use nested\n    tests to set up a context shared by several tests.\n\n\n    RUNNING TESTS\n\n    Run tests with the function \\\"(run-tests namespaces...)\\\":\n\n    (run-tests 'your.namespace 'some.other.namespace)\n\n    If you don't specify any namespaces, the current namespace is\n    used.  To run all tests in all namespaces, use \\\"(run-all-tests)\\\".\n\n    By default, these functions will search for all tests defined in\n    a namespace and run them in an undefined order.  However, if you\n    are composing tests, as in the \\\"arithmetic\\\" example above, you\n    probably do not want the \\\"addition\\\" and \\\"subtraction\\\" tests run\n    separately.  In that case, you must define a special function\n    named \\\"test-ns-hook\\\" that runs your tests in the correct order:\n\n    (defn test-ns-hook []\n    (arithmetic))\n\n    Note: test-ns-hook prevents execution of fixtures (see below).\n\n\n    OMITTING TESTS FROM PRODUCTION CODE\n\n    You can bind the variable \\\"*load-tests*\\\" to false when loading or\n    compiling code in production.  This will prevent any tests from\n    being created by \\\"with-test\\\" or \\\"deftest\\\".\n\n\n    FIXTURES\n\n    Fixtures allow you to run code before and after tests, to set up\n    the context in which tests should be run.\n\n    A fixture is just a function that calls another function passed as\n    an argument.  It looks like this:\n\n    (defn my-fixture [f]\n    Perform setup, establish bindings, whatever.\n    (f)  Then call the function we were passed.\n    Tear-down / clean-up code here.\n    )\n\n    Fixtures are attached to namespaces in one of two ways.  \\\"each\\\"\n    fixtures are run repeatedly, once for each test function created\n    with \\\"deftest\\\" or \\\"with-test\\\".  \\\"each\\\" fixtures are useful for\n    establishing a consistent before/after state for each test, like\n    clearing out database tables.\n\n    \\\"each\\\" fixtures can be attached to the current namespace like this:\n    (use-fixtures :each fixture1 fixture2 ...)\n    The fixture1, fixture2 are just functions like the example above.\n    They can also be anonymous functions, like this:\n    (use-fixtures :each (fn [f] setup... (f) cleanup...))\n\n    The other kind of fixture, a \\\"once\\\" fixture, is only run once,\n    around ALL the tests in the namespace.  \\\"once\\\" fixtures are useful\n    for tasks that only need to be performed once, like establishing\n    database connections, or for time-consuming tasks.\n\n    Attach \\\"once\\\" fixtures to the current namespace like this:\n    (use-fixtures :once fixture1 fixture2 ...)\n\n    Note: Fixtures and test-ns-hook are mutually incompatible.  If you\n    are using test-ns-hook, fixture functions will *never* be run.\n\n\n    SAVING TEST OUTPUT TO A FILE\n\n    All the test reporting functions write to the var *test-out*.  By\n    default, this is the same as *out*, but you can rebind it to any\n    PrintWriter.  For example, it could be a file opened with\n    clojure.java.io/writer.\n\n\n    EXTENDING TEST-IS (ADVANCED)\n\n    You can extend the behavior of the \\\"is\\\" macro by defining new\n    methods for the \\\"assert-expr\\\" multimethod.  These methods are\n    called during expansion of the \\\"is\\\" macro, so they should return\n    quoted forms to be evaluated.\n\n    You can plug in your own test-reporting framework by rebinding\n    the \\\"report\\\" function: (report event)\n\n    The 'event' argument is a map.  It will always have a :type key,\n    whose value will be a keyword signaling the type of event being\n    reported.  Standard events with :type value of :pass, :fail, and\n    :error are called when an assertion passes, fails, and throws an\n    exception, respectively.  In that case, the event will also have\n    the following keys:\n\n    :expected   The form that was expected to be true\n    :actual     A form representing what actually occurred\n    :message    The string message given as an argument to 'is'\n\n    The \\\"testing\\\" strings will be a list in \\\"*testing-contexts*\\\", and\n    the vars being tested will be a list in \\\"*testing-vars*\\\".\n\n    Your \\\"report\\\" function should wrap any printing calls in the\n    \\\"with-test-out\\\" macro, which rebinds *out* to the current value\n    of *test-out*.\n\n    For additional event types, see the examples in the code.\n    \"}\n  clojure.test\n  (:require [clojure.stacktrace :as stack]))\n\n\n(require '[clojure.template :as temp])\n\n;; Nothing is marked \"private\" here, so you can rebind things to plug\n;; in your own testing or reporting frameworks.\n\n\n;;; USER-MODIFIABLE GLOBALS\n\n(defonce ^:dynamic\n  ^{:doc \"True by default.  If set to false, no test functions will\n    be created by deftest, set-test, or with-test.  Use this to omit\n    tests when compiling or loading production code.\"\n    :added \"1.1\"}\n  *load-tests* true)\n\n(def ^:dynamic\n  ^{:doc \"The maximum depth of stack traces to print when an Exception\n    is thrown during a test.  Defaults to nil, which means print the\n    complete stack trace.\"\n    :added \"1.1\"}\n  *stack-trace-depth* nil)\n\n\n;;; GLOBALS USED BY THE REPORTING FUNCTIONS\n\n(def ^:dynamic *report-counters* nil)\t  ; bound to a ref of a map in test-ns\n\n(def ^:dynamic *initial-report-counters*  ; used to initialize *report-counters*\n  {:test 0, :pass 0, :fail 0, :error 0})\n\n(def ^:dynamic *testing-vars* (list))  ; bound to hierarchy of vars being tested\n\n(def ^:dynamic *testing-contexts* (list)) ; bound to hierarchy of \"testing\" strings\n\n(def ^:dynamic *test-out* *out*)         ; PrintWriter for test reporting output\n\n(defmacro with-test-out\n  \"Runs body with *out* bound to the value of *test-out*.\"\n  {:added \"1.1\"}\n  [& body]\n  `(binding [*out* *test-out*]\n     ~@body))\n\n;;; UTILITIES FOR REPORTING FUNCTIONS\n\n(defn file-position\n  \"Returns a vector [filename line-number] for the nth call up the\n  stack.\n\n  Deprecated in 1.2: The information needed for test reporting is\n  now on :file and :line keys in the result map.\"\n  {:added \"1.1\"\n   :deprecated \"1.2\"}\n  [n]\n  (let [^StackTraceElement s (nth (.getStackTrace (new java.lang.Throwable)) n)]\n    [(.getFileName s) (.getLineNumber s)]))\n\n(defn testing-vars-str\n  \"Returns a string representation of the current test.  Renders names\n  in *testing-vars* as a list, then the source file and line of\n  current assertion.\"\n  {:added \"1.1\"}\n  [m]\n  (let [{:keys [file line]} m]\n    (str\n     ;; Uncomment to include namespace in failure report:\n     ;;(ns-name (:ns (meta (first *testing-vars*)))) \"/ \"\n     (reverse (map #(:name (meta %)) *testing-vars*))\n     \" (\" file \":\" line \")\")))\n\n(defn testing-contexts-str\n  \"Returns a string representation of the current test context. Joins\n  strings in *testing-contexts* with spaces.\"\n  {:added \"1.1\"}\n  []\n  (apply str (interpose \" \" (reverse *testing-contexts*))))\n\n(defn inc-report-counter\n  \"Increments the named counter in *report-counters*, a ref to a map.\n  Does nothing if *report-counters* is nil.\"\n  {:added \"1.1\"}\n  [name]\n  (when *report-counters*\n    (dosync (commute *report-counters* assoc name\n                     (inc (or (*report-counters* name) 0))))))\n\n;;; TEST RESULT REPORTING\n\n(defmulti\n  ^{:doc \"Generic reporting function, may be overridden to plug in\n    different report formats (e.g., TAP, JUnit).  Assertions such as\n    'is' call 'report' to indicate results.  The argument given to\n    'report' will be a map with a :type key.  See the documentation at\n    the top of test_is.clj for more information on the types of\n    arguments for 'report'.\"\n    :dynamic true\n    :added \"1.1\"}\n  report :type)\n\n(defn- file-and-line\n  [^Throwable exception depth]\n  (let [stacktrace (.getStackTrace exception)]\n    (if (< depth (count stacktrace))\n      (let [^StackTraceElement s (nth stacktrace depth)]\n        {:file (.getFileName s) :line (.getLineNumber s)})\n      {:file nil :line nil})))\n\n(defn do-report\n  \"Add file and line information to a test result and call report.\n  If you are writing a custom assert-expr method, call this function\n  to pass test results to report.\"\n  {:added \"1.2\"}\n  [m]\n  (report\n   (case\n     (:type m)\n     :fail (merge (file-and-line (new java.lang.Throwable) 1) m)\n     :error (merge (file-and-line (:actual m) 0) m)\n     m)))\n\n(defmethod report :default [m]\n  (with-test-out (prn m)))\n\n(defmethod report :pass [m]\n  (with-test-out (inc-report-counter :pass)))\n\n(defmethod report :fail [m]\n  (with-test-out\n    (inc-report-counter :fail)\n    (println \"\\nFAIL in\" (testing-vars-str m))\n    (when (seq *testing-contexts*) (println (testing-contexts-str)))\n    (when-let [message (:message m)] (println message))\n    (println \"expected:\" (pr-str (:expected m)))\n    (println \"  actual:\" (pr-str (:actual m)))))\n\n(defmethod report :error [m]\n  (with-test-out\n    (inc-report-counter :error)\n    (println \"\\nERROR in\" (testing-vars-str m))\n    (when (seq *testing-contexts*) (println (testing-contexts-str)))\n    (when-let [message (:message m)] (println message))\n    (println \"expected:\" (pr-str (:expected m)))\n    (print \"  actual: \")\n    (let [actual (:actual m)]\n      (if (instance? Throwable actual)\n        (stack/print-cause-trace actual *stack-trace-depth*)\n        (prn actual)))))\n\n(defmethod report :summary [m]\n  (with-test-out\n    (println \"\\nRan\" (:test m) \"tests containing\"\n             (+ (:pass m) (:fail m) (:error m)) \"assertions.\")\n    (println (:fail m) \"failures,\" (:error m) \"errors.\")))\n\n(defmethod report :begin-test-ns [m]\n  (with-test-out\n    (println \"\\nTesting\" (ns-name (:ns m)))))\n\n;; Ignore these message types:\n(defmethod report :end-test-ns [m])\n(defmethod report :begin-test-var [m])\n(defmethod report :end-test-var [m])\n\n\n\n;;; UTILITIES FOR ASSERTIONS\n\n(defn get-possibly-unbound-var\n  \"Like var-get but returns nil if the var is unbound.\"\n  {:added \"1.1\"}\n  [v]\n  (try (var-get v)\n    (catch IllegalStateException e\n      nil)))\n\n(defn function?\n  \"Returns true if argument is a function or a symbol that resolves to\n  a function (not a macro).\"\n  {:added \"1.1\"}\n  [x]\n  (if (symbol? x)\n    (when-let [v (resolve x)]\n      (when-let [value (get-possibly-unbound-var v)]\n        (and (fn? value)\n             (not (:macro (meta v))))))\n    (fn? x)))\n\n(defn assert-predicate\n  \"Returns generic assertion code for any functional predicate.  The\n  'expected' argument to 'report' will contains the original form, the\n  'actual' argument will contain the form with all its sub-forms\n  evaluated.  If the predicate returns false, the 'actual' form will\n  be wrapped in (not...).\"\n  {:added \"1.1\"}\n  [msg form]\n  (let [args (rest form)\n        pred (first form)]\n    `(let [values# (list ~@args)\n           result# (apply ~pred values#)]\n       (if result#\n         (do-report {:type :pass, :message ~msg,\n                     :expected '~form, :actual (cons ~pred values#)})\n         (do-report {:type :fail, :message ~msg,\n                     :expected '~form, :actual (list '~'not (cons '~pred values#))}))\n       result#)))\n\n(defn assert-any\n  \"Returns generic assertion code for any test, including macros, Java\n  method calls, or isolated symbols.\"\n  {:added \"1.1\"}\n  [msg form]\n  `(let [value# ~form]\n     (if value#\n       (do-report {:type :pass, :message ~msg,\n                   :expected '~form, :actual value#})\n       (do-report {:type :fail, :message ~msg,\n                   :expected '~form, :actual value#}))\n     value#))\n\n\n\n;;; ASSERTION METHODS\n\n;; You don't call these, but you can add methods to extend the 'is'\n;; macro.  These define different kinds of tests, based on the first\n;; symbol in the test expression.\n\n(defmulti assert-expr\n  (fn [msg form]\n    (cond\n     (nil? form) :always-fail\n     (seq? form) (first form)\n     :else :default)))\n\n(defmethod assert-expr :always-fail [msg form]\n  ;; nil test: always fail\n  `(do-report {:type :fail, :message ~msg}))\n\n(defmethod assert-expr :default [msg form]\n  (if (and (sequential? form) (function? (first form)))\n    (assert-predicate msg form)\n    (assert-any msg form)))\n\n(defmethod assert-expr 'instance? [msg form]\n  ;; Test if x is an instance of y.\n  `(let [klass# ~(nth form 1)\n         object# ~(nth form 2)]\n     (let [result# (instance? klass# object#)]\n       (if result#\n         (do-report {:type :pass, :message ~msg,\n                     :expected '~form, :actual (class object#)})\n         (do-report {:type :fail, :message ~msg,\n                     :expected '~form, :actual (class object#)}))\n       result#)))\n\n(defmethod assert-expr 'thrown? [msg form]\n  ;; (is (thrown? c expr))\n  ;; Asserts that evaluating expr throws an exception of class c.\n  ;; Returns the exception thrown.\n  (let [klass (second form)\n        body (nthnext form 2)]\n    `(try ~@body\n       (do-report {:type :fail, :message ~msg,\n                   :expected '~form, :actual nil})\n       (catch ~klass e#\n         (do-report {:type :pass, :message ~msg,\n                     :expected '~form, :actual e#})\n         e#))))\n\n(defmethod assert-expr 'thrown-with-msg? [msg form]\n  ;; (is (thrown-with-msg? c re expr))\n  ;; Asserts that evaluating expr throws an exception of class c.\n  ;; Also asserts that the message string of the exception matches\n  ;; (with re-find) the regular expression re.\n  (let [klass (nth form 1)\n        re (nth form 2)\n        body (nthnext form 3)]\n    `(try ~@body\n       (do-report {:type :fail, :message ~msg, :expected '~form, :actual nil})\n       (catch ~klass e#\n         (let [m# (.getMessage e#)]\n           (if (re-find ~re m#)\n             (do-report {:type :pass, :message ~msg,\n                         :expected '~form, :actual e#})\n             (do-report {:type :fail, :message ~msg,\n                         :expected '~form, :actual e#})))\n         e#))))\n\n(defmacro try-expr\n  \"Used by the 'is' macro to catch unexpected exceptions.\n  You don't call this.\"\n  {:added \"1.1\"}\n  [msg form]\n  `(try ~(assert-expr msg form)\n     (catch Throwable t#\n       (do-report {:type :error, :message ~msg,\n                   :expected '~form, :actual t#}))))\n\n\n\n;;; ASSERTION MACROS\n\n;; You use these in your tests.\n\n(defmacro is\n  \"Generic assertion macro.  'form' is any predicate test.\n  'msg' is an optional message to attach to the assertion.\n\n  Example: (is (= 4 (+ 2 2)) \\\"Two plus two should be 4\\\")\n\n  Special forms:\n\n  (is (thrown? c body)) checks that an instance of c is thrown from\n  body, fails if not; then returns the thing thrown.\n\n  (is (thrown-with-msg? c re body)) checks that an instance of c is\n  thrown AND that the message on the exception matches (with\n  re-find) the regular expression re.\"\n  {:added \"1.1\"}\n  ([form] `(is ~form nil))\n  ([form msg] `(try-expr ~msg ~form)))\n\n(defmacro are\n  \"Checks multiple assertions with a template expression.\n  See clojure.template/do-template for an explanation of\n  templates.\n\n  Example: (are [x y] (= x y)\n  2 (+ 1 1)\n  4 (* 2 2))\n  Expands to:\n  (do (is (= 2 (+ 1 1)))\n  (is (= 4 (* 2 2))))\n\n  Note: This breaks some reporting features, such as line numbers.\"\n  {:added \"1.1\"}\n  [argv expr & args]\n  (if (or\n       ;; (are [] true) is meaningless but ok\n       (and (empty? argv) (empty? args))\n       ;; Catch wrong number of args\n       (and (pos? (count argv))\n            (pos? (count args))\n            (zero? (mod (count args) (count argv)))))\n    `(temp/do-template ~argv (is ~expr) ~@args)\n    (throw (IllegalArgumentException. \"The number of args doesn't match are's argv.\"))))\n\n(defmacro testing\n  \"Adds a new string to the list of testing contexts.  May be nested,\n  but must occur inside a test function (deftest).\"\n  {:added \"1.1\"}\n  [string & body]\n  `(binding [*testing-contexts* (conj *testing-contexts* ~string)]\n     ~@body))\n\n\n\n;;; DEFINING TESTS\n\n(defmacro with-test\n  \"Takes any definition form (that returns a Var) as the first argument.\n  Remaining body goes in the :test metadata function for that Var.\n\n  When *load-tests* is false, only evaluates the definition, ignoring\n  the tests.\"\n  {:added \"1.1\"}\n  [definition & body]\n  (if *load-tests*\n    `(doto ~definition (alter-meta! assoc :test (fn [] ~@body)))\n    definition))\n\n\n(defmacro deftest\n  \"Defines a test function with no arguments.  Test functions may call\n  other tests, so tests may be composed.  If you compose tests, you\n  should also define a function named test-ns-hook; run-tests will\n  call test-ns-hook instead of testing all vars.\n\n  Note: Actually, the test body goes in the :test metadata on the var,\n  and the real function (the value of the var) calls test-var on\n  itself.\n\n  When *load-tests* is false, deftest is ignored.\"\n  {:added \"1.1\"}\n  [name & body]\n  (when *load-tests*\n    `(def ~(vary-meta name assoc :test `(fn [] ~@body))\n       (fn [] (test-var (var ~name))))))\n\n(defmacro deftest-\n  \"Like deftest but creates a private var.\"\n  {:added \"1.1\"}\n  [name & body]\n  (when *load-tests*\n    `(def ~(vary-meta name assoc :test `(fn [] ~@body) :private true)\n       (fn [] (test-var (var ~name))))))\n\n\n(defmacro set-test\n  \"Experimental.\n  Sets :test metadata of the named var to a fn with the given body.\n  The var must already exist.  Does not modify the value of the var.\n\n  When *load-tests* is false, set-test is ignored.\"\n  {:added \"1.1\"}\n  [name & body]\n  (when *load-tests*\n    `(alter-meta! (var ~name) assoc :test (fn [] ~@body))))\n\n;;; DEFINING FIXTURES\n\n(defn- add-ns-meta\n  \"Adds elements in coll to the current namespace metadata as the\n  value of key.\"\n  {:added \"1.1\"}\n  [key coll]\n  (alter-meta! *ns* assoc key coll))\n\n(defmulti use-fixtures\n  \"Wrap test runs in a fixture function to perform setup and\n  teardown. Using a fixture-type of :each wraps every test\n  individually, while:once wraps the whole run in a single function.\"\n  {:added \"1.1\"}\n  (fn [fixture-type & args] fixture-type))\n\n(defmethod use-fixtures :each [fixture-type & args]\n  (add-ns-meta ::each-fixtures args))\n\n(defmethod use-fixtures :once [fixture-type & args]\n  (add-ns-meta ::once-fixtures args))\n\n(defn- default-fixture\n  \"The default, empty, fixture function.  Just calls its argument.\"\n  {:added \"1.1\"}\n  [f]\n  (f))\n\n(defn compose-fixtures\n  \"Composes two fixture functions, creating a new fixture function\n  that combines their behavior.\"\n  {:added \"1.1\"}\n  [f1 f2]\n  (fn [g] (f1 (fn [] (f2 g)))))\n\n(defn join-fixtures\n  \"Composes a collection of fixtures, in order.  Always returns a valid\n  fixture function, even if the collection is empty.\"\n  {:added \"1.1\"}\n  [fixtures]\n  (reduce compose-fixtures default-fixture fixtures))\n\n\n\n\n;;; RUNNING TESTS: LOW-LEVEL FUNCTIONS\n\n(defn test-var\n  \"If v has a function in its :test metadata, calls that function,\n  with *testing-vars* bound to (conj *testing-vars* v).\"\n  {:dynamic true, :added \"1.1\"}\n  [v]\n  (when-let [t (:test (meta v))]\n    (binding [*testing-vars* (conj *testing-vars* v)]\n      (do-report {:type :begin-test-var, :var v})\n      (inc-report-counter :test)\n      (try (t)\n        (catch Throwable e\n          (do-report {:type :error, :message \"Uncaught exception, not in assertion.\"\n                      :expected nil, :actual e})))\n      (do-report {:type :end-test-var, :var v}))))\n\n(defn test-vars\n  \"Groups vars by their namespace and runs test-vars on them with\n   appropriate fixtures applied.\"\n  {:added \"1.6\"}\n  [vars]\n  (doseq [[ns vars] (group-by (comp :ns meta) vars)]\n    (let [once-fixture-fn (join-fixtures (::once-fixtures (meta ns)))\n          each-fixture-fn (join-fixtures (::each-fixtures (meta ns)))]\n      (once-fixture-fn\n       (fn []\n         (doseq [v vars]\n           (when (:test (meta v))\n             (each-fixture-fn (fn [] (test-var v))))))))))\n\n(defn test-all-vars\n  \"Calls test-vars on every var interned in the namespace, with fixtures.\"\n  {:added \"1.1\"}\n  [ns]\n  (test-vars (vals (ns-interns ns))))\n\n(defn test-ns\n  \"If the namespace defines a function named test-ns-hook, calls that.\n  Otherwise, calls test-all-vars on the namespace.  'ns' is a\n  namespace object or a symbol.\n\n  Internally binds *report-counters* to a ref initialized to\n  *initial-report-counters*.  Returns the final, dereferenced state of\n  *report-counters*.\"\n  {:added \"1.1\"}\n  [ns]\n  (binding [*report-counters* (ref *initial-report-counters*)]\n    (let [ns-obj (the-ns ns)]\n      (do-report {:type :begin-test-ns, :ns ns-obj})\n      ;; If the namespace has a test-ns-hook function, call that:\n      (if-let [v (find-var (symbol (str (ns-name ns-obj)) \"test-ns-hook\"))]\n        ((var-get v))\n        ;; Otherwise, just test every var in the namespace.\n        (test-all-vars ns-obj))\n      (do-report {:type :end-test-ns, :ns ns-obj}))\n    @*report-counters*))\n\n\n\n;;; RUNNING TESTS: HIGH-LEVEL FUNCTIONS\n\n(defn run-tests\n  \"Runs all tests in the given namespaces; prints results.\n  Defaults to current namespace if none given.  Returns a map\n  summarizing test results.\"\n  {:added \"1.1\"}\n  ([] (run-tests *ns*))\n  ([& namespaces]\n   (let [summary (assoc (apply merge-with + (map test-ns namespaces))\n                   :type :summary)]\n     (do-report summary)\n     summary)))\n\n(defn run-all-tests\n  \"Runs all tests in all namespaces; prints results.\n  Optional argument is a regular expression; only namespaces with\n  names matching the regular expression (with re-matches) will be\n  tested.\"\n  {:added \"1.1\"}\n  ([] (apply run-tests (all-ns)))\n  ([re] (apply run-tests (filter #(re-matches re (name (ns-name %))) (all-ns)))))\n\n(defn successful?\n  \"Returns true if the given test summary indicates all tests\n  were successful, false otherwise.\"\n  {:added \"1.1\"}\n  [summary]\n  (and (zero? (:fail summary 0))\n       (zero? (:error summary 0))))\n"
  },
  {
    "path": "src/clj/clojure/uuid.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns clojure.uuid)\n\n(defn- default-uuid-reader [form]\n  {:pre [(string? form)]}\n  (java.util.UUID/fromString form))\n\n(defmethod print-method java.util.UUID [uuid ^java.io.Writer w]\n  (.write w (str \"#uuid \\\"\" (str uuid) \"\\\"\")))\n\n(defmethod print-dup java.util.UUID [o w]\n  (print-method o w))\n"
  },
  {
    "path": "src/clj/clojure/walk.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;;; walk.clj - generic tree walker with replacement\n\n;; by Stuart Sierra\n;; December 15, 2008\n\n;; CHANGE LOG:\n;;\n;; * December 15, 2008: replaced 'walk' with 'prewalk' & 'postwalk'\n;;\n;; * December 9, 2008: first version\n\n\n(ns \n  ^{:author \"Stuart Sierra\",\n     :doc \"This file defines a generic tree walker for Clojure data\nstructures.  It takes any data structure (list, vector, map, set,\nseq), calls a function on every element, and uses the return value\nof the function in place of the original.  This makes it fairly\neasy to write recursive search-and-replace functions, as shown in\nthe examples.\n\nNote: \\\"walk\\\" supports all Clojure data structures EXCEPT maps\ncreated with sorted-map-by.  There is no (obvious) way to retrieve\nthe sorting function.\"}\n  clojure.walk)\n\n(defn walk\n  \"Traverses form, an arbitrary data structure.  inner and outer are\n  functions.  Applies inner to each element of form, building up a\n  data structure of the same type, then applies outer to the result.\n  Recognizes all Clojure data structures. Consumes seqs as with doall.\"\n\n  {:added \"1.1\"}\n  [inner outer form]\n  (cond\n   (list? form) (outer (apply list (map inner form)))\n   (instance? clojure.lang.IMapEntry form) (outer (vec (map inner form)))\n   (seq? form) (outer (doall (map inner form)))\n   (instance? clojure.lang.IRecord form)\n     (outer (reduce (fn [r x] (conj r (inner x))) form form))\n   (coll? form) (outer (into (empty form) (map inner form)))\n   :else (outer form)))\n\n(defn postwalk\n  \"Performs a depth-first, post-order traversal of form.  Calls f on\n  each sub-form, uses f's return value in place of the original.\n  Recognizes all Clojure data structures. Consumes seqs as with doall.\"\n  {:added \"1.1\"}\n  [f form]\n  (walk (partial postwalk f) f form))\n\n(defn prewalk\n  \"Like postwalk, but does pre-order traversal.\"\n  {:added \"1.1\"}\n  [f form]\n  (walk (partial prewalk f) identity (f form)))\n\n\n;; Note: I wanted to write:\n;;\n;; (defn walk\n;;   [f form]\n;;   (let [pf (partial walk f)]\n;;     (if (coll? form)\n;;       (f (into (empty form) (map pf form)))\n;;       (f form))))\n;;\n;; but this throws a ClassCastException when applied to a map.\n\n\n(defn postwalk-demo\n  \"Demonstrates the behavior of postwalk by printing each form as it is\n  walked.  Returns form.\"\n  {:added \"1.1\"}\n  [form]\n  (postwalk (fn [x] (print \"Walked: \") (prn x) x) form))\n\n(defn prewalk-demo\n  \"Demonstrates the behavior of prewalk by printing each form as it is\n  walked.  Returns form.\"\n  {:added \"1.1\"}\n  [form]\n  (prewalk (fn [x] (print \"Walked: \") (prn x) x) form))\n\n(defn keywordize-keys\n  \"Recursively transforms all map keys from strings to keywords.\"\n  {:added \"1.1\"}\n  [m]\n  (let [f (fn [[k v]] (if (string? k) [(keyword k) v] [k v]))]\n    ;; only apply to maps\n    (postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))\n\n(defn stringify-keys\n  \"Recursively transforms all map keys from keywords to strings.\"\n  {:added \"1.1\"}\n  [m]\n  (let [f (fn [[k v]] (if (keyword? k) [(name k) v] [k v]))]\n    ;; only apply to maps\n    (postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))\n\n(defn prewalk-replace\n  \"Recursively transforms form by replacing keys in smap with their\n  values.  Like clojure/replace but works on any data structure.  Does\n  replacement at the root of the tree first.\"\n  {:added \"1.1\"}\n  [smap form]\n  (prewalk (fn [x] (if (contains? smap x) (smap x) x)) form))\n\n(defn postwalk-replace\n  \"Recursively transforms form by replacing keys in smap with their\n  values.  Like clojure/replace but works on any data structure.  Does\n  replacement at the leaves of the tree first.\"\n  {:added \"1.1\"}\n  [smap form]\n  (postwalk (fn [x] (if (contains? smap x) (smap x) x)) form))\n\n(defn macroexpand-all\n  \"Recursively performs all possible macroexpansions in form.\"\n  {:added \"1.1\"}\n  [form]\n  (prewalk (fn [x] (if (seq? x) (macroexpand x) x)) form))\n\n"
  },
  {
    "path": "src/clj/clojure/xml.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns ^{:doc \"XML reading/writing.\"\n       :author \"Rich Hickey\"}\n  clojure.xml\n  (:import (org.xml.sax ContentHandler Attributes SAXException)\n           (javax.xml.parsers SAXParser SAXParserFactory)))\n\n(def ^:dynamic *stack*)\n(def ^:dynamic *current*)\n(def ^:dynamic *state*) ; :element :chars :between\n(def ^:dynamic *sb*)\n\n(defstruct element :tag :attrs :content)\n\n(def tag (accessor element :tag))\n(def attrs (accessor element :attrs))\n(def content (accessor element :content))\n\n(def content-handler\n  (let [push-content (fn [e c]\n                       (assoc e :content (conj (or (:content e) []) c)))\n        push-chars (fn []\n                     (when (and (= *state* :chars)\n                                (some (complement #(Character/isWhitespace (char %))) (str *sb*)))\n                       (set! *current* (push-content *current* (str *sb*)))))]\n    (new clojure.lang.XMLHandler\n         (proxy [ContentHandler] []\n           (startElement [uri local-name q-name ^Attributes atts]\n             (let [attrs (fn [ret i]\n                           (if (neg? i)\n                             ret\n                             (recur (assoc ret\n                                           (clojure.lang.Keyword/intern (symbol (.getQName atts i)))\n                                           (.getValue atts (int i)))\n                                    (dec i))))\n                   e (struct element\n                             (. clojure.lang.Keyword (intern (symbol q-name)))\n                             (when (pos? (.getLength atts))\n                               (attrs {} (dec (.getLength atts)))))]\n               (push-chars)\n               (set! *stack* (conj *stack* *current*))\n               (set! *current* e)\n               (set! *state* :element))\n             nil)\n           (endElement [uri local-name q-name]\n             (push-chars)\n             (set! *current* (push-content (peek *stack*) *current*))\n             (set! *stack* (pop *stack*))\n             (set! *state* :between)\n             nil)\n           (characters [^chars ch start length]\n             (when-not (= *state* :chars)\n               (set! *sb* (new StringBuilder)))\n             (let [^StringBuilder sb *sb*]\n               (.append sb ch (int start) (int length))\n               (set! *state* :chars))\n             nil)\n           (setDocumentLocator [locator])\n           (startDocument [])\n           (endDocument [])\n           (startPrefixMapping [prefix uri])\n           (endPrefixMapping [prefix])\n           (ignorableWhitespace [ch start length])\n           (processingInstruction [target data])\n           (skippedEntity [name])\n           ))))\n\n(defn startparse-sax [s ch]\n  (.parse ^javax.xml.parsers.SAXParser\n         (.. SAXParserFactory (newInstance) (newSAXParser)) s ch))\n\n(defn parse\n  \"Parses and loads the source s, which can be a File, InputStream or\n  String naming a URI. Returns a tree of the xml/element struct-map,\n  which has the keys :tag, :attrs, and :content. and accessor fns tag,\n  attrs, and content. Other parsers can be supplied by passing\n  startparse, a fn taking a source and a ContentHandler and returning\n  a parser\"\n  {:added \"1.0\"}\n  ([s] (parse s startparse-sax))\n  ([s startparse]\n    (binding [*stack* nil\n              *current* (struct element)\n              *state* :between\n              *sb* nil]\n      (startparse s content-handler)\n      ((:content *current*) 0))))\n\n(defn emit-element [e]\n  (if (instance? String e)\n    (println e)\n    (do\n      (print (str \"<\" (name (:tag e))))\n      (when (:attrs e)\n\t(doseq [attr (:attrs e)]\n\t  (print (str \" \" (name (key attr)) \"='\" (val attr)\"'\"))))\n      (if (:content e)\n\t(do\n\t  (println \">\")\n\t  (doseq [c (:content e)]\n\t    (emit-element c))\n\t  (println (str \"</\" (name (:tag e)) \">\")))\n\t(println \"/>\")))))\n\n(defn emit [x]\n  (println \"<?xml version='1.0' encoding='UTF-8'?>\")\n  (emit-element x))\n\n;(export '(tag attrs content parse element emit emit-element))\n\n;(load-file \"/Users/rich/dev/clojure/src/xml.clj\")\n;(def x (xml/parse \"http://arstechnica.com/journals.rssx\"))\n"
  },
  {
    "path": "src/clj/clojure/zip.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;functional hierarchical zipper, with navigation, editing and enumeration\n;see Huet\n\n(ns ^{:doc \"Functional hierarchical zipper, with navigation, editing,\n  and enumeration.  See Huet\"\n       :author \"Rich Hickey\"}\n  clojure.zip\n  (:refer-clojure :exclude (replace remove next)))\n\n(defn zipper\n  \"Creates a new zipper structure. \n\n  branch? is a fn that, given a node, returns true if can have\n  children, even if it currently doesn't.\n\n  children is a fn that, given a branch node, returns a seq of its\n  children.\n\n  make-node is a fn that, given an existing node and a seq of\n  children, returns a new branch node with the supplied children.\n  root is the root node.\"\n  {:added \"1.0\"}\n  [branch? children make-node root]\n    ^{:zip/branch? branch? :zip/children children :zip/make-node make-node}\n    [root nil])\n\n(defn seq-zip\n  \"Returns a zipper for nested sequences, given a root sequence\"\n  {:added \"1.0\"}\n  [root]\n    (zipper seq?\n            identity\n            (fn [node children] (with-meta children (meta node)))\n            root))\n\n(defn vector-zip\n  \"Returns a zipper for nested vectors, given a root vector\"\n  {:added \"1.0\"}\n  [root]\n    (zipper vector?\n            seq\n            (fn [node children] (with-meta (vec children) (meta node)))\n            root))\n\n(defn xml-zip\n  \"Returns a zipper for xml elements (as from xml/parse),\n  given a root element\"\n  {:added \"1.0\"}\n  [root]\n    (zipper (complement string?) \n            (comp seq :content)\n            (fn [node children]\n              (assoc node :content (and children (apply vector children))))\n            root))\n\n(defn node\n  \"Returns the node at loc\"\n  {:added \"1.0\"}\n  [loc] (loc 0))\n\n(defn branch?\n  \"Returns true if the node at loc is a branch\"\n  {:added \"1.0\"}\n  [loc]\n    ((:zip/branch? (meta loc)) (node loc)))\n\n(defn children\n  \"Returns a seq of the children of node at loc, which must be a branch\"\n  {:added \"1.0\"}\n  [loc]\n    (if (branch? loc)\n      ((:zip/children (meta loc)) (node loc))\n      (throw (Exception. \"called children on a leaf node\"))))\n\n(defn make-node\n  \"Returns a new branch node, given an existing node and new\n  children. The loc is only used to supply the constructor.\"\n  {:added \"1.0\"}\n  [loc node children]\n    ((:zip/make-node (meta loc)) node children))\n\n(defn path\n  \"Returns a seq of nodes leading to this loc\"\n  {:added \"1.0\"}\n  [loc]\n    (:pnodes (loc 1)))\n\n(defn lefts\n  \"Returns a seq of the left siblings of this loc\"\n  {:added \"1.0\"}\n  [loc]\n    (seq (:l (loc 1))))\n\n(defn rights\n  \"Returns a seq of the right siblings of this loc\"\n  {:added \"1.0\"}\n  [loc]\n    (:r (loc 1)))\n\n\n(defn down\n  \"Returns the loc of the leftmost child of the node at this loc, or\n  nil if no children\"\n  {:added \"1.0\"}\n  [loc]\n    (when (branch? loc)\n      (let [[node path] loc\n            [c & cnext :as cs] (children loc)]\n        (when cs\n          (with-meta [c {:l [] \n                         :pnodes (if path (conj (:pnodes path) node) [node]) \n                         :ppath path \n                         :r cnext}] (meta loc))))))\n\n(defn up\n  \"Returns the loc of the parent of the node at this loc, or nil if at\n  the top\"\n  {:added \"1.0\"}\n  [loc]\n    (let [[node {l :l, ppath :ppath, pnodes :pnodes r :r, changed? :changed?, :as path}] loc]\n      (when pnodes\n        (let [pnode (peek pnodes)]\n          (with-meta (if changed?\n                       [(make-node loc pnode (concat l (cons node r))) \n                        (and ppath (assoc ppath :changed? true))]\n                       [pnode ppath])\n                     (meta loc))))))\n\n(defn root\n  \"zips all the way up and returns the root node, reflecting any\n changes.\"\n  {:added \"1.0\"}\n  [loc]\n    (if (= :end (loc 1))\n      (node loc)\n      (let [p (up loc)]\n        (if p\n          (recur p)\n          (node loc)))))\n\n(defn right\n  \"Returns the loc of the right sibling of the node at this loc, or nil\"\n  {:added \"1.0\"}\n  [loc]\n    (let [[node {l :l  [r & rnext :as rs] :r :as path}] loc]\n      (when (and path rs)\n        (with-meta [r (assoc path :l (conj l node) :r rnext)] (meta loc)))))\n\n(defn rightmost\n  \"Returns the loc of the rightmost sibling of the node at this loc, or self\"\n  {:added \"1.0\"}\n  [loc]\n    (let [[node {l :l r :r :as path}] loc]\n      (if (and path r)\n        (with-meta [(last r) (assoc path :l (apply conj l node (butlast r)) :r nil)] (meta loc))\n        loc)))\n\n(defn left\n  \"Returns the loc of the left sibling of the node at this loc, or nil\"\n  {:added \"1.0\"}\n  [loc]\n    (let [[node {l :l r :r :as path}] loc]\n      (when (and path (seq l))\n        (with-meta [(peek l) (assoc path :l (pop l) :r (cons node r))] (meta loc)))))\n\n(defn leftmost\n  \"Returns the loc of the leftmost sibling of the node at this loc, or self\"\n  {:added \"1.0\"}\n  [loc]\n    (let [[node {l :l r :r :as path}] loc]\n      (if (and path (seq l))\n        (with-meta [(first l) (assoc path :l [] :r (concat (rest l) [node] r))] (meta loc))\n        loc)))\n\n(defn insert-left\n  \"Inserts the item as the left sibling of the node at this loc,\n without moving\"\n  {:added \"1.0\"}\n  [loc item]\n    (let [[node {l :l :as path}] loc]\n      (if (nil? path)\n        (throw (new Exception \"Insert at top\"))\n        (with-meta [node (assoc path :l (conj l item) :changed? true)] (meta loc)))))\n\n(defn insert-right\n  \"Inserts the item as the right sibling of the node at this loc,\n  without moving\"\n  {:added \"1.0\"}\n  [loc item]\n    (let [[node {r :r :as path}] loc]\n      (if (nil? path)\n        (throw (new Exception \"Insert at top\"))\n        (with-meta [node (assoc path :r (cons item r) :changed? true)] (meta loc)))))\n\n(defn replace\n  \"Replaces the node at this loc, without moving\"\n  {:added \"1.0\"}\n  [loc node]\n    (let [[_ path] loc]\n      (with-meta [node (assoc path :changed? true)] (meta loc))))\n\n(defn edit\n  \"Replaces the node at this loc with the value of (f node args)\"\n  {:added \"1.0\"}\n  [loc f & args]\n    (replace loc (apply f (node loc) args)))\n\n(defn insert-child\n  \"Inserts the item as the leftmost child of the node at this loc,\n  without moving\"\n  {:added \"1.0\"}\n  [loc item]\n    (replace loc (make-node loc (node loc) (cons item (children loc)))))\n\n(defn append-child\n  \"Inserts the item as the rightmost child of the node at this loc,\n  without moving\"\n  {:added \"1.0\"}\n  [loc item]\n    (replace loc (make-node loc (node loc) (concat (children loc) [item]))))\n\n(defn next\n  \"Moves to the next loc in the hierarchy, depth-first. When reaching\n  the end, returns a distinguished loc detectable via end?. If already\n  at the end, stays there.\"\n  {:added \"1.0\"}\n  [loc]\n    (if (= :end (loc 1))\n      loc\n      (or \n       (and (branch? loc) (down loc))\n       (right loc)\n       (loop [p loc]\n         (if (up p)\n           (or (right (up p)) (recur (up p)))\n           [(node p) :end])))))\n\n(defn prev\n  \"Moves to the previous loc in the hierarchy, depth-first. If already\n  at the root, returns nil.\"\n  {:added \"1.0\"}\n  [loc]\n    (if-let [lloc (left loc)]\n      (loop [loc lloc]\n        (if-let [child (and (branch? loc) (down loc))]\n          (recur (rightmost child))\n          loc))\n      (up loc)))\n\n(defn end?\n  \"Returns true if loc represents the end of a depth-first walk\"\n  {:added \"1.0\"}\n  [loc]\n    (= :end (loc 1)))\n\n(defn remove\n  \"Removes the node at loc, returning the loc that would have preceded\n  it in a depth-first walk.\"\n  {:added \"1.0\"}\n  [loc]\n    (let [[node {l :l, ppath :ppath, pnodes :pnodes, rs :r, :as path}] loc]\n      (if (nil? path)\n        (throw (new Exception \"Remove at top\"))\n        (if (pos? (count l))\n          (loop [loc (with-meta [(peek l) (assoc path :l (pop l) :changed? true)] (meta loc))]\n            (if-let [child (and (branch? loc) (down loc))]\n              (recur (rightmost child))\n              loc))\n          (with-meta [(make-node loc (peek pnodes) rs) \n                      (and ppath (assoc ppath :changed? true))]\n                     (meta loc))))))\n  \n(comment\n\n(load-file \"/Users/rich/dev/clojure/src/zip.clj\")\n(refer 'zip)\n(def data '[[a * b] + [c * d]])\n(def dz (vector-zip data))\n\n(right (down (right (right (down dz)))))\n(lefts (right (down (right (right (down dz))))))\n(rights (right (down (right (right (down dz))))))\n(up (up (right (down (right (right (down dz)))))))\n(path (right (down (right (right (down dz))))))\n\n(-> dz down right right down right)\n(-> dz down right right down right (replace '/) root)\n(-> dz next next (edit str) next next next (replace '/) root)\n(-> dz next next next next next next next next next remove root)\n(-> dz next next next next next next next next next remove (insert-right 'e) root)\n(-> dz next next next next next next next next next remove up (append-child 'e) root)\n\n(end? (-> dz next next next next next next next next next remove next))\n\n(-> dz next remove next remove root)\n\n(loop [loc dz]\n  (if (end? loc)\n    (root loc)\n    (recur (next (if (= '* (node loc)) \n                   (replace loc '/)\n                   loc)))))\n\n(loop [loc dz]\n  (if (end? loc)\n    (root loc)\n    (recur (next (if (= '* (node loc)) \n                   (remove loc)\n                   loc)))))\n)\n"
  },
  {
    "path": "src/ffi/ffi.h",
    "content": "#ifdef __arm64__\n\n#include \"ffi_arm64.h\"\n\n\n#endif\n#ifdef __i386__\n\n#include \"ffi_i386.h\"\n\n\n#endif\n#ifdef __arm__\n\n#include \"ffi_armv7.h\"\n\n\n#endif\n#ifdef __x86_64__\n\n#include \"ffi_x86_64.h\"\n\n\n#endif\n"
  },
  {
    "path": "src/ffi/ffi_arm64.h",
    "content": "#ifdef __arm64__\n\n/* -----------------------------------------------------------------*-C-*-\n   libffi 3.1-rc1 - Copyright (c) 2011 Anthony Green\n                    - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.\n\n   Permission is hereby granted, free of charge, to any person\n   obtaining a copy of this software and associated documentation\n   files (the ``Software''), to deal in the Software without\n   restriction, including without limitation the rights to use, copy,\n   modify, merge, publish, distribute, sublicense, and/or sell copies\n   of the Software, and to permit persons to whom the Software is\n   furnished to do so, subject to the following conditions:\n\n   The above copyright notice and this permission notice shall be\n   included in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n   DEALINGS IN THE SOFTWARE.\n\n   ----------------------------------------------------------------------- */\n\n/* -------------------------------------------------------------------\n   The basic API is described in the README file.\n\n   The raw API is designed to bypass some of the argument packing\n   and unpacking on architectures for which it can be avoided.\n\n   The closure API allows interpreted functions to be packaged up\n   inside a C function pointer, so that they can be called as C functions,\n   with no understanding on the client side that they are interpreted.\n   It can also be used in other cases in which it is necessary to package\n   up a user specified parameter and a function pointer as a single\n   function pointer.\n\n   The closure API must be implemented in order to get its functionality,\n   e.g. for use by gij.  Routines are provided to emulate the raw API\n   if the underlying platform doesn't allow faster implementation.\n\n   More details on the raw and cloure API can be found in:\n\n   http://gcc.gnu.org/ml/java/1999-q3/msg00138.html\n\n   and\n\n   http://gcc.gnu.org/ml/java/1999-q3/msg00174.html\n   -------------------------------------------------------------------- */\n\n#ifndef LIBFFI_H\n#define LIBFFI_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Specify which architecture libffi is configured for. */\n#ifndef AARCH64\n#define AARCH64\n#endif\n\n/* ---- System configuration information --------------------------------- */\n\n#include \"ffitarget.h\"\n\n#ifndef LIBFFI_ASM\n\n#ifdef _MSC_VER\n#define __attribute__(X)\n#endif\n\n#include <stddef.h>\n#include <limits.h>\n\n/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).\n   But we can find it either under the correct ANSI name, or under GNU\n   C's internal name.  */\n\n#define FFI_64_BIT_MAX 9223372036854775807\n\n#ifdef LONG_LONG_MAX\n# define FFI_LONG_LONG_MAX LONG_LONG_MAX\n#else\n# ifdef LLONG_MAX\n#  define FFI_LONG_LONG_MAX LLONG_MAX\n#  ifdef _AIX52 /* or newer has C99 LLONG_MAX */\n#   undef FFI_64_BIT_MAX\n#   define FFI_64_BIT_MAX 9223372036854775807LL\n#  endif /* _AIX52 or newer */\n# else\n#  ifdef __GNUC__\n#   define FFI_LONG_LONG_MAX __LONG_LONG_MAX__\n#  endif\n#  ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */\n#   ifndef __PPC64__\n#    if defined (__IBMC__) || defined (__IBMCPP__)\n#     define FFI_LONG_LONG_MAX LONGLONG_MAX\n#    endif\n#   endif /* __PPC64__ */\n#   undef  FFI_64_BIT_MAX\n#   define FFI_64_BIT_MAX 9223372036854775807LL\n#  endif\n# endif\n#endif\n\n/* The closure code assumes that this works on pointers, i.e. a size_t\t*/\n/* can hold a pointer.\t\t\t\t\t\t\t*/\n\ntypedef struct _ffi_type\n{\n  size_t size;\n  unsigned short alignment;\n  unsigned short type;\n  struct _ffi_type **elements;\n} ffi_type;\n\n#ifndef LIBFFI_HIDE_BASIC_TYPES\n#if SCHAR_MAX == 127\n# define ffi_type_uchar                ffi_type_uint8\n# define ffi_type_schar                ffi_type_sint8\n#else\n #error \"char size not supported\"\n#endif\n\n#if SHRT_MAX == 32767\n# define ffi_type_ushort       ffi_type_uint16\n# define ffi_type_sshort       ffi_type_sint16\n#elif SHRT_MAX == 2147483647\n# define ffi_type_ushort       ffi_type_uint32\n# define ffi_type_sshort       ffi_type_sint32\n#else\n #error \"short size not supported\"\n#endif\n\n#if INT_MAX == 32767\n# define ffi_type_uint         ffi_type_uint16\n# define ffi_type_sint         ffi_type_sint16\n#elif INT_MAX == 2147483647\n# define ffi_type_uint         ffi_type_uint32\n# define ffi_type_sint         ffi_type_sint32\n#elif INT_MAX == 9223372036854775807\n# define ffi_type_uint         ffi_type_uint64\n# define ffi_type_sint         ffi_type_sint64\n#else\n #error \"int size not supported\"\n#endif\n\n#if LONG_MAX == 2147483647\n# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX\n #error \"no 64-bit data type supported\"\n# endif\n#elif LONG_MAX != FFI_64_BIT_MAX\n #error \"long size not supported\"\n#endif\n\n#if LONG_MAX == 2147483647\n# define ffi_type_ulong        ffi_type_uint32\n# define ffi_type_slong        ffi_type_sint32\n#elif LONG_MAX == FFI_64_BIT_MAX\n# define ffi_type_ulong        ffi_type_uint64\n# define ffi_type_slong        ffi_type_sint64\n#else\n #error \"long size not supported\"\n#endif\n\n/* Need minimal decorations for DLLs to works on Windows. */\n/* GCC has autoimport and autoexport.  Rely on Libtool to */\n/* help MSVC export from a DLL, but always declare data   */\n/* to be imported for MSVC clients.  This costs an extra  */\n/* indirection for MSVC clients using the static version  */\n/* of the library, but don't worry about that.  Besides,  */\n/* as a workaround, they can define FFI_BUILDING if they  */\n/* *know* they are going to link with the static library. */\n#if defined _MSC_VER && !defined FFI_BUILDING\n#define FFI_EXTERN extern __declspec(dllimport)\n#else\n#define FFI_EXTERN extern\n#endif\n\n/* These are defined in types.c */\nFFI_EXTERN ffi_type ffi_type_void;\nFFI_EXTERN ffi_type ffi_type_uint8;\nFFI_EXTERN ffi_type ffi_type_sint8;\nFFI_EXTERN ffi_type ffi_type_uint16;\nFFI_EXTERN ffi_type ffi_type_sint16;\nFFI_EXTERN ffi_type ffi_type_uint32;\nFFI_EXTERN ffi_type ffi_type_sint32;\nFFI_EXTERN ffi_type ffi_type_uint64;\nFFI_EXTERN ffi_type ffi_type_sint64;\nFFI_EXTERN ffi_type ffi_type_float;\nFFI_EXTERN ffi_type ffi_type_double;\nFFI_EXTERN ffi_type ffi_type_pointer;\n\n#if 0\nFFI_EXTERN ffi_type ffi_type_longdouble;\n#else\n#define ffi_type_longdouble ffi_type_double\n#endif\n#endif /* LIBFFI_HIDE_BASIC_TYPES */\n\ntypedef enum {\n  FFI_OK = 0,\n  FFI_BAD_TYPEDEF,\n  FFI_BAD_ABI\n} ffi_status;\n\ntypedef unsigned FFI_TYPE;\n\ntypedef struct {\n  ffi_abi abi;\n  unsigned nargs;\n  ffi_type **arg_types;\n  ffi_type *rtype;\n  unsigned bytes;\n  unsigned flags;\n#ifdef FFI_EXTRA_CIF_FIELDS\n  FFI_EXTRA_CIF_FIELDS;\n#endif\n} ffi_cif;\n\n#if HAVE_LONG_DOUBLE_VARIANT\n/* Used to adjust size/alignment of ffi types.  */\nvoid ffi_prep_types (ffi_abi abi);\n# endif\n\n/* Used internally, but overridden by some architectures */\nffi_status ffi_prep_cif_core(ffi_cif *cif,\n\t\t\t     ffi_abi abi,\n\t\t\t     unsigned int isvariadic,\n\t\t\t     unsigned int nfixedargs,\n\t\t\t     unsigned int ntotalargs,\n\t\t\t     ffi_type *rtype,\n\t\t\t     ffi_type **atypes);\n\n/* ---- Definitions for the raw API -------------------------------------- */\n\n#ifndef FFI_SIZEOF_ARG\n# if LONG_MAX == 2147483647\n#  define FFI_SIZEOF_ARG        4\n# elif LONG_MAX == FFI_64_BIT_MAX\n#  define FFI_SIZEOF_ARG        8\n# endif\n#endif\n\n#ifndef FFI_SIZEOF_JAVA_RAW\n#  define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG\n#endif\n\ntypedef union {\n  ffi_sarg  sint;\n  ffi_arg   uint;\n  float\t    flt;\n  char      data[FFI_SIZEOF_ARG];\n  void*     ptr;\n} ffi_raw;\n\n#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8\n/* This is a special case for mips64/n32 ABI (and perhaps others) where\n   sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8.  */\ntypedef union {\n  signed int\tsint;\n  unsigned int\tuint;\n  float\t\tflt;\n  char\t\tdata[FFI_SIZEOF_JAVA_RAW];\n  void*\t\tptr;\n} ffi_java_raw;\n#else\ntypedef ffi_raw ffi_java_raw;\n#endif\n\n\nvoid ffi_raw_call (ffi_cif *cif,\n\t\t   void (*fn)(void),\n\t\t   void *rvalue,\n\t\t   ffi_raw *avalue);\n\nvoid ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);\nvoid ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);\nsize_t ffi_raw_size (ffi_cif *cif);\n\n/* This is analogous to the raw API, except it uses Java parameter\t*/\n/* packing, even on 64-bit machines.  I.e. on 64-bit machines\t\t*/\n/* longs and doubles are followed by an empty 64-bit word.\t\t*/\n\nvoid ffi_java_raw_call (ffi_cif *cif,\n\t\t\tvoid (*fn)(void),\n\t\t\tvoid *rvalue,\n\t\t\tffi_java_raw *avalue);\n\nvoid ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw);\nvoid ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args);\nsize_t ffi_java_raw_size (ffi_cif *cif);\n\n/* ---- Definitions for closures ----------------------------------------- */\n\n#if FFI_CLOSURES\n\n#ifdef _MSC_VER\n__declspec(align(8))\n#endif\ntypedef struct {\n#if 0\n  void *trampoline_table;\n  void *trampoline_table_entry;\n#else\n  char tramp[FFI_TRAMPOLINE_SIZE];\n#endif\n  ffi_cif   *cif;\n  void     (*fun)(ffi_cif*,void*,void**,void*);\n  void      *user_data;\n#ifdef __GNUC__\n} ffi_closure __attribute__((aligned (8)));\n#else\n} ffi_closure;\n# ifdef __sgi\n#  pragma pack 0\n# endif\n#endif\n\nvoid *ffi_closure_alloc (size_t size, void **code);\nvoid ffi_closure_free (void *);\n\nffi_status\nffi_prep_closure (ffi_closure*,\n\t\t  ffi_cif *,\n\t\t  void (*fun)(ffi_cif*,void*,void**,void*),\n\t\t  void *user_data);\n\nffi_status\nffi_prep_closure_loc (ffi_closure*,\n\t\t      ffi_cif *,\n\t\t      void (*fun)(ffi_cif*,void*,void**,void*),\n\t\t      void *user_data,\n\t\t      void*codeloc);\n\n#ifdef __sgi\n# pragma pack 8\n#endif\ntypedef struct {\n#if 0\n  void *trampoline_table;\n  void *trampoline_table_entry;\n#else\n  char tramp[FFI_TRAMPOLINE_SIZE];\n#endif\n  ffi_cif   *cif;\n\n#if !FFI_NATIVE_RAW_API\n\n  /* if this is enabled, then a raw closure has the same layout \n     as a regular closure.  We use this to install an intermediate \n     handler to do the transaltion, void** -> ffi_raw*. */\n\n  void     (*translate_args)(ffi_cif*,void*,void**,void*);\n  void      *this_closure;\n\n#endif\n\n  void     (*fun)(ffi_cif*,void*,ffi_raw*,void*);\n  void      *user_data;\n\n} ffi_raw_closure;\n\ntypedef struct {\n#if 0\n  void *trampoline_table;\n  void *trampoline_table_entry;\n#else\n  char tramp[FFI_TRAMPOLINE_SIZE];\n#endif\n\n  ffi_cif   *cif;\n\n#if !FFI_NATIVE_RAW_API\n\n  /* if this is enabled, then a raw closure has the same layout \n     as a regular closure.  We use this to install an intermediate \n     handler to do the transaltion, void** -> ffi_raw*. */\n\n  void     (*translate_args)(ffi_cif*,void*,void**,void*);\n  void      *this_closure;\n\n#endif\n\n  void     (*fun)(ffi_cif*,void*,ffi_java_raw*,void*);\n  void      *user_data;\n\n} ffi_java_raw_closure;\n\nffi_status\nffi_prep_raw_closure (ffi_raw_closure*,\n\t\t      ffi_cif *cif,\n\t\t      void (*fun)(ffi_cif*,void*,ffi_raw*,void*),\n\t\t      void *user_data);\n\nffi_status\nffi_prep_raw_closure_loc (ffi_raw_closure*,\n\t\t\t  ffi_cif *cif,\n\t\t\t  void (*fun)(ffi_cif*,void*,ffi_raw*,void*),\n\t\t\t  void *user_data,\n\t\t\t  void *codeloc);\n\nffi_status\nffi_prep_java_raw_closure (ffi_java_raw_closure*,\n\t\t           ffi_cif *cif,\n\t\t           void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),\n\t\t           void *user_data);\n\nffi_status\nffi_prep_java_raw_closure_loc (ffi_java_raw_closure*,\n\t\t\t       ffi_cif *cif,\n\t\t\t       void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),\n\t\t\t       void *user_data,\n\t\t\t       void *codeloc);\n\n#endif /* FFI_CLOSURES */\n\n/* ---- Public interface definition -------------------------------------- */\n\nffi_status ffi_prep_cif(ffi_cif *cif,\n\t\t\tffi_abi abi,\n\t\t\tunsigned int nargs,\n\t\t\tffi_type *rtype,\n\t\t\tffi_type **atypes);\n\nffi_status ffi_prep_cif_var(ffi_cif *cif,\n\t\t\t    ffi_abi abi,\n\t\t\t    unsigned int nfixedargs,\n\t\t\t    unsigned int ntotalargs,\n\t\t\t    ffi_type *rtype,\n\t\t\t    ffi_type **atypes);\n\nvoid ffi_call(ffi_cif *cif,\n\t      void (*fn)(void),\n\t      void *rvalue,\n\t      void **avalue);\n\n/* Useful for eliminating compiler warnings */\n#define FFI_FN(f) ((void (*)(void))f)\n\n/* ---- Definitions shared with assembly code ---------------------------- */\n\n#endif\n\n/* If these change, update src/mips/ffitarget.h. */\n#define FFI_TYPE_VOID       0    \n#define FFI_TYPE_INT        1\n#define FFI_TYPE_FLOAT      2    \n#define FFI_TYPE_DOUBLE     3\n#if 0\n#define FFI_TYPE_LONGDOUBLE 4\n#else\n#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE\n#endif\n#define FFI_TYPE_UINT8      5   \n#define FFI_TYPE_SINT8      6\n#define FFI_TYPE_UINT16     7 \n#define FFI_TYPE_SINT16     8\n#define FFI_TYPE_UINT32     9\n#define FFI_TYPE_SINT32     10\n#define FFI_TYPE_UINT64     11\n#define FFI_TYPE_SINT64     12\n#define FFI_TYPE_STRUCT     13\n#define FFI_TYPE_POINTER    14\n\n/* This should always refer to the last type code (for sanity checks) */\n#define FFI_TYPE_LAST       FFI_TYPE_POINTER\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n\n#endif"
  },
  {
    "path": "src/ffi/ffi_armv7.h",
    "content": "#ifdef __arm__\n\n/* -----------------------------------------------------------------*-C-*-\n   libffi 3.1-rc1 - Copyright (c) 2011 Anthony Green\n                    - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.\n\n   Permission is hereby granted, free of charge, to any person\n   obtaining a copy of this software and associated documentation\n   files (the ``Software''), to deal in the Software without\n   restriction, including without limitation the rights to use, copy,\n   modify, merge, publish, distribute, sublicense, and/or sell copies\n   of the Software, and to permit persons to whom the Software is\n   furnished to do so, subject to the following conditions:\n\n   The above copyright notice and this permission notice shall be\n   included in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n   DEALINGS IN THE SOFTWARE.\n\n   ----------------------------------------------------------------------- */\n\n/* -------------------------------------------------------------------\n   The basic API is described in the README file.\n\n   The raw API is designed to bypass some of the argument packing\n   and unpacking on architectures for which it can be avoided.\n\n   The closure API allows interpreted functions to be packaged up\n   inside a C function pointer, so that they can be called as C functions,\n   with no understanding on the client side that they are interpreted.\n   It can also be used in other cases in which it is necessary to package\n   up a user specified parameter and a function pointer as a single\n   function pointer.\n\n   The closure API must be implemented in order to get its functionality,\n   e.g. for use by gij.  Routines are provided to emulate the raw API\n   if the underlying platform doesn't allow faster implementation.\n\n   More details on the raw and cloure API can be found in:\n\n   http://gcc.gnu.org/ml/java/1999-q3/msg00138.html\n\n   and\n\n   http://gcc.gnu.org/ml/java/1999-q3/msg00174.html\n   -------------------------------------------------------------------- */\n\n#ifndef LIBFFI_H\n#define LIBFFI_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Specify which architecture libffi is configured for. */\n#ifndef ARM\n#define ARM\n#endif\n\n/* ---- System configuration information --------------------------------- */\n\n#include \"ffitarget.h\"\n\n#ifndef LIBFFI_ASM\n\n#ifdef _MSC_VER\n#define __attribute__(X)\n#endif\n\n#include <stddef.h>\n#include <limits.h>\n\n/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).\n   But we can find it either under the correct ANSI name, or under GNU\n   C's internal name.  */\n\n#define FFI_64_BIT_MAX 9223372036854775807\n\n#ifdef LONG_LONG_MAX\n# define FFI_LONG_LONG_MAX LONG_LONG_MAX\n#else\n# ifdef LLONG_MAX\n#  define FFI_LONG_LONG_MAX LLONG_MAX\n#  ifdef _AIX52 /* or newer has C99 LLONG_MAX */\n#   undef FFI_64_BIT_MAX\n#   define FFI_64_BIT_MAX 9223372036854775807LL\n#  endif /* _AIX52 or newer */\n# else\n#  ifdef __GNUC__\n#   define FFI_LONG_LONG_MAX __LONG_LONG_MAX__\n#  endif\n#  ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */\n#   ifndef __PPC64__\n#    if defined (__IBMC__) || defined (__IBMCPP__)\n#     define FFI_LONG_LONG_MAX LONGLONG_MAX\n#    endif\n#   endif /* __PPC64__ */\n#   undef  FFI_64_BIT_MAX\n#   define FFI_64_BIT_MAX 9223372036854775807LL\n#  endif\n# endif\n#endif\n\n/* The closure code assumes that this works on pointers, i.e. a size_t\t*/\n/* can hold a pointer.\t\t\t\t\t\t\t*/\n\ntypedef struct _ffi_type\n{\n  size_t size;\n  unsigned short alignment;\n  unsigned short type;\n  struct _ffi_type **elements;\n} ffi_type;\n\n#ifndef LIBFFI_HIDE_BASIC_TYPES\n#if SCHAR_MAX == 127\n# define ffi_type_uchar                ffi_type_uint8\n# define ffi_type_schar                ffi_type_sint8\n#else\n #error \"char size not supported\"\n#endif\n\n#if SHRT_MAX == 32767\n# define ffi_type_ushort       ffi_type_uint16\n# define ffi_type_sshort       ffi_type_sint16\n#elif SHRT_MAX == 2147483647\n# define ffi_type_ushort       ffi_type_uint32\n# define ffi_type_sshort       ffi_type_sint32\n#else\n #error \"short size not supported\"\n#endif\n\n#if INT_MAX == 32767\n# define ffi_type_uint         ffi_type_uint16\n# define ffi_type_sint         ffi_type_sint16\n#elif INT_MAX == 2147483647\n# define ffi_type_uint         ffi_type_uint32\n# define ffi_type_sint         ffi_type_sint32\n#elif INT_MAX == 9223372036854775807\n# define ffi_type_uint         ffi_type_uint64\n# define ffi_type_sint         ffi_type_sint64\n#else\n #error \"int size not supported\"\n#endif\n\n#if LONG_MAX == 2147483647\n# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX\n #error \"no 64-bit data type supported\"\n# endif\n#elif LONG_MAX != FFI_64_BIT_MAX\n #error \"long size not supported\"\n#endif\n\n#if LONG_MAX == 2147483647\n# define ffi_type_ulong        ffi_type_uint32\n# define ffi_type_slong        ffi_type_sint32\n#elif LONG_MAX == FFI_64_BIT_MAX\n# define ffi_type_ulong        ffi_type_uint64\n# define ffi_type_slong        ffi_type_sint64\n#else\n #error \"long size not supported\"\n#endif\n\n/* Need minimal decorations for DLLs to works on Windows. */\n/* GCC has autoimport and autoexport.  Rely on Libtool to */\n/* help MSVC export from a DLL, but always declare data   */\n/* to be imported for MSVC clients.  This costs an extra  */\n/* indirection for MSVC clients using the static version  */\n/* of the library, but don't worry about that.  Besides,  */\n/* as a workaround, they can define FFI_BUILDING if they  */\n/* *know* they are going to link with the static library. */\n#if defined _MSC_VER && !defined FFI_BUILDING\n#define FFI_EXTERN extern __declspec(dllimport)\n#else\n#define FFI_EXTERN extern\n#endif\n\n/* These are defined in types.c */\nFFI_EXTERN ffi_type ffi_type_void;\nFFI_EXTERN ffi_type ffi_type_uint8;\nFFI_EXTERN ffi_type ffi_type_sint8;\nFFI_EXTERN ffi_type ffi_type_uint16;\nFFI_EXTERN ffi_type ffi_type_sint16;\nFFI_EXTERN ffi_type ffi_type_uint32;\nFFI_EXTERN ffi_type ffi_type_sint32;\nFFI_EXTERN ffi_type ffi_type_uint64;\nFFI_EXTERN ffi_type ffi_type_sint64;\nFFI_EXTERN ffi_type ffi_type_float;\nFFI_EXTERN ffi_type ffi_type_double;\nFFI_EXTERN ffi_type ffi_type_pointer;\n\n#if 0\nFFI_EXTERN ffi_type ffi_type_longdouble;\n#else\n#define ffi_type_longdouble ffi_type_double\n#endif\n#endif /* LIBFFI_HIDE_BASIC_TYPES */\n\ntypedef enum {\n  FFI_OK = 0,\n  FFI_BAD_TYPEDEF,\n  FFI_BAD_ABI\n} ffi_status;\n\ntypedef unsigned FFI_TYPE;\n\ntypedef struct {\n  ffi_abi abi;\n  unsigned nargs;\n  ffi_type **arg_types;\n  ffi_type *rtype;\n  unsigned bytes;\n  unsigned flags;\n#ifdef FFI_EXTRA_CIF_FIELDS\n  FFI_EXTRA_CIF_FIELDS;\n#endif\n} ffi_cif;\n\n#if HAVE_LONG_DOUBLE_VARIANT\n/* Used to adjust size/alignment of ffi types.  */\nvoid ffi_prep_types (ffi_abi abi);\n# endif\n\n/* Used internally, but overridden by some architectures */\nffi_status ffi_prep_cif_core(ffi_cif *cif,\n\t\t\t     ffi_abi abi,\n\t\t\t     unsigned int isvariadic,\n\t\t\t     unsigned int nfixedargs,\n\t\t\t     unsigned int ntotalargs,\n\t\t\t     ffi_type *rtype,\n\t\t\t     ffi_type **atypes);\n\n/* ---- Definitions for the raw API -------------------------------------- */\n\n#ifndef FFI_SIZEOF_ARG\n# if LONG_MAX == 2147483647\n#  define FFI_SIZEOF_ARG        4\n# elif LONG_MAX == FFI_64_BIT_MAX\n#  define FFI_SIZEOF_ARG        8\n# endif\n#endif\n\n#ifndef FFI_SIZEOF_JAVA_RAW\n#  define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG\n#endif\n\ntypedef union {\n  ffi_sarg  sint;\n  ffi_arg   uint;\n  float\t    flt;\n  char      data[FFI_SIZEOF_ARG];\n  void*     ptr;\n} ffi_raw;\n\n#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8\n/* This is a special case for mips64/n32 ABI (and perhaps others) where\n   sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8.  */\ntypedef union {\n  signed int\tsint;\n  unsigned int\tuint;\n  float\t\tflt;\n  char\t\tdata[FFI_SIZEOF_JAVA_RAW];\n  void*\t\tptr;\n} ffi_java_raw;\n#else\ntypedef ffi_raw ffi_java_raw;\n#endif\n\n\nvoid ffi_raw_call (ffi_cif *cif,\n\t\t   void (*fn)(void),\n\t\t   void *rvalue,\n\t\t   ffi_raw *avalue);\n\nvoid ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);\nvoid ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);\nsize_t ffi_raw_size (ffi_cif *cif);\n\n/* This is analogous to the raw API, except it uses Java parameter\t*/\n/* packing, even on 64-bit machines.  I.e. on 64-bit machines\t\t*/\n/* longs and doubles are followed by an empty 64-bit word.\t\t*/\n\nvoid ffi_java_raw_call (ffi_cif *cif,\n\t\t\tvoid (*fn)(void),\n\t\t\tvoid *rvalue,\n\t\t\tffi_java_raw *avalue);\n\nvoid ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw);\nvoid ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args);\nsize_t ffi_java_raw_size (ffi_cif *cif);\n\n/* ---- Definitions for closures ----------------------------------------- */\n\n#if FFI_CLOSURES\n\n#ifdef _MSC_VER\n__declspec(align(8))\n#endif\ntypedef struct {\n#if 1\n  void *trampoline_table;\n  void *trampoline_table_entry;\n#else\n  char tramp[FFI_TRAMPOLINE_SIZE];\n#endif\n  ffi_cif   *cif;\n  void     (*fun)(ffi_cif*,void*,void**,void*);\n  void      *user_data;\n#ifdef __GNUC__\n} ffi_closure __attribute__((aligned (8)));\n#else\n} ffi_closure;\n# ifdef __sgi\n#  pragma pack 0\n# endif\n#endif\n\nvoid *ffi_closure_alloc (size_t size, void **code);\nvoid ffi_closure_free (void *);\n\nffi_status\nffi_prep_closure (ffi_closure*,\n\t\t  ffi_cif *,\n\t\t  void (*fun)(ffi_cif*,void*,void**,void*),\n\t\t  void *user_data);\n\nffi_status\nffi_prep_closure_loc (ffi_closure*,\n\t\t      ffi_cif *,\n\t\t      void (*fun)(ffi_cif*,void*,void**,void*),\n\t\t      void *user_data,\n\t\t      void*codeloc);\n\n#ifdef __sgi\n# pragma pack 8\n#endif\ntypedef struct {\n#if 1\n  void *trampoline_table;\n  void *trampoline_table_entry;\n#else\n  char tramp[FFI_TRAMPOLINE_SIZE];\n#endif\n  ffi_cif   *cif;\n\n#if !FFI_NATIVE_RAW_API\n\n  /* if this is enabled, then a raw closure has the same layout \n     as a regular closure.  We use this to install an intermediate \n     handler to do the transaltion, void** -> ffi_raw*. */\n\n  void     (*translate_args)(ffi_cif*,void*,void**,void*);\n  void      *this_closure;\n\n#endif\n\n  void     (*fun)(ffi_cif*,void*,ffi_raw*,void*);\n  void      *user_data;\n\n} ffi_raw_closure;\n\ntypedef struct {\n#if 1\n  void *trampoline_table;\n  void *trampoline_table_entry;\n#else\n  char tramp[FFI_TRAMPOLINE_SIZE];\n#endif\n\n  ffi_cif   *cif;\n\n#if !FFI_NATIVE_RAW_API\n\n  /* if this is enabled, then a raw closure has the same layout \n     as a regular closure.  We use this to install an intermediate \n     handler to do the transaltion, void** -> ffi_raw*. */\n\n  void     (*translate_args)(ffi_cif*,void*,void**,void*);\n  void      *this_closure;\n\n#endif\n\n  void     (*fun)(ffi_cif*,void*,ffi_java_raw*,void*);\n  void      *user_data;\n\n} ffi_java_raw_closure;\n\nffi_status\nffi_prep_raw_closure (ffi_raw_closure*,\n\t\t      ffi_cif *cif,\n\t\t      void (*fun)(ffi_cif*,void*,ffi_raw*,void*),\n\t\t      void *user_data);\n\nffi_status\nffi_prep_raw_closure_loc (ffi_raw_closure*,\n\t\t\t  ffi_cif *cif,\n\t\t\t  void (*fun)(ffi_cif*,void*,ffi_raw*,void*),\n\t\t\t  void *user_data,\n\t\t\t  void *codeloc);\n\nffi_status\nffi_prep_java_raw_closure (ffi_java_raw_closure*,\n\t\t           ffi_cif *cif,\n\t\t           void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),\n\t\t           void *user_data);\n\nffi_status\nffi_prep_java_raw_closure_loc (ffi_java_raw_closure*,\n\t\t\t       ffi_cif *cif,\n\t\t\t       void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),\n\t\t\t       void *user_data,\n\t\t\t       void *codeloc);\n\n#endif /* FFI_CLOSURES */\n\n/* ---- Public interface definition -------------------------------------- */\n\nffi_status ffi_prep_cif(ffi_cif *cif,\n\t\t\tffi_abi abi,\n\t\t\tunsigned int nargs,\n\t\t\tffi_type *rtype,\n\t\t\tffi_type **atypes);\n\nffi_status ffi_prep_cif_var(ffi_cif *cif,\n\t\t\t    ffi_abi abi,\n\t\t\t    unsigned int nfixedargs,\n\t\t\t    unsigned int ntotalargs,\n\t\t\t    ffi_type *rtype,\n\t\t\t    ffi_type **atypes);\n\nvoid ffi_call(ffi_cif *cif,\n\t      void (*fn)(void),\n\t      void *rvalue,\n\t      void **avalue);\n\n/* Useful for eliminating compiler warnings */\n#define FFI_FN(f) ((void (*)(void))f)\n\n/* ---- Definitions shared with assembly code ---------------------------- */\n\n#endif\n\n/* If these change, update src/mips/ffitarget.h. */\n#define FFI_TYPE_VOID       0    \n#define FFI_TYPE_INT        1\n#define FFI_TYPE_FLOAT      2    \n#define FFI_TYPE_DOUBLE     3\n#if 0\n#define FFI_TYPE_LONGDOUBLE 4\n#else\n#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE\n#endif\n#define FFI_TYPE_UINT8      5   \n#define FFI_TYPE_SINT8      6\n#define FFI_TYPE_UINT16     7 \n#define FFI_TYPE_SINT16     8\n#define FFI_TYPE_UINT32     9\n#define FFI_TYPE_SINT32     10\n#define FFI_TYPE_UINT64     11\n#define FFI_TYPE_SINT64     12\n#define FFI_TYPE_STRUCT     13\n#define FFI_TYPE_POINTER    14\n\n/* This should always refer to the last type code (for sanity checks) */\n#define FFI_TYPE_LAST       FFI_TYPE_POINTER\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n\n#endif"
  },
  {
    "path": "src/ffi/ffi_common.h",
    "content": "/* -----------------------------------------------------------------------\n   ffi_common.h - Copyright (C) 2011, 2012, 2013  Anthony Green\n                  Copyright (C) 2007  Free Software Foundation, Inc\n                  Copyright (c) 1996  Red Hat, Inc.\n                  \n   Common internal definitions and macros. Only necessary for building\n   libffi.\n   ----------------------------------------------------------------------- */\n\n#ifndef FFI_COMMON_H\n#define FFI_COMMON_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <fficonfig.h>\n\n/* Do not move this. Some versions of AIX are very picky about where\n   this is positioned. */\n#ifdef __GNUC__\n# if HAVE_ALLOCA_H\n#  include <alloca.h>\n# else\n  /* mingw64 defines this already in malloc.h. */\n#  ifndef alloca\n#    define alloca __builtin_alloca\n#  endif\n# endif\n# define MAYBE_UNUSED __attribute__((__unused__))\n#else\n# define MAYBE_UNUSED\n# if HAVE_ALLOCA_H\n#  include <alloca.h>\n# else\n#  ifdef _AIX\n#   pragma alloca\n#  else\n#   ifndef alloca /* predefined by HP cc +Olibcalls */\n#    ifdef _MSC_VER\n#     define alloca _alloca\n#    else\nchar *alloca ();\n#   endif\n#  endif\n# endif\n# endif\n#endif\n\n/* Check for the existence of memcpy. */\n#if STDC_HEADERS\n# include <string.h>\n#else\n# ifndef HAVE_MEMCPY\n#  define memcpy(d, s, n) bcopy ((s), (d), (n))\n# endif\n#endif\n\n#if defined(FFI_DEBUG)\n#include <stdio.h>\n#endif\n\n#ifdef FFI_DEBUG\nvoid ffi_assert(char *expr, char *file, int line);\nvoid ffi_stop_here(void);\nvoid ffi_type_test(ffi_type *a, char *file, int line);\n\n#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))\n#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))\n#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)\n#else\n#define FFI_ASSERT(x)\n#define FFI_ASSERT_AT(x, f, l)\n#define FFI_ASSERT_VALID_TYPE(x)\n#endif\n\n#define ALIGN(v, a)  (((((size_t) (v))-1) | ((a)-1))+1)\n#define ALIGN_DOWN(v, a) (((size_t) (v)) & -a)\n\n/* Perform machine dependent cif processing */\nffi_status ffi_prep_cif_machdep(ffi_cif *cif);\nffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,\n\t unsigned int nfixedargs, unsigned int ntotalargs);\n\n/* Extended cif, used in callback from assembly routine */\ntypedef struct\n{\n  ffi_cif *cif;\n  void *rvalue;\n  void **avalue;\n} extended_cif;\n\n/* Terse sized type definitions.  */\n#if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C)\ntypedef unsigned char UINT8;\ntypedef signed char   SINT8;\ntypedef unsigned short UINT16;\ntypedef signed short   SINT16;\ntypedef unsigned int UINT32;\ntypedef signed int   SINT32;\n# ifdef _MSC_VER\ntypedef unsigned __int64 UINT64;\ntypedef signed __int64   SINT64;\n# else\n# include <inttypes.h>\ntypedef uint64_t UINT64;\ntypedef int64_t  SINT64;\n# endif\n#else\ntypedef unsigned int UINT8  __attribute__((__mode__(__QI__)));\ntypedef signed int   SINT8  __attribute__((__mode__(__QI__)));\ntypedef unsigned int UINT16 __attribute__((__mode__(__HI__)));\ntypedef signed int   SINT16 __attribute__((__mode__(__HI__)));\ntypedef unsigned int UINT32 __attribute__((__mode__(__SI__)));\ntypedef signed int   SINT32 __attribute__((__mode__(__SI__)));\ntypedef unsigned int UINT64 __attribute__((__mode__(__DI__)));\ntypedef signed int   SINT64 __attribute__((__mode__(__DI__)));\n#endif\n\ntypedef float FLOAT32;\n\n#ifndef __GNUC__\n#define __builtin_expect(x, expected_value) (x)\n#endif\n#define LIKELY(x)    __builtin_expect(!!(x),1)\n#define UNLIKELY(x)  __builtin_expect((x)!=0,0)\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "src/ffi/ffi_i386.h",
    "content": "#ifdef __i386__\n\n/* -----------------------------------------------------------------*-C-*-\n   libffi 3.1-rc1 - Copyright (c) 2011 Anthony Green\n                    - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.\n\n   Permission is hereby granted, free of charge, to any person\n   obtaining a copy of this software and associated documentation\n   files (the ``Software''), to deal in the Software without\n   restriction, including without limitation the rights to use, copy,\n   modify, merge, publish, distribute, sublicense, and/or sell copies\n   of the Software, and to permit persons to whom the Software is\n   furnished to do so, subject to the following conditions:\n\n   The above copyright notice and this permission notice shall be\n   included in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n   DEALINGS IN THE SOFTWARE.\n\n   ----------------------------------------------------------------------- */\n\n/* -------------------------------------------------------------------\n   The basic API is described in the README file.\n\n   The raw API is designed to bypass some of the argument packing\n   and unpacking on architectures for which it can be avoided.\n\n   The closure API allows interpreted functions to be packaged up\n   inside a C function pointer, so that they can be called as C functions,\n   with no understanding on the client side that they are interpreted.\n   It can also be used in other cases in which it is necessary to package\n   up a user specified parameter and a function pointer as a single\n   function pointer.\n\n   The closure API must be implemented in order to get its functionality,\n   e.g. for use by gij.  Routines are provided to emulate the raw API\n   if the underlying platform doesn't allow faster implementation.\n\n   More details on the raw and cloure API can be found in:\n\n   http://gcc.gnu.org/ml/java/1999-q3/msg00138.html\n\n   and\n\n   http://gcc.gnu.org/ml/java/1999-q3/msg00174.html\n   -------------------------------------------------------------------- */\n\n#ifndef LIBFFI_H\n#define LIBFFI_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Specify which architecture libffi is configured for. */\n#ifndef X86_DARWIN\n#define X86_DARWIN\n#endif\n\n/* ---- System configuration information --------------------------------- */\n\n#include \"ffitarget.h\"\n\n#ifndef LIBFFI_ASM\n\n#ifdef _MSC_VER\n#define __attribute__(X)\n#endif\n\n#include <stddef.h>\n#include <limits.h>\n\n/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).\n   But we can find it either under the correct ANSI name, or under GNU\n   C's internal name.  */\n\n#define FFI_64_BIT_MAX 9223372036854775807\n\n#ifdef LONG_LONG_MAX\n# define FFI_LONG_LONG_MAX LONG_LONG_MAX\n#else\n# ifdef LLONG_MAX\n#  define FFI_LONG_LONG_MAX LLONG_MAX\n#  ifdef _AIX52 /* or newer has C99 LLONG_MAX */\n#   undef FFI_64_BIT_MAX\n#   define FFI_64_BIT_MAX 9223372036854775807LL\n#  endif /* _AIX52 or newer */\n# else\n#  ifdef __GNUC__\n#   define FFI_LONG_LONG_MAX __LONG_LONG_MAX__\n#  endif\n#  ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */\n#   ifndef __PPC64__\n#    if defined (__IBMC__) || defined (__IBMCPP__)\n#     define FFI_LONG_LONG_MAX LONGLONG_MAX\n#    endif\n#   endif /* __PPC64__ */\n#   undef  FFI_64_BIT_MAX\n#   define FFI_64_BIT_MAX 9223372036854775807LL\n#  endif\n# endif\n#endif\n\n/* The closure code assumes that this works on pointers, i.e. a size_t\t*/\n/* can hold a pointer.\t\t\t\t\t\t\t*/\n\ntypedef struct _ffi_type\n{\n  size_t size;\n  unsigned short alignment;\n  unsigned short type;\n  struct _ffi_type **elements;\n} ffi_type;\n\n#ifndef LIBFFI_HIDE_BASIC_TYPES\n#if SCHAR_MAX == 127\n# define ffi_type_uchar                ffi_type_uint8\n# define ffi_type_schar                ffi_type_sint8\n#else\n #error \"char size not supported\"\n#endif\n\n#if SHRT_MAX == 32767\n# define ffi_type_ushort       ffi_type_uint16\n# define ffi_type_sshort       ffi_type_sint16\n#elif SHRT_MAX == 2147483647\n# define ffi_type_ushort       ffi_type_uint32\n# define ffi_type_sshort       ffi_type_sint32\n#else\n #error \"short size not supported\"\n#endif\n\n#if INT_MAX == 32767\n# define ffi_type_uint         ffi_type_uint16\n# define ffi_type_sint         ffi_type_sint16\n#elif INT_MAX == 2147483647\n# define ffi_type_uint         ffi_type_uint32\n# define ffi_type_sint         ffi_type_sint32\n#elif INT_MAX == 9223372036854775807\n# define ffi_type_uint         ffi_type_uint64\n# define ffi_type_sint         ffi_type_sint64\n#else\n #error \"int size not supported\"\n#endif\n\n#if LONG_MAX == 2147483647\n# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX\n #error \"no 64-bit data type supported\"\n# endif\n#elif LONG_MAX != FFI_64_BIT_MAX\n #error \"long size not supported\"\n#endif\n\n#if LONG_MAX == 2147483647\n# define ffi_type_ulong        ffi_type_uint32\n# define ffi_type_slong        ffi_type_sint32\n#elif LONG_MAX == FFI_64_BIT_MAX\n# define ffi_type_ulong        ffi_type_uint64\n# define ffi_type_slong        ffi_type_sint64\n#else\n #error \"long size not supported\"\n#endif\n\n/* Need minimal decorations for DLLs to works on Windows. */\n/* GCC has autoimport and autoexport.  Rely on Libtool to */\n/* help MSVC export from a DLL, but always declare data   */\n/* to be imported for MSVC clients.  This costs an extra  */\n/* indirection for MSVC clients using the static version  */\n/* of the library, but don't worry about that.  Besides,  */\n/* as a workaround, they can define FFI_BUILDING if they  */\n/* *know* they are going to link with the static library. */\n#if defined _MSC_VER && !defined FFI_BUILDING\n#define FFI_EXTERN extern __declspec(dllimport)\n#else\n#define FFI_EXTERN extern\n#endif\n\n/* These are defined in types.c */\nFFI_EXTERN ffi_type ffi_type_void;\nFFI_EXTERN ffi_type ffi_type_uint8;\nFFI_EXTERN ffi_type ffi_type_sint8;\nFFI_EXTERN ffi_type ffi_type_uint16;\nFFI_EXTERN ffi_type ffi_type_sint16;\nFFI_EXTERN ffi_type ffi_type_uint32;\nFFI_EXTERN ffi_type ffi_type_sint32;\nFFI_EXTERN ffi_type ffi_type_uint64;\nFFI_EXTERN ffi_type ffi_type_sint64;\nFFI_EXTERN ffi_type ffi_type_float;\nFFI_EXTERN ffi_type ffi_type_double;\nFFI_EXTERN ffi_type ffi_type_pointer;\n\n#if 1\nFFI_EXTERN ffi_type ffi_type_longdouble;\n#else\n#define ffi_type_longdouble ffi_type_double\n#endif\n#endif /* LIBFFI_HIDE_BASIC_TYPES */\n\ntypedef enum {\n  FFI_OK = 0,\n  FFI_BAD_TYPEDEF,\n  FFI_BAD_ABI\n} ffi_status;\n\ntypedef unsigned FFI_TYPE;\n\ntypedef struct {\n  ffi_abi abi;\n  unsigned nargs;\n  ffi_type **arg_types;\n  ffi_type *rtype;\n  unsigned bytes;\n  unsigned flags;\n#ifdef FFI_EXTRA_CIF_FIELDS\n  FFI_EXTRA_CIF_FIELDS;\n#endif\n} ffi_cif;\n\n#if HAVE_LONG_DOUBLE_VARIANT\n/* Used to adjust size/alignment of ffi types.  */\nvoid ffi_prep_types (ffi_abi abi);\n# endif\n\n/* Used internally, but overridden by some architectures */\nffi_status ffi_prep_cif_core(ffi_cif *cif,\n\t\t\t     ffi_abi abi,\n\t\t\t     unsigned int isvariadic,\n\t\t\t     unsigned int nfixedargs,\n\t\t\t     unsigned int ntotalargs,\n\t\t\t     ffi_type *rtype,\n\t\t\t     ffi_type **atypes);\n\n/* ---- Definitions for the raw API -------------------------------------- */\n\n#ifndef FFI_SIZEOF_ARG\n# if LONG_MAX == 2147483647\n#  define FFI_SIZEOF_ARG        4\n# elif LONG_MAX == FFI_64_BIT_MAX\n#  define FFI_SIZEOF_ARG        8\n# endif\n#endif\n\n#ifndef FFI_SIZEOF_JAVA_RAW\n#  define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG\n#endif\n\ntypedef union {\n  ffi_sarg  sint;\n  ffi_arg   uint;\n  float\t    flt;\n  char      data[FFI_SIZEOF_ARG];\n  void*     ptr;\n} ffi_raw;\n\n#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8\n/* This is a special case for mips64/n32 ABI (and perhaps others) where\n   sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8.  */\ntypedef union {\n  signed int\tsint;\n  unsigned int\tuint;\n  float\t\tflt;\n  char\t\tdata[FFI_SIZEOF_JAVA_RAW];\n  void*\t\tptr;\n} ffi_java_raw;\n#else\ntypedef ffi_raw ffi_java_raw;\n#endif\n\n\nvoid ffi_raw_call (ffi_cif *cif,\n\t\t   void (*fn)(void),\n\t\t   void *rvalue,\n\t\t   ffi_raw *avalue);\n\nvoid ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);\nvoid ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);\nsize_t ffi_raw_size (ffi_cif *cif);\n\n/* This is analogous to the raw API, except it uses Java parameter\t*/\n/* packing, even on 64-bit machines.  I.e. on 64-bit machines\t\t*/\n/* longs and doubles are followed by an empty 64-bit word.\t\t*/\n\nvoid ffi_java_raw_call (ffi_cif *cif,\n\t\t\tvoid (*fn)(void),\n\t\t\tvoid *rvalue,\n\t\t\tffi_java_raw *avalue);\n\nvoid ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw);\nvoid ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args);\nsize_t ffi_java_raw_size (ffi_cif *cif);\n\n/* ---- Definitions for closures ----------------------------------------- */\n\n#if FFI_CLOSURES\n\n#ifdef _MSC_VER\n__declspec(align(8))\n#endif\ntypedef struct {\n#if 0\n  void *trampoline_table;\n  void *trampoline_table_entry;\n#else\n  char tramp[FFI_TRAMPOLINE_SIZE];\n#endif\n  ffi_cif   *cif;\n  void     (*fun)(ffi_cif*,void*,void**,void*);\n  void      *user_data;\n#ifdef __GNUC__\n} ffi_closure __attribute__((aligned (8)));\n#else\n} ffi_closure;\n# ifdef __sgi\n#  pragma pack 0\n# endif\n#endif\n\nvoid *ffi_closure_alloc (size_t size, void **code);\nvoid ffi_closure_free (void *);\n\nffi_status\nffi_prep_closure (ffi_closure*,\n\t\t  ffi_cif *,\n\t\t  void (*fun)(ffi_cif*,void*,void**,void*),\n\t\t  void *user_data);\n\nffi_status\nffi_prep_closure_loc (ffi_closure*,\n\t\t      ffi_cif *,\n\t\t      void (*fun)(ffi_cif*,void*,void**,void*),\n\t\t      void *user_data,\n\t\t      void*codeloc);\n\n#ifdef __sgi\n# pragma pack 8\n#endif\ntypedef struct {\n#if 0\n  void *trampoline_table;\n  void *trampoline_table_entry;\n#else\n  char tramp[FFI_TRAMPOLINE_SIZE];\n#endif\n  ffi_cif   *cif;\n\n#if !FFI_NATIVE_RAW_API\n\n  /* if this is enabled, then a raw closure has the same layout \n     as a regular closure.  We use this to install an intermediate \n     handler to do the transaltion, void** -> ffi_raw*. */\n\n  void     (*translate_args)(ffi_cif*,void*,void**,void*);\n  void      *this_closure;\n\n#endif\n\n  void     (*fun)(ffi_cif*,void*,ffi_raw*,void*);\n  void      *user_data;\n\n} ffi_raw_closure;\n\ntypedef struct {\n#if 0\n  void *trampoline_table;\n  void *trampoline_table_entry;\n#else\n  char tramp[FFI_TRAMPOLINE_SIZE];\n#endif\n\n  ffi_cif   *cif;\n\n#if !FFI_NATIVE_RAW_API\n\n  /* if this is enabled, then a raw closure has the same layout \n     as a regular closure.  We use this to install an intermediate \n     handler to do the transaltion, void** -> ffi_raw*. */\n\n  void     (*translate_args)(ffi_cif*,void*,void**,void*);\n  void      *this_closure;\n\n#endif\n\n  void     (*fun)(ffi_cif*,void*,ffi_java_raw*,void*);\n  void      *user_data;\n\n} ffi_java_raw_closure;\n\nffi_status\nffi_prep_raw_closure (ffi_raw_closure*,\n\t\t      ffi_cif *cif,\n\t\t      void (*fun)(ffi_cif*,void*,ffi_raw*,void*),\n\t\t      void *user_data);\n\nffi_status\nffi_prep_raw_closure_loc (ffi_raw_closure*,\n\t\t\t  ffi_cif *cif,\n\t\t\t  void (*fun)(ffi_cif*,void*,ffi_raw*,void*),\n\t\t\t  void *user_data,\n\t\t\t  void *codeloc);\n\nffi_status\nffi_prep_java_raw_closure (ffi_java_raw_closure*,\n\t\t           ffi_cif *cif,\n\t\t           void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),\n\t\t           void *user_data);\n\nffi_status\nffi_prep_java_raw_closure_loc (ffi_java_raw_closure*,\n\t\t\t       ffi_cif *cif,\n\t\t\t       void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),\n\t\t\t       void *user_data,\n\t\t\t       void *codeloc);\n\n#endif /* FFI_CLOSURES */\n\n/* ---- Public interface definition -------------------------------------- */\n\nffi_status ffi_prep_cif(ffi_cif *cif,\n\t\t\tffi_abi abi,\n\t\t\tunsigned int nargs,\n\t\t\tffi_type *rtype,\n\t\t\tffi_type **atypes);\n\nffi_status ffi_prep_cif_var(ffi_cif *cif,\n\t\t\t    ffi_abi abi,\n\t\t\t    unsigned int nfixedargs,\n\t\t\t    unsigned int ntotalargs,\n\t\t\t    ffi_type *rtype,\n\t\t\t    ffi_type **atypes);\n\nvoid ffi_call(ffi_cif *cif,\n\t      void (*fn)(void),\n\t      void *rvalue,\n\t      void **avalue);\n\n/* Useful for eliminating compiler warnings */\n#define FFI_FN(f) ((void (*)(void))f)\n\n/* ---- Definitions shared with assembly code ---------------------------- */\n\n#endif\n\n/* If these change, update src/mips/ffitarget.h. */\n#define FFI_TYPE_VOID       0    \n#define FFI_TYPE_INT        1\n#define FFI_TYPE_FLOAT      2    \n#define FFI_TYPE_DOUBLE     3\n#if 1\n#define FFI_TYPE_LONGDOUBLE 4\n#else\n#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE\n#endif\n#define FFI_TYPE_UINT8      5   \n#define FFI_TYPE_SINT8      6\n#define FFI_TYPE_UINT16     7 \n#define FFI_TYPE_SINT16     8\n#define FFI_TYPE_UINT32     9\n#define FFI_TYPE_SINT32     10\n#define FFI_TYPE_UINT64     11\n#define FFI_TYPE_SINT64     12\n#define FFI_TYPE_STRUCT     13\n#define FFI_TYPE_POINTER    14\n\n/* This should always refer to the last type code (for sanity checks) */\n#define FFI_TYPE_LAST       FFI_TYPE_POINTER\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n\n#endif"
  },
  {
    "path": "src/ffi/ffi_x86_64.h",
    "content": "#ifdef __x86_64__\n\n/* -----------------------------------------------------------------*-C-*-\n   libffi 3.1-rc1 - Copyright (c) 2011 Anthony Green\n                    - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.\n\n   Permission is hereby granted, free of charge, to any person\n   obtaining a copy of this software and associated documentation\n   files (the ``Software''), to deal in the Software without\n   restriction, including without limitation the rights to use, copy,\n   modify, merge, publish, distribute, sublicense, and/or sell copies\n   of the Software, and to permit persons to whom the Software is\n   furnished to do so, subject to the following conditions:\n\n   The above copyright notice and this permission notice shall be\n   included in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n   DEALINGS IN THE SOFTWARE.\n\n   ----------------------------------------------------------------------- */\n\n/* -------------------------------------------------------------------\n   The basic API is described in the README file.\n\n   The raw API is designed to bypass some of the argument packing\n   and unpacking on architectures for which it can be avoided.\n\n   The closure API allows interpreted functions to be packaged up\n   inside a C function pointer, so that they can be called as C functions,\n   with no understanding on the client side that they are interpreted.\n   It can also be used in other cases in which it is necessary to package\n   up a user specified parameter and a function pointer as a single\n   function pointer.\n\n   The closure API must be implemented in order to get its functionality,\n   e.g. for use by gij.  Routines are provided to emulate the raw API\n   if the underlying platform doesn't allow faster implementation.\n\n   More details on the raw and cloure API can be found in:\n\n   http://gcc.gnu.org/ml/java/1999-q3/msg00138.html\n\n   and\n\n   http://gcc.gnu.org/ml/java/1999-q3/msg00174.html\n   -------------------------------------------------------------------- */\n\n#ifndef LIBFFI_H\n#define LIBFFI_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Specify which architecture libffi is configured for. */\n#ifndef X86_DARWIN\n#define X86_DARWIN\n#endif\n\n/* ---- System configuration information --------------------------------- */\n\n#include \"ffitarget.h\"\n\n#ifndef LIBFFI_ASM\n\n#ifdef _MSC_VER\n#define __attribute__(X)\n#endif\n\n#include <stddef.h>\n#include <limits.h>\n\n/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).\n   But we can find it either under the correct ANSI name, or under GNU\n   C's internal name.  */\n\n#define FFI_64_BIT_MAX 9223372036854775807\n\n#ifdef LONG_LONG_MAX\n# define FFI_LONG_LONG_MAX LONG_LONG_MAX\n#else\n# ifdef LLONG_MAX\n#  define FFI_LONG_LONG_MAX LLONG_MAX\n#  ifdef _AIX52 /* or newer has C99 LLONG_MAX */\n#   undef FFI_64_BIT_MAX\n#   define FFI_64_BIT_MAX 9223372036854775807LL\n#  endif /* _AIX52 or newer */\n# else\n#  ifdef __GNUC__\n#   define FFI_LONG_LONG_MAX __LONG_LONG_MAX__\n#  endif\n#  ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */\n#   ifndef __PPC64__\n#    if defined (__IBMC__) || defined (__IBMCPP__)\n#     define FFI_LONG_LONG_MAX LONGLONG_MAX\n#    endif\n#   endif /* __PPC64__ */\n#   undef  FFI_64_BIT_MAX\n#   define FFI_64_BIT_MAX 9223372036854775807LL\n#  endif\n# endif\n#endif\n\n/* The closure code assumes that this works on pointers, i.e. a size_t\t*/\n/* can hold a pointer.\t\t\t\t\t\t\t*/\n\ntypedef struct _ffi_type\n{\n  size_t size;\n  unsigned short alignment;\n  unsigned short type;\n  struct _ffi_type **elements;\n} ffi_type;\n\n#ifndef LIBFFI_HIDE_BASIC_TYPES\n#if SCHAR_MAX == 127\n# define ffi_type_uchar                ffi_type_uint8\n# define ffi_type_schar                ffi_type_sint8\n#else\n #error \"char size not supported\"\n#endif\n\n#if SHRT_MAX == 32767\n# define ffi_type_ushort       ffi_type_uint16\n# define ffi_type_sshort       ffi_type_sint16\n#elif SHRT_MAX == 2147483647\n# define ffi_type_ushort       ffi_type_uint32\n# define ffi_type_sshort       ffi_type_sint32\n#else\n #error \"short size not supported\"\n#endif\n\n#if INT_MAX == 32767\n# define ffi_type_uint         ffi_type_uint16\n# define ffi_type_sint         ffi_type_sint16\n#elif INT_MAX == 2147483647\n# define ffi_type_uint         ffi_type_uint32\n# define ffi_type_sint         ffi_type_sint32\n#elif INT_MAX == 9223372036854775807\n# define ffi_type_uint         ffi_type_uint64\n# define ffi_type_sint         ffi_type_sint64\n#else\n #error \"int size not supported\"\n#endif\n\n#if LONG_MAX == 2147483647\n# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX\n #error \"no 64-bit data type supported\"\n# endif\n#elif LONG_MAX != FFI_64_BIT_MAX\n #error \"long size not supported\"\n#endif\n\n#if LONG_MAX == 2147483647\n# define ffi_type_ulong        ffi_type_uint32\n# define ffi_type_slong        ffi_type_sint32\n#elif LONG_MAX == FFI_64_BIT_MAX\n# define ffi_type_ulong        ffi_type_uint64\n# define ffi_type_slong        ffi_type_sint64\n#else\n #error \"long size not supported\"\n#endif\n\n/* Need minimal decorations for DLLs to works on Windows. */\n/* GCC has autoimport and autoexport.  Rely on Libtool to */\n/* help MSVC export from a DLL, but always declare data   */\n/* to be imported for MSVC clients.  This costs an extra  */\n/* indirection for MSVC clients using the static version  */\n/* of the library, but don't worry about that.  Besides,  */\n/* as a workaround, they can define FFI_BUILDING if they  */\n/* *know* they are going to link with the static library. */\n#if defined _MSC_VER && !defined FFI_BUILDING\n#define FFI_EXTERN extern __declspec(dllimport)\n#else\n#define FFI_EXTERN extern\n#endif\n\n/* These are defined in types.c */\nFFI_EXTERN ffi_type ffi_type_void;\nFFI_EXTERN ffi_type ffi_type_uint8;\nFFI_EXTERN ffi_type ffi_type_sint8;\nFFI_EXTERN ffi_type ffi_type_uint16;\nFFI_EXTERN ffi_type ffi_type_sint16;\nFFI_EXTERN ffi_type ffi_type_uint32;\nFFI_EXTERN ffi_type ffi_type_sint32;\nFFI_EXTERN ffi_type ffi_type_uint64;\nFFI_EXTERN ffi_type ffi_type_sint64;\nFFI_EXTERN ffi_type ffi_type_float;\nFFI_EXTERN ffi_type ffi_type_double;\nFFI_EXTERN ffi_type ffi_type_pointer;\n\n#if 1\nFFI_EXTERN ffi_type ffi_type_longdouble;\n#else\n#define ffi_type_longdouble ffi_type_double\n#endif\n#endif /* LIBFFI_HIDE_BASIC_TYPES */\n\ntypedef enum {\n  FFI_OK = 0,\n  FFI_BAD_TYPEDEF,\n  FFI_BAD_ABI\n} ffi_status;\n\ntypedef unsigned FFI_TYPE;\n\ntypedef struct {\n  ffi_abi abi;\n  unsigned nargs;\n  ffi_type **arg_types;\n  ffi_type *rtype;\n  unsigned bytes;\n  unsigned flags;\n#ifdef FFI_EXTRA_CIF_FIELDS\n  FFI_EXTRA_CIF_FIELDS;\n#endif\n} ffi_cif;\n\n#if HAVE_LONG_DOUBLE_VARIANT\n/* Used to adjust size/alignment of ffi types.  */\nvoid ffi_prep_types (ffi_abi abi);\n# endif\n\n/* Used internally, but overridden by some architectures */\nffi_status ffi_prep_cif_core(ffi_cif *cif,\n\t\t\t     ffi_abi abi,\n\t\t\t     unsigned int isvariadic,\n\t\t\t     unsigned int nfixedargs,\n\t\t\t     unsigned int ntotalargs,\n\t\t\t     ffi_type *rtype,\n\t\t\t     ffi_type **atypes);\n\n/* ---- Definitions for the raw API -------------------------------------- */\n\n#ifndef FFI_SIZEOF_ARG\n# if LONG_MAX == 2147483647\n#  define FFI_SIZEOF_ARG        4\n# elif LONG_MAX == FFI_64_BIT_MAX\n#  define FFI_SIZEOF_ARG        8\n# endif\n#endif\n\n#ifndef FFI_SIZEOF_JAVA_RAW\n#  define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG\n#endif\n\ntypedef union {\n  ffi_sarg  sint;\n  ffi_arg   uint;\n  float\t    flt;\n  char      data[FFI_SIZEOF_ARG];\n  void*     ptr;\n} ffi_raw;\n\n#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8\n/* This is a special case for mips64/n32 ABI (and perhaps others) where\n   sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8.  */\ntypedef union {\n  signed int\tsint;\n  unsigned int\tuint;\n  float\t\tflt;\n  char\t\tdata[FFI_SIZEOF_JAVA_RAW];\n  void*\t\tptr;\n} ffi_java_raw;\n#else\ntypedef ffi_raw ffi_java_raw;\n#endif\n\n\nvoid ffi_raw_call (ffi_cif *cif,\n\t\t   void (*fn)(void),\n\t\t   void *rvalue,\n\t\t   ffi_raw *avalue);\n\nvoid ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);\nvoid ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);\nsize_t ffi_raw_size (ffi_cif *cif);\n\n/* This is analogous to the raw API, except it uses Java parameter\t*/\n/* packing, even on 64-bit machines.  I.e. on 64-bit machines\t\t*/\n/* longs and doubles are followed by an empty 64-bit word.\t\t*/\n\nvoid ffi_java_raw_call (ffi_cif *cif,\n\t\t\tvoid (*fn)(void),\n\t\t\tvoid *rvalue,\n\t\t\tffi_java_raw *avalue);\n\nvoid ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw);\nvoid ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args);\nsize_t ffi_java_raw_size (ffi_cif *cif);\n\n/* ---- Definitions for closures ----------------------------------------- */\n\n#if FFI_CLOSURES\n\n#ifdef _MSC_VER\n__declspec(align(8))\n#endif\ntypedef struct {\n#if 0\n  void *trampoline_table;\n  void *trampoline_table_entry;\n#else\n  char tramp[FFI_TRAMPOLINE_SIZE];\n#endif\n  ffi_cif   *cif;\n  void     (*fun)(ffi_cif*,void*,void**,void*);\n  void      *user_data;\n#ifdef __GNUC__\n} ffi_closure __attribute__((aligned (8)));\n#else\n} ffi_closure;\n# ifdef __sgi\n#  pragma pack 0\n# endif\n#endif\n\nvoid *ffi_closure_alloc (size_t size, void **code);\nvoid ffi_closure_free (void *);\n\nffi_status\nffi_prep_closure (ffi_closure*,\n\t\t  ffi_cif *,\n\t\t  void (*fun)(ffi_cif*,void*,void**,void*),\n\t\t  void *user_data);\n\nffi_status\nffi_prep_closure_loc (ffi_closure*,\n\t\t      ffi_cif *,\n\t\t      void (*fun)(ffi_cif*,void*,void**,void*),\n\t\t      void *user_data,\n\t\t      void*codeloc);\n\n#ifdef __sgi\n# pragma pack 8\n#endif\ntypedef struct {\n#if 0\n  void *trampoline_table;\n  void *trampoline_table_entry;\n#else\n  char tramp[FFI_TRAMPOLINE_SIZE];\n#endif\n  ffi_cif   *cif;\n\n#if !FFI_NATIVE_RAW_API\n\n  /* if this is enabled, then a raw closure has the same layout \n     as a regular closure.  We use this to install an intermediate \n     handler to do the transaltion, void** -> ffi_raw*. */\n\n  void     (*translate_args)(ffi_cif*,void*,void**,void*);\n  void      *this_closure;\n\n#endif\n\n  void     (*fun)(ffi_cif*,void*,ffi_raw*,void*);\n  void      *user_data;\n\n} ffi_raw_closure;\n\ntypedef struct {\n#if 0\n  void *trampoline_table;\n  void *trampoline_table_entry;\n#else\n  char tramp[FFI_TRAMPOLINE_SIZE];\n#endif\n\n  ffi_cif   *cif;\n\n#if !FFI_NATIVE_RAW_API\n\n  /* if this is enabled, then a raw closure has the same layout \n     as a regular closure.  We use this to install an intermediate \n     handler to do the transaltion, void** -> ffi_raw*. */\n\n  void     (*translate_args)(ffi_cif*,void*,void**,void*);\n  void      *this_closure;\n\n#endif\n\n  void     (*fun)(ffi_cif*,void*,ffi_java_raw*,void*);\n  void      *user_data;\n\n} ffi_java_raw_closure;\n\nffi_status\nffi_prep_raw_closure (ffi_raw_closure*,\n\t\t      ffi_cif *cif,\n\t\t      void (*fun)(ffi_cif*,void*,ffi_raw*,void*),\n\t\t      void *user_data);\n\nffi_status\nffi_prep_raw_closure_loc (ffi_raw_closure*,\n\t\t\t  ffi_cif *cif,\n\t\t\t  void (*fun)(ffi_cif*,void*,ffi_raw*,void*),\n\t\t\t  void *user_data,\n\t\t\t  void *codeloc);\n\nffi_status\nffi_prep_java_raw_closure (ffi_java_raw_closure*,\n\t\t           ffi_cif *cif,\n\t\t           void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),\n\t\t           void *user_data);\n\nffi_status\nffi_prep_java_raw_closure_loc (ffi_java_raw_closure*,\n\t\t\t       ffi_cif *cif,\n\t\t\t       void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),\n\t\t\t       void *user_data,\n\t\t\t       void *codeloc);\n\n#endif /* FFI_CLOSURES */\n\n/* ---- Public interface definition -------------------------------------- */\n\nffi_status ffi_prep_cif(ffi_cif *cif,\n\t\t\tffi_abi abi,\n\t\t\tunsigned int nargs,\n\t\t\tffi_type *rtype,\n\t\t\tffi_type **atypes);\n\nffi_status ffi_prep_cif_var(ffi_cif *cif,\n\t\t\t    ffi_abi abi,\n\t\t\t    unsigned int nfixedargs,\n\t\t\t    unsigned int ntotalargs,\n\t\t\t    ffi_type *rtype,\n\t\t\t    ffi_type **atypes);\n\nvoid ffi_call(ffi_cif *cif,\n\t      void (*fn)(void),\n\t      void *rvalue,\n\t      void **avalue);\n\n/* Useful for eliminating compiler warnings */\n#define FFI_FN(f) ((void (*)(void))f)\n\n/* ---- Definitions shared with assembly code ---------------------------- */\n\n#endif\n\n/* If these change, update src/mips/ffitarget.h. */\n#define FFI_TYPE_VOID       0    \n#define FFI_TYPE_INT        1\n#define FFI_TYPE_FLOAT      2    \n#define FFI_TYPE_DOUBLE     3\n#if 1\n#define FFI_TYPE_LONGDOUBLE 4\n#else\n#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE\n#endif\n#define FFI_TYPE_UINT8      5   \n#define FFI_TYPE_SINT8      6\n#define FFI_TYPE_UINT16     7 \n#define FFI_TYPE_SINT16     8\n#define FFI_TYPE_UINT32     9\n#define FFI_TYPE_SINT32     10\n#define FFI_TYPE_UINT64     11\n#define FFI_TYPE_SINT64     12\n#define FFI_TYPE_STRUCT     13\n#define FFI_TYPE_POINTER    14\n\n/* This should always refer to the last type code (for sanity checks) */\n#define FFI_TYPE_LAST       FFI_TYPE_POINTER\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n\n#endif"
  },
  {
    "path": "src/ffi/fficonfig.h",
    "content": "#ifdef __arm64__\n\n#include <fficonfig_arm64.h>\n\n\n#endif\n#ifdef __i386__\n\n#include <fficonfig_i386.h>\n\n\n#endif\n#ifdef __arm__\n\n#include <fficonfig_armv7.h>\n\n\n#endif\n#ifdef __x86_64__\n\n#include <fficonfig_x86_64.h>\n\n\n#endif\n"
  },
  {
    "path": "src/ffi/fficonfig_arm64.h",
    "content": "#ifdef __arm64__\n\n/* fficonfig.h.  Generated from fficonfig.h.in by configure.  */\n/* fficonfig.h.in.  Generated from configure.ac by autoheader.  */\n\n/* Define if building universal (internal helper macro) */\n/* #undef AC_APPLE_UNIVERSAL_BUILD */\n\n/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP\n   systems. This function is required for `alloca.c' support on those systems.\n   */\n/* #undef CRAY_STACKSEG_END */\n\n/* Define to 1 if using `alloca.c'. */\n/* #undef C_ALLOCA */\n\n/* Define to the flags needed for the .section .eh_frame directive. */\n#define EH_FRAME_FLAGS \"aw\"\n\n/* Define this if you want extra debugging. */\n/* #undef FFI_DEBUG */\n\n/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */\n/* #undef FFI_EXEC_TRAMPOLINE_TABLE */\n\n/* Define this if you want to enable pax emulated trampolines */\n/* #undef FFI_MMAP_EXEC_EMUTRAMP_PAX */\n\n/* Cannot use malloc on this target, so, we revert to alternative means */\n#define FFI_MMAP_EXEC_WRIT 1\n\n/* Define this if you do not want support for the raw API. */\n/* #undef FFI_NO_RAW_API */\n\n/* Define this if you do not want support for aggregate types. */\n/* #undef FFI_NO_STRUCTS */\n\n/* Define to 1 if you have `alloca', as a function or macro. */\n#define HAVE_ALLOCA 1\n\n/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).\n   */\n#define HAVE_ALLOCA_H 1\n\n/* Define if your assembler supports .ascii. */\n/* #undef HAVE_AS_ASCII_PSEUDO_OP */\n\n/* Define if your assembler supports .cfi_* directives. */\n#define HAVE_AS_CFI_PSEUDO_OP 1\n\n/* Define if your assembler supports .register. */\n/* #undef HAVE_AS_REGISTER_PSEUDO_OP */\n\n/* Define if your assembler and linker support unaligned PC relative relocs.\n   */\n/* #undef HAVE_AS_SPARC_UA_PCREL */\n\n/* Define if your assembler supports .string. */\n/* #undef HAVE_AS_STRING_PSEUDO_OP */\n\n/* Define if your assembler supports unwind section type. */\n/* #undef HAVE_AS_X86_64_UNWIND_SECTION_TYPE */\n\n/* Define if your assembler supports PC relative relocs. */\n/* #undef HAVE_AS_X86_PCREL */\n\n/* Define to 1 if you have the <dlfcn.h> header file. */\n#define HAVE_DLFCN_H 1\n\n/* Define if __attribute__((visibility(\"hidden\"))) is supported. */\n/* #undef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE */\n\n/* Define to 1 if you have the <inttypes.h> header file. */\n#define HAVE_INTTYPES_H 1\n\n/* Define if you have the long double type and it is bigger than a double */\n/* #undef HAVE_LONG_DOUBLE */\n\n/* Define if you support more than one size of the long double type */\n/* #undef HAVE_LONG_DOUBLE_VARIANT */\n\n/* Define to 1 if you have the `memcpy' function. */\n#define HAVE_MEMCPY 1\n\n/* Define to 1 if you have the <memory.h> header file. */\n#define HAVE_MEMORY_H 1\n\n/* Define to 1 if you have the `mmap' function. */\n#define HAVE_MMAP 1\n\n/* Define if mmap with MAP_ANON(YMOUS) works. */\n#define HAVE_MMAP_ANON 1\n\n/* Define if mmap of /dev/zero works. */\n/* #undef HAVE_MMAP_DEV_ZERO */\n\n/* Define if read-only mmap of a plain file works. */\n#define HAVE_MMAP_FILE 1\n\n/* Define if .eh_frame sections should be read-only. */\n/* #undef HAVE_RO_EH_FRAME */\n\n/* Define to 1 if you have the <stdint.h> header file. */\n#define HAVE_STDINT_H 1\n\n/* Define to 1 if you have the <stdlib.h> header file. */\n#define HAVE_STDLIB_H 1\n\n/* Define to 1 if you have the <strings.h> header file. */\n#define HAVE_STRINGS_H 1\n\n/* Define to 1 if you have the <string.h> header file. */\n#define HAVE_STRING_H 1\n\n/* Define to 1 if you have the <sys/mman.h> header file. */\n#define HAVE_SYS_MMAN_H 1\n\n/* Define to 1 if you have the <sys/stat.h> header file. */\n#define HAVE_SYS_STAT_H 1\n\n/* Define to 1 if you have the <sys/types.h> header file. */\n#define HAVE_SYS_TYPES_H 1\n\n/* Define to 1 if you have the <unistd.h> header file. */\n#define HAVE_UNISTD_H 1\n\n/* Define to the sub-directory in which libtool stores uninstalled libraries.\n   */\n#define LT_OBJDIR \".libs/\"\n\n/* Name of package */\n#define PACKAGE \"libffi\"\n\n/* Define to the address where bug reports for this package should be sent. */\n#define PACKAGE_BUGREPORT \"http://github.com/atgreen/libffi/issues\"\n\n/* Define to the full name of this package. */\n#define PACKAGE_NAME \"libffi\"\n\n/* Define to the full name and version of this package. */\n#define PACKAGE_STRING \"libffi 3.1-rc1\"\n\n/* Define to the one symbol short name of this package. */\n#define PACKAGE_TARNAME \"libffi\"\n\n/* Define to the home page for this package. */\n#define PACKAGE_URL \"\"\n\n/* Define to the version of this package. */\n#define PACKAGE_VERSION \"3.1-rc1\"\n\n/* The size of `double', as computed by sizeof. */\n#define SIZEOF_DOUBLE 8\n\n/* The size of `long double', as computed by sizeof. */\n#define SIZEOF_LONG_DOUBLE 8\n\n/* The size of `size_t', as computed by sizeof. */\n#define SIZEOF_SIZE_T 8\n\n/* If using the C implementation of alloca, define if you know the\n   direction of stack growth for your system; otherwise it will be\n   automatically deduced at runtime.\n\tSTACK_DIRECTION > 0 => grows toward higher addresses\n\tSTACK_DIRECTION < 0 => grows toward lower addresses\n\tSTACK_DIRECTION = 0 => direction of growth unknown */\n/* #undef STACK_DIRECTION */\n\n/* Define to 1 if you have the ANSI C header files. */\n#define STDC_HEADERS 1\n\n/* Define if symbols are underscored. */\n#define SYMBOL_UNDERSCORE 1\n\n/* Define this if you are using Purify and want to suppress spurious messages.\n   */\n/* #undef USING_PURIFY */\n\n/* Version number of package */\n#define VERSION \"3.1-rc1\"\n\n/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most\n   significant byte first (like Motorola and SPARC, unlike Intel). */\n#if defined AC_APPLE_UNIVERSAL_BUILD\n# if defined __BIG_ENDIAN__\n#  define WORDS_BIGENDIAN 1\n# endif\n#else\n# ifndef WORDS_BIGENDIAN\n/* #  undef WORDS_BIGENDIAN */\n# endif\n#endif\n\n/* Define to `unsigned int' if <sys/types.h> does not define. */\n/* #undef size_t */\n\n\n#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE\n#ifdef LIBFFI_ASM\n#define FFI_HIDDEN(name) .hidden name\n#else\n#define FFI_HIDDEN __attribute__ ((visibility (\"hidden\")))\n#endif\n#else\n#ifdef LIBFFI_ASM\n#define FFI_HIDDEN(name)\n#else\n#define FFI_HIDDEN\n#endif\n#endif\n\n\n\n#endif"
  },
  {
    "path": "src/ffi/fficonfig_armv7.h",
    "content": "#ifdef __arm__\n\n/* fficonfig.h.  Generated from fficonfig.h.in by configure.  */\n/* fficonfig.h.in.  Generated from configure.ac by autoheader.  */\n\n/* Define if building universal (internal helper macro) */\n/* #undef AC_APPLE_UNIVERSAL_BUILD */\n\n/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP\n   systems. This function is required for `alloca.c' support on those systems.\n   */\n/* #undef CRAY_STACKSEG_END */\n\n/* Define to 1 if using `alloca.c'. */\n/* #undef C_ALLOCA */\n\n/* Define to the flags needed for the .section .eh_frame directive. */\n#define EH_FRAME_FLAGS \"aw\"\n\n/* Define this if you want extra debugging. */\n/* #undef FFI_DEBUG */\n\n/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */\n#define FFI_EXEC_TRAMPOLINE_TABLE 1\n\n/* Define this if you want to enable pax emulated trampolines */\n/* #undef FFI_MMAP_EXEC_EMUTRAMP_PAX */\n\n/* Cannot use malloc on this target, so, we revert to alternative means */\n/* #undef FFI_MMAP_EXEC_WRIT */\n\n/* Define this if you do not want support for the raw API. */\n/* #undef FFI_NO_RAW_API */\n\n/* Define this if you do not want support for aggregate types. */\n/* #undef FFI_NO_STRUCTS */\n\n/* Define to 1 if you have `alloca', as a function or macro. */\n#define HAVE_ALLOCA 1\n\n/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).\n   */\n#define HAVE_ALLOCA_H 1\n\n/* Define if your assembler supports .ascii. */\n/* #undef HAVE_AS_ASCII_PSEUDO_OP */\n\n/* Define if your assembler supports .cfi_* directives. */\n#define HAVE_AS_CFI_PSEUDO_OP 1\n\n/* Define if your assembler supports .register. */\n/* #undef HAVE_AS_REGISTER_PSEUDO_OP */\n\n/* Define if your assembler and linker support unaligned PC relative relocs.\n   */\n/* #undef HAVE_AS_SPARC_UA_PCREL */\n\n/* Define if your assembler supports .string. */\n/* #undef HAVE_AS_STRING_PSEUDO_OP */\n\n/* Define if your assembler supports unwind section type. */\n/* #undef HAVE_AS_X86_64_UNWIND_SECTION_TYPE */\n\n/* Define if your assembler supports PC relative relocs. */\n/* #undef HAVE_AS_X86_PCREL */\n\n/* Define to 1 if you have the <dlfcn.h> header file. */\n#define HAVE_DLFCN_H 1\n\n/* Define if __attribute__((visibility(\"hidden\"))) is supported. */\n/* #undef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE */\n\n/* Define to 1 if you have the <inttypes.h> header file. */\n#define HAVE_INTTYPES_H 1\n\n/* Define if you have the long double type and it is bigger than a double */\n/* #undef HAVE_LONG_DOUBLE */\n\n/* Define if you support more than one size of the long double type */\n/* #undef HAVE_LONG_DOUBLE_VARIANT */\n\n/* Define to 1 if you have the `memcpy' function. */\n#define HAVE_MEMCPY 1\n\n/* Define to 1 if you have the <memory.h> header file. */\n#define HAVE_MEMORY_H 1\n\n/* Define to 1 if you have the `mmap' function. */\n#define HAVE_MMAP 1\n\n/* Define if mmap with MAP_ANON(YMOUS) works. */\n#define HAVE_MMAP_ANON 1\n\n/* Define if mmap of /dev/zero works. */\n/* #undef HAVE_MMAP_DEV_ZERO */\n\n/* Define if read-only mmap of a plain file works. */\n#define HAVE_MMAP_FILE 1\n\n/* Define if .eh_frame sections should be read-only. */\n/* #undef HAVE_RO_EH_FRAME */\n\n/* Define to 1 if you have the <stdint.h> header file. */\n#define HAVE_STDINT_H 1\n\n/* Define to 1 if you have the <stdlib.h> header file. */\n#define HAVE_STDLIB_H 1\n\n/* Define to 1 if you have the <strings.h> header file. */\n#define HAVE_STRINGS_H 1\n\n/* Define to 1 if you have the <string.h> header file. */\n#define HAVE_STRING_H 1\n\n/* Define to 1 if you have the <sys/mman.h> header file. */\n#define HAVE_SYS_MMAN_H 1\n\n/* Define to 1 if you have the <sys/stat.h> header file. */\n#define HAVE_SYS_STAT_H 1\n\n/* Define to 1 if you have the <sys/types.h> header file. */\n#define HAVE_SYS_TYPES_H 1\n\n/* Define to 1 if you have the <unistd.h> header file. */\n#define HAVE_UNISTD_H 1\n\n/* Define to the sub-directory in which libtool stores uninstalled libraries.\n   */\n#define LT_OBJDIR \".libs/\"\n\n/* Name of package */\n#define PACKAGE \"libffi\"\n\n/* Define to the address where bug reports for this package should be sent. */\n#define PACKAGE_BUGREPORT \"http://github.com/atgreen/libffi/issues\"\n\n/* Define to the full name of this package. */\n#define PACKAGE_NAME \"libffi\"\n\n/* Define to the full name and version of this package. */\n#define PACKAGE_STRING \"libffi 3.1-rc1\"\n\n/* Define to the one symbol short name of this package. */\n#define PACKAGE_TARNAME \"libffi\"\n\n/* Define to the home page for this package. */\n#define PACKAGE_URL \"\"\n\n/* Define to the version of this package. */\n#define PACKAGE_VERSION \"3.1-rc1\"\n\n/* The size of `double', as computed by sizeof. */\n#define SIZEOF_DOUBLE 8\n\n/* The size of `long double', as computed by sizeof. */\n#define SIZEOF_LONG_DOUBLE 8\n\n/* The size of `size_t', as computed by sizeof. */\n#define SIZEOF_SIZE_T 4\n\n/* If using the C implementation of alloca, define if you know the\n   direction of stack growth for your system; otherwise it will be\n   automatically deduced at runtime.\n\tSTACK_DIRECTION > 0 => grows toward higher addresses\n\tSTACK_DIRECTION < 0 => grows toward lower addresses\n\tSTACK_DIRECTION = 0 => direction of growth unknown */\n/* #undef STACK_DIRECTION */\n\n/* Define to 1 if you have the ANSI C header files. */\n#define STDC_HEADERS 1\n\n/* Define if symbols are underscored. */\n#define SYMBOL_UNDERSCORE 1\n\n/* Define this if you are using Purify and want to suppress spurious messages.\n   */\n/* #undef USING_PURIFY */\n\n/* Version number of package */\n#define VERSION \"3.1-rc1\"\n\n/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most\n   significant byte first (like Motorola and SPARC, unlike Intel). */\n#if defined AC_APPLE_UNIVERSAL_BUILD\n# if defined __BIG_ENDIAN__\n#  define WORDS_BIGENDIAN 1\n# endif\n#else\n# ifndef WORDS_BIGENDIAN\n/* #  undef WORDS_BIGENDIAN */\n# endif\n#endif\n\n/* Define to `unsigned int' if <sys/types.h> does not define. */\n/* #undef size_t */\n\n\n#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE\n#ifdef LIBFFI_ASM\n#define FFI_HIDDEN(name) .hidden name\n#else\n#define FFI_HIDDEN __attribute__ ((visibility (\"hidden\")))\n#endif\n#else\n#ifdef LIBFFI_ASM\n#define FFI_HIDDEN(name)\n#else\n#define FFI_HIDDEN\n#endif\n#endif\n\n\n\n#endif"
  },
  {
    "path": "src/ffi/fficonfig_i386.h",
    "content": "#ifdef __i386__\n\n/* fficonfig.h.  Generated from fficonfig.h.in by configure.  */\n/* fficonfig.h.in.  Generated from configure.ac by autoheader.  */\n\n/* Define if building universal (internal helper macro) */\n/* #undef AC_APPLE_UNIVERSAL_BUILD */\n\n/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP\n   systems. This function is required for `alloca.c' support on those systems.\n   */\n/* #undef CRAY_STACKSEG_END */\n\n/* Define to 1 if using `alloca.c'. */\n/* #undef C_ALLOCA */\n\n/* Define to the flags needed for the .section .eh_frame directive. */\n#define EH_FRAME_FLAGS \"aw\"\n\n/* Define this if you want extra debugging. */\n/* #undef FFI_DEBUG */\n\n/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */\n/* #undef FFI_EXEC_TRAMPOLINE_TABLE */\n\n/* Define this if you want to enable pax emulated trampolines */\n/* #undef FFI_MMAP_EXEC_EMUTRAMP_PAX */\n\n/* Cannot use malloc on this target, so, we revert to alternative means */\n#define FFI_MMAP_EXEC_WRIT 1\n\n/* Define this if you do not want support for the raw API. */\n/* #undef FFI_NO_RAW_API */\n\n/* Define this if you do not want support for aggregate types. */\n/* #undef FFI_NO_STRUCTS */\n\n/* Define to 1 if you have `alloca', as a function or macro. */\n#define HAVE_ALLOCA 1\n\n/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).\n   */\n#define HAVE_ALLOCA_H 1\n\n/* Define if your assembler supports .ascii. */\n/* #undef HAVE_AS_ASCII_PSEUDO_OP */\n\n/* Define if your assembler supports .cfi_* directives. */\n#define HAVE_AS_CFI_PSEUDO_OP 1\n\n/* Define if your assembler supports .register. */\n/* #undef HAVE_AS_REGISTER_PSEUDO_OP */\n\n/* Define if your assembler and linker support unaligned PC relative relocs.\n   */\n/* #undef HAVE_AS_SPARC_UA_PCREL */\n\n/* Define if your assembler supports .string. */\n/* #undef HAVE_AS_STRING_PSEUDO_OP */\n\n/* Define if your assembler supports unwind section type. */\n/* #undef HAVE_AS_X86_64_UNWIND_SECTION_TYPE */\n\n/* Define if your assembler supports PC relative relocs. */\n/* #undef HAVE_AS_X86_PCREL */\n\n/* Define to 1 if you have the <dlfcn.h> header file. */\n#define HAVE_DLFCN_H 1\n\n/* Define if __attribute__((visibility(\"hidden\"))) is supported. */\n/* #undef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE */\n\n/* Define to 1 if you have the <inttypes.h> header file. */\n#define HAVE_INTTYPES_H 1\n\n/* Define if you have the long double type and it is bigger than a double */\n#define HAVE_LONG_DOUBLE 1\n\n/* Define if you support more than one size of the long double type */\n/* #undef HAVE_LONG_DOUBLE_VARIANT */\n\n/* Define to 1 if you have the `memcpy' function. */\n#define HAVE_MEMCPY 1\n\n/* Define to 1 if you have the <memory.h> header file. */\n#define HAVE_MEMORY_H 1\n\n/* Define to 1 if you have the `mmap' function. */\n#define HAVE_MMAP 1\n\n/* Define if mmap with MAP_ANON(YMOUS) works. */\n#define HAVE_MMAP_ANON 1\n\n/* Define if mmap of /dev/zero works. */\n/* #undef HAVE_MMAP_DEV_ZERO */\n\n/* Define if read-only mmap of a plain file works. */\n#define HAVE_MMAP_FILE 1\n\n/* Define if .eh_frame sections should be read-only. */\n/* #undef HAVE_RO_EH_FRAME */\n\n/* Define to 1 if you have the <stdint.h> header file. */\n#define HAVE_STDINT_H 1\n\n/* Define to 1 if you have the <stdlib.h> header file. */\n#define HAVE_STDLIB_H 1\n\n/* Define to 1 if you have the <strings.h> header file. */\n#define HAVE_STRINGS_H 1\n\n/* Define to 1 if you have the <string.h> header file. */\n#define HAVE_STRING_H 1\n\n/* Define to 1 if you have the <sys/mman.h> header file. */\n#define HAVE_SYS_MMAN_H 1\n\n/* Define to 1 if you have the <sys/stat.h> header file. */\n#define HAVE_SYS_STAT_H 1\n\n/* Define to 1 if you have the <sys/types.h> header file. */\n#define HAVE_SYS_TYPES_H 1\n\n/* Define to 1 if you have the <unistd.h> header file. */\n#define HAVE_UNISTD_H 1\n\n/* Define to the sub-directory in which libtool stores uninstalled libraries.\n   */\n#define LT_OBJDIR \".libs/\"\n\n/* Name of package */\n#define PACKAGE \"libffi\"\n\n/* Define to the address where bug reports for this package should be sent. */\n#define PACKAGE_BUGREPORT \"http://github.com/atgreen/libffi/issues\"\n\n/* Define to the full name of this package. */\n#define PACKAGE_NAME \"libffi\"\n\n/* Define to the full name and version of this package. */\n#define PACKAGE_STRING \"libffi 3.1-rc1\"\n\n/* Define to the one symbol short name of this package. */\n#define PACKAGE_TARNAME \"libffi\"\n\n/* Define to the home page for this package. */\n#define PACKAGE_URL \"\"\n\n/* Define to the version of this package. */\n#define PACKAGE_VERSION \"3.1-rc1\"\n\n/* The size of `double', as computed by sizeof. */\n#define SIZEOF_DOUBLE 8\n\n/* The size of `long double', as computed by sizeof. */\n#define SIZEOF_LONG_DOUBLE 16\n\n/* The size of `size_t', as computed by sizeof. */\n#define SIZEOF_SIZE_T 4\n\n/* If using the C implementation of alloca, define if you know the\n   direction of stack growth for your system; otherwise it will be\n   automatically deduced at runtime.\n\tSTACK_DIRECTION > 0 => grows toward higher addresses\n\tSTACK_DIRECTION < 0 => grows toward lower addresses\n\tSTACK_DIRECTION = 0 => direction of growth unknown */\n/* #undef STACK_DIRECTION */\n\n/* Define to 1 if you have the ANSI C header files. */\n#define STDC_HEADERS 1\n\n/* Define if symbols are underscored. */\n#define SYMBOL_UNDERSCORE 1\n\n/* Define this if you are using Purify and want to suppress spurious messages.\n   */\n/* #undef USING_PURIFY */\n\n/* Version number of package */\n#define VERSION \"3.1-rc1\"\n\n/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most\n   significant byte first (like Motorola and SPARC, unlike Intel). */\n#if defined AC_APPLE_UNIVERSAL_BUILD\n# if defined __BIG_ENDIAN__\n#  define WORDS_BIGENDIAN 1\n# endif\n#else\n# ifndef WORDS_BIGENDIAN\n/* #  undef WORDS_BIGENDIAN */\n# endif\n#endif\n\n/* Define to `unsigned int' if <sys/types.h> does not define. */\n/* #undef size_t */\n\n\n#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE\n#ifdef LIBFFI_ASM\n#define FFI_HIDDEN(name) .hidden name\n#else\n#define FFI_HIDDEN __attribute__ ((visibility (\"hidden\")))\n#endif\n#else\n#ifdef LIBFFI_ASM\n#define FFI_HIDDEN(name)\n#else\n#define FFI_HIDDEN\n#endif\n#endif\n\n\n\n#endif"
  },
  {
    "path": "src/ffi/fficonfig_x86_64.h",
    "content": "#ifdef __x86_64__\n\n/* fficonfig.h.  Generated from fficonfig.h.in by configure.  */\n/* fficonfig.h.in.  Generated from configure.ac by autoheader.  */\n\n/* Define if building universal (internal helper macro) */\n/* #undef AC_APPLE_UNIVERSAL_BUILD */\n\n/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP\n   systems. This function is required for `alloca.c' support on those systems.\n   */\n/* #undef CRAY_STACKSEG_END */\n\n/* Define to 1 if using `alloca.c'. */\n/* #undef C_ALLOCA */\n\n/* Define to the flags needed for the .section .eh_frame directive. */\n#define EH_FRAME_FLAGS \"aw\"\n\n/* Define this if you want extra debugging. */\n/* #undef FFI_DEBUG */\n\n/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */\n/* #undef FFI_EXEC_TRAMPOLINE_TABLE */\n\n/* Define this if you want to enable pax emulated trampolines */\n/* #undef FFI_MMAP_EXEC_EMUTRAMP_PAX */\n\n/* Cannot use malloc on this target, so, we revert to alternative means */\n#define FFI_MMAP_EXEC_WRIT 1\n\n/* Define this if you do not want support for the raw API. */\n/* #undef FFI_NO_RAW_API */\n\n/* Define this if you do not want support for aggregate types. */\n/* #undef FFI_NO_STRUCTS */\n\n/* Define to 1 if you have `alloca', as a function or macro. */\n#define HAVE_ALLOCA 1\n\n/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).\n   */\n#define HAVE_ALLOCA_H 1\n\n/* Define if your assembler supports .ascii. */\n/* #undef HAVE_AS_ASCII_PSEUDO_OP */\n\n/* Define if your assembler supports .cfi_* directives. */\n#define HAVE_AS_CFI_PSEUDO_OP 1\n\n/* Define if your assembler supports .register. */\n/* #undef HAVE_AS_REGISTER_PSEUDO_OP */\n\n/* Define if your assembler and linker support unaligned PC relative relocs.\n   */\n/* #undef HAVE_AS_SPARC_UA_PCREL */\n\n/* Define if your assembler supports .string. */\n/* #undef HAVE_AS_STRING_PSEUDO_OP */\n\n/* Define if your assembler supports unwind section type. */\n/* #undef HAVE_AS_X86_64_UNWIND_SECTION_TYPE */\n\n/* Define if your assembler supports PC relative relocs. */\n/* #undef HAVE_AS_X86_PCREL */\n\n/* Define to 1 if you have the <dlfcn.h> header file. */\n#define HAVE_DLFCN_H 1\n\n/* Define if __attribute__((visibility(\"hidden\"))) is supported. */\n/* #undef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE */\n\n/* Define to 1 if you have the <inttypes.h> header file. */\n#define HAVE_INTTYPES_H 1\n\n/* Define if you have the long double type and it is bigger than a double */\n#define HAVE_LONG_DOUBLE 1\n\n/* Define if you support more than one size of the long double type */\n/* #undef HAVE_LONG_DOUBLE_VARIANT */\n\n/* Define to 1 if you have the `memcpy' function. */\n#define HAVE_MEMCPY 1\n\n/* Define to 1 if you have the <memory.h> header file. */\n#define HAVE_MEMORY_H 1\n\n/* Define to 1 if you have the `mmap' function. */\n#define HAVE_MMAP 1\n\n/* Define if mmap with MAP_ANON(YMOUS) works. */\n#define HAVE_MMAP_ANON 1\n\n/* Define if mmap of /dev/zero works. */\n/* #undef HAVE_MMAP_DEV_ZERO */\n\n/* Define if read-only mmap of a plain file works. */\n#define HAVE_MMAP_FILE 1\n\n/* Define if .eh_frame sections should be read-only. */\n/* #undef HAVE_RO_EH_FRAME */\n\n/* Define to 1 if you have the <stdint.h> header file. */\n#define HAVE_STDINT_H 1\n\n/* Define to 1 if you have the <stdlib.h> header file. */\n#define HAVE_STDLIB_H 1\n\n/* Define to 1 if you have the <strings.h> header file. */\n#define HAVE_STRINGS_H 1\n\n/* Define to 1 if you have the <string.h> header file. */\n#define HAVE_STRING_H 1\n\n/* Define to 1 if you have the <sys/mman.h> header file. */\n#define HAVE_SYS_MMAN_H 1\n\n/* Define to 1 if you have the <sys/stat.h> header file. */\n#define HAVE_SYS_STAT_H 1\n\n/* Define to 1 if you have the <sys/types.h> header file. */\n#define HAVE_SYS_TYPES_H 1\n\n/* Define to 1 if you have the <unistd.h> header file. */\n#define HAVE_UNISTD_H 1\n\n/* Define to the sub-directory in which libtool stores uninstalled libraries.\n   */\n#define LT_OBJDIR \".libs/\"\n\n/* Name of package */\n#define PACKAGE \"libffi\"\n\n/* Define to the address where bug reports for this package should be sent. */\n#define PACKAGE_BUGREPORT \"http://github.com/atgreen/libffi/issues\"\n\n/* Define to the full name of this package. */\n#define PACKAGE_NAME \"libffi\"\n\n/* Define to the full name and version of this package. */\n#define PACKAGE_STRING \"libffi 3.1-rc1\"\n\n/* Define to the one symbol short name of this package. */\n#define PACKAGE_TARNAME \"libffi\"\n\n/* Define to the home page for this package. */\n#define PACKAGE_URL \"\"\n\n/* Define to the version of this package. */\n#define PACKAGE_VERSION \"3.1-rc1\"\n\n/* The size of `double', as computed by sizeof. */\n#define SIZEOF_DOUBLE 8\n\n/* The size of `long double', as computed by sizeof. */\n#define SIZEOF_LONG_DOUBLE 16\n\n/* The size of `size_t', as computed by sizeof. */\n#define SIZEOF_SIZE_T 8\n\n/* If using the C implementation of alloca, define if you know the\n   direction of stack growth for your system; otherwise it will be\n   automatically deduced at runtime.\n\tSTACK_DIRECTION > 0 => grows toward higher addresses\n\tSTACK_DIRECTION < 0 => grows toward lower addresses\n\tSTACK_DIRECTION = 0 => direction of growth unknown */\n/* #undef STACK_DIRECTION */\n\n/* Define to 1 if you have the ANSI C header files. */\n#define STDC_HEADERS 1\n\n/* Define if symbols are underscored. */\n#define SYMBOL_UNDERSCORE 1\n\n/* Define this if you are using Purify and want to suppress spurious messages.\n   */\n/* #undef USING_PURIFY */\n\n/* Version number of package */\n#define VERSION \"3.1-rc1\"\n\n/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most\n   significant byte first (like Motorola and SPARC, unlike Intel). */\n#if defined AC_APPLE_UNIVERSAL_BUILD\n# if defined __BIG_ENDIAN__\n#  define WORDS_BIGENDIAN 1\n# endif\n#else\n# ifndef WORDS_BIGENDIAN\n/* #  undef WORDS_BIGENDIAN */\n# endif\n#endif\n\n/* Define to `unsigned int' if <sys/types.h> does not define. */\n/* #undef size_t */\n\n\n#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE\n#ifdef LIBFFI_ASM\n#define FFI_HIDDEN(name) .hidden name\n#else\n#define FFI_HIDDEN __attribute__ ((visibility (\"hidden\")))\n#endif\n#else\n#ifdef LIBFFI_ASM\n#define FFI_HIDDEN(name)\n#else\n#define FFI_HIDDEN\n#endif\n#endif\n\n\n\n#endif"
  },
  {
    "path": "src/ffi/ffitarget.h",
    "content": "#ifdef __arm64__\n\n#include \"ffitarget_arm64.h\"\n\n\n#endif\n#ifdef __i386__\n\n#include \"ffitarget_i386.h\"\n\n\n#endif\n#ifdef __arm__\n\n#include \"ffitarget_armv7.h\"\n\n\n#endif\n#ifdef __x86_64__\n\n#include \"ffitarget_x86_64.h\"\n\n\n#endif\n"
  },
  {
    "path": "src/ffi/ffitarget_arm64.h",
    "content": "#ifdef __arm64__\n\n/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n``Software''), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */\n\n#ifndef LIBFFI_TARGET_H\n#define LIBFFI_TARGET_H\n\n#ifndef LIBFFI_H\n#error \"Please do not include ffitarget.h directly into your source.  Use ffi.h instead.\"\n#endif\n\n#ifndef LIBFFI_ASM\ntypedef unsigned long ffi_arg;\ntypedef signed long ffi_sarg;\n\ntypedef enum ffi_abi\n  {\n    FFI_FIRST_ABI = 0,\n    FFI_SYSV,\n    FFI_LAST_ABI,\n    FFI_DEFAULT_ABI = FFI_SYSV\n  } ffi_abi;\n#endif\n\n/* ---- Definitions for closures ----------------------------------------- */\n\n#define FFI_CLOSURES 1\n#define FFI_TRAMPOLINE_SIZE 36\n#define FFI_NATIVE_RAW_API 0\n\n/* ---- Internal ---- */\n\n\n#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_flags\n\n#define AARCH64_FFI_WITH_V_BIT 0\n\n#define AARCH64_N_XREG 32\n#define AARCH64_N_VREG 32\n#define AARCH64_CALL_CONTEXT_SIZE (AARCH64_N_XREG * 8 + AARCH64_N_VREG * 16)\n\n#endif\n\n\n#endif"
  },
  {
    "path": "src/ffi/ffitarget_armv7.h",
    "content": "#ifdef __arm__\n\n/* -----------------------------------------------------------------*-C-*-\n   ffitarget.h - Copyright (c) 2012  Anthony Green\n                 Copyright (c) 2010  CodeSourcery\n                 Copyright (c) 1996-2003  Red Hat, Inc.\n\n   Target configuration macros for ARM.\n\n   Permission is hereby granted, free of charge, to any person obtaining\n   a copy of this software and associated documentation files (the\n   ``Software''), to deal in the Software without restriction, including\n   without limitation the rights to use, copy, modify, merge, publish,\n   distribute, sublicense, and/or sell copies of the Software, and to\n   permit persons to whom the Software is furnished to do so, subject to\n   the following conditions:\n\n   The above copyright notice and this permission notice shall be included\n   in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n   DEALINGS IN THE SOFTWARE.\n\n   ----------------------------------------------------------------------- */\n\n#ifndef LIBFFI_TARGET_H\n#define LIBFFI_TARGET_H\n\n#ifndef LIBFFI_H\n#error \"Please do not include ffitarget.h directly into your source.  Use ffi.h instead.\"\n#endif\n\n#ifndef LIBFFI_ASM\ntypedef unsigned long          ffi_arg;\ntypedef signed long            ffi_sarg;\n\ntypedef enum ffi_abi {\n  FFI_FIRST_ABI = 0,\n  FFI_SYSV,\n  FFI_VFP,\n  FFI_LAST_ABI,\n#ifdef __ARM_PCS_VFP\n  FFI_DEFAULT_ABI = FFI_VFP,\n#else\n  FFI_DEFAULT_ABI = FFI_SYSV,\n#endif\n} ffi_abi;\n#endif\n\n#define FFI_EXTRA_CIF_FIELDS\t\t\t\\\n  int vfp_used;\t\t\t\t\t\\\n  short vfp_reg_free, vfp_nargs;\t\t\\\n  signed char vfp_args[16]\t\t\t\\\n\n/* Internally used. */\n#define FFI_TYPE_STRUCT_VFP_FLOAT  (FFI_TYPE_LAST + 1)\n#define FFI_TYPE_STRUCT_VFP_DOUBLE (FFI_TYPE_LAST + 2)\n\n#define FFI_TARGET_SPECIFIC_VARIADIC\n\n/* ---- Definitions for closures ----------------------------------------- */\n\n#define FFI_CLOSURES 1\n#define FFI_TRAMPOLINE_SIZE 20\n#define FFI_NATIVE_RAW_API 0\n\n#endif\n\n\n#endif"
  },
  {
    "path": "src/ffi/ffitarget_i386.h",
    "content": "#ifdef __i386__\n\n/* -----------------------------------------------------------------*-C-*-\n   ffitarget.h - Copyright (c) 2012  Anthony Green\n                 Copyright (c) 1996-2003, 2010  Red Hat, Inc.\n                 Copyright (C) 2008  Free Software Foundation, Inc.\n\n   Target configuration macros for x86 and x86-64.\n\n   Permission is hereby granted, free of charge, to any person obtaining\n   a copy of this software and associated documentation files (the\n   ``Software''), to deal in the Software without restriction, including\n   without limitation the rights to use, copy, modify, merge, publish,\n   distribute, sublicense, and/or sell copies of the Software, and to\n   permit persons to whom the Software is furnished to do so, subject to\n   the following conditions:\n\n   The above copyright notice and this permission notice shall be included\n   in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n   DEALINGS IN THE SOFTWARE.\n\n   ----------------------------------------------------------------------- */\n\n#ifndef LIBFFI_TARGET_H\n#define LIBFFI_TARGET_H\n\n#ifndef LIBFFI_H\n#error \"Please do not include ffitarget.h directly into your source.  Use ffi.h instead.\"\n#endif\n\n/* ---- System specific configurations ----------------------------------- */\n\n/* For code common to all platforms on x86 and x86_64. */\n#define X86_ANY\n\n#if defined (X86_64) && defined (__i386__)\n#undef X86_64\n#define X86\n#endif\n\n#ifdef X86_WIN64\n#define FFI_SIZEOF_ARG 8\n#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */\n#endif\n\n/* ---- Generic type definitions ----------------------------------------- */\n\n#ifndef LIBFFI_ASM\n#ifdef X86_WIN64\n#ifdef _MSC_VER\ntypedef unsigned __int64       ffi_arg;\ntypedef __int64                ffi_sarg;\n#else\ntypedef unsigned long long     ffi_arg;\ntypedef long long              ffi_sarg;\n#endif\n#else\n#if defined __x86_64__ && defined __ILP32__\n#define FFI_SIZEOF_ARG 8\n#define FFI_SIZEOF_JAVA_RAW  4\ntypedef unsigned long long     ffi_arg;\ntypedef long long              ffi_sarg;\n#else\ntypedef unsigned long          ffi_arg;\ntypedef signed long            ffi_sarg;\n#endif\n#endif\n\ntypedef enum ffi_abi {\n  FFI_FIRST_ABI = 0,\n\n  /* ---- Intel x86 Win32 ---------- */\n#ifdef X86_WIN32\n  FFI_SYSV,\n  FFI_STDCALL,\n  FFI_THISCALL,\n  FFI_FASTCALL,\n  FFI_MS_CDECL,\n  FFI_LAST_ABI,\n#ifdef _MSC_VER\n  FFI_DEFAULT_ABI = FFI_MS_CDECL\n#else\n  FFI_DEFAULT_ABI = FFI_SYSV\n#endif\n\n#elif defined(X86_WIN64)\n  FFI_WIN64,\n  FFI_LAST_ABI,\n  FFI_DEFAULT_ABI = FFI_WIN64\n\n#else\n  /* ---- Intel x86 and AMD x86-64 - */\n  FFI_SYSV,\n  FFI_UNIX64,   /* Unix variants all use the same ABI for x86-64  */\n  FFI_THISCALL,\n  FFI_FASTCALL,\n  FFI_STDCALL,\n  FFI_LAST_ABI,\n#if defined(__i386__) || defined(__i386)\n  FFI_DEFAULT_ABI = FFI_SYSV\n#else\n  FFI_DEFAULT_ABI = FFI_UNIX64\n#endif\n#endif\n} ffi_abi;\n#endif\n\n/* ---- Definitions for closures ----------------------------------------- */\n\n#define FFI_CLOSURES 1\n#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)\n#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)\n#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)\n#define FFI_TYPE_MS_STRUCT       (FFI_TYPE_LAST + 4)\n\n#if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))\n#define FFI_TRAMPOLINE_SIZE 24\n#define FFI_NATIVE_RAW_API 0\n#elif defined(X86_WIN64)\n#define FFI_TRAMPOLINE_SIZE 29\n#define FFI_NATIVE_RAW_API 0\n#define FFI_NO_RAW_API 1\n#else\n#define FFI_TRAMPOLINE_SIZE 52\n#define FFI_NATIVE_RAW_API 1\t/* x86 has native raw api support */\n#endif\n\n#endif\n\n\n\n#endif"
  },
  {
    "path": "src/ffi/ffitarget_x86_64.h",
    "content": "#ifdef __x86_64__\n\n/* -----------------------------------------------------------------*-C-*-\n   ffitarget.h - Copyright (c) 2012  Anthony Green\n                 Copyright (c) 1996-2003, 2010  Red Hat, Inc.\n                 Copyright (C) 2008  Free Software Foundation, Inc.\n\n   Target configuration macros for x86 and x86-64.\n\n   Permission is hereby granted, free of charge, to any person obtaining\n   a copy of this software and associated documentation files (the\n   ``Software''), to deal in the Software without restriction, including\n   without limitation the rights to use, copy, modify, merge, publish,\n   distribute, sublicense, and/or sell copies of the Software, and to\n   permit persons to whom the Software is furnished to do so, subject to\n   the following conditions:\n\n   The above copyright notice and this permission notice shall be included\n   in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n   DEALINGS IN THE SOFTWARE.\n\n   ----------------------------------------------------------------------- */\n\n#ifndef LIBFFI_TARGET_H\n#define LIBFFI_TARGET_H\n\n#ifndef LIBFFI_H\n#error \"Please do not include ffitarget.h directly into your source.  Use ffi.h instead.\"\n#endif\n\n/* ---- System specific configurations ----------------------------------- */\n\n/* For code common to all platforms on x86 and x86_64. */\n#define X86_ANY\n\n#if defined (X86_64) && defined (__i386__)\n#undef X86_64\n#define X86\n#endif\n\n#ifdef X86_WIN64\n#define FFI_SIZEOF_ARG 8\n#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */\n#endif\n\n/* ---- Generic type definitions ----------------------------------------- */\n\n#ifndef LIBFFI_ASM\n#ifdef X86_WIN64\n#ifdef _MSC_VER\ntypedef unsigned __int64       ffi_arg;\ntypedef __int64                ffi_sarg;\n#else\ntypedef unsigned long long     ffi_arg;\ntypedef long long              ffi_sarg;\n#endif\n#else\n#if defined __x86_64__ && defined __ILP32__\n#define FFI_SIZEOF_ARG 8\n#define FFI_SIZEOF_JAVA_RAW  4\ntypedef unsigned long long     ffi_arg;\ntypedef long long              ffi_sarg;\n#else\ntypedef unsigned long          ffi_arg;\ntypedef signed long            ffi_sarg;\n#endif\n#endif\n\ntypedef enum ffi_abi {\n  FFI_FIRST_ABI = 0,\n\n  /* ---- Intel x86 Win32 ---------- */\n#ifdef X86_WIN32\n  FFI_SYSV,\n  FFI_STDCALL,\n  FFI_THISCALL,\n  FFI_FASTCALL,\n  FFI_MS_CDECL,\n  FFI_LAST_ABI,\n#ifdef _MSC_VER\n  FFI_DEFAULT_ABI = FFI_MS_CDECL\n#else\n  FFI_DEFAULT_ABI = FFI_SYSV\n#endif\n\n#elif defined(X86_WIN64)\n  FFI_WIN64,\n  FFI_LAST_ABI,\n  FFI_DEFAULT_ABI = FFI_WIN64\n\n#else\n  /* ---- Intel x86 and AMD x86-64 - */\n  FFI_SYSV,\n  FFI_UNIX64,   /* Unix variants all use the same ABI for x86-64  */\n  FFI_THISCALL,\n  FFI_FASTCALL,\n  FFI_STDCALL,\n  FFI_LAST_ABI,\n#if defined(__i386__) || defined(__i386)\n  FFI_DEFAULT_ABI = FFI_SYSV\n#else\n  FFI_DEFAULT_ABI = FFI_UNIX64\n#endif\n#endif\n} ffi_abi;\n#endif\n\n/* ---- Definitions for closures ----------------------------------------- */\n\n#define FFI_CLOSURES 1\n#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)\n#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)\n#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)\n#define FFI_TYPE_MS_STRUCT       (FFI_TYPE_LAST + 4)\n\n#if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))\n#define FFI_TRAMPOLINE_SIZE 24\n#define FFI_NATIVE_RAW_API 0\n#elif defined(X86_WIN64)\n#define FFI_TRAMPOLINE_SIZE 29\n#define FFI_NATIVE_RAW_API 0\n#define FFI_NO_RAW_API 1\n#else\n#define FFI_TRAMPOLINE_SIZE 52\n#define FFI_NATIVE_RAW_API 1\t/* x86 has native raw api support */\n#endif\n\n#endif\n\n\n\n#endif"
  },
  {
    "path": "src/jvm/clojure/asm/AnnotationVisitor.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * A visitor to visit a Java annotation. The methods of this class must be\n * called in the following order: ( <tt>visit</tt> | <tt>visitEnum</tt> |\n * <tt>visitAnnotation</tt> | <tt>visitArray</tt> )* <tt>visitEnd</tt>.\n *\n * @author Eric Bruneton\n * @author Eugene Kuleshov\n */\npublic abstract class AnnotationVisitor {\n\n    /**\n     * The ASM API version implemented by this visitor. The value of this field\n     * must be one of {@link Opcodes#ASM4}.\n     */\n    protected final int api;\n\n    /**\n     * The annotation visitor to which this visitor must delegate method calls.\n     * May be null.\n     */\n    protected AnnotationVisitor av;\n\n    /**\n     * Constructs a new {@link AnnotationVisitor}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     */\n    public AnnotationVisitor(final int api) {\n        this(api, null);\n    }\n\n    /**\n     * Constructs a new {@link AnnotationVisitor}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     * @param av\n     *            the annotation visitor to which this visitor must delegate\n     *            method calls. May be null.\n     */\n    public AnnotationVisitor(final int api, final AnnotationVisitor av) {\n        if (api != Opcodes.ASM4) {\n            throw new IllegalArgumentException();\n        }\n        this.api = api;\n        this.av = av;\n    }\n\n    /**\n     * Visits a primitive value of the annotation.\n     *\n     * @param name\n     *            the value name.\n     * @param value\n     *            the actual value, whose type must be {@link Byte},\n     *            {@link Boolean}, {@link Character}, {@link Short},\n     *            {@link Integer} , {@link Long}, {@link Float}, {@link Double},\n     *            {@link String} or {@link Type} or OBJECT or ARRAY sort. This\n     *            value can also be an array of byte, boolean, short, char, int,\n     *            long, float or double values (this is equivalent to using\n     *            {@link #visitArray visitArray} and visiting each array element\n     *            in turn, but is more convenient).\n     */\n    public void visit(String name, Object value) {\n        if (av != null) {\n            av.visit(name, value);\n        }\n    }\n\n    /**\n     * Visits an enumeration value of the annotation.\n     *\n     * @param name\n     *            the value name.\n     * @param desc\n     *            the class descriptor of the enumeration class.\n     * @param value\n     *            the actual enumeration value.\n     */\n    public void visitEnum(String name, String desc, String value) {\n        if (av != null) {\n            av.visitEnum(name, desc, value);\n        }\n    }\n\n    /**\n     * Visits a nested annotation value of the annotation.\n     *\n     * @param name\n     *            the value name.\n     * @param desc\n     *            the class descriptor of the nested annotation class.\n     * @return a visitor to visit the actual nested annotation value, or\n     *         <tt>null</tt> if this visitor is not interested in visiting this\n     *         nested annotation. <i>The nested annotation value must be fully\n     *         visited before calling other methods on this annotation\n     *         visitor</i>.\n     */\n    public AnnotationVisitor visitAnnotation(String name, String desc) {\n        if (av != null) {\n            return av.visitAnnotation(name, desc);\n        }\n        return null;\n    }\n\n    /**\n     * Visits an array value of the annotation. Note that arrays of primitive\n     * types (such as byte, boolean, short, char, int, long, float or double)\n     * can be passed as value to {@link #visit visit}. This is what\n     * {@link ClassReader} does.\n     *\n     * @param name\n     *            the value name.\n     * @return a visitor to visit the actual array value elements, or\n     *         <tt>null</tt> if this visitor is not interested in visiting these\n     *         values. The 'name' parameters passed to the methods of this\n     *         visitor are ignored. <i>All the array values must be visited\n     *         before calling other methods on this annotation visitor</i>.\n     */\n    public AnnotationVisitor visitArray(String name) {\n        if (av != null) {\n            return av.visitArray(name);\n        }\n        return null;\n    }\n\n    /**\n     * Visits the end of the annotation.\n     */\n    public void visitEnd() {\n        if (av != null) {\n            av.visitEnd();\n        }\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/AnnotationWriter.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * An {@link AnnotationVisitor} that generates annotations in bytecode form.\n *\n * @author Eric Bruneton\n * @author Eugene Kuleshov\n */\nfinal class AnnotationWriter extends AnnotationVisitor {\n\n    /**\n     * The class writer to which this annotation must be added.\n     */\n    private final ClassWriter cw;\n\n    /**\n     * The number of values in this annotation.\n     */\n    private int size;\n\n    /**\n     * <tt>true<tt> if values are named, <tt>false</tt> otherwise. Annotation\n     * writers used for annotation default and annotation arrays use unnamed\n     * values.\n     */\n    private final boolean named;\n\n    /**\n     * The annotation values in bytecode form. This byte vector only contains\n     * the values themselves, i.e. the number of values must be stored as a\n     * unsigned short just before these bytes.\n     */\n    private final ByteVector bv;\n\n    /**\n     * The byte vector to be used to store the number of values of this\n     * annotation. See {@link #bv}.\n     */\n    private final ByteVector parent;\n\n    /**\n     * Where the number of values of this annotation must be stored in\n     * {@link #parent}.\n     */\n    private final int offset;\n\n    /**\n     * Next annotation writer. This field is used to store annotation lists.\n     */\n    AnnotationWriter next;\n\n    /**\n     * Previous annotation writer. This field is used to store annotation lists.\n     */\n    AnnotationWriter prev;\n\n    // ------------------------------------------------------------------------\n    // Constructor\n    // ------------------------------------------------------------------------\n\n    /**\n     * Constructs a new {@link AnnotationWriter}.\n     *\n     * @param cw\n     *            the class writer to which this annotation must be added.\n     * @param named\n     *            <tt>true<tt> if values are named, <tt>false</tt> otherwise.\n     * @param bv\n     *            where the annotation values must be stored.\n     * @param parent\n     *            where the number of annotation values must be stored.\n     * @param offset\n     *            where in <tt>parent</tt> the number of annotation values must\n     *            be stored.\n     */\n    AnnotationWriter(final ClassWriter cw, final boolean named,\n            final ByteVector bv, final ByteVector parent, final int offset) {\n        super(Opcodes.ASM4);\n        this.cw = cw;\n        this.named = named;\n        this.bv = bv;\n        this.parent = parent;\n        this.offset = offset;\n    }\n\n    // ------------------------------------------------------------------------\n    // Implementation of the AnnotationVisitor abstract class\n    // ------------------------------------------------------------------------\n\n    @Override\n    public void visit(final String name, final Object value) {\n        ++size;\n        if (named) {\n            bv.putShort(cw.newUTF8(name));\n        }\n        if (value instanceof String) {\n            bv.put12('s', cw.newUTF8((String) value));\n        } else if (value instanceof Byte) {\n            bv.put12('B', cw.newInteger(((Byte) value).byteValue()).index);\n        } else if (value instanceof Boolean) {\n            int v = ((Boolean) value).booleanValue() ? 1 : 0;\n            bv.put12('Z', cw.newInteger(v).index);\n        } else if (value instanceof Character) {\n            bv.put12('C', cw.newInteger(((Character) value).charValue()).index);\n        } else if (value instanceof Short) {\n            bv.put12('S', cw.newInteger(((Short) value).shortValue()).index);\n        } else if (value instanceof Type) {\n            bv.put12('c', cw.newUTF8(((Type) value).getDescriptor()));\n        } else if (value instanceof byte[]) {\n            byte[] v = (byte[]) value;\n            bv.put12('[', v.length);\n            for (int i = 0; i < v.length; i++) {\n                bv.put12('B', cw.newInteger(v[i]).index);\n            }\n        } else if (value instanceof boolean[]) {\n            boolean[] v = (boolean[]) value;\n            bv.put12('[', v.length);\n            for (int i = 0; i < v.length; i++) {\n                bv.put12('Z', cw.newInteger(v[i] ? 1 : 0).index);\n            }\n        } else if (value instanceof short[]) {\n            short[] v = (short[]) value;\n            bv.put12('[', v.length);\n            for (int i = 0; i < v.length; i++) {\n                bv.put12('S', cw.newInteger(v[i]).index);\n            }\n        } else if (value instanceof char[]) {\n            char[] v = (char[]) value;\n            bv.put12('[', v.length);\n            for (int i = 0; i < v.length; i++) {\n                bv.put12('C', cw.newInteger(v[i]).index);\n            }\n        } else if (value instanceof int[]) {\n            int[] v = (int[]) value;\n            bv.put12('[', v.length);\n            for (int i = 0; i < v.length; i++) {\n                bv.put12('I', cw.newInteger(v[i]).index);\n            }\n        } else if (value instanceof long[]) {\n            long[] v = (long[]) value;\n            bv.put12('[', v.length);\n            for (int i = 0; i < v.length; i++) {\n                bv.put12('J', cw.newLong(v[i]).index);\n            }\n        } else if (value instanceof float[]) {\n            float[] v = (float[]) value;\n            bv.put12('[', v.length);\n            for (int i = 0; i < v.length; i++) {\n                bv.put12('F', cw.newFloat(v[i]).index);\n            }\n        } else if (value instanceof double[]) {\n            double[] v = (double[]) value;\n            bv.put12('[', v.length);\n            for (int i = 0; i < v.length; i++) {\n                bv.put12('D', cw.newDouble(v[i]).index);\n            }\n        } else {\n            Item i = cw.newConstItem(value);\n            bv.put12(\".s.IFJDCS\".charAt(i.type), i.index);\n        }\n    }\n\n    @Override\n    public void visitEnum(final String name, final String desc,\n            final String value) {\n        ++size;\n        if (named) {\n            bv.putShort(cw.newUTF8(name));\n        }\n        bv.put12('e', cw.newUTF8(desc)).putShort(cw.newUTF8(value));\n    }\n\n    @Override\n    public AnnotationVisitor visitAnnotation(final String name,\n            final String desc) {\n        ++size;\n        if (named) {\n            bv.putShort(cw.newUTF8(name));\n        }\n        // write tag and type, and reserve space for values count\n        bv.put12('@', cw.newUTF8(desc)).putShort(0);\n        return new AnnotationWriter(cw, true, bv, bv, bv.length - 2);\n    }\n\n    @Override\n    public AnnotationVisitor visitArray(final String name) {\n        ++size;\n        if (named) {\n            bv.putShort(cw.newUTF8(name));\n        }\n        // write tag, and reserve space for array size\n        bv.put12('[', 0);\n        return new AnnotationWriter(cw, false, bv, bv, bv.length - 2);\n    }\n\n    @Override\n    public void visitEnd() {\n        if (parent != null) {\n            byte[] data = parent.data;\n            data[offset] = (byte) (size >>> 8);\n            data[offset + 1] = (byte) size;\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Utility methods\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns the size of this annotation writer list.\n     *\n     * @return the size of this annotation writer list.\n     */\n    int getSize() {\n        int size = 0;\n        AnnotationWriter aw = this;\n        while (aw != null) {\n            size += aw.bv.length;\n            aw = aw.next;\n        }\n        return size;\n    }\n\n    /**\n     * Puts the annotations of this annotation writer list into the given byte\n     * vector.\n     *\n     * @param out\n     *            where the annotations must be put.\n     */\n    void put(final ByteVector out) {\n        int n = 0;\n        int size = 2;\n        AnnotationWriter aw = this;\n        AnnotationWriter last = null;\n        while (aw != null) {\n            ++n;\n            size += aw.bv.length;\n            aw.visitEnd(); // in case user forgot to call visitEnd\n            aw.prev = last;\n            last = aw;\n            aw = aw.next;\n        }\n        out.putInt(size);\n        out.putShort(n);\n        aw = last;\n        while (aw != null) {\n            out.putByteArray(aw.bv.data, 0, aw.bv.length);\n            aw = aw.prev;\n        }\n    }\n\n    /**\n     * Puts the given annotation lists into the given byte vector.\n     *\n     * @param panns\n     *            an array of annotation writer lists.\n     * @param off\n     *            index of the first annotation to be written.\n     * @param out\n     *            where the annotations must be put.\n     */\n    static void put(final AnnotationWriter[] panns, final int off,\n            final ByteVector out) {\n        int size = 1 + 2 * (panns.length - off);\n        for (int i = off; i < panns.length; ++i) {\n            size += panns[i] == null ? 0 : panns[i].getSize();\n        }\n        out.putInt(size).putByte(panns.length - off);\n        for (int i = off; i < panns.length; ++i) {\n            AnnotationWriter aw = panns[i];\n            AnnotationWriter last = null;\n            int n = 0;\n            while (aw != null) {\n                ++n;\n                aw.visitEnd(); // in case user forgot to call visitEnd\n                aw.prev = last;\n                last = aw;\n                aw = aw.next;\n            }\n            out.putShort(n);\n            aw = last;\n            while (aw != null) {\n                out.putByteArray(aw.bv.data, 0, aw.bv.length);\n                aw = aw.prev;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/Attribute.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * A non standard class, field, method or code attribute.\n *\n * @author Eric Bruneton\n * @author Eugene Kuleshov\n */\npublic class Attribute {\n\n    /**\n     * The type of this attribute.\n     */\n    public final String type;\n\n    /**\n     * The raw value of this attribute, used only for unknown attributes.\n     */\n    byte[] value;\n\n    /**\n     * The next attribute in this attribute list. May be <tt>null</tt>.\n     */\n    Attribute next;\n\n    /**\n     * Constructs a new empty attribute.\n     *\n     * @param type\n     *            the type of the attribute.\n     */\n    protected Attribute(final String type) {\n        this.type = type;\n    }\n\n    /**\n     * Returns <tt>true</tt> if this type of attribute is unknown. The default\n     * implementation of this method always returns <tt>true</tt>.\n     *\n     * @return <tt>true</tt> if this type of attribute is unknown.\n     */\n    public boolean isUnknown() {\n        return true;\n    }\n\n    /**\n     * Returns <tt>true</tt> if this type of attribute is a code attribute.\n     *\n     * @return <tt>true</tt> if this type of attribute is a code attribute.\n     */\n    public boolean isCodeAttribute() {\n        return false;\n    }\n\n    /**\n     * Returns the labels corresponding to this attribute.\n     *\n     * @return the labels corresponding to this attribute, or <tt>null</tt> if\n     *         this attribute is not a code attribute that contains labels.\n     */\n    protected Label[] getLabels() {\n        return null;\n    }\n\n    /**\n     * Reads a {@link #type type} attribute. This method must return a\n     * <i>new</i> {@link Attribute} object, of type {@link #type type},\n     * corresponding to the <tt>len</tt> bytes starting at the given offset, in\n     * the given class reader.\n     *\n     * @param cr\n     *            the class that contains the attribute to be read.\n     * @param off\n     *            index of the first byte of the attribute's content in\n     *            {@link ClassReader#b cr.b}. The 6 attribute header bytes,\n     *            containing the type and the length of the attribute, are not\n     *            taken into account here.\n     * @param len\n     *            the length of the attribute's content.\n     * @param buf\n     *            buffer to be used to call {@link ClassReader#readUTF8\n     *            readUTF8}, {@link ClassReader#readClass(int,char[]) readClass}\n     *            or {@link ClassReader#readConst readConst}.\n     * @param codeOff\n     *            index of the first byte of code's attribute content in\n     *            {@link ClassReader#b cr.b}, or -1 if the attribute to be read\n     *            is not a code attribute. The 6 attribute header bytes,\n     *            containing the type and the length of the attribute, are not\n     *            taken into account here.\n     * @param labels\n     *            the labels of the method's code, or <tt>null</tt> if the\n     *            attribute to be read is not a code attribute.\n     * @return a <i>new</i> {@link Attribute} object corresponding to the given\n     *         bytes.\n     */\n    protected Attribute read(final ClassReader cr, final int off,\n            final int len, final char[] buf, final int codeOff,\n            final Label[] labels) {\n        Attribute attr = new Attribute(type);\n        attr.value = new byte[len];\n        System.arraycopy(cr.b, off, attr.value, 0, len);\n        return attr;\n    }\n\n    /**\n     * Returns the byte array form of this attribute.\n     *\n     * @param cw\n     *            the class to which this attribute must be added. This\n     *            parameter can be used to add to the constant pool of this\n     *            class the items that corresponds to this attribute.\n     * @param code\n     *            the bytecode of the method corresponding to this code\n     *            attribute, or <tt>null</tt> if this attribute is not a code\n     *            attributes.\n     * @param len\n     *            the length of the bytecode of the method corresponding to this\n     *            code attribute, or <tt>null</tt> if this attribute is not a\n     *            code attribute.\n     * @param maxStack\n     *            the maximum stack size of the method corresponding to this\n     *            code attribute, or -1 if this attribute is not a code\n     *            attribute.\n     * @param maxLocals\n     *            the maximum number of local variables of the method\n     *            corresponding to this code attribute, or -1 if this attribute\n     *            is not a code attribute.\n     * @return the byte array form of this attribute.\n     */\n    protected ByteVector write(final ClassWriter cw, final byte[] code,\n            final int len, final int maxStack, final int maxLocals) {\n        ByteVector v = new ByteVector();\n        v.data = value;\n        v.length = value.length;\n        return v;\n    }\n\n    /**\n     * Returns the length of the attribute list that begins with this attribute.\n     *\n     * @return the length of the attribute list that begins with this attribute.\n     */\n    final int getCount() {\n        int count = 0;\n        Attribute attr = this;\n        while (attr != null) {\n            count += 1;\n            attr = attr.next;\n        }\n        return count;\n    }\n\n    /**\n     * Returns the size of all the attributes in this attribute list.\n     *\n     * @param cw\n     *            the class writer to be used to convert the attributes into\n     *            byte arrays, with the {@link #write write} method.\n     * @param code\n     *            the bytecode of the method corresponding to these code\n     *            attributes, or <tt>null</tt> if these attributes are not code\n     *            attributes.\n     * @param len\n     *            the length of the bytecode of the method corresponding to\n     *            these code attributes, or <tt>null</tt> if these attributes\n     *            are not code attributes.\n     * @param maxStack\n     *            the maximum stack size of the method corresponding to these\n     *            code attributes, or -1 if these attributes are not code\n     *            attributes.\n     * @param maxLocals\n     *            the maximum number of local variables of the method\n     *            corresponding to these code attributes, or -1 if these\n     *            attributes are not code attributes.\n     * @return the size of all the attributes in this attribute list. This size\n     *         includes the size of the attribute headers.\n     */\n    final int getSize(final ClassWriter cw, final byte[] code, final int len,\n            final int maxStack, final int maxLocals) {\n        Attribute attr = this;\n        int size = 0;\n        while (attr != null) {\n            cw.newUTF8(attr.type);\n            size += attr.write(cw, code, len, maxStack, maxLocals).length + 6;\n            attr = attr.next;\n        }\n        return size;\n    }\n\n    /**\n     * Writes all the attributes of this attribute list in the given byte\n     * vector.\n     *\n     * @param cw\n     *            the class writer to be used to convert the attributes into\n     *            byte arrays, with the {@link #write write} method.\n     * @param code\n     *            the bytecode of the method corresponding to these code\n     *            attributes, or <tt>null</tt> if these attributes are not code\n     *            attributes.\n     * @param len\n     *            the length of the bytecode of the method corresponding to\n     *            these code attributes, or <tt>null</tt> if these attributes\n     *            are not code attributes.\n     * @param maxStack\n     *            the maximum stack size of the method corresponding to these\n     *            code attributes, or -1 if these attributes are not code\n     *            attributes.\n     * @param maxLocals\n     *            the maximum number of local variables of the method\n     *            corresponding to these code attributes, or -1 if these\n     *            attributes are not code attributes.\n     * @param out\n     *            where the attributes must be written.\n     */\n    final void put(final ClassWriter cw, final byte[] code, final int len,\n            final int maxStack, final int maxLocals, final ByteVector out) {\n        Attribute attr = this;\n        while (attr != null) {\n            ByteVector b = attr.write(cw, code, len, maxStack, maxLocals);\n            out.putShort(cw.newUTF8(attr.type)).putInt(b.length);\n            out.putByteArray(b.data, 0, b.length);\n            attr = attr.next;\n        }\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/ByteVector.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * A dynamically extensible vector of bytes. This class is roughly equivalent to\n * a DataOutputStream on top of a ByteArrayOutputStream, but is more efficient.\n *\n * @author Eric Bruneton\n */\npublic class ByteVector {\n\n    /**\n     * The content of this vector.\n     */\n    byte[] data;\n\n    /**\n     * Actual number of bytes in this vector.\n     */\n    int length;\n\n    /**\n     * Constructs a new {@link ByteVector ByteVector} with a default initial\n     * size.\n     */\n    public ByteVector() {\n        data = new byte[64];\n    }\n\n    /**\n     * Constructs a new {@link ByteVector ByteVector} with the given initial\n     * size.\n     *\n     * @param initialSize\n     *            the initial size of the byte vector to be constructed.\n     */\n    public ByteVector(final int initialSize) {\n        data = new byte[initialSize];\n    }\n\n    /**\n     * Puts a byte into this byte vector. The byte vector is automatically\n     * enlarged if necessary.\n     *\n     * @param b\n     *            a byte.\n     * @return this byte vector.\n     */\n    public ByteVector putByte(final int b) {\n        int length = this.length;\n        if (length + 1 > data.length) {\n            enlarge(1);\n        }\n        data[length++] = (byte) b;\n        this.length = length;\n        return this;\n    }\n\n    /**\n     * Puts two bytes into this byte vector. The byte vector is automatically\n     * enlarged if necessary.\n     *\n     * @param b1\n     *            a byte.\n     * @param b2\n     *            another byte.\n     * @return this byte vector.\n     */\n    ByteVector put11(final int b1, final int b2) {\n        int length = this.length;\n        if (length + 2 > data.length) {\n            enlarge(2);\n        }\n        byte[] data = this.data;\n        data[length++] = (byte) b1;\n        data[length++] = (byte) b2;\n        this.length = length;\n        return this;\n    }\n\n    /**\n     * Puts a short into this byte vector. The byte vector is automatically\n     * enlarged if necessary.\n     *\n     * @param s\n     *            a short.\n     * @return this byte vector.\n     */\n    public ByteVector putShort(final int s) {\n        int length = this.length;\n        if (length + 2 > data.length) {\n            enlarge(2);\n        }\n        byte[] data = this.data;\n        data[length++] = (byte) (s >>> 8);\n        data[length++] = (byte) s;\n        this.length = length;\n        return this;\n    }\n\n    /**\n     * Puts a byte and a short into this byte vector. The byte vector is\n     * automatically enlarged if necessary.\n     *\n     * @param b\n     *            a byte.\n     * @param s\n     *            a short.\n     * @return this byte vector.\n     */\n    ByteVector put12(final int b, final int s) {\n        int length = this.length;\n        if (length + 3 > data.length) {\n            enlarge(3);\n        }\n        byte[] data = this.data;\n        data[length++] = (byte) b;\n        data[length++] = (byte) (s >>> 8);\n        data[length++] = (byte) s;\n        this.length = length;\n        return this;\n    }\n\n    /**\n     * Puts an int into this byte vector. The byte vector is automatically\n     * enlarged if necessary.\n     *\n     * @param i\n     *            an int.\n     * @return this byte vector.\n     */\n    public ByteVector putInt(final int i) {\n        int length = this.length;\n        if (length + 4 > data.length) {\n            enlarge(4);\n        }\n        byte[] data = this.data;\n        data[length++] = (byte) (i >>> 24);\n        data[length++] = (byte) (i >>> 16);\n        data[length++] = (byte) (i >>> 8);\n        data[length++] = (byte) i;\n        this.length = length;\n        return this;\n    }\n\n    /**\n     * Puts a long into this byte vector. The byte vector is automatically\n     * enlarged if necessary.\n     *\n     * @param l\n     *            a long.\n     * @return this byte vector.\n     */\n    public ByteVector putLong(final long l) {\n        int length = this.length;\n        if (length + 8 > data.length) {\n            enlarge(8);\n        }\n        byte[] data = this.data;\n        int i = (int) (l >>> 32);\n        data[length++] = (byte) (i >>> 24);\n        data[length++] = (byte) (i >>> 16);\n        data[length++] = (byte) (i >>> 8);\n        data[length++] = (byte) i;\n        i = (int) l;\n        data[length++] = (byte) (i >>> 24);\n        data[length++] = (byte) (i >>> 16);\n        data[length++] = (byte) (i >>> 8);\n        data[length++] = (byte) i;\n        this.length = length;\n        return this;\n    }\n\n    /**\n     * Puts an UTF8 string into this byte vector. The byte vector is\n     * automatically enlarged if necessary.\n     *\n     * @param s\n     *            a String.\n     * @return this byte vector.\n     */\n    public ByteVector putUTF8(final String s) {\n        int charLength = s.length();\n        int len = length;\n        if (len + 2 + charLength > data.length) {\n            enlarge(2 + charLength);\n        }\n        byte[] data = this.data;\n        // optimistic algorithm: instead of computing the byte length and then\n        // serializing the string (which requires two loops), we assume the byte\n        // length is equal to char length (which is the most frequent case), and\n        // we start serializing the string right away. During the serialization,\n        // if we find that this assumption is wrong, we continue with the\n        // general method.\n        data[len++] = (byte) (charLength >>> 8);\n        data[len++] = (byte) charLength;\n        for (int i = 0; i < charLength; ++i) {\n            char c = s.charAt(i);\n            if (c >= '\\001' && c <= '\\177') {\n                data[len++] = (byte) c;\n            } else {\n                int byteLength = i;\n                for (int j = i; j < charLength; ++j) {\n                    c = s.charAt(j);\n                    if (c >= '\\001' && c <= '\\177') {\n                        byteLength++;\n                    } else if (c > '\\u07FF') {\n                        byteLength += 3;\n                    } else {\n                        byteLength += 2;\n                    }\n                }\n                data[length] = (byte) (byteLength >>> 8);\n                data[length + 1] = (byte) byteLength;\n                if (length + 2 + byteLength > data.length) {\n                    length = len;\n                    enlarge(2 + byteLength);\n                    data = this.data;\n                }\n                for (int j = i; j < charLength; ++j) {\n                    c = s.charAt(j);\n                    if (c >= '\\001' && c <= '\\177') {\n                        data[len++] = (byte) c;\n                    } else if (c > '\\u07FF') {\n                        data[len++] = (byte) (0xE0 | c >> 12 & 0xF);\n                        data[len++] = (byte) (0x80 | c >> 6 & 0x3F);\n                        data[len++] = (byte) (0x80 | c & 0x3F);\n                    } else {\n                        data[len++] = (byte) (0xC0 | c >> 6 & 0x1F);\n                        data[len++] = (byte) (0x80 | c & 0x3F);\n                    }\n                }\n                break;\n            }\n        }\n        length = len;\n        return this;\n    }\n\n    /**\n     * Puts an array of bytes into this byte vector. The byte vector is\n     * automatically enlarged if necessary.\n     *\n     * @param b\n     *            an array of bytes. May be <tt>null</tt> to put <tt>len</tt>\n     *            null bytes into this byte vector.\n     * @param off\n     *            index of the fist byte of b that must be copied.\n     * @param len\n     *            number of bytes of b that must be copied.\n     * @return this byte vector.\n     */\n    public ByteVector putByteArray(final byte[] b, final int off, final int len) {\n        if (length + len > data.length) {\n            enlarge(len);\n        }\n        if (b != null) {\n            System.arraycopy(b, off, data, length, len);\n        }\n        length += len;\n        return this;\n    }\n\n    /**\n     * Enlarge this byte vector so that it can receive n more bytes.\n     *\n     * @param size\n     *            number of additional bytes that this byte vector should be\n     *            able to receive.\n     */\n    private void enlarge(final int size) {\n        int length1 = 2 * data.length;\n        int length2 = length + size;\n        byte[] newData = new byte[length1 > length2 ? length1 : length2];\n        System.arraycopy(data, 0, newData, 0, length);\n        data = newData;\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/ClassReader.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/**\n * A Java class parser to make a {@link ClassVisitor} visit an existing class.\n * This class parses a byte array conforming to the Java class file format and\n * calls the appropriate visit methods of a given class visitor for each field,\n * method and bytecode instruction encountered.\n *\n * @author Eric Bruneton\n * @author Eugene Kuleshov\n */\npublic class ClassReader {\n\n    /**\n     * True to enable signatures support.\n     */\n    static final boolean SIGNATURES = true;\n\n    /**\n     * True to enable annotations support.\n     */\n    static final boolean ANNOTATIONS = true;\n\n    /**\n     * True to enable stack map frames support.\n     */\n    static final boolean FRAMES = true;\n\n    /**\n     * True to enable bytecode writing support.\n     */\n    static final boolean WRITER = true;\n\n    /**\n     * True to enable JSR_W and GOTO_W support.\n     */\n    static final boolean RESIZE = true;\n\n    /**\n     * Flag to skip method code. If this class is set <code>CODE</code>\n     * attribute won't be visited. This can be used, for example, to retrieve\n     * annotations for methods and method parameters.\n     */\n    public static final int SKIP_CODE = 1;\n\n    /**\n     * Flag to skip the debug information in the class. If this flag is set the\n     * debug information of the class is not visited, i.e. the\n     * {@link MethodVisitor#visitLocalVariable visitLocalVariable} and\n     * {@link MethodVisitor#visitLineNumber visitLineNumber} methods will not be\n     * called.\n     */\n    public static final int SKIP_DEBUG = 2;\n\n    /**\n     * Flag to skip the stack map frames in the class. If this flag is set the\n     * stack map frames of the class is not visited, i.e. the\n     * {@link MethodVisitor#visitFrame visitFrame} method will not be called.\n     * This flag is useful when the {@link ClassWriter#COMPUTE_FRAMES} option is\n     * used: it avoids visiting frames that will be ignored and recomputed from\n     * scratch in the class writer.\n     */\n    public static final int SKIP_FRAMES = 4;\n\n    /**\n     * Flag to expand the stack map frames. By default stack map frames are\n     * visited in their original format (i.e. \"expanded\" for classes whose\n     * version is less than V1_6, and \"compressed\" for the other classes). If\n     * this flag is set, stack map frames are always visited in expanded format\n     * (this option adds a decompression/recompression step in ClassReader and\n     * ClassWriter which degrades performances quite a lot).\n     */\n    public static final int EXPAND_FRAMES = 8;\n\n    /**\n     * The class to be parsed. <i>The content of this array must not be\n     * modified. This field is intended for {@link Attribute} sub classes, and\n     * is normally not needed by class generators or adapters.</i>\n     */\n    public final byte[] b;\n\n    /**\n     * The start index of each constant pool item in {@link #b b}, plus one. The\n     * one byte offset skips the constant pool item tag that indicates its type.\n     */\n    private final int[] items;\n\n    /**\n     * The String objects corresponding to the CONSTANT_Utf8 items. This cache\n     * avoids multiple parsing of a given CONSTANT_Utf8 constant pool item,\n     * which GREATLY improves performances (by a factor 2 to 3). This caching\n     * strategy could be extended to all constant pool items, but its benefit\n     * would not be so great for these items (because they are much less\n     * expensive to parse than CONSTANT_Utf8 items).\n     */\n    private final String[] strings;\n\n    /**\n     * Maximum length of the strings contained in the constant pool of the\n     * class.\n     */\n    private final int maxStringLength;\n\n    /**\n     * Start index of the class header information (access, name...) in\n     * {@link #b b}.\n     */\n    public final int header;\n\n    // ------------------------------------------------------------------------\n    // Constructors\n    // ------------------------------------------------------------------------\n\n    /**\n     * Constructs a new {@link ClassReader} object.\n     *\n     * @param b\n     *            the bytecode of the class to be read.\n     */\n    public ClassReader(final byte[] b) {\n        this(b, 0, b.length);\n    }\n\n    /**\n     * Constructs a new {@link ClassReader} object.\n     *\n     * @param b\n     *            the bytecode of the class to be read.\n     * @param off\n     *            the start offset of the class data.\n     * @param len\n     *            the length of the class data.\n     */\n    public ClassReader(final byte[] b, final int off, final int len) {\n        this.b = b;\n        // checks the class version\n        if (readShort(off + 6) > Opcodes.V1_7) {\n            throw new IllegalArgumentException();\n        }\n        // parses the constant pool\n        items = new int[readUnsignedShort(off + 8)];\n        int n = items.length;\n        strings = new String[n];\n        int max = 0;\n        int index = off + 10;\n        for (int i = 1; i < n; ++i) {\n            items[i] = index + 1;\n            int size;\n            switch (b[index]) {\n            case ClassWriter.FIELD:\n            case ClassWriter.METH:\n            case ClassWriter.IMETH:\n            case ClassWriter.INT:\n            case ClassWriter.FLOAT:\n            case ClassWriter.NAME_TYPE:\n            case ClassWriter.INDY:\n                size = 5;\n                break;\n            case ClassWriter.LONG:\n            case ClassWriter.DOUBLE:\n                size = 9;\n                ++i;\n                break;\n            case ClassWriter.UTF8:\n                size = 3 + readUnsignedShort(index + 1);\n                if (size > max) {\n                    max = size;\n                }\n                break;\n            case ClassWriter.HANDLE:\n                size = 4;\n                break;\n            // case ClassWriter.CLASS:\n            // case ClassWriter.STR:\n            // case ClassWriter.MTYPE\n            default:\n                size = 3;\n                break;\n            }\n            index += size;\n        }\n        maxStringLength = max;\n        // the class header information starts just after the constant pool\n        header = index;\n    }\n\n    /**\n     * Returns the class's access flags (see {@link Opcodes}). This value may\n     * not reflect Deprecated and Synthetic flags when bytecode is before 1.5\n     * and those flags are represented by attributes.\n     *\n     * @return the class access flags\n     *\n     * @see ClassVisitor#visit(int, int, String, String, String, String[])\n     */\n    public int getAccess() {\n        return readUnsignedShort(header);\n    }\n\n    /**\n     * Returns the internal name of the class (see\n     * {@link Type#getInternalName() getInternalName}).\n     *\n     * @return the internal class name\n     *\n     * @see ClassVisitor#visit(int, int, String, String, String, String[])\n     */\n    public String getClassName() {\n        return readClass(header + 2, new char[maxStringLength]);\n    }\n\n    /**\n     * Returns the internal of name of the super class (see\n     * {@link Type#getInternalName() getInternalName}). For interfaces, the\n     * super class is {@link Object}.\n     *\n     * @return the internal name of super class, or <tt>null</tt> for\n     *         {@link Object} class.\n     *\n     * @see ClassVisitor#visit(int, int, String, String, String, String[])\n     */\n    public String getSuperName() {\n        return readClass(header + 4, new char[maxStringLength]);\n    }\n\n    /**\n     * Returns the internal names of the class's interfaces (see\n     * {@link Type#getInternalName() getInternalName}).\n     *\n     * @return the array of internal names for all implemented interfaces or\n     *         <tt>null</tt>.\n     *\n     * @see ClassVisitor#visit(int, int, String, String, String, String[])\n     */\n    public String[] getInterfaces() {\n        int index = header + 6;\n        int n = readUnsignedShort(index);\n        String[] interfaces = new String[n];\n        if (n > 0) {\n            char[] buf = new char[maxStringLength];\n            for (int i = 0; i < n; ++i) {\n                index += 2;\n                interfaces[i] = readClass(index, buf);\n            }\n        }\n        return interfaces;\n    }\n\n    /**\n     * Copies the constant pool data into the given {@link ClassWriter}. Should\n     * be called before the {@link #accept(ClassVisitor,int)} method.\n     *\n     * @param classWriter\n     *            the {@link ClassWriter} to copy constant pool into.\n     */\n    void copyPool(final ClassWriter classWriter) {\n        char[] buf = new char[maxStringLength];\n        int ll = items.length;\n        Item[] items2 = new Item[ll];\n        for (int i = 1; i < ll; i++) {\n            int index = items[i];\n            int tag = b[index - 1];\n            Item item = new Item(i);\n            int nameType;\n            switch (tag) {\n            case ClassWriter.FIELD:\n            case ClassWriter.METH:\n            case ClassWriter.IMETH:\n                nameType = items[readUnsignedShort(index + 2)];\n                item.set(tag, readClass(index, buf), readUTF8(nameType, buf),\n                        readUTF8(nameType + 2, buf));\n                break;\n            case ClassWriter.INT:\n                item.set(readInt(index));\n                break;\n            case ClassWriter.FLOAT:\n                item.set(Float.intBitsToFloat(readInt(index)));\n                break;\n            case ClassWriter.NAME_TYPE:\n                item.set(tag, readUTF8(index, buf), readUTF8(index + 2, buf),\n                        null);\n                break;\n            case ClassWriter.LONG:\n                item.set(readLong(index));\n                ++i;\n                break;\n            case ClassWriter.DOUBLE:\n                item.set(Double.longBitsToDouble(readLong(index)));\n                ++i;\n                break;\n            case ClassWriter.UTF8: {\n                String s = strings[i];\n                if (s == null) {\n                    index = items[i];\n                    s = strings[i] = readUTF(index + 2,\n                            readUnsignedShort(index), buf);\n                }\n                item.set(tag, s, null, null);\n                break;\n            }\n            case ClassWriter.HANDLE: {\n                int fieldOrMethodRef = items[readUnsignedShort(index + 1)];\n                nameType = items[readUnsignedShort(fieldOrMethodRef + 2)];\n                item.set(ClassWriter.HANDLE_BASE + readByte(index),\n                        readClass(fieldOrMethodRef, buf),\n                        readUTF8(nameType, buf), readUTF8(nameType + 2, buf));\n                break;\n            }\n            case ClassWriter.INDY:\n                if (classWriter.bootstrapMethods == null) {\n                    copyBootstrapMethods(classWriter, items2, buf);\n                }\n                nameType = items[readUnsignedShort(index + 2)];\n                item.set(readUTF8(nameType, buf), readUTF8(nameType + 2, buf),\n                        readUnsignedShort(index));\n                break;\n            // case ClassWriter.STR:\n            // case ClassWriter.CLASS:\n            // case ClassWriter.MTYPE\n            default:\n                item.set(tag, readUTF8(index, buf), null, null);\n                break;\n            }\n\n            int index2 = item.hashCode % items2.length;\n            item.next = items2[index2];\n            items2[index2] = item;\n        }\n\n        int off = items[1] - 1;\n        classWriter.pool.putByteArray(b, off, header - off);\n        classWriter.items = items2;\n        classWriter.threshold = (int) (0.75d * ll);\n        classWriter.index = ll;\n    }\n\n    /**\n     * Copies the bootstrap method data into the given {@link ClassWriter}.\n     * Should be called before the {@link #accept(ClassVisitor,int)} method.\n     *\n     * @param classWriter\n     *            the {@link ClassWriter} to copy bootstrap methods into.\n     */\n    private void copyBootstrapMethods(final ClassWriter classWriter,\n            final Item[] items, final char[] c) {\n        // finds the \"BootstrapMethods\" attribute\n        int u = getAttributes();\n        boolean found = false;\n        for (int i = readUnsignedShort(u); i > 0; --i) {\n            String attrName = readUTF8(u + 2, c);\n            if (\"BootstrapMethods\".equals(attrName)) {\n                found = true;\n                break;\n            }\n            u += 6 + readInt(u + 4);\n        }\n        if (!found) {\n            return;\n        }\n        // copies the bootstrap methods in the class writer\n        int boostrapMethodCount = readUnsignedShort(u + 8);\n        for (int j = 0, v = u + 10; j < boostrapMethodCount; j++) {\n            int position = v - u - 10;\n            int hashCode = readConst(readUnsignedShort(v), c).hashCode();\n            for (int k = readUnsignedShort(v + 2); k > 0; --k) {\n                hashCode ^= readConst(readUnsignedShort(v + 4), c).hashCode();\n                v += 2;\n            }\n            v += 4;\n            Item item = new Item(j);\n            item.set(position, hashCode & 0x7FFFFFFF);\n            int index = item.hashCode % items.length;\n            item.next = items[index];\n            items[index] = item;\n        }\n        int attrSize = readInt(u + 4);\n        ByteVector bootstrapMethods = new ByteVector(attrSize + 62);\n        bootstrapMethods.putByteArray(b, u + 10, attrSize - 2);\n        classWriter.bootstrapMethodsCount = boostrapMethodCount;\n        classWriter.bootstrapMethods = bootstrapMethods;\n    }\n\n    /**\n     * Constructs a new {@link ClassReader} object.\n     *\n     * @param is\n     *            an input stream from which to read the class.\n     * @throws IOException\n     *             if a problem occurs during reading.\n     */\n    public ClassReader(final InputStream is) throws IOException {\n        this(readClass(is, false));\n    }\n\n    /**\n     * Constructs a new {@link ClassReader} object.\n     *\n     * @param name\n     *            the binary qualified name of the class to be read.\n     * @throws IOException\n     *             if an exception occurs during reading.\n     */\n    public ClassReader(final String name) throws IOException {\n        this(readClass(\n                ClassLoader.getSystemResourceAsStream(name.replace('.', '/')\n                        + \".class\"), true));\n    }\n\n    /**\n     * Reads the bytecode of a class.\n     *\n     * @param is\n     *            an input stream from which to read the class.\n     * @param close\n     *            true to close the input stream after reading.\n     * @return the bytecode read from the given input stream.\n     * @throws IOException\n     *             if a problem occurs during reading.\n     */\n    private static byte[] readClass(final InputStream is, boolean close)\n            throws IOException {\n        if (is == null) {\n            throw new IOException(\"Class not found\");\n        }\n        try {\n            byte[] b = new byte[is.available()];\n            int len = 0;\n            while (true) {\n                int n = is.read(b, len, b.length - len);\n                if (n == -1) {\n                    if (len < b.length) {\n                        byte[] c = new byte[len];\n                        System.arraycopy(b, 0, c, 0, len);\n                        b = c;\n                    }\n                    return b;\n                }\n                len += n;\n                if (len == b.length) {\n                    int last = is.read();\n                    if (last < 0) {\n                        return b;\n                    }\n                    byte[] c = new byte[b.length + 1000];\n                    System.arraycopy(b, 0, c, 0, len);\n                    c[len++] = (byte) last;\n                    b = c;\n                }\n            }\n        } finally {\n            if (close) {\n                is.close();\n            }\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Public methods\n    // ------------------------------------------------------------------------\n\n    /**\n     * Makes the given visitor visit the Java class of this {@link ClassReader}\n     * . This class is the one specified in the constructor (see\n     * {@link #ClassReader(byte[]) ClassReader}).\n     *\n     * @param classVisitor\n     *            the visitor that must visit this class.\n     * @param flags\n     *            option flags that can be used to modify the default behavior\n     *            of this class. See {@link #SKIP_DEBUG}, {@link #EXPAND_FRAMES}\n     *            , {@link #SKIP_FRAMES}, {@link #SKIP_CODE}.\n     */\n    public void accept(final ClassVisitor classVisitor, final int flags) {\n        accept(classVisitor, new Attribute[0], flags);\n    }\n\n    /**\n     * Makes the given visitor visit the Java class of this {@link ClassReader}.\n     * This class is the one specified in the constructor (see\n     * {@link #ClassReader(byte[]) ClassReader}).\n     *\n     * @param classVisitor\n     *            the visitor that must visit this class.\n     * @param attrs\n     *            prototypes of the attributes that must be parsed during the\n     *            visit of the class. Any attribute whose type is not equal to\n     *            the type of one the prototypes will not be parsed: its byte\n     *            array value will be passed unchanged to the ClassWriter.\n     *            <i>This may corrupt it if this value contains references to\n     *            the constant pool, or has syntactic or semantic links with a\n     *            class element that has been transformed by a class adapter\n     *            between the reader and the writer</i>.\n     * @param flags\n     *            option flags that can be used to modify the default behavior\n     *            of this class. See {@link #SKIP_DEBUG}, {@link #EXPAND_FRAMES}\n     *            , {@link #SKIP_FRAMES}, {@link #SKIP_CODE}.\n     */\n    public void accept(final ClassVisitor classVisitor,\n            final Attribute[] attrs, final int flags) {\n        int u = header; // current offset in the class file\n        char[] c = new char[maxStringLength]; // buffer used to read strings\n\n        Context context = new Context();\n        context.attrs = attrs;\n        context.flags = flags;\n        context.buffer = c;\n\n        // reads the class declaration\n        int access = readUnsignedShort(u);\n        String name = readClass(u + 2, c);\n        String superClass = readClass(u + 4, c);\n        String[] interfaces = new String[readUnsignedShort(u + 6)];\n        u += 8;\n        for (int i = 0; i < interfaces.length; ++i) {\n            interfaces[i] = readClass(u, c);\n            u += 2;\n        }\n\n        // reads the class attributes\n        String signature = null;\n        String sourceFile = null;\n        String sourceDebug = null;\n        String enclosingOwner = null;\n        String enclosingName = null;\n        String enclosingDesc = null;\n        int anns = 0;\n        int ianns = 0;\n        int innerClasses = 0;\n        Attribute attributes = null;\n\n        u = getAttributes();\n        for (int i = readUnsignedShort(u); i > 0; --i) {\n            String attrName = readUTF8(u + 2, c);\n            // tests are sorted in decreasing frequency order\n            // (based on frequencies observed on typical classes)\n            if (\"SourceFile\".equals(attrName)) {\n                sourceFile = readUTF8(u + 8, c);\n            } else if (\"InnerClasses\".equals(attrName)) {\n                innerClasses = u + 8;\n            } else if (\"EnclosingMethod\".equals(attrName)) {\n                enclosingOwner = readClass(u + 8, c);\n                int item = readUnsignedShort(u + 10);\n                if (item != 0) {\n                    enclosingName = readUTF8(items[item], c);\n                    enclosingDesc = readUTF8(items[item] + 2, c);\n                }\n            } else if (SIGNATURES && \"Signature\".equals(attrName)) {\n                signature = readUTF8(u + 8, c);\n            } else if (ANNOTATIONS\n                    && \"RuntimeVisibleAnnotations\".equals(attrName)) {\n                anns = u + 8;\n            } else if (\"Deprecated\".equals(attrName)) {\n                access |= Opcodes.ACC_DEPRECATED;\n            } else if (\"Synthetic\".equals(attrName)) {\n                access |= Opcodes.ACC_SYNTHETIC\n                        | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE;\n            } else if (\"SourceDebugExtension\".equals(attrName)) {\n                int len = readInt(u + 4);\n                sourceDebug = readUTF(u + 8, len, new char[len]);\n            } else if (ANNOTATIONS\n                    && \"RuntimeInvisibleAnnotations\".equals(attrName)) {\n                ianns = u + 8;\n            } else if (\"BootstrapMethods\".equals(attrName)) {\n                int[] bootstrapMethods = new int[readUnsignedShort(u + 8)];\n                for (int j = 0, v = u + 10; j < bootstrapMethods.length; j++) {\n                    bootstrapMethods[j] = v;\n                    v += 2 + readUnsignedShort(v + 2) << 1;\n                }\n                context.bootstrapMethods = bootstrapMethods;\n            } else {\n                Attribute attr = readAttribute(attrs, attrName, u + 8,\n                        readInt(u + 4), c, -1, null);\n                if (attr != null) {\n                    attr.next = attributes;\n                    attributes = attr;\n                }\n            }\n            u += 6 + readInt(u + 4);\n        }\n\n        // visits the class declaration\n        classVisitor.visit(readInt(items[1] - 7), access, name, signature,\n                superClass, interfaces);\n\n        // visits the source and debug info\n        if ((flags & SKIP_DEBUG) == 0\n                && (sourceFile != null || sourceDebug != null)) {\n            classVisitor.visitSource(sourceFile, sourceDebug);\n        }\n\n        // visits the outer class\n        if (enclosingOwner != null) {\n            classVisitor.visitOuterClass(enclosingOwner, enclosingName,\n                    enclosingDesc);\n        }\n\n        // visits the class annotations\n        if (ANNOTATIONS && anns != 0) {\n            for (int i = readUnsignedShort(anns), v = anns + 2; i > 0; --i) {\n                v = readAnnotationValues(v + 2, c, true,\n                        classVisitor.visitAnnotation(readUTF8(v, c), true));\n            }\n        }\n        if (ANNOTATIONS && ianns != 0) {\n            for (int i = readUnsignedShort(ianns), v = ianns + 2; i > 0; --i) {\n                v = readAnnotationValues(v + 2, c, true,\n                        classVisitor.visitAnnotation(readUTF8(v, c), false));\n            }\n        }\n\n        // visits the attributes\n        while (attributes != null) {\n            Attribute attr = attributes.next;\n            attributes.next = null;\n            classVisitor.visitAttribute(attributes);\n            attributes = attr;\n        }\n\n        // visits the inner classes\n        if (innerClasses != 0) {\n            int v = innerClasses + 2;\n            for (int i = readUnsignedShort(innerClasses); i > 0; --i) {\n                classVisitor.visitInnerClass(readClass(v, c),\n                        readClass(v + 2, c), readUTF8(v + 4, c),\n                        readUnsignedShort(v + 6));\n                v += 8;\n            }\n        }\n\n        // visits the fields and methods\n        u = header + 10 + 2 * interfaces.length;\n        for (int i = readUnsignedShort(u - 2); i > 0; --i) {\n            u = readField(classVisitor, context, u);\n        }\n        u += 2;\n        for (int i = readUnsignedShort(u - 2); i > 0; --i) {\n            u = readMethod(classVisitor, context, u);\n        }\n\n        // visits the end of the class\n        classVisitor.visitEnd();\n    }\n\n    /**\n     * Reads a field and makes the given visitor visit it.\n     *\n     * @param classVisitor\n     *            the visitor that must visit the field.\n     * @param context\n     *            information about the class being parsed.\n     * @param u\n     *            the start offset of the field in the class file.\n     * @return the offset of the first byte following the field in the class.\n     */\n    private int readField(final ClassVisitor classVisitor,\n            final Context context, int u) {\n        // reads the field declaration\n        char[] c = context.buffer;\n        int access = readUnsignedShort(u);\n        String name = readUTF8(u + 2, c);\n        String desc = readUTF8(u + 4, c);\n        u += 6;\n\n        // reads the field attributes\n        String signature = null;\n        int anns = 0;\n        int ianns = 0;\n        Object value = null;\n        Attribute attributes = null;\n\n        for (int i = readUnsignedShort(u); i > 0; --i) {\n            String attrName = readUTF8(u + 2, c);\n            // tests are sorted in decreasing frequency order\n            // (based on frequencies observed on typical classes)\n            if (\"ConstantValue\".equals(attrName)) {\n                int item = readUnsignedShort(u + 8);\n                value = item == 0 ? null : readConst(item, c);\n            } else if (SIGNATURES && \"Signature\".equals(attrName)) {\n                signature = readUTF8(u + 8, c);\n            } else if (\"Deprecated\".equals(attrName)) {\n                access |= Opcodes.ACC_DEPRECATED;\n            } else if (\"Synthetic\".equals(attrName)) {\n                access |= Opcodes.ACC_SYNTHETIC\n                        | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE;\n            } else if (ANNOTATIONS\n                    && \"RuntimeVisibleAnnotations\".equals(attrName)) {\n                anns = u + 8;\n            } else if (ANNOTATIONS\n                    && \"RuntimeInvisibleAnnotations\".equals(attrName)) {\n                ianns = u + 8;\n            } else {\n                Attribute attr = readAttribute(context.attrs, attrName, u + 8,\n                        readInt(u + 4), c, -1, null);\n                if (attr != null) {\n                    attr.next = attributes;\n                    attributes = attr;\n                }\n            }\n            u += 6 + readInt(u + 4);\n        }\n        u += 2;\n\n        // visits the field declaration\n        FieldVisitor fv = classVisitor.visitField(access, name, desc,\n                signature, value);\n        if (fv == null) {\n            return u;\n        }\n\n        // visits the field annotations\n        if (ANNOTATIONS && anns != 0) {\n            for (int i = readUnsignedShort(anns), v = anns + 2; i > 0; --i) {\n                v = readAnnotationValues(v + 2, c, true,\n                        fv.visitAnnotation(readUTF8(v, c), true));\n            }\n        }\n        if (ANNOTATIONS && ianns != 0) {\n            for (int i = readUnsignedShort(ianns), v = ianns + 2; i > 0; --i) {\n                v = readAnnotationValues(v + 2, c, true,\n                        fv.visitAnnotation(readUTF8(v, c), false));\n            }\n        }\n\n        // visits the field attributes\n        while (attributes != null) {\n            Attribute attr = attributes.next;\n            attributes.next = null;\n            fv.visitAttribute(attributes);\n            attributes = attr;\n        }\n\n        // visits the end of the field\n        fv.visitEnd();\n\n        return u;\n    }\n\n    /**\n     * Reads a method and makes the given visitor visit it.\n     *\n     * @param classVisitor\n     *            the visitor that must visit the method.\n     * @param context\n     *            information about the class being parsed.\n     * @param u\n     *            the start offset of the method in the class file.\n     * @return the offset of the first byte following the method in the class.\n     */\n    private int readMethod(final ClassVisitor classVisitor,\n            final Context context, int u) {\n        // reads the method declaration\n        char[] c = context.buffer;\n        int access = readUnsignedShort(u);\n        String name = readUTF8(u + 2, c);\n        String desc = readUTF8(u + 4, c);\n        u += 6;\n\n        // reads the method attributes\n        int code = 0;\n        int exception = 0;\n        String[] exceptions = null;\n        String signature = null;\n        int anns = 0;\n        int ianns = 0;\n        int dann = 0;\n        int mpanns = 0;\n        int impanns = 0;\n        int firstAttribute = u;\n        Attribute attributes = null;\n\n        for (int i = readUnsignedShort(u); i > 0; --i) {\n            String attrName = readUTF8(u + 2, c);\n            // tests are sorted in decreasing frequency order\n            // (based on frequencies observed on typical classes)\n            if (\"Code\".equals(attrName)) {\n                if ((context.flags & SKIP_CODE) == 0) {\n                    code = u + 8;\n                }\n            } else if (\"Exceptions\".equals(attrName)) {\n                exceptions = new String[readUnsignedShort(u + 8)];\n                exception = u + 10;\n                for (int j = 0; j < exceptions.length; ++j) {\n                    exceptions[j] = readClass(exception, c);\n                    exception += 2;\n                }\n            } else if (SIGNATURES && \"Signature\".equals(attrName)) {\n                signature = readUTF8(u + 8, c);\n            } else if (\"Deprecated\".equals(attrName)) {\n                access |= Opcodes.ACC_DEPRECATED;\n            } else if (ANNOTATIONS\n                    && \"RuntimeVisibleAnnotations\".equals(attrName)) {\n                anns = u + 8;\n            } else if (ANNOTATIONS && \"AnnotationDefault\".equals(attrName)) {\n                dann = u + 8;\n            } else if (\"Synthetic\".equals(attrName)) {\n                access |= Opcodes.ACC_SYNTHETIC\n                        | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE;\n            } else if (ANNOTATIONS\n                    && \"RuntimeInvisibleAnnotations\".equals(attrName)) {\n                ianns = u + 8;\n            } else if (ANNOTATIONS\n                    && \"RuntimeVisibleParameterAnnotations\".equals(attrName)) {\n                mpanns = u + 8;\n            } else if (ANNOTATIONS\n                    && \"RuntimeInvisibleParameterAnnotations\".equals(attrName)) {\n                impanns = u + 8;\n            } else {\n                Attribute attr = readAttribute(context.attrs, attrName, u + 8,\n                        readInt(u + 4), c, -1, null);\n                if (attr != null) {\n                    attr.next = attributes;\n                    attributes = attr;\n                }\n            }\n            u += 6 + readInt(u + 4);\n        }\n        u += 2;\n\n        // visits the method declaration\n        MethodVisitor mv = classVisitor.visitMethod(access, name, desc,\n                signature, exceptions);\n        if (mv == null) {\n            return u;\n        }\n\n        /*\n         * if the returned MethodVisitor is in fact a MethodWriter, it means\n         * there is no method adapter between the reader and the writer. If, in\n         * addition, the writer's constant pool was copied from this reader\n         * (mw.cw.cr == this), and the signature and exceptions of the method\n         * have not been changed, then it is possible to skip all visit events\n         * and just copy the original code of the method to the writer (the\n         * access, name and descriptor can have been changed, this is not\n         * important since they are not copied as is from the reader).\n         */\n        if (WRITER && mv instanceof MethodWriter) {\n            MethodWriter mw = (MethodWriter) mv;\n            if (mw.cw.cr == this && signature == mw.signature) {\n                boolean sameExceptions = false;\n                if (exceptions == null) {\n                    sameExceptions = mw.exceptionCount == 0;\n                } else if (exceptions.length == mw.exceptionCount) {\n                    sameExceptions = true;\n                    for (int j = exceptions.length - 1; j >= 0; --j) {\n                        exception -= 2;\n                        if (mw.exceptions[j] != readUnsignedShort(exception)) {\n                            sameExceptions = false;\n                            break;\n                        }\n                    }\n                }\n                if (sameExceptions) {\n                    /*\n                     * we do not copy directly the code into MethodWriter to\n                     * save a byte array copy operation. The real copy will be\n                     * done in ClassWriter.toByteArray().\n                     */\n                    mw.classReaderOffset = firstAttribute;\n                    mw.classReaderLength = u - firstAttribute;\n                    return u;\n                }\n            }\n        }\n\n        // visits the method annotations\n        if (ANNOTATIONS && dann != 0) {\n            AnnotationVisitor dv = mv.visitAnnotationDefault();\n            readAnnotationValue(dann, c, null, dv);\n            if (dv != null) {\n                dv.visitEnd();\n            }\n        }\n        if (ANNOTATIONS && anns != 0) {\n            for (int i = readUnsignedShort(anns), v = anns + 2; i > 0; --i) {\n                v = readAnnotationValues(v + 2, c, true,\n                        mv.visitAnnotation(readUTF8(v, c), true));\n            }\n        }\n        if (ANNOTATIONS && ianns != 0) {\n            for (int i = readUnsignedShort(ianns), v = ianns + 2; i > 0; --i) {\n                v = readAnnotationValues(v + 2, c, true,\n                        mv.visitAnnotation(readUTF8(v, c), false));\n            }\n        }\n        if (ANNOTATIONS && mpanns != 0) {\n            readParameterAnnotations(mpanns, desc, c, true, mv);\n        }\n        if (ANNOTATIONS && impanns != 0) {\n            readParameterAnnotations(impanns, desc, c, false, mv);\n        }\n\n        // visits the method attributes\n        while (attributes != null) {\n            Attribute attr = attributes.next;\n            attributes.next = null;\n            mv.visitAttribute(attributes);\n            attributes = attr;\n        }\n\n        // visits the method code\n        if (code != 0) {\n            context.access = access;\n            context.name = name;\n            context.desc = desc;\n            mv.visitCode();\n            readCode(mv, context, code);\n        }\n\n        // visits the end of the method\n        mv.visitEnd();\n\n        return u;\n    }\n\n    /**\n     * Reads the bytecode of a method and makes the given visitor visit it.\n     *\n     * @param mv\n     *            the visitor that must visit the method's code.\n     * @param context\n     *            information about the class being parsed.\n     * @param u\n     *            the start offset of the code attribute in the class file.\n     */\n    private void readCode(final MethodVisitor mv, final Context context, int u) {\n        // reads the header\n        byte[] b = this.b;\n        char[] c = context.buffer;\n        int maxStack = readUnsignedShort(u);\n        int maxLocals = readUnsignedShort(u + 2);\n        int codeLength = readInt(u + 4);\n        u += 8;\n\n        // reads the bytecode to find the labels\n        int codeStart = u;\n        int codeEnd = u + codeLength;\n        Label[] labels = new Label[codeLength + 2];\n        readLabel(codeLength + 1, labels);\n        while (u < codeEnd) {\n            int offset = u - codeStart;\n            int opcode = b[u] & 0xFF;\n            switch (ClassWriter.TYPE[opcode]) {\n            case ClassWriter.NOARG_INSN:\n            case ClassWriter.IMPLVAR_INSN:\n                u += 1;\n                break;\n            case ClassWriter.LABEL_INSN:\n                readLabel(offset + readShort(u + 1), labels);\n                u += 3;\n                break;\n            case ClassWriter.LABELW_INSN:\n                readLabel(offset + readInt(u + 1), labels);\n                u += 5;\n                break;\n            case ClassWriter.WIDE_INSN:\n                opcode = b[u + 1] & 0xFF;\n                if (opcode == Opcodes.IINC) {\n                    u += 6;\n                } else {\n                    u += 4;\n                }\n                break;\n            case ClassWriter.TABL_INSN:\n                // skips 0 to 3 padding bytes\n                u = u + 4 - (offset & 3);\n                // reads instruction\n                readLabel(offset + readInt(u), labels);\n                for (int i = readInt(u + 8) - readInt(u + 4) + 1; i > 0; --i) {\n                    readLabel(offset + readInt(u + 12), labels);\n                    u += 4;\n                }\n                u += 12;\n                break;\n            case ClassWriter.LOOK_INSN:\n                // skips 0 to 3 padding bytes\n                u = u + 4 - (offset & 3);\n                // reads instruction\n                readLabel(offset + readInt(u), labels);\n                for (int i = readInt(u + 4); i > 0; --i) {\n                    readLabel(offset + readInt(u + 12), labels);\n                    u += 8;\n                }\n                u += 8;\n                break;\n            case ClassWriter.VAR_INSN:\n            case ClassWriter.SBYTE_INSN:\n            case ClassWriter.LDC_INSN:\n                u += 2;\n                break;\n            case ClassWriter.SHORT_INSN:\n            case ClassWriter.LDCW_INSN:\n            case ClassWriter.FIELDORMETH_INSN:\n            case ClassWriter.TYPE_INSN:\n            case ClassWriter.IINC_INSN:\n                u += 3;\n                break;\n            case ClassWriter.ITFMETH_INSN:\n            case ClassWriter.INDYMETH_INSN:\n                u += 5;\n                break;\n            // case MANA_INSN:\n            default:\n                u += 4;\n                break;\n            }\n        }\n\n        // reads the try catch entries to find the labels, and also visits them\n        for (int i = readUnsignedShort(u); i > 0; --i) {\n            Label start = readLabel(readUnsignedShort(u + 2), labels);\n            Label end = readLabel(readUnsignedShort(u + 4), labels);\n            Label handler = readLabel(readUnsignedShort(u + 6), labels);\n            String type = readUTF8(items[readUnsignedShort(u + 8)], c);\n            mv.visitTryCatchBlock(start, end, handler, type);\n            u += 8;\n        }\n        u += 2;\n\n        // reads the code attributes\n        int varTable = 0;\n        int varTypeTable = 0;\n        boolean zip = true;\n        boolean unzip = (context.flags & EXPAND_FRAMES) != 0;\n        int stackMap = 0;\n        int stackMapSize = 0;\n        int frameCount = 0;\n        Context frame = null;\n        Attribute attributes = null;\n\n        for (int i = readUnsignedShort(u); i > 0; --i) {\n            String attrName = readUTF8(u + 2, c);\n            if (\"LocalVariableTable\".equals(attrName)) {\n                if ((context.flags & SKIP_DEBUG) == 0) {\n                    varTable = u + 8;\n                    for (int j = readUnsignedShort(u + 8), v = u; j > 0; --j) {\n                        int label = readUnsignedShort(v + 10);\n                        if (labels[label] == null) {\n                            readLabel(label, labels).status |= Label.DEBUG;\n                        }\n                        label += readUnsignedShort(v + 12);\n                        if (labels[label] == null) {\n                            readLabel(label, labels).status |= Label.DEBUG;\n                        }\n                        v += 10;\n                    }\n                }\n            } else if (\"LocalVariableTypeTable\".equals(attrName)) {\n                varTypeTable = u + 8;\n            } else if (\"LineNumberTable\".equals(attrName)) {\n                if ((context.flags & SKIP_DEBUG) == 0) {\n                    for (int j = readUnsignedShort(u + 8), v = u; j > 0; --j) {\n                        int label = readUnsignedShort(v + 10);\n                        if (labels[label] == null) {\n                            readLabel(label, labels).status |= Label.DEBUG;\n                        }\n                        labels[label].line = readUnsignedShort(v + 12);\n                        v += 4;\n                    }\n                }\n            } else if (FRAMES && \"StackMapTable\".equals(attrName)) {\n                if ((context.flags & SKIP_FRAMES) == 0) {\n                    stackMap = u + 10;\n                    stackMapSize = readInt(u + 4);\n                    frameCount = readUnsignedShort(u + 8);\n                }\n                /*\n                 * here we do not extract the labels corresponding to the\n                 * attribute content. This would require a full parsing of the\n                 * attribute, which would need to be repeated in the second\n                 * phase (see below). Instead the content of the attribute is\n                 * read one frame at a time (i.e. after a frame has been\n                 * visited, the next frame is read), and the labels it contains\n                 * are also extracted one frame at a time. Thanks to the\n                 * ordering of frames, having only a \"one frame lookahead\" is\n                 * not a problem, i.e. it is not possible to see an offset\n                 * smaller than the offset of the current insn and for which no\n                 * Label exist.\n                 */\n                /*\n                 * This is not true for UNINITIALIZED type offsets. We solve\n                 * this by parsing the stack map table without a full decoding\n                 * (see below).\n                 */\n            } else if (FRAMES && \"StackMap\".equals(attrName)) {\n                if ((context.flags & SKIP_FRAMES) == 0) {\n                    zip = false;\n                    stackMap = u + 10;\n                    stackMapSize = readInt(u + 4);\n                    frameCount = readUnsignedShort(u + 8);\n                }\n                /*\n                 * IMPORTANT! here we assume that the frames are ordered, as in\n                 * the StackMapTable attribute, although this is not guaranteed\n                 * by the attribute format.\n                 */\n            } else {\n                for (int j = 0; j < context.attrs.length; ++j) {\n                    if (context.attrs[j].type.equals(attrName)) {\n                        Attribute attr = context.attrs[j].read(this, u + 8,\n                                readInt(u + 4), c, codeStart - 8, labels);\n                        if (attr != null) {\n                            attr.next = attributes;\n                            attributes = attr;\n                        }\n                    }\n                }\n            }\n            u += 6 + readInt(u + 4);\n        }\n        u += 2;\n\n        // generates the first (implicit) stack map frame\n        if (FRAMES && stackMap != 0) {\n            /*\n             * for the first explicit frame the offset is not offset_delta + 1\n             * but only offset_delta; setting the implicit frame offset to -1\n             * allow the use of the \"offset_delta + 1\" rule in all cases\n             */\n            frame = context;\n            frame.offset = -1;\n            frame.mode = 0;\n            frame.localCount = 0;\n            frame.localDiff = 0;\n            frame.stackCount = 0;\n            frame.local = new Object[maxLocals];\n            frame.stack = new Object[maxStack];\n            if (unzip) {\n                getImplicitFrame(context);\n            }\n            /*\n             * Finds labels for UNINITIALIZED frame types. Instead of decoding\n             * each element of the stack map table, we look for 3 consecutive\n             * bytes that \"look like\" an UNINITIALIZED type (tag 8, offset\n             * within code bounds, NEW instruction at this offset). We may find\n             * false positives (i.e. not real UNINITIALIZED types), but this\n             * should be rare, and the only consequence will be the creation of\n             * an unneeded label. This is better than creating a label for each\n             * NEW instruction, and faster than fully decoding the whole stack\n             * map table.\n             */\n            for (int i = stackMap; i < stackMap + stackMapSize - 2; ++i) {\n                if (b[i] == 8) { // UNINITIALIZED FRAME TYPE\n                    int v = readUnsignedShort(i + 1);\n                    if (v >= 0 && v < codeLength) {\n                        if ((b[codeStart + v] & 0xFF) == Opcodes.NEW) {\n                            readLabel(v, labels);\n                        }\n                    }\n                }\n            }\n        }\n\n        // visits the instructions\n        u = codeStart;\n        while (u < codeEnd) {\n            int offset = u - codeStart;\n\n            // visits the label and line number for this offset, if any\n            Label l = labels[offset];\n            if (l != null) {\n                mv.visitLabel(l);\n                if ((context.flags & SKIP_DEBUG) == 0 && l.line > 0) {\n                    mv.visitLineNumber(l.line, l);\n                }\n            }\n\n            // visits the frame for this offset, if any\n            while (FRAMES && frame != null\n                    && (frame.offset == offset || frame.offset == -1)) {\n                // if there is a frame for this offset, makes the visitor visit\n                // it, and reads the next frame if there is one.\n                if (frame.offset != -1) {\n                    if (!zip || unzip) {\n                        mv.visitFrame(Opcodes.F_NEW, frame.localCount,\n                                frame.local, frame.stackCount, frame.stack);\n                    } else {\n                        mv.visitFrame(frame.mode, frame.localDiff, frame.local,\n                                frame.stackCount, frame.stack);\n                    }\n                }\n                if (frameCount > 0) {\n                    stackMap = readFrame(stackMap, zip, unzip, labels, frame);\n                    --frameCount;\n                } else {\n                    frame = null;\n                }\n            }\n\n            // visits the instruction at this offset\n            int opcode = b[u] & 0xFF;\n            switch (ClassWriter.TYPE[opcode]) {\n            case ClassWriter.NOARG_INSN:\n                mv.visitInsn(opcode);\n                u += 1;\n                break;\n            case ClassWriter.IMPLVAR_INSN:\n                if (opcode > Opcodes.ISTORE) {\n                    opcode -= 59; // ISTORE_0\n                    mv.visitVarInsn(Opcodes.ISTORE + (opcode >> 2),\n                            opcode & 0x3);\n                } else {\n                    opcode -= 26; // ILOAD_0\n                    mv.visitVarInsn(Opcodes.ILOAD + (opcode >> 2), opcode & 0x3);\n                }\n                u += 1;\n                break;\n            case ClassWriter.LABEL_INSN:\n                mv.visitJumpInsn(opcode, labels[offset + readShort(u + 1)]);\n                u += 3;\n                break;\n            case ClassWriter.LABELW_INSN:\n                mv.visitJumpInsn(opcode - 33, labels[offset + readInt(u + 1)]);\n                u += 5;\n                break;\n            case ClassWriter.WIDE_INSN:\n                opcode = b[u + 1] & 0xFF;\n                if (opcode == Opcodes.IINC) {\n                    mv.visitIincInsn(readUnsignedShort(u + 2), readShort(u + 4));\n                    u += 6;\n                } else {\n                    mv.visitVarInsn(opcode, readUnsignedShort(u + 2));\n                    u += 4;\n                }\n                break;\n            case ClassWriter.TABL_INSN: {\n                // skips 0 to 3 padding bytes\n                u = u + 4 - (offset & 3);\n                // reads instruction\n                int label = offset + readInt(u);\n                int min = readInt(u + 4);\n                int max = readInt(u + 8);\n                Label[] table = new Label[max - min + 1];\n                u += 12;\n                for (int i = 0; i < table.length; ++i) {\n                    table[i] = labels[offset + readInt(u)];\n                    u += 4;\n                }\n                mv.visitTableSwitchInsn(min, max, labels[label], table);\n                break;\n            }\n            case ClassWriter.LOOK_INSN: {\n                // skips 0 to 3 padding bytes\n                u = u + 4 - (offset & 3);\n                // reads instruction\n                int label = offset + readInt(u);\n                int len = readInt(u + 4);\n                int[] keys = new int[len];\n                Label[] values = new Label[len];\n                u += 8;\n                for (int i = 0; i < len; ++i) {\n                    keys[i] = readInt(u);\n                    values[i] = labels[offset + readInt(u + 4)];\n                    u += 8;\n                }\n                mv.visitLookupSwitchInsn(labels[label], keys, values);\n                break;\n            }\n            case ClassWriter.VAR_INSN:\n                mv.visitVarInsn(opcode, b[u + 1] & 0xFF);\n                u += 2;\n                break;\n            case ClassWriter.SBYTE_INSN:\n                mv.visitIntInsn(opcode, b[u + 1]);\n                u += 2;\n                break;\n            case ClassWriter.SHORT_INSN:\n                mv.visitIntInsn(opcode, readShort(u + 1));\n                u += 3;\n                break;\n            case ClassWriter.LDC_INSN:\n                mv.visitLdcInsn(readConst(b[u + 1] & 0xFF, c));\n                u += 2;\n                break;\n            case ClassWriter.LDCW_INSN:\n                mv.visitLdcInsn(readConst(readUnsignedShort(u + 1), c));\n                u += 3;\n                break;\n            case ClassWriter.FIELDORMETH_INSN:\n            case ClassWriter.ITFMETH_INSN: {\n                int cpIndex = items[readUnsignedShort(u + 1)];\n                String iowner = readClass(cpIndex, c);\n                cpIndex = items[readUnsignedShort(cpIndex + 2)];\n                String iname = readUTF8(cpIndex, c);\n                String idesc = readUTF8(cpIndex + 2, c);\n                if (opcode < Opcodes.INVOKEVIRTUAL) {\n                    mv.visitFieldInsn(opcode, iowner, iname, idesc);\n                } else {\n                    mv.visitMethodInsn(opcode, iowner, iname, idesc);\n                }\n                if (opcode == Opcodes.INVOKEINTERFACE) {\n                    u += 5;\n                } else {\n                    u += 3;\n                }\n                break;\n            }\n            case ClassWriter.INDYMETH_INSN: {\n                int cpIndex = items[readUnsignedShort(u + 1)];\n                int bsmIndex = context.bootstrapMethods[readUnsignedShort(cpIndex)];\n                Handle bsm = (Handle) readConst(readUnsignedShort(bsmIndex), c);\n                int bsmArgCount = readUnsignedShort(bsmIndex + 2);\n                Object[] bsmArgs = new Object[bsmArgCount];\n                bsmIndex += 4;\n                for (int i = 0; i < bsmArgCount; i++) {\n                    bsmArgs[i] = readConst(readUnsignedShort(bsmIndex), c);\n                    bsmIndex += 2;\n                }\n                cpIndex = items[readUnsignedShort(cpIndex + 2)];\n                String iname = readUTF8(cpIndex, c);\n                String idesc = readUTF8(cpIndex + 2, c);\n                mv.visitInvokeDynamicInsn(iname, idesc, bsm, bsmArgs);\n                u += 5;\n                break;\n            }\n            case ClassWriter.TYPE_INSN:\n                mv.visitTypeInsn(opcode, readClass(u + 1, c));\n                u += 3;\n                break;\n            case ClassWriter.IINC_INSN:\n                mv.visitIincInsn(b[u + 1] & 0xFF, b[u + 2]);\n                u += 3;\n                break;\n            // case MANA_INSN:\n            default:\n                mv.visitMultiANewArrayInsn(readClass(u + 1, c), b[u + 3] & 0xFF);\n                u += 4;\n                break;\n            }\n        }\n        if (labels[codeLength] != null) {\n            mv.visitLabel(labels[codeLength]);\n        }\n\n        // visits the local variable tables\n        if ((context.flags & SKIP_DEBUG) == 0 && varTable != 0) {\n            int[] typeTable = null;\n            if (varTypeTable != 0) {\n                u = varTypeTable + 2;\n                typeTable = new int[readUnsignedShort(varTypeTable) * 3];\n                for (int i = typeTable.length; i > 0;) {\n                    typeTable[--i] = u + 6; // signature\n                    typeTable[--i] = readUnsignedShort(u + 8); // index\n                    typeTable[--i] = readUnsignedShort(u); // start\n                    u += 10;\n                }\n            }\n            u = varTable + 2;\n            for (int i = readUnsignedShort(varTable); i > 0; --i) {\n                int start = readUnsignedShort(u);\n                int length = readUnsignedShort(u + 2);\n                int index = readUnsignedShort(u + 8);\n                String vsignature = null;\n                if (typeTable != null) {\n                    for (int j = 0; j < typeTable.length; j += 3) {\n                        if (typeTable[j] == start && typeTable[j + 1] == index) {\n                            vsignature = readUTF8(typeTable[j + 2], c);\n                            break;\n                        }\n                    }\n                }\n                mv.visitLocalVariable(readUTF8(u + 4, c), readUTF8(u + 6, c),\n                        vsignature, labels[start], labels[start + length],\n                        index);\n                u += 10;\n            }\n        }\n\n        // visits the code attributes\n        while (attributes != null) {\n            Attribute attr = attributes.next;\n            attributes.next = null;\n            mv.visitAttribute(attributes);\n            attributes = attr;\n        }\n\n        // visits the max stack and max locals values\n        mv.visitMaxs(maxStack, maxLocals);\n    }\n\n    /**\n     * Reads parameter annotations and makes the given visitor visit them.\n     *\n     * @param v\n     *            start offset in {@link #b b} of the annotations to be read.\n     * @param desc\n     *            the method descriptor.\n     * @param buf\n     *            buffer to be used to call {@link #readUTF8 readUTF8},\n     *            {@link #readClass(int,char[]) readClass} or {@link #readConst\n     *            readConst}.\n     * @param visible\n     *            <tt>true</tt> if the annotations to be read are visible at\n     *            runtime.\n     * @param mv\n     *            the visitor that must visit the annotations.\n     */\n    private void readParameterAnnotations(int v, final String desc,\n            final char[] buf, final boolean visible, final MethodVisitor mv) {\n        int i;\n        int n = b[v++] & 0xFF;\n        // workaround for a bug in javac (javac compiler generates a parameter\n        // annotation array whose size is equal to the number of parameters in\n        // the Java source file, while it should generate an array whose size is\n        // equal to the number of parameters in the method descriptor - which\n        // includes the synthetic parameters added by the compiler). This work-\n        // around supposes that the synthetic parameters are the first ones.\n        int synthetics = Type.getArgumentTypes(desc).length - n;\n        AnnotationVisitor av;\n        for (i = 0; i < synthetics; ++i) {\n            // virtual annotation to detect synthetic parameters in MethodWriter\n            av = mv.visitParameterAnnotation(i, \"Ljava/lang/Synthetic;\", false);\n            if (av != null) {\n                av.visitEnd();\n            }\n        }\n        for (; i < n + synthetics; ++i) {\n            int j = readUnsignedShort(v);\n            v += 2;\n            for (; j > 0; --j) {\n                av = mv.visitParameterAnnotation(i, readUTF8(v, buf), visible);\n                v = readAnnotationValues(v + 2, buf, true, av);\n            }\n        }\n    }\n\n    /**\n     * Reads the values of an annotation and makes the given visitor visit them.\n     *\n     * @param v\n     *            the start offset in {@link #b b} of the values to be read\n     *            (including the unsigned short that gives the number of\n     *            values).\n     * @param buf\n     *            buffer to be used to call {@link #readUTF8 readUTF8},\n     *            {@link #readClass(int,char[]) readClass} or {@link #readConst\n     *            readConst}.\n     * @param named\n     *            if the annotation values are named or not.\n     * @param av\n     *            the visitor that must visit the values.\n     * @return the end offset of the annotation values.\n     */\n    private int readAnnotationValues(int v, final char[] buf,\n            final boolean named, final AnnotationVisitor av) {\n        int i = readUnsignedShort(v);\n        v += 2;\n        if (named) {\n            for (; i > 0; --i) {\n                v = readAnnotationValue(v + 2, buf, readUTF8(v, buf), av);\n            }\n        } else {\n            for (; i > 0; --i) {\n                v = readAnnotationValue(v, buf, null, av);\n            }\n        }\n        if (av != null) {\n            av.visitEnd();\n        }\n        return v;\n    }\n\n    /**\n     * Reads a value of an annotation and makes the given visitor visit it.\n     *\n     * @param v\n     *            the start offset in {@link #b b} of the value to be read\n     *            (<i>not including the value name constant pool index</i>).\n     * @param buf\n     *            buffer to be used to call {@link #readUTF8 readUTF8},\n     *            {@link #readClass(int,char[]) readClass} or {@link #readConst\n     *            readConst}.\n     * @param name\n     *            the name of the value to be read.\n     * @param av\n     *            the visitor that must visit the value.\n     * @return the end offset of the annotation value.\n     */\n    private int readAnnotationValue(int v, final char[] buf, final String name,\n            final AnnotationVisitor av) {\n        int i;\n        if (av == null) {\n            switch (b[v] & 0xFF) {\n            case 'e': // enum_const_value\n                return v + 5;\n            case '@': // annotation_value\n                return readAnnotationValues(v + 3, buf, true, null);\n            case '[': // array_value\n                return readAnnotationValues(v + 1, buf, false, null);\n            default:\n                return v + 3;\n            }\n        }\n        switch (b[v++] & 0xFF) {\n        case 'I': // pointer to CONSTANT_Integer\n        case 'J': // pointer to CONSTANT_Long\n        case 'F': // pointer to CONSTANT_Float\n        case 'D': // pointer to CONSTANT_Double\n            av.visit(name, readConst(readUnsignedShort(v), buf));\n            v += 2;\n            break;\n        case 'B': // pointer to CONSTANT_Byte\n            av.visit(name,\n                    new Byte((byte) readInt(items[readUnsignedShort(v)])));\n            v += 2;\n            break;\n        case 'Z': // pointer to CONSTANT_Boolean\n            av.visit(name,\n                    readInt(items[readUnsignedShort(v)]) == 0 ? Boolean.FALSE\n                            : Boolean.TRUE);\n            v += 2;\n            break;\n        case 'S': // pointer to CONSTANT_Short\n            av.visit(name, new Short(\n                    (short) readInt(items[readUnsignedShort(v)])));\n            v += 2;\n            break;\n        case 'C': // pointer to CONSTANT_Char\n            av.visit(name, new Character(\n                    (char) readInt(items[readUnsignedShort(v)])));\n            v += 2;\n            break;\n        case 's': // pointer to CONSTANT_Utf8\n            av.visit(name, readUTF8(v, buf));\n            v += 2;\n            break;\n        case 'e': // enum_const_value\n            av.visitEnum(name, readUTF8(v, buf), readUTF8(v + 2, buf));\n            v += 4;\n            break;\n        case 'c': // class_info\n            av.visit(name, Type.getType(readUTF8(v, buf)));\n            v += 2;\n            break;\n        case '@': // annotation_value\n            v = readAnnotationValues(v + 2, buf, true,\n                    av.visitAnnotation(name, readUTF8(v, buf)));\n            break;\n        case '[': // array_value\n            int size = readUnsignedShort(v);\n            v += 2;\n            if (size == 0) {\n                return readAnnotationValues(v - 2, buf, false,\n                        av.visitArray(name));\n            }\n            switch (this.b[v++] & 0xFF) {\n            case 'B':\n                byte[] bv = new byte[size];\n                for (i = 0; i < size; i++) {\n                    bv[i] = (byte) readInt(items[readUnsignedShort(v)]);\n                    v += 3;\n                }\n                av.visit(name, bv);\n                --v;\n                break;\n            case 'Z':\n                boolean[] zv = new boolean[size];\n                for (i = 0; i < size; i++) {\n                    zv[i] = readInt(items[readUnsignedShort(v)]) != 0;\n                    v += 3;\n                }\n                av.visit(name, zv);\n                --v;\n                break;\n            case 'S':\n                short[] sv = new short[size];\n                for (i = 0; i < size; i++) {\n                    sv[i] = (short) readInt(items[readUnsignedShort(v)]);\n                    v += 3;\n                }\n                av.visit(name, sv);\n                --v;\n                break;\n            case 'C':\n                char[] cv = new char[size];\n                for (i = 0; i < size; i++) {\n                    cv[i] = (char) readInt(items[readUnsignedShort(v)]);\n                    v += 3;\n                }\n                av.visit(name, cv);\n                --v;\n                break;\n            case 'I':\n                int[] iv = new int[size];\n                for (i = 0; i < size; i++) {\n                    iv[i] = readInt(items[readUnsignedShort(v)]);\n                    v += 3;\n                }\n                av.visit(name, iv);\n                --v;\n                break;\n            case 'J':\n                long[] lv = new long[size];\n                for (i = 0; i < size; i++) {\n                    lv[i] = readLong(items[readUnsignedShort(v)]);\n                    v += 3;\n                }\n                av.visit(name, lv);\n                --v;\n                break;\n            case 'F':\n                float[] fv = new float[size];\n                for (i = 0; i < size; i++) {\n                    fv[i] = Float\n                            .intBitsToFloat(readInt(items[readUnsignedShort(v)]));\n                    v += 3;\n                }\n                av.visit(name, fv);\n                --v;\n                break;\n            case 'D':\n                double[] dv = new double[size];\n                for (i = 0; i < size; i++) {\n                    dv[i] = Double\n                            .longBitsToDouble(readLong(items[readUnsignedShort(v)]));\n                    v += 3;\n                }\n                av.visit(name, dv);\n                --v;\n                break;\n            default:\n                v = readAnnotationValues(v - 3, buf, false, av.visitArray(name));\n            }\n        }\n        return v;\n    }\n\n    /**\n     * Computes the implicit frame of the method currently being parsed (as\n     * defined in the given {@link Context}) and stores it in the given context.\n     *\n     * @param frame\n     *            information about the class being parsed.\n     */\n    private void getImplicitFrame(final Context frame) {\n        String desc = frame.desc;\n        Object[] locals = frame.local;\n        int local = 0;\n        if ((frame.access & Opcodes.ACC_STATIC) == 0) {\n            if (\"<init>\".equals(frame.name)) {\n                locals[local++] = Opcodes.UNINITIALIZED_THIS;\n            } else {\n                locals[local++] = readClass(header + 2, frame.buffer);\n            }\n        }\n        int i = 1;\n        loop: while (true) {\n            int j = i;\n            switch (desc.charAt(i++)) {\n            case 'Z':\n            case 'C':\n            case 'B':\n            case 'S':\n            case 'I':\n                locals[local++] = Opcodes.INTEGER;\n                break;\n            case 'F':\n                locals[local++] = Opcodes.FLOAT;\n                break;\n            case 'J':\n                locals[local++] = Opcodes.LONG;\n                break;\n            case 'D':\n                locals[local++] = Opcodes.DOUBLE;\n                break;\n            case '[':\n                while (desc.charAt(i) == '[') {\n                    ++i;\n                }\n                if (desc.charAt(i) == 'L') {\n                    ++i;\n                    while (desc.charAt(i) != ';') {\n                        ++i;\n                    }\n                }\n                locals[local++] = desc.substring(j, ++i);\n                break;\n            case 'L':\n                while (desc.charAt(i) != ';') {\n                    ++i;\n                }\n                locals[local++] = desc.substring(j + 1, i++);\n                break;\n            default:\n                break loop;\n            }\n        }\n        frame.localCount = local;\n    }\n\n    /**\n     * Reads a stack map frame and stores the result in the given\n     * {@link Context} object.\n     *\n     * @param stackMap\n     *            the start offset of a stack map frame in the class file.\n     * @param zip\n     *            if the stack map frame at stackMap is compressed or not.\n     * @param unzip\n     *            if the stack map frame must be uncompressed.\n     * @param labels\n     *            the labels of the method currently being parsed, indexed by\n     *            their offset. A new label for the parsed stack map frame is\n     *            stored in this array if it does not already exist.\n     * @param frame\n     *            where the parsed stack map frame must be stored.\n     * @return the offset of the first byte following the parsed frame.\n     */\n    private int readFrame(int stackMap, boolean zip, boolean unzip,\n            Label[] labels, Context frame) {\n        char[] c = frame.buffer;\n        int tag;\n        int delta;\n        if (zip) {\n            tag = b[stackMap++] & 0xFF;\n        } else {\n            tag = MethodWriter.FULL_FRAME;\n            frame.offset = -1;\n        }\n        frame.localDiff = 0;\n        if (tag < MethodWriter.SAME_LOCALS_1_STACK_ITEM_FRAME) {\n            delta = tag;\n            frame.mode = Opcodes.F_SAME;\n            frame.stackCount = 0;\n        } else if (tag < MethodWriter.RESERVED) {\n            delta = tag - MethodWriter.SAME_LOCALS_1_STACK_ITEM_FRAME;\n            stackMap = readFrameType(frame.stack, 0, stackMap, c, labels);\n            frame.mode = Opcodes.F_SAME1;\n            frame.stackCount = 1;\n        } else {\n            delta = readUnsignedShort(stackMap);\n            stackMap += 2;\n            if (tag == MethodWriter.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {\n                stackMap = readFrameType(frame.stack, 0, stackMap, c, labels);\n                frame.mode = Opcodes.F_SAME1;\n                frame.stackCount = 1;\n            } else if (tag >= MethodWriter.CHOP_FRAME\n                    && tag < MethodWriter.SAME_FRAME_EXTENDED) {\n                frame.mode = Opcodes.F_CHOP;\n                frame.localDiff = MethodWriter.SAME_FRAME_EXTENDED - tag;\n                frame.localCount -= frame.localDiff;\n                frame.stackCount = 0;\n            } else if (tag == MethodWriter.SAME_FRAME_EXTENDED) {\n                frame.mode = Opcodes.F_SAME;\n                frame.stackCount = 0;\n            } else if (tag < MethodWriter.FULL_FRAME) {\n                int local = unzip ? frame.localCount : 0;\n                for (int i = tag - MethodWriter.SAME_FRAME_EXTENDED; i > 0; i--) {\n                    stackMap = readFrameType(frame.local, local++, stackMap, c,\n                            labels);\n                }\n                frame.mode = Opcodes.F_APPEND;\n                frame.localDiff = tag - MethodWriter.SAME_FRAME_EXTENDED;\n                frame.localCount += frame.localDiff;\n                frame.stackCount = 0;\n            } else { // if (tag == FULL_FRAME) {\n                frame.mode = Opcodes.F_FULL;\n                int n = readUnsignedShort(stackMap);\n                stackMap += 2;\n                frame.localDiff = n;\n                frame.localCount = n;\n                for (int local = 0; n > 0; n--) {\n                    stackMap = readFrameType(frame.local, local++, stackMap, c,\n                            labels);\n                }\n                n = readUnsignedShort(stackMap);\n                stackMap += 2;\n                frame.stackCount = n;\n                for (int stack = 0; n > 0; n--) {\n                    stackMap = readFrameType(frame.stack, stack++, stackMap, c,\n                            labels);\n                }\n            }\n        }\n        frame.offset += delta + 1;\n        readLabel(frame.offset, labels);\n        return stackMap;\n    }\n\n    /**\n     * Reads a stack map frame type and stores it at the given index in the\n     * given array.\n     *\n     * @param frame\n     *            the array where the parsed type must be stored.\n     * @param index\n     *            the index in 'frame' where the parsed type must be stored.\n     * @param v\n     *            the start offset of the stack map frame type to read.\n     * @param buf\n     *            a buffer to read strings.\n     * @param labels\n     *            the labels of the method currently being parsed, indexed by\n     *            their offset. If the parsed type is an Uninitialized type, a\n     *            new label for the corresponding NEW instruction is stored in\n     *            this array if it does not already exist.\n     * @return the offset of the first byte after the parsed type.\n     */\n    private int readFrameType(final Object[] frame, final int index, int v,\n            final char[] buf, final Label[] labels) {\n        int type = b[v++] & 0xFF;\n        switch (type) {\n        case 0:\n            frame[index] = Opcodes.TOP;\n            break;\n        case 1:\n            frame[index] = Opcodes.INTEGER;\n            break;\n        case 2:\n            frame[index] = Opcodes.FLOAT;\n            break;\n        case 3:\n            frame[index] = Opcodes.DOUBLE;\n            break;\n        case 4:\n            frame[index] = Opcodes.LONG;\n            break;\n        case 5:\n            frame[index] = Opcodes.NULL;\n            break;\n        case 6:\n            frame[index] = Opcodes.UNINITIALIZED_THIS;\n            break;\n        case 7: // Object\n            frame[index] = readClass(v, buf);\n            v += 2;\n            break;\n        default: // Uninitialized\n            frame[index] = readLabel(readUnsignedShort(v), labels);\n            v += 2;\n        }\n        return v;\n    }\n\n    /**\n     * Returns the label corresponding to the given offset. The default\n     * implementation of this method creates a label for the given offset if it\n     * has not been already created.\n     *\n     * @param offset\n     *            a bytecode offset in a method.\n     * @param labels\n     *            the already created labels, indexed by their offset. If a\n     *            label already exists for offset this method must not create a\n     *            new one. Otherwise it must store the new label in this array.\n     * @return a non null Label, which must be equal to labels[offset].\n     */\n    protected Label readLabel(int offset, Label[] labels) {\n        if (labels[offset] == null) {\n            labels[offset] = new Label();\n        }\n        return labels[offset];\n    }\n\n    /**\n     * Returns the start index of the attribute_info structure of this class.\n     *\n     * @return the start index of the attribute_info structure of this class.\n     */\n    private int getAttributes() {\n        // skips the header\n        int u = header + 8 + readUnsignedShort(header + 6) * 2;\n        // skips fields and methods\n        for (int i = readUnsignedShort(u); i > 0; --i) {\n            for (int j = readUnsignedShort(u + 8); j > 0; --j) {\n                u += 6 + readInt(u + 12);\n            }\n            u += 8;\n        }\n        u += 2;\n        for (int i = readUnsignedShort(u); i > 0; --i) {\n            for (int j = readUnsignedShort(u + 8); j > 0; --j) {\n                u += 6 + readInt(u + 12);\n            }\n            u += 8;\n        }\n        // the attribute_info structure starts just after the methods\n        return u + 2;\n    }\n\n    /**\n     * Reads an attribute in {@link #b b}.\n     *\n     * @param attrs\n     *            prototypes of the attributes that must be parsed during the\n     *            visit of the class. Any attribute whose type is not equal to\n     *            the type of one the prototypes is ignored (i.e. an empty\n     *            {@link Attribute} instance is returned).\n     * @param type\n     *            the type of the attribute.\n     * @param off\n     *            index of the first byte of the attribute's content in\n     *            {@link #b b}. The 6 attribute header bytes, containing the\n     *            type and the length of the attribute, are not taken into\n     *            account here (they have already been read).\n     * @param len\n     *            the length of the attribute's content.\n     * @param buf\n     *            buffer to be used to call {@link #readUTF8 readUTF8},\n     *            {@link #readClass(int,char[]) readClass} or {@link #readConst\n     *            readConst}.\n     * @param codeOff\n     *            index of the first byte of code's attribute content in\n     *            {@link #b b}, or -1 if the attribute to be read is not a code\n     *            attribute. The 6 attribute header bytes, containing the type\n     *            and the length of the attribute, are not taken into account\n     *            here.\n     * @param labels\n     *            the labels of the method's code, or <tt>null</tt> if the\n     *            attribute to be read is not a code attribute.\n     * @return the attribute that has been read, or <tt>null</tt> to skip this\n     *         attribute.\n     */\n    private Attribute readAttribute(final Attribute[] attrs, final String type,\n            final int off, final int len, final char[] buf, final int codeOff,\n            final Label[] labels) {\n        for (int i = 0; i < attrs.length; ++i) {\n            if (attrs[i].type.equals(type)) {\n                return attrs[i].read(this, off, len, buf, codeOff, labels);\n            }\n        }\n        return new Attribute(type).read(this, off, len, null, -1, null);\n    }\n\n    // ------------------------------------------------------------------------\n    // Utility methods: low level parsing\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns the number of constant pool items in {@link #b b}.\n     *\n     * @return the number of constant pool items in {@link #b b}.\n     */\n    public int getItemCount() {\n        return items.length;\n    }\n\n    /**\n     * Returns the start index of the constant pool item in {@link #b b}, plus\n     * one. <i>This method is intended for {@link Attribute} sub classes, and is\n     * normally not needed by class generators or adapters.</i>\n     *\n     * @param item\n     *            the index a constant pool item.\n     * @return the start index of the constant pool item in {@link #b b}, plus\n     *         one.\n     */\n    public int getItem(final int item) {\n        return items[item];\n    }\n\n    /**\n     * Returns the maximum length of the strings contained in the constant pool\n     * of the class.\n     *\n     * @return the maximum length of the strings contained in the constant pool\n     *         of the class.\n     */\n    public int getMaxStringLength() {\n        return maxStringLength;\n    }\n\n    /**\n     * Reads a byte value in {@link #b b}. <i>This method is intended for\n     * {@link Attribute} sub classes, and is normally not needed by class\n     * generators or adapters.</i>\n     *\n     * @param index\n     *            the start index of the value to be read in {@link #b b}.\n     * @return the read value.\n     */\n    public int readByte(final int index) {\n        return b[index] & 0xFF;\n    }\n\n    /**\n     * Reads an unsigned short value in {@link #b b}. <i>This method is intended\n     * for {@link Attribute} sub classes, and is normally not needed by class\n     * generators or adapters.</i>\n     *\n     * @param index\n     *            the start index of the value to be read in {@link #b b}.\n     * @return the read value.\n     */\n    public int readUnsignedShort(final int index) {\n        byte[] b = this.b;\n        return ((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF);\n    }\n\n    /**\n     * Reads a signed short value in {@link #b b}. <i>This method is intended\n     * for {@link Attribute} sub classes, and is normally not needed by class\n     * generators or adapters.</i>\n     *\n     * @param index\n     *            the start index of the value to be read in {@link #b b}.\n     * @return the read value.\n     */\n    public short readShort(final int index) {\n        byte[] b = this.b;\n        return (short) (((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF));\n    }\n\n    /**\n     * Reads a signed int value in {@link #b b}. <i>This method is intended for\n     * {@link Attribute} sub classes, and is normally not needed by class\n     * generators or adapters.</i>\n     *\n     * @param index\n     *            the start index of the value to be read in {@link #b b}.\n     * @return the read value.\n     */\n    public int readInt(final int index) {\n        byte[] b = this.b;\n        return ((b[index] & 0xFF) << 24) | ((b[index + 1] & 0xFF) << 16)\n                | ((b[index + 2] & 0xFF) << 8) | (b[index + 3] & 0xFF);\n    }\n\n    /**\n     * Reads a signed long value in {@link #b b}. <i>This method is intended for\n     * {@link Attribute} sub classes, and is normally not needed by class\n     * generators or adapters.</i>\n     *\n     * @param index\n     *            the start index of the value to be read in {@link #b b}.\n     * @return the read value.\n     */\n    public long readLong(final int index) {\n        long l1 = readInt(index);\n        long l0 = readInt(index + 4) & 0xFFFFFFFFL;\n        return (l1 << 32) | l0;\n    }\n\n    /**\n     * Reads an UTF8 string constant pool item in {@link #b b}. <i>This method\n     * is intended for {@link Attribute} sub classes, and is normally not needed\n     * by class generators or adapters.</i>\n     *\n     * @param index\n     *            the start index of an unsigned short value in {@link #b b},\n     *            whose value is the index of an UTF8 constant pool item.\n     * @param buf\n     *            buffer to be used to read the item. This buffer must be\n     *            sufficiently large. It is not automatically resized.\n     * @return the String corresponding to the specified UTF8 item.\n     */\n    public String readUTF8(int index, final char[] buf) {\n        int item = readUnsignedShort(index);\n        if (index == 0 || item == 0) {\n            return null;\n        }\n        String s = strings[item];\n        if (s != null) {\n            return s;\n        }\n        index = items[item];\n        return strings[item] = readUTF(index + 2, readUnsignedShort(index), buf);\n    }\n\n    /**\n     * Reads UTF8 string in {@link #b b}.\n     *\n     * @param index\n     *            start offset of the UTF8 string to be read.\n     * @param utfLen\n     *            length of the UTF8 string to be read.\n     * @param buf\n     *            buffer to be used to read the string. This buffer must be\n     *            sufficiently large. It is not automatically resized.\n     * @return the String corresponding to the specified UTF8 string.\n     */\n    private String readUTF(int index, final int utfLen, final char[] buf) {\n        int endIndex = index + utfLen;\n        byte[] b = this.b;\n        int strLen = 0;\n        int c;\n        int st = 0;\n        char cc = 0;\n        while (index < endIndex) {\n            c = b[index++];\n            switch (st) {\n            case 0:\n                c = c & 0xFF;\n                if (c < 0x80) { // 0xxxxxxx\n                    buf[strLen++] = (char) c;\n                } else if (c < 0xE0 && c > 0xBF) { // 110x xxxx 10xx xxxx\n                    cc = (char) (c & 0x1F);\n                    st = 1;\n                } else { // 1110 xxxx 10xx xxxx 10xx xxxx\n                    cc = (char) (c & 0x0F);\n                    st = 2;\n                }\n                break;\n\n            case 1: // byte 2 of 2-byte char or byte 3 of 3-byte char\n                buf[strLen++] = (char) ((cc << 6) | (c & 0x3F));\n                st = 0;\n                break;\n\n            case 2: // byte 2 of 3-byte char\n                cc = (char) ((cc << 6) | (c & 0x3F));\n                st = 1;\n                break;\n            }\n        }\n        return new String(buf, 0, strLen);\n    }\n\n    /**\n     * Reads a class constant pool item in {@link #b b}. <i>This method is\n     * intended for {@link Attribute} sub classes, and is normally not needed by\n     * class generators or adapters.</i>\n     *\n     * @param index\n     *            the start index of an unsigned short value in {@link #b b},\n     *            whose value is the index of a class constant pool item.\n     * @param buf\n     *            buffer to be used to read the item. This buffer must be\n     *            sufficiently large. It is not automatically resized.\n     * @return the String corresponding to the specified class item.\n     */\n    public String readClass(final int index, final char[] buf) {\n        // computes the start index of the CONSTANT_Class item in b\n        // and reads the CONSTANT_Utf8 item designated by\n        // the first two bytes of this CONSTANT_Class item\n        return readUTF8(items[readUnsignedShort(index)], buf);\n    }\n\n    /**\n     * Reads a numeric or string constant pool item in {@link #b b}. <i>This\n     * method is intended for {@link Attribute} sub classes, and is normally not\n     * needed by class generators or adapters.</i>\n     *\n     * @param item\n     *            the index of a constant pool item.\n     * @param buf\n     *            buffer to be used to read the item. This buffer must be\n     *            sufficiently large. It is not automatically resized.\n     * @return the {@link Integer}, {@link Float}, {@link Long}, {@link Double},\n     *         {@link String}, {@link Type} or {@link Handle} corresponding to\n     *         the given constant pool item.\n     */\n    public Object readConst(final int item, final char[] buf) {\n        int index = items[item];\n        switch (b[index - 1]) {\n        case ClassWriter.INT:\n            return new Integer(readInt(index));\n        case ClassWriter.FLOAT:\n            return new Float(Float.intBitsToFloat(readInt(index)));\n        case ClassWriter.LONG:\n            return new Long(readLong(index));\n        case ClassWriter.DOUBLE:\n            return new Double(Double.longBitsToDouble(readLong(index)));\n        case ClassWriter.CLASS:\n            return Type.getObjectType(readUTF8(index, buf));\n        case ClassWriter.STR:\n            return readUTF8(index, buf);\n        case ClassWriter.MTYPE:\n            return Type.getMethodType(readUTF8(index, buf));\n        default: // case ClassWriter.HANDLE_BASE + [1..9]:\n            int tag = readByte(index);\n            int[] items = this.items;\n            int cpIndex = items[readUnsignedShort(index + 1)];\n            String owner = readClass(cpIndex, buf);\n            cpIndex = items[readUnsignedShort(cpIndex + 2)];\n            String name = readUTF8(cpIndex, buf);\n            String desc = readUTF8(cpIndex + 2, buf);\n            return new Handle(tag, owner, name, desc);\n        }\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/ClassVisitor.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * A visitor to visit a Java class. The methods of this class must be called in\n * the following order: <tt>visit</tt> [ <tt>visitSource</tt> ] [\n * <tt>visitOuterClass</tt> ] ( <tt>visitAnnotation</tt> |\n * <tt>visitAttribute</tt> )* ( <tt>visitInnerClass</tt> | <tt>visitField</tt> |\n * <tt>visitMethod</tt> )* <tt>visitEnd</tt>.\n *\n * @author Eric Bruneton\n */\npublic abstract class ClassVisitor {\n\n    /**\n     * The ASM API version implemented by this visitor. The value of this field\n     * must be one of {@link Opcodes#ASM4}.\n     */\n    protected final int api;\n\n    /**\n     * The class visitor to which this visitor must delegate method calls. May\n     * be null.\n     */\n    protected ClassVisitor cv;\n\n    /**\n     * Constructs a new {@link ClassVisitor}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     */\n    public ClassVisitor(final int api) {\n        this(api, null);\n    }\n\n    /**\n     * Constructs a new {@link ClassVisitor}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     * @param cv\n     *            the class visitor to which this visitor must delegate method\n     *            calls. May be null.\n     */\n    public ClassVisitor(final int api, final ClassVisitor cv) {\n        if (api != Opcodes.ASM4) {\n            throw new IllegalArgumentException();\n        }\n        this.api = api;\n        this.cv = cv;\n    }\n\n    /**\n     * Visits the header of the class.\n     *\n     * @param version\n     *            the class version.\n     * @param access\n     *            the class's access flags (see {@link Opcodes}). This parameter\n     *            also indicates if the class is deprecated.\n     * @param name\n     *            the internal name of the class (see\n     *            {@link Type#getInternalName() getInternalName}).\n     * @param signature\n     *            the signature of this class. May be <tt>null</tt> if the class\n     *            is not a generic one, and does not extend or implement generic\n     *            classes or interfaces.\n     * @param superName\n     *            the internal of name of the super class (see\n     *            {@link Type#getInternalName() getInternalName}). For\n     *            interfaces, the super class is {@link Object}. May be\n     *            <tt>null</tt>, but only for the {@link Object} class.\n     * @param interfaces\n     *            the internal names of the class's interfaces (see\n     *            {@link Type#getInternalName() getInternalName}). May be\n     *            <tt>null</tt>.\n     */\n    public void visit(int version, int access, String name, String signature,\n            String superName, String[] interfaces) {\n        if (cv != null) {\n            cv.visit(version, access, name, signature, superName, interfaces);\n        }\n    }\n\n    /**\n     * Visits the source of the class.\n     *\n     * @param source\n     *            the name of the source file from which the class was compiled.\n     *            May be <tt>null</tt>.\n     * @param debug\n     *            additional debug information to compute the correspondance\n     *            between source and compiled elements of the class. May be\n     *            <tt>null</tt>.\n     */\n    public void visitSource(String source, String debug) {\n        if (cv != null) {\n            cv.visitSource(source, debug);\n        }\n    }\n\n    /**\n     * Visits the enclosing class of the class. This method must be called only\n     * if the class has an enclosing class.\n     *\n     * @param owner\n     *            internal name of the enclosing class of the class.\n     * @param name\n     *            the name of the method that contains the class, or\n     *            <tt>null</tt> if the class is not enclosed in a method of its\n     *            enclosing class.\n     * @param desc\n     *            the descriptor of the method that contains the class, or\n     *            <tt>null</tt> if the class is not enclosed in a method of its\n     *            enclosing class.\n     */\n    public void visitOuterClass(String owner, String name, String desc) {\n        if (cv != null) {\n            cv.visitOuterClass(owner, name, desc);\n        }\n    }\n\n    /**\n     * Visits an annotation of the class.\n     *\n     * @param desc\n     *            the class descriptor of the annotation class.\n     * @param visible\n     *            <tt>true</tt> if the annotation is visible at runtime.\n     * @return a visitor to visit the annotation values, or <tt>null</tt> if\n     *         this visitor is not interested in visiting this annotation.\n     */\n    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {\n        if (cv != null) {\n            return cv.visitAnnotation(desc, visible);\n        }\n        return null;\n    }\n\n    /**\n     * Visits a non standard attribute of the class.\n     *\n     * @param attr\n     *            an attribute.\n     */\n    public void visitAttribute(Attribute attr) {\n        if (cv != null) {\n            cv.visitAttribute(attr);\n        }\n    }\n\n    /**\n     * Visits information about an inner class. This inner class is not\n     * necessarily a member of the class being visited.\n     *\n     * @param name\n     *            the internal name of an inner class (see\n     *            {@link Type#getInternalName() getInternalName}).\n     * @param outerName\n     *            the internal name of the class to which the inner class\n     *            belongs (see {@link Type#getInternalName() getInternalName}).\n     *            May be <tt>null</tt> for not member classes.\n     * @param innerName\n     *            the (simple) name of the inner class inside its enclosing\n     *            class. May be <tt>null</tt> for anonymous inner classes.\n     * @param access\n     *            the access flags of the inner class as originally declared in\n     *            the enclosing class.\n     */\n    public void visitInnerClass(String name, String outerName,\n            String innerName, int access) {\n        if (cv != null) {\n            cv.visitInnerClass(name, outerName, innerName, access);\n        }\n    }\n\n    /**\n     * Visits a field of the class.\n     *\n     * @param access\n     *            the field's access flags (see {@link Opcodes}). This parameter\n     *            also indicates if the field is synthetic and/or deprecated.\n     * @param name\n     *            the field's name.\n     * @param desc\n     *            the field's descriptor (see {@link Type Type}).\n     * @param signature\n     *            the field's signature. May be <tt>null</tt> if the field's\n     *            type does not use generic types.\n     * @param value\n     *            the field's initial value. This parameter, which may be\n     *            <tt>null</tt> if the field does not have an initial value,\n     *            must be an {@link Integer}, a {@link Float}, a {@link Long}, a\n     *            {@link Double} or a {@link String} (for <tt>int</tt>,\n     *            <tt>float</tt>, <tt>long</tt> or <tt>String</tt> fields\n     *            respectively). <i>This parameter is only used for static\n     *            fields</i>. Its value is ignored for non static fields, which\n     *            must be initialized through bytecode instructions in\n     *            constructors or methods.\n     * @return a visitor to visit field annotations and attributes, or\n     *         <tt>null</tt> if this class visitor is not interested in visiting\n     *         these annotations and attributes.\n     */\n    public FieldVisitor visitField(int access, String name, String desc,\n            String signature, Object value) {\n        if (cv != null) {\n            return cv.visitField(access, name, desc, signature, value);\n        }\n        return null;\n    }\n\n    /**\n     * Visits a method of the class. This method <i>must</i> return a new\n     * {@link MethodVisitor} instance (or <tt>null</tt>) each time it is called,\n     * i.e., it should not return a previously returned visitor.\n     *\n     * @param access\n     *            the method's access flags (see {@link Opcodes}). This\n     *            parameter also indicates if the method is synthetic and/or\n     *            deprecated.\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor (see {@link Type Type}).\n     * @param signature\n     *            the method's signature. May be <tt>null</tt> if the method\n     *            parameters, return type and exceptions do not use generic\n     *            types.\n     * @param exceptions\n     *            the internal names of the method's exception classes (see\n     *            {@link Type#getInternalName() getInternalName}). May be\n     *            <tt>null</tt>.\n     * @return an object to visit the byte code of the method, or <tt>null</tt>\n     *         if this class visitor is not interested in visiting the code of\n     *         this method.\n     */\n    public MethodVisitor visitMethod(int access, String name, String desc,\n            String signature, String[] exceptions) {\n        if (cv != null) {\n            return cv.visitMethod(access, name, desc, signature, exceptions);\n        }\n        return null;\n    }\n\n    /**\n     * Visits the end of the class. This method, which is the last one to be\n     * called, is used to inform the visitor that all the fields and methods of\n     * the class have been visited.\n     */\n    public void visitEnd() {\n        if (cv != null) {\n            cv.visitEnd();\n        }\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/ClassWriter.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\nimport clojure.lang.SourceWriter;\n\n/**\n * A {@link ClassVisitor} that generates classes in bytecode form. More\n * precisely this visitor generates a byte array conforming to the Java class\n * file format. It can be used alone, to generate a Java class \"from scratch\",\n * or with one or more {@link ClassReader ClassReader} and adapter class visitor\n * to generate a modified class from one or more existing Java classes.\n *\n * @author Eric Bruneton\n */\npublic class ClassWriter extends ClassVisitor {\n  \n    private final SourceWriter sc;\n\n    /**\n     * Flag to automatically compute the maximum stack size and the maximum\n     * number of local variables of methods. If this flag is set, then the\n     * arguments of the {@link MethodVisitor#visitMaxs visitMaxs} method of the\n     * {@link MethodVisitor} returned by the {@link #visitMethod visitMethod}\n     * method will be ignored, and computed automatically from the signature and\n     * the bytecode of each method.\n     *\n     * @see #ClassWriter(int)\n     */\n    public static final int COMPUTE_MAXS = 1;\n\n    /**\n     * Flag to automatically compute the stack map frames of methods from\n     * scratch. If this flag is set, then the calls to the\n     * {@link MethodVisitor#visitFrame} method are ignored, and the stack map\n     * frames are recomputed from the methods bytecode. The arguments of the\n     * {@link MethodVisitor#visitMaxs visitMaxs} method are also ignored and\n     * recomputed from the bytecode. In other words, computeFrames implies\n     * computeMaxs.\n     *\n     * @see #ClassWriter(int)\n     */\n    public static final int COMPUTE_FRAMES = 2;\n\n    /**\n     * Pseudo access flag to distinguish between the synthetic attribute and the\n     * synthetic access flag.\n     */\n    static final int ACC_SYNTHETIC_ATTRIBUTE = 0x40000;\n\n    /**\n     * Factor to convert from ACC_SYNTHETIC_ATTRIBUTE to Opcode.ACC_SYNTHETIC.\n     */\n    static final int TO_ACC_SYNTHETIC = ACC_SYNTHETIC_ATTRIBUTE\n            / Opcodes.ACC_SYNTHETIC;\n\n    /**\n     * The type of instructions without any argument.\n     */\n    static final int NOARG_INSN = 0;\n\n    /**\n     * The type of instructions with an signed byte argument.\n     */\n    static final int SBYTE_INSN = 1;\n\n    /**\n     * The type of instructions with an signed short argument.\n     */\n    static final int SHORT_INSN = 2;\n\n    /**\n     * The type of instructions with a local variable index argument.\n     */\n    static final int VAR_INSN = 3;\n\n    /**\n     * The type of instructions with an implicit local variable index argument.\n     */\n    static final int IMPLVAR_INSN = 4;\n\n    /**\n     * The type of instructions with a type descriptor argument.\n     */\n    static final int TYPE_INSN = 5;\n\n    /**\n     * The type of field and method invocations instructions.\n     */\n    static final int FIELDORMETH_INSN = 6;\n\n    /**\n     * The type of the INVOKEINTERFACE/INVOKEDYNAMIC instruction.\n     */\n    static final int ITFMETH_INSN = 7;\n\n    /**\n     * The type of the INVOKEDYNAMIC instruction.\n     */\n    static final int INDYMETH_INSN = 8;\n\n    /**\n     * The type of instructions with a 2 bytes bytecode offset label.\n     */\n    static final int LABEL_INSN = 9;\n\n    /**\n     * The type of instructions with a 4 bytes bytecode offset label.\n     */\n    static final int LABELW_INSN = 10;\n\n    /**\n     * The type of the LDC instruction.\n     */\n    static final int LDC_INSN = 11;\n\n    /**\n     * The type of the LDC_W and LDC2_W instructions.\n     */\n    static final int LDCW_INSN = 12;\n\n    /**\n     * The type of the IINC instruction.\n     */\n    static final int IINC_INSN = 13;\n\n    /**\n     * The type of the TABLESWITCH instruction.\n     */\n    static final int TABL_INSN = 14;\n\n    /**\n     * The type of the LOOKUPSWITCH instruction.\n     */\n    static final int LOOK_INSN = 15;\n\n    /**\n     * The type of the MULTIANEWARRAY instruction.\n     */\n    static final int MANA_INSN = 16;\n\n    /**\n     * The type of the WIDE instruction.\n     */\n    static final int WIDE_INSN = 17;\n\n    /**\n     * The instruction types of all JVM opcodes.\n     */\n    static final byte[] TYPE;\n\n    /**\n     * The type of CONSTANT_Class constant pool items.\n     */\n    static final int CLASS = 7;\n\n    /**\n     * The type of CONSTANT_Fieldref constant pool items.\n     */\n    static final int FIELD = 9;\n\n    /**\n     * The type of CONSTANT_Methodref constant pool items.\n     */\n    static final int METH = 10;\n\n    /**\n     * The type of CONSTANT_InterfaceMethodref constant pool items.\n     */\n    static final int IMETH = 11;\n\n    /**\n     * The type of CONSTANT_String constant pool items.\n     */\n    static final int STR = 8;\n\n    /**\n     * The type of CONSTANT_Integer constant pool items.\n     */\n    static final int INT = 3;\n\n    /**\n     * The type of CONSTANT_Float constant pool items.\n     */\n    static final int FLOAT = 4;\n\n    /**\n     * The type of CONSTANT_Long constant pool items.\n     */\n    static final int LONG = 5;\n\n    /**\n     * The type of CONSTANT_Double constant pool items.\n     */\n    static final int DOUBLE = 6;\n\n    /**\n     * The type of CONSTANT_NameAndType constant pool items.\n     */\n    static final int NAME_TYPE = 12;\n\n    /**\n     * The type of CONSTANT_Utf8 constant pool items.\n     */\n    static final int UTF8 = 1;\n\n    /**\n     * The type of CONSTANT_MethodType constant pool items.\n     */\n    static final int MTYPE = 16;\n\n    /**\n     * The type of CONSTANT_MethodHandle constant pool items.\n     */\n    static final int HANDLE = 15;\n\n    /**\n     * The type of CONSTANT_InvokeDynamic constant pool items.\n     */\n    static final int INDY = 18;\n\n    /**\n     * The base value for all CONSTANT_MethodHandle constant pool items.\n     * Internally, ASM store the 9 variations of CONSTANT_MethodHandle into 9\n     * different items.\n     */\n    static final int HANDLE_BASE = 20;\n\n    /**\n     * Normal type Item stored in the ClassWriter {@link ClassWriter#typeTable},\n     * instead of the constant pool, in order to avoid clashes with normal\n     * constant pool items in the ClassWriter constant pool's hash table.\n     */\n    static final int TYPE_NORMAL = 30;\n\n    /**\n     * Uninitialized type Item stored in the ClassWriter\n     * {@link ClassWriter#typeTable}, instead of the constant pool, in order to\n     * avoid clashes with normal constant pool items in the ClassWriter constant\n     * pool's hash table.\n     */\n    static final int TYPE_UNINIT = 31;\n\n    /**\n     * Merged type Item stored in the ClassWriter {@link ClassWriter#typeTable},\n     * instead of the constant pool, in order to avoid clashes with normal\n     * constant pool items in the ClassWriter constant pool's hash table.\n     */\n    static final int TYPE_MERGED = 32;\n\n    /**\n     * The type of BootstrapMethods items. These items are stored in a special\n     * class attribute named BootstrapMethods and not in the constant pool.\n     */\n    static final int BSM = 33;\n\n    /**\n     * The class reader from which this class writer was constructed, if any.\n     */\n    ClassReader cr;\n\n    /**\n     * Minor and major version numbers of the class to be generated.\n     */\n    int version;\n\n    /**\n     * Index of the next item to be added in the constant pool.\n     */\n    int index;\n\n    /**\n     * The constant pool of this class.\n     */\n    final ByteVector pool;\n\n    /**\n     * The constant pool's hash table data.\n     */\n    Item[] items;\n\n    /**\n     * The threshold of the constant pool's hash table.\n     */\n    int threshold;\n\n    /**\n     * A reusable key used to look for items in the {@link #items} hash table.\n     */\n    final Item key;\n\n    /**\n     * A reusable key used to look for items in the {@link #items} hash table.\n     */\n    final Item key2;\n\n    /**\n     * A reusable key used to look for items in the {@link #items} hash table.\n     */\n    final Item key3;\n\n    /**\n     * A reusable key used to look for items in the {@link #items} hash table.\n     */\n    final Item key4;\n\n    /**\n     * A type table used to temporarily store internal names that will not\n     * necessarily be stored in the constant pool. This type table is used by\n     * the control flow and data flow analysis algorithm used to compute stack\n     * map frames from scratch. This array associates to each index <tt>i</tt>\n     * the Item whose index is <tt>i</tt>. All Item objects stored in this array\n     * are also stored in the {@link #items} hash table. These two arrays allow\n     * to retrieve an Item from its index or, conversely, to get the index of an\n     * Item from its value. Each Item stores an internal name in its\n     * {@link Item#strVal1} field.\n     */\n    Item[] typeTable;\n\n    /**\n     * Number of elements in the {@link #typeTable} array.\n     */\n    private short typeCount;\n\n    /**\n     * The access flags of this class.\n     */\n    private int access;\n\n    /**\n     * The constant pool item that contains the internal name of this class.\n     */\n    private int name;\n\n    /**\n     * The internal name of this class.\n     */\n    String thisName;\n\n    /**\n     * The constant pool item that contains the signature of this class.\n     */\n    private int signature;\n\n    /**\n     * The constant pool item that contains the internal name of the super class\n     * of this class.\n     */\n    private int superName;\n\n    /**\n     * Number of interfaces implemented or extended by this class or interface.\n     */\n    private int interfaceCount;\n\n    /**\n     * The interfaces implemented or extended by this class or interface. More\n     * precisely, this array contains the indexes of the constant pool items\n     * that contain the internal names of these interfaces.\n     */\n    private int[] interfaces;\n\n    /**\n     * The index of the constant pool item that contains the name of the source\n     * file from which this class was compiled.\n     */\n    private int sourceFile;\n\n    /**\n     * The SourceDebug attribute of this class.\n     */\n    private ByteVector sourceDebug;\n\n    /**\n     * The constant pool item that contains the name of the enclosing class of\n     * this class.\n     */\n    private int enclosingMethodOwner;\n\n    /**\n     * The constant pool item that contains the name and descriptor of the\n     * enclosing method of this class.\n     */\n    private int enclosingMethod;\n\n    /**\n     * The runtime visible annotations of this class.\n     */\n    private AnnotationWriter anns;\n\n    /**\n     * The runtime invisible annotations of this class.\n     */\n    private AnnotationWriter ianns;\n\n    /**\n     * The non standard attributes of this class.\n     */\n    private Attribute attrs;\n\n    /**\n     * The number of entries in the InnerClasses attribute.\n     */\n    private int innerClassesCount;\n\n    /**\n     * The InnerClasses attribute.\n     */\n    private ByteVector innerClasses;\n\n    /**\n     * The number of entries in the BootstrapMethods attribute.\n     */\n    int bootstrapMethodsCount;\n\n    /**\n     * The BootstrapMethods attribute.\n     */\n    ByteVector bootstrapMethods;\n\n    /**\n     * The fields of this class. These fields are stored in a linked list of\n     * {@link FieldWriter} objects, linked to each other by their\n     * {@link FieldWriter#fv} field. This field stores the first element of this\n     * list.\n     */\n    FieldWriter firstField;\n\n    /**\n     * The fields of this class. These fields are stored in a linked list of\n     * {@link FieldWriter} objects, linked to each other by their\n     * {@link FieldWriter#fv} field. This field stores the last element of this\n     * list.\n     */\n    FieldWriter lastField;\n\n    /**\n     * The methods of this class. These methods are stored in a linked list of\n     * {@link MethodWriter} objects, linked to each other by their\n     * {@link MethodWriter#mv} field. This field stores the first element of\n     * this list.\n     */\n    MethodWriter firstMethod;\n\n    /**\n     * The methods of this class. These methods are stored in a linked list of\n     * {@link MethodWriter} objects, linked to each other by their\n     * {@link MethodWriter#mv} field. This field stores the last element of this\n     * list.\n     */\n    MethodWriter lastMethod;\n\n    /**\n     * <tt>true</tt> if the maximum stack size and number of local variables\n     * must be automatically computed.\n     */\n    private final boolean computeMaxs;\n\n    /**\n     * <tt>true</tt> if the stack map frames must be recomputed from scratch.\n     */\n    private final boolean computeFrames;\n\n    /**\n     * <tt>true</tt> if the stack map tables of this class are invalid. The\n     * {@link MethodWriter#resizeInstructions} method cannot transform existing\n     * stack map tables, and so produces potentially invalid classes when it is\n     * executed. In this case the class is reread and rewritten with the\n     * {@link #COMPUTE_FRAMES} option (the resizeInstructions method can resize\n     * stack map tables when this option is used).\n     */\n    boolean invalidFrames;\n\n    // ------------------------------------------------------------------------\n    // Static initializer\n    // ------------------------------------------------------------------------\n\n    /**\n     * Computes the instruction types of JVM opcodes.\n     */\n    static {\n        int i;\n        byte[] b = new byte[220];\n        String s = \"AAAAAAAAAAAAAAAABCLMMDDDDDEEEEEEEEEEEEEEEEEEEEAAAAAAAADD\"\n                + \"DDDEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\n                + \"AAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAJJJJJJJJJJJJJJJJDOPAA\"\n                + \"AAAAGGGGGGGHIFBFAAFFAARQJJKKJJJJJJJJJJJJJJJJJJ\";\n        for (i = 0; i < b.length; ++i) {\n            b[i] = (byte) (s.charAt(i) - 'A');\n        }\n        TYPE = b;\n\n        // code to generate the above string\n        //\n        // // SBYTE_INSN instructions\n        // b[Constants.NEWARRAY] = SBYTE_INSN;\n        // b[Constants.BIPUSH] = SBYTE_INSN;\n        //\n        // // SHORT_INSN instructions\n        // b[Constants.SIPUSH] = SHORT_INSN;\n        //\n        // // (IMPL)VAR_INSN instructions\n        // b[Constants.RET] = VAR_INSN;\n        // for (i = Constants.ILOAD; i <= Constants.ALOAD; ++i) {\n        // b[i] = VAR_INSN;\n        // }\n        // for (i = Constants.ISTORE; i <= Constants.ASTORE; ++i) {\n        // b[i] = VAR_INSN;\n        // }\n        // for (i = 26; i <= 45; ++i) { // ILOAD_0 to ALOAD_3\n        // b[i] = IMPLVAR_INSN;\n        // }\n        // for (i = 59; i <= 78; ++i) { // ISTORE_0 to ASTORE_3\n        // b[i] = IMPLVAR_INSN;\n        // }\n        //\n        // // TYPE_INSN instructions\n        // b[Constants.NEW] = TYPE_INSN;\n        // b[Constants.ANEWARRAY] = TYPE_INSN;\n        // b[Constants.CHECKCAST] = TYPE_INSN;\n        // b[Constants.INSTANCEOF] = TYPE_INSN;\n        //\n        // // (Set)FIELDORMETH_INSN instructions\n        // for (i = Constants.GETSTATIC; i <= Constants.INVOKESTATIC; ++i) {\n        // b[i] = FIELDORMETH_INSN;\n        // }\n        // b[Constants.INVOKEINTERFACE] = ITFMETH_INSN;\n        // b[Constants.INVOKEDYNAMIC] = INDYMETH_INSN;\n        //\n        // // LABEL(W)_INSN instructions\n        // for (i = Constants.IFEQ; i <= Constants.JSR; ++i) {\n        // b[i] = LABEL_INSN;\n        // }\n        // b[Constants.IFNULL] = LABEL_INSN;\n        // b[Constants.IFNONNULL] = LABEL_INSN;\n        // b[200] = LABELW_INSN; // GOTO_W\n        // b[201] = LABELW_INSN; // JSR_W\n        // // temporary opcodes used internally by ASM - see Label and\n        // MethodWriter\n        // for (i = 202; i < 220; ++i) {\n        // b[i] = LABEL_INSN;\n        // }\n        //\n        // // LDC(_W) instructions\n        // b[Constants.LDC] = LDC_INSN;\n        // b[19] = LDCW_INSN; // LDC_W\n        // b[20] = LDCW_INSN; // LDC2_W\n        //\n        // // special instructions\n        // b[Constants.IINC] = IINC_INSN;\n        // b[Constants.TABLESWITCH] = TABL_INSN;\n        // b[Constants.LOOKUPSWITCH] = LOOK_INSN;\n        // b[Constants.MULTIANEWARRAY] = MANA_INSN;\n        // b[196] = WIDE_INSN; // WIDE\n        //\n        // for (i = 0; i < b.length; ++i) {\n        // System.err.print((char)('A' + b[i]));\n        // }\n        // System.err.println();\n    }\n\n    // ------------------------------------------------------------------------\n    // Constructor\n    // ------------------------------------------------------------------------\n\n    /**\n     * Constructs a new {@link ClassWriter} object.\n     *\n     * @param flags\n     *            option flags that can be used to modify the default behavior\n     *            of this class. See {@link #COMPUTE_MAXS},\n     *            {@link #COMPUTE_FRAMES}.\n     */\n    public ClassWriter(final int flags) {\n        super(Opcodes.ASM4);\n        this.sc = new SourceWriter();\n        index = 1;\n        pool = new ByteVector();\n        items = new Item[256];\n        threshold = (int) (0.75d * items.length);\n        key = new Item();\n        key2 = new Item();\n        key3 = new Item();\n        key4 = new Item();\n        this.computeMaxs = (flags & COMPUTE_MAXS) != 0;\n        this.computeFrames = (flags & COMPUTE_FRAMES) != 0;\n    }\n\n    /**\n     * Constructs a new {@link ClassWriter} object and enables optimizations for\n     * \"mostly add\" bytecode transformations. These optimizations are the\n     * following:\n     *\n     * <ul>\n     * <li>The constant pool from the original class is copied as is in the new\n     * class, which saves time. New constant pool entries will be added at the\n     * end if necessary, but unused constant pool entries <i>won't be\n     * removed</i>.</li>\n     * <li>Methods that are not transformed are copied as is in the new class,\n     * directly from the original class bytecode (i.e. without emitting visit\n     * events for all the method instructions), which saves a <i>lot</i> of\n     * time. Untransformed methods are detected by the fact that the\n     * {@link ClassReader} receives {@link MethodVisitor} objects that come from\n     * a {@link ClassWriter} (and not from any other {@link ClassVisitor}\n     * instance).</li>\n     * </ul>\n     *\n     * @param classReader\n     *            the {@link ClassReader} used to read the original class. It\n     *            will be used to copy the entire constant pool from the\n     *            original class and also to copy other fragments of original\n     *            bytecode where applicable.\n     * @param flags\n     *            option flags that can be used to modify the default behavior\n     *            of this class. <i>These option flags do not affect methods\n     *            that are copied as is in the new class. This means that the\n     *            maximum stack size nor the stack frames will be computed for\n     *            these methods</i>. See {@link #COMPUTE_MAXS},\n     *            {@link #COMPUTE_FRAMES}.\n     */\n    public ClassWriter(final ClassReader classReader, final int flags) {\n        this(flags);\n        classReader.copyPool(this);\n        this.cr = classReader;\n    }\n\n    // ------------------------------------------------------------------------\n    // Implementation of the ClassVisitor abstract class\n    // ------------------------------------------------------------------------\n\n    @Override\n    public final void visit(final int version, final int access,\n            final String name, final String signature, final String superName,\n            final String[] interfaces) {\n        this.version = version;\n        this.access = access;\n        this.name = newClass(name);\n        thisName = name;\n        if (ClassReader.SIGNATURES && signature != null) {\n            this.signature = newUTF8(signature);\n        }\n        this.superName = superName == null ? 0 : newClass(superName);\n        if (interfaces != null && interfaces.length > 0) {\n            interfaceCount = interfaces.length;\n            this.interfaces = new int[interfaceCount];\n            for (int i = 0; i < interfaceCount; ++i) {\n                this.interfaces[i] = newClass(interfaces[i]);\n            }\n        }\n    }\n\n    @Override\n    public final void visitSource(final String file, final String debug) {\n        if (file != null) {\n            sourceFile = newUTF8(file);\n        }\n        if (debug != null) {\n            sourceDebug = new ByteVector().putUTF8(debug);\n        }\n    }\n\n    @Override\n    public final void visitOuterClass(final String owner, final String name,\n            final String desc) {\n        enclosingMethodOwner = newClass(owner);\n        if (name != null && desc != null) {\n            enclosingMethod = newNameType(name, desc);\n        }\n    }\n\n    @Override\n    public final AnnotationVisitor visitAnnotation(final String desc,\n            final boolean visible) {\n        if (!ClassReader.ANNOTATIONS) {\n            return null;\n        }\n        ByteVector bv = new ByteVector();\n        // write type, and reserve space for values count\n        bv.putShort(newUTF8(desc)).putShort(0);\n        AnnotationWriter aw = new AnnotationWriter(this, true, bv, bv, 2);\n        if (visible) {\n            aw.next = anns;\n            anns = aw;\n        } else {\n            aw.next = ianns;\n            ianns = aw;\n        }\n        return aw;\n    }\n\n    @Override\n    public final void visitAttribute(final Attribute attr) {\n        attr.next = attrs;\n        attrs = attr;\n    }\n\n    @Override\n    public final void visitInnerClass(final String name,\n            final String outerName, final String innerName, final int access) {\n        if (innerClasses == null) {\n            innerClasses = new ByteVector();\n        }\n        ++innerClassesCount;\n        innerClasses.putShort(name == null ? 0 : newClass(name));\n        innerClasses.putShort(outerName == null ? 0 : newClass(outerName));\n        innerClasses.putShort(innerName == null ? 0 : newUTF8(innerName));\n        innerClasses.putShort(access);\n    }\n\n    @Override\n    public final FieldVisitor visitField(final int access, final String name,\n            final String desc, final String signature, final Object value) {\n        return new FieldWriter(this, access, name, desc, signature, value);\n    }\n\n    @Override\n    public final MethodVisitor visitMethod(final int access, final String name,\n            final String desc, final String signature, final String[] exceptions) {\n        return new MethodWriter(this, access, name, desc, signature,\n                exceptions, computeMaxs, computeFrames);\n    }\n\n    @Override\n    public final void visitEnd() {\n    }\n\n    // ------------------------------------------------------------------------\n    // Other public methods\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns the bytecode of the class that was build with this class writer.\n     *\n     * @return the bytecode of the class that was build with this class writer.\n     */\n    public byte[] toByteArray() {\n        if (index > 0xFFFF) {\n            throw new RuntimeException(\"Class file too large!\");\n        }\n        // computes the real size of the bytecode of this class\n        int size = 24 + 2 * interfaceCount;\n        int nbFields = 0;\n        FieldWriter fb = firstField;\n        while (fb != null) {\n            ++nbFields;\n            size += fb.getSize();\n            fb = (FieldWriter) fb.fv;\n        }\n        int nbMethods = 0;\n        MethodWriter mb = firstMethod;\n        while (mb != null) {\n            ++nbMethods;\n            size += mb.getSize();\n            mb = (MethodWriter) mb.mv;\n        }\n        int attributeCount = 0;\n        if (bootstrapMethods != null) {\n            // we put it as first attribute in order to improve a bit\n            // ClassReader.copyBootstrapMethods\n            ++attributeCount;\n            size += 8 + bootstrapMethods.length;\n            newUTF8(\"BootstrapMethods\");\n        }\n        if (ClassReader.SIGNATURES && signature != 0) {\n            ++attributeCount;\n            size += 8;\n            newUTF8(\"Signature\");\n        }\n        if (sourceFile != 0) {\n            ++attributeCount;\n            size += 8;\n            newUTF8(\"SourceFile\");\n        }\n        if (sourceDebug != null) {\n            ++attributeCount;\n            size += sourceDebug.length + 4;\n            newUTF8(\"SourceDebugExtension\");\n        }\n        if (enclosingMethodOwner != 0) {\n            ++attributeCount;\n            size += 10;\n            newUTF8(\"EnclosingMethod\");\n        }\n        if ((access & Opcodes.ACC_DEPRECATED) != 0) {\n            ++attributeCount;\n            size += 6;\n            newUTF8(\"Deprecated\");\n        }\n        if ((access & Opcodes.ACC_SYNTHETIC) != 0) {\n            if ((version & 0xFFFF) < Opcodes.V1_5\n                    || (access & ACC_SYNTHETIC_ATTRIBUTE) != 0) {\n                ++attributeCount;\n                size += 6;\n                newUTF8(\"Synthetic\");\n            }\n        }\n        if (innerClasses != null) {\n            ++attributeCount;\n            size += 8 + innerClasses.length;\n            newUTF8(\"InnerClasses\");\n        }\n        if (ClassReader.ANNOTATIONS && anns != null) {\n            ++attributeCount;\n            size += 8 + anns.getSize();\n            newUTF8(\"RuntimeVisibleAnnotations\");\n        }\n        if (ClassReader.ANNOTATIONS && ianns != null) {\n            ++attributeCount;\n            size += 8 + ianns.getSize();\n            newUTF8(\"RuntimeInvisibleAnnotations\");\n        }\n        if (attrs != null) {\n            attributeCount += attrs.getCount();\n            size += attrs.getSize(this, null, 0, -1, -1);\n        }\n        size += pool.length;\n        // allocates a byte vector of this size, in order to avoid unnecessary\n        // arraycopy operations in the ByteVector.enlarge() method\n        ByteVector out = new ByteVector(size);\n        out.putInt(0xCAFEBABE).putInt(version);\n        out.putShort(index).putByteArray(pool.data, 0, pool.length);\n        int mask = Opcodes.ACC_DEPRECATED | ACC_SYNTHETIC_ATTRIBUTE\n                | ((access & ACC_SYNTHETIC_ATTRIBUTE) / TO_ACC_SYNTHETIC);\n        out.putShort(access & ~mask).putShort(name).putShort(superName);\n        out.putShort(interfaceCount);\n        for (int i = 0; i < interfaceCount; ++i) {\n            out.putShort(interfaces[i]);\n        }\n        out.putShort(nbFields);\n        fb = firstField;\n        while (fb != null) {\n            fb.put(out);\n            fb = (FieldWriter) fb.fv;\n        }\n        out.putShort(nbMethods);\n        mb = firstMethod;\n        while (mb != null) {\n            mb.put(out);\n            mb = (MethodWriter) mb.mv;\n        }\n        out.putShort(attributeCount);\n        if (bootstrapMethods != null) {\n            out.putShort(newUTF8(\"BootstrapMethods\"));\n            out.putInt(bootstrapMethods.length + 2).putShort(\n                    bootstrapMethodsCount);\n            out.putByteArray(bootstrapMethods.data, 0, bootstrapMethods.length);\n        }\n        if (ClassReader.SIGNATURES && signature != 0) {\n            out.putShort(newUTF8(\"Signature\")).putInt(2).putShort(signature);\n        }\n        if (sourceFile != 0) {\n            out.putShort(newUTF8(\"SourceFile\")).putInt(2).putShort(sourceFile);\n        }\n        if (sourceDebug != null) {\n            int len = sourceDebug.length - 2;\n            out.putShort(newUTF8(\"SourceDebugExtension\")).putInt(len);\n            out.putByteArray(sourceDebug.data, 2, len);\n        }\n        if (enclosingMethodOwner != 0) {\n            out.putShort(newUTF8(\"EnclosingMethod\")).putInt(4);\n            out.putShort(enclosingMethodOwner).putShort(enclosingMethod);\n        }\n        if ((access & Opcodes.ACC_DEPRECATED) != 0) {\n            out.putShort(newUTF8(\"Deprecated\")).putInt(0);\n        }\n        if ((access & Opcodes.ACC_SYNTHETIC) != 0) {\n            if ((version & 0xFFFF) < Opcodes.V1_5\n                    || (access & ACC_SYNTHETIC_ATTRIBUTE) != 0) {\n                out.putShort(newUTF8(\"Synthetic\")).putInt(0);\n            }\n        }\n        if (innerClasses != null) {\n            out.putShort(newUTF8(\"InnerClasses\"));\n            out.putInt(innerClasses.length + 2).putShort(innerClassesCount);\n            out.putByteArray(innerClasses.data, 0, innerClasses.length);\n        }\n        if (ClassReader.ANNOTATIONS && anns != null) {\n            out.putShort(newUTF8(\"RuntimeVisibleAnnotations\"));\n            anns.put(out);\n        }\n        if (ClassReader.ANNOTATIONS && ianns != null) {\n            out.putShort(newUTF8(\"RuntimeInvisibleAnnotations\"));\n            ianns.put(out);\n        }\n        if (attrs != null) {\n            attrs.put(this, null, 0, -1, -1, out);\n        }\n        if (invalidFrames) {\n            ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);\n            new ClassReader(out.data).accept(cw, ClassReader.SKIP_FRAMES);\n            return cw.toByteArray();\n        }\n        return out.data;\n    }\n\n    // ------------------------------------------------------------------------\n    // Utility methods: constant pool management\n    // ------------------------------------------------------------------------\n\n    /**\n     * Adds a number or string constant to the constant pool of the class being\n     * build. Does nothing if the constant pool already contains a similar item.\n     *\n     * @param cst\n     *            the value of the constant to be added to the constant pool.\n     *            This parameter must be an {@link Integer}, a {@link Float}, a\n     *            {@link Long}, a {@link Double}, a {@link String} or a\n     *            {@link Type}.\n     * @return a new or already existing constant item with the given value.\n     */\n    Item newConstItem(final Object cst) {\n        if (cst instanceof Integer) {\n            int val = ((Integer) cst).intValue();\n            return newInteger(val);\n        } else if (cst instanceof Byte) {\n            int val = ((Byte) cst).intValue();\n            return newInteger(val);\n        } else if (cst instanceof Character) {\n            int val = ((Character) cst).charValue();\n            return newInteger(val);\n        } else if (cst instanceof Short) {\n            int val = ((Short) cst).intValue();\n            return newInteger(val);\n        } else if (cst instanceof Boolean) {\n            int val = ((Boolean) cst).booleanValue() ? 1 : 0;\n            return newInteger(val);\n        } else if (cst instanceof Float) {\n            float val = ((Float) cst).floatValue();\n            return newFloat(val);\n        } else if (cst instanceof Long) {\n            long val = ((Long) cst).longValue();\n            return newLong(val);\n        } else if (cst instanceof Double) {\n            double val = ((Double) cst).doubleValue();\n            return newDouble(val);\n        } else if (cst instanceof String) {\n            return newString((String) cst);\n        } else if (cst instanceof Type) {\n            Type t = (Type) cst;\n            int s = t.getSort();\n            if (s == Type.OBJECT) {\n                return newClassItem(t.getInternalName());\n            } else if (s == Type.METHOD) {\n                return newMethodTypeItem(t.getDescriptor());\n            } else { // s == primitive type or array\n                return newClassItem(t.getDescriptor());\n            }\n        } else if (cst instanceof Handle) {\n            Handle h = (Handle) cst;\n            return newHandleItem(h.tag, h.owner, h.name, h.desc);\n        } else {\n            throw new IllegalArgumentException(\"value \" + cst);\n        }\n    }\n\n    /**\n     * Adds a number or string constant to the constant pool of the class being\n     * build. Does nothing if the constant pool already contains a similar item.\n     * <i>This method is intended for {@link Attribute} sub classes, and is\n     * normally not needed by class generators or adapters.</i>\n     *\n     * @param cst\n     *            the value of the constant to be added to the constant pool.\n     *            This parameter must be an {@link Integer}, a {@link Float}, a\n     *            {@link Long}, a {@link Double} or a {@link String}.\n     * @return the index of a new or already existing constant item with the\n     *         given value.\n     */\n    public int newConst(final Object cst) {\n        return newConstItem(cst).index;\n    }\n\n    /**\n     * Adds an UTF8 string to the constant pool of the class being build. Does\n     * nothing if the constant pool already contains a similar item. <i>This\n     * method is intended for {@link Attribute} sub classes, and is normally not\n     * needed by class generators or adapters.</i>\n     *\n     * @param value\n     *            the String value.\n     * @return the index of a new or already existing UTF8 item.\n     */\n    public int newUTF8(final String value) {\n        key.set(UTF8, value, null, null);\n        Item result = get(key);\n        if (result == null) {\n            pool.putByte(UTF8).putUTF8(value);\n            result = new Item(index++, key);\n            put(result);\n        }\n        return result.index;\n    }\n\n    /**\n     * Adds a class reference to the constant pool of the class being build.\n     * Does nothing if the constant pool already contains a similar item.\n     * <i>This method is intended for {@link Attribute} sub classes, and is\n     * normally not needed by class generators or adapters.</i>\n     *\n     * @param value\n     *            the internal name of the class.\n     * @return a new or already existing class reference item.\n     */\n    Item newClassItem(final String value) {\n        key2.set(CLASS, value, null, null);\n        Item result = get(key2);\n        if (result == null) {\n            pool.put12(CLASS, newUTF8(value));\n            result = new Item(index++, key2);\n            put(result);\n        }\n        return result;\n    }\n\n    /**\n     * Adds a class reference to the constant pool of the class being build.\n     * Does nothing if the constant pool already contains a similar item.\n     * <i>This method is intended for {@link Attribute} sub classes, and is\n     * normally not needed by class generators or adapters.</i>\n     *\n     * @param value\n     *            the internal name of the class.\n     * @return the index of a new or already existing class reference item.\n     */\n    public int newClass(final String value) {\n        return newClassItem(value).index;\n    }\n\n    /**\n     * Adds a method type reference to the constant pool of the class being\n     * build. Does nothing if the constant pool already contains a similar item.\n     * <i>This method is intended for {@link Attribute} sub classes, and is\n     * normally not needed by class generators or adapters.</i>\n     *\n     * @param methodDesc\n     *            method descriptor of the method type.\n     * @return a new or already existing method type reference item.\n     */\n    Item newMethodTypeItem(final String methodDesc) {\n        key2.set(MTYPE, methodDesc, null, null);\n        Item result = get(key2);\n        if (result == null) {\n            pool.put12(MTYPE, newUTF8(methodDesc));\n            result = new Item(index++, key2);\n            put(result);\n        }\n        return result;\n    }\n\n    /**\n     * Adds a method type reference to the constant pool of the class being\n     * build. Does nothing if the constant pool already contains a similar item.\n     * <i>This method is intended for {@link Attribute} sub classes, and is\n     * normally not needed by class generators or adapters.</i>\n     *\n     * @param methodDesc\n     *            method descriptor of the method type.\n     * @return the index of a new or already existing method type reference\n     *         item.\n     */\n    public int newMethodType(final String methodDesc) {\n        return newMethodTypeItem(methodDesc).index;\n    }\n\n    /**\n     * Adds a handle to the constant pool of the class being build. Does nothing\n     * if the constant pool already contains a similar item. <i>This method is\n     * intended for {@link Attribute} sub classes, and is normally not needed by\n     * class generators or adapters.</i>\n     *\n     * @param tag\n     *            the kind of this handle. Must be {@link Opcodes#H_GETFIELD},\n     *            {@link Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD},\n     *            {@link Opcodes#H_PUTSTATIC}, {@link Opcodes#H_INVOKEVIRTUAL},\n     *            {@link Opcodes#H_INVOKESTATIC},\n     *            {@link Opcodes#H_INVOKESPECIAL},\n     *            {@link Opcodes#H_NEWINVOKESPECIAL} or\n     *            {@link Opcodes#H_INVOKEINTERFACE}.\n     * @param owner\n     *            the internal name of the field or method owner class.\n     * @param name\n     *            the name of the field or method.\n     * @param desc\n     *            the descriptor of the field or method.\n     * @return a new or an already existing method type reference item.\n     */\n    Item newHandleItem(final int tag, final String owner, final String name,\n            final String desc) {\n        key4.set(HANDLE_BASE + tag, owner, name, desc);\n        Item result = get(key4);\n        if (result == null) {\n            if (tag <= Opcodes.H_PUTSTATIC) {\n                put112(HANDLE, tag, newField(owner, name, desc));\n            } else {\n                put112(HANDLE,\n                        tag,\n                        newMethod(owner, name, desc,\n                                tag == Opcodes.H_INVOKEINTERFACE));\n            }\n            result = new Item(index++, key4);\n            put(result);\n        }\n        return result;\n    }\n\n    /**\n     * Adds a handle to the constant pool of the class being build. Does nothing\n     * if the constant pool already contains a similar item. <i>This method is\n     * intended for {@link Attribute} sub classes, and is normally not needed by\n     * class generators or adapters.</i>\n     *\n     * @param tag\n     *            the kind of this handle. Must be {@link Opcodes#H_GETFIELD},\n     *            {@link Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD},\n     *            {@link Opcodes#H_PUTSTATIC}, {@link Opcodes#H_INVOKEVIRTUAL},\n     *            {@link Opcodes#H_INVOKESTATIC},\n     *            {@link Opcodes#H_INVOKESPECIAL},\n     *            {@link Opcodes#H_NEWINVOKESPECIAL} or\n     *            {@link Opcodes#H_INVOKEINTERFACE}.\n     * @param owner\n     *            the internal name of the field or method owner class.\n     * @param name\n     *            the name of the field or method.\n     * @param desc\n     *            the descriptor of the field or method.\n     * @return the index of a new or already existing method type reference\n     *         item.\n     */\n    public int newHandle(final int tag, final String owner, final String name,\n            final String desc) {\n        return newHandleItem(tag, owner, name, desc).index;\n    }\n\n    /**\n     * Adds an invokedynamic reference to the constant pool of the class being\n     * build. Does nothing if the constant pool already contains a similar item.\n     * <i>This method is intended for {@link Attribute} sub classes, and is\n     * normally not needed by class generators or adapters.</i>\n     *\n     * @param name\n     *            name of the invoked method.\n     * @param desc\n     *            descriptor of the invoke method.\n     * @param bsm\n     *            the bootstrap method.\n     * @param bsmArgs\n     *            the bootstrap method constant arguments.\n     *\n     * @return a new or an already existing invokedynamic type reference item.\n     */\n    Item newInvokeDynamicItem(final String name, final String desc,\n            final Handle bsm, final Object... bsmArgs) {\n        // cache for performance\n        ByteVector bootstrapMethods = this.bootstrapMethods;\n        if (bootstrapMethods == null) {\n            bootstrapMethods = this.bootstrapMethods = new ByteVector();\n        }\n\n        int position = bootstrapMethods.length; // record current position\n\n        int hashCode = bsm.hashCode();\n        bootstrapMethods.putShort(newHandle(bsm.tag, bsm.owner, bsm.name,\n                bsm.desc));\n\n        int argsLength = bsmArgs.length;\n        bootstrapMethods.putShort(argsLength);\n\n        for (int i = 0; i < argsLength; i++) {\n            Object bsmArg = bsmArgs[i];\n            hashCode ^= bsmArg.hashCode();\n            bootstrapMethods.putShort(newConst(bsmArg));\n        }\n\n        byte[] data = bootstrapMethods.data;\n        int length = (1 + 1 + argsLength) << 1; // (bsm + argCount + arguments)\n        hashCode &= 0x7FFFFFFF;\n        Item result = items[hashCode % items.length];\n        loop: while (result != null) {\n            if (result.type != BSM || result.hashCode != hashCode) {\n                result = result.next;\n                continue;\n            }\n\n            // because the data encode the size of the argument\n            // we don't need to test if these size are equals\n            int resultPosition = result.intVal;\n            for (int p = 0; p < length; p++) {\n                if (data[position + p] != data[resultPosition + p]) {\n                    result = result.next;\n                    continue loop;\n                }\n            }\n            break;\n        }\n\n        int bootstrapMethodIndex;\n        if (result != null) {\n            bootstrapMethodIndex = result.index;\n            bootstrapMethods.length = position; // revert to old position\n        } else {\n            bootstrapMethodIndex = bootstrapMethodsCount++;\n            result = new Item(bootstrapMethodIndex);\n            result.set(position, hashCode);\n            put(result);\n        }\n\n        // now, create the InvokeDynamic constant\n        key3.set(name, desc, bootstrapMethodIndex);\n        result = get(key3);\n        if (result == null) {\n            put122(INDY, bootstrapMethodIndex, newNameType(name, desc));\n            result = new Item(index++, key3);\n            put(result);\n        }\n        return result;\n    }\n\n    /**\n     * Adds an invokedynamic reference to the constant pool of the class being\n     * build. Does nothing if the constant pool already contains a similar item.\n     * <i>This method is intended for {@link Attribute} sub classes, and is\n     * normally not needed by class generators or adapters.</i>\n     *\n     * @param name\n     *            name of the invoked method.\n     * @param desc\n     *            descriptor of the invoke method.\n     * @param bsm\n     *            the bootstrap method.\n     * @param bsmArgs\n     *            the bootstrap method constant arguments.\n     *\n     * @return the index of a new or already existing invokedynamic reference\n     *         item.\n     */\n    public int newInvokeDynamic(final String name, final String desc,\n            final Handle bsm, final Object... bsmArgs) {\n        return newInvokeDynamicItem(name, desc, bsm, bsmArgs).index;\n    }\n\n    /**\n     * Adds a field reference to the constant pool of the class being build.\n     * Does nothing if the constant pool already contains a similar item.\n     *\n     * @param owner\n     *            the internal name of the field's owner class.\n     * @param name\n     *            the field's name.\n     * @param desc\n     *            the field's descriptor.\n     * @return a new or already existing field reference item.\n     */\n    Item newFieldItem(final String owner, final String name, final String desc) {\n        key3.set(FIELD, owner, name, desc);\n        Item result = get(key3);\n        if (result == null) {\n            put122(FIELD, newClass(owner), newNameType(name, desc));\n            result = new Item(index++, key3);\n            put(result);\n        }\n        return result;\n    }\n\n    /**\n     * Adds a field reference to the constant pool of the class being build.\n     * Does nothing if the constant pool already contains a similar item.\n     * <i>This method is intended for {@link Attribute} sub classes, and is\n     * normally not needed by class generators or adapters.</i>\n     *\n     * @param owner\n     *            the internal name of the field's owner class.\n     * @param name\n     *            the field's name.\n     * @param desc\n     *            the field's descriptor.\n     * @return the index of a new or already existing field reference item.\n     */\n    public int newField(final String owner, final String name, final String desc) {\n        return newFieldItem(owner, name, desc).index;\n    }\n\n    /**\n     * Adds a method reference to the constant pool of the class being build.\n     * Does nothing if the constant pool already contains a similar item.\n     *\n     * @param owner\n     *            the internal name of the method's owner class.\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor.\n     * @param itf\n     *            <tt>true</tt> if <tt>owner</tt> is an interface.\n     * @return a new or already existing method reference item.\n     */\n    Item newMethodItem(final String owner, final String name,\n            final String desc, final boolean itf) {\n        int type = itf ? IMETH : METH;\n        key3.set(type, owner, name, desc);\n        Item result = get(key3);\n        if (result == null) {\n            put122(type, newClass(owner), newNameType(name, desc));\n            result = new Item(index++, key3);\n            put(result);\n        }\n        return result;\n    }\n\n    /**\n     * Adds a method reference to the constant pool of the class being build.\n     * Does nothing if the constant pool already contains a similar item.\n     * <i>This method is intended for {@link Attribute} sub classes, and is\n     * normally not needed by class generators or adapters.</i>\n     *\n     * @param owner\n     *            the internal name of the method's owner class.\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor.\n     * @param itf\n     *            <tt>true</tt> if <tt>owner</tt> is an interface.\n     * @return the index of a new or already existing method reference item.\n     */\n    public int newMethod(final String owner, final String name,\n            final String desc, final boolean itf) {\n        return newMethodItem(owner, name, desc, itf).index;\n    }\n\n    /**\n     * Adds an integer to the constant pool of the class being build. Does\n     * nothing if the constant pool already contains a similar item.\n     *\n     * @param value\n     *            the int value.\n     * @return a new or already existing int item.\n     */\n    Item newInteger(final int value) {\n        key.set(value);\n        Item result = get(key);\n        if (result == null) {\n            pool.putByte(INT).putInt(value);\n            result = new Item(index++, key);\n            put(result);\n        }\n        return result;\n    }\n\n    /**\n     * Adds a float to the constant pool of the class being build. Does nothing\n     * if the constant pool already contains a similar item.\n     *\n     * @param value\n     *            the float value.\n     * @return a new or already existing float item.\n     */\n    Item newFloat(final float value) {\n        key.set(value);\n        Item result = get(key);\n        if (result == null) {\n            pool.putByte(FLOAT).putInt(key.intVal);\n            result = new Item(index++, key);\n            put(result);\n        }\n        return result;\n    }\n\n    /**\n     * Adds a long to the constant pool of the class being build. Does nothing\n     * if the constant pool already contains a similar item.\n     *\n     * @param value\n     *            the long value.\n     * @return a new or already existing long item.\n     */\n    Item newLong(final long value) {\n        key.set(value);\n        Item result = get(key);\n        if (result == null) {\n            pool.putByte(LONG).putLong(value);\n            result = new Item(index, key);\n            index += 2;\n            put(result);\n        }\n        return result;\n    }\n\n    /**\n     * Adds a double to the constant pool of the class being build. Does nothing\n     * if the constant pool already contains a similar item.\n     *\n     * @param value\n     *            the double value.\n     * @return a new or already existing double item.\n     */\n    Item newDouble(final double value) {\n        key.set(value);\n        Item result = get(key);\n        if (result == null) {\n            pool.putByte(DOUBLE).putLong(key.longVal);\n            result = new Item(index, key);\n            index += 2;\n            put(result);\n        }\n        return result;\n    }\n\n    /**\n     * Adds a string to the constant pool of the class being build. Does nothing\n     * if the constant pool already contains a similar item.\n     *\n     * @param value\n     *            the String value.\n     * @return a new or already existing string item.\n     */\n    private Item newString(final String value) {\n        key2.set(STR, value, null, null);\n        Item result = get(key2);\n        if (result == null) {\n            pool.put12(STR, newUTF8(value));\n            result = new Item(index++, key2);\n            put(result);\n        }\n        return result;\n    }\n\n    /**\n     * Adds a name and type to the constant pool of the class being build. Does\n     * nothing if the constant pool already contains a similar item. <i>This\n     * method is intended for {@link Attribute} sub classes, and is normally not\n     * needed by class generators or adapters.</i>\n     *\n     * @param name\n     *            a name.\n     * @param desc\n     *            a type descriptor.\n     * @return the index of a new or already existing name and type item.\n     */\n    public int newNameType(final String name, final String desc) {\n        return newNameTypeItem(name, desc).index;\n    }\n\n    /**\n     * Adds a name and type to the constant pool of the class being build. Does\n     * nothing if the constant pool already contains a similar item.\n     *\n     * @param name\n     *            a name.\n     * @param desc\n     *            a type descriptor.\n     * @return a new or already existing name and type item.\n     */\n    Item newNameTypeItem(final String name, final String desc) {\n        key2.set(NAME_TYPE, name, desc, null);\n        Item result = get(key2);\n        if (result == null) {\n            put122(NAME_TYPE, newUTF8(name), newUTF8(desc));\n            result = new Item(index++, key2);\n            put(result);\n        }\n        return result;\n    }\n\n    /**\n     * Adds the given internal name to {@link #typeTable} and returns its index.\n     * Does nothing if the type table already contains this internal name.\n     *\n     * @param type\n     *            the internal name to be added to the type table.\n     * @return the index of this internal name in the type table.\n     */\n    int addType(final String type) {\n        key.set(TYPE_NORMAL, type, null, null);\n        Item result = get(key);\n        if (result == null) {\n            result = addType(key);\n        }\n        return result.index;\n    }\n\n    /**\n     * Adds the given \"uninitialized\" type to {@link #typeTable} and returns its\n     * index. This method is used for UNINITIALIZED types, made of an internal\n     * name and a bytecode offset.\n     *\n     * @param type\n     *            the internal name to be added to the type table.\n     * @param offset\n     *            the bytecode offset of the NEW instruction that created this\n     *            UNINITIALIZED type value.\n     * @return the index of this internal name in the type table.\n     */\n    int addUninitializedType(final String type, final int offset) {\n        key.type = TYPE_UNINIT;\n        key.intVal = offset;\n        key.strVal1 = type;\n        key.hashCode = 0x7FFFFFFF & (TYPE_UNINIT + type.hashCode() + offset);\n        Item result = get(key);\n        if (result == null) {\n            result = addType(key);\n        }\n        return result.index;\n    }\n\n    /**\n     * Adds the given Item to {@link #typeTable}.\n     *\n     * @param item\n     *            the value to be added to the type table.\n     * @return the added Item, which a new Item instance with the same value as\n     *         the given Item.\n     */\n    private Item addType(final Item item) {\n        ++typeCount;\n        Item result = new Item(typeCount, key);\n        put(result);\n        if (typeTable == null) {\n            typeTable = new Item[16];\n        }\n        if (typeCount == typeTable.length) {\n            Item[] newTable = new Item[2 * typeTable.length];\n            System.arraycopy(typeTable, 0, newTable, 0, typeTable.length);\n            typeTable = newTable;\n        }\n        typeTable[typeCount] = result;\n        return result;\n    }\n\n    /**\n     * Returns the index of the common super type of the two given types. This\n     * method calls {@link #getCommonSuperClass} and caches the result in the\n     * {@link #items} hash table to speedup future calls with the same\n     * parameters.\n     *\n     * @param type1\n     *            index of an internal name in {@link #typeTable}.\n     * @param type2\n     *            index of an internal name in {@link #typeTable}.\n     * @return the index of the common super type of the two given types.\n     */\n    int getMergedType(final int type1, final int type2) {\n        key2.type = TYPE_MERGED;\n        key2.longVal = type1 | (((long) type2) << 32);\n        key2.hashCode = 0x7FFFFFFF & (TYPE_MERGED + type1 + type2);\n        Item result = get(key2);\n        if (result == null) {\n            String t = typeTable[type1].strVal1;\n            String u = typeTable[type2].strVal1;\n            key2.intVal = addType(getCommonSuperClass(t, u));\n            result = new Item((short) 0, key2);\n            put(result);\n        }\n        return result.intVal;\n    }\n\n    /**\n     * Returns the common super type of the two given types. The default\n     * implementation of this method <i>loads<i> the two given classes and uses\n     * the java.lang.Class methods to find the common super class. It can be\n     * overridden to compute this common super type in other ways, in particular\n     * without actually loading any class, or to take into account the class\n     * that is currently being generated by this ClassWriter, which can of\n     * course not be loaded since it is under construction.\n     *\n     * @param type1\n     *            the internal name of a class.\n     * @param type2\n     *            the internal name of another class.\n     * @return the internal name of the common super class of the two given\n     *         classes.\n     */\n    protected String getCommonSuperClass(final String type1, final String type2) {\n        Class<?> c, d;\n        ClassLoader classLoader = getClass().getClassLoader();\n        try {\n            c = Class.forName(type1.replace('/', '.'), false, classLoader);\n            d = Class.forName(type2.replace('/', '.'), false, classLoader);\n        } catch (Exception e) {\n            throw new RuntimeException(e.toString());\n        }\n        if (c.isAssignableFrom(d)) {\n            return type1;\n        }\n        if (d.isAssignableFrom(c)) {\n            return type2;\n        }\n        if (c.isInterface() || d.isInterface()) {\n            return \"java/lang/Object\";\n        } else {\n            do {\n                c = c.getSuperclass();\n            } while (!c.isAssignableFrom(d));\n            return c.getName().replace('.', '/');\n        }\n    }\n\n    /**\n     * Returns the constant pool's hash table item which is equal to the given\n     * item.\n     *\n     * @param key\n     *            a constant pool item.\n     * @return the constant pool's hash table item which is equal to the given\n     *         item, or <tt>null</tt> if there is no such item.\n     */\n    private Item get(final Item key) {\n        Item i = items[key.hashCode % items.length];\n        while (i != null && (i.type != key.type || !key.isEqualTo(i))) {\n            i = i.next;\n        }\n        return i;\n    }\n\n    /**\n     * Puts the given item in the constant pool's hash table. The hash table\n     * <i>must</i> not already contains this item.\n     *\n     * @param i\n     *            the item to be added to the constant pool's hash table.\n     */\n    private void put(final Item i) {\n        if (index + typeCount > threshold) {\n            int ll = items.length;\n            int nl = ll * 2 + 1;\n            Item[] newItems = new Item[nl];\n            for (int l = ll - 1; l >= 0; --l) {\n                Item j = items[l];\n                while (j != null) {\n                    int index = j.hashCode % newItems.length;\n                    Item k = j.next;\n                    j.next = newItems[index];\n                    newItems[index] = j;\n                    j = k;\n                }\n            }\n            items = newItems;\n            threshold = (int) (nl * 0.75);\n        }\n        int index = i.hashCode % items.length;\n        i.next = items[index];\n        items[index] = i;\n    }\n\n    /**\n     * Puts one byte and two shorts into the constant pool.\n     *\n     * @param b\n     *            a byte.\n     * @param s1\n     *            a short.\n     * @param s2\n     *            another short.\n     */\n    private void put122(final int b, final int s1, final int s2) {\n        pool.put12(b, s1).putShort(s2);\n    }\n\n    /**\n     * Puts two bytes and one short into the constant pool.\n     *\n     * @param b1\n     *            a byte.\n     * @param b2\n     *            another byte.\n     * @param s\n     *            a short.\n     */\n    private void put112(final int b1, final int b2, final int s) {\n        pool.put11(b1, b2).putShort(s);\n    }\n    \n    public SourceWriter getSc() {\n      return sc;\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/Context.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\n\npackage clojure.asm;\n\n/**\n * Information about a class being parsed in a {@link ClassReader}.\n *\n * @author Eric Bruneton\n */\nclass Context {\n\n    /**\n     * Prototypes of the attributes that must be parsed for this class.\n     */\n    Attribute[] attrs;\n\n    /**\n     * The {@link ClassReader} option flags for the parsing of this class.\n     */\n    int flags;\n\n    /**\n     * The buffer used to read strings.\n     */\n    char[] buffer;\n\n    /**\n     * The start index of each bootstrap method.\n     */\n    int[] bootstrapMethods;\n\n    /**\n     * The access flags of the method currently being parsed.\n     */\n    int access;\n\n    /**\n     * The name of the method currently being parsed.\n     */\n    String name;\n\n    /**\n     * The descriptor of the method currently being parsed.\n     */\n    String desc;\n\n    /**\n     * The offset of the latest stack map frame that has been parsed.\n     */\n    int offset;\n\n    /**\n     * The encoding of the latest stack map frame that has been parsed.\n     */\n    int mode;\n\n    /**\n     * The number of locals in the latest stack map frame that has been parsed.\n     */\n    int localCount;\n\n    /**\n     * The number locals in the latest stack map frame that has been parsed,\n     * minus the number of locals in the previous frame.\n     */\n    int localDiff;\n\n    /**\n     * The local values of the latest stack map frame that has been parsed.\n     */\n    Object[] local;\n\n    /**\n     * The stack size of the latest stack map frame that has been parsed.\n     */\n    int stackCount;\n\n    /**\n     * The stack values of the latest stack map frame that has been parsed.\n     */\n    Object[] stack;\n}"
  },
  {
    "path": "src/jvm/clojure/asm/Edge.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * An edge in the control flow graph of a method body. See {@link Label Label}.\n *\n * @author Eric Bruneton\n */\nclass Edge {\n\n    /**\n     * Denotes a normal control flow graph edge.\n     */\n    static final int NORMAL = 0;\n\n    /**\n     * Denotes a control flow graph edge corresponding to an exception handler.\n     * More precisely any {@link Edge} whose {@link #info} is strictly positive\n     * corresponds to an exception handler. The actual value of {@link #info} is\n     * the index, in the {@link ClassWriter} type table, of the exception that\n     * is catched.\n     */\n    static final int EXCEPTION = 0x7FFFFFFF;\n\n    /**\n     * Information about this control flow graph edge. If\n     * {@link ClassWriter#COMPUTE_MAXS} is used this field is the (relative)\n     * stack size in the basic block from which this edge originates. This size\n     * is equal to the stack size at the \"jump\" instruction to which this edge\n     * corresponds, relatively to the stack size at the beginning of the\n     * originating basic block. If {@link ClassWriter#COMPUTE_FRAMES} is used,\n     * this field is the kind of this control flow graph edge (i.e. NORMAL or\n     * EXCEPTION).\n     */\n    int info;\n\n    /**\n     * The successor block of the basic block from which this edge originates.\n     */\n    Label successor;\n\n    /**\n     * The next edge in the list of successors of the originating basic block.\n     * See {@link Label#successors successors}.\n     */\n    Edge next;\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/FieldVisitor.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * A visitor to visit a Java field. The methods of this class must be called in\n * the following order: ( <tt>visitAnnotation</tt> | <tt>visitAttribute</tt> )*\n * <tt>visitEnd</tt>.\n *\n * @author Eric Bruneton\n */\npublic abstract class FieldVisitor {\n\n    /**\n     * The ASM API version implemented by this visitor. The value of this field\n     * must be one of {@link Opcodes#ASM4}.\n     */\n    protected final int api;\n\n    /**\n     * The field visitor to which this visitor must delegate method calls. May\n     * be null.\n     */\n    protected FieldVisitor fv;\n\n    /**\n     * Constructs a new {@link FieldVisitor}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     */\n    public FieldVisitor(final int api) {\n        this(api, null);\n    }\n\n    /**\n     * Constructs a new {@link FieldVisitor}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     * @param fv\n     *            the field visitor to which this visitor must delegate method\n     *            calls. May be null.\n     */\n    public FieldVisitor(final int api, final FieldVisitor fv) {\n        if (api != Opcodes.ASM4) {\n            throw new IllegalArgumentException();\n        }\n        this.api = api;\n        this.fv = fv;\n    }\n\n    /**\n     * Visits an annotation of the field.\n     *\n     * @param desc\n     *            the class descriptor of the annotation class.\n     * @param visible\n     *            <tt>true</tt> if the annotation is visible at runtime.\n     * @return a visitor to visit the annotation values, or <tt>null</tt> if\n     *         this visitor is not interested in visiting this annotation.\n     */\n    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {\n        if (fv != null) {\n            return fv.visitAnnotation(desc, visible);\n        }\n        return null;\n    }\n\n    /**\n     * Visits a non standard attribute of the field.\n     *\n     * @param attr\n     *            an attribute.\n     */\n    public void visitAttribute(Attribute attr) {\n        if (fv != null) {\n            fv.visitAttribute(attr);\n        }\n    }\n\n    /**\n     * Visits the end of the field. This method, which is the last one to be\n     * called, is used to inform the visitor that all the annotations and\n     * attributes of the field have been visited.\n     */\n    public void visitEnd() {\n        if (fv != null) {\n            fv.visitEnd();\n        }\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/FieldWriter.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * An {@link FieldVisitor} that generates Java fields in bytecode form.\n *\n * @author Eric Bruneton\n */\nfinal class FieldWriter extends FieldVisitor {\n\n    /**\n     * The class writer to which this field must be added.\n     */\n    private final ClassWriter cw;\n\n    /**\n     * Access flags of this field.\n     */\n    private final int access;\n\n    /**\n     * The index of the constant pool item that contains the name of this\n     * method.\n     */\n    private final int name;\n\n    /**\n     * The index of the constant pool item that contains the descriptor of this\n     * field.\n     */\n    private final int desc;\n\n    /**\n     * The index of the constant pool item that contains the signature of this\n     * field.\n     */\n    private int signature;\n\n    /**\n     * The index of the constant pool item that contains the constant value of\n     * this field.\n     */\n    private int value;\n\n    /**\n     * The runtime visible annotations of this field. May be <tt>null</tt>.\n     */\n    private AnnotationWriter anns;\n\n    /**\n     * The runtime invisible annotations of this field. May be <tt>null</tt>.\n     */\n    private AnnotationWriter ianns;\n\n    /**\n     * The non standard attributes of this field. May be <tt>null</tt>.\n     */\n    private Attribute attrs;\n\n    // ------------------------------------------------------------------------\n    // Constructor\n    // ------------------------------------------------------------------------\n\n    /**\n     * Constructs a new {@link FieldWriter}.\n     *\n     * @param cw\n     *            the class writer to which this field must be added.\n     * @param access\n     *            the field's access flags (see {@link Opcodes}).\n     * @param name\n     *            the field's name.\n     * @param desc\n     *            the field's descriptor (see {@link Type}).\n     * @param signature\n     *            the field's signature. May be <tt>null</tt>.\n     * @param value\n     *            the field's constant value. May be <tt>null</tt>.\n     */\n    FieldWriter(final ClassWriter cw, final int access, final String name,\n            final String desc, final String signature, final Object value) {\n        super(Opcodes.ASM4);\n        if (cw.firstField == null) {\n            cw.firstField = this;\n        } else {\n            cw.lastField.fv = this;\n        }\n        cw.lastField = this;\n        this.cw = cw;\n        this.access = access;\n        this.name = cw.newUTF8(name);\n        this.desc = cw.newUTF8(desc);\n        if (ClassReader.SIGNATURES && signature != null) {\n            this.signature = cw.newUTF8(signature);\n        }\n        if (value != null) {\n            this.value = cw.newConstItem(value).index;\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Implementation of the FieldVisitor abstract class\n    // ------------------------------------------------------------------------\n\n    @Override\n    public AnnotationVisitor visitAnnotation(final String desc,\n            final boolean visible) {\n        if (!ClassReader.ANNOTATIONS) {\n            return null;\n        }\n        ByteVector bv = new ByteVector();\n        // write type, and reserve space for values count\n        bv.putShort(cw.newUTF8(desc)).putShort(0);\n        AnnotationWriter aw = new AnnotationWriter(cw, true, bv, bv, 2);\n        if (visible) {\n            aw.next = anns;\n            anns = aw;\n        } else {\n            aw.next = ianns;\n            ianns = aw;\n        }\n        return aw;\n    }\n\n    @Override\n    public void visitAttribute(final Attribute attr) {\n        attr.next = attrs;\n        attrs = attr;\n    }\n\n    @Override\n    public void visitEnd() {\n    }\n\n    // ------------------------------------------------------------------------\n    // Utility methods\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns the size of this field.\n     *\n     * @return the size of this field.\n     */\n    int getSize() {\n        int size = 8;\n        if (value != 0) {\n            cw.newUTF8(\"ConstantValue\");\n            size += 8;\n        }\n        if ((access & Opcodes.ACC_SYNTHETIC) != 0) {\n            if ((cw.version & 0xFFFF) < Opcodes.V1_5\n                    || (access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) != 0) {\n                cw.newUTF8(\"Synthetic\");\n                size += 6;\n            }\n        }\n        if ((access & Opcodes.ACC_DEPRECATED) != 0) {\n            cw.newUTF8(\"Deprecated\");\n            size += 6;\n        }\n        if (ClassReader.SIGNATURES && signature != 0) {\n            cw.newUTF8(\"Signature\");\n            size += 8;\n        }\n        if (ClassReader.ANNOTATIONS && anns != null) {\n            cw.newUTF8(\"RuntimeVisibleAnnotations\");\n            size += 8 + anns.getSize();\n        }\n        if (ClassReader.ANNOTATIONS && ianns != null) {\n            cw.newUTF8(\"RuntimeInvisibleAnnotations\");\n            size += 8 + ianns.getSize();\n        }\n        if (attrs != null) {\n            size += attrs.getSize(cw, null, 0, -1, -1);\n        }\n        return size;\n    }\n\n    /**\n     * Puts the content of this field into the given byte vector.\n     *\n     * @param out\n     *            where the content of this field must be put.\n     */\n    void put(final ByteVector out) {\n        final int FACTOR = ClassWriter.TO_ACC_SYNTHETIC;\n        int mask = Opcodes.ACC_DEPRECATED | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE\n                | ((access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) / FACTOR);\n        out.putShort(access & ~mask).putShort(name).putShort(desc);\n        int attributeCount = 0;\n        if (value != 0) {\n            ++attributeCount;\n        }\n        if ((access & Opcodes.ACC_SYNTHETIC) != 0) {\n            if ((cw.version & 0xFFFF) < Opcodes.V1_5\n                    || (access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) != 0) {\n                ++attributeCount;\n            }\n        }\n        if ((access & Opcodes.ACC_DEPRECATED) != 0) {\n            ++attributeCount;\n        }\n        if (ClassReader.SIGNATURES && signature != 0) {\n            ++attributeCount;\n        }\n        if (ClassReader.ANNOTATIONS && anns != null) {\n            ++attributeCount;\n        }\n        if (ClassReader.ANNOTATIONS && ianns != null) {\n            ++attributeCount;\n        }\n        if (attrs != null) {\n            attributeCount += attrs.getCount();\n        }\n        out.putShort(attributeCount);\n        if (value != 0) {\n            out.putShort(cw.newUTF8(\"ConstantValue\"));\n            out.putInt(2).putShort(value);\n        }\n        if ((access & Opcodes.ACC_SYNTHETIC) != 0) {\n            if ((cw.version & 0xFFFF) < Opcodes.V1_5\n                    || (access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) != 0) {\n                out.putShort(cw.newUTF8(\"Synthetic\")).putInt(0);\n            }\n        }\n        if ((access & Opcodes.ACC_DEPRECATED) != 0) {\n            out.putShort(cw.newUTF8(\"Deprecated\")).putInt(0);\n        }\n        if (ClassReader.SIGNATURES && signature != 0) {\n            out.putShort(cw.newUTF8(\"Signature\"));\n            out.putInt(2).putShort(signature);\n        }\n        if (ClassReader.ANNOTATIONS && anns != null) {\n            out.putShort(cw.newUTF8(\"RuntimeVisibleAnnotations\"));\n            anns.put(out);\n        }\n        if (ClassReader.ANNOTATIONS && ianns != null) {\n            out.putShort(cw.newUTF8(\"RuntimeInvisibleAnnotations\"));\n            ianns.put(out);\n        }\n        if (attrs != null) {\n            attrs.put(cw, null, 0, -1, -1, out);\n        }\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/Frame.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * Information about the input and output stack map frames of a basic block.\n *\n * @author Eric Bruneton\n */\nfinal class Frame {\n\n    /*\n     * Frames are computed in a two steps process: during the visit of each\n     * instruction, the state of the frame at the end of current basic block is\n     * updated by simulating the action of the instruction on the previous state\n     * of this so called \"output frame\". In visitMaxs, a fix point algorithm is\n     * used to compute the \"input frame\" of each basic block, i.e. the stack map\n     * frame at the beginning of the basic block, starting from the input frame\n     * of the first basic block (which is computed from the method descriptor),\n     * and by using the previously computed output frames to compute the input\n     * state of the other blocks.\n     *\n     * All output and input frames are stored as arrays of integers. Reference\n     * and array types are represented by an index into a type table (which is\n     * not the same as the constant pool of the class, in order to avoid adding\n     * unnecessary constants in the pool - not all computed frames will end up\n     * being stored in the stack map table). This allows very fast type\n     * comparisons.\n     *\n     * Output stack map frames are computed relatively to the input frame of the\n     * basic block, which is not yet known when output frames are computed. It\n     * is therefore necessary to be able to represent abstract types such as\n     * \"the type at position x in the input frame locals\" or \"the type at\n     * position x from the top of the input frame stack\" or even \"the type at\n     * position x in the input frame, with y more (or less) array dimensions\".\n     * This explains the rather complicated type format used in output frames.\n     *\n     * This format is the following: DIM KIND VALUE (4, 4 and 24 bits). DIM is a\n     * signed number of array dimensions (from -8 to 7). KIND is either BASE,\n     * LOCAL or STACK. BASE is used for types that are not relative to the input\n     * frame. LOCAL is used for types that are relative to the input local\n     * variable types. STACK is used for types that are relative to the input\n     * stack types. VALUE depends on KIND. For LOCAL types, it is an index in\n     * the input local variable types. For STACK types, it is a position\n     * relatively to the top of input frame stack. For BASE types, it is either\n     * one of the constants defined in FrameVisitor, or for OBJECT and\n     * UNINITIALIZED types, a tag and an index in the type table.\n     *\n     * Output frames can contain types of any kind and with a positive or\n     * negative dimension (and even unassigned types, represented by 0 - which\n     * does not correspond to any valid type value). Input frames can only\n     * contain BASE types of positive or null dimension. In all cases the type\n     * table contains only internal type names (array type descriptors are\n     * forbidden - dimensions must be represented through the DIM field).\n     *\n     * The LONG and DOUBLE types are always represented by using two slots (LONG\n     * + TOP or DOUBLE + TOP), for local variable types as well as in the\n     * operand stack. This is necessary to be able to simulate DUPx_y\n     * instructions, whose effect would be dependent on the actual type values\n     * if types were always represented by a single slot in the stack (and this\n     * is not possible, since actual type values are not always known - cf LOCAL\n     * and STACK type kinds).\n     */\n\n    /**\n     * Mask to get the dimension of a frame type. This dimension is a signed\n     * integer between -8 and 7.\n     */\n    static final int DIM = 0xF0000000;\n\n    /**\n     * Constant to be added to a type to get a type with one more dimension.\n     */\n    static final int ARRAY_OF = 0x10000000;\n\n    /**\n     * Constant to be added to a type to get a type with one less dimension.\n     */\n    static final int ELEMENT_OF = 0xF0000000;\n\n    /**\n     * Mask to get the kind of a frame type.\n     *\n     * @see #BASE\n     * @see #LOCAL\n     * @see #STACK\n     */\n    static final int KIND = 0xF000000;\n\n    /**\n     * Flag used for LOCAL and STACK types. Indicates that if this type happens\n     * to be a long or double type (during the computations of input frames),\n     * then it must be set to TOP because the second word of this value has been\n     * reused to store other data in the basic block. Hence the first word no\n     * longer stores a valid long or double value.\n     */\n    static final int TOP_IF_LONG_OR_DOUBLE = 0x800000;\n\n    /**\n     * Mask to get the value of a frame type.\n     */\n    static final int VALUE = 0x7FFFFF;\n\n    /**\n     * Mask to get the kind of base types.\n     */\n    static final int BASE_KIND = 0xFF00000;\n\n    /**\n     * Mask to get the value of base types.\n     */\n    static final int BASE_VALUE = 0xFFFFF;\n\n    /**\n     * Kind of the types that are not relative to an input stack map frame.\n     */\n    static final int BASE = 0x1000000;\n\n    /**\n     * Base kind of the base reference types. The BASE_VALUE of such types is an\n     * index into the type table.\n     */\n    static final int OBJECT = BASE | 0x700000;\n\n    /**\n     * Base kind of the uninitialized base types. The BASE_VALUE of such types\n     * in an index into the type table (the Item at that index contains both an\n     * instruction offset and an internal class name).\n     */\n    static final int UNINITIALIZED = BASE | 0x800000;\n\n    /**\n     * Kind of the types that are relative to the local variable types of an\n     * input stack map frame. The value of such types is a local variable index.\n     */\n    private static final int LOCAL = 0x2000000;\n\n    /**\n     * Kind of the the types that are relative to the stack of an input stack\n     * map frame. The value of such types is a position relatively to the top of\n     * this stack.\n     */\n    private static final int STACK = 0x3000000;\n\n    /**\n     * The TOP type. This is a BASE type.\n     */\n    static final int TOP = BASE | 0;\n\n    /**\n     * The BOOLEAN type. This is a BASE type mainly used for array types.\n     */\n    static final int BOOLEAN = BASE | 9;\n\n    /**\n     * The BYTE type. This is a BASE type mainly used for array types.\n     */\n    static final int BYTE = BASE | 10;\n\n    /**\n     * The CHAR type. This is a BASE type mainly used for array types.\n     */\n    static final int CHAR = BASE | 11;\n\n    /**\n     * The SHORT type. This is a BASE type mainly used for array types.\n     */\n    static final int SHORT = BASE | 12;\n\n    /**\n     * The INTEGER type. This is a BASE type.\n     */\n    static final int INTEGER = BASE | 1;\n\n    /**\n     * The FLOAT type. This is a BASE type.\n     */\n    static final int FLOAT = BASE | 2;\n\n    /**\n     * The DOUBLE type. This is a BASE type.\n     */\n    static final int DOUBLE = BASE | 3;\n\n    /**\n     * The LONG type. This is a BASE type.\n     */\n    static final int LONG = BASE | 4;\n\n    /**\n     * The NULL type. This is a BASE type.\n     */\n    static final int NULL = BASE | 5;\n\n    /**\n     * The UNINITIALIZED_THIS type. This is a BASE type.\n     */\n    static final int UNINITIALIZED_THIS = BASE | 6;\n\n    /**\n     * The stack size variation corresponding to each JVM instruction. This\n     * stack variation is equal to the size of the values produced by an\n     * instruction, minus the size of the values consumed by this instruction.\n     */\n    static final int[] SIZE;\n\n    /**\n     * Computes the stack size variation corresponding to each JVM instruction.\n     */\n    static {\n        int i;\n        int[] b = new int[202];\n        String s = \"EFFFFFFFFGGFFFGGFFFEEFGFGFEEEEEEEEEEEEEEEEEEEEDEDEDDDDD\"\n                + \"CDCDEEEEEEEEEEEEEEEEEEEEBABABBBBDCFFFGGGEDCDCDCDCDCDCDCDCD\"\n                + \"CDCEEEEDDDDDDDCDCDCEFEFDDEEFFDEDEEEBDDBBDDDDDDCCCCCCCCEFED\"\n                + \"DDCDCDEEEEEEEEEEFEEEEEEDDEEDDEE\";\n        for (i = 0; i < b.length; ++i) {\n            b[i] = s.charAt(i) - 'E';\n        }\n        SIZE = b;\n\n        // code to generate the above string\n        //\n        // int NA = 0; // not applicable (unused opcode or variable size opcode)\n        //\n        // b = new int[] {\n        // 0, //NOP, // visitInsn\n        // 1, //ACONST_NULL, // -\n        // 1, //ICONST_M1, // -\n        // 1, //ICONST_0, // -\n        // 1, //ICONST_1, // -\n        // 1, //ICONST_2, // -\n        // 1, //ICONST_3, // -\n        // 1, //ICONST_4, // -\n        // 1, //ICONST_5, // -\n        // 2, //LCONST_0, // -\n        // 2, //LCONST_1, // -\n        // 1, //FCONST_0, // -\n        // 1, //FCONST_1, // -\n        // 1, //FCONST_2, // -\n        // 2, //DCONST_0, // -\n        // 2, //DCONST_1, // -\n        // 1, //BIPUSH, // visitIntInsn\n        // 1, //SIPUSH, // -\n        // 1, //LDC, // visitLdcInsn\n        // NA, //LDC_W, // -\n        // NA, //LDC2_W, // -\n        // 1, //ILOAD, // visitVarInsn\n        // 2, //LLOAD, // -\n        // 1, //FLOAD, // -\n        // 2, //DLOAD, // -\n        // 1, //ALOAD, // -\n        // NA, //ILOAD_0, // -\n        // NA, //ILOAD_1, // -\n        // NA, //ILOAD_2, // -\n        // NA, //ILOAD_3, // -\n        // NA, //LLOAD_0, // -\n        // NA, //LLOAD_1, // -\n        // NA, //LLOAD_2, // -\n        // NA, //LLOAD_3, // -\n        // NA, //FLOAD_0, // -\n        // NA, //FLOAD_1, // -\n        // NA, //FLOAD_2, // -\n        // NA, //FLOAD_3, // -\n        // NA, //DLOAD_0, // -\n        // NA, //DLOAD_1, // -\n        // NA, //DLOAD_2, // -\n        // NA, //DLOAD_3, // -\n        // NA, //ALOAD_0, // -\n        // NA, //ALOAD_1, // -\n        // NA, //ALOAD_2, // -\n        // NA, //ALOAD_3, // -\n        // -1, //IALOAD, // visitInsn\n        // 0, //LALOAD, // -\n        // -1, //FALOAD, // -\n        // 0, //DALOAD, // -\n        // -1, //AALOAD, // -\n        // -1, //BALOAD, // -\n        // -1, //CALOAD, // -\n        // -1, //SALOAD, // -\n        // -1, //ISTORE, // visitVarInsn\n        // -2, //LSTORE, // -\n        // -1, //FSTORE, // -\n        // -2, //DSTORE, // -\n        // -1, //ASTORE, // -\n        // NA, //ISTORE_0, // -\n        // NA, //ISTORE_1, // -\n        // NA, //ISTORE_2, // -\n        // NA, //ISTORE_3, // -\n        // NA, //LSTORE_0, // -\n        // NA, //LSTORE_1, // -\n        // NA, //LSTORE_2, // -\n        // NA, //LSTORE_3, // -\n        // NA, //FSTORE_0, // -\n        // NA, //FSTORE_1, // -\n        // NA, //FSTORE_2, // -\n        // NA, //FSTORE_3, // -\n        // NA, //DSTORE_0, // -\n        // NA, //DSTORE_1, // -\n        // NA, //DSTORE_2, // -\n        // NA, //DSTORE_3, // -\n        // NA, //ASTORE_0, // -\n        // NA, //ASTORE_1, // -\n        // NA, //ASTORE_2, // -\n        // NA, //ASTORE_3, // -\n        // -3, //IASTORE, // visitInsn\n        // -4, //LASTORE, // -\n        // -3, //FASTORE, // -\n        // -4, //DASTORE, // -\n        // -3, //AASTORE, // -\n        // -3, //BASTORE, // -\n        // -3, //CASTORE, // -\n        // -3, //SASTORE, // -\n        // -1, //POP, // -\n        // -2, //POP2, // -\n        // 1, //DUP, // -\n        // 1, //DUP_X1, // -\n        // 1, //DUP_X2, // -\n        // 2, //DUP2, // -\n        // 2, //DUP2_X1, // -\n        // 2, //DUP2_X2, // -\n        // 0, //SWAP, // -\n        // -1, //IADD, // -\n        // -2, //LADD, // -\n        // -1, //FADD, // -\n        // -2, //DADD, // -\n        // -1, //ISUB, // -\n        // -2, //LSUB, // -\n        // -1, //FSUB, // -\n        // -2, //DSUB, // -\n        // -1, //IMUL, // -\n        // -2, //LMUL, // -\n        // -1, //FMUL, // -\n        // -2, //DMUL, // -\n        // -1, //IDIV, // -\n        // -2, //LDIV, // -\n        // -1, //FDIV, // -\n        // -2, //DDIV, // -\n        // -1, //IREM, // -\n        // -2, //LREM, // -\n        // -1, //FREM, // -\n        // -2, //DREM, // -\n        // 0, //INEG, // -\n        // 0, //LNEG, // -\n        // 0, //FNEG, // -\n        // 0, //DNEG, // -\n        // -1, //ISHL, // -\n        // -1, //LSHL, // -\n        // -1, //ISHR, // -\n        // -1, //LSHR, // -\n        // -1, //IUSHR, // -\n        // -1, //LUSHR, // -\n        // -1, //IAND, // -\n        // -2, //LAND, // -\n        // -1, //IOR, // -\n        // -2, //LOR, // -\n        // -1, //IXOR, // -\n        // -2, //LXOR, // -\n        // 0, //IINC, // visitIincInsn\n        // 1, //I2L, // visitInsn\n        // 0, //I2F, // -\n        // 1, //I2D, // -\n        // -1, //L2I, // -\n        // -1, //L2F, // -\n        // 0, //L2D, // -\n        // 0, //F2I, // -\n        // 1, //F2L, // -\n        // 1, //F2D, // -\n        // -1, //D2I, // -\n        // 0, //D2L, // -\n        // -1, //D2F, // -\n        // 0, //I2B, // -\n        // 0, //I2C, // -\n        // 0, //I2S, // -\n        // -3, //LCMP, // -\n        // -1, //FCMPL, // -\n        // -1, //FCMPG, // -\n        // -3, //DCMPL, // -\n        // -3, //DCMPG, // -\n        // -1, //IFEQ, // visitJumpInsn\n        // -1, //IFNE, // -\n        // -1, //IFLT, // -\n        // -1, //IFGE, // -\n        // -1, //IFGT, // -\n        // -1, //IFLE, // -\n        // -2, //IF_ICMPEQ, // -\n        // -2, //IF_ICMPNE, // -\n        // -2, //IF_ICMPLT, // -\n        // -2, //IF_ICMPGE, // -\n        // -2, //IF_ICMPGT, // -\n        // -2, //IF_ICMPLE, // -\n        // -2, //IF_ACMPEQ, // -\n        // -2, //IF_ACMPNE, // -\n        // 0, //GOTO, // -\n        // 1, //JSR, // -\n        // 0, //RET, // visitVarInsn\n        // -1, //TABLESWITCH, // visiTableSwitchInsn\n        // -1, //LOOKUPSWITCH, // visitLookupSwitch\n        // -1, //IRETURN, // visitInsn\n        // -2, //LRETURN, // -\n        // -1, //FRETURN, // -\n        // -2, //DRETURN, // -\n        // -1, //ARETURN, // -\n        // 0, //RETURN, // -\n        // NA, //GETSTATIC, // visitFieldInsn\n        // NA, //PUTSTATIC, // -\n        // NA, //GETFIELD, // -\n        // NA, //PUTFIELD, // -\n        // NA, //INVOKEVIRTUAL, // visitMethodInsn\n        // NA, //INVOKESPECIAL, // -\n        // NA, //INVOKESTATIC, // -\n        // NA, //INVOKEINTERFACE, // -\n        // NA, //INVOKEDYNAMIC, // visitInvokeDynamicInsn\n        // 1, //NEW, // visitTypeInsn\n        // 0, //NEWARRAY, // visitIntInsn\n        // 0, //ANEWARRAY, // visitTypeInsn\n        // 0, //ARRAYLENGTH, // visitInsn\n        // NA, //ATHROW, // -\n        // 0, //CHECKCAST, // visitTypeInsn\n        // 0, //INSTANCEOF, // -\n        // -1, //MONITORENTER, // visitInsn\n        // -1, //MONITOREXIT, // -\n        // NA, //WIDE, // NOT VISITED\n        // NA, //MULTIANEWARRAY, // visitMultiANewArrayInsn\n        // -1, //IFNULL, // visitJumpInsn\n        // -1, //IFNONNULL, // -\n        // NA, //GOTO_W, // -\n        // NA, //JSR_W, // -\n        // };\n        // for (i = 0; i < b.length; ++i) {\n        // System.err.print((char)('E' + b[i]));\n        // }\n        // System.err.println();\n    }\n\n    /**\n     * The label (i.e. basic block) to which these input and output stack map\n     * frames correspond.\n     */\n    Label owner;\n\n    /**\n     * The input stack map frame locals.\n     */\n    int[] inputLocals;\n\n    /**\n     * The input stack map frame stack.\n     */\n    int[] inputStack;\n\n    /**\n     * The output stack map frame locals.\n     */\n    private int[] outputLocals;\n\n    /**\n     * The output stack map frame stack.\n     */\n    private int[] outputStack;\n\n    /**\n     * Relative size of the output stack. The exact semantics of this field\n     * depends on the algorithm that is used.\n     *\n     * When only the maximum stack size is computed, this field is the size of\n     * the output stack relatively to the top of the input stack.\n     *\n     * When the stack map frames are completely computed, this field is the\n     * actual number of types in {@link #outputStack}.\n     */\n    private int outputStackTop;\n\n    /**\n     * Number of types that are initialized in the basic block.\n     *\n     * @see #initializations\n     */\n    private int initializationCount;\n\n    /**\n     * The types that are initialized in the basic block. A constructor\n     * invocation on an UNINITIALIZED or UNINITIALIZED_THIS type must replace\n     * <i>every occurence</i> of this type in the local variables and in the\n     * operand stack. This cannot be done during the first phase of the\n     * algorithm since, during this phase, the local variables and the operand\n     * stack are not completely computed. It is therefore necessary to store the\n     * types on which constructors are invoked in the basic block, in order to\n     * do this replacement during the second phase of the algorithm, where the\n     * frames are fully computed. Note that this array can contain types that\n     * are relative to input locals or to the input stack (see below for the\n     * description of the algorithm).\n     */\n    private int[] initializations;\n\n    /**\n     * Returns the output frame local variable type at the given index.\n     *\n     * @param local\n     *            the index of the local that must be returned.\n     * @return the output frame local variable type at the given index.\n     */\n    private int get(final int local) {\n        if (outputLocals == null || local >= outputLocals.length) {\n            // this local has never been assigned in this basic block,\n            // so it is still equal to its value in the input frame\n            return LOCAL | local;\n        } else {\n            int type = outputLocals[local];\n            if (type == 0) {\n                // this local has never been assigned in this basic block,\n                // so it is still equal to its value in the input frame\n                type = outputLocals[local] = LOCAL | local;\n            }\n            return type;\n        }\n    }\n\n    /**\n     * Sets the output frame local variable type at the given index.\n     *\n     * @param local\n     *            the index of the local that must be set.\n     * @param type\n     *            the value of the local that must be set.\n     */\n    private void set(final int local, final int type) {\n        // creates and/or resizes the output local variables array if necessary\n        if (outputLocals == null) {\n            outputLocals = new int[10];\n        }\n        int n = outputLocals.length;\n        if (local >= n) {\n            int[] t = new int[Math.max(local + 1, 2 * n)];\n            System.arraycopy(outputLocals, 0, t, 0, n);\n            outputLocals = t;\n        }\n        // sets the local variable\n        outputLocals[local] = type;\n    }\n\n    /**\n     * Pushes a new type onto the output frame stack.\n     *\n     * @param type\n     *            the type that must be pushed.\n     */\n    private void push(final int type) {\n        // creates and/or resizes the output stack array if necessary\n        if (outputStack == null) {\n            outputStack = new int[10];\n        }\n        int n = outputStack.length;\n        if (outputStackTop >= n) {\n            int[] t = new int[Math.max(outputStackTop + 1, 2 * n)];\n            System.arraycopy(outputStack, 0, t, 0, n);\n            outputStack = t;\n        }\n        // pushes the type on the output stack\n        outputStack[outputStackTop++] = type;\n        // updates the maximun height reached by the output stack, if needed\n        int top = owner.inputStackTop + outputStackTop;\n        if (top > owner.outputStackMax) {\n            owner.outputStackMax = top;\n        }\n    }\n\n    /**\n     * Pushes a new type onto the output frame stack.\n     *\n     * @param cw\n     *            the ClassWriter to which this label belongs.\n     * @param desc\n     *            the descriptor of the type to be pushed. Can also be a method\n     *            descriptor (in this case this method pushes its return type\n     *            onto the output frame stack).\n     */\n    private void push(final ClassWriter cw, final String desc) {\n        int type = type(cw, desc);\n        if (type != 0) {\n            push(type);\n            if (type == LONG || type == DOUBLE) {\n                push(TOP);\n            }\n        }\n    }\n\n    /**\n     * Returns the int encoding of the given type.\n     *\n     * @param cw\n     *            the ClassWriter to which this label belongs.\n     * @param desc\n     *            a type descriptor.\n     * @return the int encoding of the given type.\n     */\n    private static int type(final ClassWriter cw, final String desc) {\n        String t;\n        int index = desc.charAt(0) == '(' ? desc.indexOf(')') + 1 : 0;\n        switch (desc.charAt(index)) {\n        case 'V':\n            return 0;\n        case 'Z':\n        case 'C':\n        case 'B':\n        case 'S':\n        case 'I':\n            return INTEGER;\n        case 'F':\n            return FLOAT;\n        case 'J':\n            return LONG;\n        case 'D':\n            return DOUBLE;\n        case 'L':\n            // stores the internal name, not the descriptor!\n            t = desc.substring(index + 1, desc.length() - 1);\n            return OBJECT | cw.addType(t);\n            // case '[':\n        default:\n            // extracts the dimensions and the element type\n            int data;\n            int dims = index + 1;\n            while (desc.charAt(dims) == '[') {\n                ++dims;\n            }\n            switch (desc.charAt(dims)) {\n            case 'Z':\n                data = BOOLEAN;\n                break;\n            case 'C':\n                data = CHAR;\n                break;\n            case 'B':\n                data = BYTE;\n                break;\n            case 'S':\n                data = SHORT;\n                break;\n            case 'I':\n                data = INTEGER;\n                break;\n            case 'F':\n                data = FLOAT;\n                break;\n            case 'J':\n                data = LONG;\n                break;\n            case 'D':\n                data = DOUBLE;\n                break;\n            // case 'L':\n            default:\n                // stores the internal name, not the descriptor\n                t = desc.substring(dims + 1, desc.length() - 1);\n                data = OBJECT | cw.addType(t);\n            }\n            return (dims - index) << 28 | data;\n        }\n    }\n\n    /**\n     * Pops a type from the output frame stack and returns its value.\n     *\n     * @return the type that has been popped from the output frame stack.\n     */\n    private int pop() {\n        if (outputStackTop > 0) {\n            return outputStack[--outputStackTop];\n        } else {\n            // if the output frame stack is empty, pops from the input stack\n            return STACK | -(--owner.inputStackTop);\n        }\n    }\n\n    /**\n     * Pops the given number of types from the output frame stack.\n     *\n     * @param elements\n     *            the number of types that must be popped.\n     */\n    private void pop(final int elements) {\n        if (outputStackTop >= elements) {\n            outputStackTop -= elements;\n        } else {\n            // if the number of elements to be popped is greater than the number\n            // of elements in the output stack, clear it, and pops the remaining\n            // elements from the input stack.\n            owner.inputStackTop -= elements - outputStackTop;\n            outputStackTop = 0;\n        }\n    }\n\n    /**\n     * Pops a type from the output frame stack.\n     *\n     * @param desc\n     *            the descriptor of the type to be popped. Can also be a method\n     *            descriptor (in this case this method pops the types\n     *            corresponding to the method arguments).\n     */\n    private void pop(final String desc) {\n        char c = desc.charAt(0);\n        if (c == '(') {\n            pop((Type.getArgumentsAndReturnSizes(desc) >> 2) - 1);\n        } else if (c == 'J' || c == 'D') {\n            pop(2);\n        } else {\n            pop(1);\n        }\n    }\n\n    /**\n     * Adds a new type to the list of types on which a constructor is invoked in\n     * the basic block.\n     *\n     * @param var\n     *            a type on a which a constructor is invoked.\n     */\n    private void init(final int var) {\n        // creates and/or resizes the initializations array if necessary\n        if (initializations == null) {\n            initializations = new int[2];\n        }\n        int n = initializations.length;\n        if (initializationCount >= n) {\n            int[] t = new int[Math.max(initializationCount + 1, 2 * n)];\n            System.arraycopy(initializations, 0, t, 0, n);\n            initializations = t;\n        }\n        // stores the type to be initialized\n        initializations[initializationCount++] = var;\n    }\n\n    /**\n     * Replaces the given type with the appropriate type if it is one of the\n     * types on which a constructor is invoked in the basic block.\n     *\n     * @param cw\n     *            the ClassWriter to which this label belongs.\n     * @param t\n     *            a type\n     * @return t or, if t is one of the types on which a constructor is invoked\n     *         in the basic block, the type corresponding to this constructor.\n     */\n    private int init(final ClassWriter cw, final int t) {\n        int s;\n        if (t == UNINITIALIZED_THIS) {\n            s = OBJECT | cw.addType(cw.thisName);\n        } else if ((t & (DIM | BASE_KIND)) == UNINITIALIZED) {\n            String type = cw.typeTable[t & BASE_VALUE].strVal1;\n            s = OBJECT | cw.addType(type);\n        } else {\n            return t;\n        }\n        for (int j = 0; j < initializationCount; ++j) {\n            int u = initializations[j];\n            int dim = u & DIM;\n            int kind = u & KIND;\n            if (kind == LOCAL) {\n                u = dim + inputLocals[u & VALUE];\n            } else if (kind == STACK) {\n                u = dim + inputStack[inputStack.length - (u & VALUE)];\n            }\n            if (t == u) {\n                return s;\n            }\n        }\n        return t;\n    }\n\n    /**\n     * Initializes the input frame of the first basic block from the method\n     * descriptor.\n     *\n     * @param cw\n     *            the ClassWriter to which this label belongs.\n     * @param access\n     *            the access flags of the method to which this label belongs.\n     * @param args\n     *            the formal parameter types of this method.\n     * @param maxLocals\n     *            the maximum number of local variables of this method.\n     */\n    void initInputFrame(final ClassWriter cw, final int access,\n            final Type[] args, final int maxLocals) {\n        inputLocals = new int[maxLocals];\n        inputStack = new int[0];\n        int i = 0;\n        if ((access & Opcodes.ACC_STATIC) == 0) {\n            if ((access & MethodWriter.ACC_CONSTRUCTOR) == 0) {\n                inputLocals[i++] = OBJECT | cw.addType(cw.thisName);\n            } else {\n                inputLocals[i++] = UNINITIALIZED_THIS;\n            }\n        }\n        for (int j = 0; j < args.length; ++j) {\n            int t = type(cw, args[j].getDescriptor());\n            inputLocals[i++] = t;\n            if (t == LONG || t == DOUBLE) {\n                inputLocals[i++] = TOP;\n            }\n        }\n        while (i < maxLocals) {\n            inputLocals[i++] = TOP;\n        }\n    }\n\n    /**\n     * Simulates the action of the given instruction on the output stack frame.\n     *\n     * @param opcode\n     *            the opcode of the instruction.\n     * @param arg\n     *            the operand of the instruction, if any.\n     * @param cw\n     *            the class writer to which this label belongs.\n     * @param item\n     *            the operand of the instructions, if any.\n     */\n    void execute(final int opcode, final int arg, final ClassWriter cw,\n            final Item item) {\n        int t1, t2, t3, t4;\n        switch (opcode) {\n        case Opcodes.NOP:\n        case Opcodes.INEG:\n        case Opcodes.LNEG:\n        case Opcodes.FNEG:\n        case Opcodes.DNEG:\n        case Opcodes.I2B:\n        case Opcodes.I2C:\n        case Opcodes.I2S:\n        case Opcodes.GOTO:\n        case Opcodes.RETURN:\n            break;\n        case Opcodes.ACONST_NULL:\n            push(NULL);\n            break;\n        case Opcodes.ICONST_M1:\n        case Opcodes.ICONST_0:\n        case Opcodes.ICONST_1:\n        case Opcodes.ICONST_2:\n        case Opcodes.ICONST_3:\n        case Opcodes.ICONST_4:\n        case Opcodes.ICONST_5:\n        case Opcodes.BIPUSH:\n        case Opcodes.SIPUSH:\n        case Opcodes.ILOAD:\n            push(INTEGER);\n            break;\n        case Opcodes.LCONST_0:\n        case Opcodes.LCONST_1:\n        case Opcodes.LLOAD:\n            push(LONG);\n            push(TOP);\n            break;\n        case Opcodes.FCONST_0:\n        case Opcodes.FCONST_1:\n        case Opcodes.FCONST_2:\n        case Opcodes.FLOAD:\n            push(FLOAT);\n            break;\n        case Opcodes.DCONST_0:\n        case Opcodes.DCONST_1:\n        case Opcodes.DLOAD:\n            push(DOUBLE);\n            push(TOP);\n            break;\n        case Opcodes.LDC:\n            switch (item.type) {\n            case ClassWriter.INT:\n                push(INTEGER);\n                break;\n            case ClassWriter.LONG:\n                push(LONG);\n                push(TOP);\n                break;\n            case ClassWriter.FLOAT:\n                push(FLOAT);\n                break;\n            case ClassWriter.DOUBLE:\n                push(DOUBLE);\n                push(TOP);\n                break;\n            case ClassWriter.CLASS:\n                push(OBJECT | cw.addType(\"java/lang/Class\"));\n                break;\n            case ClassWriter.STR:\n                push(OBJECT | cw.addType(\"java/lang/String\"));\n                break;\n            case ClassWriter.MTYPE:\n                push(OBJECT | cw.addType(\"java/lang/invoke/MethodType\"));\n                break;\n            // case ClassWriter.HANDLE_BASE + [1..9]:\n            default:\n                push(OBJECT | cw.addType(\"java/lang/invoke/MethodHandle\"));\n            }\n            break;\n        case Opcodes.ALOAD:\n            push(get(arg));\n            break;\n        case Opcodes.IALOAD:\n        case Opcodes.BALOAD:\n        case Opcodes.CALOAD:\n        case Opcodes.SALOAD:\n            pop(2);\n            push(INTEGER);\n            break;\n        case Opcodes.LALOAD:\n        case Opcodes.D2L:\n            pop(2);\n            push(LONG);\n            push(TOP);\n            break;\n        case Opcodes.FALOAD:\n            pop(2);\n            push(FLOAT);\n            break;\n        case Opcodes.DALOAD:\n        case Opcodes.L2D:\n            pop(2);\n            push(DOUBLE);\n            push(TOP);\n            break;\n        case Opcodes.AALOAD:\n            pop(1);\n            t1 = pop();\n            push(ELEMENT_OF + t1);\n            break;\n        case Opcodes.ISTORE:\n        case Opcodes.FSTORE:\n        case Opcodes.ASTORE:\n            t1 = pop();\n            set(arg, t1);\n            if (arg > 0) {\n                t2 = get(arg - 1);\n                // if t2 is of kind STACK or LOCAL we cannot know its size!\n                if (t2 == LONG || t2 == DOUBLE) {\n                    set(arg - 1, TOP);\n                } else if ((t2 & KIND) != BASE) {\n                    set(arg - 1, t2 | TOP_IF_LONG_OR_DOUBLE);\n                }\n            }\n            break;\n        case Opcodes.LSTORE:\n        case Opcodes.DSTORE:\n            pop(1);\n            t1 = pop();\n            set(arg, t1);\n            set(arg + 1, TOP);\n            if (arg > 0) {\n                t2 = get(arg - 1);\n                // if t2 is of kind STACK or LOCAL we cannot know its size!\n                if (t2 == LONG || t2 == DOUBLE) {\n                    set(arg - 1, TOP);\n                } else if ((t2 & KIND) != BASE) {\n                    set(arg - 1, t2 | TOP_IF_LONG_OR_DOUBLE);\n                }\n            }\n            break;\n        case Opcodes.IASTORE:\n        case Opcodes.BASTORE:\n        case Opcodes.CASTORE:\n        case Opcodes.SASTORE:\n        case Opcodes.FASTORE:\n        case Opcodes.AASTORE:\n            pop(3);\n            break;\n        case Opcodes.LASTORE:\n        case Opcodes.DASTORE:\n            pop(4);\n            break;\n        case Opcodes.POP:\n        case Opcodes.IFEQ:\n        case Opcodes.IFNE:\n        case Opcodes.IFLT:\n        case Opcodes.IFGE:\n        case Opcodes.IFGT:\n        case Opcodes.IFLE:\n        case Opcodes.IRETURN:\n        case Opcodes.FRETURN:\n        case Opcodes.ARETURN:\n        case Opcodes.TABLESWITCH:\n        case Opcodes.LOOKUPSWITCH:\n        case Opcodes.ATHROW:\n        case Opcodes.MONITORENTER:\n        case Opcodes.MONITOREXIT:\n        case Opcodes.IFNULL:\n        case Opcodes.IFNONNULL:\n            pop(1);\n            break;\n        case Opcodes.POP2:\n        case Opcodes.IF_ICMPEQ:\n        case Opcodes.IF_ICMPNE:\n        case Opcodes.IF_ICMPLT:\n        case Opcodes.IF_ICMPGE:\n        case Opcodes.IF_ICMPGT:\n        case Opcodes.IF_ICMPLE:\n        case Opcodes.IF_ACMPEQ:\n        case Opcodes.IF_ACMPNE:\n        case Opcodes.LRETURN:\n        case Opcodes.DRETURN:\n            pop(2);\n            break;\n        case Opcodes.DUP:\n            t1 = pop();\n            push(t1);\n            push(t1);\n            break;\n        case Opcodes.DUP_X1:\n            t1 = pop();\n            t2 = pop();\n            push(t1);\n            push(t2);\n            push(t1);\n            break;\n        case Opcodes.DUP_X2:\n            t1 = pop();\n            t2 = pop();\n            t3 = pop();\n            push(t1);\n            push(t3);\n            push(t2);\n            push(t1);\n            break;\n        case Opcodes.DUP2:\n            t1 = pop();\n            t2 = pop();\n            push(t2);\n            push(t1);\n            push(t2);\n            push(t1);\n            break;\n        case Opcodes.DUP2_X1:\n            t1 = pop();\n            t2 = pop();\n            t3 = pop();\n            push(t2);\n            push(t1);\n            push(t3);\n            push(t2);\n            push(t1);\n            break;\n        case Opcodes.DUP2_X2:\n            t1 = pop();\n            t2 = pop();\n            t3 = pop();\n            t4 = pop();\n            push(t2);\n            push(t1);\n            push(t4);\n            push(t3);\n            push(t2);\n            push(t1);\n            break;\n        case Opcodes.SWAP:\n            t1 = pop();\n            t2 = pop();\n            push(t1);\n            push(t2);\n            break;\n        case Opcodes.IADD:\n        case Opcodes.ISUB:\n        case Opcodes.IMUL:\n        case Opcodes.IDIV:\n        case Opcodes.IREM:\n        case Opcodes.IAND:\n        case Opcodes.IOR:\n        case Opcodes.IXOR:\n        case Opcodes.ISHL:\n        case Opcodes.ISHR:\n        case Opcodes.IUSHR:\n        case Opcodes.L2I:\n        case Opcodes.D2I:\n        case Opcodes.FCMPL:\n        case Opcodes.FCMPG:\n            pop(2);\n            push(INTEGER);\n            break;\n        case Opcodes.LADD:\n        case Opcodes.LSUB:\n        case Opcodes.LMUL:\n        case Opcodes.LDIV:\n        case Opcodes.LREM:\n        case Opcodes.LAND:\n        case Opcodes.LOR:\n        case Opcodes.LXOR:\n            pop(4);\n            push(LONG);\n            push(TOP);\n            break;\n        case Opcodes.FADD:\n        case Opcodes.FSUB:\n        case Opcodes.FMUL:\n        case Opcodes.FDIV:\n        case Opcodes.FREM:\n        case Opcodes.L2F:\n        case Opcodes.D2F:\n            pop(2);\n            push(FLOAT);\n            break;\n        case Opcodes.DADD:\n        case Opcodes.DSUB:\n        case Opcodes.DMUL:\n        case Opcodes.DDIV:\n        case Opcodes.DREM:\n            pop(4);\n            push(DOUBLE);\n            push(TOP);\n            break;\n        case Opcodes.LSHL:\n        case Opcodes.LSHR:\n        case Opcodes.LUSHR:\n            pop(3);\n            push(LONG);\n            push(TOP);\n            break;\n        case Opcodes.IINC:\n            set(arg, INTEGER);\n            break;\n        case Opcodes.I2L:\n        case Opcodes.F2L:\n            pop(1);\n            push(LONG);\n            push(TOP);\n            break;\n        case Opcodes.I2F:\n            pop(1);\n            push(FLOAT);\n            break;\n        case Opcodes.I2D:\n        case Opcodes.F2D:\n            pop(1);\n            push(DOUBLE);\n            push(TOP);\n            break;\n        case Opcodes.F2I:\n        case Opcodes.ARRAYLENGTH:\n        case Opcodes.INSTANCEOF:\n            pop(1);\n            push(INTEGER);\n            break;\n        case Opcodes.LCMP:\n        case Opcodes.DCMPL:\n        case Opcodes.DCMPG:\n            pop(4);\n            push(INTEGER);\n            break;\n        case Opcodes.JSR:\n        case Opcodes.RET:\n            throw new RuntimeException(\n                    \"JSR/RET are not supported with computeFrames option\");\n        case Opcodes.GETSTATIC:\n            push(cw, item.strVal3);\n            break;\n        case Opcodes.PUTSTATIC:\n            pop(item.strVal3);\n            break;\n        case Opcodes.GETFIELD:\n            pop(1);\n            push(cw, item.strVal3);\n            break;\n        case Opcodes.PUTFIELD:\n            pop(item.strVal3);\n            pop();\n            break;\n        case Opcodes.INVOKEVIRTUAL:\n        case Opcodes.INVOKESPECIAL:\n        case Opcodes.INVOKESTATIC:\n        case Opcodes.INVOKEINTERFACE:\n            pop(item.strVal3);\n            if (opcode != Opcodes.INVOKESTATIC) {\n                t1 = pop();\n                if (opcode == Opcodes.INVOKESPECIAL\n                        && item.strVal2.charAt(0) == '<') {\n                    init(t1);\n                }\n            }\n            push(cw, item.strVal3);\n            break;\n        case Opcodes.INVOKEDYNAMIC:\n            pop(item.strVal2);\n            push(cw, item.strVal2);\n            break;\n        case Opcodes.NEW:\n            push(UNINITIALIZED | cw.addUninitializedType(item.strVal1, arg));\n            break;\n        case Opcodes.NEWARRAY:\n            pop();\n            switch (arg) {\n            case Opcodes.T_BOOLEAN:\n                push(ARRAY_OF | BOOLEAN);\n                break;\n            case Opcodes.T_CHAR:\n                push(ARRAY_OF | CHAR);\n                break;\n            case Opcodes.T_BYTE:\n                push(ARRAY_OF | BYTE);\n                break;\n            case Opcodes.T_SHORT:\n                push(ARRAY_OF | SHORT);\n                break;\n            case Opcodes.T_INT:\n                push(ARRAY_OF | INTEGER);\n                break;\n            case Opcodes.T_FLOAT:\n                push(ARRAY_OF | FLOAT);\n                break;\n            case Opcodes.T_DOUBLE:\n                push(ARRAY_OF | DOUBLE);\n                break;\n            // case Opcodes.T_LONG:\n            default:\n                push(ARRAY_OF | LONG);\n                break;\n            }\n            break;\n        case Opcodes.ANEWARRAY:\n            String s = item.strVal1;\n            pop();\n            if (s.charAt(0) == '[') {\n                push(cw, '[' + s);\n            } else {\n                push(ARRAY_OF | OBJECT | cw.addType(s));\n            }\n            break;\n        case Opcodes.CHECKCAST:\n            s = item.strVal1;\n            pop();\n            if (s.charAt(0) == '[') {\n                push(cw, s);\n            } else {\n                push(OBJECT | cw.addType(s));\n            }\n            break;\n        // case Opcodes.MULTIANEWARRAY:\n        default:\n            pop(arg);\n            push(cw, item.strVal1);\n            break;\n        }\n    }\n\n    /**\n     * Merges the input frame of the given basic block with the input and output\n     * frames of this basic block. Returns <tt>true</tt> if the input frame of\n     * the given label has been changed by this operation.\n     *\n     * @param cw\n     *            the ClassWriter to which this label belongs.\n     * @param frame\n     *            the basic block whose input frame must be updated.\n     * @param edge\n     *            the kind of the {@link Edge} between this label and 'label'.\n     *            See {@link Edge#info}.\n     * @return <tt>true</tt> if the input frame of the given label has been\n     *         changed by this operation.\n     */\n    boolean merge(final ClassWriter cw, final Frame frame, final int edge) {\n        boolean changed = false;\n        int i, s, dim, kind, t;\n\n        int nLocal = inputLocals.length;\n        int nStack = inputStack.length;\n        if (frame.inputLocals == null) {\n            frame.inputLocals = new int[nLocal];\n            changed = true;\n        }\n\n        for (i = 0; i < nLocal; ++i) {\n            if (outputLocals != null && i < outputLocals.length) {\n                s = outputLocals[i];\n                if (s == 0) {\n                    t = inputLocals[i];\n                } else {\n                    dim = s & DIM;\n                    kind = s & KIND;\n                    if (kind == BASE) {\n                        t = s;\n                    } else {\n                        if (kind == LOCAL) {\n                            t = dim + inputLocals[s & VALUE];\n                        } else {\n                            t = dim + inputStack[nStack - (s & VALUE)];\n                        }\n                        if ((s & TOP_IF_LONG_OR_DOUBLE) != 0\n                                && (t == LONG || t == DOUBLE)) {\n                            t = TOP;\n                        }\n                    }\n                }\n            } else {\n                t = inputLocals[i];\n            }\n            if (initializations != null) {\n                t = init(cw, t);\n            }\n            changed |= merge(cw, t, frame.inputLocals, i);\n        }\n\n        if (edge > 0) {\n            for (i = 0; i < nLocal; ++i) {\n                t = inputLocals[i];\n                changed |= merge(cw, t, frame.inputLocals, i);\n            }\n            if (frame.inputStack == null) {\n                frame.inputStack = new int[1];\n                changed = true;\n            }\n            changed |= merge(cw, edge, frame.inputStack, 0);\n            return changed;\n        }\n\n        int nInputStack = inputStack.length + owner.inputStackTop;\n        if (frame.inputStack == null) {\n            frame.inputStack = new int[nInputStack + outputStackTop];\n            changed = true;\n        }\n\n        for (i = 0; i < nInputStack; ++i) {\n            t = inputStack[i];\n            if (initializations != null) {\n                t = init(cw, t);\n            }\n            changed |= merge(cw, t, frame.inputStack, i);\n        }\n        for (i = 0; i < outputStackTop; ++i) {\n            s = outputStack[i];\n            dim = s & DIM;\n            kind = s & KIND;\n            if (kind == BASE) {\n                t = s;\n            } else {\n                if (kind == LOCAL) {\n                    t = dim + inputLocals[s & VALUE];\n                } else {\n                    t = dim + inputStack[nStack - (s & VALUE)];\n                }\n                if ((s & TOP_IF_LONG_OR_DOUBLE) != 0\n                        && (t == LONG || t == DOUBLE)) {\n                    t = TOP;\n                }\n            }\n            if (initializations != null) {\n                t = init(cw, t);\n            }\n            changed |= merge(cw, t, frame.inputStack, nInputStack + i);\n        }\n        return changed;\n    }\n\n    /**\n     * Merges the type at the given index in the given type array with the given\n     * type. Returns <tt>true</tt> if the type array has been modified by this\n     * operation.\n     *\n     * @param cw\n     *            the ClassWriter to which this label belongs.\n     * @param t\n     *            the type with which the type array element must be merged.\n     * @param types\n     *            an array of types.\n     * @param index\n     *            the index of the type that must be merged in 'types'.\n     * @return <tt>true</tt> if the type array has been modified by this\n     *         operation.\n     */\n    private static boolean merge(final ClassWriter cw, int t,\n            final int[] types, final int index) {\n        int u = types[index];\n        if (u == t) {\n            // if the types are equal, merge(u,t)=u, so there is no change\n            return false;\n        }\n        if ((t & ~DIM) == NULL) {\n            if (u == NULL) {\n                return false;\n            }\n            t = NULL;\n        }\n        if (u == 0) {\n            // if types[index] has never been assigned, merge(u,t)=t\n            types[index] = t;\n            return true;\n        }\n        int v;\n        if ((u & BASE_KIND) == OBJECT || (u & DIM) != 0) {\n            // if u is a reference type of any dimension\n            if (t == NULL) {\n                // if t is the NULL type, merge(u,t)=u, so there is no change\n                return false;\n            } else if ((t & (DIM | BASE_KIND)) == (u & (DIM | BASE_KIND))) {\n                if ((u & BASE_KIND) == OBJECT) {\n                    // if t is also a reference type, and if u and t have the\n                    // same dimension merge(u,t) = dim(t) | common parent of the\n                    // element types of u and t\n                    v = (t & DIM) | OBJECT\n                            | cw.getMergedType(t & BASE_VALUE, u & BASE_VALUE);\n                } else {\n                    // if u and t are array types, but not with the same element\n                    // type, merge(u,t)=java/lang/Object\n                    v = OBJECT | cw.addType(\"java/lang/Object\");\n                }\n            } else if ((t & BASE_KIND) == OBJECT || (t & DIM) != 0) {\n                // if t is any other reference or array type,\n                // merge(u,t)=java/lang/Object\n                v = OBJECT | cw.addType(\"java/lang/Object\");\n            } else {\n                // if t is any other type, merge(u,t)=TOP\n                v = TOP;\n            }\n        } else if (u == NULL) {\n            // if u is the NULL type, merge(u,t)=t,\n            // or TOP if t is not a reference type\n            v = (t & BASE_KIND) == OBJECT || (t & DIM) != 0 ? t : TOP;\n        } else {\n            // if u is any other type, merge(u,t)=TOP whatever t\n            v = TOP;\n        }\n        if (u != v) {\n            types[index] = v;\n            return true;\n        }\n        return false;\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/Handle.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\n\npackage clojure.asm;\n\n/**\n * A reference to a field or a method.\n *\n * @author Remi Forax\n * @author Eric Bruneton\n */\npublic final class Handle {\n\n    /**\n     * The kind of field or method designated by this Handle. Should be\n     * {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC},\n     * {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC},\n     * {@link Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC},\n     * {@link Opcodes#H_INVOKESPECIAL}, {@link Opcodes#H_NEWINVOKESPECIAL} or\n     * {@link Opcodes#H_INVOKEINTERFACE}.\n     */\n    final int tag;\n\n    /**\n     * The internal name of the field or method designed by this handle.\n     */\n    final String owner;\n\n    /**\n     * The name of the field or method designated by this handle.\n     */\n    final String name;\n\n    /**\n     * The descriptor of the field or method designated by this handle.\n     */\n    final String desc;\n\n    /**\n     * Constructs a new field or method handle.\n     *\n     * @param tag\n     *            the kind of field or method designated by this Handle. Must be\n     *            {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC},\n     *            {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC},\n     *            {@link Opcodes#H_INVOKEVIRTUAL},\n     *            {@link Opcodes#H_INVOKESTATIC},\n     *            {@link Opcodes#H_INVOKESPECIAL},\n     *            {@link Opcodes#H_NEWINVOKESPECIAL} or\n     *            {@link Opcodes#H_INVOKEINTERFACE}.\n     * @param owner\n     *            the internal name of the field or method designed by this\n     *            handle.\n     * @param name\n     *            the name of the field or method designated by this handle.\n     * @param desc\n     *            the descriptor of the field or method designated by this\n     *            handle.\n     */\n    public Handle(int tag, String owner, String name, String desc) {\n        this.tag = tag;\n        this.owner = owner;\n        this.name = name;\n        this.desc = desc;\n    }\n\n    /**\n     * Returns the kind of field or method designated by this handle.\n     *\n     * @return {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC},\n     *         {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC},\n     *         {@link Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC},\n     *         {@link Opcodes#H_INVOKESPECIAL},\n     *         {@link Opcodes#H_NEWINVOKESPECIAL} or\n     *         {@link Opcodes#H_INVOKEINTERFACE}.\n     */\n    public int getTag() {\n        return tag;\n    }\n\n    /**\n     * Returns the internal name of the field or method designed by this handle.\n     *\n     * @return the internal name of the field or method designed by this handle.\n     */\n    public String getOwner() {\n        return owner;\n    }\n\n    /**\n     * Returns the name of the field or method designated by this handle.\n     *\n     * @return the name of the field or method designated by this handle.\n     */\n    public String getName() {\n        return name;\n    }\n\n    /**\n     * Returns the descriptor of the field or method designated by this handle.\n     *\n     * @return the descriptor of the field or method designated by this handle.\n     */\n    public String getDesc() {\n        return desc;\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n        if (obj == this) {\n            return true;\n        }\n        if (!(obj instanceof Handle)) {\n            return false;\n        }\n        Handle h = (Handle) obj;\n        return tag == h.tag && owner.equals(h.owner) && name.equals(h.name)\n                && desc.equals(h.desc);\n    }\n\n    @Override\n    public int hashCode() {\n        return tag + owner.hashCode() * name.hashCode() * desc.hashCode();\n    }\n\n    /**\n     * Returns the textual representation of this handle. The textual\n     * representation is:\n     *\n     * <pre>\n     * owner '.' name desc ' ' '(' tag ')'\n     * </pre>\n     *\n     * . As this format is unambiguous, it can be parsed if necessary.\n     */\n    @Override\n    public String toString() {\n        return owner + '.' + name + desc + \" (\" + tag + ')';\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/Handler.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * Information about an exception handler block.\n *\n * @author Eric Bruneton\n */\nclass Handler {\n\n    /**\n     * Beginning of the exception handler's scope (inclusive).\n     */\n    Label start;\n\n    /**\n     * End of the exception handler's scope (exclusive).\n     */\n    Label end;\n\n    /**\n     * Beginning of the exception handler's code.\n     */\n    Label handler;\n\n    /**\n     * Internal name of the type of exceptions handled by this handler, or\n     * <tt>null</tt> to catch any exceptions.\n     */\n    String desc;\n\n    /**\n     * Constant pool index of the internal name of the type of exceptions\n     * handled by this handler, or 0 to catch any exceptions.\n     */\n    int type;\n\n    /**\n     * Next exception handler block info.\n     */\n    Handler next;\n\n    /**\n     * Removes the range between start and end from the given exception\n     * handlers.\n     *\n     * @param h\n     *            an exception handler list.\n     * @param start\n     *            the start of the range to be removed.\n     * @param end\n     *            the end of the range to be removed. Maybe null.\n     * @return the exception handler list with the start-end range removed.\n     */\n    static Handler remove(Handler h, Label start, Label end) {\n        if (h == null) {\n            return null;\n        } else {\n            h.next = remove(h.next, start, end);\n        }\n        int hstart = h.start.position;\n        int hend = h.end.position;\n        int s = start.position;\n        int e = end == null ? Integer.MAX_VALUE : end.position;\n        // if [hstart,hend[ and [s,e[ intervals intersect...\n        if (s < hend && e > hstart) {\n            if (s <= hstart) {\n                if (e >= hend) {\n                    // [hstart,hend[ fully included in [s,e[, h removed\n                    h = h.next;\n                } else {\n                    // [hstart,hend[ minus [s,e[ = [e,hend[\n                    h.start = end;\n                }\n            } else if (e >= hend) {\n                // [hstart,hend[ minus [s,e[ = [hstart,s[\n                h.end = start;\n            } else {\n                // [hstart,hend[ minus [s,e[ = [hstart,s[ + [e,hend[\n                Handler g = new Handler();\n                g.start = end;\n                g.end = h.end;\n                g.handler = h.handler;\n                g.desc = h.desc;\n                g.type = h.type;\n                g.next = h.next;\n                h.end = start;\n                h.next = g;\n            }\n        }\n        return h;\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/Item.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * A constant pool item. Constant pool items can be created with the 'newXXX'\n * methods in the {@link ClassWriter} class.\n *\n * @author Eric Bruneton\n */\nfinal class Item {\n\n    /**\n     * Index of this item in the constant pool.\n     */\n    int index;\n\n    /**\n     * Type of this constant pool item. A single class is used to represent all\n     * constant pool item types, in order to minimize the bytecode size of this\n     * package. The value of this field is one of {@link ClassWriter#INT},\n     * {@link ClassWriter#LONG}, {@link ClassWriter#FLOAT},\n     * {@link ClassWriter#DOUBLE}, {@link ClassWriter#UTF8},\n     * {@link ClassWriter#STR}, {@link ClassWriter#CLASS},\n     * {@link ClassWriter#NAME_TYPE}, {@link ClassWriter#FIELD},\n     * {@link ClassWriter#METH}, {@link ClassWriter#IMETH},\n     * {@link ClassWriter#MTYPE}, {@link ClassWriter#INDY}.\n     *\n     * MethodHandle constant 9 variations are stored using a range of 9 values\n     * from {@link ClassWriter#HANDLE_BASE} + 1 to\n     * {@link ClassWriter#HANDLE_BASE} + 9.\n     *\n     * Special Item types are used for Items that are stored in the ClassWriter\n     * {@link ClassWriter#typeTable}, instead of the constant pool, in order to\n     * avoid clashes with normal constant pool items in the ClassWriter constant\n     * pool's hash table. These special item types are\n     * {@link ClassWriter#TYPE_NORMAL}, {@link ClassWriter#TYPE_UNINIT} and\n     * {@link ClassWriter#TYPE_MERGED}.\n     */\n    int type;\n\n    /**\n     * Value of this item, for an integer item.\n     */\n    int intVal;\n\n    /**\n     * Value of this item, for a long item.\n     */\n    long longVal;\n\n    /**\n     * First part of the value of this item, for items that do not hold a\n     * primitive value.\n     */\n    String strVal1;\n\n    /**\n     * Second part of the value of this item, for items that do not hold a\n     * primitive value.\n     */\n    String strVal2;\n\n    /**\n     * Third part of the value of this item, for items that do not hold a\n     * primitive value.\n     */\n    String strVal3;\n\n    /**\n     * The hash code value of this constant pool item.\n     */\n    int hashCode;\n\n    /**\n     * Link to another constant pool item, used for collision lists in the\n     * constant pool's hash table.\n     */\n    Item next;\n\n    /**\n     * Constructs an uninitialized {@link Item}.\n     */\n    Item() {\n    }\n\n    /**\n     * Constructs an uninitialized {@link Item} for constant pool element at\n     * given position.\n     *\n     * @param index\n     *            index of the item to be constructed.\n     */\n    Item(final int index) {\n        this.index = index;\n    }\n\n    /**\n     * Constructs a copy of the given item.\n     *\n     * @param index\n     *            index of the item to be constructed.\n     * @param i\n     *            the item that must be copied into the item to be constructed.\n     */\n    Item(final int index, final Item i) {\n        this.index = index;\n        type = i.type;\n        intVal = i.intVal;\n        longVal = i.longVal;\n        strVal1 = i.strVal1;\n        strVal2 = i.strVal2;\n        strVal3 = i.strVal3;\n        hashCode = i.hashCode;\n    }\n\n    /**\n     * Sets this item to an integer item.\n     *\n     * @param intVal\n     *            the value of this item.\n     */\n    void set(final int intVal) {\n        this.type = ClassWriter.INT;\n        this.intVal = intVal;\n        this.hashCode = 0x7FFFFFFF & (type + intVal);\n    }\n\n    /**\n     * Sets this item to a long item.\n     *\n     * @param longVal\n     *            the value of this item.\n     */\n    void set(final long longVal) {\n        this.type = ClassWriter.LONG;\n        this.longVal = longVal;\n        this.hashCode = 0x7FFFFFFF & (type + (int) longVal);\n    }\n\n    /**\n     * Sets this item to a float item.\n     *\n     * @param floatVal\n     *            the value of this item.\n     */\n    void set(final float floatVal) {\n        this.type = ClassWriter.FLOAT;\n        this.intVal = Float.floatToRawIntBits(floatVal);\n        this.hashCode = 0x7FFFFFFF & (type + (int) floatVal);\n    }\n\n    /**\n     * Sets this item to a double item.\n     *\n     * @param doubleVal\n     *            the value of this item.\n     */\n    void set(final double doubleVal) {\n        this.type = ClassWriter.DOUBLE;\n        this.longVal = Double.doubleToRawLongBits(doubleVal);\n        this.hashCode = 0x7FFFFFFF & (type + (int) doubleVal);\n    }\n\n    /**\n     * Sets this item to an item that do not hold a primitive value.\n     *\n     * @param type\n     *            the type of this item.\n     * @param strVal1\n     *            first part of the value of this item.\n     * @param strVal2\n     *            second part of the value of this item.\n     * @param strVal3\n     *            third part of the value of this item.\n     */\n    void set(final int type, final String strVal1, final String strVal2,\n            final String strVal3) {\n        this.type = type;\n        this.strVal1 = strVal1;\n        this.strVal2 = strVal2;\n        this.strVal3 = strVal3;\n        switch (type) {\n        case ClassWriter.UTF8:\n        case ClassWriter.STR:\n        case ClassWriter.CLASS:\n        case ClassWriter.MTYPE:\n        case ClassWriter.TYPE_NORMAL:\n            hashCode = 0x7FFFFFFF & (type + strVal1.hashCode());\n            return;\n        case ClassWriter.NAME_TYPE: {\n            hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()\n                    * strVal2.hashCode());\n            return;\n        }\n        // ClassWriter.FIELD:\n        // ClassWriter.METH:\n        // ClassWriter.IMETH:\n        // ClassWriter.HANDLE_BASE + 1..9\n        default:\n            hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()\n                    * strVal2.hashCode() * strVal3.hashCode());\n        }\n    }\n\n    /**\n     * Sets the item to an InvokeDynamic item.\n     *\n     * @param name\n     *            invokedynamic's name.\n     * @param desc\n     *            invokedynamic's desc.\n     * @param bsmIndex\n     *            zero based index into the class attribute BootrapMethods.\n     */\n    void set(String name, String desc, int bsmIndex) {\n        this.type = ClassWriter.INDY;\n        this.longVal = bsmIndex;\n        this.strVal1 = name;\n        this.strVal2 = desc;\n        this.hashCode = 0x7FFFFFFF & (ClassWriter.INDY + bsmIndex\n                * strVal1.hashCode() * strVal2.hashCode());\n    }\n\n    /**\n     * Sets the item to a BootstrapMethod item.\n     *\n     * @param position\n     *            position in byte in the class attribute BootrapMethods.\n     * @param hashCode\n     *            hashcode of the item. This hashcode is processed from the\n     *            hashcode of the bootstrap method and the hashcode of all\n     *            bootstrap arguments.\n     */\n    void set(int position, int hashCode) {\n        this.type = ClassWriter.BSM;\n        this.intVal = position;\n        this.hashCode = hashCode;\n    }\n\n    /**\n     * Indicates if the given item is equal to this one. <i>This method assumes\n     * that the two items have the same {@link #type}</i>.\n     *\n     * @param i\n     *            the item to be compared to this one. Both items must have the\n     *            same {@link #type}.\n     * @return <tt>true</tt> if the given item if equal to this one,\n     *         <tt>false</tt> otherwise.\n     */\n    boolean isEqualTo(final Item i) {\n        switch (type) {\n        case ClassWriter.UTF8:\n        case ClassWriter.STR:\n        case ClassWriter.CLASS:\n        case ClassWriter.MTYPE:\n        case ClassWriter.TYPE_NORMAL:\n            return i.strVal1.equals(strVal1);\n        case ClassWriter.TYPE_MERGED:\n        case ClassWriter.LONG:\n        case ClassWriter.DOUBLE:\n            return i.longVal == longVal;\n        case ClassWriter.INT:\n        case ClassWriter.FLOAT:\n            return i.intVal == intVal;\n        case ClassWriter.TYPE_UNINIT:\n            return i.intVal == intVal && i.strVal1.equals(strVal1);\n        case ClassWriter.NAME_TYPE:\n            return i.strVal1.equals(strVal1) && i.strVal2.equals(strVal2);\n        case ClassWriter.INDY: {\n            return i.longVal == longVal && i.strVal1.equals(strVal1)\n                    && i.strVal2.equals(strVal2);\n        }\n        // case ClassWriter.FIELD:\n        // case ClassWriter.METH:\n        // case ClassWriter.IMETH:\n        // case ClassWriter.HANDLE_BASE + 1..9\n        default:\n            return i.strVal1.equals(strVal1) && i.strVal2.equals(strVal2)\n                    && i.strVal3.equals(strVal3);\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/Label.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * A label represents a position in the bytecode of a method. Labels are used\n * for jump, goto, and switch instructions, and for try catch blocks. A label\n * designates the <i>instruction</i> that is just after. Note however that there\n * can be other elements between a label and the instruction it designates (such\n * as other labels, stack map frames, line numbers, etc.).\n *\n * @author Eric Bruneton\n */\npublic class Label {\n\n    /**\n     * Indicates if this label is only used for debug attributes. Such a label\n     * is not the start of a basic block, the target of a jump instruction, or\n     * an exception handler. It can be safely ignored in control flow graph\n     * analysis algorithms (for optimization purposes).\n     */\n    static final int DEBUG = 1;\n\n    /**\n     * Indicates if the position of this label is known.\n     */\n    static final int RESOLVED = 2;\n\n    /**\n     * Indicates if this label has been updated, after instruction resizing.\n     */\n    static final int RESIZED = 4;\n\n    /**\n     * Indicates if this basic block has been pushed in the basic block stack.\n     * See {@link MethodWriter#visitMaxs visitMaxs}.\n     */\n    static final int PUSHED = 8;\n\n    /**\n     * Indicates if this label is the target of a jump instruction, or the start\n     * of an exception handler.\n     */\n    static final int TARGET = 16;\n\n    /**\n     * Indicates if a stack map frame must be stored for this label.\n     */\n    static final int STORE = 32;\n\n    /**\n     * Indicates if this label corresponds to a reachable basic block.\n     */\n    static final int REACHABLE = 64;\n\n    /**\n     * Indicates if this basic block ends with a JSR instruction.\n     */\n    static final int JSR = 128;\n\n    /**\n     * Indicates if this basic block ends with a RET instruction.\n     */\n    static final int RET = 256;\n\n    /**\n     * Indicates if this basic block is the start of a subroutine.\n     */\n    static final int SUBROUTINE = 512;\n\n    /**\n     * Indicates if this subroutine basic block has been visited by a\n     * visitSubroutine(null, ...) call.\n     */\n    static final int VISITED = 1024;\n\n    /**\n     * Indicates if this subroutine basic block has been visited by a\n     * visitSubroutine(!null, ...) call.\n     */\n    static final int VISITED2 = 2048;\n\n    /**\n     * Field used to associate user information to a label. Warning: this field\n     * is used by the ASM tree package. In order to use it with the ASM tree\n     * package you must override the\n     * {@link clojure.asm.tree.MethodNode#getLabelNode} method.\n     */\n    public Object info;\n\n    /**\n     * Flags that indicate the status of this label.\n     *\n     * @see #DEBUG\n     * @see #RESOLVED\n     * @see #RESIZED\n     * @see #PUSHED\n     * @see #TARGET\n     * @see #STORE\n     * @see #REACHABLE\n     * @see #JSR\n     * @see #RET\n     */\n    int status;\n\n    /**\n     * The line number corresponding to this label, if known.\n     */\n    int line;\n\n    /**\n     * The position of this label in the code, if known.\n     */\n    int position;\n\n    /**\n     * Number of forward references to this label, times two.\n     */\n    private int referenceCount;\n\n    /**\n     * Informations about forward references. Each forward reference is\n     * described by two consecutive integers in this array: the first one is the\n     * position of the first byte of the bytecode instruction that contains the\n     * forward reference, while the second is the position of the first byte of\n     * the forward reference itself. In fact the sign of the first integer\n     * indicates if this reference uses 2 or 4 bytes, and its absolute value\n     * gives the position of the bytecode instruction. This array is also used\n     * as a bitset to store the subroutines to which a basic block belongs. This\n     * information is needed in {@linked MethodWriter#visitMaxs}, after all\n     * forward references have been resolved. Hence the same array can be used\n     * for both purposes without problems.\n     */\n    private int[] srcAndRefPositions;\n\n    // ------------------------------------------------------------------------\n\n    /*\n     * Fields for the control flow and data flow graph analysis algorithms (used\n     * to compute the maximum stack size or the stack map frames). A control\n     * flow graph contains one node per \"basic block\", and one edge per \"jump\"\n     * from one basic block to another. Each node (i.e., each basic block) is\n     * represented by the Label object that corresponds to the first instruction\n     * of this basic block. Each node also stores the list of its successors in\n     * the graph, as a linked list of Edge objects.\n     *\n     * The control flow analysis algorithms used to compute the maximum stack\n     * size or the stack map frames are similar and use two steps. The first\n     * step, during the visit of each instruction, builds information about the\n     * state of the local variables and the operand stack at the end of each\n     * basic block, called the \"output frame\", <i>relatively</i> to the frame\n     * state at the beginning of the basic block, which is called the \"input\n     * frame\", and which is <i>unknown</i> during this step. The second step, in\n     * {@link MethodWriter#visitMaxs}, is a fix point algorithm that computes\n     * information about the input frame of each basic block, from the input\n     * state of the first basic block (known from the method signature), and by\n     * the using the previously computed relative output frames.\n     *\n     * The algorithm used to compute the maximum stack size only computes the\n     * relative output and absolute input stack heights, while the algorithm\n     * used to compute stack map frames computes relative output frames and\n     * absolute input frames.\n     */\n\n    /**\n     * Start of the output stack relatively to the input stack. The exact\n     * semantics of this field depends on the algorithm that is used.\n     *\n     * When only the maximum stack size is computed, this field is the number of\n     * elements in the input stack.\n     *\n     * When the stack map frames are completely computed, this field is the\n     * offset of the first output stack element relatively to the top of the\n     * input stack. This offset is always negative or null. A null offset means\n     * that the output stack must be appended to the input stack. A -n offset\n     * means that the first n output stack elements must replace the top n input\n     * stack elements, and that the other elements must be appended to the input\n     * stack.\n     */\n    int inputStackTop;\n\n    /**\n     * Maximum height reached by the output stack, relatively to the top of the\n     * input stack. This maximum is always positive or null.\n     */\n    int outputStackMax;\n\n    /**\n     * Information about the input and output stack map frames of this basic\n     * block. This field is only used when {@link ClassWriter#COMPUTE_FRAMES}\n     * option is used.\n     */\n    Frame frame;\n\n    /**\n     * The successor of this label, in the order they are visited. This linked\n     * list does not include labels used for debug info only. If\n     * {@link ClassWriter#COMPUTE_FRAMES} option is used then, in addition, it\n     * does not contain successive labels that denote the same bytecode position\n     * (in this case only the first label appears in this list).\n     */\n    Label successor;\n\n    /**\n     * The successors of this node in the control flow graph. These successors\n     * are stored in a linked list of {@link Edge Edge} objects, linked to each\n     * other by their {@link Edge#next} field.\n     */\n    Edge successors;\n\n    /**\n     * The next basic block in the basic block stack. This stack is used in the\n     * main loop of the fix point algorithm used in the second step of the\n     * control flow analysis algorithms. It is also used in\n     * {@link #visitSubroutine} to avoid using a recursive method.\n     *\n     * @see MethodWriter#visitMaxs\n     */\n    Label next;\n\n    // ------------------------------------------------------------------------\n    // Constructor\n    // ------------------------------------------------------------------------\n\n    /**\n     * Constructs a new label.\n     */\n    public Label() {\n    }\n\n    // ------------------------------------------------------------------------\n    // Methods to compute offsets and to manage forward references\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns the offset corresponding to this label. This offset is computed\n     * from the start of the method's bytecode. <i>This method is intended for\n     * {@link Attribute} sub classes, and is normally not needed by class\n     * generators or adapters.</i>\n     *\n     * @return the offset corresponding to this label.\n     * @throws IllegalStateException\n     *             if this label is not resolved yet.\n     */\n    public int getOffset() {\n        if ((status & RESOLVED) == 0) {\n            throw new IllegalStateException(\n                    \"Label offset position has not been resolved yet\");\n        }\n        return position;\n    }\n\n    /**\n     * Puts a reference to this label in the bytecode of a method. If the\n     * position of the label is known, the offset is computed and written\n     * directly. Otherwise, a null offset is written and a new forward reference\n     * is declared for this label.\n     *\n     * @param owner\n     *            the code writer that calls this method.\n     * @param out\n     *            the bytecode of the method.\n     * @param source\n     *            the position of first byte of the bytecode instruction that\n     *            contains this label.\n     * @param wideOffset\n     *            <tt>true</tt> if the reference must be stored in 4 bytes, or\n     *            <tt>false</tt> if it must be stored with 2 bytes.\n     * @throws IllegalArgumentException\n     *             if this label has not been created by the given code writer.\n     */\n    void put(final MethodWriter owner, final ByteVector out, final int source,\n            final boolean wideOffset) {\n        if ((status & RESOLVED) == 0) {\n            if (wideOffset) {\n                addReference(-1 - source, out.length);\n                out.putInt(-1);\n            } else {\n                addReference(source, out.length);\n                out.putShort(-1);\n            }\n        } else {\n            if (wideOffset) {\n                out.putInt(position - source);\n            } else {\n                out.putShort(position - source);\n            }\n        }\n    }\n\n    /**\n     * Adds a forward reference to this label. This method must be called only\n     * for a true forward reference, i.e. only if this label is not resolved\n     * yet. For backward references, the offset of the reference can be, and\n     * must be, computed and stored directly.\n     *\n     * @param sourcePosition\n     *            the position of the referencing instruction. This position\n     *            will be used to compute the offset of this forward reference.\n     * @param referencePosition\n     *            the position where the offset for this forward reference must\n     *            be stored.\n     */\n    private void addReference(final int sourcePosition,\n            final int referencePosition) {\n        if (srcAndRefPositions == null) {\n            srcAndRefPositions = new int[6];\n        }\n        if (referenceCount >= srcAndRefPositions.length) {\n            int[] a = new int[srcAndRefPositions.length + 6];\n            System.arraycopy(srcAndRefPositions, 0, a, 0,\n                    srcAndRefPositions.length);\n            srcAndRefPositions = a;\n        }\n        srcAndRefPositions[referenceCount++] = sourcePosition;\n        srcAndRefPositions[referenceCount++] = referencePosition;\n    }\n\n    /**\n     * Resolves all forward references to this label. This method must be called\n     * when this label is added to the bytecode of the method, i.e. when its\n     * position becomes known. This method fills in the blanks that where left\n     * in the bytecode by each forward reference previously added to this label.\n     *\n     * @param owner\n     *            the code writer that calls this method.\n     * @param position\n     *            the position of this label in the bytecode.\n     * @param data\n     *            the bytecode of the method.\n     * @return <tt>true</tt> if a blank that was left for this label was to\n     *         small to store the offset. In such a case the corresponding jump\n     *         instruction is replaced with a pseudo instruction (using unused\n     *         opcodes) using an unsigned two bytes offset. These pseudo\n     *         instructions will need to be replaced with true instructions with\n     *         wider offsets (4 bytes instead of 2). This is done in\n     *         {@link MethodWriter#resizeInstructions}.\n     * @throws IllegalArgumentException\n     *             if this label has already been resolved, or if it has not\n     *             been created by the given code writer.\n     */\n    boolean resolve(final MethodWriter owner, final int position,\n            final byte[] data) {\n        boolean needUpdate = false;\n        this.status |= RESOLVED;\n        this.position = position;\n        int i = 0;\n        while (i < referenceCount) {\n            int source = srcAndRefPositions[i++];\n            int reference = srcAndRefPositions[i++];\n            int offset;\n            if (source >= 0) {\n                offset = position - source;\n                if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) {\n                    /*\n                     * changes the opcode of the jump instruction, in order to\n                     * be able to find it later (see resizeInstructions in\n                     * MethodWriter). These temporary opcodes are similar to\n                     * jump instruction opcodes, except that the 2 bytes offset\n                     * is unsigned (and can therefore represent values from 0 to\n                     * 65535, which is sufficient since the size of a method is\n                     * limited to 65535 bytes).\n                     */\n                    int opcode = data[reference - 1] & 0xFF;\n                    if (opcode <= Opcodes.JSR) {\n                        // changes IFEQ ... JSR to opcodes 202 to 217\n                        data[reference - 1] = (byte) (opcode + 49);\n                    } else {\n                        // changes IFNULL and IFNONNULL to opcodes 218 and 219\n                        data[reference - 1] = (byte) (opcode + 20);\n                    }\n                    needUpdate = true;\n                }\n                data[reference++] = (byte) (offset >>> 8);\n                data[reference] = (byte) offset;\n            } else {\n                offset = position + source + 1;\n                data[reference++] = (byte) (offset >>> 24);\n                data[reference++] = (byte) (offset >>> 16);\n                data[reference++] = (byte) (offset >>> 8);\n                data[reference] = (byte) offset;\n            }\n        }\n        return needUpdate;\n    }\n\n    /**\n     * Returns the first label of the series to which this label belongs. For an\n     * isolated label or for the first label in a series of successive labels,\n     * this method returns the label itself. For other labels it returns the\n     * first label of the series.\n     *\n     * @return the first label of the series to which this label belongs.\n     */\n    Label getFirst() {\n        return !ClassReader.FRAMES || frame == null ? this : frame.owner;\n    }\n\n    // ------------------------------------------------------------------------\n    // Methods related to subroutines\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns true is this basic block belongs to the given subroutine.\n     *\n     * @param id\n     *            a subroutine id.\n     * @return true is this basic block belongs to the given subroutine.\n     */\n    boolean inSubroutine(final long id) {\n        if ((status & Label.VISITED) != 0) {\n            return (srcAndRefPositions[(int) (id >>> 32)] & (int) id) != 0;\n        }\n        return false;\n    }\n\n    /**\n     * Returns true if this basic block and the given one belong to a common\n     * subroutine.\n     *\n     * @param block\n     *            another basic block.\n     * @return true if this basic block and the given one belong to a common\n     *         subroutine.\n     */\n    boolean inSameSubroutine(final Label block) {\n        if ((status & VISITED) == 0 || (block.status & VISITED) == 0) {\n            return false;\n        }\n        for (int i = 0; i < srcAndRefPositions.length; ++i) {\n            if ((srcAndRefPositions[i] & block.srcAndRefPositions[i]) != 0) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    /**\n     * Marks this basic block as belonging to the given subroutine.\n     *\n     * @param id\n     *            a subroutine id.\n     * @param nbSubroutines\n     *            the total number of subroutines in the method.\n     */\n    void addToSubroutine(final long id, final int nbSubroutines) {\n        if ((status & VISITED) == 0) {\n            status |= VISITED;\n            srcAndRefPositions = new int[(nbSubroutines - 1) / 32 + 1];\n        }\n        srcAndRefPositions[(int) (id >>> 32)] |= (int) id;\n    }\n\n    /**\n     * Finds the basic blocks that belong to a given subroutine, and marks these\n     * blocks as belonging to this subroutine. This method follows the control\n     * flow graph to find all the blocks that are reachable from the current\n     * block WITHOUT following any JSR target.\n     *\n     * @param JSR\n     *            a JSR block that jumps to this subroutine. If this JSR is not\n     *            null it is added to the successor of the RET blocks found in\n     *            the subroutine.\n     * @param id\n     *            the id of this subroutine.\n     * @param nbSubroutines\n     *            the total number of subroutines in the method.\n     */\n    void visitSubroutine(final Label JSR, final long id, final int nbSubroutines) {\n        // user managed stack of labels, to avoid using a recursive method\n        // (recursivity can lead to stack overflow with very large methods)\n        Label stack = this;\n        while (stack != null) {\n            // removes a label l from the stack\n            Label l = stack;\n            stack = l.next;\n            l.next = null;\n\n            if (JSR != null) {\n                if ((l.status & VISITED2) != 0) {\n                    continue;\n                }\n                l.status |= VISITED2;\n                // adds JSR to the successors of l, if it is a RET block\n                if ((l.status & RET) != 0) {\n                    if (!l.inSameSubroutine(JSR)) {\n                        Edge e = new Edge();\n                        e.info = l.inputStackTop;\n                        e.successor = JSR.successors.successor;\n                        e.next = l.successors;\n                        l.successors = e;\n                    }\n                }\n            } else {\n                // if the l block already belongs to subroutine 'id', continue\n                if (l.inSubroutine(id)) {\n                    continue;\n                }\n                // marks the l block as belonging to subroutine 'id'\n                l.addToSubroutine(id, nbSubroutines);\n            }\n            // pushes each successor of l on the stack, except JSR targets\n            Edge e = l.successors;\n            while (e != null) {\n                // if the l block is a JSR block, then 'l.successors.next' leads\n                // to the JSR target (see {@link #visitJumpInsn}) and must\n                // therefore not be followed\n                if ((l.status & Label.JSR) == 0 || e != l.successors.next) {\n                    // pushes e.successor on the stack if it not already added\n                    if (e.successor.next == null) {\n                        e.successor.next = stack;\n                        stack = e.successor;\n                    }\n                }\n                e = e.next;\n            }\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Overriden Object methods\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns a string representation of this label.\n     *\n     * @return a string representation of this label.\n     */\n    @Override\n    public String toString() {\n        return \"L\" + System.identityHashCode(this);\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/MethodVisitor.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * A visitor to visit a Java method. The methods of this class must be called in\n * the following order: [ <tt>visitAnnotationDefault</tt> ] (\n * <tt>visitAnnotation</tt> | <tt>visitParameterAnnotation</tt> |\n * <tt>visitAttribute</tt> )* [ <tt>visitCode</tt> ( <tt>visitFrame</tt> |\n * <tt>visit</tt><i>X</i>Insn</tt> | <tt>visitLabel</tt> |\n * <tt>visitTryCatchBlock</tt> | <tt>visitLocalVariable</tt> |\n * <tt>visitLineNumber</tt> )* <tt>visitMaxs</tt> ] <tt>visitEnd</tt>. In\n * addition, the <tt>visit</tt><i>X</i>Insn</tt> and <tt>visitLabel</tt> methods\n * must be called in the sequential order of the bytecode instructions of the\n * visited code, <tt>visitTryCatchBlock</tt> must be called <i>before</i> the\n * labels passed as arguments have been visited, and the\n * <tt>visitLocalVariable</tt> and <tt>visitLineNumber</tt> methods must be\n * called <i>after</i> the labels passed as arguments have been visited.\n *\n * @author Eric Bruneton\n */\npublic abstract class MethodVisitor {\n\n    /**\n     * The ASM API version implemented by this visitor. The value of this field\n     * must be one of {@link Opcodes#ASM4}.\n     */\n    protected final int api;\n\n    /**\n     * The method visitor to which this visitor must delegate method calls. May\n     * be null.\n     */\n    protected MethodVisitor mv;\n\n    /**\n     * Constructs a new {@link MethodVisitor}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     */\n    public MethodVisitor(final int api) {\n        this(api, null);\n    }\n\n    /**\n     * Constructs a new {@link MethodVisitor}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     * @param mv\n     *            the method visitor to which this visitor must delegate method\n     *            calls. May be null.\n     */\n    public MethodVisitor(final int api, final MethodVisitor mv) {\n        if (api != Opcodes.ASM4) {\n            throw new IllegalArgumentException();\n        }\n        this.api = api;\n        this.mv = mv;\n    }\n\n    // -------------------------------------------------------------------------\n    // Annotations and non standard attributes\n    // -------------------------------------------------------------------------\n\n    /**\n     * Visits the default value of this annotation interface method.\n     *\n     * @return a visitor to the visit the actual default value of this\n     *         annotation interface method, or <tt>null</tt> if this visitor is\n     *         not interested in visiting this default value. The 'name'\n     *         parameters passed to the methods of this annotation visitor are\n     *         ignored. Moreover, exacly one visit method must be called on this\n     *         annotation visitor, followed by visitEnd.\n     */\n    public AnnotationVisitor visitAnnotationDefault() {\n        if (mv != null) {\n            return mv.visitAnnotationDefault();\n        }\n        return null;\n    }\n\n    /**\n     * Visits an annotation of this method.\n     *\n     * @param desc\n     *            the class descriptor of the annotation class.\n     * @param visible\n     *            <tt>true</tt> if the annotation is visible at runtime.\n     * @return a visitor to visit the annotation values, or <tt>null</tt> if\n     *         this visitor is not interested in visiting this annotation.\n     */\n    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {\n        if (mv != null) {\n            return mv.visitAnnotation(desc, visible);\n        }\n        return null;\n    }\n\n    /**\n     * Visits an annotation of a parameter this method.\n     *\n     * @param parameter\n     *            the parameter index.\n     * @param desc\n     *            the class descriptor of the annotation class.\n     * @param visible\n     *            <tt>true</tt> if the annotation is visible at runtime.\n     * @return a visitor to visit the annotation values, or <tt>null</tt> if\n     *         this visitor is not interested in visiting this annotation.\n     */\n    public AnnotationVisitor visitParameterAnnotation(int parameter,\n            String desc, boolean visible) {\n        if (mv != null) {\n            return mv.visitParameterAnnotation(parameter, desc, visible);\n        }\n        return null;\n    }\n\n    /**\n     * Visits a non standard attribute of this method.\n     *\n     * @param attr\n     *            an attribute.\n     */\n    public void visitAttribute(Attribute attr) {\n        if (mv != null) {\n            mv.visitAttribute(attr);\n        }\n    }\n\n    /**\n     * Starts the visit of the method's code, if any (i.e. non abstract method).\n     */\n    public void visitCode() {\n        if (mv != null) {\n            mv.visitCode();\n        }\n    }\n\n    /**\n     * Visits the current state of the local variables and operand stack\n     * elements. This method must(*) be called <i>just before</i> any\n     * instruction <b>i</b> that follows an unconditional branch instruction\n     * such as GOTO or THROW, that is the target of a jump instruction, or that\n     * starts an exception handler block. The visited types must describe the\n     * values of the local variables and of the operand stack elements <i>just\n     * before</i> <b>i</b> is executed.<br>\n     * <br>\n     * (*) this is mandatory only for classes whose version is greater than or\n     * equal to {@link Opcodes#V1_6 V1_6}. <br>\n     * <br>\n     * The frames of a method must be given either in expanded form, or in\n     * compressed form (all frames must use the same format, i.e. you must not\n     * mix expanded and compressed frames within a single method):\n     * <ul>\n     * <li>In expanded form, all frames must have the F_NEW type.</li>\n     * <li>In compressed form, frames are basically \"deltas\" from the state of\n     * the previous frame:\n     * <ul>\n     * <li>{@link Opcodes#F_SAME} representing frame with exactly the same\n     * locals as the previous frame and with the empty stack.</li>\n     * <li>{@link Opcodes#F_SAME1} representing frame with exactly the same\n     * locals as the previous frame and with single value on the stack (\n     * <code>nStack</code> is 1 and <code>stack[0]</code> contains value for the\n     * type of the stack item).</li>\n     * <li>{@link Opcodes#F_APPEND} representing frame with current locals are\n     * the same as the locals in the previous frame, except that additional\n     * locals are defined (<code>nLocal</code> is 1, 2 or 3 and\n     * <code>local</code> elements contains values representing added types).</li>\n     * <li>{@link Opcodes#F_CHOP} representing frame with current locals are the\n     * same as the locals in the previous frame, except that the last 1-3 locals\n     * are absent and with the empty stack (<code>nLocals</code> is 1, 2 or 3).</li>\n     * <li>{@link Opcodes#F_FULL} representing complete frame data.</li></li>\n     * </ul>\n     * </ul> <br>\n     * In both cases the first frame, corresponding to the method's parameters\n     * and access flags, is implicit and must not be visited. Also, it is\n     * illegal to visit two or more frames for the same code location (i.e., at\n     * least one instruction must be visited between two calls to visitFrame).\n     *\n     * @param type\n     *            the type of this stack map frame. Must be\n     *            {@link Opcodes#F_NEW} for expanded frames, or\n     *            {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND},\n     *            {@link Opcodes#F_CHOP}, {@link Opcodes#F_SAME} or\n     *            {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for\n     *            compressed frames.\n     * @param nLocal\n     *            the number of local variables in the visited frame.\n     * @param local\n     *            the local variable types in this frame. This array must not be\n     *            modified. Primitive types are represented by\n     *            {@link Opcodes#TOP}, {@link Opcodes#INTEGER},\n     *            {@link Opcodes#FLOAT}, {@link Opcodes#LONG},\n     *            {@link Opcodes#DOUBLE},{@link Opcodes#NULL} or\n     *            {@link Opcodes#UNINITIALIZED_THIS} (long and double are\n     *            represented by a single element). Reference types are\n     *            represented by String objects (representing internal names),\n     *            and uninitialized types by Label objects (this label\n     *            designates the NEW instruction that created this uninitialized\n     *            value).\n     * @param nStack\n     *            the number of operand stack elements in the visited frame.\n     * @param stack\n     *            the operand stack types in this frame. This array must not be\n     *            modified. Its content has the same format as the \"local\"\n     *            array.\n     * @throws IllegalStateException\n     *             if a frame is visited just after another one, without any\n     *             instruction between the two (unless this frame is a\n     *             Opcodes#F_SAME frame, in which case it is silently ignored).\n     */\n    public void visitFrame(int type, int nLocal, Object[] local, int nStack,\n            Object[] stack) {\n        if (mv != null) {\n            mv.visitFrame(type, nLocal, local, nStack, stack);\n        }\n    }\n\n    // -------------------------------------------------------------------------\n    // Normal instructions\n    // -------------------------------------------------------------------------\n\n    /**\n     * Visits a zero operand instruction.\n     *\n     * @param opcode\n     *            the opcode of the instruction to be visited. This opcode is\n     *            either NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1,\n     *            ICONST_2, ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1,\n     *            FCONST_0, FCONST_1, FCONST_2, DCONST_0, DCONST_1, IALOAD,\n     *            LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD,\n     *            IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE,\n     *            SASTORE, POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1,\n     *            DUP2_X2, SWAP, IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB,\n     *            IMUL, LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM,\n     *            FREM, DREM, INEG, LNEG, FNEG, DNEG, ISHL, LSHL, ISHR, LSHR,\n     *            IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR, I2L, I2F, I2D,\n     *            L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, I2S,\n     *            LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN, FRETURN,\n     *            DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW, MONITORENTER,\n     *            or MONITOREXIT.\n     */\n    public void visitInsn(int opcode) {\n        if (mv != null) {\n            mv.visitInsn(opcode);\n        }\n    }\n\n    /**\n     * Visits an instruction with a single int operand.\n     *\n     * @param opcode\n     *            the opcode of the instruction to be visited. This opcode is\n     *            either BIPUSH, SIPUSH or NEWARRAY.\n     * @param operand\n     *            the operand of the instruction to be visited.<br>\n     *            When opcode is BIPUSH, operand value should be between\n     *            Byte.MIN_VALUE and Byte.MAX_VALUE.<br>\n     *            When opcode is SIPUSH, operand value should be between\n     *            Short.MIN_VALUE and Short.MAX_VALUE.<br>\n     *            When opcode is NEWARRAY, operand value should be one of\n     *            {@link Opcodes#T_BOOLEAN}, {@link Opcodes#T_CHAR},\n     *            {@link Opcodes#T_FLOAT}, {@link Opcodes#T_DOUBLE},\n     *            {@link Opcodes#T_BYTE}, {@link Opcodes#T_SHORT},\n     *            {@link Opcodes#T_INT} or {@link Opcodes#T_LONG}.\n     */\n    public void visitIntInsn(int opcode, int operand) {\n        if (mv != null) {\n            mv.visitIntInsn(opcode, operand);\n        }\n    }\n\n    /**\n     * Visits a local variable instruction. A local variable instruction is an\n     * instruction that loads or stores the value of a local variable.\n     *\n     * @param opcode\n     *            the opcode of the local variable instruction to be visited.\n     *            This opcode is either ILOAD, LLOAD, FLOAD, DLOAD, ALOAD,\n     *            ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.\n     * @param var\n     *            the operand of the instruction to be visited. This operand is\n     *            the index of a local variable.\n     */\n    public void visitVarInsn(int opcode, int var) {\n        if (mv != null) {\n            mv.visitVarInsn(opcode, var);\n        }\n    }\n\n    /**\n     * Visits a type instruction. A type instruction is an instruction that\n     * takes the internal name of a class as parameter.\n     *\n     * @param opcode\n     *            the opcode of the type instruction to be visited. This opcode\n     *            is either NEW, ANEWARRAY, CHECKCAST or INSTANCEOF.\n     * @param type\n     *            the operand of the instruction to be visited. This operand\n     *            must be the internal name of an object or array class (see\n     *            {@link Type#getInternalName() getInternalName}).\n     */\n    public void visitTypeInsn(int opcode, String type) {\n        if (mv != null) {\n            mv.visitTypeInsn(opcode, type);\n        }\n    }\n\n    /**\n     * Visits a field instruction. A field instruction is an instruction that\n     * loads or stores the value of a field of an object.\n     *\n     * @param opcode\n     *            the opcode of the type instruction to be visited. This opcode\n     *            is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.\n     * @param owner\n     *            the internal name of the field's owner class (see\n     *            {@link Type#getInternalName() getInternalName}).\n     * @param name\n     *            the field's name.\n     * @param desc\n     *            the field's descriptor (see {@link Type Type}).\n     */\n    public void visitFieldInsn(int opcode, String owner, String name,\n            String desc) {\n        if (mv != null) {\n            mv.visitFieldInsn(opcode, owner, name, desc);\n        }\n    }\n\n    /**\n     * Visits a method instruction. A method instruction is an instruction that\n     * invokes a method.\n     *\n     * @param opcode\n     *            the opcode of the type instruction to be visited. This opcode\n     *            is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or\n     *            INVOKEINTERFACE.\n     * @param owner\n     *            the internal name of the method's owner class (see\n     *            {@link Type#getInternalName() getInternalName}).\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor (see {@link Type Type}).\n     */\n    public void visitMethodInsn(int opcode, String owner, String name,\n            String desc) {\n        if (mv != null) {\n            mv.visitMethodInsn(opcode, owner, name, desc);\n        }\n    }\n\n    /**\n     * Visits an invokedynamic instruction.\n     *\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor (see {@link Type Type}).\n     * @param bsm\n     *            the bootstrap method.\n     * @param bsmArgs\n     *            the bootstrap method constant arguments. Each argument must be\n     *            an {@link Integer}, {@link Float}, {@link Long},\n     *            {@link Double}, {@link String}, {@link Type} or {@link Handle}\n     *            value. This method is allowed to modify the content of the\n     *            array so a caller should expect that this array may change.\n     */\n    public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,\n            Object... bsmArgs) {\n        if (mv != null) {\n            mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);\n        }\n    }\n\n    /**\n     * Visits a jump instruction. A jump instruction is an instruction that may\n     * jump to another instruction.\n     *\n     * @param opcode\n     *            the opcode of the type instruction to be visited. This opcode\n     *            is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ,\n     *            IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE,\n     *            IF_ACMPEQ, IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL.\n     * @param label\n     *            the operand of the instruction to be visited. This operand is\n     *            a label that designates the instruction to which the jump\n     *            instruction may jump.\n     */\n    public void visitJumpInsn(int opcode, Label label) {\n        if (mv != null) {\n            mv.visitJumpInsn(opcode, label);\n        }\n    }\n\n    /**\n     * Visits a label. A label designates the instruction that will be visited\n     * just after it.\n     *\n     * @param label\n     *            a {@link Label Label} object.\n     */\n    public void visitLabel(Label label) {\n        if (mv != null) {\n            mv.visitLabel(label);\n        }\n    }\n\n    // -------------------------------------------------------------------------\n    // Special instructions\n    // -------------------------------------------------------------------------\n\n    /**\n     * Visits a LDC instruction. Note that new constant types may be added in\n     * future versions of the Java Virtual Machine. To easily detect new\n     * constant types, implementations of this method should check for\n     * unexpected constant types, like this:\n     *\n     * <pre>\n     * if (cst instanceof Integer) {\n     *     // ...\n     * } else if (cst instanceof Float) {\n     *     // ...\n     * } else if (cst instanceof Long) {\n     *     // ...\n     * } else if (cst instanceof Double) {\n     *     // ...\n     * } else if (cst instanceof String) {\n     *     // ...\n     * } else if (cst instanceof Type) {\n     *     int sort = ((Type) cst).getSort();\n     *     if (sort == Type.OBJECT) {\n     *         // ...\n     *     } else if (sort == Type.ARRAY) {\n     *         // ...\n     *     } else if (sort == Type.METHOD) {\n     *         // ...\n     *     } else {\n     *         // throw an exception\n     *     }\n     * } else if (cst instanceof Handle) {\n     *     // ...\n     * } else {\n     *     // throw an exception\n     * }\n     * </pre>\n     *\n     * @param cst\n     *            the constant to be loaded on the stack. This parameter must be\n     *            a non null {@link Integer}, a {@link Float}, a {@link Long}, a\n     *            {@link Double}, a {@link String}, a {@link Type} of OBJECT or\n     *            ARRAY sort for <tt>.class</tt> constants, for classes whose\n     *            version is 49.0, a {@link Type} of METHOD sort or a\n     *            {@link Handle} for MethodType and MethodHandle constants, for\n     *            classes whose version is 51.0.\n     */\n    public void visitLdcInsn(Object cst) {\n        if (mv != null) {\n            mv.visitLdcInsn(cst);\n        }\n    }\n\n    /**\n     * Visits an IINC instruction.\n     *\n     * @param var\n     *            index of the local variable to be incremented.\n     * @param increment\n     *            amount to increment the local variable by.\n     */\n    public void visitIincInsn(int var, int increment) {\n        if (mv != null) {\n            mv.visitIincInsn(var, increment);\n        }\n    }\n\n    /**\n     * Visits a TABLESWITCH instruction.\n     *\n     * @param min\n     *            the minimum key value.\n     * @param max\n     *            the maximum key value.\n     * @param dflt\n     *            beginning of the default handler block.\n     * @param labels\n     *            beginnings of the handler blocks. <tt>labels[i]</tt> is the\n     *            beginning of the handler block for the <tt>min + i</tt> key.\n     */\n    public void visitTableSwitchInsn(int min, int max, Label dflt,\n            Label... labels) {\n        if (mv != null) {\n            mv.visitTableSwitchInsn(min, max, dflt, labels);\n        }\n    }\n\n    /**\n     * Visits a LOOKUPSWITCH instruction.\n     *\n     * @param dflt\n     *            beginning of the default handler block.\n     * @param keys\n     *            the values of the keys.\n     * @param labels\n     *            beginnings of the handler blocks. <tt>labels[i]</tt> is the\n     *            beginning of the handler block for the <tt>keys[i]</tt> key.\n     */\n    public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {\n        if (mv != null) {\n            mv.visitLookupSwitchInsn(dflt, keys, labels);\n        }\n    }\n\n    /**\n     * Visits a MULTIANEWARRAY instruction.\n     *\n     * @param desc\n     *            an array type descriptor (see {@link Type Type}).\n     * @param dims\n     *            number of dimensions of the array to allocate.\n     */\n    public void visitMultiANewArrayInsn(String desc, int dims) {\n        if (mv != null) {\n            mv.visitMultiANewArrayInsn(desc, dims);\n        }\n    }\n\n    // -------------------------------------------------------------------------\n    // Exceptions table entries, debug information, max stack and max locals\n    // -------------------------------------------------------------------------\n\n    /**\n     * Visits a try catch block.\n     *\n     * @param start\n     *            beginning of the exception handler's scope (inclusive).\n     * @param end\n     *            end of the exception handler's scope (exclusive).\n     * @param handler\n     *            beginning of the exception handler's code.\n     * @param type\n     *            internal name of the type of exceptions handled by the\n     *            handler, or <tt>null</tt> to catch any exceptions (for\n     *            \"finally\" blocks).\n     * @throws IllegalArgumentException\n     *             if one of the labels has already been visited by this visitor\n     *             (by the {@link #visitLabel visitLabel} method).\n     */\n    public void visitTryCatchBlock(Label start, Label end, Label handler,\n            String type) {\n        if (mv != null) {\n            mv.visitTryCatchBlock(start, end, handler, type);\n        }\n    }\n\n    /**\n     * Visits a local variable declaration.\n     *\n     * @param name\n     *            the name of a local variable.\n     * @param desc\n     *            the type descriptor of this local variable.\n     * @param signature\n     *            the type signature of this local variable. May be\n     *            <tt>null</tt> if the local variable type does not use generic\n     *            types.\n     * @param start\n     *            the first instruction corresponding to the scope of this local\n     *            variable (inclusive).\n     * @param end\n     *            the last instruction corresponding to the scope of this local\n     *            variable (exclusive).\n     * @param index\n     *            the local variable's index.\n     * @throws IllegalArgumentException\n     *             if one of the labels has not already been visited by this\n     *             visitor (by the {@link #visitLabel visitLabel} method).\n     */\n    public void visitLocalVariable(String name, String desc, String signature,\n            Label start, Label end, int index) {\n        if (mv != null) {\n            mv.visitLocalVariable(name, desc, signature, start, end, index);\n        }\n    }\n\n    /**\n     * Visits a line number declaration.\n     *\n     * @param line\n     *            a line number. This number refers to the source file from\n     *            which the class was compiled.\n     * @param start\n     *            the first instruction corresponding to this line number.\n     * @throws IllegalArgumentException\n     *             if <tt>start</tt> has not already been visited by this\n     *             visitor (by the {@link #visitLabel visitLabel} method).\n     */\n    public void visitLineNumber(int line, Label start) {\n        if (mv != null) {\n            mv.visitLineNumber(line, start);\n        }\n    }\n\n    /**\n     * Visits the maximum stack size and the maximum number of local variables\n     * of the method.\n     *\n     * @param maxStack\n     *            maximum stack size of the method.\n     * @param maxLocals\n     *            maximum number of local variables for the method.\n     */\n    public void visitMaxs(int maxStack, int maxLocals) {\n        if (mv != null) {\n            mv.visitMaxs(maxStack, maxLocals);\n        }\n    }\n\n    /**\n     * Visits the end of the method. This method, which is the last one to be\n     * called, is used to inform the visitor that all the annotations and\n     * attributes of the method have been visited.\n     */\n    public void visitEnd() {\n        if (mv != null) {\n            mv.visitEnd();\n        }\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/MethodWriter.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * A {@link MethodVisitor} that generates methods in bytecode form. Each visit\n * method of this class appends the bytecode corresponding to the visited\n * instruction to a byte vector, in the order these methods are called.\n *\n * @author Eric Bruneton\n * @author Eugene Kuleshov\n */\nclass MethodWriter extends MethodVisitor {\n\n    /**\n     * Pseudo access flag used to denote constructors.\n     */\n    static final int ACC_CONSTRUCTOR = 0x80000;\n\n    /**\n     * Frame has exactly the same locals as the previous stack map frame and\n     * number of stack items is zero.\n     */\n    static final int SAME_FRAME = 0; // to 63 (0-3f)\n\n    /**\n     * Frame has exactly the same locals as the previous stack map frame and\n     * number of stack items is 1\n     */\n    static final int SAME_LOCALS_1_STACK_ITEM_FRAME = 64; // to 127 (40-7f)\n\n    /**\n     * Reserved for future use\n     */\n    static final int RESERVED = 128;\n\n    /**\n     * Frame has exactly the same locals as the previous stack map frame and\n     * number of stack items is 1. Offset is bigger then 63;\n     */\n    static final int SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED = 247; // f7\n\n    /**\n     * Frame where current locals are the same as the locals in the previous\n     * frame, except that the k last locals are absent. The value of k is given\n     * by the formula 251-frame_type.\n     */\n    static final int CHOP_FRAME = 248; // to 250 (f8-fA)\n\n    /**\n     * Frame has exactly the same locals as the previous stack map frame and\n     * number of stack items is zero. Offset is bigger then 63;\n     */\n    static final int SAME_FRAME_EXTENDED = 251; // fb\n\n    /**\n     * Frame where current locals are the same as the locals in the previous\n     * frame, except that k additional locals are defined. The value of k is\n     * given by the formula frame_type-251.\n     */\n    static final int APPEND_FRAME = 252; // to 254 // fc-fe\n\n    /**\n     * Full frame\n     */\n    static final int FULL_FRAME = 255; // ff\n\n    /**\n     * Indicates that the stack map frames must be recomputed from scratch. In\n     * this case the maximum stack size and number of local variables is also\n     * recomputed from scratch.\n     *\n     * @see #compute\n     */\n    private static final int FRAMES = 0;\n\n    /**\n     * Indicates that the maximum stack size and number of local variables must\n     * be automatically computed.\n     *\n     * @see #compute\n     */\n    private static final int MAXS = 1;\n\n    /**\n     * Indicates that nothing must be automatically computed.\n     *\n     * @see #compute\n     */\n    private static final int NOTHING = 2;\n\n    /**\n     * The class writer to which this method must be added.\n     */\n    final ClassWriter cw;\n\n    /**\n     * Access flags of this method.\n     */\n    private int access;\n\n    /**\n     * The index of the constant pool item that contains the name of this\n     * method.\n     */\n    private final int name;\n\n    /**\n     * The index of the constant pool item that contains the descriptor of this\n     * method.\n     */\n    private final int desc;\n\n    /**\n     * The descriptor of this method.\n     */\n    private final String descriptor;\n\n    /**\n     * The signature of this method.\n     */\n    String signature;\n\n    /**\n     * If not zero, indicates that the code of this method must be copied from\n     * the ClassReader associated to this writer in <code>cw.cr</code>. More\n     * precisely, this field gives the index of the first byte to copied from\n     * <code>cw.cr.b</code>.\n     */\n    int classReaderOffset;\n\n    /**\n     * If not zero, indicates that the code of this method must be copied from\n     * the ClassReader associated to this writer in <code>cw.cr</code>. More\n     * precisely, this field gives the number of bytes to copied from\n     * <code>cw.cr.b</code>.\n     */\n    int classReaderLength;\n\n    /**\n     * Number of exceptions that can be thrown by this method.\n     */\n    int exceptionCount;\n\n    /**\n     * The exceptions that can be thrown by this method. More precisely, this\n     * array contains the indexes of the constant pool items that contain the\n     * internal names of these exception classes.\n     */\n    int[] exceptions;\n\n    /**\n     * The annotation default attribute of this method. May be <tt>null</tt>.\n     */\n    private ByteVector annd;\n\n    /**\n     * The runtime visible annotations of this method. May be <tt>null</tt>.\n     */\n    private AnnotationWriter anns;\n\n    /**\n     * The runtime invisible annotations of this method. May be <tt>null</tt>.\n     */\n    private AnnotationWriter ianns;\n\n    /**\n     * The runtime visible parameter annotations of this method. May be\n     * <tt>null</tt>.\n     */\n    private AnnotationWriter[] panns;\n\n    /**\n     * The runtime invisible parameter annotations of this method. May be\n     * <tt>null</tt>.\n     */\n    private AnnotationWriter[] ipanns;\n\n    /**\n     * The number of synthetic parameters of this method.\n     */\n    private int synthetics;\n\n    /**\n     * The non standard attributes of the method.\n     */\n    private Attribute attrs;\n\n    /**\n     * The bytecode of this method.\n     */\n    private ByteVector code = new ByteVector();\n\n    /**\n     * Maximum stack size of this method.\n     */\n    private int maxStack;\n\n    /**\n     * Maximum number of local variables for this method.\n     */\n    private int maxLocals;\n\n    /**\n     * Number of local variables in the current stack map frame.\n     */\n    private int currentLocals;\n\n    /**\n     * Number of stack map frames in the StackMapTable attribute.\n     */\n    private int frameCount;\n\n    /**\n     * The StackMapTable attribute.\n     */\n    private ByteVector stackMap;\n\n    /**\n     * The offset of the last frame that was written in the StackMapTable\n     * attribute.\n     */\n    private int previousFrameOffset;\n\n    /**\n     * The last frame that was written in the StackMapTable attribute.\n     *\n     * @see #frame\n     */\n    private int[] previousFrame;\n\n    /**\n     * The current stack map frame. The first element contains the offset of the\n     * instruction to which the frame corresponds, the second element is the\n     * number of locals and the third one is the number of stack elements. The\n     * local variables start at index 3 and are followed by the operand stack\n     * values. In summary frame[0] = offset, frame[1] = nLocal, frame[2] =\n     * nStack, frame[3] = nLocal. All types are encoded as integers, with the\n     * same format as the one used in {@link Label}, but limited to BASE types.\n     */\n    private int[] frame;\n\n    /**\n     * Number of elements in the exception handler list.\n     */\n    private int handlerCount;\n\n    /**\n     * The first element in the exception handler list.\n     */\n    private Handler firstHandler;\n\n    /**\n     * The last element in the exception handler list.\n     */\n    private Handler lastHandler;\n\n    /**\n     * Number of entries in the LocalVariableTable attribute.\n     */\n    private int localVarCount;\n\n    /**\n     * The LocalVariableTable attribute.\n     */\n    private ByteVector localVar;\n\n    /**\n     * Number of entries in the LocalVariableTypeTable attribute.\n     */\n    private int localVarTypeCount;\n\n    /**\n     * The LocalVariableTypeTable attribute.\n     */\n    private ByteVector localVarType;\n\n    /**\n     * Number of entries in the LineNumberTable attribute.\n     */\n    private int lineNumberCount;\n\n    /**\n     * The LineNumberTable attribute.\n     */\n    private ByteVector lineNumber;\n\n    /**\n     * The non standard attributes of the method's code.\n     */\n    private Attribute cattrs;\n\n    /**\n     * Indicates if some jump instructions are too small and need to be resized.\n     */\n    private boolean resize;\n\n    /**\n     * The number of subroutines in this method.\n     */\n    private int subroutines;\n\n    // ------------------------------------------------------------------------\n\n    /*\n     * Fields for the control flow graph analysis algorithm (used to compute the\n     * maximum stack size). A control flow graph contains one node per \"basic\n     * block\", and one edge per \"jump\" from one basic block to another. Each\n     * node (i.e., each basic block) is represented by the Label object that\n     * corresponds to the first instruction of this basic block. Each node also\n     * stores the list of its successors in the graph, as a linked list of Edge\n     * objects.\n     */\n\n    /**\n     * Indicates what must be automatically computed.\n     *\n     * @see #FRAMES\n     * @see #MAXS\n     * @see #NOTHING\n     */\n    private final int compute;\n\n    /**\n     * A list of labels. This list is the list of basic blocks in the method,\n     * i.e. a list of Label objects linked to each other by their\n     * {@link Label#successor} field, in the order they are visited by\n     * {@link MethodVisitor#visitLabel}, and starting with the first basic\n     * block.\n     */\n    private Label labels;\n\n    /**\n     * The previous basic block.\n     */\n    private Label previousBlock;\n\n    /**\n     * The current basic block.\n     */\n    private Label currentBlock;\n\n    /**\n     * The (relative) stack size after the last visited instruction. This size\n     * is relative to the beginning of the current basic block, i.e., the true\n     * stack size after the last visited instruction is equal to the\n     * {@link Label#inputStackTop beginStackSize} of the current basic block\n     * plus <tt>stackSize</tt>.\n     */\n    private int stackSize;\n\n    /**\n     * The (relative) maximum stack size after the last visited instruction.\n     * This size is relative to the beginning of the current basic block, i.e.,\n     * the true maximum stack size after the last visited instruction is equal\n     * to the {@link Label#inputStackTop beginStackSize} of the current basic\n     * block plus <tt>stackSize</tt>.\n     */\n    private int maxStackSize;\n\n    // ------------------------------------------------------------------------\n    // Constructor\n    // ------------------------------------------------------------------------\n\n    /**\n     * Constructs a new {@link MethodWriter}.\n     *\n     * @param cw\n     *            the class writer in which the method must be added.\n     * @param access\n     *            the method's access flags (see {@link Opcodes}).\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor (see {@link Type}).\n     * @param signature\n     *            the method's signature. May be <tt>null</tt>.\n     * @param exceptions\n     *            the internal names of the method's exceptions. May be\n     *            <tt>null</tt>.\n     * @param computeMaxs\n     *            <tt>true</tt> if the maximum stack size and number of local\n     *            variables must be automatically computed.\n     * @param computeFrames\n     *            <tt>true</tt> if the stack map tables must be recomputed from\n     *            scratch.\n     */\n    MethodWriter(final ClassWriter cw, final int access, final String name,\n            final String desc, final String signature,\n            final String[] exceptions, final boolean computeMaxs,\n            final boolean computeFrames) {\n        super(Opcodes.ASM4);\n        if (cw.firstMethod == null) {\n            cw.firstMethod = this;\n        } else {\n            cw.lastMethod.mv = this;\n        }\n        cw.lastMethod = this;\n        this.cw = cw;\n        this.access = access;\n        if (\"<init>\".equals(name)) {\n            this.access |= ACC_CONSTRUCTOR;\n        }\n        this.name = cw.newUTF8(name);\n        this.desc = cw.newUTF8(desc);\n        this.descriptor = desc;\n        if (ClassReader.SIGNATURES) {\n            this.signature = signature;\n        }\n        if (exceptions != null && exceptions.length > 0) {\n            exceptionCount = exceptions.length;\n            this.exceptions = new int[exceptionCount];\n            for (int i = 0; i < exceptionCount; ++i) {\n                this.exceptions[i] = cw.newClass(exceptions[i]);\n            }\n        }\n        this.compute = computeFrames ? FRAMES : (computeMaxs ? MAXS : NOTHING);\n        if (computeMaxs || computeFrames) {\n            // updates maxLocals\n            int size = Type.getArgumentsAndReturnSizes(descriptor) >> 2;\n            if ((access & Opcodes.ACC_STATIC) != 0) {\n                --size;\n            }\n            maxLocals = size;\n            currentLocals = size;\n            // creates and visits the label for the first basic block\n            labels = new Label();\n            labels.status |= Label.PUSHED;\n            visitLabel(labels);\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Implementation of the MethodVisitor abstract class\n    // ------------------------------------------------------------------------\n\n    @Override\n    public AnnotationVisitor visitAnnotationDefault() {\n        if (!ClassReader.ANNOTATIONS) {\n            return null;\n        }\n        annd = new ByteVector();\n        return new AnnotationWriter(cw, false, annd, null, 0);\n    }\n\n    @Override\n    public AnnotationVisitor visitAnnotation(final String desc,\n            final boolean visible) {\n        if (!ClassReader.ANNOTATIONS) {\n            return null;\n        }\n        ByteVector bv = new ByteVector();\n        // write type, and reserve space for values count\n        bv.putShort(cw.newUTF8(desc)).putShort(0);\n        AnnotationWriter aw = new AnnotationWriter(cw, true, bv, bv, 2);\n        if (visible) {\n            aw.next = anns;\n            anns = aw;\n        } else {\n            aw.next = ianns;\n            ianns = aw;\n        }\n        return aw;\n    }\n\n    @Override\n    public AnnotationVisitor visitParameterAnnotation(final int parameter,\n            final String desc, final boolean visible) {\n        if (!ClassReader.ANNOTATIONS) {\n            return null;\n        }\n        ByteVector bv = new ByteVector();\n        if (\"Ljava/lang/Synthetic;\".equals(desc)) {\n            // workaround for a bug in javac with synthetic parameters\n            // see ClassReader.readParameterAnnotations\n            synthetics = Math.max(synthetics, parameter + 1);\n            return new AnnotationWriter(cw, false, bv, null, 0);\n        }\n        // write type, and reserve space for values count\n        bv.putShort(cw.newUTF8(desc)).putShort(0);\n        AnnotationWriter aw = new AnnotationWriter(cw, true, bv, bv, 2);\n        if (visible) {\n            if (panns == null) {\n                panns = new AnnotationWriter[Type.getArgumentTypes(descriptor).length];\n            }\n            aw.next = panns[parameter];\n            panns[parameter] = aw;\n        } else {\n            if (ipanns == null) {\n                ipanns = new AnnotationWriter[Type.getArgumentTypes(descriptor).length];\n            }\n            aw.next = ipanns[parameter];\n            ipanns[parameter] = aw;\n        }\n        return aw;\n    }\n\n    @Override\n    public void visitAttribute(final Attribute attr) {\n        if (attr.isCodeAttribute()) {\n            attr.next = cattrs;\n            cattrs = attr;\n        } else {\n            attr.next = attrs;\n            attrs = attr;\n        }\n    }\n\n    @Override\n    public void visitCode() {\n    }\n\n    @Override\n    public void visitFrame(final int type, final int nLocal,\n            final Object[] local, final int nStack, final Object[] stack) {\n        if (!ClassReader.FRAMES || compute == FRAMES) {\n            return;\n        }\n\n        if (type == Opcodes.F_NEW) {\n            if (previousFrame == null) {\n                visitImplicitFirstFrame();\n            }\n            currentLocals = nLocal;\n            int frameIndex = startFrame(code.length, nLocal, nStack);\n            for (int i = 0; i < nLocal; ++i) {\n                if (local[i] instanceof String) {\n                    frame[frameIndex++] = Frame.OBJECT\n                            | cw.addType((String) local[i]);\n                } else if (local[i] instanceof Integer) {\n                    frame[frameIndex++] = ((Integer) local[i]).intValue();\n                } else {\n                    frame[frameIndex++] = Frame.UNINITIALIZED\n                            | cw.addUninitializedType(\"\",\n                                    ((Label) local[i]).position);\n                }\n            }\n            for (int i = 0; i < nStack; ++i) {\n                if (stack[i] instanceof String) {\n                    frame[frameIndex++] = Frame.OBJECT\n                            | cw.addType((String) stack[i]);\n                } else if (stack[i] instanceof Integer) {\n                    frame[frameIndex++] = ((Integer) stack[i]).intValue();\n                } else {\n                    frame[frameIndex++] = Frame.UNINITIALIZED\n                            | cw.addUninitializedType(\"\",\n                                    ((Label) stack[i]).position);\n                }\n            }\n            endFrame();\n        } else {\n            int delta;\n            if (stackMap == null) {\n                stackMap = new ByteVector();\n                delta = code.length;\n            } else {\n                delta = code.length - previousFrameOffset - 1;\n                if (delta < 0) {\n                    if (type == Opcodes.F_SAME) {\n                        return;\n                    } else {\n                        throw new IllegalStateException();\n                    }\n                }\n            }\n\n            switch (type) {\n            case Opcodes.F_FULL:\n                currentLocals = nLocal;\n                stackMap.putByte(FULL_FRAME).putShort(delta).putShort(nLocal);\n                for (int i = 0; i < nLocal; ++i) {\n                    writeFrameType(local[i]);\n                }\n                stackMap.putShort(nStack);\n                for (int i = 0; i < nStack; ++i) {\n                    writeFrameType(stack[i]);\n                }\n                break;\n            case Opcodes.F_APPEND:\n                currentLocals += nLocal;\n                stackMap.putByte(SAME_FRAME_EXTENDED + nLocal).putShort(delta);\n                for (int i = 0; i < nLocal; ++i) {\n                    writeFrameType(local[i]);\n                }\n                break;\n            case Opcodes.F_CHOP:\n                currentLocals -= nLocal;\n                stackMap.putByte(SAME_FRAME_EXTENDED - nLocal).putShort(delta);\n                break;\n            case Opcodes.F_SAME:\n                if (delta < 64) {\n                    stackMap.putByte(delta);\n                } else {\n                    stackMap.putByte(SAME_FRAME_EXTENDED).putShort(delta);\n                }\n                break;\n            case Opcodes.F_SAME1:\n                if (delta < 64) {\n                    stackMap.putByte(SAME_LOCALS_1_STACK_ITEM_FRAME + delta);\n                } else {\n                    stackMap.putByte(SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED)\n                            .putShort(delta);\n                }\n                writeFrameType(stack[0]);\n                break;\n            }\n\n            previousFrameOffset = code.length;\n            ++frameCount;\n        }\n\n        maxStack = Math.max(maxStack, nStack);\n        maxLocals = Math.max(maxLocals, currentLocals);\n    }\n\n    @Override\n    public void visitInsn(final int opcode) {\n        // adds the instruction to the bytecode of the method\n        code.putByte(opcode);\n        // update currentBlock\n        // Label currentBlock = this.currentBlock;\n        if (currentBlock != null) {\n            if (compute == FRAMES) {\n                currentBlock.frame.execute(opcode, 0, null, null);\n            } else {\n                // updates current and max stack sizes\n                int size = stackSize + Frame.SIZE[opcode];\n                if (size > maxStackSize) {\n                    maxStackSize = size;\n                }\n                stackSize = size;\n            }\n            // if opcode == ATHROW or xRETURN, ends current block (no successor)\n            if ((opcode >= Opcodes.IRETURN && opcode <= Opcodes.RETURN)\n                    || opcode == Opcodes.ATHROW) {\n                noSuccessor();\n            }\n        }\n    }\n\n    @Override\n    public void visitIntInsn(final int opcode, final int operand) {\n        // Label currentBlock = this.currentBlock;\n        if (currentBlock != null) {\n            if (compute == FRAMES) {\n                currentBlock.frame.execute(opcode, operand, null, null);\n            } else if (opcode != Opcodes.NEWARRAY) {\n                // updates current and max stack sizes only for NEWARRAY\n                // (stack size variation = 0 for BIPUSH or SIPUSH)\n                int size = stackSize + 1;\n                if (size > maxStackSize) {\n                    maxStackSize = size;\n                }\n                stackSize = size;\n            }\n        }\n        // adds the instruction to the bytecode of the method\n        if (opcode == Opcodes.SIPUSH) {\n            code.put12(opcode, operand);\n        } else { // BIPUSH or NEWARRAY\n            code.put11(opcode, operand);\n        }\n    }\n\n    @Override\n    public void visitVarInsn(final int opcode, final int var) {\n        // Label currentBlock = this.currentBlock;\n        if (currentBlock != null) {\n            if (compute == FRAMES) {\n                currentBlock.frame.execute(opcode, var, null, null);\n            } else {\n                // updates current and max stack sizes\n                if (opcode == Opcodes.RET) {\n                    // no stack change, but end of current block (no successor)\n                    currentBlock.status |= Label.RET;\n                    // save 'stackSize' here for future use\n                    // (see {@link #findSubroutineSuccessors})\n                    currentBlock.inputStackTop = stackSize;\n                    noSuccessor();\n                } else { // xLOAD or xSTORE\n                    int size = stackSize + Frame.SIZE[opcode];\n                    if (size > maxStackSize) {\n                        maxStackSize = size;\n                    }\n                    stackSize = size;\n                }\n            }\n        }\n        if (compute != NOTHING) {\n            // updates max locals\n            int n;\n            if (opcode == Opcodes.LLOAD || opcode == Opcodes.DLOAD\n                    || opcode == Opcodes.LSTORE || opcode == Opcodes.DSTORE) {\n                n = var + 2;\n            } else {\n                n = var + 1;\n            }\n            if (n > maxLocals) {\n                maxLocals = n;\n            }\n        }\n        // adds the instruction to the bytecode of the method\n        if (var < 4 && opcode != Opcodes.RET) {\n            int opt;\n            if (opcode < Opcodes.ISTORE) {\n                /* ILOAD_0 */\n                opt = 26 + ((opcode - Opcodes.ILOAD) << 2) + var;\n            } else {\n                /* ISTORE_0 */\n                opt = 59 + ((opcode - Opcodes.ISTORE) << 2) + var;\n            }\n            code.putByte(opt);\n        } else if (var >= 256) {\n            code.putByte(196 /* WIDE */).put12(opcode, var);\n        } else {\n            code.put11(opcode, var);\n        }\n        if (opcode >= Opcodes.ISTORE && compute == FRAMES && handlerCount > 0) {\n            visitLabel(new Label());\n        }\n    }\n\n    @Override\n    public void visitTypeInsn(final int opcode, final String type) {\n        Item i = cw.newClassItem(type);\n        // Label currentBlock = this.currentBlock;\n        if (currentBlock != null) {\n            if (compute == FRAMES) {\n                currentBlock.frame.execute(opcode, code.length, cw, i);\n            } else if (opcode == Opcodes.NEW) {\n                // updates current and max stack sizes only if opcode == NEW\n                // (no stack change for ANEWARRAY, CHECKCAST, INSTANCEOF)\n                int size = stackSize + 1;\n                if (size > maxStackSize) {\n                    maxStackSize = size;\n                }\n                stackSize = size;\n            }\n        }\n        // adds the instruction to the bytecode of the method\n        code.put12(opcode, i.index);\n    }\n\n    @Override\n    public void visitFieldInsn(final int opcode, final String owner,\n            final String name, final String desc) {\n        Item i = cw.newFieldItem(owner, name, desc);\n        // Label currentBlock = this.currentBlock;\n        if (currentBlock != null) {\n            if (compute == FRAMES) {\n                currentBlock.frame.execute(opcode, 0, cw, i);\n            } else {\n                int size;\n                // computes the stack size variation\n                char c = desc.charAt(0);\n                switch (opcode) {\n                case Opcodes.GETSTATIC:\n                    size = stackSize + (c == 'D' || c == 'J' ? 2 : 1);\n                    break;\n                case Opcodes.PUTSTATIC:\n                    size = stackSize + (c == 'D' || c == 'J' ? -2 : -1);\n                    break;\n                case Opcodes.GETFIELD:\n                    size = stackSize + (c == 'D' || c == 'J' ? 1 : 0);\n                    break;\n                // case Constants.PUTFIELD:\n                default:\n                    size = stackSize + (c == 'D' || c == 'J' ? -3 : -2);\n                    break;\n                }\n                // updates current and max stack sizes\n                if (size > maxStackSize) {\n                    maxStackSize = size;\n                }\n                stackSize = size;\n            }\n        }\n        // adds the instruction to the bytecode of the method\n        code.put12(opcode, i.index);\n    }\n\n    @Override\n    public void visitMethodInsn(final int opcode, final String owner,\n            final String name, final String desc) {\n        boolean itf = opcode == Opcodes.INVOKEINTERFACE;\n        Item i = cw.newMethodItem(owner, name, desc, itf);\n        int argSize = i.intVal;\n        // Label currentBlock = this.currentBlock;\n        if (currentBlock != null) {\n            if (compute == FRAMES) {\n                currentBlock.frame.execute(opcode, 0, cw, i);\n            } else {\n                /*\n                 * computes the stack size variation. In order not to recompute\n                 * several times this variation for the same Item, we use the\n                 * intVal field of this item to store this variation, once it\n                 * has been computed. More precisely this intVal field stores\n                 * the sizes of the arguments and of the return value\n                 * corresponding to desc.\n                 */\n                if (argSize == 0) {\n                    // the above sizes have not been computed yet,\n                    // so we compute them...\n                    argSize = Type.getArgumentsAndReturnSizes(desc);\n                    // ... and we save them in order\n                    // not to recompute them in the future\n                    i.intVal = argSize;\n                }\n                int size;\n                if (opcode == Opcodes.INVOKESTATIC) {\n                    size = stackSize - (argSize >> 2) + (argSize & 0x03) + 1;\n                } else {\n                    size = stackSize - (argSize >> 2) + (argSize & 0x03);\n                }\n                // updates current and max stack sizes\n                if (size > maxStackSize) {\n                    maxStackSize = size;\n                }\n                stackSize = size;\n            }\n        }\n        // adds the instruction to the bytecode of the method\n        if (itf) {\n            if (argSize == 0) {\n                argSize = Type.getArgumentsAndReturnSizes(desc);\n                i.intVal = argSize;\n            }\n            code.put12(Opcodes.INVOKEINTERFACE, i.index).put11(argSize >> 2, 0);\n        } else {\n            code.put12(opcode, i.index);\n        }\n    }\n\n    @Override\n    public void visitInvokeDynamicInsn(final String name, final String desc,\n            final Handle bsm, final Object... bsmArgs) {\n        Item i = cw.newInvokeDynamicItem(name, desc, bsm, bsmArgs);\n        int argSize = i.intVal;\n        // Label currentBlock = this.currentBlock;\n        if (currentBlock != null) {\n            if (compute == FRAMES) {\n                currentBlock.frame.execute(Opcodes.INVOKEDYNAMIC, 0, cw, i);\n            } else {\n                /*\n                 * computes the stack size variation. In order not to recompute\n                 * several times this variation for the same Item, we use the\n                 * intVal field of this item to store this variation, once it\n                 * has been computed. More precisely this intVal field stores\n                 * the sizes of the arguments and of the return value\n                 * corresponding to desc.\n                 */\n                if (argSize == 0) {\n                    // the above sizes have not been computed yet,\n                    // so we compute them...\n                    argSize = Type.getArgumentsAndReturnSizes(desc);\n                    // ... and we save them in order\n                    // not to recompute them in the future\n                    i.intVal = argSize;\n                }\n                int size = stackSize - (argSize >> 2) + (argSize & 0x03) + 1;\n\n                // updates current and max stack sizes\n                if (size > maxStackSize) {\n                    maxStackSize = size;\n                }\n                stackSize = size;\n            }\n        }\n        // adds the instruction to the bytecode of the method\n        code.put12(Opcodes.INVOKEDYNAMIC, i.index);\n        code.putShort(0);\n    }\n\n    @Override\n    public void visitJumpInsn(final int opcode, final Label label) {\n        Label nextInsn = null;\n        // Label currentBlock = this.currentBlock;\n        if (currentBlock != null) {\n            if (compute == FRAMES) {\n                currentBlock.frame.execute(opcode, 0, null, null);\n                // 'label' is the target of a jump instruction\n                label.getFirst().status |= Label.TARGET;\n                // adds 'label' as a successor of this basic block\n                addSuccessor(Edge.NORMAL, label);\n                if (opcode != Opcodes.GOTO) {\n                    // creates a Label for the next basic block\n                    nextInsn = new Label();\n                }\n            } else {\n                if (opcode == Opcodes.JSR) {\n                    if ((label.status & Label.SUBROUTINE) == 0) {\n                        label.status |= Label.SUBROUTINE;\n                        ++subroutines;\n                    }\n                    currentBlock.status |= Label.JSR;\n                    addSuccessor(stackSize + 1, label);\n                    // creates a Label for the next basic block\n                    nextInsn = new Label();\n                    /*\n                     * note that, by construction in this method, a JSR block\n                     * has at least two successors in the control flow graph:\n                     * the first one leads the next instruction after the JSR,\n                     * while the second one leads to the JSR target.\n                     */\n                } else {\n                    // updates current stack size (max stack size unchanged\n                    // because stack size variation always negative in this\n                    // case)\n                    stackSize += Frame.SIZE[opcode];\n                    addSuccessor(stackSize, label);\n                }\n            }\n        }\n        // adds the instruction to the bytecode of the method\n        if ((label.status & Label.RESOLVED) != 0\n                && label.position - code.length < Short.MIN_VALUE) {\n            /*\n             * case of a backward jump with an offset < -32768. In this case we\n             * automatically replace GOTO with GOTO_W, JSR with JSR_W and IFxxx\n             * <l> with IFNOTxxx <l'> GOTO_W <l>, where IFNOTxxx is the\n             * \"opposite\" opcode of IFxxx (i.e., IFNE for IFEQ) and where <l'>\n             * designates the instruction just after the GOTO_W.\n             */\n            if (opcode == Opcodes.GOTO) {\n                code.putByte(200); // GOTO_W\n            } else if (opcode == Opcodes.JSR) {\n                code.putByte(201); // JSR_W\n            } else {\n                // if the IF instruction is transformed into IFNOT GOTO_W the\n                // next instruction becomes the target of the IFNOT instruction\n                if (nextInsn != null) {\n                    nextInsn.status |= Label.TARGET;\n                }\n                code.putByte(opcode <= 166 ? ((opcode + 1) ^ 1) - 1\n                        : opcode ^ 1);\n                code.putShort(8); // jump offset\n                code.putByte(200); // GOTO_W\n            }\n            label.put(this, code, code.length - 1, true);\n        } else {\n            /*\n             * case of a backward jump with an offset >= -32768, or of a forward\n             * jump with, of course, an unknown offset. In these cases we store\n             * the offset in 2 bytes (which will be increased in\n             * resizeInstructions, if needed).\n             */\n            code.putByte(opcode);\n            label.put(this, code, code.length - 1, false);\n        }\n        if (currentBlock != null) {\n            if (nextInsn != null) {\n                // if the jump instruction is not a GOTO, the next instruction\n                // is also a successor of this instruction. Calling visitLabel\n                // adds the label of this next instruction as a successor of the\n                // current block, and starts a new basic block\n                visitLabel(nextInsn);\n            }\n            if (opcode == Opcodes.GOTO) {\n                noSuccessor();\n            }\n        }\n    }\n\n    @Override\n    public void visitLabel(final Label label) {\n        // resolves previous forward references to label, if any\n        resize |= label.resolve(this, code.length, code.data);\n        // updates currentBlock\n        if ((label.status & Label.DEBUG) != 0) {\n            return;\n        }\n        if (compute == FRAMES) {\n            if (currentBlock != null) {\n                if (label.position == currentBlock.position) {\n                    // successive labels, do not start a new basic block\n                    currentBlock.status |= (label.status & Label.TARGET);\n                    label.frame = currentBlock.frame;\n                    return;\n                }\n                // ends current block (with one new successor)\n                addSuccessor(Edge.NORMAL, label);\n            }\n            // begins a new current block\n            currentBlock = label;\n            if (label.frame == null) {\n                label.frame = new Frame();\n                label.frame.owner = label;\n            }\n            // updates the basic block list\n            if (previousBlock != null) {\n                if (label.position == previousBlock.position) {\n                    previousBlock.status |= (label.status & Label.TARGET);\n                    label.frame = previousBlock.frame;\n                    currentBlock = previousBlock;\n                    return;\n                }\n                previousBlock.successor = label;\n            }\n            previousBlock = label;\n        } else if (compute == MAXS) {\n            if (currentBlock != null) {\n                // ends current block (with one new successor)\n                currentBlock.outputStackMax = maxStackSize;\n                addSuccessor(stackSize, label);\n            }\n            // begins a new current block\n            currentBlock = label;\n            // resets the relative current and max stack sizes\n            stackSize = 0;\n            maxStackSize = 0;\n            // updates the basic block list\n            if (previousBlock != null) {\n                previousBlock.successor = label;\n            }\n            previousBlock = label;\n        }\n    }\n\n    @Override\n    public void visitLdcInsn(final Object cst) {\n        Item i = cw.newConstItem(cst);\n        // Label currentBlock = this.currentBlock;\n        if (currentBlock != null) {\n            if (compute == FRAMES) {\n                currentBlock.frame.execute(Opcodes.LDC, 0, cw, i);\n            } else {\n                int size;\n                // computes the stack size variation\n                if (i.type == ClassWriter.LONG || i.type == ClassWriter.DOUBLE) {\n                    size = stackSize + 2;\n                } else {\n                    size = stackSize + 1;\n                }\n                // updates current and max stack sizes\n                if (size > maxStackSize) {\n                    maxStackSize = size;\n                }\n                stackSize = size;\n            }\n        }\n        // adds the instruction to the bytecode of the method\n        int index = i.index;\n        if (i.type == ClassWriter.LONG || i.type == ClassWriter.DOUBLE) {\n            code.put12(20 /* LDC2_W */, index);\n        } else if (index >= 256) {\n            code.put12(19 /* LDC_W */, index);\n        } else {\n            code.put11(Opcodes.LDC, index);\n        }\n    }\n\n    @Override\n    public void visitIincInsn(final int var, final int increment) {\n        if (currentBlock != null) {\n            if (compute == FRAMES) {\n                currentBlock.frame.execute(Opcodes.IINC, var, null, null);\n            }\n        }\n        if (compute != NOTHING) {\n            // updates max locals\n            int n = var + 1;\n            if (n > maxLocals) {\n                maxLocals = n;\n            }\n        }\n        // adds the instruction to the bytecode of the method\n        if ((var > 255) || (increment > 127) || (increment < -128)) {\n            code.putByte(196 /* WIDE */).put12(Opcodes.IINC, var)\n                    .putShort(increment);\n        } else {\n            code.putByte(Opcodes.IINC).put11(var, increment);\n        }\n    }\n\n    @Override\n    public void visitTableSwitchInsn(final int min, final int max,\n            final Label dflt, final Label... labels) {\n        // adds the instruction to the bytecode of the method\n        int source = code.length;\n        code.putByte(Opcodes.TABLESWITCH);\n        code.putByteArray(null, 0, (4 - code.length % 4) % 4);\n        dflt.put(this, code, source, true);\n        code.putInt(min).putInt(max);\n        for (int i = 0; i < labels.length; ++i) {\n            labels[i].put(this, code, source, true);\n        }\n        // updates currentBlock\n        visitSwitchInsn(dflt, labels);\n    }\n\n    @Override\n    public void visitLookupSwitchInsn(final Label dflt, final int[] keys,\n            final Label[] labels) {\n        // adds the instruction to the bytecode of the method\n        int source = code.length;\n        code.putByte(Opcodes.LOOKUPSWITCH);\n        code.putByteArray(null, 0, (4 - code.length % 4) % 4);\n        dflt.put(this, code, source, true);\n        code.putInt(labels.length);\n        for (int i = 0; i < labels.length; ++i) {\n            code.putInt(keys[i]);\n            labels[i].put(this, code, source, true);\n        }\n        // updates currentBlock\n        visitSwitchInsn(dflt, labels);\n    }\n\n    private void visitSwitchInsn(final Label dflt, final Label[] labels) {\n        // Label currentBlock = this.currentBlock;\n        if (currentBlock != null) {\n            if (compute == FRAMES) {\n                currentBlock.frame.execute(Opcodes.LOOKUPSWITCH, 0, null, null);\n                // adds current block successors\n                addSuccessor(Edge.NORMAL, dflt);\n                dflt.getFirst().status |= Label.TARGET;\n                for (int i = 0; i < labels.length; ++i) {\n                    addSuccessor(Edge.NORMAL, labels[i]);\n                    labels[i].getFirst().status |= Label.TARGET;\n                }\n            } else {\n                // updates current stack size (max stack size unchanged)\n                --stackSize;\n                // adds current block successors\n                addSuccessor(stackSize, dflt);\n                for (int i = 0; i < labels.length; ++i) {\n                    addSuccessor(stackSize, labels[i]);\n                }\n            }\n            // ends current block\n            noSuccessor();\n        }\n    }\n\n    @Override\n    public void visitMultiANewArrayInsn(final String desc, final int dims) {\n        Item i = cw.newClassItem(desc);\n        // Label currentBlock = this.currentBlock;\n        if (currentBlock != null) {\n            if (compute == FRAMES) {\n                currentBlock.frame.execute(Opcodes.MULTIANEWARRAY, dims, cw, i);\n            } else {\n                // updates current stack size (max stack size unchanged because\n                // stack size variation always negative or null)\n                stackSize += 1 - dims;\n            }\n        }\n        // adds the instruction to the bytecode of the method\n        code.put12(Opcodes.MULTIANEWARRAY, i.index).putByte(dims);\n    }\n\n    @Override\n    public void visitTryCatchBlock(final Label start, final Label end,\n            final Label handler, final String type) {\n        ++handlerCount;\n        Handler h = new Handler();\n        h.start = start;\n        h.end = end;\n        h.handler = handler;\n        h.desc = type;\n        h.type = type != null ? cw.newClass(type) : 0;\n        if (lastHandler == null) {\n            firstHandler = h;\n        } else {\n            lastHandler.next = h;\n        }\n        lastHandler = h;\n    }\n\n    @Override\n    public void visitLocalVariable(final String name, final String desc,\n            final String signature, final Label start, final Label end,\n            final int index) {\n        if (signature != null) {\n            if (localVarType == null) {\n                localVarType = new ByteVector();\n            }\n            ++localVarTypeCount;\n            localVarType.putShort(start.position)\n                    .putShort(end.position - start.position)\n                    .putShort(cw.newUTF8(name)).putShort(cw.newUTF8(signature))\n                    .putShort(index);\n        }\n        if (localVar == null) {\n            localVar = new ByteVector();\n        }\n        ++localVarCount;\n        localVar.putShort(start.position)\n                .putShort(end.position - start.position)\n                .putShort(cw.newUTF8(name)).putShort(cw.newUTF8(desc))\n                .putShort(index);\n        if (compute != NOTHING) {\n            // updates max locals\n            char c = desc.charAt(0);\n            int n = index + (c == 'J' || c == 'D' ? 2 : 1);\n            if (n > maxLocals) {\n                maxLocals = n;\n            }\n        }\n    }\n\n    @Override\n    public void visitLineNumber(final int line, final Label start) {\n        if (lineNumber == null) {\n            lineNumber = new ByteVector();\n        }\n        ++lineNumberCount;\n        lineNumber.putShort(start.position);\n        lineNumber.putShort(line);\n    }\n\n    @Override\n    public void visitMaxs(final int maxStack, final int maxLocals) {\n        if (ClassReader.FRAMES && compute == FRAMES) {\n            // completes the control flow graph with exception handler blocks\n            Handler handler = firstHandler;\n            while (handler != null) {\n                Label l = handler.start.getFirst();\n                Label h = handler.handler.getFirst();\n                Label e = handler.end.getFirst();\n                // computes the kind of the edges to 'h'\n                String t = handler.desc == null ? \"java/lang/Throwable\"\n                        : handler.desc;\n                int kind = Frame.OBJECT | cw.addType(t);\n                // h is an exception handler\n                h.status |= Label.TARGET;\n                // adds 'h' as a successor of labels between 'start' and 'end'\n                while (l != e) {\n                    // creates an edge to 'h'\n                    Edge b = new Edge();\n                    b.info = kind;\n                    b.successor = h;\n                    // adds it to the successors of 'l'\n                    b.next = l.successors;\n                    l.successors = b;\n                    // goes to the next label\n                    l = l.successor;\n                }\n                handler = handler.next;\n            }\n\n            // creates and visits the first (implicit) frame\n            Frame f = labels.frame;\n            Type[] args = Type.getArgumentTypes(descriptor);\n            f.initInputFrame(cw, access, args, this.maxLocals);\n            visitFrame(f);\n\n            /*\n             * fix point algorithm: mark the first basic block as 'changed'\n             * (i.e. put it in the 'changed' list) and, while there are changed\n             * basic blocks, choose one, mark it as unchanged, and update its\n             * successors (which can be changed in the process).\n             */\n            int max = 0;\n            Label changed = labels;\n            while (changed != null) {\n                // removes a basic block from the list of changed basic blocks\n                Label l = changed;\n                changed = changed.next;\n                l.next = null;\n                f = l.frame;\n                // a reachable jump target must be stored in the stack map\n                if ((l.status & Label.TARGET) != 0) {\n                    l.status |= Label.STORE;\n                }\n                // all visited labels are reachable, by definition\n                l.status |= Label.REACHABLE;\n                // updates the (absolute) maximum stack size\n                int blockMax = f.inputStack.length + l.outputStackMax;\n                if (blockMax > max) {\n                    max = blockMax;\n                }\n                // updates the successors of the current basic block\n                Edge e = l.successors;\n                while (e != null) {\n                    Label n = e.successor.getFirst();\n                    boolean change = f.merge(cw, n.frame, e.info);\n                    if (change && n.next == null) {\n                        // if n has changed and is not already in the 'changed'\n                        // list, adds it to this list\n                        n.next = changed;\n                        changed = n;\n                    }\n                    e = e.next;\n                }\n            }\n\n            // visits all the frames that must be stored in the stack map\n            Label l = labels;\n            while (l != null) {\n                f = l.frame;\n                if ((l.status & Label.STORE) != 0) {\n                    visitFrame(f);\n                }\n                if ((l.status & Label.REACHABLE) == 0) {\n                    // finds start and end of dead basic block\n                    Label k = l.successor;\n                    int start = l.position;\n                    int end = (k == null ? code.length : k.position) - 1;\n                    // if non empty basic block\n                    if (end >= start) {\n                        max = Math.max(max, 1);\n                        // replaces instructions with NOP ... NOP ATHROW\n                        for (int i = start; i < end; ++i) {\n                            code.data[i] = Opcodes.NOP;\n                        }\n                        code.data[end] = (byte) Opcodes.ATHROW;\n                        // emits a frame for this unreachable block\n                        int frameIndex = startFrame(start, 0, 1);\n                        frame[frameIndex] = Frame.OBJECT\n                                | cw.addType(\"java/lang/Throwable\");\n                        endFrame();\n                        // removes the start-end range from the exception\n                        // handlers\n                        firstHandler = Handler.remove(firstHandler, l, k);\n                    }\n                }\n                l = l.successor;\n            }\n\n            handler = firstHandler;\n            handlerCount = 0;\n            while (handler != null) {\n                handlerCount += 1;\n                handler = handler.next;\n            }\n\n            this.maxStack = max;\n        } else if (compute == MAXS) {\n            // completes the control flow graph with exception handler blocks\n            Handler handler = firstHandler;\n            while (handler != null) {\n                Label l = handler.start;\n                Label h = handler.handler;\n                Label e = handler.end;\n                // adds 'h' as a successor of labels between 'start' and 'end'\n                while (l != e) {\n                    // creates an edge to 'h'\n                    Edge b = new Edge();\n                    b.info = Edge.EXCEPTION;\n                    b.successor = h;\n                    // adds it to the successors of 'l'\n                    if ((l.status & Label.JSR) == 0) {\n                        b.next = l.successors;\n                        l.successors = b;\n                    } else {\n                        // if l is a JSR block, adds b after the first two edges\n                        // to preserve the hypothesis about JSR block successors\n                        // order (see {@link #visitJumpInsn})\n                        b.next = l.successors.next.next;\n                        l.successors.next.next = b;\n                    }\n                    // goes to the next label\n                    l = l.successor;\n                }\n                handler = handler.next;\n            }\n\n            if (subroutines > 0) {\n                // completes the control flow graph with the RET successors\n                /*\n                 * first step: finds the subroutines. This step determines, for\n                 * each basic block, to which subroutine(s) it belongs.\n                 */\n                // finds the basic blocks that belong to the \"main\" subroutine\n                int id = 0;\n                labels.visitSubroutine(null, 1, subroutines);\n                // finds the basic blocks that belong to the real subroutines\n                Label l = labels;\n                while (l != null) {\n                    if ((l.status & Label.JSR) != 0) {\n                        // the subroutine is defined by l's TARGET, not by l\n                        Label subroutine = l.successors.next.successor;\n                        // if this subroutine has not been visited yet...\n                        if ((subroutine.status & Label.VISITED) == 0) {\n                            // ...assigns it a new id and finds its basic blocks\n                            id += 1;\n                            subroutine.visitSubroutine(null, (id / 32L) << 32\n                                    | (1L << (id % 32)), subroutines);\n                        }\n                    }\n                    l = l.successor;\n                }\n                // second step: finds the successors of RET blocks\n                l = labels;\n                while (l != null) {\n                    if ((l.status & Label.JSR) != 0) {\n                        Label L = labels;\n                        while (L != null) {\n                            L.status &= ~Label.VISITED2;\n                            L = L.successor;\n                        }\n                        // the subroutine is defined by l's TARGET, not by l\n                        Label subroutine = l.successors.next.successor;\n                        subroutine.visitSubroutine(l, 0, subroutines);\n                    }\n                    l = l.successor;\n                }\n            }\n\n            /*\n             * control flow analysis algorithm: while the block stack is not\n             * empty, pop a block from this stack, update the max stack size,\n             * compute the true (non relative) begin stack size of the\n             * successors of this block, and push these successors onto the\n             * stack (unless they have already been pushed onto the stack).\n             * Note: by hypothesis, the {@link Label#inputStackTop} of the\n             * blocks in the block stack are the true (non relative) beginning\n             * stack sizes of these blocks.\n             */\n            int max = 0;\n            Label stack = labels;\n            while (stack != null) {\n                // pops a block from the stack\n                Label l = stack;\n                stack = stack.next;\n                // computes the true (non relative) max stack size of this block\n                int start = l.inputStackTop;\n                int blockMax = start + l.outputStackMax;\n                // updates the global max stack size\n                if (blockMax > max) {\n                    max = blockMax;\n                }\n                // analyzes the successors of the block\n                Edge b = l.successors;\n                if ((l.status & Label.JSR) != 0) {\n                    // ignores the first edge of JSR blocks (virtual successor)\n                    b = b.next;\n                }\n                while (b != null) {\n                    l = b.successor;\n                    // if this successor has not already been pushed...\n                    if ((l.status & Label.PUSHED) == 0) {\n                        // computes its true beginning stack size...\n                        l.inputStackTop = b.info == Edge.EXCEPTION ? 1 : start\n                                + b.info;\n                        // ...and pushes it onto the stack\n                        l.status |= Label.PUSHED;\n                        l.next = stack;\n                        stack = l;\n                    }\n                    b = b.next;\n                }\n            }\n            this.maxStack = Math.max(maxStack, max);\n        } else {\n            this.maxStack = maxStack;\n            this.maxLocals = maxLocals;\n        }\n    }\n\n    @Override\n    public void visitEnd() {\n    }\n\n    // ------------------------------------------------------------------------\n    // Utility methods: control flow analysis algorithm\n    // ------------------------------------------------------------------------\n\n    /**\n     * Adds a successor to the {@link #currentBlock currentBlock} block.\n     *\n     * @param info\n     *            information about the control flow edge to be added.\n     * @param successor\n     *            the successor block to be added to the current block.\n     */\n    private void addSuccessor(final int info, final Label successor) {\n        // creates and initializes an Edge object...\n        Edge b = new Edge();\n        b.info = info;\n        b.successor = successor;\n        // ...and adds it to the successor list of the currentBlock block\n        b.next = currentBlock.successors;\n        currentBlock.successors = b;\n    }\n\n    /**\n     * Ends the current basic block. This method must be used in the case where\n     * the current basic block does not have any successor.\n     */\n    private void noSuccessor() {\n        if (compute == FRAMES) {\n            Label l = new Label();\n            l.frame = new Frame();\n            l.frame.owner = l;\n            l.resolve(this, code.length, code.data);\n            previousBlock.successor = l;\n            previousBlock = l;\n        } else {\n            currentBlock.outputStackMax = maxStackSize;\n        }\n        currentBlock = null;\n    }\n\n    // ------------------------------------------------------------------------\n    // Utility methods: stack map frames\n    // ------------------------------------------------------------------------\n\n    /**\n     * Visits a frame that has been computed from scratch.\n     *\n     * @param f\n     *            the frame that must be visited.\n     */\n    private void visitFrame(final Frame f) {\n        int i, t;\n        int nTop = 0;\n        int nLocal = 0;\n        int nStack = 0;\n        int[] locals = f.inputLocals;\n        int[] stacks = f.inputStack;\n        // computes the number of locals (ignores TOP types that are just after\n        // a LONG or a DOUBLE, and all trailing TOP types)\n        for (i = 0; i < locals.length; ++i) {\n            t = locals[i];\n            if (t == Frame.TOP) {\n                ++nTop;\n            } else {\n                nLocal += nTop + 1;\n                nTop = 0;\n            }\n            if (t == Frame.LONG || t == Frame.DOUBLE) {\n                ++i;\n            }\n        }\n        // computes the stack size (ignores TOP types that are just after\n        // a LONG or a DOUBLE)\n        for (i = 0; i < stacks.length; ++i) {\n            t = stacks[i];\n            ++nStack;\n            if (t == Frame.LONG || t == Frame.DOUBLE) {\n                ++i;\n            }\n        }\n        // visits the frame and its content\n        int frameIndex = startFrame(f.owner.position, nLocal, nStack);\n        for (i = 0; nLocal > 0; ++i, --nLocal) {\n            t = locals[i];\n            frame[frameIndex++] = t;\n            if (t == Frame.LONG || t == Frame.DOUBLE) {\n                ++i;\n            }\n        }\n        for (i = 0; i < stacks.length; ++i) {\n            t = stacks[i];\n            frame[frameIndex++] = t;\n            if (t == Frame.LONG || t == Frame.DOUBLE) {\n                ++i;\n            }\n        }\n        endFrame();\n    }\n\n    /**\n     * Visit the implicit first frame of this method.\n     */\n    private void visitImplicitFirstFrame() {\n        // There can be at most descriptor.length() + 1 locals\n        int frameIndex = startFrame(0, descriptor.length() + 1, 0);\n        if ((access & Opcodes.ACC_STATIC) == 0) {\n            if ((access & ACC_CONSTRUCTOR) == 0) {\n                frame[frameIndex++] = Frame.OBJECT | cw.addType(cw.thisName);\n            } else {\n                frame[frameIndex++] = 6; // Opcodes.UNINITIALIZED_THIS;\n            }\n        }\n        int i = 1;\n        loop: while (true) {\n            int j = i;\n            switch (descriptor.charAt(i++)) {\n            case 'Z':\n            case 'C':\n            case 'B':\n            case 'S':\n            case 'I':\n                frame[frameIndex++] = 1; // Opcodes.INTEGER;\n                break;\n            case 'F':\n                frame[frameIndex++] = 2; // Opcodes.FLOAT;\n                break;\n            case 'J':\n                frame[frameIndex++] = 4; // Opcodes.LONG;\n                break;\n            case 'D':\n                frame[frameIndex++] = 3; // Opcodes.DOUBLE;\n                break;\n            case '[':\n                while (descriptor.charAt(i) == '[') {\n                    ++i;\n                }\n                if (descriptor.charAt(i) == 'L') {\n                    ++i;\n                    while (descriptor.charAt(i) != ';') {\n                        ++i;\n                    }\n                }\n                frame[frameIndex++] = Frame.OBJECT\n                        | cw.addType(descriptor.substring(j, ++i));\n                break;\n            case 'L':\n                while (descriptor.charAt(i) != ';') {\n                    ++i;\n                }\n                frame[frameIndex++] = Frame.OBJECT\n                        | cw.addType(descriptor.substring(j + 1, i++));\n                break;\n            default:\n                break loop;\n            }\n        }\n        frame[1] = frameIndex - 3;\n        endFrame();\n    }\n\n    /**\n     * Starts the visit of a stack map frame.\n     *\n     * @param offset\n     *            the offset of the instruction to which the frame corresponds.\n     * @param nLocal\n     *            the number of local variables in the frame.\n     * @param nStack\n     *            the number of stack elements in the frame.\n     * @return the index of the next element to be written in this frame.\n     */\n    private int startFrame(final int offset, final int nLocal, final int nStack) {\n        int n = 3 + nLocal + nStack;\n        if (frame == null || frame.length < n) {\n            frame = new int[n];\n        }\n        frame[0] = offset;\n        frame[1] = nLocal;\n        frame[2] = nStack;\n        return 3;\n    }\n\n    /**\n     * Checks if the visit of the current frame {@link #frame} is finished, and\n     * if yes, write it in the StackMapTable attribute.\n     */\n    private void endFrame() {\n        if (previousFrame != null) { // do not write the first frame\n            if (stackMap == null) {\n                stackMap = new ByteVector();\n            }\n            writeFrame();\n            ++frameCount;\n        }\n        previousFrame = frame;\n        frame = null;\n    }\n\n    /**\n     * Compress and writes the current frame {@link #frame} in the StackMapTable\n     * attribute.\n     */\n    private void writeFrame() {\n        int clocalsSize = frame[1];\n        int cstackSize = frame[2];\n        if ((cw.version & 0xFFFF) < Opcodes.V1_6) {\n            stackMap.putShort(frame[0]).putShort(clocalsSize);\n            writeFrameTypes(3, 3 + clocalsSize);\n            stackMap.putShort(cstackSize);\n            writeFrameTypes(3 + clocalsSize, 3 + clocalsSize + cstackSize);\n            return;\n        }\n        int localsSize = previousFrame[1];\n        int type = FULL_FRAME;\n        int k = 0;\n        int delta;\n        if (frameCount == 0) {\n            delta = frame[0];\n        } else {\n            delta = frame[0] - previousFrame[0] - 1;\n        }\n        if (cstackSize == 0) {\n            k = clocalsSize - localsSize;\n            switch (k) {\n            case -3:\n            case -2:\n            case -1:\n                type = CHOP_FRAME;\n                localsSize = clocalsSize;\n                break;\n            case 0:\n                type = delta < 64 ? SAME_FRAME : SAME_FRAME_EXTENDED;\n                break;\n            case 1:\n            case 2:\n            case 3:\n                type = APPEND_FRAME;\n                break;\n            }\n        } else if (clocalsSize == localsSize && cstackSize == 1) {\n            type = delta < 63 ? SAME_LOCALS_1_STACK_ITEM_FRAME\n                    : SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED;\n        }\n        if (type != FULL_FRAME) {\n            // verify if locals are the same\n            int l = 3;\n            for (int j = 0; j < localsSize; j++) {\n                if (frame[l] != previousFrame[l]) {\n                    type = FULL_FRAME;\n                    break;\n                }\n                l++;\n            }\n        }\n        switch (type) {\n        case SAME_FRAME:\n            stackMap.putByte(delta);\n            break;\n        case SAME_LOCALS_1_STACK_ITEM_FRAME:\n            stackMap.putByte(SAME_LOCALS_1_STACK_ITEM_FRAME + delta);\n            writeFrameTypes(3 + clocalsSize, 4 + clocalsSize);\n            break;\n        case SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED:\n            stackMap.putByte(SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED).putShort(\n                    delta);\n            writeFrameTypes(3 + clocalsSize, 4 + clocalsSize);\n            break;\n        case SAME_FRAME_EXTENDED:\n            stackMap.putByte(SAME_FRAME_EXTENDED).putShort(delta);\n            break;\n        case CHOP_FRAME:\n            stackMap.putByte(SAME_FRAME_EXTENDED + k).putShort(delta);\n            break;\n        case APPEND_FRAME:\n            stackMap.putByte(SAME_FRAME_EXTENDED + k).putShort(delta);\n            writeFrameTypes(3 + localsSize, 3 + clocalsSize);\n            break;\n        // case FULL_FRAME:\n        default:\n            stackMap.putByte(FULL_FRAME).putShort(delta).putShort(clocalsSize);\n            writeFrameTypes(3, 3 + clocalsSize);\n            stackMap.putShort(cstackSize);\n            writeFrameTypes(3 + clocalsSize, 3 + clocalsSize + cstackSize);\n        }\n    }\n\n    /**\n     * Writes some types of the current frame {@link #frame} into the\n     * StackMapTableAttribute. This method converts types from the format used\n     * in {@link Label} to the format used in StackMapTable attributes. In\n     * particular, it converts type table indexes to constant pool indexes.\n     *\n     * @param start\n     *            index of the first type in {@link #frame} to write.\n     * @param end\n     *            index of last type in {@link #frame} to write (exclusive).\n     */\n    private void writeFrameTypes(final int start, final int end) {\n        for (int i = start; i < end; ++i) {\n            int t = frame[i];\n            int d = t & Frame.DIM;\n            if (d == 0) {\n                int v = t & Frame.BASE_VALUE;\n                switch (t & Frame.BASE_KIND) {\n                case Frame.OBJECT:\n                    stackMap.putByte(7).putShort(\n                            cw.newClass(cw.typeTable[v].strVal1));\n                    break;\n                case Frame.UNINITIALIZED:\n                    stackMap.putByte(8).putShort(cw.typeTable[v].intVal);\n                    break;\n                default:\n                    stackMap.putByte(v);\n                }\n            } else {\n                StringBuffer buf = new StringBuffer();\n                d >>= 28;\n                while (d-- > 0) {\n                    buf.append('[');\n                }\n                if ((t & Frame.BASE_KIND) == Frame.OBJECT) {\n                    buf.append('L');\n                    buf.append(cw.typeTable[t & Frame.BASE_VALUE].strVal1);\n                    buf.append(';');\n                } else {\n                    switch (t & 0xF) {\n                    case 1:\n                        buf.append('I');\n                        break;\n                    case 2:\n                        buf.append('F');\n                        break;\n                    case 3:\n                        buf.append('D');\n                        break;\n                    case 9:\n                        buf.append('Z');\n                        break;\n                    case 10:\n                        buf.append('B');\n                        break;\n                    case 11:\n                        buf.append('C');\n                        break;\n                    case 12:\n                        buf.append('S');\n                        break;\n                    default:\n                        buf.append('J');\n                    }\n                }\n                stackMap.putByte(7).putShort(cw.newClass(buf.toString()));\n            }\n        }\n    }\n\n    private void writeFrameType(final Object type) {\n        if (type instanceof String) {\n            stackMap.putByte(7).putShort(cw.newClass((String) type));\n        } else if (type instanceof Integer) {\n            stackMap.putByte(((Integer) type).intValue());\n        } else {\n            stackMap.putByte(8).putShort(((Label) type).position);\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Utility methods: dump bytecode array\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns the size of the bytecode of this method.\n     *\n     * @return the size of the bytecode of this method.\n     */\n    final int getSize() {\n        if (classReaderOffset != 0) {\n            return 6 + classReaderLength;\n        }\n        if (resize) {\n            // replaces the temporary jump opcodes introduced by Label.resolve.\n            if (ClassReader.RESIZE) {\n                resizeInstructions();\n            } else {\n                throw new RuntimeException(\"Method code too large!\");\n            }\n        }\n        int size = 8;\n        if (code.length > 0) {\n            if (code.length > 65536) {\n                throw new RuntimeException(\"Method code too large!\");\n            }\n            cw.newUTF8(\"Code\");\n            size += 18 + code.length + 8 * handlerCount;\n            if (localVar != null) {\n                cw.newUTF8(\"LocalVariableTable\");\n                size += 8 + localVar.length;\n            }\n            if (localVarType != null) {\n                cw.newUTF8(\"LocalVariableTypeTable\");\n                size += 8 + localVarType.length;\n            }\n            if (lineNumber != null) {\n                cw.newUTF8(\"LineNumberTable\");\n                size += 8 + lineNumber.length;\n            }\n            if (stackMap != null) {\n                boolean zip = (cw.version & 0xFFFF) >= Opcodes.V1_6;\n                cw.newUTF8(zip ? \"StackMapTable\" : \"StackMap\");\n                size += 8 + stackMap.length;\n            }\n            if (cattrs != null) {\n                size += cattrs.getSize(cw, code.data, code.length, maxStack,\n                        maxLocals);\n            }\n        }\n        if (exceptionCount > 0) {\n            cw.newUTF8(\"Exceptions\");\n            size += 8 + 2 * exceptionCount;\n        }\n        if ((access & Opcodes.ACC_SYNTHETIC) != 0) {\n            if ((cw.version & 0xFFFF) < Opcodes.V1_5\n                    || (access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) != 0) {\n                cw.newUTF8(\"Synthetic\");\n                size += 6;\n            }\n        }\n        if ((access & Opcodes.ACC_DEPRECATED) != 0) {\n            cw.newUTF8(\"Deprecated\");\n            size += 6;\n        }\n        if (ClassReader.SIGNATURES && signature != null) {\n            cw.newUTF8(\"Signature\");\n            cw.newUTF8(signature);\n            size += 8;\n        }\n        if (ClassReader.ANNOTATIONS && annd != null) {\n            cw.newUTF8(\"AnnotationDefault\");\n            size += 6 + annd.length;\n        }\n        if (ClassReader.ANNOTATIONS && anns != null) {\n            cw.newUTF8(\"RuntimeVisibleAnnotations\");\n            size += 8 + anns.getSize();\n        }\n        if (ClassReader.ANNOTATIONS && ianns != null) {\n            cw.newUTF8(\"RuntimeInvisibleAnnotations\");\n            size += 8 + ianns.getSize();\n        }\n        if (ClassReader.ANNOTATIONS && panns != null) {\n            cw.newUTF8(\"RuntimeVisibleParameterAnnotations\");\n            size += 7 + 2 * (panns.length - synthetics);\n            for (int i = panns.length - 1; i >= synthetics; --i) {\n                size += panns[i] == null ? 0 : panns[i].getSize();\n            }\n        }\n        if (ClassReader.ANNOTATIONS && ipanns != null) {\n            cw.newUTF8(\"RuntimeInvisibleParameterAnnotations\");\n            size += 7 + 2 * (ipanns.length - synthetics);\n            for (int i = ipanns.length - 1; i >= synthetics; --i) {\n                size += ipanns[i] == null ? 0 : ipanns[i].getSize();\n            }\n        }\n        if (attrs != null) {\n            size += attrs.getSize(cw, null, 0, -1, -1);\n        }\n        return size;\n    }\n\n    /**\n     * Puts the bytecode of this method in the given byte vector.\n     *\n     * @param out\n     *            the byte vector into which the bytecode of this method must be\n     *            copied.\n     */\n    final void put(final ByteVector out) {\n        final int FACTOR = ClassWriter.TO_ACC_SYNTHETIC;\n        int mask = ACC_CONSTRUCTOR | Opcodes.ACC_DEPRECATED\n                | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE\n                | ((access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) / FACTOR);\n        out.putShort(access & ~mask).putShort(name).putShort(desc);\n        if (classReaderOffset != 0) {\n            out.putByteArray(cw.cr.b, classReaderOffset, classReaderLength);\n            return;\n        }\n        int attributeCount = 0;\n        if (code.length > 0) {\n            ++attributeCount;\n        }\n        if (exceptionCount > 0) {\n            ++attributeCount;\n        }\n        if ((access & Opcodes.ACC_SYNTHETIC) != 0) {\n            if ((cw.version & 0xFFFF) < Opcodes.V1_5\n                    || (access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) != 0) {\n                ++attributeCount;\n            }\n        }\n        if ((access & Opcodes.ACC_DEPRECATED) != 0) {\n            ++attributeCount;\n        }\n        if (ClassReader.SIGNATURES && signature != null) {\n            ++attributeCount;\n        }\n        if (ClassReader.ANNOTATIONS && annd != null) {\n            ++attributeCount;\n        }\n        if (ClassReader.ANNOTATIONS && anns != null) {\n            ++attributeCount;\n        }\n        if (ClassReader.ANNOTATIONS && ianns != null) {\n            ++attributeCount;\n        }\n        if (ClassReader.ANNOTATIONS && panns != null) {\n            ++attributeCount;\n        }\n        if (ClassReader.ANNOTATIONS && ipanns != null) {\n            ++attributeCount;\n        }\n        if (attrs != null) {\n            attributeCount += attrs.getCount();\n        }\n        out.putShort(attributeCount);\n        if (code.length > 0) {\n            int size = 12 + code.length + 8 * handlerCount;\n            if (localVar != null) {\n                size += 8 + localVar.length;\n            }\n            if (localVarType != null) {\n                size += 8 + localVarType.length;\n            }\n            if (lineNumber != null) {\n                size += 8 + lineNumber.length;\n            }\n            if (stackMap != null) {\n                size += 8 + stackMap.length;\n            }\n            if (cattrs != null) {\n                size += cattrs.getSize(cw, code.data, code.length, maxStack,\n                        maxLocals);\n            }\n            out.putShort(cw.newUTF8(\"Code\")).putInt(size);\n            out.putShort(maxStack).putShort(maxLocals);\n            out.putInt(code.length).putByteArray(code.data, 0, code.length);\n            out.putShort(handlerCount);\n            if (handlerCount > 0) {\n                Handler h = firstHandler;\n                while (h != null) {\n                    out.putShort(h.start.position).putShort(h.end.position)\n                            .putShort(h.handler.position).putShort(h.type);\n                    h = h.next;\n                }\n            }\n            attributeCount = 0;\n            if (localVar != null) {\n                ++attributeCount;\n            }\n            if (localVarType != null) {\n                ++attributeCount;\n            }\n            if (lineNumber != null) {\n                ++attributeCount;\n            }\n            if (stackMap != null) {\n                ++attributeCount;\n            }\n            if (cattrs != null) {\n                attributeCount += cattrs.getCount();\n            }\n            out.putShort(attributeCount);\n            if (localVar != null) {\n                out.putShort(cw.newUTF8(\"LocalVariableTable\"));\n                out.putInt(localVar.length + 2).putShort(localVarCount);\n                out.putByteArray(localVar.data, 0, localVar.length);\n            }\n            if (localVarType != null) {\n                out.putShort(cw.newUTF8(\"LocalVariableTypeTable\"));\n                out.putInt(localVarType.length + 2).putShort(localVarTypeCount);\n                out.putByteArray(localVarType.data, 0, localVarType.length);\n            }\n            if (lineNumber != null) {\n                out.putShort(cw.newUTF8(\"LineNumberTable\"));\n                out.putInt(lineNumber.length + 2).putShort(lineNumberCount);\n                out.putByteArray(lineNumber.data, 0, lineNumber.length);\n            }\n            if (stackMap != null) {\n                boolean zip = (cw.version & 0xFFFF) >= Opcodes.V1_6;\n                out.putShort(cw.newUTF8(zip ? \"StackMapTable\" : \"StackMap\"));\n                out.putInt(stackMap.length + 2).putShort(frameCount);\n                out.putByteArray(stackMap.data, 0, stackMap.length);\n            }\n            if (cattrs != null) {\n                cattrs.put(cw, code.data, code.length, maxLocals, maxStack, out);\n            }\n        }\n        if (exceptionCount > 0) {\n            out.putShort(cw.newUTF8(\"Exceptions\")).putInt(\n                    2 * exceptionCount + 2);\n            out.putShort(exceptionCount);\n            for (int i = 0; i < exceptionCount; ++i) {\n                out.putShort(exceptions[i]);\n            }\n        }\n        if ((access & Opcodes.ACC_SYNTHETIC) != 0) {\n            if ((cw.version & 0xFFFF) < Opcodes.V1_5\n                    || (access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) != 0) {\n                out.putShort(cw.newUTF8(\"Synthetic\")).putInt(0);\n            }\n        }\n        if ((access & Opcodes.ACC_DEPRECATED) != 0) {\n            out.putShort(cw.newUTF8(\"Deprecated\")).putInt(0);\n        }\n        if (ClassReader.SIGNATURES && signature != null) {\n            out.putShort(cw.newUTF8(\"Signature\")).putInt(2)\n                    .putShort(cw.newUTF8(signature));\n        }\n        if (ClassReader.ANNOTATIONS && annd != null) {\n            out.putShort(cw.newUTF8(\"AnnotationDefault\"));\n            out.putInt(annd.length);\n            out.putByteArray(annd.data, 0, annd.length);\n        }\n        if (ClassReader.ANNOTATIONS && anns != null) {\n            out.putShort(cw.newUTF8(\"RuntimeVisibleAnnotations\"));\n            anns.put(out);\n        }\n        if (ClassReader.ANNOTATIONS && ianns != null) {\n            out.putShort(cw.newUTF8(\"RuntimeInvisibleAnnotations\"));\n            ianns.put(out);\n        }\n        if (ClassReader.ANNOTATIONS && panns != null) {\n            out.putShort(cw.newUTF8(\"RuntimeVisibleParameterAnnotations\"));\n            AnnotationWriter.put(panns, synthetics, out);\n        }\n        if (ClassReader.ANNOTATIONS && ipanns != null) {\n            out.putShort(cw.newUTF8(\"RuntimeInvisibleParameterAnnotations\"));\n            AnnotationWriter.put(ipanns, synthetics, out);\n        }\n        if (attrs != null) {\n            attrs.put(cw, null, 0, -1, -1, out);\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Utility methods: instruction resizing (used to handle GOTO_W and JSR_W)\n    // ------------------------------------------------------------------------\n\n    /**\n     * Resizes and replaces the temporary instructions inserted by\n     * {@link Label#resolve} for wide forward jumps, while keeping jump offsets\n     * and instruction addresses consistent. This may require to resize other\n     * existing instructions, or even to introduce new instructions: for\n     * example, increasing the size of an instruction by 2 at the middle of a\n     * method can increases the offset of an IFEQ instruction from 32766 to\n     * 32768, in which case IFEQ 32766 must be replaced with IFNEQ 8 GOTO_W\n     * 32765. This, in turn, may require to increase the size of another jump\n     * instruction, and so on... All these operations are handled automatically\n     * by this method.\n     * <p>\n     * <i>This method must be called after all the method that is being built\n     * has been visited</i>. In particular, the {@link Label Label} objects used\n     * to construct the method are no longer valid after this method has been\n     * called.\n     */\n    private void resizeInstructions() {\n        byte[] b = code.data; // bytecode of the method\n        int u, v, label; // indexes in b\n        int i, j; // loop indexes\n        /*\n         * 1st step: As explained above, resizing an instruction may require to\n         * resize another one, which may require to resize yet another one, and\n         * so on. The first step of the algorithm consists in finding all the\n         * instructions that need to be resized, without modifying the code.\n         * This is done by the following \"fix point\" algorithm:\n         *\n         * Parse the code to find the jump instructions whose offset will need\n         * more than 2 bytes to be stored (the future offset is computed from\n         * the current offset and from the number of bytes that will be inserted\n         * or removed between the source and target instructions). For each such\n         * instruction, adds an entry in (a copy of) the indexes and sizes\n         * arrays (if this has not already been done in a previous iteration!).\n         *\n         * If at least one entry has been added during the previous step, go\n         * back to the beginning, otherwise stop.\n         *\n         * In fact the real algorithm is complicated by the fact that the size\n         * of TABLESWITCH and LOOKUPSWITCH instructions depends on their\n         * position in the bytecode (because of padding). In order to ensure the\n         * convergence of the algorithm, the number of bytes to be added or\n         * removed from these instructions is over estimated during the previous\n         * loop, and computed exactly only after the loop is finished (this\n         * requires another pass to parse the bytecode of the method).\n         */\n        int[] allIndexes = new int[0]; // copy of indexes\n        int[] allSizes = new int[0]; // copy of sizes\n        boolean[] resize; // instructions to be resized\n        int newOffset; // future offset of a jump instruction\n\n        resize = new boolean[code.length];\n\n        // 3 = loop again, 2 = loop ended, 1 = last pass, 0 = done\n        int state = 3;\n        do {\n            if (state == 3) {\n                state = 2;\n            }\n            u = 0;\n            while (u < b.length) {\n                int opcode = b[u] & 0xFF; // opcode of current instruction\n                int insert = 0; // bytes to be added after this instruction\n\n                switch (ClassWriter.TYPE[opcode]) {\n                case ClassWriter.NOARG_INSN:\n                case ClassWriter.IMPLVAR_INSN:\n                    u += 1;\n                    break;\n                case ClassWriter.LABEL_INSN:\n                    if (opcode > 201) {\n                        // converts temporary opcodes 202 to 217, 218 and\n                        // 219 to IFEQ ... JSR (inclusive), IFNULL and\n                        // IFNONNULL\n                        opcode = opcode < 218 ? opcode - 49 : opcode - 20;\n                        label = u + readUnsignedShort(b, u + 1);\n                    } else {\n                        label = u + readShort(b, u + 1);\n                    }\n                    newOffset = getNewOffset(allIndexes, allSizes, u, label);\n                    if (newOffset < Short.MIN_VALUE\n                            || newOffset > Short.MAX_VALUE) {\n                        if (!resize[u]) {\n                            if (opcode == Opcodes.GOTO || opcode == Opcodes.JSR) {\n                                // two additional bytes will be required to\n                                // replace this GOTO or JSR instruction with\n                                // a GOTO_W or a JSR_W\n                                insert = 2;\n                            } else {\n                                // five additional bytes will be required to\n                                // replace this IFxxx <l> instruction with\n                                // IFNOTxxx <l'> GOTO_W <l>, where IFNOTxxx\n                                // is the \"opposite\" opcode of IFxxx (i.e.,\n                                // IFNE for IFEQ) and where <l'> designates\n                                // the instruction just after the GOTO_W.\n                                insert = 5;\n                            }\n                            resize[u] = true;\n                        }\n                    }\n                    u += 3;\n                    break;\n                case ClassWriter.LABELW_INSN:\n                    u += 5;\n                    break;\n                case ClassWriter.TABL_INSN:\n                    if (state == 1) {\n                        // true number of bytes to be added (or removed)\n                        // from this instruction = (future number of padding\n                        // bytes - current number of padding byte) -\n                        // previously over estimated variation =\n                        // = ((3 - newOffset%4) - (3 - u%4)) - u%4\n                        // = (-newOffset%4 + u%4) - u%4\n                        // = -(newOffset & 3)\n                        newOffset = getNewOffset(allIndexes, allSizes, 0, u);\n                        insert = -(newOffset & 3);\n                    } else if (!resize[u]) {\n                        // over estimation of the number of bytes to be\n                        // added to this instruction = 3 - current number\n                        // of padding bytes = 3 - (3 - u%4) = u%4 = u & 3\n                        insert = u & 3;\n                        resize[u] = true;\n                    }\n                    // skips instruction\n                    u = u + 4 - (u & 3);\n                    u += 4 * (readInt(b, u + 8) - readInt(b, u + 4) + 1) + 12;\n                    break;\n                case ClassWriter.LOOK_INSN:\n                    if (state == 1) {\n                        // like TABL_INSN\n                        newOffset = getNewOffset(allIndexes, allSizes, 0, u);\n                        insert = -(newOffset & 3);\n                    } else if (!resize[u]) {\n                        // like TABL_INSN\n                        insert = u & 3;\n                        resize[u] = true;\n                    }\n                    // skips instruction\n                    u = u + 4 - (u & 3);\n                    u += 8 * readInt(b, u + 4) + 8;\n                    break;\n                case ClassWriter.WIDE_INSN:\n                    opcode = b[u + 1] & 0xFF;\n                    if (opcode == Opcodes.IINC) {\n                        u += 6;\n                    } else {\n                        u += 4;\n                    }\n                    break;\n                case ClassWriter.VAR_INSN:\n                case ClassWriter.SBYTE_INSN:\n                case ClassWriter.LDC_INSN:\n                    u += 2;\n                    break;\n                case ClassWriter.SHORT_INSN:\n                case ClassWriter.LDCW_INSN:\n                case ClassWriter.FIELDORMETH_INSN:\n                case ClassWriter.TYPE_INSN:\n                case ClassWriter.IINC_INSN:\n                    u += 3;\n                    break;\n                case ClassWriter.ITFMETH_INSN:\n                case ClassWriter.INDYMETH_INSN:\n                    u += 5;\n                    break;\n                // case ClassWriter.MANA_INSN:\n                default:\n                    u += 4;\n                    break;\n                }\n                if (insert != 0) {\n                    // adds a new (u, insert) entry in the allIndexes and\n                    // allSizes arrays\n                    int[] newIndexes = new int[allIndexes.length + 1];\n                    int[] newSizes = new int[allSizes.length + 1];\n                    System.arraycopy(allIndexes, 0, newIndexes, 0,\n                            allIndexes.length);\n                    System.arraycopy(allSizes, 0, newSizes, 0, allSizes.length);\n                    newIndexes[allIndexes.length] = u;\n                    newSizes[allSizes.length] = insert;\n                    allIndexes = newIndexes;\n                    allSizes = newSizes;\n                    if (insert > 0) {\n                        state = 3;\n                    }\n                }\n            }\n            if (state < 3) {\n                --state;\n            }\n        } while (state != 0);\n\n        // 2nd step:\n        // copies the bytecode of the method into a new bytevector, updates the\n        // offsets, and inserts (or removes) bytes as requested.\n\n        ByteVector newCode = new ByteVector(code.length);\n\n        u = 0;\n        while (u < code.length) {\n            int opcode = b[u] & 0xFF;\n            switch (ClassWriter.TYPE[opcode]) {\n            case ClassWriter.NOARG_INSN:\n            case ClassWriter.IMPLVAR_INSN:\n                newCode.putByte(opcode);\n                u += 1;\n                break;\n            case ClassWriter.LABEL_INSN:\n                if (opcode > 201) {\n                    // changes temporary opcodes 202 to 217 (inclusive), 218\n                    // and 219 to IFEQ ... JSR (inclusive), IFNULL and\n                    // IFNONNULL\n                    opcode = opcode < 218 ? opcode - 49 : opcode - 20;\n                    label = u + readUnsignedShort(b, u + 1);\n                } else {\n                    label = u + readShort(b, u + 1);\n                }\n                newOffset = getNewOffset(allIndexes, allSizes, u, label);\n                if (resize[u]) {\n                    // replaces GOTO with GOTO_W, JSR with JSR_W and IFxxx\n                    // <l> with IFNOTxxx <l'> GOTO_W <l>, where IFNOTxxx is\n                    // the \"opposite\" opcode of IFxxx (i.e., IFNE for IFEQ)\n                    // and where <l'> designates the instruction just after\n                    // the GOTO_W.\n                    if (opcode == Opcodes.GOTO) {\n                        newCode.putByte(200); // GOTO_W\n                    } else if (opcode == Opcodes.JSR) {\n                        newCode.putByte(201); // JSR_W\n                    } else {\n                        newCode.putByte(opcode <= 166 ? ((opcode + 1) ^ 1) - 1\n                                : opcode ^ 1);\n                        newCode.putShort(8); // jump offset\n                        newCode.putByte(200); // GOTO_W\n                        // newOffset now computed from start of GOTO_W\n                        newOffset -= 3;\n                    }\n                    newCode.putInt(newOffset);\n                } else {\n                    newCode.putByte(opcode);\n                    newCode.putShort(newOffset);\n                }\n                u += 3;\n                break;\n            case ClassWriter.LABELW_INSN:\n                label = u + readInt(b, u + 1);\n                newOffset = getNewOffset(allIndexes, allSizes, u, label);\n                newCode.putByte(opcode);\n                newCode.putInt(newOffset);\n                u += 5;\n                break;\n            case ClassWriter.TABL_INSN:\n                // skips 0 to 3 padding bytes\n                v = u;\n                u = u + 4 - (v & 3);\n                // reads and copies instruction\n                newCode.putByte(Opcodes.TABLESWITCH);\n                newCode.putByteArray(null, 0, (4 - newCode.length % 4) % 4);\n                label = v + readInt(b, u);\n                u += 4;\n                newOffset = getNewOffset(allIndexes, allSizes, v, label);\n                newCode.putInt(newOffset);\n                j = readInt(b, u);\n                u += 4;\n                newCode.putInt(j);\n                j = readInt(b, u) - j + 1;\n                u += 4;\n                newCode.putInt(readInt(b, u - 4));\n                for (; j > 0; --j) {\n                    label = v + readInt(b, u);\n                    u += 4;\n                    newOffset = getNewOffset(allIndexes, allSizes, v, label);\n                    newCode.putInt(newOffset);\n                }\n                break;\n            case ClassWriter.LOOK_INSN:\n                // skips 0 to 3 padding bytes\n                v = u;\n                u = u + 4 - (v & 3);\n                // reads and copies instruction\n                newCode.putByte(Opcodes.LOOKUPSWITCH);\n                newCode.putByteArray(null, 0, (4 - newCode.length % 4) % 4);\n                label = v + readInt(b, u);\n                u += 4;\n                newOffset = getNewOffset(allIndexes, allSizes, v, label);\n                newCode.putInt(newOffset);\n                j = readInt(b, u);\n                u += 4;\n                newCode.putInt(j);\n                for (; j > 0; --j) {\n                    newCode.putInt(readInt(b, u));\n                    u += 4;\n                    label = v + readInt(b, u);\n                    u += 4;\n                    newOffset = getNewOffset(allIndexes, allSizes, v, label);\n                    newCode.putInt(newOffset);\n                }\n                break;\n            case ClassWriter.WIDE_INSN:\n                opcode = b[u + 1] & 0xFF;\n                if (opcode == Opcodes.IINC) {\n                    newCode.putByteArray(b, u, 6);\n                    u += 6;\n                } else {\n                    newCode.putByteArray(b, u, 4);\n                    u += 4;\n                }\n                break;\n            case ClassWriter.VAR_INSN:\n            case ClassWriter.SBYTE_INSN:\n            case ClassWriter.LDC_INSN:\n                newCode.putByteArray(b, u, 2);\n                u += 2;\n                break;\n            case ClassWriter.SHORT_INSN:\n            case ClassWriter.LDCW_INSN:\n            case ClassWriter.FIELDORMETH_INSN:\n            case ClassWriter.TYPE_INSN:\n            case ClassWriter.IINC_INSN:\n                newCode.putByteArray(b, u, 3);\n                u += 3;\n                break;\n            case ClassWriter.ITFMETH_INSN:\n            case ClassWriter.INDYMETH_INSN:\n                newCode.putByteArray(b, u, 5);\n                u += 5;\n                break;\n            // case MANA_INSN:\n            default:\n                newCode.putByteArray(b, u, 4);\n                u += 4;\n                break;\n            }\n        }\n\n        // recomputes the stack map frames\n        if (frameCount > 0) {\n            if (compute == FRAMES) {\n                frameCount = 0;\n                stackMap = null;\n                previousFrame = null;\n                frame = null;\n                Frame f = new Frame();\n                f.owner = labels;\n                Type[] args = Type.getArgumentTypes(descriptor);\n                f.initInputFrame(cw, access, args, maxLocals);\n                visitFrame(f);\n                Label l = labels;\n                while (l != null) {\n                    /*\n                     * here we need the original label position. getNewOffset\n                     * must therefore never have been called for this label.\n                     */\n                    u = l.position - 3;\n                    if ((l.status & Label.STORE) != 0 || (u >= 0 && resize[u])) {\n                        getNewOffset(allIndexes, allSizes, l);\n                        // TODO update offsets in UNINITIALIZED values\n                        visitFrame(l.frame);\n                    }\n                    l = l.successor;\n                }\n            } else {\n                /*\n                 * Resizing an existing stack map frame table is really hard.\n                 * Not only the table must be parsed to update the offets, but\n                 * new frames may be needed for jump instructions that were\n                 * inserted by this method. And updating the offsets or\n                 * inserting frames can change the format of the following\n                 * frames, in case of packed frames. In practice the whole table\n                 * must be recomputed. For this the frames are marked as\n                 * potentially invalid. This will cause the whole class to be\n                 * reread and rewritten with the COMPUTE_FRAMES option (see the\n                 * ClassWriter.toByteArray method). This is not very efficient\n                 * but is much easier and requires much less code than any other\n                 * method I can think of.\n                 */\n                cw.invalidFrames = true;\n            }\n        }\n        // updates the exception handler block labels\n        Handler h = firstHandler;\n        while (h != null) {\n            getNewOffset(allIndexes, allSizes, h.start);\n            getNewOffset(allIndexes, allSizes, h.end);\n            getNewOffset(allIndexes, allSizes, h.handler);\n            h = h.next;\n        }\n        // updates the instructions addresses in the\n        // local var and line number tables\n        for (i = 0; i < 2; ++i) {\n            ByteVector bv = i == 0 ? localVar : localVarType;\n            if (bv != null) {\n                b = bv.data;\n                u = 0;\n                while (u < bv.length) {\n                    label = readUnsignedShort(b, u);\n                    newOffset = getNewOffset(allIndexes, allSizes, 0, label);\n                    writeShort(b, u, newOffset);\n                    label += readUnsignedShort(b, u + 2);\n                    newOffset = getNewOffset(allIndexes, allSizes, 0, label)\n                            - newOffset;\n                    writeShort(b, u + 2, newOffset);\n                    u += 10;\n                }\n            }\n        }\n        if (lineNumber != null) {\n            b = lineNumber.data;\n            u = 0;\n            while (u < lineNumber.length) {\n                writeShort(\n                        b,\n                        u,\n                        getNewOffset(allIndexes, allSizes, 0,\n                                readUnsignedShort(b, u)));\n                u += 4;\n            }\n        }\n        // updates the labels of the other attributes\n        Attribute attr = cattrs;\n        while (attr != null) {\n            Label[] labels = attr.getLabels();\n            if (labels != null) {\n                for (i = labels.length - 1; i >= 0; --i) {\n                    getNewOffset(allIndexes, allSizes, labels[i]);\n                }\n            }\n            attr = attr.next;\n        }\n\n        // replaces old bytecodes with new ones\n        code = newCode;\n    }\n\n    /**\n     * Reads an unsigned short value in the given byte array.\n     *\n     * @param b\n     *            a byte array.\n     * @param index\n     *            the start index of the value to be read.\n     * @return the read value.\n     */\n    static int readUnsignedShort(final byte[] b, final int index) {\n        return ((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF);\n    }\n\n    /**\n     * Reads a signed short value in the given byte array.\n     *\n     * @param b\n     *            a byte array.\n     * @param index\n     *            the start index of the value to be read.\n     * @return the read value.\n     */\n    static short readShort(final byte[] b, final int index) {\n        return (short) (((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF));\n    }\n\n    /**\n     * Reads a signed int value in the given byte array.\n     *\n     * @param b\n     *            a byte array.\n     * @param index\n     *            the start index of the value to be read.\n     * @return the read value.\n     */\n    static int readInt(final byte[] b, final int index) {\n        return ((b[index] & 0xFF) << 24) | ((b[index + 1] & 0xFF) << 16)\n                | ((b[index + 2] & 0xFF) << 8) | (b[index + 3] & 0xFF);\n    }\n\n    /**\n     * Writes a short value in the given byte array.\n     *\n     * @param b\n     *            a byte array.\n     * @param index\n     *            where the first byte of the short value must be written.\n     * @param s\n     *            the value to be written in the given byte array.\n     */\n    static void writeShort(final byte[] b, final int index, final int s) {\n        b[index] = (byte) (s >>> 8);\n        b[index + 1] = (byte) s;\n    }\n\n    /**\n     * Computes the future value of a bytecode offset.\n     * <p>\n     * Note: it is possible to have several entries for the same instruction in\n     * the <tt>indexes</tt> and <tt>sizes</tt>: two entries (index=a,size=b) and\n     * (index=a,size=b') are equivalent to a single entry (index=a,size=b+b').\n     *\n     * @param indexes\n     *            current positions of the instructions to be resized. Each\n     *            instruction must be designated by the index of its <i>last</i>\n     *            byte, plus one (or, in other words, by the index of the\n     *            <i>first</i> byte of the <i>next</i> instruction).\n     * @param sizes\n     *            the number of bytes to be <i>added</i> to the above\n     *            instructions. More precisely, for each i < <tt>len</tt>,\n     *            <tt>sizes</tt>[i] bytes will be added at the end of the\n     *            instruction designated by <tt>indexes</tt>[i] or, if\n     *            <tt>sizes</tt>[i] is negative, the <i>last</i> |\n     *            <tt>sizes[i]</tt>| bytes of the instruction will be removed\n     *            (the instruction size <i>must not</i> become negative or\n     *            null).\n     * @param begin\n     *            index of the first byte of the source instruction.\n     * @param end\n     *            index of the first byte of the target instruction.\n     * @return the future value of the given bytecode offset.\n     */\n    static int getNewOffset(final int[] indexes, final int[] sizes,\n            final int begin, final int end) {\n        int offset = end - begin;\n        for (int i = 0; i < indexes.length; ++i) {\n            if (begin < indexes[i] && indexes[i] <= end) {\n                // forward jump\n                offset += sizes[i];\n            } else if (end < indexes[i] && indexes[i] <= begin) {\n                // backward jump\n                offset -= sizes[i];\n            }\n        }\n        return offset;\n    }\n\n    /**\n     * Updates the offset of the given label.\n     *\n     * @param indexes\n     *            current positions of the instructions to be resized. Each\n     *            instruction must be designated by the index of its <i>last</i>\n     *            byte, plus one (or, in other words, by the index of the\n     *            <i>first</i> byte of the <i>next</i> instruction).\n     * @param sizes\n     *            the number of bytes to be <i>added</i> to the above\n     *            instructions. More precisely, for each i < <tt>len</tt>,\n     *            <tt>sizes</tt>[i] bytes will be added at the end of the\n     *            instruction designated by <tt>indexes</tt>[i] or, if\n     *            <tt>sizes</tt>[i] is negative, the <i>last</i> |\n     *            <tt>sizes[i]</tt>| bytes of the instruction will be removed\n     *            (the instruction size <i>must not</i> become negative or\n     *            null).\n     * @param label\n     *            the label whose offset must be updated.\n     */\n    static void getNewOffset(final int[] indexes, final int[] sizes,\n            final Label label) {\n        if ((label.status & Label.RESIZED) == 0) {\n            label.position = getNewOffset(indexes, sizes, 0, label.position);\n            label.status |= Label.RESIZED;\n        }\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/Opcodes.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\n/**\n * Defines the JVM opcodes, access flags and array type codes. This interface\n * does not define all the JVM opcodes because some opcodes are automatically\n * handled. For example, the xLOAD and xSTORE opcodes are automatically replaced\n * by xLOAD_n and xSTORE_n opcodes when possible. The xLOAD_n and xSTORE_n\n * opcodes are therefore not defined in this interface. Likewise for LDC,\n * automatically replaced by LDC_W or LDC2_W when necessary, WIDE, GOTO_W and\n * JSR_W.\n *\n * @author Eric Bruneton\n * @author Eugene Kuleshov\n */\npublic interface Opcodes {\n\n    // ASM API versions\n\n    int ASM4 = 4 << 16 | 0 << 8 | 0;\n\n    // versions\n\n    int V1_1 = 3 << 16 | 45;\n    int V1_2 = 0 << 16 | 46;\n    int V1_3 = 0 << 16 | 47;\n    int V1_4 = 0 << 16 | 48;\n    int V1_5 = 0 << 16 | 49;\n    int V1_6 = 0 << 16 | 50;\n    int V1_7 = 0 << 16 | 51;\n\n    // access flags\n\n    int ACC_PUBLIC = 0x0001; // class, field, method\n    int ACC_PRIVATE = 0x0002; // class, field, method\n    int ACC_PROTECTED = 0x0004; // class, field, method\n    int ACC_STATIC = 0x0008; // field, method\n    int ACC_FINAL = 0x0010; // class, field, method\n    int ACC_SUPER = 0x0020; // class\n    int ACC_SYNCHRONIZED = 0x0020; // method\n    int ACC_VOLATILE = 0x0040; // field\n    int ACC_BRIDGE = 0x0040; // method\n    int ACC_VARARGS = 0x0080; // method\n    int ACC_TRANSIENT = 0x0080; // field\n    int ACC_NATIVE = 0x0100; // method\n    int ACC_INTERFACE = 0x0200; // class\n    int ACC_ABSTRACT = 0x0400; // class, method\n    int ACC_STRICT = 0x0800; // method\n    int ACC_SYNTHETIC = 0x1000; // class, field, method\n    int ACC_ANNOTATION = 0x2000; // class\n    int ACC_ENUM = 0x4000; // class(?) field inner\n\n    // ASM specific pseudo access flags\n\n    int ACC_DEPRECATED = 0x20000; // class, field, method\n\n    // types for NEWARRAY\n\n    int T_BOOLEAN = 4;\n    int T_CHAR = 5;\n    int T_FLOAT = 6;\n    int T_DOUBLE = 7;\n    int T_BYTE = 8;\n    int T_SHORT = 9;\n    int T_INT = 10;\n    int T_LONG = 11;\n\n    // tags for Handle\n\n    int H_GETFIELD = 1;\n    int H_GETSTATIC = 2;\n    int H_PUTFIELD = 3;\n    int H_PUTSTATIC = 4;\n    int H_INVOKEVIRTUAL = 5;\n    int H_INVOKESTATIC = 6;\n    int H_INVOKESPECIAL = 7;\n    int H_NEWINVOKESPECIAL = 8;\n    int H_INVOKEINTERFACE = 9;\n\n    // stack map frame types\n\n    /**\n     * Represents an expanded frame. See {@link ClassReader#EXPAND_FRAMES}.\n     */\n    int F_NEW = -1;\n\n    /**\n     * Represents a compressed frame with complete frame data.\n     */\n    int F_FULL = 0;\n\n    /**\n     * Represents a compressed frame where locals are the same as the locals in\n     * the previous frame, except that additional 1-3 locals are defined, and\n     * with an empty stack.\n     */\n    int F_APPEND = 1;\n\n    /**\n     * Represents a compressed frame where locals are the same as the locals in\n     * the previous frame, except that the last 1-3 locals are absent and with\n     * an empty stack.\n     */\n    int F_CHOP = 2;\n\n    /**\n     * Represents a compressed frame with exactly the same locals as the\n     * previous frame and with an empty stack.\n     */\n    int F_SAME = 3;\n\n    /**\n     * Represents a compressed frame with exactly the same locals as the\n     * previous frame and with a single value on the stack.\n     */\n    int F_SAME1 = 4;\n\n    Integer TOP = new Integer(0);\n    Integer INTEGER = new Integer(1);\n    Integer FLOAT = new Integer(2);\n    Integer DOUBLE = new Integer(3);\n    Integer LONG = new Integer(4);\n    Integer NULL = new Integer(5);\n    Integer UNINITIALIZED_THIS = new Integer(6);\n\n    // opcodes // visit method (- = idem)\n\n    int NOP = 0; // visitInsn\n    int ACONST_NULL = 1; // -\n    int ICONST_M1 = 2; // -\n    int ICONST_0 = 3; // -\n    int ICONST_1 = 4; // -\n    int ICONST_2 = 5; // -\n    int ICONST_3 = 6; // -\n    int ICONST_4 = 7; // -\n    int ICONST_5 = 8; // -\n    int LCONST_0 = 9; // -\n    int LCONST_1 = 10; // -\n    int FCONST_0 = 11; // -\n    int FCONST_1 = 12; // -\n    int FCONST_2 = 13; // -\n    int DCONST_0 = 14; // -\n    int DCONST_1 = 15; // -\n    int BIPUSH = 16; // visitIntInsn\n    int SIPUSH = 17; // -\n    int LDC = 18; // visitLdcInsn\n    // int LDC_W = 19; // -\n    // int LDC2_W = 20; // -\n    int ILOAD = 21; // visitVarInsn\n    int LLOAD = 22; // -\n    int FLOAD = 23; // -\n    int DLOAD = 24; // -\n    int ALOAD = 25; // -\n    // int ILOAD_0 = 26; // -\n    // int ILOAD_1 = 27; // -\n    // int ILOAD_2 = 28; // -\n    // int ILOAD_3 = 29; // -\n    // int LLOAD_0 = 30; // -\n    // int LLOAD_1 = 31; // -\n    // int LLOAD_2 = 32; // -\n    // int LLOAD_3 = 33; // -\n    // int FLOAD_0 = 34; // -\n    // int FLOAD_1 = 35; // -\n    // int FLOAD_2 = 36; // -\n    // int FLOAD_3 = 37; // -\n    // int DLOAD_0 = 38; // -\n    // int DLOAD_1 = 39; // -\n    // int DLOAD_2 = 40; // -\n    // int DLOAD_3 = 41; // -\n    // int ALOAD_0 = 42; // -\n    // int ALOAD_1 = 43; // -\n    // int ALOAD_2 = 44; // -\n    // int ALOAD_3 = 45; // -\n    int IALOAD = 46; // visitInsn\n    int LALOAD = 47; // -\n    int FALOAD = 48; // -\n    int DALOAD = 49; // -\n    int AALOAD = 50; // -\n    int BALOAD = 51; // -\n    int CALOAD = 52; // -\n    int SALOAD = 53; // -\n    int ISTORE = 54; // visitVarInsn\n    int LSTORE = 55; // -\n    int FSTORE = 56; // -\n    int DSTORE = 57; // -\n    int ASTORE = 58; // -\n    // int ISTORE_0 = 59; // -\n    // int ISTORE_1 = 60; // -\n    // int ISTORE_2 = 61; // -\n    // int ISTORE_3 = 62; // -\n    // int LSTORE_0 = 63; // -\n    // int LSTORE_1 = 64; // -\n    // int LSTORE_2 = 65; // -\n    // int LSTORE_3 = 66; // -\n    // int FSTORE_0 = 67; // -\n    // int FSTORE_1 = 68; // -\n    // int FSTORE_2 = 69; // -\n    // int FSTORE_3 = 70; // -\n    // int DSTORE_0 = 71; // -\n    // int DSTORE_1 = 72; // -\n    // int DSTORE_2 = 73; // -\n    // int DSTORE_3 = 74; // -\n    // int ASTORE_0 = 75; // -\n    // int ASTORE_1 = 76; // -\n    // int ASTORE_2 = 77; // -\n    // int ASTORE_3 = 78; // -\n    int IASTORE = 79; // visitInsn\n    int LASTORE = 80; // -\n    int FASTORE = 81; // -\n    int DASTORE = 82; // -\n    int AASTORE = 83; // -\n    int BASTORE = 84; // -\n    int CASTORE = 85; // -\n    int SASTORE = 86; // -\n    int POP = 87; // -\n    int POP2 = 88; // -\n    int DUP = 89; // -\n    int DUP_X1 = 90; // -\n    int DUP_X2 = 91; // -\n    int DUP2 = 92; // -\n    int DUP2_X1 = 93; // -\n    int DUP2_X2 = 94; // -\n    int SWAP = 95; // -\n    int IADD = 96; // -\n    int LADD = 97; // -\n    int FADD = 98; // -\n    int DADD = 99; // -\n    int ISUB = 100; // -\n    int LSUB = 101; // -\n    int FSUB = 102; // -\n    int DSUB = 103; // -\n    int IMUL = 104; // -\n    int LMUL = 105; // -\n    int FMUL = 106; // -\n    int DMUL = 107; // -\n    int IDIV = 108; // -\n    int LDIV = 109; // -\n    int FDIV = 110; // -\n    int DDIV = 111; // -\n    int IREM = 112; // -\n    int LREM = 113; // -\n    int FREM = 114; // -\n    int DREM = 115; // -\n    int INEG = 116; // -\n    int LNEG = 117; // -\n    int FNEG = 118; // -\n    int DNEG = 119; // -\n    int ISHL = 120; // -\n    int LSHL = 121; // -\n    int ISHR = 122; // -\n    int LSHR = 123; // -\n    int IUSHR = 124; // -\n    int LUSHR = 125; // -\n    int IAND = 126; // -\n    int LAND = 127; // -\n    int IOR = 128; // -\n    int LOR = 129; // -\n    int IXOR = 130; // -\n    int LXOR = 131; // -\n    int IINC = 132; // visitIincInsn\n    int I2L = 133; // visitInsn\n    int I2F = 134; // -\n    int I2D = 135; // -\n    int L2I = 136; // -\n    int L2F = 137; // -\n    int L2D = 138; // -\n    int F2I = 139; // -\n    int F2L = 140; // -\n    int F2D = 141; // -\n    int D2I = 142; // -\n    int D2L = 143; // -\n    int D2F = 144; // -\n    int I2B = 145; // -\n    int I2C = 146; // -\n    int I2S = 147; // -\n    int LCMP = 148; // -\n    int FCMPL = 149; // -\n    int FCMPG = 150; // -\n    int DCMPL = 151; // -\n    int DCMPG = 152; // -\n    int IFEQ = 153; // visitJumpInsn\n    int IFNE = 154; // -\n    int IFLT = 155; // -\n    int IFGE = 156; // -\n    int IFGT = 157; // -\n    int IFLE = 158; // -\n    int IF_ICMPEQ = 159; // -\n    int IF_ICMPNE = 160; // -\n    int IF_ICMPLT = 161; // -\n    int IF_ICMPGE = 162; // -\n    int IF_ICMPGT = 163; // -\n    int IF_ICMPLE = 164; // -\n    int IF_ACMPEQ = 165; // -\n    int IF_ACMPNE = 166; // -\n    int GOTO = 167; // -\n    int JSR = 168; // -\n    int RET = 169; // visitVarInsn\n    int TABLESWITCH = 170; // visiTableSwitchInsn\n    int LOOKUPSWITCH = 171; // visitLookupSwitch\n    int IRETURN = 172; // visitInsn\n    int LRETURN = 173; // -\n    int FRETURN = 174; // -\n    int DRETURN = 175; // -\n    int ARETURN = 176; // -\n    int RETURN = 177; // -\n    int GETSTATIC = 178; // visitFieldInsn\n    int PUTSTATIC = 179; // -\n    int GETFIELD = 180; // -\n    int PUTFIELD = 181; // -\n    int INVOKEVIRTUAL = 182; // visitMethodInsn\n    int INVOKESPECIAL = 183; // -\n    int INVOKESTATIC = 184; // -\n    int INVOKEINTERFACE = 185; // -\n    int INVOKEDYNAMIC = 186; // visitInvokeDynamicInsn\n    int NEW = 187; // visitTypeInsn\n    int NEWARRAY = 188; // visitIntInsn\n    int ANEWARRAY = 189; // visitTypeInsn\n    int ARRAYLENGTH = 190; // visitInsn\n    int ATHROW = 191; // -\n    int CHECKCAST = 192; // visitTypeInsn\n    int INSTANCEOF = 193; // -\n    int MONITORENTER = 194; // visitInsn\n    int MONITOREXIT = 195; // -\n    // int WIDE = 196; // NOT VISITED\n    int MULTIANEWARRAY = 197; // visitMultiANewArrayInsn\n    int IFNULL = 198; // visitJumpInsn\n    int IFNONNULL = 199; // -\n    // int GOTO_W = 200; // -\n    // int JSR_W = 201; // -\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/Type.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm;\n\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Method;\n\n/**\n * A Java field or method type. This class can be used to make it easier to\n * manipulate type and method descriptors.\n *\n * @author Eric Bruneton\n * @author Chris Nokleberg\n */\npublic class Type {\n\n    /**\n     * The sort of the <tt>void</tt> type. See {@link #getSort getSort}.\n     */\n    public static final int VOID = 0;\n\n    /**\n     * The sort of the <tt>boolean</tt> type. See {@link #getSort getSort}.\n     */\n    public static final int BOOLEAN = 1;\n\n    /**\n     * The sort of the <tt>char</tt> type. See {@link #getSort getSort}.\n     */\n    public static final int CHAR = 2;\n\n    /**\n     * The sort of the <tt>byte</tt> type. See {@link #getSort getSort}.\n     */\n    public static final int BYTE = 3;\n\n    /**\n     * The sort of the <tt>short</tt> type. See {@link #getSort getSort}.\n     */\n    public static final int SHORT = 4;\n\n    /**\n     * The sort of the <tt>int</tt> type. See {@link #getSort getSort}.\n     */\n    public static final int INT = 5;\n\n    /**\n     * The sort of the <tt>float</tt> type. See {@link #getSort getSort}.\n     */\n    public static final int FLOAT = 6;\n\n    /**\n     * The sort of the <tt>long</tt> type. See {@link #getSort getSort}.\n     */\n    public static final int LONG = 7;\n\n    /**\n     * The sort of the <tt>double</tt> type. See {@link #getSort getSort}.\n     */\n    public static final int DOUBLE = 8;\n\n    /**\n     * The sort of array reference types. See {@link #getSort getSort}.\n     */\n    public static final int ARRAY = 9;\n\n    /**\n     * The sort of object reference types. See {@link #getSort getSort}.\n     */\n    public static final int OBJECT = 10;\n\n    /**\n     * The sort of method types. See {@link #getSort getSort}.\n     */\n    public static final int METHOD = 11;\n\n    /**\n     * The <tt>void</tt> type.\n     */\n    public static final Type VOID_TYPE = new Type(VOID, null, ('V' << 24)\n            | (5 << 16) | (0 << 8) | 0, 1);\n\n    /**\n     * The <tt>boolean</tt> type.\n     */\n    public static final Type BOOLEAN_TYPE = new Type(BOOLEAN, null, ('Z' << 24)\n            | (0 << 16) | (5 << 8) | 1, 1);\n\n    /**\n     * The <tt>char</tt> type.\n     */\n    public static final Type CHAR_TYPE = new Type(CHAR, null, ('C' << 24)\n            | (0 << 16) | (6 << 8) | 1, 1);\n\n    /**\n     * The <tt>byte</tt> type.\n     */\n    public static final Type BYTE_TYPE = new Type(BYTE, null, ('B' << 24)\n            | (0 << 16) | (5 << 8) | 1, 1);\n\n    /**\n     * The <tt>short</tt> type.\n     */\n    public static final Type SHORT_TYPE = new Type(SHORT, null, ('S' << 24)\n            | (0 << 16) | (7 << 8) | 1, 1);\n\n    /**\n     * The <tt>int</tt> type.\n     */\n    public static final Type INT_TYPE = new Type(INT, null, ('I' << 24)\n            | (0 << 16) | (0 << 8) | 1, 1);\n\n    /**\n     * The <tt>float</tt> type.\n     */\n    public static final Type FLOAT_TYPE = new Type(FLOAT, null, ('F' << 24)\n            | (2 << 16) | (2 << 8) | 1, 1);\n\n    /**\n     * The <tt>long</tt> type.\n     */\n    public static final Type LONG_TYPE = new Type(LONG, null, ('J' << 24)\n            | (1 << 16) | (1 << 8) | 2, 1);\n\n    /**\n     * The <tt>double</tt> type.\n     */\n    public static final Type DOUBLE_TYPE = new Type(DOUBLE, null, ('D' << 24)\n            | (3 << 16) | (3 << 8) | 2, 1);\n\n    // ------------------------------------------------------------------------\n    // Fields\n    // ------------------------------------------------------------------------\n\n    /**\n     * The sort of this Java type.\n     */\n    private final int sort;\n\n    /**\n     * A buffer containing the internal name of this Java type. This field is\n     * only used for reference types.\n     */\n    private final char[] buf;\n\n    /**\n     * The offset of the internal name of this Java type in {@link #buf buf} or,\n     * for primitive types, the size, descriptor and getOpcode offsets for this\n     * type (byte 0 contains the size, byte 1 the descriptor, byte 2 the offset\n     * for IALOAD or IASTORE, byte 3 the offset for all other instructions).\n     */\n    private final int off;\n\n    /**\n     * The length of the internal name of this Java type.\n     */\n    private final int len;\n\n    // ------------------------------------------------------------------------\n    // Constructors\n    // ------------------------------------------------------------------------\n\n    /**\n     * Constructs a reference type.\n     *\n     * @param sort\n     *            the sort of the reference type to be constructed.\n     * @param buf\n     *            a buffer containing the descriptor of the previous type.\n     * @param off\n     *            the offset of this descriptor in the previous buffer.\n     * @param len\n     *            the length of this descriptor.\n     */\n    private Type(final int sort, final char[] buf, final int off, final int len) {\n        this.sort = sort;\n        this.buf = buf;\n        this.off = off;\n        this.len = len;\n    }\n\n    /**\n     * Returns the Java type corresponding to the given type descriptor.\n     *\n     * @param typeDescriptor\n     *            a field or method type descriptor.\n     * @return the Java type corresponding to the given type descriptor.\n     */\n    public static Type getType(final String typeDescriptor) {\n        return getType(typeDescriptor.toCharArray(), 0);\n    }\n\n    /**\n     * Returns the Java type corresponding to the given internal name.\n     *\n     * @param internalName\n     *            an internal name.\n     * @return the Java type corresponding to the given internal name.\n     */\n    public static Type getObjectType(final String internalName) {\n        char[] buf = internalName.toCharArray();\n        return new Type(buf[0] == '[' ? ARRAY : OBJECT, buf, 0, buf.length);\n    }\n\n    /**\n     * Returns the Java type corresponding to the given method descriptor.\n     * Equivalent to <code>Type.getType(methodDescriptor)</code>.\n     *\n     * @param methodDescriptor\n     *            a method descriptor.\n     * @return the Java type corresponding to the given method descriptor.\n     */\n    public static Type getMethodType(final String methodDescriptor) {\n        return getType(methodDescriptor.toCharArray(), 0);\n    }\n\n    /**\n     * Returns the Java method type corresponding to the given argument and\n     * return types.\n     *\n     * @param returnType\n     *            the return type of the method.\n     * @param argumentTypes\n     *            the argument types of the method.\n     * @return the Java type corresponding to the given argument and return\n     *         types.\n     */\n    public static Type getMethodType(final Type returnType,\n            final Type... argumentTypes) {\n        return getType(getMethodDescriptor(returnType, argumentTypes));\n    }\n\n    /**\n     * Returns the Java type corresponding to the given class.\n     *\n     * @param c\n     *            a class.\n     * @return the Java type corresponding to the given class.\n     */\n    public static Type getType(final Class<?> c) {\n        if (c.isPrimitive()) {\n            if (c == Integer.TYPE) {\n                return INT_TYPE;\n            } else if (c == Void.TYPE) {\n                return VOID_TYPE;\n            } else if (c == Boolean.TYPE) {\n                return BOOLEAN_TYPE;\n            } else if (c == Byte.TYPE) {\n                return BYTE_TYPE;\n            } else if (c == Character.TYPE) {\n                return CHAR_TYPE;\n            } else if (c == Short.TYPE) {\n                return SHORT_TYPE;\n            } else if (c == Double.TYPE) {\n                return DOUBLE_TYPE;\n            } else if (c == Float.TYPE) {\n                return FLOAT_TYPE;\n            } else /* if (c == Long.TYPE) */{\n                return LONG_TYPE;\n            }\n        } else {\n            return getType(getDescriptor(c));\n        }\n    }\n\n    /**\n     * Returns the Java method type corresponding to the given constructor.\n     *\n     * @param c\n     *            a {@link Constructor Constructor} object.\n     * @return the Java method type corresponding to the given constructor.\n     */\n    public static Type getType(final Constructor<?> c) {\n        return getType(getConstructorDescriptor(c));\n    }\n\n    /**\n     * Returns the Java method type corresponding to the given method.\n     *\n     * @param m\n     *            a {@link Method Method} object.\n     * @return the Java method type corresponding to the given method.\n     */\n    public static Type getType(final Method m) {\n        return getType(getMethodDescriptor(m));\n    }\n\n    /**\n     * Returns the Java types corresponding to the argument types of the given\n     * method descriptor.\n     *\n     * @param methodDescriptor\n     *            a method descriptor.\n     * @return the Java types corresponding to the argument types of the given\n     *         method descriptor.\n     */\n    public static Type[] getArgumentTypes(final String methodDescriptor) {\n        char[] buf = methodDescriptor.toCharArray();\n        int off = 1;\n        int size = 0;\n        while (true) {\n            char car = buf[off++];\n            if (car == ')') {\n                break;\n            } else if (car == 'L') {\n                while (buf[off++] != ';') {\n                }\n                ++size;\n            } else if (car != '[') {\n                ++size;\n            }\n        }\n        Type[] args = new Type[size];\n        off = 1;\n        size = 0;\n        while (buf[off] != ')') {\n            args[size] = getType(buf, off);\n            off += args[size].len + (args[size].sort == OBJECT ? 2 : 0);\n            size += 1;\n        }\n        return args;\n    }\n\n    /**\n     * Returns the Java types corresponding to the argument types of the given\n     * method.\n     *\n     * @param method\n     *            a method.\n     * @return the Java types corresponding to the argument types of the given\n     *         method.\n     */\n    public static Type[] getArgumentTypes(final Method method) {\n        Class<?>[] classes = method.getParameterTypes();\n        Type[] types = new Type[classes.length];\n        for (int i = classes.length - 1; i >= 0; --i) {\n            types[i] = getType(classes[i]);\n        }\n        return types;\n    }\n\n    /**\n     * Returns the Java type corresponding to the return type of the given\n     * method descriptor.\n     *\n     * @param methodDescriptor\n     *            a method descriptor.\n     * @return the Java type corresponding to the return type of the given\n     *         method descriptor.\n     */\n    public static Type getReturnType(final String methodDescriptor) {\n        char[] buf = methodDescriptor.toCharArray();\n        return getType(buf, methodDescriptor.indexOf(')') + 1);\n    }\n\n    /**\n     * Returns the Java type corresponding to the return type of the given\n     * method.\n     *\n     * @param method\n     *            a method.\n     * @return the Java type corresponding to the return type of the given\n     *         method.\n     */\n    public static Type getReturnType(final Method method) {\n        return getType(method.getReturnType());\n    }\n\n    /**\n     * Computes the size of the arguments and of the return value of a method.\n     *\n     * @param desc\n     *            the descriptor of a method.\n     * @return the size of the arguments of the method (plus one for the\n     *         implicit this argument), argSize, and the size of its return\n     *         value, retSize, packed into a single int i =\n     *         <tt>(argSize << 2) | retSize</tt> (argSize is therefore equal to\n     *         <tt>i >> 2</tt>, and retSize to <tt>i & 0x03</tt>).\n     */\n    public static int getArgumentsAndReturnSizes(final String desc) {\n        int n = 1;\n        int c = 1;\n        while (true) {\n            char car = desc.charAt(c++);\n            if (car == ')') {\n                car = desc.charAt(c);\n                return n << 2\n                        | (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));\n            } else if (car == 'L') {\n                while (desc.charAt(c++) != ';') {\n                }\n                n += 1;\n            } else if (car == '[') {\n                while ((car = desc.charAt(c)) == '[') {\n                    ++c;\n                }\n                if (car == 'D' || car == 'J') {\n                    n -= 1;\n                }\n            } else if (car == 'D' || car == 'J') {\n                n += 2;\n            } else {\n                n += 1;\n            }\n        }\n    }\n\n    /**\n     * Returns the Java type corresponding to the given type descriptor. For\n     * method descriptors, buf is supposed to contain nothing more than the\n     * descriptor itself.\n     *\n     * @param buf\n     *            a buffer containing a type descriptor.\n     * @param off\n     *            the offset of this descriptor in the previous buffer.\n     * @return the Java type corresponding to the given type descriptor.\n     */\n    private static Type getType(final char[] buf, final int off) {\n        int len;\n        switch (buf[off]) {\n        case 'V':\n            return VOID_TYPE;\n        case 'Z':\n            return BOOLEAN_TYPE;\n        case 'C':\n            return CHAR_TYPE;\n        case 'B':\n            return BYTE_TYPE;\n        case 'S':\n            return SHORT_TYPE;\n        case 'I':\n            return INT_TYPE;\n        case 'F':\n            return FLOAT_TYPE;\n        case 'J':\n            return LONG_TYPE;\n        case 'D':\n            return DOUBLE_TYPE;\n        case '[':\n            len = 1;\n            while (buf[off + len] == '[') {\n                ++len;\n            }\n            if (buf[off + len] == 'L') {\n                ++len;\n                while (buf[off + len] != ';') {\n                    ++len;\n                }\n            }\n            return new Type(ARRAY, buf, off, len + 1);\n        case 'L':\n            len = 1;\n            while (buf[off + len] != ';') {\n                ++len;\n            }\n            return new Type(OBJECT, buf, off + 1, len - 1);\n            // case '(':\n        default:\n            return new Type(METHOD, buf, off, buf.length - off);\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Accessors\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns the sort of this Java type.\n     *\n     * @return {@link #VOID VOID}, {@link #BOOLEAN BOOLEAN}, {@link #CHAR CHAR},\n     *         {@link #BYTE BYTE}, {@link #SHORT SHORT}, {@link #INT INT},\n     *         {@link #FLOAT FLOAT}, {@link #LONG LONG}, {@link #DOUBLE DOUBLE},\n     *         {@link #ARRAY ARRAY}, {@link #OBJECT OBJECT} or {@link #METHOD\n     *         METHOD}.\n     */\n    public int getSort() {\n        return sort;\n    }\n\n    /**\n     * Returns the number of dimensions of this array type. This method should\n     * only be used for an array type.\n     *\n     * @return the number of dimensions of this array type.\n     */\n    public int getDimensions() {\n        int i = 1;\n        while (buf[off + i] == '[') {\n            ++i;\n        }\n        return i;\n    }\n\n    /**\n     * Returns the type of the elements of this array type. This method should\n     * only be used for an array type.\n     *\n     * @return Returns the type of the elements of this array type.\n     */\n    public Type getElementType() {\n        return getType(buf, off + getDimensions());\n    }\n\n    /**\n     * Returns the binary name of the class corresponding to this type. This\n     * method must not be used on method types.\n     *\n     * @return the binary name of the class corresponding to this type.\n     */\n    public String getClassName() {\n        switch (sort) {\n        case VOID:\n            return \"void\";\n        case BOOLEAN:\n            return \"boolean\";\n        case CHAR:\n            return \"char\";\n        case BYTE:\n            return \"byte\";\n        case SHORT:\n            return \"short\";\n        case INT:\n            return \"int\";\n        case FLOAT:\n            return \"float\";\n        case LONG:\n            return \"long\";\n        case DOUBLE:\n            return \"double\";\n        case ARRAY:\n            StringBuffer b = new StringBuffer(getElementType().getClassName());\n            for (int i = getDimensions(); i > 0; --i) {\n                b.append(\"[]\");\n            }\n            return b.toString();\n        case OBJECT:\n            return new String(buf, off, len).replace('/', '.');\n        default:\n            return null;\n        }\n    }\n\n    /**\n     * Returns the internal name of the class corresponding to this object or\n     * array type. The internal name of a class is its fully qualified name (as\n     * returned by Class.getName(), where '.' are replaced by '/'. This method\n     * should only be used for an object or array type.\n     *\n     * @return the internal name of the class corresponding to this object type.\n     */\n    public String getInternalName() {\n        return new String(buf, off, len);\n    }\n\n    /**\n     * Returns the argument types of methods of this type. This method should\n     * only be used for method types.\n     *\n     * @return the argument types of methods of this type.\n     */\n    public Type[] getArgumentTypes() {\n        return getArgumentTypes(getDescriptor());\n    }\n\n    /**\n     * Returns the return type of methods of this type. This method should only\n     * be used for method types.\n     *\n     * @return the return type of methods of this type.\n     */\n    public Type getReturnType() {\n        return getReturnType(getDescriptor());\n    }\n\n    /**\n     * Returns the size of the arguments and of the return value of methods of\n     * this type. This method should only be used for method types.\n     *\n     * @return the size of the arguments (plus one for the implicit this\n     *         argument), argSize, and the size of the return value, retSize,\n     *         packed into a single int i = <tt>(argSize << 2) | retSize</tt>\n     *         (argSize is therefore equal to <tt>i >> 2</tt>, and retSize to\n     *         <tt>i & 0x03</tt>).\n     */\n    public int getArgumentsAndReturnSizes() {\n        return getArgumentsAndReturnSizes(getDescriptor());\n    }\n\n    // ------------------------------------------------------------------------\n    // Conversion to type descriptors\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns the descriptor corresponding to this Java type.\n     *\n     * @return the descriptor corresponding to this Java type.\n     */\n    public String getDescriptor() {\n        StringBuffer buf = new StringBuffer();\n        getDescriptor(buf);\n        return buf.toString();\n    }\n\n    /**\n     * Returns the descriptor corresponding to the given argument and return\n     * types.\n     *\n     * @param returnType\n     *            the return type of the method.\n     * @param argumentTypes\n     *            the argument types of the method.\n     * @return the descriptor corresponding to the given argument and return\n     *         types.\n     */\n    public static String getMethodDescriptor(final Type returnType,\n            final Type... argumentTypes) {\n        StringBuffer buf = new StringBuffer();\n        buf.append('(');\n        for (int i = 0; i < argumentTypes.length; ++i) {\n            argumentTypes[i].getDescriptor(buf);\n        }\n        buf.append(')');\n        returnType.getDescriptor(buf);\n        return buf.toString();\n    }\n\n    /**\n     * Appends the descriptor corresponding to this Java type to the given\n     * string buffer.\n     *\n     * @param buf\n     *            the string buffer to which the descriptor must be appended.\n     */\n    private void getDescriptor(final StringBuffer buf) {\n        if (this.buf == null) {\n            // descriptor is in byte 3 of 'off' for primitive types (buf ==\n            // null)\n            buf.append((char) ((off & 0xFF000000) >>> 24));\n        } else if (sort == OBJECT) {\n            buf.append('L');\n            buf.append(this.buf, off, len);\n            buf.append(';');\n        } else { // sort == ARRAY || sort == METHOD\n            buf.append(this.buf, off, len);\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Direct conversion from classes to type descriptors,\n    // without intermediate Type objects\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns the internal name of the given class. The internal name of a\n     * class is its fully qualified name, as returned by Class.getName(), where\n     * '.' are replaced by '/'.\n     *\n     * @param c\n     *            an object or array class.\n     * @return the internal name of the given class.\n     */\n    public static String getInternalName(final Class<?> c) {\n        return c.getName().replace('.', '/');\n    }\n\n    /**\n     * Returns the descriptor corresponding to the given Java type.\n     *\n     * @param c\n     *            an object class, a primitive class or an array class.\n     * @return the descriptor corresponding to the given class.\n     */\n    public static String getDescriptor(final Class<?> c) {\n        StringBuffer buf = new StringBuffer();\n        getDescriptor(buf, c);\n        return buf.toString();\n    }\n\n    /**\n     * Returns the descriptor corresponding to the given constructor.\n     *\n     * @param c\n     *            a {@link Constructor Constructor} object.\n     * @return the descriptor of the given constructor.\n     */\n    public static String getConstructorDescriptor(final Constructor<?> c) {\n        Class<?>[] parameters = c.getParameterTypes();\n        StringBuffer buf = new StringBuffer();\n        buf.append('(');\n        for (int i = 0; i < parameters.length; ++i) {\n            getDescriptor(buf, parameters[i]);\n        }\n        return buf.append(\")V\").toString();\n    }\n\n    /**\n     * Returns the descriptor corresponding to the given method.\n     *\n     * @param m\n     *            a {@link Method Method} object.\n     * @return the descriptor of the given method.\n     */\n    public static String getMethodDescriptor(final Method m) {\n        Class<?>[] parameters = m.getParameterTypes();\n        StringBuffer buf = new StringBuffer();\n        buf.append('(');\n        for (int i = 0; i < parameters.length; ++i) {\n            getDescriptor(buf, parameters[i]);\n        }\n        buf.append(')');\n        getDescriptor(buf, m.getReturnType());\n        return buf.toString();\n    }\n\n    /**\n     * Appends the descriptor of the given class to the given string buffer.\n     *\n     * @param buf\n     *            the string buffer to which the descriptor must be appended.\n     * @param c\n     *            the class whose descriptor must be computed.\n     */\n    private static void getDescriptor(final StringBuffer buf, final Class<?> c) {\n        Class<?> d = c;\n        while (true) {\n            if (d.isPrimitive()) {\n                char car;\n                if (d == Integer.TYPE) {\n                    car = 'I';\n                } else if (d == Void.TYPE) {\n                    car = 'V';\n                } else if (d == Boolean.TYPE) {\n                    car = 'Z';\n                } else if (d == Byte.TYPE) {\n                    car = 'B';\n                } else if (d == Character.TYPE) {\n                    car = 'C';\n                } else if (d == Short.TYPE) {\n                    car = 'S';\n                } else if (d == Double.TYPE) {\n                    car = 'D';\n                } else if (d == Float.TYPE) {\n                    car = 'F';\n                } else /* if (d == Long.TYPE) */{\n                    car = 'J';\n                }\n                buf.append(car);\n                return;\n            } else if (d.isArray()) {\n                buf.append('[');\n                d = d.getComponentType();\n            } else {\n                buf.append('L');\n                String name = d.getName();\n                int len = name.length();\n                for (int i = 0; i < len; ++i) {\n                    char car = name.charAt(i);\n                    buf.append(car == '.' ? '/' : car);\n                }\n                buf.append(';');\n                return;\n            }\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Corresponding size and opcodes\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns the size of values of this type. This method must not be used for\n     * method types.\n     *\n     * @return the size of values of this type, i.e., 2 for <tt>long</tt> and\n     *         <tt>double</tt>, 0 for <tt>void</tt> and 1 otherwise.\n     */\n    public int getSize() {\n        // the size is in byte 0 of 'off' for primitive types (buf == null)\n        return buf == null ? (off & 0xFF) : 1;\n    }\n\n    /**\n     * Returns a JVM instruction opcode adapted to this Java type. This method\n     * must not be used for method types.\n     *\n     * @param opcode\n     *            a JVM instruction opcode. This opcode must be one of ILOAD,\n     *            ISTORE, IALOAD, IASTORE, IADD, ISUB, IMUL, IDIV, IREM, INEG,\n     *            ISHL, ISHR, IUSHR, IAND, IOR, IXOR and IRETURN.\n     * @return an opcode that is similar to the given opcode, but adapted to\n     *         this Java type. For example, if this type is <tt>float</tt> and\n     *         <tt>opcode</tt> is IRETURN, this method returns FRETURN.\n     */\n    public int getOpcode(final int opcode) {\n        if (opcode == Opcodes.IALOAD || opcode == Opcodes.IASTORE) {\n            // the offset for IALOAD or IASTORE is in byte 1 of 'off' for\n            // primitive types (buf == null)\n            return opcode + (buf == null ? (off & 0xFF00) >> 8 : 4);\n        } else {\n            // the offset for other instructions is in byte 2 of 'off' for\n            // primitive types (buf == null)\n            return opcode + (buf == null ? (off & 0xFF0000) >> 16 : 4);\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Equals, hashCode and toString\n    // ------------------------------------------------------------------------\n\n    /**\n     * Tests if the given object is equal to this type.\n     *\n     * @param o\n     *            the object to be compared to this type.\n     * @return <tt>true</tt> if the given object is equal to this type.\n     */\n    @Override\n    public boolean equals(final Object o) {\n        if (this == o) {\n            return true;\n        }\n        if (!(o instanceof Type)) {\n            return false;\n        }\n        Type t = (Type) o;\n        if (sort != t.sort) {\n            return false;\n        }\n        if (sort >= ARRAY) {\n            if (len != t.len) {\n                return false;\n            }\n            for (int i = off, j = t.off, end = i + len; i < end; i++, j++) {\n                if (buf[i] != t.buf[j]) {\n                    return false;\n                }\n            }\n        }\n        return true;\n    }\n\n    /**\n     * Returns a hash code value for this type.\n     *\n     * @return a hash code value for this type.\n     */\n    @Override\n    public int hashCode() {\n        int hc = 13 * sort;\n        if (sort >= ARRAY) {\n            for (int i = off, end = i + len; i < end; i++) {\n                hc = 17 * (hc + buf[i]);\n            }\n        }\n        return hc;\n    }\n\n    /**\n     * Returns a string representation of this type.\n     *\n     * @return the descriptor of this type.\n     */\n    @Override\n    public String toString() {\n        return getDescriptor();\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/commons/AdviceAdapter.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm.commons;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport clojure.asm.Handle;\nimport clojure.asm.Label;\nimport clojure.asm.MethodVisitor;\nimport clojure.asm.Opcodes;\nimport clojure.asm.Type;\n\n/**\n * A {@link clojure.asm.MethodVisitor} to insert before, after and around\n * advices in methods and constructors.\n * <p>\n * The behavior for constructors is like this:\n * <ol>\n *\n * <li>as long as the INVOKESPECIAL for the object initialization has not been\n * reached, every bytecode instruction is dispatched in the ctor code visitor</li>\n *\n * <li>when this one is reached, it is only added in the ctor code visitor and a\n * JP invoke is added</li>\n *\n * <li>after that, only the other code visitor receives the instructions</li>\n *\n * </ol>\n *\n * @author Eugene Kuleshov\n * @author Eric Bruneton\n */\npublic abstract class AdviceAdapter extends GeneratorAdapter implements Opcodes {\n\n    private static final Object THIS = new Object();\n\n    private static final Object OTHER = new Object();\n\n    protected int methodAccess;\n\n    protected String methodDesc;\n\n    private boolean constructor;\n\n    private boolean superInitialized;\n\n    private List<Object> stackFrame;\n\n    private Map<Label, List<Object>> branches;\n\n    /**\n     * Creates a new {@link AdviceAdapter}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     * @param mv\n     *            the method visitor to which this adapter delegates calls.\n     * @param access\n     *            the method's access flags (see {@link Opcodes}).\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor (see {@link Type Type}).\n     */\n    protected AdviceAdapter(final int api, final MethodVisitor mv,\n            final int access, final String name, final String desc) {\n        super(api, mv, access, name, desc);\n        methodAccess = access;\n        methodDesc = desc;\n        constructor = \"<init>\".equals(name);\n    }\n\n    @Override\n    public void visitCode() {\n        mv.visitCode();\n        if (constructor) {\n            stackFrame = new ArrayList<Object>();\n            branches = new HashMap<Label, List<Object>>();\n        } else {\n            superInitialized = true;\n            onMethodEnter();\n        }\n    }\n\n    @Override\n    public void visitLabel(final Label label) {\n        mv.visitLabel(label);\n        if (constructor && branches != null) {\n            List<Object> frame = branches.get(label);\n            if (frame != null) {\n                stackFrame = frame;\n                branches.remove(label);\n            }\n        }\n    }\n\n    @Override\n    public void visitInsn(final int opcode) {\n        if (constructor) {\n            int s;\n            switch (opcode) {\n            case RETURN: // empty stack\n                onMethodExit(opcode);\n                break;\n            case IRETURN: // 1 before n/a after\n            case FRETURN: // 1 before n/a after\n            case ARETURN: // 1 before n/a after\n            case ATHROW: // 1 before n/a after\n                popValue();\n                onMethodExit(opcode);\n                break;\n            case LRETURN: // 2 before n/a after\n            case DRETURN: // 2 before n/a after\n                popValue();\n                popValue();\n                onMethodExit(opcode);\n                break;\n            case NOP:\n            case LALOAD: // remove 2 add 2\n            case DALOAD: // remove 2 add 2\n            case LNEG:\n            case DNEG:\n            case FNEG:\n            case INEG:\n            case L2D:\n            case D2L:\n            case F2I:\n            case I2B:\n            case I2C:\n            case I2S:\n            case I2F:\n            case ARRAYLENGTH:\n                break;\n            case ACONST_NULL:\n            case ICONST_M1:\n            case ICONST_0:\n            case ICONST_1:\n            case ICONST_2:\n            case ICONST_3:\n            case ICONST_4:\n            case ICONST_5:\n            case FCONST_0:\n            case FCONST_1:\n            case FCONST_2:\n            case F2L: // 1 before 2 after\n            case F2D:\n            case I2L:\n            case I2D:\n                pushValue(OTHER);\n                break;\n            case LCONST_0:\n            case LCONST_1:\n            case DCONST_0:\n            case DCONST_1:\n                pushValue(OTHER);\n                pushValue(OTHER);\n                break;\n            case IALOAD: // remove 2 add 1\n            case FALOAD: // remove 2 add 1\n            case AALOAD: // remove 2 add 1\n            case BALOAD: // remove 2 add 1\n            case CALOAD: // remove 2 add 1\n            case SALOAD: // remove 2 add 1\n            case POP:\n            case IADD:\n            case FADD:\n            case ISUB:\n            case LSHL: // 3 before 2 after\n            case LSHR: // 3 before 2 after\n            case LUSHR: // 3 before 2 after\n            case L2I: // 2 before 1 after\n            case L2F: // 2 before 1 after\n            case D2I: // 2 before 1 after\n            case D2F: // 2 before 1 after\n            case FSUB:\n            case FMUL:\n            case FDIV:\n            case FREM:\n            case FCMPL: // 2 before 1 after\n            case FCMPG: // 2 before 1 after\n            case IMUL:\n            case IDIV:\n            case IREM:\n            case ISHL:\n            case ISHR:\n            case IUSHR:\n            case IAND:\n            case IOR:\n            case IXOR:\n            case MONITORENTER:\n            case MONITOREXIT:\n                popValue();\n                break;\n            case POP2:\n            case LSUB:\n            case LMUL:\n            case LDIV:\n            case LREM:\n            case LADD:\n            case LAND:\n            case LOR:\n            case LXOR:\n            case DADD:\n            case DMUL:\n            case DSUB:\n            case DDIV:\n            case DREM:\n                popValue();\n                popValue();\n                break;\n            case IASTORE:\n            case FASTORE:\n            case AASTORE:\n            case BASTORE:\n            case CASTORE:\n            case SASTORE:\n            case LCMP: // 4 before 1 after\n            case DCMPL:\n            case DCMPG:\n                popValue();\n                popValue();\n                popValue();\n                break;\n            case LASTORE:\n            case DASTORE:\n                popValue();\n                popValue();\n                popValue();\n                popValue();\n                break;\n            case DUP:\n                pushValue(peekValue());\n                break;\n            case DUP_X1:\n                s = stackFrame.size();\n                stackFrame.add(s - 2, stackFrame.get(s - 1));\n                break;\n            case DUP_X2:\n                s = stackFrame.size();\n                stackFrame.add(s - 3, stackFrame.get(s - 1));\n                break;\n            case DUP2:\n                s = stackFrame.size();\n                stackFrame.add(s - 2, stackFrame.get(s - 1));\n                stackFrame.add(s - 2, stackFrame.get(s - 1));\n                break;\n            case DUP2_X1:\n                s = stackFrame.size();\n                stackFrame.add(s - 3, stackFrame.get(s - 1));\n                stackFrame.add(s - 3, stackFrame.get(s - 1));\n                break;\n            case DUP2_X2:\n                s = stackFrame.size();\n                stackFrame.add(s - 4, stackFrame.get(s - 1));\n                stackFrame.add(s - 4, stackFrame.get(s - 1));\n                break;\n            case SWAP:\n                s = stackFrame.size();\n                stackFrame.add(s - 2, stackFrame.get(s - 1));\n                stackFrame.remove(s);\n                break;\n            }\n        } else {\n            switch (opcode) {\n            case RETURN:\n            case IRETURN:\n            case FRETURN:\n            case ARETURN:\n            case LRETURN:\n            case DRETURN:\n            case ATHROW:\n                onMethodExit(opcode);\n                break;\n            }\n        }\n        mv.visitInsn(opcode);\n    }\n\n    @Override\n    public void visitVarInsn(final int opcode, final int var) {\n        super.visitVarInsn(opcode, var);\n        if (constructor) {\n            switch (opcode) {\n            case ILOAD:\n            case FLOAD:\n                pushValue(OTHER);\n                break;\n            case LLOAD:\n            case DLOAD:\n                pushValue(OTHER);\n                pushValue(OTHER);\n                break;\n            case ALOAD:\n                pushValue(var == 0 ? THIS : OTHER);\n                break;\n            case ASTORE:\n            case ISTORE:\n            case FSTORE:\n                popValue();\n                break;\n            case LSTORE:\n            case DSTORE:\n                popValue();\n                popValue();\n                break;\n            }\n        }\n    }\n\n    @Override\n    public void visitFieldInsn(final int opcode, final String owner,\n            final String name, final String desc) {\n        mv.visitFieldInsn(opcode, owner, name, desc);\n        if (constructor) {\n            char c = desc.charAt(0);\n            boolean longOrDouble = c == 'J' || c == 'D';\n            switch (opcode) {\n            case GETSTATIC:\n                pushValue(OTHER);\n                if (longOrDouble) {\n                    pushValue(OTHER);\n                }\n                break;\n            case PUTSTATIC:\n                popValue();\n                if (longOrDouble) {\n                    popValue();\n                }\n                break;\n            case PUTFIELD:\n                popValue();\n                if (longOrDouble) {\n                    popValue();\n                    popValue();\n                }\n                break;\n            // case GETFIELD:\n            default:\n                if (longOrDouble) {\n                    pushValue(OTHER);\n                }\n            }\n        }\n    }\n\n    @Override\n    public void visitIntInsn(final int opcode, final int operand) {\n        mv.visitIntInsn(opcode, operand);\n        if (constructor && opcode != NEWARRAY) {\n            pushValue(OTHER);\n        }\n    }\n\n    @Override\n    public void visitLdcInsn(final Object cst) {\n        mv.visitLdcInsn(cst);\n        if (constructor) {\n            pushValue(OTHER);\n            if (cst instanceof Double || cst instanceof Long) {\n                pushValue(OTHER);\n            }\n        }\n    }\n\n    @Override\n    public void visitMultiANewArrayInsn(final String desc, final int dims) {\n        mv.visitMultiANewArrayInsn(desc, dims);\n        if (constructor) {\n            for (int i = 0; i < dims; i++) {\n                popValue();\n            }\n            pushValue(OTHER);\n        }\n    }\n\n    @Override\n    public void visitTypeInsn(final int opcode, final String type) {\n        mv.visitTypeInsn(opcode, type);\n        // ANEWARRAY, CHECKCAST or INSTANCEOF don't change stack\n        if (constructor && opcode == NEW) {\n            pushValue(OTHER);\n        }\n    }\n\n    @Override\n    public void visitMethodInsn(final int opcode, final String owner,\n            final String name, final String desc) {\n        mv.visitMethodInsn(opcode, owner, name, desc);\n        if (constructor) {\n            Type[] types = Type.getArgumentTypes(desc);\n            for (int i = 0; i < types.length; i++) {\n                popValue();\n                if (types[i].getSize() == 2) {\n                    popValue();\n                }\n            }\n            switch (opcode) {\n            // case INVOKESTATIC:\n            // break;\n            case INVOKEINTERFACE:\n            case INVOKEVIRTUAL:\n                popValue(); // objectref\n                break;\n            case INVOKESPECIAL:\n                Object type = popValue(); // objectref\n                if (type == THIS && !superInitialized) {\n                    onMethodEnter();\n                    superInitialized = true;\n                    // once super has been initialized it is no longer\n                    // necessary to keep track of stack state\n                    constructor = false;\n                }\n                break;\n            }\n\n            Type returnType = Type.getReturnType(desc);\n            if (returnType != Type.VOID_TYPE) {\n                pushValue(OTHER);\n                if (returnType.getSize() == 2) {\n                    pushValue(OTHER);\n                }\n            }\n        }\n    }\n\n    @Override\n    public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,\n            Object... bsmArgs) {\n        mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);\n        if (constructor) {\n            Type[] types = Type.getArgumentTypes(desc);\n            for (int i = 0; i < types.length; i++) {\n                popValue();\n                if (types[i].getSize() == 2) {\n                    popValue();\n                }\n            }\n\n            Type returnType = Type.getReturnType(desc);\n            if (returnType != Type.VOID_TYPE) {\n                pushValue(OTHER);\n                if (returnType.getSize() == 2) {\n                    pushValue(OTHER);\n                }\n            }\n        }\n    }\n\n    @Override\n    public void visitJumpInsn(final int opcode, final Label label) {\n        mv.visitJumpInsn(opcode, label);\n        if (constructor) {\n            switch (opcode) {\n            case IFEQ:\n            case IFNE:\n            case IFLT:\n            case IFGE:\n            case IFGT:\n            case IFLE:\n            case IFNULL:\n            case IFNONNULL:\n                popValue();\n                break;\n            case IF_ICMPEQ:\n            case IF_ICMPNE:\n            case IF_ICMPLT:\n            case IF_ICMPGE:\n            case IF_ICMPGT:\n            case IF_ICMPLE:\n            case IF_ACMPEQ:\n            case IF_ACMPNE:\n                popValue();\n                popValue();\n                break;\n            case JSR:\n                pushValue(OTHER);\n                break;\n            }\n            addBranch(label);\n        }\n    }\n\n    @Override\n    public void visitLookupSwitchInsn(final Label dflt, final int[] keys,\n            final Label[] labels) {\n        mv.visitLookupSwitchInsn(dflt, keys, labels);\n        if (constructor) {\n            popValue();\n            addBranches(dflt, labels);\n        }\n    }\n\n    @Override\n    public void visitTableSwitchInsn(final int min, final int max,\n            final Label dflt, final Label... labels) {\n        mv.visitTableSwitchInsn(min, max, dflt, labels);\n        if (constructor) {\n            popValue();\n            addBranches(dflt, labels);\n        }\n    }\n\n    @Override\n    public void visitTryCatchBlock(Label start, Label end, Label handler,\n            String type) {\n        super.visitTryCatchBlock(start, end, handler, type);\n        if (constructor && !branches.containsKey(handler)) {\n            List<Object> stackFrame = new ArrayList<Object>();\n            stackFrame.add(OTHER);\n            branches.put(handler, stackFrame);\n        }\n    }\n\n    private void addBranches(final Label dflt, final Label[] labels) {\n        addBranch(dflt);\n        for (int i = 0; i < labels.length; i++) {\n            addBranch(labels[i]);\n        }\n    }\n\n    private void addBranch(final Label label) {\n        if (branches.containsKey(label)) {\n            return;\n        }\n        branches.put(label, new ArrayList<Object>(stackFrame));\n    }\n\n    private Object popValue() {\n        return stackFrame.remove(stackFrame.size() - 1);\n    }\n\n    private Object peekValue() {\n        return stackFrame.get(stackFrame.size() - 1);\n    }\n\n    private void pushValue(final Object o) {\n        stackFrame.add(o);\n    }\n\n    /**\n     * Called at the beginning of the method or after super class class call in\n     * the constructor. <br>\n     * <br>\n     *\n     * <i>Custom code can use or change all the local variables, but should not\n     * change state of the stack.</i>\n     */\n    protected void onMethodEnter() {\n    }\n\n    /**\n     * Called before explicit exit from the method using either return or throw.\n     * Top element on the stack contains the return value or exception instance.\n     * For example:\n     *\n     * <pre>\n     *   public void onMethodExit(int opcode) {\n     *     if(opcode==RETURN) {\n     *         visitInsn(ACONST_NULL);\n     *     } else if(opcode==ARETURN || opcode==ATHROW) {\n     *         dup();\n     *     } else {\n     *         if(opcode==LRETURN || opcode==DRETURN) {\n     *             dup2();\n     *         } else {\n     *             dup();\n     *         }\n     *         box(Type.getReturnType(this.methodDesc));\n     *     }\n     *     visitIntInsn(SIPUSH, opcode);\n     *     visitMethodInsn(INVOKESTATIC, owner, \"onExit\", \"(Ljava/lang/Object;I)V\");\n     *   }\n     *\n     *   // an actual call back method\n     *   public static void onExit(Object param, int opcode) {\n     *     ...\n     * </pre>\n     *\n     * <br>\n     * <br>\n     *\n     * <i>Custom code can use or change all the local variables, but should not\n     * change state of the stack.</i>\n     *\n     * @param opcode\n     *            one of the RETURN, IRETURN, FRETURN, ARETURN, LRETURN, DRETURN\n     *            or ATHROW\n     *\n     */\n    protected void onMethodExit(int opcode) {\n    }\n\n    // TODO onException, onMethodCall\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/commons/AnalyzerAdapter.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm.commons;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport clojure.asm.Handle;\nimport clojure.asm.Label;\nimport clojure.asm.MethodVisitor;\nimport clojure.asm.Opcodes;\nimport clojure.asm.Type;\n\n/**\n * A {@link MethodVisitor} that keeps track of stack map frame changes between\n * {@link #visitFrame(int, int, Object[], int, Object[]) visitFrame} calls. This\n * adapter must be used with the\n * {@link clojure.asm.ClassReader#EXPAND_FRAMES} option. Each\n * visit<i>X</i> instruction delegates to the next visitor in the chain, if any,\n * and then simulates the effect of this instruction on the stack map frame,\n * represented by {@link #locals} and {@link #stack}. The next visitor in the\n * chain can get the state of the stack map frame <i>before</i> each instruction\n * by reading the value of these fields in its visit<i>X</i> methods (this\n * requires a reference to the AnalyzerAdapter that is before it in the chain).\n * If this adapter is used with a class that does not contain stack map table\n * attributes (i.e., pre Java 6 classes) then this adapter may not be able to\n * compute the stack map frame for each instruction. In this case no exception\n * is thrown but the {@link #locals} and {@link #stack} fields will be null for\n * these instructions.\n *\n * @author Eric Bruneton\n */\npublic class AnalyzerAdapter extends MethodVisitor {\n\n    /**\n     * <code>List</code> of the local variable slots for current execution\n     * frame. Primitive types are represented by {@link Opcodes#TOP},\n     * {@link Opcodes#INTEGER}, {@link Opcodes#FLOAT}, {@link Opcodes#LONG},\n     * {@link Opcodes#DOUBLE},{@link Opcodes#NULL} or\n     * {@link Opcodes#UNINITIALIZED_THIS} (long and double are represented by\n     * two elements, the second one being TOP). Reference types are represented\n     * by String objects (representing internal names), and uninitialized types\n     * by Label objects (this label designates the NEW instruction that created\n     * this uninitialized value). This field is <tt>null</tt> for unreachable\n     * instructions.\n     */\n    public List<Object> locals;\n\n    /**\n     * <code>List</code> of the operand stack slots for current execution frame.\n     * Primitive types are represented by {@link Opcodes#TOP},\n     * {@link Opcodes#INTEGER}, {@link Opcodes#FLOAT}, {@link Opcodes#LONG},\n     * {@link Opcodes#DOUBLE},{@link Opcodes#NULL} or\n     * {@link Opcodes#UNINITIALIZED_THIS} (long and double are represented by\n     * two elements, the second one being TOP). Reference types are represented\n     * by String objects (representing internal names), and uninitialized types\n     * by Label objects (this label designates the NEW instruction that created\n     * this uninitialized value). This field is <tt>null</tt> for unreachable\n     * instructions.\n     */\n    public List<Object> stack;\n\n    /**\n     * The labels that designate the next instruction to be visited. May be\n     * <tt>null</tt>.\n     */\n    private List<Label> labels;\n\n    /**\n     * Information about uninitialized types in the current execution frame.\n     * This map associates internal names to Label objects. Each label\n     * designates a NEW instruction that created the currently uninitialized\n     * types, and the associated internal name represents the NEW operand, i.e.\n     * the final, initialized type value.\n     */\n    public Map<Object, Object> uninitializedTypes;\n\n    /**\n     * The maximum stack size of this method.\n     */\n    private int maxStack;\n\n    /**\n     * The maximum number of local variables of this method.\n     */\n    private int maxLocals;\n\n    /**\n     * The owner's class name.\n     */\n    private String owner;\n\n    /**\n     * Creates a new {@link AnalyzerAdapter}. <i>Subclasses must not use this\n     * constructor</i>. Instead, they must use the\n     * {@link #AnalyzerAdapter(int, String, int, String, String, MethodVisitor)}\n     * version.\n     *\n     * @param owner\n     *            the owner's class name.\n     * @param access\n     *            the method's access flags (see {@link Opcodes}).\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor (see {@link Type Type}).\n     * @param mv\n     *            the method visitor to which this adapter delegates calls. May\n     *            be <tt>null</tt>.\n     */\n    public AnalyzerAdapter(final String owner, final int access,\n            final String name, final String desc, final MethodVisitor mv) {\n        this(Opcodes.ASM4, owner, access, name, desc, mv);\n    }\n\n    /**\n     * Creates a new {@link AnalyzerAdapter}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     * @param owner\n     *            the owner's class name.\n     * @param access\n     *            the method's access flags (see {@link Opcodes}).\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor (see {@link Type Type}).\n     * @param mv\n     *            the method visitor to which this adapter delegates calls. May\n     *            be <tt>null</tt>.\n     */\n    protected AnalyzerAdapter(final int api, final String owner,\n            final int access, final String name, final String desc,\n            final MethodVisitor mv) {\n        super(api, mv);\n        this.owner = owner;\n        locals = new ArrayList<Object>();\n        stack = new ArrayList<Object>();\n        uninitializedTypes = new HashMap<Object, Object>();\n\n        if ((access & Opcodes.ACC_STATIC) == 0) {\n            if (\"<init>\".equals(name)) {\n                locals.add(Opcodes.UNINITIALIZED_THIS);\n            } else {\n                locals.add(owner);\n            }\n        }\n        Type[] types = Type.getArgumentTypes(desc);\n        for (int i = 0; i < types.length; ++i) {\n            Type type = types[i];\n            switch (type.getSort()) {\n            case Type.BOOLEAN:\n            case Type.CHAR:\n            case Type.BYTE:\n            case Type.SHORT:\n            case Type.INT:\n                locals.add(Opcodes.INTEGER);\n                break;\n            case Type.FLOAT:\n                locals.add(Opcodes.FLOAT);\n                break;\n            case Type.LONG:\n                locals.add(Opcodes.LONG);\n                locals.add(Opcodes.TOP);\n                break;\n            case Type.DOUBLE:\n                locals.add(Opcodes.DOUBLE);\n                locals.add(Opcodes.TOP);\n                break;\n            case Type.ARRAY:\n                locals.add(types[i].getDescriptor());\n                break;\n            // case Type.OBJECT:\n            default:\n                locals.add(types[i].getInternalName());\n            }\n        }\n    }\n\n    @Override\n    public void visitFrame(final int type, final int nLocal,\n            final Object[] local, final int nStack, final Object[] stack) {\n        if (type != Opcodes.F_NEW) { // uncompressed frame\n            throw new IllegalStateException(\n                    \"ClassReader.accept() should be called with EXPAND_FRAMES flag\");\n        }\n\n        if (mv != null) {\n            mv.visitFrame(type, nLocal, local, nStack, stack);\n        }\n\n        if (this.locals != null) {\n            this.locals.clear();\n            this.stack.clear();\n        } else {\n            this.locals = new ArrayList<Object>();\n            this.stack = new ArrayList<Object>();\n        }\n        visitFrameTypes(nLocal, local, this.locals);\n        visitFrameTypes(nStack, stack, this.stack);\n        maxStack = Math.max(maxStack, this.stack.size());\n    }\n\n    private static void visitFrameTypes(final int n, final Object[] types,\n            final List<Object> result) {\n        for (int i = 0; i < n; ++i) {\n            Object type = types[i];\n            result.add(type);\n            if (type == Opcodes.LONG || type == Opcodes.DOUBLE) {\n                result.add(Opcodes.TOP);\n            }\n        }\n    }\n\n    @Override\n    public void visitInsn(final int opcode) {\n        if (mv != null) {\n            mv.visitInsn(opcode);\n        }\n        execute(opcode, 0, null);\n        if ((opcode >= Opcodes.IRETURN && opcode <= Opcodes.RETURN)\n                || opcode == Opcodes.ATHROW) {\n            this.locals = null;\n            this.stack = null;\n        }\n    }\n\n    @Override\n    public void visitIntInsn(final int opcode, final int operand) {\n        if (mv != null) {\n            mv.visitIntInsn(opcode, operand);\n        }\n        execute(opcode, operand, null);\n    }\n\n    @Override\n    public void visitVarInsn(final int opcode, final int var) {\n        if (mv != null) {\n            mv.visitVarInsn(opcode, var);\n        }\n        execute(opcode, var, null);\n    }\n\n    @Override\n    public void visitTypeInsn(final int opcode, final String type) {\n        if (opcode == Opcodes.NEW) {\n            if (labels == null) {\n                Label l = new Label();\n                labels = new ArrayList<Label>(3);\n                labels.add(l);\n                if (mv != null) {\n                    mv.visitLabel(l);\n                }\n            }\n            for (int i = 0; i < labels.size(); ++i) {\n                uninitializedTypes.put(labels.get(i), type);\n            }\n        }\n        if (mv != null) {\n            mv.visitTypeInsn(opcode, type);\n        }\n        execute(opcode, 0, type);\n    }\n\n    @Override\n    public void visitFieldInsn(final int opcode, final String owner,\n            final String name, final String desc) {\n        if (mv != null) {\n            mv.visitFieldInsn(opcode, owner, name, desc);\n        }\n        execute(opcode, 0, desc);\n    }\n\n    @Override\n    public void visitMethodInsn(final int opcode, final String owner,\n            final String name, final String desc) {\n        if (mv != null) {\n            mv.visitMethodInsn(opcode, owner, name, desc);\n        }\n        if (this.locals == null) {\n            labels = null;\n            return;\n        }\n        pop(desc);\n        if (opcode != Opcodes.INVOKESTATIC) {\n            Object t = pop();\n            if (opcode == Opcodes.INVOKESPECIAL && name.charAt(0) == '<') {\n                Object u;\n                if (t == Opcodes.UNINITIALIZED_THIS) {\n                    u = this.owner;\n                } else {\n                    u = uninitializedTypes.get(t);\n                }\n                for (int i = 0; i < locals.size(); ++i) {\n                    if (locals.get(i) == t) {\n                        locals.set(i, u);\n                    }\n                }\n                for (int i = 0; i < stack.size(); ++i) {\n                    if (stack.get(i) == t) {\n                        stack.set(i, u);\n                    }\n                }\n            }\n        }\n        pushDesc(desc);\n        labels = null;\n    }\n\n    @Override\n    public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,\n            Object... bsmArgs) {\n        if (mv != null) {\n            mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);\n        }\n        if (this.locals == null) {\n            labels = null;\n            return;\n        }\n        pop(desc);\n        pushDesc(desc);\n        labels = null;\n    }\n\n    @Override\n    public void visitJumpInsn(final int opcode, final Label label) {\n        if (mv != null) {\n            mv.visitJumpInsn(opcode, label);\n        }\n        execute(opcode, 0, null);\n        if (opcode == Opcodes.GOTO) {\n            this.locals = null;\n            this.stack = null;\n        }\n    }\n\n    @Override\n    public void visitLabel(final Label label) {\n        if (mv != null) {\n            mv.visitLabel(label);\n        }\n        if (labels == null) {\n            labels = new ArrayList<Label>(3);\n        }\n        labels.add(label);\n    }\n\n    @Override\n    public void visitLdcInsn(final Object cst) {\n        if (mv != null) {\n            mv.visitLdcInsn(cst);\n        }\n        if (this.locals == null) {\n            labels = null;\n            return;\n        }\n        if (cst instanceof Integer) {\n            push(Opcodes.INTEGER);\n        } else if (cst instanceof Long) {\n            push(Opcodes.LONG);\n            push(Opcodes.TOP);\n        } else if (cst instanceof Float) {\n            push(Opcodes.FLOAT);\n        } else if (cst instanceof Double) {\n            push(Opcodes.DOUBLE);\n            push(Opcodes.TOP);\n        } else if (cst instanceof String) {\n            push(\"java/lang/String\");\n        } else if (cst instanceof Type) {\n            int sort = ((Type) cst).getSort();\n            if (sort == Type.OBJECT || sort == Type.ARRAY) {\n                push(\"java/lang/Class\");\n            } else if (sort == Type.METHOD) {\n                push(\"java/lang/invoke/MethodType\");\n            } else {\n                throw new IllegalArgumentException();\n            }\n        } else if (cst instanceof Handle) {\n            push(\"java/lang/invoke/MethodHandle\");\n        } else {\n            throw new IllegalArgumentException();\n        }\n        labels = null;\n    }\n\n    @Override\n    public void visitIincInsn(final int var, final int increment) {\n        if (mv != null) {\n            mv.visitIincInsn(var, increment);\n        }\n        execute(Opcodes.IINC, var, null);\n    }\n\n    @Override\n    public void visitTableSwitchInsn(final int min, final int max,\n            final Label dflt, final Label... labels) {\n        if (mv != null) {\n            mv.visitTableSwitchInsn(min, max, dflt, labels);\n        }\n        execute(Opcodes.TABLESWITCH, 0, null);\n        this.locals = null;\n        this.stack = null;\n    }\n\n    @Override\n    public void visitLookupSwitchInsn(final Label dflt, final int[] keys,\n            final Label[] labels) {\n        if (mv != null) {\n            mv.visitLookupSwitchInsn(dflt, keys, labels);\n        }\n        execute(Opcodes.LOOKUPSWITCH, 0, null);\n        this.locals = null;\n        this.stack = null;\n    }\n\n    @Override\n    public void visitMultiANewArrayInsn(final String desc, final int dims) {\n        if (mv != null) {\n            mv.visitMultiANewArrayInsn(desc, dims);\n        }\n        execute(Opcodes.MULTIANEWARRAY, dims, desc);\n    }\n\n    @Override\n    public void visitMaxs(final int maxStack, final int maxLocals) {\n        if (mv != null) {\n            this.maxStack = Math.max(this.maxStack, maxStack);\n            this.maxLocals = Math.max(this.maxLocals, maxLocals);\n            mv.visitMaxs(this.maxStack, this.maxLocals);\n        }\n    }\n\n    // ------------------------------------------------------------------------\n\n    private Object get(final int local) {\n        maxLocals = Math.max(maxLocals, local);\n        return local < locals.size() ? locals.get(local) : Opcodes.TOP;\n    }\n\n    private void set(final int local, final Object type) {\n        maxLocals = Math.max(maxLocals, local);\n        while (local >= locals.size()) {\n            locals.add(Opcodes.TOP);\n        }\n        locals.set(local, type);\n    }\n\n    private void push(final Object type) {\n        stack.add(type);\n        maxStack = Math.max(maxStack, stack.size());\n    }\n\n    private void pushDesc(final String desc) {\n        int index = desc.charAt(0) == '(' ? desc.indexOf(')') + 1 : 0;\n        switch (desc.charAt(index)) {\n        case 'V':\n            return;\n        case 'Z':\n        case 'C':\n        case 'B':\n        case 'S':\n        case 'I':\n            push(Opcodes.INTEGER);\n            return;\n        case 'F':\n            push(Opcodes.FLOAT);\n            return;\n        case 'J':\n            push(Opcodes.LONG);\n            push(Opcodes.TOP);\n            return;\n        case 'D':\n            push(Opcodes.DOUBLE);\n            push(Opcodes.TOP);\n            return;\n        case '[':\n            if (index == 0) {\n                push(desc);\n            } else {\n                push(desc.substring(index, desc.length()));\n            }\n            break;\n        // case 'L':\n        default:\n            if (index == 0) {\n                push(desc.substring(1, desc.length() - 1));\n            } else {\n                push(desc.substring(index + 1, desc.length() - 1));\n            }\n        }\n    }\n\n    private Object pop() {\n        return stack.remove(stack.size() - 1);\n    }\n\n    private void pop(final int n) {\n        int size = stack.size();\n        int end = size - n;\n        for (int i = size - 1; i >= end; --i) {\n            stack.remove(i);\n        }\n    }\n\n    private void pop(final String desc) {\n        char c = desc.charAt(0);\n        if (c == '(') {\n            int n = 0;\n            Type[] types = Type.getArgumentTypes(desc);\n            for (int i = 0; i < types.length; ++i) {\n                n += types[i].getSize();\n            }\n            pop(n);\n        } else if (c == 'J' || c == 'D') {\n            pop(2);\n        } else {\n            pop(1);\n        }\n    }\n\n    private void execute(final int opcode, final int iarg, final String sarg) {\n        if (this.locals == null) {\n            labels = null;\n            return;\n        }\n        Object t1, t2, t3, t4;\n        switch (opcode) {\n        case Opcodes.NOP:\n        case Opcodes.INEG:\n        case Opcodes.LNEG:\n        case Opcodes.FNEG:\n        case Opcodes.DNEG:\n        case Opcodes.I2B:\n        case Opcodes.I2C:\n        case Opcodes.I2S:\n        case Opcodes.GOTO:\n        case Opcodes.RETURN:\n            break;\n        case Opcodes.ACONST_NULL:\n            push(Opcodes.NULL);\n            break;\n        case Opcodes.ICONST_M1:\n        case Opcodes.ICONST_0:\n        case Opcodes.ICONST_1:\n        case Opcodes.ICONST_2:\n        case Opcodes.ICONST_3:\n        case Opcodes.ICONST_4:\n        case Opcodes.ICONST_5:\n        case Opcodes.BIPUSH:\n        case Opcodes.SIPUSH:\n            push(Opcodes.INTEGER);\n            break;\n        case Opcodes.LCONST_0:\n        case Opcodes.LCONST_1:\n            push(Opcodes.LONG);\n            push(Opcodes.TOP);\n            break;\n        case Opcodes.FCONST_0:\n        case Opcodes.FCONST_1:\n        case Opcodes.FCONST_2:\n            push(Opcodes.FLOAT);\n            break;\n        case Opcodes.DCONST_0:\n        case Opcodes.DCONST_1:\n            push(Opcodes.DOUBLE);\n            push(Opcodes.TOP);\n            break;\n        case Opcodes.ILOAD:\n        case Opcodes.FLOAD:\n        case Opcodes.ALOAD:\n            push(get(iarg));\n            break;\n        case Opcodes.LLOAD:\n        case Opcodes.DLOAD:\n            push(get(iarg));\n            push(Opcodes.TOP);\n            break;\n        case Opcodes.IALOAD:\n        case Opcodes.BALOAD:\n        case Opcodes.CALOAD:\n        case Opcodes.SALOAD:\n            pop(2);\n            push(Opcodes.INTEGER);\n            break;\n        case Opcodes.LALOAD:\n        case Opcodes.D2L:\n            pop(2);\n            push(Opcodes.LONG);\n            push(Opcodes.TOP);\n            break;\n        case Opcodes.FALOAD:\n            pop(2);\n            push(Opcodes.FLOAT);\n            break;\n        case Opcodes.DALOAD:\n        case Opcodes.L2D:\n            pop(2);\n            push(Opcodes.DOUBLE);\n            push(Opcodes.TOP);\n            break;\n        case Opcodes.AALOAD:\n            pop(1);\n            t1 = pop();\n            if (t1 instanceof String) {\n                pushDesc(((String) t1).substring(1));\n            } else {\n                push(\"java/lang/Object\");\n            }\n            break;\n        case Opcodes.ISTORE:\n        case Opcodes.FSTORE:\n        case Opcodes.ASTORE:\n            t1 = pop();\n            set(iarg, t1);\n            if (iarg > 0) {\n                t2 = get(iarg - 1);\n                if (t2 == Opcodes.LONG || t2 == Opcodes.DOUBLE) {\n                    set(iarg - 1, Opcodes.TOP);\n                }\n            }\n            break;\n        case Opcodes.LSTORE:\n        case Opcodes.DSTORE:\n            pop(1);\n            t1 = pop();\n            set(iarg, t1);\n            set(iarg + 1, Opcodes.TOP);\n            if (iarg > 0) {\n                t2 = get(iarg - 1);\n                if (t2 == Opcodes.LONG || t2 == Opcodes.DOUBLE) {\n                    set(iarg - 1, Opcodes.TOP);\n                }\n            }\n            break;\n        case Opcodes.IASTORE:\n        case Opcodes.BASTORE:\n        case Opcodes.CASTORE:\n        case Opcodes.SASTORE:\n        case Opcodes.FASTORE:\n        case Opcodes.AASTORE:\n            pop(3);\n            break;\n        case Opcodes.LASTORE:\n        case Opcodes.DASTORE:\n            pop(4);\n            break;\n        case Opcodes.POP:\n        case Opcodes.IFEQ:\n        case Opcodes.IFNE:\n        case Opcodes.IFLT:\n        case Opcodes.IFGE:\n        case Opcodes.IFGT:\n        case Opcodes.IFLE:\n        case Opcodes.IRETURN:\n        case Opcodes.FRETURN:\n        case Opcodes.ARETURN:\n        case Opcodes.TABLESWITCH:\n        case Opcodes.LOOKUPSWITCH:\n        case Opcodes.ATHROW:\n        case Opcodes.MONITORENTER:\n        case Opcodes.MONITOREXIT:\n        case Opcodes.IFNULL:\n        case Opcodes.IFNONNULL:\n            pop(1);\n            break;\n        case Opcodes.POP2:\n        case Opcodes.IF_ICMPEQ:\n        case Opcodes.IF_ICMPNE:\n        case Opcodes.IF_ICMPLT:\n        case Opcodes.IF_ICMPGE:\n        case Opcodes.IF_ICMPGT:\n        case Opcodes.IF_ICMPLE:\n        case Opcodes.IF_ACMPEQ:\n        case Opcodes.IF_ACMPNE:\n        case Opcodes.LRETURN:\n        case Opcodes.DRETURN:\n            pop(2);\n            break;\n        case Opcodes.DUP:\n            t1 = pop();\n            push(t1);\n            push(t1);\n            break;\n        case Opcodes.DUP_X1:\n            t1 = pop();\n            t2 = pop();\n            push(t1);\n            push(t2);\n            push(t1);\n            break;\n        case Opcodes.DUP_X2:\n            t1 = pop();\n            t2 = pop();\n            t3 = pop();\n            push(t1);\n            push(t3);\n            push(t2);\n            push(t1);\n            break;\n        case Opcodes.DUP2:\n            t1 = pop();\n            t2 = pop();\n            push(t2);\n            push(t1);\n            push(t2);\n            push(t1);\n            break;\n        case Opcodes.DUP2_X1:\n            t1 = pop();\n            t2 = pop();\n            t3 = pop();\n            push(t2);\n            push(t1);\n            push(t3);\n            push(t2);\n            push(t1);\n            break;\n        case Opcodes.DUP2_X2:\n            t1 = pop();\n            t2 = pop();\n            t3 = pop();\n            t4 = pop();\n            push(t2);\n            push(t1);\n            push(t4);\n            push(t3);\n            push(t2);\n            push(t1);\n            break;\n        case Opcodes.SWAP:\n            t1 = pop();\n            t2 = pop();\n            push(t1);\n            push(t2);\n            break;\n        case Opcodes.IADD:\n        case Opcodes.ISUB:\n        case Opcodes.IMUL:\n        case Opcodes.IDIV:\n        case Opcodes.IREM:\n        case Opcodes.IAND:\n        case Opcodes.IOR:\n        case Opcodes.IXOR:\n        case Opcodes.ISHL:\n        case Opcodes.ISHR:\n        case Opcodes.IUSHR:\n        case Opcodes.L2I:\n        case Opcodes.D2I:\n        case Opcodes.FCMPL:\n        case Opcodes.FCMPG:\n            pop(2);\n            push(Opcodes.INTEGER);\n            break;\n        case Opcodes.LADD:\n        case Opcodes.LSUB:\n        case Opcodes.LMUL:\n        case Opcodes.LDIV:\n        case Opcodes.LREM:\n        case Opcodes.LAND:\n        case Opcodes.LOR:\n        case Opcodes.LXOR:\n            pop(4);\n            push(Opcodes.LONG);\n            push(Opcodes.TOP);\n            break;\n        case Opcodes.FADD:\n        case Opcodes.FSUB:\n        case Opcodes.FMUL:\n        case Opcodes.FDIV:\n        case Opcodes.FREM:\n        case Opcodes.L2F:\n        case Opcodes.D2F:\n            pop(2);\n            push(Opcodes.FLOAT);\n            break;\n        case Opcodes.DADD:\n        case Opcodes.DSUB:\n        case Opcodes.DMUL:\n        case Opcodes.DDIV:\n        case Opcodes.DREM:\n            pop(4);\n            push(Opcodes.DOUBLE);\n            push(Opcodes.TOP);\n            break;\n        case Opcodes.LSHL:\n        case Opcodes.LSHR:\n        case Opcodes.LUSHR:\n            pop(3);\n            push(Opcodes.LONG);\n            push(Opcodes.TOP);\n            break;\n        case Opcodes.IINC:\n            set(iarg, Opcodes.INTEGER);\n            break;\n        case Opcodes.I2L:\n        case Opcodes.F2L:\n            pop(1);\n            push(Opcodes.LONG);\n            push(Opcodes.TOP);\n            break;\n        case Opcodes.I2F:\n            pop(1);\n            push(Opcodes.FLOAT);\n            break;\n        case Opcodes.I2D:\n        case Opcodes.F2D:\n            pop(1);\n            push(Opcodes.DOUBLE);\n            push(Opcodes.TOP);\n            break;\n        case Opcodes.F2I:\n        case Opcodes.ARRAYLENGTH:\n        case Opcodes.INSTANCEOF:\n            pop(1);\n            push(Opcodes.INTEGER);\n            break;\n        case Opcodes.LCMP:\n        case Opcodes.DCMPL:\n        case Opcodes.DCMPG:\n            pop(4);\n            push(Opcodes.INTEGER);\n            break;\n        case Opcodes.JSR:\n        case Opcodes.RET:\n            throw new RuntimeException(\"JSR/RET are not supported\");\n        case Opcodes.GETSTATIC:\n            pushDesc(sarg);\n            break;\n        case Opcodes.PUTSTATIC:\n            pop(sarg);\n            break;\n        case Opcodes.GETFIELD:\n            pop(1);\n            pushDesc(sarg);\n            break;\n        case Opcodes.PUTFIELD:\n            pop(sarg);\n            pop();\n            break;\n        case Opcodes.NEW:\n            push(labels.get(0));\n            break;\n        case Opcodes.NEWARRAY:\n            pop();\n            switch (iarg) {\n            case Opcodes.T_BOOLEAN:\n                pushDesc(\"[Z\");\n                break;\n            case Opcodes.T_CHAR:\n                pushDesc(\"[C\");\n                break;\n            case Opcodes.T_BYTE:\n                pushDesc(\"[B\");\n                break;\n            case Opcodes.T_SHORT:\n                pushDesc(\"[S\");\n                break;\n            case Opcodes.T_INT:\n                pushDesc(\"[I\");\n                break;\n            case Opcodes.T_FLOAT:\n                pushDesc(\"[F\");\n                break;\n            case Opcodes.T_DOUBLE:\n                pushDesc(\"[D\");\n                break;\n            // case Opcodes.T_LONG:\n            default:\n                pushDesc(\"[J\");\n                break;\n            }\n            break;\n        case Opcodes.ANEWARRAY:\n            pop();\n            pushDesc(\"[\" + Type.getObjectType(sarg));\n            break;\n        case Opcodes.CHECKCAST:\n            pop();\n            pushDesc(Type.getObjectType(sarg).getDescriptor());\n            break;\n        // case Opcodes.MULTIANEWARRAY:\n        default:\n            pop(iarg);\n            pushDesc(sarg);\n            break;\n        }\n        labels = null;\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/commons/CodeSizeEvaluator.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm.commons;\n\nimport clojure.asm.Handle;\nimport clojure.asm.Label;\nimport clojure.asm.MethodVisitor;\nimport clojure.asm.Opcodes;\n\n/**\n * A {@link MethodVisitor} that can be used to approximate method size.\n *\n * @author Eugene Kuleshov\n */\npublic class CodeSizeEvaluator extends MethodVisitor implements Opcodes {\n\n    private int minSize;\n\n    private int maxSize;\n\n    public CodeSizeEvaluator(final MethodVisitor mv) {\n        this(Opcodes.ASM4, mv);\n    }\n\n    protected CodeSizeEvaluator(final int api, final MethodVisitor mv) {\n        super(api, mv);\n    }\n\n    public int getMinSize() {\n        return this.minSize;\n    }\n\n    public int getMaxSize() {\n        return this.maxSize;\n    }\n\n    @Override\n    public void visitInsn(final int opcode) {\n        minSize += 1;\n        maxSize += 1;\n        if (mv != null) {\n            mv.visitInsn(opcode);\n        }\n    }\n\n    @Override\n    public void visitIntInsn(final int opcode, final int operand) {\n        if (opcode == SIPUSH) {\n            minSize += 3;\n            maxSize += 3;\n        } else {\n            minSize += 2;\n            maxSize += 2;\n        }\n        if (mv != null) {\n            mv.visitIntInsn(opcode, operand);\n        }\n    }\n\n    @Override\n    public void visitVarInsn(final int opcode, final int var) {\n        if (var < 4 && opcode != RET) {\n            minSize += 1;\n            maxSize += 1;\n        } else if (var >= 256) {\n            minSize += 4;\n            maxSize += 4;\n        } else {\n            minSize += 2;\n            maxSize += 2;\n        }\n        if (mv != null) {\n            mv.visitVarInsn(opcode, var);\n        }\n    }\n\n    @Override\n    public void visitTypeInsn(final int opcode, final String type) {\n        minSize += 3;\n        maxSize += 3;\n        if (mv != null) {\n            mv.visitTypeInsn(opcode, type);\n        }\n    }\n\n    @Override\n    public void visitFieldInsn(final int opcode, final String owner,\n            final String name, final String desc) {\n        minSize += 3;\n        maxSize += 3;\n        if (mv != null) {\n            mv.visitFieldInsn(opcode, owner, name, desc);\n        }\n    }\n\n    @Override\n    public void visitMethodInsn(final int opcode, final String owner,\n            final String name, final String desc) {\n        if (opcode == INVOKEINTERFACE) {\n            minSize += 5;\n            maxSize += 5;\n        } else {\n            minSize += 3;\n            maxSize += 3;\n        }\n        if (mv != null) {\n            mv.visitMethodInsn(opcode, owner, name, desc);\n        }\n    }\n\n    @Override\n    public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,\n            Object... bsmArgs) {\n        minSize += 5;\n        maxSize += 5;\n        if (mv != null) {\n            mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);\n        }\n    }\n\n    @Override\n    public void visitJumpInsn(final int opcode, final Label label) {\n        minSize += 3;\n        if (opcode == GOTO || opcode == JSR) {\n            maxSize += 5;\n        } else {\n            maxSize += 8;\n        }\n        if (mv != null) {\n            mv.visitJumpInsn(opcode, label);\n        }\n    }\n\n    @Override\n    public void visitLdcInsn(final Object cst) {\n        if (cst instanceof Long || cst instanceof Double) {\n            minSize += 3;\n            maxSize += 3;\n        } else {\n            minSize += 2;\n            maxSize += 3;\n        }\n        if (mv != null) {\n            mv.visitLdcInsn(cst);\n        }\n    }\n\n    @Override\n    public void visitIincInsn(final int var, final int increment) {\n        if (var > 255 || increment > 127 || increment < -128) {\n            minSize += 6;\n            maxSize += 6;\n        } else {\n            minSize += 3;\n            maxSize += 3;\n        }\n        if (mv != null) {\n            mv.visitIincInsn(var, increment);\n        }\n    }\n\n    @Override\n    public void visitTableSwitchInsn(final int min, final int max,\n            final Label dflt, final Label... labels) {\n        minSize += 13 + labels.length * 4;\n        maxSize += 16 + labels.length * 4;\n        if (mv != null) {\n            mv.visitTableSwitchInsn(min, max, dflt, labels);\n        }\n    }\n\n    @Override\n    public void visitLookupSwitchInsn(final Label dflt, final int[] keys,\n            final Label[] labels) {\n        minSize += 9 + keys.length * 8;\n        maxSize += 12 + keys.length * 8;\n        if (mv != null) {\n            mv.visitLookupSwitchInsn(dflt, keys, labels);\n        }\n    }\n\n    @Override\n    public void visitMultiANewArrayInsn(final String desc, final int dims) {\n        minSize += 4;\n        maxSize += 4;\n        if (mv != null) {\n            mv.visitMultiANewArrayInsn(desc, dims);\n        }\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/commons/GeneratorAdapter.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm.commons;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\nimport clojure.asm.ClassVisitor;\nimport clojure.asm.Handle;\nimport clojure.asm.Label;\nimport clojure.asm.MethodVisitor;\nimport clojure.asm.Opcodes;\nimport clojure.asm.Type;\n\n/**\n * A {@link clojure.asm.MethodVisitor} with convenient methods to generate\n * code. For example, using this adapter, the class below\n *\n * <pre>\n * public class Example {\n *     public static void main(String[] args) {\n *         System.out.println(&quot;Hello world!&quot;);\n *     }\n * }\n * </pre>\n *\n * can be generated as follows:\n *\n * <pre>\n * ClassWriter cw = new ClassWriter(true);\n * cw.visit(V1_1, ACC_PUBLIC, &quot;Example&quot;, null, &quot;java/lang/Object&quot;, null);\n *\n * Method m = Method.getMethod(&quot;void &lt;init&gt; ()&quot;);\n * GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, m, null, null, cw);\n * mg.loadThis();\n * mg.invokeConstructor(Type.getType(Object.class), m);\n * mg.returnValue();\n * mg.endMethod();\n *\n * m = Method.getMethod(&quot;void main (String[])&quot;);\n * mg = new GeneratorAdapter(ACC_PUBLIC + ACC_STATIC, m, null, null, cw);\n * mg.getStatic(Type.getType(System.class), &quot;out&quot;, Type.getType(PrintStream.class));\n * mg.push(&quot;Hello world!&quot;);\n * mg.invokeVirtual(Type.getType(PrintStream.class),\n *         Method.getMethod(&quot;void println (String)&quot;));\n * mg.returnValue();\n * mg.endMethod();\n *\n * cw.visitEnd();\n * </pre>\n *\n * @author Juozas Baliuka\n * @author Chris Nokleberg\n * @author Eric Bruneton\n * @author Prashant Deva\n */\npublic class GeneratorAdapter extends LocalVariablesSorter {\n\n    private static final String CLDESC = \"Ljava/lang/Class;\";\n\n    private static final Type BYTE_TYPE = Type.getObjectType(\"java/lang/Byte\");\n\n    private static final Type BOOLEAN_TYPE = Type\n            .getObjectType(\"java/lang/Boolean\");\n\n    private static final Type SHORT_TYPE = Type\n            .getObjectType(\"java/lang/Short\");\n\n    private static final Type CHARACTER_TYPE = Type\n            .getObjectType(\"java/lang/Character\");\n\n    private static final Type INTEGER_TYPE = Type\n            .getObjectType(\"java/lang/Integer\");\n\n    private static final Type FLOAT_TYPE = Type\n            .getObjectType(\"java/lang/Float\");\n\n    private static final Type LONG_TYPE = Type.getObjectType(\"java/lang/Long\");\n\n    private static final Type DOUBLE_TYPE = Type\n            .getObjectType(\"java/lang/Double\");\n\n    private static final Type NUMBER_TYPE = Type\n            .getObjectType(\"java/lang/Number\");\n\n    private static final Type OBJECT_TYPE = Type\n            .getObjectType(\"java/lang/Object\");\n\n    private static final Method BOOLEAN_VALUE = Method\n            .getMethod(\"boolean booleanValue()\");\n\n    private static final Method CHAR_VALUE = Method\n            .getMethod(\"char charValue()\");\n\n    private static final Method INT_VALUE = Method.getMethod(\"int intValue()\");\n\n    private static final Method FLOAT_VALUE = Method\n            .getMethod(\"float floatValue()\");\n\n    private static final Method LONG_VALUE = Method\n            .getMethod(\"long longValue()\");\n\n    private static final Method DOUBLE_VALUE = Method\n            .getMethod(\"double doubleValue()\");\n\n    /**\n     * Constant for the {@link #math math} method.\n     */\n    public static final int ADD = Opcodes.IADD;\n\n    /**\n     * Constant for the {@link #math math} method.\n     */\n    public static final int SUB = Opcodes.ISUB;\n\n    /**\n     * Constant for the {@link #math math} method.\n     */\n    public static final int MUL = Opcodes.IMUL;\n\n    /**\n     * Constant for the {@link #math math} method.\n     */\n    public static final int DIV = Opcodes.IDIV;\n\n    /**\n     * Constant for the {@link #math math} method.\n     */\n    public static final int REM = Opcodes.IREM;\n\n    /**\n     * Constant for the {@link #math math} method.\n     */\n    public static final int NEG = Opcodes.INEG;\n\n    /**\n     * Constant for the {@link #math math} method.\n     */\n    public static final int SHL = Opcodes.ISHL;\n\n    /**\n     * Constant for the {@link #math math} method.\n     */\n    public static final int SHR = Opcodes.ISHR;\n\n    /**\n     * Constant for the {@link #math math} method.\n     */\n    public static final int USHR = Opcodes.IUSHR;\n\n    /**\n     * Constant for the {@link #math math} method.\n     */\n    public static final int AND = Opcodes.IAND;\n\n    /**\n     * Constant for the {@link #math math} method.\n     */\n    public static final int OR = Opcodes.IOR;\n\n    /**\n     * Constant for the {@link #math math} method.\n     */\n    public static final int XOR = Opcodes.IXOR;\n\n    /**\n     * Constant for the {@link #ifCmp ifCmp} method.\n     */\n    public static final int EQ = Opcodes.IFEQ;\n\n    /**\n     * Constant for the {@link #ifCmp ifCmp} method.\n     */\n    public static final int NE = Opcodes.IFNE;\n\n    /**\n     * Constant for the {@link #ifCmp ifCmp} method.\n     */\n    public static final int LT = Opcodes.IFLT;\n\n    /**\n     * Constant for the {@link #ifCmp ifCmp} method.\n     */\n    public static final int GE = Opcodes.IFGE;\n\n    /**\n     * Constant for the {@link #ifCmp ifCmp} method.\n     */\n    public static final int GT = Opcodes.IFGT;\n\n    /**\n     * Constant for the {@link #ifCmp ifCmp} method.\n     */\n    public static final int LE = Opcodes.IFLE;\n\n    /**\n     * Access flags of the method visited by this adapter.\n     */\n    private final int access;\n\n    /**\n     * Return type of the method visited by this adapter.\n     */\n    private final Type returnType;\n\n    /**\n     * Argument types of the method visited by this adapter.\n     */\n    private final Type[] argumentTypes;\n\n    /**\n     * Types of the local variables of the method visited by this adapter.\n     */\n    private final List<Type> localTypes = new ArrayList<Type>();\n\n    /**\n     * Creates a new {@link GeneratorAdapter}. <i>Subclasses must not use this\n     * constructor</i>. Instead, they must use the\n     * {@link #GeneratorAdapter(int, MethodVisitor, int, String, String)}\n     * version.\n     *\n     * @param mv\n     *            the method visitor to which this adapter delegates calls.\n     * @param access\n     *            the method's access flags (see {@link Opcodes}).\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor (see {@link Type Type}).\n     */\n    public GeneratorAdapter(final MethodVisitor mv, final int access,\n            final String name, final String desc) {\n        this(Opcodes.ASM4, mv, access, name, desc);\n    }\n\n    /**\n     * Creates a new {@link GeneratorAdapter}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     * @param mv\n     *            the method visitor to which this adapter delegates calls.\n     * @param access\n     *            the method's access flags (see {@link Opcodes}).\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor (see {@link Type Type}).\n     */\n    protected GeneratorAdapter(final int api, final MethodVisitor mv,\n            final int access, final String name, final String desc) {\n        super(api, access, desc, mv);\n        this.access = access;\n        this.returnType = Type.getReturnType(desc);\n        this.argumentTypes = Type.getArgumentTypes(desc);\n    }\n\n    /**\n     * Creates a new {@link GeneratorAdapter}. <i>Subclasses must not use this\n     * constructor</i>. Instead, they must use the\n     * {@link #GeneratorAdapter(int, MethodVisitor, int, String, String)}\n     * version.\n     *\n     * @param access\n     *            access flags of the adapted method.\n     * @param method\n     *            the adapted method.\n     * @param mv\n     *            the method visitor to which this adapter delegates calls.\n     */\n    public GeneratorAdapter(final int access, final Method method,\n            final MethodVisitor mv) {\n        this(mv, access, null, method.getDescriptor());\n    }\n\n    /**\n     * Creates a new {@link GeneratorAdapter}. <i>Subclasses must not use this\n     * constructor</i>. Instead, they must use the\n     * {@link #GeneratorAdapter(int, MethodVisitor, int, String, String)}\n     * version.\n     *\n     * @param access\n     *            access flags of the adapted method.\n     * @param method\n     *            the adapted method.\n     * @param signature\n     *            the signature of the adapted method (may be <tt>null</tt>).\n     * @param exceptions\n     *            the exceptions thrown by the adapted method (may be\n     *            <tt>null</tt>).\n     * @param cv\n     *            the class visitor to which this adapter delegates calls.\n     */\n    public GeneratorAdapter(final int access, final Method method,\n            final String signature, final Type[] exceptions,\n            final ClassVisitor cv) {\n        this(access, method, cv\n                .visitMethod(access, method.getName(), method.getDescriptor(),\n                        signature, getInternalNames(exceptions)));\n    }\n\n    /**\n     * Returns the internal names of the given types.\n     *\n     * @param types\n     *            a set of types.\n     * @return the internal names of the given types.\n     */\n    private static String[] getInternalNames(final Type[] types) {\n        if (types == null) {\n            return null;\n        }\n        String[] names = new String[types.length];\n        for (int i = 0; i < names.length; ++i) {\n            names[i] = types[i].getInternalName();\n        }\n        return names;\n    }\n\n    // ------------------------------------------------------------------------\n    // Instructions to push constants on the stack\n    // ------------------------------------------------------------------------\n\n    /**\n     * Generates the instruction to push the given value on the stack.\n     *\n     * @param value\n     *            the value to be pushed on the stack.\n     */\n    public void push(final boolean value) {\n        push(value ? 1 : 0);\n    }\n\n    /**\n     * Generates the instruction to push the given value on the stack.\n     *\n     * @param value\n     *            the value to be pushed on the stack.\n     */\n    public void push(final int value) {\n        if (value >= -1 && value <= 5) {\n            mv.visitInsn(Opcodes.ICONST_0 + value);\n        } else if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE) {\n            mv.visitIntInsn(Opcodes.BIPUSH, value);\n        } else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) {\n            mv.visitIntInsn(Opcodes.SIPUSH, value);\n        } else {\n            mv.visitLdcInsn(new Integer(value));\n        }\n    }\n\n    /**\n     * Generates the instruction to push the given value on the stack.\n     *\n     * @param value\n     *            the value to be pushed on the stack.\n     */\n    public void push(final long value) {\n        if (value == 0L || value == 1L) {\n            mv.visitInsn(Opcodes.LCONST_0 + (int) value);\n        } else {\n            mv.visitLdcInsn(new Long(value));\n        }\n    }\n\n    /**\n     * Generates the instruction to push the given value on the stack.\n     *\n     * @param value\n     *            the value to be pushed on the stack.\n     */\n    public void push(final float value) {\n        int bits = Float.floatToIntBits(value);\n        if (bits == 0L || bits == 0x3f800000 || bits == 0x40000000) { // 0..2\n            mv.visitInsn(Opcodes.FCONST_0 + (int) value);\n        } else {\n            mv.visitLdcInsn(new Float(value));\n        }\n    }\n\n    /**\n     * Generates the instruction to push the given value on the stack.\n     *\n     * @param value\n     *            the value to be pushed on the stack.\n     */\n    public void push(final double value) {\n        long bits = Double.doubleToLongBits(value);\n        if (bits == 0L || bits == 0x3ff0000000000000L) { // +0.0d and 1.0d\n            mv.visitInsn(Opcodes.DCONST_0 + (int) value);\n        } else {\n            mv.visitLdcInsn(new Double(value));\n        }\n    }\n\n    /**\n     * Generates the instruction to push the given value on the stack.\n     *\n     * @param value\n     *            the value to be pushed on the stack. May be <tt>null</tt>.\n     */\n    public void push(final String value) {\n        if (value == null) {\n            mv.visitInsn(Opcodes.ACONST_NULL);\n        } else {\n            mv.visitLdcInsn(value);\n        }\n    }\n\n    /**\n     * Generates the instruction to push the given value on the stack.\n     *\n     * @param value\n     *            the value to be pushed on the stack.\n     */\n    public void push(final Type value) {\n        if (value == null) {\n            mv.visitInsn(Opcodes.ACONST_NULL);\n        } else {\n            switch (value.getSort()) {\n            case Type.BOOLEAN:\n                mv.visitFieldInsn(Opcodes.GETSTATIC, \"java/lang/Boolean\",\n                        \"TYPE\", CLDESC);\n                break;\n            case Type.CHAR:\n                mv.visitFieldInsn(Opcodes.GETSTATIC, \"java/lang/Character\",\n                        \"TYPE\", CLDESC);\n                break;\n            case Type.BYTE:\n                mv.visitFieldInsn(Opcodes.GETSTATIC, \"java/lang/Byte\", \"TYPE\",\n                        CLDESC);\n                break;\n            case Type.SHORT:\n                mv.visitFieldInsn(Opcodes.GETSTATIC, \"java/lang/Short\", \"TYPE\",\n                        CLDESC);\n                break;\n            case Type.INT:\n                mv.visitFieldInsn(Opcodes.GETSTATIC, \"java/lang/Integer\",\n                        \"TYPE\", CLDESC);\n                break;\n            case Type.FLOAT:\n                mv.visitFieldInsn(Opcodes.GETSTATIC, \"java/lang/Float\", \"TYPE\",\n                        CLDESC);\n                break;\n            case Type.LONG:\n                mv.visitFieldInsn(Opcodes.GETSTATIC, \"java/lang/Long\", \"TYPE\",\n                        CLDESC);\n                break;\n            case Type.DOUBLE:\n                mv.visitFieldInsn(Opcodes.GETSTATIC, \"java/lang/Double\",\n                        \"TYPE\", CLDESC);\n                break;\n            default:\n                mv.visitLdcInsn(value);\n            }\n        }\n    }\n\n    /**\n     * Generates the instruction to push a handle on the stack.\n     *\n     * @param handle\n     *            the handle to be pushed on the stack.\n     */\n    public void push(final Handle handle) {\n        mv.visitLdcInsn(handle);\n    }\n\n    // ------------------------------------------------------------------------\n    // Instructions to load and store method arguments\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns the index of the given method argument in the frame's local\n     * variables array.\n     *\n     * @param arg\n     *            the index of a method argument.\n     * @return the index of the given method argument in the frame's local\n     *         variables array.\n     */\n    private int getArgIndex(final int arg) {\n        int index = (access & Opcodes.ACC_STATIC) == 0 ? 1 : 0;\n        for (int i = 0; i < arg; i++) {\n            index += argumentTypes[i].getSize();\n        }\n        return index;\n    }\n\n    /**\n     * Generates the instruction to push a local variable on the stack.\n     *\n     * @param type\n     *            the type of the local variable to be loaded.\n     * @param index\n     *            an index in the frame's local variables array.\n     */\n    private void loadInsn(final Type type, final int index) {\n        mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), index);\n    }\n\n    /**\n     * Generates the instruction to store the top stack value in a local\n     * variable.\n     *\n     * @param type\n     *            the type of the local variable to be stored.\n     * @param index\n     *            an index in the frame's local variables array.\n     */\n    private void storeInsn(final Type type, final int index) {\n        mv.visitVarInsn(type.getOpcode(Opcodes.ISTORE), index);\n    }\n\n    /**\n     * Generates the instruction to load 'this' on the stack.\n     */\n    public void loadThis() {\n        if ((access & Opcodes.ACC_STATIC) != 0) {\n            throw new IllegalStateException(\n                    \"no 'this' pointer within static method\");\n        }\n        mv.visitVarInsn(Opcodes.ALOAD, 0);\n    }\n\n    /**\n     * Generates the instruction to load the given method argument on the stack.\n     *\n     * @param arg\n     *            the index of a method argument.\n     */\n    public void loadArg(final int arg) {\n        loadInsn(argumentTypes[arg], getArgIndex(arg));\n    }\n\n    /**\n     * Generates the instructions to load the given method arguments on the\n     * stack.\n     *\n     * @param arg\n     *            the index of the first method argument to be loaded.\n     * @param count\n     *            the number of method arguments to be loaded.\n     */\n    public void loadArgs(final int arg, final int count) {\n        int index = getArgIndex(arg);\n        for (int i = 0; i < count; ++i) {\n            Type t = argumentTypes[arg + i];\n            loadInsn(t, index);\n            index += t.getSize();\n        }\n    }\n\n    /**\n     * Generates the instructions to load all the method arguments on the stack.\n     */\n    public void loadArgs() {\n        loadArgs(0, argumentTypes.length);\n    }\n\n    /**\n     * Generates the instructions to load all the method arguments on the stack,\n     * as a single object array.\n     */\n    public void loadArgArray() {\n        push(argumentTypes.length);\n        newArray(OBJECT_TYPE);\n        for (int i = 0; i < argumentTypes.length; i++) {\n            dup();\n            push(i);\n            loadArg(i);\n            box(argumentTypes[i], \"\");\n            arrayStore(OBJECT_TYPE);\n        }\n    }\n\n    /**\n     * Generates the instruction to store the top stack value in the given\n     * method argument.\n     *\n     * @param arg\n     *            the index of a method argument.\n     */\n    public void storeArg(final int arg) {\n        storeInsn(argumentTypes[arg], getArgIndex(arg));\n    }\n\n    // ------------------------------------------------------------------------\n    // Instructions to load and store local variables\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns the type of the given local variable.\n     *\n     * @param local\n     *            a local variable identifier, as returned by\n     *            {@link LocalVariablesSorter#newLocal(Type) newLocal()}.\n     * @return the type of the given local variable.\n     */\n    public Type getLocalType(final int local) {\n        return localTypes.get(local - firstLocal);\n    }\n\n    @Override\n    protected void setLocalType(final int local, final Type type) {\n        int index = local - firstLocal;\n        while (localTypes.size() < index + 1) {\n            localTypes.add(null);\n        }\n        localTypes.set(index, type);\n    }\n\n    /**\n     * Generates the instruction to load the given local variable on the stack.\n     *\n     * @param local\n     *            a local variable identifier, as returned by\n     *            {@link LocalVariablesSorter#newLocal(Type) newLocal()}.\n     */\n    public void loadLocal(final int local) {\n        loadInsn(getLocalType(local), local);\n    }\n\n    /**\n     * Generates the instruction to load the given local variable on the stack.\n     *\n     * @param local\n     *            a local variable identifier, as returned by\n     *            {@link LocalVariablesSorter#newLocal(Type) newLocal()}.\n     * @param type\n     *            the type of this local variable.\n     */\n    public void loadLocal(final int local, final Type type) {\n        setLocalType(local, type);\n        loadInsn(type, local);\n    }\n\n    /**\n     * Generates the instruction to store the top stack value in the given local\n     * variable.\n     *\n     * @param local\n     *            a local variable identifier, as returned by\n     *            {@link LocalVariablesSorter#newLocal(Type) newLocal()}.\n     */\n    public void storeLocal(final int local) {\n        storeInsn(getLocalType(local), local);\n    }\n\n    /**\n     * Generates the instruction to store the top stack value in the given local\n     * variable.\n     *\n     * @param local\n     *            a local variable identifier, as returned by\n     *            {@link LocalVariablesSorter#newLocal(Type) newLocal()}.\n     * @param type\n     *            the type of this local variable.\n     */\n    public void storeLocal(final int local, final Type type) {\n        setLocalType(local, type);\n        storeInsn(type, local);\n    }\n\n    /**\n     * Generates the instruction to load an element from an array.\n     *\n     * @param type\n     *            the type of the array element to be loaded.\n     */\n    public void arrayLoad(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.IALOAD));\n    }\n\n    /**\n     * Generates the instruction to store an element in an array.\n     *\n     * @param type\n     *            the type of the array element to be stored.\n     */\n    public void arrayStore(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.IASTORE));\n    }\n\n    // ------------------------------------------------------------------------\n    // Instructions to manage the stack\n    // ------------------------------------------------------------------------\n\n    /**\n     * Generates a POP instruction.\n     */\n    public void pop() {\n        mv.visitInsn(Opcodes.POP);\n    }\n\n    /**\n     * Generates a POP2 instruction.\n     */\n    public void pop2() {\n        mv.visitInsn(Opcodes.POP2);\n    }\n\n    /**\n     * Generates a DUP instruction.\n     */\n    public void dup() {\n        mv.visitInsn(Opcodes.DUP);\n    }\n\n    /**\n     * Generates a DUP2 instruction.\n     */\n    public void dup2() {\n        mv.visitInsn(Opcodes.DUP2);\n    }\n\n    /**\n     * Generates a DUP_X1 instruction.\n     */\n    public void dupX1() {\n        mv.visitInsn(Opcodes.DUP_X1);\n    }\n\n    /**\n     * Generates a DUP_X2 instruction.\n     */\n    public void dupX2() {\n        mv.visitInsn(Opcodes.DUP_X2);\n    }\n\n    /**\n     * Generates a DUP2_X1 instruction.\n     */\n    public void dup2X1() {\n        mv.visitInsn(Opcodes.DUP2_X1);\n    }\n\n    /**\n     * Generates a DUP2_X2 instruction.\n     */\n    public void dup2X2() {\n        mv.visitInsn(Opcodes.DUP2_X2);\n    }\n\n    /**\n     * Generates a SWAP instruction.\n     */\n    public void swap() {\n        mv.visitInsn(Opcodes.SWAP);\n    }\n\n    /**\n     * Generates the instructions to swap the top two stack values.\n     *\n     * @param prev\n     *            type of the top - 1 stack value.\n     * @param type\n     *            type of the top stack value.\n     */\n    public void swap(final Type prev, final Type type) {\n        if (type.getSize() == 1) {\n            if (prev.getSize() == 1) {\n                swap(); // same as dupX1(), pop();\n            } else {\n                dupX2();\n                pop();\n            }\n        } else {\n            if (prev.getSize() == 1) {\n                dup2X1();\n                pop2();\n            } else {\n                dup2X2();\n                pop2();\n            }\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Instructions to do mathematical and logical operations\n    // ------------------------------------------------------------------------\n\n    /**\n     * Generates the instruction to do the specified mathematical or logical\n     * operation.\n     *\n     * @param op\n     *            a mathematical or logical operation. Must be one of ADD, SUB,\n     *            MUL, DIV, REM, NEG, SHL, SHR, USHR, AND, OR, XOR.\n     * @param type\n     *            the type of the operand(s) for this operation.\n     */\n    public void math(final int op, final Type type) {\n        mv.visitInsn(type.getOpcode(op));\n    }\n\n    /**\n     * Generates the instructions to compute the bitwise negation of the top\n     * stack value.\n     */\n    public void not() {\n        mv.visitInsn(Opcodes.ICONST_1);\n        mv.visitInsn(Opcodes.IXOR);\n    }\n\n    /**\n     * Generates the instruction to increment the given local variable.\n     *\n     * @param local\n     *            the local variable to be incremented.\n     * @param amount\n     *            the amount by which the local variable must be incremented.\n     */\n    public void iinc(final int local, final int amount) {\n        mv.visitIincInsn(local, amount);\n    }\n\n    /**\n     * Generates the instructions to cast a numerical value from one type to\n     * another.\n     *\n     * @param from\n     *            the type of the top stack value\n     * @param to\n     *            the type into which this value must be cast.\n     */\n    public void cast(final Type from, final Type to) {\n        if (from != to) {\n            if (from == Type.DOUBLE_TYPE) {\n                if (to == Type.FLOAT_TYPE) {\n                    mv.visitInsn(Opcodes.D2F);\n                } else if (to == Type.LONG_TYPE) {\n                    mv.visitInsn(Opcodes.D2L);\n                } else {\n                    mv.visitInsn(Opcodes.D2I);\n                    cast(Type.INT_TYPE, to);\n                }\n            } else if (from == Type.FLOAT_TYPE) {\n                if (to == Type.DOUBLE_TYPE) {\n                    mv.visitInsn(Opcodes.F2D);\n                } else if (to == Type.LONG_TYPE) {\n                    mv.visitInsn(Opcodes.F2L);\n                } else {\n                    mv.visitInsn(Opcodes.F2I);\n                    cast(Type.INT_TYPE, to);\n                }\n            } else if (from == Type.LONG_TYPE) {\n                if (to == Type.DOUBLE_TYPE) {\n                    mv.visitInsn(Opcodes.L2D);\n                } else if (to == Type.FLOAT_TYPE) {\n                    mv.visitInsn(Opcodes.L2F);\n                } else {\n                    mv.visitInsn(Opcodes.L2I);\n                    cast(Type.INT_TYPE, to);\n                }\n            } else {\n                if (to == Type.BYTE_TYPE) {\n                    mv.visitInsn(Opcodes.I2B);\n                } else if (to == Type.CHAR_TYPE) {\n                    mv.visitInsn(Opcodes.I2C);\n                } else if (to == Type.DOUBLE_TYPE) {\n                    mv.visitInsn(Opcodes.I2D);\n                } else if (to == Type.FLOAT_TYPE) {\n                    mv.visitInsn(Opcodes.I2F);\n                } else if (to == Type.LONG_TYPE) {\n                    mv.visitInsn(Opcodes.I2L);\n                } else if (to == Type.SHORT_TYPE) {\n                    mv.visitInsn(Opcodes.I2S);\n                }\n            }\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Instructions to do boxing and unboxing operations\n    // ------------------------------------------------------------------------\n\n    private static Type getBoxedType(final Type type) {\n        switch (type.getSort()) {\n        case Type.BYTE:\n            return BYTE_TYPE;\n        case Type.BOOLEAN:\n            return BOOLEAN_TYPE;\n        case Type.SHORT:\n            return SHORT_TYPE;\n        case Type.CHAR:\n            return CHARACTER_TYPE;\n        case Type.INT:\n            return INTEGER_TYPE;\n        case Type.FLOAT:\n            return FLOAT_TYPE;\n        case Type.LONG:\n            return LONG_TYPE;\n        case Type.DOUBLE:\n            return DOUBLE_TYPE;\n        }\n        return type;\n    }\n\n    /**\n     * Generates the instructions to box the top stack value. This value is\n     * replaced by its boxed equivalent on top of the stack.\n     *\n     * @param type\n     *            the type of the top stack value.\n     */\n    public String box(final Type type, String val) {\n        if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {\n            return val;\n        }\n        if (type == Type.VOID_TYPE) {\n            push((String) null);\n            return val;\n        } else {\n            Type boxed = getBoxedType(type);\n            newInstance(boxed);\n            if (type.getSize() == 2) {\n                // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o\n                dupX2();\n                dupX2();\n                pop();\n            } else {\n                // p -> po -> opo -> oop -> o\n                dupX1();\n                swap();\n            }\n            invokeConstructor(boxed, new Method(\"<init>\", Type.VOID_TYPE,\n                    new Type[] { type }));\n            return \"new \" + boxed.getClassName() + \"((\" + type.getClassName() + \")\" + val + \")\";\n        }\n    }\n    \n    /**\n     * Generates the instructions to box the top stack value using Java 5's\n     * valueOf() method. This value is replaced by its boxed equivalent on top\n     * of the stack.\n     *\n     * @param type\n     *            the type of the top stack value.\n     */\n    public void valueOf(final Type type) {\n        if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {\n            return;\n        }\n        if (type == Type.VOID_TYPE) {\n            push((String) null);\n        } else {\n            Type boxed = getBoxedType(type);\n            invokeStatic(boxed, new Method(\"valueOf\", boxed,\n                    new Type[] { type }));\n        }\n    }\n\n    /**\n     * Generates the instructions to unbox the top stack value. This value is\n     * replaced by its unboxed equivalent on top of the stack.\n     *\n     * @param type\n     *            the type of the top stack value.\n     */\n    public void unbox(final Type type) {\n        Type t = NUMBER_TYPE;\n        Method sig = null;\n        switch (type.getSort()) {\n        case Type.VOID:\n            return;\n        case Type.CHAR:\n            t = CHARACTER_TYPE;\n            sig = CHAR_VALUE;\n            break;\n        case Type.BOOLEAN:\n            t = BOOLEAN_TYPE;\n            sig = BOOLEAN_VALUE;\n            break;\n        case Type.DOUBLE:\n            sig = DOUBLE_VALUE;\n            break;\n        case Type.FLOAT:\n            sig = FLOAT_VALUE;\n            break;\n        case Type.LONG:\n            sig = LONG_VALUE;\n            break;\n        case Type.INT:\n        case Type.SHORT:\n        case Type.BYTE:\n            sig = INT_VALUE;\n        }\n        if (sig == null) {\n            checkCast(type);\n        } else {\n            checkCast(t);\n            invokeVirtual(t, sig);\n        }\n    }\n    \n    public String unbox(final Type type, String value) {\n      Type t = NUMBER_TYPE;\n      Method sig = null;\n      switch (type.getSort()) {\n      case Type.VOID:\n        return value;\n      case Type.CHAR:\n        t = CHARACTER_TYPE;\n        sig = CHAR_VALUE;\n        break;\n      case Type.BOOLEAN:\n        t = BOOLEAN_TYPE;\n        sig = BOOLEAN_VALUE;\n        break;\n      case Type.DOUBLE:\n        sig = DOUBLE_VALUE;\n        break;\n      case Type.FLOAT:\n        sig = FLOAT_VALUE;\n        break;\n      case Type.LONG:\n        sig = LONG_VALUE;\n        break;\n      case Type.INT:\n      case Type.SHORT:\n      case Type.BYTE:\n        sig = INT_VALUE;\n      }\n      if (sig == null) {\n        return value;\n      } else {\n        return \"((\" + t.getClassName() + \")\" + value + \").\" + sig.getName()\n            + \"()\";\n      }\n    }\n\n    // ------------------------------------------------------------------------\n    // Instructions to jump to other instructions\n    // ------------------------------------------------------------------------\n\n    /**\n     * Creates a new {@link Label}.\n     *\n     * @return a new {@link Label}.\n     */\n    public Label newLabel() {\n        return new Label();\n    }\n\n    /**\n     * Marks the current code position with the given label.\n     *\n     * @param label\n     *            a label.\n     */\n    public void mark(final Label label) {\n        mv.visitLabel(label);\n    }\n\n    /**\n     * Marks the current code position with a new label.\n     *\n     * @return the label that was created to mark the current code position.\n     */\n    public Label mark() {\n        Label label = new Label();\n        mv.visitLabel(label);\n        return label;\n    }\n\n    /**\n     * Generates the instructions to jump to a label based on the comparison of\n     * the top two stack values.\n     *\n     * @param type\n     *            the type of the top two stack values.\n     * @param mode\n     *            how these values must be compared. One of EQ, NE, LT, GE, GT,\n     *            LE.\n     * @param label\n     *            where to jump if the comparison result is <tt>true</tt>.\n     */\n    public void ifCmp(final Type type, final int mode, final Label label) {\n        switch (type.getSort()) {\n        case Type.LONG:\n            mv.visitInsn(Opcodes.LCMP);\n            break;\n        case Type.DOUBLE:\n            mv.visitInsn(mode == GE || mode == GT ? Opcodes.DCMPL\n                    : Opcodes.DCMPG);\n            break;\n        case Type.FLOAT:\n            mv.visitInsn(mode == GE || mode == GT ? Opcodes.FCMPL\n                    : Opcodes.FCMPG);\n            break;\n        case Type.ARRAY:\n        case Type.OBJECT:\n            switch (mode) {\n            case EQ:\n                mv.visitJumpInsn(Opcodes.IF_ACMPEQ, label);\n                return;\n            case NE:\n                mv.visitJumpInsn(Opcodes.IF_ACMPNE, label);\n                return;\n            }\n            throw new IllegalArgumentException(\"Bad comparison for type \"\n                    + type);\n        default:\n            int intOp = -1;\n            switch (mode) {\n            case EQ:\n                intOp = Opcodes.IF_ICMPEQ;\n                break;\n            case NE:\n                intOp = Opcodes.IF_ICMPNE;\n                break;\n            case GE:\n                intOp = Opcodes.IF_ICMPGE;\n                break;\n            case LT:\n                intOp = Opcodes.IF_ICMPLT;\n                break;\n            case LE:\n                intOp = Opcodes.IF_ICMPLE;\n                break;\n            case GT:\n                intOp = Opcodes.IF_ICMPGT;\n                break;\n            }\n            mv.visitJumpInsn(intOp, label);\n            return;\n        }\n        mv.visitJumpInsn(mode, label);\n    }\n\n    /**\n     * Generates the instructions to jump to a label based on the comparison of\n     * the top two integer stack values.\n     *\n     * @param mode\n     *            how these values must be compared. One of EQ, NE, LT, GE, GT,\n     *            LE.\n     * @param label\n     *            where to jump if the comparison result is <tt>true</tt>.\n     */\n    public void ifICmp(final int mode, final Label label) {\n        ifCmp(Type.INT_TYPE, mode, label);\n    }\n\n    /**\n     * Generates the instructions to jump to a label based on the comparison of\n     * the top integer stack value with zero.\n     *\n     * @param mode\n     *            how these values must be compared. One of EQ, NE, LT, GE, GT,\n     *            LE.\n     * @param label\n     *            where to jump if the comparison result is <tt>true</tt>.\n     */\n    public void ifZCmp(final int mode, final Label label) {\n        mv.visitJumpInsn(mode, label);\n    }\n\n    /**\n     * Generates the instruction to jump to the given label if the top stack\n     * value is null.\n     *\n     * @param label\n     *            where to jump if the condition is <tt>true</tt>.\n     */\n    public void ifNull(final Label label) {\n        mv.visitJumpInsn(Opcodes.IFNULL, label);\n    }\n\n    /**\n     * Generates the instruction to jump to the given label if the top stack\n     * value is not null.\n     *\n     * @param label\n     *            where to jump if the condition is <tt>true</tt>.\n     */\n    public void ifNonNull(final Label label) {\n        mv.visitJumpInsn(Opcodes.IFNONNULL, label);\n    }\n\n    /**\n     * Generates the instruction to jump to the given label.\n     *\n     * @param label\n     *            where to jump if the condition is <tt>true</tt>.\n     */\n    public void goTo(final Label label) {\n        mv.visitJumpInsn(Opcodes.GOTO, label);\n    }\n\n    /**\n     * Generates a RET instruction.\n     *\n     * @param local\n     *            a local variable identifier, as returned by\n     *            {@link LocalVariablesSorter#newLocal(Type) newLocal()}.\n     */\n    public void ret(final int local) {\n        mv.visitVarInsn(Opcodes.RET, local);\n    }\n\n    /**\n     * Generates the instructions for a switch statement.\n     *\n     * @param keys\n     *            the switch case keys.\n     * @param generator\n     *            a generator to generate the code for the switch cases.\n     */\n    public void tableSwitch(final int[] keys,\n            final TableSwitchGenerator generator) {\n        float density;\n        if (keys.length == 0) {\n            density = 0;\n        } else {\n            density = (float) keys.length\n                    / (keys[keys.length - 1] - keys[0] + 1);\n        }\n        tableSwitch(keys, generator, density >= 0.5f);\n    }\n\n    /**\n     * Generates the instructions for a switch statement.\n     *\n     * @param keys\n     *            the switch case keys.\n     * @param generator\n     *            a generator to generate the code for the switch cases.\n     * @param useTable\n     *            <tt>true</tt> to use a TABLESWITCH instruction, or\n     *            <tt>false</tt> to use a LOOKUPSWITCH instruction.\n     */\n    public void tableSwitch(final int[] keys,\n            final TableSwitchGenerator generator, final boolean useTable) {\n        for (int i = 1; i < keys.length; ++i) {\n            if (keys[i] < keys[i - 1]) {\n                throw new IllegalArgumentException(\n                        \"keys must be sorted ascending\");\n            }\n        }\n        Label def = newLabel();\n        Label end = newLabel();\n        if (keys.length > 0) {\n            int len = keys.length;\n            int min = keys[0];\n            int max = keys[len - 1];\n            int range = max - min + 1;\n            if (useTable) {\n                Label[] labels = new Label[range];\n                Arrays.fill(labels, def);\n                for (int i = 0; i < len; ++i) {\n                    labels[keys[i] - min] = newLabel();\n                }\n                mv.visitTableSwitchInsn(min, max, def, labels);\n                for (int i = 0; i < range; ++i) {\n                    Label label = labels[i];\n                    if (label != def) {\n                        mark(label);\n                        generator.generateCase(i + min, end);\n                    }\n                }\n            } else {\n                Label[] labels = new Label[len];\n                for (int i = 0; i < len; ++i) {\n                    labels[i] = newLabel();\n                }\n                mv.visitLookupSwitchInsn(def, keys, labels);\n                for (int i = 0; i < len; ++i) {\n                    mark(labels[i]);\n                    generator.generateCase(keys[i], end);\n                }\n            }\n        }\n        mark(def);\n        generator.generateDefault();\n        mark(end);\n    }\n\n    /**\n     * Generates the instruction to return the top stack value to the caller.\n     */\n    public void returnValue() {\n        mv.visitInsn(returnType.getOpcode(Opcodes.IRETURN));\n    }\n\n    // ------------------------------------------------------------------------\n    // Instructions to load and store fields\n    // ------------------------------------------------------------------------\n\n    /**\n     * Generates a get field or set field instruction.\n     *\n     * @param opcode\n     *            the instruction's opcode.\n     * @param ownerType\n     *            the class in which the field is defined.\n     * @param name\n     *            the name of the field.\n     * @param fieldType\n     *            the type of the field.\n     */\n    private void fieldInsn(final int opcode, final Type ownerType,\n            final String name, final Type fieldType) {\n        mv.visitFieldInsn(opcode, ownerType.getInternalName(), name,\n                fieldType.getDescriptor());\n    }\n\n    /**\n     * Generates the instruction to push the value of a static field on the\n     * stack.\n     *\n     * @param owner\n     *            the class in which the field is defined.\n     * @param name\n     *            the name of the field.\n     * @param type\n     *            the type of the field.\n     */\n    public void getStatic(final Type owner, final String name, final Type type) {\n        fieldInsn(Opcodes.GETSTATIC, owner, name, type);\n    }\n\n    /**\n     * Generates the instruction to store the top stack value in a static field.\n     *\n     * @param owner\n     *            the class in which the field is defined.\n     * @param name\n     *            the name of the field.\n     * @param type\n     *            the type of the field.\n     */\n    public void putStatic(final Type owner, final String name, final Type type) {\n        fieldInsn(Opcodes.PUTSTATIC, owner, name, type);\n    }\n\n    /**\n     * Generates the instruction to push the value of a non static field on the\n     * stack.\n     *\n     * @param owner\n     *            the class in which the field is defined.\n     * @param name\n     *            the name of the field.\n     * @param type\n     *            the type of the field.\n     */\n    public void getField(final Type owner, final String name, final Type type) {\n        fieldInsn(Opcodes.GETFIELD, owner, name, type);\n    }\n\n    /**\n     * Generates the instruction to store the top stack value in a non static\n     * field.\n     *\n     * @param owner\n     *            the class in which the field is defined.\n     * @param name\n     *            the name of the field.\n     * @param type\n     *            the type of the field.\n     */\n    public void putField(final Type owner, final String name, final Type type) {\n        fieldInsn(Opcodes.PUTFIELD, owner, name, type);\n    }\n\n    // ------------------------------------------------------------------------\n    // Instructions to invoke methods\n    // ------------------------------------------------------------------------\n\n    /**\n     * Generates an invoke method instruction.\n     *\n     * @param opcode\n     *            the instruction's opcode.\n     * @param type\n     *            the class in which the method is defined.\n     * @param method\n     *            the method to be invoked.\n     */\n    private void invokeInsn(final int opcode, final Type type,\n            final Method method) {\n        String owner = type.getSort() == Type.ARRAY ? type.getDescriptor()\n                : type.getInternalName();\n        mv.visitMethodInsn(opcode, owner, method.getName(),\n                method.getDescriptor());\n    }\n\n    /**\n     * Generates the instruction to invoke a normal method.\n     *\n     * @param owner\n     *            the class in which the method is defined.\n     * @param method\n     *            the method to be invoked.\n     */\n    public void invokeVirtual(final Type owner, final Method method) {\n        invokeInsn(Opcodes.INVOKEVIRTUAL, owner, method);\n    }\n\n    /**\n     * Generates the instruction to invoke a constructor.\n     *\n     * @param type\n     *            the class in which the constructor is defined.\n     * @param method\n     *            the constructor to be invoked.\n     */\n    public void invokeConstructor(final Type type, final Method method) {\n        invokeInsn(Opcodes.INVOKESPECIAL, type, method);\n    }\n\n    /**\n     * Generates the instruction to invoke a static method.\n     *\n     * @param owner\n     *            the class in which the method is defined.\n     * @param method\n     *            the method to be invoked.\n     */\n    public void invokeStatic(final Type owner, final Method method) {\n        invokeInsn(Opcodes.INVOKESTATIC, owner, method);\n    }\n\n    /**\n     * Generates the instruction to invoke an interface method.\n     *\n     * @param owner\n     *            the class in which the method is defined.\n     * @param method\n     *            the method to be invoked.\n     */\n    public void invokeInterface(final Type owner, final Method method) {\n        invokeInsn(Opcodes.INVOKEINTERFACE, owner, method);\n    }\n\n    /**\n     * Generates an invokedynamic instruction.\n     *\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor (see {@link Type Type}).\n     * @param bsm\n     *            the bootstrap method.\n     * @param bsmArgs\n     *            the bootstrap method constant arguments. Each argument must be\n     *            an {@link Integer}, {@link Float}, {@link Long},\n     *            {@link Double}, {@link String}, {@link Type} or {@link Handle}\n     *            value. This method is allowed to modify the content of the\n     *            array so a caller should expect that this array may change.\n     */\n    public void invokeDynamic(String name, String desc, Handle bsm,\n            Object... bsmArgs) {\n        mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);\n    }\n\n    // ------------------------------------------------------------------------\n    // Instructions to create objects and arrays\n    // ------------------------------------------------------------------------\n\n    /**\n     * Generates a type dependent instruction.\n     *\n     * @param opcode\n     *            the instruction's opcode.\n     * @param type\n     *            the instruction's operand.\n     */\n    private void typeInsn(final int opcode, final Type type) {\n        mv.visitTypeInsn(opcode, type.getInternalName());\n    }\n\n    /**\n     * Generates the instruction to create a new object.\n     *\n     * @param type\n     *            the class of the object to be created.\n     */\n    public void newInstance(final Type type) {\n        typeInsn(Opcodes.NEW, type);\n    }\n\n    /**\n     * Generates the instruction to create a new array.\n     *\n     * @param type\n     *            the type of the array elements.\n     */\n    public void newArray(final Type type) {\n        int typ;\n        switch (type.getSort()) {\n        case Type.BOOLEAN:\n            typ = Opcodes.T_BOOLEAN;\n            break;\n        case Type.CHAR:\n            typ = Opcodes.T_CHAR;\n            break;\n        case Type.BYTE:\n            typ = Opcodes.T_BYTE;\n            break;\n        case Type.SHORT:\n            typ = Opcodes.T_SHORT;\n            break;\n        case Type.INT:\n            typ = Opcodes.T_INT;\n            break;\n        case Type.FLOAT:\n            typ = Opcodes.T_FLOAT;\n            break;\n        case Type.LONG:\n            typ = Opcodes.T_LONG;\n            break;\n        case Type.DOUBLE:\n            typ = Opcodes.T_DOUBLE;\n            break;\n        default:\n            typeInsn(Opcodes.ANEWARRAY, type);\n            return;\n        }\n        mv.visitIntInsn(Opcodes.NEWARRAY, typ);\n    }\n\n    // ------------------------------------------------------------------------\n    // Miscelaneous instructions\n    // ------------------------------------------------------------------------\n\n    /**\n     * Generates the instruction to compute the length of an array.\n     */\n    public void arrayLength() {\n        mv.visitInsn(Opcodes.ARRAYLENGTH);\n    }\n\n    /**\n     * Generates the instruction to throw an exception.\n     */\n    public void throwException() {\n        mv.visitInsn(Opcodes.ATHROW);\n    }\n\n    /**\n     * Generates the instructions to create and throw an exception. The\n     * exception class must have a constructor with a single String argument.\n     *\n     * @param type\n     *            the class of the exception to be thrown.\n     * @param msg\n     *            the detailed message of the exception.\n     */\n    public void throwException(final Type type, final String msg) {\n        newInstance(type);\n        dup();\n        push(msg);\n        invokeConstructor(type, Method.getMethod(\"void <init> (String)\"));\n        throwException();\n    }\n\n    /**\n     * Generates the instruction to check that the top stack value is of the\n     * given type.\n     *\n     * @param type\n     *            a class or interface type.\n     */\n    public void checkCast(final Type type) {\n        if (!type.equals(OBJECT_TYPE)) {\n            typeInsn(Opcodes.CHECKCAST, type);\n        }\n    }\n\n    /**\n     * Generates the instruction to test if the top stack value is of the given\n     * type.\n     *\n     * @param type\n     *            a class or interface type.\n     */\n    public void instanceOf(final Type type) {\n        typeInsn(Opcodes.INSTANCEOF, type);\n    }\n\n    /**\n     * Generates the instruction to get the monitor of the top stack value.\n     */\n    public void monitorEnter() {\n        mv.visitInsn(Opcodes.MONITORENTER);\n    }\n\n    /**\n     * Generates the instruction to release the monitor of the top stack value.\n     */\n    public void monitorExit() {\n        mv.visitInsn(Opcodes.MONITOREXIT);\n    }\n\n    // ------------------------------------------------------------------------\n    // Non instructions\n    // ------------------------------------------------------------------------\n\n    /**\n     * Marks the end of the visited method.\n     */\n    public void endMethod() {\n        if ((access & Opcodes.ACC_ABSTRACT) == 0) {\n            mv.visitMaxs(0, 0);\n        }\n        mv.visitEnd();\n    }\n\n    /**\n     * Marks the start of an exception handler.\n     *\n     * @param start\n     *            beginning of the exception handler's scope (inclusive).\n     * @param end\n     *            end of the exception handler's scope (exclusive).\n     * @param exception\n     *            internal name of the type of exceptions handled by the\n     *            handler.\n     */\n    public void catchException(final Label start, final Label end,\n            final Type exception) {\n        if (exception == null) {\n            mv.visitTryCatchBlock(start, end, mark(), null);\n        } else {\n            mv.visitTryCatchBlock(start, end, mark(),\n                    exception.getInternalName());\n        }\n    }\n}"
  },
  {
    "path": "src/jvm/clojure/asm/commons/InstructionAdapter.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\n\npackage clojure.asm.commons;\n\nimport clojure.asm.Handle;\nimport clojure.asm.Label;\nimport clojure.asm.MethodVisitor;\nimport clojure.asm.Opcodes;\nimport clojure.asm.Type;\n\n/**\n * A {@link MethodVisitor} providing a more detailed API to generate and\n * transform instructions.\n *\n * @author Eric Bruneton\n */\npublic class InstructionAdapter extends MethodVisitor {\n\n    public final static Type OBJECT_TYPE = Type.getType(\"Ljava/lang/Object;\");\n\n    /**\n     * Creates a new {@link InstructionAdapter}. <i>Subclasses must not use this\n     * constructor</i>. Instead, they must use the\n     * {@link #InstructionAdapter(int, MethodVisitor)} version.\n     *\n     * @param mv\n     *            the method visitor to which this adapter delegates calls.\n     */\n    public InstructionAdapter(final MethodVisitor mv) {\n        this(Opcodes.ASM4, mv);\n    }\n\n    /**\n     * Creates a new {@link InstructionAdapter}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     * @param mv\n     *            the method visitor to which this adapter delegates calls.\n     */\n    protected InstructionAdapter(final int api, final MethodVisitor mv) {\n        super(api, mv);\n    }\n\n    @Override\n    public void visitInsn(final int opcode) {\n        switch (opcode) {\n        case Opcodes.NOP:\n            nop();\n            break;\n        case Opcodes.ACONST_NULL:\n            aconst(null);\n            break;\n        case Opcodes.ICONST_M1:\n        case Opcodes.ICONST_0:\n        case Opcodes.ICONST_1:\n        case Opcodes.ICONST_2:\n        case Opcodes.ICONST_3:\n        case Opcodes.ICONST_4:\n        case Opcodes.ICONST_5:\n            iconst(opcode - Opcodes.ICONST_0);\n            break;\n        case Opcodes.LCONST_0:\n        case Opcodes.LCONST_1:\n            lconst(opcode - Opcodes.LCONST_0);\n            break;\n        case Opcodes.FCONST_0:\n        case Opcodes.FCONST_1:\n        case Opcodes.FCONST_2:\n            fconst(opcode - Opcodes.FCONST_0);\n            break;\n        case Opcodes.DCONST_0:\n        case Opcodes.DCONST_1:\n            dconst(opcode - Opcodes.DCONST_0);\n            break;\n        case Opcodes.IALOAD:\n            aload(Type.INT_TYPE);\n            break;\n        case Opcodes.LALOAD:\n            aload(Type.LONG_TYPE);\n            break;\n        case Opcodes.FALOAD:\n            aload(Type.FLOAT_TYPE);\n            break;\n        case Opcodes.DALOAD:\n            aload(Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.AALOAD:\n            aload(OBJECT_TYPE);\n            break;\n        case Opcodes.BALOAD:\n            aload(Type.BYTE_TYPE);\n            break;\n        case Opcodes.CALOAD:\n            aload(Type.CHAR_TYPE);\n            break;\n        case Opcodes.SALOAD:\n            aload(Type.SHORT_TYPE);\n            break;\n        case Opcodes.IASTORE:\n            astore(Type.INT_TYPE);\n            break;\n        case Opcodes.LASTORE:\n            astore(Type.LONG_TYPE);\n            break;\n        case Opcodes.FASTORE:\n            astore(Type.FLOAT_TYPE);\n            break;\n        case Opcodes.DASTORE:\n            astore(Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.AASTORE:\n            astore(OBJECT_TYPE);\n            break;\n        case Opcodes.BASTORE:\n            astore(Type.BYTE_TYPE);\n            break;\n        case Opcodes.CASTORE:\n            astore(Type.CHAR_TYPE);\n            break;\n        case Opcodes.SASTORE:\n            astore(Type.SHORT_TYPE);\n            break;\n        case Opcodes.POP:\n            pop();\n            break;\n        case Opcodes.POP2:\n            pop2();\n            break;\n        case Opcodes.DUP:\n            dup();\n            break;\n        case Opcodes.DUP_X1:\n            dupX1();\n            break;\n        case Opcodes.DUP_X2:\n            dupX2();\n            break;\n        case Opcodes.DUP2:\n            dup2();\n            break;\n        case Opcodes.DUP2_X1:\n            dup2X1();\n            break;\n        case Opcodes.DUP2_X2:\n            dup2X2();\n            break;\n        case Opcodes.SWAP:\n            swap();\n            break;\n        case Opcodes.IADD:\n            add(Type.INT_TYPE);\n            break;\n        case Opcodes.LADD:\n            add(Type.LONG_TYPE);\n            break;\n        case Opcodes.FADD:\n            add(Type.FLOAT_TYPE);\n            break;\n        case Opcodes.DADD:\n            add(Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.ISUB:\n            sub(Type.INT_TYPE);\n            break;\n        case Opcodes.LSUB:\n            sub(Type.LONG_TYPE);\n            break;\n        case Opcodes.FSUB:\n            sub(Type.FLOAT_TYPE);\n            break;\n        case Opcodes.DSUB:\n            sub(Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.IMUL:\n            mul(Type.INT_TYPE);\n            break;\n        case Opcodes.LMUL:\n            mul(Type.LONG_TYPE);\n            break;\n        case Opcodes.FMUL:\n            mul(Type.FLOAT_TYPE);\n            break;\n        case Opcodes.DMUL:\n            mul(Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.IDIV:\n            div(Type.INT_TYPE);\n            break;\n        case Opcodes.LDIV:\n            div(Type.LONG_TYPE);\n            break;\n        case Opcodes.FDIV:\n            div(Type.FLOAT_TYPE);\n            break;\n        case Opcodes.DDIV:\n            div(Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.IREM:\n            rem(Type.INT_TYPE);\n            break;\n        case Opcodes.LREM:\n            rem(Type.LONG_TYPE);\n            break;\n        case Opcodes.FREM:\n            rem(Type.FLOAT_TYPE);\n            break;\n        case Opcodes.DREM:\n            rem(Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.INEG:\n            neg(Type.INT_TYPE);\n            break;\n        case Opcodes.LNEG:\n            neg(Type.LONG_TYPE);\n            break;\n        case Opcodes.FNEG:\n            neg(Type.FLOAT_TYPE);\n            break;\n        case Opcodes.DNEG:\n            neg(Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.ISHL:\n            shl(Type.INT_TYPE);\n            break;\n        case Opcodes.LSHL:\n            shl(Type.LONG_TYPE);\n            break;\n        case Opcodes.ISHR:\n            shr(Type.INT_TYPE);\n            break;\n        case Opcodes.LSHR:\n            shr(Type.LONG_TYPE);\n            break;\n        case Opcodes.IUSHR:\n            ushr(Type.INT_TYPE);\n            break;\n        case Opcodes.LUSHR:\n            ushr(Type.LONG_TYPE);\n            break;\n        case Opcodes.IAND:\n            and(Type.INT_TYPE);\n            break;\n        case Opcodes.LAND:\n            and(Type.LONG_TYPE);\n            break;\n        case Opcodes.IOR:\n            or(Type.INT_TYPE);\n            break;\n        case Opcodes.LOR:\n            or(Type.LONG_TYPE);\n            break;\n        case Opcodes.IXOR:\n            xor(Type.INT_TYPE);\n            break;\n        case Opcodes.LXOR:\n            xor(Type.LONG_TYPE);\n            break;\n        case Opcodes.I2L:\n            cast(Type.INT_TYPE, Type.LONG_TYPE);\n            break;\n        case Opcodes.I2F:\n            cast(Type.INT_TYPE, Type.FLOAT_TYPE);\n            break;\n        case Opcodes.I2D:\n            cast(Type.INT_TYPE, Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.L2I:\n            cast(Type.LONG_TYPE, Type.INT_TYPE);\n            break;\n        case Opcodes.L2F:\n            cast(Type.LONG_TYPE, Type.FLOAT_TYPE);\n            break;\n        case Opcodes.L2D:\n            cast(Type.LONG_TYPE, Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.F2I:\n            cast(Type.FLOAT_TYPE, Type.INT_TYPE);\n            break;\n        case Opcodes.F2L:\n            cast(Type.FLOAT_TYPE, Type.LONG_TYPE);\n            break;\n        case Opcodes.F2D:\n            cast(Type.FLOAT_TYPE, Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.D2I:\n            cast(Type.DOUBLE_TYPE, Type.INT_TYPE);\n            break;\n        case Opcodes.D2L:\n            cast(Type.DOUBLE_TYPE, Type.LONG_TYPE);\n            break;\n        case Opcodes.D2F:\n            cast(Type.DOUBLE_TYPE, Type.FLOAT_TYPE);\n            break;\n        case Opcodes.I2B:\n            cast(Type.INT_TYPE, Type.BYTE_TYPE);\n            break;\n        case Opcodes.I2C:\n            cast(Type.INT_TYPE, Type.CHAR_TYPE);\n            break;\n        case Opcodes.I2S:\n            cast(Type.INT_TYPE, Type.SHORT_TYPE);\n            break;\n        case Opcodes.LCMP:\n            lcmp();\n            break;\n        case Opcodes.FCMPL:\n            cmpl(Type.FLOAT_TYPE);\n            break;\n        case Opcodes.FCMPG:\n            cmpg(Type.FLOAT_TYPE);\n            break;\n        case Opcodes.DCMPL:\n            cmpl(Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.DCMPG:\n            cmpg(Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.IRETURN:\n            areturn(Type.INT_TYPE);\n            break;\n        case Opcodes.LRETURN:\n            areturn(Type.LONG_TYPE);\n            break;\n        case Opcodes.FRETURN:\n            areturn(Type.FLOAT_TYPE);\n            break;\n        case Opcodes.DRETURN:\n            areturn(Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.ARETURN:\n            areturn(OBJECT_TYPE);\n            break;\n        case Opcodes.RETURN:\n            areturn(Type.VOID_TYPE);\n            break;\n        case Opcodes.ARRAYLENGTH:\n            arraylength();\n            break;\n        case Opcodes.ATHROW:\n            athrow();\n            break;\n        case Opcodes.MONITORENTER:\n            monitorenter();\n            break;\n        case Opcodes.MONITOREXIT:\n            monitorexit();\n            break;\n        default:\n            throw new IllegalArgumentException();\n        }\n    }\n\n    @Override\n    public void visitIntInsn(final int opcode, final int operand) {\n        switch (opcode) {\n        case Opcodes.BIPUSH:\n            iconst(operand);\n            break;\n        case Opcodes.SIPUSH:\n            iconst(operand);\n            break;\n        case Opcodes.NEWARRAY:\n            switch (operand) {\n            case Opcodes.T_BOOLEAN:\n                newarray(Type.BOOLEAN_TYPE);\n                break;\n            case Opcodes.T_CHAR:\n                newarray(Type.CHAR_TYPE);\n                break;\n            case Opcodes.T_BYTE:\n                newarray(Type.BYTE_TYPE);\n                break;\n            case Opcodes.T_SHORT:\n                newarray(Type.SHORT_TYPE);\n                break;\n            case Opcodes.T_INT:\n                newarray(Type.INT_TYPE);\n                break;\n            case Opcodes.T_FLOAT:\n                newarray(Type.FLOAT_TYPE);\n                break;\n            case Opcodes.T_LONG:\n                newarray(Type.LONG_TYPE);\n                break;\n            case Opcodes.T_DOUBLE:\n                newarray(Type.DOUBLE_TYPE);\n                break;\n            default:\n                throw new IllegalArgumentException();\n            }\n            break;\n        default:\n            throw new IllegalArgumentException();\n        }\n    }\n\n    @Override\n    public void visitVarInsn(final int opcode, final int var) {\n        switch (opcode) {\n        case Opcodes.ILOAD:\n            load(var, Type.INT_TYPE);\n            break;\n        case Opcodes.LLOAD:\n            load(var, Type.LONG_TYPE);\n            break;\n        case Opcodes.FLOAD:\n            load(var, Type.FLOAT_TYPE);\n            break;\n        case Opcodes.DLOAD:\n            load(var, Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.ALOAD:\n            load(var, OBJECT_TYPE);\n            break;\n        case Opcodes.ISTORE:\n            store(var, Type.INT_TYPE);\n            break;\n        case Opcodes.LSTORE:\n            store(var, Type.LONG_TYPE);\n            break;\n        case Opcodes.FSTORE:\n            store(var, Type.FLOAT_TYPE);\n            break;\n        case Opcodes.DSTORE:\n            store(var, Type.DOUBLE_TYPE);\n            break;\n        case Opcodes.ASTORE:\n            store(var, OBJECT_TYPE);\n            break;\n        case Opcodes.RET:\n            ret(var);\n            break;\n        default:\n            throw new IllegalArgumentException();\n        }\n    }\n\n    @Override\n    public void visitTypeInsn(final int opcode, final String type) {\n        Type t = Type.getObjectType(type);\n        switch (opcode) {\n        case Opcodes.NEW:\n            anew(t);\n            break;\n        case Opcodes.ANEWARRAY:\n            newarray(t);\n            break;\n        case Opcodes.CHECKCAST:\n            checkcast(t);\n            break;\n        case Opcodes.INSTANCEOF:\n            instanceOf(t);\n            break;\n        default:\n            throw new IllegalArgumentException();\n        }\n    }\n\n    @Override\n    public void visitFieldInsn(final int opcode, final String owner,\n            final String name, final String desc) {\n        switch (opcode) {\n        case Opcodes.GETSTATIC:\n            getstatic(owner, name, desc);\n            break;\n        case Opcodes.PUTSTATIC:\n            putstatic(owner, name, desc);\n            break;\n        case Opcodes.GETFIELD:\n            getfield(owner, name, desc);\n            break;\n        case Opcodes.PUTFIELD:\n            putfield(owner, name, desc);\n            break;\n        default:\n            throw new IllegalArgumentException();\n        }\n    }\n\n    @Override\n    public void visitMethodInsn(final int opcode, final String owner,\n            final String name, final String desc) {\n        switch (opcode) {\n        case Opcodes.INVOKESPECIAL:\n            invokespecial(owner, name, desc);\n            break;\n        case Opcodes.INVOKEVIRTUAL:\n            invokevirtual(owner, name, desc);\n            break;\n        case Opcodes.INVOKESTATIC:\n            invokestatic(owner, name, desc);\n            break;\n        case Opcodes.INVOKEINTERFACE:\n            invokeinterface(owner, name, desc);\n            break;\n        default:\n            throw new IllegalArgumentException();\n        }\n    }\n\n    @Override\n    public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,\n            Object... bsmArgs) {\n        invokedynamic(name, desc, bsm, bsmArgs);\n    }\n\n    @Override\n    public void visitJumpInsn(final int opcode, final Label label) {\n        switch (opcode) {\n        case Opcodes.IFEQ:\n            ifeq(label);\n            break;\n        case Opcodes.IFNE:\n            ifne(label);\n            break;\n        case Opcodes.IFLT:\n            iflt(label);\n            break;\n        case Opcodes.IFGE:\n            ifge(label);\n            break;\n        case Opcodes.IFGT:\n            ifgt(label);\n            break;\n        case Opcodes.IFLE:\n            ifle(label);\n            break;\n        case Opcodes.IF_ICMPEQ:\n            ificmpeq(label);\n            break;\n        case Opcodes.IF_ICMPNE:\n            ificmpne(label);\n            break;\n        case Opcodes.IF_ICMPLT:\n            ificmplt(label);\n            break;\n        case Opcodes.IF_ICMPGE:\n            ificmpge(label);\n            break;\n        case Opcodes.IF_ICMPGT:\n            ificmpgt(label);\n            break;\n        case Opcodes.IF_ICMPLE:\n            ificmple(label);\n            break;\n        case Opcodes.IF_ACMPEQ:\n            ifacmpeq(label);\n            break;\n        case Opcodes.IF_ACMPNE:\n            ifacmpne(label);\n            break;\n        case Opcodes.GOTO:\n            goTo(label);\n            break;\n        case Opcodes.JSR:\n            jsr(label);\n            break;\n        case Opcodes.IFNULL:\n            ifnull(label);\n            break;\n        case Opcodes.IFNONNULL:\n            ifnonnull(label);\n            break;\n        default:\n            throw new IllegalArgumentException();\n        }\n    }\n\n    @Override\n    public void visitLabel(final Label label) {\n        mark(label);\n    }\n\n    @Override\n    public void visitLdcInsn(final Object cst) {\n        if (cst instanceof Integer) {\n            int val = ((Integer) cst).intValue();\n            iconst(val);\n        } else if (cst instanceof Byte) {\n            int val = ((Byte) cst).intValue();\n            iconst(val);\n        } else if (cst instanceof Character) {\n            int val = ((Character) cst).charValue();\n            iconst(val);\n        } else if (cst instanceof Short) {\n            int val = ((Short) cst).intValue();\n            iconst(val);\n        } else if (cst instanceof Boolean) {\n            int val = ((Boolean) cst).booleanValue() ? 1 : 0;\n            iconst(val);\n        } else if (cst instanceof Float) {\n            float val = ((Float) cst).floatValue();\n            fconst(val);\n        } else if (cst instanceof Long) {\n            long val = ((Long) cst).longValue();\n            lconst(val);\n        } else if (cst instanceof Double) {\n            double val = ((Double) cst).doubleValue();\n            dconst(val);\n        } else if (cst instanceof String) {\n            aconst(cst);\n        } else if (cst instanceof Type) {\n            tconst((Type) cst);\n        } else if (cst instanceof Handle) {\n            hconst((Handle) cst);\n        } else {\n            throw new IllegalArgumentException();\n        }\n    }\n\n    @Override\n    public void visitIincInsn(final int var, final int increment) {\n        iinc(var, increment);\n    }\n\n    @Override\n    public void visitTableSwitchInsn(final int min, final int max,\n            final Label dflt, final Label... labels) {\n        tableswitch(min, max, dflt, labels);\n    }\n\n    @Override\n    public void visitLookupSwitchInsn(final Label dflt, final int[] keys,\n            final Label[] labels) {\n        lookupswitch(dflt, keys, labels);\n    }\n\n    @Override\n    public void visitMultiANewArrayInsn(final String desc, final int dims) {\n        multianewarray(desc, dims);\n    }\n\n    // -----------------------------------------------------------------------\n\n    public void nop() {\n        mv.visitInsn(Opcodes.NOP);\n    }\n\n    public void aconst(final Object cst) {\n        if (cst == null) {\n            mv.visitInsn(Opcodes.ACONST_NULL);\n        } else {\n            mv.visitLdcInsn(cst);\n        }\n    }\n\n    public void iconst(final int cst) {\n        if (cst >= -1 && cst <= 5) {\n            mv.visitInsn(Opcodes.ICONST_0 + cst);\n        } else if (cst >= Byte.MIN_VALUE && cst <= Byte.MAX_VALUE) {\n            mv.visitIntInsn(Opcodes.BIPUSH, cst);\n        } else if (cst >= Short.MIN_VALUE && cst <= Short.MAX_VALUE) {\n            mv.visitIntInsn(Opcodes.SIPUSH, cst);\n        } else {\n            mv.visitLdcInsn(new Integer(cst));\n        }\n    }\n\n    public void lconst(final long cst) {\n        if (cst == 0L || cst == 1L) {\n            mv.visitInsn(Opcodes.LCONST_0 + (int) cst);\n        } else {\n            mv.visitLdcInsn(new Long(cst));\n        }\n    }\n\n    public void fconst(final float cst) {\n        int bits = Float.floatToIntBits(cst);\n        if (bits == 0L || bits == 0x3f800000 || bits == 0x40000000) { // 0..2\n            mv.visitInsn(Opcodes.FCONST_0 + (int) cst);\n        } else {\n            mv.visitLdcInsn(new Float(cst));\n        }\n    }\n\n    public void dconst(final double cst) {\n        long bits = Double.doubleToLongBits(cst);\n        if (bits == 0L || bits == 0x3ff0000000000000L) { // +0.0d and 1.0d\n            mv.visitInsn(Opcodes.DCONST_0 + (int) cst);\n        } else {\n            mv.visitLdcInsn(new Double(cst));\n        }\n    }\n\n    public void tconst(final Type type) {\n        mv.visitLdcInsn(type);\n    }\n\n    public void hconst(final Handle handle) {\n        mv.visitLdcInsn(handle);\n    }\n\n    public void load(final int var, final Type type) {\n        mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), var);\n    }\n\n    public void aload(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.IALOAD));\n    }\n\n    public void store(final int var, final Type type) {\n        mv.visitVarInsn(type.getOpcode(Opcodes.ISTORE), var);\n    }\n\n    public void astore(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.IASTORE));\n    }\n\n    public void pop() {\n        mv.visitInsn(Opcodes.POP);\n    }\n\n    public void pop2() {\n        mv.visitInsn(Opcodes.POP2);\n    }\n\n    public void dup() {\n        mv.visitInsn(Opcodes.DUP);\n    }\n\n    public void dup2() {\n        mv.visitInsn(Opcodes.DUP2);\n    }\n\n    public void dupX1() {\n        mv.visitInsn(Opcodes.DUP_X1);\n    }\n\n    public void dupX2() {\n        mv.visitInsn(Opcodes.DUP_X2);\n    }\n\n    public void dup2X1() {\n        mv.visitInsn(Opcodes.DUP2_X1);\n    }\n\n    public void dup2X2() {\n        mv.visitInsn(Opcodes.DUP2_X2);\n    }\n\n    public void swap() {\n        mv.visitInsn(Opcodes.SWAP);\n    }\n\n    public void add(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.IADD));\n    }\n\n    public void sub(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.ISUB));\n    }\n\n    public void mul(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.IMUL));\n    }\n\n    public void div(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.IDIV));\n    }\n\n    public void rem(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.IREM));\n    }\n\n    public void neg(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.INEG));\n    }\n\n    public void shl(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.ISHL));\n    }\n\n    public void shr(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.ISHR));\n    }\n\n    public void ushr(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.IUSHR));\n    }\n\n    public void and(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.IAND));\n    }\n\n    public void or(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.IOR));\n    }\n\n    public void xor(final Type type) {\n        mv.visitInsn(type.getOpcode(Opcodes.IXOR));\n    }\n\n    public void iinc(final int var, final int increment) {\n        mv.visitIincInsn(var, increment);\n    }\n\n    public void cast(final Type from, final Type to) {\n        if (from != to) {\n            if (from == Type.DOUBLE_TYPE) {\n                if (to == Type.FLOAT_TYPE) {\n                    mv.visitInsn(Opcodes.D2F);\n                } else if (to == Type.LONG_TYPE) {\n                    mv.visitInsn(Opcodes.D2L);\n                } else {\n                    mv.visitInsn(Opcodes.D2I);\n                    cast(Type.INT_TYPE, to);\n                }\n            } else if (from == Type.FLOAT_TYPE) {\n                if (to == Type.DOUBLE_TYPE) {\n                    mv.visitInsn(Opcodes.F2D);\n                } else if (to == Type.LONG_TYPE) {\n                    mv.visitInsn(Opcodes.F2L);\n                } else {\n                    mv.visitInsn(Opcodes.F2I);\n                    cast(Type.INT_TYPE, to);\n                }\n            } else if (from == Type.LONG_TYPE) {\n                if (to == Type.DOUBLE_TYPE) {\n                    mv.visitInsn(Opcodes.L2D);\n                } else if (to == Type.FLOAT_TYPE) {\n                    mv.visitInsn(Opcodes.L2F);\n                } else {\n                    mv.visitInsn(Opcodes.L2I);\n                    cast(Type.INT_TYPE, to);\n                }\n            } else {\n                if (to == Type.BYTE_TYPE) {\n                    mv.visitInsn(Opcodes.I2B);\n                } else if (to == Type.CHAR_TYPE) {\n                    mv.visitInsn(Opcodes.I2C);\n                } else if (to == Type.DOUBLE_TYPE) {\n                    mv.visitInsn(Opcodes.I2D);\n                } else if (to == Type.FLOAT_TYPE) {\n                    mv.visitInsn(Opcodes.I2F);\n                } else if (to == Type.LONG_TYPE) {\n                    mv.visitInsn(Opcodes.I2L);\n                } else if (to == Type.SHORT_TYPE) {\n                    mv.visitInsn(Opcodes.I2S);\n                }\n            }\n        }\n    }\n\n    public void lcmp() {\n        mv.visitInsn(Opcodes.LCMP);\n    }\n\n    public void cmpl(final Type type) {\n        mv.visitInsn(type == Type.FLOAT_TYPE ? Opcodes.FCMPL : Opcodes.DCMPL);\n    }\n\n    public void cmpg(final Type type) {\n        mv.visitInsn(type == Type.FLOAT_TYPE ? Opcodes.FCMPG : Opcodes.DCMPG);\n    }\n\n    public void ifeq(final Label label) {\n        mv.visitJumpInsn(Opcodes.IFEQ, label);\n    }\n\n    public void ifne(final Label label) {\n        mv.visitJumpInsn(Opcodes.IFNE, label);\n    }\n\n    public void iflt(final Label label) {\n        mv.visitJumpInsn(Opcodes.IFLT, label);\n    }\n\n    public void ifge(final Label label) {\n        mv.visitJumpInsn(Opcodes.IFGE, label);\n    }\n\n    public void ifgt(final Label label) {\n        mv.visitJumpInsn(Opcodes.IFGT, label);\n    }\n\n    public void ifle(final Label label) {\n        mv.visitJumpInsn(Opcodes.IFLE, label);\n    }\n\n    public void ificmpeq(final Label label) {\n        mv.visitJumpInsn(Opcodes.IF_ICMPEQ, label);\n    }\n\n    public void ificmpne(final Label label) {\n        mv.visitJumpInsn(Opcodes.IF_ICMPNE, label);\n    }\n\n    public void ificmplt(final Label label) {\n        mv.visitJumpInsn(Opcodes.IF_ICMPLT, label);\n    }\n\n    public void ificmpge(final Label label) {\n        mv.visitJumpInsn(Opcodes.IF_ICMPGE, label);\n    }\n\n    public void ificmpgt(final Label label) {\n        mv.visitJumpInsn(Opcodes.IF_ICMPGT, label);\n    }\n\n    public void ificmple(final Label label) {\n        mv.visitJumpInsn(Opcodes.IF_ICMPLE, label);\n    }\n\n    public void ifacmpeq(final Label label) {\n        mv.visitJumpInsn(Opcodes.IF_ACMPEQ, label);\n    }\n\n    public void ifacmpne(final Label label) {\n        mv.visitJumpInsn(Opcodes.IF_ACMPNE, label);\n    }\n\n    public void goTo(final Label label) {\n        mv.visitJumpInsn(Opcodes.GOTO, label);\n    }\n\n    public void jsr(final Label label) {\n        mv.visitJumpInsn(Opcodes.JSR, label);\n    }\n\n    public void ret(final int var) {\n        mv.visitVarInsn(Opcodes.RET, var);\n    }\n\n    public void tableswitch(final int min, final int max, final Label dflt,\n            final Label... labels) {\n        mv.visitTableSwitchInsn(min, max, dflt, labels);\n    }\n\n    public void lookupswitch(final Label dflt, final int[] keys,\n            final Label[] labels) {\n        mv.visitLookupSwitchInsn(dflt, keys, labels);\n    }\n\n    public void areturn(final Type t) {\n        mv.visitInsn(t.getOpcode(Opcodes.IRETURN));\n    }\n\n    public void getstatic(final String owner, final String name,\n            final String desc) {\n        mv.visitFieldInsn(Opcodes.GETSTATIC, owner, name, desc);\n    }\n\n    public void putstatic(final String owner, final String name,\n            final String desc) {\n        mv.visitFieldInsn(Opcodes.PUTSTATIC, owner, name, desc);\n    }\n\n    public void getfield(final String owner, final String name,\n            final String desc) {\n        mv.visitFieldInsn(Opcodes.GETFIELD, owner, name, desc);\n    }\n\n    public void putfield(final String owner, final String name,\n            final String desc) {\n        mv.visitFieldInsn(Opcodes.PUTFIELD, owner, name, desc);\n    }\n\n    public void invokevirtual(final String owner, final String name,\n            final String desc) {\n        mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, desc);\n    }\n\n    public void invokespecial(final String owner, final String name,\n            final String desc) {\n        mv.visitMethodInsn(Opcodes.INVOKESPECIAL, owner, name, desc);\n    }\n\n    public void invokestatic(final String owner, final String name,\n            final String desc) {\n        mv.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name, desc);\n    }\n\n    public void invokeinterface(final String owner, final String name,\n            final String desc) {\n        mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, owner, name, desc);\n    }\n\n    public void invokedynamic(String name, String desc, Handle bsm,\n            Object[] bsmArgs) {\n        mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);\n    }\n\n    public void anew(final Type type) {\n        mv.visitTypeInsn(Opcodes.NEW, type.getInternalName());\n    }\n\n    public void newarray(final Type type) {\n        int typ;\n        switch (type.getSort()) {\n        case Type.BOOLEAN:\n            typ = Opcodes.T_BOOLEAN;\n            break;\n        case Type.CHAR:\n            typ = Opcodes.T_CHAR;\n            break;\n        case Type.BYTE:\n            typ = Opcodes.T_BYTE;\n            break;\n        case Type.SHORT:\n            typ = Opcodes.T_SHORT;\n            break;\n        case Type.INT:\n            typ = Opcodes.T_INT;\n            break;\n        case Type.FLOAT:\n            typ = Opcodes.T_FLOAT;\n            break;\n        case Type.LONG:\n            typ = Opcodes.T_LONG;\n            break;\n        case Type.DOUBLE:\n            typ = Opcodes.T_DOUBLE;\n            break;\n        default:\n            mv.visitTypeInsn(Opcodes.ANEWARRAY, type.getInternalName());\n            return;\n        }\n        mv.visitIntInsn(Opcodes.NEWARRAY, typ);\n    }\n\n    public void arraylength() {\n        mv.visitInsn(Opcodes.ARRAYLENGTH);\n    }\n\n    public void athrow() {\n        mv.visitInsn(Opcodes.ATHROW);\n    }\n\n    public void checkcast(final Type type) {\n        mv.visitTypeInsn(Opcodes.CHECKCAST, type.getInternalName());\n    }\n\n    public void instanceOf(final Type type) {\n        mv.visitTypeInsn(Opcodes.INSTANCEOF, type.getInternalName());\n    }\n\n    public void monitorenter() {\n        mv.visitInsn(Opcodes.MONITORENTER);\n    }\n\n    public void monitorexit() {\n        mv.visitInsn(Opcodes.MONITOREXIT);\n    }\n\n    public void multianewarray(final String desc, final int dims) {\n        mv.visitMultiANewArrayInsn(desc, dims);\n    }\n\n    public void ifnull(final Label label) {\n        mv.visitJumpInsn(Opcodes.IFNULL, label);\n    }\n\n    public void ifnonnull(final Label label) {\n        mv.visitJumpInsn(Opcodes.IFNONNULL, label);\n    }\n\n    public void mark(final Label label) {\n        mv.visitLabel(label);\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/commons/LocalVariablesSorter.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm.commons;\n\nimport clojure.asm.Label;\nimport clojure.asm.MethodVisitor;\nimport clojure.asm.Opcodes;\nimport clojure.asm.Type;\n\n/**\n * A {@link MethodVisitor} that renumbers local variables in their order of\n * appearance. This adapter allows one to easily add new local variables to a\n * method. It may be used by inheriting from this class, but the preferred way\n * of using it is via delegation: the next visitor in the chain can indeed add\n * new locals when needed by calling {@link #newLocal} on this adapter (this\n * requires a reference back to this {@link LocalVariablesSorter}).\n *\n * @author Chris Nokleberg\n * @author Eugene Kuleshov\n * @author Eric Bruneton\n */\npublic class LocalVariablesSorter extends MethodVisitor {\n\n    private static final Type OBJECT_TYPE = Type\n            .getObjectType(\"java/lang/Object\");\n\n    /**\n     * Mapping from old to new local variable indexes. A local variable at index\n     * i of size 1 is remapped to 'mapping[2*i]', while a local variable at\n     * index i of size 2 is remapped to 'mapping[2*i+1]'.\n     */\n    private int[] mapping = new int[40];\n\n    /**\n     * Array used to store stack map local variable types after remapping.\n     */\n    private Object[] newLocals = new Object[20];\n\n    /**\n     * Index of the first local variable, after formal parameters.\n     */\n    protected final int firstLocal;\n\n    /**\n     * Index of the next local variable to be created by {@link #newLocal}.\n     */\n    protected int nextLocal;\n\n    /**\n     * Indicates if at least one local variable has moved due to remapping.\n     */\n    private boolean changed;\n\n    /**\n     * Creates a new {@link LocalVariablesSorter}. <i>Subclasses must not use\n     * this constructor</i>. Instead, they must use the\n     * {@link #LocalVariablesSorter(int, int, String, MethodVisitor)} version.\n     *\n     * @param access\n     *            access flags of the adapted method.\n     * @param desc\n     *            the method's descriptor (see {@link Type Type}).\n     * @param mv\n     *            the method visitor to which this adapter delegates calls.\n     */\n    public LocalVariablesSorter(final int access, final String desc,\n            final MethodVisitor mv) {\n        this(Opcodes.ASM4, access, desc, mv);\n    }\n\n    /**\n     * Creates a new {@link LocalVariablesSorter}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     * @param access\n     *            access flags of the adapted method.\n     * @param desc\n     *            the method's descriptor (see {@link Type Type}).\n     * @param mv\n     *            the method visitor to which this adapter delegates calls.\n     */\n    protected LocalVariablesSorter(final int api, final int access,\n            final String desc, final MethodVisitor mv) {\n        super(api, mv);\n        Type[] args = Type.getArgumentTypes(desc);\n        nextLocal = (Opcodes.ACC_STATIC & access) == 0 ? 1 : 0;\n        for (int i = 0; i < args.length; i++) {\n            nextLocal += args[i].getSize();\n        }\n        firstLocal = nextLocal;\n    }\n\n    @Override\n    public void visitVarInsn(final int opcode, final int var) {\n        Type type;\n        switch (opcode) {\n        case Opcodes.LLOAD:\n        case Opcodes.LSTORE:\n            type = Type.LONG_TYPE;\n            break;\n\n        case Opcodes.DLOAD:\n        case Opcodes.DSTORE:\n            type = Type.DOUBLE_TYPE;\n            break;\n\n        case Opcodes.FLOAD:\n        case Opcodes.FSTORE:\n            type = Type.FLOAT_TYPE;\n            break;\n\n        case Opcodes.ILOAD:\n        case Opcodes.ISTORE:\n            type = Type.INT_TYPE;\n            break;\n\n        default:\n            // case Opcodes.ALOAD:\n            // case Opcodes.ASTORE:\n            // case RET:\n            type = OBJECT_TYPE;\n            break;\n        }\n        mv.visitVarInsn(opcode, remap(var, type));\n    }\n\n    @Override\n    public void visitIincInsn(final int var, final int increment) {\n        mv.visitIincInsn(remap(var, Type.INT_TYPE), increment);\n    }\n\n    @Override\n    public void visitMaxs(final int maxStack, final int maxLocals) {\n        mv.visitMaxs(maxStack, nextLocal);\n    }\n\n    @Override\n    public void visitLocalVariable(final String name, final String desc,\n            final String signature, final Label start, final Label end,\n            final int index) {\n        int newIndex = remap(index, Type.getType(desc));\n        mv.visitLocalVariable(name, desc, signature, start, end, newIndex);\n    }\n\n    @Override\n    public void visitFrame(final int type, final int nLocal,\n            final Object[] local, final int nStack, final Object[] stack) {\n        if (type != Opcodes.F_NEW) { // uncompressed frame\n            throw new IllegalStateException(\n                    \"ClassReader.accept() should be called with EXPAND_FRAMES flag\");\n        }\n\n        if (!changed) { // optimization for the case where mapping = identity\n            mv.visitFrame(type, nLocal, local, nStack, stack);\n            return;\n        }\n\n        // creates a copy of newLocals\n        Object[] oldLocals = new Object[newLocals.length];\n        System.arraycopy(newLocals, 0, oldLocals, 0, oldLocals.length);\n\n        updateNewLocals(newLocals);\n\n        // copies types from 'local' to 'newLocals'\n        // 'newLocals' already contains the variables added with 'newLocal'\n\n        int index = 0; // old local variable index\n        int number = 0; // old local variable number\n        for (; number < nLocal; ++number) {\n            Object t = local[number];\n            int size = t == Opcodes.LONG || t == Opcodes.DOUBLE ? 2 : 1;\n            if (t != Opcodes.TOP) {\n                Type typ = OBJECT_TYPE;\n                if (t == Opcodes.INTEGER) {\n                    typ = Type.INT_TYPE;\n                } else if (t == Opcodes.FLOAT) {\n                    typ = Type.FLOAT_TYPE;\n                } else if (t == Opcodes.LONG) {\n                    typ = Type.LONG_TYPE;\n                } else if (t == Opcodes.DOUBLE) {\n                    typ = Type.DOUBLE_TYPE;\n                } else if (t instanceof String) {\n                    typ = Type.getObjectType((String) t);\n                }\n                setFrameLocal(remap(index, typ), t);\n            }\n            index += size;\n        }\n\n        // removes TOP after long and double types as well as trailing TOPs\n\n        index = 0;\n        number = 0;\n        for (int i = 0; index < newLocals.length; ++i) {\n            Object t = newLocals[index++];\n            if (t != null && t != Opcodes.TOP) {\n                newLocals[i] = t;\n                number = i + 1;\n                if (t == Opcodes.LONG || t == Opcodes.DOUBLE) {\n                    index += 1;\n                }\n            } else {\n                newLocals[i] = Opcodes.TOP;\n            }\n        }\n\n        // visits remapped frame\n        mv.visitFrame(type, number, newLocals, nStack, stack);\n\n        // restores original value of 'newLocals'\n        newLocals = oldLocals;\n    }\n\n    // -------------\n\n    /**\n     * Creates a new local variable of the given type.\n     *\n     * @param type\n     *            the type of the local variable to be created.\n     * @return the identifier of the newly created local variable.\n     */\n    public int newLocal(final Type type) {\n        Object t;\n        switch (type.getSort()) {\n        case Type.BOOLEAN:\n        case Type.CHAR:\n        case Type.BYTE:\n        case Type.SHORT:\n        case Type.INT:\n            t = Opcodes.INTEGER;\n            break;\n        case Type.FLOAT:\n            t = Opcodes.FLOAT;\n            break;\n        case Type.LONG:\n            t = Opcodes.LONG;\n            break;\n        case Type.DOUBLE:\n            t = Opcodes.DOUBLE;\n            break;\n        case Type.ARRAY:\n            t = type.getDescriptor();\n            break;\n        // case Type.OBJECT:\n        default:\n            t = type.getInternalName();\n            break;\n        }\n        int local = newLocalMapping(type);\n        setLocalType(local, type);\n        setFrameLocal(local, t);\n        return local;\n    }\n\n    /**\n     * Notifies subclasses that a new stack map frame is being visited. The\n     * array argument contains the stack map frame types corresponding to the\n     * local variables added with {@link #newLocal}. This method can update\n     * these types in place for the stack map frame being visited. The default\n     * implementation of this method does nothing, i.e. a local variable added\n     * with {@link #newLocal} will have the same type in all stack map frames.\n     * But this behavior is not always the desired one, for instance if a local\n     * variable is added in the middle of a try/catch block: the frame for the\n     * exception handler should have a TOP type for this new local.\n     *\n     * @param newLocals\n     *            the stack map frame types corresponding to the local variables\n     *            added with {@link #newLocal} (and null for the others). The\n     *            format of this array is the same as in\n     *            {@link MethodVisitor#visitFrame}, except that long and double\n     *            types use two slots. The types for the current stack map frame\n     *            must be updated in place in this array.\n     */\n    protected void updateNewLocals(Object[] newLocals) {\n    }\n\n    /**\n     * Notifies subclasses that a local variable has been added or remapped. The\n     * default implementation of this method does nothing.\n     *\n     * @param local\n     *            a local variable identifier, as returned by {@link #newLocal\n     *            newLocal()}.\n     * @param type\n     *            the type of the value being stored in the local variable.\n     */\n    protected void setLocalType(final int local, final Type type) {\n    }\n\n    private void setFrameLocal(final int local, final Object type) {\n        int l = newLocals.length;\n        if (local >= l) {\n            Object[] a = new Object[Math.max(2 * l, local + 1)];\n            System.arraycopy(newLocals, 0, a, 0, l);\n            newLocals = a;\n        }\n        newLocals[local] = type;\n    }\n\n    private int remap(final int var, final Type type) {\n        if (var + type.getSize() <= firstLocal) {\n            return var;\n        }\n        int key = 2 * var + type.getSize() - 1;\n        int size = mapping.length;\n        if (key >= size) {\n            int[] newMapping = new int[Math.max(2 * size, key + 1)];\n            System.arraycopy(mapping, 0, newMapping, 0, size);\n            mapping = newMapping;\n        }\n        int value = mapping[key];\n        if (value == 0) {\n            value = newLocalMapping(type);\n            setLocalType(value, type);\n            mapping[key] = value + 1;\n        } else {\n            value--;\n        }\n        if (value != var) {\n            changed = true;\n        }\n        return value;\n    }\n\n    protected int newLocalMapping(final Type type) {\n        int local = nextLocal;\n        nextLocal += type.getSize();\n        return local;\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/commons/Method.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm.commons;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport clojure.asm.Type;\n\n/**\n * A named method descriptor.\n *\n * @author Juozas Baliuka\n * @author Chris Nokleberg\n * @author Eric Bruneton\n */\npublic class Method {\n\n    /**\n     * The method name.\n     */\n    private final String name;\n\n    /**\n     * The method descriptor.\n     */\n    private final String desc;\n\n    /**\n     * Maps primitive Java type names to their descriptors.\n     */\n    private static final Map<String, String> DESCRIPTORS;\n\n    static {\n        DESCRIPTORS = new HashMap<String, String>();\n        DESCRIPTORS.put(\"void\", \"V\");\n        DESCRIPTORS.put(\"byte\", \"B\");\n        DESCRIPTORS.put(\"char\", \"C\");\n        DESCRIPTORS.put(\"double\", \"D\");\n        DESCRIPTORS.put(\"float\", \"F\");\n        DESCRIPTORS.put(\"int\", \"I\");\n        DESCRIPTORS.put(\"long\", \"J\");\n        DESCRIPTORS.put(\"short\", \"S\");\n        DESCRIPTORS.put(\"boolean\", \"Z\");\n    }\n\n    /**\n     * Creates a new {@link Method}.\n     *\n     * @param name\n     *            the method's name.\n     * @param desc\n     *            the method's descriptor.\n     */\n    public Method(final String name, final String desc) {\n        this.name = name;\n        this.desc = desc;\n    }\n\n    /**\n     * Creates a new {@link Method}.\n     *\n     * @param name\n     *            the method's name.\n     * @param returnType\n     *            the method's return type.\n     * @param argumentTypes\n     *            the method's argument types.\n     */\n    public Method(final String name, final Type returnType,\n            final Type[] argumentTypes) {\n        this(name, Type.getMethodDescriptor(returnType, argumentTypes));\n    }\n\n    /**\n     * Creates a new {@link Method}.\n     *\n     * @param m\n     *            a java.lang.reflect method descriptor\n     * @return a {@link Method} corresponding to the given Java method\n     *         declaration.\n     */\n    public static Method getMethod(java.lang.reflect.Method m) {\n        return new Method(m.getName(), Type.getMethodDescriptor(m));\n    }\n\n    /**\n     * Creates a new {@link Method}.\n     *\n     * @param c\n     *            a java.lang.reflect constructor descriptor\n     * @return a {@link Method} corresponding to the given Java constructor\n     *         declaration.\n     */\n    public static Method getMethod(java.lang.reflect.Constructor<?> c) {\n        return new Method(\"<init>\", Type.getConstructorDescriptor(c));\n    }\n\n    /**\n     * Returns a {@link Method} corresponding to the given Java method\n     * declaration.\n     *\n     * @param method\n     *            a Java method declaration, without argument names, of the form\n     *            \"returnType name (argumentType1, ... argumentTypeN)\", where\n     *            the types are in plain Java (e.g. \"int\", \"float\",\n     *            \"java.util.List\", ...). Classes of the java.lang package can\n     *            be specified by their unqualified name; all other classes\n     *            names must be fully qualified.\n     * @return a {@link Method} corresponding to the given Java method\n     *         declaration.\n     * @throws IllegalArgumentException\n     *             if <code>method</code> could not get parsed.\n     */\n    public static Method getMethod(final String method)\n            throws IllegalArgumentException {\n        return getMethod(method, false);\n    }\n\n    /**\n     * Returns a {@link Method} corresponding to the given Java method\n     * declaration.\n     *\n     * @param method\n     *            a Java method declaration, without argument names, of the form\n     *            \"returnType name (argumentType1, ... argumentTypeN)\", where\n     *            the types are in plain Java (e.g. \"int\", \"float\",\n     *            \"java.util.List\", ...). Classes of the java.lang package may\n     *            be specified by their unqualified name, depending on the\n     *            defaultPackage argument; all other classes names must be fully\n     *            qualified.\n     * @param defaultPackage\n     *            true if unqualified class names belong to the default package,\n     *            or false if they correspond to java.lang classes. For instance\n     *            \"Object\" means \"Object\" if this option is true, or\n     *            \"java.lang.Object\" otherwise.\n     * @return a {@link Method} corresponding to the given Java method\n     *         declaration.\n     * @throws IllegalArgumentException\n     *             if <code>method</code> could not get parsed.\n     */\n    public static Method getMethod(final String method,\n            final boolean defaultPackage) throws IllegalArgumentException {\n        int space = method.indexOf(' ');\n        int start = method.indexOf('(', space) + 1;\n        int end = method.indexOf(')', start);\n        if (space == -1 || start == -1 || end == -1) {\n            throw new IllegalArgumentException();\n        }\n        String returnType = method.substring(0, space);\n        String methodName = method.substring(space + 1, start - 1).trim();\n        StringBuffer sb = new StringBuffer();\n        sb.append('(');\n        int p;\n        do {\n            String s;\n            p = method.indexOf(',', start);\n            if (p == -1) {\n                s = map(method.substring(start, end).trim(), defaultPackage);\n            } else {\n                s = map(method.substring(start, p).trim(), defaultPackage);\n                start = p + 1;\n            }\n            sb.append(s);\n        } while (p != -1);\n        sb.append(')');\n        sb.append(map(returnType, defaultPackage));\n        return new Method(methodName, sb.toString());\n    }\n\n    private static String map(final String type, final boolean defaultPackage) {\n        if (\"\".equals(type)) {\n            return type;\n        }\n\n        StringBuffer sb = new StringBuffer();\n        int index = 0;\n        while ((index = type.indexOf(\"[]\", index) + 1) > 0) {\n            sb.append('[');\n        }\n\n        String t = type.substring(0, type.length() - sb.length() * 2);\n        String desc = DESCRIPTORS.get(t);\n        if (desc != null) {\n            sb.append(desc);\n        } else {\n            sb.append('L');\n            if (t.indexOf('.') < 0) {\n                if (!defaultPackage) {\n                    sb.append(\"java/lang/\");\n                }\n                sb.append(t);\n            } else {\n                sb.append(t.replace('.', '/'));\n            }\n            sb.append(';');\n        }\n        return sb.toString();\n    }\n\n    /**\n     * Returns the name of the method described by this object.\n     *\n     * @return the name of the method described by this object.\n     */\n    public String getName() {\n        return name;\n    }\n\n    /**\n     * Returns the descriptor of the method described by this object.\n     *\n     * @return the descriptor of the method described by this object.\n     */\n    public String getDescriptor() {\n        return desc;\n    }\n\n    /**\n     * Returns the return type of the method described by this object.\n     *\n     * @return the return type of the method described by this object.\n     */\n    public Type getReturnType() {\n        return Type.getReturnType(desc);\n    }\n\n    /**\n     * Returns the argument types of the method described by this object.\n     *\n     * @return the argument types of the method described by this object.\n     */\n    public Type[] getArgumentTypes() {\n        return Type.getArgumentTypes(desc);\n    }\n\n    @Override\n    public String toString() {\n        return name + desc;\n    }\n\n    @Override\n    public boolean equals(final Object o) {\n        if (!(o instanceof Method)) {\n            return false;\n        }\n        Method other = (Method) o;\n        return name.equals(other.name) && desc.equals(other.desc);\n    }\n\n    @Override\n    public int hashCode() {\n        return name.hashCode() ^ desc.hashCode();\n    }\n}"
  },
  {
    "path": "src/jvm/clojure/asm/commons/SerialVersionUIDAdder.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm.commons;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.DataOutput;\nimport java.io.DataOutputStream;\nimport java.io.IOException;\nimport java.security.MessageDigest;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\n\nimport clojure.asm.ClassVisitor;\nimport clojure.asm.FieldVisitor;\nimport clojure.asm.MethodVisitor;\nimport clojure.asm.Opcodes;\nimport clojure.lang.Reflector;\n\n/**\n * A {@link ClassVisitor} that adds a serial version unique identifier to a\n * class if missing. Here is typical usage of this class:\n *\n * <pre>\n *   ClassWriter cw = new ClassWriter(...);\n *   ClassVisitor sv = new SerialVersionUIDAdder(cw);\n *   ClassVisitor ca = new MyClassAdapter(sv);\n *   new ClassReader(orginalClass).accept(ca, false);\n * </pre>\n *\n * The SVUID algorithm can be found <a href=\n * \"http://java.sun.com/j2se/1.4.2/docs/guide/serialization/spec/class.html\"\n * >http://java.sun.com/j2se/1.4.2/docs/guide/serialization/spec/class.html</a>:\n *\n * <pre>\n * The serialVersionUID is computed using the signature of a stream of bytes\n * that reflect the class definition. The National Institute of Standards and\n * Technology (NIST) Secure Hash Algorithm (SHA-1) is used to compute a\n * signature for the stream. The first two 32-bit quantities are used to form a\n * 64-bit hash. A java.lang.DataOutputStream is used to convert primitive data\n * types to a sequence of bytes. The values input to the stream are defined by\n * the Java Virtual Machine (VM) specification for classes.\n *\n * The sequence of items in the stream is as follows:\n *\n * 1. The class name written using UTF encoding.\n * 2. The class modifiers written as a 32-bit integer.\n * 3. The name of each interface sorted by name written using UTF encoding.\n * 4. For each field of the class sorted by field name (except private static\n * and private transient fields):\n * 1. The name of the field in UTF encoding.\n * 2. The modifiers of the field written as a 32-bit integer.\n * 3. The descriptor of the field in UTF encoding\n * 5. If a class initializer exists, write out the following:\n * 1. The name of the method, &lt;clinit&gt;, in UTF encoding.\n * 2. The modifier of the method, java.lang.reflect.Modifier.STATIC,\n * written as a 32-bit integer.\n * 3. The descriptor of the method, ()V, in UTF encoding.\n * 6. For each non-private constructor sorted by method name and signature:\n * 1. The name of the method, &lt;init&gt;, in UTF encoding.\n * 2. The modifiers of the method written as a 32-bit integer.\n * 3. The descriptor of the method in UTF encoding.\n * 7. For each non-private method sorted by method name and signature:\n * 1. The name of the method in UTF encoding.\n * 2. The modifiers of the method written as a 32-bit integer.\n * 3. The descriptor of the method in UTF encoding.\n * 8. The SHA-1 algorithm is executed on the stream of bytes produced by\n * DataOutputStream and produces five 32-bit values sha[0..4].\n *\n * 9. The hash value is assembled from the first and second 32-bit values of\n * the SHA-1 message digest. If the result of the message digest, the five\n * 32-bit words H0 H1 H2 H3 H4, is in an array of five int values named\n * sha, the hash value would be computed as follows:\n *\n * long hash = ((sha[0] &gt;&gt;&gt; 24) &amp; 0xFF) |\n * ((sha[0] &gt;&gt;&gt; 16) &amp; 0xFF) &lt;&lt; 8 |\n * ((sha[0] &gt;&gt;&gt; 8) &amp; 0xFF) &lt;&lt; 16 |\n * ((sha[0] &gt;&gt;&gt; 0) &amp; 0xFF) &lt;&lt; 24 |\n * ((sha[1] &gt;&gt;&gt; 24) &amp; 0xFF) &lt;&lt; 32 |\n * ((sha[1] &gt;&gt;&gt; 16) &amp; 0xFF) &lt;&lt; 40 |\n * ((sha[1] &gt;&gt;&gt; 8) &amp; 0xFF) &lt;&lt; 48 |\n * ((sha[1] &gt;&gt;&gt; 0) &amp; 0xFF) &lt;&lt; 56;\n * </pre>\n *\n * @author Rajendra Inamdar, Vishal Vishnoi\n */\npublic class SerialVersionUIDAdder extends ClassVisitor {\n\n    /**\n     * Flag that indicates if we need to compute SVUID.\n     */\n    private boolean computeSVUID;\n\n    /**\n     * Set to true if the class already has SVUID.\n     */\n    private boolean hasSVUID;\n\n    /**\n     * Classes access flags.\n     */\n    private int access;\n\n    /**\n     * Internal name of the class\n     */\n    private String name;\n\n    /**\n     * Interfaces implemented by the class.\n     */\n    private String[] interfaces;\n\n    /**\n     * Collection of fields. (except private static and private transient\n     * fields)\n     */\n    private Collection<Item> svuidFields;\n\n    /**\n     * Set to true if the class has static initializer.\n     */\n    private boolean hasStaticInitializer;\n\n    /**\n     * Collection of non-private constructors.\n     */\n    private Collection<Item> svuidConstructors;\n\n    /**\n     * Collection of non-private methods.\n     */\n    private Collection<Item> svuidMethods;\n\n    /**\n     * Creates a new {@link SerialVersionUIDAdder}. <i>Subclasses must not use\n     * this constructor</i>. Instead, they must use the\n     * {@link #SerialVersionUIDAdder(int, ClassVisitor)} version.\n     *\n     * @param cv\n     *            a {@link ClassVisitor} to which this visitor will delegate\n     *            calls.\n     */\n    public SerialVersionUIDAdder(final ClassVisitor cv) {\n        this(Opcodes.ASM4, cv);\n    }\n\n    /**\n     * Creates a new {@link SerialVersionUIDAdder}.\n     *\n     * @param api\n     *            the ASM API version implemented by this visitor. Must be one\n     *            of {@link Opcodes#ASM4}.\n     * @param cv\n     *            a {@link ClassVisitor} to which this visitor will delegate\n     *            calls.\n     */\n    protected SerialVersionUIDAdder(final int api, final ClassVisitor cv) {\n        super(api, cv);\n        svuidFields = new ArrayList<Item>();\n        svuidConstructors = new ArrayList<Item>();\n        svuidMethods = new ArrayList<Item>();\n    }\n\n    // ------------------------------------------------------------------------\n    // Overriden methods\n    // ------------------------------------------------------------------------\n\n    /*\n     * Visit class header and get class name, access , and interfaces\n     * information (step 1,2, and 3) for SVUID computation.\n     */\n    @Override\n    public void visit(final int version, final int access, final String name,\n            final String signature, final String superName,\n            final String[] interfaces) {\n        computeSVUID = (access & Opcodes.ACC_INTERFACE) == 0;\n\n        if (computeSVUID) {\n            this.name = name;\n            this.access = access;\n            this.interfaces = interfaces;\n        }\n\n        super.visit(version, access, name, signature, superName, interfaces);\n    }\n\n    /*\n     * Visit the methods and get constructor and method information (step 5 and\n     * 7). Also determine if there is a class initializer (step 6).\n     */\n    @Override\n    public MethodVisitor visitMethod(final int access, final String name,\n            final String desc, final String signature, final String[] exceptions) {\n        if (computeSVUID) {\n            if (\"<clinit>\".equals(name)) {\n                hasStaticInitializer = true;\n            }\n            /*\n             * Remembers non private constructors and methods for SVUID\n             * computation For constructor and method modifiers, only the\n             * ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,\n             * ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT and ACC_STRICT flags\n             * are used.\n             */\n            int mods = access\n                    & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE\n                            | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC\n                            | Opcodes.ACC_FINAL | Opcodes.ACC_SYNCHRONIZED\n                            | Opcodes.ACC_NATIVE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_STRICT);\n\n            // all non private methods\n            if ((access & Opcodes.ACC_PRIVATE) == 0) {\n                if (\"<init>\".equals(name)) {\n                    svuidConstructors.add(new Item(name, mods, desc));\n                } else if (!\"<clinit>\".equals(name)) {\n                    svuidMethods.add(new Item(name, mods, desc));\n                }\n            }\n        }\n\n        return super.visitMethod(access, name, desc, signature, exceptions);\n    }\n\n    /*\n     * Gets class field information for step 4 of the algorithm. Also determines\n     * if the class already has a SVUID.\n     */\n    @Override\n    public FieldVisitor visitField(final int access, final String name,\n            final String desc, final String signature, final Object value) {\n        if (computeSVUID) {\n            if (\"serialVersionUID\".equals(name)) {\n                // since the class already has SVUID, we won't be computing it.\n                computeSVUID = false;\n                hasSVUID = true;\n            }\n            /*\n             * Remember field for SVUID computation For field modifiers, only\n             * the ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC,\n             * ACC_FINAL, ACC_VOLATILE, and ACC_TRANSIENT flags are used when\n             * computing serialVersionUID values.\n             */\n            if ((access & Opcodes.ACC_PRIVATE) == 0\n                    || (access & (Opcodes.ACC_STATIC | Opcodes.ACC_TRANSIENT)) == 0) {\n                int mods = access\n                        & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE\n                                | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC\n                                | Opcodes.ACC_FINAL | Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT);\n                svuidFields.add(new Item(name, mods, desc));\n            }\n        }\n\n        return super.visitField(access, name, desc, signature, value);\n    }\n\n    /**\n     * Handle a bizarre special case. Nested classes (static classes declared\n     * inside another class) that are protected have their access bit set to\n     * public in their class files to deal with some odd reflection situation.\n     * Our SVUID computation must do as the JVM does and ignore access bits in\n     * the class file in favor of the access bits InnerClass attribute.\n     */\n    @Override\n    public void visitInnerClass(final String aname, final String outerName,\n            final String innerName, final int attr_access) {\n        if ((name != null) && name.equals(aname)) {\n            this.access = attr_access;\n        }\n        super.visitInnerClass(aname, outerName, innerName, attr_access);\n    }\n\n    /*\n     * Add the SVUID if class doesn't have one\n     */\n    @Override\n    public void visitEnd() {\n        // compute SVUID and add it to the class\n        if (computeSVUID && !hasSVUID) {\n            try {\n                addSVUID(computeSVUID());\n            } catch (Throwable e) {\n                throw new RuntimeException(\"Error while computing SVUID for \"\n                        + name, e);\n            }\n        }\n\n        super.visitEnd();\n    }\n\n    // ------------------------------------------------------------------------\n    // Utility methods\n    // ------------------------------------------------------------------------\n\n    /**\n     * Returns true if the class already has a SVUID field. The result of this\n     * method is only valid when visitEnd is or has been called.\n     *\n     * @return true if the class already has a SVUID field.\n     */\n    public boolean hasSVUID() {\n        return hasSVUID;\n    }\n\n    protected void addSVUID(long svuid) {\n        FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL\n                + Opcodes.ACC_STATIC, \"serialVersionUID\", \"J\", null, new Long(\n                svuid));\n        if (fv != null) {\n            fv.visitEnd();\n        }\n    }\n\n    /**\n     * Computes and returns the value of SVUID.\n     *\n     * @return Returns the serial version UID\n     * @throws IOException\n     *             if an I/O error occurs\n     */\n    protected long computeSVUID() throws IOException {\n        ByteArrayOutputStream bos;\n        DataOutputStream dos = null;\n        long svuid = 0;\n\n        try {\n            bos = new ByteArrayOutputStream();\n            dos = new DataOutputStream(bos);\n\n            /*\n             * 1. The class name written using UTF encoding.\n             */\n            dos.writeUTF(name.replace('/', '.'));\n\n            /*\n             * 2. The class modifiers written as a 32-bit integer.\n             */\n            dos.writeInt(access\n                    & (Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL\n                            | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT));\n\n            /*\n             * 3. The name of each interface sorted by name written using UTF\n             * encoding.\n             */\n            Arrays.sort(interfaces);\n            for (int i = 0; i < interfaces.length; i++) {\n                dos.writeUTF(interfaces[i].replace('/', '.'));\n            }\n\n            /*\n             * 4. For each field of the class sorted by field name (except\n             * private static and private transient fields):\n             *\n             * 1. The name of the field in UTF encoding. 2. The modifiers of the\n             * field written as a 32-bit integer. 3. The descriptor of the field\n             * in UTF encoding\n             *\n             * Note that field signatures are not dot separated. Method and\n             * constructor signatures are dot separated. Go figure...\n             */\n            writeItems(svuidFields, dos, false);\n\n            /*\n             * 5. If a class initializer exists, write out the following: 1. The\n             * name of the method, <clinit>, in UTF encoding. 2. The modifier of\n             * the method, java.lang.reflect.Modifier.STATIC, written as a\n             * 32-bit integer. 3. The descriptor of the method, ()V, in UTF\n             * encoding.\n             */\n            if (hasStaticInitializer) {\n                dos.writeUTF(\"<clinit>\");\n                dos.writeInt(Opcodes.ACC_STATIC);\n                dos.writeUTF(\"()V\");\n            } // if..\n\n            /*\n             * 6. For each non-private constructor sorted by method name and\n             * signature: 1. The name of the method, <init>, in UTF encoding. 2.\n             * The modifiers of the method written as a 32-bit integer. 3. The\n             * descriptor of the method in UTF encoding.\n             */\n            writeItems(svuidConstructors, dos, true);\n\n            /*\n             * 7. For each non-private method sorted by method name and\n             * signature: 1. The name of the method in UTF encoding. 2. The\n             * modifiers of the method written as a 32-bit integer. 3. The\n             * descriptor of the method in UTF encoding.\n             */\n            writeItems(svuidMethods, dos, true);\n\n            dos.flush();\n\n            /*\n             * 8. The SHA-1 algorithm is executed on the stream of bytes\n             * produced by DataOutputStream and produces five 32-bit values\n             * sha[0..4].\n             */\n            byte[] hashBytes = computeSHAdigest(bos.toByteArray());\n\n            /*\n             * 9. The hash value is assembled from the first and second 32-bit\n             * values of the SHA-1 message digest. If the result of the message\n             * digest, the five 32-bit words H0 H1 H2 H3 H4, is in an array of\n             * five int values named sha, the hash value would be computed as\n             * follows:\n             *\n             * long hash = ((sha[0] >>> 24) & 0xFF) | ((sha[0] >>> 16) & 0xFF)\n             * << 8 | ((sha[0] >>> 8) & 0xFF) << 16 | ((sha[0] >>> 0) & 0xFF) <<\n             * 24 | ((sha[1] >>> 24) & 0xFF) << 32 | ((sha[1] >>> 16) & 0xFF) <<\n             * 40 | ((sha[1] >>> 8) & 0xFF) << 48 | ((sha[1] >>> 0) & 0xFF) <<\n             * 56;\n             */\n            for (int i = Math.min(hashBytes.length, 8) - 1; i >= 0; i--) {\n                svuid = (svuid << 8) | (hashBytes[i] & 0xFF);\n            }\n        } finally {\n            // close the stream (if open)\n            if (dos != null) {\n                dos.close();\n            }\n        }\n\n        return svuid;\n    }\n\n    /**\n     * Returns the SHA-1 message digest of the given value.\n     *\n     * @param value\n     *            the value whose SHA message digest must be computed.\n     * @return the SHA-1 message digest of the given value.\n     */\n    protected byte[] computeSHAdigest(final byte[] value) {\n        try {\n          return (byte[]) Reflector.invokeInstanceMethod(\n              Reflector.invokeStaticMethod(\"java.security.MessageDigest\",\n                  \"getInstance\", new Object[] { \"SHA\" }), \"digest\",\n                  new Object[] { value });\n        } catch (Exception e) {\n          throw new UnsupportedOperationException(e);\n        }\n    }\n\n    /**\n     * Sorts the items in the collection and writes it to the data output stream\n     *\n     * @param itemCollection\n     *            collection of items\n     * @param dos\n     *            a <code>DataOutputStream</code> value\n     * @param dotted\n     *            a <code>boolean</code> value\n     * @exception IOException\n     *                if an error occurs\n     */\n    private static void writeItems(final Collection<Item> itemCollection,\n            final DataOutput dos, final boolean dotted) throws IOException {\n        int size = itemCollection.size();\n        Item[] items = itemCollection.toArray(new Item[size]);\n        Arrays.sort(items);\n        for (int i = 0; i < size; i++) {\n            dos.writeUTF(items[i].name);\n            dos.writeInt(items[i].access);\n            dos.writeUTF(dotted ? items[i].desc.replace('/', '.')\n                    : items[i].desc);\n        }\n    }\n\n    // ------------------------------------------------------------------------\n    // Inner classes\n    // ------------------------------------------------------------------------\n\n    private static class Item implements Comparable<Item> {\n\n        final String name;\n\n        final int access;\n\n        final String desc;\n\n        Item(final String name, final int access, final String desc) {\n            this.name = name;\n            this.access = access;\n            this.desc = desc;\n        }\n\n        public int compareTo(final Item other) {\n            int retVal = name.compareTo(other.name);\n            if (retVal == 0) {\n                retVal = desc.compareTo(other.desc);\n            }\n            return retVal;\n        }\n\n        @Override\n        public boolean equals(final Object o) {\n            if (o instanceof Item) {\n                return compareTo((Item) o) == 0;\n            }\n            return false;\n        }\n\n        @Override\n        public int hashCode() {\n            return (name + desc).hashCode();\n        }\n    }\n}"
  },
  {
    "path": "src/jvm/clojure/asm/commons/StaticInitMerger.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm.commons;\n\nimport clojure.asm.ClassVisitor;\nimport clojure.asm.MethodVisitor;\nimport clojure.asm.Opcodes;\n\n/**\n * A {@link ClassVisitor} that merges clinit methods into a single one.\n *\n * @author Eric Bruneton\n */\npublic class StaticInitMerger extends ClassVisitor {\n\n    private String name;\n\n    private MethodVisitor clinit;\n\n    private final String prefix;\n\n    private int counter;\n\n    public StaticInitMerger(final String prefix, final ClassVisitor cv) {\n        this(Opcodes.ASM4, prefix, cv);\n    }\n\n    protected StaticInitMerger(final int api, final String prefix,\n            final ClassVisitor cv) {\n        super(api, cv);\n        this.prefix = prefix;\n    }\n\n    @Override\n    public void visit(final int version, final int access, final String name,\n            final String signature, final String superName,\n            final String[] interfaces) {\n        cv.visit(version, access, name, signature, superName, interfaces);\n        this.name = name;\n    }\n\n    @Override\n    public MethodVisitor visitMethod(final int access, final String name,\n            final String desc, final String signature, final String[] exceptions) {\n        MethodVisitor mv;\n        if (\"<clinit>\".equals(name)) {\n            int a = Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC;\n            String n = prefix + counter++;\n            mv = cv.visitMethod(a, n, desc, signature, exceptions);\n\n            if (clinit == null) {\n                clinit = cv.visitMethod(a, name, desc, null, null);\n            }\n            clinit.visitMethodInsn(Opcodes.INVOKESTATIC, this.name, n, desc);\n        } else {\n            mv = cv.visitMethod(access, name, desc, signature, exceptions);\n        }\n        return mv;\n    }\n\n    @Override\n    public void visitEnd() {\n        if (clinit != null) {\n            clinit.visitInsn(Opcodes.RETURN);\n            clinit.visitMaxs(0, 0);\n        }\n        cv.visitEnd();\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/commons/TableSwitchGenerator.java",
    "content": "/***\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n */\npackage clojure.asm.commons;\n\nimport clojure.asm.Label;\n\n/**\n * A code generator for switch statements.\n *\n * @author Juozas Baliuka\n * @author Chris Nokleberg\n * @author Eric Bruneton\n */\npublic interface TableSwitchGenerator {\n\n    /**\n     * Generates the code for a switch case.\n     *\n     * @param key\n     *            the switch case key.\n     * @param end\n     *            a label that corresponds to the end of the switch statement.\n     */\n    void generateCase(int key, Label end);\n\n    /**\n     * Generates the code for the default switch case.\n     */\n    void generateDefault();\n}\n"
  },
  {
    "path": "src/jvm/clojure/asm/commons/package.html",
    "content": "<html>\n<!--\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n-->\n<body>\nProvides some useful class and method adapters. <i>The preferred way of using\nthese adapters is by chaining them together and to custom adapters (instead of\ninheriting from them)</i>. Indeed this approach provides more combination\npossibilities than inheritance. For instance, suppose you want to implement an\nadapter MyAdapter than needs sorted local variables and intermediate stack map\nframe values taking into account the local variables sort. By using inheritance,\nthis would require MyAdapter to extend AnalyzerAdapter, itself extending\nLocalVariablesSorter. But AnalyzerAdapter is not a subclass of\nLocalVariablesSorter, so this is not possible. On the contrary, by using\ndelegation, you can make LocalVariablesSorter delegate to AnalyzerAdapter,\nitself delegating to MyAdapter. In this case AnalyzerAdapter computes\nintermediate frames based on the output of LocalVariablesSorter, and MyAdapter\ncan add new locals by calling the newLocal method on LocalVariablesSorter, and\ncan get the stack map frame state before each instruction by reading the locals\nand stack fields in AnalyzerAdapter (this requires references from MyAdapter\nback to LocalVariablesSorter and AnalyzerAdapter).\n</body>"
  },
  {
    "path": "src/jvm/clojure/asm/package.html",
    "content": "<html>\n<!--\n * ASM: a very small and fast Java bytecode manipulation framework\n * Copyright (c) 2000-2011 INRIA, France Telecom\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the copyright holders nor the names of its\n *    contributors may be used to endorse or promote products derived from\n *    this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n * THE POSSIBILITY OF SUCH DAMAGE.\n-->\n<body>\nProvides a small and fast bytecode manipulation framework.\n\n<p>\nThe <a href=\"http://www.objectweb.org/asm\">ASM</a> framework is organized\naround the {@link clojure.asm.ClassVisitor ClassVisitor},\n{@link clojure.asm.FieldVisitor FieldVisitor},\n{@link clojure.asm.MethodVisitor MethodVisitor} and\n{@link clojure.asm.AnnotationVisitor AnnotationVisitor} abstract classes,\nwhich allow one to visit the fields, methods and annotations of a class,\nincluding the bytecode instructions of each method.\n\n<p>\nIn addition to these main abstract classes, ASM provides a {@link\nclojure.asm.ClassReader ClassReader} class, that can parse an\nexisting class and make a given visitor visit it. ASM also provides\na {@link clojure.asm.ClassWriter ClassWriter} class, which is\na visitor that generates Java class files.\n\n<p>\nIn order to generate a class from scratch, only the {@link\nclojure.asm.ClassWriter ClassWriter} class is necessary. Indeed,\nin order to generate a class, one must just call its visit<i>Xxx</i>\nmethods with the appropriate arguments to generate the desired fields\nand methods. See the \"helloworld\" example in the ASM distribution for\nmore details about class generation.\n\n<p>\nIn order to modify existing classes, one must use a {@link\nclojure.asm.ClassReader ClassReader} class to analyze\nthe original class, a class modifier, and a {@link clojure.asm.ClassWriter\nClassWriter} to construct the modified class. The class modifier\nis just a {@link clojure.asm.ClassVisitor ClassVisitor}\nthat delegates most of the work to another {@link clojure.asm.ClassVisitor\nClassVisitor}, but that sometimes changes some parameter values,\nor call additional methods, in order to implement the desired\nmodification process. In order to make it easier to implement such\nclass modifiers, the {@link clojure.asm.ClassVisitor\nClassVisitor} and {@link clojure.asm.MethodVisitor MethodVisitor}\nclasses delegate by default all the method calls they receive to an\noptional visitor. See the \"adapt\" example in the ASM\ndistribution for more details about class modification.\n\n<p>\nThe size of the core ASM library, <tt>asm.jar</tt>, is only 45KB, which is much\nsmaller than the size of the\n<a href=\"http://jakarta.apache.org/bcel\">BCEL</a> library (504KB), and than the\nsize of the\n<a href=\"http://serp.sourceforge.net\">SERP</a> library (150KB). ASM is also\nmuch faster than these tools. Indeed the overhead of a load time class\ntransformation process is of the order of 60% with ASM, 700% or more with BCEL,\nand 1100% or more with SERP (see the <tt>test/perf</tt> directory in the ASM\ndistribution)!\n\n@since ASM 1.3\n</body>\n</html>\n"
  },
  {
    "path": "src/jvm/clojure/java/api/Clojure.java",
    "content": "/**\n *   Copyright (c) Rich Hickey and Contributors. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.java.api;\n\nimport clojure.lang.IFn;\nimport clojure.lang.Symbol;\nimport clojure.lang.Var;\n\n/**\n * <p>The Clojure class provides a minimal interface to bootstrap Clojure access\n * from other JVM languages. It provides:</p>\n *\n * <ol>\n * <li>The ability to use Clojure's namespaces to locate an arbitrary\n * <a href=\"http://clojure.org/vars\">var</a>, returning the\n * var's {@link clojure.lang.IFn} interface.</li>\n * <li>A convenience method <code>read</code> for reading data using\n * Clojure's edn reader</li>\n * </ol>\n *\n * <p>To lookup and call a Clojure function:</p>\n *\n * <pre>\n * IFn plus = Clojure.var(\"clojure.core\", \"+\");\n * plus.invoke(1, 2);</pre>\n *\n * <p>Functions in <code>clojure.core</code> are automatically loaded. Other\n * namespaces can be loaded via <code>require</code>:</p>\n *\n * <pre>\n * IFn require = Clojure.var(\"clojure.core\", \"require\");\n * require.invoke(Clojure.read(\"clojure.set\"));</pre>\n *\n * <p><code>IFn</code>s can be passed to higher order functions, e.g. the\n * example below passes <code>plus</code> to <code>read</code>:</p>\n *\n * <pre>\n * IFn map = Clojure.var(\"clojure.core\", \"map\");\n * IFn inc = Clojure.var(\"clojure.core\", \"inc\");\n * map.invoke(inc, Clojure.read(\"[1 2 3]\"));</pre>\n */\npublic class Clojure {\n    private Clojure() {}\n\n    private static Symbol asSym(Object o) {\n        Symbol s;\n        if (o instanceof String) {\n            s = Symbol.intern((String) o);\n        }  else {\n            s = (Symbol) o;\n        }\n        return s;\n    }\n\n    /**\n     * Returns the var associated with qualifiedName.\n     *\n     * @param qualifiedName  a String or clojure.lang.Symbol\n     * @return               a clojure.lang.IFn\n     */\n    public static IFn var(Object qualifiedName) {\n        Symbol s = asSym(qualifiedName);\n        return var(s.getNamespace(), s.getName());\n    }\n\n    /**\n     * Returns an IFn associated with the namespace and name.\n     *\n     * @param ns        a String or clojure.lang.Symbol\n     * @param name      a String or clojure.lang.Symbol\n     * @return          a clojure.lang.IFn\n     */\n    public static IFn var(Object ns, Object name) {\n        return Var.intern(asSym(ns), asSym(name));\n    }\n\n    /**\n     * Read one object from the String s.  Reads data in the\n     * <a href=\"http://edn-format.org\">edn format</a>.\n     * @param s   a String\n     * @return    an Object, or nil.\n     */\n    public static Object read(String s) {\n        return EDN_READ_STRING.invoke(s);\n    }\n\n    static {\n        Symbol edn = (Symbol) var(\"clojure.core\", \"symbol\").invoke(\"clojure.edn\");\n        var(\"clojure.core\", \"require\").invoke(edn);\n    }\n    private static final IFn EDN_READ_STRING = var(\"clojure.edn\", \"read-string\");\n}\n"
  },
  {
    "path": "src/jvm/clojure/java/api/package.html",
    "content": "<html>\n\n<!--\nCopyright (c) Rich Hickey and Contributors. All rights reserved.\nThe use and distribution terms for this software are covered by the\nEclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\nwhich can be found in the file epl-v10.html at the root of this distribution.\nBy using this software in any fashion, you are agreeing to be bound by\nthe terms of this license.\nYou must not remove this notice, or any other, from this software.\n-->\n\n<body>Clojure interop from Java.\n\n<p>The clojure.java.api package provides a minimal interface to bootstrap\n  Clojure access from other JVM languages.  It does this by providing:\n</p>\n\n<ol>\n  <li>The ability to use Clojure's namespaces to locate an arbitrary\n  <a href=\"http://clojure.org/vars\">var</a>, returning the\n  var's <code>clojure.lang.IFn</code> interface.</li>\n  <li>A convenience method <code>read</code> for reading data using\n  Clojure's edn reader</li>\n</ol>\n\n<p><code>IFn</code>s provide complete access to\n  Clojure's <a href=\"http://clojure.github.io/clojure/\">API</a>s.\n  You can also access any other library written in Clojure, after adding\n  either its source or compiled form to the classpath.</p>\n\n<p>The public Java API for Clojure consists of the following classes\n  and interfaces:\n</p>\n\n<ol>\n<li>clojure.java.api.Clojure</li>\n<li>clojure.lang.IFn</li>\n</ol>\n\n<p>All other Java classes should be treated as implementation details,\n  and applications should avoid relying on them.</p>\n\n<p>To lookup and call a Clojure function:\n<pre>\nIFn plus = Clojure.var(\"clojure.core\", \"+\");\nplus.invoke(1, 2);\n</pre>\n</p>\n\n<p>Functions in <code>clojure.core</code> are automatically loaded. Other\n  namespaces can be loaded via <code>require</code>:\n<pre>\nIFn require = Clojure.var(\"clojure.core\", \"require\");\nrequire.invoke(Clojure.read(\"clojure.set\"));\n</pre>\n</p>\n\n<p><code>IFn</code>s can be passed to higher order functions, e.g. the\n  example below passes <code>plus</code> to <code>read</code>:\n<pre>\nIFn map = Clojure.var(\"clojure.core\", \"map\");\nIFn inc = Clojure.var(\"clojure.core\", \"inc\");\nmap.invoke(inc, Clojure.read(\"[1 2 3]\"));\n</pre>\n</p>\n\n<p>Most IFns in Clojure refer to functions. A few, however, refer to\n  non-function data values. To access these, use <code>deref</code>\n  instead of <code>fn</code>:</p>\n\n<pre>\nIFn printLength = Clojure.var(\"clojure.core\", \"*print-length*\");\nIFn deref = Clojure.var(\"clojure.core\", \"deref\");\nderef.invoke(printLength);\n</pre>\n\n</body>\n</html>\n"
  },
  {
    "path": "src/jvm/clojure/lang/AFn.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 25, 2006 4:05:37 PM */\n\npackage clojure.lang;\n\npublic abstract class AFn implements IFn {\n\npublic Object call() {\n\treturn invoke();\n}\n\npublic void run(){\n        invoke();\n}\n\n\n\npublic Object invoke() {\n\treturn throwArity(0);\n}\n\npublic Object invoke(Object arg1) {\n\treturn throwArity(1);\n}\n\npublic Object invoke(Object arg1, Object arg2) {\n\treturn throwArity(2);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3) {\n\treturn throwArity(3);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) {\n\treturn throwArity(4);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {\n\treturn throwArity(5);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {\n\treturn throwArity(6);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)\n\t\t{\n\treturn throwArity(7);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8) {\n\treturn throwArity(8);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9) {\n\treturn throwArity(9);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10) {\n\treturn throwArity(10);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11) {\n\treturn throwArity(11);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) {\n\treturn throwArity(12);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13)\n\t\t{\n\treturn throwArity(13);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)\n\t\t{\n\treturn throwArity(14);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15) {\n\treturn throwArity(15);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16) {\n\treturn throwArity(16);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17) {\n\treturn throwArity(17);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18) {\n\treturn throwArity(18);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19) {\n\treturn throwArity(19);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20)\n\t\t{\n\treturn throwArity(20);\n}\n\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20,\n                     Object... args)\n\t\t{\n\treturn throwArity(21);\n}\n\npublic Object applyTo(ISeq arglist) {\n\treturn applyToHelper(this, Util.ret1(arglist,arglist = null));\n}\n\nstatic public Object applyToHelper(IFn ifn, ISeq arglist) {\n\tswitch(RT.boundedLength(arglist, 20))\n\t\t{\n\t\tcase 0:\n\t\t\targlist = null;\n\t\t\treturn ifn.invoke();\n\t\tcase 1:\n\t\t\treturn ifn.invoke(Util.ret1(arglist.first(),arglist = null));\n\t\tcase 2:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 3:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 4:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 5:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 6:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 7:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 8:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 9:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 10:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 11:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 12:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 13:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 14:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 15:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 16:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 17:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 18:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 19:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tcase 20:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, Util.ret1((arglist = arglist.next()).first(),arglist = null)\n\t\t\t);\n\t\tdefault:\n\t\t\treturn ifn.invoke(arglist.first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, (arglist = arglist.next()).first()\n\t\t\t\t\t, RT.seqToArray(Util.ret1(arglist.next(),arglist = null)));\n\t\t}\n}\n\npublic Object throwArity(int n){\n\tString name = getClass().getSimpleName();\n\tthrow new ArityException(n, Compiler.demunge(name));\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/AFunction.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Dec 16, 2008 */\n\npackage clojure.lang;\n\nimport java.io.Serializable;\nimport java.util.Comparator;\n\npublic abstract class AFunction extends AFn implements IObj, Comparator, Fn, Serializable {\n\npublic volatile MethodImplCache __methodImplCache;\n\npublic IPersistentMap meta(){\n\treturn null;\n}\n\npublic IObj withMeta(final IPersistentMap meta){\n  return new RestFnWithMeta(this, meta);\n}\n\npublic int compare(Object o1, Object o2){\n        Object o = invoke(o1, o2);\n\n        if(o instanceof Boolean)\n                {\n                if(RT.booleanCast(o))\n                        return -1;\n                return RT.booleanCast(invoke(o2,o1))? 1 : 0;\n                }\n\n        Number n = (Number) o;\n        return n.intValue();\n}\n\n@Override\npublic boolean equals(Object f) {\n  return this == f;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/AMapEntry.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 1, 2008 */\n\npackage clojure.lang;\n\nimport java.io.StringWriter;\n\npublic abstract class AMapEntry extends APersistentVector implements IMapEntry{\n\npublic Object nth(int i){\n\tif(i == 0)\n\t\treturn key();\n\telse if(i == 1)\n\t\treturn val();\n\telse\n\t\tthrow new IndexOutOfBoundsException();\n}\n\nprivate IPersistentVector asVector(){\n\treturn LazilyPersistentVector.createOwning(key(), val());\n}\n\npublic IPersistentVector assocN(int i, Object val){\n\treturn asVector().assocN(i, val);\n}\n\npublic int count(){\n\treturn 2;\n}\n\npublic ISeq seq(){\n\treturn asVector().seq();\n}\n\npublic IPersistentVector cons(Object o){\n\treturn asVector().cons(o);\n}\n\npublic IPersistentCollection empty(){\n\treturn null;\n}\n\npublic IPersistentStack pop(){\n\treturn LazilyPersistentVector.createOwning(key());\n}\n\npublic Object setValue(Object value){\n\tthrow new UnsupportedOperationException();\n}\n\n/*\n\npublic boolean equals(Object obj){\n\treturn APersistentVector.doEquals(this, obj);\n}\n\npublic int hashCode(){\n\t//must match logic in APersistentVector\n\treturn 31 * (31 + Util.hash(key())) + Util.hash(val());\n//\treturn Util.hashCombine(Util.hashCombine(0, Util.hash(key())), Util.hash(val()));\n}\n\npublic String toString(){\n\tStringWriter sw = new StringWriter();\n\ttry\n\t\t{\n\t\tRT.print(this, sw);\n\t\t}\n\tcatch(Exception e)\n\t\t{\n\t\t//checked exceptions stink!\n\t\tthrow Util.sneakyThrow(e);\n\t\t}\n\treturn sw.toString();\n}\n\npublic int length(){\n\treturn 2;\n}\n\npublic Object nth(int i){\n\tif(i == 0)\n\t\treturn key();\n\telse if(i == 1)\n\t\treturn val();\n\telse\n\t\tthrow new IndexOutOfBoundsException();\n}\n\nprivate IPersistentVector asVector(){\n\treturn LazilyPersistentVector.createOwning(key(), val());\n}\n\npublic IPersistentVector assocN(int i, Object val){\n\treturn asVector().assocN(i, val);\n}\n\npublic int count(){\n\treturn 2;\n}\n\npublic ISeq seq(){\n\treturn asVector().seq();\n}\n\npublic IPersistentVector cons(Object o){\n\treturn asVector().cons(o);\n}\n\npublic boolean containsKey(Object key){\n\treturn asVector().containsKey(key);\n}\n\npublic IMapEntry entryAt(Object key){\n\treturn asVector().entryAt(key);\n}\n\npublic Associative assoc(Object key, Object val){\n\treturn asVector().assoc(key, val);\n}\n\npublic Object valAt(Object key){\n\treturn asVector().valAt(key);\n}\n\npublic Object valAt(Object key, Object notFound){\n\treturn asVector().valAt(key, notFound);\n}\n\npublic Object peek(){\n\treturn val();\n}\n\n\npublic ISeq rseq() {\n\treturn asVector().rseq();\n}\n*/\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/APersistentMap.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.io.Serializable;\nimport java.util.*;\n\npublic abstract class APersistentMap extends AFn implements IPersistentMap, Map, Iterable, Serializable, MapEquivalence, IHashEq {\nint _hash = -1;\nint _hasheq = -1;\n\npublic String toString(){\n\treturn RT.printString(this);\n}\n\npublic IPersistentCollection cons(Object o){\n\tif(o instanceof Map.Entry)\n\t\t{\n\t\tMap.Entry e = (Map.Entry) o;\n\n\t\treturn assoc(e.getKey(), e.getValue());\n\t\t}\n\telse if(o instanceof IPersistentVector)\n\t\t{\n\t\tIPersistentVector v = (IPersistentVector) o;\n\t\tif(v.count() != 2)\n\t\t\tthrow new IllegalArgumentException(\"Vector arg to map conj must be a pair\");\n\t\treturn assoc(v.nth(0), v.nth(1));\n\t\t}\n\n\tIPersistentMap ret = this;\n\tfor(ISeq es = RT.seq(o); es != null; es = es.next())\n\t\t{\n\t\tMap.Entry e = (Map.Entry) es.first();\n\t\tret = ret.assoc(e.getKey(), e.getValue());\n\t\t}\n\treturn ret;\n}\n\npublic boolean equals(Object obj){\n\treturn mapEquals(this, obj);\n}\n\nstatic public boolean mapEquals(IPersistentMap m1, Object obj){\n\tif(m1 == obj) return true;\n\tif(!(obj instanceof Map))\n\t\treturn false;\n\tMap m = (Map) obj;\n\n\tif(m.size() != m1.count())\n\t\treturn false;\n\n\tfor(ISeq s = m1.seq(); s != null; s = s.next())\n\t\t{\n\t\tMap.Entry e = (Map.Entry) s.first();\n\t\tboolean found = m.containsKey(e.getKey());\n\n\t\tif(!found || !Util.equals(e.getValue(), m.get(e.getKey())))\n\t\t\treturn false;\n\t\t}\n\n\treturn true;\n}\n\npublic boolean equiv(Object obj){\n\tif(!(obj instanceof Map))\n\t\treturn false;\n\tif(obj instanceof IPersistentMap && !(obj instanceof MapEquivalence))\n\t\treturn false;\n\t\n\tMap m = (Map) obj;\n\n\tif(m.size() != size())\n\t\treturn false;\n\n\tfor(ISeq s = seq(); s != null; s = s.next())\n\t\t{\n\t\tMap.Entry e = (Map.Entry) s.first();\n\t\tboolean found = m.containsKey(e.getKey());\n\n\t\tif(!found || !Util.equiv(e.getValue(), m.get(e.getKey())))\n\t\t\treturn false;\n\t\t}\n\n\treturn true;\n}\npublic int hashCode(){\n\tif(_hash == -1)\n\t\t{\n\t\tthis._hash = mapHash(this);\n\t\t}\n\treturn _hash;\n}\n\nstatic public int mapHash(IPersistentMap m){\n\tint hash = 0;\n\tfor(ISeq s = m.seq(); s != null; s = s.next())\n\t\t{\n\t\tMap.Entry e = (Map.Entry) s.first();\n\t\thash += (e.getKey() == null ? 0 : Util.hash(e.getKey())) ^\n\t\t\t\t(e.getValue() == null ? 0 : Util.hash(e.getValue()));\n\t\t}\n\treturn hash;\n}\n\npublic int hasheq(){\n\tif(_hasheq == -1)\n\t\t{\n\t\t//this._hasheq = mapHasheq(this);\n\t\t_hasheq = Murmur3.hashUnordered(this);\n\t\t}\n\treturn _hasheq;\n}\n\nstatic public int mapHasheq(IPersistentMap m) {\n\treturn Murmur3.hashUnordered(m);\n//\tint hash = 0;\n//\tfor(ISeq s = m.seq(); s != null; s = s.next())\n//\t\t{\n//\t\tMap.Entry e = (Map.Entry) s.first();\n//\t\thash += Util.hasheq(e.getKey()) ^\n//\t\t\t\tUtil.hasheq(e.getValue());\n//\t\t}\n//\treturn hash;\n}\n\nstatic public class KeySeq extends ASeq{\n\tfinal ISeq seq;\n\tfinal Iterable iterable;\n\n\tstatic public KeySeq create(ISeq seq){\n\t\tif(seq == null)\n\t\t\treturn null;\n\t\treturn new KeySeq(seq, null);\n\t}\n\n\tstatic public KeySeq createFromMap(IPersistentMap map){\n\t\tif(map == null)\n\t\t\treturn null;\n\t\tISeq seq = map.seq();\n\t\tif(seq == null)\n\t\t\treturn null;\n\t\treturn new KeySeq(seq, map);\n\t}\n\n\tprivate KeySeq(ISeq seq, Iterable iterable){\n\t\tthis.seq = seq;\n\t\tthis.iterable = iterable;\n\t}\n\n\tprivate KeySeq(IPersistentMap meta, ISeq seq, Iterable iterable){\n\t\tsuper(meta);\n\t\tthis.seq = seq;\n\t\tthis.iterable = iterable;\n\t}\n\n\tpublic Object first(){\n\t\treturn ((Map.Entry) seq.first()).getKey();\n\t}\n\n\tpublic ISeq next(){\n\t\treturn create(seq.next());\n\t}\n\n\tpublic KeySeq withMeta(IPersistentMap meta){\n\t\treturn new KeySeq(meta, seq, iterable);\n\t}\n\n\tpublic Iterator iterator(){\n\t\tif(iterable == null)\n\t\t\treturn super.iterator();\n\n\t\tif(iterable instanceof IMapIterable)\n\t\t\treturn ((IMapIterable)iterable).keyIterator();\n\n\t\tfinal Iterator mapIter = iterable.iterator();\n\t\treturn new Iterator() {\n\t\t\tpublic boolean hasNext() {\n\t\t\t\treturn mapIter.hasNext();\n\t\t\t}\n\n\t\t\tpublic Object next() {\n\t\t\t\treturn ((Map.Entry)mapIter.next()).getKey();\n\t\t\t}\n\n\t\t\tpublic void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t};\n\t}\n}\n\nstatic public class ValSeq extends ASeq{\n\tfinal ISeq seq;\n\tfinal Iterable iterable;\n\n\tstatic public ValSeq create(ISeq seq){\n\t\tif(seq == null)\n\t\t\treturn null;\n\t\treturn new ValSeq(seq, null);\n\t}\n\n\tstatic public ValSeq createFromMap(IPersistentMap map) {\n\t\tif(map == null)\n\t\t\treturn null;\n\t\tISeq seq = map.seq();\n\t\tif(seq == null)\n\t\t\treturn null;\n\t\treturn new ValSeq(seq, map);\n\t}\n\n\tprivate ValSeq(ISeq seq, Iterable iterable){\n\t\tthis.seq = seq;\n\t\tthis.iterable = iterable;\n\t}\n\n\tprivate ValSeq(IPersistentMap meta, ISeq seq, Iterable iterable){\n\t\tsuper(meta);\n\t\tthis.seq = seq;\n\t\tthis.iterable = iterable;\n\t}\n\n\tpublic Object first(){\n\t\treturn ((Map.Entry) seq.first()).getValue();\n\t}\n\n\tpublic ISeq next(){\n\t\treturn create(seq.next());\n\t}\n\n\tpublic ValSeq withMeta(IPersistentMap meta){\n\t\treturn new ValSeq(meta, seq, iterable);\n\t}\n\n\tpublic Iterator iterator(){\n\t\tif(iterable == null)\n\t\t\treturn super.iterator();\n\n\t\tif(iterable instanceof IMapIterable)\n\t\t\treturn ((IMapIterable)iterable).valIterator();\n\n\t\tfinal Iterator mapIter = iterable.iterator();\n\t\treturn new Iterator() {\n\t\t\tpublic boolean hasNext() {\n\t\t\t\treturn mapIter.hasNext();\n\t\t\t}\n\n\t\t\tpublic Object next() {\n\t\t\t\treturn ((Map.Entry)mapIter.next()).getValue();\n\t\t\t}\n\n\t\t\tpublic void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t};\n\t}\n}\n\nstatic final IFn MAKE_ENTRY = new AFn() {\n    public Object invoke(Object key, Object val) {\n        return new MapEntry(key, val);\n    }\n};\n\nstatic final IFn MAKE_KEY = new AFn() {\n    public Object invoke(Object key, Object val) {\n        return key;\n    }\n};\n\nstatic final IFn MAKE_VAL = new AFn() {\n    public Object invoke(Object key, Object val) {\n        return val;\n    }\n};\n\npublic Object invoke(Object arg1) {\n\treturn valAt(arg1);\n}\n\npublic Object invoke(Object arg1, Object notFound) {\n\treturn valAt(arg1, notFound);\n}\n\n// java.util.Map implementation\n\npublic void clear(){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean containsValue(Object value){\n\treturn values().contains(value);\n}\n\npublic Set entrySet(){\n\treturn new AbstractSet(){\n\n\t\tpublic Iterator iterator(){\n\t\t\treturn APersistentMap.this.iterator();\n\t\t}\n\n\t\tpublic int size(){\n\t\t\treturn count();\n\t\t}\n\n\t\tpublic int hashCode(){\n\t\t\treturn Util.hash(APersistentMap.this);\n\t\t}\n\n\t\tpublic boolean contains(Object o){\n\t\t\tif(o instanceof Entry)\n\t\t\t\t{\n\t\t\t\tEntry e = (Entry) o;\n\t\t\t\tEntry found = entryAt(e.getKey());\n\t\t\t\tif(found != null && Util.equals(found.getValue(), e.getValue()))\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t};\n}\n\npublic Object get(Object key){\n\treturn valAt(key);\n}\n\npublic boolean isEmpty(){\n\treturn count() == 0;\n}\n\npublic Set keySet(){\n\treturn new AbstractSet(){\n\n\t\tpublic Iterator iterator(){\n\t\t\tfinal Iterator mi = APersistentMap.this.iterator();\n\n\t\t\treturn new Iterator(){\n\n\n\t\t\t\tpublic boolean hasNext(){\n\t\t\t\t\treturn mi.hasNext();\n\t\t\t\t}\n\n\t\t\t\tpublic Object next(){\n\t\t\t\t\tEntry e = (Entry) mi.next();\n\t\t\t\t\treturn e.getKey();\n\t\t\t\t}\n\n\t\t\t\tpublic void remove(){\n\t\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tpublic int size(){\n\t\t\treturn count();\n\t\t}\n\n\t\tpublic boolean contains(Object o){\n\t\t\treturn APersistentMap.this.containsKey(o);\n\t\t}\n\t};\n}\n\npublic Object put(Object key, Object value){\n\tthrow new UnsupportedOperationException();\n}\n\npublic void putAll(Map t){\n\tthrow new UnsupportedOperationException();\n}\n\npublic Object remove(Object key){\n\tthrow new UnsupportedOperationException();\n}\n\npublic int size(){\n\treturn count();\n}\n\npublic Collection values(){\n\treturn new AbstractCollection(){\n\n\t\tpublic Iterator iterator(){\n\t\t\tfinal Iterator mi = APersistentMap.this.iterator();\n\n\t\t\treturn new Iterator(){\n\n\n\t\t\t\tpublic boolean hasNext(){\n\t\t\t\t\treturn mi.hasNext();\n\t\t\t\t}\n\n\t\t\t\tpublic Object next(){\n\t\t\t\t\tEntry e = (Entry) mi.next();\n\t\t\t\t\treturn e.getValue();\n\t\t\t\t}\n\n\t\t\t\tpublic void remove(){\n\t\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tpublic int size(){\n\t\t\treturn count();\n\t\t}\n\t};\n}\n\n/*\n// java.util.Collection implementation\n\npublic Object[] toArray(){\n\treturn RT.seqToArray(seq());\n}\n\npublic boolean add(Object o){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean remove(Object o){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean addAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic void clear(){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean retainAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean removeAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean containsAll(Collection c){\n\tfor(Object o : c)\n\t\t{\n\t\tif(!contains(o))\n\t\t\treturn false;\n\t\t}\n\treturn true;\n}\n\npublic Object[] toArray(Object[] a){\n\tif(a.length >= count())\n\t\t{\n\t\tISeq s = seq();\n\t\tfor(int i = 0; s != null; ++i, s = s.rest())\n\t\t\t{\n\t\t\ta[i] = s.first();\n\t\t\t}\n\t\tif(a.length > count())\n\t\t\ta[count()] = null;\n\t\treturn a;\n\t\t}\n\telse\n\t\treturn toArray();\n}\n\npublic int size(){\n\treturn count();\n}\n\npublic boolean isEmpty(){\n\treturn count() == 0;\n}\n\npublic boolean contains(Object o){\n\tif(o instanceof Map.Entry)\n\t\t{\n\t\tMap.Entry e = (Map.Entry) o;\n\t\tMap.Entry v = entryAt(e.getKey());\n\t\treturn (v != null && Util.equal(v.getValue(), e.getValue()));\n\t\t}\n\treturn false;\n}\n*/\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/APersistentSet.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 3, 2008 */\n\npackage clojure.lang;\n\nimport java.io.Serializable;\nimport java.util.Collection;\nimport java.util.Iterator;\nimport java.util.Set;\n\npublic abstract class APersistentSet extends AFn implements IPersistentSet, Collection, Set, Serializable, IHashEq {\nint _hash = -1;\nint _hasheq = -1;\nfinal IPersistentMap impl;\n\nprotected APersistentSet(IPersistentMap impl){\n\tthis.impl = impl;\n}\n\npublic String toString(){\n\treturn RT.printString(this);\n}\n\npublic boolean contains(Object key){\n\treturn impl.containsKey(key);\n}\n\npublic Object get(Object key){\n\treturn impl.valAt(key);\n}\n\npublic int count(){\n\treturn impl.count();\n}\n\npublic ISeq seq(){\n\treturn RT.keys(impl);\n}\n\npublic Object invoke(Object arg1) {\n\treturn get(arg1);\n}\n\npublic boolean equals(Object obj){\n    return setEquals(this, obj);\n}\n\nstatic public boolean setEquals(IPersistentSet s1, Object obj) {\n    if(s1 == obj) return true;\n    if(!(obj instanceof Set))\n        return false;\n    Set m = (Set) obj;\n\n    if(m.size() != s1.count())\n        return false;\n\n    for(Object aM : m)\n    {\n        if(!s1.contains(aM))\n            return false;\n    }\n\n    return true;\n}\n\npublic boolean equiv(Object obj){\n\tif (!(obj instanceof Set))\n        return false;\n\n    Set m = (Set) obj;\n\n    if (m.size() != size())\n        return false;\n\n    for(Object aM : m)\n    {\n        if(!contains(aM))\n            return false;\n    }\n\n    return true;\n}\n\npublic int hashCode(){\n\tif(_hash == -1)\n\t\t{\n\t\t//int hash = count();\n\t\tint hash = 0;\n\t\tfor(ISeq s = seq(); s != null; s = s.next())\n\t\t\t{\n\t\t\tObject e = s.first();\n//\t\t\thash = Util.hashCombine(hash, Util.hash(e));\n\t\t\thash +=  Util.hash(e);\n\t\t\t}\n\t\tthis._hash = hash;\n\t\t}\n\treturn _hash;\n}\n\npublic int hasheq(){\n\tif(_hasheq == -1){\n//\t\tint hash = 0;\n//\t\tfor(ISeq s = seq(); s != null; s = s.next())\n//\t\t\t{\n//\t\t\tObject e = s.first();\n//\t\t\thash +=  Util.hasheq(e);\n//\t\t\t}\n//\t\tthis._hasheq = hash;\n\t\t_hasheq = Murmur3.hashUnordered(this);\n\t}\n\treturn _hasheq;\t\t\n}\n\npublic Object[] toArray(){\n\treturn RT.seqToArray(seq());\n}\n\npublic boolean add(Object o){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean remove(Object o){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean addAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic void clear(){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean retainAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean removeAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean containsAll(Collection c){\n\tfor(Object o : c)\n\t\t{\n\t\tif(!contains(o))\n\t\t\treturn false;\n\t\t}\n\treturn true;\n}\n\npublic Object[] toArray(Object[] a){\n    return RT.seqToPassedArray(seq(), a);\n}\n\npublic int size(){\n\treturn count();\n}\n\npublic boolean isEmpty(){\n\treturn count() == 0;\n}\n\npublic Iterator iterator(){\n    if(impl instanceof IMapIterable)\n        return ((IMapIterable)impl).keyIterator();\n    else return new Iterator() {\n        private final Iterator iter = impl.iterator();\n\n        public boolean hasNext() {\n            return iter.hasNext();\n        }\n\n        public Object next() {\n            return ((IMapEntry)iter.next()).key();\n        }\n\n        public void remove() {\n            throw new UnsupportedOperationException();\n        }\n    };\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/APersistentVector.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Dec 18, 2007 */\n\npackage clojure.lang;\n\nimport java.io.Serializable;\nimport java.util.*;\n\npublic abstract class APersistentVector extends AFn implements IPersistentVector, Iterable,\n                                                               List,\n                                                               RandomAccess, Comparable,\n                                                               Serializable, IHashEq {\nint _hash = -1;\nint _hasheq = -1;\n\npublic String toString(){\n\treturn RT.printString(this);\n}\n\npublic ISeq seq(){\n\tif(count() > 0)\n\t\treturn new Seq(this, 0);\n\treturn null;\n}\n\npublic ISeq rseq(){\n\tif(count() > 0)\n\t\treturn new RSeq(this, count() - 1);\n\treturn null;\n}\n\nstatic boolean doEquals(IPersistentVector v, Object obj){\n\tif(v == obj) return true;\n\tif(obj instanceof List || obj instanceof IPersistentVector)\n\t\t{\n\t\tCollection ma = (Collection) obj;\n\t\tif(ma.size() != v.count() || Util.hash(ma) != Util.hash(v))\n\t\t\treturn false;\n\t\tfor(Iterator i1 = ((List) v).iterator(), i2 = ma.iterator();\n\t\t    i1.hasNext();)\n\t\t\t{\n\t\t\tif(!Util.equals(i1.next(), i2.next()))\n\t\t\t\treturn false;\n\t\t\t}\n\t\treturn true;\n\t\t}\n//\tif(obj instanceof IPersistentVector)\n//\t\t{\n//\t\tIPersistentVector ma = (IPersistentVector) obj;\n//\t\tif(ma.count() != v.count() || Util.hash(ma) != Util.hash(v))\n//\t\t\treturn false;\n//\t\tfor(int i = 0; i < v.count(); i++)\n//\t\t\t{\n//\t\t\tif(!Util.equal(v.nth(i), ma.nth(i)))\n//\t\t\t\treturn false;\n//\t\t\t}\n//\t\t}\n\telse\n\t\t{\n\t\tif(!(obj instanceof Sequential))\n\t\t\treturn false;\n\t\tISeq ms = RT.seq(obj);\n\t\tfor(int i = 0; i < v.count(); i++, ms = ms.next())\n\t\t\t{\n\t\t\tif(ms == null || !Util.equals(v.nth(i), ms.first()))\n\t\t\t\treturn false;\n\t\t\t}\n\t\tif(ms != null)\n\t\t\treturn false;\n\t\t}\n\n\treturn true;\n\n}\n\nstatic boolean doEquiv(IPersistentVector v, Object obj){\n\tif(obj instanceof List || obj instanceof IPersistentVector)\n\t\t{\n\t\tCollection ma = (Collection) obj;\n\t\tif(ma.size() != v.count())\n\t\t\treturn false;\n\t\tfor(Iterator i1 = ((List) v).iterator(), i2 = ma.iterator();\n\t\t    i1.hasNext();)\n\t\t\t{\n\t\t\tif(!Util.equiv(i1.next(), i2.next()))\n\t\t\t\treturn false;\n\t\t\t}\n\t\treturn true;\n\t\t}\n//\tif(obj instanceof IPersistentVector)\n//\t\t{\n//\t\tIPersistentVector ma = (IPersistentVector) obj;\n//\t\tif(ma.count() != v.count() || Util.hash(ma) != Util.hash(v))\n//\t\t\treturn false;\n//\t\tfor(int i = 0; i < v.count(); i++)\n//\t\t\t{\n//\t\t\tif(!Util.equal(v.nth(i), ma.nth(i)))\n//\t\t\t\treturn false;\n//\t\t\t}\n//\t\t}\n\telse\n\t\t{\n\t\tif(!(obj instanceof Sequential))\n\t\t\treturn false;\n\t\tISeq ms = RT.seq(obj);\n\t\tfor(int i = 0; i < v.count(); i++, ms = ms.next())\n\t\t\t{\n\t\t\tif(ms == null || !Util.equiv(v.nth(i), ms.first()))\n\t\t\t\treturn false;\n\t\t\t}\n\t\tif(ms != null)\n\t\t\treturn false;\n\t\t}\n\n\treturn true;\n\n}\n\npublic boolean equals(Object obj){\n\treturn doEquals(this, obj);\n}\n\npublic boolean equiv(Object obj){\n\treturn doEquiv(this, obj);\n}\n\npublic int hashCode(){\n\tif(_hash == -1)\n\t\t{\n\t\tint hash = 1;\n\t\tIterator i = iterator();\n\t\twhile(i.hasNext())\n\t\t\t{\n\t\t\tObject obj = i.next();\n\t\t\thash = 31 * hash + (obj == null ? 0 : Util.hash(obj));\n\t\t\t}\n//\t\tint hash = 0;\n//\t\tfor(int i = 0; i < count(); i++)\n//\t\t\t{\n//\t\t\thash = Util.hashCombine(hash, Util.hash(nth(i)));\n//\t\t\t}\n\t\tthis._hash = hash;\n\t\t}\n\treturn _hash;\n}\n\npublic int hasheq(){\n\tif(_hasheq == -1) {\n//\tint hash = 1;\n//\tIterator i = iterator();\n//\twhile(i.hasNext())\n//\t\t{\n//\t\tObject obj = i.next();\n//\t\thash = 31 * hash + Util.hasheq(obj);\n//\t\t}\n//\t_hasheq = hash;\n\t_hasheq  = Murmur3.hashOrdered(this);\n\t}\n\treturn _hasheq;\n}\n\npublic Object get(int index){\n\treturn nth(index);\n}\n\npublic Object nth(int i, Object notFound){\n\tif(i >= 0 && i < count())\n\t\treturn nth(i);\n\treturn notFound;\n}\n\npublic Object remove(int i){\n\tthrow new UnsupportedOperationException();\n}\n\npublic int indexOf(Object o){\n\tfor(int i = 0; i < count(); i++)\n\t\tif(Util.equiv(nth(i), o))\n\t\t\treturn i;\n\treturn -1;\n}\n\npublic int lastIndexOf(Object o){\n\tfor(int i = count() - 1; i >= 0; i--)\n\t\tif(Util.equiv(nth(i), o))\n\t\t\treturn i;\n\treturn -1;\n}\n\npublic ListIterator listIterator(){\n\treturn listIterator(0);\n}\n\npublic ListIterator listIterator(final int index){\n\treturn new ListIterator(){\n\t\tint nexti = index;\n\n\t\tpublic boolean hasNext(){\n\t\t\treturn nexti < count();\n\t\t}\n\n\t\tpublic Object next(){\n\t\t\treturn nth(nexti++);\n\t\t}\n\n\t\tpublic boolean hasPrevious(){\n\t\t\treturn nexti > 0;\n\t\t}\n\n\t\tpublic Object previous(){\n\t\t\treturn nth(--nexti);\n\t\t}\n\n\t\tpublic int nextIndex(){\n\t\t\treturn nexti;\n\t\t}\n\n\t\tpublic int previousIndex(){\n\t\t\treturn nexti - 1;\n\t\t}\n\n\t\tpublic void remove(){\n\t\t\tthrow new UnsupportedOperationException();\n\t\t}\n\n\t\tpublic void set(Object o){\n\t\t\tthrow new UnsupportedOperationException();\n\t\t}\n\n\t\tpublic void add(Object o){\n\t\t\tthrow new UnsupportedOperationException();\n\t\t}\n\t};\n}\n\nIterator rangedIterator(final int start, final int end){\n\treturn new Iterator(){\n\t\tint i = start;\n\n\t\tpublic boolean hasNext(){\n\t\t\treturn i < end;\n\t\t}\n\n\t\tpublic Object next(){\n\t\t\treturn nth(i++);\n\t\t}\n\n\t\tpublic void remove(){\n\t\t\tthrow new UnsupportedOperationException();\n\t\t}\n\t};\n}\n\npublic List subList(int fromIndex, int toIndex){\n\treturn (List) RT.subvec(this, fromIndex, toIndex);\n}\n\n\npublic Object set(int i, Object o){\n\tthrow new UnsupportedOperationException();\n}\n\npublic void add(int i, Object o){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean addAll(int i, Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\n\npublic Object invoke(Object arg1) {\n\tif(Util.isInteger(arg1))\n\t\treturn nth(((Number) arg1).intValue());\n\tthrow new IllegalArgumentException(\"Key must be integer\");\n}\n\npublic Iterator iterator(){\n\t//todo - something more efficient\n\treturn new Iterator(){\n\t\tint i = 0;\n\n\t\tpublic boolean hasNext(){\n\t\t\treturn i < count();\n\t\t}\n\n\t\tpublic Object next(){\n\t\t\treturn nth(i++);\n\t\t}\n\n\t\tpublic void remove(){\n\t\t\tthrow new UnsupportedOperationException();\n\t\t}\n\t};\n}\n\npublic Object peek(){\n\tif(count() > 0)\n\t\treturn nth(count() - 1);\n\treturn null;\n}\n\npublic boolean containsKey(Object key){\n\tif(!(Util.isInteger(key)))\n\t\treturn false;\n\tint i = ((Number) key).intValue();\n\treturn i >= 0 && i < count();\n}\n\npublic IMapEntry entryAt(Object key){\n\tif(Util.isInteger(key))\n\t\t{\n\t\tint i = ((Number) key).intValue();\n\t\tif(i >= 0 && i < count())\n\t\t\treturn new MapEntry(key, nth(i));\n\t\t}\n\treturn null;\n}\n\npublic IPersistentVector assoc(Object key, Object val){\n\tif(Util.isInteger(key))\n\t\t{\n\t\tint i = ((Number) key).intValue();\n\t\treturn assocN(i, val);\n\t\t}\n\tthrow new IllegalArgumentException(\"Key must be integer\");\n}\n\npublic Object valAt(Object key, Object notFound){\n\tif(Util.isInteger(key))\n\t\t{\n\t\tint i = ((Number) key).intValue();\n\t\tif(i >= 0 && i < count())\n\t\t\treturn nth(i);\n\t\t}\n\treturn notFound;\n}\n\npublic Object valAt(Object key){\n\treturn valAt(key, null);\n}\n\n// java.util.Collection implementation\n\npublic Object[] toArray(){\n\treturn RT.seqToArray(seq());\n}\n\npublic boolean add(Object o){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean remove(Object o){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean addAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic void clear(){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean retainAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean removeAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean containsAll(Collection c){\n\tfor(Object o : c)\n\t\t{\n\t\tif(!contains(o))\n\t\t\treturn false;\n\t\t}\n\treturn true;\n}\n\npublic Object[] toArray(Object[] a){\n    return RT.seqToPassedArray(seq(), a);\n}\n\npublic int size(){\n\treturn count();\n}\n\npublic boolean isEmpty(){\n\treturn count() == 0;\n}\n\npublic boolean contains(Object o){\n\tfor(ISeq s = seq(); s != null; s = s.next())\n\t\t{\n\t\tif(Util.equiv(s.first(), o))\n\t\t\treturn true;\n\t\t}\n\treturn false;\n}\n\npublic int length(){\n\treturn count();\n}\n\npublic int compareTo(Object o){\n\tIPersistentVector v = (IPersistentVector) o;\n\tif(count() < v.count())\n\t\treturn -1;\n\telse if(count() > v.count())\n\t\treturn 1;\n\tfor(int i = 0; i < count(); i++)\n\t\t{\n\t\tint c = Util.compare(nth(i),v.nth(i));\n\t\tif(c != 0)\n\t\t\treturn c;\n\t\t}\n\treturn 0;\n}\n\n    static class Seq extends ASeq implements IndexedSeq, IReduce{\n\t//todo - something more efficient\n\tfinal IPersistentVector v;\n\tfinal int i;\n\n\n\tpublic Seq(IPersistentVector v, int i){\n\t\tthis.v = v;\n\t\tthis.i = i;\n\t}\n\n\tSeq(IPersistentMap meta, IPersistentVector v, int i){\n\t\tsuper(meta);\n\t\tthis.v = v;\n\t\tthis.i = i;\n\t}\n\n\tpublic Object first(){\n\t\treturn v.nth(i);\n\t}\n\n\tpublic ISeq next(){\n\t\tif(i + 1 < v.count())\n\t\t\treturn new APersistentVector.Seq(v, i + 1);\n\t\treturn null;\n\t}\n\n\tpublic int index(){\n\t\treturn i;\n\t}\n\n\tpublic int count(){\n\t\treturn v.count() - i;\n\t}\n\n\tpublic APersistentVector.Seq withMeta(IPersistentMap meta){\n\t\treturn new APersistentVector.Seq(meta, v, i);\n\t}\n\n\tpublic Object reduce(IFn f) {\n\t\tObject ret = v.nth(i);\n\t\tfor(int x = i + 1; x < v.count(); x++) {\n            ret = f.invoke(ret, v.nth(x));\n            if (RT.isReduced(ret)) return ((IDeref)ret).deref();\n        }\n\t\treturn ret;\n\t}\n\n\tpublic Object reduce(IFn f, Object start) {\n\t\tObject ret = f.invoke(start, v.nth(i));\n\t\tfor(int x = i + 1; x < v.count(); x++) {\n            if (RT.isReduced(ret)) return ((IDeref)ret).deref();\n            ret = f.invoke(ret, v.nth(x));\n        }\n\t\tif (RT.isReduced(ret)) return ((IDeref)ret).deref();\n\t\treturn ret;\n\t}\n    }\n\npublic static class RSeq extends ASeq implements IndexedSeq, Counted{\n\tfinal IPersistentVector v;\n\tfinal int i;\n\n\tpublic RSeq(IPersistentVector vector, int i){\n\t\tthis.v = vector;\n\t\tthis.i = i;\n\t}\n\n\tRSeq(IPersistentMap meta, IPersistentVector v, int i){\n\t\tsuper(meta);\n\t\tthis.v = v;\n\t\tthis.i = i;\n\t}\n\n\tpublic Object first(){\n\t\treturn v.nth(i);\n\t}\n\n\tpublic ISeq next(){\n\t\tif(i > 0)\n\t\t\treturn new APersistentVector.RSeq(v, i - 1);\n\t\treturn null;\n\t}\n\n\tpublic int index(){\n\t\treturn i;\n\t}\n\n\tpublic int count(){\n\t\treturn i + 1;\n\t}\n\n\tpublic APersistentVector.RSeq withMeta(IPersistentMap meta){\n\t\treturn new APersistentVector.RSeq(meta, v, i);\n\t}\n}\n\npublic static class SubVector extends APersistentVector implements IObj{\n\tpublic final IPersistentVector v;\n\tpublic final int start;\n\tpublic final int end;\n\tfinal IPersistentMap _meta;\n\n\n\n\tpublic SubVector(IPersistentMap meta, IPersistentVector v, int start, int end){\n\t\tthis._meta = meta;\n\n\t\tif(v instanceof APersistentVector.SubVector)\n\t\t\t{\n\t\t\tAPersistentVector.SubVector sv = (APersistentVector.SubVector) v;\n\t\t\tstart += sv.start;\n\t\t\tend += sv.start;\n\t\t\tv = sv.v;\n\t\t\t}\n\t\tthis.v = v;\n\t\tthis.start = start;\n\t\tthis.end = end;\n\t}\n\n\tpublic Iterator iterator(){\n\t\tif (v instanceof APersistentVector) {\n\t\t\treturn ((APersistentVector)v).rangedIterator(start,end);\n\t\t}\n\t\treturn super.iterator();\n\t}\n\n\tpublic Object nth(int i){\n\t\tif((start + i >= end) || (i < 0))\n\t\t\tthrow new IndexOutOfBoundsException();\n\t\treturn v.nth(start + i);\n\t}\n\n\tpublic IPersistentVector assocN(int i, Object val){\n\t\tif(start + i > end)\n\t\t\tthrow new IndexOutOfBoundsException();\n\t\telse if(start + i == end)\n\t\t\treturn cons(val);\n\t\treturn new SubVector(_meta, v.assocN(start + i, val), start, end);\n\t}\n\n\tpublic int count(){\n\t\treturn end - start;\n\t}\n\n\tpublic IPersistentVector cons(Object o){\n\t\treturn new SubVector(_meta, v.assocN(end, o), start, end + 1);\n\t}\n\n\tpublic IPersistentCollection empty(){\n\t\treturn PersistentVector.EMPTY.withMeta(meta());\n\t}\n\n\tpublic IPersistentStack pop(){\n\t\tif(end - 1 == start)\n\t\t\t{\n\t\t\treturn PersistentVector.EMPTY;\n\t\t\t}\n\t\treturn new SubVector(_meta, v, start, end - 1);\n\t}\n\n\tpublic SubVector withMeta(IPersistentMap meta){\n\t\tif(meta == _meta)\n\t\t\treturn this;\n\t\treturn new SubVector(meta, v, start, end);\n\t}\n\n\tpublic IPersistentMap meta(){\n\t\treturn _meta;\n\t}\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ARef.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jan 1, 2009 */\n\npackage clojure.lang;\n\nimport java.util.Map;\n\npublic abstract class ARef extends AReference implements IRef{\nprotected volatile IFn validator = null;\nprivate volatile IPersistentMap watches = PersistentHashMap.EMPTY;\n\npublic ARef(){\n\tsuper();\n}\n\npublic ARef(IPersistentMap meta){\n\tsuper(meta);\n}\n\nvoid validate(IFn vf, Object val){\n\ttry\n\t\t{\n\t\tif(vf != null && !RT.booleanCast(vf.invoke(val)))\n\t\t\tthrow new IllegalStateException(\"Invalid reference state\");\n\t\t}\n\tcatch(RuntimeException re)\n\t\t{\n\t\tthrow re;\n\t\t}\n\tcatch(Exception e)\n\t\t{\n\t\tthrow new IllegalStateException(\"Invalid reference state\", e);\n\t\t}\n}\n\nvoid validate(Object val){\n\tvalidate(validator, val);\n}\n\npublic void setValidator(IFn vf){\n\tvalidate(vf, deref());\n\tvalidator = vf;\n}\n\npublic IFn getValidator(){\n\treturn validator;\n}\n\npublic IPersistentMap getWatches(){\n\treturn watches;\n}\n\nsynchronized public IRef addWatch(Object key, IFn callback){\n\twatches = watches.assoc(key, callback);\n\treturn this;\n}\n\nsynchronized public IRef removeWatch(Object key){\n\twatches = watches.without(key);\n\treturn this;\n}\n\npublic void notifyWatches(Object oldval, Object newval){\n\tIPersistentMap ws = watches;\n\tif(ws.count() > 0)\n\t\t{\n\t\tfor(ISeq s = ws.seq(); s != null; s = s.next())\n\t\t\t{\n\t\t\tMap.Entry e = (Map.Entry) s.first();\n\t\t\tIFn fn = (IFn) e.getValue();\n\t\t\tif(fn != null)\n                                fn.invoke(e.getKey(), this, oldval, newval);\n\t\t\t}\n\t\t}\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/AReference.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Dec 31, 2008 */\n\npackage clojure.lang;\n\npublic class AReference implements IReference {\n    private IPersistentMap _meta;\n\n    public AReference() {\n        this(null);\n    }\n\n    public AReference(IPersistentMap meta) {\n        _meta = meta;\n    }\n\n    synchronized public IPersistentMap meta() {\n        return _meta;\n    }\n\n    synchronized public IPersistentMap alterMeta(IFn alter, ISeq args)  {\n        _meta = (IPersistentMap) alter.applyTo(new Cons(_meta, args));\n        return _meta;\n    }\n\n    synchronized public IPersistentMap resetMeta(IPersistentMap m) {\n        _meta = m;\n        return m;\n    }\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ASeq.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.io.Serializable;\nimport java.util.*;\n\npublic abstract class ASeq extends Obj implements ISeq, Sequential, List, Serializable, IHashEq {\ntransient int _hash = -1;\ntransient int _hasheq = -1;\n\npublic String toString(){\n\treturn RT.printString(this);\n}\n\npublic IPersistentCollection empty(){\n\treturn PersistentList.EMPTY;\n}\n\nprotected ASeq(IPersistentMap meta){\n\tsuper(meta);\n}\n\n\nprotected ASeq(){\n}\n\npublic boolean equiv(Object obj){\n\n\tif(!(obj instanceof Sequential || obj instanceof List))\n\t\treturn false;\n\tISeq ms = RT.seq(obj);\n\tfor(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())\n\t\t{\n\t\tif(ms == null || !Util.equiv(s.first(), ms.first()))\n\t\t\treturn false;\n\t\t}\n\treturn ms == null;\n\n}\n\npublic boolean equals(Object obj){\n\tif(this == obj) return true;\n\tif(!(obj instanceof Sequential || obj instanceof List))\n\t\treturn false;\n\tISeq ms = RT.seq(obj);\n\tfor(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())\n\t\t{\n\t\tif(ms == null || !Util.equals(s.first(), ms.first()))\n\t\t\treturn false;\n\t\t}\n\treturn ms == null;\n\n}\n\npublic int hashCode(){\n\tif(_hash == -1)\n\t\t{\n\t\tint hash = 1;\n\t\tfor(ISeq s = seq(); s != null; s = s.next())\n\t\t\t{\n\t\t\thash = 31 * hash + (s.first() == null ? 0 : Util.hash(s.first()));\n\t\t\t}\n\t\tthis._hash = hash;\n\t\t}\n\treturn _hash;\n}\n\npublic int hasheq(){\n\tif(_hasheq == -1)\n\t\t{\n//\t\tint hash = 1;\n//\t\tfor(ISeq s = seq(); s != null; s = s.next())\n//\t\t\t{\n//\t\t\thash = 31 * hash + Util.hasheq(s.first());\n//\t\t\t}\n//\t\tthis._hasheq = hash;\n\t\t_hasheq  = Murmur3.hashOrdered(this);\n\t\t}\n\treturn _hasheq;\n}\n\n\n//public Object reduce(IFn f) {\n//\tObject ret = first();\n//\tfor(ISeq s = rest(); s != null; s = s.rest())\n//\t\tret = f.invoke(ret, s.first());\n//\treturn ret;\n//}\n//\n//public Object reduce(IFn f, Object start) {\n//\tObject ret = f.invoke(start, first());\n//\tfor(ISeq s = rest(); s != null; s = s.rest())\n//\t\tret = f.invoke(ret, s.first());\n//\treturn ret;\n//}\n\n//public Object peek(){\n//\treturn first();\n//}\n//\n//public IPersistentList pop(){\n//\treturn rest();\n//}\n\npublic int count(){\n\tint i = 1;\n\tfor(ISeq s = next(); s != null; s = s.next(), i++)\n\t\tif(s instanceof Counted)\n\t\t\treturn i + s.count();\n\treturn i;\n}\n\nfinal public ISeq seq(){\n\treturn this;\n}\n\npublic ISeq cons(Object o){\n\treturn new Cons(o, this);\n}\n\npublic ISeq more(){\n    ISeq s = next();\n    if(s == null)\n        return PersistentList.EMPTY;\n    return s;\n}\n\n//final public ISeq rest(){\n//    Seqable m = more();\n//    if(m == null)\n//        return null;\n//    return m.seq();\n//}\n\n// java.util.Collection implementation\n\npublic Object[] toArray(){\n\treturn RT.seqToArray(seq());\n}\n\npublic boolean add(Object o){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean remove(Object o){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean addAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic void clear(){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean retainAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean removeAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean containsAll(Collection c){\n\tfor(Object o : c)\n\t\t{\n\t\tif(!contains(o))\n\t\t\treturn false;\n\t\t}\n\treturn true;\n}\n\npublic Object[] toArray(Object[] a){\n    return RT.seqToPassedArray(seq(), a);\n}\n\npublic int size(){\n\treturn count();\n}\n\npublic boolean isEmpty(){\n\treturn seq() == null;\n}\n\npublic boolean contains(Object o){\n\tfor(ISeq s = seq(); s != null; s = s.next())\n\t\t{\n\t\tif(Util.equiv(s.first(), o))\n\t\t\treturn true;\n\t\t}\n\treturn false;\n}\n\n\npublic Iterator iterator(){\n\treturn new SeqIterator(this);\n}\n\n\n\n//////////// List stuff /////////////////\nprivate List reify(){\n\treturn Collections.unmodifiableList(new ArrayList(this));\n}\n\npublic List subList(int fromIndex, int toIndex){\n\treturn reify().subList(fromIndex, toIndex);\n}\n\npublic Object set(int index, Object element){\n\tthrow new UnsupportedOperationException();\n}\n\npublic Object remove(int index){\n\tthrow new UnsupportedOperationException();\n}\n\npublic int indexOf(Object o){\n\tISeq s = seq();\n\tfor(int i = 0; s != null; s = s.next(), i++)\n\t\t{\n\t\tif(Util.equiv(s.first(), o))\n\t\t\treturn i;\n\t\t}\n\treturn -1;\n}\n\npublic int lastIndexOf(Object o){\n\treturn reify().lastIndexOf(o);\n}\n\npublic ListIterator listIterator(){\n\treturn reify().listIterator();\n}\n\npublic ListIterator listIterator(int index){\n\treturn reify().listIterator(index);\n}\n\npublic Object get(int index){\n\treturn RT.nth(this, index);\n}\n\npublic void add(int index, Object element){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean addAll(int index, Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ATransientMap.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.util.Map;\n\nimport clojure.lang.PersistentHashMap.INode;\n\nabstract class ATransientMap extends AFn implements ITransientMap {\n\tabstract void ensureEditable();\n\tabstract ITransientMap doAssoc(Object key, Object val);\n\tabstract ITransientMap doWithout(Object key);\n\tabstract Object doValAt(Object key, Object notFound);\n\tabstract int doCount();\n\tabstract IPersistentMap doPersistent();\n\n\tpublic ITransientMap conj(Object o) {\n\t\tensureEditable();\n\t\tif(o instanceof Map.Entry)\n\t\t\t{\n\t\t\tMap.Entry e = (Map.Entry) o;\n\t\t\n\t\t\treturn assoc(e.getKey(), e.getValue());\n\t\t\t}\n\t\telse if(o instanceof IPersistentVector)\n\t\t\t{\n\t\t\tIPersistentVector v = (IPersistentVector) o;\n\t\t\tif(v.count() != 2)\n\t\t\t\tthrow new IllegalArgumentException(\"Vector arg to map conj must be a pair\");\n\t\t\treturn assoc(v.nth(0), v.nth(1));\n\t\t\t}\n\t\t\n\t\tITransientMap ret = this;\n\t\tfor(ISeq es = RT.seq(o); es != null; es = es.next())\n\t\t\t{\n\t\t\tMap.Entry e = (Map.Entry) es.first();\n\t\t\tret = ret.assoc(e.getKey(), e.getValue());\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tpublic final Object invoke(Object arg1) {\n\t\treturn valAt(arg1);\n\t}\n\n\tpublic final Object invoke(Object arg1, Object notFound) {\n\t\treturn valAt(arg1, notFound);\n\t}\n\n\tpublic final Object valAt(Object key) {\n\t\treturn valAt(key, null);\n\t}\n\n\tpublic final ITransientMap assoc(Object key, Object val) {\n\t\tensureEditable();\n\t\treturn doAssoc(key, val);\n\t}\n\n\tpublic final ITransientMap without(Object key) {\n\t\tensureEditable();\n\t\treturn doWithout(key);\n\t}\n\n\tpublic final IPersistentMap persistent() {\n\t\tensureEditable();\n\t\treturn doPersistent();\n\t}\n\n\tpublic final Object valAt(Object key, Object notFound) {\n\t\tensureEditable();\n\t\treturn doValAt(key, notFound);\n\t}\n\n\tpublic final int count() {\n\t\tensureEditable();\n\t\treturn doCount();\n\t}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ATransientSet.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 3, 2008 */\n\npackage clojure.lang;\n\npublic abstract class ATransientSet extends AFn implements ITransientSet{\n\tvolatile ITransientMap impl;\n\n\tATransientSet(ITransientMap impl) {\n\t\tthis.impl = impl;\n\t}\n\t\n\tpublic int count() {\n\t\treturn impl.count();\n\t}\n\n\tpublic ITransientSet conj(Object val) {\n\t\tITransientMap m = impl.assoc(val, val);\n\t\tif (m != impl) this.impl = m;\n\t\treturn this;\n\t}\n\n\tpublic boolean contains(Object key) {\n\t\treturn this != impl.valAt(key, this);\n\t}\n\n\tpublic ITransientSet disjoin(Object key)  {\n\t\tITransientMap m = impl.without(key);\n\t\tif (m != impl) this.impl = m;\n\t\treturn this;\n\t}\n\n\tpublic Object get(Object key) {\n\t\treturn impl.valAt(key);\n\t}\n\n\tpublic Object invoke(Object key, Object notFound)  {\n\t\treturn impl.valAt(key, notFound);\n\t}\n\n\tpublic Object invoke(Object key)  {\n\t\treturn impl.valAt(key);\t\n\t}\n\t\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Agent.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Nov 17, 2007 */\n\npackage clojure.lang;\n\nimport java.util.concurrent.Executor;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.atomic.AtomicReference;\n\npublic class Agent extends ARef {\n\nstatic class ActionQueue {\n\tpublic final IPersistentStack q;\n\tpublic final Throwable error; // non-null indicates fail state\n\tstatic final ActionQueue EMPTY = new ActionQueue(PersistentQueue.EMPTY, null);\n\n\tpublic ActionQueue( IPersistentStack q, Throwable error )\n\t\t{\n\t\tthis.q = q;\n\t\tthis.error = error;\n\t\t}\n}\n\nstatic final Keyword CONTINUE = Keyword.intern(null, \"continue\");\nstatic final Keyword FAIL = Keyword.intern(null, \"fail\");\n\nvolatile Object state;\n    AtomicReference<ActionQueue> aq = new AtomicReference<ActionQueue>(ActionQueue.EMPTY);\n\n    volatile Keyword errorMode = CONTINUE;\n    volatile IFn errorHandler = null;\n\n//final private static AtomicLong sendThreadPoolCounter = new AtomicLong(0);\n\n//final private static AtomicLong sendOffThreadPoolCounter = new AtomicLong(0);\n\nvolatile public static java.util.concurrent.ExecutorService pooledExecutor =\n\tExecutors.newFixedThreadPool(2 + Runtime.getRuntime().availableProcessors());\n//,createThreadFactory(\"clojure-agent-send-pool-%d\", sendThreadPoolCounter)\n\nvolatile public static java.util.concurrent.ExecutorService soloExecutor = Executors.newCachedThreadPool();\n//createThreadFactory(\"clojure-agent-send-off-pool-%d\", sendOffThreadPoolCounter)\n\nfinal static ThreadLocal<IPersistentVector> nested = new ThreadLocal<IPersistentVector>();\n\n//private static java.util.concurrent.ThreadFactory createThreadFactory(final String format, final AtomicLong threadPoolCounter) {\n//\treturn new java.util.concurrent.ThreadFactory() {\n//\t\tpublic Thread newThread(Runnable runnable) {\n//\t\t\tThread thread = new Thread(runnable);\n//\t\t\tthread.setName(String.format(format, threadPoolCounter.getAndIncrement()));\n//\t\t\treturn thread;\n//\t\t}\n//\t};\n//}\n\npublic static void shutdown(){\n\tsoloExecutor.shutdown();\n\tpooledExecutor.shutdown();\n}\n\nstatic class Action implements Runnable{\n\tfinal Agent agent;\n\tfinal IFn fn;\n\tfinal ISeq args;\n\tfinal Executor exec;\n\n\n\tpublic Action(Agent agent, IFn fn, ISeq args, Executor exec){\n\t\tthis.agent = agent;\n\t\tthis.args = args;\n\t\tthis.fn = fn;\n\t\tthis.exec = exec;\n\t}\n\n\tvoid execute(){\n\t\ttry\n\t\t\t{\n\t\t\texec.execute(this);\n\t\t\t}\n\t\tcatch(Throwable error)\n\t\t\t{\n\t\t\tif(agent.errorHandler != null)\n\t\t\t\t{\n\t\t\t\ttry\n\t\t\t\t\t{\n\t\t\t\t\tagent.errorHandler.invoke(agent, error);\n\t\t\t\t\t}\n\t\t\t\tcatch(Throwable e) {} // ignore errorHandler errors\n\t\t\t\t}\n\t\t\t}\n\t}\n\n\tstatic void doRun(Action action){\n\t\ttry\n\t\t\t{\n\t\t\tnested.set(PersistentVector.EMPTY);\n\n\t\t\tThrowable error = null;\n\t\t\ttry\n\t\t\t\t{\n\t\t\t\tObject oldval = action.agent.state;\n\t\t\t\tObject newval =  action.fn.applyTo(RT.cons(action.agent.state, action.args));\n\t\t\t\taction.agent.setState(newval);\n                action.agent.notifyWatches(oldval,newval);\n\t\t\t\t}\n\t\t\tcatch(Throwable e)\n\t\t\t\t{\n\t\t\t\terror = e;\n\t\t\t\t}\n\n\t\t\tif(error == null)\n\t\t\t\t{\n\t\t\t\treleasePendingSends();\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tnested.set(null); // allow errorHandler to send\n\t\t\t\tif(action.agent.errorHandler != null)\n\t\t\t\t\t{\n\t\t\t\t\ttry\n\t\t\t\t\t\t{\n\t\t\t\t\t\taction.agent.errorHandler.invoke(action.agent, error);\n\t\t\t\t\t\t}\n\t\t\t\t\tcatch(Throwable e) {} // ignore errorHandler errors\n\t\t\t\t\t}\n\t\t\t\tif(action.agent.errorMode == CONTINUE)\n\t\t\t\t\t{\n\t\t\t\t\terror = null;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tboolean popped = false;\n\t\t\tActionQueue next = null;\n\t\t\twhile(!popped)\n\t\t\t\t{\n\t\t\t\tActionQueue prior = action.agent.aq.get();\n\t\t\t\tnext = new ActionQueue(prior.q.pop(), error);\n\t\t\t\tpopped = action.agent.aq.compareAndSet(prior, next);\n\t\t\t\t}\n\n\t\t\tif(error == null && next.q.count() > 0)\n\t\t\t\t((Action) next.q.peek()).execute();\n\t\t\t}\n\t\tfinally\n\t\t\t{\n\t\t\tnested.set(null);\n\t\t\t}\n\t}\n\n\tpublic void run(){\n\t\tdoRun(this);\n\t}\n}\n\npublic Agent(Object state) {\n\tthis(state,null);\n}\n\npublic Agent(Object state, IPersistentMap meta)  {\n    super(meta);\n    setState(state);\n}\n\nboolean setState(Object newState) {\n\tvalidate(newState);\n\tboolean ret = state != newState;\n\tstate = newState;\n\treturn ret;\n}\n\npublic Object deref() {\n\treturn state;\n}\n\npublic Throwable getError(){\n\treturn aq.get().error;\n}\n\npublic void setErrorMode(Keyword k){\n\terrorMode = k;\n}\n\npublic Keyword getErrorMode(){\n\treturn errorMode;\n}\n\npublic void setErrorHandler(IFn f){\n\terrorHandler = f;\n}\n\npublic IFn getErrorHandler(){\n\treturn errorHandler;\n}\n\nsynchronized public Object restart(Object newState, boolean clearActions){\n\tif(getError() == null)\n\t\t{\n\t\tthrow Util.runtimeException(\"Agent does not need a restart\");\n\t\t}\n\tvalidate(newState);\n\tstate = newState;\n\n\tif(clearActions)\n\t\taq.set(ActionQueue.EMPTY);\n\telse\n\t\t{\n\t\tboolean restarted = false;\n\t\tActionQueue prior = null;\n\t\twhile(!restarted)\n\t\t\t{\n\t\t\tprior = aq.get();\n\t\t\trestarted = aq.compareAndSet(prior, new ActionQueue(prior.q, null));\n\t\t\t}\n\n\t\tif(prior.q.count() > 0)\n\t\t\t((Action) prior.q.peek()).execute();\n\t\t}\n\n\treturn newState;\n}\n\npublic Object dispatch(IFn fn, ISeq args, Executor exec) {\n\tThrowable error = getError();\n\tif(error != null)\n\t\t{\n\t\tthrow Util.runtimeException(\"Agent is failed, needs restart\", error);\n\t\t}\n\tAction action = new Action(this, fn, args, exec);\n\tdispatchAction(action);\n\n\treturn this;\n}\n\nstatic void dispatchAction(Action action){\n\tLockingTransaction trans = LockingTransaction.getRunning();\n\tif(trans != null)\n\t\ttrans.enqueue(action);\n\telse if(nested.get() != null)\n\t\t{\n\t\tnested.set(nested.get().cons(action));\n\t\t}\n\telse\n\t\taction.agent.enqueue(action);\n}\n\nvoid enqueue(Action action){\n\tboolean queued = false;\n\tActionQueue prior = null;\n\twhile(!queued)\n\t\t{\n\t\tprior = aq.get();\n\t\tqueued = aq.compareAndSet(prior, new ActionQueue((IPersistentStack)prior.q.cons(action), prior.error));\n\t\t}\n\n\tif(prior.q.count() == 0 && prior.error == null)\n\t\taction.execute();\n}\n\npublic int getQueueCount(){\n\treturn aq.get().q.count();\n}\n\nstatic public int releasePendingSends(){\n\tIPersistentVector sends = nested.get();\n\tif(sends == null)\n\t\treturn 0;\n\tfor(int i=0;i<sends.count();i++)\n\t\t{\n\t\tAction a = (Action) sends.valAt(i);\n\t\ta.agent.enqueue(a);\n\t\t}\n\tnested.set(PersistentVector.EMPTY);\n\treturn sends.count();\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ArityException.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\n/**\n * @since 1.3\n */\npublic class ArityException extends IllegalArgumentException {\n\n\tfinal public int actual;\n\n\tfinal public String name;\n\n\tpublic ArityException(int actual, String name) {\n\t\tthis(actual, name, null);\n\t}\n\n\tpublic ArityException(int actual, String name, Throwable cause) {\n\t\tsuper(\"Wrong number of args (\" + actual + \") passed to: \" + name, cause);\n\t\tthis.actual = actual;\n\t\tthis.name = name;\n\t}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ArrayChunk.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich May 24, 2009 */\n\npackage clojure.lang;\n\nimport java.io.Serializable;\n\npublic final class ArrayChunk implements IChunk, Serializable {\n\nfinal Object[] array;\nfinal int off;\nfinal int end;\n\npublic ArrayChunk(Object[] array){\n\tthis(array, 0, array.length);\n}\n\npublic ArrayChunk(Object[] array, int off){\n\tthis(array, off, array.length);\n}\n\npublic ArrayChunk(Object[] array, int off, int end){\n\tthis.array = array;\n\tthis.off = off;\n\tthis.end = end;\n}\n\npublic Object nth(int i){\n\treturn array[off + i];\n}\n\npublic Object nth(int i, Object notFound){\n\tif(i >= 0 && i < count())\n\t\treturn nth(i);\n\treturn notFound;\n}\n\npublic int count(){\n\treturn end - off;\n}\n\npublic IChunk dropFirst(){\n\tif(off==end)\n\t\tthrow new IllegalStateException(\"dropFirst of empty chunk\");\n\treturn new ArrayChunk(array, off + 1, end);\n}\n\npublic Object reduce(IFn f, Object start) {\n\t\tObject ret = f.invoke(start, array[off]);\n\t\tif(RT.isReduced(ret))\n\t\t\treturn ret;\n\t\tfor(int x = off + 1; x < end; x++)\n\t\t\t{\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ret;\n\t\t\t}\n\t\treturn ret;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ArrayIter.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n *    the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.lang.reflect.Array;\nimport java.util.Iterator;\n\npublic class ArrayIter implements Iterator {\nfinal Object[] array;\nint i;\n\nstatic public Iterator EMPTY_ITERATOR = new Iterator() {\n  public boolean hasNext() { return false; }\n  public Object next() { return null; }\n  public void remove() { throw new UnsupportedOperationException(\"remove() not supported\"); }\n};\n\nstatic public Iterator create(){\n  return EMPTY_ITERATOR;\n}\n\nstatic public Iterator create(Object... array){\n  if(array == null || array.length == 0)\n    return EMPTY_ITERATOR;\n  return new ArrayIter(array, 0);\n}\n\nstatic public Iterator createFromObject(Object array){\n  if(array == null || Array.getLength(array) == 0)\n    return EMPTY_ITERATOR;\n  Class aclass = array.getClass();\n  if(aclass == int[].class)\n    return new ArrayIter_int((int[]) array, 0);\n  if(aclass == float[].class)\n    return new ArrayIter_float((float[]) array, 0);\n  if(aclass == double[].class)\n    return new ArrayIter_double((double[]) array, 0);\n  if(aclass == long[].class)\n    return new ArrayIter_long((long[]) array, 0);\n  if(aclass == byte[].class)\n    return new ArrayIter_byte((byte[]) array, 0);\n  if(aclass == char[].class)\n    return new ArrayIter_char((char[]) array, 0);\n  if(aclass == short[].class)\n    return new ArrayIter_short((short[]) array, 0);\n  if(aclass == boolean[].class)\n    return new ArrayIter_boolean((boolean[]) array, 0);\n  return new ArrayIter(array, 0);\n}\n\nArrayIter(Object array, int i){\n  this.i = i;\n  this.array = (Object[]) array;\n}\n\npublic boolean hasNext() {\n  return array != null && i < array.length;\n}\n\npublic Object next() {\n  if(array != null && i < array.length)\n    return array[i++];\n  return null;\n}\n\npublic void remove() {\n  throw new UnsupportedOperationException(\"remove() not supported\");\n}\n\n//////////////////////////////////// specialized primitive versions ///////////////////////////////\n\nstatic public class ArrayIter_int implements Iterator<Long> {\n  final int[] array;\n  int i;\n\n  ArrayIter_int(int[] array, int i){\n    this.array = array;\n    this.i = i;\n  }\n\n  public boolean hasNext() {\n    return array != null && i < array.length;\n  }\n\n  public Long next() {\n    if(array != null && i < array.length)\n      return Long.valueOf(array[i++]);\n    return null;\n  }\n\n  public void remove() {\n    throw new UnsupportedOperationException(\"remove() not supported\");\n  }\n}\n\nstatic public class ArrayIter_float implements Iterator<Double> {\n  final float[] array;\n  int i;\n\n  ArrayIter_float(float[] array, int i){\n    this.array = array;\n    this.i = i;\n  }\n\n  public boolean hasNext() {\n    return array != null && i < array.length;\n  }\n\n  public Double next() {\n    if(array != null && i < array.length)\n      return Double.valueOf(array[i++]);\n    return null;\n  }\n\n  public void remove() {\n    throw new UnsupportedOperationException(\"remove() not supported\");\n  }\n}\n\nstatic public class ArrayIter_double implements Iterator<Double> {\n  final double[] array;\n  int i;\n\n  ArrayIter_double(double[] array, int i){\n    this.array = array;\n    this.i = i;\n  }\n\n  public boolean hasNext() {\n    return array != null && i < array.length;\n  }\n\n  public Double next() {\n    if(array != null && i < array.length)\n      return array[i++];\n    return null;\n  }\n\n  public void remove() {\n    throw new UnsupportedOperationException(\"remove() not supported\");\n  }\n\n}\n\nstatic public class ArrayIter_long implements Iterator<Long> {\n  final long[] array;\n  int i;\n\n  ArrayIter_long(long[] array, int i){\n    this.array = array;\n    this.i = i;\n  }\n\n  public boolean hasNext() {\n    return array != null && i < array.length;\n  }\n\n  public Long next() {\n    if(array != null && i < array.length)\n      return Long.valueOf(array[i++]);\n    return null;\n  }\n\n  public void remove() {\n    throw new UnsupportedOperationException(\"remove() not supported\");\n  }\n\n}\n\nstatic public class ArrayIter_byte implements Iterator<Byte> {\n  final byte[] array;\n  int i;\n\n  ArrayIter_byte(byte[] array, int i){\n    this.array = array;\n    this.i = i;\n  }\n\n  public boolean hasNext() {\n    return array != null && i < array.length;\n  }\n\n  public Byte next() {\n    if(array != null && i < array.length)\n      return array[i++];\n    return null;\n  }\n\n  public void remove() {\n    throw new UnsupportedOperationException(\"remove() not supported\");\n  }\n\n}\n\nstatic public class ArrayIter_char implements Iterator<Character> {\n  final char[] array;\n  int i;\n\n  ArrayIter_char(char[] array, int i){\n    this.array = array;\n    this.i = i;\n  }\n\n  public boolean hasNext() {\n    return array != null && i < array.length;\n  }\n\n  public Character next() {\n    if(array != null && i < array.length)\n      return array[i++];\n    return null;\n  }\n\n  public void remove() {\n    throw new UnsupportedOperationException(\"remove() not supported\");\n  }\n\n}\n\nstatic public class ArrayIter_short implements Iterator<Long> {\n  final short[] array;\n  int i;\n\n  ArrayIter_short(short[] array, int i){\n    this.array = array;\n    this.i = i;\n  }\n\n  public boolean hasNext() {\n    return array != null && i < array.length;\n  }\n\n  public Long next() {\n    if(array != null && i < array.length)\n      return Long.valueOf(array[i++]);\n    return null;\n  }\n\n  public void remove() {\n    throw new UnsupportedOperationException(\"remove() not supported\");\n  }\n\n}\n\nstatic public class ArrayIter_boolean implements Iterator<Boolean> {\n  final boolean[] array;\n  int i;\n\n  ArrayIter_boolean(boolean[] array, int i){\n    this.array = array;\n    this.i = i;\n  }\n\n  public boolean hasNext() {\n    return array != null && i < array.length;\n  }\n\n  public Boolean next() {\n    if(array != null && i < array.length)\n      return Boolean.valueOf(array[i++]);\n    return null;\n  }\n\n  public void remove() {\n    throw new UnsupportedOperationException(\"remove() not supported\");\n  }\n\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ArraySeq.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jun 19, 2006 */\n\npackage clojure.lang;\n\nimport java.lang.reflect.Array;\n\npublic class ArraySeq extends ASeq implements IndexedSeq, IReduce{\npublic final Object[] array;\nfinal int i;\n//ISeq _rest;\n\nstatic public ArraySeq create(){\n\treturn null;\n}\n\nstatic public ArraySeq create(Object... array){\n\tif(array == null || array.length == 0)\n\t\treturn null;\n\treturn new ArraySeq(array, 0);\n}\n\nstatic ISeq createFromObject(Object array){\n\tif(array == null || Array.getLength(array) == 0)\n\t\treturn null;\n\tClass aclass = array.getClass();\n\tif(aclass == int[].class)\n\t\treturn new ArraySeq_int(null, (int[]) array, 0);\n\tif(aclass == float[].class)\n\t\treturn new ArraySeq_float(null, (float[]) array, 0);\n\tif(aclass == double[].class)\n\t\treturn new ArraySeq_double(null, (double[]) array, 0);\n\tif(aclass == long[].class)\n\t\treturn new ArraySeq_long(null, (long[]) array, 0);\n\tif(aclass == byte[].class)\n\t\treturn new ArraySeq_byte(null, (byte[]) array, 0);\n\tif(aclass == char[].class)\n\t\treturn new ArraySeq_char(null, (char[]) array, 0);\n        if(aclass == short[].class)\n            return new ArraySeq_short(null, (short[]) array, 0);\n\tif(aclass == boolean[].class)\n\t\treturn new ArraySeq_boolean(null, (boolean[]) array, 0);\n\treturn new ArraySeq(array, 0);\n}\n\nArraySeq(Object array, int i){\n\tthis.i = i;\n\tthis.array = (Object[]) array;\n//    this._rest = this;\n}\n\nArraySeq(IPersistentMap meta, Object array, int i){\n\tsuper(meta);\n\tthis.i = i;\n\tthis.array = (Object[]) array;\n}\n\npublic Object first(){\n\tif(array != null)\n\t\treturn array[i];\n\treturn null;\n}\n\npublic ISeq next(){\n\tif(array != null && i + 1 < array.length)\n\t\treturn new ArraySeq(array, i + 1);\n\treturn null;\n}\n\npublic int count(){\n\tif(array != null)\n\t\treturn array.length - i;\n\treturn 0;\n}\n\npublic int index(){\n\treturn i;\n}\n\npublic ArraySeq withMeta(IPersistentMap meta){\n\treturn new ArraySeq(meta, array, i);\n}\n\npublic Object reduce(IFn f) {\n\tif(array != null) {\n\t\tObject ret = array[i];\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\t}\n\t\treturn ret;\n\t}\n\treturn null;\n}\n\npublic Object reduce(IFn f, Object start) {\n\tif(array != null) {\n\t\tObject ret = f.invoke(start, array[i]);\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\t}\n\t\tif(RT.isReduced(ret))\n\t\t\treturn ((IDeref)ret).deref();\n\t\treturn ret;\n\t}\n\treturn null;\n}\n\npublic int indexOf(Object o) {\n\tif(array != null)\n\t\tfor (int j = i; j < array.length; j++)\n\t\t\tif (Util.equals(o, array[j])) return j - i;\n\treturn -1;\n}\n\npublic int lastIndexOf(Object o) {\n\tif (array != null) {\n\t\tif (o == null) {\n\t\t\tfor (int j = array.length - 1 ; j >= i; j--)\n\t\t\t\tif (array[j] == null) return j - i;\n\t\t} else {\n\t\t\tfor (int j = array.length - 1 ; j >= i; j--)\n\t\t\t\tif (o.equals(array[j])) return j - i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n//////////////////////////////////// specialized primitive versions ///////////////////////////////\n\nstatic public class ArraySeq_int extends ASeq implements IndexedSeq, IReduce{\n\tpublic final int[] array;\n\tfinal int i;\n\n\tArraySeq_int(IPersistentMap meta, int[] array, int i){\n\t\tsuper(meta);\n\t\tthis.array = array;\n\t\tthis.i = i;\n\t}\n\n\tpublic Object first(){\n\t\treturn array[i];\n\t}\n\n\tpublic ISeq next(){\n\t\tif(i + 1 < array.length)\n\t\t\treturn new ArraySeq_int(meta(), array, i + 1);\n\t\treturn null;\n\t}\n\n\tpublic int count(){\n\t\treturn array.length - i;\n\t}\n\n\tpublic int index(){\n\t\treturn i;\n\t}\n\n\tpublic ArraySeq_int withMeta(IPersistentMap meta){\n\t\treturn new ArraySeq_int(meta, array, i);\n\t}\n\n\tpublic Object reduce(IFn f) {\n\t\tObject ret = array[i];\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tpublic Object reduce(IFn f, Object start) {\n\t\tObject ret = f.invoke(start, array[i]);\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\t}\n\t\tif(RT.isReduced(ret))\n\t\t\treturn ((IDeref)ret).deref();\n\t\treturn ret;\n\t}\n\n\tpublic int indexOf(Object o) {\n\t\tif (o instanceof Number) {\n\t\t\tint k = ((Number) o).intValue();\n\t\t\tfor (int j = i; j < array.length; j++)\n\t\t\t\tif (k == array[j]) return j - i;\n\t\t}\n\n\t\treturn -1;\n\t}\n\t\n\tpublic int lastIndexOf(Object o) {\n\t\tif (o instanceof Number) {\n\t\t\tint k = ((Number) o).intValue();\n\t\t\tfor (int j = array.length - 1; j >= i; j--)\n\t\t\t\tif (k == array[j]) return j - i;\n\t\t}\n\n\t\treturn -1;\n\t}\n}\n\n\nstatic public class ArraySeq_float extends ASeq implements IndexedSeq, IReduce{\n\tpublic final float[] array;\n\tfinal int i;\n\n\tArraySeq_float(IPersistentMap meta, float[] array, int i){\n\t\tsuper(meta);\n\t\tthis.array = array;\n\t\tthis.i = i;\n\t}\n\n\tpublic Object first(){\n\t\treturn Numbers.num(array[i]);\n\t}\n\n\tpublic ISeq next(){\n\t\tif(i + 1 < array.length)\n\t\t\treturn new ArraySeq_float(meta(), array, i + 1);\n\t\treturn null;\n\t}\n\n\tpublic int count(){\n\t\treturn array.length - i;\n\t}\n\n\tpublic int index(){\n\t\treturn i;\n\t}\n\n\tpublic ArraySeq_float withMeta(IPersistentMap meta){\n\t\treturn new ArraySeq_float(meta, array, i);\n\t}\n\n\tpublic Object reduce(IFn f) {\n\t\tObject ret = Numbers.num(array[i]);\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tret = f.invoke(ret, Numbers.num(array[x]));\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tpublic Object reduce(IFn f, Object start) {\n\t\tObject ret = f.invoke(start, Numbers.num(array[i]));\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\tret = f.invoke(ret, Numbers.num(array[x]));\n\t\t\t}\n\t\tif(RT.isReduced(ret))\n\t\t\treturn ((IDeref)ret).deref();\n\t\treturn ret;\n\t}\n\n\tpublic int indexOf(Object o) {\n\t\tif (o instanceof Number) {\n\t\t\tfloat f = ((Number) o).floatValue();\n\t\t\tfor (int j = i; j < array.length; j++)\n\t\t\t\tif (f == array[j]) return j - i;\n\t\t}\n\t\treturn -1;\n\t}\n\t\n\tpublic int lastIndexOf(Object o) {\n\t\tif (o instanceof Number) {\n\t\t\tfloat f = ((Number) o).floatValue();\n\t\t\tfor (int j = array.length - 1; j >= i; j--)\n\t\t\t\tif (f == array[j]) return j - i;\n\t\t}\n\t\treturn -1;\n\t}\n}\n\nstatic public class ArraySeq_double extends ASeq implements IndexedSeq, IReduce{\n\tpublic final double[] array;\n\tfinal int i;\n\n\tArraySeq_double(IPersistentMap meta, double[] array, int i){\n\t\tsuper(meta);\n\t\tthis.array = array;\n\t\tthis.i = i;\n\t}\n\n\tpublic Object first(){\n\t\treturn array[i];\n\t}\n\n\tpublic ISeq next(){\n\t\tif(i + 1 < array.length)\n\t\t\treturn new ArraySeq_double(meta(), array, i + 1);\n\t\treturn null;\n\t}\n\n\tpublic int count(){\n\t\treturn array.length - i;\n\t}\n\n\tpublic int index(){\n\t\treturn i;\n\t}\n\n\tpublic ArraySeq_double withMeta(IPersistentMap meta){\n\t\treturn new ArraySeq_double(meta, array, i);\n\t}\n\n\tpublic Object reduce(IFn f) {\n\t\tObject ret = array[i];\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tpublic Object reduce(IFn f, Object start) {\n\t\tObject ret = f.invoke(start, array[i]);\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\t}\n\t\tif(RT.isReduced(ret))\n\t\t\treturn ((IDeref)ret).deref();\n\t\treturn ret;\n\t}\n\n\tpublic int indexOf(Object o) {\n\t\tif (o instanceof Number) {\n\t\t\tdouble d = ((Number) o).doubleValue();\n\t\t\tfor (int j = i; j < array.length; j++)\n\t\t\t\tif (d == array[j]) return j - i;\n\t\t}\n\n\t\treturn -1;\n\t}\n\t\n\tpublic int lastIndexOf(Object o) {\n\t\tif (o instanceof Number) {\n\t\t\tdouble d = ((Number) o).doubleValue();\n\t\t\tfor (int j = array.length - 1; j >= i; j--)\n\t\t\t\tif (d == array[j]) return j - i;\n\t\t}\n\n\t\treturn -1;\n\t}\n}\n\nstatic public class ArraySeq_long extends ASeq implements IndexedSeq, IReduce{\n\tpublic final long[] array;\n\tfinal int i;\n\n\tArraySeq_long(IPersistentMap meta, long[] array, int i){\n\t\tsuper(meta);\n\t\tthis.array = array;\n\t\tthis.i = i;\n\t}\n\n\tpublic Object first(){\n\t\treturn Numbers.num(array[i]);\n\t}\n\n\tpublic ISeq next(){\n\t\tif(i + 1 < array.length)\n\t\t\treturn new ArraySeq_long(meta(), array, i + 1);\n\t\treturn null;\n\t}\n\n\tpublic int count(){\n\t\treturn array.length - i;\n\t}\n\n\tpublic int index(){\n\t\treturn i;\n\t}\n\n\tpublic ArraySeq_long withMeta(IPersistentMap meta){\n\t\treturn new ArraySeq_long(meta, array, i);\n\t}\n\n\tpublic Object reduce(IFn f) {\n\t\tObject ret = Numbers.num(array[i]);\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tret = f.invoke(ret, Numbers.num(array[x]));\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tpublic Object reduce(IFn f, Object start) {\n\t\tObject ret = f.invoke(start, Numbers.num(array[i]));\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\tret = f.invoke(ret, Numbers.num(array[x]));\n\t\t\t}\n\t\tif(RT.isReduced(ret))\n\t\t\treturn ((IDeref)ret).deref();\n\t\treturn ret;\n\t}\n\n\tpublic int indexOf(Object o) {\n\t\tif (o instanceof Number) {\n\t\t\tlong l = ((Number) o).longValue();\n\t\t\tfor (int j = i; j < array.length; j++)\n\t\t\t\tif (l == array[j]) return j - i;\n\t\t}\n\n\t\treturn -1;\n\t}\n\t\n\tpublic int lastIndexOf(Object o) {\n\t\tif (o instanceof Number) {\n\t\t\tlong l = ((Number) o).longValue();\n\t\t\tfor (int j = array.length - 1; j >= i; j--)\n\t\t\t\tif (l == array[j]) return j - i;\n\t\t}\n\n\t\treturn -1;\n\t}\n}\n\nstatic public class ArraySeq_byte extends ASeq implements IndexedSeq, IReduce{\n\tpublic final byte[] array;\n\tfinal int i;\n\n\tArraySeq_byte(IPersistentMap meta, byte[] array, int i){\n\t\tsuper(meta);\n\t\tthis.array = array;\n\t\tthis.i = i;\n\t}\n\n\tpublic Object first(){\n\t\treturn array[i];\n\t}\n\n\tpublic ISeq next(){\n\t\tif(i + 1 < array.length)\n\t\t\treturn new ArraySeq_byte(meta(), array, i + 1);\n\t\treturn null;\n\t}\n\n\tpublic int count(){\n\t\treturn array.length - i;\n\t}\n\n\tpublic int index(){\n\t\treturn i;\n\t}\n\n\tpublic ArraySeq_byte withMeta(IPersistentMap meta){\n\t\treturn new ArraySeq_byte(meta, array, i);\n\t}\n\n\tpublic Object reduce(IFn f) {\n\t\tObject ret = array[i];\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tpublic Object reduce(IFn f, Object start) {\n\t\tObject ret = f.invoke(start, array[i]);\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\t}\n\t\tif(RT.isReduced(ret))\n\t\t\treturn ((IDeref)ret).deref();\n\t\treturn ret;\n\t}\n\n\tpublic int indexOf(Object o) {\n\t\tif (o instanceof Byte) {\n\t\t\tbyte b = ((Byte) o).byteValue();\n\t\t\tfor (int j = i; j < array.length; j++)\n\t\t\t\tif (b == array[j]) return j - i;\n\t\t}\n\t\tif (o == null) {\n\t\t\treturn -1;\n\t\t}\n\t\tfor (int j = i; j < array.length; j++)\n\t\t\tif (o.equals(array[j])) return j - i;\n\t\treturn -1;\n\t}\n\t\n\tpublic int lastIndexOf(Object o) {\n\t\tif (o instanceof Byte) {\n\t\t\tbyte b = ((Byte) o).byteValue();\n\t\t\tfor (int j = array.length - 1; j >= i; j--)\n\t\t\t\tif (b == array[j]) return j - i;\n\t\t}\n\t\tif (o == null) {\n\t\t\treturn -1;\n\t\t}\n\t\tfor (int j = array.length - 1; j >= i; j--)\n\t\t\tif (o.equals(array[j])) return j - i;\n\t\treturn -1;\n\t}\n}\n\nstatic public class ArraySeq_char extends ASeq implements IndexedSeq, IReduce{\n\tpublic final char[] array;\n\tfinal int i;\n\n\tArraySeq_char(IPersistentMap meta, char[] array, int i){\n\t\tsuper(meta);\n\t\tthis.array = array;\n\t\tthis.i = i;\n\t}\n\n\tpublic Object first(){\n\t\treturn array[i];\n\t}\n\n\tpublic ISeq next(){\n\t\tif(i + 1 < array.length)\n\t\t\treturn new ArraySeq_char(meta(), array, i + 1);\n\t\treturn null;\n\t}\n\n\tpublic int count(){\n\t\treturn array.length - i;\n\t}\n\n\tpublic int index(){\n\t\treturn i;\n\t}\n\n\tpublic ArraySeq_char withMeta(IPersistentMap meta){\n\t\treturn new ArraySeq_char(meta, array, i);\n\t}\n\n\tpublic Object reduce(IFn f) {\n\t\tObject ret = array[i];\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tpublic Object reduce(IFn f, Object start) {\n\t\tObject ret = f.invoke(start, array[i]);\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\t}\n\t\tif(RT.isReduced(ret))\n\t\t\treturn ((IDeref)ret).deref();\n\t\treturn ret;\n\t}\n\t\n\tpublic int indexOf(Object o) {\n\t\tif (o instanceof Character) {\n\t\t\tchar c = ((Character) o).charValue();\n\t\t\tfor (int j = i; j < array.length; j++)\n\t\t\t\tif (c == array[j]) return j - i;\n\t\t}\n\t\tif (o == null) {\n\t\t\treturn -1;\n\t\t}\n\t\tfor (int j = i; j < array.length; j++)\n\t\t\tif (o.equals(array[j])) return j - i;\n\t\treturn -1;\n\t}\n\t\n\tpublic int lastIndexOf(Object o) {\n\t\tif (o instanceof Character) {\n\t\t\tchar c = ((Character) o).charValue();\n\t\t\tfor (int j = array.length - 1; j >= i; j--)\n\t\t\t\tif (c == array[j]) return j - i;\n\t\t}\n\t\tif (o == null) {\n\t\t\treturn -1;\n\t\t}\n\t\tfor (int j = array.length - 1; j >= i; j--)\n\t\t\tif (o.equals(array[j])) return j - i;\n\t\treturn -1;\n\t}\n}\n\nstatic public class ArraySeq_short extends ASeq implements IndexedSeq, IReduce{\n\tpublic final short[] array;\n\tfinal int i;\n\n\tArraySeq_short(IPersistentMap meta, short[] array, int i){\n\t\tsuper(meta);\n\t\tthis.array = array;\n\t\tthis.i = i;\n\t}\n\n\tpublic Object first(){\n\t\treturn array[i];\n\t}\n\n\tpublic ISeq next(){\n\t\tif(i + 1 < array.length)\n\t\t\treturn new ArraySeq_short(meta(), array, i + 1);\n\t\treturn null;\n\t}\n\n\tpublic int count(){\n\t\treturn array.length - i;\n\t}\n\n\tpublic int index(){\n\t\treturn i;\n\t}\n\n\tpublic ArraySeq_short withMeta(IPersistentMap meta){\n\t\treturn new ArraySeq_short(meta, array, i);\n\t}\n\n\tpublic Object reduce(IFn f) {\n\t\tObject ret = array[i];\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tpublic Object reduce(IFn f, Object start) {\n\t\tObject ret = f.invoke(start, array[i]);\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\t}\n\t\tif(RT.isReduced(ret))\n\t\t\treturn ((IDeref)ret).deref();\n\t\treturn ret;\n\t}\n\n\tpublic int indexOf(Object o) {\n\t\tif (o instanceof Short) {\n\t\t\tshort s = ((Short) o).shortValue();\n\t\t\tfor (int j = i; j < array.length; j++)\n\t\t\t\tif (s == array[j]) return j - i;\n\t\t}\n\t\tif (o == null) {\n\t\t\treturn -1;\n\t\t}\n\t\tfor (int j = i; j < array.length; j++)\n\t\t\tif (o.equals(array[j])) return j - i;\n\t\treturn -1;\n\t}\n\n\tpublic int lastIndexOf(Object o) {\n\t\tif (o instanceof Short) {\n\t\t\tshort s = ((Short) o).shortValue();\n\t\t\tfor (int j = array.length - 1; j >= i; j--)\n\t\t\t\tif (s == array[j]) return j - i;\n\t\t}\n\t\tif (o == null) {\n\t\t\treturn -1;\n\t\t}\n\t\tfor (int j = array.length - 1; j >= i; j--)\n\t\t\tif (o.equals(array[j])) return j - i;\n\t\treturn -1;\n\t}\n}\n\nstatic public class ArraySeq_boolean extends ASeq implements IndexedSeq, IReduce{\n\tpublic final boolean[] array;\n\tfinal int i;\n\n\tArraySeq_boolean(IPersistentMap meta, boolean[] array, int i){\n\t\tsuper(meta);\n\t\tthis.array = array;\n\t\tthis.i = i;\n\t}\n\n\tpublic Object first(){\n\t\treturn array[i];\n\t}\n\n\tpublic ISeq next(){\n\t\tif(i + 1 < array.length)\n\t\t\treturn new ArraySeq_boolean(meta(), array, i + 1);\n\t\treturn null;\n\t}\n\n\tpublic int count(){\n\t\treturn array.length - i;\n\t}\n\n\tpublic int index(){\n\t\treturn i;\n\t}\n\n\tpublic ArraySeq_boolean withMeta(IPersistentMap meta){\n\t\treturn new ArraySeq_boolean(meta, array, i);\n\t}\n\n\tpublic Object reduce(IFn f) {\n\t\tObject ret = array[i];\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tpublic Object reduce(IFn f, Object start) {\n\t\tObject ret = f.invoke(start, array[i]);\n\t\tfor(int x = i + 1; x < array.length; x++)\n\t\t\t{\n\t\t\tif(RT.isReduced(ret))\n\t\t\t\treturn ((IDeref)ret).deref();\n\t\t\tret = f.invoke(ret, array[x]);\n\t\t\t}\n\t\tif(RT.isReduced(ret))\n\t\t\treturn ((IDeref)ret).deref();\n\t\treturn ret;\n\t}\n\t\n\tpublic int indexOf(Object o) {\n\t\tif (o instanceof Boolean) {\n\t\t\tboolean b = ((Boolean) o).booleanValue();\n\t\t\tfor (int j = i; j < array.length; j++)\n\t\t\t\tif (b == array[j]) return j - i;\n\t\t}\n\t\tif (o == null) {\n\t\t\treturn -1;\n\t\t}\n\t\tfor (int j = i; j < array.length; j++)\n\t\t\tif (o.equals(array[j])) return j - i;\n\t\treturn -1;\n\t}\n\t\n\tpublic int lastIndexOf(Object o) {\n\t\tif (o instanceof Boolean) {\n\t\t\tboolean b = ((Boolean) o).booleanValue();\n\t\t\tfor (int j = array.length - 1; j >= i; j--)\n\t\t\t\tif (b == array[j]) return j - i;\n\t\t}\n\t\tif (o == null) {\n\t\t\treturn -1;\n\t\t}\n\t\tfor (int j = array.length - 1; j >= i; j--)\n\t\t\tif (o.equals(array[j])) return j - i;\n\t\treturn -1;\n\t}\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Associative.java",
    "content": "package clojure.lang;\r\n\r\n/**\r\n * Copyright (c) Rich Hickey. All rights reserved.\r\n * The use and distribution terms for this software are covered by the\r\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n * which can be found in the file epl-v10.html at the root of this distribution.\r\n * By using this software in any fashion, you are agreeing to be bound by\r\n * the terms of this license.\r\n * You must not remove this notice, or any other, from this software.\r\n */\r\npublic interface Associative extends IPersistentCollection, ILookup{\r\nboolean containsKey(Object key);\r\n\r\nIMapEntry entryAt(Object key);\r\n\r\nAssociative assoc(Object key, Object val);\r\n\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/Atom.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jan 1, 2009 */\n\npackage clojure.lang;\n\nimport java.util.concurrent.atomic.AtomicReference;\n\nfinal public class Atom extends ARef implements IAtom{\nfinal AtomicReference state;\n\npublic Atom(Object state){\n\tthis.state = new AtomicReference(state);\n}\n\npublic Atom(Object state, IPersistentMap meta){\n\tsuper(meta);\n\tthis.state = new AtomicReference(state);\n}\n\npublic Object deref(){\n\treturn state.get();\n}\n\npublic Object swap(IFn f) {\n\tfor(; ;)\n\t\t{\n\t\tObject v = deref();\n\t\tObject newv = f.invoke(v);\n\t\tvalidate(newv);\n\t\tif(state.compareAndSet(v, newv))\n\t\t\t{\n\t\t\tnotifyWatches(v, newv);\n\t\t\treturn newv;\n\t\t\t}\n\t\t}\n}\n\npublic Object swap(IFn f, Object arg) {\n\tfor(; ;)\n\t\t{\n\t\tObject v = deref();\n\t\tObject newv = f.invoke(v, arg);\n\t\tvalidate(newv);\n\t\tif(state.compareAndSet(v, newv))\n\t\t\t{\n\t\t\tnotifyWatches(v, newv);\n\t\t\treturn newv;\n\t\t\t}\n\t\t}\n}\n\npublic Object swap(IFn f, Object arg1, Object arg2) {\n\tfor(; ;)\n\t\t{\n\t\tObject v = deref();\n\t\tObject newv = f.invoke(v, arg1, arg2);\n\t\tvalidate(newv);\n\t\tif(state.compareAndSet(v, newv))\n\t\t\t{\n\t\t\tnotifyWatches(v, newv);\n\t\t\treturn newv;\n\t\t\t}\n\t\t}\n}\n\npublic Object swap(IFn f, Object x, Object y, ISeq args) {\n\tfor(; ;)\n\t\t{\n\t\tObject v = deref();\n\t\tObject newv = f.applyTo(RT.listStar(v, x, y, args));\n\t\tvalidate(newv);\n\t\tif(state.compareAndSet(v, newv))\n\t\t\t{\n\t\t\tnotifyWatches(v, newv);\n\t\t\treturn newv;\n\t\t\t}\n\t\t}\n}\n\npublic boolean compareAndSet(Object oldv, Object newv){\n\tvalidate(newv);\n\tboolean ret = state.compareAndSet(oldv, newv);\n\tif(ret)\n\t\tnotifyWatches(oldv, newv);\n\treturn ret;\n}\n\npublic Object reset(Object newval){\n\tObject oldval = state.get();\n\tvalidate(newval);\n\tstate.set(newval);\n\tnotifyWatches(oldval, newval);\n\treturn newval;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/BigInt.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* chouser Jun 23, 2010 */\n\npackage clojure.lang;\n\nimport java.math.BigInteger;\nimport java.math.BigDecimal;\n\npublic final class BigInt extends Number implements IHashEq{\n\nfinal public long lpart;\nfinal public BigInteger bipart;\n\nfinal public static BigInt ZERO = new BigInt(0,null);\nfinal public static BigInt ONE = new BigInt(1,null);\n\n\n//must follow Long\npublic int hashCode(){\n\tif(bipart == null)\n\t\treturn (int) (this.lpart ^ (this.lpart >>> 32));\n\treturn Util.hash(bipart);\n}\n\npublic int hasheq(){\n\tif(bipart == null)\n\t\treturn Murmur3.hashLong(lpart);\n\treturn Util.hash(bipart);\n\n}\n\npublic boolean equals(Object obj){\n\tif(this == obj)\n\t\treturn true;\n\tif(obj instanceof BigInt)\n\t\t{\n\t\tBigInt o = (BigInt) obj;\n\t\tif(bipart == null)\n\t\t\treturn o.bipart == null && this.lpart == o.lpart;\n\t\treturn o.bipart != null && this.bipart.equals(o.bipart);\n\t\t}\n\treturn false;\n}\n\nprivate BigInt(long lpart, BigInteger bipart){\n\tthis.lpart = lpart;\n\tthis.bipart = bipart;\n}\n\npublic static BigInt fromBigInteger(BigInteger val){\n\tif(val.bitLength() < 64)\n\t\treturn new BigInt(val.longValue(), null);\n\telse\n\t\treturn new BigInt(0, val);\n}\n\npublic static BigInt fromLong(long val){\n\treturn new BigInt(val, null);\n}\n\npublic BigInteger toBigInteger(){\n\tif(bipart == null)\n\t\treturn BigInteger.valueOf(lpart);\n\telse\n\t\treturn bipart;\n}\n\npublic BigDecimal toBigDecimal(){\n\tif(bipart == null)\n\t\treturn BigDecimal.valueOf(lpart);\n\telse\n\t\treturn new BigDecimal(bipart);\n}\n\n///// java.lang.Number:\n\npublic int intValue(){\n\tif(bipart == null)\n\t\treturn (int) lpart;\n\telse\n\t\treturn bipart.intValue();\n}\n\npublic long longValue(){\n\tif(bipart == null)\n\t\treturn lpart;\n\telse\n\t\treturn bipart.longValue();\n}\n\npublic float floatValue(){\n\tif(bipart == null)\n\t\t\treturn lpart;\n\telse\n\t\treturn bipart.floatValue();\n}\n\npublic double doubleValue(){\n\tif(bipart == null)\n\t\treturn lpart;\n\telse\n\t\treturn bipart.doubleValue();\n}\n\npublic byte byteValue(){\n\tif(bipart == null)\n\t\treturn (byte) lpart;\n\telse\n\t\treturn bipart.byteValue();\n}\n\npublic short shortValue(){\n\tif(bipart == null)\n\t\treturn (short) lpart;\n\telse\n\t\treturn bipart.shortValue();\n}\n\npublic static BigInt valueOf(long val){\n\treturn new BigInt(val, null);\n}\n\npublic String toString(){\n\tif(bipart == null)\n\t\treturn String.valueOf(lpart);\n\treturn bipart.toString();\n}\n\npublic int bitLength(){\n\treturn toBigInteger().bitLength();\n}\n\npublic BigInt add(BigInt y) {\n    if ((bipart == null) && (y.bipart == null)) {\n        long ret = lpart + y.lpart;\n        if ((ret ^ lpart) >= 0 || (ret ^ y.lpart) >= 0)\n            return BigInt.valueOf(ret);\n    }\n    return BigInt.fromBigInteger(this.toBigInteger().add(y.toBigInteger()));\n}\n\npublic BigInt multiply(BigInt y) {\n    if ((bipart == null) && (y.bipart == null)) {\n        long ret = lpart * y.lpart;\n            if (y.lpart == 0 ||\n                (ret / y.lpart == lpart && lpart != Long.MIN_VALUE))\n                return BigInt.valueOf(ret);\n        }\n    return BigInt.fromBigInteger(this.toBigInteger().multiply(y.toBigInteger()));\n}\n\npublic BigInt quotient(BigInt y) {\n    if ((bipart == null) && (y.bipart == null)) {\n        return BigInt.valueOf(lpart / y.lpart);\n    }\n    return BigInt.fromBigInteger(this.toBigInteger().divide(y.toBigInteger()));\n}\n\npublic BigInt remainder(BigInt y) {\n    if ((bipart == null) && (y.bipart == null)) {\n        return BigInt.valueOf(lpart % y.lpart);\n    }\n    return BigInt.fromBigInteger(this.toBigInteger().remainder(y.toBigInteger()));\n}\n\npublic boolean lt(BigInt y) {\n    if ((bipart == null) && (y.bipart == null)) {\n        return lpart < y.lpart;\n    }\n    return this.toBigInteger().compareTo(y.toBigInteger()) < 0;\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Binding.java",
    "content": "/**\r\n *   Copyright (c) Rich Hickey. All rights reserved.\r\n *   The use and distribution terms for this software are covered by the\r\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n *   which can be found in the file epl-v10.html at the root of this distribution.\r\n *   By using this software in any fashion, you are agreeing to be bound by\r\n * \t the terms of this license.\r\n *   You must not remove this notice, or any other, from this software.\r\n **/\r\n\r\npackage clojure.lang;\r\n\r\npublic class Binding<T>{\r\npublic T val;\r\npublic final Binding rest;\r\n\r\npublic Binding(T val){\r\n\tthis.val = val;\r\n\tthis.rest = null;\r\n}\r\n\r\npublic Binding(T val, Binding rest){\r\n\tthis.val = val;\r\n\tthis.rest = rest;\r\n}\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/Box.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 27, 2006 8:40:19 PM */\n\npackage clojure.lang;\n\npublic class Box{\n\npublic Object val;\n\npublic Box(Object val){\n\tthis.val = val;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ChunkBuffer.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich May 26, 2009 */\n\npackage clojure.lang;\n\nfinal public class ChunkBuffer implements Counted{\n\tObject[] buffer;\n\tint end;\n\npublic ChunkBuffer(int capacity){\n\tbuffer = new Object[capacity];\n\tend = 0;\n}\n\npublic void add(Object o){\n\tbuffer[end++] = o;\n}\n\npublic IChunk chunk(){\n\tArrayChunk ret = new ArrayChunk(buffer, 0, end);\n\tbuffer = null;\n\treturn ret;\n}\n\npublic int count(){\n\treturn end;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ChunkedCons.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich May 25, 2009 */\n\npackage clojure.lang;\n\nfinal public class ChunkedCons extends ASeq implements IChunkedSeq{\n\nfinal IChunk chunk;\nfinal ISeq _more;\n\nChunkedCons(IPersistentMap meta, IChunk chunk, ISeq more){\n\tsuper(meta);\n\tthis.chunk = chunk;\n\tthis._more = more;\n}\n\npublic ChunkedCons(IChunk chunk, ISeq more){\n\tthis(null,chunk, more);\n}\n\npublic Obj withMeta(IPersistentMap meta){\n\tif(meta != _meta)\n\t\treturn new ChunkedCons(meta, chunk, _more);\n\treturn this;\n}\n\npublic Object first(){\n\treturn chunk.nth(0);\n}\n\npublic ISeq next(){\n\tif(chunk.count() > 1)\n\t\treturn new ChunkedCons(chunk.dropFirst(), _more);\n\treturn chunkedNext();\n}\n\npublic ISeq more(){\n\tif(chunk.count() > 1)\n\t\treturn new ChunkedCons(chunk.dropFirst(), _more);\n\tif(_more == null)\n\t\treturn PersistentList.EMPTY;\n\treturn _more;\n}\n\npublic IChunk chunkedFirst(){\n\treturn chunk;\n}\n\npublic ISeq chunkedNext(){\n\treturn chunkedMore().seq();\t\n}\n\npublic ISeq chunkedMore(){\n\tif(_more == null)\n\t\treturn PersistentList.EMPTY;\n\treturn _more;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Compile.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.io.OutputStreamWriter;\nimport java.io.PrintWriter;\nimport java.util.Map;\nimport java.io.IOException;\n\n// Compiles libs and generates class files stored within the directory\n// named by the Java System property \"clojure.compile.path\". Arguments are\n// strings naming the libs to be compiled. The libs and compile-path must\n// all be within CLASSPATH.\n\npublic class Compile {\n\n  private static final String PATH_PROP = \"clojure.compile.path\";\n  private static final String REFLECTION_WARNING_PROP = \"clojure.compile.warn-on-reflection\";\n  private static final String UNCHECKED_MATH_PROP = \"clojure.compile.unchecked-math\";\n\n  private static final Var compile_path = RT.var(\"clojure.core\", \"*compile-path*\");\n  private static final Var compile = RT.var(\"clojure.core\", \"compile\");\n  private static final Var warn_on_reflection = RT.var(\"clojure.core\", \"*warn-on-reflection*\");\n  private static final Var unchecked_math = RT.var(\"clojure.core\", \"*unchecked-math*\");\n  private static Keyword sourceOutputKey = Keyword.intern(\"clojure.compiler.source-output\");\n\n  public static void main(String[] args) throws Exception {\n    OutputStreamWriter out = (OutputStreamWriter) RT.OUT.deref();\n    PrintWriter err = RT.errPrintWriter();\n    String path = System.getProperty(PATH_PROP);\n    int count = args.length;\n\n    if (path == null) {\n      err.println(\"ERROR: Must set system property \" + PATH_PROP\n          + \"\\nto the location for compiled .class files.\"\n          + \"\\nThis directory must also be on your CLASSPATH.\");\n      System.exit(1);\n    }\n\n    boolean warnOnReflection = System.getProperty(REFLECTION_WARNING_PROP,\n        \"false\").equals(\"true\");\n    boolean uncheckedMath = System.getProperty(UNCHECKED_MATH_PROP, \"false\")\n        .equals(\"true\");\n\n    String sourceOutput = \"target/gen\"; //(String) (compilerOptions.containsKey(sourceOutputKey) ? compilerOptions.valAt(sourceOutputKey ) : \"target/gen\");\n    new File(sourceOutput).mkdirs();\n    \n    try {\n      Var.pushThreadBindings(RT.map(clojure.lang.Compiler.SOURCE_GEN_PATH,\n          sourceOutput, compile_path, path, warn_on_reflection,\n          warnOnReflection, unchecked_math, uncheckedMath));\n\n      for (String lib : args) {\n        out.write(\"Compiling \" + lib + \" to \" + path + \"\\n\");\n        out.flush();\n        compile.invoke(Symbol.intern(lib));\n      }\n    } catch (Exception e) {\n      e.printStackTrace();\n    } finally {\n      Var.popThreadBindings();\n      try {\n        out.flush();\n      } catch (IOException e) {\n        e.printStackTrace(err);\n      }\n      System.exit(0);\n    }\n  }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Compiler.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Aug 21, 2007 */\n\npackage clojure.lang;\n\nimport java.io.BufferedReader;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileOutputStream;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.Reader;\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Modifier;\nimport java.lang.reflect.ParameterizedType;\nimport java.lang.reflect.TypeVariable;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Comparator;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.IdentityHashMap;\nimport java.util.Iterator;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Map.Entry;\nimport java.util.Set;\nimport java.util.SortedMap;\nimport java.util.TreeMap;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\nimport com.google.j2objc.annotations.ReflectionSupport.Level;\n\nimport clojure.main;\nimport clojure.asm.Attribute;\nimport clojure.asm.ByteVector;\nimport clojure.asm.ClassVisitor;\nimport clojure.asm.ClassWriter;\nimport clojure.asm.FieldVisitor;\nimport clojure.asm.Label;\nimport clojure.asm.MethodVisitor;\nimport clojure.asm.Opcodes;\nimport clojure.asm.Type;\nimport clojure.asm.commons.GeneratorAdapter;\nimport clojure.asm.commons.Method;\n\npublic class Compiler implements Opcodes {\n\n  static final String DOLLAR = \"_\";\n\n  static final Symbol DEF = Symbol.intern(\"def\");\n  static final Symbol LOOP = Symbol.intern(\"loop*\");\n  static final Symbol RECUR = Symbol.intern(\"recur\");\n  static final Symbol IF = Symbol.intern(\"if\");\n  static final Symbol LET = Symbol.intern(\"let*\");\n  static final Symbol LETFN = Symbol.intern(\"letfn*\");\n  static final Symbol DO = Symbol.intern(\"do\");\n  static final Symbol FN = Symbol.intern(\"fn*\");\n  static final Symbol FNONCE = (Symbol) Symbol.intern(\"fn*\").withMeta(\n      RT.map(Keyword.intern(null, \"once\"), RT.T));\n  static final Symbol QUOTE = Symbol.intern(\"quote\");\n  static final Symbol THE_VAR = Symbol.intern(\"var\");\n  static final Symbol DOT = Symbol.intern(\".\");\n  static final Symbol ASSIGN = Symbol.intern(\"set!\");\n  // static final Symbol TRY_FINALLY = Symbol.intern(\"try-finally\");\n  static final Symbol TRY = Symbol.intern(\"try\");\n  static final Symbol CATCH = Symbol.intern(\"catch\");\n  static final Symbol FINALLY = Symbol.intern(\"finally\");\n  static final Symbol THROW = Symbol.intern(\"throw\");\n  static final Symbol MONITOR_ENTER = Symbol.intern(\"monitor-enter\");\n  static final Symbol MONITOR_EXIT = Symbol.intern(\"monitor-exit\");\n  static final Symbol IMPORT = Symbol.intern(\"clojure.core\", \"import*\");\n  // static final Symbol INSTANCE = Symbol.intern(\"instance?\");\n  static final Symbol DEFTYPE = Symbol.intern(\"deftype*\");\n  static final Symbol CASE = Symbol.intern(\"case*\");\n\n  // static final Symbol THISFN = Symbol.intern(\"thisfn\");\n  static final Symbol CLASS = Symbol.intern(\"Class\");\n  static final Symbol NEW = Symbol.intern(\"new\");\n  static final Symbol THIS = Symbol.intern(\"this\");\n  static final Symbol REIFY = Symbol.intern(\"reify*\");\n  // static final Symbol UNQUOTE = Symbol.intern(\"unquote\");\n  // static final Symbol UNQUOTE_SPLICING = Symbol.intern(\"unquote-splicing\");\n  // static final Symbol SYNTAX_QUOTE = Symbol.intern(\"clojure.core\",\n  // \"syntax-quote\");\n  static final Symbol LIST = Symbol.intern(\"clojure.core\", \"list\");\n  static final Symbol HASHMAP = Symbol.intern(\"clojure.core\", \"hash-map\");\n  static final Symbol VECTOR = Symbol.intern(\"clojure.core\", \"vector\");\n  static final Symbol IDENTITY = Symbol.intern(\"clojure.core\", \"identity\");\n\n  static final Symbol _AMP_ = Symbol.intern(\"&\");\n  static final Symbol ISEQ = Symbol.intern(\"clojure.lang.ISeq\");\n\n  static final Keyword inlineKey = Keyword.intern(null, \"inline\");\n  static final Keyword inlineAritiesKey = Keyword\n      .intern(null, \"inline-arities\");\n  static final Keyword staticKey = Keyword.intern(null, \"static\");\n  static final Keyword arglistsKey = Keyword.intern(null, \"arglists\");\n  static final Symbol INVOKE_STATIC = Symbol.intern(\"invokeStatic\");\n\n  static final Keyword volatileKey = Keyword.intern(null, \"volatile\");\n  static final Keyword implementsKey = Keyword.intern(null, \"implements\");\n  static final String COMPILE_STUB_PREFIX = \"compile__stub\";\n\n  static final Keyword protocolKey = Keyword.intern(null, \"protocol\");\n  static final Keyword onKey = Keyword.intern(null, \"on\");\n  static Keyword dynamicKey = Keyword.intern(\"dynamic\");\n\n  static final Symbol NS = Symbol.intern(\"ns\");\n  static final Symbol IN_NS = Symbol.intern(\"in-ns\");\n\n  // static final Symbol IMPORT = Symbol.intern(\"import\");\n  // static final Symbol USE = Symbol.intern(\"use\");\n\n  // static final Symbol IFN = Symbol.intern(\"clojure.lang\", \"IFn\");\n\n  static final public IPersistentMap specials = PersistentHashMap.create(DEF,\n      new DefExpr.Parser(), LOOP, new LetExpr.Parser(), RECUR,\n      new RecurExpr.Parser(), IF, new IfExpr.Parser(), CASE,\n      new CaseExpr.Parser(), LET, new LetExpr.Parser(), LETFN,\n      new LetFnExpr.Parser(), DO, new BodyExpr.Parser(), FN, null, QUOTE,\n      new ConstantExpr.Parser(), THE_VAR, new TheVarExpr.Parser(), IMPORT,\n      new ImportExpr.Parser(), DOT, new HostExpr.Parser(), ASSIGN,\n      new AssignExpr.Parser(), DEFTYPE, new NewInstanceExpr.DeftypeParser(),\n      REIFY,\n      new NewInstanceExpr.ReifyParser(),\n      // TRY_FINALLY, new TryFinallyExpr.Parser(),\n      TRY, new TryExpr.Parser(), THROW, new ThrowExpr.Parser(), MONITOR_ENTER,\n      new MonitorEnterExpr.Parser(), MONITOR_EXIT,\n      new MonitorExitExpr.Parser(),\n      // INSTANCE, new InstanceExpr.Parser(),\n      // IDENTICAL, new IdenticalExpr.Parser(),\n      // THISFN, null,\n      CATCH, null, FINALLY, null,\n      // CLASS, new ClassExpr.Parser(),\n      NEW, new NewExpr.Parser(),\n      // UNQUOTE, null,\n      // UNQUOTE_SPLICING, null,\n      // SYNTAX_QUOTE, null,\n      _AMP_, null);\n\n  private static final int MAX_POSITIONAL_ARITY = 20;\n  private static final Type OBJECT_TYPE;\n  // private static final Type KEYWORD_TYPE = Type.getType(Keyword.class);\n  private static final Type VAR_TYPE = Type.getType(Var.class);\n  private static final Type SYMBOL_TYPE = Type.getType(Symbol.class);\n  // private static final Type NUM_TYPE = Type.getType(Num.class);\n  private static final Type IFN_TYPE = Type.getType(IFn.class);\n  // private static final Type AFUNCTION_TYPE = Type.getType(AFunction.class);\n  private static final Type RT_TYPE = Type.getType(RT.class);\n  private static final Type NUMBERS_TYPE = Type.getType(Numbers.class);\n  final static Type CLASS_TYPE = Type.getType(Class.class);\n  final static Type NS_TYPE = Type.getType(Namespace.class);\n  final static Type UTIL_TYPE = Type.getType(Util.class);\n  final static Type REFLECTOR_TYPE = Type.getType(Reflector.class);\n  final static Type THROWABLE_TYPE = Type.getType(Throwable.class);\n  final static Type BOOLEAN_OBJECT_TYPE = Type.getType(Boolean.class);\n  final static Type IPERSISTENTMAP_TYPE = Type.getType(IPersistentMap.class);\n  final static Type IOBJ_TYPE = Type.getType(IObj.class);\n\n  private static final Type[][] ARG_TYPES;\n  // private static final Type[] EXCEPTION_TYPES =\n  // {Type.getType(Exception.class)};\n  private static final Type[] EXCEPTION_TYPES = {};\n\n  static final public IPersistentMap CHAR_MAP = PersistentHashMap.create(\n      '-',\n      \"_\",\n      // '.', \"_DOT_\",\n      ':', \"_COLON_\", '+', \"_PLUS_\", '>', \"_GT_\", '<', \"_LT_\", '=', \"_EQ_\",\n      '~', \"_TILDE_\", '!', \"_BANG_\", '@', \"_CIRCA_\", '#', \"_SHARP_\", '\\'',\n      \"_SINGLEQUOTE_\", '\"', \"_DOUBLEQUOTE_\", '%', \"_PERCENT_\", '^', \"_CARET_\",\n      '&', \"_AMPERSAND_\", '*', \"_STAR_\", '|', \"_BAR_\", '{', \"_LBRACE_\", '}',\n      \"_RBRACE_\", '[', \"_LBRACK_\", ']', \"_RBRACK_\", '/', \"_SLASH_\", '\\\\',\n      \"_BSLASH_\", '?', \"_QMARK_\");\n\n  static final public IPersistentMap DEMUNGE_MAP;\n  static final public Pattern DEMUNGE_PATTERN;\n\n  static {\n    OBJECT_TYPE = Type.getType(Object.class);\n    ARG_TYPES = new Type[MAX_POSITIONAL_ARITY + 2][];\n    for (int i = 0; i <= MAX_POSITIONAL_ARITY; ++i) {\n      Type[] a = new Type[i];\n      for (int j = 0; j < i; j++)\n        a[j] = OBJECT_TYPE;\n      ARG_TYPES[i] = a;\n    }\n    Type[] a = new Type[MAX_POSITIONAL_ARITY + 1];\n    for (int j = 0; j < MAX_POSITIONAL_ARITY; j++)\n      a[j] = OBJECT_TYPE;\n    a[MAX_POSITIONAL_ARITY] = Type.getType(\"[Ljava/lang/Object;\");\n    ARG_TYPES[MAX_POSITIONAL_ARITY + 1] = a;\n\n  }\n\n  // static final public Var RUNTIME = Var.intern(\n  // Namespace.findOrCreate(Symbol.intern(\"clojure.core\")),\n  // Symbol.intern(\"*runtime*\"), Boolean.FALSE).setDynamic();\n\n  static final public Var STOP_EMIT_SOURCE = Var.create(false).setDynamic();\n\n  // symbol->localbinding\n  static final public Var LOCAL_ENV = Var.create(null).setDynamic();\n\n  // vector<localbinding>\n  static final public Var LOOP_LOCALS = Var.create().setDynamic();\n\n  // Label\n  static final public Var LOOP_LABEL = Var.create().setDynamic();\n\n  // Return type of method\n  static final public Var RETURN_TYPE = Var.create().setDynamic();\n\n  // vector<object>\n  static final public Var CONSTANTS = Var.create().setDynamic();\n\n  // IdentityHashMap\n  static final public Var CONSTANT_IDS = Var.create().setDynamic();\n\n  // vector<keyword>\n  static final public Var KEYWORD_CALLSITES = Var.create().setDynamic();\n\n  // vector<var>\n  static final public Var PROTOCOL_CALLSITES = Var.create().setDynamic();\n\n  // set<var>\n  static final public Var VAR_CALLSITES = Var.create().setDynamic();\n\n  // keyword->constid\n  static final public Var KEYWORDS = Var.create().setDynamic();\n\n  // var->constid\n  static final public Var VARS = Var.create().setDynamic();\n\n  // FnFrame\n  static final public Var METHOD = Var.create(null).setDynamic();\n\n  // null or not\n  static final public Var IN_CATCH_FINALLY = Var.create(null).setDynamic();\n\n  static final public Var NO_RECUR = Var.create(null).setDynamic();\n\n  // DynamicClassLoader\n  static final public Var LOADER = Var.create().setDynamic();\n  \n  static final public Var NEXT_ID = Var.create(new Atom(1)).setDynamic();\n\n  // String\n  static final public Var SOURCE = Var.intern(\n      Namespace.findOrCreate(Symbol.intern(\"clojure.core\")),\n      Symbol.intern(\"*source-path*\"), \"NO_SOURCE_FILE\").setDynamic();\n\n  // String\n  static final public Var SOURCE_PATH = Var.intern(\n      Namespace.findOrCreate(Symbol.intern(\"clojure.core\")),\n      Symbol.intern(\"*file*\"), \"NO_SOURCE_PATH\").setDynamic();\n\n  static final public Var SOURCE_WRITER = Var.intern(\n      Namespace.findOrCreate(Symbol.intern(\"clojure.core\")),\n      Symbol.intern(\"*source-writer*\"), null).setDynamic();\n\n  // String\n  static final public Var COMPILE_PATH = Var.intern(\n      Namespace.findOrCreate(Symbol.intern(\"clojure.core\")),\n      Symbol.intern(\"*compile-path*\"), null).setDynamic();\n\n  // String\n  static final public Var SOURCE_GEN_PATH = Var.intern(\n      Namespace.findOrCreate(Symbol.intern(\"clojure.core\")),\n      Symbol.intern(\"*source-gen-path*\"), null).setDynamic();\n\n  // boolean\n  static final public Var COMPILE_FILES = Var.intern(\n      Namespace.findOrCreate(Symbol.intern(\"clojure.core\")),\n      Symbol.intern(\"*compile-files*\"), Boolean.FALSE).setDynamic();\n\n  static final public Var INSTANCE = Var.intern(\n      Namespace.findOrCreate(Symbol.intern(\"clojure.core\")),\n      Symbol.intern(\"instance?\"));\n\n  static final public Var ADD_ANNOTATIONS = Var.intern(\n      Namespace.findOrCreate(Symbol.intern(\"clojure.core\")),\n      Symbol.intern(\"add-annotations\"));\n\n  static final public Keyword disableLocalsClearingKey = Keyword\n      .intern(\"disable-locals-clearing\");\n  static final public Keyword elideMetaKey = Keyword.intern(\"elide-meta\");\n\n  static final public Var COMPILER_OPTIONS;\n\n  public static void emitSource(String source) {\n    if (Boolean.TRUE.equals(STOP_EMIT_SOURCE.deref())) {\n      return;\n    }\n    if (source != null && source.endsWith(\";;\")) {\n      new RuntimeException(source).printStackTrace();\n    }\n\n    if (source == null) {\n      new RuntimeException().printStackTrace();\n      return; // TODO Handle error\n    }\n\n    if (source != null && (source.isEmpty() || \"null;\".equals(source))) {\n      return;\n    }\n\n    SourceWriter sc = (SourceWriter) SOURCE_WRITER.deref();\n    if (sc != null) {\n      source = source.replaceAll(COMPILE_STUB_PREFIX + \".\", \"\"); // TODO ?\n      sc.println(source);\n    }\n  }\n  \n  public static int nextScopedID() {\n    Atom n = (Atom) NEXT_ID.deref();\n    Integer i = (Integer) n.deref();\n    n.reset(i+1);\n    return i;\n  }\n\n  public static void emitSource() {\n    SourceWriter sc = (SourceWriter) SOURCE_WRITER.deref();\n    if (sc != null) {\n      sc.println();\n    }\n  }\n\n  public static void tab() {\n    SourceWriter sc = (SourceWriter) SOURCE_WRITER.deref();\n    if (sc != null) {\n      sc.tab();\n    }\n  }\n\n  public static void untab() {\n    SourceWriter sc = (SourceWriter) SOURCE_WRITER.deref();\n    if (sc != null) {\n      sc.untab();\n    }\n  }\n\n  static public Object getCompilerOption(Keyword k) {\n    return RT.get(COMPILER_OPTIONS.deref(), k);\n  }\n\n  static {\n    Object compilerOptions = null;\n\n    for (Map.Entry e : System.getProperties().entrySet()) {\n      String name = (String) e.getKey();\n      String v = (String) e.getValue();\n      if (name.startsWith(\"clojure.compiler.\")) {\n        compilerOptions = RT.assoc(compilerOptions,\n            RT.keyword(null, name.substring(1 + name.lastIndexOf('.'))),\n            RT.readString(v));\n      }\n    }\n\n    COMPILER_OPTIONS = Var.intern(\n        Namespace.findOrCreate(Symbol.intern(\"clojure.core\")),\n        Symbol.intern(\"*compiler-options*\"), compilerOptions).setDynamic();\n  }\n\n  static Object elideMeta(Object m) {\n    Collection<Object> elides = (Collection<Object>) getCompilerOption(elideMetaKey);\n    if (elides != null) {\n      for (Object k : elides) {\n        // System.out.println(\"Eliding:\" + k + \" : \" + RT.get(m, k));\n        m = RT.dissoc(m, k);\n      }\n      // System.out.println(\"Remaining: \" + RT.keys(m));\n    }\n    return m;\n  }\n\n  // Integer\n  static final public Var LINE = Var.create(0).setDynamic();\n  static final public Var COLUMN = Var.create(0).setDynamic();\n\n  static int lineDeref() {\n    return ((Number) LINE.deref()).intValue();\n  }\n\n  static int columnDeref() {\n    return ((Number) COLUMN.deref()).intValue();\n  }\n\n  // Integer\n  static final public Var LINE_BEFORE = Var.create(0).setDynamic();\n  static final public Var COLUMN_BEFORE = Var.create(0).setDynamic();\n  static final public Var LINE_AFTER = Var.create(0).setDynamic();\n  static final public Var COLUMN_AFTER = Var.create(0).setDynamic();\n\n  // Integer\n  static final public Var NEXT_LOCAL_NUM = Var.create(0).setDynamic();\n\n  // Integer\n  static final public Var RET_LOCAL_NUM = Var.create().setDynamic();\n\n  static final public Var COMPILE_STUB_SYM = Var.create(null).setDynamic();\n  static final public Var COMPILE_STUB_CLASS = Var.create(null).setDynamic();\n\n  // PathNode chain\n  static final public Var CLEAR_PATH = Var.create(null).setDynamic();\n\n  // tail of PathNode chain\n  static final public Var CLEAR_ROOT = Var.create(null).setDynamic();\n\n  // LocalBinding -> Set<LocalBindingExpr>\n  static final public Var CLEAR_SITES = Var.create(null).setDynamic();\n\n  public enum C {\n    STATEMENT, // value ignored\n    EXPRESSION, // value required\n    RETURN, // tail position relative to enclosing recur frame\n    EVAL\n  }\n\n  private class Recur {\n  };\n\n  static final public Class RECUR_CLASS = Recur.class;\n\n  interface Expr {\n    Object eval();\n\n    String emit(C context, ObjExpr objx, GeneratorAdapter gen);\n\n    boolean hasJavaClass();\n\n    Class getJavaClass();\n  }\n\n  public static abstract class UntypedExpr implements Expr {\n\n    public Class getJavaClass() {\n      throw new IllegalArgumentException(\"Has no Java class\");\n    }\n\n    public boolean hasJavaClass() {\n      return false;\n    }\n  }\n\n  interface IParser {\n    Expr parse(C context, Object form);\n  }\n\n  static boolean isSpecial(Object sym) {\n    return specials.containsKey(sym);\n  }\n\n  public static String printClass(Object c) {\n    if (c instanceof Class) {\n      return ((Class) c).getCanonicalName();\n    } else if (c instanceof Type) {\n      return ((Type) c).getClassName();\n    } else if (c instanceof String) {\n      return c.toString();\n    }\n    throw new RuntimeException(\"printClass doesn't support: \"\n        + c.getClass().getCanonicalName());\n  }\n\n  static Symbol resolveSymbol(Symbol sym) {\n    // already qualified or classname?\n    if (sym.name.indexOf('.') > 0)\n      return sym;\n    if (sym.ns != null) {\n      Namespace ns = namespaceFor(sym);\n      if (ns == null || (ns.name.name == null ? sym.ns == null : ns.name.name.equals(sym.ns)))\n        return sym;\n      return Symbol.intern(ns.name.name, sym.name);\n    }\n    Object o = currentNS().getMapping(sym);\n    if (o == null)\n      return Symbol.intern(currentNS().name.name, sym.name);\n    else if (o instanceof Class)\n      return Symbol.intern(null, ((Class) o).getName());\n    else if (o instanceof Var) {\n      Var v = (Var) o;\n      return Symbol.intern(v.ns.name.name, v.sym.name);\n    }\n    return null;\n\n  }\n\n  static class DefExpr implements Expr {\n    public final Var var;\n    public final Expr init;\n    public final Expr meta;\n    public final boolean initProvided;\n    public final boolean emitOnInit;\n    public final boolean isDynamic;\n    public final boolean shadowsCoreMapping;\n    public final String source;\n    public final int line;\n    public final int column;\n    final static Method bindRootMethod = Method\n        .getMethod(\"void bindRoot(Object)\");\n    final static Method setTagMethod = Method\n        .getMethod(\"void setTag(clojure.lang.Symbol)\");\n    final static Method setMetaMethod = Method\n        .getMethod(\"void setMeta(clojure.lang.IPersistentMap)\");\n    final static Method setDynamicMethod = Method\n        .getMethod(\"clojure.lang.Var setDynamic(boolean)\");\n    final static Method symintern = Method\n        .getMethod(\"clojure.lang.Symbol intern(String, String)\");\n    final static Method internVar = Method.getMethod(\"clojure.lang.Var refer(clojure.lang.Symbol, clojure.lang.Var)\");\n    \n    public DefExpr(C c, String source, int line, int column, Var var,\n        Expr init, Expr meta, boolean initProvided, boolean isDynamic,\n        boolean shadowsCoreMapping, boolean isDeclared) {\n      this.source = source;\n      this.line = line;\n      this.column = column;\n      this.var = var;\n      this.init = init;\n      this.meta = meta;\n      this.isDynamic = isDynamic;\n      this.shadowsCoreMapping = shadowsCoreMapping;\n      this.initProvided = initProvided;\n      this.emitOnInit = C.RETURN == c || C.EXPRESSION == c || !(init instanceof FnExpr);\n    }\n\n    // private boolean includesExplicitMetadata(MapExpr expr) {\n    // for (int i = 0; i < expr.keyvals.count(); i += 2) {\n    // Keyword k = ((KeywordExpr) expr.keyvals.nth(i)).k;\n    // if ((k != RT.FILE_KEY) && (k != RT.DECLARED_KEY) && (k != RT.LINE_KEY)\n    // && (k != RT.COLUMN_KEY))\n    // return true;\n    // }\n    // return false;\n    // }\n\n    public Object eval() {\n      try {\n        if (initProvided) {\n          // if(init instanceof FnExpr && ((FnExpr) init).closes.count()==0)\n          // var.bindRoot(new FnLoaderThunk((FnExpr) init,var));\n          // else\n          var.bindRoot(init.eval());\n        }\n        if (meta != null) {\n          var.setMeta((IPersistentMap) meta.eval());\n        }\n        return var.setDynamic(isDynamic);\n      } catch (Throwable e) {\n        if (!(e instanceof CompilerException))\n          throw new CompilerException(source, line, column, e);\n        else\n          throw (CompilerException) e;\n      }\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      if (emitOnInit) {\n        String constant = objx.emitVar(gen, var);\n        \n        if (shadowsCoreMapping)\n        {\n          gen.dup();\n          gen.getField(VAR_TYPE, \"ns\", NS_TYPE);\n          gen.swap();\n          gen.dup();\n          gen.getField(VAR_TYPE, \"sym\", SYMBOL_TYPE);\n          gen.swap();\n          gen.invokeVirtual(NS_TYPE, internVar);\n          constant = constant + \".ns.refer(\" + constant + \".sym, \" + constant + \")\";\n        }\n        if (isDynamic) {\n          gen.push(isDynamic);\n          gen.invokeVirtual(VAR_TYPE, setDynamicMethod);\n          emitSource(constant + \".setDynamic(true);\");\n        }\n        if (meta != null) {\n          if (initProvided || true)// includesExplicitMetadata((MapExpr) meta))\n          {\n            gen.dup();\n            String val = meta.emit(C.EXPRESSION, objx, gen);\n            gen.checkCast(IPERSISTENTMAP_TYPE);\n            gen.invokeVirtual(VAR_TYPE, setMetaMethod);\n            emitSource(constant + \".setMeta((IPersistentMap)\" + val + \");\");\n          }\n        }\n\n        if (initProvided) {\n          gen.dup();\n          String val;\n          if (init instanceof FnExpr) {\n            val = ((FnExpr) init).emitForDefn(objx, gen);\n          } else\n            val = init.emit(C.EXPRESSION, objx, gen);\n          gen.invokeVirtual(VAR_TYPE, bindRootMethod);\n          emitSource(constant + \".bindRoot(\" + val + \");\");\n        }\n\n        if (context == C.STATEMENT) {\n          gen.pop();\n          return \"\";\n        } else {\n          return wrap(context, constant);\n        }\n      } else {\n        return \"\";\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return Var.class;\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object form) {\n        // (def x) or (def x initexpr) or (def x \"docstring\" initexpr)\n        String docstring = null;\n        if (RT.count(form) == 4 && (RT.third(form) instanceof String)) {\n          docstring = (String) RT.third(form);\n          form = RT.list(RT.first(form), RT.second(form), RT.fourth(form));\n        }\n        if (RT.count(form) > 3)\n          throw Util.runtimeException(\"Too many arguments to def\");\n        else if (RT.count(form) < 2)\n          throw Util.runtimeException(\"Too few arguments to def\");\n        else if (!(RT.second(form) instanceof Symbol))\n          throw Util.runtimeException(\"First argument to def must be a Symbol\");\n        Symbol sym = (Symbol) RT.second(form);\n        Var v = lookupVar(sym, true);\n        if (v == null)\n          throw Util\n              .runtimeException(\"Can't refer to qualified var that doesn't exist\");\n        boolean shadowsCoreMapping = false;\n        if (!v.ns.equals(currentNS())) {\n          if (sym.ns == null) {\n            v = currentNS().intern(sym);\n            shadowsCoreMapping = true;\n            registerVar(v);\n          }\n          // throw Util.runtimeException(\"Name conflict, can't def \" + sym +\n          // \" because namespace: \" + currentNS().name +\n          // \" refers to:\" + v);\n          else\n            throw Util\n                .runtimeException(\"Can't create defs outside of current ns\");\n        }\n        IPersistentMap mm = sym.meta();\n        boolean isDynamic = RT.booleanCast(RT.get(mm, dynamicKey));\n        boolean isDeclared = RT.booleanCast(RT.get(mm,\n            Keyword.intern(\"declared\")));\n        if (isDynamic)\n          v.setDynamic();\n        if (!isDynamic && sym.name.startsWith(\"*\") && sym.name.endsWith(\"*\")\n            && sym.name.length() > 2) {\n          RT.errPrintWriter()\n              .format(\n                  \"Warning: %1$s not declared dynamic and thus is not dynamically rebindable, \"\n                      + \"but its name suggests otherwise. Please either indicate ^:dynamic %1$s or change the name. (%2$s:%3$d)\\n\",\n                  sym, SOURCE_PATH.get(), LINE.get());\n        }\n        if (RT.booleanCast(RT.get(mm, arglistsKey))) {\n          IPersistentMap vm = v.meta();\n          // vm = (IPersistentMap) RT.assoc(vm,staticKey,RT.T);\n          vm = (IPersistentMap) RT.assoc(vm, Var.macroKey,\n              mm.valAt(Var.macroKey));\n          // drop quote\n          vm = (IPersistentMap) RT.assoc(vm, arglistsKey,\n              RT.second(mm.valAt(arglistsKey)));\n          v.setMeta(vm);\n        }\n        Object source_path = SOURCE_PATH.get();\n        source_path = source_path == null ? \"NO_SOURCE_FILE\" : source_path;\n        mm = (IPersistentMap) RT.assoc(mm, RT.LINE_KEY, LINE.get())\n            .assoc(RT.COLUMN_KEY, COLUMN.get()).assoc(RT.FILE_KEY, source_path);\n        if (docstring != null)\n          mm = (IPersistentMap) RT.assoc(mm, RT.DOC_KEY, docstring);\n        // mm = mm.without(RT.DOC_KEY)\n        // .without(Keyword.intern(null, \"arglists\"))\n        // .without(RT.FILE_KEY)\n        // .without(RT.LINE_KEY)\n        // .without(RT.COLUMN_KEY)\n        // .without(Keyword.intern(null, \"ns\"))\n        // .without(Keyword.intern(null, \"name\"))\n        // .without(Keyword.intern(null, \"added\"))\n        // .without(Keyword.intern(null, \"static\"));\n        mm = (IPersistentMap) elideMeta(mm);\n        Expr meta = null;\n        Expr init = analyze(\n            context == C.EVAL ? context : C.EXPRESSION,\n            RT.third(form),\n            v.sym.name,\n            (C.RETURN == context || C.EXPRESSION == context) ? null : RT\n                .vector(v, mm, isDynamic));\n        if ((C.RETURN == context || C.EXPRESSION == context)\n            || (!isDeclared && !(init instanceof FnExpr))) {\n          meta = mm.count() == 0 ? null : analyze(context == C.EVAL ? context\n              : C.EXPRESSION, mm);\n        }\n        return new DefExpr(context, (String) SOURCE.deref(), lineDeref(),\n            columnDeref(), v, init, meta, RT.count(form) == 3, isDynamic, shadowsCoreMapping,\n            isDeclared);\n      }\n    }\n  }\n\n  public static class AssignExpr implements Expr {\n    public final AssignableExpr target;\n    public final Expr val;\n\n    public AssignExpr(AssignableExpr target, Expr val) {\n      this.target = target;\n      this.val = val;\n    }\n\n    public Object eval() {\n      return target.evalAssign(val);\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      return target.emitAssign(context, objx, gen, val);\n    }\n\n    public boolean hasJavaClass() {\n      return val.hasJavaClass();\n    }\n\n    public Class getJavaClass() {\n      return val.getJavaClass();\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object frm) {\n        ISeq form = (ISeq) frm;\n        if (RT.length(form) != 3)\n          throw new IllegalArgumentException(\n              \"Malformed assignment, expecting (set! target val)\");\n        Expr target = analyze(C.EXPRESSION, RT.second(form));\n        if (!(target instanceof AssignableExpr))\n          throw new IllegalArgumentException(\"Invalid assignment target\");\n        return new AssignExpr((AssignableExpr) target, analyze(C.EXPRESSION,\n            RT.third(form)));\n      }\n    }\n  }\n\n  public static class VarExpr implements Expr, AssignableExpr {\n    public final Var var;\n    public final Object tag;\n    final static Method getMethod = Method.getMethod(\"Object get()\");\n    final static Method setMethod = Method.getMethod(\"Object set(Object)\");\n\n    public VarExpr(Var var, Symbol tag) {\n      this.var = var;\n      this.tag = tag != null ? tag : var.getTag();\n    }\n\n    public Object eval() {\n      return var.deref();\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String val = objx.emitVarValue(gen, var);\n      if (context == C.STATEMENT) {\n        gen.pop();\n        return \"\";\n      } else {\n        return wrap(context, val);\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return tag != null;\n    }\n\n    public Class getJavaClass() {\n      return HostExpr.tagToClass(tag);\n    }\n\n    public Object evalAssign(Expr val) {\n      return var.set(val.eval());\n    }\n\n    public String emitAssign(C context, ObjExpr objx, GeneratorAdapter gen,\n        Expr val) {\n      String to = objx.emitVar(gen, var);\n      String value = val.emit(C.EXPRESSION, objx, gen);\n      gen.invokeVirtual(VAR_TYPE, setMethod);\n      if (context == C.STATEMENT)\n        gen.pop();\n\n      return wrap(context, to + \".set(\" + value + \")\");\n    }\n  }\n\n  public static class TheVarExpr implements Expr {\n    public final Var var;\n\n    public TheVarExpr(Var var) {\n      this.var = var;\n    }\n\n    public Object eval() {\n      return var;\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String val = objx.emitVar(gen, var);\n      if (context == C.STATEMENT) {\n        gen.pop();\n        return \"\";\n      } else {\n        return wrap(context, val);\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return Var.class;\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object form) {\n        Symbol sym = (Symbol) RT.second(form);\n        Var v = lookupVar(sym, false);\n        if (v != null)\n          return new TheVarExpr(v);\n        throw Util.runtimeException(\"Unable to resolve var: \" + sym\n            + \" in this context\");\n      }\n    }\n  }\n\n  public static class KeywordExpr extends LiteralExpr {\n    public final Keyword k;\n\n    public KeywordExpr(Keyword k) {\n      this.k = k;\n    }\n\n    Object val() {\n      return k;\n    }\n\n    public Object eval() {\n      return k;\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String val = objx.emitKeyword(gen, k);\n      if (context == C.STATEMENT) {\n        gen.pop();\n        return \"\";\n      } else {\n        return wrap(context, val);\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return Keyword.class;\n    }\n  }\n\n  public static class ImportExpr implements Expr {\n    public final String c;\n    final static Method forNameMethod = Method\n        .getMethod(\"Class classForNameNonLoading(String)\");\n    final static Method importClassMethod = Method\n        .getMethod(\"Class importClass(Class)\");\n    final static Method derefMethod = Method.getMethod(\"Object deref()\");\n\n    public ImportExpr(String c) {\n      this.c = c;\n    }\n\n    public Object eval() {\n      Namespace ns = (Namespace) RT.CURRENT_NS.deref();\n      ns.importClass(RT.classForNameNonLoading(c));\n      return null;\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      gen.getStatic(RT_TYPE, \"CURRENT_NS\", VAR_TYPE);\n      gen.invokeVirtual(VAR_TYPE, derefMethod);\n      gen.checkCast(NS_TYPE);\n      gen.push(c);\n      gen.invokeStatic(RT_TYPE, forNameMethod);\n      gen.invokeVirtual(NS_TYPE, importClassMethod);\n      // TODO proper fix\n      String className = c;\n      try {\n        Class cl = Class.forName(className);\n        if (cl.getEnclosingClass() != null) {\n          className = className.replaceAll(\"\\\\$\", \".\");\n        }\n      } catch (Exception e) {\n      }\n      emitSource(\"((Namespace)RT.CURRENT_NS.deref()).importClass(\"\n          + printClass(className) + \".class);\");\n      if (context == C.STATEMENT) {\n        gen.pop();\n        return \"\";\n      } else {\n        return wrap(context, \"null\");\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return false;\n    }\n\n    public Class getJavaClass() {\n      throw new IllegalArgumentException(\"ImportExpr has no Java class\");\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object form) {\n        return new ImportExpr((String) RT.second(form));\n      }\n    }\n  }\n\n  public static abstract class LiteralExpr implements Expr {\n    abstract Object val();\n\n    public Object eval() {\n      return val();\n    }\n  }\n\n  static interface AssignableExpr {\n    Object evalAssign(Expr val);\n\n    String emitAssign(C context, ObjExpr objx, GeneratorAdapter gen, Expr val);\n  }\n\n  static public interface MaybePrimitiveExpr extends Expr {\n    public boolean canEmitPrimitive();\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen);\n  }\n\n  static public abstract class HostExpr implements Expr, MaybePrimitiveExpr {\n    final static Type BOOLEAN_TYPE = Type.getType(Boolean.class);\n    final static Type CHAR_TYPE = Type.getType(Character.class);\n    final static Type INTEGER_TYPE = Type.getType(Integer.class);\n    final static Type LONG_TYPE = Type.getType(Long.class);\n    final static Type FLOAT_TYPE = Type.getType(Float.class);\n    final static Type DOUBLE_TYPE = Type.getType(Double.class);\n    final static Type SHORT_TYPE = Type.getType(Short.class);\n    final static Type BYTE_TYPE = Type.getType(Byte.class);\n    final static Type NUMBER_TYPE = Type.getType(Number.class);\n\n    final static Method charValueMethod = Method.getMethod(\"char charValue()\");\n    final static Method booleanValueMethod = Method\n        .getMethod(\"boolean booleanValue()\");\n\n    final static Method charValueOfMethod = Method\n        .getMethod(\"Character valueOf(char)\");\n    final static Method intValueOfMethod = Method\n        .getMethod(\"Integer valueOf(int)\");\n    final static Method longValueOfMethod = Method\n        .getMethod(\"Long valueOf(long)\");\n    final static Method floatValueOfMethod = Method\n        .getMethod(\"Float valueOf(float)\");\n    final static Method doubleValueOfMethod = Method\n        .getMethod(\"Double valueOf(double)\");\n    final static Method shortValueOfMethod = Method\n        .getMethod(\"Short valueOf(short)\");\n    final static Method byteValueOfMethod = Method\n        .getMethod(\"Byte valueOf(byte)\");\n\n    final static Method intValueMethod = Method.getMethod(\"int intValue()\");\n    final static Method longValueMethod = Method.getMethod(\"long longValue()\");\n    final static Method floatValueMethod = Method\n        .getMethod(\"float floatValue()\");\n    final static Method doubleValueMethod = Method\n        .getMethod(\"double doubleValue()\");\n    final static Method byteValueMethod = Method.getMethod(\"byte byteValue()\");\n    final static Method shortValueMethod = Method\n        .getMethod(\"short shortValue()\");\n\n    final static Method fromIntMethod = Method\n        .getMethod(\"clojure.lang.Num from(int)\");\n    final static Method fromLongMethod = Method\n        .getMethod(\"clojure.lang.Num from(long)\");\n    final static Method fromDoubleMethod = Method\n        .getMethod(\"clojure.lang.Num from(double)\");\n\n    // *\n    public static String emitBoxReturn(ObjExpr objx, GeneratorAdapter gen,\n        Class returnType, String val) {\n      if (returnType.isPrimitive()) {\n        if (returnType == boolean.class) {\n          Label falseLabel = gen.newLabel();\n          Label endLabel = gen.newLabel();\n          gen.ifZCmp(GeneratorAdapter.EQ, falseLabel);\n          gen.getStatic(BOOLEAN_OBJECT_TYPE, \"TRUE\", BOOLEAN_OBJECT_TYPE);\n          gen.goTo(endLabel);\n          gen.mark(falseLabel);\n          gen.getStatic(BOOLEAN_OBJECT_TYPE, \"FALSE\", BOOLEAN_OBJECT_TYPE);\n          // NIL_EXPR.emit(C.EXPRESSION, fn, gen);\n          gen.mark(endLabel);\n          return \"(\" + val + \" ? Boolean.TRUE : Boolean.FALSE)\";\n        } else if (returnType == void.class) {\n          NIL_EXPR.emit(C.EXPRESSION, objx, gen);\n          emitSource(val + \";\");\n          return \"null\";\n        } else if (returnType == char.class) {\n          gen.invokeStatic(CHAR_TYPE, charValueOfMethod);\n          return \"Character.valueOf(\" + val + \")\";\n        } else {\n          if (returnType == int.class) {\n            gen.invokeStatic(INTEGER_TYPE, intValueOfMethod);\n            // gen.visitInsn(I2L);\n            // gen.invokeStatic(NUMBERS_TYPE,\n            // Method.getMethod(\"Number num(long)\"));\n            return \"Integer.valueOf(\" + val + \")\";\n          } else if (returnType == float.class) {\n            gen.invokeStatic(FLOAT_TYPE, floatValueOfMethod);\n\n            // gen.visitInsn(F2D);\n            // gen.invokeStatic(DOUBLE_TYPE, doubleValueOfMethod);\n            return \"Float.valueOf(\" + val + \")\";\n          } else if (returnType == double.class) {\n            gen.invokeStatic(DOUBLE_TYPE, doubleValueOfMethod);\n            return \"Double.valueOf(\" + val + \")\";\n          } else if (returnType == long.class) {\n            gen.invokeStatic(NUMBERS_TYPE, Method.getMethod(\"Number num(long)\"));\n            return \"Numbers.num(\" + val + \")\";\n          } else if (returnType == byte.class) {\n            gen.invokeStatic(BYTE_TYPE, byteValueOfMethod);\n            return \"Byte.valueOf(\" + val + \")\";\n          } else if (returnType == short.class) {\n            gen.invokeStatic(SHORT_TYPE, shortValueOfMethod);\n            return \"Short.valueOf(\" + val + \")\";\n          }\n        }\n      }\n      return \"((\" + printClass(returnType) + \")\" + val + \")\";\n    }\n\n    // */\n    public static String emitUnboxArg(ObjExpr objx, GeneratorAdapter gen,\n        Class paramType, String val) {\n      if (paramType.isPrimitive()) {\n        if (paramType == boolean.class) {\n          gen.checkCast(BOOLEAN_TYPE);\n          gen.invokeVirtual(BOOLEAN_TYPE, booleanValueMethod);\n          // Label falseLabel = gen.newLabel();\n          // Label endLabel = gen.newLabel();\n          // gen.ifNull(falseLabel);\n          // gen.push(1);\n          // gen.goTo(endLabel);\n          // gen.mark(falseLabel);\n          // gen.push(0);\n          // gen.mark(endLabel);\n          return \"((Boolean)\" + val + \").booleanValue()\";\n        } else if (paramType == char.class) {\n          gen.checkCast(CHAR_TYPE);\n          gen.invokeVirtual(CHAR_TYPE, charValueMethod);\n          return \"((Character)\" + val + \").charValue()\";\n        } else {\n          Method m = null;\n          gen.checkCast(NUMBER_TYPE);\n          if (RT.booleanCast(RT.UNCHECKED_MATH.deref())) {\n            if (paramType == int.class)\n              m = Method.getMethod(\"int uncheckedIntCast(Object)\");\n            else if (paramType == float.class)\n              m = Method.getMethod(\"float uncheckedFloatCast(Object)\");\n            else if (paramType == double.class)\n              m = Method.getMethod(\"double uncheckedDoubleCast(Object)\");\n            else if (paramType == long.class)\n              m = Method.getMethod(\"long uncheckedLongCast(Object)\");\n            else if (paramType == byte.class)\n              m = Method.getMethod(\"byte uncheckedByteCast(Object)\");\n            else if (paramType == short.class)\n              m = Method.getMethod(\"short uncheckedShortCast(Object)\");\n          } else {\n            if (paramType == int.class)\n              m = Method.getMethod(\"int intCast(Object)\");\n            else if (paramType == float.class)\n              m = Method.getMethod(\"float floatCast(Object)\");\n            else if (paramType == double.class)\n              m = Method.getMethod(\"double doubleCast(Object)\");\n            else if (paramType == long.class)\n              m = Method.getMethod(\"long longCast(Object)\");\n            else if (paramType == byte.class)\n              m = Method.getMethod(\"byte byteCast(Object)\");\n            else if (paramType == short.class)\n              m = Method.getMethod(\"short shortCast(Object)\");\n          }\n          gen.invokeStatic(RT_TYPE, m);\n          return \"RT.\" + m.getName() + \"(\" + val + \")\";\n        }\n      } else {\n        gen.checkCast(Type.getType(paramType));\n        return \"((\" + printClass(paramType) + \")\" + val + \")\";\n      }\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object frm) {\n        ISeq form = (ISeq) frm;\n        // (. x fieldname-sym) or\n        // (. x 0-ary-method)\n        // (. x methodname-sym args+)\n        // (. x (methodname-sym args?))\n        if (RT.length(form) < 3)\n          throw new IllegalArgumentException(\n              \"Malformed member expression, expecting (. target member ...)\");\n        // determine static or instance\n        // static target must be symbol, either fully.qualified.Classname or\n        // Classname that has been imported\n        int line = lineDeref();\n        int column = columnDeref();\n        String source = (String) SOURCE.deref();\n        Class c = maybeClass(RT.second(form), false);\n        // at this point c will be non-null if static\n        Expr instance = null;\n        if (c == null)\n          instance = analyze(context == C.EVAL ? context : C.EXPRESSION,\n              RT.second(form));\n\n        boolean maybeField = RT.length(form) == 3\n            && (RT.third(form) instanceof Symbol && !RT.third(form).equals(\n                Symbol.intern(\"getClass\")));\n\n        if (maybeField && !(((Symbol) RT.third(form)).name.charAt(0) == '-')) {\n          Symbol sym = (Symbol) RT.third(form);\n          if (c != null)\n            maybeField = Reflector.getMethods(c, 0, munge(sym.name), true)\n                .size() == 0;\n          else if (instance != null && instance.hasJavaClass()\n              && instance.getJavaClass() != null)\n            maybeField = Reflector.getMethods(instance.getJavaClass(), 0,\n                munge(sym.name), false).size() == 0;\n        }\n\n        if (maybeField) // field\n        {\n          Symbol sym = (((Symbol) RT.third(form)).name.charAt(0) == '-') ? Symbol\n              .intern(((Symbol) RT.third(form)).name.substring(1))\n              : (Symbol) RT.third(form);\n          Symbol tag = tagOf(form);\n          if (c != null) {\n            return new StaticFieldExpr(line, column, c, munge(sym.name), tag);\n          } else\n            return new InstanceFieldExpr(line, column, instance,\n                munge(sym.name), tag,\n                (((Symbol) RT.third(form)).name.charAt(0) == '-'));\n        } else {\n          ISeq call = (ISeq) ((RT.third(form) instanceof ISeq) ? RT.third(form)\n              : RT.next(RT.next(form)));\n          if (!(RT.first(call) instanceof Symbol))\n            throw new IllegalArgumentException(\"Malformed member expression\");\n          Symbol sym = (Symbol) RT.first(call);\n          Symbol tag = tagOf(form);\n          PersistentVector args = PersistentVector.EMPTY;\n          for (ISeq s = RT.next(call); s != null; s = s.next())\n            args = args.cons(analyze(\n                context == C.EVAL ? context : C.EXPRESSION, s.first()));\n          if (c != null)\n            return new StaticMethodExpr(source, line, column, tag, c,\n                munge(sym.name), args);\n          else\n            return new InstanceMethodExpr(source, line, column, tag, instance,\n                munge(sym.name), args);\n        }\n      }\n    }\n\n    private static Class maybeClass(Object form, boolean stringOk) {\n      if (form instanceof Class)\n        return (Class) form;\n      Class c = null;\n      if (form instanceof Symbol) {\n        Symbol sym = (Symbol) form;\n        if (sym.ns == null) // if ns-qualified can't be classname\n        {\n          if (Util.equals(sym, COMPILE_STUB_SYM.get()))\n            return (Class) COMPILE_STUB_CLASS.get();\n          if (sym.name.indexOf('.') > 0 || sym.name.charAt(0) == '[')\n            c = RT.classForName(sym.name);\n          else {\n            Object o = currentNS().getMapping(Symbol.intern(sym.toString().replaceAll(\"-\", \"_\")));\n            if (o instanceof Class)\n              c = (Class) o;\n            else if(LOCAL_ENV.deref() != null && ((java.util.Map)LOCAL_ENV.deref()).containsKey(form))\n              return null;\n            else {\n              try {\n                c = RT.classForName(sym.name);\n              } catch (Exception e) {\n                // aargh\n                // leave c set to null -> return null\n              }\n            }\n          }\n        }\n      } else if (stringOk && form instanceof String)\n        c = RT.classForName((String) form);\n      return c;\n    }\n\n    /*\n     * private static String maybeClassName(Object form, boolean stringOk){\n     * String className = null; if(form instanceof Symbol) { Symbol sym =\n     * (Symbol) form; if(sym.ns == null) //if ns-qualified can't be classname {\n     * if(sym.name.indexOf('.') > 0 || sym.name.charAt(0) == '[') className =\n     * sym.name; else { IPersistentMap imports = (IPersistentMap) ((Var)\n     * RT.NS_IMPORTS.get()).get(); className = (String) imports.valAt(sym); } }\n     * } else if(stringOk && form instanceof String) className = (String) form;\n     * return className; }\n     */\n    static Class tagToClass(Object tag) {\n      Class c = null;\n      if (tag instanceof Symbol) {\n        Symbol sym = (Symbol) tag;\n        if (sym.ns == null) // if ns-qualified can't be classname\n        {\n          if (sym.name.equals(\"objects\"))\n            c = Object[].class;\n          else if (sym.name.equals(\"ints\"))\n            c = int[].class;\n          else if (sym.name.equals(\"longs\"))\n            c = long[].class;\n          else if (sym.name.equals(\"floats\"))\n            c = float[].class;\n          else if (sym.name.equals(\"doubles\"))\n            c = double[].class;\n          else if (sym.name.equals(\"chars\"))\n            c = char[].class;\n          else if (sym.name.equals(\"shorts\"))\n            c = short[].class;\n          else if (sym.name.equals(\"bytes\"))\n            c = byte[].class;\n          else if (sym.name.equals(\"booleans\"))\n            c = boolean[].class;\n          else if (sym.name.equals(\"int\"))\n            c = Integer.TYPE;\n          else if (sym.name.equals(\"long\"))\n            c = Long.TYPE;\n          else if (sym.name.equals(\"float\"))\n            c = Float.TYPE;\n          else if (sym.name.equals(\"double\"))\n            c = Double.TYPE;\n          else if (sym.name.equals(\"char\"))\n            c = Character.TYPE;\n          else if (sym.name.equals(\"short\"))\n            c = Short.TYPE;\n          else if (sym.name.equals(\"byte\"))\n            c = Byte.TYPE;\n          else if (sym.name.equals(\"boolean\"))\n            c = Boolean.TYPE;\n        }\n      }\n      if(c == null)\n        c = maybeClass(tag, true);\n      if (c != null)\n        return c;\n      throw new IllegalArgumentException(\"Unable to resolve classname: \" + tag);\n    }\n\n    public static String tagToCanonical(Object tag) {\n      try {\n        return printClass(tagToClass(tag));\n      } catch (Exception e) {\n        return printClass(String.valueOf(tag));\n      }\n    }\n  }\n\n  static abstract class FieldExpr extends HostExpr {\n  }\n\n  static class InstanceFieldExpr extends FieldExpr implements AssignableExpr {\n    public final Expr target;\n    public final Class targetClass;\n    public final java.lang.reflect.Field field;\n    public final String fieldName;\n    public final int line;\n    public final int column;\n    public final Symbol tag;\n    public final boolean requireField;\n    final static Method invokeNoArgInstanceMember = Method\n        .getMethod(\"Object invokeNoArgInstanceMember(Object,String,boolean)\");\n    final static Method setInstanceFieldMethod = Method\n        .getMethod(\"Object setInstanceField(Object,String,Object)\");\n\n    public InstanceFieldExpr(int line, int column, Expr target,\n        String fieldName, Symbol tag, boolean requireField) {\n      this.target = target;\n      this.targetClass = target.hasJavaClass() ? target.getJavaClass() : null;\n      this.field = targetClass != null ? Reflector.getField(targetClass,\n          fieldName, false) : null;\n      this.fieldName = fieldName;\n      this.line = line;\n      this.column = column;\n      this.tag = tag;\n      this.requireField = requireField;\n      if (field == null && RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) {\n        if (targetClass == null) {\n          RT.errPrintWriter()\n              .format(\n                  \"Reflection warning, %s:%d:%d - reference to field %s can't be resolved.\\n\",\n                  SOURCE_PATH.deref(), line, column, fieldName);\n        } else {\n          RT.errPrintWriter()\n              .format(\n                  \"Reflection warning, %s:%d:%d - reference to field %s on %s can't be resolved.\\n\",\n                  SOURCE_PATH.deref(), line, column, fieldName,\n                  targetClass.getName());\n        }\n      }\n    }\n\n    public Object eval() {\n      return Reflector.invokeNoArgInstanceMember(target.eval(), fieldName,\n          requireField);\n    }\n\n    public boolean canEmitPrimitive() {\n      return targetClass != null && field != null\n          && Util.isPrimitive(field.getType());\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      if (targetClass != null && field != null) {\n        String value = target.emit(C.EXPRESSION, objx, gen);\n        gen.visitLineNumber(line, gen.mark());\n        gen.checkCast(getType(targetClass));\n        gen.getField(getType(targetClass), fieldName,\n            Type.getType(field.getType()));\n        return wrap(context, \"((\" + printClass(targetClass) + \")\" + value\n            + \").\" + fieldName);\n      } else\n        throw new UnsupportedOperationException(\n            \"Unboxed emit of unknown member\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      if (targetClass != null && field != null) {\n        String value = target.emit(C.EXPRESSION, objx, gen);\n        gen.visitLineNumber(line, gen.mark());\n        gen.checkCast(getType(targetClass));\n        gen.getField(getType(targetClass), fieldName,\n            Type.getType(field.getType()));\n        // if(context != C.STATEMENT)\n        String v = \"((\" + printClass(targetClass) + \")\" + value + \").\"\n            + fieldName;\n        v = HostExpr.emitBoxReturn(objx, gen, field.getType(), v);\n        if (context == C.STATEMENT) {\n          gen.pop();\n          return \"\";\n        } else {\n          return wrap(context, v);\n        }\n      } else {\n        String t = target.emit(C.EXPRESSION, objx, gen);\n        gen.visitLineNumber(line, gen.mark());\n        gen.push(fieldName);\n        gen.push(requireField);\n        gen.invokeStatic(REFLECTOR_TYPE, invokeNoArgInstanceMember);\n        if (context == C.STATEMENT)\n          gen.pop();\n\n        return wrap(context, \"Reflector.invokeNoArgInstanceMember(\" + t\n            + \", \\\"\" + fieldName + \"\\\")\");\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return field != null || tag != null;\n    }\n\n    public Class getJavaClass() {\n      return tag != null ? HostExpr.tagToClass(tag) : field.getType();\n    }\n\n    public Object evalAssign(Expr val) {\n      return Reflector.setInstanceField(target.eval(), fieldName, val.eval());\n    }\n\n    public String emitAssign(C context, ObjExpr objx, GeneratorAdapter gen,\n        Expr val) {\n      String ret;\n      if (targetClass != null && field != null) {\n        String t = target.emit(C.EXPRESSION, objx, gen);\n        gen.checkCast(Type.getType(targetClass));\n        String value = val.emit(C.EXPRESSION, objx, gen);\n        gen.visitLineNumber(line, gen.mark());\n        gen.dupX1();\n        t = \"((\" + printClass(targetClass) + \")\" + t + \")\";\n        emitSource(t + \".\" + fieldName\n            + \" = (\" + printClass(field.getType()) + \")\" + value + \";\");\n        String v = HostExpr.emitUnboxArg(objx, gen, field.getType(), t + \".\"\n            + fieldName);\n        gen.putField(Type.getType(targetClass), fieldName,\n            Type.getType(field.getType()));\n        ret = wrap(context, v);\n      } else {\n        String t = target.emit(C.EXPRESSION, objx, gen);\n        gen.push(fieldName);\n        String e = val.emit(C.EXPRESSION, objx, gen);\n        gen.visitLineNumber(line, gen.mark());\n        gen.invokeStatic(REFLECTOR_TYPE, setInstanceFieldMethod);\n        ret = wrap(context, \"Reflector.setInstanceField(\" + t + \", \\\"\" + fieldName + \"\\\", \" + e + \")\");\n      }\n      if (context == C.STATEMENT) {\n        gen.pop();\n        return \"\";\n      } else {\n        return ret;\n      }\n    }\n  }\n\n  static class StaticFieldExpr extends FieldExpr implements AssignableExpr {\n    // final String className;\n    public final String fieldName;\n    public final Class c;\n    public final java.lang.reflect.Field field;\n    public final Symbol tag;\n    // final static Method getStaticFieldMethod =\n    // Method.getMethod(\"Object getStaticField(String,String)\");\n    // final static Method setStaticFieldMethod =\n    // Method.getMethod(\"Object setStaticField(String,String,Object)\");\n    final int line;\n    final int column;\n\n    public StaticFieldExpr(int line, int column, Class c, String fieldName,\n        Symbol tag) {\n      // this.className = className;\n      this.fieldName = fieldName;\n      this.line = line;\n      this.column = column;\n      // c = Class.forName(className);\n      this.c = c;\n      try {\n        field = c.getField(fieldName);\n      } catch (NoSuchFieldException e) {\n        throw Util.sneakyThrow(e);\n      }\n      this.tag = tag;\n    }\n\n    public Object eval() {\n      return Reflector.getStaticField(c, fieldName);\n    }\n\n    public boolean canEmitPrimitive() {\n      return Util.isPrimitive(field.getType());\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      gen.visitLineNumber(line, gen.mark());\n      gen.getStatic(Type.getType(c), fieldName, Type.getType(field.getType()));\n\n      return printClass(c) + \".\" + fieldName;\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      gen.visitLineNumber(line, gen.mark());\n\n      gen.getStatic(Type.getType(c), fieldName, Type.getType(field.getType()));\n      // if(context != C.STATEMENT)\n      String v = printClass(c) + \".\" + fieldName;\n      v = HostExpr.emitBoxReturn(objx, gen, field.getType(), v);\n      if (context == C.STATEMENT) {\n        gen.pop();\n        return \"\";\n      } else {\n        // gen.push(className);\n        // gen.push(fieldName);\n        // gen.invokeStatic(REFLECTOR_TYPE, getStaticFieldMethod);\n\n        return wrap(context, v);\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      // Class c = Class.forName(className);\n      // java.lang.reflect.Field field = c.getField(fieldName);\n      return tag != null ? HostExpr.tagToClass(tag) : field.getType();\n    }\n\n    public Object evalAssign(Expr val) {\n      return Reflector.setStaticField(c, fieldName, val.eval());\n    }\n\n    public String emitAssign(C context, ObjExpr objx, GeneratorAdapter gen,\n        Expr val) {\n      String value = val.emit(C.EXPRESSION, objx, gen);\n      gen.visitLineNumber(line, gen.mark());\n      gen.dup();\n      emitSource(printClass(c) + \".\" + fieldName + \" = (\"\n          + printClass(field.getType()) + \")\" + value + \";\");\n      String v = HostExpr.emitUnboxArg(objx, gen, field.getType(),\n          printClass(c) + \".\" + fieldName);\n      gen.putStatic(Type.getType(c), fieldName, Type.getType(field.getType()));\n      if (context == C.STATEMENT) {\n        gen.pop();\n        return \"\";\n      } else {\n        return wrap(context, v);\n      }\n    }\n  }\n\n  static Class maybePrimitiveType(Expr e) {\n    if (e instanceof MaybePrimitiveExpr && e.hasJavaClass()\n        && ((MaybePrimitiveExpr) e).canEmitPrimitive()) {\n      Class c = e.getJavaClass();\n      if (Util.isPrimitive(c))\n        return c;\n    }\n    return null;\n  }\n\n  static Class maybeJavaClass(Collection<Expr> exprs) {\n    Class match = null;\n    try {\n      for (Expr e : exprs) {\n        if (e instanceof ThrowExpr)\n          continue;\n        if (!e.hasJavaClass())\n          return null;\n        Class c = e.getJavaClass();\n        if (match == null)\n          match = c;\n        else if (match != c)\n          return null;\n      }\n    } catch (Exception e) {\n      return null;\n    }\n    return match;\n  }\n\n  static abstract class MethodExpr extends HostExpr {\n    static String emitArgsAsArray(IPersistentVector args, ObjExpr objx,\n        GeneratorAdapter gen) {\n      gen.push(args.count());\n      gen.newArray(OBJECT_TYPE);\n      StringBuilder sb = new StringBuilder();\n      for (int i = 0; i < args.count(); i++) {\n        if (sb.length() > 0) {\n          sb.append(\", \");\n        }\n        gen.dup();\n        gen.push(i);\n        sb.append(((Expr) args.nth(i)).emit(C.EXPRESSION, objx, gen));\n        gen.arrayStore(OBJECT_TYPE);\n      }\n      return sb.toString();\n    }\n\n    public static String combineArgs(List<String> a) {\n      StringBuilder sb = new StringBuilder();\n      for (String s : a) {\n        if (sb.length() > 0) {\n          sb.append(\", \");\n        }\n        sb.append(s);\n      }\n      return sb.toString();\n    }\n\n    public static List<String> emitTypedArgs(ObjExpr objx,\n        GeneratorAdapter gen, Class[] parameterTypes, IPersistentVector args) {\n      ArrayList<String> r = new ArrayList<String>();\n      for (int i = 0; i < parameterTypes.length; i++) {\n        Expr e = (Expr) args.nth(i);\n        try {\n          StringBuilder sb = new StringBuilder();\n          final Class primc = maybePrimitiveType(e);\n          String canonicalName = printClass(parameterTypes[i]);\n          if (primc != null) {\n            sb.append(\"(\" + canonicalName + \")\");\n          }\n          if (primc == parameterTypes[i]) {\n            final MaybePrimitiveExpr pe = (MaybePrimitiveExpr) e;\n            sb.append(pe.emitUnboxed(C.EXPRESSION, objx, gen));\n          } else if (primc == int.class && parameterTypes[i] == long.class) {\n            final MaybePrimitiveExpr pe = (MaybePrimitiveExpr) e;\n            sb.append(pe.emitUnboxed(C.EXPRESSION, objx, gen));\n            gen.visitInsn(I2L);\n          } else if (primc == long.class && parameterTypes[i] == int.class) {\n            final MaybePrimitiveExpr pe = (MaybePrimitiveExpr) e;\n            String val = pe.emitUnboxed(C.EXPRESSION, objx, gen);\n            if (RT.booleanCast(RT.UNCHECKED_MATH.deref())) {\n              gen.invokeStatic(RT_TYPE,\n                  Method.getMethod(\"int uncheckedIntCast(long)\"));\n              sb.append(\"RT.uncheckedIntCast(\" + val + \")\");\n            } else {\n              gen.invokeStatic(RT_TYPE, Method.getMethod(\"int intCast(long)\"));\n              sb.append(\"RT.intCast(\" + val + \")\");\n            }\n          } else if (primc == float.class && parameterTypes[i] == double.class) {\n            final MaybePrimitiveExpr pe = (MaybePrimitiveExpr) e;\n            sb.append(pe.emitUnboxed(C.EXPRESSION, objx, gen));\n            gen.visitInsn(F2D);\n          } else if (primc == double.class && parameterTypes[i] == float.class) {\n            final MaybePrimitiveExpr pe = (MaybePrimitiveExpr) e;\n            sb.append(pe.emitUnboxed(C.EXPRESSION, objx, gen));\n            gen.visitInsn(D2F);\n          } else {\n            String v = e.emit(C.EXPRESSION, objx, gen);\n            v = HostExpr.emitUnboxArg(objx, gen, parameterTypes[i], v);\n            sb.append(v);\n          }\n          r.add(sb.toString());\n        } catch (Exception e1) {\n          e1.printStackTrace(RT.errPrintWriter());\n        }\n      }\n      return r;\n    }\n  }\n\n  static class InstanceMethodExpr extends MethodExpr {\n    public final Expr target;\n    public final String methodName;\n    public final IPersistentVector args;\n    public final String source;\n    public final int line;\n    public final int column;\n    public final Symbol tag;\n    public final java.lang.reflect.Method method;\n\n    final static Method invokeInstanceMethodMethod = Method\n        .getMethod(\"Object invokeInstanceMethod(Object,String,Object[])\");\n\n    public InstanceMethodExpr(String source, int line, int column, Symbol tag,\n        Expr target, String methodName, IPersistentVector args) {\n      this.source = source;\n      this.line = line;\n      this.column = column;\n      this.args = args;\n      this.methodName = methodName;\n      this.target = target;\n      this.tag = tag;\n      List methods = Reflector.getMethods(\n          target.hasJavaClass() && target.getJavaClass() != null ? target\n              .getJavaClass() : Object.class, args.count(), methodName, false);\n      if (methods.isEmpty())\n        method = null;\n      else {\n        int methodidx = 0;\n        if (methods.size() > 1) {\n          ArrayList<Class[]> params = new ArrayList();\n          ArrayList<Class> rets = new ArrayList();\n          for (int i = 0; i < methods.size(); i++) {\n            java.lang.reflect.Method m = (java.lang.reflect.Method) methods\n                .get(i);\n            params.add(m.getParameterTypes());\n            rets.add(m.getReturnType());\n          }\n          methodidx = getMatchingParams(methodName, params, args, rets);\n        }\n        java.lang.reflect.Method m = (java.lang.reflect.Method) (methodidx >= 0 ? methods\n            .get(methodidx) : null);\n\n        if (m != null) {\n          ObjMethod objm = (ObjMethod) METHOD.get();\n          if (objm != null && !objm.hasException) {\n            for (Class ex : m.getExceptionTypes()) {\n              if (!RuntimeException.class.isAssignableFrom(ex)) {\n                objm.hasException = true;\n                break;\n              }\n            }\n          }\n        }\n        if (m != null\n            && !Modifier.isPublic(m.getDeclaringClass().getModifiers())) {\n          // public method of non-public class, try to find it in hierarchy\n          m = Reflector.getAsMethodOfPublicBase(m.getDeclaringClass(), m);\n        }\n        method = m;\n      }\n\n      if (method == null && RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) {\n        RT.errPrintWriter()\n            .format(\n                \"Reflection warning, %s:%d:%d - call to method %s on %s can't be resolved (argument types: %s).\\n\",\n                SOURCE_PATH.deref(), line, column, methodName,\n                target.getJavaClass().getName(), getTypeStringForArgs(args));\n      }\n    }\n\n    public Object eval() {\n      try {\n        Object targetval = target.eval();\n        Object[] argvals = new Object[args.count()];\n        for (int i = 0; i < args.count(); i++)\n          argvals[i] = ((Expr) args.nth(i)).eval();\n        if (method != null) {\n          LinkedList ms = new LinkedList();\n          ms.add(method);\n          return Reflector.invokeMatchingMethod(methodName, ms, targetval,\n              argvals);\n        }\n        return Reflector.invokeInstanceMethod(targetval, methodName, argvals);\n      } catch (Throwable e) {\n        if (!(e instanceof CompilerException))\n          throw new CompilerException(source, line, column, e);\n        else\n          throw (CompilerException) e;\n      }\n    }\n\n    public boolean canEmitPrimitive() {\n      return method != null && Util.isPrimitive(method.getReturnType());\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      if (method != null) {\n        Type type = Type.getType(method.getDeclaringClass());\n        String first = target.emit(C.EXPRESSION, objx, gen);\n        // if(!method.getDeclaringClass().isInterface())\n        gen.checkCast(type);\n        String argsList = MethodExpr.combineArgs(MethodExpr.emitTypedArgs(objx,\n            gen, method.getParameterTypes(), args));\n        gen.visitLineNumber(line, gen.mark());\n        if (context == C.RETURN) {\n          ObjMethod method = (ObjMethod) METHOD.deref();\n          method.emitClearLocals(gen);\n        }\n        Method m = new Method(methodName, Type.getReturnType(method),\n            Type.getArgumentTypes(method));\n        if (method.getDeclaringClass().isInterface())\n          gen.invokeInterface(type, m);\n        else\n          gen.invokeVirtual(type, m);\n        return wrap(context, \"((\" + printClass(method.getDeclaringClass())\n            + \")\" + first + \").\" + method.getName() + \"(\" + argsList + \")\");\n      } else\n        throw new UnsupportedOperationException(\n            \"Unboxed emit of unknown member\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String ret = null;\n      if (method != null) {\n        Type type = Type.getType(method.getDeclaringClass());\n        String val = target.emit(C.EXPRESSION, objx, gen);\n        // if(!method.getDeclaringClass().isInterface())\n        gen.checkCast(type);\n        String argsList = MethodExpr.combineArgs(MethodExpr.emitTypedArgs(objx,\n            gen, method.getParameterTypes(), args));\n        gen.visitLineNumber(line, gen.mark());\n        if (context == C.RETURN) {\n          ObjMethod method = (ObjMethod) METHOD.deref();\n          method.emitClearLocals(gen);\n        }\n\n        Method m = new Method(methodName, Type.getReturnType(method),\n            Type.getArgumentTypes(method));\n        if (method.getDeclaringClass().isInterface())\n          gen.invokeInterface(type, m);\n        else\n          gen.invokeVirtual(type, m);\n        // if(context != C.STATEMENT || method.getReturnType() == Void.TYPE)\n        ret = \"((\" + printClass(method.getDeclaringClass()) + \")\" + val + \").\"\n            + methodName + \"(\" + argsList + \")\";\n        String ret1 = HostExpr.emitBoxReturn(objx, gen, method.getReturnType(),\n            ret);\n        if (context != C.STATEMENT) {\n          ret = ret1;\n        }\n        if (context == C.STATEMENT && ret1.equals(\"null\")) {\n          ret = \"\";\n        }\n      } else {\n        String t = target.emit(C.EXPRESSION, objx, gen);\n        gen.push(methodName);\n        String argsList = emitArgsAsArray(args, objx, gen);\n        gen.visitLineNumber(line, gen.mark());\n        if (context == C.RETURN) {\n          ObjMethod method = (ObjMethod) METHOD.deref();\n          method.emitClearLocals(gen);\n        }\n        gen.invokeStatic(REFLECTOR_TYPE, invokeInstanceMethodMethod);\n        ret = \"Reflector.invokeInstanceMethod(\" + t + \", \\\"\" + methodName\n            + \"\\\", new Object[]{\" + argsList + \"})\";\n      }\n      if (context == C.STATEMENT)\n        gen.pop();\n\n      if (ret.isEmpty()) {\n        return \"\";\n      } else {\n        return wrap(context, ret);\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return method != null || tag != null;\n    }\n\n    public Class getJavaClass() {\n      return tag != null ? HostExpr.tagToClass(tag) : method.getReturnType();\n    }\n  }\n\n  static class StaticMethodExpr extends MethodExpr {\n    // final String className;\n    public final Class c;\n    public final String methodName;\n    public final IPersistentVector args;\n    public final String source;\n    public final int line;\n    public final int column;\n    public final java.lang.reflect.Method method;\n    public final Symbol tag;\n    final static Method forNameMethod = Method\n        .getMethod(\"Class classForName(String)\");\n    final static Method invokeStaticMethodMethod = Method\n        .getMethod(\"Object invokeStaticMethod(Class,String,Object[])\");\n    final static Keyword warnOnBoxedKeyword = Keyword.intern(\"warn-on-boxed\");\n\n    public StaticMethodExpr(String source, int line, int column, Symbol tag,\n        Class c, String methodName, IPersistentVector args) {\n      this.c = c;\n      this.methodName = methodName;\n      this.args = args;\n      this.source = source;\n      this.line = line;\n      this.column = column;\n      this.tag = tag;\n\n      List methods = Reflector.getMethods(c, args.count(), methodName, true);\n      if (methods.isEmpty())\n        throw new IllegalArgumentException(\"No matching method: \"\n            + printClass(c) + \".\" + methodName);\n\n      int methodidx = 0;\n      if (methods.size() > 1) {\n        ArrayList<Class[]> params = new ArrayList();\n        ArrayList<Class> rets = new ArrayList();\n        for (int i = 0; i < methods.size(); i++) {\n          java.lang.reflect.Method m = (java.lang.reflect.Method) methods\n              .get(i);\n          params.add(m.getParameterTypes());\n          rets.add(m.getReturnType());\n        }\n        methodidx = getMatchingParams(methodName, params, args, rets);\n      }\n      method = (java.lang.reflect.Method) (methodidx >= 0 ? methods\n          .get(methodidx) : null);\n\n      if (method != null) {\n        ObjMethod m = (ObjMethod) METHOD.get();\n        if (m != null && !m.hasException) {\n          for (Class ex : method.getExceptionTypes()) {\n            if (!RuntimeException.class.isAssignableFrom(ex)) {\n              m.hasException = true;\n              break;\n            }\n          }\n        }\n      }\n\n      if (method == null && RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) {\n        RT.errPrintWriter()\n            .format(\n                \"Reflection warning, %s:%d:%d - call to static method %s on %s can't be resolved (argument types: %s).\\n\",\n                SOURCE_PATH.deref(), line, column, methodName, c.getName(),\n                getTypeStringForArgs(args));\n      }\n      if (method != null\n          && warnOnBoxedKeyword.equals(RT.UNCHECKED_MATH.deref())\n          && isBoxedMath(method)) {\n        RT.errPrintWriter().format(\n            \"Boxed math warning, %s:%d:%d - call: %s.\\n\", SOURCE_PATH.deref(),\n            line, column, method.toString());\n      }\n    }\n\n    public static boolean isBoxedMath(java.lang.reflect.Method m) {\n      Class c = m.getDeclaringClass();\n      if (c.equals(Numbers.class)) {\n        WarnBoxedMath boxedMath = m.getAnnotation(WarnBoxedMath.class);\n        if (boxedMath != null)\n          return boxedMath.value();\n\n        Class[] argTypes = m.getParameterTypes();\n        for (Class argType : argTypes)\n          if (argType.equals(Object.class) || argType.equals(Number.class))\n            return true;\n      }\n      return false;\n    }\n\n    public Object eval() {\n      try {\n        Object[] argvals = new Object[args.count()];\n        for (int i = 0; i < args.count(); i++)\n          argvals[i] = ((Expr) args.nth(i)).eval();\n        if (method != null) {\n          LinkedList ms = new LinkedList();\n          ms.add(method);\n          return Reflector.invokeMatchingMethod(methodName, ms, null, argvals);\n        }\n        return Reflector.invokeStaticMethod(c, methodName, argvals);\n      } catch (Throwable e) {\n        if (!(e instanceof CompilerException))\n          throw new CompilerException(source, line, column, e);\n        else\n          throw (CompilerException) e;\n      }\n    }\n\n    public boolean canEmitPrimitive() {\n      return method != null && Util.isPrimitive(method.getReturnType());\n    }\n\n    public boolean canEmitIntrinsicPredicate() {\n      return method != null\n          && RT.get(Intrinsics.preds, method.toString()) != null;\n    }\n\n    public String emitIntrinsicPredicate(C context, ObjExpr objx,\n        GeneratorAdapter gen, Label falseLabel) {\n      gen.visitLineNumber(line, gen.mark());\n      if (method != null) {\n        List<String> argsList = MethodExpr.emitTypedArgs(objx, gen,\n            method.getParameterTypes(), args);\n        if (context == C.RETURN) {\n          ObjMethod method = (ObjMethod) METHOD.deref();\n          method.emitClearLocals(gen);\n        }\n        Object[] predOps = (Object[]) RT.get(Intrinsics.preds,\n            method.toString());\n        for (int i = 0; i < predOps.length - 1; i++)\n          gen.visitInsn((Integer) predOps[i]);\n        gen.visitJumpInsn((Integer) predOps[predOps.length - 1], falseLabel);\n\n        String op = (String) RT.get(SourceGenIntrinsics.preds,\n            method.toString());\n        if (argsList.size() == 1) {\n          return wrap(context, \"(\" + op + argsList.get(0) + \")\");\n        } else if (argsList.size() == 2) {\n          return wrap(context, \"(\" + argsList.get(0) + \" \" + op + \" \"\n              + argsList.get(1) + \")\");\n        }\n        throw new RuntimeException(\"Error emiting intrinsics: \" + op + \" with \"\n            + argsList);\n      } else\n        throw new UnsupportedOperationException(\n            \"Unboxed emit of unknown member\");\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      if (method != null) {\n        List<String> argsList = MethodExpr.emitTypedArgs(objx, gen,\n            method.getParameterTypes(), args);\n        gen.visitLineNumber(line, gen.mark());\n        // Type type = Type.getObjectType(className.replace('.', '/'));\n        if (context == C.RETURN) {\n          ObjMethod method = (ObjMethod) METHOD.deref();\n          method.emitClearLocals(gen);\n        }\n        Object ops = RT.get(Intrinsics.ops, method.toString());\n        if (ops != null) {\n          if (ops instanceof Object[]) {\n            for (Object op : (Object[]) ops)\n              gen.visitInsn((Integer) op);\n          } else\n            gen.visitInsn((Integer) ops);\n\n          String op = (String) RT.get(SourceGenIntrinsics.ops,\n              method.toString());\n          String r;\n          if (op.equals(\"aget[]\")) {\n            return wrap(context, argsList.get(0) + \"[\" + argsList.get(1) + \"]\");\n          } else if (op.equals(\"alength[]\")) {\n            return wrap(context, argsList.get(0) + \".length\");\n          } else if (argsList.size() == 1) {\n            return wrap(context, \"(\" + op + argsList.get(0) + \")\");\n          } else if (argsList.size() == 2) {\n            return wrap(context, \"(\" + argsList.get(0) + \" \" + op + \" \"\n                + argsList.get(1) + \")\");\n          }\n          throw new RuntimeException(\"Error emiting intrinsics\");\n\n        } else {\n          Type type = Type.getType(c);\n          Method m = new Method(methodName, Type.getReturnType(method),\n              Type.getArgumentTypes(method));\n          gen.invokeStatic(type, m);\n          return wrap(context, printClass(c) + \".\" + m.getName() + \"(\"\n              + MethodExpr.combineArgs(argsList) + \")\");\n        }\n      } else\n        throw new UnsupportedOperationException(\n            \"Unboxed emit of unknown member\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      if (method != null) {\n        String argsList = MethodExpr.combineArgs(MethodExpr.emitTypedArgs(objx,\n            gen, method.getParameterTypes(), args));\n        gen.visitLineNumber(line, gen.mark());\n        // Type type = Type.getObjectType(className.replace('.', '/'));\n        if (context == C.RETURN) {\n          ObjMethod method = (ObjMethod) METHOD.deref();\n          method.emitClearLocals(gen);\n        }\n        Type type = Type.getType(c);\n        Method m = new Method(methodName, Type.getReturnType(method),\n            Type.getArgumentTypes(method));\n        gen.invokeStatic(type, m);\n        // if(context != C.STATEMENT || method.getReturnType() == Void.TYPE)\n        Class retClass = method.getReturnType();\n        String v = printClass(c) + \".\" + method.getName() + \"(\" + argsList\n            + \")\";\n        if (context == C.STATEMENT) {\n          if (retClass == long.class || retClass == double.class)\n            gen.pop2();\n          else if (retClass != void.class)\n            gen.pop();\n        } else {\n          v = HostExpr.emitBoxReturn(objx, gen, method.getReturnType(), v);\n        }\n        return wrap(context, v);\n      } else {\n        gen.visitLineNumber(line, gen.mark());\n        gen.push(c.getName());\n        gen.invokeStatic(RT_TYPE, forNameMethod);\n        gen.push(methodName);\n        String argsList = emitArgsAsArray(args, objx, gen);\n        gen.visitLineNumber(line, gen.mark());\n        if (context == C.RETURN) {\n          ObjMethod method = (ObjMethod) METHOD.deref();\n          method.emitClearLocals(gen);\n        }\n        gen.invokeStatic(REFLECTOR_TYPE, invokeStaticMethodMethod);\n        if (context == C.STATEMENT)\n          gen.pop();\n\n        return wrap(context, \"Reflector.invokeStaticMethod(\" + printClass(c)\n            + \".class, \\\"\" + methodName + \"\\\", new Object[]{\" + argsList + \"})\");\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return method != null || tag != null;\n    }\n\n    public Class getJavaClass() {\n      return tag != null ? HostExpr.tagToClass(tag) : method.getReturnType();\n    }\n  }\n\n  static class UnresolvedVarExpr implements Expr {\n    public final Symbol symbol;\n\n    public UnresolvedVarExpr(Symbol symbol) {\n      this.symbol = symbol;\n    }\n\n    public boolean hasJavaClass() {\n      return false;\n    }\n\n    public Class getJavaClass() {\n      throw new IllegalArgumentException(\"UnresolvedVarExpr has no Java class\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      throw new RuntimeException();\n    }\n\n    public Object eval() {\n      throw new IllegalArgumentException(\"UnresolvedVarExpr cannot be evalled\");\n    }\n  }\n\n  static class NumberExpr extends LiteralExpr implements MaybePrimitiveExpr {\n    final Number n;\n    public final int id;\n\n    public NumberExpr(Number n) {\n      this.n = n;\n      this.id = registerConstant(n);\n    }\n\n    Object val() {\n      return n;\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      if (context != C.STATEMENT) {\n        return wrap(context, objx.emitConstant(gen, id));\n        // emitUnboxed(context,objx,gen);\n        // HostExpr.emitBoxReturn(objx,gen,getJavaClass());\n      }\n      return \"\";\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      if (n instanceof Integer)\n        return long.class;\n      else if (n instanceof Double)\n        return double.class;\n      else if (n instanceof Long)\n        return long.class;\n      else\n        throw new IllegalStateException(\"Unsupported Number type: \"\n            + n.getClass().getName());\n    }\n\n    public boolean canEmitPrimitive() {\n      return true;\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      if (n instanceof Integer) {\n        gen.push(n.longValue());\n        return wrap(context, String.valueOf(n.longValue()));\n      } else if (n instanceof Double) {\n        gen.push(n.doubleValue());\n        return wrap(context, String.valueOf(n.doubleValue()));\n      } else if (n instanceof Long) {\n        gen.push(n.longValue());\n        return wrap(context, String.valueOf(n.longValue()) + \"L\");\n      }\n      throw new RuntimeException();\n    }\n\n    static public Expr parse(Number form) {\n      if (form instanceof Integer || form instanceof Double\n          || form instanceof Long)\n        return new NumberExpr(form);\n      else\n        return new ConstantExpr(form);\n    }\n  }\n\n  static class ConstantExpr extends LiteralExpr {\n    // stuff quoted vals in classloader at compile time, pull out at runtime\n    // this won't work for static compilation...\n    public final Object v;\n    public final int id;\n\n    public ConstantExpr(Object v) {\n      this.v = v;\n      this.id = registerConstant(v);\n      // this.id = RT.nextID();\n      // DynamicClassLoader loader = (DynamicClassLoader) LOADER.get();\n      // loader.registerQuotedVal(id, v);\n    }\n\n    Object val() {\n      return v;\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String val = objx.emitConstant(gen, id);\n\n      if (context == C.STATEMENT) {\n        gen.pop();\n        // gen.loadThis();\n        // gen.invokeVirtual(OBJECT_TYPE, getClassMethod);\n        // gen.invokeVirtual(CLASS_TYPE, getClassLoaderMethod);\n        // gen.checkCast(DYNAMIC_CLASSLOADER_TYPE);\n        // gen.push(id);\n        // gen.invokeVirtual(DYNAMIC_CLASSLOADER_TYPE, getQuotedValMethod);\n        return \"\";\n      } else {\n        return wrap(context, val);\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return Modifier.isPublic(v.getClass().getModifiers());\n      // return false;\n    }\n\n    public Class getJavaClass() {\n      if (v instanceof APersistentMap)\n        return APersistentMap.class;\n      else if (v instanceof APersistentSet)\n        return APersistentSet.class;\n      else if (v instanceof APersistentVector)\n        return APersistentVector.class;\n      else\n        return v.getClass();\n      // throw new IllegalArgumentException(\"Has no Java class\");\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object form) {\n        Object v = RT.second(form);\n\n        if (v == null)\n          return NIL_EXPR;\n        else if (v == Boolean.TRUE)\n          return TRUE_EXPR;\n        else if (v == Boolean.FALSE)\n          return FALSE_EXPR;\n        if (v instanceof Number)\n          return NumberExpr.parse((Number) v);\n        else if (v instanceof String)\n          return new StringExpr((String) v);\n        else if (v instanceof IPersistentCollection\n            && ((IPersistentCollection) v).count() == 0)\n          return new EmptyExpr(v);\n        else\n          return new ConstantExpr(v);\n      }\n    }\n  }\n\n  static class NilExpr extends LiteralExpr {\n    Object val() {\n      return null;\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      gen.visitInsn(Opcodes.ACONST_NULL);\n      if (context == C.STATEMENT) {\n        gen.pop();\n        return \"\";\n      }\n      return wrap(context, \"null\");\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return null;\n    }\n  }\n\n  final static NilExpr NIL_EXPR = new NilExpr();\n\n  static class BooleanExpr extends LiteralExpr {\n    public final boolean val;\n\n    public BooleanExpr(boolean val) {\n      this.val = val;\n    }\n\n    Object val() {\n      return val ? RT.T : RT.F;\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      if (val)\n        gen.getStatic(BOOLEAN_OBJECT_TYPE, \"TRUE\", BOOLEAN_OBJECT_TYPE);\n      else\n        gen.getStatic(BOOLEAN_OBJECT_TYPE, \"FALSE\", BOOLEAN_OBJECT_TYPE);\n      if (context == C.STATEMENT) {\n        gen.pop();\n        return \"\";\n      }\n      return wrap(context, (val ? \"Boolean.TRUE\" : \"Boolean.FALSE\"));\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return Boolean.class;\n    }\n  }\n\n  final static BooleanExpr TRUE_EXPR = new BooleanExpr(true);\n  final static BooleanExpr FALSE_EXPR = new BooleanExpr(false);\n\n  static class StringExpr extends LiteralExpr {\n    public final String str;\n\n    public StringExpr(String str) {\n      this.str = str;\n    }\n\n    Object val() {\n      return str;\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      if (context != C.STATEMENT) {\n        gen.push(str);\n        return wrap(context, \"\\\"\" + escapeString(str) + \"\\\"\");\n      } else {\n        return \"\";\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return String.class;\n    }\n  }\n\n  static class MonitorEnterExpr extends UntypedExpr {\n    final Expr target;\n\n    public MonitorEnterExpr(Expr target) {\n      this.target = target;\n    }\n\n    public Object eval() {\n      throw new UnsupportedOperationException(\"Can't eval monitor-enter\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      target.emit(C.EXPRESSION, objx, gen);\n      gen.monitorEnter();\n      NIL_EXPR.emit(context, objx, gen);\n      return \"\";\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object form) {\n        return new MonitorEnterExpr(analyze(C.EXPRESSION, RT.second(form)));\n      }\n    }\n  }\n\n  static class MonitorExitExpr extends UntypedExpr {\n    final Expr target;\n\n    public MonitorExitExpr(Expr target) {\n      this.target = target;\n    }\n\n    public Object eval() {\n      throw new UnsupportedOperationException(\"Can't eval monitor-exit\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      target.emit(C.EXPRESSION, objx, gen);\n      gen.monitorExit();\n      NIL_EXPR.emit(context, objx, gen);\n      return \"\";\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object form) {\n        return new MonitorExitExpr(analyze(C.EXPRESSION, RT.second(form)));\n      }\n    }\n\n  }\n\n  public static class TryExpr implements Expr {\n    public final Expr tryExpr;\n    public final Expr finallyExpr;\n    public final PersistentVector catchExprs;\n    public final int retLocal;\n    public final int finallyLocal;\n\n    public static class CatchClause {\n      // final String className;\n      public final Class c;\n      public final LocalBinding lb;\n      public final Expr handler;\n      Label label;\n      Label endLabel;\n\n      public CatchClause(Class c, LocalBinding lb, Expr handler) {\n        this.c = c;\n        this.lb = lb;\n        this.handler = handler;\n      }\n    }\n\n    public TryExpr(Expr tryExpr, PersistentVector catchExprs, Expr finallyExpr,\n        int retLocal, int finallyLocal) {\n      this.tryExpr = tryExpr;\n      this.catchExprs = catchExprs;\n      this.finallyExpr = finallyExpr;\n      this.retLocal = retLocal;\n      this.finallyLocal = finallyLocal;\n    }\n\n    public Object eval() {\n      throw new UnsupportedOperationException(\"Can't eval try\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      Label startTry = gen.newLabel();\n      Label endTry = gen.newLabel();\n      Label end = gen.newLabel();\n      Label ret = gen.newLabel();\n      Label finallyLabel = gen.newLabel();\n      for (int i = 0; i < catchExprs.count(); i++) {\n        CatchClause clause = (CatchClause) catchExprs.nth(i);\n        clause.label = gen.newLabel();\n        clause.endLabel = gen.newLabel();\n      }\n\n      String r = null;\n      if (context == C.EXPRESSION) {\n        r = registerTemp();\n        emitSource(\"Object \" + r + \" = null;\");\n      }\n\n      gen.mark(startTry);\n      emitSource(\"try {\");\n      tab();\n      if (catchExprs.count() > 0 && finallyExpr != null) {\n        emitSource(\"try {\");\n        tab();\n      }\n      String e = tryExpr.emit(context, objx, gen);\n      if (e != null) {\n        emitAssigRet(context, r, e);\n      }\n      if (context != C.STATEMENT)\n        gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), retLocal);\n      gen.mark(endTry);\n\n      if (catchExprs.count() == 0) {\n        untab();\n        emitSource(\"} finally {\");\n        tab();\n      }\n\n      if (finallyExpr != null) {\n        if (catchExprs.count() > 0) {\n          untab();\n          emitSource(\"} finally {\");\n          tab();\n        }\n        String f = finallyExpr.emit(C.STATEMENT, objx, gen);\n        if (f != null) {\n          emitAssigRet(context, r, f);\n        }\n        if (catchExprs.count() > 0) {\n          untab();\n          emitSource(\"}\");\n        }\n      }\n      untab();\n      emitSource(\"}\");\n      gen.goTo(ret);\n\n      if (catchExprs.count() > 0) {\n        emitSource(\"catch (Throwable ex___) {\");\n        tab();\n\n        for (int i = 0; i < catchExprs.count(); i++) {\n          CatchClause clause = (CatchClause) catchExprs.nth(i);\n          gen.mark(clause.label);\n          // exception should be on stack\n          // put in clause local\n          String clazz = printClass(clause.c);\n          emitSource((i > 0 ? \"else \" : \"\") + \"if (ex___ instanceof \" + clazz\n              + \") {\");\n          tab();\n          emitSource(clazz + \" \" + clause.lb.print() + \" = (\" + clazz\n              + \") ex___;\");\n          if (finallyExpr != null) {\n            emitSource(\"try {\");\n            tab();\n          }\n          gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), clause.lb.idx);\n          String h = clause.handler.emit(context, objx, gen);\n          if (h != null) {\n            emitAssigRet(context, r, h);\n          }\n          if (context != C.STATEMENT)\n            gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), retLocal);\n          gen.mark(clause.endLabel);\n\n          if (finallyExpr != null) {\n            untab();\n            emitSource(\"} finally {\");\n            tab();\n            emitSource(finallyExpr.emit(C.STATEMENT, objx, gen));\n            untab();\n            emitSource(\"}\");\n          }\n\n          untab();\n          emitSource(\"}\");\n          gen.goTo(ret);\n        }\n        emitSource(\"else {\");\n        tab();\n        emitSource(\"throw Util.sneakyThrow(ex___);\");\n        untab();\n        emitSource(\"}\");\n        untab();\n        emitSource(\"}\");\n      }\n\n      if (finallyExpr != null) {\n        gen.mark(finallyLabel);\n        // exception should be on stack\n        gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), finallyLocal);\n        Var.pushThreadBindings(RT.map(STOP_EMIT_SOURCE, true));\n        finallyExpr.emit(C.STATEMENT, objx, gen);\n        Var.popThreadBindings();\n        gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ILOAD), finallyLocal);\n        gen.throwException();\n      }\n      gen.mark(ret);\n      if (context != C.STATEMENT)\n        gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ILOAD), retLocal);\n      gen.mark(end);\n      for (int i = 0; i < catchExprs.count(); i++) {\n        CatchClause clause = (CatchClause) catchExprs.nth(i);\n        gen.visitTryCatchBlock(startTry, endTry, clause.label, clause.c\n            .getName().replace('.', '/'));\n      }\n      if (finallyExpr != null) {\n        gen.visitTryCatchBlock(startTry, endTry, finallyLabel, null);\n        for (int i = 0; i < catchExprs.count(); i++) {\n          CatchClause clause = (CatchClause) catchExprs.nth(i);\n          gen.visitTryCatchBlock(clause.label, clause.endLabel, finallyLabel,\n              null);\n        }\n      }\n      for (int i = 0; i < catchExprs.count(); i++) {\n        CatchClause clause = (CatchClause) catchExprs.nth(i);\n        gen.visitLocalVariable(clause.lb.name, \"Ljava/lang/Object;\", null,\n            clause.label, clause.endLabel, clause.lb.idx);\n      }\n\n      return (context == C.EXPRESSION ? r : \"\");\n    }\n\n    public boolean hasJavaClass() {\n      return tryExpr.hasJavaClass();\n    }\n\n    public Class getJavaClass() {\n      return tryExpr.getJavaClass();\n    }\n\n    static class Parser implements IParser {\n\n      public Expr parse(C context, Object frm) {\n        ISeq form = (ISeq) frm;\n        // if(context == C.EVAL || context == C.EXPRESSION)\n        if (context != C.RETURN)\n          return analyze(context,\n              RT.list(RT.list(FNONCE, PersistentVector.EMPTY, form)));\n\n        // (try try-expr* catch-expr* finally-expr?)\n        // catch-expr: (catch class sym expr*)\n        // finally-expr: (finally expr*)\n\n        PersistentVector body = PersistentVector.EMPTY;\n        PersistentVector catches = PersistentVector.EMPTY;\n        Expr bodyExpr = null;\n        Expr finallyExpr = null;\n        boolean caught = false;\n\n        int retLocal = getAndIncLocalNum();\n        int finallyLocal = getAndIncLocalNum();\n        for (ISeq fs = form.next(); fs != null; fs = fs.next()) {\n          Object f = fs.first();\n          Object op = (f instanceof ISeq) ? ((ISeq) f).first() : null;\n          if (!Util.equals(op, CATCH) && !Util.equals(op, FINALLY)) {\n            if (caught)\n              throw Util\n                  .runtimeException(\"Only catch or finally clause can follow catch in try expression\");\n            body = body.cons(f);\n          } else {\n            if (bodyExpr == null)\n              try {\n                Var.pushThreadBindings(RT.map(NO_RECUR, true));\n                bodyExpr = (new BodyExpr.Parser()).parse(context, RT.seq(body));\n              } finally {\n                Var.popThreadBindings();\n              }\n            if (Util.equals(op, CATCH)) {\n              Class c = HostExpr.maybeClass(RT.second(f), false);\n              if (c == null)\n                throw new IllegalArgumentException(\n                    \"Unable to resolve classname: \" + RT.second(f));\n              if (!(RT.third(f) instanceof Symbol))\n                throw new IllegalArgumentException(\n                    \"Bad binding form, expected symbol, got: \" + RT.third(f));\n              Symbol sym = (Symbol) RT.third(f);\n              if (sym.getNamespace() != null)\n                throw Util.runtimeException(\"Can't bind qualified name:\" + sym);\n\n              IPersistentMap dynamicBindings = RT.map(LOCAL_ENV,\n                  LOCAL_ENV.deref(), // NEXT_LOCAL_NUM, NEXT_LOCAL_NUM.deref(),\n                  IN_CATCH_FINALLY, RT.T);\n              try {\n                Var.pushThreadBindings(dynamicBindings);\n                LocalBinding lb = registerLocal(sym,\n                    (Symbol) (RT.second(f) instanceof Symbol ? RT.second(f)\n                        : null), null, false);\n                Expr handler = (new BodyExpr.Parser()).parse(C.EXPRESSION,\n                    RT.next(RT.next(RT.next(f))));\n                catches = catches.cons(new CatchClause(c, lb, handler));\n              } finally {\n                Var.popThreadBindings();\n              }\n              caught = true;\n            } else // finally\n            {\n              if (fs.next() != null)\n                throw Util\n                    .runtimeException(\"finally clause must be last in try expression\");\n              try {\n                Var.pushThreadBindings(RT.map(IN_CATCH_FINALLY, RT.T));\n                finallyExpr = (new BodyExpr.Parser()).parse(C.STATEMENT,\n                    RT.next(f));\n              } finally {\n                Var.popThreadBindings();\n              }\n            }\n          }\n        }\n        if (bodyExpr == null) {\n          try {\n            Var.pushThreadBindings(RT.map(NO_RECUR, true));\n            bodyExpr = (new BodyExpr.Parser())\n                .parse(C.EXPRESSION, RT.seq(body));\n          } finally {\n            Var.popThreadBindings();\n          }\n        }\n\n        return new TryExpr(bodyExpr, catches, finallyExpr, retLocal,\n            finallyLocal);\n      }\n    }\n  }\n\n  // static class TryFinallyExpr implements Expr{\n  // final Expr tryExpr;\n  // final Expr finallyExpr;\n  //\n  //\n  // public TryFinallyExpr(Expr tryExpr, Expr finallyExpr){\n  // this.tryExpr = tryExpr;\n  // this.finallyExpr = finallyExpr;\n  // }\n  //\n  // public Object eval() {\n  // throw new UnsupportedOperationException(\"Can't eval try\");\n  // }\n  //\n  // public void emit(C context, FnExpr fn, GeneratorAdapter gen){\n  // Label startTry = gen.newLabel();\n  // Label endTry = gen.newLabel();\n  // Label end = gen.newLabel();\n  // Label finallyLabel = gen.newLabel();\n  // gen.visitTryCatchBlock(startTry, endTry, finallyLabel, null);\n  // gen.mark(startTry);\n  // tryExpr.emit(context, fn, gen);\n  // gen.mark(endTry);\n  // finallyExpr.emit(C.STATEMENT, fn, gen);\n  // gen.goTo(end);\n  // gen.mark(finallyLabel);\n  // //exception should be on stack\n  // finallyExpr.emit(C.STATEMENT, fn, gen);\n  // gen.throwException();\n  // gen.mark(end);\n  // }\n  //\n  // public boolean hasJavaClass() {\n  // return tryExpr.hasJavaClass();\n  // }\n  //\n  // public Class getJavaClass() {\n  // return tryExpr.getJavaClass();\n  // }\n  //\n  // static class Parser implements IParser{\n  // public Expr parse(C context, Object frm) {\n  // ISeq form = (ISeq) frm;\n  // //(try-finally try-expr finally-expr)\n  // if(form.count() != 3)\n  // throw new IllegalArgumentException(\n  // \"Wrong number of arguments, expecting: (try-finally try-expr finally-expr) \");\n  //\n  // if(context == C.EVAL || context == C.EXPRESSION)\n  // return analyze(context, RT.list(RT.list(FN, PersistentVector.EMPTY,\n  // form)));\n  //\n  // return new TryFinallyExpr(analyze(context, RT.second(form)),\n  // analyze(C.STATEMENT, RT.third(form)));\n  // }\n  // }\n  // }\n\n  static class ThrowExpr extends UntypedExpr {\n    public final Expr excExpr;\n\n    public ThrowExpr(Expr excExpr) {\n      this.excExpr = excExpr;\n    }\n\n    public Object eval() {\n      throw Util.runtimeException(\"Can't eval throw\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String val = excExpr.emit(C.EXPRESSION, objx, gen);\n      gen.checkCast(THROWABLE_TYPE);\n      gen.throwException();\n      emitSource(\"Util.trow((Throwable)\" + val + \");\");\n      return wrap(context, \"null\");\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object form) {\n        if (context == C.EVAL)\n          return analyze(context,\n              RT.list(RT.list(FNONCE, PersistentVector.EMPTY, form)));\n        return new ThrowExpr(analyze(C.EXPRESSION, RT.second(form)));\n      }\n    }\n  }\n\n  static public boolean subsumes(Class[] c1, Class[] c2) {\n    // presumes matching lengths\n    Boolean better = false;\n    for (int i = 0; i < c1.length; i++) {\n      if (c1[i] != c2[i])// || c2[i].isPrimitive() && c1[i] == Object.class))\n      {\n        if (!c1[i].isPrimitive() && c2[i].isPrimitive()\n        // || Number.class.isAssignableFrom(c1[i]) && c2[i].isPrimitive()\n            || c2[i].isAssignableFrom(c1[i]))\n          better = true;\n        else\n          return false;\n      }\n    }\n    return better;\n  }\n\n  static int getMatchingParams(String methodName,\n      ArrayList<Class[]> paramlists, IPersistentVector argexprs,\n      List<Class> rets) {\n    // presumes matching lengths\n    int matchIdx = -1;\n    boolean tied = false;\n    boolean foundExact = false;\n    for (int i = 0; i < paramlists.size(); i++) {\n      boolean match = true;\n      ISeq aseq = argexprs.seq();\n      int exact = 0;\n      for (int p = 0; match && p < argexprs.count() && aseq != null; ++p, aseq = aseq\n          .next()) {\n        Expr arg = (Expr) aseq.first();\n        Class aclass = arg.hasJavaClass() ? arg.getJavaClass() : Object.class;\n        Class pclass = paramlists.get(i)[p];\n        if (arg.hasJavaClass() && aclass == pclass)\n          exact++;\n        else\n          match = Reflector.paramArgTypeMatch(pclass, aclass);\n      }\n      if (exact == argexprs.count()) {\n        if (!foundExact || matchIdx == -1\n            || rets.get(matchIdx).isAssignableFrom(rets.get(i)))\n          matchIdx = i;\n        tied = false;\n        foundExact = true;\n      } else if (match && !foundExact) {\n        if (matchIdx == -1)\n          matchIdx = i;\n        else {\n          if (subsumes(paramlists.get(i), paramlists.get(matchIdx))) {\n            matchIdx = i;\n            tied = false;\n          } else if (Arrays.equals(paramlists.get(matchIdx), paramlists.get(i))) {\n            if (rets.get(matchIdx).isAssignableFrom(rets.get(i)))\n              matchIdx = i;\n          } else if (!(subsumes(paramlists.get(matchIdx), paramlists.get(i))))\n            tied = true;\n        }\n      }\n    }\n    if (tied)\n      throw new IllegalArgumentException(\n          \"More than one matching method found: \" + methodName);\n\n    return matchIdx;\n  }\n\n  public static class NewExpr implements Expr {\n    public final IPersistentVector args;\n    public final Constructor ctor;\n    public final Class c;\n    final static Method invokeConstructorMethod = Method\n        .getMethod(\"Object invokeConstructor(Class,Object[])\");\n    final static Method forNameMethod = Method\n        .getMethod(\"Class classForName(String)\");\n\n    public NewExpr(Class c, IPersistentVector args, int line, int column) {\n      this.args = args;\n      this.c = c;\n      Constructor[] allctors = c.getConstructors();\n      ArrayList ctors = new ArrayList();\n      ArrayList<Class[]> params = new ArrayList();\n      ArrayList<Class> rets = new ArrayList();\n      for (int i = 0; i < allctors.length; i++) {\n        Constructor ctor = allctors[i];\n        if (ctor.getParameterTypes().length == args.count()) {\n          ctors.add(ctor);\n          params.add(ctor.getParameterTypes());\n          rets.add(c);\n        }\n      }\n      if (ctors.isEmpty())\n        throw new IllegalArgumentException(\"No matching ctor found for \" + c);\n\n      int ctoridx = 0;\n      if (ctors.size() > 1) {\n        ctoridx = getMatchingParams(c.getName(), params, args, rets);\n      }\n\n      this.ctor = ctoridx >= 0 ? (Constructor) ctors.get(ctoridx) : null;\n      if (this.ctor != null) {\n        ObjMethod objm = (ObjMethod) METHOD.get();\n        if (objm != null && !objm.hasException) {\n          for (Class ex : this.ctor.getExceptionTypes()) {\n            if (!RuntimeException.class.isAssignableFrom(ex)) {\n              objm.hasException = true;\n              break;\n            }\n          }\n        }\n      }\n\n      if (ctor == null && RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) {\n        RT.errPrintWriter()\n            .format(\n                \"Reflection warning, %s:%d:%d - call to %s ctor can't be resolved.\\n\",\n                SOURCE_PATH.deref(), line, column, c.getName());\n      }\n    }\n\n    public Object eval() {\n      Object[] argvals = new Object[args.count()];\n      for (int i = 0; i < args.count(); i++)\n        argvals[i] = ((Expr) args.nth(i)).eval();\n      if (this.ctor != null) {\n        try {\n          return ctor.newInstance(Reflector.boxArgs(ctor.getParameterTypes(),\n              argvals));\n        } catch (Exception e) {\n          throw Util.sneakyThrow(e);\n        }\n      }\n      return Reflector.invokeConstructor(c, argvals);\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String val;\n      String canonicalName = printClass(c);\n      if (this.ctor != null) {\n        Type type = getType(c);\n        gen.newInstance(type);\n        gen.dup();\n        String argsList = MethodExpr.combineArgs(MethodExpr.emitTypedArgs(objx,\n            gen, ctor.getParameterTypes(), args));\n        if (context == C.RETURN) {\n          ObjMethod method = (ObjMethod) METHOD.deref();\n          method.emitClearLocals(gen);\n        }\n        gen.invokeConstructor(type,\n            new Method(\"<init>\", Type.getConstructorDescriptor(ctor)));\n        val = \"new \" + canonicalName + \"(\" + argsList + \")\";\n      } else {\n        gen.push(destubClassName(c.getName()));\n        gen.invokeStatic(RT_TYPE, forNameMethod);\n        String argsList = MethodExpr.emitArgsAsArray(args, objx, gen);\n        if (context == C.RETURN) {\n          ObjMethod method = (ObjMethod) METHOD.deref();\n          method.emitClearLocals(gen);\n        }\n        gen.invokeStatic(REFLECTOR_TYPE, invokeConstructorMethod);\n        val = \"Reflector.invokeConstructor(\" + canonicalName\n            + \".class, new Object[]{\" + argsList + \"})\";\n      }\n      if (context == C.STATEMENT)\n        gen.pop();\n\n      return wrap(context, val);\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return c;\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object frm) {\n        int line = lineDeref();\n        int column = columnDeref();\n        ISeq form = (ISeq) frm;\n        // (new Classname args...)\n        if (form.count() < 2)\n          throw Util\n              .runtimeException(\"wrong number of arguments, expecting: (new Classname args...)\");\n        Class c = HostExpr.maybeClass(RT.second(form), false);\n        if (c == null)\n          throw new IllegalArgumentException(\"Unable to resolve classname: \"\n              + RT.second(form));\n        PersistentVector args = PersistentVector.EMPTY;\n        for (ISeq s = RT.next(RT.next(form)); s != null; s = s.next())\n          args = args.cons(analyze(context == C.EVAL ? context : C.EXPRESSION,\n              s.first()));\n        return new NewExpr(c, args, line, column);\n      }\n    }\n\n  }\n\n  public static class MetaExpr implements Expr {\n    public final Expr expr;\n    public final Expr meta;\n    final static Type IOBJ_TYPE = Type.getType(IObj.class);\n    final static Method withMetaMethod = Method\n        .getMethod(\"clojure.lang.IObj withMeta(clojure.lang.IPersistentMap)\");\n\n    public MetaExpr(Expr expr, Expr meta) {\n      this.expr = expr;\n      this.meta = meta;\n    }\n\n    public Object eval() {\n      return ((IObj) expr.eval()).withMeta((IPersistentMap) meta.eval());\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String val = expr.emit(C.EXPRESSION, objx, gen);\n      gen.checkCast(IOBJ_TYPE);\n      String m = meta.emit(C.EXPRESSION, objx, gen);\n      gen.checkCast(IPERSISTENTMAP_TYPE);\n      gen.invokeInterface(IOBJ_TYPE, withMetaMethod);\n      if (context == C.STATEMENT) {\n        gen.pop();\n        return \"\";\n      }\n      return wrap(context, \"((IObj)\" + val + \").withMeta(\" + m + \")\");\n    }\n\n    public boolean hasJavaClass() {\n      return expr.hasJavaClass();\n    }\n\n    public Class getJavaClass() {\n      return expr.getJavaClass();\n    }\n  }\n\n  public static class IfExpr implements Expr, MaybePrimitiveExpr {\n    public final Expr testExpr;\n    public final Expr thenExpr;\n    public final Expr elseExpr;\n    public final int line;\n    public final int column;\n\n    public IfExpr(int line, int column, Expr testExpr, Expr thenExpr,\n        Expr elseExpr) {\n      this.testExpr = testExpr;\n      this.thenExpr = thenExpr;\n      this.elseExpr = elseExpr;\n      this.line = line;\n      this.column = column;\n    }\n\n    public Object eval() {\n      Object t = testExpr.eval();\n      if (t != null && t != Boolean.FALSE)\n        return thenExpr.eval();\n      return elseExpr.eval();\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      return doEmit(context, objx, gen, false);\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      return doEmit(context, objx, gen, true);\n    }\n\n    public String doEmit(C context, ObjExpr objx, GeneratorAdapter gen,\n        boolean emitUnboxed) {\n      if (testExpr instanceof NilExpr) {\n        return elseExpr.emit(context, objx, gen);\n      }\n\n      Label nullLabel = gen.newLabel();\n      Label falseLabel = gen.newLabel();\n      Label endLabel = gen.newLabel();\n\n      gen.visitLineNumber(line, gen.mark());\n\n      StringBuilder sb = new StringBuilder();\n      String ret = registerTemp();\n\n      if (C.EXPRESSION == context) {\n        emitSource(\"Object \" + ret + \";\");\n      }\n\n      sb.append(\"if (\");\n      if (testExpr instanceof StaticMethodExpr\n          && ((StaticMethodExpr) testExpr).canEmitIntrinsicPredicate()) {\n        sb.append(((StaticMethodExpr) testExpr).emitIntrinsicPredicate(\n            C.EXPRESSION, objx, gen, falseLabel));\n      } else if (maybePrimitiveType(testExpr) == boolean.class) {\n        sb.append(((MaybePrimitiveExpr) testExpr).emitUnboxed(C.EXPRESSION,\n            objx, gen));\n        gen.ifZCmp(GeneratorAdapter.EQ, falseLabel);\n      } else {\n        String val = testExpr.emit(C.EXPRESSION, objx, gen);\n        gen.dup();\n        gen.ifNull(nullLabel);\n        gen.getStatic(BOOLEAN_OBJECT_TYPE, \"FALSE\", BOOLEAN_OBJECT_TYPE);\n        gen.visitJumpInsn(IF_ACMPEQ, falseLabel);\n        String temp = registerTemp();\n        emitSource(\"Object \" + temp + \" = \" + val + \";\");\n        sb.append(temp + \" != null && \" + temp + \" != Boolean.FALSE\");\n      }\n      sb.append(\") {\");\n      emitSource(sb.toString());\n      tab();\n      String e;\n      if (emitUnboxed) {\n        e = ((MaybePrimitiveExpr) thenExpr).emitUnboxed(context, objx, gen);\n      } else {\n        e = thenExpr.emit(context, objx, gen);\n      }\n      if (e != null) {\n        emitAssigRet(context, ret, e);\n      }\n      untab();\n      emitSource(\"} else {\");\n      tab();\n      gen.goTo(endLabel);\n      gen.mark(nullLabel);\n      gen.pop();\n      gen.mark(falseLabel);\n\n      if (emitUnboxed) {\n        e = ((MaybePrimitiveExpr) elseExpr).emitUnboxed(context, objx, gen);\n      } else {\n        e = elseExpr.emit(context, objx, gen);\n      }\n      if (e != null) {\n        emitAssigRet(context, ret, e);\n      }\n      untab();\n      emitSource(\"}\");\n      gen.mark(endLabel);\n\n      Class cast;\n      try {\n        Class thenClass = thenExpr.getJavaClass();\n        Class elseClass = elseExpr.getJavaClass();\n        cast = thenClass.isPrimitive() && thenClass == elseClass ? thenClass\n            : null;\n      } catch (Exception e2) {\n        cast = null;\n      }\n\n      return C.EXPRESSION == context ? (cast != null ? \"(\"\n          + printClass(asBoxClass(cast)) + \")\" : \"\")\n          + ret : \"\";\n    }\n\n    private Class asBoxClass(Class cast) {\n      switch (Type.getType(cast).getSort()) {\n      case Type.CHAR:\n        return Character.class;\n      case Type.BOOLEAN:\n        return Boolean.class;\n      case Type.DOUBLE:\n        return Double.class;\n      case Type.FLOAT:\n        return Float.class;\n      case Type.LONG:\n        return Long.class;\n      case Type.INT:\n        return Integer.class;\n      case Type.SHORT:\n        return Short.class;\n      case Type.BYTE:\n        return Byte.class;\n      default:\n        return cast;\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return thenExpr.hasJavaClass()\n          && elseExpr.hasJavaClass()\n          && (thenExpr.getJavaClass() == elseExpr.getJavaClass()\n              || thenExpr.getJavaClass() == RECUR_CLASS\n              || elseExpr.getJavaClass() == RECUR_CLASS\n              || (thenExpr.getJavaClass() == null && !elseExpr.getJavaClass()\n                  .isPrimitive()) || (elseExpr.getJavaClass() == null && !thenExpr\n              .getJavaClass().isPrimitive()));\n    }\n\n    public boolean canEmitPrimitive() {\n      try {\n        return thenExpr instanceof MaybePrimitiveExpr\n            && elseExpr instanceof MaybePrimitiveExpr\n            && (thenExpr.getJavaClass() == elseExpr.getJavaClass()\n                || thenExpr.getJavaClass() == RECUR_CLASS || elseExpr\n                .getJavaClass() == RECUR_CLASS)\n            && ((MaybePrimitiveExpr) thenExpr).canEmitPrimitive()\n            && ((MaybePrimitiveExpr) elseExpr).canEmitPrimitive();\n      } catch (Exception e) {\n        return false;\n      }\n    }\n\n    public Class getJavaClass() {\n      Class thenClass = thenExpr.getJavaClass();\n      if (thenClass != null && thenClass != RECUR_CLASS)\n        return thenClass;\n      return elseExpr.getJavaClass();\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object frm) {\n        ISeq form = (ISeq) frm;\n        // (if test then) or (if test then else)\n        if (form.count() > 4)\n          throw Util.runtimeException(\"Too many arguments to if\");\n        else if (form.count() < 3)\n          throw Util.runtimeException(\"Too few arguments to if\");\n        PathNode branch = new PathNode(PATHTYPE.BRANCH,\n            (PathNode) CLEAR_PATH.get());\n        Expr testexpr = analyze(context == C.EVAL ? context : C.EXPRESSION,\n            RT.second(form));\n        Expr thenexpr, elseexpr;\n        try {\n          Var.pushThreadBindings(RT.map(CLEAR_PATH, new PathNode(PATHTYPE.PATH,\n              branch)));\n          thenexpr = analyze(context, RT.third(form));\n        } finally {\n          Var.popThreadBindings();\n        }\n        try {\n          Var.pushThreadBindings(RT.map(CLEAR_PATH, new PathNode(PATHTYPE.PATH,\n              branch)));\n          elseexpr = analyze(context, RT.fourth(form));\n        } finally {\n          Var.popThreadBindings();\n        }\n        return new IfExpr(lineDeref(), columnDeref(), testexpr, thenexpr,\n            elseexpr);\n      }\n    }\n  }\n\n  static {\n    // DEMUNGE_MAP maps strings to characters in the opposite\n    // direction that CHAR_MAP does, plus it maps DOLLAR to '/'\n    IPersistentMap m = RT.map(DOLLAR, '/');\n    for (ISeq s = RT.seq(CHAR_MAP); s != null; s = s.next()) {\n      IMapEntry e = (IMapEntry) s.first();\n      Character origCh = (Character) e.key();\n      String escapeStr = (String) e.val();\n      m = m.assoc(escapeStr, origCh);\n    }\n    DEMUNGE_MAP = m;\n\n    // DEMUNGE_PATTERN searches for the first of any occurrence of\n    // the strings that are keys of DEMUNGE_MAP.\n    // Note: Regex matching rules mean that #\"_|_COLON_\" \"_COLON_\"\n    // returns \"_\", but #\"_COLON_|_\" \"_COLON_\" returns \"_COLON_\"\n    // as desired. Sorting string keys of DEMUNGE_MAP from longest to\n    // shortest ensures correct matching behavior, even if some strings are\n    // prefixes of others.\n    Object[] mungeStrs = RT.toArray(RT.keys(m));\n    Arrays.sort(mungeStrs, new Comparator() {\n      public int compare(Object s1, Object s2) {\n        return ((String) s2).length() - ((String) s1).length();\n      }\n    });\n    StringBuilder sb = new StringBuilder();\n    boolean first = true;\n    for (Object s : mungeStrs) {\n      String escapeStr = (String) s;\n      if (!first)\n        sb.append(\"|\");\n      first = false;\n      sb.append(\"\\\\Q\");\n      sb.append(escapeStr);\n      sb.append(\"\\\\E\");\n    }\n    DEMUNGE_PATTERN = Pattern.compile(sb.toString());\n  }\n\n  static public String munge(String name) {\n    StringBuilder sb = new StringBuilder();\n    for (char c : name.toCharArray()) {\n      String sub = (String) CHAR_MAP.valAt(c);\n      if (sub != null)\n        sb.append(sub);\n      else\n        sb.append(c);\n    }\n    return sb.toString();\n  }\n\n  static public String demunge(String mungedName) {\n    StringBuilder sb = new StringBuilder();\n    Matcher m = DEMUNGE_PATTERN.matcher(mungedName);\n    int lastMatchEnd = 0;\n    while (m.find()) {\n      int start = m.start();\n      int end = m.end();\n      // Keep everything before the match\n      sb.append(mungedName.substring(lastMatchEnd, start));\n      lastMatchEnd = end;\n      // Replace the match with DEMUNGE_MAP result\n      Character origCh = (Character) DEMUNGE_MAP.valAt(m.group());\n      sb.append(origCh);\n    }\n    // Keep everything after the last match\n    sb.append(mungedName.substring(lastMatchEnd));\n    return sb.toString();\n  }\n  \n  static String getTypeStringForArgs(IPersistentVector args) {\n    StringBuilder sb = new StringBuilder();\n    for (int i = 0; i < args.count(); i++) {\n      Expr arg = (Expr) args.nth(i);\n      if (i > 0)\n        sb.append(\", \");\n      sb.append((arg.hasJavaClass() && arg.getJavaClass() != null) ? arg.getJavaClass().getName() : \"unknown\");\n    }\n    return sb.toString();\n  }\n\n  public static class EmptyExpr implements Expr {\n    public final Object coll;\n    final static Type HASHMAP_TYPE = Type.getType(PersistentArrayMap.class);\n    final static Type HASHSET_TYPE = Type.getType(PersistentHashSet.class);\n    final static Type VECTOR_TYPE = Type.getType(PersistentVector.class);\n    final static Type LIST_TYPE = Type.getType(PersistentList.class);\n    final static Type EMPTY_LIST_TYPE = Type\n        .getType(PersistentList.EmptyList.class);\n\n    public EmptyExpr(Object coll) {\n      this.coll = coll;\n    }\n\n    public Object eval() {\n      return coll;\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String ret;\n      if (coll instanceof IPersistentList) {\n        gen.getStatic(LIST_TYPE, \"EMPTY\", EMPTY_LIST_TYPE);\n        ret = LIST_TYPE.getClassName() + \".EMPTY\";\n      } else if (coll instanceof IPersistentVector) {\n        gen.getStatic(VECTOR_TYPE, \"EMPTY\", VECTOR_TYPE);\n        ret = VECTOR_TYPE.getClassName() + \".EMPTY\";\n      } else if (coll instanceof IPersistentMap) {\n        gen.getStatic(HASHMAP_TYPE, \"EMPTY\", HASHMAP_TYPE);\n        ret = HASHMAP_TYPE.getClassName() + \".EMPTY\";\n      } else if (coll instanceof IPersistentSet) {\n        gen.getStatic(HASHSET_TYPE, \"EMPTY\", HASHSET_TYPE);\n        ret = HASHSET_TYPE.getClassName() + \".EMPTY\";\n      } else {\n        throw new UnsupportedOperationException(\"Unknown Collection type\");\n      }\n      if (context == C.STATEMENT) {\n        gen.pop();\n        return \"\";\n      } else {\n        return wrap(context, ret);\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      if (coll instanceof IPersistentList)\n        return IPersistentList.class;\n      else if (coll instanceof IPersistentVector)\n        return IPersistentVector.class;\n      else if (coll instanceof IPersistentMap)\n        return IPersistentMap.class;\n      else if (coll instanceof IPersistentSet)\n        return IPersistentSet.class;\n      else\n        throw new UnsupportedOperationException(\"Unknown Collection type\");\n    }\n  }\n\n  public static class ListExpr implements Expr {\n    public final IPersistentVector args;\n    final static Method arrayToListMethod = Method\n        .getMethod(\"clojure.lang.ISeq arrayToList(Object[])\");\n\n    public ListExpr(IPersistentVector args) {\n      this.args = args;\n    }\n\n    public Object eval() {\n      IPersistentVector ret = PersistentVector.EMPTY;\n      for (int i = 0; i < args.count(); i++)\n        ret = (IPersistentVector) ret.cons(((Expr) args.nth(i)).eval());\n      return ret.seq();\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String argsList = MethodExpr.emitArgsAsArray(args, objx, gen);\n      gen.invokeStatic(RT_TYPE, arrayToListMethod);\n      if (context == C.STATEMENT)\n        gen.pop();\n      return wrap(context, \"RT.arrayToList(\" + argsList + \")\");\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return IPersistentList.class;\n    }\n\n  }\n\n  public static class MapExpr implements Expr {\n    public final IPersistentVector keyvals;\n    final static Method mapMethod = Method\n        .getMethod(\"clojure.lang.IPersistentMap map(Object[])\");\n    final static Method mapUniqueKeysMethod = Method\n        .getMethod(\"clojure.lang.IPersistentMap mapUniqueKeys(Object[])\");\n\n    public MapExpr(IPersistentVector keyvals) {\n      this.keyvals = keyvals;\n    }\n\n    public Object eval() {\n      Object[] ret = new Object[keyvals.count()];\n      for (int i = 0; i < keyvals.count(); i++)\n        ret[i] = ((Expr) keyvals.nth(i)).eval();\n      return RT.map(ret);\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      boolean allKeysConstant = true;\n      boolean allConstantKeysUnique = true;\n      IPersistentSet constantKeys = PersistentHashSet.EMPTY;\n      for (int i = 0; i < keyvals.count(); i += 2) {\n        Expr k = (Expr) keyvals.nth(i);\n        if (k instanceof LiteralExpr) {\n          Object kval = k.eval();\n          if (constantKeys.contains(kval))\n            allConstantKeysUnique = false;\n          else\n            constantKeys = (IPersistentSet) constantKeys.cons(kval);\n        } else\n          allKeysConstant = false;\n      }\n      String val = MethodExpr.emitArgsAsArray(keyvals, objx, gen);\n      if ((allKeysConstant && allConstantKeysUnique) || (keyvals.count() <= 2)) {\n        gen.invokeStatic(RT_TYPE, mapUniqueKeysMethod);\n        val = \"RT.mapUniqueKeys(\" + val + \")\";\n      } else {\n        gen.invokeStatic(RT_TYPE, mapMethod);\n        val = \"RT.map(\" + val + \")\";\n      }\n\n      if (context == C.STATEMENT) {\n        gen.pop();\n        return \"\";\n      } else {\n        return wrap(context, val);\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return IPersistentMap.class;\n    }\n\n    static public Expr parse(C context, IPersistentMap form) {\n      IPersistentVector keyvals = PersistentVector.EMPTY;\n      boolean keysConstant = true;\n      boolean valsConstant = true;\n      boolean allConstantKeysUnique = true;\n      IPersistentSet constantKeys = PersistentHashSet.EMPTY;\n      for (ISeq s = RT.seq(form); s != null; s = s.next()) {\n        IMapEntry e = (IMapEntry) s.first();\n        Expr k = analyze(context == C.EVAL ? context : C.EXPRESSION, e.key());\n        Expr v = analyze(context == C.EVAL ? context : C.EXPRESSION, e.val());\n        keyvals = (IPersistentVector) keyvals.cons(k);\n        keyvals = (IPersistentVector) keyvals.cons(v);\n        if (k instanceof LiteralExpr) {\n          Object kval = k.eval();\n          if (constantKeys.contains(kval))\n            allConstantKeysUnique = false;\n          else\n            constantKeys = (IPersistentSet) constantKeys.cons(kval);\n        } else\n          keysConstant = false;\n        if (!(v instanceof LiteralExpr))\n          valsConstant = false;\n      }\n\n      Expr ret = new MapExpr(keyvals);\n      if (form instanceof IObj && ((IObj) form).meta() != null)\n        return new MetaExpr(ret, MapExpr.parse(context == C.EVAL ? context\n            : C.EXPRESSION, ((IObj) form).meta()));\n      else if (keysConstant) {\n        // TBD: Add more detail to exception thrown below.\n        if (!allConstantKeysUnique)\n          throw new IllegalArgumentException(\"Duplicate constant keys in map\");\n        if (valsConstant) {\n          IPersistentMap m = PersistentArrayMap.EMPTY;\n          for (int i = 0; i < keyvals.length(); i += 2) {\n            m = m.assoc(((LiteralExpr) keyvals.nth(i)).val(),\n                ((LiteralExpr) keyvals.nth(i + 1)).val());\n          }\n          // System.err.println(\"Constant: \" + m);\n          return new ConstantExpr(m);\n        } else\n          return ret;\n      } else\n        return ret;\n    }\n  }\n\n  public static class SetExpr implements Expr {\n    public final IPersistentVector keys;\n    final static Method setMethod = Method\n        .getMethod(\"clojure.lang.IPersistentSet set(Object[])\");\n\n    public SetExpr(IPersistentVector keys) {\n      this.keys = keys;\n    }\n\n    public Object eval() {\n      Object[] ret = new Object[keys.count()];\n      for (int i = 0; i < keys.count(); i++)\n        ret[i] = ((Expr) keys.nth(i)).eval();\n      return RT.set(ret);\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String argsList = MethodExpr.emitArgsAsArray(keys, objx, gen);\n      gen.invokeStatic(RT_TYPE, setMethod);\n      if (context == C.STATEMENT)\n        gen.pop();\n\n      return wrap(context, \"RT.set(\" + argsList + \")\");\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return IPersistentSet.class;\n    }\n\n    static public Expr parse(C context, IPersistentSet form) {\n      IPersistentVector keys = PersistentVector.EMPTY;\n      boolean constant = true;\n\n      for (ISeq s = RT.seq(form); s != null; s = s.next()) {\n        Object e = s.first();\n        Expr expr = analyze(context == C.EVAL ? context : C.EXPRESSION, e);\n        keys = (IPersistentVector) keys.cons(expr);\n        if (!(expr instanceof LiteralExpr))\n          constant = false;\n      }\n      Expr ret = new SetExpr(keys);\n      if (form instanceof IObj && ((IObj) form).meta() != null)\n        return new MetaExpr(ret, MapExpr.parse(context == C.EVAL ? context\n            : C.EXPRESSION, ((IObj) form).meta()));\n      else if (constant) {\n        IPersistentSet set = PersistentHashSet.EMPTY;\n        for (int i = 0; i < keys.count(); i++) {\n          LiteralExpr ve = (LiteralExpr) keys.nth(i);\n          set = (IPersistentSet) set.cons(ve.val());\n        }\n        // System.err.println(\"Constant: \" + set);\n        return new ConstantExpr(set);\n      } else\n        return ret;\n    }\n  }\n\n  public static class VectorExpr implements Expr {\n    public final IPersistentVector args;\n    final static Method vectorMethod = Method\n        .getMethod(\"clojure.lang.IPersistentVector vector(Object[])\");\n\n    public VectorExpr(IPersistentVector args) {\n      this.args = args;\n    }\n\n    public Object eval() {\n      IPersistentVector ret = PersistentVector.EMPTY;\n      for (int i = 0; i < args.count(); i++)\n        ret = (IPersistentVector) ret.cons(((Expr) args.nth(i)).eval());\n      return ret;\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String val = MethodExpr.emitArgsAsArray(args, objx, gen);\n      gen.invokeStatic(RT_TYPE, vectorMethod);\n      if (context == C.STATEMENT)\n        gen.pop();\n      if (val.equals(\"null\")) {\n        return wrap(context, \"RT.vector().cons(null)\");\n      } else {\n        return wrap(context, \"RT.vector(\" + val + \")\");\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return IPersistentVector.class;\n    }\n\n    static public Expr parse(C context, IPersistentVector form) {\n      boolean constant = true;\n\n      IPersistentVector args = PersistentVector.EMPTY;\n      for (int i = 0; i < form.count(); i++) {\n        Expr v = analyze(context == C.EVAL ? context : C.EXPRESSION,\n            form.nth(i));\n        args = (IPersistentVector) args.cons(v);\n        if (!(v instanceof LiteralExpr))\n          constant = false;\n      }\n      Expr ret = new VectorExpr(args);\n      if (form instanceof IObj && ((IObj) form).meta() != null)\n        return new MetaExpr(ret, MapExpr.parse(context == C.EVAL ? context\n            : C.EXPRESSION, ((IObj) form).meta()));\n      else if (constant) {\n        PersistentVector rv = PersistentVector.EMPTY;\n        for (int i = 0; i < args.count(); i++) {\n          LiteralExpr ve = (LiteralExpr) args.nth(i);\n          rv = rv.cons(ve.val());\n        }\n        // System.err.println(\"Constant: \" + rv);\n        return new ConstantExpr(rv);\n      } else\n        return ret;\n    }\n\n  }\n\n  static class KeywordInvokeExpr implements Expr {\n    public final KeywordExpr kw;\n    public final Object tag;\n    public final Expr target;\n    public final int line;\n    public final int column;\n    public final int siteIndex;\n    public final String source;\n    static Type ILOOKUP_TYPE = Type.getType(ILookup.class);\n\n    public KeywordInvokeExpr(String source, int line, int column, Symbol tag,\n        KeywordExpr kw, Expr target) {\n      this.source = source;\n      this.kw = kw;\n      this.target = target;\n      this.line = line;\n      this.column = column;\n      this.tag = tag;\n      this.siteIndex = registerKeywordCallsite(kw.k);\n    }\n\n    public Object eval() {\n      try {\n        return kw.k.invoke(target.eval());\n      } catch (Throwable e) {\n        if (!(e instanceof CompilerException))\n          throw new CompilerException(source, line, column, e);\n        else\n          throw (CompilerException) e;\n      }\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      Label endLabel = gen.newLabel();\n      Label faultLabel = gen.newLabel();\n\n      gen.visitLineNumber(line, gen.mark());\n      gen.getStatic(objx.objtype, objx.thunkNameStatic(siteIndex),\n          ObjExpr.ILOOKUP_THUNK_TYPE);\n      gen.dup(); // thunk, thunk\n      // String val = registerTemp();\n      String tar = target.emit(C.EXPRESSION, objx, gen);\n      gen.visitLineNumber(line, gen.mark());\n      // emitSource(\"Object \" + val + \" = \" + tar + \";\"); // thunk,thunk,target\n      gen.dupX2(); // target,thunk,thunk,target\n      gen.invokeInterface(ObjExpr.ILOOKUP_THUNK_TYPE,\n          Method.getMethod(\"Object get(Object)\")); // target,thunk,result\n      gen.dupX2(); // result,target,thunk,result\n      gen.visitJumpInsn(IF_ACMPEQ, faultLabel); // result,target\n      gen.pop(); // result\n      gen.goTo(endLabel);\n\n      // emitSource(\"if (\" + objx.thunkNameStatic(siteIndex) + \" == \" +\n      // objx.thunkNameStatic(siteIndex) + \".get(\" + val + \")) {\");\n      // tab();\n\n      gen.mark(faultLabel); // result,target\n      gen.swap(); // target,result\n      gen.pop(); // target\n      gen.dup(); // target,target\n      gen.getStatic(objx.objtype, objx.siteNameStatic(siteIndex),\n          ObjExpr.KEYWORD_LOOKUPSITE_TYPE); // target,target,site\n      gen.swap(); // target,site,target\n      gen.invokeInterface(ObjExpr.ILOOKUP_SITE_TYPE,\n          Method.getMethod(\"clojure.lang.ILookupThunk fault(Object)\")); // target,new-thunk\n      gen.dup(); // target,new-thunk,new-thunk\n      gen.putStatic(objx.objtype, objx.thunkNameStatic(siteIndex),\n          ObjExpr.ILOOKUP_THUNK_TYPE); // target,new-thunk\n\n      // emitSource(objx.thunkNameStatic(siteIndex) + \" = \" +\n      // objx.siteNameStatic(siteIndex) + \".fault(\" + val + \");\");\n\n      gen.swap(); // new-thunk,target\n      gen.invokeInterface(ObjExpr.ILOOKUP_THUNK_TYPE,\n          Method.getMethod(\"Object get(Object)\")); // result\n      // String rval = objx.thunkNameStatic(siteIndex) + \".get(\" + val + \")\";\n      // if (C.EXPRESSION != context) {\n      // emitSource(ret(context) + rval + statement(context));\n      // }\n      gen.mark(endLabel);\n      if (context == C.STATEMENT)\n        gen.pop();\n\n      // untab();\n      // emitSource(\"}\");\n      // return context == C.EXPRESSION ? rval : \"\";\n\n      return wrap(\n          context,\n          \"RT.get(\"\n              + tar\n              + \", Keyword.intern(\"\n              + (kw.k.getNamespace() == null ? \"null\" : (\"\\\"\"\n                  + kw.k.getNamespace() + \"\\\"\")) + \", \\\"\" + kw.k.getName()\n              + \"\\\"))\");\n    }\n\n    public boolean hasJavaClass() {\n      return tag != null;\n    }\n\n    public Class getJavaClass() {\n      return HostExpr.tagToClass(tag);\n    }\n\n  }\n\n  // static class KeywordSiteInvokeExpr implements Expr{\n  // public final Expr site;\n  // public final Object tag;\n  // public final Expr target;\n  // public final int line;\n  // public final int column;\n  // public final String source;\n  //\n  // public KeywordSiteInvokeExpr(String source, int line, int column, Symbol\n  // tag, Expr site, Expr target){\n  // this.source = source;\n  // this.site = site;\n  // this.target = target;\n  // this.line = line;\n  // this.column = column;\n  // this.tag = tag;\n  // }\n  //\n  // public Object eval() {\n  // try\n  // {\n  // KeywordCallSite s = (KeywordCallSite) site.eval();\n  // return s.thunk.invoke(s,target.eval());\n  // }\n  // catch(Throwable e)\n  // {\n  // if(!(e instanceof CompilerException))\n  // throw new CompilerException(source, line, column, e);\n  // else\n  // throw (CompilerException) e;\n  // }\n  // }\n  //\n  // public void emit(C context, ObjExpr objx, GeneratorAdapter gen){\n  // gen.visitLineNumber(line, gen.mark());\n  // site.emit(C.EXPRESSION, objx, gen);\n  // gen.dup();\n  // gen.getField(Type.getType(KeywordCallSite.class),\"thunk\",IFN_TYPE);\n  // gen.swap();\n  // target.emit(C.EXPRESSION, objx, gen);\n  //\n  // gen.invokeInterface(IFN_TYPE, new Method(\"invoke\", OBJECT_TYPE,\n  // ARG_TYPES[2]));\n  // if(context == C.STATEMENT)\n  // gen.pop();\n  // }\n  //\n  // public boolean hasJavaClass() {\n  // return tag != null;\n  // }\n  //\n  // public Class getJavaClass() {\n  // return HostExpr.tagToClass(tag);\n  // }\n  //\n  // }\n\n  public static class InstanceOfExpr implements Expr, MaybePrimitiveExpr {\n    Expr expr;\n    Class c;\n\n    public InstanceOfExpr(Class c, Expr expr) {\n      this.expr = expr;\n      this.c = c;\n    }\n\n    public Object eval() {\n      if (c.isInstance(expr.eval()))\n        return RT.T;\n      return RT.F;\n    }\n\n    public boolean canEmitPrimitive() {\n      return true;\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String val = expr.emit(C.EXPRESSION, objx, gen);\n      gen.instanceOf(getType(c));\n      return \"(\" + val + \" instanceof \" + printClass(c) + \")\";\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String val = emitUnboxed(context, objx, gen);\n      val = HostExpr.emitBoxReturn(objx, gen, Boolean.TYPE, val);\n      if (context == C.STATEMENT)\n        gen.pop();\n      return wrap(context, val);\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return Boolean.TYPE;\n    }\n\n  }\n\n  static class StaticInvokeExpr implements Expr, MaybePrimitiveExpr {\n    public final Type target;\n    public final Class retClass;\n    public final Class[] paramclasses;\n    public final Type[] paramtypes;\n    public final IPersistentVector args;\n    public final boolean variadic;\n    public final Symbol tag;\n\n    StaticInvokeExpr(Type target, Class retClass, Class[] paramclasses,\n        Type[] paramtypes, boolean variadic, IPersistentVector args, Symbol tag) {\n      this.target = target;\n      this.retClass = retClass;\n      this.paramclasses = paramclasses;\n      this.paramtypes = paramtypes;\n      this.args = args;\n      this.variadic = variadic;\n      this.tag = tag;\n    }\n\n    public Object eval() {\n      throw new UnsupportedOperationException(\"Can't eval StaticInvokeExpr\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String val = emitUnboxed(context, objx, gen);\n      if (context != C.STATEMENT)\n        val = HostExpr.emitBoxReturn(objx, gen, retClass, val);\n      if (context == C.STATEMENT) {\n        if (retClass == long.class || retClass == double.class)\n          gen.pop2();\n        else\n          gen.pop();\n      }\n      return wrap(context, val);\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return tag != null ? HostExpr.tagToClass(tag) : retClass;\n    }\n\n    public boolean canEmitPrimitive() {\n      return retClass.isPrimitive();\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      Method ms = new Method(\"invokeStatic\", getReturnType(), paramtypes);\n      if (variadic) {\n        for (int i = 0; i < paramclasses.length - 1; i++) {\n          Expr e = (Expr) args.nth(i);\n          if (maybePrimitiveType(e) == paramclasses[i]) {\n            // if (maybePrimitiveType(e) == paramclasses[i]) {\n            // ((MaybePrimitiveExpr) e).emitUnboxed(C.EXPRESSION, objx, gen);\n            // } else {\n            // String v = e.emit(C.EXPRESSION, objx, gen);\n            // v = HostExpr.emitUnboxArg(objx, gen, paramclasses[i], v);\n            // }\n            // } catch (Exception ex) {\n            // throw Util.sneakyThrow(ex);\n            // }\n          } else {\n            HostExpr.emitUnboxArg(objx, gen, paramclasses[i],\n                e.emit(C.EXPRESSION, objx, gen));\n          }\n        }\n        IPersistentVector restArgs = RT.subvec(args, paramclasses.length - 1,\n            args.count());\n        MethodExpr.emitArgsAsArray(restArgs, objx, gen);\n        gen.invokeStatic(Type.getType(ArraySeq.class),\n            Method.getMethod(\"clojure.lang.ArraySeq create(Object[])\"));\n      } else {\n        MethodExpr.emitTypedArgs(objx, gen, paramclasses, args);\n      }\n\n      gen.invokeStatic(target, ms);\n      throw new RuntimeException(\"NOT IMPLEMENTED; TODO FIX\");\n    }\n\n    private Type getReturnType() {\n      return Type.getType(retClass);\n    }\n\n    public static Expr parse(Var v, ISeq args, Symbol tag) {\n      IPersistentCollection paramlists = (IPersistentCollection) RT.get(\n          v.meta(), arglistsKey);\n      if (paramlists == null)\n        throw new IllegalStateException(\n            \"Can't call static fn with no arglists: \" + v);\n      IPersistentVector paramlist = null;\n      int argcount = RT.count(args);\n      boolean variadic = false;\n      for (ISeq aseq = RT.seq(paramlists); aseq != null; aseq = aseq.next()) {\n        if (!(aseq.first() instanceof IPersistentVector))\n          throw new IllegalStateException(\"Expected vector arglist, had: \"\n              + aseq.first());\n        IPersistentVector alist = (IPersistentVector) aseq.first();\n        if (alist.count() > 1 && alist.nth(alist.count() - 2).equals(_AMP_)) {\n          if (argcount >= alist.count() - 2) {\n            paramlist = alist;\n            variadic = true;\n          }\n        } else if (alist.count() == argcount) {\n          paramlist = alist;\n          variadic = false;\n          break;\n        }\n      }\n\n      if (paramlist == null)\n        throw new IllegalArgumentException(\"Invalid arity - can't call: \" + v\n            + \" with \" + argcount + \" args\");\n\n      Class retClass = tagClass(tagOf(paramlist));\n\n      ArrayList<Class> paramClasses = new ArrayList();\n      ArrayList<Type> paramTypes = new ArrayList();\n\n      if (variadic) {\n        for (int i = 0; i < paramlist.count() - 2; i++) {\n          Class pc = tagClass(tagOf(paramlist.nth(i)));\n          paramClasses.add(pc);\n          paramTypes.add(Type.getType(pc));\n        }\n        paramClasses.add(ISeq.class);\n        paramTypes.add(Type.getType(ISeq.class));\n      } else {\n        for (int i = 0; i < argcount; i++) {\n          Class pc = tagClass(tagOf(paramlist.nth(i)));\n          paramClasses.add(pc);\n          paramTypes.add(Type.getType(pc));\n        }\n      }\n\n      String cname = v.ns.name.name.replace('.', '/').replace('-', '_')\n          + DOLLAR + munge(v.sym.name);\n      Type target = Type.getObjectType(cname);\n\n      PersistentVector argv = PersistentVector.EMPTY;\n      for (ISeq s = RT.seq(args); s != null; s = s.next())\n        argv = argv.cons(analyze(C.EXPRESSION, s.first()));\n\n      return new StaticInvokeExpr(target, retClass,\n          paramClasses.toArray(new Class[paramClasses.size()]),\n          paramTypes.toArray(new Type[paramTypes.size()]), variadic, argv, tag);\n    }\n  }\n\n  static class InvokeExpr implements Expr {\n    public final Expr fexpr;\n    public final Object tag;\n    public final IPersistentVector args;\n    public final int line;\n    public final int column;\n    public final String source;\n    public boolean isProtocol = false;\n    public boolean isDirect = false;\n    public int siteIndex = -1;\n    public Class protocolOn;\n    public java.lang.reflect.Method onMethod;\n    static Keyword onKey = Keyword.intern(\"on\");\n    static Keyword methodMapKey = Keyword.intern(\"method-map\");\n\n    public InvokeExpr(String source, int line, int column, Symbol tag,\n        Expr fexpr, IPersistentVector args) {\n      this.source = source;\n      this.fexpr = fexpr;\n      this.args = args;\n      this.line = line;\n      this.column = column;\n      if (fexpr instanceof VarExpr) {\n        Var fvar = ((VarExpr) fexpr).var;\n        Var pvar = (Var) RT.get(fvar.meta(), protocolKey);\n        if (pvar != null && PROTOCOL_CALLSITES.isBound()) {\n          this.isProtocol = true;\n          this.siteIndex = registerProtocolCallsite(((VarExpr) fexpr).var);\n          Object pon = RT.get(pvar.get(), onKey);\n          this.protocolOn = HostExpr.maybeClass(pon, false);\n          if (this.protocolOn != null) {\n            IPersistentMap mmap = (IPersistentMap) RT.get(pvar.get(),\n                methodMapKey);\n            Keyword mmapVal = (Keyword) mmap.valAt(Keyword.intern(fvar.sym));\n            if (mmapVal == null) {\n              throw new IllegalArgumentException(\n                  \"No method of interface: \"\n                      + protocolOn.getName()\n                      + \" found for function: \"\n                      + fvar.sym\n                      + \" of protocol: \"\n                      + pvar.sym\n                      + \" (The protocol method may have been defined before and removed.)\");\n            }\n            String mname = munge(mmapVal.sym.toString());\n            List methods = Reflector.getMethods(protocolOn, args.count() - 1,\n                mname, false);\n            if (methods.size() != 1)\n              throw new IllegalArgumentException(\"No single method: \" + mname\n                  + \" of interface: \" + protocolOn.getName()\n                  + \" found for function: \" + fvar.sym + \" of protocol: \"\n                  + pvar.sym);\n            this.onMethod = (java.lang.reflect.Method) methods.get(0);\n          }\n        }\n      }\n\n      if (tag != null) {\n        this.tag = tag;\n      } else if (fexpr instanceof VarExpr) {\n        Object arglists = RT.get(RT.meta(((VarExpr) fexpr).var), arglistsKey);\n        Object sigTag = null;\n        for (ISeq s = RT.seq(arglists); s != null; s = s.next()) {\n          APersistentVector sig = (APersistentVector) s.first();\n          int restOffset = sig.indexOf(_AMP_);\n          if (args.count() == sig.count()\n              || (restOffset > -1 && args.count() >= restOffset)) {\n            sigTag = tagOf(sig);\n            break;\n          }\n        }\n\n        this.tag = sigTag == null ? ((VarExpr) fexpr).tag : sigTag;\n      } else {\n        this.tag = null;\n      }\n    }\n\n    public Object eval() {\n      try {\n        IFn fn = (IFn) fexpr.eval();\n        PersistentVector argvs = PersistentVector.EMPTY;\n        for (int i = 0; i < args.count(); i++)\n          argvs = argvs.cons(((Expr) args.nth(i)).eval());\n        return fn.applyTo(RT.seq(Util.ret1(argvs, argvs = null)));\n      } catch (Throwable e) {\n        if (!(e instanceof CompilerException))\n          throw new CompilerException(source, line, column, e);\n        else\n          throw (CompilerException) e;\n      }\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      String ret;\n      if (isProtocol) {\n        gen.visitLineNumber(line, gen.mark());\n        ret = emitProto(context, objx, gen);\n      } else {\n        String val = fexpr.emit(C.EXPRESSION, objx, gen);\n        gen.visitLineNumber(line, gen.mark());\n        gen.checkCast(IFN_TYPE);\n        ret = wrap(\n            context,\n            \"((IFn)\" + val + \").invoke(\"\n                + emitArgsAndCall(0, context, objx, gen) + \")\");\n      }\n      if (context == C.STATEMENT)\n        gen.pop();\n      return ret;\n    }\n\n    public String emitProto(C context, ObjExpr objx, GeneratorAdapter gen) {\n      Label onLabel = gen.newLabel();\n      Label callLabel = gen.newLabel();\n      Label endLabel = gen.newLabel();\n\n      Var v = ((VarExpr) fexpr).var;\n\n      Expr e = (Expr) args.nth(0);\n      String eetemp = registerTemp();\n      emitSource(\"Object \" + eetemp + \" = \" + e.emit(C.EXPRESSION, objx, gen)\n          + \";\");\n      String ee = eetemp;\n\n      gen.dup(); // target, target\n      gen.invokeStatic(UTIL_TYPE, Method.getMethod(\"Class classOf(Object)\")); // target,class\n      gen.getStatic(objx.objtype, objx.cachedClassName(siteIndex), CLASS_TYPE); // target,class,cached-class\n      gen.visitJumpInsn(IF_ACMPEQ, callLabel); // target\n\n      // emitSource(\"if (Util.classOf(\" + ee + \") != this.\" +\n      // objx.cachedClassName(siteIndex) + \") {\");\n      // tab();\n      if (protocolOn != null) {\n        gen.dup(); // target, target\n        gen.instanceOf(Type.getType(protocolOn));\n        gen.ifZCmp(GeneratorAdapter.NE, onLabel);\n\n        emitSource(\"if (!(\" + ee + \" instanceof \" + printClass(protocolOn)\n            + \")) {\");\n        tab();\n      }\n\n      gen.dup(); // target, target\n      gen.invokeStatic(UTIL_TYPE, Method.getMethod(\"Class classOf(Object)\")); // target,class\n      gen.putStatic(objx.objtype, objx.cachedClassName(siteIndex), CLASS_TYPE); // target\n\n      // emitSource(\"this.\" + objx.cachedClassName(siteIndex) +\n      // \" = Util.classOf(\" + ee + \");\");\n\n      gen.mark(callLabel); // target\n      String vare = objx.emitVar(gen, v);\n      gen.invokeVirtual(VAR_TYPE, Method.getMethod(\"Object getRawRoot()\")); // target,\n                                                                            // proto-fn\n      gen.swap();\n      String argse = emitArgsAndCall(1, context, objx, gen);\n      gen.goTo(endLabel);\n\n      String body = \"((IFn)\" + vare + \".getRawRoot()).invoke(\" + ee\n          + (argse.length() > 0 ? \", \" + argse : \"\") + \")\";\n      body = wrap(context, body);\n      if (context == C.EXPRESSION) {\n        emitAssigRet(context, eetemp, body);\n      } else {\n        emitSource(body);\n      }\n\n      untab();\n      emitSource(\"} else {\");\n      tab();\n\n      gen.mark(onLabel); // target\n      if (protocolOn != null) {\n        String argList = MethodExpr\n            .combineArgs(MethodExpr.emitTypedArgs(objx, gen,\n                onMethod.getParameterTypes(), RT.subvec(args, 1, args.count())));\n\n        if (context == C.RETURN) {\n          ObjMethod method = (ObjMethod) METHOD.deref();\n          method.emitClearLocals(gen);\n        }\n        Method m = new Method(onMethod.getName(), Type.getReturnType(onMethod),\n            Type.getArgumentTypes(onMethod));\n        gen.invokeInterface(Type.getType(protocolOn), m);\n        String b = \"((\" + printClass(protocolOn) + \") \" + ee + \").\"\n            + onMethod.getName() + \"(\" + argList + \")\";\n        String boxed = HostExpr.emitBoxReturn(objx, gen,\n            onMethod.getReturnType(), b);\n        if (context == C.EXPRESSION) {\n          emitAssigRet(context, eetemp, wrap(context, boxed));\n        } else {\n          emitSource(wrap(context, b));\n        }\n        untab();\n        emitSource(\"}\");\n      }\n\n      // untab();\n      // emitSource(\"}\");\n      gen.mark(endLabel);\n      return context != C.EXPRESSION ? \"\" : eetemp;\n    }\n\n    String emitArgsAndCall(int firstArgToEmit, C context, ObjExpr objx,\n        GeneratorAdapter gen) {\n      StringBuilder sb = new StringBuilder();\n      for (int i = firstArgToEmit; i < Math.min(MAX_POSITIONAL_ARITY,\n          args.count()); i++) {\n        if (sb.length() > 0) {\n          sb.append(\", \");\n        }\n        Expr e = (Expr) args.nth(i);\n        sb.append(e.emit(C.EXPRESSION, objx, gen));\n      }\n      if (args.count() > MAX_POSITIONAL_ARITY) {\n        PersistentVector restArgs = PersistentVector.EMPTY;\n        for (int i = MAX_POSITIONAL_ARITY; i < args.count(); i++) {\n          restArgs = restArgs.cons(args.nth(i));\n        }\n        sb.append(\", \" + MethodExpr.emitArgsAsArray(restArgs, objx, gen));\n      }\n      gen.visitLineNumber(line, gen.mark());\n      if (context == C.RETURN) {\n        ObjMethod method = (ObjMethod) METHOD.deref();\n        method.emitClearLocals(gen);\n      }\n\n      gen.invokeInterface(IFN_TYPE, new Method(\"invoke\", OBJECT_TYPE,\n          ARG_TYPES[Math.min(MAX_POSITIONAL_ARITY + 1, args.count())]));\n      return sb.toString();\n    }\n\n    public boolean hasJavaClass() {\n      return tag != null;\n    }\n\n    public Class getJavaClass() {\n      return HostExpr.tagToClass(tag);\n    }\n\n    static public Expr parse(C context, ISeq form) {\n      if (context != C.EVAL)\n        context = C.EXPRESSION;\n      Expr fexpr = analyze(context, form.first());\n      if (fexpr instanceof VarExpr && ((VarExpr) fexpr).var.equals(INSTANCE)\n          && RT.count(form) == 3) {\n        Expr sexpr = analyze(C.EXPRESSION, RT.second(form));\n        if (sexpr instanceof ConstantExpr) {\n          Object val = ((ConstantExpr) sexpr).val();\n          if (val instanceof Class) {\n            return new InstanceOfExpr((Class) val, analyze(context,\n                RT.third(form)));\n          }\n        }\n      }\n\n      // if(fexpr instanceof VarExpr && context != C.EVAL)\n      // {\n      // Var v = ((VarExpr)fexpr).var;\n      // if(RT.booleanCast(RT.get(RT.meta(v),staticKey)))\n      // {\n      // return StaticInvokeExpr.parse(v, RT.next(form), tagOf(form));\n      // }\n      // }\n\n      if (fexpr instanceof VarExpr && context != C.EVAL) {\n        Var v = ((VarExpr) fexpr).var;\n        Object arglists = RT.get(RT.meta(v), arglistsKey);\n        int arity = RT.count(form.next());\n        for (ISeq s = RT.seq(arglists); s != null; s = s.next()) {\n          IPersistentVector args = (IPersistentVector) s.first();\n          if (args.count() == arity) {\n            String primc = FnMethod.primInterface(args);\n            if (primc != null) {\n              return analyze(context, RT.listStar(\n                  Symbol.intern(\".invokePrim\"),\n                  ((Symbol) form.first()).withMeta(RT.map(RT.TAG_KEY,\n                      Symbol.intern(primc))), form.next()));\n            }\n            break;\n          }\n        }\n      }\n\n      if (fexpr instanceof KeywordExpr && RT.count(form) == 2\n          && KEYWORD_CALLSITES.isBound()) {\n        // fexpr = new ConstantExpr(new\n        // KeywordCallSite(((KeywordExpr)fexpr).k));\n        Expr target = analyze(context, RT.second(form));\n        return new KeywordInvokeExpr((String) SOURCE.deref(), lineDeref(),\n            columnDeref(), tagOf(form), (KeywordExpr) fexpr, target);\n      }\n      PersistentVector args = PersistentVector.EMPTY;\n      for (ISeq s = RT.seq(form.next()); s != null; s = s.next()) {\n        args = args.cons(analyze(context, s.first()));\n      }\n      // if(args.count() > MAX_POSITIONAL_ARITY)\n      // throw new IllegalArgumentException(\n      // String.format(\"No more than %d args supported\", MAX_POSITIONAL_ARITY));\n\n      return new InvokeExpr((String) SOURCE.deref(), lineDeref(),\n          columnDeref(), tagOf(form), fexpr, args);\n    }\n  }\n\n  static class SourceDebugExtensionAttribute extends Attribute {\n    public SourceDebugExtensionAttribute() {\n      super(\"SourceDebugExtension\");\n    }\n\n    void writeSMAP(ClassWriter cw, String smap) {\n      ByteVector bv = write(cw, null, -1, -1, -1);\n      bv.putUTF8(smap);\n    }\n  }\n\n  static public class FnExpr extends ObjExpr {\n    final static Type aFnType = Type.getType(AFunction.class);\n    final static Type restFnType = Type.getType(RestFn.class);\n    // if there is a variadic overload (there can only be one) it is stored here\n    FnMethod variadicMethod = null;\n    IPersistentCollection methods;\n    // private boolean hasPrimSigs;\n    private boolean hasMeta;\n\n    // String superName = null;\n\n    public FnExpr(Object tag) {\n      super(tag);\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    boolean supportsMeta() {\n      return hasMeta;\n    }\n\n    public Class getJavaClass() {\n      return tag != null ? HostExpr.tagToClass(tag) : AFunction.class;\n    }\n\n    protected void emitMethods(ClassVisitor cv) {\n      // override of invoke/doInvoke for each method\n      for (ISeq s = RT.seq(methods); s != null; s = s.next()) {\n        ObjMethod method = (ObjMethod) s.first();\n        method.emit(this, cv);\n      }\n\n      if (isVariadic()) {\n        emitSource(\"public int getRequiredArity() {\");\n        tab();\n        emitSource(\"return \" + variadicMethod.reqParms.count() + \";\");\n        untab();\n        emitSource(\"}\");\n        GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC,\n            Method.getMethod(\"int getRequiredArity()\"), null, null, cv);\n        gen.visitCode();\n        gen.push(variadicMethod.reqParms.count());\n        gen.returnValue();\n        gen.endMethod();\n      }\n    }\n\n    static Expr parse(C context, ISeq form, String name, Object defContext) {\n      ISeq origForm = form;\n      FnExpr fn = new FnExpr(tagOf(form));\n      fn.src = form;\n      ObjMethod enclosingMethod = (ObjMethod) METHOD.deref();\n      if (((IMeta) form.first()).meta() != null) {\n        fn.onceOnly = RT.booleanCast(RT.get(RT.meta(form.first()),\n            Keyword.intern(null, \"once\")));\n        // fn.superName = (String) RT.get(RT.meta(form.first()),\n        // Keyword.intern(null, \"super-name\"));\n      }\n      // fn.thisName = name;\n      // TODO http://dev.clojure.org/jira/browse/CLJ-1330\n      String basename = enclosingMethod != null ? (enclosingMethod.objx.name + DOLLAR)\n          : // \"clojure.fns.\" +\n          (munge(currentNS().name.name) + DOLLAR);\n      if (RT.second(form) instanceof Symbol)\n        name = ((Symbol) RT.second(form)).name;\n      String simpleName = name != null ? (munge(name).replace(\".\", \"_DOT_\") + (enclosingMethod != null ? \"__\"\n          + nextScopedID()\n          : \"\"))\n          : (\"fn\" + \"__\" + nextScopedID());\n      \n      /*Fix CLJ-1330\n         String basename = (enclosingMethod != null ?\n          enclosingMethod.objx.name\n          : (munge(currentNS().name.name))) + \"$\";\n          \n      Symbol nm = null;\n          \n      if(RT.second(form) instanceof Symbol) {\n        nm = (Symbol) RT.second(form);\n        name = nm.name + \"__\" + RT.nextID();\n      } else {\n        if(name == null)\n          name = \"fn__\" + RT.nextID();\n        else if (enclosingMethod != null)\n          name += \"__\" + RT.nextID();\n      }\n      \n      String simpleName = munge(name).replace(\".\", \"_DOT_\");\n      \n  -     if(RT.second(form) instanceof Symbol)\n  +     if(nm != null)\n        {\n  -       Symbol nm = (Symbol) RT.second(form);\n      */\n      fn.name = basename + simpleName;\n      fn.internalName = fn.name.replace('.', '/');\n      fn.objtype = Type.getObjectType(fn.internalName);\n      ArrayList<String> prims = new ArrayList();\n      try {\n        Var.pushThreadBindings(RT.mapUniqueKeys(CONSTANTS,\n            PersistentVector.EMPTY, CONSTANT_IDS, new IdentityHashMap(),\n            KEYWORDS, PersistentHashMap.EMPTY, VARS, PersistentHashMap.EMPTY,\n            KEYWORD_CALLSITES, PersistentVector.EMPTY, PROTOCOL_CALLSITES,\n            PersistentVector.EMPTY, VAR_CALLSITES, emptyVarCallSites(),\n            NO_RECUR, null, Compiler.NEXT_ID, new Atom(1)));\n\n        // arglist might be preceded by symbol naming this fn\n        if (RT.second(form) instanceof Symbol) {\n          Symbol nm = (Symbol) RT.second(form);\n          fn.thisName = nm.name;\n          fn.isStatic = false; // RT.booleanCast(RT.get(nm.meta(), staticKey));\n          form = RT.cons(FN, RT.next(RT.next(form)));\n        }\n\n        // now (fn [args] body...) or (fn ([args] body...) ([args2] body2...)\n        // ...)\n        // turn former into latter\n        if (RT.second(form) instanceof IPersistentVector)\n          form = RT.list(FN, RT.next(form));\n        fn.line = lineDeref();\n        fn.column = columnDeref();\n        FnMethod[] methodArray = new FnMethod[MAX_POSITIONAL_ARITY + 1];\n        FnMethod variadicMethod = null;\n        for (ISeq s = RT.next(form); s != null; s = RT.next(s)) {\n          FnMethod f = FnMethod.parse(fn, (ISeq) RT.first(s), fn.isStatic);\n          if (f.isVariadic()) {\n            if (variadicMethod == null)\n              variadicMethod = f;\n            else\n              throw Util\n                  .runtimeException(\"Can't have more than 1 variadic overload\");\n          } else if (methodArray[f.reqParms.count()] == null)\n            methodArray[f.reqParms.count()] = f;\n          else\n            throw Util\n                .runtimeException(\"Can't have 2 overloads with same arity\");\n          if (f.prim != null)\n            prims.add(f.prim);\n        }\n        if (variadicMethod != null) {\n          for (int i = variadicMethod.reqParms.count() + 1; i <= MAX_POSITIONAL_ARITY; i++)\n            if (methodArray[i] != null)\n              throw Util\n                  .runtimeException(\"Can't have fixed arity function with more params than variadic function\");\n        }\n\n        if (fn.isStatic && fn.closes.count() > 0)\n          throw new IllegalArgumentException(\"static fns can't be closures\");\n        IPersistentCollection methods = null;\n        for (int i = 0; i < methodArray.length; i++)\n          if (methodArray[i] != null)\n            methods = RT.conj(methods, methodArray[i]);\n        if (variadicMethod != null)\n          methods = RT.conj(methods, variadicMethod);\n\n        maybeSelfContain(context, fn, defContext);\n\n        fn.methods = methods;\n        fn.variadicMethod = variadicMethod;\n        fn.keywords = (IPersistentMap) KEYWORDS.deref();\n        fn.vars = (IPersistentMap) VARS.deref();\n        fn.constants = (PersistentVector) CONSTANTS.deref();\n        fn.keywordCallsites = (IPersistentVector) KEYWORD_CALLSITES.deref();\n        fn.protocolCallsites = (IPersistentVector) PROTOCOL_CALLSITES.deref();\n        fn.varCallsites = (IPersistentSet) VAR_CALLSITES.deref();\n\n        fn.constantsID = RT.nextID();\n        // DynamicClassLoader loader = (DynamicClassLoader) LOADER.get();\n        // loader.registerConstants(fn.constantsID, fn.constants.toArray());\n      } finally {\n        Var.popThreadBindings();\n      }\n      // fn.hasPrimSigs = prims.size() > 0;\n      IPersistentMap fmeta = RT.meta(origForm);\n      if (fmeta != null)\n        fmeta = fmeta.without(RT.LINE_KEY).without(RT.COLUMN_KEY)\n            .without(RT.FILE_KEY);\n\n      fn.hasMeta = RT.count(fmeta) > 0;\n\n      try {\n        fn.compile(\n            fn.isVariadic() ? \"clojure/lang/RestFn\" : \"clojure/lang/AFunction\",\n            (prims.size() == 0) ? null\n                : prims.toArray(new String[prims.size()]), fn.onceOnly);\n      } catch (IOException e) {\n        throw Util.sneakyThrow(e);\n      }\n      fn.getCompiledClass();\n\n      if (fn.supportsMeta()) {\n        // System.err.println(name + \" supports meta\");\n        return new MetaExpr(fn, MapExpr.parse(context == C.EVAL ? context\n            : C.EXPRESSION, fmeta));\n      } else\n        return fn;\n    }\n\n    private static void maybeSelfContain(C context, ObjExpr fn,\n        Object defContext) {\n      if (defContext != null) {\n        PersistentVector v = (PersistentVector) defContext;\n        fn.var = (Var) v.get(0);\n        IPersistentMap mm = (IPersistentMap) v.get(1);\n        fn.meta = mm.count() == 0 ? null : analyze(context == C.EVAL ? context\n            : C.EXPRESSION, mm);\n        fn.isDynamic = (Boolean) v.get(2);\n      }\n    }\n\n    public final ObjMethod variadicMethod() {\n      return variadicMethod;\n    }\n\n    boolean isVariadic() {\n      return variadicMethod != null;\n    }\n\n    public final IPersistentCollection methods() {\n      return methods;\n    }\n\n    public String emitForDefn(ObjExpr objx, GeneratorAdapter gen) {\n      // if(!hasPrimSigs && closes.count() == 0)\n      // {\n      // Type thunkType = Type.getType(FnLoaderThunk.class);\n      // // presumes var on stack\n      // gen.dup();\n      // gen.newInstance(thunkType);\n      // gen.dupX1();\n      // gen.swap();\n      // gen.push(internalName.replace('/','.'));\n      // gen.invokeConstructor(thunkType,Method.getMethod(\"void <init>(clojure.lang.Var,String)\"));\n      // }\n      // else\n      return emit(C.EXPRESSION, objx, gen);\n    }\n  }\n\n  static public class ObjExpr implements Expr {\n    static final String CONST_PREFIX = \"const__\";\n    String name;\n    // String simpleName;\n    String internalName;\n    String thisName;\n    Type objtype;\n    public final Object tag;\n    // localbinding->itself\n    IPersistentMap closes = PersistentHashMap.EMPTY;\n    // localbndingexprs\n    IPersistentVector closesExprs = PersistentVector.EMPTY;\n    // symbols\n    IPersistentSet volatiles = PersistentHashSet.EMPTY;\n\n    // symbol->lb\n    IPersistentMap fields = null;\n\n    // hinted fields\n    IPersistentVector hintedFields = PersistentVector.EMPTY;\n\n    // Keyword->KeywordExpr\n    IPersistentMap keywords = PersistentHashMap.EMPTY;\n    IPersistentMap vars = PersistentHashMap.EMPTY;\n    Class compiledClass;\n    int line;\n    int column;\n    PersistentVector constants;\n    IPersistentSet usedConstants = PersistentTreeSet.EMPTY;\n    int constantsID;\n    int altCtorDrops = 0;\n\n    IPersistentVector keywordCallsites;\n    IPersistentVector protocolCallsites;\n    IPersistentSet varCallsites;\n    boolean onceOnly = false;\n\n    Object src;\n\n    final static Method voidctor = Method.getMethod(\"void <init>()\");\n    protected IPersistentMap classMeta;\n    protected boolean isStatic;\n    protected boolean isDynamic;\n    protected Var var;\n    protected Expr meta;\n\n    public final String name() {\n      return name;\n    }\n\n    // public final String simpleName(){\n    // return simpleName;\n    // }\n\n    public final String internalName() {\n      return internalName;\n    }\n\n    public final String thisName() {\n      return thisName;\n    }\n\n    public final Type objtype() {\n      return objtype;\n    }\n\n    public final IPersistentMap closes() {\n      return closes;\n    }\n\n    public final IPersistentMap keywords() {\n      return keywords;\n    }\n\n    public final IPersistentMap vars() {\n      return vars;\n    }\n\n    public final Class compiledClass() {\n      return compiledClass;\n    }\n\n    public final int line() {\n      return line;\n    }\n\n    public final int column() {\n      return column;\n    }\n\n    public final PersistentVector constants() {\n      return constants;\n    }\n\n    public final int constantsID() {\n      return constantsID;\n    }\n\n    final static Method kwintern = Method\n        .getMethod(\"clojure.lang.Keyword intern(String, String)\");\n    final static Method symintern = Method\n        .getMethod(\"clojure.lang.Symbol intern(String)\");\n    final static Method varintern = Method\n        .getMethod(\"clojure.lang.Var intern(clojure.lang.Symbol, clojure.lang.Symbol)\");\n\n    final static Type DYNAMIC_CLASSLOADER_TYPE = Type\n        .getType(DynamicClassLoader.class);\n    final static Method getClassMethod = Method.getMethod(\"Class getClass()\");\n    final static Method getClassLoaderMethod = Method\n        .getMethod(\"ClassLoader getClassLoader()\");\n    final static Method getConstantsMethod = Method\n        .getMethod(\"Object[] getConstants(int)\");\n    final static Method readStringMethod = Method\n        .getMethod(\"Object readString(String)\");\n\n    final static Type ILOOKUP_SITE_TYPE = Type.getType(ILookupSite.class);\n    final static Type ILOOKUP_THUNK_TYPE = Type.getType(ILookupThunk.class);\n    final static Type KEYWORD_LOOKUPSITE_TYPE = Type\n        .getType(KeywordLookupSite.class);\n\n    private DynamicClassLoader loader;\n    private byte[] bytecode;\n\n    public ObjExpr(Object tag) {\n      this.tag = tag;\n    }\n\n    static String trimGenID(String name) {\n      int i = name.lastIndexOf(\"__\");\n      return i == -1 ? name : name.substring(0, i);\n    }\n\n    Type[] ctorTypes() {\n      IPersistentVector tv = !supportsMeta() ? PersistentVector.EMPTY : RT\n          .vector(IPERSISTENTMAP_TYPE);\n      for (ISeq s = RT.keys(closes); s != null; s = s.next()) {\n        LocalBinding lb = (LocalBinding) s.first();\n        if (lb.getPrimitiveType() != null)\n          tv = tv.cons(Type.getType(lb.getPrimitiveType()));\n        else\n          tv = tv.cons(OBJECT_TYPE);\n      }\n      Type[] ret = new Type[tv.count()];\n      for (int i = 0; i < tv.count(); i++)\n        ret[i] = (Type) tv.nth(i);\n      return ret;\n    }\n\n    void compile(String superName, String[] interfaceNames, boolean oneTimeUse)\n        throws IOException {\n      // create bytecode for a class\n      // with name current_ns.defname[$letname]+\n      // anonymous fns get names fn__id\n      // derived from AFn/RestFn\n      ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);\n      // ClassWriter cw = new ClassWriter(0);\n      ClassVisitor cv = cw;\n      // ClassVisitor cv = new TraceClassVisitor(new CheckClassAdapter(cw), new\n      // PrintWriter(System.out));\n      // ClassVisitor cv = new TraceClassVisitor(cw, new\n      // PrintWriter(System.out));\n      Var.pushThreadBindings(RT.mapUniqueKeys(SOURCE_WRITER, cw.getSc()));\n\n      int lastSlash = internalName.lastIndexOf('/');\n      String className;\n      String packageName;\n      if (lastSlash != -1) {\n        className = internalName.substring(lastSlash + 1);\n        packageName = internalName.substring(0, lastSlash).replaceAll(\"/\", \".\");\n      } else {\n        packageName = \"\";\n        className = internalName;\n      }\n\n      emitSource(\"package \" + packageName + \";\");\n      emitSource();\n      emitSource(\"import clojure.lang.*;\");\n      emitSource();\n      StringBuilder interfaces = new StringBuilder();\n      if (interfaceNames != null) {\n        for (String in : interfaceNames) {\n          if (interfaces.length() > 0) {\n            interfaces.append(\", \");\n          }\n          interfaces.append(in.replaceAll(\"/\", \".\").replaceAll(\"\\\\$\", \".\"));\n        }\n\n      }\n\n      cv.visit(V1_5, ACC_PUBLIC + ACC_SUPER + ACC_FINAL, internalName, null,\n          superName, interfaceNames);\n      // superName != null ? superName :\n      // (isVariadic() ? \"clojure/lang/RestFn\" : \"clojure/lang/AFunction\"),\n      // null);\n      String source = (String) SOURCE.deref();\n      int lineBefore = (Integer) LINE_BEFORE.deref();\n      int lineAfter = (Integer) LINE_AFTER.deref() + 1;\n      int columnBefore = (Integer) COLUMN_BEFORE.deref();\n      int columnAfter = (Integer) COLUMN_AFTER.deref() + 1;\n\n      if (source != null && SOURCE_PATH.deref() != null) {\n        // cv.visitSource(source, null);\n        String smap = \"SMAP\\n\"\n            + ((source.lastIndexOf('.') > 0) ? source.substring(0,\n                source.lastIndexOf('.')) : source)\n            // : simpleName)\n            + \".java\\n\"\n            + \"Clojure\\n\"\n            + \"*S Clojure\\n\"\n            + \"*F\\n\"\n            + \"+ 1 \"\n            + source\n            + \"\\n\"\n            + (String) SOURCE_PATH.deref()\n            + \"\\n\"\n            + \"*L\\n\"\n            + String.format(\"%d#1,%d:%d\\n\", lineBefore, lineAfter - lineBefore,\n                lineBefore) + \"*E\";\n        cv.visitSource(source, smap);\n      }\n      addAnnotation(cv, classMeta);\n\n      emitSource(\"@com.google.j2objc.annotations.ReflectionSupport(com.google.j2objc.annotations.ReflectionSupport.Level.NATIVE_ONLY)\");\n      emitSource(\"public final class \" + className + \" extends \"\n          + superName.replaceAll(\"/\", \".\")\n          + (interfaces.length() > 0 ? \" implements \" : \"\") + interfaces + \" {\");\n      tab();\n\n      // static fields for constants\n      for (int i = 0; i < constants.count(); i++) {\n        emitSource(\"public static final \" + printClass(constantType(i)) + \" \"\n            + constantName(i) + \";\");\n        cv.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, constantName(i),\n            constantType(i).getDescriptor(), null, null);\n      }\n\n      // static fields for lookup sites\n      for (int i = 0; i < keywordCallsites.count(); i++) {\n        // emitSource(\"public static final \" +\n        // KEYWORD_LOOKUPSITE_TYPE.getClassName() + \" \" + siteNameStatic(i) +\n        // \";\");\n        // emitSource(\"public static \" + ILOOKUP_THUNK_TYPE.getClassName() + \" \"\n        // + thunkNameStatic(i) + \";\");\n        cv.visitField(ACC_FINAL + ACC_STATIC, siteNameStatic(i),\n            KEYWORD_LOOKUPSITE_TYPE.getDescriptor(), null, null);\n        cv.visitField(ACC_STATIC, thunkNameStatic(i),\n            ILOOKUP_THUNK_TYPE.getDescriptor(), null, null);\n      }\n\n      // for(int i=0;i<varCallsites.count();i++)\n      // {\n      // cv.visitField(ACC_PRIVATE + ACC_STATIC + ACC_FINAL\n      // , varCallsiteName(i), IFN_TYPE.getDescriptor(), null, null);\n      // }\n\n      if (var != null) {\n        cv.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, \"VAR\",\n            VAR_TYPE.getDescriptor(), null, null);\n        emitSource(\"public static final Var VAR;\");\n      }\n\n      // static init for constants, keywords and vars\n      emitSource(\"static {\");\n      tab();\n      GeneratorAdapter clinitgen = new GeneratorAdapter(\n          ACC_PUBLIC + ACC_STATIC, Method.getMethod(\"void <clinit> ()\"), null,\n          null, cv);\n      clinitgen.visitCode();\n      clinitgen.visitLineNumber(line, clinitgen.mark());\n\n      if (var != null) {\n        clinitgen.push(var.ns.name.name);\n        clinitgen.push(var.sym.name);\n        clinitgen.invokeStatic(RT_TYPE,\n            Method.getMethod(\"clojure.lang.Var var(String,String)\"));\n        clinitgen.putStatic(objtype, \"VAR\", VAR_TYPE);\n        emitSource(\"VAR = RT.var(\\\"\" + var.ns.name.name + \"\\\", \\\"\"\n            + var.sym.name + \"\\\");\");\n      }\n\n      if (constants.count() > 0) {\n        emitConstants(clinitgen);\n      }\n\n      if (keywordCallsites.count() > 0)\n        emitKeywordCallsites(clinitgen);\n\n      /*\n       * for(int i=0;i<varCallsites.count();i++) { Label skipLabel =\n       * clinitgen.newLabel(); Label endLabel = clinitgen.newLabel(); Var var =\n       * (Var) varCallsites.nth(i); clinitgen.push(var.ns.name.toString());\n       * clinitgen.push(var.sym.toString()); clinitgen.invokeStatic(RT_TYPE,\n       * Method.getMethod(\"clojure.lang.Var var(String,String)\"));\n       * clinitgen.dup();\n       * clinitgen.invokeVirtual(VAR_TYPE,Method.getMethod(\"boolean hasRoot()\"\n       * )); clinitgen.ifZCmp(GeneratorAdapter.EQ,skipLabel);\n       * \n       * clinitgen.invokeVirtual(VAR_TYPE,Method.getMethod(\"Object getRoot()\"));\n       * clinitgen.dup(); clinitgen.instanceOf(AFUNCTION_TYPE);\n       * clinitgen.ifZCmp(GeneratorAdapter.EQ,skipLabel);\n       * clinitgen.checkCast(IFN_TYPE); clinitgen.putStatic(objtype,\n       * varCallsiteName(i), IFN_TYPE); clinitgen.goTo(endLabel);\n       * \n       * clinitgen.mark(skipLabel); clinitgen.pop();\n       * \n       * clinitgen.mark(endLabel); }\n       */\n\n      if (var != null) {\n        clinitgen.getStatic(objtype, \"VAR\", VAR_TYPE);\n        if (isDynamic) {\n          emitSource(\"VAR.setDynamic();\");\n          clinitgen.invokeVirtual(VAR_TYPE,\n              Method.getMethod(\"clojure.lang.Var setDynamic()\"));\n        }\n        if (var.isMacro()) {\n          emitSource(\"VAR.setMacro();\");\n          clinitgen.dup();\n          clinitgen\n              .invokeVirtual(VAR_TYPE, Method.getMethod(\"void setMacro()\"));\n        }\n        if (meta != null) {\n          clinitgen.dup();\n          String metastr = meta.emit(C.EXPRESSION, this, clinitgen);\n          clinitgen.checkCast(IPERSISTENTMAP_TYPE);\n          clinitgen.invokeVirtual(VAR_TYPE,\n              Method.getMethod(\"void setMeta(clojure.lang.IPersistentMap)\"));\n          emitSource(\"VAR.setMeta((IPersistentMap)\" + metastr + \");\");\n        }\n\n        String v;\n        if (this instanceof FnExpr) {\n          v = ((FnExpr) this).emitForDefn(this, clinitgen);\n        } else\n          v = emit(C.EXPRESSION, this, clinitgen);\n        clinitgen.invokeVirtual(VAR_TYPE,\n            Method.getMethod(\"void bindRoot(Object)\"));\n        emitSource(\"VAR.bindRoot(\" + v + \");\");\n      }\n\n      clinitgen.returnValue();\n\n      clinitgen.endMethod();\n\n      untab();\n      emitSource(\"}\");\n\n      StringBuilder sb = new StringBuilder();\n      if (supportsMeta()) {\n        emitSource(\"final \" + IPERSISTENTMAP_TYPE.getClassName() + \" __meta;\");\n        cv.visitField(ACC_FINAL, \"__meta\", IPERSISTENTMAP_TYPE.getDescriptor(),\n            null, null);\n        sb.append(\"final \" + IPERSISTENTMAP_TYPE.getClassName() + \" __meta\");\n      }\n      // instance fields for closed-overs\n      for (ISeq s = RT.keys(closes); s != null; s = s.next()) {\n        if (sb.length() > 0) {\n          sb.append(\", \");\n        }\n        LocalBinding lb = (LocalBinding) s.first();\n        if (isDeftype()) {\n          int access = isVolatile(lb) ? ACC_VOLATILE : isMutable(lb) ? 0\n              : (ACC_PUBLIC + ACC_FINAL);\n          FieldVisitor fv;\n          if (lb.getPrimitiveType() != null) {\n            fv = cv\n                .visitField(access, lb.name, Type\n                    .getType(lb.getPrimitiveType()).getDescriptor(), null, null);\n          } else {\n            // todo - when closed-overs are fields, use more specific types here\n            // and in ctor and emitLocal?\n            fv = cv.visitField(access, lb.name, OBJECT_TYPE.getDescriptor(),\n                null, null);\n\n          }\n          String type = (lb.getPrimitiveType() != null ? printClass(lb\n              .getPrimitiveType()) : \"Object\");\n          sb.append(\"final \").append(type).append(\" \").append(lb.print());\n          addAnnotation(fv, RT.meta(lb.sym));\n          emitSource(\"public \" + (isVolatile(lb) ? \"volatile\" : \"\") + \" \"\n              + (isMutable(lb) ? \"\" : \"final\") + \" \" + type + \" \" + lb.print()\n              + \";\");\n        } else {\n          // todo - only enable this non-private+writability for letfns where we\n          // need it\n          if (lb.getPrimitiveType() != null) {\n            cv.visitField(0 + (isVolatile(lb) ? ACC_VOLATILE : 0), lb.name,\n                Type.getType(lb.getPrimitiveType()).getDescriptor(), null, null);\n            emitSource((isVolatile(lb) ? \"volatile \" : \"\")\n                + printClass(lb.getPrimitiveType()) + \" \" + lb.print() + \";\");\n            sb.append(\"final \" + printClass(lb.getPrimitiveType()) + \" \"\n                + lb.print());\n          } else {\n            cv.visitField(0 // + (oneTimeUse ? 0 : ACC_FINAL)\n                , lb.name, OBJECT_TYPE.getDescriptor(), null, null);\n            emitSource(\"Object \" + lb.print() + \";\");\n            sb.append(\"final Object \" + lb.print());\n          }\n        }\n      }\n\n      // static fields for callsites and thunks\n      for (int i = 0; i < protocolCallsites.count(); i++) {\n        cv.visitField(ACC_PRIVATE + ACC_STATIC, cachedClassName(i),\n            CLASS_TYPE.getDescriptor(), null, null);\n        // emitSource(\"private \" + CLASS_TYPE.getClassName() + \" \" +\n        // cachedClassName(i) + \";\");\n      }\n\n      // ctor that takes closed-overs and inits base + fields\n      Method m = new Method(\"<init>\", Type.VOID_TYPE, ctorTypes());\n      emitSource(\"public \" + className + \"(\" + sb.toString() + \") {\");\n      tab();\n      GeneratorAdapter ctorgen = new GeneratorAdapter(ACC_PUBLIC, m, null,\n          null, cv);\n      Label start = ctorgen.newLabel();\n      Label end = ctorgen.newLabel();\n      ctorgen.visitCode();\n      ctorgen.visitLineNumber(line, ctorgen.mark());\n      ctorgen.visitLabel(start);\n      ctorgen.loadThis();\n      // if(superName != null)\n      ctorgen.invokeConstructor(Type.getObjectType(superName), voidctor);\n      emitSource(\"super();\");\n      // else if(isVariadic()) //RestFn ctor takes reqArity arg\n      // {\n      // ctorgen.push(variadicMethod.reqParms.count());\n      // ctorgen.invokeConstructor(restFnType, restfnctor);\n      // }\n      // else\n      // ctorgen.invokeConstructor(aFnType, voidctor);\n\n      // if(vars.count() > 0)\n      // {\n      // ctorgen.loadThis();\n      // ctorgen.getStatic(VAR_TYPE,\"rev\",Type.INT_TYPE);\n      // ctorgen.push(-1);\n      // ctorgen.visitInsn(Opcodes.IADD);\n      // ctorgen.putField(objtype, \"__varrev__\", Type.INT_TYPE);\n      // }\n\n      if (supportsMeta()) {\n        ctorgen.loadThis();\n        ctorgen.visitVarInsn(IPERSISTENTMAP_TYPE.getOpcode(Opcodes.ILOAD), 1);\n        ctorgen.putField(objtype, \"__meta\", IPERSISTENTMAP_TYPE);\n        emitSource(\"this.__meta = __meta;\");\n      }\n\n      int a = supportsMeta() ? 2 : 1;\n      for (ISeq s = RT.keys(closes); s != null; s = s.next(), ++a) {\n        LocalBinding lb = (LocalBinding) s.first();\n        emitSource(\"this.\" + lb.print() + \" = \" + lb.print() + \";\");\n        ctorgen.loadThis();\n        Class primc = lb.getPrimitiveType();\n        if (primc != null) {\n          ctorgen.visitVarInsn(Type.getType(primc).getOpcode(Opcodes.ILOAD), a);\n          ctorgen.putField(objtype, lb.name, Type.getType(primc));\n          if (primc == Long.TYPE || primc == Double.TYPE)\n            ++a;\n        } else {\n          ctorgen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ILOAD), a);\n          ctorgen.putField(objtype, lb.name, OBJECT_TYPE);\n        }\n        closesExprs = closesExprs.cons(new LocalBindingExpr(lb, null));\n      }\n\n      ctorgen.visitLabel(end);\n\n      ctorgen.returnValue();\n\n      ctorgen.endMethod();\n\n      untab();\n      emitSource(\"}\");\n\n      if (altCtorDrops > 0) {\n        // ctor that takes closed-overs and inits base + fields\n        Type[] ctorTypes = ctorTypes();\n        Type[] altCtorTypes = new Type[ctorTypes.length - altCtorDrops];\n        StringBuilder params = new StringBuilder();\n        StringBuilder args = new StringBuilder();\n        for (int i = 0; i < altCtorTypes.length; i++) {\n          if (params.length() > 0) {\n            params.append(\", \");\n            args.append(\", \");\n          }\n          params.append(\"o\" + i);\n          args.append(printClass(ctorTypes[i]) + \" o\" + i);\n          altCtorTypes[i] = ctorTypes[i];\n        }\n        Method alt = new Method(\"<init>\", Type.VOID_TYPE, altCtorTypes);\n        ctorgen = new GeneratorAdapter(ACC_PUBLIC, alt, null, null, cv);\n        ctorgen.visitCode();\n        ctorgen.loadThis();\n        ctorgen.loadArgs();\n        for (int i = 0; i < altCtorDrops; i++) {\n          if (params.length() > 0) {\n            params.append(\", \");\n          }\n          params.append(\"null\");\n          ctorgen.visitInsn(Opcodes.ACONST_NULL);\n        }\n        ctorgen.invokeConstructor(objtype, new Method(\"<init>\", Type.VOID_TYPE,\n            ctorTypes));\n\n        emitSource(\"public \" + className + \"(\" + args + \") {\");\n        tab();\n        emitSource(\"this(\" + params + \");\");\n        untab();\n        emitSource(\"}\");\n\n        ctorgen.returnValue();\n        ctorgen.endMethod();\n      }\n\n      if (supportsMeta()) {\n        // ctor that takes closed-overs but not meta\n        Type[] ctorTypes = ctorTypes();\n        Type[] noMetaCtorTypes = new Type[ctorTypes.length - 1];\n        StringBuilder params = new StringBuilder();\n        StringBuilder paramNames = new StringBuilder();\n        for (int i = 1; i < ctorTypes.length; i++) {\n          if (params.length() > 0) {\n            params.append(\", \");\n          }\n          paramNames.append(\", \");\n          String t = registerTemp();\n          noMetaCtorTypes[i - 1] = ctorTypes[i];\n          params.append(printClass(ctorTypes[i]) + \" \" + t);\n          paramNames.append(t);\n        }\n        Method alt = new Method(\"<init>\", Type.VOID_TYPE, noMetaCtorTypes);\n        ctorgen = new GeneratorAdapter(ACC_PUBLIC, alt, null, null, cv);\n        ctorgen.visitCode();\n        ctorgen.loadThis();\n        ctorgen.visitInsn(Opcodes.ACONST_NULL); // null meta\n        ctorgen.loadArgs();\n        ctorgen.invokeConstructor(objtype, new Method(\"<init>\", Type.VOID_TYPE,\n            ctorTypes));\n\n        emitSource(\"public \" + className + \"(\" + params + \") {\");\n        tab();\n        emitSource(\"this(null\" + paramNames + \");\");\n        untab();\n        emitSource(\"}\");\n\n        ctorgen.returnValue();\n        ctorgen.endMethod();\n\n        // meta()\n        Method meth = Method.getMethod(\"clojure.lang.IPersistentMap meta()\");\n\n        GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC, meth, null,\n            null, cv);\n        gen.visitCode();\n        gen.loadThis();\n        gen.getField(objtype, \"__meta\", IPERSISTENTMAP_TYPE);\n\n        emitSource(\"public clojure.lang.IPersistentMap meta() { return this.__meta; }\");\n\n        gen.returnValue();\n        gen.endMethod();\n\n        // withMeta()\n        meth = Method\n            .getMethod(\"clojure.lang.IObj withMeta(clojure.lang.IPersistentMap)\");\n\n        emitSource(\"public clojure.lang.IObj withMeta(clojure.lang.IPersistentMap __meta) {\");\n        tab();\n        gen = new GeneratorAdapter(ACC_PUBLIC, meth, null, null, cv);\n        gen.visitCode();\n        gen.newInstance(objtype);\n        gen.dup();\n        gen.loadArg(0);\n\n        StringBuilder ctorParams = new StringBuilder();\n        for (ISeq s = RT.keys(closes); s != null; s = s.next(), ++a) {\n          ctorParams.append(\", \");\n          LocalBinding lb = (LocalBinding) s.first();\n          gen.loadThis();\n          Class primc = lb.getPrimitiveType();\n          if (primc != null) {\n            gen.getField(objtype, lb.name, Type.getType(primc));\n            ctorParams.append(\"(\" + printClass(primc) + \")\" + lb.print());\n          } else {\n            gen.getField(objtype, lb.name, OBJECT_TYPE);\n            ctorParams.append(\"(Object)\" + lb.print());\n          }\n        }\n        emitSource(\"return new \" + className + \"(__meta\" + ctorParams + \");\");\n        gen.invokeConstructor(objtype, new Method(\"<init>\", Type.VOID_TYPE,\n            ctorTypes));\n        untab();\n        emitSource(\"}\");\n        gen.returnValue();\n        gen.endMethod();\n      }\n\n      emitStatics(cv);\n      emitMethods(cv);\n\n      if (keywordCallsites.count() > 0) {\n        Method meth = Method\n            .getMethod(\"void swapThunk(int,clojure.lang.ILookupThunk)\");\n        // String n = registerTemp();\n        // String thunk = registerTemp();\n        // emitSource(\"public void swapThunk(int \" + n +\n        // \",clojure.lang.ILookupThunk \" + thunk + \") {\");\n        // tab();\n\n        GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC, meth, null,\n            null, cv);\n        gen.visitCode();\n        Label endLabel = gen.newLabel();\n\n        Label[] labels = new Label[keywordCallsites.count()];\n        for (int i = 0; i < keywordCallsites.count(); i++) {\n          labels[i] = gen.newLabel();\n        }\n        gen.loadArg(0);\n        gen.visitTableSwitchInsn(0, keywordCallsites.count() - 1, endLabel,\n            labels);\n\n        // emitSource(\"switch (\" + n + \") {\");\n        for (int i = 0; i < keywordCallsites.count(); i++) {\n          gen.mark(labels[i]);\n          // gen.loadThis();\n          gen.loadArg(1);\n          gen.putStatic(objtype, thunkNameStatic(i), ILOOKUP_THUNK_TYPE);\n          gen.goTo(endLabel);\n          // emitSource(\"case \" + i + \":\");\n          // tab();\n          // emitSource(thunkNameStatic(i) + \" = (\" +\n          // ILOOKUP_THUNK_TYPE.getClassName() + \")\" + thunk + \";\");\n          // emitSource(\"break;\");\n          // untab();\n        }\n        // emitSource(\"}\");\n\n        gen.mark(endLabel);\n\n        // untab();\n        // emitSource(\"}\");\n\n        gen.returnValue();\n        gen.endMethod();\n      }\n\n      // end of class\n      cv.visitEnd();\n      untab();\n      emitSource(\"}\");\n\n      bytecode = cw.toByteArray();\n      if (RT.booleanCast(COMPILE_FILES.deref())) {\n        writeClassFile(internalName, bytecode);\n        writeSourceFile(internalName, SOURCE_WRITER.deref().toString());\n      }\n      Var.popThreadBindings();\n      // else\n      // getCompiledClass();\n    }\n\n    private void emitKeywordCallsites(GeneratorAdapter clinitgen) {\n      for (int i = 0; i < keywordCallsites.count(); i++) {\n        Keyword k = (Keyword) keywordCallsites.nth(i);\n        clinitgen.newInstance(KEYWORD_LOOKUPSITE_TYPE);\n        clinitgen.dup();\n        String val = emitValue(k, clinitgen);\n        clinitgen.invokeConstructor(KEYWORD_LOOKUPSITE_TYPE,\n            Method.getMethod(\"void <init>(clojure.lang.Keyword)\"));\n        clinitgen.dup();\n        clinitgen\n            .putStatic(objtype, siteNameStatic(i), KEYWORD_LOOKUPSITE_TYPE);\n        clinitgen.putStatic(objtype, thunkNameStatic(i), ILOOKUP_THUNK_TYPE);\n\n        // emitSource(thunkNameStatic(i) + \" = (\" + siteNameStatic(i) +\n        // \" = new \" + KEYWORD_LOOKUPSITE_TYPE.getClassName() + \"(\" + val +\n        // \"));\");\n      }\n    }\n\n    protected void emitStatics(ClassVisitor gen) {\n    }\n\n    protected void emitMethods(ClassVisitor gen) {\n    }\n\n    String emitListAsObjectArray(Object value, GeneratorAdapter gen) {\n      StringBuilder sb = new StringBuilder();\n      gen.push(((List) value).size());\n      gen.newArray(OBJECT_TYPE);\n      int i = 0;\n      for (Iterator it = ((List) value).iterator(); it.hasNext(); i++) {\n        if (sb.length() > 0) {\n          sb.append(\", \");\n        }\n        gen.dup();\n        gen.push(i);\n        sb.append(emitValue(it.next(), gen));\n        gen.arrayStore(OBJECT_TYPE);\n      }\n      return sb.toString();\n    }\n\n    String emitValue(Object value, GeneratorAdapter gen) {\n      boolean partial = true;\n      String str;\n\n      if (value == null) {\n        gen.visitInsn(Opcodes.ACONST_NULL);\n        str = \"null\";\n      } else if (value instanceof String) {\n        gen.push((String) value);\n        str = \"\\\"\" + escapeString((String) value) + \"\\\"\";\n      } else if (value instanceof Boolean) {\n        if (((Boolean) value).booleanValue()) {\n          gen.getStatic(BOOLEAN_OBJECT_TYPE, \"TRUE\", BOOLEAN_OBJECT_TYPE);\n          str = \"Boolean.TRUE\";\n        } else {\n          gen.getStatic(BOOLEAN_OBJECT_TYPE, \"FALSE\", BOOLEAN_OBJECT_TYPE);\n          str = \"Boolean.FALSE\";\n        }\n      } else {\n        String valueStr = value instanceof Number ? String.valueOf(value) : \"\";\n        boolean isNeg = valueStr.startsWith(\"-\");\n        if (value instanceof Integer) {\n          gen.push(((Integer) value).intValue());\n          gen.invokeStatic(Type.getType(Integer.class),\n              Method.getMethod(\"Integer valueOf(int)\"));\n          str = isNeg ? \"(\" + valueStr + \")\" : valueStr;\n        } else if (value instanceof Long) {\n          gen.push(((Long) value).longValue());\n          gen.invokeStatic(Type.getType(Long.class),\n              Method.getMethod(\"Long valueOf(long)\"));\n          str = isNeg ? \"(\" + value + \"L)\" : value + \"L\";\n        } else if (value instanceof Double) {\n          gen.push(((Double) value).doubleValue());\n          gen.invokeStatic(Type.getType(Double.class),\n              Method.getMethod(\"Double valueOf(double)\"));\n          str = isNeg ? \"(\" + valueStr + \")\" : valueStr;\n        } else if (value instanceof Float) {\n          gen.push(((Float) value).floatValue());\n          gen.invokeStatic(Type.getType(Float.class),\n              Method.getMethod(\"Float valueOf(float)\"));\n          str = isNeg ? \"(\" + valueStr + \")\" : valueStr;\n        } else if (value instanceof Character) {\n          gen.push(((Character) value).charValue());\n          gen.invokeStatic(Type.getType(Character.class),\n              Method.getMethod(\"Character valueOf(char)\"));\n          str = \"Character.valueOf((char)\"\n              + (int) ((Character) value).charValue() + \")\";\n        } else if (value instanceof Class) {\n          Class cc = (Class) value;\n          if (cc.isPrimitive()) {\n            Type bt;\n            if (cc == boolean.class)\n              bt = Type.getType(Boolean.class);\n            else if (cc == byte.class)\n              bt = Type.getType(Byte.class);\n            else if (cc == char.class)\n              bt = Type.getType(Character.class);\n            else if (cc == double.class)\n              bt = Type.getType(Double.class);\n            else if (cc == float.class)\n              bt = Type.getType(Float.class);\n            else if (cc == int.class)\n              bt = Type.getType(Integer.class);\n            else if (cc == long.class)\n              bt = Type.getType(Long.class);\n            else if (cc == short.class)\n              bt = Type.getType(Short.class);\n            else\n              throw Util\n                  .runtimeException(\"Can't embed unknown primitive in code: \"\n                      + value);\n            gen.getStatic(bt, \"TYPE\", Type.getType(Class.class));\n          } else {\n            gen.push(destubClassName(cc.getName()));\n            gen.invokeStatic(RT_TYPE, Method.getMethod(\"Class classForName(String)\"));\n          }\n          str = printClass(cc) + \".class\";\n        } else if (value instanceof Symbol) {\n          String ns_ = ((Symbol) value).ns;\n          gen.push(ns_);\n          String name_ = ((Symbol) value).name;\n          gen.push(name_);\n          gen.invokeStatic(Type.getType(Symbol.class),\n              Method.getMethod(\"clojure.lang.Symbol intern(String,String)\"));\n          str = \"Symbol.intern(\" + (ns_ == null ? \"null\" : \"\\\"\" + ns_ + \"\\\"\")\n              + \", \" + (name_ == null ? \"null\" : \"\\\"\" + name_ + \"\\\"\") + \")\";\n        } else if (value instanceof Keyword) {\n          String ns_ = ((Keyword) value).sym.ns;\n          gen.push(ns_);\n          String name_ = ((Keyword) value).sym.name;\n          gen.push(name_);\n          gen.invokeStatic(RT_TYPE,\n              Method.getMethod(\"clojure.lang.Keyword keyword(String,String)\"));\n          str = \"Keyword.intern(\" + (ns_ == null ? \"null\" : \"\\\"\" + ns_ + \"\\\"\")\n              + \", \" + (name_ == null ? \"null\" : \"\\\"\" + name_ + \"\\\"\") + \")\";\n        }\n        // else if(value instanceof KeywordCallSite)\n        // {\n        // emitValue(((KeywordCallSite) value).k.sym, gen);\n        // gen.invokeStatic(Type.getType(KeywordCallSite.class),\n        // Method.getMethod(\"clojure.lang.KeywordCallSite create(clojure.lang.Symbol)\"));\n        // }\n        else if (value instanceof Var) {\n          Var var = (Var) value;\n\n          String className = maybeClassWithVAR(var);\n          if (className != null) {\n            gen.getStatic(\n                Type.getType(\"L\" + className.replaceAll(\"\\\\.\", \"/\") + \";\"),\n                \"VAR\", VAR_TYPE);\n            return className + \".VAR\";\n          } else {\n            String ns_ = var.ns.name.toString();\n            String name_ = var.sym.toString();\n            gen.push(ns_);\n            gen.push(name_);\n            gen.invokeStatic(RT_TYPE,\n                Method.getMethod(\"clojure.lang.Var var(String,String)\"));\n            str = \"RT.var(\" + (ns_ == null ? \"null\" : \"\\\"\" + ns_ + \"\\\"\") + \", \"\n                + (name_ == null ? \"null\" : \"\\\"\" + name_ + \"\\\"\") + \")\";\n          }\n        } else if (value instanceof IType) {\n          Method ctor = new Method(\n              \"<init>\",\n              Type.getConstructorDescriptor(value.getClass().getConstructors()[0]));\n          gen.newInstance(Type.getType(value.getClass()));\n          gen.dup();\n          IPersistentVector fields = (IPersistentVector) Reflector\n              .invokeStaticMethod(value.getClass(), \"getBasis\", new Object[] {});\n          StringBuilder sb = new StringBuilder();\n          for (ISeq s = RT.seq(fields); s != null; s = s.next()) {\n            Symbol field = (Symbol) s.first();\n            Class k = tagClass(tagOf(field));\n            Object val = Reflector.getInstanceField(value, field.name);\n            String f = emitValue(val, gen);\n\n            if (k.isPrimitive()) {\n              Type b = Type.getType(boxClass(k));\n              String p = Type.getType(k).getDescriptor();\n              String n = k.getName();\n\n              gen.invokeVirtual(b, new Method(n + \"Value\", \"()\" + p));\n              f = f + \".\" + n + \"Value()\";\n            }\n            if (sb.length() > 0) {\n              sb.append(\", \");\n            }\n            sb.append(f);\n          }\n          gen.invokeConstructor(Type.getType(value.getClass()), ctor);\n          return \"new \" + printClass(value.getClass()) + \"(\" + sb.toString()\n              + \")\";\n        } else if (value instanceof IRecord) {\n          Method createMethod = Method.getMethod(value.getClass().getName()\n              + \" create(clojure.lang.IPersistentMap)\");\n          String val = emitValue(\n              PersistentArrayMap.create((java.util.Map) value), gen);\n          gen.invokeStatic(getType(value.getClass()), createMethod);\n          str = printClass(value.getClass()) + \".create(\" + val + \")\";\n        } else if (value instanceof IPersistentMap) {\n          List entries = new ArrayList();\n          for (Map.Entry entry : (Set<Map.Entry>) ((Map) value).entrySet()) {\n            entries.add(entry.getKey());\n            entries.add(entry.getValue());\n          }\n          String val = emitListAsObjectArray(entries, gen);\n          gen.invokeStatic(RT_TYPE,\n              Method.getMethod(\"clojure.lang.IPersistentMap map(Object[])\"));\n          str = \"RT.map(\" + val + \")\";\n        } else if (value instanceof IPersistentVector) {\n          String val = emitListAsObjectArray(value, gen);\n          gen.invokeStatic(RT_TYPE, Method\n              .getMethod(\"clojure.lang.IPersistentVector vector(Object[])\"));\n          if (val.equals(\"null\")) {\n            str = \"RT.vector().cons(null)\";\n          } else {\n            str = \"RT.vector(\" + val + \")\";\n          }\n        } else if (value instanceof PersistentHashSet) {\n          ISeq vs = RT.seq(value);\n          if (vs == null) {\n            gen.getStatic(Type.getType(PersistentHashSet.class), \"EMPTY\",\n                Type.getType(PersistentHashSet.class));\n            str = \"PersistentHashSet.EMPTY\";\n          } else {\n            String val = emitListAsObjectArray(vs, gen);\n            gen.invokeStatic(Type.getType(PersistentHashSet.class), Method\n                .getMethod(\"clojure.lang.PersistentHashSet create(Object[])\"));\n            if (val.equals(\"null\")) {\n              str = \"PersistentHashSet.create().cons(null)\";\n            } else {\n              str = \"PersistentHashSet.create(\" + val + \")\";\n            }\n          }\n        } else if (value instanceof ISeq || value instanceof IPersistentList) {\n          String val = emitListAsObjectArray(value, gen);\n          gen.invokeStatic(Type.getType(java.util.Arrays.class),\n              Method.getMethod(\"java.util.List asList(Object[])\"));\n          gen.invokeStatic(Type.getType(PersistentList.class), Method\n              .getMethod(\"clojure.lang.IPersistentList create(java.util.List)\"));\n          if (val.equals(\"null\")) {\n            str = \"PersistentList.EMPTY.cons(null)\";\n          } else {\n            str = \"PersistentList.create(java.util.Arrays.asList(\" + val + \"))\";\n          }\n        } else if (value instanceof Pattern) {\n          String v = emitValue(value.toString(), gen);\n          gen.invokeStatic(Type.getType(Pattern.class),\n              Method.getMethod(\"java.util.regex.Pattern compile(String)\"));\n          str = \"java.util.regex.Pattern.compile(\" + v + \")\";\n        } else {\n          String cs = null;\n          try {\n            cs = RT.printString(value);\n            // System.out.println(\"WARNING SLOW CODE: \" + Util.classOf(value) +\n            // \" -> \" + cs);\n          } catch (Exception e) {\n            throw Util\n                .runtimeException(\"Can't embed object in code, maybe print-dup not defined: \"\n                    + value);\n          }\n          if (cs.length() == 0)\n            throw Util\n                .runtimeException(\"Can't embed unreadable object in code: \"\n                    + value);\n\n          if (cs.startsWith(\"#<\"))\n            throw Util\n                .runtimeException(\"Can't embed unreadable object in code: \"\n                    + cs);\n\n          gen.push(cs);\n          gen.invokeStatic(RT_TYPE, readStringMethod);\n          partial = false;\n          str = \"RT.readString(\\\"\" + escapeString(cs) + \"\\\")\";\n        }\n      }\n\n      if (partial) {\n        if (value instanceof IObj && RT.count(((IObj) value).meta()) > 0) {\n          gen.checkCast(IOBJ_TYPE);\n          Object m = ((IObj) value).meta();\n          String val = emitValue(elideMeta(m), gen);\n          gen.checkCast(IPERSISTENTMAP_TYPE);\n          gen.invokeInterface(\n              IOBJ_TYPE,\n              Method\n                  .getMethod(\"clojure.lang.IObj withMeta(clojure.lang.IPersistentMap)\"));\n          return \"((clojure.lang.IObj)\" + str + \").withMeta((IPersistentMap)\"\n              + val + \")\";\n        }\n      }\n      return str;\n    }\n\n    private String maybeClassWithVAR(Var var) {\n      try {\n        Class c = Class.forName(\n            var.ns.name.toString() + DOLLAR + munge(var.sym.toString()), false,\n            getClass().getClassLoader());\n        c.getDeclaredField(\"VAR\");\n        return c.getCanonicalName();\n      } catch (Throwable e) {\n        return null;\n      }\n    }\n\n    void emitConstants(GeneratorAdapter clinitgen) {\n      try {\n        Var.pushThreadBindings(RT.map(RT.PRINT_DUP, RT.T));\n\n        for (int i = 0; i < constants.count(); i++) {\n          String val = emitValue(constants.nth(i), clinitgen);\n          clinitgen.checkCast(constantType(i));\n          clinitgen.putStatic(objtype, constantName(i), constantType(i));\n          emitSource(constantName(i) + \" = (\" + printClass(constantType(i))\n              + \")\" + val + \";\");\n        }\n      } finally {\n        Var.popThreadBindings();\n      }\n    }\n\n    boolean isMutable(LocalBinding lb) {\n      return isVolatile(lb)\n          || RT.booleanCast(RT.contains(fields, lb.sym))\n          && RT.booleanCast(RT.get(lb.sym.meta(),\n              Keyword.intern(\"unsynchronized-mutable\")));\n    }\n\n    boolean isVolatile(LocalBinding lb) {\n      return RT.booleanCast(RT.contains(fields, lb.sym))\n          && RT.booleanCast(RT.get(lb.sym.meta(),\n              Keyword.intern(\"volatile-mutable\")));\n    }\n\n    boolean isDeftype() {\n      return fields != null;\n    }\n\n    boolean supportsMeta() {\n      return !isDeftype();\n    }\n\n    void emitClearCloses(GeneratorAdapter gen) {\n      // int a = 1;\n      // for(ISeq s = RT.keys(closes); s != null; s = s.next(), ++a)\n      // {\n      // LocalBinding lb = (LocalBinding) s.first();\n      // Class primc = lb.getPrimitiveType();\n      // if(primc == null)\n      // {\n      // gen.loadThis();\n      // gen.visitInsn(Opcodes.ACONST_NULL);\n      // gen.putField(objtype, lb.name, OBJECT_TYPE);\n      // }\n      // }\n    }\n\n    synchronized Class getCompiledClass() {\n      if (compiledClass == null) {\n        // if(RT.booleanCast(COMPILE_FILES.deref()))\n        // compiledClass = RT.classForName(name);//loader.defineClass(name,\n        // bytecode);\n        // else\n        loader = (DynamicClassLoader) LOADER.deref();\n        compiledClass = loader.defineClass(name, bytecode, src);\n      }\n      return compiledClass;\n    }\n\n    public Object eval() {\n      if (isDeftype())\n        return null;\n      try {\n        return getCompiledClass().newInstance();\n      } catch (Exception e) {\n        throw Util.sneakyThrow(e);\n      }\n    }\n\n    public void emitLetFnInits(GeneratorAdapter gen, ObjExpr objx,\n        IPersistentSet letFnLocals) {\n      // objx arg is enclosing objx, not this\n      gen.checkCast(objtype);\n\n      for (ISeq s = RT.keys(closes); s != null; s = s.next()) {\n        LocalBinding lb = (LocalBinding) s.first();\n        if (letFnLocals.contains(lb)) {\n          Class primc = lb.getPrimitiveType();\n          gen.dup();\n          if (primc != null) {\n            objx.emitUnboxedLocal(gen, lb);\n            gen.putField(objtype, lb.name, Type.getType(primc));\n          } else {\n            objx.emitLocal(gen, lb, false);\n            gen.putField(objtype, lb.name, OBJECT_TYPE);\n          }\n        }\n      }\n      gen.pop();\n\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      // emitting a Fn means constructing an instance, feeding closed-overs from\n      // enclosing scope, if any\n      // objx arg is enclosing objx, not this\n      // getCompiledClass();\n      String val;\n      if (isDeftype()) {\n        gen.visitInsn(Opcodes.ACONST_NULL);\n        val = \"\";\n      } else {\n        gen.newInstance(objtype);\n        gen.dup();\n        if (supportsMeta())\n          gen.visitInsn(Opcodes.ACONST_NULL);\n        StringBuilder argsList = new StringBuilder();\n        for (ISeq s = RT.seq(closesExprs); s != null; s = s.next()) {\n          if (argsList.length() > 0) {\n            argsList.append(\", \");\n          }\n          LocalBindingExpr lbe = (LocalBindingExpr) s.first();\n          LocalBinding lb = lbe.b;\n          if (lb.getPrimitiveType() != null)\n            argsList.append(objx.emitUnboxedLocal(gen, lb));\n          else\n            argsList.append(objx.emitLocal(gen, lb, lbe.shouldClear));\n        }\n        gen.invokeConstructor(objtype, new Method(\"<init>\", Type.VOID_TYPE,\n            ctorTypes()));\n\n        val = \"new \" + printClass(objtype) + \"(\" + argsList + \")\";\n      }\n      if (context == C.STATEMENT) {\n        gen.pop();\n      }\n      if (!val.isEmpty()) {\n        return wrap(context, val);\n      } else {\n        return \"\";\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return (compiledClass != null) ? compiledClass : (tag != null) ? HostExpr\n          .tagToClass(tag) : IFn.class;\n    }\n\n    public void emitAssignLocal(GeneratorAdapter gen, LocalBinding lb, Expr val) {\n      if (!isMutable(lb))\n        throw new IllegalArgumentException(\"Cannot assign to non-mutable: \"\n            + lb.name);\n      Class primc = lb.getPrimitiveType();\n      gen.loadThis();\n      if (primc != null) {\n        if (!(val instanceof MaybePrimitiveExpr && ((MaybePrimitiveExpr) val)\n            .canEmitPrimitive()))\n          throw new IllegalArgumentException(\n              \"Must assign primitive to primitive mutable: \" + lb.name);\n        MaybePrimitiveExpr me = (MaybePrimitiveExpr) val;\n        String t = me.emitUnboxed(C.EXPRESSION, this, gen);\n        gen.putField(objtype, lb.name, Type.getType(primc));\n        emitSource(\"this.\" + lb.print() + \" = \" + t + \";\");\n      } else {\n        String t = val.emit(C.EXPRESSION, this, gen);\n        gen.putField(objtype, lb.name, OBJECT_TYPE);\n        emitSource(\"this.\" + lb.print() + \" = \" + t + \";\");\n      }\n    }\n\n    private String emitLocal(GeneratorAdapter gen, LocalBinding lb,\n        boolean clear) {\n      if (closes.containsKey(lb)) {\n        Class primc = lb.getPrimitiveType();\n        gen.loadThis();\n        if (primc != null) {\n          gen.getField(objtype, lb.name, Type.getType(primc));\n          return HostExpr.emitBoxReturn(this, gen, primc, \"this.\" + lb.print());\n        } else {\n          gen.getField(objtype, lb.name, OBJECT_TYPE);\n          if (onceOnly && clear && lb.canBeCleared) {\n            gen.loadThis();\n            gen.visitInsn(Opcodes.ACONST_NULL);\n            gen.putField(objtype, lb.name, OBJECT_TYPE);\n          }\n          return \"this.\" + lb.print();\n        }\n      } else {\n        int argoff = isStatic ? 0 : 1;\n        Class primc = lb.getPrimitiveType();\n        // String rep = lb.sym.name + \" \" +\n        // lb.toString().substring(lb.toString().lastIndexOf('@'));\n        if (lb.isArg) {\n          gen.loadArg(lb.idx - argoff);\n          if (primc != null)\n            return HostExpr.emitBoxReturn(this, gen, primc, lb.print());\n          else {\n            if (clear && lb.canBeCleared) {\n              // System.out.println(\"clear: \" + rep);\n              gen.visitInsn(Opcodes.ACONST_NULL);\n              gen.storeArg(lb.idx - argoff);\n            } else {\n              // System.out.println(\"use: \" + rep);\n            }\n            return lb.print();\n          }\n        } else {\n          if (primc != null) {\n            gen.visitVarInsn(Type.getType(primc).getOpcode(Opcodes.ILOAD),\n                lb.idx);\n            return HostExpr.emitBoxReturn(this, gen, primc, lb.print());\n          } else {\n            gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ILOAD), lb.idx);\n            if (clear && lb.canBeCleared) {\n              // System.out.println(\"clear: \" + rep);\n              gen.visitInsn(Opcodes.ACONST_NULL);\n              gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), lb.idx);\n            } else {\n              // System.out.println(\"use: \" + rep);\n            }\n            if (METHOD.deref() instanceof FnMethod) {\n              FnMethod m = (FnMethod) METHOD.deref();\n              if (m.thisName != null && lb.name.equals(munge(m.thisName))) {\n                return \"this\";\n              }\n            }\n            if (METHOD.deref() instanceof NewInstanceMethod) {\n              NewInstanceMethod m = (NewInstanceMethod) METHOD.deref();\n              Symbol tname = m.thisName;\n              if (tname.name != null && lb.name.equals(munge(tname.name))) {\n                return \"this\";\n              }\n            }\n            if (thisName != null && lb.name.equals(munge(thisName))) {\n              return \"this\";\n            } else {\n              return lb.print();\n            }\n          }\n        }\n      }\n    }\n\n    private String emitUnboxedLocal(GeneratorAdapter gen, LocalBinding lb) {\n      int argoff = isStatic ? 0 : 1;\n      Class primc = lb.getPrimitiveType();\n      if (closes.containsKey(lb)) {\n        gen.loadThis();\n        gen.getField(objtype, lb.name, Type.getType(primc));\n      } else if (lb.isArg) {\n        gen.loadArg(lb.idx - argoff);\n      } else {\n        gen.visitVarInsn(Type.getType(primc).getOpcode(Opcodes.ILOAD), lb.idx);\n      }\n      return lb.print();\n    }\n\n    public String emitVar(GeneratorAdapter gen, Var var) {\n      Integer i = (Integer) vars.valAt(var);\n      return emitConstant(gen, i);\n      // gen.getStatic(fntype, munge(var.sym.toString()), VAR_TYPE);\n    }\n\n    final static Method varGetMethod = Method.getMethod(\"Object get()\");\n    final static Method varGetRawMethod = Method\n        .getMethod(\"Object getRawRoot()\");\n\n    public String emitVarValue(GeneratorAdapter gen, Var v) {\n      Integer i = (Integer) vars.valAt(v);\n      if (!v.isDynamic()) {\n        String val = emitConstant(gen, i);\n        gen.invokeVirtual(VAR_TYPE, varGetRawMethod);\n        return val + \".getRawRoot()\";\n      } else {\n        String val = emitConstant(gen, i);\n        gen.invokeVirtual(VAR_TYPE, varGetMethod);\n        return val + \".get()\";\n      }\n    }\n\n    public String emitKeyword(GeneratorAdapter gen, Keyword k) {\n      Integer i = (Integer) keywords.valAt(k);\n      return emitConstant(gen, i);\n      // gen.getStatic(fntype, munge(k.sym.toString()), KEYWORD_TYPE);\n    }\n\n    public String emitConstant(GeneratorAdapter gen, int id) {\n      usedConstants = (IPersistentSet) usedConstants.cons(id);\n      String constantName = constantName(id);\n      Type constantType = constantType(id);\n      gen.getStatic(objtype, constantName, constantType);\n      return constantName;\n    }\n\n    String constantName(int id) {\n      return CONST_PREFIX + id;\n    }\n\n    String siteName(int n) {\n      return \"__site__\" + n;\n    }\n\n    String siteNameStatic(int n) {\n      return siteName(n) + \"__\";\n    }\n\n    String thunkName(int n) {\n      return \"__thunk__\" + n;\n    }\n\n    String cachedClassName(int n) {\n      return \"__cached_class__\" + n;\n    }\n\n    String cachedVarName(int n) {\n      return \"__cached_var__\" + n;\n    }\n\n    String varCallsiteName(int n) {\n      return \"__var__callsite__\" + n;\n    }\n\n    String thunkNameStatic(int n) {\n      return thunkName(n) + \"__\";\n    }\n\n    Class constantRealType(int id) {\n      Object o = constants.nth(id);\n      Class c = clojure.lang.Util.classOf(o);\n      if (o != null) {\n        if (o instanceof ISeq || o instanceof IPersistentList) {\n          return IPersistentList.class;\n        } else if (o instanceof IPersistentMap) {\n          return IPersistentMap.class;\n        }\n      }\n      return c;\n    }\n\n    Type constantType(int id) {\n      Object o = constants.nth(id);\n      Class c = clojure.lang.Util.classOf(o);\n      if (c != null && Modifier.isPublic(c.getModifiers())) {\n        // can't emit derived fn types due to visibility\n        if (LazySeq.class.isAssignableFrom(c))\n          return Type.getType(ISeq.class);\n        else if (c == Keyword.class)\n          return Type.getType(Keyword.class);\n        // else if(c == KeywordCallSite.class)\n        // return Type.getType(KeywordCallSite.class);\n        else if (RestFn.class.isAssignableFrom(c))\n          return Type.getType(RestFn.class);\n        else if (IPersistentMap.class.isAssignableFrom(c))\n          return Type.getType(IPersistentMap.class);\n        else if (IPersistentSet.class.isAssignableFrom(c))\n          return Type.getType(IPersistentSet.class);\n        else if (IPersistentStack.class.isAssignableFrom(c))\n          return Type.getType(IPersistentStack.class);\n        else if (IPersistentVector.class.isAssignableFrom(c))\n          return Type.getType(IPersistentVector.class);\n        else if (IPersistentList.class.isAssignableFrom(c))\n          return Type.getType(IPersistentList.class);\n        else if (Symbol.class.isAssignableFrom(c))\n          return Type.getType(Symbol.class);\n        else if (AFn.class.isAssignableFrom(c))\n          return Type.getType(AFn.class);\n        else if (c == Var.class)\n          return Type.getType(Var.class);\n        else if (c == String.class)\n          return Type.getType(String.class);\n        // return Type.getType(c);\n      }\n      return OBJECT_TYPE;\n    }\n\n  }\n\n  enum PATHTYPE {\n    PATH, BRANCH;\n  }\n\n  static class PathNode {\n    final PATHTYPE type;\n    final PathNode parent;\n\n    PathNode(PATHTYPE type, PathNode parent) {\n      this.type = type;\n      this.parent = parent;\n    }\n  }\n\n  static PathNode clearPathRoot() {\n    return (PathNode) CLEAR_ROOT.get();\n  }\n\n  public static String escapeString(String value) {\n    return StringEscapeUtils.escapeJava(value);\n  }\n\n  enum PSTATE {\n    REQ, REST, DONE\n  }\n\n  public static class FnMethod extends ObjMethod {\n    // localbinding->localbinding\n    PersistentVector reqParms = PersistentVector.EMPTY;\n    LocalBinding restParm = null;\n    Type[] argtypes;\n    Class[] argclasses;\n    Class retClass;\n    String prim;\n    private String thisName;\n\n    public FnMethod(ObjExpr objx, ObjMethod parent) {\n      super(objx, parent);\n    }\n\n    static public char classChar(Object x) {\n      Class c = null;\n      if (x instanceof Class)\n        c = (Class) x;\n      else if (x instanceof Symbol)\n        c = primClass((Symbol) x);\n      if (c == null || !c.isPrimitive())\n        return 'O';\n      if (c == long.class)\n        return 'L';\n      if (c == double.class)\n        return 'D';\n      throw new IllegalArgumentException(\n          \"Only long and double primitives are supported\");\n    }\n\n    static public String primInterface(IPersistentVector arglist) {\n      StringBuilder sb = new StringBuilder();\n      for (int i = 0; i < arglist.count(); i++)\n        sb.append(classChar(tagOf(arglist.nth(i))));\n      sb.append(classChar(tagOf(arglist)));\n      String ret = sb.toString();\n      boolean prim = ret.contains(\"L\") || ret.contains(\"D\");\n      if (prim && arglist.count() > 4)\n        throw new IllegalArgumentException(\n            \"fns taking primitives support only 4 or fewer args\");\n      if (prim)\n        return \"clojure.lang.IFn$\" + ret;\n      return null;\n    }\n\n    static FnMethod parse(ObjExpr objx, ISeq form, boolean isStatic) {\n      // ([args] body...)\n      IPersistentVector parms = (IPersistentVector) RT.first(form);\n      ISeq body = RT.next(form);\n      try {\n        FnMethod method = new FnMethod(objx, (ObjMethod) METHOD.deref());\n        method.line = lineDeref();\n        method.column = columnDeref();\n        // register as the current method and set up a new env frame\n        PathNode pnode = (PathNode) CLEAR_PATH.get();\n        if (pnode == null)\n          pnode = new PathNode(PATHTYPE.PATH, null);\n        Var.pushThreadBindings(RT.mapUniqueKeys(METHOD, method, LOCAL_ENV,\n            LOCAL_ENV.deref(), LOOP_LOCALS, null, NEXT_LOCAL_NUM, 0,\n            CLEAR_PATH, pnode, CLEAR_ROOT, pnode, CLEAR_SITES,\n            PersistentHashMap.EMPTY));\n\n        method.prim = primInterface(parms);\n        if (method.prim != null)\n          method.prim = method.prim.replace('.', '/');\n\n        method.retClass = tagClass(tagOf(parms));\n        if (method.retClass.isPrimitive()\n            && !(method.retClass == double.class || method.retClass == long.class))\n          throw new IllegalArgumentException(\n              \"Only long and double primitives are supported\");\n\n        // register 'this' as local 0\n        // registerLocal(THISFN, null, null);\n        if (!isStatic) {\n          method.thisName = objx.thisName;\n          if (objx.thisName != null) {\n            registerLocal(Symbol.intern(objx.thisName), null, null, false);\n          } else {\n            getAndIncLocalNum();\n          }\n        }\n        PSTATE state = PSTATE.REQ;\n        PersistentVector argLocals = PersistentVector.EMPTY;\n        ArrayList<Type> argtypes = new ArrayList();\n        ArrayList<Class> argclasses = new ArrayList();\n        for (int i = 0; i < parms.count(); i++) {\n          if (!(parms.nth(i) instanceof Symbol))\n            throw new IllegalArgumentException(\"fn params must be Symbols: \"\n                + parms.nth(i));\n          Symbol p = (Symbol) parms.nth(i);\n          if (p.getNamespace() != null)\n            throw Util\n                .runtimeException(\"Can't use qualified name as parameter: \" + p);\n          if (p.equals(_AMP_)) {\n            // if(isStatic)\n            // throw Util.runtimeException(\"Variadic fns cannot be static\");\n            if (state == PSTATE.REQ)\n              state = PSTATE.REST;\n            else\n              throw Util.runtimeException(\"Invalid parameter list\");\n          }\n\n          else {\n            Class pc = primClass(tagClass(tagOf(p)));\n            // if(pc.isPrimitive() && !isStatic)\n            // {\n            // pc = Object.class;\n            // p = (Symbol) ((IObj) p).withMeta((IPersistentMap)\n            // RT.assoc(RT.meta(p), RT.TAG_KEY, null));\n            // }\n            // throw\n            // Util.runtimeException(\"Non-static fn can't have primitive parameter: \"\n            // + p);\n            if (pc.isPrimitive() && !(pc == double.class || pc == long.class))\n              throw new IllegalArgumentException(\n                  \"Only long and double primitives are supported: \" + p);\n\n            if (state == PSTATE.REST && tagOf(p) != null)\n              throw Util.runtimeException(\"& arg cannot have type hint\");\n            if (state == PSTATE.REST && method.prim != null)\n              throw Util\n                  .runtimeException(\"fns taking primitives cannot be variadic\");\n\n            if (state == PSTATE.REST)\n              pc = ISeq.class;\n            argtypes.add(Type.getType(pc));\n            argclasses.add(pc);\n            LocalBinding lb = pc.isPrimitive() ? registerLocal(p, null,\n                new MethodParamExpr(pc), true) : registerLocal(p,\n                state == PSTATE.REST ? ISEQ : tagOf(p), null, true);\n            argLocals = argLocals.cons(lb);\n            switch (state) {\n            case REQ:\n              method.reqParms = method.reqParms.cons(lb);\n              break;\n            case REST:\n              method.restParm = lb;\n              state = PSTATE.DONE;\n              break;\n\n            default:\n              throw Util.runtimeException(\"Unexpected parameter\");\n            }\n          }\n        }\n        if (method.reqParms.count() > MAX_POSITIONAL_ARITY)\n          throw Util.runtimeException(\"Can't specify more than \"\n              + MAX_POSITIONAL_ARITY + \" params\");\n        LOOP_LOCALS.set(argLocals);\n        method.argLocals = argLocals;\n        // if(isStatic)\n        if (method.prim != null) {\n          method.argtypes = argtypes.toArray(new Type[argtypes.size()]);\n          method.argclasses = argclasses.toArray(new Class[argtypes.size()]);\n          for (int i = 0; i < method.argclasses.length; i++) {\n            if (method.argclasses[i] == long.class\n                || method.argclasses[i] == double.class)\n              getAndIncLocalNum();\n          }\n        }\n        method.body = (new BodyExpr.Parser()).parse(C.RETURN, body);\n        return method;\n      } finally {\n        Var.popThreadBindings();\n      }\n    }\n\n    public void emit(ObjExpr fn, ClassVisitor cv) {\n      if (prim != null)\n        doEmitPrim(fn, cv);\n      else if (fn.isStatic)\n        doEmitStatic(fn, cv);\n      else\n        doEmit(fn, cv);\n    }\n\n    // TODO: is this required?\n    public void doEmitStatic(ObjExpr fn, ClassVisitor cv) {\n      new RuntimeException().printStackTrace();\n      Method ms = new Method(\"invokeStatic\", getReturnType(), argtypes);\n\n      GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC + ACC_STATIC, ms,\n          null,\n          // todo don't hardwire this\n          EXCEPTION_TYPES, cv);\n      gen.visitCode();\n      Label loopLabel = gen.mark();\n      gen.visitLineNumber(line, loopLabel);\n      try {\n        Var.pushThreadBindings(RT.map(LOOP_LABEL, loopLabel, METHOD, this));\n        emitBody(objx, gen, retClass, body);\n\n        Label end = gen.mark();\n        for (ISeq lbs = argLocals.seq(); lbs != null; lbs = lbs.next()) {\n          LocalBinding lb = (LocalBinding) lbs.first();\n          gen.visitLocalVariable(lb.name, argtypes[lb.idx].getDescriptor(),\n              null, loopLabel, end, lb.idx);\n        }\n      } finally {\n        Var.popThreadBindings();\n      }\n\n      gen.returnValue();\n      // gen.visitMaxs(1, 1);\n      gen.endMethod();\n\n      // generate the regular invoke, calling the static method\n      Method m = new Method(getMethodName(), OBJECT_TYPE, getArgTypes());\n\n      gen = new GeneratorAdapter(ACC_PUBLIC, m, null,\n      // todo don't hardwire this\n          EXCEPTION_TYPES, cv);\n      gen.visitCode();\n      for (int i = 0; i < argtypes.length; i++) {\n        gen.loadArg(i);\n        HostExpr.emitUnboxArg(fn, gen, argclasses[i], \"\");\n      }\n      gen.invokeStatic(objx.objtype, ms);\n      gen.box(getReturnType(), \"\");\n\n      gen.returnValue();\n      // gen.visitMaxs(1, 1);\n      gen.endMethod();\n      // TODOCLJ\n    }\n\n    public void doEmitPrim(ObjExpr fn, ClassVisitor cv) {\n      Type returnType;\n      if (retClass == double.class || retClass == long.class)\n        returnType = getReturnType();\n      else\n        returnType = OBJECT_TYPE;\n      Method ms = new Method(\"invokePrim\", returnType, argtypes);\n\n      GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC + ACC_FINAL, ms,\n          null,\n          // todo don't hardwire this\n          EXCEPTION_TYPES, cv);\n      gen.visitCode();\n\n      StringBuilder sb = new StringBuilder();\n      for (int i = 0; i < argLocals.count(); i++) {\n        if (sb.length() > 0) {\n          sb.append(\", \");\n        }\n        sb.append(printClass(argclasses[i]) + \" \"\n            + ((LocalBinding) argLocals.nth(i)).print());\n      }\n      emitSource(\"public final \" + printClass(retClass) + \" invokePrim(\"\n          + sb.toString() + \") {\");\n      tab();\n\n      if (hasException) {\n        emitSource(\"try {\");\n        tab();\n      }\n\n      Label loopLabel = gen.mark();\n      gen.visitLineNumber(line, loopLabel);\n      try {\n        Var.pushThreadBindings(RT.map(LOOP_LABEL, loopLabel, METHOD, this));\n        String b = emitBody(objx, gen, retClass, body);\n        if (b != null) {\n          emitSource(b);\n        }\n\n        Label end = gen.mark();\n        gen.visitLocalVariable(\"this\", \"Ljava/lang/Object;\", null, loopLabel,\n            end, 0);\n        for (ISeq lbs = argLocals.seq(); lbs != null; lbs = lbs.next()) {\n          LocalBinding lb = (LocalBinding) lbs.first();\n          gen.visitLocalVariable(lb.name, argtypes[lb.idx - 1].getDescriptor(),\n              null, loopLabel, end, lb.idx);\n        }\n      } finally {\n        Var.popThreadBindings();\n      }\n\n      if (hasException) {\n        untab();\n        emitSource(\"} catch (Exception ___e) {\");\n        tab();\n        emitSource(\"throw Util.sneakyThrow(___e);\");\n        untab();\n        emitSource(\"}\");\n      }\n\n      untab();\n      emitSource(\"}\");\n      gen.returnValue();\n      // gen.visitMaxs(1, 1);\n      gen.endMethod();\n\n      // generate the regular invoke, calling the prim method\n      Method m = new Method(getMethodName(), OBJECT_TYPE, getArgTypes());\n\n      gen = new GeneratorAdapter(ACC_PUBLIC, m, null,\n      // todo don't hardwire this\n          EXCEPTION_TYPES, cv);\n\n      gen.visitCode();\n      gen.loadThis();\n      sb = new StringBuilder();\n      StringBuilder args = new StringBuilder();\n      for (int i = 0; i < argtypes.length; i++) {\n        if (sb.length() > 0) {\n          sb.append(\", \");\n          args.append(\", \");\n        }\n        gen.loadArg(i);\n        String argname = ((LocalBinding) argLocals.nth(i)).print();\n        sb.append(\"Object \" + argname);\n        args.append(HostExpr.emitUnboxArg(fn, gen, argclasses[i], argname));\n      }\n      emitSource(\"public Object invoke(\" + sb.toString() + \") {\");\n      tab();\n\n      gen.invokeInterface(Type.getType(\"L\" + prim + \";\"), ms);\n      emitSource(\"return \"\n          + gen.box(getReturnType(), \"invokePrim(\" + args + \")\") + \";\");\n\n      untab();\n      emitSource(\"}\");\n      gen.returnValue();\n      // gen.visitMaxs(1, 1);\n      gen.endMethod();\n      // TODOCLJ\n    }\n\n    public void doEmit(ObjExpr fn, ClassVisitor cv) {\n      Method m = new Method(getMethodName(), getReturnType(), getArgTypes());\n\n      StringBuilder sb = new StringBuilder();\n      for (int i = 0; i < argLocals.count(); i++) {\n        if (sb.length() > 0) {\n          sb.append(\", \");\n        }\n        LocalBinding b = (LocalBinding) argLocals.get(i);\n        sb.append(printClass(getArgTypes()[i]) + \" \" + b.print());\n      }\n      emitSource(\"public \" + printClass(getReturnType()) + \" \"\n          + getMethodName() + \"(\" + sb.toString() + \") {\");\n      tab();\n\n      GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC, m, null,\n      // todo don't hardwire this\n          EXCEPTION_TYPES, cv);\n      gen.visitCode();\n\n      if (hasException) {\n        emitSource(\"try {\");\n        tab();\n      }\n\n      if (hasRecur) {\n        emitSource(\"while(true) {\");\n        tab();\n      }\n\n      Label loopLabel = gen.mark();\n      gen.visitLineNumber(line, loopLabel);\n      try {\n        Var.pushThreadBindings(RT.map(LOOP_LABEL, loopLabel, METHOD, this));\n\n        String r = body.emit(C.RETURN, fn, gen);\n        if (r != null) { // handle throw\n          emitSource(r);\n        }\n        Label end = gen.mark();\n\n        gen.visitLocalVariable(\"this\", \"Ljava/lang/Object;\", null, loopLabel,\n            end, 0);\n        for (ISeq lbs = argLocals.seq(); lbs != null; lbs = lbs.next()) {\n          LocalBinding lb = (LocalBinding) lbs.first();\n          gen.visitLocalVariable(lb.name, \"Ljava/lang/Object;\", null,\n              loopLabel, end, lb.idx);\n        }\n      } finally {\n        Var.popThreadBindings();\n      }\n\n      gen.returnValue();\n      // gen.visitMaxs(1, 1);\n      gen.endMethod();\n      if (hasRecur) {\n        untab();\n        emitSource(\"}\");\n      }\n      if (hasException) {\n        untab();\n        emitSource(\"} catch (Exception ___e) {\");\n        tab();\n        emitSource(\"throw Util.sneakyThrow(___e);\");\n        untab();\n        emitSource(\"}\");\n      }\n      untab();\n      emitSource(\"}\");\n    }\n\n    public final PersistentVector reqParms() {\n      return reqParms;\n    }\n\n    public final LocalBinding restParm() {\n      return restParm;\n    }\n\n    boolean isVariadic() {\n      return restParm != null;\n    }\n\n    int numParams() {\n      return reqParms.count() + (isVariadic() ? 1 : 0);\n    }\n\n    String getMethodName() {\n      return isVariadic() ? \"doInvoke\" : \"invoke\";\n    }\n\n    Type getReturnType() {\n      if (prim != null) // objx.isStatic)\n        return Type.getType(retClass);\n      return OBJECT_TYPE;\n    }\n\n    Type[] getArgTypes() {\n      if (isVariadic() && reqParms.count() == MAX_POSITIONAL_ARITY) {\n        Type[] ret = new Type[MAX_POSITIONAL_ARITY + 1];\n        for (int i = 0; i < MAX_POSITIONAL_ARITY + 1; i++)\n          ret[i] = OBJECT_TYPE;\n        return ret;\n      }\n      return ARG_TYPES[numParams()];\n    }\n\n    void emitClearLocals(GeneratorAdapter gen) {\n      // for(int i = 1; i < numParams() + 1; i++)\n      // {\n      // if(!localsUsedInCatchFinally.contains(i))\n      // {\n      // gen.visitInsn(Opcodes.ACONST_NULL);\n      // gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), i);\n      // }\n      // }\n      // for(int i = numParams() + 1; i < maxLocal + 1; i++)\n      // {\n      // if(!localsUsedInCatchFinally.contains(i))\n      // {\n      // LocalBinding b = (LocalBinding) RT.get(indexlocals, i);\n      // if(b == null || maybePrimitiveType(b.init) == null)\n      // {\n      // gen.visitInsn(Opcodes.ACONST_NULL);\n      // gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), i);\n      // }\n      // }\n      // }\n      // if(((FnExpr)objx).onceOnly)\n      // {\n      // objx.emitClearCloses(gen);\n      // }\n    }\n  }\n\n  abstract public static class ObjMethod {\n    // when closures are defined inside other closures,\n    // the closed over locals need to be propagated to the enclosing objx\n    public final ObjMethod parent;\n    boolean hasRecur;\n    boolean hasException;\n    // localbinding->localbinding\n    IPersistentMap locals = null;\n    // num->localbinding\n    IPersistentMap indexlocals = null;\n    Expr body = null;\n    ObjExpr objx;\n    PersistentVector argLocals;\n    int maxLocal = 0;\n    int line;\n    int column;\n    PersistentHashSet localsUsedInCatchFinally = PersistentHashSet.EMPTY;\n    protected IPersistentMap methodMeta;\n\n    public final IPersistentMap locals() {\n      return locals;\n    }\n\n    public final Expr body() {\n      return body;\n    }\n\n    public final ObjExpr objx() {\n      return objx;\n    }\n\n    public final PersistentVector argLocals() {\n      return argLocals;\n    }\n\n    public final int maxLocal() {\n      return maxLocal;\n    }\n\n    public final int line() {\n      return line;\n    }\n\n    public final int column() {\n      return column;\n    }\n\n    public ObjMethod(ObjExpr objx, ObjMethod parent) {\n      this.parent = parent;\n      this.objx = objx;\n    }\n\n    static String emitBody(ObjExpr objx, GeneratorAdapter gen, Class retClass,\n        Expr body) {\n      String ret;\n      MaybePrimitiveExpr be = (MaybePrimitiveExpr) body;\n      if (Util.isPrimitive(retClass) && be.canEmitPrimitive()) {\n        Class bc = maybePrimitiveType(be);\n        if (bc == retClass)\n          ret = be.emitUnboxed(C.RETURN, objx, gen);\n        else if (retClass == long.class && bc == int.class) {\n          ret = be.emitUnboxed(C.RETURN, objx, gen);\n          gen.visitInsn(I2L);\n        } else if (retClass == double.class && bc == float.class) {\n          ret = be.emitUnboxed(C.RETURN, objx, gen);\n          gen.visitInsn(F2D);\n        } else if (retClass == int.class && bc == long.class) {\n          Var.pushThreadBindings(RT.map(RETURN_TYPE, int.class));\n          ret = be.emitUnboxed(C.RETURN, objx, gen);\n          Var.popThreadBindings();\n          gen.invokeStatic(RT_TYPE, Method.getMethod(\"int intCast(long)\"));\n        } else if (retClass == float.class && bc == double.class) {\n          ret = be.emitUnboxed(C.RETURN, objx, gen);\n          gen.visitInsn(D2F);\n        } else\n          throw new IllegalArgumentException(\n              \"Mismatched primitive return, expected: \" + retClass + \", had: \"\n                  + be.getJavaClass());\n      } else {\n        Var.pushThreadBindings(RT.map(RETURN_TYPE, retClass));\n        ret = body.emit(C.RETURN, objx, gen);\n        Var.popThreadBindings();\n        if (retClass == void.class) {\n          gen.pop();\n        } else {\n          gen.unbox(Type.getType(retClass));\n        }\n      }\n      return ret;\n    }\n\n    abstract int numParams();\n\n    abstract String getMethodName();\n\n    abstract Type getReturnType();\n\n    abstract Type[] getArgTypes();\n\n    public void emit(ObjExpr fn, ClassVisitor cv) {\n      Method m = new Method(getMethodName(), getReturnType(), getArgTypes());\n      StringBuilder params = new StringBuilder();\n      int pos = 0;\n      for (ISeq lbs = argLocals.seq(); lbs != null; lbs = lbs.next()) {\n        LocalBinding lb = (LocalBinding) lbs.first();\n        if (params.length() > 0) {\n          params.append(\", \");\n        }\n        params.append(printClass(getArgTypes()[pos]) + \" \" + lb.name + lb.idx);\n        pos++;\n      }\n      emitSource(\"public \" + printClass(getReturnType()) + \" \"\n          + getMethodName() + \"(\" + params + \") {\");\n      tab();\n      if (hasException) {\n        emitSource(\"try {\");\n        tab();\n      }\n      if (hasRecur) {\n        emitSource(\"while(true) {\");\n        tab();\n      }\n      GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC, m, null,\n      // todo don't hardwire this\n          EXCEPTION_TYPES, cv);\n      gen.visitCode();\n\n      Label loopLabel = gen.mark();\n      gen.visitLineNumber(line, loopLabel);\n      try {\n        Var.pushThreadBindings(RT.map(LOOP_LABEL, loopLabel, METHOD, this));\n\n        emitSource(body.emit(C.RETURN, fn, gen));\n        Label end = gen.mark();\n        gen.visitLocalVariable(\"this\", \"Ljava/lang/Object;\", null, loopLabel,\n            end, 0);\n        for (ISeq lbs = argLocals.seq(); lbs != null; lbs = lbs.next()) {\n          LocalBinding lb = (LocalBinding) lbs.first();\n          gen.visitLocalVariable(lb.name, \"Ljava/lang/Object;\", null,\n              loopLabel, end, lb.idx);\n        }\n      } finally {\n        Var.popThreadBindings();\n      }\n\n      gen.returnValue();\n      // gen.visitMaxs(1, 1);\n      gen.endMethod();\n\n      if (hasRecur) {\n        untab();\n        emitSource(\"}\");\n      }\n      if (hasException) {\n        untab();\n        emitSource(\"} catch (Exception ___e) {\");\n        tab();\n        emitSource(\"throw Util.sneakyThrow(___e);\");\n        untab();\n        emitSource(\"}\");\n      }\n\n      untab();\n      emitSource(\"}\");\n    }\n\n    void emitClearLocals(GeneratorAdapter gen) {\n    }\n\n    void emitClearLocalsOld(GeneratorAdapter gen) {\n      for (int i = 0; i < argLocals.count(); i++) {\n        LocalBinding lb = (LocalBinding) argLocals.nth(i);\n        if (!localsUsedInCatchFinally.contains(lb.idx)\n            && lb.getPrimitiveType() == null) {\n          gen.visitInsn(Opcodes.ACONST_NULL);\n          gen.storeArg(lb.idx - 1);\n        }\n\n      }\n      // for(int i = 1; i < numParams() + 1; i++)\n      // {\n      // if(!localsUsedInCatchFinally.contains(i))\n      // {\n      // gen.visitInsn(Opcodes.ACONST_NULL);\n      // gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), i);\n      // }\n      // }\n      for (int i = numParams() + 1; i < maxLocal + 1; i++) {\n        if (!localsUsedInCatchFinally.contains(i)) {\n          LocalBinding b = (LocalBinding) RT.get(indexlocals, i);\n          if (b == null || maybePrimitiveType(b.init) == null) {\n            gen.visitInsn(Opcodes.ACONST_NULL);\n            gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), i);\n          }\n        }\n      }\n    }\n  }\n\n  public static class LocalBinding {\n    public final Symbol sym;\n    public final Symbol tag;\n    public Expr init;\n    public final int idx;\n    public final String name;\n    public final boolean isArg;\n    public final PathNode clearPathRoot;\n    public boolean canBeCleared = !RT\n        .booleanCast(getCompilerOption(disableLocalsClearingKey));\n    public boolean recurMistmatch = false;\n\n    public LocalBinding(int num, Symbol sym, Symbol tag, Expr init,\n        boolean isArg, PathNode clearPathRoot) {\n      if (maybePrimitiveType(init) != null && tag != null)\n        throw new UnsupportedOperationException(\n            \"Can't type hint a local with a primitive initializer\");\n      this.idx = num;\n      this.sym = sym;\n      this.tag = tag;\n      this.init = init;\n      this.isArg = isArg;\n      this.clearPathRoot = clearPathRoot;\n      name = munge(sym.name);\n    }\n\n    public boolean hasJavaClass() {\n      if (init != null && init.hasJavaClass()\n          && Util.isPrimitive(init.getJavaClass())\n          && !(init instanceof MaybePrimitiveExpr))\n        return false;\n      return tag != null || (init != null && init.hasJavaClass());\n    }\n\n    public Class getJavaClass() {\n      return tag != null ? HostExpr.tagToClass(tag) : init.getJavaClass();\n    }\n\n    public Class getPrimitiveType() {\n      return maybePrimitiveType(init);\n    }\n\n    public String print() {\n      if (idx == -1) {\n        return name;\n      } else {\n        return name + idx;\n      }\n    }\n  }\n\n  public static class LocalBindingExpr implements Expr, MaybePrimitiveExpr,\n      AssignableExpr {\n    public final LocalBinding b;\n    public final Symbol tag;\n\n    public final PathNode clearPath;\n    public final PathNode clearRoot;\n    public boolean shouldClear = false;\n\n    public LocalBindingExpr(LocalBinding b, Symbol tag) {\n      if (b.getPrimitiveType() != null && tag != null)\n        throw new UnsupportedOperationException(\n            \"Can't type hint a primitive local\");\n      this.b = b;\n      this.tag = tag;\n\n      this.clearPath = (PathNode) CLEAR_PATH.get();\n      this.clearRoot = (PathNode) CLEAR_ROOT.get();\n      IPersistentCollection sites = (IPersistentCollection) RT.get(\n          CLEAR_SITES.get(), b);\n\n      if (b.idx > 0) {\n        // Object dummy;\n\n        if (sites != null) {\n          for (ISeq s = sites.seq(); s != null; s = s.next()) {\n            LocalBindingExpr o = (LocalBindingExpr) s.first();\n            PathNode common = commonPath(clearPath, o.clearPath);\n            if (common != null && common.type == PATHTYPE.PATH)\n              o.shouldClear = false;\n            // else\n            // dummy = null;\n          }\n        }\n\n        if (clearRoot == b.clearPathRoot) {\n          this.shouldClear = true;\n          sites = RT.conj(sites, this);\n          CLEAR_SITES.set(RT.assoc(CLEAR_SITES.get(), b, sites));\n        }\n        // else\n        // dummy = null;\n      }\n    }\n\n    public Object eval() {\n      throw new UnsupportedOperationException(\"Can't eval locals\");\n    }\n\n    public boolean canEmitPrimitive() {\n      return b.getPrimitiveType() != null;\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      return wrap(context, objx.emitUnboxedLocal(gen, b));\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      if (context != C.STATEMENT)\n        return wrap(context, objx.emitLocal(gen, b, shouldClear));\n      return \"\";\n    }\n\n    public Object evalAssign(Expr val) {\n      throw new UnsupportedOperationException(\"Can't eval locals\");\n    }\n\n    public String emitAssign(C context, ObjExpr objx, GeneratorAdapter gen,\n        Expr val) {\n      objx.emitAssignLocal(gen, b, val);\n      if (context != C.STATEMENT)\n        return objx.emitLocal(gen, b, false);\n      return \"\";\n    }\n\n    public boolean hasJavaClass() {\n      return tag != null || b.hasJavaClass();\n    }\n\n    public Class getJavaClass() {\n      if (tag != null)\n        return HostExpr.tagToClass(tag);\n      return b.getJavaClass();\n    }\n\n  }\n\n  public static class BodyExpr implements Expr, MaybePrimitiveExpr {\n    PersistentVector exprs;\n\n    public final PersistentVector exprs() {\n      return exprs;\n    }\n\n    public BodyExpr(PersistentVector exprs) {\n      this.exprs = exprs;\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object frms) {\n        ISeq forms = (ISeq) frms;\n        if (Util.equals(RT.first(forms), DO))\n          forms = RT.next(forms);\n        PersistentVector exprs = PersistentVector.EMPTY;\n        for (; forms != null; forms = forms.next()) {\n          Expr e = (context != C.EVAL && (context == C.STATEMENT || forms\n              .next() != null)) ? analyze(C.STATEMENT, forms.first())\n              : analyze(context, forms.first());\n          exprs = exprs.cons(e);\n        }\n        if (exprs.count() == 0)\n          exprs = exprs.cons(NIL_EXPR);\n        return new BodyExpr(exprs);\n      }\n    }\n\n    public Object eval() {\n      Object ret = null;\n      for (Object o : exprs) {\n        Expr e = (Expr) o;\n        ret = e.eval();\n      }\n      return ret;\n    }\n\n    public boolean canEmitPrimitive() {\n      return lastExpr() instanceof MaybePrimitiveExpr\n          && ((MaybePrimitiveExpr) lastExpr()).canEmitPrimitive();\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      for (int i = 0; i < exprs.count() - 1; i++) {\n        Expr e = (Expr) exprs.nth(i);\n        String emit = e.emit(C.STATEMENT, objx, gen);\n        if (emit == null) {\n          return null;\n        }\n        emitSource(emit);\n      }\n      MaybePrimitiveExpr last = (MaybePrimitiveExpr) exprs\n          .nth(exprs.count() - 1);\n      return last.emitUnboxed(context, objx, gen);\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      for (int i = 0; i < exprs.count() - 1; i++) {\n        Expr e = (Expr) exprs.nth(i);\n        String emit = e.emit(C.STATEMENT, objx, gen);\n        if (emit == null) {\n          return null;\n        }\n        emitSource(emit);\n      }\n      Expr last = (Expr) exprs.nth(exprs.count() - 1);\n      return last.emit(context, objx, gen);\n    }\n\n    public boolean hasJavaClass() {\n      return lastExpr().hasJavaClass();\n    }\n\n    public Class getJavaClass() {\n      return lastExpr().getJavaClass();\n    }\n\n    private Expr lastExpr() {\n      return (Expr) exprs.nth(exprs.count() - 1);\n    }\n  }\n\n  public static class BindingInit {\n    LocalBinding binding;\n    Expr init;\n\n    public final LocalBinding binding() {\n      return binding;\n    }\n\n    public final Expr init() {\n      return init;\n    }\n\n    public BindingInit(LocalBinding binding, Expr init) {\n      this.binding = binding;\n      this.init = init;\n    }\n  }\n\n  public static class LetFnExpr implements Expr {\n    public final PersistentVector bindingInits;\n    public final Expr body;\n\n    public LetFnExpr(PersistentVector bindingInits, Expr body) {\n      this.bindingInits = bindingInits;\n      this.body = body;\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object frm) {\n        ISeq form = (ISeq) frm;\n        // (letfns* [var (fn [args] body) ...] body...)\n        if (!(RT.second(form) instanceof IPersistentVector))\n          throw new IllegalArgumentException(\n              \"Bad binding form, expected vector\");\n\n        IPersistentVector bindings = (IPersistentVector) RT.second(form);\n        if ((bindings.count() % 2) != 0)\n          throw new IllegalArgumentException(\n              \"Bad binding form, expected matched symbol expression pairs\");\n\n        ISeq body = RT.next(RT.next(form));\n\n        if (context == C.EVAL)\n          return analyze(context,\n              RT.list(RT.list(FNONCE, PersistentVector.EMPTY, form)));\n\n        IPersistentMap dynamicBindings = RT.map(LOCAL_ENV, LOCAL_ENV.deref()\n        // ,NEXT_LOCAL_NUM, NEXT_LOCAL_NUM.deref()\n            );\n\n        try {\n          Var.pushThreadBindings(dynamicBindings);\n\n          // pre-seed env (like Lisp labels)\n          PersistentVector lbs = PersistentVector.EMPTY;\n          for (int i = 0; i < bindings.count(); i += 2) {\n            if (!(bindings.nth(i) instanceof Symbol))\n              throw new IllegalArgumentException(\n                  \"Bad binding form, expected symbol, got: \" + bindings.nth(i));\n            Symbol sym = (Symbol) bindings.nth(i);\n            if (sym.getNamespace() != null)\n              throw Util.runtimeException(\"Can't let qualified name: \" + sym);\n            LocalBinding lb = registerLocal(sym, tagOf(sym), null, false);\n            lb.canBeCleared = false;\n            lbs = lbs.cons(lb);\n          }\n          PersistentVector bindingInits = PersistentVector.EMPTY;\n          for (int i = 0; i < bindings.count(); i += 2) {\n            Symbol sym = (Symbol) bindings.nth(i);\n            Expr init = analyze(C.EXPRESSION, bindings.nth(i + 1), sym.name);\n            LocalBinding lb = (LocalBinding) lbs.nth(i / 2);\n            lb.init = init;\n            BindingInit bi = new BindingInit(lb, init);\n            bindingInits = bindingInits.cons(bi);\n          }\n          return new LetFnExpr(bindingInits, (new BodyExpr.Parser()).parse(\n              context, body));\n        } finally {\n          Var.popThreadBindings();\n        }\n      }\n    }\n\n    public Object eval() {\n      throw new UnsupportedOperationException(\"Can't eval letfns\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      for (int i = 0; i < bindingInits.count(); i++) {\n        BindingInit bi = (BindingInit) bindingInits.nth(i);\n        gen.visitInsn(Opcodes.ACONST_NULL);\n        gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), bi.binding.idx);\n      }\n\n      String r = registerTemp();\n      if (context == C.EXPRESSION) {\n        emitSource(\"Object \" + r + \";\");\n      }\n\n      IPersistentSet lbset = PersistentHashSet.EMPTY;\n\n      for (int i = 0; i < bindingInits.count(); i++) {\n        BindingInit bi = (BindingInit) bindingInits.nth(i);\n        lbset = (IPersistentSet) lbset.cons(bi.binding);\n        String val = bi.init.emit(C.EXPRESSION, objx, gen);\n        gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), bi.binding.idx);\n        emitSource(\"IFn \" + bi.binding.print() + \" = \" + val + \";\");\n      }\n\n      for (int i = 0; i < bindingInits.count(); i++) {\n        BindingInit bi = (BindingInit) bindingInits.nth(i);\n        ObjExpr fe = (ObjExpr) bi.init;\n        gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ILOAD), bi.binding.idx);\n        fe.emitLetFnInits(gen, objx, lbset);\n      }\n\n      Label loopLabel = gen.mark();\n\n      emitAssigRet(context, r, body.emit(context, objx, gen));\n\n      Label end = gen.mark();\n      // gen.visitLocalVariable(\"this\", \"Ljava/lang/Object;\", null, loopLabel,\n      // end, 0);\n      for (ISeq bis = bindingInits.seq(); bis != null; bis = bis.next()) {\n        BindingInit bi = (BindingInit) bis.first();\n        String lname = bi.binding.name;\n        if (lname.endsWith(\"__auto__\"))\n          lname += RT.nextID();\n        Class primc = maybePrimitiveType(bi.init);\n        if (primc != null)\n          gen.visitLocalVariable(lname, Type.getDescriptor(primc), null,\n              loopLabel, end, bi.binding.idx);\n        else\n          gen.visitLocalVariable(lname, \"Ljava/lang/Object;\", null, loopLabel,\n              end, bi.binding.idx);\n      }\n\n      return (C.EXPRESSION == context ? r : \"\");\n    }\n\n    public boolean hasJavaClass() {\n      return body.hasJavaClass();\n    }\n\n    public Class getJavaClass() {\n      return body.getJavaClass();\n    }\n  }\n\n  public static class LetExpr implements Expr, MaybePrimitiveExpr {\n    public final PersistentVector bindingInits;\n    public final Expr body;\n    public final boolean isLoop;\n\n    public LetExpr(PersistentVector bindingInits, Expr body, boolean isLoop) {\n      this.bindingInits = bindingInits;\n      this.body = body;\n      this.isLoop = isLoop;\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object frm) {\n        ISeq form = (ISeq) frm;\n        // (let [var val var2 val2 ...] body...)\n        boolean isLoop = RT.first(form).equals(LOOP);\n        if (!(RT.second(form) instanceof IPersistentVector))\n          throw new IllegalArgumentException(\n              \"Bad binding form, expected vector\");\n\n        IPersistentVector bindings = (IPersistentVector) RT.second(form);\n        if ((bindings.count() % 2) != 0)\n          throw new IllegalArgumentException(\n              \"Bad binding form, expected matched symbol expression pairs\");\n\n        ISeq body = RT.next(RT.next(form));\n\n        if (context == C.EVAL || (context == C.EXPRESSION && isLoop))\n          return analyze(context,\n              RT.list(RT.list(FNONCE, PersistentVector.EMPTY, form)));\n\n        ObjMethod method = (ObjMethod) METHOD.deref();\n        boolean methodHasRecur = method.hasRecur;\n        IPersistentMap backupMethodLocals = method.locals;\n        IPersistentMap backupMethodIndexLocals = method.indexlocals;\n        IPersistentVector recurMismatches = PersistentVector.EMPTY;\n        for (int i = 0; i < bindings.count() / 2; i++) {\n          recurMismatches = recurMismatches.cons(RT.F);\n        }\n\n        // may repeat once for each binding with a mismatch, return breaks\n        while (true) {\n          IPersistentMap dynamicBindings = RT.map(LOCAL_ENV, LOCAL_ENV.deref()\n          // ,NEXT_LOCAL_NUM, NEXT_LOCAL_NUM.deref()\n              );\n          method.locals = backupMethodLocals;\n          method.indexlocals = backupMethodIndexLocals;\n\n          PathNode looproot = new PathNode(PATHTYPE.PATH,\n              (PathNode) CLEAR_PATH.get());\n          PathNode clearroot = new PathNode(PATHTYPE.PATH, looproot);\n          PathNode clearpath = new PathNode(PATHTYPE.PATH, looproot);\n\n          if (isLoop)\n            dynamicBindings = dynamicBindings.assoc(LOOP_LOCALS, null);\n\n          try {\n            Var.pushThreadBindings(dynamicBindings);\n\n            PersistentVector bindingInits = PersistentVector.EMPTY;\n            PersistentVector loopLocals = PersistentVector.EMPTY;\n            for (int i = 0; i < bindings.count(); i += 2) {\n              if (!(bindings.nth(i) instanceof Symbol))\n                throw new IllegalArgumentException(\n                    \"Bad binding form, expected symbol, got: \"\n                        + bindings.nth(i));\n              Symbol sym = (Symbol) bindings.nth(i);\n              if (sym.getNamespace() != null)\n                throw Util.runtimeException(\"Can't let qualified name: \" + sym);\n              Expr init = analyze(C.EXPRESSION, bindings.nth(i + 1), sym.name);\n              if (isLoop) {\n                if (recurMismatches != null\n                    && RT.booleanCast(recurMismatches.nth(i / 2))) {\n                  init = new StaticMethodExpr(\"\", 0, 0, null, RT.class, \"box\",\n                      RT.vector(init));\n                  if (RT.booleanCast(RT.WARN_ON_REFLECTION.deref()))\n                    RT.errPrintWriter().println(\"Auto-boxing loop arg: \" + sym);\n                } else if (maybePrimitiveType(init) == int.class)\n                  init = new StaticMethodExpr(\"\", 0, 0, null, RT.class,\n                      \"longCast\", RT.vector(init));\n                else if (maybePrimitiveType(init) == float.class)\n                  init = new StaticMethodExpr(\"\", 0, 0, null, RT.class,\n                      \"doubleCast\", RT.vector(init));\n              }\n              // sequential enhancement of env (like Lisp let*)\n\n              try {\n                if (isLoop) {\n                  Var.pushThreadBindings(RT.map(CLEAR_PATH, clearpath,\n                      CLEAR_ROOT, clearroot, NO_RECUR, null));\n                }\n                LocalBinding lb = registerLocal(sym, tagOf(sym), init, false);\n                BindingInit bi = new BindingInit(lb, init);\n                bindingInits = bindingInits.cons(bi);\n                if (isLoop)\n                  loopLocals = loopLocals.cons(lb);\n              } finally {\n                if (isLoop)\n                  Var.popThreadBindings();\n              }\n            }\n            if (isLoop)\n              LOOP_LOCALS.set(loopLocals);\n            Expr bodyExpr;\n            boolean moreMismatches = false;\n            try {\n              if (isLoop) {\n                Var.pushThreadBindings(RT.map(CLEAR_PATH, clearpath,\n                    CLEAR_ROOT, clearroot, NO_RECUR, null));\n              }\n              bodyExpr = (new BodyExpr.Parser()).parse(isLoop ? C.RETURN\n                  : context, body);\n            } finally {\n              if (isLoop) {\n                Var.popThreadBindings();\n                for (int i = 0; i < loopLocals.count(); i++) {\n                  LocalBinding lb = (LocalBinding) loopLocals.nth(i);\n                  if (lb.recurMistmatch) {\n                    recurMismatches = (IPersistentVector) recurMismatches\n                        .assoc(i, RT.T);\n                    moreMismatches = true;\n                  }\n                }\n              }\n            }\n            if (!moreMismatches)\n              return new LetExpr(bindingInits, bodyExpr, isLoop);\n          } finally {\n            if (isLoop) {\n              // Loop doesn't affect hasRecur\n              method.hasRecur = methodHasRecur;\n            }\n            Var.popThreadBindings();\n          }\n        }\n      }\n    }\n\n    public Object eval() {\n      throw new UnsupportedOperationException(\"Can't eval let/loop\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      return doEmit(context, objx, gen, false);\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      return doEmit(context, objx, gen, true);\n    }\n\n    public String doEmit(C context, ObjExpr objx, GeneratorAdapter gen,\n        boolean emitUnboxed) {\n\n      String r = null;\n      if (context == C.EXPRESSION) {\n        r = registerTemp();\n        emitSource(\"Object \" + r + \" = null;\");\n      }\n      if (!emitUnboxed) {\n        emitSource(\"{\");\n        tab();\n      }\n\n      HashMap<BindingInit, Label> bindingLabels = new HashMap();\n      for (int i = 0; i < bindingInits.count(); i++) {\n        BindingInit bi = (BindingInit) bindingInits.nth(i);\n        Class primc = maybePrimitiveType(bi.init);\n        String val;\n        boolean typed = true;\n        if (primc != null) {\n          val = ((MaybePrimitiveExpr) bi.init).emitUnboxed(C.EXPRESSION, objx,\n              gen);\n          gen.visitVarInsn(Type.getType(primc).getOpcode(Opcodes.ISTORE),\n              bi.binding.idx);\n          emitSource((typed ? printClass(primc) + \" \" : \"\")\n              + bi.binding.print() + \" = \" + val + \";\");\n        } else {\n          val = bi.init.emit(C.EXPRESSION, objx, gen);\n          gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE),\n              bi.binding.idx);\n          emitSource((typed ? \"Object \" : \"\") + bi.binding.print() + \" = \"\n              + val + \";\");\n        }\n        bindingLabels.put(bi, gen.mark());\n      }\n\n      if (isLoop) {\n        emitSource(\"while(true) {\");\n        tab();\n      }\n\n      Label loopLabel = gen.mark();\n      String v;\n      if (isLoop) {\n        try {\n          Var.pushThreadBindings(RT.map(LOOP_LABEL, loopLabel));\n          if (emitUnboxed) {\n            v = ((MaybePrimitiveExpr) body).emitUnboxed(context, objx, gen);\n          } else {\n            v = body.emit(context, objx, gen);\n          }\n        } finally {\n          Var.popThreadBindings();\n        }\n      } else {\n        if (emitUnboxed) {\n          v = ((MaybePrimitiveExpr) body).emitUnboxed(context, objx, gen);\n        } else {\n          v = body.emit(context, objx, gen);\n        }\n      }\n      if (v != null) {\n        if (emitUnboxed) {\n          r = v;\n        } else {\n          emitAssigRet(context, r, v);\n        }\n      } else if (emitUnboxed) {\n        r = \"null\";\n      }\n      Label end = gen.mark();\n      // gen.visitLocalVariable(\"this\", \"Ljava/lang/Object;\", null, loopLabel,\n      // end, 0);\n      for (ISeq bis = bindingInits.seq(); bis != null; bis = bis.next()) {\n        BindingInit bi = (BindingInit) bis.first();\n        String lname = bi.binding.name;\n        if (lname.endsWith(\"__auto__\"))\n          lname += RT.nextID();\n        Class primc = maybePrimitiveType(bi.init);\n        if (primc != null)\n          gen.visitLocalVariable(lname, Type.getDescriptor(primc), null,\n              bindingLabels.get(bi), end, bi.binding.idx);\n        else\n          gen.visitLocalVariable(lname, \"Ljava/lang/Object;\", null,\n              bindingLabels.get(bi), end, bi.binding.idx);\n      }\n      if (isLoop) {\n        if (C.RETURN != context) {\n          emitSource(\"break;\");\n        }\n        untab();\n        emitSource(\"}\");\n      }\n      if (!emitUnboxed) {\n        untab();\n        emitSource(\"}\");\n      }\n\n      return (context == C.EXPRESSION || emitUnboxed ? r : (v == null ? null\n          : \"\"));\n    }\n\n    public boolean hasJavaClass() {\n      return body.hasJavaClass();\n    }\n\n    public Class getJavaClass() {\n      return body.getJavaClass();\n    }\n\n    public boolean canEmitPrimitive() {\n      return body instanceof MaybePrimitiveExpr\n          && ((MaybePrimitiveExpr) body).canEmitPrimitive();\n    }\n\n  }\n\n  public static class RecurExpr implements Expr, MaybePrimitiveExpr {\n    public final IPersistentVector args;\n    public final IPersistentVector loopLocals;\n    final int line;\n    final int column;\n    final String source;\n\n    public RecurExpr(IPersistentVector loopLocals, IPersistentVector args,\n        int line, int column, String source) {\n      this.loopLocals = loopLocals;\n      this.args = args;\n      this.line = line;\n      this.column = column;\n      this.source = source;\n    }\n\n    public Object eval() {\n      throw new UnsupportedOperationException(\"Can't eval recur\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      Label loopLabel = (Label) LOOP_LABEL.deref();\n      String val = null;\n      if (loopLabel == null)\n        throw new IllegalStateException();\n\n      Expr last = null;\n      ArrayList<String> auxs = new ArrayList<String>();\n      for (int i = 0; i < loopLocals.count(); i++) {\n        LocalBinding lb = (LocalBinding) loopLocals.nth(i);\n        Expr arg = (Expr) args.nth(i);\n        last = arg;\n        if (lb.getPrimitiveType() != null) {\n          Class primc = lb.getPrimitiveType();\n          final Class pc = maybePrimitiveType(arg);\n          if (pc == primc)\n            val = ((MaybePrimitiveExpr) arg).emitUnboxed(C.EXPRESSION, objx,\n                gen);\n          else if (primc == long.class && pc == int.class) {\n            val = ((MaybePrimitiveExpr) arg).emitUnboxed(C.EXPRESSION, objx,\n                gen);\n            gen.visitInsn(I2L);\n          } else if (primc == double.class && pc == float.class) {\n            val = ((MaybePrimitiveExpr) arg).emitUnboxed(C.EXPRESSION, objx,\n                gen);\n            gen.visitInsn(F2D);\n          } else if (primc == int.class && pc == long.class) {\n            val = ((MaybePrimitiveExpr) arg).emitUnboxed(C.EXPRESSION, objx,\n                gen);\n            gen.invokeStatic(RT_TYPE, Method.getMethod(\"int intCast(long)\"));\n            val = \"RT.intCast(\" + val + \")\";\n          } else if (primc == float.class && pc == double.class) {\n            val = ((MaybePrimitiveExpr) arg).emitUnboxed(C.EXPRESSION, objx,\n                gen);\n            gen.visitInsn(D2F);\n          } else {\n            throw new IllegalArgumentException(\n                \" recur arg for primitive local: \"\n                    + lb.name\n                    + \" is not matching primitive, had: \"\n                    + (arg.hasJavaClass() ? arg.getJavaClass().getName()\n                        : \"Object\") + \", needed: \" + primc.getName());\n          }\n        } else {\n          val = arg.emit(C.EXPRESSION, objx, gen);\n        }\n        if (!lb.print().equals(val)) {\n          Class type = lb.getPrimitiveType();\n          emitSource(printClass(type == null ? Object.class : type) + \" \"\n              + lb.print() + \"___aux = \" + val + \";\");\n          auxs.add(lb.print());\n        }\n      }\n\n      for (String a : auxs) {\n        emitSource(a + \" = \" + a + \"___aux;\");\n      }\n\n      for (int i = loopLocals.count() - 1; i >= 0; i--) {\n        LocalBinding lb = (LocalBinding) loopLocals.nth(i);\n\n        Class primc = lb.getPrimitiveType();\n        if (lb.isArg)\n          gen.storeArg(lb.idx - (objx.isStatic ? 0 : 1));\n        else {\n          if (primc != null)\n            gen.visitVarInsn(Type.getType(primc).getOpcode(Opcodes.ISTORE),\n                lb.idx);\n          else\n            gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), lb.idx);\n        }\n      }\n\n      gen.goTo(loopLabel);\n      return \"continue;\";\n    }\n\n    public boolean hasJavaClass() {\n      return true;\n    }\n\n    public Class getJavaClass() {\n      return RECUR_CLASS;\n    }\n\n    static class Parser implements IParser {\n      public Expr parse(C context, Object frm) {\n        int line = lineDeref();\n        int column = columnDeref();\n        String source = (String) SOURCE.deref();\n\n        ISeq form = (ISeq) frm;\n        IPersistentVector loopLocals = (IPersistentVector) LOOP_LOCALS.deref();\n        if (context != C.RETURN || loopLocals == null)\n          throw new UnsupportedOperationException(\n              \"Can only recur from tail position\");\n        if (NO_RECUR.deref() != null)\n          throw new UnsupportedOperationException(\"Cannot recur across try\");\n\n        ObjMethod objmethod = (ObjMethod) METHOD.deref();\n        objmethod.hasRecur = true;\n\n        PersistentVector args = PersistentVector.EMPTY;\n        for (ISeq s = RT.seq(form.next()); s != null; s = s.next()) {\n          args = args.cons(analyze(C.EXPRESSION, s.first()));\n        }\n        if (args.count() != loopLocals.count())\n          throw new IllegalArgumentException(String.format(\n              \"Mismatched argument count to recur, expected: %d args, got: %d\",\n              loopLocals.count(), args.count()));\n        for (int i = 0; i < loopLocals.count(); i++) {\n          LocalBinding lb = (LocalBinding) loopLocals.nth(i);\n          Class primc = lb.getPrimitiveType();\n          if (primc != null) {\n            boolean mismatch = false;\n            final Class pc = maybePrimitiveType((Expr) args.nth(i));\n            if (primc == long.class) {\n              if (!(pc == long.class || pc == int.class || pc == short.class\n                  || pc == char.class || pc == byte.class))\n                mismatch = true;\n            } else if (primc == double.class) {\n              if (!(pc == double.class || pc == float.class))\n                mismatch = true;\n            }\n            if (mismatch) {\n              lb.recurMistmatch = true;\n              if (RT.booleanCast(RT.WARN_ON_REFLECTION.deref()))\n                RT.errPrintWriter().println(\n                    source + \":\" + line + \" recur arg for primitive local: \"\n                        + lb.name + \" is not matching primitive, had: \"\n                        + (pc != null ? pc.getName() : \"Object\") + \", needed: \"\n                        + primc.getName());\n            }\n          }\n        }\n        return new RecurExpr(loopLocals, args, line, column, source);\n      }\n    }\n\n    public boolean canEmitPrimitive() {\n      return true;\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      return emit(context, objx, gen);\n    }\n  }\n\n  private static LocalBinding registerLocal(Symbol sym, Symbol tag, Expr init,\n      boolean isArg) {\n    int num = getAndIncLocalNum();\n    LocalBinding b = new LocalBinding(num, sym, tag, init, isArg,\n        clearPathRoot());\n    IPersistentMap localsMap = (IPersistentMap) LOCAL_ENV.deref();\n    LOCAL_ENV.set(RT.assoc(localsMap, b.sym, b));\n    ObjMethod method = (ObjMethod) METHOD.deref();\n    method.locals = (IPersistentMap) RT.assoc(method.locals, b, b);\n    method.indexlocals = (IPersistentMap) RT.assoc(method.indexlocals, num, b);\n    return b;\n  }\n\n  static int temp = 0;\n\n  private static String registerTemp() {\n    return \"__r\" + temp++;\n  }\n\n  private static int getAndIncLocalNum() {\n    int num = ((Number) NEXT_LOCAL_NUM.deref()).intValue();\n    ObjMethod m = (ObjMethod) METHOD.deref();\n    if (num > m.maxLocal)\n      m.maxLocal = num;\n    NEXT_LOCAL_NUM.set(num + 1);\n    return num;\n  }\n\n  public static Expr analyze(C context, Object form) {\n    return analyze(context, form, null);\n  }\n\n  private static Expr analyze(C context, Object form, String name) {\n    return analyze(context, form, name, null);\n  }\n\n  private static Expr analyze(C context, Object form, String name,\n      Object defContext) {\n    // todo symbol macro expansion?\n    try {\n      if (form instanceof LazySeq) {\n        form = RT.seq(form);\n        if (form == null)\n          form = PersistentList.EMPTY;\n      }\n      if (form == null)\n        return NIL_EXPR;\n      else if (form == Boolean.TRUE)\n        return TRUE_EXPR;\n      else if (form == Boolean.FALSE)\n        return FALSE_EXPR;\n      Class fclass = form.getClass();\n      if (fclass == Symbol.class)\n        return analyzeSymbol((Symbol) form);\n      else if (fclass == Keyword.class)\n        return registerKeyword((Keyword) form);\n      else if (form instanceof Number)\n        return NumberExpr.parse((Number) form);\n      else if (fclass == String.class)\n        return new StringExpr(((String) form).intern());\n      // else if(fclass == Character.class)\n      // return new CharExpr((Character) form);\n      else if (form instanceof IPersistentCollection\n          && ((IPersistentCollection) form).count() == 0) {\n        Expr ret = new EmptyExpr(form);\n        if (RT.meta(form) != null)\n          ret = new MetaExpr(ret, MapExpr.parse(context == C.EVAL ? context\n              : C.EXPRESSION, ((IObj) form).meta()));\n        return ret;\n      } else if (form instanceof ISeq)\n        return analyzeSeq(context, (ISeq) form, name, defContext);\n      else if (form instanceof IPersistentVector)\n        return VectorExpr.parse(context, (IPersistentVector) form);\n      else if (form instanceof IRecord)\n        return new ConstantExpr(form);\n      else if (form instanceof IType)\n        return new ConstantExpr(form);\n      else if (form instanceof IPersistentMap)\n        return MapExpr.parse(context, (IPersistentMap) form);\n      else if (form instanceof IPersistentSet)\n        return SetExpr.parse(context, (IPersistentSet) form);\n\n      // else\n      // throw new UnsupportedOperationException();\n      return new ConstantExpr(form);\n    } catch (Throwable e) {\n      if (!(e instanceof CompilerException))\n        throw new CompilerException((String) SOURCE_PATH.deref(), lineDeref(),\n            columnDeref(), e);\n      else\n        throw (CompilerException) e;\n    }\n  }\n\n  static public class CompilerException extends RuntimeException {\n    final public String source;\n\n    final public int line;\n\n    public CompilerException(String source, int line, int column,\n        Throwable cause) {\n      super(errorMsg(source, line, column, cause.toString()), cause);\n      this.source = source;\n      this.line = line;\n    }\n\n    public String toString() {\n      return getMessage();\n    }\n  }\n\n  static public Var isMacro(Object op) {\n    // no local macros for now\n    if (op instanceof Symbol && referenceLocal((Symbol) op) != null)\n      return null;\n    if (op instanceof Symbol || op instanceof Var) {\n      Var v = (op instanceof Var) ? (Var) op : lookupVar((Symbol) op, false,\n          false);\n      if (v != null && v.isMacro()) {\n        if (v.ns != currentNS() && !v.isPublic())\n          throw new IllegalStateException(\"var: \" + v + \" is not public\");\n        return v;\n      }\n    }\n    return null;\n  }\n\n  static public IFn isInline(Object op, int arity) {\n    // no local inlines for now\n    if (op instanceof Symbol && referenceLocal((Symbol) op) != null)\n      return null;\n    if (op instanceof Symbol || op instanceof Var) {\n      Var v = (op instanceof Var) ? (Var) op : lookupVar((Symbol) op, false);\n      if (v != null) {\n        if (v.ns != currentNS() && !v.isPublic())\n          throw new IllegalStateException(\"var: \" + v + \" is not public\");\n        IFn ret = (IFn) RT.get(v.meta(), inlineKey);\n        if (ret != null) {\n          IFn arityPred = (IFn) RT.get(v.meta(), inlineAritiesKey);\n          if (arityPred == null || RT.booleanCast(arityPred.invoke(arity)))\n            return ret;\n        }\n      }\n    }\n    return null;\n  }\n\n  public static boolean namesStaticMember(Symbol sym) {\n    return sym.ns != null && namespaceFor(sym) == null;\n  }\n\n  public static Object preserveTag(ISeq src, Object dst) {\n    Symbol tag = tagOf(src);\n    if (tag != null && dst instanceof IObj) {\n      IPersistentMap meta = RT.meta(dst);\n      return ((IObj) dst).withMeta((IPersistentMap) RT.assoc(meta, RT.TAG_KEY,\n          tag));\n    }\n    return dst;\n  }\n\n  public static Object macroexpand1(Object x) {\n    if (x instanceof ISeq) {\n      ISeq form = (ISeq) x;\n      Object op = RT.first(form);\n      if (isSpecial(op))\n        return x;\n      // macro expansion\n      Var v = isMacro(op);\n      if (v != null) {\n        try {\n          return v\n              .applyTo(RT.cons(form, RT.cons(LOCAL_ENV.get(), form.next())));\n        } catch (ArityException e) {\n          // hide the 2 extra params for a macro\n          throw new ArityException(e.actual - 2, e.name);\n        }\n      } else {\n        if (op instanceof Symbol) {\n          Symbol sym = (Symbol) op;\n          String sname = sym.name;\n          // (.substring s 2 5) => (. s substring 2 5)\n          if (sym.name.charAt(0) == '.') {\n            if (RT.length(form) < 2)\n              throw new IllegalArgumentException(\n                  \"Malformed member expression, expecting (.member target ...)\");\n            Symbol meth = Symbol.intern(sname.substring(1));\n            Object target = RT.second(form);\n            if (HostExpr.maybeClass(target, false) != null) {\n              target = ((IObj) RT.list(IDENTITY, target)).withMeta(RT.map(\n                  RT.TAG_KEY, CLASS));\n            }\n            return preserveTag(form,\n                RT.listStar(DOT, target, meth, form.next().next()));\n          } else if (namesStaticMember(sym)) {\n            Symbol target = Symbol.intern(sym.ns);\n            Class c = HostExpr.maybeClass(target, false);\n            if (c != null) {\n              Symbol meth = Symbol.intern(sym.name);\n              return preserveTag(form,\n                  RT.listStar(DOT, target, meth, form.next()));\n            }\n          } else {\n            // (s.substring 2 5) => (. s substring 2 5)\n            // also (package.class.name ...) (. package.class name ...)\n            int idx = sname.lastIndexOf('.');\n            // if(idx > 0 && idx < sname.length() - 1)\n            // {\n            // Symbol target = Symbol.intern(sname.substring(0, idx));\n            // Symbol meth = Symbol.intern(sname.substring(idx + 1));\n            // return RT.listStar(DOT, target, meth, form.rest());\n            // }\n            // (StringBuilder. \"foo\") => (new StringBuilder \"foo\")\n            // else\n            if (idx == sname.length() - 1)\n              return RT.listStar(NEW, Symbol.intern(sname.substring(0, idx)),\n                  form.next());\n          }\n        }\n      }\n    }\n    return x;\n  }\n\n  static Object macroexpand(Object form) {\n    Object exf = macroexpand1(form);\n    if (exf != form)\n      return macroexpand(exf);\n    return form;\n  }\n\n  private static Expr analyzeSeq(C context, ISeq form, String name,\n      Object defContext) {\n    Object line = lineDeref();\n    Object column = columnDeref();\n    if (RT.meta(form) != null && RT.meta(form).containsKey(RT.LINE_KEY))\n      line = RT.meta(form).valAt(RT.LINE_KEY);\n    if (RT.meta(form) != null && RT.meta(form).containsKey(RT.COLUMN_KEY))\n      column = RT.meta(form).valAt(RT.COLUMN_KEY);\n    Var.pushThreadBindings(RT.map(LINE, line, COLUMN, column));\n    try {\n      Object me = macroexpand1(form);\n      if (me != form)\n        return analyze(context, me, name, defContext);\n\n      Object op = RT.first(form);\n      if (op == null)\n        throw new IllegalArgumentException(\"Can't call nil\");\n      IFn inline = isInline(op, RT.count(RT.next(form)));\n      if (inline != null)\n        return analyze(context,\n            preserveTag(form, inline.applyTo(RT.next(form))));\n      IParser p;\n      if (op.equals(FN))\n        return FnExpr.parse(context, form, name, defContext);\n      else if ((p = (IParser) specials.valAt(op)) != null)\n        return p.parse(context, form);\n      else\n        return InvokeExpr.parse(context, form);\n    } catch (Throwable e) {\n      if (!(e instanceof CompilerException))\n        throw new CompilerException((String) SOURCE_PATH.deref(), lineDeref(),\n            columnDeref(), e);\n      else\n        throw (CompilerException) e;\n    } finally {\n      Var.popThreadBindings();\n    }\n  }\n\n  static String errorMsg(String source, int line, int column, String s) {\n    return String.format(\"%s, compiling:(%s:%d:%d)\", s, source, line, column);\n  }\n\n  public static Object eval(Object form) {\n    return eval(form, true);\n  }\n\n  public static Object eval(Object form, boolean freshLoader) {\n    boolean createdLoader = false;\n    if (true)// !LOADER.isBound())\n    {\n      Var.pushThreadBindings(RT.map(LOADER, RT.makeClassLoader()));\n      createdLoader = true;\n    }\n    try {\n      Object line = lineDeref();\n      Object column = columnDeref();\n      if (RT.meta(form) != null && RT.meta(form).containsKey(RT.LINE_KEY))\n        line = RT.meta(form).valAt(RT.LINE_KEY);\n      if (RT.meta(form) != null && RT.meta(form).containsKey(RT.COLUMN_KEY))\n        column = RT.meta(form).valAt(RT.COLUMN_KEY);\n      Var.pushThreadBindings(RT.map(LINE, line, COLUMN, column));\n      try {\n        form = macroexpand(form);\n        if (form instanceof ISeq && Util.equals(RT.first(form), DO)) {\n          ISeq s = RT.next(form);\n          for (; RT.next(s) != null; s = RT.next(s))\n            eval(RT.first(s), false);\n          return eval(RT.first(s), false);\n        } else if ((form instanceof IType)\n            || (form instanceof IPersistentCollection && !(RT.first(form) instanceof Symbol && ((Symbol) RT\n                .first(form)).name.startsWith(\"def\")))) {\n          ObjExpr fexpr = (ObjExpr) analyze(C.EXPRESSION,\n              RT.list(FN, PersistentVector.EMPTY, form), \"eval\" + RT.nextID());\n          IFn fn = (IFn) fexpr.eval();\n          return fn.invoke();\n        } else {\n          Expr expr = analyze(C.EVAL, form);\n          return expr.eval();\n        }\n      } finally {\n        Var.popThreadBindings();\n      }\n    }\n\n    finally {\n      if (createdLoader)\n        Var.popThreadBindings();\n    }\n  }\n\n  private static int registerConstant(Object o) {\n    if (!CONSTANTS.isBound())\n      return -1;\n    PersistentVector v = (PersistentVector) CONSTANTS.deref();\n    IdentityHashMap<Object, Integer> ids = (IdentityHashMap<Object, Integer>) CONSTANT_IDS\n        .deref();\n    Integer i = ids.get(o);\n    if (i != null)\n      return i;\n    CONSTANTS.set(RT.conj(v, o));\n    ids.put(o, v.count());\n    return v.count();\n  }\n\n  private static KeywordExpr registerKeyword(Keyword keyword) {\n    if (!KEYWORDS.isBound())\n      return new KeywordExpr(keyword);\n\n    IPersistentMap keywordsMap = (IPersistentMap) KEYWORDS.deref();\n    Object id = RT.get(keywordsMap, keyword);\n    if (id == null) {\n      KEYWORDS.set(RT.assoc(keywordsMap, keyword, registerConstant(keyword)));\n    }\n    return new KeywordExpr(keyword);\n    // KeywordExpr ke = (KeywordExpr) RT.get(keywordsMap, keyword);\n    // if(ke == null)\n    // KEYWORDS.set(RT.assoc(keywordsMap, keyword, ke = new\n    // KeywordExpr(keyword)));\n    // return ke;\n  }\n\n  private static int registerKeywordCallsite(Keyword keyword) {\n    if (!KEYWORD_CALLSITES.isBound())\n      throw new IllegalAccessError(\"KEYWORD_CALLSITES is not bound\");\n\n    IPersistentVector keywordCallsites = (IPersistentVector) KEYWORD_CALLSITES\n        .deref();\n\n    keywordCallsites = keywordCallsites.cons(keyword);\n    KEYWORD_CALLSITES.set(keywordCallsites);\n    return keywordCallsites.count() - 1;\n  }\n\n  private static int registerProtocolCallsite(Var v) {\n    if (!PROTOCOL_CALLSITES.isBound())\n      throw new IllegalAccessError(\"PROTOCOL_CALLSITES is not bound\");\n\n    IPersistentVector protocolCallsites = (IPersistentVector) PROTOCOL_CALLSITES\n        .deref();\n\n    protocolCallsites = protocolCallsites.cons(v);\n    PROTOCOL_CALLSITES.set(protocolCallsites);\n    return protocolCallsites.count() - 1;\n  }\n\n  // private static void registerVarCallsite(Var v) {\n  // if (!VAR_CALLSITES.isBound())\n  // throw new IllegalAccessError(\"VAR_CALLSITES is not bound\");\n  //\n  // IPersistentCollection varCallsites = (IPersistentCollection) VAR_CALLSITES\n  // .deref();\n  //\n  // varCallsites = varCallsites.cons(v);\n  // VAR_CALLSITES.set(varCallsites);\n  // // return varCallsites.count()-1;\n  // }\n\n  static ISeq fwdPath(PathNode p1) {\n    ISeq ret = null;\n    for (; p1 != null; p1 = p1.parent)\n      ret = RT.cons(p1, ret);\n    return ret;\n  }\n\n  static PathNode commonPath(PathNode n1, PathNode n2) {\n    ISeq xp = fwdPath(n1);\n    ISeq yp = fwdPath(n2);\n    if (RT.first(xp) != RT.first(yp))\n      return null;\n    while (RT.second(xp) != null && RT.second(xp) == RT.second(yp)) {\n      xp = xp.next();\n      yp = yp.next();\n    }\n    return (PathNode) RT.first(xp);\n  }\n\n  static void addAnnotation(Object visitor, IPersistentMap meta) {\n    if (meta != null && ADD_ANNOTATIONS.isBound())\n      ADD_ANNOTATIONS.invoke(visitor, meta);\n  }\n\n  static void addParameterAnnotation(Object visitor, IPersistentMap meta, int i) {\n    if (meta != null && ADD_ANNOTATIONS.isBound())\n      ADD_ANNOTATIONS.invoke(visitor, meta, i);\n  }\n\n  private static Expr analyzeSymbol(Symbol sym) {\n    Symbol tag = tagOf(sym);\n    if (sym.ns == null) // ns-qualified syms are always Vars\n    {\n      LocalBinding b = referenceLocal(sym);\n      if (b != null) {\n        return new LocalBindingExpr(b, tag);\n      }\n    } else {\n      if (namespaceFor(sym) == null) {\n        Symbol nsSym = Symbol.intern(sym.ns);\n        Class c = HostExpr.maybeClass(nsSym, false);\n        if (c != null) {\n          if (Reflector.getField(c, sym.name, true) != null)\n            return new StaticFieldExpr(lineDeref(), columnDeref(), c, sym.name,\n                tag);\n          throw Util.runtimeException(\"Unable to find static field: \"\n              + sym.name + \" in \" + c);\n        }\n      }\n    }\n    // Var v = lookupVar(sym, false);\n    // Var v = lookupVar(sym, false);\n    // if(v != null)\n    // return new VarExpr(v, tag);\n    Object o = resolve(sym);\n    if (o instanceof Var) {\n      Var v = (Var) o;\n      if (isMacro(v) != null)\n        throw Util.runtimeException(\"Can't take value of a macro: \" + v);\n      if (RT.booleanCast(RT.get(v.meta(), RT.CONST_KEY)))\n        return analyze(C.EXPRESSION, RT.list(QUOTE, v.get()));\n      registerVar(v);\n      return new VarExpr(v, tag);\n    } else if (o instanceof Class)\n      return new ConstantExpr(o);\n    else if (o instanceof Symbol)\n      return new UnresolvedVarExpr((Symbol) o);\n\n    throw Util.runtimeException(\"Unable to resolve symbol: \" + sym\n        + \" in this context\");\n\n  }\n\n  static String destubClassName(String className) {\n    // skip over prefix + '.' or '/'\n    if (className.startsWith(COMPILE_STUB_PREFIX))\n      return className.substring(COMPILE_STUB_PREFIX.length() + 1);\n    return className;\n  }\n\n  static Type getType(Class c) {\n    String descriptor = Type.getType(c).getDescriptor();\n    if (descriptor.startsWith(\"L\"))\n      descriptor = \"L\" + destubClassName(descriptor.substring(1));\n    return Type.getType(descriptor);\n  }\n\n  static Object resolve(Symbol sym, boolean allowPrivate) {\n    return resolveIn(currentNS(), sym, allowPrivate);\n  }\n\n  static Object resolve(Symbol sym) {\n    return resolveIn(currentNS(), sym, false);\n  }\n\n  static Namespace namespaceFor(Symbol sym) {\n    return namespaceFor(currentNS(), sym);\n  }\n\n  static Namespace namespaceFor(Namespace inns, Symbol sym) {\n    // note, presumes non-nil sym.ns\n    // first check against currentNS' aliases...\n    Symbol nsSym = Symbol.intern(sym.ns);\n    Namespace ns = inns.lookupAlias(nsSym);\n    if (ns == null) {\n      // ...otherwise check the Namespaces map.\n      ns = Namespace.find(nsSym);\n    }\n    return ns;\n  }\n\n  static public Object resolveIn(Namespace n, Symbol sym, boolean allowPrivate) {\n    // note - ns-qualified vars must already exist\n    if (sym.ns != null) {\n      Namespace ns = namespaceFor(n, sym);\n      if (ns == null)\n        throw Util.runtimeException(\"No such namespace: \" + sym.ns);\n\n      Var v = ns.findInternedVar(Symbol.intern(sym.name));\n      if (v == null)\n        throw Util.runtimeException(\"No such var: \" + sym);\n      else if (v.ns != currentNS() && !v.isPublic() && !allowPrivate)\n        throw new IllegalStateException(\"var: \" + sym + \" is not public\");\n      return v;\n    } else if (sym.name.indexOf('.') > 0 || sym.name.charAt(0) == '[') {\n      return RT.classForName(sym.name);\n    } else if (sym.equals(NS))\n      return RT.NS_VAR;\n    else if (sym.equals(IN_NS))\n      return RT.IN_NS_VAR;\n    else {\n      if (Util.equals(sym, COMPILE_STUB_SYM.get()))\n        return COMPILE_STUB_CLASS.get();\n      Object o = n.getMapping(sym);\n      if (o == null) {\n        if (RT.booleanCast(RT.ALLOW_UNRESOLVED_VARS.deref())) {\n          return sym;\n        } else {\n          throw Util.runtimeException(\"Unable to resolve symbol: \" + sym\n              + \" in this context\");\n        }\n      }\n      return o;\n    }\n  }\n\n  static public Object maybeResolveIn(Namespace n, Symbol sym) {\n    // note - ns-qualified vars must already exist\n    if (sym.ns != null) {\n      Namespace ns = namespaceFor(n, sym);\n      if (ns == null)\n        return null;\n      Var v = ns.findInternedVar(Symbol.intern(sym.name));\n      if (v == null)\n        return null;\n      return v;\n    } else if (sym.name.indexOf('.') > 0 && !sym.name.endsWith(\".\")\n        || sym.name.charAt(0) == '[') {\n      return RT.classForName(sym.name);\n    } else if (sym.equals(NS))\n      return RT.NS_VAR;\n    else if (sym.equals(IN_NS))\n      return RT.IN_NS_VAR;\n    else {\n      Object o = n.getMapping(sym);\n      return o;\n    }\n  }\n\n  static Var lookupVar(Symbol sym, boolean internNew, boolean registerMacro) {\n    Var var = null;\n\n    // note - ns-qualified vars in other namespaces must already exist\n    if (sym.ns != null) {\n      Namespace ns = namespaceFor(sym);\n      if (ns == null)\n        return null;\n      // throw Util.runtimeException(\"No such namespace: \" + sym.ns);\n      Symbol name = Symbol.intern(sym.name);\n      if (internNew && ns == currentNS())\n        var = currentNS().intern(name);\n      else\n        var = ns.findInternedVar(name);\n    } else if (sym.equals(NS))\n      var = RT.NS_VAR;\n    else if (sym.equals(IN_NS))\n      var = RT.IN_NS_VAR;\n    else {\n      // is it mapped?\n      Object o = currentNS().getMapping(sym);\n      if (o == null) {\n        // introduce a new var in the current ns\n        if (internNew)\n          var = currentNS().intern(Symbol.intern(sym.name));\n      } else if (o instanceof Var) {\n        var = (Var) o;\n      } else {\n        throw Util.runtimeException(\"Expecting var, but \" + sym\n            + \" is mapped to \" + o);\n      }\n    }\n    if (var != null && (!var.isMacro() || registerMacro))\n      registerVar(var);\n    return var;\n  }\n\n  static Var lookupVar(Symbol sym, boolean internNew) {\n    return lookupVar(sym, internNew, true);\n  }\n\n  private static void registerVar(Var var) {\n    if (!VARS.isBound())\n      return;\n    IPersistentMap varsMap = (IPersistentMap) VARS.deref();\n    Object id = RT.get(varsMap, var);\n    if (id == null) {\n      VARS.set(RT.assoc(varsMap, var, registerConstant(var)));\n    }\n    // if(varsMap != null && RT.get(varsMap, var) == null)\n    // VARS.set(RT.assoc(varsMap, var, var));\n  }\n\n  static Namespace currentNS() {\n    return (Namespace) RT.CURRENT_NS.deref();\n  }\n\n  static void closeOver(LocalBinding b, ObjMethod method) {\n    if (b != null && method != null) {\n      if (RT.get(method.locals, b) == null) {\n        method.objx.closes = (IPersistentMap) RT\n            .assoc(method.objx.closes, b, b);\n        closeOver(b, method.parent);\n      } else if (IN_CATCH_FINALLY.deref() != null) {\n        method.localsUsedInCatchFinally = (PersistentHashSet) method.localsUsedInCatchFinally\n            .cons(b.idx);\n      }\n    }\n  }\n\n  static LocalBinding referenceLocal(Symbol sym) {\n    if (!LOCAL_ENV.isBound())\n      return null;\n    LocalBinding b = (LocalBinding) RT.get(LOCAL_ENV.deref(), sym);\n    if (b != null) {\n      ObjMethod method = (ObjMethod) METHOD.deref();\n      closeOver(b, method);\n    }\n    return b;\n  }\n\n  private static Symbol tagOf(Object o) {\n    Object tag = RT.get(RT.meta(o), RT.TAG_KEY);\n    if (tag instanceof Symbol)\n      return (Symbol) tag;\n    else if (tag instanceof String)\n      return Symbol.intern(null, (String) tag);\n    return null;\n  }\n\n  public static Object loadFile(String file) throws IOException {\n    // File fo = new File(file);\n    // if(!fo.exists())\n    // return null;\n\n    FileInputStream f = new FileInputStream(file);\n    try {\n      return load(new InputStreamReader(f, RT.UTF8),\n          new File(file).getAbsolutePath(), (new File(file)).getName());\n    } finally {\n      f.close();\n    }\n  }\n\n  public static Object load(Reader rdr) {\n    return load(rdr, null, \"NO_SOURCE_FILE\");\n  }\n\n  static void consumeWhitespaces(LineNumberingPushbackReader pushbackReader) {\n    int ch = LispReader.read1(pushbackReader);\n    while(LispReader.isWhitespace(ch))\n      ch = LispReader.read1(pushbackReader);\n    LispReader.unread(pushbackReader, ch);\n  }\n  \n  private static final Object OPTS_COND_ALLOWED = RT.mapUniqueKeys(LispReader.OPT_READ_COND, LispReader.COND_ALLOW);\n  private static Object readerOpts(String sourceName) {\n      if(sourceName != null && sourceName.endsWith(\".cljc\"))\n          return OPTS_COND_ALLOWED;\n      else\n          return null;\n  }\n  \n  public static Object load(Reader rdr, String sourcePath, String sourceName) {\n    Object EOF = new Object();\n    Object ret = null;\n    LineNumberingPushbackReader pushbackReader = (rdr instanceof LineNumberingPushbackReader) ? (LineNumberingPushbackReader) rdr\n        : new LineNumberingPushbackReader(rdr);\n    consumeWhitespaces(pushbackReader);\n    Var.pushThreadBindings(RT.mapUniqueKeys(LOADER, RT.makeClassLoader(),\n        SOURCE_PATH, sourcePath, SOURCE, sourceName, METHOD, null, LOCAL_ENV,\n        null, LOOP_LOCALS, null, NEXT_LOCAL_NUM, 0, RT.READEVAL, RT.T,\n        RT.CURRENT_NS, RT.CURRENT_NS.deref(), LINE_BEFORE,\n        pushbackReader.getLineNumber(), COLUMN_BEFORE,\n        pushbackReader.getColumnNumber(), LINE_AFTER,\n        pushbackReader.getLineNumber(), COLUMN_AFTER,\n        pushbackReader.getColumnNumber(), RT.UNCHECKED_MATH,\n        RT.UNCHECKED_MATH.deref(), RT.WARN_ON_REFLECTION,\n        RT.WARN_ON_REFLECTION.deref(), RT.DATA_READERS, RT.DATA_READERS.deref()));\n    Object readerOpts = readerOpts(sourceName);\n    try {\n      for (Object r = LispReader.read(pushbackReader, false, EOF, false, readerOpts); r != EOF; r = LispReader\n          .read(pushbackReader, false, EOF, false, readerOpts)) {\n        consumeWhitespaces(pushbackReader);\n        LINE_AFTER.set(pushbackReader.getLineNumber());\n        COLUMN_AFTER.set(pushbackReader.getColumnNumber());\n        ret = eval(r, false);\n        LINE_BEFORE.set(pushbackReader.getLineNumber());\n        COLUMN_BEFORE.set(pushbackReader.getColumnNumber());\n      }\n    } catch (LispReader.ReaderException e) {\n      throw new CompilerException(sourcePath, e.line, e.column, e.getCause());\n    } catch (Throwable e) {\n      if(!(e instanceof CompilerException))\n        throw new CompilerException(sourcePath, (Integer) LINE_BEFORE.deref(), (Integer) COLUMN_BEFORE.deref(), e);\n      else\n        throw (CompilerException) e;\n    } finally {\n      Var.popThreadBindings();\n    }\n    return ret;\n  }\n\n  static public void writeClassFile(String internalName, byte[] bytecode)\n      throws IOException {\n    String genPath = (String) COMPILE_PATH.deref();\n    if (genPath == null)\n      throw Util.runtimeException(\"*compile-path* not set\");\n    String[] dirs = internalName.split(\"/\");\n    String p = genPath;\n    for (int i = 0; i < dirs.length - 1; i++) {\n      p += File.separator + dirs[i];\n      (new File(p)).mkdir();\n    }\n    String path = genPath + File.separator + internalName + \".class\";\n    File cf = new File(path);\n    cf.createNewFile();\n    FileOutputStream cfs = new FileOutputStream(cf);\n    try {\n      cfs.write(bytecode);\n      cfs.flush();\n      cfs.getFD().sync();\n    } finally {\n      cfs.close();\n    }\n  }\n\n  private static String readFileAsString(String filePath) throws IOException {\n    StringBuffer fileData = new StringBuffer();\n    BufferedReader reader = new BufferedReader(new FileReader(filePath));\n    char[] buf = new char[1024];\n    int numRead = 0;\n    while ((numRead = reader.read(buf)) != -1) {\n      String readData = String.valueOf(buf, 0, numRead);\n      fileData.append(readData);\n    }\n    reader.close();\n    return fileData.toString();\n  }\n\n  static public void writeSourceFile(String internalName, String source)\n      throws IOException {\n    String genPath = (String) Compiler.SOURCE_GEN_PATH.deref();\n    if (genPath == null) {\n      genPath = \"target/gen\";\n    }\n    String[] dirs = internalName.split(\"/\");\n    String path = genPath + File.separator + internalName + \".java\";\n    File cf = new File(path);\n    cf.getParentFile().mkdirs();\n    if (!cf.exists()) {\n      cf.createNewFile();\n    } else {\n      if (readFileAsString(path).equals(source)) {\n        return;\n      }\n    }\n    FileOutputStream cfs = new FileOutputStream(cf);\n    try {\n      cfs.write(source.getBytes());\n      cfs.flush();\n      cfs.getFD().sync();\n    } finally {\n      cfs.close();\n    }\n  }\n\n  public static void pushNS() {\n    Var.pushThreadBindings(PersistentHashMap.create(\n        Var.intern(Symbol.intern(\"clojure.core\"), Symbol.intern(\"*ns*\"))\n            .setDynamic(), null));\n  }\n\n  public static void pushNSandLoader(ClassLoader loader) {\n    Var.pushThreadBindings(RT.map(\n        Var.intern(Symbol.intern(\"clojure.core\"), Symbol.intern(\"*ns*\"))\n            .setDynamic(), null, RT.FN_LOADER_VAR, loader, RT.READEVAL, RT.T));\n  }\n\n  public static ILookupThunk getLookupThunk(Object target, Keyword k) {\n    return null; // To change body of created methods use File | Settings | File\n                 // Templates.\n  }\n\n  static void compile1(GeneratorAdapter gen, ObjExpr objx, Object form) {\n    Object line = lineDeref();\n    Object column = columnDeref();\n    if (RT.meta(form) != null && RT.meta(form).containsKey(RT.LINE_KEY))\n      line = RT.meta(form).valAt(RT.LINE_KEY);\n    if (RT.meta(form) != null && RT.meta(form).containsKey(RT.COLUMN_KEY))\n      column = RT.meta(form).valAt(RT.COLUMN_KEY);\n    Var.pushThreadBindings(RT.map(LINE, line, COLUMN, column, LOADER,\n        RT.makeClassLoader()));\n    try {\n      form = macroexpand(form);\n      if (form instanceof ISeq && Util.equals(RT.first(form), DO)) {\n        for (ISeq s = RT.next(form); s != null; s = RT.next(s)) {\n          compile1(gen, objx, RT.first(s));\n        }\n      } else {\n        Expr expr = analyze(C.EVAL, form);\n        // System.out.println(form);\n        objx.keywords = (IPersistentMap) KEYWORDS.deref();\n        objx.vars = (IPersistentMap) VARS.deref();\n        objx.constants = (PersistentVector) CONSTANTS.deref();\n        emitSource(expr.emit(C.STATEMENT, objx, gen)); // C.EXPRESSION??\n        expr.eval();\n      }\n    } finally {\n      Var.popThreadBindings();\n    }\n  }\n\n  public static Object compile(Reader rdr, String sourcePath, String sourceName)\n      throws IOException {\n    if (COMPILE_PATH.deref() == null)\n      throw Util.runtimeException(\"*compile-path* not set\");\n\n    Object EOF = new Object();\n    Object ret = null;\n    LineNumberingPushbackReader pushbackReader = (rdr instanceof LineNumberingPushbackReader) ? (LineNumberingPushbackReader) rdr\n        : new LineNumberingPushbackReader(rdr);\n    Var.pushThreadBindings(RT.mapUniqueKeys(SOURCE_PATH, sourcePath, SOURCE,\n        sourceName, METHOD, null, LOCAL_ENV, null, LOOP_LOCALS, null,\n        NEXT_LOCAL_NUM, 0, RT.READEVAL, RT.T, RT.CURRENT_NS,\n        RT.CURRENT_NS.deref(), LINE_BEFORE, pushbackReader.getLineNumber(),\n        COLUMN_BEFORE, pushbackReader.getColumnNumber(), LINE_AFTER,\n        pushbackReader.getLineNumber(), COLUMN_AFTER,\n        pushbackReader.getColumnNumber(), CONSTANTS, PersistentVector.EMPTY,\n        CONSTANT_IDS, new IdentityHashMap(), KEYWORDS, PersistentHashMap.EMPTY,\n        VARS, PersistentHashMap.EMPTY, RT.UNCHECKED_MATH,\n        RT.UNCHECKED_MATH.deref(), RT.WARN_ON_REFLECTION,\n        RT.WARN_ON_REFLECTION.deref(), RT.DATA_READERS, RT.DATA_READERS.deref()\n    // ,LOADER, RT.makeClassLoader()\n        ));\n\n    try {\n      // generate loader class\n      ObjExpr objx = new ObjExpr(null);\n      objx.internalName = sourcePath.replace(File.separator, \"/\").substring(0,\n          sourcePath.lastIndexOf('.'))\n          + RT.LOADER_SUFFIX;\n\n      objx.objtype = Type.getObjectType(objx.internalName);\n      ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);\n      ClassVisitor cv = cw;\n\n      int lastSlash = objx.internalName.lastIndexOf('/');\n      String className = objx.internalName.substring(lastSlash + 1);\n      String packageName = objx.internalName.substring(0, lastSlash)\n          .replaceAll(\"/\", \".\");\n      SourceWriter source = cw.getSc();\n      Var.pushThreadBindings(RT.mapUniqueKeys(SOURCE_WRITER, source));\n\n      emitSource(\"package \" + packageName + \";\");\n      emitSource();\n      emitSource(\"import clojure.lang.*;\");\n      emitSource();\n      emitSource(\"@com.google.j2objc.annotations.ReflectionSupport(com.google.j2objc.annotations.ReflectionSupport.Level.NATIVE_ONLY)\");\n      emitSource(\"public class \" + className + \" {\");\n      tab();\n\n      cv.visit(V1_5, ACC_PUBLIC + ACC_SUPER, objx.internalName, null,\n          \"java/lang/Object\", null);\n\n      emitSource(\"public static void load() throws Exception {\");\n      // static load method\n      GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC + ACC_STATIC,\n          Method.getMethod(\"void load ()\"), null, null, cv);\n      tab();\n      gen.visitCode();\n      Object readerOpts = readerOpts(sourceName);\n      for (Object r = LispReader.read(pushbackReader, false, EOF, false, readerOpts); r != EOF; r = LispReader\n          .read(pushbackReader, false, EOF, false, readerOpts)) {\n        LINE_AFTER.set(pushbackReader.getLineNumber());\n        COLUMN_AFTER.set(pushbackReader.getColumnNumber());\n        compile1(gen, objx, r);\n        LINE_BEFORE.set(pushbackReader.getLineNumber());\n        COLUMN_BEFORE.set(pushbackReader.getColumnNumber());\n      }\n\n      // end of load\n      gen.returnValue();\n      gen.endMethod();\n\n      untab();\n      emitSource(\"}\");\n\n      // static fields for constants\n      PersistentVector constants = PersistentVector.create(objx.usedConstants\n          .seq());\n      for (int j = 0; j < constants.count(); j++) {\n        int i = (Integer) constants.nth(j);\n        cv.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC,\n            objx.constantName(i), objx.constantType(i).getDescriptor(), null,\n            null);\n\n        emitSource(\"private static \" + printClass(objx.constantRealType(i))\n            + \" \" + objx.constantName(i) + \";\");\n      }\n\n      final int INITS_PER = 100;\n      int numInits = constants.count() / INITS_PER;\n      if (constants.count() % INITS_PER != 0)\n        ++numInits;\n\n      for (int n = 0; n < numInits; n++) {\n        GeneratorAdapter clinitgen = new GeneratorAdapter(ACC_PUBLIC\n            + ACC_STATIC, Method.getMethod(\"void __init\" + n + \"()\"), null,\n            null, cv);\n        emitSource(\"static void __init\" + n + \"() {\");\n        tab();\n        clinitgen.visitCode();\n        try {\n          Var.pushThreadBindings(RT.map(RT.PRINT_DUP, RT.T));\n\n          for (int j = n * INITS_PER; j < constants.count()\n              && j < (n + 1) * INITS_PER; j++) {\n            int i = (Integer) constants.nth(j);\n            String val = objx.emitValue(objx.constants.nth(i), clinitgen);\n            clinitgen.checkCast(objx.constantType(i));\n            clinitgen.putStatic(objx.objtype, objx.constantName(i),\n                objx.constantType(i));\n            emitSource(objx.constantName(i) + \" = (\"\n                + printClass(objx.constantRealType(i)) + \")\" + val + \";\");\n          }\n        } finally {\n          Var.popThreadBindings();\n        }\n        untab();\n        emitSource(\"}\");\n        clinitgen.returnValue();\n        clinitgen.endMethod();\n      }\n\n      emitSource(\"static {\");\n      tab();\n      // static init for constants, keywords and vars\n      GeneratorAdapter clinitgen = new GeneratorAdapter(\n          ACC_PUBLIC + ACC_STATIC, Method.getMethod(\"void <clinit> ()\"), null,\n          null, cv);\n      clinitgen.visitCode();\n      Label startTry = clinitgen.newLabel();\n      Label endTry = clinitgen.newLabel();\n      Label end = clinitgen.newLabel();\n      Label finallyLabel = clinitgen.newLabel();\n\n      // if(objx.constants.count() > 0)\n      // {\n      // objx.emitConstants(clinitgen);\n      // }\n      for (int n = 0; n < numInits; n++) {\n        clinitgen.invokeStatic(objx.objtype,\n            Method.getMethod(\"void __init\" + n + \"()\"));\n\n        emitSource(\"__init\" + n + \"();\");\n      }\n\n      String iname = objx.internalName.replace('/', '.');\n      clinitgen.push(iname);\n      clinitgen.invokeStatic(RT_TYPE,\n          Method.getMethod(\"Class classForName(String)\"));\n      clinitgen.invokeVirtual(CLASS_TYPE,\n          Method.getMethod(\"ClassLoader getClassLoader()\"));\n      clinitgen.invokeStatic(Type.getType(Compiler.class),\n          Method.getMethod(\"void pushNSandLoader(ClassLoader)\"));\n      clinitgen.mark(startTry);\n      clinitgen.invokeStatic(objx.objtype, Method.getMethod(\"void load()\"));\n      clinitgen.mark(endTry);\n      clinitgen.invokeStatic(VAR_TYPE,\n          Method.getMethod(\"void popThreadBindings()\"));\n      clinitgen.goTo(end);\n\n      clinitgen.mark(finallyLabel);\n      // exception should be on stack\n      clinitgen.invokeStatic(VAR_TYPE,\n          Method.getMethod(\"void popThreadBindings()\"));\n      clinitgen.throwException();\n      clinitgen.mark(end);\n      clinitgen.visitTryCatchBlock(startTry, endTry, finallyLabel, null);\n\n      // end of static init\n      clinitgen.returnValue();\n      clinitgen.endMethod();\n\n      // end of class\n      cv.visitEnd();\n\n      emitSource(\"clojure.lang.Compiler.pushNSandLoader(\" + iname\n          + \".class.getClassLoader());\");\n      emitSource(\"try {\");\n      tab();\n      emitSource(\"load();\");\n      untab();\n      emitSource(\"} catch (Exception ___x) {\");\n      emitSource(\"throw new RuntimeException(___x);\");\n      emitSource(\"} finally {\");\n      tab();\n      emitSource(\"Var.popThreadBindings();\");\n      untab();\n      emitSource(\"}\");\n\n      untab();\n      emitSource(\"}\");\n      untab();\n      emitSource(\"}\");\n\n      Var.popThreadBindings();\n      writeClassFile(objx.internalName, cw.toByteArray());\n      writeSourceFile(objx.internalName, source.toString());\n    } catch (LispReader.ReaderException e) {\n      throw new CompilerException(sourcePath, e.line, e.column, e.getCause());\n    } finally {\n      Var.popThreadBindings();\n    }\n    return ret;\n  }\n\n  static public class NewInstanceExpr extends ObjExpr {\n    // IPersistentMap optionsMap = PersistentArrayMap.EMPTY;\n    IPersistentCollection methods;\n\n    Map<IPersistentVector, java.lang.reflect.Method> mmap;\n    Map<IPersistentVector, Set<Class>> covariants;\n\n    private IPersistentVector overrideMethods;\n\n    public NewInstanceExpr(Object tag) {\n      super(tag);\n    }\n\n    static class DeftypeParser implements IParser {\n      public Expr parse(C context, final Object frm) {\n        ISeq rform = (ISeq) frm;\n        // (deftype* tagname classname [fields] :implements [interfaces] :tag\n        // tagname methods*)\n        rform = RT.next(rform);\n        String tagname = ((Symbol) rform.first()).toString();\n        rform = rform.next();\n        Symbol classname = (Symbol) rform.first();\n        rform = rform.next();\n        IPersistentVector fields = (IPersistentVector) rform.first();\n        rform = rform.next();\n        IPersistentMap opts = PersistentHashMap.EMPTY;\n        while (rform != null && rform.first() instanceof Keyword) {\n          opts = opts.assoc(rform.first(), RT.second(rform));\n          rform = rform.next().next();\n        }\n        ObjExpr ret = build((IPersistentVector) RT.get(opts, implementsKey,\n            PersistentVector.EMPTY), fields, null, tagname, classname,\n            (Symbol) RT.get(opts, RT.TAG_KEY), rform, frm);\n        return ret;\n      }\n    }\n\n    static class ReifyParser implements IParser {\n      public Expr parse(C context, Object frm) {\n        // (reify this-name? [interfaces] (method-name [args] body)*)\n        ISeq form = (ISeq) frm;\n        ObjMethod enclosingMethod = (ObjMethod) METHOD.deref();\n        String basename = enclosingMethod != null ? (trimGenID(enclosingMethod.objx.name) + DOLLAR)\n            : (munge(currentNS().name.name) + DOLLAR);\n        String simpleName = \"reify__\" + RT.nextID();\n        String classname = basename + simpleName;\n\n        ISeq rform = RT.next(form);\n\n        IPersistentVector interfaces = ((IPersistentVector) RT.first(rform))\n            .cons(Symbol.intern(\"clojure.lang.IObj\"));\n\n        rform = RT.next(rform);\n\n        ObjExpr ret = build(interfaces, null, null, classname,\n            Symbol.intern(classname), null, rform, frm);\n        if (frm instanceof IObj && ((IObj) frm).meta() != null)\n          return new MetaExpr(ret, MapExpr.parse(context == C.EVAL ? context\n              : C.EXPRESSION, ((IObj) frm).meta()));\n        else\n          return ret;\n      }\n    }\n\n    static ObjExpr build(IPersistentVector interfaceSyms,\n        IPersistentVector fieldSyms, Symbol thisSym, String tagName,\n        Symbol className, Symbol typeTag, ISeq methodForms, Object frm) {\n      NewInstanceExpr ret = new NewInstanceExpr(null);\n\n      ret.src = frm;\n      ret.name = className.toString();\n      ret.classMeta = RT.meta(className);\n      ret.internalName = ret.name.replace('.', '/');\n      ret.objtype = Type.getObjectType(ret.internalName);\n\n      if (thisSym != null)\n        ret.thisName = thisSym.name;\n\n      if (fieldSyms != null) {\n        IPersistentMap fmap = PersistentHashMap.EMPTY;\n        Object[] closesvec = new Object[2 * fieldSyms.count()];\n        for (int i = 0; i < fieldSyms.count(); i++) {\n          Symbol sym = (Symbol) fieldSyms.nth(i);\n          if (sym.name.equals(\"this\")) {\n            throw new RuntimeException(\n                \"A deftype/defrecord field cannot be named 'this'\");\n          }\n          LocalBinding lb = new LocalBinding(-1, sym, null,\n              new MethodParamExpr(tagClass(tagOf(sym))), false, null);\n          fmap = fmap.assoc(sym, lb);\n          closesvec[i * 2] = lb;\n          closesvec[i * 2 + 1] = lb;\n        }\n\n        // todo - inject __meta et al into closes - when?\n        // use array map to preserve ctor order\n        ret.closes = new PersistentArrayMap(closesvec);\n        ret.fields = fmap;\n        for (int i = fieldSyms.count() - 1; i >= 0\n            && (((Symbol) fieldSyms.nth(i)).name.equals(\"__meta\") || ((Symbol) fieldSyms\n                .nth(i)).name.equals(\"__extmap\")); --i)\n          ret.altCtorDrops++;\n      }\n      // todo - set up volatiles\n      // ret.volatiles = PersistentHashSet.create(RT.seq(RT.get(ret.optionsMap,\n      // volatileKey)));\n\n      PersistentVector interfaces = PersistentVector.EMPTY;\n      for (ISeq s = RT.seq(interfaceSyms); s != null; s = s.next()) {\n        Class c = (Class) resolve((Symbol) s.first());\n        if (!c.isInterface())\n          throw new IllegalArgumentException(\n              \"only interfaces are supported, had: \" + c.getName());\n        interfaces = interfaces.cons(c);\n      }\n      Class superClass = Object.class;\n      Map[] mc = gatherMethods(superClass, RT.seq(interfaces));\n      Map overrideables = mc[0];\n      Map covariants = mc[1];\n      Map parameters = mc[2];\n      ret.mmap = overrideables;\n      ret.covariants = covariants;\n      Map allmethods = new HashMap(overrideables);\n      String[] inames = interfaceNames(interfaces);\n\n      Class stub = compileStub(slashname(superClass), ret, inames, frm);\n      Symbol thistag = Symbol.intern(null, stub.getName());\n\n      try {\n        Var.pushThreadBindings(RT.mapUniqueKeys(CONSTANTS,\n            PersistentVector.EMPTY, CONSTANT_IDS, new IdentityHashMap(),\n            KEYWORDS, PersistentHashMap.EMPTY, VARS, PersistentHashMap.EMPTY,\n            KEYWORD_CALLSITES, PersistentVector.EMPTY, PROTOCOL_CALLSITES,\n            PersistentVector.EMPTY, VAR_CALLSITES, emptyVarCallSites(),\n            NO_RECUR, null, Compiler.NEXT_ID, new Atom(1)));\n        if (ret.isDeftype()) {\n          Var.pushThreadBindings(RT.mapUniqueKeys(METHOD, null, LOCAL_ENV,\n              ret.fields, COMPILE_STUB_SYM, Symbol.intern(null, tagName),\n              COMPILE_STUB_CLASS, stub));\n\n          ret.hintedFields = RT.subvec(fieldSyms, 0, fieldSyms.count()\n              - ret.altCtorDrops);\n        }\n\n        // now (methodname [args] body)*\n        ret.line = lineDeref();\n        ret.column = columnDeref();\n        IPersistentCollection methods = null;\n        for (ISeq s = methodForms; s != null; s = RT.next(s)) {\n          NewInstanceMethod m = NewInstanceMethod.parse(ret,\n              (ISeq) RT.first(s), thistag, overrideables, parameters);\n          methods = RT.conj(methods, m);\n          allmethods.remove(m.mk);\n        }\n\n        IPersistentVector overrideMethods = RT.vector();\n        for (Object ee : allmethods.entrySet()) {\n          Entry e = (Entry) ee;\n          java.lang.reflect.Method method = (java.lang.reflect.Method) e\n              .getValue();\n          Class<?> dc = method.getDeclaringClass();\n          if (!dc.equals(IMeta.class) && !dc.equals(IObj.class)) {\n            if (Modifier.isAbstract(method.getModifiers())) {\n              overrideMethods = overrideMethods.cons(method);\n            }\n          }\n        }\n        ret.overrideMethods = overrideMethods;\n        ret.methods = methods;\n        ret.keywords = (IPersistentMap) KEYWORDS.deref();\n        ret.vars = (IPersistentMap) VARS.deref();\n        ret.constants = (PersistentVector) CONSTANTS.deref();\n        ret.constantsID = RT.nextID();\n        ret.keywordCallsites = (IPersistentVector) KEYWORD_CALLSITES.deref();\n        ret.protocolCallsites = (IPersistentVector) PROTOCOL_CALLSITES.deref();\n        ret.varCallsites = (IPersistentSet) VAR_CALLSITES.deref();\n      } finally {\n        if (ret.isDeftype())\n          Var.popThreadBindings();\n        Var.popThreadBindings();\n      }\n\n      try {\n        ret.compile(slashname(superClass), inames, false);\n      } catch (IOException e) {\n        throw Util.sneakyThrow(e);\n      }\n      ret.getCompiledClass();\n      return ret;\n    }\n\n    /***\n     * Current host interop uses reflection, which requires pre-existing classes\n     * Work around this by: Generate a stub class that has the same interfaces\n     * and fields as the class we are generating. Use it as a type hint for\n     * this, and bind the simple name of the class to this stub (in resolve etc)\n     * Unmunge the name (using a magic prefix) on any code gen for classes\n     */\n    static Class compileStub(String superName, NewInstanceExpr ret,\n        String[] interfaceNames, Object frm) {\n      ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);\n      ClassVisitor cv = cw;\n\n      Var.pushThreadBindings(RT.mapUniqueKeys(SOURCE_WRITER, cw.getSc()));\n\n      cv.visit(V1_5, ACC_PUBLIC + ACC_SUPER, COMPILE_STUB_PREFIX + \"/\"\n          + ret.internalName, null, superName, interfaceNames);\n\n      int lastSlash = ret.internalName.lastIndexOf('/');\n      String className;\n      String packageName;\n      if (lastSlash != -1) {\n        className = ret.internalName.substring(lastSlash + 1);\n        packageName = ret.internalName.substring(0, lastSlash).replaceAll(\"/\",\n            \".\");\n      } else {\n        packageName = \"\";\n        className = ret.internalName;\n      }\n      packageName = COMPILE_STUB_PREFIX + \".\" + packageName;\n\n      emitSource(\"package \" + packageName + \";\");\n\n      emitSource();\n      emitSource(\"import clojure.lang.*;\");\n      emitSource();\n\n      StringBuilder sb = new StringBuilder();\n      for (String i : interfaceNames) {\n        if (sb.length() > 0) {\n          sb.append(\", \");\n        }\n        sb.append(i.replaceAll(\"/\", \".\"));\n      }\n\n      emitSource(\"@com.google.j2objc.annotations.ReflectionSupport(com.google.j2objc.annotations.ReflectionSupport.Level.NATIVE_ONLY)\");\n      emitSource(\"public class \" + className + \" extends \"\n          + superName.replaceAll(\"/\", \".\")\n          + (sb.length() > 0 ? \" implements \" + sb.toString() : \"\") + \" {\");\n      tab();\n\n      // instance fields for closed-overs\n      for (ISeq s = RT.keys(ret.closes); s != null; s = s.next()) {\n        LocalBinding lb = (LocalBinding) s.first();\n        int access = ACC_PUBLIC\n            + (ret.isVolatile(lb) ? ACC_VOLATILE : ret.isMutable(lb) ? 0\n                : ACC_FINAL);\n        String modif = ret.isVolatile(lb) ? \"volatile \"\n            : ret.isMutable(lb) ? \"\" : \"final \";\n        if (lb.getPrimitiveType() != null) {\n          cv.visitField(access, lb.name, Type.getType(lb.getPrimitiveType())\n              .getDescriptor(), null, null);\n          emitSource(modif + printClass(lb.getPrimitiveType()) + \" \"\n              + lb.print() + \";\");\n        } else {\n          // todo - when closed-overs are fields, use more specific types here\n          // and in ctor and emitLocal?\n          cv.visitField(access, lb.name, OBJECT_TYPE.getDescriptor(), null,\n              null);\n          emitSource(modif + \"Object \" + lb.print() + \";\");\n        }\n      }\n\n      // ctor that takes closed-overs and does nothing\n      Method m = new Method(\"<init>\", Type.VOID_TYPE, ret.ctorTypes());\n      GeneratorAdapter ctorgen = new GeneratorAdapter(ACC_PUBLIC, m, null,\n          null, cv);\n      StringBuilder cparams = new StringBuilder();\n      StringBuilder sparams = new StringBuilder();\n      int n = 0;\n      for (Type t : ret.ctorTypes()) {\n        if (cparams.length() > 0) {\n          cparams.append(\", \");\n          sparams.append(\", \");\n        }\n        cparams.append(printClass(t) + \" p\" + n);\n        sparams.append(\"p\" + n);\n        n++;\n      }\n\n      emitSource(\"public \" + className + \"(\" + cparams + \") {\");\n      tab();\n      ctorgen.visitCode();\n      ctorgen.loadThis();\n      ctorgen.invokeConstructor(Type.getObjectType(superName), voidctor);\n      emitSource(\"super(\" + sparams + \");\");\n      ctorgen.returnValue();\n      ctorgen.endMethod();\n      untab();\n      emitSource(\"}\");\n\n      if (ret.altCtorDrops > 0) {\n        Type[] ctorTypes = ret.ctorTypes();\n        Type[] altCtorTypes = new Type[ctorTypes.length - ret.altCtorDrops];\n        for (int i = 0; i < altCtorTypes.length; i++)\n          altCtorTypes[i] = ctorTypes[i];\n        Method alt = new Method(\"<init>\", Type.VOID_TYPE, altCtorTypes);\n\n        cparams = new StringBuilder();\n        sparams = new StringBuilder();\n        n = 0;\n        for (Type t : altCtorTypes) {\n          if (cparams.length() > 0) {\n            cparams.append(\", \");\n            sparams.append(\", \");\n          }\n          cparams.append(printClass(t) + \" p\" + n);\n          sparams.append(\"p\" + n);\n          n++;\n        }\n\n        emitSource(\"public \" + className + \"(\" + cparams + \") {\");\n        tab();\n        emitSource(\"super(\" + sparams + \");\");\n        untab();\n        emitSource(\"}\");\n\n        ctorgen = new GeneratorAdapter(ACC_PUBLIC, alt, null, null, cv);\n        ctorgen.visitCode();\n        ctorgen.loadThis();\n        ctorgen.loadArgs();\n        for (int i = 0; i < ret.altCtorDrops; i++)\n          ctorgen.visitInsn(Opcodes.ACONST_NULL);\n\n        ctorgen.invokeConstructor(\n            Type.getObjectType(COMPILE_STUB_PREFIX + \"/\" + ret.internalName),\n            new Method(\"<init>\", Type.VOID_TYPE, ctorTypes));\n\n        ctorgen.returnValue();\n        ctorgen.endMethod();\n      }\n      // end of class\n      cv.visitEnd();\n\n      byte[] bytecode = cw.toByteArray();\n      DynamicClassLoader loader = (DynamicClassLoader) LOADER.deref();\n\n      untab();\n      emitSource(\"}\");\n\n      // TODO?\n      // if (RT.booleanCast(COMPILE_FILES.deref())) {\n      // try {\n      // writeSourceFile(COMPILE_STUB_PREFIX + \"/\" + ret.internalName,\n      // SOURCE_WRITER.deref().toString());\n      // } catch (IOException e) {\n      // throw Util.sneakyThrow(e);\n      // }\n      // }\n      Var.popThreadBindings();\n\n      return loader.defineClass(COMPILE_STUB_PREFIX + \".\" + ret.name, bytecode,\n          frm);\n    }\n\n    static String[] interfaceNames(IPersistentVector interfaces) {\n      int icnt = interfaces.count();\n      String[] inames = icnt > 0 ? new String[icnt] : null;\n      for (int i = 0; i < icnt; i++)\n        inames[i] = slashname((Class) interfaces.nth(i));\n      return inames;\n    }\n\n    static String slashname(Class c) {\n      return c.getName().replace('.', '/');\n    }\n\n    protected void emitStatics(ClassVisitor cv) {\n      if (this.isDeftype()) {\n        // getBasis()\n        Method meth = Method\n            .getMethod(\"clojure.lang.IPersistentVector getBasis()\");\n        GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC + ACC_STATIC,\n            meth, null, null, cv);\n        emitSource(\"public static clojure.lang.IPersistentVector getBasis() {\");\n        tab();\n        emitSource(\"return \" + emitValue(hintedFields, gen) + \";\");\n        untab();\n        emitSource(\"}\");\n        gen.returnValue();\n        gen.endMethod();\n\n        if (this.fields.count() > this.hintedFields.count()) {\n          // create(IPersistentMap)\n          String className = name.replace('.', '/');\n          int i = 1;\n          int fieldCount = hintedFields.count();\n\n          MethodVisitor mv = cv.visitMethod(ACC_PUBLIC + ACC_STATIC, \"create\",\n              \"(Lclojure/lang/IPersistentMap;)L\" + className + \";\", null, null);\n          mv.visitCode();\n          emitSource(\"public static \" + printClass(name)\n              + \" create(IPersistentMap map) {\");\n          tab();\n\n          StringBuilder sb = new StringBuilder();\n          StringBuilder others = new StringBuilder();\n          for (ISeq s = RT.seq(hintedFields); s != null; s = s.next(), i++) {\n            if (sb.length() > 0) {\n              sb.append(\", \");\n            }\n            String bName = ((Symbol) s.first()).name;\n            Class k = tagClass(tagOf(s.first()));\n\n            others.append(\".without(Keyword.intern(\\\"\" + bName + \"\\\"))\");\n            String val = \"map.valAt(Keyword.intern(\\\"\" + bName + \"\\\"), null)\";\n            if (k.isPrimitive()) {\n              sb.append(\"(\" + printClass(boxClass(k)) + \")\" + val);\n            } else {\n              sb.append(val);\n            }\n\n            mv.visitVarInsn(ALOAD, 0);\n            mv.visitLdcInsn(bName);\n            mv.visitMethodInsn(INVOKESTATIC, \"clojure/lang/Keyword\", \"intern\",\n                \"(Ljava/lang/String;)Lclojure/lang/Keyword;\");\n            mv.visitInsn(ACONST_NULL);\n            mv.visitMethodInsn(INVOKEINTERFACE, \"clojure/lang/IPersistentMap\",\n                \"valAt\",\n                \"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\");\n            if (k.isPrimitive()) {\n              mv.visitTypeInsn(CHECKCAST, Type.getType(boxClass(k))\n                  .getInternalName());\n            }\n            mv.visitVarInsn(ASTORE, i);\n            mv.visitVarInsn(ALOAD, 0);\n            mv.visitLdcInsn(bName);\n            mv.visitMethodInsn(INVOKESTATIC, \"clojure/lang/Keyword\", \"intern\",\n                \"(Ljava/lang/String;)Lclojure/lang/Keyword;\");\n            mv.visitMethodInsn(INVOKEINTERFACE, \"clojure/lang/IPersistentMap\",\n                \"without\", \"(Ljava/lang/Object;)Lclojure/lang/IPersistentMap;\");\n            mv.visitVarInsn(ASTORE, 0);\n          }\n\n          mv.visitTypeInsn(Opcodes.NEW, className);\n          mv.visitInsn(DUP);\n\n          Method ctor = new Method(\"<init>\", Type.VOID_TYPE, ctorTypes());\n\n          if (hintedFields.count() > 0) {\n            for (i = 1; i <= fieldCount; i++) {\n              mv.visitVarInsn(ALOAD, i);\n              Class k = tagClass(tagOf(hintedFields.nth(i - 1)));\n              if (k.isPrimitive()) {\n                String b = Type.getType(boxClass(k)).getInternalName();\n                String p = Type.getType(k).getDescriptor();\n                String n = k.getName();\n\n                mv.visitMethodInsn(INVOKEVIRTUAL, b, n + \"Value\", \"()\" + p);\n              }\n            }\n          }\n\n          emitSource(\"return new \" + printClass(name) + \"(\" + sb\n              + (sb.length() > 0 ? \", \" : \"\") + \"null, RT.seqOrElse(map\"\n              + others + \"));\");\n\n          mv.visitInsn(ACONST_NULL);\n          mv.visitVarInsn(ALOAD, 0);\n          mv.visitMethodInsn(INVOKESTATIC, \"clojure/lang/RT\", \"seqOrElse\",\n              \"(Ljava/lang/Object;)Ljava/lang/Object;\");\n          mv.visitMethodInsn(INVOKESPECIAL, className, \"<init>\",\n              ctor.getDescriptor());\n          mv.visitInsn(ARETURN);\n          mv.visitMaxs(4 + fieldCount, 1 + fieldCount);\n          mv.visitEnd();\n          untab();\n          emitSource(\"}\");\n        }\n      }\n    }\n\n    protected void emitMethods(ClassVisitor cv) {\n      for (ISeq s = RT.seq(methods); s != null; s = s.next()) {\n        ObjMethod method = (ObjMethod) s.first();\n        method.emit(this, cv);\n      }\n\n      for (ISeq i = overrideMethods.seq(); i != null; i = i.next()) {\n        java.lang.reflect.Method m = (java.lang.reflect.Method) i.first();\n        StringBuilder sb = new StringBuilder();\n        int n = 0;\n        for (Class<?> p : m.getParameterTypes()) {\n          if (sb.length() > 0) {\n            sb.append(\", \");\n          }\n          sb.append(printClass(p) + \" p\" + n);\n          n++;\n        }\n        StringBuilder exs = new StringBuilder();\n        for (Class<?> e : m.getExceptionTypes()) {\n          if (exs.length() > 0) {\n            exs.append(\", \");\n          }\n          exs.append(printClass(e));\n        }\n        emitSource(\"public \" + printClass(m.getReturnType()) + \" \"\n            + m.getName() + \"(\" + sb + \") \"\n            + (exs.length() > 0 ? \"throws \" : \"\") + exs + \" {\");\n        tab();\n        emitSource(\"throw new RuntimeException(\\\"Reify non implemented method\\\");\");\n        untab();\n        emitSource(\"}\");\n      }\n\n      // emit bridge methods\n      for (Map.Entry<IPersistentVector, Set<Class>> e : covariants.entrySet()) {\n        java.lang.reflect.Method m = mmap.get(e.getKey());\n        Class[] params = m.getParameterTypes();\n        Type[] argTypes = new Type[params.length];\n\n        for (int i = 0; i < params.length; i++) {\n          argTypes[i] = Type.getType(params[i]);\n        }\n\n        Method target = new Method(m.getName(),\n            Type.getType(m.getReturnType()), argTypes);\n\n        for (Class retType : e.getValue()) {\n          Method meth = new Method(m.getName(), Type.getType(retType), argTypes);\n          GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC + ACC_BRIDGE,\n              meth, null,\n              // todo don't hardwire this\n              EXCEPTION_TYPES, cv);\n\n          gen.visitCode();\n          gen.loadThis();\n          gen.loadArgs();\n          gen.invokeInterface(Type.getType(m.getDeclaringClass()), target);\n          gen.returnValue();\n          gen.endMethod();\n        }\n      }\n    }\n\n    static public IPersistentVector msig(java.lang.reflect.Method m) {\n      return RT.vector(m.getName(), RT.seq(m.getParameterTypes()),\n          m.getReturnType());\n    }\n\n    static void considerMethod(java.lang.reflect.Method m, Map mm) {\n      IPersistentVector mk = msig(m);\n      int mods = m.getModifiers();\n\n      if (!(mm.containsKey(mk)\n          || !(Modifier.isPublic(mods) || Modifier.isProtected(mods))\n          || Modifier.isStatic(mods) || Modifier.isFinal(mods))) {\n        mm.put(mk, m);\n      }\n    }\n\n    static void gatherMethods(Class c, Map mm) {\n      for (; c != null; c = c.getSuperclass()) {\n        for (java.lang.reflect.Method m : c.getDeclaredMethods())\n          considerMethod(m, mm);\n        for (java.lang.reflect.Method m : c.getMethods())\n          considerMethod(m, mm);\n      }\n    }\n\n    static public Map[] gatherMethods(Class sc, ISeq interfaces) {\n      Map<Class, Map<String, Class>> parameters = new HashMap<Class, Map<String, Class>>();\n\n      Map allm = new HashMap();\n      gatherMethods(sc, allm);\n      for (; interfaces != null; interfaces = interfaces.next()) {\n        Class i = (Class) interfaces.first();\n        gatherMethods(i, allm);\n\n        for (java.lang.reflect.Type t : i.getGenericInterfaces()) {\n          if (t instanceof ParameterizedType) {\n            ParameterizedType p = (ParameterizedType) t;\n            Class r = (Class) p.getRawType();\n            TypeVariable[] l = r.getTypeParameters();\n            java.lang.reflect.Type[] k = p.getActualTypeArguments();\n            if (l.length != k.length) {\n              throw new RuntimeException();\n            }\n            HashMap<String, Class> params = new HashMap<String, Class>();\n            for (int j = 0; j < k.length; j++) {\n              if (k[j] instanceof Class) {\n                params.put(l[j].toString(), (Class) k[j]);\n              }\n            }\n            if (!params.isEmpty()) {\n              parameters.put((Class) ((ParameterizedType) t).getRawType(),\n                  params);\n            }\n          }\n        }\n      }\n\n      Map<IPersistentVector, java.lang.reflect.Method> mm = new HashMap<IPersistentVector, java.lang.reflect.Method>();\n      Map<IPersistentVector, Set<Class>> covariants = new HashMap<IPersistentVector, Set<Class>>();\n      for (Object o : allm.entrySet()) {\n        Map.Entry e = (Map.Entry) o;\n        IPersistentVector mk = (IPersistentVector) e.getKey();\n        mk = (IPersistentVector) mk.pop();\n        java.lang.reflect.Method m = (java.lang.reflect.Method) e.getValue();\n        if (mm.containsKey(mk)) // covariant return\n        {\n          Set<Class> cvs = covariants.get(mk);\n          if (cvs == null) {\n            cvs = new HashSet<Class>();\n            covariants.put(mk, cvs);\n          }\n          java.lang.reflect.Method om = mm.get(mk);\n          if (om.getReturnType().isAssignableFrom(m.getReturnType())) {\n            cvs.add(om.getReturnType());\n            mm.put(mk, m);\n          } else\n            cvs.add(m.getReturnType());\n        } else\n          mm.put(mk, m);\n      }\n      return new Map[] { mm, covariants, parameters };\n    }\n  }\n\n  public static class NewInstanceMethod extends ObjMethod {\n    String name;\n    Type[] argTypes;\n    Type retType;\n    Class retClass;\n    Class[] exclasses;\n\n    static Symbol dummyThis = Symbol.intern(null, \"dummy_this_dlskjsdfower\");\n    private IPersistentVector parms;\n    private Symbol thisName;\n    private Object mk;\n\n    public NewInstanceMethod(ObjExpr objx, ObjMethod parent) {\n      super(objx, parent);\n    }\n\n    int numParams() {\n      return argLocals.count();\n    }\n\n    String getMethodName() {\n      return name;\n    }\n\n    Type getReturnType() {\n      return retType;\n    }\n\n    Type[] getArgTypes() {\n      return argTypes;\n    }\n\n    static public IPersistentVector msig(String name,\n        java.lang.reflect.Type[] paramTypes) {\n      return RT.vector(name, RT.seq(paramTypes));\n    }\n\n    static NewInstanceMethod parse(ObjExpr objx, ISeq form, Symbol thistag,\n        Map overrideables, Map parameters) {\n      // (methodname [this-name args*] body...)\n      // this-name might be nil\n      NewInstanceMethod method = new NewInstanceMethod(objx,\n          (ObjMethod) METHOD.deref());\n      Symbol dotname = (Symbol) RT.first(form);\n      Symbol name = (Symbol) Symbol.intern(null, munge(dotname.name)).withMeta(\n          RT.meta(dotname));\n      IPersistentVector parms = (IPersistentVector) RT.second(form);\n      if (parms.count() == 0) {\n        throw new IllegalArgumentException(\n            \"Must supply at least one argument for 'this' in: \" + dotname);\n      }\n      Symbol thisName = (Symbol) parms.nth(0);\n      parms = RT.subvec(parms, 1, parms.count());\n      ISeq body = RT.next(RT.next(form));\n      try {\n        method.line = lineDeref();\n        method.column = columnDeref();\n        // register as the current method and set up a new env frame\n        PathNode pnode = new PathNode(PATHTYPE.PATH,\n            (PathNode) CLEAR_PATH.get());\n        Var.pushThreadBindings(RT.mapUniqueKeys(METHOD, method, LOCAL_ENV,\n            LOCAL_ENV.deref(), LOOP_LOCALS, null, NEXT_LOCAL_NUM, 0,\n            CLEAR_PATH, pnode, CLEAR_ROOT, pnode, CLEAR_SITES,\n            PersistentHashMap.EMPTY));\n\n        // register 'this' as local 0\n        if (thisName != null)\n          registerLocal((thisName == null) ? dummyThis : thisName, thistag,\n              null, false);\n        else\n          getAndIncLocalNum();\n\n        PersistentVector argLocals = PersistentVector.EMPTY;\n        method.thisName = thisName;\n        method.retClass = tagClass(tagOf(name));\n        method.argTypes = new Type[parms.count()];\n        boolean hinted = tagOf(name) != null;\n        Class[] pclasses = new Class[parms.count()];\n        java.lang.reflect.Type[] gclasses = new java.lang.reflect.Type[parms\n            .count()];\n        Symbol[] psyms = new Symbol[parms.count()];\n\n        for (int i = 0; i < parms.count(); i++) {\n          if (!(parms.nth(i) instanceof Symbol))\n            throw new IllegalArgumentException(\"params must be Symbols\");\n          Symbol p = (Symbol) parms.nth(i);\n          Object tag = tagOf(p);\n          if (tag != null)\n            hinted = true;\n          if (p.getNamespace() != null)\n            p = Symbol.intern(p.name);\n          Class pclass = tagClass(tag);\n          pclasses[i] = pclass;\n          psyms[i] = p;\n        }\n        Map matches = findMethodsWithNameAndArity(name.name, parms.count(),\n            overrideables);\n        Object mk = msig(name.name, pclasses);\n        java.lang.reflect.Method m = null;\n        if (matches.size() > 0) {\n          // multiple methods\n          if (matches.size() > 1) {\n            // must be hinted and match one method\n            if (!hinted)\n              throw new IllegalArgumentException(\n                  \"Must hint overloaded method: \" + name.name);\n            m = (java.lang.reflect.Method) matches.get(mk);\n            if (m == null)\n              throw new IllegalArgumentException(\n                  \"Can't find matching overloaded method: \" + name.name);\n            if (m.getReturnType() != method.retClass)\n              throw new IllegalArgumentException(\"Mismatched return type: \"\n                  + name.name + \", expected: \" + m.getReturnType().getName()\n                  + \", had: \" + method.retClass.getName());\n          } else // one match\n          {\n            // if hinted, validate match,\n            if (hinted) {\n              m = (java.lang.reflect.Method) matches.get(mk);\n              if (m == null)\n                throw new IllegalArgumentException(\n                    \"Can't find matching method: \" + name.name\n                        + \", leave off hints for auto match.\");\n              if (m.getReturnType() != method.retClass)\n                throw new IllegalArgumentException(\"Mismatched return type: \"\n                    + name.name + \", expected: \" + m.getReturnType().getName()\n                    + \", had: \" + method.retClass.getName());\n            } else // adopt found method sig\n            {\n              m = (java.lang.reflect.Method) matches.values().iterator().next();\n              method.retClass = m.getReturnType();\n              pclasses = m.getParameterTypes();\n              gclasses = m.getGenericParameterTypes();\n            }\n          }\n        }\n        // else if(findMethodsWithName(name.name,allmethods).size()>0)\n        // throw new IllegalArgumentException(\"Can't override/overload method: \"\n        // + name.name);\n        else\n          throw new IllegalArgumentException(\n              \"Can't define method not in interfaces: \" + name.name);\n\n        // else\n        // validate unque name+arity among additional methods\n\n        IPersistentVector types = RT.vector();\n        for (Class<?> t : m.getParameterTypes()) {\n          types = types.cons(t);\n        }\n        method.mk = RT.vector(m.getName(), types.seq());\n        method.retType = Type.getType(method.retClass);\n        method.exclasses = m.getExceptionTypes();\n\n        for (int i = 0; i < parms.count(); i++) {\n          java.lang.reflect.Type c = pclasses[i];\n          if (!parameters.isEmpty() && gclasses[i] != null) {\n            if (gclasses[i] instanceof TypeVariable) {\n              Map pm = (Map) parameters.get(m.getDeclaringClass());\n              String key = gclasses[i].toString();\n              if (pm != null && pm.containsKey(key)) {\n                c = (java.lang.reflect.Type) pm.get(key);\n              }\n            }\n          }\n          LocalBinding lb = registerLocal(psyms[i], null, new MethodParamExpr(\n              (Class) c), true);\n          argLocals = argLocals.assocN(i, lb);\n          method.argTypes[i] = Type.getType((Class) c);\n        }\n        for (int i = 0; i < parms.count(); i++) {\n          if (pclasses[i] == long.class || pclasses[i] == double.class)\n            getAndIncLocalNum();\n        }\n        LOOP_LOCALS.set(argLocals);\n        method.name = name.name;\n        method.methodMeta = RT.meta(name);\n        method.parms = parms;\n        method.argLocals = argLocals;\n        method.body = (new BodyExpr.Parser()).parse(C.RETURN, body);\n        return method;\n      } finally {\n        Var.popThreadBindings();\n      }\n    }\n\n    private static Map findMethodsWithNameAndArity(String name, int arity,\n        Map mm) {\n      Map ret = new HashMap();\n      for (Object o : mm.entrySet()) {\n        Map.Entry e = (Map.Entry) o;\n        java.lang.reflect.Method m = (java.lang.reflect.Method) e.getValue();\n        if (name.equals(m.getName()) && m.getParameterTypes().length == arity)\n          ret.put(e.getKey(), e.getValue());\n      }\n      return ret;\n    }\n\n    // private static Map findMethodsWithName(String name, Map mm) {\n    // Map ret = new HashMap();\n    // for (Object o : mm.entrySet()) {\n    // Map.Entry e = (Map.Entry) o;\n    // java.lang.reflect.Method m = (java.lang.reflect.Method) e.getValue();\n    // if (name.equals(m.getName()))\n    // ret.put(e.getKey(), e.getValue());\n    // }\n    // return ret;\n    // }\n\n    public void emit(ObjExpr obj, ClassVisitor cv) {\n      Method m = new Method(getMethodName(), getReturnType(), getArgTypes());\n      StringBuilder params = new StringBuilder();\n      int pos = 0;\n      for (ISeq lbs = argLocals.seq(); lbs != null; lbs = lbs.next()) {\n        LocalBinding lb = (LocalBinding) lbs.first();\n        if (params.length() > 0) {\n          params.append(\", \");\n        }\n        params.append(printClass(getArgTypes()[pos]) + \" \" + lb.print());\n        pos++;\n      }\n\n      Type[] extypes = null;\n      StringBuilder exs = null;\n      if (exclasses.length > 0) {\n        exs = new StringBuilder();\n        extypes = new Type[exclasses.length];\n        for (int i = 0; i < exclasses.length; i++) {\n          if (exs.length() > 0) {\n            exs.append(\", \");\n          }\n          extypes[i] = Type.getType(exclasses[i]);\n          exs.append(printClass(exclasses[i]));\n        }\n      }\n\n      GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC, m, null, extypes,\n          cv);\n      addAnnotation(gen, methodMeta);\n\n      emitSource(\"public \" + printClass(getReturnType()) + \" \"\n          + getMethodName() + \"(\" + params + \") \"\n          + (exclasses.length > 0 ? \"throws \" + exs.toString() : \"\") + \" {\");\n      tab();\n\n      if (hasException) {\n        emitSource(\"try {\");\n        tab();\n      }\n      if (hasRecur) {\n        emitSource(\"while(true) {\");\n        tab();\n      }\n\n      for (int i = 0; i < parms.count(); i++) {\n        IPersistentMap meta = RT.meta(parms.nth(i));\n        addParameterAnnotation(gen, meta, i);\n      }\n      gen.visitCode();\n\n      Label loopLabel = gen.mark();\n\n      gen.visitLineNumber(line, loopLabel);\n      try {\n        Var.pushThreadBindings(RT.map(LOOP_LABEL, loopLabel, METHOD, this));\n\n        String b = emitBody(objx, gen, retClass, body);\n        if (b != null) {\n          emitSource(b);\n        }\n        Label end = gen.mark();\n        gen.visitLocalVariable(\"this\", obj.objtype.getDescriptor(), null,\n            loopLabel, end, 0);\n        for (ISeq lbs = argLocals.seq(); lbs != null; lbs = lbs.next()) {\n          LocalBinding lb = (LocalBinding) lbs.first();\n          gen.visitLocalVariable(lb.name, argTypes[lb.idx - 1].getDescriptor(),\n              null, loopLabel, end, lb.idx);\n        }\n      } finally {\n        Var.popThreadBindings();\n      }\n\n      gen.returnValue();\n      // gen.visitMaxs(1, 1);\n      gen.endMethod();\n\n      if (hasRecur) {\n        untab();\n        emitSource(\"}\");\n      }\n      if (hasException) {\n        untab();\n        emitSource(\"} catch (Exception ___e) {\");\n        tab();\n        emitSource(\"throw Util.sneakyThrow(___e);\");\n        untab();\n        emitSource(\"}\");\n      }\n      untab();\n      emitSource(\"}\");\n    }\n  }\n\n  static Class primClass(Symbol sym) {\n    if (sym == null)\n      return null;\n    Class c = null;\n    if (sym.name.equals(\"int\"))\n      c = int.class;\n    else if (sym.name.equals(\"long\"))\n      c = long.class;\n    else if (sym.name.equals(\"float\"))\n      c = float.class;\n    else if (sym.name.equals(\"double\"))\n      c = double.class;\n    else if (sym.name.equals(\"char\"))\n      c = char.class;\n    else if (sym.name.equals(\"short\"))\n      c = short.class;\n    else if (sym.name.equals(\"byte\"))\n      c = byte.class;\n    else if (sym.name.equals(\"boolean\"))\n      c = boolean.class;\n    else if (sym.name.equals(\"void\"))\n      c = void.class;\n    return c;\n  }\n\n  static Class tagClass(Object tag) {\n    if (tag == null)\n      return Object.class;\n    Class c = null;\n    if (tag instanceof Symbol)\n      c = primClass((Symbol) tag);\n    if (c == null)\n      c = HostExpr.tagToClass(tag);\n    return c;\n  }\n\n  static Class primClass(Class c) {\n    return c.isPrimitive() ? c : Object.class;\n  }\n\n  static Class boxClass(Class p) {\n    if (!p.isPrimitive())\n      return p;\n\n    Class c = null;\n\n    if (p == Integer.TYPE)\n      c = Integer.class;\n    else if (p == Long.TYPE)\n      c = Long.class;\n    else if (p == Float.TYPE)\n      c = Float.class;\n    else if (p == Double.TYPE)\n      c = Double.class;\n    else if (p == Character.TYPE)\n      c = Character.class;\n    else if (p == Short.TYPE)\n      c = Short.class;\n    else if (p == Byte.TYPE)\n      c = Byte.class;\n    else if (p == Boolean.TYPE)\n      c = Boolean.class;\n\n    return c;\n  }\n\n  static public class MethodParamExpr implements Expr, MaybePrimitiveExpr {\n    final Class c;\n\n    public MethodParamExpr(Class c) {\n      this.c = c;\n    }\n\n    public Object eval() {\n      throw Util.runtimeException(\"Can't eval\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      throw Util.runtimeException(\"Can't emit\");\n    }\n\n    public boolean hasJavaClass() {\n      return c != null;\n    }\n\n    public Class getJavaClass() {\n      return c;\n    }\n\n    public boolean canEmitPrimitive() {\n      return Util.isPrimitive(c);\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      throw Util.runtimeException(\"Can't emit\");\n    }\n  }\n\n  public static class CaseExpr implements Expr, MaybePrimitiveExpr {\n    public final LocalBindingExpr expr;\n    public final int shift, mask, low, high;\n    public final Expr defaultExpr;\n    public final SortedMap<Integer, Expr> tests;\n    public final HashMap<Integer, Expr> thens;\n    public final Keyword switchType;\n    public final Keyword testType;\n    public final Set<Integer> skipCheck;\n    public final Class returnType;\n    public final int line;\n    public final int column;\n\n    final static Type NUMBER_TYPE = Type.getType(Number.class);\n    final static Method intValueMethod = Method.getMethod(\"int intValue()\");\n\n    final static Method hashMethod = Method.getMethod(\"int hash(Object)\");\n    final static Method hashCodeMethod = Method.getMethod(\"int hashCode()\");\n    final static Method equivMethod = Method\n        .getMethod(\"boolean equiv(Object, Object)\");\n    final static Keyword compactKey = Keyword.intern(null, \"compact\");\n    final static Keyword sparseKey = Keyword.intern(null, \"sparse\");\n    final static Keyword hashIdentityKey = Keyword\n        .intern(null, \"hash-identity\");\n    final static Keyword hashEquivKey = Keyword.intern(null, \"hash-equiv\");\n    final static Keyword intKey = Keyword.intern(null, \"int\");\n\n    // (case* expr shift mask default map<minhash, [test then]> table-type\n    // test-type skip-check?)\n    public CaseExpr(int line, int column, LocalBindingExpr expr, int shift,\n        int mask, int low, int high, Expr defaultExpr,\n        SortedMap<Integer, Expr> tests, HashMap<Integer, Expr> thens,\n        Keyword switchType, Keyword testType, Set<Integer> skipCheck) {\n      this.expr = expr;\n      this.shift = shift;\n      this.mask = mask;\n      this.low = low;\n      this.high = high;\n      this.defaultExpr = defaultExpr;\n      this.tests = tests;\n      this.thens = thens;\n      this.line = line;\n      this.column = column;\n      if (switchType != compactKey && switchType != sparseKey)\n        throw new IllegalArgumentException(\"Unexpected switch type: \"\n            + switchType);\n      this.switchType = switchType;\n      if (testType != intKey && testType != hashEquivKey\n          && testType != hashIdentityKey)\n        throw new IllegalArgumentException(\"Unexpected test type: \"\n            + switchType);\n      this.testType = testType;\n      this.skipCheck = skipCheck;\n      Collection<Expr> returns = new ArrayList(thens.values());\n      returns.add(defaultExpr);\n      this.returnType = maybeJavaClass(returns);\n      if (RT.count(skipCheck) > 0\n          && RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) {\n        RT.errPrintWriter()\n            .format(\n                \"Performance warning, %s:%d:%d - hash collision of some case test constants; if selected, those entries will be tested sequentially.\\n\",\n                SOURCE_PATH.deref(), line, column);\n      }\n    }\n\n    public boolean hasJavaClass() {\n      return returnType != null;\n    }\n\n    public boolean canEmitPrimitive() {\n      return Util.isPrimitive(returnType);\n    }\n\n    public Class getJavaClass() {\n      return returnType;\n    }\n\n    public Object eval() {\n      throw new UnsupportedOperationException(\"Can't eval case\");\n    }\n\n    public String emit(C context, ObjExpr objx, GeneratorAdapter gen) {\n      return doEmit(context, objx, gen, false);\n    }\n\n    public String emitUnboxed(C context, ObjExpr objx, GeneratorAdapter gen) {\n      return doEmit(context, objx, gen, true);\n    }\n\n    public String doEmit(C context, ObjExpr objx, GeneratorAdapter gen,\n        boolean emitUnboxed) {\n      String r = registerTemp();\n      Label defaultLabel = gen.newLabel();\n      Label endLabel = gen.newLabel();\n      SortedMap<Integer, Label> labels = new TreeMap();\n\n      if (context == C.EXPRESSION) {\n        emitSource(\"Object \" + r + \" = null;\");\n      }\n\n      for (Integer i : tests.keySet()) {\n        labels.put(i, gen.newLabel());\n      }\n\n      gen.visitLineNumber(line, gen.mark());\n\n      Class primExprClass = maybePrimitiveType(expr);\n      Type primExprType = primExprClass == null ? null : Type\n          .getType(primExprClass);\n\n      String cond;\n      if (testType == intKey)\n        cond = emitExprForInts(objx, gen, primExprType, defaultLabel);\n      else\n        cond = emitExprForHashes(objx, gen);\n\n      emitSource(\"switch (\" + cond + \") {\");\n      tab();\n\n      if (switchType == sparseKey) {\n        Label[] la = new Label[labels.size()];\n        la = labels.values().toArray(la);\n        int[] ints = Numbers.int_array(tests.keySet());\n        gen.visitLookupSwitchInsn(defaultLabel, ints, la);\n      } else {\n        Label[] la = new Label[(high - low) + 1];\n        for (int i = low; i <= high; i++) {\n          la[i - low] = labels.containsKey(i) ? labels.get(i) : defaultLabel;\n        }\n        gen.visitTableSwitchInsn(low, high, defaultLabel, la);\n      }\n\n      int pos = 0;\n      for (Integer i : labels.keySet()) {\n        emitSource(\"case \" + i + \":\");\n        pos++;\n        tab();\n        gen.mark(labels.get(i));\n        if (testType == intKey) {\n          emitThenForInts(context, r, objx, gen, primExprType, tests.get(i),\n              thens.get(i), defaultLabel, emitUnboxed);\n        } else if (RT.contains(skipCheck, i) == RT.T) {\n          String e = emitExpr(context, objx, gen, thens.get(i), emitUnboxed);\n          if (e != null) {\n            if (context != C.STATEMENT) {\n              emitAssigRet(context, r, e);\n            }\n          }\n          if (context != C.RETURN) {\n            emitSource(\"break;\");\n          }\n        } else {\n          emitThenForHashes(context, r, objx, gen, tests.get(i), thens.get(i),\n              defaultLabel, emitUnboxed);\n        }\n        gen.goTo(endLabel);\n        untab();\n      }\n      gen.mark(defaultLabel);\n      emitSource(\"default:\");\n      tab();\n      String e = emitExpr(context, objx, gen, defaultExpr, emitUnboxed);\n      if (e != null) {\n        if (context != C.STATEMENT) {\n          emitAssigRet(context, r, e);\n        }\n      }\n      untab();\n      untab();\n      emitSource(\"}\");\n      gen.mark(endLabel);\n      return context == C.EXPRESSION ? r : \"\";\n    }\n\n    private boolean isShiftMasked() {\n      return mask != 0;\n    }\n\n    private String emitShiftMask(GeneratorAdapter gen, String v) {\n      if (isShiftMasked()) {\n        gen.push(shift);\n        gen.visitInsn(ISHR);\n        gen.push(mask);\n        gen.visitInsn(IAND);\n\n        return v + \" >> \" + shift + \" & \" + mask;\n      }\n      return v;\n    }\n\n    private String emitExprForInts(ObjExpr objx, GeneratorAdapter gen,\n        Type exprType, Label defaultLabel) {\n      if (exprType == null) {\n        if (RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) {\n          RT.errPrintWriter()\n              .format(\n                  \"Performance warning, %s:%d:%d - case has int tests, but tested expression is not primitive.\\n\",\n                  SOURCE_PATH.deref(), line, column);\n        }\n        String val = expr.emit(C.EXPRESSION, objx, gen);\n        gen.instanceOf(NUMBER_TYPE);\n        gen.ifZCmp(GeneratorAdapter.EQ, defaultLabel);\n        expr.emit(C.EXPRESSION, objx, gen);\n        gen.checkCast(NUMBER_TYPE);\n        gen.invokeVirtual(NUMBER_TYPE, intValueMethod);\n        return emitShiftMask(gen, \"RT.uncheckedIntCast(\" + val + \")\");\n      } else if (exprType == Type.LONG_TYPE || exprType == Type.INT_TYPE\n          || exprType == Type.SHORT_TYPE || exprType == Type.BYTE_TYPE) {\n        String val = expr.emitUnboxed(C.EXPRESSION, objx, gen);\n        gen.cast(exprType, Type.INT_TYPE);\n        return emitShiftMask(gen, \"(int)\" + val);\n      } else {\n        gen.goTo(defaultLabel);\n        return \"-666123\"; // Magic number to jump to default TODO proper impl\n      }\n    }\n\n    private void emitThenForInts(C context, String r, ObjExpr objx,\n        GeneratorAdapter gen, Type exprType, Expr test, Expr then,\n        Label defaultLabel, boolean emitUnboxed) {\n      if (exprType == null) {\n        String val = expr.emit(C.EXPRESSION, objx, gen);\n        String tval = test.emit(C.EXPRESSION, objx, gen);\n        gen.invokeStatic(UTIL_TYPE, equivMethod);\n        gen.ifZCmp(GeneratorAdapter.EQ, defaultLabel);\n        emitSource(\"if (Util.equiv(\" + val + \", \" + tval + \")) {\");\n        tab();\n        String body = emitExpr(context, objx, gen, then, emitUnboxed);\n        if (body != null) {\n          if (context != C.STATEMENT) {\n            emitAssigRet(context, r, body);\n          }\n        }\n        if (context != C.RETURN) {\n          emitSource(\"break;\");\n        }\n        untab();\n        emitSource(\"}\");\n      } else if (exprType == Type.LONG_TYPE) {\n        String val = ((NumberExpr) test).emitUnboxed(C.EXPRESSION, objx, gen);\n        String tval = expr.emitUnboxed(C.EXPRESSION, objx, gen);\n        gen.ifCmp(Type.LONG_TYPE, GeneratorAdapter.NE, defaultLabel);\n        emitSource(\"if (\" + val + \" == \" + tval + \") {\");\n        tab();\n        String body = emitExpr(context, objx, gen, then, emitUnboxed);\n        if (body != null) {\n          if (context != C.STATEMENT) {\n            emitAssigRet(context, r, body);\n          }\n        }\n        if (context != C.RETURN) {\n          emitSource(\"break;\");\n        }\n        untab();\n        emitSource(\"}\");\n      } else if (exprType == Type.INT_TYPE || exprType == Type.SHORT_TYPE\n          || exprType == Type.BYTE_TYPE) {\n        if (isShiftMasked()) {\n          ((NumberExpr) test).emitUnboxed(C.EXPRESSION, objx, gen);\n          expr.emitUnboxed(C.EXPRESSION, objx, gen);\n          gen.cast(exprType, Type.LONG_TYPE);\n          gen.ifCmp(Type.LONG_TYPE, GeneratorAdapter.NE, defaultLabel);\n        }\n        String val = ((NumberExpr) test).n.toString();\n        String tval = expr.b.print();\n\n        emitSource(\"if (\" + val + \" == \" + tval + \") {\");\n        tab();\n\n        // else direct match\n        String body = emitExpr(context, objx, gen, then, emitUnboxed);\n\n        if (body != null) {\n          if (context != C.STATEMENT) {\n            emitAssigRet(context, r, body);\n          }\n        }\n        if (context != C.RETURN) {\n          emitSource(\"break;\");\n        }\n        untab();\n        emitSource(\"}\");\n      } else {\n        gen.goTo(defaultLabel);\n      }\n    }\n\n    private String emitExprForHashes(ObjExpr objx, GeneratorAdapter gen) {\n      String val = expr.emit(C.EXPRESSION, objx, gen);\n      gen.invokeStatic(UTIL_TYPE, hashMethod);\n      return emitShiftMask(gen, \"Util.hash(\" + val + \")\");\n    }\n\n    private void emitThenForHashes(C context, String r, ObjExpr objx,\n        GeneratorAdapter gen, Expr test, Expr then, Label defaultLabel,\n        boolean emitUnboxed) {\n      String val = expr.emit(C.EXPRESSION, objx, gen);\n      String tval = test.emit(C.EXPRESSION, objx, gen);\n      if (testType == hashIdentityKey) {\n        gen.visitJumpInsn(IF_ACMPNE, defaultLabel);\n        emitSource(\"if (\" + val + \" == \" + tval + \") {\");\n      } else {\n        emitSource(\"if (Util.equiv(\" + val + \", \" + tval + \")) {\");\n        gen.invokeStatic(UTIL_TYPE, equivMethod);\n        gen.ifZCmp(GeneratorAdapter.EQ, defaultLabel);\n      }\n      tab();\n      String e = emitExpr(context, objx, gen, then, emitUnboxed);\n      if (e != null) {\n        if (context != C.STATEMENT) {\n          emitAssigRet(context, r, e);\n        }\n      }\n      if (context != C.RETURN) {\n        emitSource(\"break;\");\n      }\n      untab();\n      emitSource(\"}\");\n    }\n\n    private static String emitExpr(C context, ObjExpr objx, GeneratorAdapter gen,\n        Expr expr, boolean emitUnboxed) {\n      if (emitUnboxed && expr instanceof MaybePrimitiveExpr)\n        return ((MaybePrimitiveExpr) expr).emitUnboxed(context, objx, gen);\n      else\n        return expr.emit(context, objx, gen);\n    }\n\n    static class Parser implements IParser {\n      // (case* expr shift mask default map<minhash, [test then]> table-type\n      // test-type skip-check?)\n      // prepared by case macro and presumed correct\n      // case macro binds actual expr in let so expr is always a local,\n      // no need to worry about multiple evaluation\n      public Expr parse(C context, Object frm) {\n        ISeq form = (ISeq) frm;\n        if (context == C.EVAL)\n          return analyze(context,\n              RT.list(RT.list(FNONCE, PersistentVector.EMPTY, form)));\n        IPersistentVector args = LazilyPersistentVector.create(form.next());\n\n        Object exprForm = args.nth(0);\n        int shift = ((Number) args.nth(1)).intValue();\n        int mask = ((Number) args.nth(2)).intValue();\n        Object defaultForm = args.nth(3);\n        Map caseMap = (Map) args.nth(4);\n        Keyword switchType = ((Keyword) args.nth(5));\n        Keyword testType = ((Keyword) args.nth(6));\n        Set skipCheck = RT.count(args) < 8 ? null : (Set) args.nth(7);\n\n        ISeq keys = RT.keys(caseMap);\n        int low = ((Number) RT.first(keys)).intValue();\n        int high = ((Number) RT.nth(keys, RT.count(keys) - 1)).intValue();\n\n        LocalBindingExpr testexpr = (LocalBindingExpr) analyze(C.EXPRESSION,\n            exprForm);\n        testexpr.shouldClear = false;\n\n        SortedMap<Integer, Expr> tests = new TreeMap();\n        HashMap<Integer, Expr> thens = new HashMap();\n\n        PathNode branch = new PathNode(PATHTYPE.BRANCH,\n            (PathNode) CLEAR_PATH.get());\n\n        for (Object o : caseMap.entrySet()) {\n          Map.Entry e = (Map.Entry) o;\n          Integer minhash = ((Number) e.getKey()).intValue();\n          Object pair = e.getValue(); // [test-val then-expr]\n          Expr testExpr = testType == intKey ? NumberExpr.parse(((Number) RT\n              .first(pair)).intValue()) : new ConstantExpr(RT.first(pair));\n          tests.put(minhash, testExpr);\n\n          Expr thenExpr;\n          try {\n            Var.pushThreadBindings(RT.map(CLEAR_PATH, new PathNode(\n                PATHTYPE.PATH, branch)));\n            thenExpr = analyze(context, RT.second(pair));\n          } finally {\n            Var.popThreadBindings();\n          }\n          thens.put(minhash, thenExpr);\n        }\n\n        Expr defaultExpr;\n        try {\n          Var.pushThreadBindings(RT.map(CLEAR_PATH, new PathNode(PATHTYPE.PATH,\n              branch)));\n          defaultExpr = analyze(context, args.nth(3));\n        } finally {\n          Var.popThreadBindings();\n        }\n\n        int line = ((Number) LINE.deref()).intValue();\n        int column = ((Number) COLUMN.deref()).intValue();\n        return new CaseExpr(line, column, testexpr, shift, mask, low, high,\n            defaultExpr, tests, thens, switchType, testType, skipCheck);\n      }\n    }\n  }\n\n  static IPersistentCollection emptyVarCallSites() {\n    return PersistentHashSet.EMPTY;\n  }\n\n  private static String wrap(C context, String v) {\n    if (C.RETURN == context) {\n      Class retClass = RETURN_TYPE.isBound() ? (Class) RETURN_TYPE.deref()\n          : Object.class;\n      if (retClass != void.class) {\n        v = \"return \" + unboxVal(retClass, v);\n      } else {\n        v = \"return\";\n      }\n    }\n    return v + (C.EXPRESSION != context ? \";\" : \"\");\n  }\n\n  public static String unboxVal(Class c, String v) {\n    switch (Type.getType(c).getSort()) {\n    case Type.CHAR:\n      v = \"RT.charCast(\" + v + \")\";\n      break;\n    case Type.BOOLEAN:\n      v = \"RT.booleanCast(\" + v + \")\";\n      break;\n    case Type.DOUBLE:\n      v = \"RT.doubleCast(\" + v + \")\";\n      break;\n    case Type.FLOAT:\n      v = \"RT.floatCast(\" + v + \")\";\n      break;\n    case Type.LONG:\n      v = \"RT.longCast(\" + v + \")\";\n      break;\n    case Type.INT:\n    case Type.SHORT:\n    case Type.BYTE:\n      if (v.startsWith(\"((short)\") || v.startsWith(\"((byte)\")\n          || v.startsWith(\"((float)\") || v.startsWith(\"((double)\")\n          || v.startsWith(\"((long)\")) {\n        v = \"((int)\" + v + \")\";\n      } else if (!v.startsWith(\"((int)\")) {\n        v = \"RT.intCast(\" + v + \")\";\n      }\n      break;\n    default:\n      if (c != Object.class && c != void.class) {\n        v = \"(\" + printClass(c) + \")\" + v + \"\";\n      }\n      break;\n    }\n    return v;\n  }\n\n  private static void emitAssigRet(C context, String r, String body) {\n    boolean ex = context == C.EXPRESSION;\n    if (body.equals(\"continue;\")) {\n      emitSource(body);\n    } else {\n      emitSource((ex ? r + \" = \" : \"\") + body + (ex ? \";\" : \"\"));\n    }\n  }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Cons.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 25, 2006 11:01:29 AM */\n\npackage clojure.lang;\n\nimport java.io.Serializable;\n\nfinal public class Cons extends ASeq implements Serializable {\n\nprivate final Object _first;\nprivate final ISeq _more;\n\npublic Cons(Object first, ISeq _more){\n\tthis._first = first;\n\tthis._more = _more;\n}\n\n\npublic Cons(IPersistentMap meta, Object _first, ISeq _more){\n\tsuper(meta);\n\tthis._first = _first;\n\tthis._more = _more;\n}\n\npublic Object first(){\n\treturn _first;\n}\n\npublic ISeq next(){\n\treturn more().seq();\n}\n\npublic ISeq more(){\n\tif(_more == null)\n\t\treturn PersistentList.EMPTY;\n\treturn _more;\n}\n\npublic int count(){\n\treturn 1 + RT.count(_more);\n}\n\npublic Cons withMeta(IPersistentMap meta){\n\treturn new Cons(meta, _first, _more);\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Counted.java",
    "content": "package clojure.lang;\n\n/**\n * Copyright (c) Rich Hickey. All rights reserved.\n * The use and distribution terms for this software are covered by the\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n * which can be found in the file epl-v10.html at the root of this distribution.\n * By using this software in any fashion, you are agreeing to be bound by\n * the terms of this license.\n * You must not remove this notice, or any other, from this software.\n */\n\n/* A class that implements Counted promises that it is a collection\n * that implement a constant-time count() */\n\npublic interface Counted {\n    int count();\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Cycle.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\n/* Alex Miller, Dec 5, 2014 */\n\npublic class Cycle extends ASeq implements IReduce, IPending {\n\nprivate final ISeq all;      // never null\nprivate final ISeq prev;\nprivate volatile ISeq _current; // lazily realized\nprivate volatile ISeq _next;  // cached\n\nprivate Cycle(ISeq all, ISeq prev, ISeq current){\n    this.all = all;\n    this.prev = prev;\n    this._current = current;\n}\n\nprivate Cycle(IPersistentMap meta, ISeq all, ISeq prev, ISeq current, ISeq next){\n    super(meta);\n    this.all = all;\n    this.prev = prev;\n    this._current = current;\n    this._next = next;\n}\n\npublic static ISeq create(ISeq vals){\n    if(vals == null)\n        return PersistentList.EMPTY;\n    return new Cycle(vals, null, vals);\n}\n\n// realization for use of current\nprivate ISeq current() {\n    if(_current == null) {\n        ISeq current = prev.next();\n        _current = (current == null) ? all : current;\n    }\n    return _current;\n}\n\npublic boolean isRealized() {\n    return _current != null;\n}\n\npublic Object first(){\n    return current().first();\n}\n\npublic ISeq next(){\n    if(_next == null)\n        _next = new Cycle(all, current(), null);\n    return _next;\n}\n\npublic Cycle withMeta(IPersistentMap meta){\n    return new Cycle(meta, all, prev, _current, _next);\n}\n\npublic Object reduce(IFn f){\n    ISeq s = current();\n    Object ret = s.first();\n    while(true) {\n        s = s.next();\n        if(s == null)\n            s = all;\n        ret = f.invoke(ret, s.first());\n        if(RT.isReduced(ret))\n            return ((IDeref)ret).deref();\n    }\n}\n\npublic Object reduce(IFn f, Object start){\n    Object ret = start;\n    ISeq s = current();\n    while(true){\n        ret = f.invoke(ret, s.first());\n        if(RT.isReduced(ret))\n            return ((IDeref)ret).deref();\n        s = s.next();\n        if(s == null)\n            s = all;\n    }\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Delay.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jun 28, 2007 */\n\npackage clojure.lang;\n\npublic class Delay implements IDeref, IPending{\nObject val;\nThrowable exception;\nIFn fn;\n\npublic Delay(IFn fn){\n\tthis.fn = fn;\n\tthis.val = null;\n        this.exception = null;\n}\n\nstatic public Object force(Object x) {\n\treturn (x instanceof Delay) ?\n\t       ((Delay) x).deref()\n\t       : x;\n}\n\nsynchronized public Object deref() {\n\tif(fn != null)\n\t\t{\n\t\ttry\n\t\t\t{\n\t\t\tval = fn.invoke();\n\t\t\t}\n\t\tcatch(Throwable t)\n\t\t\t{\n\t\t\texception = t;\n\t\t\t}\n\t\tfn = null;\n\t\t}\n\tif(exception != null)\n\t\tthrow Util.sneakyThrow(exception);\n\treturn val;\n}\n\nsynchronized public boolean isRealized(){\n\treturn fn == null;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/DynamicClassLoader.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Aug 21, 2007 */\n\npackage clojure.lang;\n\nimport java.lang.ref.Reference;\nimport java.lang.ref.ReferenceQueue;\nimport java.lang.ref.SoftReference;\nimport java.net.URL;\nimport java.util.HashMap;\nimport java.util.concurrent.ConcurrentHashMap;\n\npublic class DynamicClassLoader extends URLClassLoader{\nHashMap<Integer, Object[]> constantVals = new HashMap<Integer, Object[]>();\nstatic ConcurrentHashMap<String, Reference<Class>>classCache =\n        new ConcurrentHashMap<String, Reference<Class> >();\n\nstatic final URL[] EMPTY_URLS = new URL[]{};\n\nstatic final ReferenceQueue rq = new ReferenceQueue();\n\npublic DynamicClassLoader(){\n    //pseudo test in lieu of hasContextClassLoader()\n\tsuper(EMPTY_URLS,(Thread.currentThread().getContextClassLoader() == null ||\n                Thread.currentThread().getContextClassLoader() == ClassLoader.getSystemClassLoader())?\n                Compiler.class.getClassLoader():Thread.currentThread().getContextClassLoader());\n}\n\npublic DynamicClassLoader(ClassLoader parent){\n\tsuper(EMPTY_URLS,parent);\n}\n\npublic Class defineClass(String name, byte[] bytes, Object srcForm){\n\tUtil.clearCache(rq, classCache);\n\tClass c = defineClass(name, bytes, 0, bytes.length);\n    classCache.put(name, new SoftReference(c,rq));\n    return c;\n}\n\nstatic Class<?> findInMemoryClass(String name) {\n    Reference<Class> cr = classCache.get(name);\n\tif(cr != null)\n\t\t{\n\t\tClass c = cr.get();\n        if(c != null)\n            return c;\n\t\telse\n\t        classCache.remove(name, cr);\n\t\t}\n\treturn null;\n}\n\nprotected Class<?>findClass(String name) throws ClassNotFoundException {\n\tClass c = findInMemoryClass(name);\n\tif (c != null)\n\t\treturn c;\n\telse\n\t\treturn super.findClass(name);\n}\n\nprotected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {\n\tClass c = findLoadedClass(name);\n\tif (c == null) {\n\t\tc = findInMemoryClass(name);\n\t\tif (c == null)\n\t\t\tc = super.loadClass(name, false);\n    }\n\tif (resolve)\n\t\tresolveClass(c);\n\treturn c;\n}\n\npublic void registerConstants(int id, Object[] val){\n\tconstantVals.put(id, val);\n}\n\npublic Object[] getConstants(int id){\n\treturn constantVals.get(id);\n}\n\npublic void addURL(URL url){\n\tsuper.addURL(url);\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/EdnReader.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.io.IOException;\nimport java.io.PushbackReader;\nimport java.io.Reader;\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\npublic class EdnReader{\n\nstatic IFn[] macros = new IFn[256];\nstatic IFn[] dispatchMacros = new IFn[256];\nstatic Pattern symbolPat = Pattern.compile(\"[:]?([\\\\D&&[^/]].*/)?(/|[\\\\D&&[^/]][^/]*)\");\nstatic Pattern intPat =\n\t\tPattern.compile(\n\t\t\t\t\"([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?\");\nstatic Pattern ratioPat = Pattern.compile(\"([-+]?[0-9]+)/([0-9]+)\");\nstatic Pattern floatPat = Pattern.compile(\"([-+]?[0-9]+(\\\\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?\");\n\nstatic IFn taggedReader = new TaggedReader();\n\nstatic\n\t{\n\tmacros['\"'] = new StringReader();\n\tmacros[';'] = new CommentReader();\n\tmacros['^'] = new MetaReader();\n\tmacros['('] = new ListReader();\n\tmacros[')'] = new UnmatchedDelimiterReader();\n\tmacros['['] = new VectorReader();\n\tmacros[']'] = new UnmatchedDelimiterReader();\n\tmacros['{'] = new MapReader();\n\tmacros['}'] = new UnmatchedDelimiterReader();\n\tmacros['\\\\'] = new CharacterReader();\n\tmacros['#'] = new DispatchReader();\n\n\n\tdispatchMacros['^'] = new MetaReader();\n\t//dispatchMacros['\"'] = new RegexReader();\n\tdispatchMacros['{'] = new SetReader();\n\tdispatchMacros['<'] = new UnreadableReader();\n\tdispatchMacros['_'] = new DiscardReader();\n\t}\n\nstatic boolean nonConstituent(int ch){\n\treturn ch == '@' || ch == '`' || ch == '~';\n}\n\nstatic public Object readString(String s, IPersistentMap opts){\n\tPushbackReader r = new PushbackReader(new java.io.StringReader(s));\n\treturn read(r, opts);\n}\n\nstatic boolean isWhitespace(int ch){\n\treturn Character.isWhitespace((char)ch) || ch == ',';\n}\n\nstatic void unread(PushbackReader r, int ch) {\n\tif(ch != -1)\n\t\ttry\n\t\t\t{\n\t\t\tr.unread(ch);\n\t\t\t}\n\t\tcatch(IOException e)\n\t\t\t{\n\t\t\tthrow Util.sneakyThrow(e);\n\t\t\t}\n}\n\npublic static class ReaderException extends RuntimeException{\n\tfinal int line;\n\tfinal int column;\n\n\tpublic ReaderException(int line, int column, Throwable cause){\n\t\tsuper(cause);\n\t\tthis.line = line;\n\t\tthis.column = column;\n\t}\n}\n\nstatic public int read1(Reader r){\n\ttry\n\t\t{\n\t\treturn r.read();\n\t\t}\n\tcatch(IOException e)\n\t\t{\n\t\tthrow Util.sneakyThrow(e);\n\t\t}\n}\n\nstatic final Keyword EOF = Keyword.intern(null,\"eof\");\n\nstatic public Object read(PushbackReader r, IPersistentMap opts){\n\treturn read(r,!opts.containsKey(EOF),opts.valAt(EOF),false,opts);\n}\n\nstatic public Object read(PushbackReader r, boolean eofIsError, Object eofValue, boolean isRecursive,\n                          Object opts)\n{\n\n\ttry\n\t\t{\n\t\tfor(; ;)\n\t\t\t{\n\t\t\tint ch = read1(r);\n\n\t\t\twhile(isWhitespace(ch))\n\t\t\t\tch = read1(r);\n\n\t\t\tif(ch == -1)\n\t\t\t\t{\n\t\t\t\tif(eofIsError)\n\t\t\t\t\tthrow Util.runtimeException(\"EOF while reading\");\n\t\t\t\treturn eofValue;\n\t\t\t\t}\n\n\t\t\tif(Character.isDigit((char)ch))\n\t\t\t\t{\n\t\t\t\tObject n = readNumber(r, (char) ch);\n\t\t\t\tif(RT.suppressRead())\n\t\t\t\t\treturn null;\n\t\t\t\treturn n;\n\t\t\t\t}\n\n\t\t\tIFn macroFn = getMacro(ch);\n\t\t\tif(macroFn != null)\n\t\t\t\t{\n\t\t\t\tObject ret = macroFn.invoke(r, (char) ch, opts);\n\t\t\t\tif(RT.suppressRead())\n\t\t\t\t\treturn null;\n\t\t\t\t//no op macros return the reader\n\t\t\t\tif(ret == r)\n\t\t\t\t\tcontinue;\n\t\t\t\treturn ret;\n\t\t\t\t}\n\n\t\t\tif(ch == '+' || ch == '-')\n\t\t\t\t{\n\t\t\t\tint ch2 = read1(r);\n\t\t\t\tif(Character.isDigit((char)ch2))\n\t\t\t\t\t{\n\t\t\t\t\tunread(r, ch2);\n\t\t\t\t\tObject n = readNumber(r, (char) ch);\n\t\t\t\t\tif(RT.suppressRead())\n\t\t\t\t\t\treturn null;\n\t\t\t\t\treturn n;\n\t\t\t\t\t}\n\t\t\t\tunread(r, ch2);\n\t\t\t\t}\n\n\t\t\tString token = readToken(r, (char) ch, true);\n\t\t\tif(RT.suppressRead())\n\t\t\t\treturn null;\n\t\t\treturn interpretToken(token);\n\t\t\t}\n\t\t}\n\tcatch(Exception e)\n\t\t{\n\t\tif(isRecursive || !(r instanceof LineNumberingPushbackReader))\n\t\t\tthrow Util.sneakyThrow(e);\n\t\tLineNumberingPushbackReader rdr = (LineNumberingPushbackReader) r;\n\t\t//throw Util.runtimeException(String.format(\"ReaderError:(%d,1) %s\", rdr.getLineNumber(), e.getMessage()), e);\n\t\tthrow new ReaderException(rdr.getLineNumber(), rdr.getColumnNumber(), e);\n\t\t}\n}\n\nstatic private String readToken(PushbackReader r, char initch, boolean leadConstituent) {\n\tStringBuilder sb = new StringBuilder();\n\tif(leadConstituent && nonConstituent(initch))\n\t\tthrow Util.runtimeException(\"Invalid leading character: \" + (char)initch);\n\n\tsb.append(initch);\n\n\tfor(; ;)\n\t\t{\n\t\tint ch = read1(r);\n\n\t\tif(ch == -1 || isWhitespace(ch) || isTerminatingMacro(ch))\n\t\t\t{\n\t\t\tunread(r, ch);\n\t\t\treturn sb.toString();\n\t\t\t}\n\t\telse if(nonConstituent(ch))\n\t\t\tthrow Util.runtimeException(\"Invalid constituent character: \" + (char)ch);\n\t\tsb.append((char) ch);\n\t\t}\n}\n\nstatic private Object readNumber(PushbackReader r, char initch) {\n\tStringBuilder sb = new StringBuilder();\n\tsb.append(initch);\n\n\tfor(; ;)\n\t\t{\n\t\tint ch = read1(r);\n\t\tif(ch == -1 || isWhitespace(ch) || isMacro(ch))\n\t\t\t{\n\t\t\tunread(r, ch);\n\t\t\tbreak;\n\t\t\t}\n\t\tsb.append((char) ch);\n\t\t}\n\n\tString s = sb.toString();\n\tObject n = matchNumber(s);\n\tif(n == null)\n\t\tthrow new NumberFormatException(\"Invalid number: \" + s);\n\treturn n;\n}\n\nstatic private int readUnicodeChar(String token, int offset, int length, int base) {\n\tif(token.length() != offset + length)\n\t\tthrow new IllegalArgumentException(\"Invalid unicode character: \\\\\" + token);\n\tint uc = 0;\n\tfor(int i = offset; i < offset + length; ++i)\n\t\t{\n\t\tint d = Character.digit(token.charAt(i), base);\n\t\tif(d == -1)\n\t\t\tthrow new IllegalArgumentException(\"Invalid digit: \" + token.charAt(i));\n\t\tuc = uc * base + d;\n\t\t}\n\treturn (char) uc;\n}\n\nstatic private int readUnicodeChar(PushbackReader r, int initch, int base, int length, boolean exact) {\n\tint uc = Character.digit((char)initch, base);\n\tif(uc == -1)\n\t\tthrow new IllegalArgumentException(\"Invalid digit: \" + (char) initch);\n\tint i = 1;\n\tfor(; i < length; ++i)\n\t\t{\n\t\tint ch = read1(r);\n\t\tif(ch == -1 || isWhitespace(ch) || isMacro(ch))\n\t\t\t{\n\t\t\tunread(r, ch);\n\t\t\tbreak;\n\t\t\t}\n\t\tint d = Character.digit((char)ch, base);\n\t\tif(d == -1)\n\t\t\tthrow new IllegalArgumentException(\"Invalid digit: \" + (char) ch);\n\t\tuc = uc * base + d;\n\t\t}\n\tif(i != length && exact)\n\t\tthrow new IllegalArgumentException(\"Invalid character length: \" + i + \", should be: \" + length);\n\treturn uc;\n}\n\nstatic private Object interpretToken(String s) {\n\tif(s.equals(\"nil\"))\n\t\t{\n\t\treturn null;\n\t\t}\n\telse if(s.equals(\"true\"))\n\t\t{\n\t\treturn RT.T;\n\t\t}\n\telse if(s.equals(\"false\"))\n\t\t{\n\t\treturn RT.F;\n\t\t}\n\n\tObject ret = null;\n\n\tret = matchSymbol(s);\n\tif(ret != null)\n\t\treturn ret;\n\n\tthrow Util.runtimeException(\"Invalid token: \" + s);\n}\n\n\nprivate static Object matchSymbol(String s){\n\tMatcher m = symbolPat.matcher(s);\n\tif(m.matches())\n\t\t{\n\t\tint gc = m.groupCount();\n\t\tString ns = m.group(1);\n\t\tString name = m.group(2);\n\t\tif(ns != null && ns.endsWith(\":/\")\n\t\t   || name.endsWith(\":\")\n\t\t   || s.indexOf(\"::\", 1) != -1)\n\t\t\treturn null;\n\t\tif(s.startsWith(\"::\"))\n\t\t\t{\n\t\t\treturn null;\n\t\t\t}\n\t\tboolean isKeyword = s.charAt(0) == ':';\n\t\tSymbol sym = Symbol.intern(s.substring(isKeyword ? 1 : 0));\n\t\tif(isKeyword)\n\t\t\treturn Keyword.intern(sym);\n\t\treturn sym;\n\t\t}\n\treturn null;\n}\n\n\nprivate static Object matchNumber(String s){\n\tMatcher m = intPat.matcher(s);\n\tif(m.matches())\n\t\t{\n\t\tif(m.group(2) != null)\n\t\t\t{\n\t\t\tif(m.group(8) != null)\n\t\t\t\treturn BigInt.ZERO;\n\t\t\treturn Numbers.num(0);\n\t\t\t}\n\t\tboolean negate = (m.group(1).equals(\"-\"));\n\t\tString n;\n\t\tint radix = 10;\n\t\tif((n = m.group(3)) != null)\n\t\t\tradix = 10;\n\t\telse if((n = m.group(4)) != null)\n\t\t\tradix = 16;\n\t\telse if((n = m.group(5)) != null)\n\t\t\tradix = 8;\n\t\telse if((n = m.group(7)) != null)\n\t\t\tradix = Integer.parseInt(m.group(6));\n\t\tif(n == null)\n\t\t\treturn null;\n\t\tBigInteger bn = new BigInteger(n, radix);\n\t\tif(negate)\n\t\t\tbn = bn.negate();\n\t\tif(m.group(8) != null)\n\t\t\treturn BigInt.fromBigInteger(bn);\n\t\treturn bn.bitLength() < 64 ?\n\t\t       Numbers.num(bn.longValue())\n\t\t                           : BigInt.fromBigInteger(bn);\n\t\t}\n\tm = floatPat.matcher(s);\n\tif(m.matches())\n\t\t{\n\t\tif(m.group(4) != null)\n\t\t\treturn new BigDecimal(m.group(1));\n\t\treturn Double.parseDouble(s);\n\t\t}\n\tm = ratioPat.matcher(s);\n\tif(m.matches())\n\t\t{\n\t\tString numerator = m.group(1);\n\t\tif (numerator.startsWith(\"+\")) numerator = numerator.substring(1);\n\n\t\treturn Numbers.divide(Numbers.reduceBigInt(BigInt.fromBigInteger(new BigInteger(numerator))),\n\t\t                      Numbers.reduceBigInt(BigInt.fromBigInteger(new BigInteger(m.group(2)))));\n\t\t}\n\treturn null;\n}\n\nstatic private IFn getMacro(int ch){\n\tif(ch < macros.length)\n\t\treturn macros[ch];\n\treturn null;\n}\n\nstatic private boolean isMacro(int ch){\n\treturn (ch < macros.length && macros[ch] != null);\n}\n\nstatic private boolean isTerminatingMacro(int ch){\n\treturn (ch != '#' && ch != '\\'' && isMacro(ch));\n}\n\n/*\npublic static class RegexReader extends AFn{\n\n\tstatic StringReader stringrdr = new StringReader();\n\n\tpublic Object invoke(Object reader, Object doublequote) {\n\t\tStringBuilder sb = new StringBuilder();\n\t\tReader r = (Reader) reader;\n\t\tfor(int ch = read1(r); ch != '\"'; ch = read1(r))\n\t\t\t{\n\t\t\tif(ch == -1)\n\t\t\t\tthrow Util.runtimeException(\"EOF while reading regex\");\n\t\t\tsb.append( (char) ch );\n\t\t\tif(ch == '\\\\')\t//escape\n\t\t\t\t{\n\t\t\t\tch = read1(r);\n\t\t\t\tif(ch == -1)\n\t\t\t\t\tthrow Util.runtimeException(\"EOF while reading regex\");\n\t\t\t\tsb.append( (char) ch ) ;\n\t\t\t\t}\n\t\t\t}\n\t\treturn Pattern.compile(sb.toString());\n\t}\n}\n*/\n\npublic static class StringReader extends AFn{\n\tpublic Object invoke(Object reader, Object doublequote, Object opts) {\n\t\tStringBuilder sb = new StringBuilder();\n\t\tReader r = (Reader) reader;\n\n\t\tfor(int ch = read1(r); ch != '\"'; ch = read1(r))\n\t\t\t{\n\t\t\tif(ch == -1)\n\t\t\t\tthrow Util.runtimeException(\"EOF while reading string\");\n\t\t\tif(ch == '\\\\')\t//escape\n\t\t\t\t{\n\t\t\t\tch = read1(r);\n\t\t\t\tif(ch == -1)\n\t\t\t\t\tthrow Util.runtimeException(\"EOF while reading string\");\n\t\t\t\tswitch(ch)\n\t\t\t\t\t{\n\t\t\t\t\tcase 't':\n\t\t\t\t\t\tch = '\\t';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'r':\n\t\t\t\t\t\tch = '\\r';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'n':\n\t\t\t\t\t\tch = '\\n';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '\\\\':\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '\"':\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'b':\n\t\t\t\t\t\tch = '\\b';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'f':\n\t\t\t\t\t\tch = '\\f';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'u':\n\t\t\t\t\t{\n\t\t\t\t\tch = read1(r);\n\t\t\t\t\tif (Character.digit((char)ch, 16) == -1)\n\t\t\t\t\t\tthrow Util.runtimeException(\"Invalid unicode escape: \\\\u\" + (char) ch);\n\t\t\t\t\tch = readUnicodeChar((PushbackReader) r, ch, 16, 4, true);\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t{\n\t\t\t\t\tif(Character.isDigit((char)ch))\n\t\t\t\t\t\t{\n\t\t\t\t\t\tch = readUnicodeChar((PushbackReader) r, ch, 8, 3, false);\n\t\t\t\t\t\tif(ch > 0377)\n\t\t\t\t\t\t\tthrow Util.runtimeException(\"Octal escape sequence must be in range [0, 377].\");\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tthrow Util.runtimeException(\"Unsupported escape character: \\\\\" + (char) ch);\n\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tsb.append((char) ch);\n\t\t\t}\n\t\treturn sb.toString();\n\t}\n}\n\npublic static class CommentReader extends AFn{\n\tpublic Object invoke(Object reader, Object semicolon, Object opts) {\n\t\tReader r = (Reader) reader;\n\t\tint ch;\n\t\tdo\n\t\t\t{\n\t\t\tch = read1(r);\n\t\t\t} while(ch != -1 && ch != '\\n' && ch != '\\r');\n\t\treturn r;\n\t}\n\n}\n\npublic static class DiscardReader extends AFn{\n\tpublic Object invoke(Object reader, Object underscore, Object opts) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tread(r, true, null, true, opts);\n\t\treturn r;\n\t}\n}\n\npublic static class DispatchReader extends AFn{\n\tpublic Object invoke(Object reader, Object hash, Object opts) {\n\t\tint ch = read1((Reader) reader);\n\t\tif(ch == -1)\n\t\t\tthrow Util.runtimeException(\"EOF while reading character\");\n\t\tIFn fn = dispatchMacros[ch];\n\n\t\tif(fn == null) {\n\t\t\t//try tagged reader\n\t\t    if(Character.isLetter((char)ch))\n\t\t\t\t{\n\t\t\t\tunread((PushbackReader) reader, ch);\n\t\t        return taggedReader.invoke(reader, ch, opts);\n\t\t\t\t}\n\n\t\t\tthrow Util.runtimeException(String.format(\"No dispatch macro for: %c\", (char) ch));\n\t\t}\n\t\treturn fn.invoke(reader, ch, opts);\n\t}\n}\n\npublic static class MetaReader extends AFn{\n\tpublic Object invoke(Object reader, Object caret, Object opts) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tint line = -1;\n\t\tint column = -1;\n\t\tif(r instanceof LineNumberingPushbackReader)\n\t\t\t{\n\t\t\tline = ((LineNumberingPushbackReader) r).getLineNumber();\n\t\t\tcolumn = ((LineNumberingPushbackReader) r).getColumnNumber()-1;\n\t\t\t}\n\t\tObject meta = read(r, true, null, true, opts);\n\t\tif(meta instanceof Symbol || meta instanceof String)\n\t\t\tmeta = RT.map(RT.TAG_KEY, meta);\n\t\telse if (meta instanceof Keyword)\n\t\t\tmeta = RT.map(meta, RT.T);\n\t\telse if(!(meta instanceof IPersistentMap))\n\t\t\tthrow new IllegalArgumentException(\"Metadata must be Symbol,Keyword,String or Map\");\n\n\t\tObject o = read(r, true, null, true, opts);\n\t\tif(o instanceof IMeta)\n\t\t\t{\n\t\t\tif(line != -1 && o instanceof ISeq)\n\t\t\t\t{\n\t\t\t\tmeta = ((IPersistentMap) meta).assoc(RT.LINE_KEY, line).assoc(RT.COLUMN_KEY, column);\n\t\t\t\t}\n\t\t\tif(o instanceof IReference)\n\t\t\t\t{\n\t\t\t\t((IReference)o).resetMeta((IPersistentMap) meta);\n\t\t\t\treturn o;\n\t\t\t\t}\n\t\t\tObject ometa = RT.meta(o);\n\t\t\tfor(ISeq s = RT.seq(meta); s != null; s = s.next()) {\n\t\t\tIMapEntry kv = (IMapEntry) s.first();\n\t\t\tometa = RT.assoc(ometa, kv.getKey(), kv.getValue());\n\t\t\t}\n\t\t\treturn ((IObj) o).withMeta((IPersistentMap) ometa);\n\t\t\t}\n\t\telse\n\t\t\tthrow new IllegalArgumentException(\"Metadata can only be applied to IMetas\");\n\t}\n\n}\n\npublic static class CharacterReader extends AFn{\n\tpublic Object invoke(Object reader, Object backslash, Object opts) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tint ch = read1(r);\n\t\tif(ch == -1)\n\t\t\tthrow Util.runtimeException(\"EOF while reading character\");\n\t\tString token = readToken(r, (char) ch, false);\n\t\tif(token.length() == 1)\n\t\t\treturn Character.valueOf(token.charAt(0));\n\t\telse if(token.equals(\"newline\"))\n\t\t\treturn '\\n';\n\t\telse if(token.equals(\"space\"))\n\t\t\treturn ' ';\n\t\telse if(token.equals(\"tab\"))\n\t\t\treturn '\\t';\n\t\telse if(token.equals(\"backspace\"))\n\t\t\treturn '\\b';\n\t\telse if(token.equals(\"formfeed\"))\n\t\t\treturn '\\f';\n\t\telse if(token.equals(\"return\"))\n\t\t\treturn '\\r';\n\t\telse if(token.startsWith(\"u\"))\n\t\t\t{\n\t\t\tchar c = (char) readUnicodeChar(token, 1, 4, 16);\n\t\t\tif(c >= '\\uD800' && c <= '\\uDFFF') // surrogate code unit?\n\t\t\t\tthrow Util.runtimeException(\"Invalid character constant: \\\\u\" + Integer.toString(c, 16));\n\t\t\treturn c;\n\t\t\t}\n\t\telse if(token.startsWith(\"o\"))\n\t\t\t{\n\t\t\tint len = token.length() - 1;\n\t\t\tif(len > 3)\n\t\t\t\tthrow Util.runtimeException(\"Invalid octal escape sequence length: \" + len);\n\t\t\tint uc = readUnicodeChar(token, 1, len, 8);\n\t\t\tif(uc > 0377)\n\t\t\t\tthrow Util.runtimeException(\"Octal escape sequence must be in range [0, 377].\");\n\t\t\treturn (char) uc;\n\t\t\t}\n\t\tthrow Util.runtimeException(\"Unsupported character: \\\\\" + token);\n\t}\n\n}\n\npublic static class ListReader extends AFn{\n\tpublic Object invoke(Object reader, Object leftparen, Object opts) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tint line = -1;\n\t\tint column = -1;\n\t\tif(r instanceof LineNumberingPushbackReader)\n\t\t\t{\n\t\t\tline = ((LineNumberingPushbackReader) r).getLineNumber();\n\t\t\tcolumn = ((LineNumberingPushbackReader) r).getColumnNumber()-1;\n\t\t\t}\n\t\tList list = readDelimitedList(')', r, true, opts);\n\t\tif(list.isEmpty())\n\t\t\treturn PersistentList.EMPTY;\n\t\tIObj s = (IObj) PersistentList.create(list);\n//\t\tIObj s = (IObj) RT.seq(list);\n//\t\tif(line != -1)\n//\t\t\t{\n//\t\t\treturn s.withMeta(RT.map(RT.LINE_KEY, line, RT.COLUMN_KEY, column));\n//\t\t\t}\n//\t\telse\n\t\t\treturn s;\n\t}\n\n}\n\npublic static class VectorReader extends AFn{\n\tpublic Object invoke(Object reader, Object leftparen, Object opts) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\treturn LazilyPersistentVector.create(readDelimitedList(']', r, true, opts));\n\t}\n\n}\n\npublic static class MapReader extends AFn{\n\tpublic Object invoke(Object reader, Object leftparen, Object opts) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tObject[] a = readDelimitedList('}', r, true, opts).toArray();\n\t\tif((a.length & 1) == 1)\n\t\t\tthrow Util.runtimeException(\"Map literal must contain an even number of forms\");\n\t\treturn RT.map(a);\n\t}\n\n}\n\npublic static class SetReader extends AFn{\n\tpublic Object invoke(Object reader, Object leftbracket, Object opts) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\treturn PersistentHashSet.createWithCheck(readDelimitedList('}', r, true, opts));\n\t}\n\n}\n\npublic static class UnmatchedDelimiterReader extends AFn{\n\tpublic Object invoke(Object reader, Object rightdelim, Object opts) {\n\t\tthrow Util.runtimeException(\"Unmatched delimiter: \" + rightdelim);\n\t}\n\n}\n\npublic static class UnreadableReader extends AFn{\n\tpublic Object invoke(Object reader, Object leftangle, Object opts) {\n\t\tthrow Util.runtimeException(\"Unreadable form\");\n\t}\n}\n\npublic static List readDelimitedList(char delim, PushbackReader r, boolean isRecursive, Object opts) {\n\tfinal int firstline =\n\t\t\t(r instanceof LineNumberingPushbackReader) ?\n\t\t\t((LineNumberingPushbackReader) r).getLineNumber() : -1;\n\n\tArrayList a = new ArrayList();\n\n\tfor(; ;)\n\t\t{\n\t\tint ch = read1(r);\n\n\t\twhile(isWhitespace(ch))\n\t\t\tch = read1(r);\n\n\t\tif(ch == -1)\n\t\t\t{\n\t\t\tif(firstline < 0)\n\t\t\t\tthrow Util.runtimeException(\"EOF while reading\");\n\t\t\telse\n\t\t\t\tthrow Util.runtimeException(\"EOF while reading, starting at line \" + firstline);\n\t\t\t}\n\n\t\tif(ch == delim)\n\t\t\tbreak;\n\n\t\tIFn macroFn = getMacro(ch);\n\t\tif(macroFn != null)\n\t\t\t{\n\t\t\tObject mret = macroFn.invoke(r, (char) ch, opts);\n\t\t\t//no op macros return the reader\n\t\t\tif(mret != r)\n\t\t\t\ta.add(mret);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tunread(r, ch);\n\n\t\t\tObject o = read(r, true, null, isRecursive, opts);\n\t\t\tif(o != r)\n\t\t\t\ta.add(o);\n\t\t\t}\n\t\t}\n\n\n\treturn a;\n}\n\npublic static class TaggedReader extends AFn{\n\tpublic Object invoke(Object reader, Object firstChar, Object opts){\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tObject name = read(r, true, null, false, opts);\n\t\tif (!(name instanceof Symbol))\n\t\t\tthrow new RuntimeException(\"Reader tag must be a symbol\");\n\t\tSymbol sym = (Symbol)name;\n\t\treturn readTagged(r, sym, (IPersistentMap) opts);\n\t}\n\n\tstatic Keyword READERS = Keyword.intern(null,\"readers\");\n\tstatic Keyword DEFAULT = Keyword.intern(null,\"default\");\n\n\tprivate Object readTagged(PushbackReader reader, Symbol tag, IPersistentMap opts){\n\t\tObject o = read(reader, true, null, true, opts);\n\n\t\tILookup readers = (ILookup)RT.get(opts, READERS);\n\t\tIFn dataReader = (IFn)RT.get(readers, tag);\n\t\tif(dataReader == null)\n\t\t\tdataReader = (IFn)RT.get(RT.DEFAULT_DATA_READERS.deref(),tag);\n\t\tif(dataReader == null){\n\t\t\tIFn defaultReader = (IFn)RT.get(opts, DEFAULT);\n\t\t\tif(defaultReader != null)\n\t\t\t\treturn defaultReader.invoke(tag, o);\n\t\t\telse\n\t\t\t\tthrow new RuntimeException(\"No reader function for tag \" + tag.toString());\n\t\t}\n\t\telse\n\t\t\treturn dataReader.invoke(o);\n\t}\n\n}\n}\n\n"
  },
  {
    "path": "src/jvm/clojure/lang/EnumerationSeq.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 3, 2008 */\n\npackage clojure.lang;\n\nimport java.io.IOException;\nimport java.io.NotSerializableException;\nimport java.util.Enumeration;\n\npublic class EnumerationSeq extends ASeq{\nfinal Enumeration iter;\nfinal State state;\n\n    static class State{\n\tvolatile Object val;\n\tvolatile Object _rest;\n}\n\npublic static EnumerationSeq create(Enumeration iter){\n\tif(iter.hasMoreElements())\n\t\treturn new EnumerationSeq(iter);\n\treturn null;\n}\n\nEnumerationSeq(Enumeration iter){\n\tthis.iter = iter;\n\tstate = new State();\n\tthis.state.val = state;\n\tthis.state._rest = state;\n}\n\nEnumerationSeq(IPersistentMap meta, Enumeration iter, State state){\n\tsuper(meta);\n\tthis.iter = iter;\n\tthis.state = state;\n}\n\npublic Object first(){\n\tif(state.val == state)\n\t\tsynchronized(state)\n\t\t\t{\n\t\t\tif(state.val == state)\n\t\t\t\tstate.val = iter.nextElement();\n\t\t\t}\n\treturn state.val;\n}\n\npublic ISeq next(){\n\tif(state._rest == state)\n\t\tsynchronized(state)\n\t\t\t{\n\t\t\tif(state._rest == state)\n\t\t\t\t{\n\t\t\t\tfirst();\n\t\t\t\tstate._rest = create(iter);\n\t\t\t\t}\n\t\t\t}\n\treturn (ISeq) state._rest;\n}\n\npublic EnumerationSeq withMeta(IPersistentMap meta){\n\treturn new EnumerationSeq(meta, iter, state);\n}\n\nprivate void writeObject (java.io.ObjectOutputStream out) throws IOException {\n    throw new NotSerializableException(getClass().getName());\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ExceptionInfo.java",
    "content": "/**\n * Copyright (c) Rich Hickey. All rights reserved.\n * The use and distribution terms for this software are covered by the\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n * which can be found in the file epl-v10.html at the root of this distribution.\n * By using this software in any fashion, you are agreeing to be bound by\n * the terms of this license.\n * You must not remove this notice, or any other, from this software.\n */\n\npackage clojure.lang;\n\n/**\n * Exception that carries data (a map) as additional payload. Clojure programs that need\n * richer semantics for exceptions should use this in lieu of defining project-specific\n * exception classes.\n */\npublic class ExceptionInfo extends RuntimeException implements IExceptionInfo {\n    public final IPersistentMap data;\n\n    public ExceptionInfo(String s, IPersistentMap data) {\n        super(s);\n        if (data instanceof IPersistentMap) {\n            this.data = data;\n        }  else {\n            throw new IllegalArgumentException(\"Additional data must be a persistent map: \" + data);\n        }\n    }\n\n    public ExceptionInfo(String s, IPersistentMap data, Throwable throwable) {\n        super(s, throwable);\n        this.data = data;\n    }\n\n    public IPersistentMap getData() {\n        return data;\n    }\n\n    public String toString() {\n        return \"clojure.lang.ExceptionInfo: \" + getMessage() + \" \" + data.toString();\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Fn.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Nov 25, 2008 */\n\npackage clojure.lang;\n\npublic interface Fn{\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/FnLoaderThunk.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich 2/28/11 */\n\npackage clojure.lang;\n\npublic class FnLoaderThunk extends RestFn{\n\nfinal Var v;\nfinal ClassLoader loader;\nfinal String fnClassName;\nIFn fn;\n\npublic FnLoaderThunk(Var v, String fnClassName){\n\tthis.v = v;\n\tthis.loader = (ClassLoader) RT.FN_LOADER_VAR.get();\n\tthis.fnClassName = fnClassName;\n\tfn = null;\n}\n\npublic Object invoke(Object arg1) {\n\tload();\n\treturn fn.invoke(arg1);\n}\n\npublic Object invoke(Object arg1, Object arg2) {\n\tload();\n\treturn fn.invoke(arg1,arg2);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3) {\n\tload();\n\treturn fn.invoke(arg1,arg2,arg3);\n}\n\nprotected Object doInvoke(Object args) {\n\tload();\n\treturn fn.applyTo((ISeq) args);\n}\n\nprivate void load() {\n\tif(fn == null)\n\t\t{\n\t\ttry\n\t\t\t{\n\t\t\tfn = (IFn) Class.forName(fnClassName,true,loader).newInstance();\n\t\t\t}\n\t\tcatch(Exception e)\n\t\t\t{\n\t\t\tthrow Util.sneakyThrow(e);\n\t\t\t}\n\t\tv.root = fn;\n\t\t}\n}\n\npublic int getRequiredArity(){\n\treturn 0;\n}\n\npublic IObj withMeta(IPersistentMap meta){\n\treturn this;\n}\n\npublic IPersistentMap meta(){\n\treturn null;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IAtom.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Aug 2, 2009 */\n\npackage clojure.lang;\n\npublic interface IAtom{\nObject swap(IFn f);\n\nObject swap(IFn f, Object arg);\n\nObject swap(IFn f, Object arg1, Object arg2);\n\nObject swap(IFn f, Object x, Object y, ISeq args);\n\nboolean compareAndSet(Object oldv, Object newv);\n\nObject reset(Object newval);\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IBlockingDeref.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich 3/18/11 */\n\npackage clojure.lang;\n\npublic interface IBlockingDeref{\nObject deref(long ms, Object timeoutValue) ;\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IChunk.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jun 18, 2009 */\n\npackage clojure.lang;\n\npublic interface IChunk extends Indexed{\n\nIChunk dropFirst();\n\nObject reduce(IFn f, Object start) ;\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IChunkedSeq.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich May 24, 2009 */\n\npackage clojure.lang;\n\npublic interface IChunkedSeq extends ISeq, Sequential {\n\nIChunk chunkedFirst() ;\n\nISeq chunkedNext() ;\n\nISeq chunkedMore() ;\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IDeref.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Feb 9, 2009 */\n\npackage clojure.lang;\n\npublic interface IDeref{\nObject deref() ;\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IEditableCollection.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jul 17, 2009 */\n\npackage clojure.lang;\n\npublic interface IEditableCollection{\nITransientCollection asTransient();\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IExceptionInfo.java",
    "content": "/**\n * Copyright (c) Rich Hickey. All rights reserved.\n * The use and distribution terms for this software are covered by the\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n * which can be found in the file epl-v10.html at the root of this distribution.\n * By using this software in any fashion, you are agreeing to be bound by\n * the terms of this license.\n * You must not remove this notice, or any other, from this software.\n */\n\npackage clojure.lang;\n\n/**\n * Interface for exceptions that carry data (a map) as additional payload. Clojure \n * programs that need richer semantics for exceptions should use this in lieu of \n * defining project-specific exception classes.\n */\npublic interface IExceptionInfo {\n    public IPersistentMap getData();\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IFn.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 25, 2006 3:54:03 PM */\n\npackage clojure.lang;\n\nimport java.util.concurrent.Callable;\n\n/**\n * <p><code>IFn</code> provides complete access to invoking\n * any of Clojure's <a href=\"http://clojure.github.io/clojure/\">API</a>s.\n * You can also access any other library written in Clojure, after adding\n * either its source or compiled form to the classpath.</p>\n */\npublic interface IFn extends Callable, Runnable{\n\npublic Object invoke() ;\n\npublic Object invoke(Object arg1) ;\n\npublic Object invoke(Object arg1, Object arg2) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)\n\t\t;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)\n\t\t;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19) ;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20)\n\t\t;\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20,\n                     Object... args)\n\t\t;\n\npublic Object applyTo(ISeq arglist) ;\n\nstatic public interface L{long invokePrim();}\nstatic public interface D{double invokePrim();}\nstatic public interface OL{long invokePrim(Object arg0);}\nstatic public interface OD{double invokePrim(Object arg0);}\nstatic public interface LO{Object invokePrim(long arg0);}\nstatic public interface LL{long invokePrim(long arg0);}\nstatic public interface LD{double invokePrim(long arg0);}\nstatic public interface DO{Object invokePrim(double arg0);}\nstatic public interface DL{long invokePrim(double arg0);}\nstatic public interface DD{double invokePrim(double arg0);}\nstatic public interface OOL{long invokePrim(Object arg0, Object arg1);}\nstatic public interface OOD{double invokePrim(Object arg0, Object arg1);}\nstatic public interface OLO{Object invokePrim(Object arg0, long arg1);}\nstatic public interface OLL{long invokePrim(Object arg0, long arg1);}\nstatic public interface OLD{double invokePrim(Object arg0, long arg1);}\nstatic public interface ODO{Object invokePrim(Object arg0, double arg1);}\nstatic public interface ODL{long invokePrim(Object arg0, double arg1);}\nstatic public interface ODD{double invokePrim(Object arg0, double arg1);}\nstatic public interface LOO{Object invokePrim(long arg0, Object arg1);}\nstatic public interface LOL{long invokePrim(long arg0, Object arg1);}\nstatic public interface LOD{double invokePrim(long arg0, Object arg1);}\nstatic public interface LLO{Object invokePrim(long arg0, long arg1);}\nstatic public interface LLL{long invokePrim(long arg0, long arg1);}\nstatic public interface LLD{double invokePrim(long arg0, long arg1);}\nstatic public interface LDO{Object invokePrim(long arg0, double arg1);}\nstatic public interface LDL{long invokePrim(long arg0, double arg1);}\nstatic public interface LDD{double invokePrim(long arg0, double arg1);}\nstatic public interface DOO{Object invokePrim(double arg0, Object arg1);}\nstatic public interface DOL{long invokePrim(double arg0, Object arg1);}\nstatic public interface DOD{double invokePrim(double arg0, Object arg1);}\nstatic public interface DLO{Object invokePrim(double arg0, long arg1);}\nstatic public interface DLL{long invokePrim(double arg0, long arg1);}\nstatic public interface DLD{double invokePrim(double arg0, long arg1);}\nstatic public interface DDO{Object invokePrim(double arg0, double arg1);}\nstatic public interface DDL{long invokePrim(double arg0, double arg1);}\nstatic public interface DDD{double invokePrim(double arg0, double arg1);}\nstatic public interface OOOL{long invokePrim(Object arg0, Object arg1, Object arg2);}\nstatic public interface OOOD{double invokePrim(Object arg0, Object arg1, Object arg2);}\nstatic public interface OOLO{Object invokePrim(Object arg0, Object arg1, long arg2);}\nstatic public interface OOLL{long invokePrim(Object arg0, Object arg1, long arg2);}\nstatic public interface OOLD{double invokePrim(Object arg0, Object arg1, long arg2);}\nstatic public interface OODO{Object invokePrim(Object arg0, Object arg1, double arg2);}\nstatic public interface OODL{long invokePrim(Object arg0, Object arg1, double arg2);}\nstatic public interface OODD{double invokePrim(Object arg0, Object arg1, double arg2);}\nstatic public interface OLOO{Object invokePrim(Object arg0, long arg1, Object arg2);}\nstatic public interface OLOL{long invokePrim(Object arg0, long arg1, Object arg2);}\nstatic public interface OLOD{double invokePrim(Object arg0, long arg1, Object arg2);}\nstatic public interface OLLO{Object invokePrim(Object arg0, long arg1, long arg2);}\nstatic public interface OLLL{long invokePrim(Object arg0, long arg1, long arg2);}\nstatic public interface OLLD{double invokePrim(Object arg0, long arg1, long arg2);}\nstatic public interface OLDO{Object invokePrim(Object arg0, long arg1, double arg2);}\nstatic public interface OLDL{long invokePrim(Object arg0, long arg1, double arg2);}\nstatic public interface OLDD{double invokePrim(Object arg0, long arg1, double arg2);}\nstatic public interface ODOO{Object invokePrim(Object arg0, double arg1, Object arg2);}\nstatic public interface ODOL{long invokePrim(Object arg0, double arg1, Object arg2);}\nstatic public interface ODOD{double invokePrim(Object arg0, double arg1, Object arg2);}\nstatic public interface ODLO{Object invokePrim(Object arg0, double arg1, long arg2);}\nstatic public interface ODLL{long invokePrim(Object arg0, double arg1, long arg2);}\nstatic public interface ODLD{double invokePrim(Object arg0, double arg1, long arg2);}\nstatic public interface ODDO{Object invokePrim(Object arg0, double arg1, double arg2);}\nstatic public interface ODDL{long invokePrim(Object arg0, double arg1, double arg2);}\nstatic public interface ODDD{double invokePrim(Object arg0, double arg1, double arg2);}\nstatic public interface LOOO{Object invokePrim(long arg0, Object arg1, Object arg2);}\nstatic public interface LOOL{long invokePrim(long arg0, Object arg1, Object arg2);}\nstatic public interface LOOD{double invokePrim(long arg0, Object arg1, Object arg2);}\nstatic public interface LOLO{Object invokePrim(long arg0, Object arg1, long arg2);}\nstatic public interface LOLL{long invokePrim(long arg0, Object arg1, long arg2);}\nstatic public interface LOLD{double invokePrim(long arg0, Object arg1, long arg2);}\nstatic public interface LODO{Object invokePrim(long arg0, Object arg1, double arg2);}\nstatic public interface LODL{long invokePrim(long arg0, Object arg1, double arg2);}\nstatic public interface LODD{double invokePrim(long arg0, Object arg1, double arg2);}\nstatic public interface LLOO{Object invokePrim(long arg0, long arg1, Object arg2);}\nstatic public interface LLOL{long invokePrim(long arg0, long arg1, Object arg2);}\nstatic public interface LLOD{double invokePrim(long arg0, long arg1, Object arg2);}\nstatic public interface LLLO{Object invokePrim(long arg0, long arg1, long arg2);}\nstatic public interface LLLL{long invokePrim(long arg0, long arg1, long arg2);}\nstatic public interface LLLD{double invokePrim(long arg0, long arg1, long arg2);}\nstatic public interface LLDO{Object invokePrim(long arg0, long arg1, double arg2);}\nstatic public interface LLDL{long invokePrim(long arg0, long arg1, double arg2);}\nstatic public interface LLDD{double invokePrim(long arg0, long arg1, double arg2);}\nstatic public interface LDOO{Object invokePrim(long arg0, double arg1, Object arg2);}\nstatic public interface LDOL{long invokePrim(long arg0, double arg1, Object arg2);}\nstatic public interface LDOD{double invokePrim(long arg0, double arg1, Object arg2);}\nstatic public interface LDLO{Object invokePrim(long arg0, double arg1, long arg2);}\nstatic public interface LDLL{long invokePrim(long arg0, double arg1, long arg2);}\nstatic public interface LDLD{double invokePrim(long arg0, double arg1, long arg2);}\nstatic public interface LDDO{Object invokePrim(long arg0, double arg1, double arg2);}\nstatic public interface LDDL{long invokePrim(long arg0, double arg1, double arg2);}\nstatic public interface LDDD{double invokePrim(long arg0, double arg1, double arg2);}\nstatic public interface DOOO{Object invokePrim(double arg0, Object arg1, Object arg2);}\nstatic public interface DOOL{long invokePrim(double arg0, Object arg1, Object arg2);}\nstatic public interface DOOD{double invokePrim(double arg0, Object arg1, Object arg2);}\nstatic public interface DOLO{Object invokePrim(double arg0, Object arg1, long arg2);}\nstatic public interface DOLL{long invokePrim(double arg0, Object arg1, long arg2);}\nstatic public interface DOLD{double invokePrim(double arg0, Object arg1, long arg2);}\nstatic public interface DODO{Object invokePrim(double arg0, Object arg1, double arg2);}\nstatic public interface DODL{long invokePrim(double arg0, Object arg1, double arg2);}\nstatic public interface DODD{double invokePrim(double arg0, Object arg1, double arg2);}\nstatic public interface DLOO{Object invokePrim(double arg0, long arg1, Object arg2);}\nstatic public interface DLOL{long invokePrim(double arg0, long arg1, Object arg2);}\nstatic public interface DLOD{double invokePrim(double arg0, long arg1, Object arg2);}\nstatic public interface DLLO{Object invokePrim(double arg0, long arg1, long arg2);}\nstatic public interface DLLL{long invokePrim(double arg0, long arg1, long arg2);}\nstatic public interface DLLD{double invokePrim(double arg0, long arg1, long arg2);}\nstatic public interface DLDO{Object invokePrim(double arg0, long arg1, double arg2);}\nstatic public interface DLDL{long invokePrim(double arg0, long arg1, double arg2);}\nstatic public interface DLDD{double invokePrim(double arg0, long arg1, double arg2);}\nstatic public interface DDOO{Object invokePrim(double arg0, double arg1, Object arg2);}\nstatic public interface DDOL{long invokePrim(double arg0, double arg1, Object arg2);}\nstatic public interface DDOD{double invokePrim(double arg0, double arg1, Object arg2);}\nstatic public interface DDLO{Object invokePrim(double arg0, double arg1, long arg2);}\nstatic public interface DDLL{long invokePrim(double arg0, double arg1, long arg2);}\nstatic public interface DDLD{double invokePrim(double arg0, double arg1, long arg2);}\nstatic public interface DDDO{Object invokePrim(double arg0, double arg1, double arg2);}\nstatic public interface DDDL{long invokePrim(double arg0, double arg1, double arg2);}\nstatic public interface DDDD{double invokePrim(double arg0, double arg1, double arg2);}\nstatic public interface OOOOL{long invokePrim(Object arg0, Object arg1, Object arg2, Object arg3);}\nstatic public interface OOOOD{double invokePrim(Object arg0, Object arg1, Object arg2, Object arg3);}\nstatic public interface OOOLO{Object invokePrim(Object arg0, Object arg1, Object arg2, long arg3);}\nstatic public interface OOOLL{long invokePrim(Object arg0, Object arg1, Object arg2, long arg3);}\nstatic public interface OOOLD{double invokePrim(Object arg0, Object arg1, Object arg2, long arg3);}\nstatic public interface OOODO{Object invokePrim(Object arg0, Object arg1, Object arg2, double arg3);}\nstatic public interface OOODL{long invokePrim(Object arg0, Object arg1, Object arg2, double arg3);}\nstatic public interface OOODD{double invokePrim(Object arg0, Object arg1, Object arg2, double arg3);}\nstatic public interface OOLOO{Object invokePrim(Object arg0, Object arg1, long arg2, Object arg3);}\nstatic public interface OOLOL{long invokePrim(Object arg0, Object arg1, long arg2, Object arg3);}\nstatic public interface OOLOD{double invokePrim(Object arg0, Object arg1, long arg2, Object arg3);}\nstatic public interface OOLLO{Object invokePrim(Object arg0, Object arg1, long arg2, long arg3);}\nstatic public interface OOLLL{long invokePrim(Object arg0, Object arg1, long arg2, long arg3);}\nstatic public interface OOLLD{double invokePrim(Object arg0, Object arg1, long arg2, long arg3);}\nstatic public interface OOLDO{Object invokePrim(Object arg0, Object arg1, long arg2, double arg3);}\nstatic public interface OOLDL{long invokePrim(Object arg0, Object arg1, long arg2, double arg3);}\nstatic public interface OOLDD{double invokePrim(Object arg0, Object arg1, long arg2, double arg3);}\nstatic public interface OODOO{Object invokePrim(Object arg0, Object arg1, double arg2, Object arg3);}\nstatic public interface OODOL{long invokePrim(Object arg0, Object arg1, double arg2, Object arg3);}\nstatic public interface OODOD{double invokePrim(Object arg0, Object arg1, double arg2, Object arg3);}\nstatic public interface OODLO{Object invokePrim(Object arg0, Object arg1, double arg2, long arg3);}\nstatic public interface OODLL{long invokePrim(Object arg0, Object arg1, double arg2, long arg3);}\nstatic public interface OODLD{double invokePrim(Object arg0, Object arg1, double arg2, long arg3);}\nstatic public interface OODDO{Object invokePrim(Object arg0, Object arg1, double arg2, double arg3);}\nstatic public interface OODDL{long invokePrim(Object arg0, Object arg1, double arg2, double arg3);}\nstatic public interface OODDD{double invokePrim(Object arg0, Object arg1, double arg2, double arg3);}\nstatic public interface OLOOO{Object invokePrim(Object arg0, long arg1, Object arg2, Object arg3);}\nstatic public interface OLOOL{long invokePrim(Object arg0, long arg1, Object arg2, Object arg3);}\nstatic public interface OLOOD{double invokePrim(Object arg0, long arg1, Object arg2, Object arg3);}\nstatic public interface OLOLO{Object invokePrim(Object arg0, long arg1, Object arg2, long arg3);}\nstatic public interface OLOLL{long invokePrim(Object arg0, long arg1, Object arg2, long arg3);}\nstatic public interface OLOLD{double invokePrim(Object arg0, long arg1, Object arg2, long arg3);}\nstatic public interface OLODO{Object invokePrim(Object arg0, long arg1, Object arg2, double arg3);}\nstatic public interface OLODL{long invokePrim(Object arg0, long arg1, Object arg2, double arg3);}\nstatic public interface OLODD{double invokePrim(Object arg0, long arg1, Object arg2, double arg3);}\nstatic public interface OLLOO{Object invokePrim(Object arg0, long arg1, long arg2, Object arg3);}\nstatic public interface OLLOL{long invokePrim(Object arg0, long arg1, long arg2, Object arg3);}\nstatic public interface OLLOD{double invokePrim(Object arg0, long arg1, long arg2, Object arg3);}\nstatic public interface OLLLO{Object invokePrim(Object arg0, long arg1, long arg2, long arg3);}\nstatic public interface OLLLL{long invokePrim(Object arg0, long arg1, long arg2, long arg3);}\nstatic public interface OLLLD{double invokePrim(Object arg0, long arg1, long arg2, long arg3);}\nstatic public interface OLLDO{Object invokePrim(Object arg0, long arg1, long arg2, double arg3);}\nstatic public interface OLLDL{long invokePrim(Object arg0, long arg1, long arg2, double arg3);}\nstatic public interface OLLDD{double invokePrim(Object arg0, long arg1, long arg2, double arg3);}\nstatic public interface OLDOO{Object invokePrim(Object arg0, long arg1, double arg2, Object arg3);}\nstatic public interface OLDOL{long invokePrim(Object arg0, long arg1, double arg2, Object arg3);}\nstatic public interface OLDOD{double invokePrim(Object arg0, long arg1, double arg2, Object arg3);}\nstatic public interface OLDLO{Object invokePrim(Object arg0, long arg1, double arg2, long arg3);}\nstatic public interface OLDLL{long invokePrim(Object arg0, long arg1, double arg2, long arg3);}\nstatic public interface OLDLD{double invokePrim(Object arg0, long arg1, double arg2, long arg3);}\nstatic public interface OLDDO{Object invokePrim(Object arg0, long arg1, double arg2, double arg3);}\nstatic public interface OLDDL{long invokePrim(Object arg0, long arg1, double arg2, double arg3);}\nstatic public interface OLDDD{double invokePrim(Object arg0, long arg1, double arg2, double arg3);}\nstatic public interface ODOOO{Object invokePrim(Object arg0, double arg1, Object arg2, Object arg3);}\nstatic public interface ODOOL{long invokePrim(Object arg0, double arg1, Object arg2, Object arg3);}\nstatic public interface ODOOD{double invokePrim(Object arg0, double arg1, Object arg2, Object arg3);}\nstatic public interface ODOLO{Object invokePrim(Object arg0, double arg1, Object arg2, long arg3);}\nstatic public interface ODOLL{long invokePrim(Object arg0, double arg1, Object arg2, long arg3);}\nstatic public interface ODOLD{double invokePrim(Object arg0, double arg1, Object arg2, long arg3);}\nstatic public interface ODODO{Object invokePrim(Object arg0, double arg1, Object arg2, double arg3);}\nstatic public interface ODODL{long invokePrim(Object arg0, double arg1, Object arg2, double arg3);}\nstatic public interface ODODD{double invokePrim(Object arg0, double arg1, Object arg2, double arg3);}\nstatic public interface ODLOO{Object invokePrim(Object arg0, double arg1, long arg2, Object arg3);}\nstatic public interface ODLOL{long invokePrim(Object arg0, double arg1, long arg2, Object arg3);}\nstatic public interface ODLOD{double invokePrim(Object arg0, double arg1, long arg2, Object arg3);}\nstatic public interface ODLLO{Object invokePrim(Object arg0, double arg1, long arg2, long arg3);}\nstatic public interface ODLLL{long invokePrim(Object arg0, double arg1, long arg2, long arg3);}\nstatic public interface ODLLD{double invokePrim(Object arg0, double arg1, long arg2, long arg3);}\nstatic public interface ODLDO{Object invokePrim(Object arg0, double arg1, long arg2, double arg3);}\nstatic public interface ODLDL{long invokePrim(Object arg0, double arg1, long arg2, double arg3);}\nstatic public interface ODLDD{double invokePrim(Object arg0, double arg1, long arg2, double arg3);}\nstatic public interface ODDOO{Object invokePrim(Object arg0, double arg1, double arg2, Object arg3);}\nstatic public interface ODDOL{long invokePrim(Object arg0, double arg1, double arg2, Object arg3);}\nstatic public interface ODDOD{double invokePrim(Object arg0, double arg1, double arg2, Object arg3);}\nstatic public interface ODDLO{Object invokePrim(Object arg0, double arg1, double arg2, long arg3);}\nstatic public interface ODDLL{long invokePrim(Object arg0, double arg1, double arg2, long arg3);}\nstatic public interface ODDLD{double invokePrim(Object arg0, double arg1, double arg2, long arg3);}\nstatic public interface ODDDO{Object invokePrim(Object arg0, double arg1, double arg2, double arg3);}\nstatic public interface ODDDL{long invokePrim(Object arg0, double arg1, double arg2, double arg3);}\nstatic public interface ODDDD{double invokePrim(Object arg0, double arg1, double arg2, double arg3);}\nstatic public interface LOOOO{Object invokePrim(long arg0, Object arg1, Object arg2, Object arg3);}\nstatic public interface LOOOL{long invokePrim(long arg0, Object arg1, Object arg2, Object arg3);}\nstatic public interface LOOOD{double invokePrim(long arg0, Object arg1, Object arg2, Object arg3);}\nstatic public interface LOOLO{Object invokePrim(long arg0, Object arg1, Object arg2, long arg3);}\nstatic public interface LOOLL{long invokePrim(long arg0, Object arg1, Object arg2, long arg3);}\nstatic public interface LOOLD{double invokePrim(long arg0, Object arg1, Object arg2, long arg3);}\nstatic public interface LOODO{Object invokePrim(long arg0, Object arg1, Object arg2, double arg3);}\nstatic public interface LOODL{long invokePrim(long arg0, Object arg1, Object arg2, double arg3);}\nstatic public interface LOODD{double invokePrim(long arg0, Object arg1, Object arg2, double arg3);}\nstatic public interface LOLOO{Object invokePrim(long arg0, Object arg1, long arg2, Object arg3);}\nstatic public interface LOLOL{long invokePrim(long arg0, Object arg1, long arg2, Object arg3);}\nstatic public interface LOLOD{double invokePrim(long arg0, Object arg1, long arg2, Object arg3);}\nstatic public interface LOLLO{Object invokePrim(long arg0, Object arg1, long arg2, long arg3);}\nstatic public interface LOLLL{long invokePrim(long arg0, Object arg1, long arg2, long arg3);}\nstatic public interface LOLLD{double invokePrim(long arg0, Object arg1, long arg2, long arg3);}\nstatic public interface LOLDO{Object invokePrim(long arg0, Object arg1, long arg2, double arg3);}\nstatic public interface LOLDL{long invokePrim(long arg0, Object arg1, long arg2, double arg3);}\nstatic public interface LOLDD{double invokePrim(long arg0, Object arg1, long arg2, double arg3);}\nstatic public interface LODOO{Object invokePrim(long arg0, Object arg1, double arg2, Object arg3);}\nstatic public interface LODOL{long invokePrim(long arg0, Object arg1, double arg2, Object arg3);}\nstatic public interface LODOD{double invokePrim(long arg0, Object arg1, double arg2, Object arg3);}\nstatic public interface LODLO{Object invokePrim(long arg0, Object arg1, double arg2, long arg3);}\nstatic public interface LODLL{long invokePrim(long arg0, Object arg1, double arg2, long arg3);}\nstatic public interface LODLD{double invokePrim(long arg0, Object arg1, double arg2, long arg3);}\nstatic public interface LODDO{Object invokePrim(long arg0, Object arg1, double arg2, double arg3);}\nstatic public interface LODDL{long invokePrim(long arg0, Object arg1, double arg2, double arg3);}\nstatic public interface LODDD{double invokePrim(long arg0, Object arg1, double arg2, double arg3);}\nstatic public interface LLOOO{Object invokePrim(long arg0, long arg1, Object arg2, Object arg3);}\nstatic public interface LLOOL{long invokePrim(long arg0, long arg1, Object arg2, Object arg3);}\nstatic public interface LLOOD{double invokePrim(long arg0, long arg1, Object arg2, Object arg3);}\nstatic public interface LLOLO{Object invokePrim(long arg0, long arg1, Object arg2, long arg3);}\nstatic public interface LLOLL{long invokePrim(long arg0, long arg1, Object arg2, long arg3);}\nstatic public interface LLOLD{double invokePrim(long arg0, long arg1, Object arg2, long arg3);}\nstatic public interface LLODO{Object invokePrim(long arg0, long arg1, Object arg2, double arg3);}\nstatic public interface LLODL{long invokePrim(long arg0, long arg1, Object arg2, double arg3);}\nstatic public interface LLODD{double invokePrim(long arg0, long arg1, Object arg2, double arg3);}\nstatic public interface LLLOO{Object invokePrim(long arg0, long arg1, long arg2, Object arg3);}\nstatic public interface LLLOL{long invokePrim(long arg0, long arg1, long arg2, Object arg3);}\nstatic public interface LLLOD{double invokePrim(long arg0, long arg1, long arg2, Object arg3);}\nstatic public interface LLLLO{Object invokePrim(long arg0, long arg1, long arg2, long arg3);}\nstatic public interface LLLLL{long invokePrim(long arg0, long arg1, long arg2, long arg3);}\nstatic public interface LLLLD{double invokePrim(long arg0, long arg1, long arg2, long arg3);}\nstatic public interface LLLDO{Object invokePrim(long arg0, long arg1, long arg2, double arg3);}\nstatic public interface LLLDL{long invokePrim(long arg0, long arg1, long arg2, double arg3);}\nstatic public interface LLLDD{double invokePrim(long arg0, long arg1, long arg2, double arg3);}\nstatic public interface LLDOO{Object invokePrim(long arg0, long arg1, double arg2, Object arg3);}\nstatic public interface LLDOL{long invokePrim(long arg0, long arg1, double arg2, Object arg3);}\nstatic public interface LLDOD{double invokePrim(long arg0, long arg1, double arg2, Object arg3);}\nstatic public interface LLDLO{Object invokePrim(long arg0, long arg1, double arg2, long arg3);}\nstatic public interface LLDLL{long invokePrim(long arg0, long arg1, double arg2, long arg3);}\nstatic public interface LLDLD{double invokePrim(long arg0, long arg1, double arg2, long arg3);}\nstatic public interface LLDDO{Object invokePrim(long arg0, long arg1, double arg2, double arg3);}\nstatic public interface LLDDL{long invokePrim(long arg0, long arg1, double arg2, double arg3);}\nstatic public interface LLDDD{double invokePrim(long arg0, long arg1, double arg2, double arg3);}\nstatic public interface LDOOO{Object invokePrim(long arg0, double arg1, Object arg2, Object arg3);}\nstatic public interface LDOOL{long invokePrim(long arg0, double arg1, Object arg2, Object arg3);}\nstatic public interface LDOOD{double invokePrim(long arg0, double arg1, Object arg2, Object arg3);}\nstatic public interface LDOLO{Object invokePrim(long arg0, double arg1, Object arg2, long arg3);}\nstatic public interface LDOLL{long invokePrim(long arg0, double arg1, Object arg2, long arg3);}\nstatic public interface LDOLD{double invokePrim(long arg0, double arg1, Object arg2, long arg3);}\nstatic public interface LDODO{Object invokePrim(long arg0, double arg1, Object arg2, double arg3);}\nstatic public interface LDODL{long invokePrim(long arg0, double arg1, Object arg2, double arg3);}\nstatic public interface LDODD{double invokePrim(long arg0, double arg1, Object arg2, double arg3);}\nstatic public interface LDLOO{Object invokePrim(long arg0, double arg1, long arg2, Object arg3);}\nstatic public interface LDLOL{long invokePrim(long arg0, double arg1, long arg2, Object arg3);}\nstatic public interface LDLOD{double invokePrim(long arg0, double arg1, long arg2, Object arg3);}\nstatic public interface LDLLO{Object invokePrim(long arg0, double arg1, long arg2, long arg3);}\nstatic public interface LDLLL{long invokePrim(long arg0, double arg1, long arg2, long arg3);}\nstatic public interface LDLLD{double invokePrim(long arg0, double arg1, long arg2, long arg3);}\nstatic public interface LDLDO{Object invokePrim(long arg0, double arg1, long arg2, double arg3);}\nstatic public interface LDLDL{long invokePrim(long arg0, double arg1, long arg2, double arg3);}\nstatic public interface LDLDD{double invokePrim(long arg0, double arg1, long arg2, double arg3);}\nstatic public interface LDDOO{Object invokePrim(long arg0, double arg1, double arg2, Object arg3);}\nstatic public interface LDDOL{long invokePrim(long arg0, double arg1, double arg2, Object arg3);}\nstatic public interface LDDOD{double invokePrim(long arg0, double arg1, double arg2, Object arg3);}\nstatic public interface LDDLO{Object invokePrim(long arg0, double arg1, double arg2, long arg3);}\nstatic public interface LDDLL{long invokePrim(long arg0, double arg1, double arg2, long arg3);}\nstatic public interface LDDLD{double invokePrim(long arg0, double arg1, double arg2, long arg3);}\nstatic public interface LDDDO{Object invokePrim(long arg0, double arg1, double arg2, double arg3);}\nstatic public interface LDDDL{long invokePrim(long arg0, double arg1, double arg2, double arg3);}\nstatic public interface LDDDD{double invokePrim(long arg0, double arg1, double arg2, double arg3);}\nstatic public interface DOOOO{Object invokePrim(double arg0, Object arg1, Object arg2, Object arg3);}\nstatic public interface DOOOL{long invokePrim(double arg0, Object arg1, Object arg2, Object arg3);}\nstatic public interface DOOOD{double invokePrim(double arg0, Object arg1, Object arg2, Object arg3);}\nstatic public interface DOOLO{Object invokePrim(double arg0, Object arg1, Object arg2, long arg3);}\nstatic public interface DOOLL{long invokePrim(double arg0, Object arg1, Object arg2, long arg3);}\nstatic public interface DOOLD{double invokePrim(double arg0, Object arg1, Object arg2, long arg3);}\nstatic public interface DOODO{Object invokePrim(double arg0, Object arg1, Object arg2, double arg3);}\nstatic public interface DOODL{long invokePrim(double arg0, Object arg1, Object arg2, double arg3);}\nstatic public interface DOODD{double invokePrim(double arg0, Object arg1, Object arg2, double arg3);}\nstatic public interface DOLOO{Object invokePrim(double arg0, Object arg1, long arg2, Object arg3);}\nstatic public interface DOLOL{long invokePrim(double arg0, Object arg1, long arg2, Object arg3);}\nstatic public interface DOLOD{double invokePrim(double arg0, Object arg1, long arg2, Object arg3);}\nstatic public interface DOLLO{Object invokePrim(double arg0, Object arg1, long arg2, long arg3);}\nstatic public interface DOLLL{long invokePrim(double arg0, Object arg1, long arg2, long arg3);}\nstatic public interface DOLLD{double invokePrim(double arg0, Object arg1, long arg2, long arg3);}\nstatic public interface DOLDO{Object invokePrim(double arg0, Object arg1, long arg2, double arg3);}\nstatic public interface DOLDL{long invokePrim(double arg0, Object arg1, long arg2, double arg3);}\nstatic public interface DOLDD{double invokePrim(double arg0, Object arg1, long arg2, double arg3);}\nstatic public interface DODOO{Object invokePrim(double arg0, Object arg1, double arg2, Object arg3);}\nstatic public interface DODOL{long invokePrim(double arg0, Object arg1, double arg2, Object arg3);}\nstatic public interface DODOD{double invokePrim(double arg0, Object arg1, double arg2, Object arg3);}\nstatic public interface DODLO{Object invokePrim(double arg0, Object arg1, double arg2, long arg3);}\nstatic public interface DODLL{long invokePrim(double arg0, Object arg1, double arg2, long arg3);}\nstatic public interface DODLD{double invokePrim(double arg0, Object arg1, double arg2, long arg3);}\nstatic public interface DODDO{Object invokePrim(double arg0, Object arg1, double arg2, double arg3);}\nstatic public interface DODDL{long invokePrim(double arg0, Object arg1, double arg2, double arg3);}\nstatic public interface DODDD{double invokePrim(double arg0, Object arg1, double arg2, double arg3);}\nstatic public interface DLOOO{Object invokePrim(double arg0, long arg1, Object arg2, Object arg3);}\nstatic public interface DLOOL{long invokePrim(double arg0, long arg1, Object arg2, Object arg3);}\nstatic public interface DLOOD{double invokePrim(double arg0, long arg1, Object arg2, Object arg3);}\nstatic public interface DLOLO{Object invokePrim(double arg0, long arg1, Object arg2, long arg3);}\nstatic public interface DLOLL{long invokePrim(double arg0, long arg1, Object arg2, long arg3);}\nstatic public interface DLOLD{double invokePrim(double arg0, long arg1, Object arg2, long arg3);}\nstatic public interface DLODO{Object invokePrim(double arg0, long arg1, Object arg2, double arg3);}\nstatic public interface DLODL{long invokePrim(double arg0, long arg1, Object arg2, double arg3);}\nstatic public interface DLODD{double invokePrim(double arg0, long arg1, Object arg2, double arg3);}\nstatic public interface DLLOO{Object invokePrim(double arg0, long arg1, long arg2, Object arg3);}\nstatic public interface DLLOL{long invokePrim(double arg0, long arg1, long arg2, Object arg3);}\nstatic public interface DLLOD{double invokePrim(double arg0, long arg1, long arg2, Object arg3);}\nstatic public interface DLLLO{Object invokePrim(double arg0, long arg1, long arg2, long arg3);}\nstatic public interface DLLLL{long invokePrim(double arg0, long arg1, long arg2, long arg3);}\nstatic public interface DLLLD{double invokePrim(double arg0, long arg1, long arg2, long arg3);}\nstatic public interface DLLDO{Object invokePrim(double arg0, long arg1, long arg2, double arg3);}\nstatic public interface DLLDL{long invokePrim(double arg0, long arg1, long arg2, double arg3);}\nstatic public interface DLLDD{double invokePrim(double arg0, long arg1, long arg2, double arg3);}\nstatic public interface DLDOO{Object invokePrim(double arg0, long arg1, double arg2, Object arg3);}\nstatic public interface DLDOL{long invokePrim(double arg0, long arg1, double arg2, Object arg3);}\nstatic public interface DLDOD{double invokePrim(double arg0, long arg1, double arg2, Object arg3);}\nstatic public interface DLDLO{Object invokePrim(double arg0, long arg1, double arg2, long arg3);}\nstatic public interface DLDLL{long invokePrim(double arg0, long arg1, double arg2, long arg3);}\nstatic public interface DLDLD{double invokePrim(double arg0, long arg1, double arg2, long arg3);}\nstatic public interface DLDDO{Object invokePrim(double arg0, long arg1, double arg2, double arg3);}\nstatic public interface DLDDL{long invokePrim(double arg0, long arg1, double arg2, double arg3);}\nstatic public interface DLDDD{double invokePrim(double arg0, long arg1, double arg2, double arg3);}\nstatic public interface DDOOO{Object invokePrim(double arg0, double arg1, Object arg2, Object arg3);}\nstatic public interface DDOOL{long invokePrim(double arg0, double arg1, Object arg2, Object arg3);}\nstatic public interface DDOOD{double invokePrim(double arg0, double arg1, Object arg2, Object arg3);}\nstatic public interface DDOLO{Object invokePrim(double arg0, double arg1, Object arg2, long arg3);}\nstatic public interface DDOLL{long invokePrim(double arg0, double arg1, Object arg2, long arg3);}\nstatic public interface DDOLD{double invokePrim(double arg0, double arg1, Object arg2, long arg3);}\nstatic public interface DDODO{Object invokePrim(double arg0, double arg1, Object arg2, double arg3);}\nstatic public interface DDODL{long invokePrim(double arg0, double arg1, Object arg2, double arg3);}\nstatic public interface DDODD{double invokePrim(double arg0, double arg1, Object arg2, double arg3);}\nstatic public interface DDLOO{Object invokePrim(double arg0, double arg1, long arg2, Object arg3);}\nstatic public interface DDLOL{long invokePrim(double arg0, double arg1, long arg2, Object arg3);}\nstatic public interface DDLOD{double invokePrim(double arg0, double arg1, long arg2, Object arg3);}\nstatic public interface DDLLO{Object invokePrim(double arg0, double arg1, long arg2, long arg3);}\nstatic public interface DDLLL{long invokePrim(double arg0, double arg1, long arg2, long arg3);}\nstatic public interface DDLLD{double invokePrim(double arg0, double arg1, long arg2, long arg3);}\nstatic public interface DDLDO{Object invokePrim(double arg0, double arg1, long arg2, double arg3);}\nstatic public interface DDLDL{long invokePrim(double arg0, double arg1, long arg2, double arg3);}\nstatic public interface DDLDD{double invokePrim(double arg0, double arg1, long arg2, double arg3);}\nstatic public interface DDDOO{Object invokePrim(double arg0, double arg1, double arg2, Object arg3);}\nstatic public interface DDDOL{long invokePrim(double arg0, double arg1, double arg2, Object arg3);}\nstatic public interface DDDOD{double invokePrim(double arg0, double arg1, double arg2, Object arg3);}\nstatic public interface DDDLO{Object invokePrim(double arg0, double arg1, double arg2, long arg3);}\nstatic public interface DDDLL{long invokePrim(double arg0, double arg1, double arg2, long arg3);}\nstatic public interface DDDLD{double invokePrim(double arg0, double arg1, double arg2, long arg3);}\nstatic public interface DDDDO{Object invokePrim(double arg0, double arg1, double arg2, double arg3);}\nstatic public interface DDDDL{long invokePrim(double arg0, double arg1, double arg2, double arg3);}\nstatic public interface DDDDD{double invokePrim(double arg0, double arg1, double arg2, double arg3);}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IHashEq.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich 10/23/11 */\n\npackage clojure.lang;\n\npublic interface IHashEq{\nint hasheq();\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IKeywordLookup.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Oct 31, 2009 */\n\npackage clojure.lang;\n\npublic interface IKeywordLookup{\nILookupThunk getLookupThunk(Keyword k);\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ILookup.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Aug 2, 2009 */\n\npackage clojure.lang;\n\npublic interface ILookup{\nObject valAt(Object key);\n\nObject valAt(Object key, Object notFound);\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ILookupSite.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Nov 2, 2009 */\n\npackage clojure.lang;\n\npublic interface ILookupSite{\n\nILookupThunk fault(Object target);\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ILookupThunk.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Nov 2, 2009 */\n\npackage clojure.lang;\n\npublic interface ILookupThunk{\n\nObject get(Object target);\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IMapEntry.java",
    "content": "/**\r\n * Copyright (c) Rich Hickey. All rights reserved.\r\n * The use and distribution terms for this software are covered by the\r\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n * which can be found in the file epl-v10.html at the root of this distribution.\r\n * By using this software in any fashion, you are agreeing to be bound by\r\n * the terms of this license.\r\n * You must not remove this notice, or any other, from this software.\r\n */\r\n\r\npackage clojure.lang;\r\n\r\nimport java.util.Map;\r\n\r\npublic interface IMapEntry extends Map.Entry{\r\nObject key();\r\n\r\nObject val();\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/IMapIterable.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* Alex Miller Dec 3, 2014 */\n\npackage clojure.lang;\n\nimport java.util.Iterator;\n\n/**\n * Indicate a map can provide more efficient key and val iterators.\n */\npublic interface IMapIterable {\n\nIterator keyIterator();\n\nIterator valIterator();\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IMeta.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Dec 31, 2008 */\n\npackage clojure.lang;\n\npublic interface IMeta {\n    IPersistentMap meta();\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IObj.java",
    "content": "/**\r\n *   Copyright (c) Rich Hickey. All rights reserved.\r\n *   The use and distribution terms for this software are covered by the\r\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n *   which can be found in the file epl-v10.html at the root of this distribution.\r\n *   By using this software in any fashion, you are agreeing to be bound by\r\n * \t the terms of this license.\r\n *   You must not remove this notice, or any other, from this software.\r\n **/\r\n\r\npackage clojure.lang;\r\n\r\n\r\npublic interface IObj extends IMeta {\r\n\r\n    public IObj withMeta(IPersistentMap meta);\r\n\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/IPending.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\npublic interface IPending{\n    boolean isRealized();\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IPersistentCollection.java",
    "content": "package clojure.lang;\r\n\r\n/**\r\n * Copyright (c) Rich Hickey. All rights reserved.\r\n * The use and distribution terms for this software are covered by the\r\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n * which can be found in the file epl-v10.html at the root of this distribution.\r\n * By using this software in any fashion, you are agreeing to be bound by\r\n * the terms of this license.\r\n * You must not remove this notice, or any other, from this software.\r\n */\r\n\r\n\r\npublic interface IPersistentCollection extends Seqable {\r\n\r\nint count();\r\n\r\nIPersistentCollection cons(Object o);\r\n\r\nIPersistentCollection empty();\r\n\r\nboolean equiv(Object o);\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/IPersistentList.java",
    "content": "/**\r\n * Copyright (c) Rich Hickey. All rights reserved.\r\n * The use and distribution terms for this software are covered by the\r\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n * which can be found in the file epl-v10.html at the root of this distribution.\r\n * By using this software in any fashion, you are agreeing to be bound by\r\n * the terms of this license.\r\n * You must not remove this notice, or any other, from this software.\r\n */\r\n\r\npackage clojure.lang;\r\n\r\n\r\npublic interface IPersistentList extends Sequential, IPersistentStack{\r\n\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/IPersistentMap.java",
    "content": "/**\n * Copyright (c) Rich Hickey. All rights reserved.\n * The use and distribution terms for this software are covered by the\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n * which can be found in the file epl-v10.html at the root of this distribution.\n * By using this software in any fashion, you are agreeing to be bound by\n * the terms of this license.\n * You must not remove this notice, or any other, from this software.\n */\n\npackage clojure.lang;\n\n\npublic interface IPersistentMap extends Iterable, Associative, Counted{\n\n\nIPersistentMap assoc(Object key, Object val);\n\nIPersistentMap assocEx(Object key, Object val) ;\n\nIPersistentMap without(Object key) ;\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IPersistentSet.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 3, 2008 */\n\npackage clojure.lang;\n\npublic interface IPersistentSet extends IPersistentCollection, Counted{\n\tpublic IPersistentSet disjoin(Object key) ;\n\tpublic boolean contains(Object key);\n\tpublic Object get(Object key);\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IPersistentStack.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Sep 19, 2007 */\n\npackage clojure.lang;\n\npublic interface IPersistentStack extends IPersistentCollection{\nObject peek();\n\nIPersistentStack pop();\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IPersistentVector.java",
    "content": "package clojure.lang;\r\n\r\n/**\r\n * Copyright (c) Rich Hickey. All rights reserved.\r\n * The use and distribution terms for this software are covered by the\r\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n * which can be found in the file epl-v10.html at the root of this distribution.\r\n * By using this software in any fashion, you are agreeing to be bound by\r\n * the terms of this license.\r\n * You must not remove this notice, or any other, from this software.\r\n */\r\n\r\npublic interface IPersistentVector extends Associative, Sequential, IPersistentStack, Reversible, Indexed{\r\nint length();\r\n\r\nIPersistentVector assocN(int i, Object val);\r\n\r\nIPersistentVector cons(Object o);\r\n\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/IProxy.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Feb 27, 2008 */\n\npackage clojure.lang;\n\npublic interface IProxy{\n\n    public void __initClojureFnMappings(IPersistentMap m);\n    public void __updateClojureFnMappings(IPersistentMap m);\n    public IPersistentMap __getClojureFnMappings();\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IRecord.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\npublic interface IRecord {\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IReduce.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jun 11, 2008 */\n\npackage clojure.lang;\n\npublic interface IReduce extends IReduceInit{\nObject reduce(IFn f) ;\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IReduceInit.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\npublic interface IReduceInit{\nObject reduce(IFn f, Object start) ;\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IRef.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Nov 18, 2007 */\n\npackage clojure.lang;\n\npublic interface IRef extends IDeref{\n\n\tvoid setValidator(IFn vf);\n\n    IFn getValidator();\n\n    IPersistentMap getWatches();\n\n    IRef addWatch(Object key, IFn callback);\n\n    IRef removeWatch(Object key);\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IReference.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Dec 31, 2008 */\n\npackage clojure.lang;\n\npublic interface IReference extends IMeta {\n    IPersistentMap alterMeta(IFn alter, ISeq args) ;\n    IPersistentMap resetMeta(IPersistentMap m);\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ISeq.java",
    "content": "/**\r\n * Copyright (c) Rich Hickey. All rights reserved.\r\n * The use and distribution terms for this software are covered by the\r\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n * which can be found in the file epl-v10.html at the root of this distribution.\r\n * By using this software in any fashion, you are agreeing to be bound by\r\n * the terms of this license.\r\n * You must not remove this notice, or any other, from this software.\r\n */\r\n\r\npackage clojure.lang;\r\n\r\n/**\r\n * A persistent, functional, sequence interface\r\n * <p/>\r\n * ISeqs are immutable values, i.e. neither first(), nor rest() changes\r\n * or invalidates the ISeq\r\n */\r\npublic interface ISeq extends IPersistentCollection {\n\r\nObject first();\r\n\r\nISeq next();\r\n\r\nISeq more();\r\n\r\nISeq cons(Object o);\r\n\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/ITransientAssociative.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jul 17, 2009 */\n\npackage clojure.lang;\n\npublic interface ITransientAssociative extends ITransientCollection, ILookup{\n\nITransientAssociative assoc(Object key, Object val);\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ITransientCollection.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jul 17, 2009 */\n\npackage clojure.lang;\n\npublic interface ITransientCollection{\n\nITransientCollection conj(Object val);\n\nIPersistentCollection persistent();\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ITransientMap.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jul 17, 2009 */\n\npackage clojure.lang;\n\npublic interface ITransientMap extends ITransientAssociative, Counted{\n\t\nITransientMap assoc(Object key, Object val);\n\nITransientMap without(Object key);\n\nIPersistentMap persistent();\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ITransientSet.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 3, 2008 */\n\npackage clojure.lang;\n\npublic interface ITransientSet extends ITransientCollection, Counted{\n\tpublic ITransientSet disjoin(Object key) ;\n\tpublic boolean contains(Object key);\n\tpublic Object get(Object key);\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ITransientVector.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jul 17, 2009 */\n\npackage clojure.lang;\n\npublic interface ITransientVector extends ITransientAssociative, Indexed{\n\nITransientVector assocN(int i, Object val);\n\nITransientVector pop();\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IType.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\npublic interface IType {\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IllegalAccessError.java",
    "content": "package clojure.lang;\n\nimport java.lang.RuntimeException;\nimport java.lang.String;\n\npublic class IllegalAccessError extends RuntimeException {\n\n  public IllegalAccessError(String msg) {\n    super(msg);\n  }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Indexed.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich May 24, 2009 */\n\npackage clojure.lang;\n\npublic interface Indexed extends Counted{\nObject nth(int i);\n\nObject nth(int i, Object notFound);\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IndexedSeq.java",
    "content": "/**\r\n * Copyright (c) Rich Hickey. All rights reserved.\r\n * The use and distribution terms for this software are covered by the\r\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n * which can be found in the file epl-v10.html at the root of this distribution.\r\n * By using this software in any fashion, you are agreeing to be bound by\r\n * the terms of this license.\r\n * You must not remove this notice, or any other, from this software.\r\n */\r\n\r\npackage clojure.lang;\r\n\r\npublic interface IndexedSeq extends ISeq, Sequential, Counted{\n\r\npublic int index();\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/Intrinsics.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich 9/5/11 */\n\npackage clojure.lang;\n\nimport clojure.asm.Opcodes;\n\npublic class Intrinsics implements Opcodes{\nprivate static Object[] oa(Object... arr){\n\treturn arr;\n}\n\nstatic IPersistentMap ops = RT.map(\n \"public static double clojure.lang.Numbers.add(double,double)\", DADD,\n \"public static long clojure.lang.Numbers.and(long,long)\", LAND,\n \"public static long clojure.lang.Numbers.or(long,long)\", LOR,\n \"public static long clojure.lang.Numbers.xor(long,long)\", LXOR,\n \"public static double clojure.lang.Numbers.multiply(double,double)\", DMUL,\n \"public static double clojure.lang.Numbers.divide(double,double)\", DDIV,\n \"public static long clojure.lang.Numbers.remainder(long,long)\", LREM,\n \"public static long clojure.lang.Numbers.shiftLeft(long,long)\", oa(L2I, LSHL),\n \"public static long clojure.lang.Numbers.shiftRight(long,long)\", oa(L2I, LSHR),\n \"public static long clojure.lang.Numbers.unsignedShiftRight(long,long)\", oa(L2I, LUSHR),\n \"public static double clojure.lang.Numbers.minus(double)\", DNEG,\n \"public static double clojure.lang.Numbers.minus(double,double)\", DSUB,\n \"public static double clojure.lang.Numbers.inc(double)\", oa(DCONST_1, DADD),\n \"public static double clojure.lang.Numbers.dec(double)\", oa(DCONST_1, DSUB),\n \"public static long clojure.lang.Numbers.quotient(long,long)\", LDIV,\n \"public static int clojure.lang.Numbers.shiftLeftInt(int,int)\", ISHL,\n \"public static int clojure.lang.Numbers.shiftRightInt(int,int)\", ISHR,\n \"public static int clojure.lang.Numbers.unsignedShiftRightInt(int,int)\", IUSHR,\n \"public static int clojure.lang.Numbers.unchecked_int_add(int,int)\", IADD,\n \"public static int clojure.lang.Numbers.unchecked_int_subtract(int,int)\", ISUB,\n \"public static int clojure.lang.Numbers.unchecked_int_negate(int)\", INEG,\n \"public static int clojure.lang.Numbers.unchecked_int_inc(int)\", oa(ICONST_1, IADD),\n \"public static int clojure.lang.Numbers.unchecked_int_dec(int)\", oa(ICONST_1, ISUB),\n \"public static int clojure.lang.Numbers.unchecked_int_multiply(int,int)\", IMUL,\n \"public static int clojure.lang.Numbers.unchecked_int_divide(int,int)\", IDIV,\n \"public static int clojure.lang.Numbers.unchecked_int_remainder(int,int)\", IREM,\n \"public static long clojure.lang.Numbers.unchecked_add(long,long)\", LADD,\n \"public static double clojure.lang.Numbers.unchecked_add(double,double)\", DADD,\n \"public static long clojure.lang.Numbers.unchecked_minus(long)\", LNEG,\n \"public static double clojure.lang.Numbers.unchecked_minus(double)\", DNEG,\n \"public static double clojure.lang.Numbers.unchecked_minus(double,double)\", DSUB,\n \"public static long clojure.lang.Numbers.unchecked_minus(long,long)\", LSUB,\n \"public static long clojure.lang.Numbers.unchecked_multiply(long,long)\", LMUL,\n \"public static double clojure.lang.Numbers.unchecked_multiply(double,double)\", DMUL,\n \"public static double clojure.lang.Numbers.unchecked_inc(double)\", oa(DCONST_1, DADD),\n \"public static long clojure.lang.Numbers.unchecked_inc(long)\", oa(LCONST_1, LADD),\n \"public static double clojure.lang.Numbers.unchecked_dec(double)\", oa(DCONST_1, DSUB),\n \"public static long clojure.lang.Numbers.unchecked_dec(long)\", oa(LCONST_1, LSUB),\n\n\n  \"public static short clojure.lang.RT.aget(short[],int)\", SALOAD,\n  \"public static float clojure.lang.RT.aget(float[],int)\", FALOAD,\n  \"public static double clojure.lang.RT.aget(double[],int)\", DALOAD,\n  \"public static int clojure.lang.RT.aget(int[],int)\", IALOAD,\n  \"public static long clojure.lang.RT.aget(long[],int)\", LALOAD,\n  \"public static char clojure.lang.RT.aget(char[],int)\", CALOAD,\n  \"public static byte clojure.lang.RT.aget(byte[],int)\", BALOAD,\n  \"public static boolean clojure.lang.RT.aget(boolean[],int)\", BALOAD,\n  \"public static java.lang.Object clojure.lang.RT.aget(java.lang.Object[],int)\", AALOAD,\n  \"public static int clojure.lang.RT.alength(int[])\", ARRAYLENGTH,\n  \"public static int clojure.lang.RT.alength(long[])\", ARRAYLENGTH,\n  \"public static int clojure.lang.RT.alength(char[])\", ARRAYLENGTH,\n  \"public static int clojure.lang.RT.alength(java.lang.Object[])\", ARRAYLENGTH,\n  \"public static int clojure.lang.RT.alength(byte[])\", ARRAYLENGTH,\n  \"public static int clojure.lang.RT.alength(float[])\", ARRAYLENGTH,\n  \"public static int clojure.lang.RT.alength(short[])\", ARRAYLENGTH,\n  \"public static int clojure.lang.RT.alength(boolean[])\", ARRAYLENGTH,\n  \"public static int clojure.lang.RT.alength(double[])\", ARRAYLENGTH,\n\n \"public static double clojure.lang.RT.doubleCast(long)\", L2D,\n \"public static double clojure.lang.RT.doubleCast(double)\", NOP,\n \"public static double clojure.lang.RT.doubleCast(float)\", F2D,\n \"public static double clojure.lang.RT.doubleCast(int)\", I2D,\n \"public static double clojure.lang.RT.doubleCast(short)\", I2D,\n \"public static double clojure.lang.RT.doubleCast(byte)\", I2D,\n \"public static double clojure.lang.RT.uncheckedDoubleCast(double)\", NOP,\n \"public static double clojure.lang.RT.uncheckedDoubleCast(float)\", F2D,\n \"public static double clojure.lang.RT.uncheckedDoubleCast(long)\", L2D,\n \"public static double clojure.lang.RT.uncheckedDoubleCast(int)\", I2D,\n \"public static double clojure.lang.RT.uncheckedDoubleCast(short)\", I2D,\n \"public static double clojure.lang.RT.uncheckedDoubleCast(byte)\", I2D,\n \"public static long clojure.lang.RT.longCast(long)\", NOP,\n \"public static long clojure.lang.RT.longCast(short)\", I2L,\n \"public static long clojure.lang.RT.longCast(byte)\", I2L,\n \"public static long clojure.lang.RT.longCast(int)\", I2L,\n  \"public static int clojure.lang.RT.uncheckedIntCast(long)\", L2I,\n  \"public static int clojure.lang.RT.uncheckedIntCast(double)\", D2I,\n  \"public static int clojure.lang.RT.uncheckedIntCast(byte)\", NOP,\n  \"public static int clojure.lang.RT.uncheckedIntCast(short)\", NOP,\n  \"public static int clojure.lang.RT.uncheckedIntCast(char)\", NOP,\n  \"public static int clojure.lang.RT.uncheckedIntCast(int)\", NOP,\n  \"public static int clojure.lang.RT.uncheckedIntCast(float)\", F2I,\n  \"public static long clojure.lang.RT.uncheckedLongCast(short)\", I2L,\n  \"public static long clojure.lang.RT.uncheckedLongCast(float)\", F2L,\n  \"public static long clojure.lang.RT.uncheckedLongCast(double)\", D2L,\n  \"public static long clojure.lang.RT.uncheckedLongCast(byte)\", I2L,\n  \"public static long clojure.lang.RT.uncheckedLongCast(long)\", NOP,\n  \"public static long clojure.lang.RT.uncheckedLongCast(int)\", I2L\n);\n\n//map to instructions terminated with comparator for branch to false\nstatic IPersistentMap preds = RT.map(\n  \"public static boolean clojure.lang.Numbers.lt(double,double)\", oa(DCMPG, IFGE),\n  \"public static boolean clojure.lang.Numbers.lt(long,long)\", oa(LCMP, IFGE),\n  \"public static boolean clojure.lang.Numbers.equiv(double,double)\", oa(DCMPL, IFNE),\n  \"public static boolean clojure.lang.Numbers.equiv(long,long)\", oa(LCMP, IFNE),\n  \"public static boolean clojure.lang.Numbers.lte(double,double)\", oa(DCMPG, IFGT),\n  \"public static boolean clojure.lang.Numbers.lte(long,long)\", oa(LCMP, IFGT),\n  \"public static boolean clojure.lang.Numbers.gt(long,long)\", oa(LCMP, IFLE),\n  \"public static boolean clojure.lang.Numbers.gt(double,double)\", oa(DCMPL, IFLE),\n  \"public static boolean clojure.lang.Numbers.gte(long,long)\", oa(LCMP, IFLT),\n  \"public static boolean clojure.lang.Numbers.gte(double,double)\", oa(DCMPL, IFLT),\n  \"public static boolean clojure.lang.Util.equiv(long,long)\", oa(LCMP, IFNE),\n  \"public static boolean clojure.lang.Util.equiv(boolean,boolean)\", oa(IF_ICMPNE),\n  \"public static boolean clojure.lang.Util.equiv(double,double)\", oa(DCMPL, IFNE),\n\n  \"public static boolean clojure.lang.Numbers.isZero(double)\", oa(DCONST_0, DCMPL, IFNE),\n  \"public static boolean clojure.lang.Numbers.isZero(long)\", oa(LCONST_0, LCMP, IFNE),\n  \"public static boolean clojure.lang.Numbers.isPos(long)\", oa(LCONST_0, LCMP, IFLE),\n  \"public static boolean clojure.lang.Numbers.isPos(double)\", oa(DCONST_0, DCMPL, IFLE),\n  \"public static boolean clojure.lang.Numbers.isNeg(long)\", oa(LCONST_0, LCMP, IFGE),\n  \"public static boolean clojure.lang.Numbers.isNeg(double)\", oa(DCONST_0, DCMPG, IFGE)\n);\n}"
  },
  {
    "path": "src/jvm/clojure/lang/Iterate.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\n/* Alex Miller, Dec 5, 2014 */\n\npublic class Iterate extends ASeq implements IReduce, IPending {\n\nprivate static final Object UNREALIZED_SEED = new Object();\nprivate final IFn f;      // never null\nprivate final Object prevSeed;\nprivate volatile Object _seed;  // lazily realized\nprivate volatile ISeq _next;  // cached\n\nprivate Iterate(IFn f, Object prevSeed, Object seed){\n    this.f = f;\n    this.prevSeed = prevSeed;\n    this._seed = seed;\n}\n\nprivate Iterate(IPersistentMap meta, IFn f, Object prevSeed, Object seed, ISeq next){\n    super(meta);\n    this.f = f;\n    this.prevSeed = prevSeed;\n    this._seed = seed;\n    this._next = next;\n}\n\npublic static ISeq create(IFn f, Object seed){\n    return new Iterate(f, null, seed);\n}\n\npublic boolean isRealized() {\n    return _seed != UNREALIZED_SEED;\n}\n\npublic Object first(){\n    if(_seed == UNREALIZED_SEED) {\n        _seed = f.invoke(prevSeed);\n    }\n    return _seed;\n}\n\npublic ISeq next(){\n    if(_next == null) {\n        _next = new Iterate(f, first(), UNREALIZED_SEED);\n    }\n    return _next;\n}\n\npublic Iterate withMeta(IPersistentMap meta){\n    return new Iterate(meta, f, prevSeed, _seed, _next);\n}\n\npublic Object reduce(IFn rf){\n    Object first = first();\n    Object ret = first;\n    Object v = f.invoke(first);\n    while(true){\n        ret = rf.invoke(ret, v);\n        if(RT.isReduced(ret))\n            return ((IDeref)ret).deref();\n        v = f.invoke(v);\n    }\n}\n\npublic Object reduce(IFn rf, Object start){\n    Object ret = start;\n    Object v = first();\n    while(true){\n        ret = rf.invoke(ret, v);\n        if(RT.isReduced(ret))\n            return ((IDeref)ret).deref();\n        v = f.invoke(v);\n    }\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/IteratorSeq.java",
    "content": "/**\r\n *   Copyright (c) Rich Hickey. All rights reserved.\r\n *   The use and distribution terms for this software are covered by the\r\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n *   which can be found in the file epl-v10.html at the root of this distribution.\r\n *   By using this software in any fashion, you are agreeing to be bound by\r\n * \t the terms of this license.\r\n *   You must not remove this notice, or any other, from this software.\r\n **/\r\n\r\npackage clojure.lang;\r\n\r\nimport java.io.IOException;\r\nimport java.io.NotSerializableException;\r\nimport java.util.Iterator;\r\n\r\npublic class IteratorSeq extends ASeq{\r\nfinal Iterator iter;\r\nfinal State state;\r\n\r\n    static class State{\r\n\tvolatile Object val;\r\n\tvolatile Object _rest;\r\n}\r\n\r\npublic static IteratorSeq create(Iterator iter){\r\n\tif(iter.hasNext())\r\n\t\treturn new IteratorSeq(iter);\r\n\treturn null;\r\n}\r\n\r\nIteratorSeq(Iterator iter){\r\n\tthis.iter = iter;\r\n\tstate = new State();\r\n\tthis.state.val = state;\r\n\tthis.state._rest = state;\r\n}\r\n\r\nIteratorSeq(IPersistentMap meta, Iterator iter, State state){\r\n\tsuper(meta);\r\n\tthis.iter = iter;\r\n\tthis.state = state;\r\n}\r\n\r\npublic Object first(){\r\n\tif(state.val == state)\r\n\t\tsynchronized(state)\r\n\t\t\t{\r\n\t\t\tif(state.val == state)\r\n\t\t\t\tstate.val = iter.next();\r\n\t\t\t}\r\n\treturn state.val;\r\n}\r\n\r\npublic ISeq next(){\r\n\tif(state._rest == state)\r\n\t\tsynchronized(state)\r\n\t\t\t{\r\n\t\t\tif(state._rest == state)\r\n\t\t\t\t{\r\n\t\t\t\tfirst();\r\n\t\t\t\tstate._rest = create(iter);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\treturn (ISeq) state._rest;\r\n}\r\n\r\npublic IteratorSeq withMeta(IPersistentMap meta){\r\n\treturn new IteratorSeq(meta, iter, state);\r\n}\r\n\r\nprivate void writeObject (java.io.ObjectOutputStream out) throws IOException {\r\n    throw new NotSerializableException(getClass().getName());\r\n}\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/Keyword.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 29, 2006 10:39:05 AM */\n\npackage clojure.lang;\n\nimport java.io.ObjectStreamException;\nimport java.io.Serializable;\nimport java.lang.ref.Reference;\nimport java.lang.ref.WeakReference;\nimport java.util.concurrent.ConcurrentHashMap;\nimport java.lang.ref.ReferenceQueue;\nimport java.lang.ref.SoftReference;\n\n\npublic class Keyword implements IFn, Comparable, Named, Serializable, IHashEq {\n\nprivate static ConcurrentHashMap<Symbol, Reference<Keyword>> table = new ConcurrentHashMap();\nstatic final ReferenceQueue rq = new ReferenceQueue();\npublic final Symbol sym;\nfinal int hasheq;\ntransient String _str;\n\npublic static Keyword intern(Symbol sym){\n\tKeyword k = null;\n\tReference<Keyword> existingRef = table.get(sym);\n\tif(existingRef == null)\n\t\t{\n\t\tUtil.clearCache(rq, table);\n\t\tif(sym.meta() != null)\n\t\t\tsym = (Symbol) sym.withMeta(null);\n\t\tk = new Keyword(sym);\n\t\texistingRef = table.putIfAbsent(sym, new WeakReference<Keyword>(k, rq));\n\t\t}\n\tif(existingRef == null)\n\t\treturn k;\n\tKeyword existingk = existingRef.get();\n\tif(existingk != null)\n\t\treturn existingk;\n\t//entry died in the interim, do over\n\ttable.remove(sym, existingRef);\n\treturn intern(sym);\n}\n\npublic static Keyword intern(String ns, String name){\n\treturn intern(Symbol.intern(ns, name));\n}\n\npublic static Keyword intern(String nsname){\n\treturn intern(Symbol.intern(nsname));\n}\n\nprivate Keyword(Symbol sym){\n\tthis.sym = sym;\n\thasheq = sym.hasheq() + 0x9e3779b9;\n}\n\npublic static Keyword find(Symbol sym){\n    Reference<Keyword> ref = table.get(sym);\n    if (ref != null)\n        return ref.get();\n    else\n        return null;\n}\n\npublic static Keyword find(String ns, String name){\n    return find(Symbol.intern(ns, name));\n}\n\npublic static Keyword find(String nsname){\n    return find(Symbol.intern(nsname));\n}\n\npublic final int hashCode(){\n\treturn Util.hash(sym) + 0x9e3779b9;\n}\n\npublic int hasheq() {\n\treturn hasheq;\n}\n\npublic String toString(){\n\tif(_str == null)\n\t\t_str = (\":\" + sym);\n\treturn _str;\n}\n\npublic Object throwArity(){\n\tthrow new IllegalArgumentException(\"Wrong number of args passed to keyword: \"\n\t                                   + toString());\n}\n\npublic Object call() {\n\treturn throwArity();\n}\n\npublic void run(){\n\tthrow new UnsupportedOperationException();\n}\n\npublic Object invoke() {\n\treturn throwArity();\n}\n\npublic int compareTo(Object o){\n\treturn sym.compareTo(((Keyword) o).sym);\n}\n\n\npublic String getNamespace(){\n\treturn sym.getNamespace();\n}\n\npublic String getName(){\n\treturn sym.getName();\n}\n\nprivate Object readResolve() throws ObjectStreamException{\n\treturn intern(sym);\n}\n\n/**\n * Indexer implements IFn for attr access\n *\n * @param obj - must be IPersistentMap\n * @return the value at the key or nil if not found\n * @\n */\nfinal public Object invoke(Object obj) {\n\tif(obj instanceof ILookup)\n\t\treturn ((ILookup)obj).valAt(this);\n\treturn RT.get(obj, this);\n}\n\nfinal public Object invoke(Object obj, Object notFound) {\n\tif(obj instanceof ILookup)\n\t\treturn ((ILookup)obj).valAt(this,notFound);\n\treturn RT.get(obj, this, notFound);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)\n\t\t{\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13)\n\t\t{\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)\n\t\t{\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19) {\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20)\n\t\t{\n\treturn throwArity();\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20,\n                     Object... args)\n\t\t{\n\treturn throwArity();\n}\n\n\npublic Object applyTo(ISeq arglist) {\n\treturn AFn.applyToHelper(this, arglist);\n}\n\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/KeywordLookupSite.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Nov 2, 2009 */\n\npackage clojure.lang;\n\npublic final class KeywordLookupSite implements ILookupSite, ILookupThunk{\n\nfinal Keyword k;\n\npublic KeywordLookupSite(Keyword k){\n\tthis.k = k;\n}\n\npublic ILookupThunk fault(Object target){\n\tif(target instanceof IKeywordLookup)\n\t\t{\n\t\treturn install(target);\n\t\t}\n\telse if(target instanceof ILookup)\n\t\t{\n\t\treturn ilookupThunk(target.getClass());\n\t\t}\n\treturn this;\n}\n\npublic Object get(Object target){\n\tif(target instanceof IKeywordLookup || target instanceof ILookup)\n\t\treturn this;\n\treturn RT.get(target,k);\n}\n\nprivate ILookupThunk ilookupThunk(final Class c){\n\treturn new ILookupThunk(){\n\t\t\tpublic Object get(Object target){\n\t\t\t\tif(target != null && target.getClass() == c)\n\t\t\t\t\treturn ((ILookup) target).valAt(k);\n\t\t\t\treturn this;\n\t\t\t}\n\t\t};\n}\n\nprivate ILookupThunk install(Object target){\n\tILookupThunk t = ((IKeywordLookup)target).getLookupThunk(k);\n\tif(t != null)\n\t\treturn t;\n\treturn ilookupThunk(target.getClass());\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/LazilyPersistentVector.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich May 14, 2008 */\n\npackage clojure.lang;\n\npublic class LazilyPersistentVector{\n\n\nstatic public IPersistentVector createOwning(Object... items){\n\tif(items.length == 0)\n\t\treturn PersistentVector.EMPTY;\n\telse if(items.length <= 32)\n\t\treturn new PersistentVector(items.length, 5, PersistentVector.EMPTY_NODE,items);\n\treturn PersistentVector.create(items);\n}\n\nstatic public IPersistentVector create(Object obj){\n   if(obj instanceof IReduceInit)\n       return PersistentVector.create((IReduceInit) obj);\n   else if(obj instanceof ISeq)\n       return PersistentVector.create(RT.seq(obj));\n   else if(obj instanceof Iterable)\n       return PersistentVector.create((Iterable)obj);\n   else\n       return createOwning(RT.toArray(obj));\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/LazySeq.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jan 31, 2009 */\n\npackage clojure.lang;\n\nimport java.util.*;\n\npublic final class LazySeq extends Obj implements ISeq, Sequential, List, IPending, IHashEq{\n\nprivate IFn fn;\nprivate Object sv;\nprivate ISeq s;\n\npublic LazySeq(IFn fn){\n\tthis.fn = fn;\n}\n\nprivate LazySeq(IPersistentMap meta, ISeq s){\n\tsuper(meta);\n\tthis.fn = null;\n\tthis.s = s;\n}\n\npublic Obj withMeta(IPersistentMap meta){\n\treturn new LazySeq(meta, seq());\n}\n\nfinal synchronized Object sval(){\n\tif(fn != null)\n\t\t{\n                sv = fn.invoke();\n                fn = null;\n\t\t}\n\tif(sv != null)\n\t\treturn sv;\n\treturn s;\n}\n\nfinal synchronized public ISeq seq(){\n\tsval();\n\tif(sv != null)\n\t\t{\n\t\tObject ls = sv;\n\t\tsv = null;\n\t\twhile(ls instanceof LazySeq)\n\t\t\t{\n\t\t\tls = ((LazySeq)ls).sval();\n\t\t\t}\n\t\ts = RT.seq(ls);\n\t\t}\n\treturn s;\n}\n\npublic int count(){\n\tint c = 0;\n\tfor(ISeq s = seq(); s != null; s = s.next())\n\t\t++c;                                                                                \n\treturn c;\n}\n\npublic Object first(){\n\tseq();\n\tif(s == null)\n\t\treturn null;\n\treturn s.first();\n}\n\npublic ISeq next(){\n\tseq();\n\tif(s == null)\n\t\treturn null;\n\treturn s.next();\t\n}\n\npublic ISeq more(){\n\tseq();\n\tif(s == null)\n\t\treturn PersistentList.EMPTY;\n\treturn s.more();\n}\n\npublic ISeq cons(Object o){\n\treturn RT.cons(o, seq());\n}\n\npublic IPersistentCollection empty(){\n\treturn PersistentList.EMPTY;\n}\n\npublic boolean equiv(Object o){\n\tISeq s = seq();\n\tif(s != null)\n\t\treturn s.equiv(o);\n\telse\n\t\treturn (o instanceof Sequential || o instanceof List) && RT.seq(o) == null;\n}\n\npublic int hashCode(){\n\tISeq s = seq();\n\tif(s == null)\n\t\treturn 1;\n\treturn Util.hash(seq());\n}\n\npublic int hasheq(){\n\treturn Murmur3.hashOrdered(this);\n}\n\npublic boolean equals(Object o){\n\tISeq s = seq();\n\tif(s != null)\n\t\treturn s.equals(o);\n\telse\n\t\treturn (o instanceof Sequential || o instanceof List) && RT.seq(o) == null;\n}\n\n\n// java.util.Collection implementation\n\npublic Object[] toArray(){\n\treturn RT.seqToArray(seq());\n}\n\npublic boolean add(Object o){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean remove(Object o){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean addAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic void clear(){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean retainAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean removeAll(Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean containsAll(Collection c){\n\tfor(Object o : c)\n\t\t{\n\t\tif(!contains(o))\n\t\t\treturn false;\n\t\t}\n\treturn true;\n}\n\npublic Object[] toArray(Object[] a){\n    return RT.seqToPassedArray(seq(), a);\n}\n\npublic int size(){\n\treturn count();\n}\n\npublic boolean isEmpty(){\n\treturn seq() == null;\n}\n\npublic boolean contains(Object o){\n\tfor(ISeq s = seq(); s != null; s = s.next())\n\t\t{\n\t\tif(Util.equiv(s.first(), o))\n\t\t\treturn true;\n\t\t}\n\treturn false;\n}\n\npublic Iterator iterator(){\n\treturn new SeqIterator(this);\n}\n\n//////////// List stuff /////////////////\nprivate List reify(){\n\treturn new ArrayList(this);\n}\n\npublic List subList(int fromIndex, int toIndex){\n\treturn reify().subList(fromIndex, toIndex);\n}\n\npublic Object set(int index, Object element){\n\tthrow new UnsupportedOperationException();\n}\n\npublic Object remove(int index){\n\tthrow new UnsupportedOperationException();\n}\n\npublic int indexOf(Object o){\n\tISeq s = seq();\n\tfor(int i = 0; s != null; s = s.next(), i++)\n\t\t{\n\t\tif(Util.equiv(s.first(), o))\n\t\t\treturn i;\n\t\t}\n\treturn -1;\n}\n\npublic int lastIndexOf(Object o){\n\treturn reify().lastIndexOf(o);\n}\n\npublic ListIterator listIterator(){\n\treturn reify().listIterator();\n}\n\npublic ListIterator listIterator(int index){\n\treturn reify().listIterator(index);\n}\n\npublic Object get(int index){\n\treturn RT.nth(this, index);\n}\n\npublic void add(int index, Object element){\n\tthrow new UnsupportedOperationException();\n}\n\npublic boolean addAll(int index, Collection c){\n\tthrow new UnsupportedOperationException();\n}\n\n\nsynchronized public boolean isRealized(){\n\treturn fn == null;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/LineNumberingPushbackReader.java",
    "content": "/**\r\n * Copyright (c) Rich Hickey. All rights reserved.\r\n * The use and distribution terms for this software are covered by the\r\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n * which can be found in the file epl-v10.html at the root of this distribution.\r\n * By using this software in any fashion, you are agreeing to be bound by\r\n * the terms of this license.\r\n * You must not remove this notice, or any other, from this software.\r\n */\r\n\r\npackage clojure.lang;\r\n\r\nimport java.io.PushbackReader;\r\nimport java.io.Reader;\r\nimport java.io.LineNumberReader;\r\nimport java.io.IOException;\r\n\r\n\r\npublic class LineNumberingPushbackReader extends PushbackReader{\r\n\r\n// This class is a PushbackReader that wraps a LineNumberReader. The code\r\n// here to handle line terminators only mentions '\\n' because\r\n// LineNumberReader collapses all occurrences of CR, LF, and CRLF into a\r\n// single '\\n'.\r\n\r\nprivate static final int newline = (int) '\\n';\r\n\r\nprivate boolean _atLineStart = true;\r\nprivate boolean _prev;\r\nprivate int _columnNumber = 1;\n\r\npublic LineNumberingPushbackReader(Reader r){\r\n\tsuper(new LineNumberReader(r));\r\n}\r\n\r\npublic LineNumberingPushbackReader(Reader r, int size){\n\tsuper(new LineNumberReader(r, size));\n}\n\npublic int getLineNumber(){\r\n\treturn ((LineNumberReader) in).getLineNumber() + 1;\r\n}\r\n\npublic void setLineNumber(int line) { ((LineNumberReader) in).setLineNumber(line - 1); }\n\npublic int getColumnNumber(){\n\treturn _columnNumber;\n}\n\npublic int read() throws IOException{\r\n    int c = super.read();\r\n    _prev = _atLineStart;\r\n    if((c == newline) || (c == -1))\n        {\n        _atLineStart = true;\n        _columnNumber = 1;\n        }\n    else\n        {\n        _atLineStart = false;\n        _columnNumber++;\n        }\n    return c;\r\n}\r\n\r\npublic void unread(int c) throws IOException{\r\n    super.unread(c);\r\n    _atLineStart = _prev;\r\n    _columnNumber--;\n}\r\n\r\npublic String readLine() throws IOException{\r\n    int c = read();\r\n    String line;\r\n    switch (c) {\r\n    case -1:\r\n        line = null;\r\n        break;\r\n    case newline:\r\n        line = \"\";\r\n        break;\r\n    default:\r\n        String first = String.valueOf((char) c);\r\n        String rest = ((LineNumberReader)in).readLine();\r\n        line = (rest == null) ? first : first + rest;\r\n        _prev = false;\r\n        _atLineStart = true;\r\n        _columnNumber = 1;\n        break;\r\n    }\r\n    return line;\r\n}\r\n\r\npublic boolean atLineStart(){\r\n    return _atLineStart;\r\n}\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/LispReader.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.io.IOException;\nimport java.io.PushbackReader;\nimport java.io.Reader;\nimport java.lang.Character;\nimport java.lang.Class;\nimport java.lang.Exception;\nimport java.lang.IllegalArgumentException;\nimport java.lang.IllegalStateException;\nimport java.lang.Integer;\nimport java.lang.Number;\nimport java.lang.NumberFormatException;\nimport java.lang.Object;\nimport java.lang.RuntimeException;\nimport java.lang.String;\nimport java.lang.StringBuilder;\nimport java.lang.Throwable;\nimport java.lang.UnsupportedOperationException;\nimport java.lang.reflect.Constructor;\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.util.ArrayList;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\npublic class LispReader{\n\nstatic final Symbol QUOTE = Symbol.intern(\"quote\");\nstatic final Symbol THE_VAR = Symbol.intern(\"var\");\n//static Symbol SYNTAX_QUOTE = Symbol.intern(null, \"syntax-quote\");\nstatic Symbol UNQUOTE = Symbol.intern(\"clojure.core\", \"unquote\");\nstatic Symbol UNQUOTE_SPLICING = Symbol.intern(\"clojure.core\", \"unquote-splicing\");\nstatic Symbol CONCAT = Symbol.intern(\"clojure.core\", \"concat\");\nstatic Symbol SEQ = Symbol.intern(\"clojure.core\", \"seq\");\nstatic Symbol LIST = Symbol.intern(\"clojure.core\", \"list\");\nstatic Symbol APPLY = Symbol.intern(\"clojure.core\", \"apply\");\nstatic Symbol HASHMAP = Symbol.intern(\"clojure.core\", \"hash-map\");\nstatic Symbol HASHSET = Symbol.intern(\"clojure.core\", \"hash-set\");\nstatic Symbol VECTOR = Symbol.intern(\"clojure.core\", \"vector\");\nstatic Symbol WITH_META = Symbol.intern(\"clojure.core\", \"with-meta\");\nstatic Symbol META = Symbol.intern(\"clojure.core\", \"meta\");\nstatic Symbol DEREF = Symbol.intern(\"clojure.core\", \"deref\");\nstatic Symbol READ_COND = Symbol.intern(\"clojure.core\", \"read-cond\");\nstatic Symbol READ_COND_SPLICING = Symbol.intern(\"clojure.core\", \"read-cond-splicing\");\nstatic Keyword UNKNOWN = Keyword.intern(null, \"unknown\");\n//static Symbol DEREF_BANG = Symbol.intern(\"clojure.core\", \"deref!\");\n\nstatic IFn[] macros = new IFn[256];\nstatic IFn[] dispatchMacros = new IFn[256];\n//static Pattern symbolPat = Pattern.compile(\"[:]?([\\\\D&&[^:/]][^:/]*/)?[\\\\D&&[^:/]][^:/]*\");\nstatic Pattern symbolPat = Pattern.compile(\"[:]?([\\\\D&&[^/]].*/)?(/|[\\\\D&&[^/]][^/]*)\");\n//static Pattern varPat = Pattern.compile(\"([\\\\D&&[^:\\\\.]][^:\\\\.]*):([\\\\D&&[^:\\\\.]][^:\\\\.]*)\");\n//static Pattern intPat = Pattern.compile(\"[-+]?[0-9]+\\\\.?\");\nstatic Pattern intPat =\n\t\tPattern.compile(\n\t\t\t\t\"([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?\");\nstatic Pattern ratioPat = Pattern.compile(\"([-+]?[0-9]+)/([0-9]+)\");\nstatic Pattern floatPat = Pattern.compile(\"([-+]?[0-9]+(\\\\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?\");\n//static Pattern accessorPat = Pattern.compile(\"\\\\.[a-zA-Z_]\\\\w*\");\n//static Pattern instanceMemberPat = Pattern.compile(\"\\\\.([a-zA-Z_][\\\\w\\\\.]*)\\\\.([a-zA-Z_]\\\\w*)\");\n//static Pattern staticMemberPat = Pattern.compile(\"([a-zA-Z_][\\\\w\\\\.]*)\\\\.([a-zA-Z_]\\\\w*)\");\n//static Pattern classNamePat = Pattern.compile(\"([a-zA-Z_][\\\\w\\\\.]*)\\\\.\");\n\n//symbol->gensymbol\nstatic Var GENSYM_ENV = Var.create(null).setDynamic();\n//sorted-map num->gensymbol\nstatic Var ARG_ENV = Var.create(null).setDynamic();\nstatic IFn ctorReader = new CtorReader();\n\n// Dynamic var set to true in a read-cond context\nstatic Var READ_COND_ENV = Var.create(null).setDynamic();\n\nstatic\n\t{\n\tmacros['\"'] = new StringReader();\n\tmacros[';'] = new CommentReader();\n\tmacros['\\''] = new WrappingReader(QUOTE);\n\tmacros['@'] = new WrappingReader(DEREF);//new DerefReader();\n\tmacros['^'] = new MetaReader();\n\tmacros['`'] = new SyntaxQuoteReader();\n\tmacros['~'] = new UnquoteReader();\n\tmacros['('] = new ListReader();\n\tmacros[')'] = new UnmatchedDelimiterReader();\n\tmacros['['] = new VectorReader();\n\tmacros[']'] = new UnmatchedDelimiterReader();\n\tmacros['{'] = new MapReader();\n\tmacros['}'] = new UnmatchedDelimiterReader();\n//\tmacros['|'] = new ArgVectorReader();\n\tmacros['\\\\'] = new CharacterReader();\n\tmacros['%'] = new ArgReader();\n\tmacros['#'] = new DispatchReader();\n\n\n\tdispatchMacros['^'] = new MetaReader();\n\tdispatchMacros['\\''] = new VarReader();\n\tdispatchMacros['\"'] = new RegexReader();\n\tdispatchMacros['('] = new FnReader();\n\tdispatchMacros['{'] = new SetReader();\n\tdispatchMacros['='] = new EvalReader();\n\tdispatchMacros['!'] = new CommentReader();\n\tdispatchMacros['<'] = new UnreadableReader();\n\tdispatchMacros['_'] = new DiscardReader();\n\tdispatchMacros['?'] = new ConditionalReader();\n\t}\n\nstatic boolean isWhitespace(int ch){\n\treturn Character.isWhitespace((char)ch) || ch == ',';\n}\n\nstatic void unread(PushbackReader r, int ch) {\n\tif(ch != -1)\n\t\ttry\n\t\t\t{\n\t\t\tr.unread(ch);\n\t\t\t}\n\t\tcatch(IOException e)\n\t\t\t{\n\t\t\tthrow Util.sneakyThrow(e);\n\t\t\t}\n}\n\npublic static class ReaderException extends RuntimeException{\n\tfinal int line;\n\tfinal int column;\n\n\tpublic ReaderException(int line, int column, Throwable cause){\n\t\tsuper(cause);\n\t\tthis.line = line;\n\t\tthis.column = column;\n\t}\n}\n\nstatic public int read1(Reader r){\n\ttry\n\t\t{\n\t\treturn r.read();\n\t\t}\n\tcatch(IOException e)\n\t\t{\n\t\tthrow Util.sneakyThrow(e);\n\t\t}\n}\n\n// Reader opts\nstatic public final Keyword OPT_EOF = Keyword.intern(null,\"eof\");\nstatic public final Keyword OPT_FEATURES = Keyword.intern(null,\"features\");\nstatic public final Keyword OPT_READ_COND = Keyword.intern(null, \"read-cond\");\n\n// EOF special value to throw on eof\nstatic public final Keyword EOFTHROW = Keyword.intern(null,\"eofthrow\");\n\n// Platform features - always installed\nstatic private final Keyword PLATFORM_KEY = Keyword.intern(null, \"clj\");\nstatic private final Object PLATFORM_FEATURES = PersistentHashSet.create(PLATFORM_KEY);\n\n// Reader conditional options - use with :read-cond\nstatic public final Keyword COND_ALLOW = Keyword.intern(null, \"allow\");\n    static public final Keyword COND_PRESERVE = Keyword.intern(null, \"preserve\");\n\nstatic public Object read(PushbackReader r, Object opts){\n    boolean eofIsError = true;\n    Object eofValue = null;\n    if(opts != null && opts instanceof IPersistentMap)\n    {\n        Object eof = ((IPersistentMap)opts).valAt(OPT_EOF, EOFTHROW);\n        if(!EOFTHROW.equals(eof)) {\n            eofIsError = false;\n            eofValue = eof;\n        }\n    }\n    return read(r,eofIsError,eofValue,false,opts);\n}\n\nstatic public Object read(PushbackReader r, boolean eofIsError, Object eofValue, boolean isRecursive)\n{\n    return read(r, eofIsError, eofValue, isRecursive, PersistentHashMap.EMPTY);\n}\n\nstatic public Object read(PushbackReader r, boolean eofIsError, Object eofValue, boolean isRecursive, Object opts)\n{\n\t// start with pendingForms null as reader conditional splicing is not allowed at top level\n\treturn read(r, eofIsError, eofValue, null, null, isRecursive, opts, null);\n}\n\nstatic private Object read(PushbackReader r, boolean eofIsError, Object eofValue, boolean isRecursive, Object opts, Object pendingForms) {\n\treturn read(r, eofIsError, eofValue, null, null, isRecursive, opts, ensurePending(pendingForms));\n}\n\nstatic private Object ensurePending(Object pendingForms) {\n\tif(pendingForms == null)\n\t\treturn new LinkedList();\n\telse\n\t\treturn pendingForms;\n}\n\nstatic private Object installPlatformFeature(Object opts) {\n    if(opts == null)\n        return RT.mapUniqueKeys(LispReader.OPT_FEATURES, PLATFORM_FEATURES);\n    else {\n        IPersistentMap mopts = (IPersistentMap) opts;\n        Object features = mopts.valAt(OPT_FEATURES);\n        if (features == null)\n            return mopts.assoc(LispReader.OPT_FEATURES, PLATFORM_FEATURES);\n        else\n            return mopts.assoc(LispReader.OPT_FEATURES, RT.conj((IPersistentSet) features, PLATFORM_KEY));\n    }\n}\n\nstatic private Object read(PushbackReader r, boolean eofIsError, Object eofValue, Character returnOn, Object returnOnValue, boolean isRecursive, Object opts, Object pendingForms)\n{\n    if(RT.READEVAL.deref() == UNKNOWN)\n        throw Util.runtimeException(\"Reading disallowed - *read-eval* bound to :unknown\");\n\n    opts = installPlatformFeature(opts);\n\n\ttry\n\t\t{\n\t\tfor(; ;)\n\t\t\t{\n\n\t\t\tif(pendingForms instanceof List && !((List)pendingForms).isEmpty())\n\t\t\t\treturn ((List)pendingForms).remove(0);\n\n\t\t\tint ch = read1(r);\n\n\t\t\twhile(isWhitespace(ch))\n\t\t\t\tch = read1(r);\n\n\t\t\tif(ch == -1)\n\t\t\t\t{\n\t\t\t\tif(eofIsError)\n\t\t\t\t\tthrow Util.runtimeException(\"EOF while reading\");\n\t\t\t\treturn eofValue;\n\t\t\t\t}\n\n\t\t\tif(returnOn != null && (returnOn.charValue() == ch)) {\n\t\t\t\treturn returnOnValue;\n\t\t\t}\n\n\t\t\tif(Character.isDigit((char)ch))\n\t\t\t\t{\n\t\t\t\tObject n = readNumber(r, (char) ch);\n\t\t\t\treturn n;\n\t\t\t\t}\n\n\t\t\tIFn macroFn = getMacro(ch);\n\t\t\tif(macroFn != null)\n\t\t\t\t{\n\t\t\t\tObject ret = macroFn.invoke(r, (char) ch, opts, pendingForms);\n\t\t\t\t//no op macros return the reader\n\t\t\t\tif(ret == r)\n\t\t\t\t\tcontinue;\n\t\t\t\treturn ret;\n\t\t\t\t}\n\n\t\t\tif(ch == '+' || ch == '-')\n\t\t\t\t{\n\t\t\t\tint ch2 = read1(r);\n\t\t\t\tif(Character.isDigit((char)ch2))\n\t\t\t\t\t{\n\t\t\t\t\tunread(r, ch2);\n\t\t\t\t\tObject n = readNumber(r, (char) ch);\n\t\t\t\t\treturn n;\n\t\t\t\t\t}\n\t\t\t\tunread(r, ch2);\n\t\t\t\t}\n\n\t\t\tString token = readToken(r, (char) ch);\n\t\t\treturn interpretToken(token);\n\t\t\t}\n\t\t}\n\tcatch(Exception e)\n\t\t{\n\t\tif(isRecursive || !(r instanceof LineNumberingPushbackReader))\n\t\t\tthrow Util.sneakyThrow(e);\n\t\tLineNumberingPushbackReader rdr = (LineNumberingPushbackReader) r;\n\t\t//throw Util.runtimeException(String.format(\"ReaderError:(%d,1) %s\", rdr.getLineNumber(), e.getMessage()), e);\n\t\tthrow new ReaderException(rdr.getLineNumber(), rdr.getColumnNumber(), e);\n\t\t}\n}\n\nstatic private String readToken(PushbackReader r, char initch) {\n\tStringBuilder sb = new StringBuilder();\n\tsb.append(initch);\n\n\tfor(; ;)\n\t\t{\n\t\tint ch = read1(r);\n\t\tif(ch == -1 || isWhitespace(ch) || isTerminatingMacro(ch))\n\t\t\t{\n\t\t\tunread(r, ch);\n\t\t\treturn sb.toString();\n\t\t\t}\n\t\tsb.append((char) ch);\n\t\t}\n}\n\nstatic private Object readNumber(PushbackReader r, char initch) {\n\tStringBuilder sb = new StringBuilder();\n\tsb.append(initch);\n\n\tfor(; ;)\n\t\t{\n\t\tint ch = read1(r);\n\t\tif(ch == -1 || isWhitespace(ch) || isMacro(ch))\n\t\t\t{\n\t\t\tunread(r, ch);\n\t\t\tbreak;\n\t\t\t}\n\t\tsb.append((char) ch);\n\t\t}\n\n\tString s = sb.toString();\n\tObject n = matchNumber(s);\n\tif(n == null)\n\t\tthrow new NumberFormatException(\"Invalid number: \" + s);\n\treturn n;\n}\n\nstatic private int readUnicodeChar(String token, int offset, int length, int base) {\n\tif(token.length() != offset + length)\n\t\tthrow new IllegalArgumentException(\"Invalid unicode character: \\\\\" + token);\n\tint uc = 0;\n\tfor(int i = offset; i < offset + length; ++i)\n\t\t{\n\t\tint d = Character.digit(token.charAt(i), base);\n\t\tif(d == -1)\n\t\t\tthrow new IllegalArgumentException(\"Invalid digit: \" + token.charAt(i));\n\t\tuc = uc * base + d;\n\t\t}\n\treturn (char) uc;\n}\n\nstatic private int readUnicodeChar(PushbackReader r, int initch, int base, int length, boolean exact) {\n\tint uc = Character.digit((char)initch, base);\n\tif(uc == -1)\n\t\tthrow new IllegalArgumentException(\"Invalid digit: \" + (char) initch);\n\tint i = 1;\n\tfor(; i < length; ++i)\n\t\t{\n\t\tint ch = read1(r);\n\t\tif(ch == -1 || isWhitespace(ch) || isMacro(ch))\n\t\t\t{\n\t\t\tunread(r, ch);\n\t\t\tbreak;\n\t\t\t}\n\t\tint d = Character.digit((char)ch, base);\n\t\tif(d == -1)\n\t\t\tthrow new IllegalArgumentException(\"Invalid digit: \" + (char) ch);\n\t\tuc = uc * base + d;\n\t\t}\n\tif(i != length && exact)\n\t\tthrow new IllegalArgumentException(\"Invalid character length: \" + i + \", should be: \" + length);\n\treturn uc;\n}\n\nstatic private Object interpretToken(String s) {\n\tif(s.equals(\"nil\"))\n\t\t{\n\t\treturn null;\n\t\t}\n\telse if(s.equals(\"true\"))\n\t\t{\n\t\treturn RT.T;\n\t\t}\n\telse if(s.equals(\"false\"))\n\t\t{\n\t\treturn RT.F;\n\t\t}\n\tObject ret = null;\n\n\tret = matchSymbol(s);\n\tif(ret != null)\n\t\treturn ret;\n\n\tthrow Util.runtimeException(\"Invalid token: \" + s);\n}\n\n\nprivate static Object matchSymbol(String s){\n\tMatcher m = symbolPat.matcher(s);\n\tif(m.matches())\n\t\t{\n\t\tint gc = m.groupCount();\n\t\tString ns = m.group(1);\n\t\tString name = m.group(2);\n\t\tif(ns != null && ns.endsWith(\":/\")\n\t\t   || name.endsWith(\":\")\n\t\t   || s.indexOf(\"::\", 1) != -1)\n\t\t\treturn null;\n\t\tif(s.startsWith(\"::\"))\n\t\t\t{\n\t\t\tSymbol ks = Symbol.intern(s.substring(2));\n\t\t\tNamespace kns;\n\t\t\tif(ks.ns != null)\n\t\t\t\tkns = Compiler.namespaceFor(ks);\n\t\t\telse\n\t\t\t\tkns = Compiler.currentNS();\n\t\t\t//auto-resolving keyword\n\t\t\tif (kns != null)\n\t\t\t\treturn Keyword.intern(kns.name.name,ks.name);\n\t\t\telse\n\t\t\t\treturn null;\n\t\t\t}\n\t\tboolean isKeyword = s.charAt(0) == ':';\n\t\tSymbol sym = Symbol.intern(s.substring(isKeyword ? 1 : 0));\n\t\tif(isKeyword)\n\t\t\treturn Keyword.intern(sym);\n\t\treturn sym;\n\t\t}\n\treturn null;\n}\n\n\nprivate static Object matchNumber(String s){\n  if (ObjC.objc) {\n    Object r = nativeMatchNumber(s);\n    if (r != null) {\n      return r;\n    }\n  }\n\tMatcher m = intPat.matcher(s);\n\tif(m.matches())\n\t\t{\n\t\tif(m.group(2) != null)\n\t\t\t{\n\t\t\tif(m.group(8) != null)\n\t\t\t\treturn BigInt.ZERO;\n\t\t\treturn Numbers.num(0);\n\t\t\t}\n\t\tboolean negate = (m.group(1).equals(\"-\"));\n\t\tString n;\n\t\tint radix = 10;\n\t\tif((n = m.group(3)) != null)\n\t\t\tradix = 10;\n\t\telse if((n = m.group(4)) != null)\n\t\t\tradix = 16;\n\t\telse if((n = m.group(5)) != null)\n\t\t\tradix = 8;\n\t\telse if((n = m.group(7)) != null)\n\t\t\tradix = Integer.parseInt(m.group(6));\n\t\tif(n == null)\n\t\t\treturn null;\n\t\tBigInteger bn = new BigInteger(n, radix);\n\t\tif(negate)\n\t\t\tbn = bn.negate();\n\t\tif(m.group(8) != null)\n\t\t\treturn BigInt.fromBigInteger(bn);\n\t\treturn bn.bitLength() < 64 ?\n\t\t       Numbers.num(bn.longValue())\n\t\t                           : BigInt.fromBigInteger(bn);\n\t\t}\n\tm = floatPat.matcher(s);\n\tif(m.matches())\n\t\t{\n\t\tif(m.group(4) != null)\n\t\t\treturn new BigDecimal(m.group(1));\n\t\treturn Double.parseDouble(s);\n\t\t}\n\tm = ratioPat.matcher(s);\n\tif(m.matches())\n\t\t{\n\t\tString numerator = m.group(1);\n\t\tif (numerator.startsWith(\"+\")) numerator = numerator.substring(1);\n\n\t\treturn Numbers.divide(Numbers.reduceBigInt(BigInt.fromBigInteger(new BigInteger(numerator))),\n\t\t                      Numbers.reduceBigInt(BigInt.fromBigInteger(new BigInteger(m.group(2)))));\n\t\t}\n\treturn null;\n}\n\nprivate native static Object nativeMatchNumber(String s) /*-[\n  long long v;\n  NSScanner *scanner = [NSScanner scannerWithString:s];\n  if ([scanner scanLongLong:&v] && scanner.scanLocation == s.length) {\n    return [ClojureLangRT boxWithLong:v];\n  }\n\n  double d;\n  scanner = [NSScanner scannerWithString:s];\n  if ([scanner scanDouble:&d] && scanner.scanLocation == s.length) {\n    return [ClojureLangRT boxWithDouble:d];\n  }\n  return nil;\n]-*/;\n\nstatic private IFn getMacro(int ch){\n\tif(ch < macros.length)\n\t\treturn macros[ch];\n\treturn null;\n}\n\nstatic private boolean isMacro(int ch){\n\treturn (ch < macros.length && macros[ch] != null);\n}\n\nstatic private boolean isTerminatingMacro(int ch){\n\treturn (ch != '#' && ch != '\\'' && ch != '%' && isMacro(ch));\n}\n\npublic static class RegexReader extends AFn{\n\tstatic StringReader stringrdr = new StringReader();\n\n\tpublic Object invoke(Object reader, Object doublequote, Object opts, Object pendingForms) {\n\t\tStringBuilder sb = new StringBuilder();\n\t\tReader r = (Reader) reader;\n\t\tfor(int ch = read1(r); ch != '\"'; ch = read1(r))\n\t\t\t{\n\t\t\tif(ch == -1)\n\t\t\t\tthrow Util.runtimeException(\"EOF while reading regex\");\n\t\t\tsb.append( (char) ch );\n\t\t\tif(ch == '\\\\')\t//escape\n\t\t\t\t{\n\t\t\t\tch = read1(r);\n\t\t\t\tif(ch == -1)\n\t\t\t\t\tthrow Util.runtimeException(\"EOF while reading regex\");\n\t\t\t\tsb.append( (char) ch ) ;\n\t\t\t\t}\n\t\t\t}\n\t\treturn Pattern.compile(sb.toString());\n\t}\n}\n\npublic static class StringReader extends AFn{\n\tpublic Object invoke(Object reader, Object doublequote, Object opts, Object pendingForms) {\n\t\tStringBuilder sb = new StringBuilder();\n\t\tReader r = (Reader) reader;\n\n\t\tfor(int ch = read1(r); ch != '\"'; ch = read1(r))\n\t\t\t{\n\t\t\tif(ch == -1)\n\t\t\t\tthrow Util.runtimeException(\"EOF while reading string\");\n\t\t\tif(ch == '\\\\')\t//escape\n\t\t\t\t{\n\t\t\t\tch = read1(r);\n\t\t\t\tif(ch == -1)\n\t\t\t\t\tthrow Util.runtimeException(\"EOF while reading string\");\n\t\t\t\tswitch(ch)\n\t\t\t\t\t{\n\t\t\t\t\tcase 't':\n\t\t\t\t\t\tch = '\\t';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'r':\n\t\t\t\t\t\tch = '\\r';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'n':\n\t\t\t\t\t\tch = '\\n';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '\\\\':\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '\"':\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'b':\n\t\t\t\t\t\tch = '\\b';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'f':\n\t\t\t\t\t\tch = '\\f';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'u':\n\t\t\t\t\t{\n\t\t\t\t\tch = read1(r);\n\t\t\t\t\tif (Character.digit((char)ch, 16) == -1)\n\t\t\t\t\t\tthrow Util.runtimeException(\"Invalid unicode escape: \\\\u\" + (char) ch);\n\t\t\t\t\tch = readUnicodeChar((PushbackReader) r, ch, 16, 4, true);\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t{\n\t\t\t\t\tif(Character.isDigit((char)ch))\n\t\t\t\t\t\t{\n\t\t\t\t\t\tch = readUnicodeChar((PushbackReader) r, ch, 8, 3, false);\n\t\t\t\t\t\tif(ch > 0377)\n\t\t\t\t\t\t\tthrow Util.runtimeException(\"Octal escape sequence must be in range [0, 377].\");\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tthrow Util.runtimeException(\"Unsupported escape character: \\\\\" + (char) ch);\n\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tsb.append((char) ch);\n\t\t\t}\n\t\treturn sb.toString();\n\t}\n}\n\npublic static class CommentReader extends AFn{\n\tpublic Object invoke(Object reader, Object semicolon, Object opts, Object pendingForms) {\n\t\tReader r = (Reader) reader;\n\t\tint ch;\n\t\tdo\n\t\t\t{\n\t\t\tch = read1(r);\n\t\t\t} while(ch != -1 && ch != '\\n' && ch != '\\r');\n\t\treturn r;\n\t}\n\n}\n\npublic static class DiscardReader extends AFn{\n\tpublic Object invoke(Object reader, Object underscore, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tread(r, true, null, true, opts, ensurePending(pendingForms));\n\t\treturn r;\n\t}\n}\n\npublic static class WrappingReader extends AFn{\n\tfinal Symbol sym;\n\n\tpublic WrappingReader(Symbol sym){\n\t\tthis.sym = sym;\n\t}\n\n\tpublic Object invoke(Object reader, Object quote, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tObject o = read(r, true, null, true, opts, ensurePending(pendingForms));\n\t\treturn RT.list(sym, o);\n\t}\n\n}\n\npublic static class DeprecatedWrappingReader extends AFn{\n\tfinal Symbol sym;\n\tfinal String macro;\n\n\tpublic DeprecatedWrappingReader(Symbol sym, String macro){\n\t\tthis.sym = sym;\n\t\tthis.macro = macro;\n\t}\n\n\tpublic Object invoke(Object reader, Object quote, Object opts, Object pendingForms) {\n\t\tSystem.out.println(\"WARNING: reader macro \" + macro +\n\t\t                   \" is deprecated; use \" + sym.getName() +\n\t\t                   \" instead\");\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tObject o = read(r, true, null, true, opts, ensurePending(pendingForms));\n\t\treturn RT.list(sym, o);\n\t}\n\n}\n\npublic static class VarReader extends AFn{\n\tpublic Object invoke(Object reader, Object quote, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tObject o = read(r, true, null, true, opts, ensurePending(pendingForms));\n//\t\tif(o instanceof Symbol)\n//\t\t\t{\n//\t\t\tObject v = Compiler.maybeResolveIn(Compiler.currentNS(), (Symbol) o);\n//\t\t\tif(v instanceof Var)\n//\t\t\t\treturn v;\n//\t\t\t}\n\t\treturn RT.list(THE_VAR, o);\n\t}\n}\n\n/*\nstatic class DerefReader extends AFn{\n\n\tpublic Object invoke(Object reader, Object quote) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tint ch = read1(r);\n\t\tif(ch == -1)\n\t\t\tthrow Util.runtimeException(\"EOF while reading character\");\n\t\tif(ch == '!')\n\t\t\t{\n\t\t\tObject o = read(r, true, null, true);\n\t\t\treturn RT.list(DEREF_BANG, o);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tr.unread(ch);\n\t\t\tObject o = read(r, true, null, true);\n\t\t\treturn RT.list(DEREF, o);\n\t\t\t}\n\t}\n\n}\n*/\n\npublic static class DispatchReader extends AFn{\n\tpublic Object invoke(Object reader, Object hash, Object opts, Object pendingForms) {\n\t\tint ch = read1((Reader) reader);\n\t\tif(ch == -1)\n\t\t\tthrow Util.runtimeException(\"EOF while reading character\");\n\t\tIFn fn = dispatchMacros[ch];\n\n\t\t// Try the ctor reader first\n\t\tif(fn == null) {\n\t\tunread((PushbackReader) reader, ch);\n\t\tpendingForms = ensurePending(pendingForms);\n\t\tObject result = ctorReader.invoke(reader, ch, opts, pendingForms);\n\n\t\tif(result != null)\n\t\t\treturn result;\n\t\telse\n\t\t\tthrow Util.runtimeException(String.format(\"No dispatch macro for: %c\", (char) ch));\n\t\t}\n\t\treturn fn.invoke(reader, ch, opts, pendingForms);\n\t}\n}\n\nstatic Symbol garg(int n){\n\treturn Symbol.intern(null, (n == -1 ? \"rest\" : (\"p\" + n)) + \"__\" + RT.nextID() + \"#\");\n}\n\npublic static class FnReader extends AFn{\n\tpublic Object invoke(Object reader, Object lparen, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tif(ARG_ENV.deref() != null)\n\t\t\tthrow new IllegalStateException(\"Nested #()s are not allowed\");\n\t\ttry\n\t\t\t{\n\t\t\tVar.pushThreadBindings(\n\t\t\t\t\tRT.map(ARG_ENV, PersistentTreeMap.EMPTY));\n\t\t\tunread(r, '(');\n\t\t\tObject form = read(r, true, null, true, opts, ensurePending(pendingForms));\n\n\t\t\tPersistentVector args = PersistentVector.EMPTY;\n\t\t\tPersistentTreeMap argsyms = (PersistentTreeMap) ARG_ENV.deref();\n\t\t\tISeq rargs = argsyms.rseq();\n\t\t\tif(rargs != null)\n\t\t\t\t{\n\t\t\t\tint higharg = (Integer) ((Map.Entry) rargs.first()).getKey();\n\t\t\t\tif(higharg > 0)\n\t\t\t\t\t{\n\t\t\t\t\tfor(int i = 1; i <= higharg; ++i)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tObject sym = argsyms.valAt(i);\n\t\t\t\t\t\tif(sym == null)\n\t\t\t\t\t\t\tsym = garg(i);\n\t\t\t\t\t\targs = args.cons(sym);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tObject restsym = argsyms.valAt(-1);\n\t\t\t\tif(restsym != null)\n\t\t\t\t\t{\n\t\t\t\t\targs = args.cons(Compiler._AMP_);\n\t\t\t\t\targs = args.cons(restsym);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\treturn RT.list(Compiler.FN, args, form);\n\t\t\t}\n\t\tfinally\n\t\t\t{\n\t\t\tVar.popThreadBindings();\n\t\t\t}\n\t}\n}\n\nstatic Symbol registerArg(int n){\n\tPersistentTreeMap argsyms = (PersistentTreeMap) ARG_ENV.deref();\n\tif(argsyms == null)\n\t\t{\n\t\tthrow new IllegalStateException(\"arg literal not in #()\");\n\t\t}\n\tSymbol ret = (Symbol) argsyms.valAt(n);\n\tif(ret == null)\n\t\t{\n\t\tret = garg(n);\n\t\tARG_ENV.set(argsyms.assoc(n, ret));\n\t\t}\n\treturn ret;\n}\n\nstatic class ArgReader extends AFn{\n\tpublic Object invoke(Object reader, Object pct, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tif(ARG_ENV.deref() == null)\n\t\t\t{\n\t\t\treturn interpretToken(readToken(r, '%'));\n\t\t\t}\n\t\tint ch = read1(r);\n\t\tunread(r, ch);\n\t\t//% alone is first arg\n\t\tif(ch == -1 || isWhitespace(ch) || isTerminatingMacro(ch))\n\t\t\t{\n\t\t\treturn registerArg(1);\n\t\t\t}\n\t\tObject n = read(r, true, null, true, opts, ensurePending(pendingForms));\n\t\tif(n.equals(Compiler._AMP_))\n\t\t\treturn registerArg(-1);\n\t\tif(!(n instanceof Number))\n\t\t\tthrow new IllegalStateException(\"arg literal must be %, %& or %integer\");\n\t\treturn registerArg(((Number) n).intValue());\n\t}\n}\n\npublic static class MetaReader extends AFn{\n\tpublic Object invoke(Object reader, Object caret, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tint line = -1;\n\t\tint column = -1;\n\t\tif(r instanceof LineNumberingPushbackReader)\n\t\t\t{\n\t\t\tline = ((LineNumberingPushbackReader) r).getLineNumber();\n\t\t\tcolumn = ((LineNumberingPushbackReader) r).getColumnNumber()-1;\n\t\t\t}\n\t\tpendingForms = ensurePending(pendingForms);\n\t\tObject meta = read(r, true, null, true, opts, pendingForms);\n\t\tif(meta instanceof Symbol || meta instanceof String)\n\t\t\tmeta = RT.map(RT.TAG_KEY, meta);\n\t\telse if (meta instanceof Keyword)\n\t\t\tmeta = RT.map(meta, RT.T);\n\t\telse if(!(meta instanceof IPersistentMap))\n\t\t\tthrow new IllegalArgumentException(\"Metadata must be Symbol,Keyword,String or Map\");\n\n\t\tObject o = read(r, true, null, true, opts, pendingForms);\n\t\tif(o instanceof IMeta)\n\t\t\t{\n\t\t\tif(line != -1 && o instanceof ISeq)\n\t\t\t\t{\n\t\t\t\tmeta = ((IPersistentMap) meta).assoc(RT.LINE_KEY, line).assoc(RT.COLUMN_KEY, column);\n\t\t\t\t}\n\t\t\tif(o instanceof IReference)\n\t\t\t\t{\n\t\t\t\t((IReference)o).resetMeta((IPersistentMap) meta);\n\t\t\t\treturn o;\n\t\t\t\t}\n\t\t\tObject ometa = RT.meta(o);\n\t\t\tfor(ISeq s = RT.seq(meta); s != null; s = s.next()) {\n\t\t\tIMapEntry kv = (IMapEntry) s.first();\n\t\t\tometa = RT.assoc(ometa, kv.getKey(), kv.getValue());\n\t\t\t}\n\t\t\treturn ((IObj) o).withMeta((IPersistentMap) ometa);\n\t\t\t}\n\t\telse\n\t\t\tthrow new IllegalArgumentException(\"Metadata can only be applied to IMetas\");\n\t}\n\n}\n\npublic static class SyntaxQuoteReader extends AFn{\n\tpublic Object invoke(Object reader, Object backquote, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\ttry\n\t\t\t{\n\t\t\tVar.pushThreadBindings(\n\t\t\t\t\tRT.map(GENSYM_ENV, PersistentHashMap.EMPTY));\n\n\t\t\tObject form = read(r, true, null, true, opts, ensurePending(pendingForms));\n\t\t\treturn syntaxQuote(form);\n\t\t\t}\n\t\tfinally\n\t\t\t{\n\t\t\tVar.popThreadBindings();\n\t\t\t}\n\t}\n\n\tstatic Object syntaxQuote(Object form) {\n\t\tObject ret;\n\t\tif(Compiler.isSpecial(form))\n\t\t\tret = RT.list(Compiler.QUOTE, form);\n\t\telse if(form instanceof Symbol)\n\t\t\t{\n\t\t\tSymbol sym = (Symbol) form;\n\t\t\tif(sym.ns == null && sym.name.endsWith(\"#\"))\n\t\t\t\t{\n\t\t\t\tIPersistentMap gmap = (IPersistentMap) GENSYM_ENV.deref();\n\t\t\t\tif(gmap == null)\n\t\t\t\t\tthrow new IllegalStateException(\"Gensym literal not in syntax-quote\");\n\t\t\t\tSymbol gs = (Symbol) gmap.valAt(sym);\n\t\t\t\tif(gs == null)\n\t\t\t\t\tGENSYM_ENV.set(gmap.assoc(sym, gs = Symbol.intern(null,\n\t\t\t\t\t                                                  sym.name.substring(0, sym.name.length() - 1)\n\t\t\t\t\t                                                  + \"__\" + RT.nextID() + \"__auto__\")));\n\t\t\t\tsym = gs;\n\t\t\t\t}\n\t\t\telse if(sym.ns == null && sym.name.endsWith(\".\"))\n\t\t\t\t{\n\t\t\t\tSymbol csym = Symbol.intern(null, sym.name.substring(0, sym.name.length() - 1));\n\t\t\t\tcsym = Compiler.resolveSymbol(csym);\n\t\t\t\tsym = Symbol.intern(null, csym.name.concat(\".\"));\n\t\t\t\t}\n\t\t\telse if(sym.ns == null && sym.name.startsWith(\".\"))\n\t\t\t\t{\n\t\t\t\t// Simply quote method names.\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tObject maybeClass = null;\n\t\t\t\tif(sym.ns != null)\n\t\t\t\t\tmaybeClass = Compiler.currentNS().getMapping(\n\t\t\t\t\t\t\tSymbol.intern(null, sym.ns));\n\t\t\t\tif(maybeClass instanceof Class)\n\t\t\t\t\t{\n\t\t\t\t\t// Classname/foo -> package.qualified.Classname/foo\n\t\t\t\t\tsym = Symbol.intern(\n\t\t\t\t\t\t\t((Class)maybeClass).getName(), sym.name);\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tsym = Compiler.resolveSymbol(sym);\n\t\t\t\t}\n\t\t\tret = RT.list(Compiler.QUOTE, sym);\n\t\t\t}\n\t\telse if(isUnquote(form))\n\t\t\treturn RT.second(form);\n\t\telse if(isUnquoteSplicing(form))\n\t\t\tthrow new IllegalStateException(\"splice not in list\");\n\t\telse if(form instanceof IPersistentCollection)\n\t\t\t{\n\t\t\tif(form instanceof IRecord)\n\t\t\t\tret = form;\n\t\t\telse if(form instanceof IPersistentMap)\n\t\t\t\t{\n\t\t\t\tIPersistentVector keyvals = flattenMap(form);\n\t\t\t\tret = RT.list(APPLY, HASHMAP, RT.list(SEQ, RT.cons(CONCAT, sqExpandList(keyvals.seq()))));\n\t\t\t\t}\n\t\t\telse if(form instanceof IPersistentVector)\n\t\t\t\t{\n\t\t\t\tret = RT.list(APPLY, VECTOR, RT.list(SEQ, RT.cons(CONCAT, sqExpandList(((IPersistentVector) form).seq()))));\n\t\t\t\t}\n\t\t\telse if(form instanceof IPersistentSet)\n\t\t\t\t{\n\t\t\t\tret = RT.list(APPLY, HASHSET, RT.list(SEQ, RT.cons(CONCAT, sqExpandList(((IPersistentSet) form).seq()))));\n\t\t\t\t}\n\t\t\telse if(form instanceof ISeq || form instanceof IPersistentList)\n\t\t\t\t{\n\t\t\t\tISeq seq = RT.seq(form);\n\t\t\t\tif(seq == null)\n\t\t\t\t\tret = RT.cons(LIST,null);\n\t\t\t\telse\n\t\t\t\t\tret = RT.list(SEQ, RT.cons(CONCAT, sqExpandList(seq)));\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tthrow new UnsupportedOperationException(\"Unknown Collection type\");\n\t\t\t}\n\t\telse if(form instanceof Keyword\n\t\t        || form instanceof Number\n\t\t        || form instanceof Character\n\t\t        || form instanceof String)\n\t\t\tret = form;\n\t\telse\n\t\t\tret = RT.list(Compiler.QUOTE, form);\n\n\t\tif(form instanceof IObj && RT.meta(form) != null)\n\t\t\t{\n\t\t\t//filter line and column numbers\n\t\t\tIPersistentMap newMeta = ((IObj) form).meta().without(RT.LINE_KEY).without(RT.COLUMN_KEY);\n\t\t\tif(newMeta.count() > 0)\n\t\t\t\treturn RT.list(WITH_META, ret, syntaxQuote(((IObj) form).meta()));\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tprivate static ISeq sqExpandList(ISeq seq) {\n\t\tPersistentVector ret = PersistentVector.EMPTY;\n\t\tfor(; seq != null; seq = seq.next())\n\t\t\t{\n\t\t\tObject item = seq.first();\n\t\t\tif(isUnquote(item))\n\t\t\t\tret = ret.cons(RT.list(LIST, RT.second(item)));\n\t\t\telse if(isUnquoteSplicing(item))\n\t\t\t\tret = ret.cons(RT.second(item));\n\t\t\telse\n\t\t\t\tret = ret.cons(RT.list(LIST, syntaxQuote(item)));\n\t\t\t}\n\t\treturn ret.seq();\n\t}\n\n\tprivate static IPersistentVector flattenMap(Object form){\n\t\tIPersistentVector keyvals = PersistentVector.EMPTY;\n\t\tfor(ISeq s = RT.seq(form); s != null; s = s.next())\n\t\t\t{\n\t\t\tIMapEntry e = (IMapEntry) s.first();\n\t\t\tkeyvals = (IPersistentVector) keyvals.cons(e.key());\n\t\t\tkeyvals = (IPersistentVector) keyvals.cons(e.val());\n\t\t\t}\n\t\treturn keyvals;\n\t}\n\n}\n\nstatic boolean isUnquoteSplicing(Object form){\n\treturn form instanceof ISeq && Util.equals(RT.first(form),UNQUOTE_SPLICING);\n}\n\nstatic boolean isUnquote(Object form){\n\treturn form instanceof ISeq && Util.equals(RT.first(form),UNQUOTE);\n}\n\nstatic class UnquoteReader extends AFn{\n\tpublic Object invoke(Object reader, Object comma, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tint ch = read1(r);\n\t\tif(ch == -1)\n\t\t\tthrow Util.runtimeException(\"EOF while reading character\");\n\t\tpendingForms = ensurePending(pendingForms);\n\t\tif(ch == '@')\n\t\t\t{\n\t\t\tObject o = read(r, true, null, true, opts, pendingForms);\n\t\t\treturn RT.list(UNQUOTE_SPLICING, o);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tunread(r, ch);\n\t\t\tObject o = read(r, true, null, true, opts, pendingForms);\n\t\t\treturn RT.list(UNQUOTE, o);\n\t\t\t}\n\t}\n\n}\n\npublic static class CharacterReader extends AFn{\n\tpublic Object invoke(Object reader, Object backslash, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tint ch = read1(r);\n\t\tif(ch == -1)\n\t\t\tthrow Util.runtimeException(\"EOF while reading character\");\n\t\tString token = readToken(r, (char) ch);\n\t\tif(token.length() == 1)\n\t\t\treturn Character.valueOf(token.charAt(0));\n\t\telse if(token.equals(\"newline\"))\n\t\t\treturn '\\n';\n\t\telse if(token.equals(\"space\"))\n\t\t\treturn ' ';\n\t\telse if(token.equals(\"tab\"))\n\t\t\treturn '\\t';\n\t\telse if(token.equals(\"backspace\"))\n\t\t\treturn '\\b';\n\t\telse if(token.equals(\"formfeed\"))\n\t\t\treturn '\\f';\n\t\telse if(token.equals(\"return\"))\n\t\t\treturn '\\r';\n\t\telse if(token.startsWith(\"u\"))\n\t\t\t{\n\t\t\tchar c = (char) readUnicodeChar(token, 1, 4, 16);\n\t\t\tif(c >= '\\uD800' && c <= '\\uDFFF') // surrogate code unit?\n\t\t\t\tthrow Util.runtimeException(\"Invalid character constant: \\\\u\" + Integer.toString(c, 16));\n\t\t\treturn c;\n\t\t\t}\n\t\telse if(token.startsWith(\"o\"))\n\t\t\t{\n\t\t\tint len = token.length() - 1;\n\t\t\tif(len > 3)\n\t\t\t\tthrow Util.runtimeException(\"Invalid octal escape sequence length: \" + len);\n\t\t\tint uc = readUnicodeChar(token, 1, len, 8);\n\t\t\tif(uc > 0377)\n\t\t\t\tthrow Util.runtimeException(\"Octal escape sequence must be in range [0, 377].\");\n\t\t\treturn (char) uc;\n\t\t\t}\n\t\tthrow Util.runtimeException(\"Unsupported character: \\\\\" + token);\n\t}\n\n}\n\npublic static class ListReader extends AFn{\n\tpublic Object invoke(Object reader, Object leftparen, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tint line = -1;\n\t\tint column = -1;\n\t\tif(r instanceof LineNumberingPushbackReader)\n\t\t\t{\n\t\t\tline = ((LineNumberingPushbackReader) r).getLineNumber();\n\t\t\tcolumn = ((LineNumberingPushbackReader) r).getColumnNumber()-1;\n\t\t\t}\n\t\tList list = readDelimitedList(')', r, true, opts, ensurePending(pendingForms));\n\t\tif(list.isEmpty())\n\t\t\treturn PersistentList.EMPTY;\n\t\tIObj s = (IObj) PersistentList.create(list);\n//\t\tIObj s = (IObj) RT.seq(list);\n\t\tif(line != -1)\n\t\t\t{\n\t\t\treturn s.withMeta(RT.map(RT.LINE_KEY, line, RT.COLUMN_KEY, column));\n\t\t\t}\n\t\telse\n\t\t\treturn s;\n\t}\n\n}\n\n/*\nstatic class CtorReader extends AFn{\n\tstatic final Symbol cls = Symbol.intern(\"class\");\n\n\tpublic Object invoke(Object reader, Object leftangle) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\t// #<class classname>\n\t\t// #<classname args*>\n\t\t// #<classname/staticMethod args*>\n\t\tList list = readDelimitedList('>', r, true);\n\t\tif(list.isEmpty())\n\t\t\tthrow Util.runtimeException(\"Must supply 'class', classname or classname/staticMethod\");\n\t\tSymbol s = (Symbol) list.get(0);\n\t\tObject[] args = list.subList(1, list.size()).toArray();\n\t\tif(s.equals(cls))\n\t\t\t{\n\t\t\treturn RT.classForName(args[0].toString());\n\t\t\t}\n\t\telse if(s.ns != null) //static method\n\t\t\t{\n\t\t\tString classname = s.ns;\n\t\t\tString method = s.name;\n\t\t\treturn Reflector.invokeStaticMethod(classname, method, args);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\treturn Reflector.invokeConstructor(RT.classForName(s.name), args);\n\t\t\t}\n\t}\n}\n*/\n\npublic static class EvalReader extends AFn{\n\tpublic Object invoke(Object reader, Object eq, Object opts, Object pendingForms) {\n\t\tif (!RT.booleanCast(RT.READEVAL.deref()))\n\t\t\t{\n\t\t\tthrow Util.runtimeException(\"EvalReader not allowed when *read-eval* is false.\");\n\t\t\t}\n\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tObject o = read(r, true, null, true, opts, ensurePending(pendingForms));\n\t\tif(o instanceof Symbol)\n\t\t\t{\n\t\t\treturn RT.classForName(o.toString());\n\t\t\t}\n\t\telse if(o instanceof IPersistentList)\n\t\t\t{\n\t\t\tSymbol fs = (Symbol) RT.first(o);\n\t\t\tif(fs.equals(THE_VAR))\n\t\t\t\t{\n\t\t\t\tSymbol vs = (Symbol) RT.second(o);\n\t\t\t\treturn RT.var(vs.ns, vs.name);  //Compiler.resolve((Symbol) RT.second(o),true);\n\t\t\t\t}\n\t\t\tif(fs.name.endsWith(\".\"))\n\t\t\t\t{\n\t\t\t\tObject[] args = RT.toArray(RT.next(o));\n\t\t\t\treturn Reflector.invokeConstructor(RT.classForName(fs.name.substring(0, fs.name.length() - 1)), args);\n\t\t\t\t}\n\t\t\tif(Compiler.namesStaticMember(fs))\n\t\t\t\t{\n\t\t\t\tObject[] args = RT.toArray(RT.next(o));\n\t\t\t\treturn Reflector.invokeStaticMethod(fs.ns, fs.name, args);\n\t\t\t\t}\n\t\t\tObject v = Compiler.maybeResolveIn(Compiler.currentNS(), fs);\n\t\t\tif(v instanceof Var)\n\t\t\t\t{\n\t\t\t\treturn ((IFn) v).applyTo(RT.next(o));\n\t\t\t\t}\n\t\t\tthrow Util.runtimeException(\"Can't resolve \" + fs);\n\t\t\t}\n\t\telse\n\t\t\tthrow new IllegalArgumentException(\"Unsupported #= form\");\n\t}\n}\n\n//static class ArgVectorReader extends AFn{\n//\tpublic Object invoke(Object reader, Object leftparen) {\n//\t\tPushbackReader r = (PushbackReader) reader;\n//\t\treturn ArgVector.create(readDelimitedList('|', r, true));\n//\t}\n//\n//}\n\npublic static class VectorReader extends AFn{\n\tpublic Object invoke(Object reader, Object leftparen, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\treturn LazilyPersistentVector.create(readDelimitedList(']', r, true, opts, ensurePending(pendingForms)));\n\t}\n\n}\n\npublic static class MapReader extends AFn{\n\tpublic Object invoke(Object reader, Object leftparen, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tObject[] a = readDelimitedList('}', r, true, opts, ensurePending(pendingForms)).toArray();\n\t\tif((a.length & 1) == 1)\n\t\t\tthrow Util.runtimeException(\"Map literal must contain an even number of forms\");\n\t\treturn RT.map(a);\n\t}\n\n}\n\npublic static class SetReader extends AFn{\n\tpublic Object invoke(Object reader, Object leftbracket, Object opts, Object pendingForms) {\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\treturn PersistentHashSet.createWithCheck(readDelimitedList('}', r, true, opts, ensurePending(pendingForms)));\n\t}\n\n}\n\npublic static class UnmatchedDelimiterReader extends AFn{\n\tpublic Object invoke(Object reader, Object rightdelim, Object opts, Object pendingForms) {\n\t\tthrow Util.runtimeException(\"Unmatched delimiter: \" + rightdelim);\n\t}\n\n}\n\npublic static class UnreadableReader extends AFn{\n\tpublic Object invoke(Object reader, Object leftangle, Object opts, Object pendingForms) {\n\t\tthrow Util.runtimeException(\"Unreadable form\");\n\t}\n}\n\n// Sentinel values for reading lists\nprivate static final Object READ_EOF = new Object();\nprivate static final Object READ_FINISHED = new Object();\n\npublic static List readDelimitedList(char delim, PushbackReader r, boolean isRecursive, Object opts, Object pendingForms) {\n\tfinal int firstline =\n\t\t\t(r instanceof LineNumberingPushbackReader) ?\n\t\t\t((LineNumberingPushbackReader) r).getLineNumber() : -1;\n\n\tArrayList a = new ArrayList();\n\n\tfor(; ;) {\n\n\t\tObject form = read(r, false, READ_EOF, delim, READ_FINISHED, isRecursive, opts, pendingForms);\n\n\t\tif (form == READ_EOF) {\n\t\t\tif (firstline < 0)\n\t\t\t\tthrow Util.runtimeException(\"EOF while reading\");\n\t\t\telse\n\t\t\t\tthrow Util.runtimeException(\"EOF while reading, starting at line \" + firstline);\n\t\t} else if (form == READ_FINISHED) {\n\t\t\treturn a;\n\t\t}\n\n\t\ta.add(form);\n\t}\n}\n\npublic static class CtorReader extends AFn{\n\tpublic Object invoke(Object reader, Object firstChar, Object opts, Object pendingForms){\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tpendingForms = ensurePending(pendingForms);\n\t\tObject name = read(r, true, null, false, opts, pendingForms);\n\t\tif (!(name instanceof Symbol))\n\t\t\tthrow new RuntimeException(\"Reader tag must be a symbol\");\n\t\tSymbol sym = (Symbol)name;\n\t\tObject form = read(r, true, null, true, opts, pendingForms);\n\n\t\tif(isPreserveReadCond(opts) || RT.suppressRead()) {\n\t\t\treturn TaggedLiteral.create(sym, form);\n\t\t} else {\n\t\t\treturn sym.getName().contains(\".\") ? readRecord(form, sym, opts, pendingForms) : readTagged(form, sym, opts, pendingForms);\n\t\t}\n\n\t}\n\n\tprivate Object readTagged(Object o, Symbol tag, Object opts, Object pendingForms){\n\n\t\tILookup data_readers = (ILookup)RT.DATA_READERS.deref();\n\t\tIFn data_reader = (IFn)RT.get(data_readers, tag);\n\t\tif(data_reader == null){\n\t\tdata_readers = (ILookup)RT.DEFAULT_DATA_READERS.deref();\n\t\tdata_reader = (IFn)RT.get(data_readers, tag);\n\t\tif(data_reader == null){\n\t\tIFn default_reader = (IFn)RT.DEFAULT_DATA_READER_FN.deref();\n\t\tif(default_reader != null)\n\t\t\treturn default_reader.invoke(tag, o);\n\t\telse\n\t\t\tthrow new RuntimeException(\"No reader function for tag \" + tag.toString());\n\t\t}\n\t\t}\n\n\t\treturn data_reader.invoke(o);\n\t}\n\n\tprivate Object readRecord(Object form, Symbol recordName, Object opts, Object pendingForms){\n        boolean readeval = RT.booleanCast(RT.READEVAL.deref());\n\n\t    if(!readeval)\n\t\t    {\n\t\t    throw Util.runtimeException(\"Record construction syntax can only be used when *read-eval* == true\");\n\t\t    }\n\n\t\tClass recordClass = RT.classForNameNonLoading(recordName.toString());\n\n\n\t\tboolean shortForm = true;\n\n\t\tif(form instanceof IPersistentMap) {\n\t\t\tshortForm = false;\n\t\t} else if (form instanceof IPersistentVector) {\n\t\t\tshortForm = true;\n\t\t} else {\n\t\t\tthrow Util.runtimeException(\"Unreadable constructor form starting with \\\"#\" + recordName + \"\\\"\");\n\t\t}\n\n\t\tObject ret = null;\n\t\tConstructor[] allctors = ((Class)recordClass).getConstructors();\n\n\t\tif(shortForm)\n\t\t\t{\n\t        IPersistentVector recordEntries = (IPersistentVector)form;\n\t\t\tboolean ctorFound = false;\n\t\t\tfor (Constructor ctor : allctors)\n\t\t\t\tif(ctor.getParameterTypes().length == recordEntries.count())\n\t\t\t\t\tctorFound = true;\n\n\t\t\tif(!ctorFound)\n\t\t\t\tthrow Util.runtimeException(\"Unexpected number of constructor arguments to \" + recordClass.toString() + \": got \" + recordEntries.count());\n\n\t\t\tret = Reflector.invokeConstructor(recordClass, RT.toArray(recordEntries));\n\t\t\t}\n\t\telse\n\t\t\t{\n\n\t\t\tIPersistentMap vals = (IPersistentMap)form;\n\t\t\tfor(ISeq s = RT.keys(vals); s != null; s = s.next())\n\t\t\t\t{\n\t\t\t\tif(!(s.first() instanceof Keyword))\n\t\t\t\t\tthrow Util.runtimeException(\"Unreadable defrecord form: key must be of type clojure.lang.Keyword, got \" + s.first().toString());\n\t\t\t\t}\n\t\t\tret = Reflector.invokeStaticMethod(recordClass, \"create\", new Object[]{vals});\n\t\t\t}\n\n\t\treturn ret;\n\t}\n}\n\nstatic boolean isPreserveReadCond(Object opts) {\n\tif(RT.booleanCast(READ_COND_ENV.deref()) && opts instanceof IPersistentMap)\n    {\n        Object readCond = ((IPersistentMap) opts).valAt(OPT_READ_COND);\n        return COND_PRESERVE.equals(readCond);\n    }\n    else\n        return false;\n}\n\npublic static class ConditionalReader extends AFn {\n\n\tfinal static public Keyword DEFAULT_FEATURE = Keyword.intern(null, \"default\");\n\tfinal static public IPersistentSet RESERVED_FEATURES =\n\t\tRT.set(Keyword.intern(null, \"else\"), Keyword.intern(null, \"none\"));\n\n\tpublic static boolean hasFeature(Object feature, Object opts) {\n\t\tif (! (feature instanceof Keyword))\n\t\t\tthrow Util.runtimeException(\"Feature should be a keyword: \" + feature);\n\n\t\tif(DEFAULT_FEATURE.equals(feature))\n\t\t\treturn true;\n\n\t\tIPersistentSet custom = (IPersistentSet) ((IPersistentMap)opts).valAt(OPT_FEATURES);\n\t\treturn custom != null && custom.contains(feature);\n\t}\n\n\tpublic static Object readCondDelimited(PushbackReader r, boolean splicing, Object opts, Object pendingForms) {\n\t\tObject result = null;\n\t\tObject form; // The most recently ready form\n\t\tboolean toplevel = (pendingForms == null);\n\t\tpendingForms = ensurePending(pendingForms);\n\n\t\tfinal int firstline =\n\t\t\t\t(r instanceof LineNumberingPushbackReader) ?\n\t\t\t\t\t\t((LineNumberingPushbackReader) r).getLineNumber() : -1;\n\n\t\tfor(; ;) {\n\t\t\tif(result == null) {\n\t\t\t\t// Read the next feature\n\t\t\t\tform = read(r, false, READ_EOF, ')', READ_FINISHED, true, opts, pendingForms);\n\n\t\t\t\tif (form == READ_EOF) {\n\t\t\t\t\tif (firstline < 0)\n\t\t\t\t\t\tthrow Util.runtimeException(\"EOF while reading\");\n\t\t\t\t\telse\n\t\t\t\t\t\tthrow Util.runtimeException(\"EOF while reading, starting at line \" + firstline);\n\t\t\t\t} else if (form == READ_FINISHED) {\n\t\t\t\t\tbreak; // read-cond form is done\n\t\t\t\t}\n\n\t\t\t\tif(RESERVED_FEATURES.contains(form))\n\t\t\t\t\tthrow Util.runtimeException(\"Feature name \" + form + \" is reserved.\");\n\n\t\t\t\tif (hasFeature(form, opts)) {\n\n\t\t\t\t\t//Read the form corresponding to the feature, and assign it to result if everything is kosher\n\n\t\t\t\t\tform = read(r, false, READ_EOF, ')', READ_FINISHED, true, opts, pendingForms);\n\n\t\t\t\t\tif (form == READ_EOF) {\n\t\t\t\t\t\tif (firstline < 0)\n\t\t\t\t\t\t\tthrow Util.runtimeException(\"EOF while reading\");\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tthrow Util.runtimeException(\"EOF while reading, starting at line \" + firstline);\n\t\t\t\t\t} else if (form == READ_FINISHED) {\n\t\t\t\t\t\tif (firstline < 0)\n\t\t\t\t\t\t\tthrow Util.runtimeException(\"read-cond requires an even number of forms.\");\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tthrow Util.runtimeException(\"read-cond starting on line \" + firstline + \" requires an even number of forms\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = form;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// When we already have a result, or when the feature didn't match, discard the next form in the reader\n\t\t\ttry {\n\t\t\t\tVar.pushThreadBindings(RT.map(RT.SUPPRESS_READ, RT.T));\n\t\t\t\tform = read(r, false, READ_EOF, ')', READ_FINISHED, true, opts, pendingForms);\n\n\t\t\t\tif (form == READ_EOF) {\n\t\t\t\t\tif (firstline < 0)\n\t\t\t\t\t\tthrow Util.runtimeException(\"EOF while reading\");\n\t\t\t\t\telse\n\t\t\t\t\t\tthrow Util.runtimeException(\"EOF while reading, starting at line \" + firstline);\n\t\t\t\t} else if (form == READ_FINISHED) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tVar.popThreadBindings();\n\t\t\t}\n\n\t\t}\n\n\t\tif (result == null)  // no features matched\n            return r;\n\n\t\tif (splicing) {\n\t\t\tif(! (result instanceof List))\n\t\t\t\tthrow Util.runtimeException(\"Spliced form list in read-cond-splicing must implement java.util.List\");\n\n\t\t\tif(toplevel)\n\t\t\t\tthrow Util.runtimeException(\"Reader conditional splicing not allowed at the top level.\");\n\n\t\t\t((List)pendingForms).addAll(0, (List)result);\n\n\t\t\treturn r;\n\t\t} else {\n\t\t\treturn result;\n\t\t}\n\t};\n\n    private static void checkConditionalAllowed(Object opts) {\n        IPersistentMap mopts = (IPersistentMap)opts;\n        if(! (opts != null && (COND_ALLOW.equals(mopts.valAt(OPT_READ_COND)) ||\n                               COND_PRESERVE.equals(mopts.valAt(OPT_READ_COND)))))\n            throw Util.runtimeException(\"Conditional read not allowed\");\n    }\n\n\tpublic Object invoke(Object reader, Object mode, Object opts, Object pendingForms) {\n\t\tcheckConditionalAllowed(opts);\n\n\t\tPushbackReader r = (PushbackReader) reader;\n\t\tint ch = read1(r);\n\t\tif (ch == -1)\n\t\t\tthrow Util.runtimeException(\"EOF while reading character\");\n\n\t\tboolean splicing = false;\n\n\t\tif (ch == '@') {\n\t\t\tsplicing = true;\n\t\t\tch = read1(r);\n\t\t}\n\n\t\twhile(isWhitespace(ch))\n\t\t\tch = read1(r);\n\n\t\tif (ch == -1)\n\t\t\tthrow Util.runtimeException(\"EOF while reading character\");\n\n\t\tif(ch != '(')\n\t\t\tthrow Util.runtimeException(\"read-cond body must be a list\");\n\n\t\ttry {\n\t\t\tVar.pushThreadBindings(RT.map(READ_COND_ENV, RT.T));\n\n\t\t\tif (isPreserveReadCond(opts)) {\n\t\t\t\tIFn listReader = getMacro(ch); // should always be a list\n\t\t\t\tObject form = listReader.invoke(r, ch, opts, ensurePending(pendingForms));\n\n\t\t\t\treturn ReaderConditional.create(form, splicing);\n\t\t\t} else {\n\t\t\t\treturn readCondDelimited(r, splicing, opts, pendingForms);\n\t\t\t}\n\t\t} finally {\n\t\t\tVar.popThreadBindings();\n\t\t}\n\t}\n}\n\n/*\npublic static void main(String[] args) throws Exception{\n\t//RT.init();\n\tPushbackReader rdr = new PushbackReader( new java.io.StringReader( \"(+ 21 21)\" ) );\n\tObject input = LispReader.read(rdr, false, new Object(), false );\n\tSystem.out.println(Compiler.eval(input));\n}\n\npublic static void main(String[] args){\n\tLineNumberingPushbackReader r = new LineNumberingPushbackReader(new InputStreamReader(System.in));\n\tOutputStreamWriter w = new OutputStreamWriter(System.out);\n\tObject ret = null;\n\ttry\n\t\t{\n\t\tfor(; ;)\n\t\t\t{\n\t\t\tret = LispReader.read(r, true, null, false);\n\t\t\tRT.print(ret, w);\n\t\t\tw.write('\\n');\n\t\t\tif(ret != null)\n\t\t\t\tw.write(ret.getClass().toString());\n\t\t\tw.write('\\n');\n\t\t\tw.flush();\n\t\t\t}\n\t\t}\n\tcatch(Exception e)\n\t\t{\n\t\te.printStackTrace();\n\t\t}\n}\n */\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/LockingTransaction.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jul 26, 2007 */\n\npackage clojure.lang;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.Map;\nimport java.util.TreeMap;\nimport java.util.concurrent.Callable;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.TimeUnit;\nimport java.util.concurrent.atomic.AtomicInteger;\nimport java.util.concurrent.atomic.AtomicLong;\n\n//@SuppressWarnings({\"SynchronizeOnNonFinalField\"})\npublic class LockingTransaction{\n\npublic static final int RETRY_LIMIT = 10000;\npublic static final int LOCK_WAIT_MSECS = 100;\npublic static final long BARGE_WAIT_NANOS = 10 * 1000000;\n//public static int COMMUTE_RETRY_LIMIT = 10;\n\nstatic final int RUNNING = 0;\nstatic final int COMMITTING = 1;\nstatic final int RETRY = 2;\nstatic final int KILLED = 3;\nstatic final int COMMITTED = 4;\n\nfinal static ThreadLocal<LockingTransaction> transaction = new ThreadLocal<LockingTransaction>();\n\n\nstatic class RetryEx extends Error{\n}\n\nstatic class AbortException extends Exception{\n}\n\npublic static class Info{\n\tfinal AtomicInteger status;\n\tfinal long startPoint;\n\tfinal CountDownLatch latch;\n\n\n\tpublic Info(int status, long startPoint){\n\t\tthis.status = new AtomicInteger(status);\n\t\tthis.startPoint = startPoint;\n\t\tthis.latch = new CountDownLatch(1);\n\t}\n\n\tpublic boolean running(){\n\t\tint s = status.get();\n\t\treturn s == RUNNING || s == COMMITTING;\n\t}\n}\n\nstatic class CFn{\n\tfinal IFn fn;\n\tfinal ISeq args;\n\n\tpublic CFn(IFn fn, ISeq args){\n\t\tthis.fn = fn;\n\t\tthis.args = args;\n\t}\n}\n//total order on transactions\n//transactions will consume a point for init, for each retry, and on commit if writing\nfinal private static AtomicLong lastPoint = new AtomicLong();\n\nvoid getReadPoint(){\n\treadPoint = lastPoint.incrementAndGet();\n}\n\nlong getCommitPoint(){\n\treturn lastPoint.incrementAndGet();\n}\n\nvoid stop(int status){\n\tif(info != null)\n\t\t{\n\t\tsynchronized(info)\n\t\t\t{\n\t\t\tinfo.status.set(status);\n\t\t\tinfo.latch.countDown();\n\t\t\t}\n\t\tinfo = null;\n\t\tvals.clear();\n\t\tsets.clear();\n\t\tcommutes.clear();\n\t\t//actions.clear();\n\t\t}\n}\n\n\nInfo info;\nlong readPoint;\nlong startPoint;\nlong startTime;\nstatic RetryEx retryex_;\n\nstatic RetryEx retryex() {\n  if (retryex_ == null) {\n    retryex_ = new RetryEx();\n  }\n  return retryex_;\n}\n\nfinal ArrayList<Agent.Action> actions = new ArrayList<Agent.Action>();\nfinal HashMap<Ref, Object> vals = new HashMap<Ref, Object>();\nfinal HashSet<Ref> sets = new HashSet<Ref>();\nfinal TreeMap<Ref, ArrayList<CFn>> commutes = new TreeMap<Ref, ArrayList<CFn>>();\n\nfinal HashSet<Ref> ensures = new HashSet<Ref>();   //all hold readLock\n\n\nvoid tryWriteLock(Ref ref){\n\ttry\n\t\t{\n\t\tif(!ref.lock.writeLock().tryLock(LOCK_WAIT_MSECS, TimeUnit.MILLISECONDS))\n\t\t\tthrow retryex();\n\t\t}\n\tcatch(InterruptedException e)\n\t\t{\n\t\tthrow retryex();\n\t\t}\n}\n\n//returns the most recent val\nObject lock(Ref ref){\n\t//can't upgrade readLock, so release it\n\treleaseIfEnsured(ref);\n\n\tboolean unlocked = true;\n\ttry\n\t\t{\n\t\ttryWriteLock(ref);\n\t\tunlocked = false;\n\n\t\tif(ref.tvals != null && ref.tvals.point > readPoint)\n\t\t\tthrow retryex();\n\t\tInfo refinfo = ref.tinfo;\n\n\t\t//write lock conflict\n\t\tif(refinfo != null && refinfo != info && refinfo.running())\n\t\t\t{\n\t\t\tif(!barge(refinfo))\n\t\t\t\t{\n\t\t\t\tref.lock.writeLock().unlock();\n\t\t\t\tunlocked = true;\n\t\t\t\treturn blockAndBail(refinfo);\n\t\t\t\t}\n\t\t\t}\n\t\tref.tinfo = info;\n\t\treturn ref.tvals == null ? null : ref.tvals.val;\n\t\t}\n\tfinally\n\t\t{\n\t\tif(!unlocked)\n\t\t\tref.lock.writeLock().unlock();\n\t\t}\n}\n\nprivate Object blockAndBail(Info refinfo){\n//stop prior to blocking\n\tstop(RETRY);\n\ttry\n\t\t{\n\t\trefinfo.latch.await(LOCK_WAIT_MSECS, TimeUnit.MILLISECONDS);\n\t\t}\n\tcatch(InterruptedException e)\n\t\t{\n\t\t//ignore\n\t\t}\n\tthrow retryex();\n}\n\nprivate void releaseIfEnsured(Ref ref){\n\tif(ensures.contains(ref))\n\t\t{\n\t\tensures.remove(ref);\n\t\tref.lock.readLock().unlock();\n\t\t}\n}\n\nvoid abort() throws AbortException{\n\tstop(KILLED);\n\tthrow new AbortException();\n}\n\nprivate boolean bargeTimeElapsed(){\n\treturn System.nanoTime() - startTime > BARGE_WAIT_NANOS;\n}\n\nprivate boolean barge(Info refinfo){\n\tboolean barged = false;\n\t//if this transaction is older\n\t//  try to abort the other\n\tif(bargeTimeElapsed() && startPoint < refinfo.startPoint)\n\t\t{\n        barged = refinfo.status.compareAndSet(RUNNING, KILLED);\n        if(barged)\n            refinfo.latch.countDown();\n\t\t}\n\treturn barged;\n}\n\nstatic LockingTransaction getEx(){\n\tLockingTransaction t = transaction.get();\n\tif(t == null || t.info == null)\n\t\tthrow new IllegalStateException(\"No transaction running\");\n\treturn t;\n}\n\nstatic public boolean isRunning(){\n\treturn getRunning() != null;\n}\n\nstatic LockingTransaction getRunning(){\n\tLockingTransaction t = transaction.get();\n\tif(t == null || t.info == null)\n\t\treturn null;\n\treturn t;\n}\n\nstatic public Object runInTransaction(Callable fn) throws Exception{\n\tLockingTransaction t = transaction.get();\n\tObject ret;\n\tif(t == null) {\n\t\ttransaction.set(t = new LockingTransaction());\n\t\ttry {\n\t\t\tret = t.run(fn);\n\t\t} finally {\n\t\t\ttransaction.remove();\n\t\t}\n\t} else {\n\t\tif(t.info != null) {\n\t\t\tret = fn.call();\n\t\t} else {\n\t\t\tret = t.run(fn);\n\t\t}\n\t}\n\n\treturn ret;\n}\n\nstatic class Notify{\n\tfinal public Ref ref;\n\tfinal public Object oldval;\n\tfinal public Object newval;\n\n\tNotify(Ref ref, Object oldval, Object newval){\n\t\tthis.ref = ref;\n\t\tthis.oldval = oldval;\n\t\tthis.newval = newval;\n\t}\n}\n\nObject run(Callable fn) throws Exception{\n\tboolean done = false;\n\tObject ret = null;\n\tArrayList<Ref> locked = new ArrayList<Ref>();\n\tArrayList<Notify> notify = new ArrayList<Notify>();\n\n\tfor(int i = 0; !done && i < RETRY_LIMIT; i++)\n\t\t{\n\t\ttry\n\t\t\t{\n\t\t\tgetReadPoint();\n\t\t\tif(i == 0)\n\t\t\t\t{\n\t\t\t\tstartPoint = readPoint;\n\t\t\t\tstartTime = System.nanoTime();\n\t\t\t\t}\n\t\t\tinfo = new Info(RUNNING, startPoint);\n\t\t\tret = fn.call();\n\t\t\t//make sure no one has killed us before this point, and can't from now on\n\t\t\tif(info.status.compareAndSet(RUNNING, COMMITTING))\n\t\t\t\t{\n\t\t\t\tfor(Map.Entry<Ref, ArrayList<CFn>> e : commutes.entrySet())\n\t\t\t\t\t{\n\t\t\t\t\tRef ref = e.getKey();\n\t\t\t\t\tif(sets.contains(ref)) continue;\n\t\t\t\t\t\n\t\t\t\t\tboolean wasEnsured = ensures.contains(ref);\n\t\t\t\t\t//can't upgrade readLock, so release it\n\t\t\t\t\treleaseIfEnsured(ref);\n\t\t\t\t\ttryWriteLock(ref);\n\t\t\t\t\tlocked.add(ref);\n\t\t\t\t\tif(wasEnsured && ref.tvals != null && ref.tvals.point > readPoint)\n\t\t\t\t\t\tthrow retryex();\n\n\t\t\t\t\tInfo refinfo = ref.tinfo;\n\t\t\t\t\tif(refinfo != null && refinfo != info && refinfo.running())\n\t\t\t\t\t\t{\n\t\t\t\t\t\tif(!barge(refinfo))\n\t\t\t\t\t\t\tthrow retryex();\n\t\t\t\t\t\t}\n\t\t\t\t\tObject val = ref.tvals == null ? null : ref.tvals.val;\n\t\t\t\t\tvals.put(ref, val);\n\t\t\t\t\tfor(CFn f : e.getValue())\n\t\t\t\t\t\t{\n\t\t\t\t\t\tvals.put(ref, f.fn.applyTo(RT.cons(vals.get(ref), f.args)));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tfor(Ref ref : sets)\n\t\t\t\t\t{\n\t\t\t\t\ttryWriteLock(ref);\n\t\t\t\t\tlocked.add(ref);\n\t\t\t\t\t}\n\n\t\t\t\t//validate and enqueue notifications\n\t\t\t\tfor(Map.Entry<Ref, Object> e : vals.entrySet())\n\t\t\t\t\t{\n\t\t\t\t\tRef ref = e.getKey();\n\t\t\t\t\tref.validate(ref.getValidator(), e.getValue());\n\t\t\t\t\t}\n\n\t\t\t\t//at this point, all values calced, all refs to be written locked\n\t\t\t\t//no more client code to be called\n\t\t\t\tlong commitPoint = getCommitPoint();\n\t\t\t\tfor(Map.Entry<Ref, Object> e : vals.entrySet())\n\t\t\t\t\t{\n\t\t\t\t\tRef ref = e.getKey();\n\t\t\t\t\tObject oldval = ref.tvals == null ? null : ref.tvals.val;\n\t\t\t\t\tObject newval = e.getValue();\n\t\t\t\t\tint hcount = ref.histCount();\n\n\t\t\t\t\tif(ref.tvals == null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tref.tvals = new Ref.TVal(newval, commitPoint);\n\t\t\t\t\t\t}\n\t\t\t\t\telse if((ref.faults.get() > 0 && hcount < ref.maxHistory)\n\t\t\t\t\t\t\t|| hcount < ref.minHistory)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tref.tvals = new Ref.TVal(newval, commitPoint, ref.tvals);\n\t\t\t\t\t\tref.faults.set(0);\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\tref.tvals = ref.tvals.next;\n\t\t\t\t\t\tref.tvals.val = newval;\n\t\t\t\t\t\tref.tvals.point = commitPoint;\n\t\t\t\t\t\t}\n\t\t\t\t\tif(ref.getWatches().count() > 0)\n\t\t\t\t\t\tnotify.add(new Notify(ref, oldval, newval));\n\t\t\t\t\t}\n\n\t\t\t\tdone = true;\n\t\t\t\tinfo.status.set(COMMITTED);\n\t\t\t\t}\n\t\t\t}\n\t\tcatch(RetryEx retry)\n\t\t\t{\n\t\t\t//eat this so we retry rather than fall out\n\t\t\t}\n\t\tfinally\n\t\t\t{\n\t\t\tfor(int k = locked.size() - 1; k >= 0; --k)\n\t\t\t\t{\n\t\t\t\tlocked.get(k).lock.writeLock().unlock();\n\t\t\t\t}\n\t\t\tlocked.clear();\n\t\t\tfor(Ref r : ensures)\n\t\t\t\t{\n\t\t\t\tr.lock.readLock().unlock();\n\t\t\t\t}\n\t\t\tensures.clear();\n\t\t\tstop(done ? COMMITTED : RETRY);\n\t\t\ttry\n\t\t\t\t{\n\t\t\t\tif(done) //re-dispatch out of transaction\n\t\t\t\t\t{\n\t\t\t\t\tfor(Notify n : notify)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tn.ref.notifyWatches(n.oldval, n.newval);\n\t\t\t\t\t\t}\n\t\t\t\t\tfor(Agent.Action action : actions)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tAgent.dispatchAction(action);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tfinally\n\t\t\t\t{\n\t\t\t\tnotify.clear();\n\t\t\t\tactions.clear();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif(!done)\n\t\tthrow Util.runtimeException(\"Transaction failed after reaching retry limit\");\n\treturn ret;\n}\n\npublic void enqueue(Agent.Action action){\n\tactions.add(action);\n}\n\nObject doGet(Ref ref){\n\tif(!info.running())\n\t\tthrow retryex();\n\tif(vals.containsKey(ref))\n\t\treturn vals.get(ref);\n\ttry\n\t\t{\n\t\tref.lock.readLock().lock();\n\t\tif(ref.tvals == null)\n\t\t\tthrow new IllegalStateException(ref.toString() + \" is unbound.\");\n\t\tRef.TVal ver = ref.tvals;\n\t\tdo\n\t\t\t{\n\t\t\tif(ver.point <= readPoint)\n\t\t\t\treturn ver.val;\n\t\t\t} while((ver = ver.prior) != ref.tvals);\n\t\t}\n\tfinally\n\t\t{\n\t\tref.lock.readLock().unlock();\n\t\t}\n\t//no version of val precedes the read point\n\tref.faults.incrementAndGet();\n\tthrow retryex();\n\n}\n\nObject doSet(Ref ref, Object val){\n\tif(!info.running())\n\t\tthrow retryex();\n\tif(commutes.containsKey(ref))\n\t\tthrow new IllegalStateException(\"Can't set after commute\");\n\tif(!sets.contains(ref))\n\t\t{\n\t\tsets.add(ref);\n\t\tlock(ref);\n\t\t}\n\tvals.put(ref, val);\n\treturn val;\n}\n\nvoid doEnsure(Ref ref){\n\tif(!info.running())\n\t\tthrow retryex();\n\tif(ensures.contains(ref))\n\t\treturn;\n\tref.lock.readLock().lock();\n\n\t//someone completed a write after our snapshot\n\tif(ref.tvals != null && ref.tvals.point > readPoint) {\n        ref.lock.readLock().unlock();\n        throw retryex();\n    }\n\n\tInfo refinfo = ref.tinfo;\n\n\t//writer exists\n\tif(refinfo != null && refinfo.running())\n\t\t{\n\t\tref.lock.readLock().unlock();\n\n\t\tif(refinfo != info) //not us, ensure is doomed\n\t\t\t{\n\t\t\tblockAndBail(refinfo); \n\t\t\t}\n\t\t}\n\telse\n\t\tensures.add(ref);\n}\n\nObject doCommute(Ref ref, IFn fn, ISeq args) {\n\tif(!info.running())\n\t\tthrow retryex();\n\tif(!vals.containsKey(ref))\n\t\t{\n\t\tObject val = null;\n\t\ttry\n\t\t\t{\n\t\t\tref.lock.readLock().lock();\n\t\t\tval = ref.tvals == null ? null : ref.tvals.val;\n\t\t\t}\n\t\tfinally\n\t\t\t{\n\t\t\tref.lock.readLock().unlock();\n\t\t\t}\n\t\tvals.put(ref, val);\n\t\t}\n\tArrayList<CFn> fns = commutes.get(ref);\n\tif(fns == null)\n\t\tcommutes.put(ref, fns = new ArrayList<CFn>());\n\tfns.add(new CFn(fn, args));\n\tObject ret = fn.applyTo(RT.cons(vals.get(ref), args));\n\tvals.put(ref, ret);\n\treturn ret;\n}\n\n/*\n//for test\nstatic CyclicBarrier barrier;\nstatic ArrayList<Ref> items;\n\npublic static void main(String[] args){\n\ttry\n\t\t{\n\t\tif(args.length != 4)\n\t\t\tSystem.err.println(\"Usage: LockingTransaction nthreads nitems niters ninstances\");\n\t\tint nthreads = Integer.parseInt(args[0]);\n\t\tint nitems = Integer.parseInt(args[1]);\n\t\tint niters = Integer.parseInt(args[2]);\n\t\tint ninstances = Integer.parseInt(args[3]);\n\n\t\tif(items == null)\n\t\t\t{\n\t\t\tArrayList<Ref> temp = new ArrayList(nitems);\n\t\t\tfor(int i = 0; i < nitems; i++)\n\t\t\t\ttemp.add(new Ref(0));\n\t\t\titems = temp;\n\t\t\t}\n\n\t\tclass Incr extends AFn{\n\t\t\tpublic Object invoke(Object arg1) {\n\t\t\t\tInteger i = (Integer) arg1;\n\t\t\t\treturn i + 1;\n\t\t\t}\n\n\t\t\tpublic Obj withMeta(IPersistentMap meta){\n\t\t\t\tthrow new UnsupportedOperationException();\n\n\t\t\t}\n\t\t}\n\n\t\tclass Commuter extends AFn implements Callable{\n\t\t\tint niters;\n\t\t\tList<Ref> items;\n\t\t\tIncr incr;\n\n\n\t\t\tpublic Commuter(int niters, List<Ref> items){\n\t\t\t\tthis.niters = niters;\n\t\t\t\tthis.items = items;\n\t\t\t\tthis.incr = new Incr();\n\t\t\t}\n\n\t\t\tpublic Object call() {\n\t\t\t\tlong nanos = 0;\n\t\t\t\tfor(int i = 0; i < niters; i++)\n\t\t\t\t\t{\n\t\t\t\t\tlong start = System.nanoTime();\n\t\t\t\t\tLockingTransaction.runInTransaction(this);\n\t\t\t\t\tnanos += System.nanoTime() - start;\n\t\t\t\t\t}\n\t\t\t\treturn nanos;\n\t\t\t}\n\n\t\t\tpublic Object invoke() {\n\t\t\t\tfor(Ref tref : items)\n\t\t\t\t\t{\n\t\t\t\t\tLockingTransaction.getEx().doCommute(tref, incr);\n\t\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tpublic Obj withMeta(IPersistentMap meta){\n\t\t\t\tthrow new UnsupportedOperationException();\n\n\t\t\t}\n\t\t}\n\n\t\tclass Incrementer extends AFn implements Callable{\n\t\t\tint niters;\n\t\t\tList<Ref> items;\n\n\n\t\t\tpublic Incrementer(int niters, List<Ref> items){\n\t\t\t\tthis.niters = niters;\n\t\t\t\tthis.items = items;\n\t\t\t}\n\n\t\t\tpublic Object call() {\n\t\t\t\tlong nanos = 0;\n\t\t\t\tfor(int i = 0; i < niters; i++)\n\t\t\t\t\t{\n\t\t\t\t\tlong start = System.nanoTime();\n\t\t\t\t\tLockingTransaction.runInTransaction(this);\n\t\t\t\t\tnanos += System.nanoTime() - start;\n\t\t\t\t\t}\n\t\t\t\treturn nanos;\n\t\t\t}\n\n\t\t\tpublic Object invoke() {\n\t\t\t\tfor(Ref tref : items)\n\t\t\t\t\t{\n\t\t\t\t\t//Transaction.get().doTouch(tref);\n//\t\t\t\t\tLockingTransaction t = LockingTransaction.getEx();\n//\t\t\t\t\tint val = (Integer) t.doGet(tref);\n//\t\t\t\t\tt.doSet(tref, val + 1);\n\t\t\t\t\tint val = (Integer) tref.get();\n\t\t\t\t\ttref.set(val + 1);\n\t\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tpublic Obj withMeta(IPersistentMap meta){\n\t\t\t\tthrow new UnsupportedOperationException();\n\n\t\t\t}\n\t\t}\n\n\t\tArrayList<Callable<Long>> tasks = new ArrayList(nthreads);\n\t\tfor(int i = 0; i < nthreads; i++)\n\t\t\t{\n\t\t\tArrayList<Ref> si;\n\t\t\tsynchronized(items)\n\t\t\t\t{\n\t\t\t\tsi = (ArrayList<Ref>) items.clone();\n\t\t\t\t}\n\t\t\tCollections.shuffle(si);\n\t\t\ttasks.add(new Incrementer(niters, si));\n\t\t\t//tasks.add(new Commuter(niters, si));\n\t\t\t}\n\t\tExecutorService e = Executors.newFixedThreadPool(nthreads);\n\n\t\tif(barrier == null)\n\t\t\tbarrier = new CyclicBarrier(ninstances);\n\t\tSystem.out.println(\"waiting for other instances...\");\n\t\tbarrier.await();\n\t\tSystem.out.println(\"starting\");\n\t\tlong start = System.nanoTime();\n\t\tList<Future<Long>> results = e.invokeAll(tasks);\n\t\tlong estimatedTime = System.nanoTime() - start;\n\t\tSystem.out.printf(\"nthreads: %d, nitems: %d, niters: %d, time: %d%n\", nthreads, nitems, niters,\n\t\t                  estimatedTime / 1000000);\n\t\te.shutdown();\n\t\tfor(Future<Long> result : results)\n\t\t\t{\n\t\t\tSystem.out.printf(\"%d, \", result.get() / 1000000);\n\t\t\t}\n\t\tSystem.out.println();\n\t\tSystem.out.println(\"waiting for other instances...\");\n\t\tbarrier.await();\n\t\tsynchronized(items)\n\t\t\t{\n\t\t\tfor(Ref item : items)\n\t\t\t\t{\n\t\t\t\tSystem.out.printf(\"%d, \", (Integer) item.currentVal());\n\t\t\t\t}\n\t\t\t}\n\t\tSystem.out.println(\"\\ndone\");\n\t\tSystem.out.flush();\n\t\t}\n\tcatch(Exception ex)\n\t\t{\n\t\tex.printStackTrace();\n\t\t}\n}\n*/\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/LongRange.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.io.Serializable;\n\nimport java.util.Iterator;\nimport java.util.NoSuchElementException;\n\n/**\n * Implements the special common case of a finite range based on long start, end, and step.\n */\npublic class LongRange extends ASeq implements Counted, IChunkedSeq, IReduce {\n\nprivate static final int CHUNK_SIZE = 32;\n\n// Invariants guarantee this is never an empty or infinite seq\n//   assert(start != end && step != 0)\nfinal long start;\nfinal long end;\nfinal long step;\nfinal BoundsCheck boundsCheck;\nprivate volatile LongChunk _chunk;  // lazy\nprivate volatile ISeq _chunkNext;        // lazy\nprivate volatile ISeq _next;             // cached\n\nprivate static interface BoundsCheck extends Serializable {\n    boolean exceededBounds(long val);\n}\n\nprivate static BoundsCheck positiveStep(final long end) {\n    return new BoundsCheck() {\n        public boolean exceededBounds(long val){\n            return (val >= end);\n        }\n    };\n}\n\nprivate static BoundsCheck negativeStep(final long end) {\n    return new BoundsCheck() {\n        public boolean exceededBounds(long val){\n            return (val <= end);\n        }\n    };\n}\n\nprivate LongRange(long start, long end, long step, BoundsCheck boundsCheck){\n    this.start = start;\n    this.end = end;\n    this.step = step;\n    this.boundsCheck = boundsCheck;\n}\n\nprivate LongRange(long start, long end, long step, BoundsCheck boundsCheck, LongChunk chunk, ISeq chunkNext){\n    this.start = start;\n    this.end = end;\n    this.step = step;\n    this.boundsCheck = boundsCheck;\n    this._chunk = chunk;\n    this._chunkNext = chunkNext;\n}\n\nprivate LongRange(IPersistentMap meta, long start, long end, long step, BoundsCheck boundsCheck, LongChunk chunk, ISeq chunkNext){\n    super(meta);\n    this.start = start;\n    this.end = end;\n    this.step = step;\n    this.boundsCheck = boundsCheck;\n    this._chunk = chunk;\n    this._chunkNext = chunkNext;\n}\n\npublic static ISeq create(long end) {\n    if(end > 0)\n        return new LongRange(0L, end, 1L, positiveStep(end));\n    return PersistentList.EMPTY;\n}\n\npublic static ISeq create(long start, long end) {\n    if(start >= end)\n        return PersistentList.EMPTY;\n    return new LongRange(start, end, 1L, positiveStep(end));\n}\n\npublic static ISeq create(final long start, long end, long step) {\n    if(step > 0) {\n        if(end <= start) return PersistentList.EMPTY;\n        return new LongRange(start, end, step, positiveStep(end));\n    } else if(step < 0) {\n        if(end >= start) return PersistentList.EMPTY;\n        return new LongRange(start, end, step, negativeStep(end));\n    } else {\n        if(end == start) return PersistentList.EMPTY;\n        return Repeat.create(start);\n    }\n}\n\npublic Obj withMeta(IPersistentMap meta){\n    if(meta == _meta)\n        return this;\n    return new LongRange(meta, start, end, step, boundsCheck, _chunk, _chunkNext);\n}\n\npublic Object first() {\n    return start;\n}\n\npublic void forceChunk() {\n    if(_chunk != null) return;\n\n    long count;\n    try {\n        count = rangeCount(start, end, step);\n    } catch(ArithmeticException e) {\n        // size of total range is > Long.MAX_VALUE so must step to count\n        // this only happens in pathological range cases like:\n        // (range -9223372036854775808 9223372036854775807 9223372036854775807)\n        count = steppingCount(start, end, step);\n    }\n\n    if (count > CHUNK_SIZE) { // not last chunk\n        long nextStart = start + (step * CHUNK_SIZE);   // cannot overflow, must be < end\n        _chunk = new LongChunk(start, step, CHUNK_SIZE);\n        _chunkNext = new LongRange(nextStart, end, step, boundsCheck);\n    } else {  // last chunk\n        _chunk = new LongChunk(start, step, (int) count);   // count must be <= CHUNK_SIZE\n    }\n}\n\npublic ISeq next() {\n    if(_next != null)\n        return _next;\n\n    forceChunk();\n    if(_chunk.count() > 1) {\n        LongChunk smallerChunk = _chunk.dropFirst();\n        _next = new LongRange(smallerChunk.first(), end, step, boundsCheck, smallerChunk, _chunkNext);\n        return _next;\n    }\n    return chunkedNext();\n}\n\npublic IChunk chunkedFirst() {\n    forceChunk();\n    return _chunk;\n}\n\npublic ISeq chunkedNext() {\n    return chunkedMore().seq();\n}\n\npublic ISeq chunkedMore() {\n    forceChunk();\n    if(_chunkNext == null)\n        return PersistentList.EMPTY;\n    return _chunkNext;\n}\n\n// fallback count mechanism for pathological cases\n// returns either exact count or CHUNK_SIZE+1\nlong steppingCount(long start, long end, long step) {\n    long count = 1;\n    long s = start;\n    while(count <= CHUNK_SIZE) {\n        try {\n            s = Numbers.add(s, step);\n            if(boundsCheck.exceededBounds(s))\n                break;\n            else\n                count++;\n        } catch(ArithmeticException e) {\n            break;\n        }\n    }\n    return count;\n}\n\n// returns exact size of remaining items OR throws ArithmeticException for overflow case\nlong rangeCount(long start, long end, long step) {\n    // (1) count = ceiling ( (end - start) / step )\n    // (2) ceiling(a/b) = (a+b+o)/b where o=-1 for positive stepping and +1 for negative stepping\n    // thus: count = end - start + step + o / step\n    return Numbers.add(Numbers.add(Numbers.minus(end, start), step), this.step > 0 ? -1 : 1) / step;\n}\n\npublic int count() {\n    try {\n        long c = rangeCount(start, end, step);\n        if(c > Integer.MAX_VALUE) {\n            return Numbers.throwIntOverflow();\n        } else {\n            return (int) c;\n        }\n    } catch(ArithmeticException e) {\n        // rare case from large range or step, fall back to iterating and counting\n        Iterator iter = this.iterator();\n        long count = 0;\n        while(iter.hasNext()) {\n            iter.next();\n            count++;\n        }\n\n        if(count > Integer.MAX_VALUE)\n            return Numbers.throwIntOverflow();\n        else\n            return (int)count;\n    }\n}\n\npublic Object reduce(IFn f) {\n    Object acc = start;\n    long i = start + step;\n    while(! boundsCheck.exceededBounds(i)) {\n        acc = f.invoke(acc, i);\n        if (acc instanceof Reduced) return ((Reduced)acc).deref();\n        i += step;\n    }\n    return acc;\n}\n\npublic Object reduce(IFn f, Object val) {\n    Object acc = val;\n    long i = start;\n    do {\n        acc = f.invoke(acc, i);\n        if (RT.isReduced(acc)) return ((Reduced)acc).deref();\n        i += step;\n    } while(! boundsCheck.exceededBounds(i));\n    return acc;\n}\n\npublic Iterator iterator() {\n    return new LongRangeIterator();\n}\n\nclass LongRangeIterator implements Iterator {\n    private long next;\n    private boolean hasNext;\n\n    public LongRangeIterator() {\n        this.next = start;\n        this.hasNext = true;\n    }\n\n    public boolean hasNext() {\n        return hasNext;\n    }\n\n    public Object next() {\n        if (hasNext) {\n            long ret = next;\n            try {\n                next = Numbers.add(next, step);\n                hasNext = ! boundsCheck.exceededBounds(next);\n            } catch(ArithmeticException e) {\n                hasNext = false;\n            }\n            return ret;\n        } else {\n            throw new NoSuchElementException();\n        }\n    }\n\n    public void remove() {\n        throw new UnsupportedOperationException();\n    }\n}\n\nprivate static class LongChunk implements IChunk, Serializable {\n    final long start;\n    final long step;\n    final int count;\n\n    public LongChunk(long start, long step, int count) {\n        this.start = start;\n        this.step = step;\n        this.count = count;\n    }\n\n    public long first(){\n        return start;\n    }\n\n    public Object nth(int i){\n        return start + (i * step);\n    }\n\n    public Object nth(int i, Object notFound){\n        if(i >= 0 && i < count)\n            return start + (i * step);\n        return notFound;\n    }\n\n    public int count(){\n        return count;\n    }\n\n    public LongChunk dropFirst(){\n        if(count <= 1)\n            throw new IllegalStateException(\"dropFirst of empty chunk\");\n        return new LongChunk(start+step, step, count-1);\n    }\n\n    public Object reduce(IFn f, Object init) {\n        long x = start;\n        Object ret = init;\n        for(int i=0; i<count; i++) {\n            ret = f.invoke(ret, x);\n            if(RT.isReduced(ret))\n                return ret;\n            x += step;\n        }\n        return ret;\n    }\n\n}\n}"
  },
  {
    "path": "src/jvm/clojure/lang/MapEntry.java",
    "content": "/**\r\n *   Copyright (c) Rich Hickey. All rights reserved.\r\n *   The use and distribution terms for this software are covered by the\r\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n *   which can be found in the file epl-v10.html at the root of this distribution.\r\n *   By using this software in any fashion, you are agreeing to be bound by\r\n * \t the terms of this license.\r\n *   You must not remove this notice, or any other, from this software.\r\n **/\r\n\r\npackage clojure.lang;\r\n\r\nimport java.util.Iterator;\r\n\r\npublic class MapEntry extends AMapEntry{\r\nfinal Object _key;\r\nfinal Object _val;\r\n\r\npublic MapEntry(Object key, Object val){\r\n\tthis._key = key;\r\n\tthis._val = val;\r\n}\r\n\r\npublic Object key(){\r\n\treturn _key;\r\n}\r\n\r\npublic Object val(){\r\n\treturn _val;\r\n}\r\n\r\npublic Object getKey(){\r\n\treturn key();\r\n}\r\n\r\npublic Object getValue(){\r\n\treturn val();\r\n}\r\n\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/MapEquivalence.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Aug 4, 2010 */\n\npackage clojure.lang;\n\n//marker interface\npublic interface MapEquivalence{\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/MethodImplCache.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Nov 8, 2009 */\n\npackage clojure.lang;\n\nimport java.util.Map;\n\npublic final class MethodImplCache{\n\nstatic public class Entry{\n\tfinal public Class c;\n\tfinal public IFn fn;\n\n\tpublic Entry(Class c, IFn fn){\n\t\tthis.c = c;\n\t\tthis.fn = fn;\n\t}\n}\n\npublic final IPersistentMap protocol;\npublic final Keyword methodk;\npublic final int shift;\npublic final int mask;\npublic final Object[] table;    //[class, entry. class, entry ...]\npublic final Map map;\n\nEntry mre = null;\n\npublic MethodImplCache(IPersistentMap protocol, Keyword methodk){\n\tthis(protocol, methodk, 0, 0, RT.EMPTY_ARRAY);\n}\n\npublic MethodImplCache(IPersistentMap protocol, Keyword methodk, int shift, int mask, Object[] table){\n    this.protocol = protocol;\n    this.methodk = methodk;\n    this.shift = shift;\n    this.mask = mask;\n    this.table = table;\n    this.map = null;\n}\n\npublic MethodImplCache(IPersistentMap protocol, Keyword methodk, Map map){\n    this.protocol = protocol;\n    this.methodk = methodk;\n    this.shift = 0;\n    this.mask = 0;\n    this.table = null;\n    this.map = map;\n}\n\npublic IFn fnFor(Class c){\n\tEntry last = mre;\n\tif(last != null && last.c == c)\n\t\treturn last.fn;\n\treturn findFnFor(c);\n}\n\nIFn findFnFor(Class c){\n    if (map != null)\n        {\n        Entry e = (Entry) map.get(c);\n        mre = e;\n        return  e != null ? e.fn : null;\n        }\n    else\n        {\n        int idx = ((Util.hash(c) >> shift) & mask) << 1;\n        if(idx < table.length && table[idx] == c)\n            {\n            Entry e = ((Entry) table[idx + 1]);\n            mre = e;\n            return  e != null ? e.fn : null;\n            }\n        return null;\n        }\n}\n\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/MultiFn.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Sep 13, 2007 */\n\npackage clojure.lang;\n\nimport java.util.Map;\nimport java.util.concurrent.locks.ReentrantReadWriteLock;\n\n/*-[\n#include \"clojure/core_assoc.h\"\n#include \"clojure/core_dissoc.h\"\n#include \"clojure/core_isa_QMARK_.h\"\n#include \"clojure/core_parents.h\"\n]-*/\n\npublic class MultiFn extends AFn {\n  final public IFn dispatchFn;\n  final public Object defaultDispatchVal;\n  final public IRef hierarchy;\n  final String name;\n  final ReentrantReadWriteLock rw;\n  volatile IPersistentMap methodTable;\n  volatile IPersistentMap preferTable;\n  volatile IPersistentMap methodCache;\n  volatile Object cachedHierarchy;\n\n  static final Var assoc = RT.var(\"clojure.core\", \"assoc\");\n  static final Var dissoc = RT.var(\"clojure.core\", \"dissoc\");\n  static final Var isa = RT.var(\"clojure.core\", \"isa?\");\n  static final Var parents = RT.var(\"clojure.core\", \"parents\");\n\n  static native void loadFns() /*-[\n    Clojurecore_assoc_get_VAR_();\n    Clojurecore_dissoc_get_VAR_();\n    Clojurecore_isa_QMARK__get_VAR_();\n    Clojurecore_parents_get_VAR_();\n  ]-*/;\n  \n  static {\n    if (ObjC.objc) { \n      loadFns();\n    } else {\n      assoc.maybeLoad();\n      dissoc.maybeLoad();\n      isa.maybeLoad();\n      parents.maybeLoad();  \n    }\n  }\n  \n  public MultiFn(String name, IFn dispatchFn, Object defaultDispatchVal,\n      IRef hierarchy) {\n    this.rw = new ReentrantReadWriteLock();\n    this.name = name;\n    this.dispatchFn = dispatchFn;\n    this.defaultDispatchVal = defaultDispatchVal;\n    this.methodTable = PersistentHashMap.EMPTY;\n    this.methodCache = getMethodTable();\n    this.preferTable = PersistentHashMap.EMPTY;\n    this.hierarchy = hierarchy;\n    cachedHierarchy = null;\n  }\n\n  public MultiFn reset() {\n    rw.writeLock().lock();\n    try {\n      methodTable = methodCache = preferTable = PersistentHashMap.EMPTY;\n      cachedHierarchy = null;\n      return this;\n    } finally {\n      rw.writeLock().unlock();\n    }\n  }\n\n  public MultiFn addMethod(Object dispatchVal, IFn method) {\n    rw.writeLock().lock();\n    try {\n      methodTable = getMethodTable().assoc(dispatchVal, method);\n      resetCache();\n      return this;\n    } finally {\n      rw.writeLock().unlock();\n    }\n  }\n\n  public MultiFn removeMethod(Object dispatchVal) {\n    rw.writeLock().lock();\n    try {\n      methodTable = getMethodTable().without(dispatchVal);\n      resetCache();\n      return this;\n    } finally {\n      rw.writeLock().unlock();\n    }\n  }\n\n  public MultiFn preferMethod(Object dispatchValX, Object dispatchValY) {\n    rw.writeLock().lock();\n    try {\n      // TODO: allow this in ios?\n      // This is very slow in objc runtime\n      if (!ObjC.objc && prefers(dispatchValY, dispatchValX))\n        throw new IllegalStateException(\n            String\n                .format(\n                    \"Preference conflict in multimethod '%s': %s is already preferred to %s\",\n                    name, dispatchValY, dispatchValX));\n      preferTable = getPreferTable().assoc(\n          dispatchValX,\n          RT.conj((IPersistentCollection) RT.get(getPreferTable(),\n              dispatchValX, PersistentHashSet.EMPTY), dispatchValY));\n      resetCache();\n      return this;\n    } finally {\n      rw.writeLock().unlock();\n    }\n  }\n\n  private boolean prefers(Object x, Object y) {\n    if (x == y)\n      return false;\n\n    if (x instanceof Class && y instanceof Class) {\n      for (ISeq ps = RT.keys(getPreferTable()); ps != null; ps = ps.next()) {\n        Class xx = (Class)x;\n        Class yy = (Class)y;\n        Object k = ps.first();\n        if (k instanceof Class && (x == k || ((Class) k).isAssignableFrom(xx))) {\n          IPersistentSet xprefs = (IPersistentSet) getPreferTable().valAt(k);\n          if (xprefs.contains(y)) {\n            return true;\n          }\n          for (ISeq xp = RT.seq(xprefs); xp != null; xp = xp.next()) {\n            Object p = xp.first();\n            if (p instanceof Class && (y == p || ((Class) p).isAssignableFrom(yy))) {\n              return true;\n            }\n          }\n        }\n      }\n      return false;\n    }\n    \n    IPersistentSet xprefs = (IPersistentSet) getPreferTable().valAt(x);\n    if (xprefs != null && xprefs.contains(y))\n      return true;\n\n    for (ISeq ps = RT.seq(parents.invoke(y)); ps != null; ps = ps.next()) {\n      if (prefers(x, ps.first()))\n        return true;\n    }\n    for (ISeq ps = RT.seq(parents.invoke(x)); ps != null; ps = ps.next()) {\n      if (prefers(ps.first(), y))\n        return true;\n    }\n    return false;\n  }\n\n  private boolean isA(Object x, Object y) {\n    // in objc not all classes extend java.lang.Object\n    if (x instanceof Class && y == Object.class) {\n      return true;\n    }\n    if (x instanceof Class && y instanceof Class) {\n      return ((Class) y).isAssignableFrom((Class) x);\n    }\n    return RT.booleanCast(isa.invoke(hierarchy.deref(), x, y));\n  }\n\n  private boolean dominates(Object x, Object y) {\n    return prefers(x, y) || isA(x, y);\n  }\n\n  private IPersistentMap resetCache() {\n    rw.writeLock().lock();\n    try {\n      methodCache = getMethodTable();\n      cachedHierarchy = hierarchy.deref();\n      return methodCache;\n    } finally {\n      rw.writeLock().unlock();\n    }\n  }\n\n  public IFn getMethod(Object dispatchVal) {\n    if (cachedHierarchy != hierarchy.deref())\n      resetCache();\n    IFn targetFn = (IFn) methodCache.valAt(dispatchVal);\n    if (targetFn != null)\n      return targetFn;\n    return findAndCacheBestMethod(dispatchVal);\n  }\n\n  private IFn getFn(Object dispatchVal) {\n    IFn targetFn = getMethod(dispatchVal);\n    if (targetFn == null)\n      throw new IllegalArgumentException(String.format(\n          \"No method in multimethod '%s' for dispatch value: %s\", name,\n          dispatchVal));\n    return targetFn;\n  }\n\n  private IFn findAndCacheBestMethod(Object dispatchVal) {\n    rw.readLock().lock();\n    Object bestValue;\n    IPersistentMap mt = methodTable;\n    IPersistentMap pt = preferTable;\n    Object ch = cachedHierarchy;\n    try {\n      Map.Entry bestEntry = null;\n      for (Object o : getMethodTable()) {\n        Map.Entry e = (Map.Entry) o;\n        if (isA(dispatchVal, e.getKey())) {\n          if (bestEntry == null || dominates(e.getKey(), bestEntry.getKey()))\n            bestEntry = e;\n          if (!dominates(bestEntry.getKey(), e.getKey()))\n            throw new IllegalArgumentException(\n                String\n                    .format(\n                        \"Multiple methods in multimethod '%s' match dispatch value: %s -> %s and %s, and neither is preferred\",\n                        name, dispatchVal, e.getKey(), bestEntry.getKey()));\n        }\n      }\n      if (bestEntry == null)\n      {\n         bestValue = methodTable.valAt(defaultDispatchVal);\n         if(bestValue == null)\n            return null;\n         } else {\n             bestValue = bestEntry.getValue();\n         }\n    } finally {\n      rw.readLock().unlock();\n    }\n\n    // ensure basis has stayed stable throughout, else redo\n    rw.writeLock().lock();\n    try {\n      if (mt == methodTable && pt == preferTable && ch == cachedHierarchy\n          && cachedHierarchy == hierarchy.deref()) {\n        // place in cache\n        methodCache = methodCache.assoc(dispatchVal, bestValue);\n        return (IFn) bestValue;\n      } else {\n        resetCache();\n        return findAndCacheBestMethod(dispatchVal);\n      }\n    } finally {\n      rw.writeLock().unlock();\n    }\n  }\n\n  public Object invoke() {\n    return getFn(dispatchFn.invoke()).invoke();\n  }\n\n  public Object invoke(Object arg1) {\n    return getFn(dispatchFn.invoke(arg1)).invoke(Util.ret1(arg1, arg1 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2) {\n    return getFn(dispatchFn.invoke(arg1, arg2)).invoke(\n        Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3) {\n    return getFn(dispatchFn.invoke(arg1, arg2, arg3)).invoke(\n        Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n        Util.ret1(arg3, arg3 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) {\n    return getFn(dispatchFn.invoke(arg1, arg2, arg3, arg4)).invoke(\n        Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n        Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5) {\n    return getFn(dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5)).invoke(\n        Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n        Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n        Util.ret1(arg5, arg5 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6) {\n    return getFn(dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6)).invoke(\n        Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n        Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n        Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7) {\n    return getFn(dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7))\n        .invoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n            Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n            Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null),\n            Util.ret1(arg7, arg7 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8))\n        .invoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n            Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n            Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null),\n            Util.ret1(arg7, arg7 = null), Util.ret1(arg8, arg8 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9))\n        .invoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n            Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n            Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null),\n            Util.ret1(arg7, arg7 = null), Util.ret1(arg8, arg8 = null),\n            Util.ret1(arg9, arg9 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9,\n      Object arg10) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,\n            arg10)).invoke(Util.ret1(arg1, arg1 = null),\n        Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n        Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null),\n        Util.ret1(arg6, arg6 = null), Util.ret1(arg7, arg7 = null),\n        Util.ret1(arg8, arg8 = null), Util.ret1(arg9, arg9 = null),\n        Util.ret1(arg10, arg10 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9,\n      Object arg10, Object arg11) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,\n            arg10, arg11)).invoke(Util.ret1(arg1, arg1 = null),\n        Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n        Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null),\n        Util.ret1(arg6, arg6 = null), Util.ret1(arg7, arg7 = null),\n        Util.ret1(arg8, arg8 = null), Util.ret1(arg9, arg9 = null),\n        Util.ret1(arg10, arg10 = null), Util.ret1(arg11, arg11 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9,\n      Object arg10, Object arg11, Object arg12) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,\n            arg10, arg11, arg12)).invoke(Util.ret1(arg1, arg1 = null),\n        Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n        Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null),\n        Util.ret1(arg6, arg6 = null), Util.ret1(arg7, arg7 = null),\n        Util.ret1(arg8, arg8 = null), Util.ret1(arg9, arg9 = null),\n        Util.ret1(arg10, arg10 = null), Util.ret1(arg11, arg11 = null),\n        Util.ret1(arg12, arg12 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9,\n      Object arg10, Object arg11, Object arg12, Object arg13) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,\n            arg10, arg11, arg12, arg13)).invoke(Util.ret1(arg1, arg1 = null),\n        Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n        Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null),\n        Util.ret1(arg6, arg6 = null), Util.ret1(arg7, arg7 = null),\n        Util.ret1(arg8, arg8 = null), Util.ret1(arg9, arg9 = null),\n        Util.ret1(arg10, arg10 = null), Util.ret1(arg11, arg11 = null),\n        Util.ret1(arg12, arg12 = null), Util.ret1(arg13, arg13 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9,\n      Object arg10, Object arg11, Object arg12, Object arg13, Object arg14) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,\n            arg10, arg11, arg12, arg13, arg14)).invoke(\n        Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n        Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n        Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null),\n        Util.ret1(arg7, arg7 = null), Util.ret1(arg8, arg8 = null),\n        Util.ret1(arg9, arg9 = null), Util.ret1(arg10, arg10 = null),\n        Util.ret1(arg11, arg11 = null), Util.ret1(arg12, arg12 = null),\n        Util.ret1(arg13, arg13 = null), Util.ret1(arg14, arg14 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9,\n      Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n      Object arg15) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,\n            arg10, arg11, arg12, arg13, arg14, arg15)).invoke(\n        Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n        Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n        Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null),\n        Util.ret1(arg7, arg7 = null), Util.ret1(arg8, arg8 = null),\n        Util.ret1(arg9, arg9 = null), Util.ret1(arg10, arg10 = null),\n        Util.ret1(arg11, arg11 = null), Util.ret1(arg12, arg12 = null),\n        Util.ret1(arg13, arg13 = null), Util.ret1(arg14, arg14 = null),\n        Util.ret1(arg15, arg15 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9,\n      Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n      Object arg15, Object arg16) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,\n            arg10, arg11, arg12, arg13, arg14, arg15, arg16)).invoke(\n        Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n        Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n        Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null),\n        Util.ret1(arg7, arg7 = null), Util.ret1(arg8, arg8 = null),\n        Util.ret1(arg9, arg9 = null), Util.ret1(arg10, arg10 = null),\n        Util.ret1(arg11, arg11 = null), Util.ret1(arg12, arg12 = null),\n        Util.ret1(arg13, arg13 = null), Util.ret1(arg14, arg14 = null),\n        Util.ret1(arg15, arg15 = null), Util.ret1(arg16, arg16 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9,\n      Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n      Object arg15, Object arg16, Object arg17) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,\n            arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17)).invoke(\n        Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n        Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n        Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null),\n        Util.ret1(arg7, arg7 = null), Util.ret1(arg8, arg8 = null),\n        Util.ret1(arg9, arg9 = null), Util.ret1(arg10, arg10 = null),\n        Util.ret1(arg11, arg11 = null), Util.ret1(arg12, arg12 = null),\n        Util.ret1(arg13, arg13 = null), Util.ret1(arg14, arg14 = null),\n        Util.ret1(arg15, arg15 = null), Util.ret1(arg16, arg16 = null),\n        Util.ret1(arg17, arg17 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9,\n      Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n      Object arg15, Object arg16, Object arg17, Object arg18) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,\n            arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18))\n        .invoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n            Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n            Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null),\n            Util.ret1(arg7, arg7 = null), Util.ret1(arg8, arg8 = null),\n            Util.ret1(arg9, arg9 = null), Util.ret1(arg10, arg10 = null),\n            Util.ret1(arg11, arg11 = null), Util.ret1(arg12, arg12 = null),\n            Util.ret1(arg13, arg13 = null), Util.ret1(arg14, arg14 = null),\n            Util.ret1(arg15, arg15 = null), Util.ret1(arg16, arg16 = null),\n            Util.ret1(arg17, arg17 = null), Util.ret1(arg18, arg18 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9,\n      Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n      Object arg15, Object arg16, Object arg17, Object arg18, Object arg19) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,\n            arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18,\n            arg19)).invoke(Util.ret1(arg1, arg1 = null),\n        Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n        Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null),\n        Util.ret1(arg6, arg6 = null), Util.ret1(arg7, arg7 = null),\n        Util.ret1(arg8, arg8 = null), Util.ret1(arg9, arg9 = null),\n        Util.ret1(arg10, arg10 = null), Util.ret1(arg11, arg11 = null),\n        Util.ret1(arg12, arg12 = null), Util.ret1(arg13, arg13 = null),\n        Util.ret1(arg14, arg14 = null), Util.ret1(arg15, arg15 = null),\n        Util.ret1(arg16, arg16 = null), Util.ret1(arg17, arg17 = null),\n        Util.ret1(arg18, arg18 = null), Util.ret1(arg19, arg19 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9,\n      Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n      Object arg15, Object arg16, Object arg17, Object arg18, Object arg19,\n      Object arg20) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,\n            arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18,\n            arg19, arg20)).invoke(Util.ret1(arg1, arg1 = null),\n        Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n        Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null),\n        Util.ret1(arg6, arg6 = null), Util.ret1(arg7, arg7 = null),\n        Util.ret1(arg8, arg8 = null), Util.ret1(arg9, arg9 = null),\n        Util.ret1(arg10, arg10 = null), Util.ret1(arg11, arg11 = null),\n        Util.ret1(arg12, arg12 = null), Util.ret1(arg13, arg13 = null),\n        Util.ret1(arg14, arg14 = null), Util.ret1(arg15, arg15 = null),\n        Util.ret1(arg16, arg16 = null), Util.ret1(arg17, arg17 = null),\n        Util.ret1(arg18, arg18 = null), Util.ret1(arg19, arg19 = null),\n        Util.ret1(arg20, arg20 = null));\n  }\n\n  public Object invoke(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5, Object arg6, Object arg7, Object arg8, Object arg9,\n      Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n      Object arg15, Object arg16, Object arg17, Object arg18, Object arg19,\n      Object arg20, Object... args) {\n    return getFn(\n        dispatchFn.invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,\n            arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18,\n            arg19, arg20, args)).invoke(Util.ret1(arg1, arg1 = null),\n        Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n        Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null),\n        Util.ret1(arg6, arg6 = null), Util.ret1(arg7, arg7 = null),\n        Util.ret1(arg8, arg8 = null), Util.ret1(arg9, arg9 = null),\n        Util.ret1(arg10, arg10 = null), Util.ret1(arg11, arg11 = null),\n        Util.ret1(arg12, arg12 = null), Util.ret1(arg13, arg13 = null),\n        Util.ret1(arg14, arg14 = null), Util.ret1(arg15, arg15 = null),\n        Util.ret1(arg16, arg16 = null), Util.ret1(arg17, arg17 = null),\n        Util.ret1(arg18, arg18 = null), Util.ret1(arg19, arg19 = null),\n        Util.ret1(arg20, arg20 = null), args);\n  }\n\n  public IPersistentMap getMethodTable() {\n    return methodTable;\n  }\n\n  public IPersistentMap getPreferTable() {\n    return preferTable;\n  }\n}"
  },
  {
    "path": "src/jvm/clojure/lang/Murmur3.java",
    "content": "/*\n * Copyright (C) 2011 The Guava Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under the License\n * is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\n * or implied. See the License for the specific language governing permissions and limitations under\n * the License.\n */\n\n/*\n * MurmurHash3 was written by Austin Appleby, and is placed in the public\n * domain. The author hereby disclaims copyright to this source code.\n */\n\n/*\n * Source:\n * http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp\n * (Modified to adapt to Guava coding conventions and to use the HashFunction interface)\n */\n\n/**\n * Modified to remove stuff Clojure doesn't need, placed under clojure.lang namespace,\n * all fns made static, added hashOrdered/Unordered\n */\n\npackage clojure.lang;\n\nimport java.io.Serializable;\nimport java.nio.ByteBuffer;\n\n/**\n * See http://smhasher.googlecode.com/svn/trunk/MurmurHash3.cpp\n * MurmurHash3_x86_32\n *\n * @author Austin Appleby\n * @author Dimitris Andreou\n * @author Kurt Alfred Kluever\n */\n\npublic final class Murmur3{\nprivate static final int seed = 0;\nprivate static final int C1 = 0xcc9e2d51;\nprivate static final int C2 = 0x1b873593;\n\npublic static int hashInt(int input){\n\tif(input == 0) return 0;\n\tint k1 = mixK1(input);\n\tint h1 = mixH1(seed, k1);\n\n\treturn fmix(h1, 4);\n}\n\npublic static int hashLong(long input){\n\tif(input == 0) return 0;\n\tint low = (int) input;\n\tint high = (int) (input >>> 32);\n\n\tint k1 = mixK1(low);\n\tint h1 = mixH1(seed, k1);\n\n\tk1 = mixK1(high);\n\th1 = mixH1(h1, k1);\n\n\treturn fmix(h1, 8);\n}\n\npublic static int hashUnencodedChars(CharSequence input){\n\tint h1 = seed;\n\n\t// step through the CharSequence 2 chars at a time\n\tfor(int i = 1; i < input.length(); i += 2)\n\t\t{\n\t\tint k1 = input.charAt(i - 1) | (input.charAt(i) << 16);\n\t\tk1 = mixK1(k1);\n\t\th1 = mixH1(h1, k1);\n\t\t}\n\n\t// deal with any remaining characters\n\tif((input.length() & 1) == 1)\n\t\t{\n\t\tint k1 = input.charAt(input.length() - 1);\n\t\tk1 = mixK1(k1);\n\t\th1 ^= k1;\n\t\t}\n\n\treturn fmix(h1, 2 * input.length());\n}\n\npublic static int mixCollHash(int hash, int count){\n\tint h1 = seed;\n\tint k1 = mixK1(hash);\n\th1 = mixH1(h1, k1);\n\treturn fmix(h1, count);\n}\n\npublic static int hashOrdered(Iterable xs){\n\tint n = 0;\n\tint hash = 1;\n\n\tfor(Object x : xs)\n\t\t{\n\t\thash = 31 * hash + Util.hasheq(x);\n\t\t++n;\n\t\t}\n\n\treturn mixCollHash(hash, n);\n}\n\npublic static int hashUnordered(Iterable xs){\n\tint hash = 0;\n\tint n = 0;\n\tfor(Object x : xs)\n\t\t{\n\t\thash += Util.hasheq(x);\n\t\t++n;\n\t\t}\t\n\n\treturn mixCollHash(hash, n);\n}\n\nprivate static int mixK1(int k1){\n\tk1 *= C1;\n\tk1 = Integer.rotateLeft(k1, 15);\n\tk1 *= C2;\n\treturn k1;\n}\n\nprivate static int mixH1(int h1, int k1){\n\th1 ^= k1;\n\th1 = Integer.rotateLeft(h1, 13);\n\th1 = h1 * 5 + 0xe6546b64;\n\treturn h1;\n}\n\n// Finalization mix - force all bits of a hash block to avalanche\nprivate static int fmix(int h1, int length){\n\th1 ^= length;\n\th1 ^= h1 >>> 16;\n\th1 *= 0x85ebca6b;\n\th1 ^= h1 >>> 13;\n\th1 *= 0xc2b2ae35;\n\th1 ^= h1 >>> 16;\n\treturn h1;\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Named.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Sep 20, 2007 */\n\npackage clojure.lang;\n\npublic interface Named{\nString getNamespace();\n\nString getName();\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Namespace.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jan 23, 2008 */\n\npackage clojure.lang;\n\nimport java.io.ObjectStreamException;\nimport java.io.Serializable;\nimport java.util.HashSet;\nimport java.util.concurrent.ConcurrentHashMap;\nimport java.util.concurrent.atomic.AtomicReference;\n\npublic class Namespace extends AReference implements Serializable {\nfinal public Symbol name;\ntransient final AtomicReference<IPersistentMap> mappings = new AtomicReference<IPersistentMap>();\ntransient final AtomicReference<IPersistentMap> aliases = new AtomicReference<IPersistentMap>();\ntransient final AtomicReference<IPersistentMap> refers = new AtomicReference<IPersistentMap>();\n\nfinal static ConcurrentHashMap<Symbol, Namespace> namespaces = new ConcurrentHashMap<Symbol, Namespace>();\n\npublic String toString(){\n\treturn name.toString();\n}\n\nNamespace(Symbol name){\n\tsuper(name.meta());\n\tthis.name = name;\n\tmappings.set(RT.DEFAULT_IMPORTS);\n\taliases.set(RT.map());\n\trefers.set(RT.map());\n\tif (!name.name.equals(\"clojure.core\")) {\n\t  referNs(RT.CLOJURE_NS, RT.map());\n\t}\n}\n\npublic static ISeq all(){\n\treturn RT.seq(namespaces.values());\n}\n\npublic Symbol getName(){\n\treturn name;\n}\n\npublic IPersistentMap getMappings(){\n\treturn mappings.get();\n}\n\npublic Var intern(Symbol sym){\n\tif(sym.ns != null)\n\t\t{\n\t\tthrow new IllegalArgumentException(\"Can't intern namespace-qualified symbol\");\n\t\t}\n\tIPersistentMap map = getMappings();\n\tObject o;\n\tVar v = null;\n\twhile((o = map.valAt(sym)) == null)\n\t\t{\n\t\tif(v == null)\n\t\t\tv = new Var(this, sym);\n\t\tIPersistentMap newMap = map.assoc(sym, v);\n\t\tmappings.compareAndSet(map, newMap);\n\t\tmap = getMappings();\n\t\t}\n\tif(o instanceof Var && ((Var) o).ns == this)\n\t\treturn (Var) o;\n\n\tif(v == null)\n\t\tv = new Var(this, sym);\n\n\t//warnOrFailOnReplace(sym, o, v);\n\n\n\twhile(!mappings.compareAndSet(map, map.assoc(sym, v)))\n\t\tmap = getMappings();\n\n\treturn v;\n}\n\nprivate void warnOrFailOnReplace(Symbol sym, Object o, Object v){\n    if (o instanceof Var)\n        {\n        Namespace ns = ((Var)o).ns;\n        if (ns == this || (v instanceof Var && ((Var)v).ns  == RT.CLOJURE_NS))\n            return;\n        if (ns != RT.CLOJURE_NS)\n            throw new IllegalStateException(sym + \" already refers to: \" + o + \" in namespace: \" + name);\n        }\n\tRT.errPrintWriter().println(\"WARNING: \" + sym + \" already refers to: \" + o + \" in namespace: \" + name\n\t\t+ \", being replaced by: \" + v);\n}\n\nObject reference(Symbol sym, Object val){\n\tif(sym.ns != null)\n\t\t{\n\t\tthrow new IllegalArgumentException(\"Can't intern namespace-qualified symbol\");\n\t\t}\n\tIPersistentMap map = getMappings();\n\tObject o;\n\twhile((o = map.valAt(sym)) == null)\n\t\t{\n\t\tIPersistentMap newMap = map.assoc(sym, val);\n\t\tmappings.compareAndSet(map, newMap);\n\t\tmap = getMappings();\n\t\t}\n\tif(o == val)\n\t\treturn o;\n\n\twarnOrFailOnReplace(sym, o, val);\n\n\twhile(!mappings.compareAndSet(map, map.assoc(sym, val)))\n\t\tmap = getMappings();\n\n\treturn val;\n\n}\n\npublic static boolean areDifferentInstancesOfSameClassName(Class cls1, Class cls2) {\n    return (cls1 != cls2) && (cls1.getName().equals(cls2.getName()));\n}\n\nClass referenceClass(Symbol sym, Class val){\n    if(sym.ns != null)\n        {\n        throw new IllegalArgumentException(\"Can't intern namespace-qualified symbol\");\n        }\n    IPersistentMap map = getMappings();\n    Class c = (Class) map.valAt(sym);\n    while((c == null) || (areDifferentInstancesOfSameClassName(c, val)))\n        {\n        IPersistentMap newMap = map.assoc(sym, val);\n        mappings.compareAndSet(map, newMap);\n        map = getMappings();\n        c = (Class) map.valAt(sym);\n        }\n    if(c == val)\n        return c;\n\n    throw new IllegalStateException(sym + \" already refers to: \" + c + \" in namespace: \" + name);\n}\n\npublic void unmap(Symbol sym) {\n\tif(sym.ns != null)\n\t\t{\n\t\tthrow new IllegalArgumentException(\"Can't unintern namespace-qualified symbol\");\n\t\t}\n\tIPersistentMap map = getMappings();\n\twhile(map.containsKey(sym))\n\t\t{\n\t\tIPersistentMap newMap = map.without(sym);\n\t\tmappings.compareAndSet(map, newMap);\n\t\tmap = getMappings();\n\t\t}\n}\n\npublic Class importClass(Symbol sym, Class c){\n\treturn referenceClass(sym, c);\n\n}\n\npublic Class importClass(Class c){\n\tString n = c.getName();\n\treturn importClass(Symbol.intern(n.substring(n.lastIndexOf('.') + 1)), c);\n}\n\npublic Var refer(Symbol sym, Var var){\n\treturn (Var) reference(sym, var);\n\n}\n\nstatic Keyword only = Keyword.intern(\"only\");\nstatic Keyword onlyAndRefer = Keyword.intern(\"onlyAndRefer\");\nstatic Keyword refer = Keyword.intern(\"refer\");\nstatic Keyword exclude = Keyword.intern(\"exclude\");\nstatic Keyword allkeyword = Keyword.intern(\"all\");\nstatic Keyword rename = Keyword.intern(\"rename\");\n\npublic Namespace referNs(Object ns, IPersistentMap filters) {\n  Object refer = filters.valAt(Namespace.refer);\n  Object exclude = filters.valAt(Namespace.exclude);\n  Object only = filters.valAt(Namespace.only);\n  only = only == null ? RT.set() : PersistentHashSet.create(RT.seq(only));\n  Object rename = filters.valAt(Namespace.rename);\n\n  IPersistentSet onlyAndRefer = (IPersistentSet) only;\n  if (refer != null && refer instanceof Sequential) {\n    for (ISeq e = RT.seq(refer); e != null; e = e.next()) {\n      onlyAndRefer = (IPersistentSet) onlyAndRefer.cons(e.first());\n    }\n  }\n\n  filters = filters\n      .assoc(Namespace.onlyAndRefer, onlyAndRefer)\n      .assoc(\n          Namespace.refer,\n          refer == null && refer instanceof Sequential ? PersistentHashSet\n              .create(RT.seq(refer)) : refer)\n      .assoc(\n          Namespace.exclude,\n          exclude == null ? RT.set() : PersistentHashSet.create(RT\n              .seq(exclude))).assoc(Namespace.only, only)\n      .assoc(Namespace.rename, rename == null ? RT.map() : invert(rename));\n  boolean successful = false;\n  while (!successful) {\n    IPersistentMap expects = refers.get();\n    successful = refers.compareAndSet(expects, expects.assoc(ns, filters));\n  }\n  return this;\n}\n\nprivate IPersistentMap invert(Object m) {\n  IPersistentMap r = RT.map();\n  Object s = RT.seq(RT.keys(m));\n  while (s != null) {\n    Object k = RT.first(s);\n    r = r.assoc(RT.get(m, k), k);\n    s = RT.next(s);\n  }\n  return r;\n}\n\npublic static Namespace findOrCreate(Symbol name){\n\tNamespace ns = namespaces.get(name);\n\tif(ns != null)\n\t\treturn ns;\n\tNamespace newns = new Namespace(name);\n\tns = namespaces.putIfAbsent(name, newns);\n\treturn ns == null ? newns : ns;\n}\n\npublic static Namespace remove(Symbol name){\n\tif(name.equals(RT.CLOJURE_NS.name))\n\t\tthrow new IllegalArgumentException(\"Cannot remove clojure namespace\");\n\treturn namespaces.remove(name);\n}\n\npublic static Namespace find(Symbol name){\n\treturn namespaces.get(name);\n}\n\npublic Object getMapping(Symbol name) {\n  Object val = mappings.get().valAt(name);\n  if (val == null && !ObjC.objc) {\n    val = Var.maybeLoadFromClass(this.name.toString(), name.toString());\n    if (val == null && this != RT.CLOJURE_NS) {\n      val = searchMapping(name);\n      if (val != null && val instanceof Var) {\n        refer(name, (Var) val);\n      }\n    }\n    return val;\n  }\n  return val;\n}\n\nprivate Object searchMapping(Symbol name) {\n  IPersistentMap m = refers.get();\n  for (ISeq s = m.seq(); s != null; s = s.next()) {\n    Object i = s.first();\n    Object o = null;\n    Namespace ns = (Namespace) RT.first(i);\n    IPersistentMap filters = (IPersistentMap) RT.second(i);\n    Object refer = filters.valAt(Namespace.refer);\n    IPersistentSet exclude = (IPersistentSet) filters\n        .valAt(Namespace.exclude);\n    IPersistentMap rename = (IPersistentMap) filters.valAt(Namespace.rename);\n    if (exclude.contains(name)) {\n      continue;\n    } else if (rename.containsKey(name)) {\n      o = ns.getMapping((Symbol) rename.valAt(name));\n    } else if (Namespace.allkeyword.equals(refer)) {\n      o = ns.getMapping(name);\n    } else {\n      IPersistentSet onlyAndRefer = (IPersistentSet) filters\n          .valAt(Namespace.onlyAndRefer);\n      if (onlyAndRefer.count() > 0 && !onlyAndRefer.contains(name)) {\n        continue;\n      }\n      o = ns.getMapping(name);\n    }\n    if (o != null && o instanceof Var) {\n      return o;\n    }\n  }\n  return null;\n}\n\npublic Var findInternedVar(Symbol symbol){\n\tObject o = getMapping(symbol);\n\tif(o != null && o instanceof Var && ((Var) o).ns == this)\n\t\treturn (Var) o;\n\tif (!ObjC.objc) {\n\t  return Var.maybeLoadFromClass(name.toString(), symbol.toString());\n\t} else {\n\t  return null;\n\t}\n}\n\n\npublic IPersistentMap getAliases(){\n\treturn aliases.get();\n}\n\npublic Namespace lookupAlias(Symbol alias){\n\tIPersistentMap map = getAliases();\n\treturn (Namespace) map.valAt(alias);\n}\n\npublic void addAlias(Symbol alias, Namespace ns){\n\tif (alias == null || ns == null)\n\t\tthrow new NullPointerException(\"Expecting Symbol + Namespace\");\n\tIPersistentMap map = getAliases();\n\twhile(!map.containsKey(alias))\n\t\t{\n\t\tIPersistentMap newMap = map.assoc(alias, ns);\n\t\taliases.compareAndSet(map, newMap);\n\t\tmap = getAliases();\n\t\t}\n\t// you can rebind an alias, but only to the initially-aliased namespace.\n\tif(!map.valAt(alias).equals(ns))\n\t\tthrow new IllegalStateException(\"Alias \" + alias + \" already exists in namespace \"\n\t\t                                   + name + \", aliasing \" + map.valAt(alias));\n}\n\npublic void removeAlias(Symbol alias) {\n\tIPersistentMap map = getAliases();\n\twhile(map.containsKey(alias))\n\t\t{\n\t\tIPersistentMap newMap = map.without(alias);\n\t\taliases.compareAndSet(map, newMap);\n\t\tmap = getAliases();\n\t\t}\n}\n\nprivate Object readResolve() throws ObjectStreamException {\n    // ensures that serialized namespaces are \"deserialized\" to the\n    // namespace in the present runtime\n    return findOrCreate(name);\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Numbers.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 31, 2008 */\n\npackage clojure.lang;\n\nimport java.math.BigInteger;\nimport java.math.BigDecimal;\nimport java.math.MathContext;\n\npublic class Numbers{\n\nstatic interface Ops{\n\tOps combine(Ops y);\n\n\tOps opsWith(LongOps x);\n\n\tOps opsWith(DoubleOps x);\n\n\tOps opsWith(RatioOps x);\n\n\tOps opsWith(BigIntOps x);\n\n\tOps opsWith(BigDecimalOps x);\n\n\tpublic boolean isZero(Number x);\n\n\tpublic boolean isPos(Number x);\n\n\tpublic boolean isNeg(Number x);\n\n\tpublic Number add(Number x, Number y);\n\tpublic Number addP(Number x, Number y);\n\n\tpublic Number multiply(Number x, Number y);\n\tpublic Number multiplyP(Number x, Number y);\n\n\tpublic Number divide(Number x, Number y);\n\n\tpublic Number quotient(Number x, Number y);\n\n\tpublic Number remainder(Number x, Number y);\n\n\tpublic boolean equiv(Number x, Number y);\n\n\tpublic boolean lt(Number x, Number y);\n\tpublic boolean lte(Number x, Number y);\n\tpublic boolean gte(Number x, Number y);\n\n\tpublic Number negate(Number x);\n\tpublic Number negateP(Number x);\n\n\tpublic Number inc(Number x);\n\tpublic Number incP(Number x);\n\n\tpublic Number dec(Number x);\n\tpublic Number decP(Number x);\n}\n\nstatic abstract class OpsP implements Ops{\n\tpublic Number addP(Number x, Number y){\n\t\treturn add(x, y);\n\t}\n\n\tpublic Number multiplyP(Number x, Number y){\n\t\treturn multiply(x, y);\n\t}\n\n\tpublic Number negateP(Number x){\n\t\treturn negate(x);\n\t}\n\n\tpublic Number incP(Number x){\n\t\treturn inc(x);\n\t}\n\n\tpublic Number decP(Number x){\n\t\treturn dec(x);\n\t}\n\n}\n\nstatic public boolean isZero(Object x){\n\treturn ops(x).isZero((Number)x);\n}\n\nstatic public boolean isPos(Object x){\n\treturn ops(x).isPos((Number)x);\n}\n\nstatic public boolean isNeg(Object x){\n\treturn ops(x).isNeg((Number)x);\n}\n\nstatic public Number minus(Object x){\n\treturn ops(x).negate((Number)x);\n}\n\nstatic public Number minusP(Object x){\n\treturn ops(x).negateP((Number)x);\n}\n\nstatic public Number inc(Object x){\n\treturn ops(x).inc((Number)x);\n}\n\nstatic public Number incP(Object x){\n\treturn ops(x).incP((Number)x);\n}\n\nstatic public Number dec(Object x){\n\treturn ops(x).dec((Number)x);\n}\n\nstatic public Number decP(Object x){\n\treturn ops(x).decP((Number)x);\n}\n\nstatic public Number add(Object x, Object y){\n\treturn ops(x).combine(ops(y)).add((Number)x, (Number)y);\n}\n\nstatic public Number addP(Object x, Object y){\n\treturn ops(x).combine(ops(y)).addP((Number)x, (Number)y);\n}\n\nstatic public Number minus(Object x, Object y){\n\tOps yops = ops(y);\n\treturn ops(x).combine(yops).add((Number)x, yops.negate((Number)y));\n}\n\nstatic public Number minusP(Object x, Object y){\n\tOps yops = ops(y);\n\tNumber negativeY = yops.negateP((Number) y);\n\tOps negativeYOps = ops(negativeY);\n\treturn ops(x).combine(negativeYOps).addP((Number)x, negativeY);\n}\n\nstatic public Number multiply(Object x, Object y){\n\treturn ops(x).combine(ops(y)).multiply((Number)x, (Number)y);\n}\n\nstatic public Number multiplyP(Object x, Object y){\n\treturn ops(x).combine(ops(y)).multiplyP((Number)x, (Number)y);\n}\n\nstatic public Number divide(Object x, Object y){\n\tOps yops = ops(y);\n\tif(yops.isZero((Number)y))\n\t\tthrow new ArithmeticException(\"Divide by zero\");\n\treturn ops(x).combine(yops).divide((Number)x, (Number)y);\n}\n\nstatic public Number quotient(Object x, Object y){\n\tOps yops = ops(y);\n\tif(yops.isZero((Number) y))\n\t\tthrow new ArithmeticException(\"Divide by zero\");\n\treturn ops(x).combine(yops).quotient((Number)x, (Number)y);\n}\n\nstatic public Number remainder(Object x, Object y){\n\tOps yops = ops(y);\n\tif(yops.isZero((Number) y))\n\t\tthrow new ArithmeticException(\"Divide by zero\");\n\treturn ops(x).combine(yops).remainder((Number)x, (Number)y);\n}\n\nstatic public double quotient(double n, double d){\n\tif(d == 0)\n\t\tthrow new ArithmeticException(\"Divide by zero\");\n\n\tdouble q = n / d;\n\tif(q <= Long.MAX_VALUE && q >= Long.MIN_VALUE)\n\t\t{\n\t\treturn (double)(long) q;\n\t\t}\n\telse\n\t\t{ //bigint quotient\n\t\treturn new BigDecimal(q).toBigInteger().doubleValue();\n\t\t}\n}\n\nstatic public double remainder(double n, double d){\n\tif(d == 0)\n\t\tthrow new ArithmeticException(\"Divide by zero\");\n\n\tdouble q = n / d;\n\tif(q <= Long.MAX_VALUE && q >= Long.MIN_VALUE)\n\t\t{\n\t\treturn (n - ((long) q) * d);\n\t\t}\n\telse\n\t\t{ //bigint quotient\n\t\tNumber bq = new BigDecimal(q).toBigInteger();\n\t\treturn (n - bq.doubleValue() * d);\n\t\t}\n}\n\nstatic public boolean equiv(Object x, Object y){\n\treturn equiv((Number) x, (Number) y);\n}\n\nstatic public boolean equiv(Number x, Number y){\n\treturn ops(x).combine(ops(y)).equiv(x, y);\n}\n\nstatic public boolean equal(Number x, Number y){\n\treturn category(x) == category(y)\n\t\t\t&& ops(x).combine(ops(y)).equiv(x, y);\n}\n\nstatic public boolean lt(Object x, Object y){\n\treturn ops(x).combine(ops(y)).lt((Number)x, (Number)y);\n}\n\nstatic public boolean lte(Object x, Object y){\n\treturn ops(x).combine(ops(y)).lte((Number)x, (Number)y);\n}\n\nstatic public boolean gt(Object x, Object y){\n\treturn ops(x).combine(ops(y)).lt((Number)y, (Number)x);\n}\n\nstatic public boolean gte(Object x, Object y){\n\treturn ops(x).combine(ops(y)).gte((Number)x, (Number)y);\n}\n\nstatic public int compare(Number x, Number y){\n\tOps ops = ops(x).combine(ops(y));\n\tif(ops.lt(x, y))\n\t\treturn -1;\n\telse if(ops.lt(y, x))\n\t\treturn 1;\n\treturn 0;\n}\n\n@WarnBoxedMath(false)\nstatic BigInt toBigInt(Object x){\n\tif(x instanceof BigInt)\n\t\treturn (BigInt) x;\n\tif(x instanceof BigInteger)\n\t\treturn BigInt.fromBigInteger((BigInteger) x);\n\telse\n\t\treturn BigInt.fromLong(((Number) x).longValue());\n}\n\n@WarnBoxedMath(false)\nstatic BigInteger toBigInteger(Object x){\n\tif(x instanceof BigInteger)\n\t\treturn (BigInteger) x;\n\telse if(x instanceof BigInt)\n\t\treturn ((BigInt) x).toBigInteger();\t\n\telse\n\t\treturn BigInteger.valueOf(((Number) x).longValue());\n}\n\n@WarnBoxedMath(false)\nstatic BigDecimal toBigDecimal(Object x){\n\tif(x instanceof BigDecimal)\n\t\treturn (BigDecimal) x;\n\telse if(x instanceof BigInt)\n\t\t{\n\t\tBigInt bi = (BigInt) x;\n\t\tif(bi.bipart == null)\n\t\t\treturn BigDecimal.valueOf(bi.lpart);\n\t\telse\n\t\t\treturn new BigDecimal(bi.bipart);\n\t\t}\n\telse if(x instanceof BigInteger)\n\t\treturn new BigDecimal((BigInteger) x);\n\telse if(x instanceof Double)\n\t\treturn new BigDecimal(((Number) x).doubleValue());\n\telse if(x instanceof Float)\n\t\treturn new BigDecimal(((Number) x).doubleValue());\n\telse if(x instanceof Ratio)\n\t\t{\n\t\tRatio r = (Ratio)x;\n\t\treturn (BigDecimal)divide(new BigDecimal(r.numerator), r.denominator);\n\t\t}\n\telse\n\t\treturn BigDecimal.valueOf(((Number) x).longValue());\n}\n\n@WarnBoxedMath(false)\nstatic public Ratio toRatio(Object x){\n\tif(x instanceof Ratio)\n\t\treturn (Ratio) x;\n\telse if(x instanceof BigDecimal)\n\t\t{\n\t\tBigDecimal bx = (BigDecimal) x;\n\t\tBigInteger bv = bx.unscaledValue();\n\t\tint scale = bx.scale();\n\t\tif(scale < 0)\n\t\t\treturn new Ratio(bv.multiply(BigInteger.TEN.pow(-scale)), BigInteger.ONE);\n\t\telse\n\t\t\treturn new Ratio(bv, BigInteger.TEN.pow(scale));\n\t\t}\n\treturn new Ratio(toBigInteger(x), BigInteger.ONE);\n}\n\n@WarnBoxedMath(false)\nstatic public Number rationalize(Number x){\n\tif(x instanceof Float || x instanceof Double)\n\t\treturn rationalize(BigDecimal.valueOf(x.doubleValue()));\n\telse if(x instanceof BigDecimal)\n\t\t{\n\t\tBigDecimal bx = (BigDecimal) x;\n\t\tBigInteger bv = bx.unscaledValue();\n\t\tint scale = bx.scale();\n\t\tif(scale < 0)\n\t\t\treturn BigInt.fromBigInteger(bv.multiply(BigInteger.TEN.pow(-scale)));\n\t\telse\n\t\t\treturn divide(bv, BigInteger.TEN.pow(scale));\n\t\t}\n\treturn x;\n}\n\n//static  Number box(int val){\n//\t\treturn Integer.valueOf(val);\n//}\n\n//static  Number box(long val){\n//\t\treturn Long.valueOf(val);\n//}\n//\n//static  Double box(double val){\n//\t\treturn Double.valueOf(val);\n//}\n//\n//static  Double box(float val){\n//\t\treturn Double.valueOf((double) val);\n//}\n\n@WarnBoxedMath(false)\nstatic public Number reduceBigInt(BigInt val){\n\tif(val.bipart == null)\n\t\treturn num(val.lpart);\n\telse\n\t\treturn val.bipart;\n}\n\nstatic public Number divide(BigInteger n, BigInteger d){\n\tif(d.equals(BigInteger.ZERO))\n\t\tthrow new ArithmeticException(\"Divide by zero\");\n\tBigInteger gcd = n.gcd(d);\n\tif(gcd.equals(BigInteger.ZERO))\n\t\treturn BigInt.ZERO;\n\tn = n.divide(gcd);\n\td = d.divide(gcd);\n\tif(d.equals(BigInteger.ONE))\n\t\treturn BigInt.fromBigInteger(n);\n\telse if(d.equals(BigInteger.ONE.negate()))\n\t\treturn BigInt.fromBigInteger(n.negate());\n\treturn new Ratio((d.signum() < 0 ? n.negate() : n),\n\t                 (d.signum() < 0 ? d.negate() : d));\n}\n\nstatic public int shiftLeftInt(int x, int n){\n\treturn x << n;\n}\n\nstatic public long shiftLeft(Object x, Object y){\n    return shiftLeft(bitOpsCast(x),bitOpsCast(y));\n}\nstatic public long shiftLeft(Object x, long y){\n    return shiftLeft(bitOpsCast(x),y);\n}\nstatic public long shiftLeft(long x, Object y){\n    return shiftLeft(x,bitOpsCast(y));\n}\nstatic public long shiftLeft(long x, long n){\n\treturn x << n;\n}\n\nstatic public int shiftRightInt(int x, int n){\n\treturn x >> n;\n}\n\nstatic public long shiftRight(Object x, Object y){\n    return shiftRight(bitOpsCast(x),bitOpsCast(y));\n}\nstatic public long shiftRight(Object x, long y){\n    return shiftRight(bitOpsCast(x),y);\n}\nstatic public long shiftRight(long x, Object y){\n    return shiftRight(x,bitOpsCast(y));\n}\nstatic public long shiftRight(long x, long n){\n\treturn x >> n;\n}\n\nstatic public int unsignedShiftRightInt(int x, int n){\n\treturn x >>> n;\n}\n\nstatic public long unsignedShiftRight(Object x, Object y){\n    return unsignedShiftRight(bitOpsCast(x),bitOpsCast(y));\n}\nstatic public long unsignedShiftRight(Object x, long y){\n    return unsignedShiftRight(bitOpsCast(x),y);\n}\nstatic public long unsignedShiftRight(long x, Object y){\n    return unsignedShiftRight(x,bitOpsCast(y));\n}\nstatic public long unsignedShiftRight(long x, long n){\n\treturn x >>> n;\n}\n\nfinal static class LongOps implements Ops{\n\tpublic Ops combine(Ops y){\n\t\treturn y.opsWith(this);\n\t}\n\n\tfinal public Ops opsWith(LongOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(DoubleOps x){\n\t\treturn DOUBLE_OPS;\n\t}\n\n\tfinal public Ops opsWith(RatioOps x){\n\t\treturn RATIO_OPS;\n\t}\n\n\tfinal public Ops opsWith(BigIntOps x){\n\t\treturn BIGINT_OPS;\n\t}\n\n\tfinal public Ops opsWith(BigDecimalOps x){\n\t\treturn BIGDECIMAL_OPS;\n\t}\n\n\tpublic boolean isZero(Number x){\n\t\treturn x.longValue() == 0;\n\t}\n\n\tpublic boolean isPos(Number x){\n\t\treturn x.longValue() > 0;\n\t}\n\n\tpublic boolean isNeg(Number x){\n\t\treturn x.longValue() < 0;\n\t}\n\n\tfinal public Number add(Number x, Number y){\n\t\treturn num(Numbers.add(x.longValue(),y.longValue()));\n\t}\n\n\tfinal public Number addP(Number x, Number y){\n\t\tlong lx = x.longValue(), ly = y.longValue();\n\t\tlong ret = lx + ly;\n\t\tif ((ret ^ lx) < 0 && (ret ^ ly) < 0)\n\t\t\treturn BIGINT_OPS.add(x, y);\n\t\treturn num(ret);\n\t}\n\n\tfinal public Number multiply(Number x, Number y){\n\t\treturn num(Numbers.multiply(x.longValue(), y.longValue()));\n\t}\n\n\tfinal public Number multiplyP(Number x, Number y){\n\t\tlong lx = x.longValue(), ly = y.longValue();\n    if (lx == Long.MIN_VALUE && ly < 0)\n      return BIGINT_OPS.multiply(x, y);\n\t\tlong ret = lx * ly;\n\t\tif (ly != 0 && ret/ly != lx)\n\t\t\treturn BIGINT_OPS.multiply(x, y);\n\t\treturn num(ret);\n\t}\n\tstatic long gcd(long u, long v){\n\t\twhile(v != 0)\n\t\t\t{\n\t\t\tlong r = u % v;\n\t\t\tu = v;\n\t\t\tv = r;\n\t\t\t}\n\t\treturn u;\n\t}\n\n\tpublic Number divide(Number x, Number y){\n\t\tlong n = x.longValue();\n\t\tlong val = y.longValue();\n\t\tlong gcd = gcd(n, val);\n\t\tif(gcd == 0)\n\t\t\treturn num(0);\n\n\t\tn = n / gcd;\n\t\tlong d = val / gcd;\n\t\tif(d == 1)\n\t\t\treturn num(n);\n\t\tif(d < 0)\n\t\t\t{\n\t\t\tn = -n;\n\t\t\td = -d;\n\t\t\t}\n\t\treturn new Ratio(BigInteger.valueOf(n), BigInteger.valueOf(d));\n\t}\n\n\tpublic Number quotient(Number x, Number y){\n\t\treturn num(x.longValue() / y.longValue());\n\t}\n\n\tpublic Number remainder(Number x, Number y){\n\t\treturn num(x.longValue() % y.longValue());\n\t}\n\n\tpublic boolean equiv(Number x, Number y){\n\t\treturn x.longValue() == y.longValue();\n\t}\n\n\tpublic boolean lt(Number x, Number y){\n\t\treturn x.longValue() < y.longValue();\n\t}\n\n\tpublic boolean lte(Number x, Number y){\n\t\treturn x.longValue() <= y.longValue();\n\t}\n\n\tpublic boolean gte(Number x, Number y){\n\t\treturn x.longValue() >= y.longValue();\n\t}\n\n\t//public Number subtract(Number x, Number y);\n\tfinal public Number negate(Number x){\n\t\tlong val = x.longValue();\n\t\treturn num(Numbers.minus(val));\n\t}\n\n\tfinal public Number negateP(Number x){\n\t\tlong val = x.longValue();\n\t\tif(val > Long.MIN_VALUE)\n\t\t\treturn num(-val);\n\t\treturn BigInt.fromBigInteger(BigInteger.valueOf(val).negate());\n\t}\n\tpublic Number inc(Number x){\n\t\tlong val = x.longValue();\n\t\treturn num(Numbers.inc(val));\n\t}\n\n\tpublic Number incP(Number x){\n\t\tlong val = x.longValue();\n\t\tif(val < Long.MAX_VALUE)\n\t\t\treturn num(val + 1);\n\t\treturn BIGINT_OPS.inc(x);\n\t}\n\n\tpublic Number dec(Number x){\n\t\tlong val = x.longValue();\n\t\treturn num(Numbers.dec(val));\n\t}\n\n\tpublic Number decP(Number x){\n\t\tlong val = x.longValue();\n\t\tif(val > Long.MIN_VALUE)\n\t\t\treturn num(val - 1);\n\t\treturn BIGINT_OPS.dec(x);\n\t}\n}\n\nfinal static class DoubleOps extends OpsP{\n\tpublic Ops combine(Ops y){\n\t\treturn y.opsWith(this);\n\t}\n\n\tfinal public Ops opsWith(LongOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(DoubleOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(RatioOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(BigIntOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(BigDecimalOps x){\n\t\treturn this;\n\t}\n\n\tpublic boolean isZero(Number x){\n\t\treturn x.doubleValue() == 0;\n\t}\n\n\tpublic boolean isPos(Number x){\n\t\treturn x.doubleValue() > 0;\n\t}\n\n\tpublic boolean isNeg(Number x){\n\t\treturn x.doubleValue() < 0;\n\t}\n\n\tfinal public Number add(Number x, Number y){\n\t\treturn Double.valueOf(x.doubleValue() + y.doubleValue());\n\t}\n\n\tfinal public Number multiply(Number x, Number y){\n\t\treturn Double.valueOf(x.doubleValue() * y.doubleValue());\n\t}\n\n\tpublic Number divide(Number x, Number y){\n\t\treturn Double.valueOf(x.doubleValue() / y.doubleValue());\n\t}\n\n\tpublic Number quotient(Number x, Number y){\n\t\treturn Numbers.quotient(x.doubleValue(), y.doubleValue());\n\t}\n\n\tpublic Number remainder(Number x, Number y){\n\t\treturn Numbers.remainder(x.doubleValue(), y.doubleValue());\n\t}\n\n\tpublic boolean equiv(Number x, Number y){\n\t\treturn x.doubleValue() == y.doubleValue();\n\t}\n\n\tpublic boolean lt(Number x, Number y){\n\t\treturn x.doubleValue() < y.doubleValue();\n\t}\n\n\tpublic boolean lte(Number x, Number y){\n\t\treturn x.doubleValue() <= y.doubleValue();\n\t}\n\n\tpublic boolean gte(Number x, Number y){\n\t\treturn x.doubleValue() >= y.doubleValue();\n\t}\n\n\t//public Number subtract(Number x, Number y);\n\tfinal public Number negate(Number x){\n\t\treturn Double.valueOf(-x.doubleValue());\n\t}\n\n\tpublic Number inc(Number x){\n\t\treturn Double.valueOf(x.doubleValue() + 1);\n\t}\n\n\tpublic Number dec(Number x){\n\t\treturn Double.valueOf(x.doubleValue() - 1);\n\t}\n}\n\nfinal static class RatioOps extends OpsP{\n\tpublic Ops combine(Ops y){\n\t\treturn y.opsWith(this);\n\t}\n\n\tfinal public Ops opsWith(LongOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(DoubleOps x){\n\t\treturn DOUBLE_OPS;\n\t}\n\n\tfinal public Ops opsWith(RatioOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(BigIntOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(BigDecimalOps x){\n\t\treturn BIGDECIMAL_OPS;\n\t}\n\n\tpublic boolean isZero(Number x){\n\t\tRatio r = (Ratio) x;\n\t\treturn r.numerator.signum() == 0;\n\t}\n\n\tpublic boolean isPos(Number x){\n\t\tRatio r = (Ratio) x;\n\t\treturn r.numerator.signum() > 0;\n\t}\n\n\tpublic boolean isNeg(Number x){\n\t\tRatio r = (Ratio) x;\n\t\treturn r.numerator.signum() < 0;\n\t}\n\n\tstatic Number normalizeRet(Number ret, Number x, Number y){\n//\t\tif(ret instanceof BigInteger && !(x instanceof BigInteger || y instanceof BigInteger))\n//\t\t\t{\n//\t\t\treturn reduceBigInt((BigInteger) ret);\n//\t\t\t}\n\t\treturn ret;\n\t}\n\n\tfinal public Number add(Number x, Number y){\n\t\tRatio rx = toRatio(x);\n\t\tRatio ry = toRatio(y);\n\t\tNumber ret = divide(ry.numerator.multiply(rx.denominator)\n\t\t\t\t.add(rx.numerator.multiply(ry.denominator))\n\t\t\t\t, ry.denominator.multiply(rx.denominator));\n\t\treturn normalizeRet(ret, x, y);\n\t}\n\n\tfinal public Number multiply(Number x, Number y){\n\t\tRatio rx = toRatio(x);\n\t\tRatio ry = toRatio(y);\n\t\tNumber ret = Numbers.divide(ry.numerator.multiply(rx.numerator)\n\t\t\t\t, ry.denominator.multiply(rx.denominator));\n\t\treturn normalizeRet(ret, x, y);\n\t}\n\n\tpublic Number divide(Number x, Number y){\n\t\tRatio rx = toRatio(x);\n\t\tRatio ry = toRatio(y);\n\t\tNumber ret = Numbers.divide(ry.denominator.multiply(rx.numerator)\n\t\t\t\t, ry.numerator.multiply(rx.denominator));\n\t\treturn normalizeRet(ret, x, y);\n\t}\n\n\tpublic Number quotient(Number x, Number y){\n\t\tRatio rx = toRatio(x);\n\t\tRatio ry = toRatio(y);\n\t\tBigInteger q = rx.numerator.multiply(ry.denominator).divide(\n\t\t\t\trx.denominator.multiply(ry.numerator));\n\t\treturn normalizeRet(BigInt.fromBigInteger(q), x, y);\n\t}\n\n\tpublic Number remainder(Number x, Number y){\n\t\tRatio rx = toRatio(x);\n\t\tRatio ry = toRatio(y);\n\t\tBigInteger q = rx.numerator.multiply(ry.denominator).divide(\n\t\t\t\trx.denominator.multiply(ry.numerator));\n\t\tNumber ret = Numbers.minus(x, Numbers.multiply(q, y));\n\t\treturn normalizeRet(ret, x, y);\n\t}\n\n\tpublic boolean equiv(Number x, Number y){\n\t\tRatio rx = toRatio(x);\n\t\tRatio ry = toRatio(y);\n\t\treturn rx.numerator.equals(ry.numerator)\n\t\t       && rx.denominator.equals(ry.denominator);\n\t}\n\n\tpublic boolean lt(Number x, Number y){\n\t\tRatio rx = toRatio(x);\n\t\tRatio ry = toRatio(y);\n\t\treturn Numbers.lt(rx.numerator.multiply(ry.denominator), ry.numerator.multiply(rx.denominator));\n\t}\n\n\tpublic boolean lte(Number x, Number y){\n\t\tRatio rx = toRatio(x);\n\t\tRatio ry = toRatio(y);\n\t\treturn Numbers.lte(rx.numerator.multiply(ry.denominator), ry.numerator.multiply(rx.denominator));\n\t}\n\n\tpublic boolean gte(Number x, Number y){\n\t\tRatio rx = toRatio(x);\n\t\tRatio ry = toRatio(y);\n\t\treturn Numbers.gte(rx.numerator.multiply(ry.denominator), ry.numerator.multiply(rx.denominator));\n\t}\n\n\t//public Number subtract(Number x, Number y);\n\tfinal public Number negate(Number x){\n\t\tRatio r = (Ratio) x;\n\t\treturn new Ratio(r.numerator.negate(), r.denominator);\n\t}\n\n\tpublic Number inc(Number x){\n\t\treturn Numbers.add(x, 1);\n\t}\n\n\tpublic Number dec(Number x){\n\t\treturn Numbers.add(x, -1);\n\t}\n\n}\n\nfinal static class BigIntOps extends OpsP{\n\tpublic Ops combine(Ops y){\n\t\treturn y.opsWith(this);\n\t}\n\n\tfinal public Ops opsWith(LongOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(DoubleOps x){\n\t\treturn DOUBLE_OPS;\n\t}\n\n\tfinal public Ops opsWith(RatioOps x){\n\t\treturn RATIO_OPS;\n\t}\n\n\tfinal public Ops opsWith(BigIntOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(BigDecimalOps x){\n\t\treturn BIGDECIMAL_OPS;\n\t}\n\n\tpublic boolean isZero(Number x){\n\t\tBigInt bx = toBigInt(x);\n\t\tif(bx.bipart == null)\n\t\t\treturn bx.lpart == 0;\n\t\treturn bx.bipart.signum() == 0;\n\t}\n\n\tpublic boolean isPos(Number x){\n\t\tBigInt bx = toBigInt(x);\n\t\tif(bx.bipart == null)\n\t\t\treturn bx.lpart > 0;\n\t\treturn bx.bipart.signum() > 0;\n\t}\n\n\tpublic boolean isNeg(Number x){\n\t\tBigInt bx = toBigInt(x);\n\t\tif(bx.bipart == null)\n\t\t\treturn bx.lpart < 0;\n\t\treturn bx.bipart.signum() < 0;\n\t}\n\n\tfinal public Number add(Number x, Number y){\n        return toBigInt(x).add(toBigInt(y));\n\t}\n\n\tfinal public Number multiply(Number x, Number y){\n        return toBigInt(x).multiply(toBigInt(y));\n\t}\n\n\tpublic Number divide(Number x, Number y){\n\t\treturn Numbers.divide(toBigInteger(x), toBigInteger(y));\n\t}\n\n\tpublic Number quotient(Number x, Number y){\n        return toBigInt(x).quotient(toBigInt(y));\n\t}\n\n\tpublic Number remainder(Number x, Number y){\n        return toBigInt(x).remainder(toBigInt(y));\n\t}\n\n\tpublic boolean equiv(Number x, Number y){\n\t\treturn toBigInt(x).equals(toBigInt(y));\n\t}\n\n\tpublic boolean lt(Number x, Number y){\n        return toBigInt(x).lt(toBigInt(y));\n\t}\n\n\tpublic boolean lte(Number x, Number y){\n\t\treturn toBigInteger(x).compareTo(toBigInteger(y)) <= 0;\n\t}\n\n\tpublic boolean gte(Number x, Number y){\n\t\treturn toBigInteger(x).compareTo(toBigInteger(y)) >= 0;\n\t}\n\n\t//public Number subtract(Number x, Number y);\n\tfinal public Number negate(Number x){\n\t\treturn BigInt.fromBigInteger(toBigInteger(x).negate());\n\t}\n\n\tpublic Number inc(Number x){\n\t\tBigInteger bx = toBigInteger(x);\n\t\treturn BigInt.fromBigInteger(bx.add(BigInteger.ONE));\n\t}\n\n\tpublic Number dec(Number x){\n\t\tBigInteger bx = toBigInteger(x);\n\t\treturn BigInt.fromBigInteger(bx.subtract(BigInteger.ONE));\n\t}\n}\n\n\nfinal static class BigDecimalOps extends OpsP{\n\tfinal static Var MATH_CONTEXT = RT.MATH_CONTEXT;\n\n\tpublic Ops combine(Ops y){\n\t\treturn y.opsWith(this);\n\t}\n\n\tfinal public Ops opsWith(LongOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(DoubleOps x){\n\t\treturn DOUBLE_OPS;\n\t}\n\n\tfinal public Ops opsWith(RatioOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(BigIntOps x){\n\t\treturn this;\n\t}\n\n\tfinal public Ops opsWith(BigDecimalOps x){\n\t\treturn this;\n\t}\n\n\tpublic boolean isZero(Number x){\n\t\tBigDecimal bx = (BigDecimal) x;\n\t\treturn bx.signum() == 0;\n\t}\n\n\tpublic boolean isPos(Number x){\n\t\tBigDecimal bx = (BigDecimal) x;\n\t\treturn bx.signum() > 0;\n\t}\n\n\tpublic boolean isNeg(Number x){\n\t\tBigDecimal bx = (BigDecimal) x;\n\t\treturn bx.signum() < 0;\n\t}\n\n\tfinal public Number add(Number x, Number y){\n\t\tMathContext mc = (MathContext) MATH_CONTEXT.deref();\n\t\treturn mc == null\n\t\t       ? toBigDecimal(x).add(toBigDecimal(y))\n\t\t       : toBigDecimal(x).add(toBigDecimal(y), mc);\n\t}\n\n\tfinal public Number multiply(Number x, Number y){\n\t\tMathContext mc = (MathContext) MATH_CONTEXT.deref();\n\t\treturn mc == null\n\t\t       ? toBigDecimal(x).multiply(toBigDecimal(y))\n\t\t       : toBigDecimal(x).multiply(toBigDecimal(y), mc);\n\t}\n\n\tpublic Number divide(Number x, Number y){\n\t\tMathContext mc = (MathContext) MATH_CONTEXT.deref();\n\t\treturn mc == null\n\t\t       ? toBigDecimal(x).divide(toBigDecimal(y))\n\t\t       : toBigDecimal(x).divide(toBigDecimal(y), mc);\n\t}\n\n\tpublic Number quotient(Number x, Number y){\n\t\tMathContext mc = (MathContext) MATH_CONTEXT.deref();\n\t\treturn mc == null\n\t\t       ? toBigDecimal(x).divideToIntegralValue(toBigDecimal(y))\n\t\t       : toBigDecimal(x).divideToIntegralValue(toBigDecimal(y), mc);\n\t}\n\n\tpublic Number remainder(Number x, Number y){\n\t\tMathContext mc = (MathContext) MATH_CONTEXT.deref();\n\t\treturn mc == null\n\t\t       ? toBigDecimal(x).remainder(toBigDecimal(y))\n\t\t       : toBigDecimal(x).remainder(toBigDecimal(y), mc);\n\t}\n\n\tpublic boolean equiv(Number x, Number y){\n\t\treturn toBigDecimal(x).compareTo(toBigDecimal(y)) == 0;\n\t}\n\n\tpublic boolean lt(Number x, Number y){\n\t\treturn toBigDecimal(x).compareTo(toBigDecimal(y)) < 0;\n\t}\n\n\tpublic boolean lte(Number x, Number y){\n\t\treturn toBigDecimal(x).compareTo(toBigDecimal(y)) <= 0;\n\t}\n\n\tpublic boolean gte(Number x, Number y){\n\t\treturn toBigDecimal(x).compareTo(toBigDecimal(y)) >= 0;\n\t}\n\n\t//public Number subtract(Number x, Number y);\n\tfinal public Number negate(Number x){\n\t\tMathContext mc = (MathContext) MATH_CONTEXT.deref();\n\t\treturn mc == null\n\t\t       ? ((BigDecimal) x).negate()\n\t\t       : ((BigDecimal) x).negate(mc);\n\t}\n\n\tpublic Number inc(Number x){\n\t\tMathContext mc = (MathContext) MATH_CONTEXT.deref();\n\t\tBigDecimal bx = (BigDecimal) x;\n\t\treturn mc == null\n\t\t       ? bx.add(BigDecimal.ONE)\n\t\t       : bx.add(BigDecimal.ONE, mc);\n\t}\n\n\tpublic Number dec(Number x){\n\t\tMathContext mc = (MathContext) MATH_CONTEXT.deref();\n\t\tBigDecimal bx = (BigDecimal) x;\n\t\treturn mc == null\n\t\t       ? bx.subtract(BigDecimal.ONE)\n\t\t       : bx.subtract(BigDecimal.ONE, mc);\n\t}\n}\n\nstatic final LongOps LONG_OPS = new LongOps();\nstatic final DoubleOps DOUBLE_OPS = new DoubleOps();\nstatic final RatioOps RATIO_OPS = new RatioOps();\nstatic final BigIntOps BIGINT_OPS = new BigIntOps();\nstatic final BigDecimalOps BIGDECIMAL_OPS = new BigDecimalOps();\n\nstatic public enum Category {INTEGER, FLOATING, DECIMAL, RATIO};\n\nstatic Ops ops(Object x){\n\tClass xc = x.getClass();\n\n\tif(xc == Long.class)\n\t\treturn LONG_OPS;\n\telse if(xc == Double.class)\n\t\treturn DOUBLE_OPS;\n\telse if(xc == Integer.class)\n\t\treturn LONG_OPS;\n\telse if(xc == Float.class)\n\t\treturn DOUBLE_OPS;\n\telse if(xc == BigInt.class)\n\t\treturn BIGINT_OPS;\n\telse if(xc == BigInteger.class)\n\t\treturn BIGINT_OPS;\n\telse if(xc == Ratio.class)\n\t\treturn RATIO_OPS;\n\telse if(xc == BigDecimal.class)\n\t\treturn BIGDECIMAL_OPS;\n\telse\n\t\treturn LONG_OPS;\n}\n\n@WarnBoxedMath(false)\nstatic int hasheq(Number x){\n\tClass xc = x.getClass();\n\n\tif(xc == Long.class\n\t\t|| xc == Integer.class\n\t\t|| xc == Short.class\n\t\t|| xc == Byte.class\n\t\t|| (xc == BigInteger.class && lte(x, Long.MAX_VALUE) && gte(x,Long.MIN_VALUE)))\n\t\t{\n\t\tlong lpart = x.longValue();\n\t\treturn Murmur3.hashLong(lpart);\n\t\t//return (int) (lpart ^ (lpart >>> 32));\n\t\t}\n\tif(xc == BigDecimal.class)\n\t\t{\n\t\t// stripTrailingZeros() to make all numerically equal\n\t\t// BigDecimal values come out the same before calling\n\t\t// hashCode.  Special check for 0 because\n\t\t// stripTrailingZeros() does not do anything to values\n\t\t// equal to 0 with different scales.\n\t\tif (isZero(x))\n\t\t\treturn Util.hash(BigDecimal.ZERO);\n\t\telse\n\t\t\t{\n\t\t\tBigDecimal tmp = ((BigDecimal) x).stripTrailingZeros();\n\t\t\treturn Util.hash(tmp);\n\t\t\t}\n\t\t}\n\treturn Util.hash(x);\n}\n\nstatic Category category(Object x){\n\tClass xc = x.getClass();\n\n\tif(xc == Integer.class)\n\t\treturn Category.INTEGER;\n\telse if(xc == Double.class)\n\t\treturn Category.FLOATING;\n\telse if(xc == Long.class)\n\t\treturn Category.INTEGER;\n\telse if(xc == Float.class)\n\t\treturn Category.FLOATING;\n\telse if(xc == BigInt.class)\n\t\treturn Category.INTEGER;\n\telse if(xc == Ratio.class)\n\t\treturn Category.RATIO;\n\telse if(xc == BigDecimal.class)\n\t\treturn Category.DECIMAL;\n\telse\n\t\treturn Category.INTEGER;\n}\n\nstatic long bitOpsCast(Object x){\n\tClass xc = x.getClass();\n\n\tif(xc == Long.class\n\t        || xc == Integer.class\n\t        || xc == Short.class\n\t        || xc == Byte.class)\n\t\treturn RT.longCast(x);\n\t// no bignums, no decimals\n\tthrow new IllegalArgumentException(\"bit operation not supported for: \" + xc);\n}\n\n\t@WarnBoxedMath(false)\n\tstatic public float[] float_array(int size, Object init){\n\t\tfloat[] ret = new float[size];\n\t\tif(init instanceof Number)\n\t\t\t{\n\t\t\tfloat f = ((Number) init).floatValue();\n\t\t\tfor(int i = 0; i < ret.length; i++)\n\t\t\t\tret[i] = f;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tISeq s = RT.seq(init);\n\t\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\t\tret[i] = ((Number) s.first()).floatValue();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\t@WarnBoxedMath(false)\n\tstatic public float[] float_array(Object sizeOrSeq){\n\t\tif(sizeOrSeq instanceof Number)\n\t\t\treturn new float[((Number) sizeOrSeq).intValue()];\n\t\telse\n\t\t\t{\n\t\t\tISeq s = RT.seq(sizeOrSeq);\n\t\t\tint size = RT.count(s);\n\t\t\tfloat[] ret = new float[size];\n\t\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\t\tret[i] = ((Number) s.first()).floatValue();\n\t\t\treturn ret;\n\t\t\t}\n\t}\n\n@WarnBoxedMath(false)\nstatic public double[] double_array(int size, Object init){\n\tdouble[] ret = new double[size];\n\tif(init instanceof Number)\n\t\t{\n\t\tdouble f = ((Number) init).doubleValue();\n\t\tfor(int i = 0; i < ret.length; i++)\n\t\t\tret[i] = f;\n\t\t}\n\telse\n\t\t{\n\t\tISeq s = RT.seq(init);\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = ((Number) s.first()).doubleValue();\n\t\t}\n\treturn ret;\n}\n\n@WarnBoxedMath(false)\nstatic public double[] double_array(Object sizeOrSeq){\n\tif(sizeOrSeq instanceof Number)\n\t\treturn new double[((Number) sizeOrSeq).intValue()];\n\telse\n\t\t{\n\t\tISeq s = RT.seq(sizeOrSeq);\n\t\tint size = RT.count(s);\n\t\tdouble[] ret = new double[size];\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = ((Number) s.first()).doubleValue();\n\t\treturn ret;\n\t\t}\n}\n\n@WarnBoxedMath(false)\nstatic public int[] int_array(int size, Object init){\n\tint[] ret = new int[size];\n\tif(init instanceof Number)\n\t\t{\n\t\tint f = ((Number) init).intValue();\n\t\tfor(int i = 0; i < ret.length; i++)\n\t\t\tret[i] = f;\n\t\t}\n\telse\n\t\t{\n\t\tISeq s = RT.seq(init);\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = ((Number) s.first()).intValue();\n\t\t}\n\treturn ret;\n}\n\n@WarnBoxedMath(false)\nstatic public int[] int_array(Object sizeOrSeq){\n\tif(sizeOrSeq instanceof Number)\n\t\treturn new int[((Number) sizeOrSeq).intValue()];\n\telse\n\t\t{\n\t\tISeq s = RT.seq(sizeOrSeq);\n\t\tint size = RT.count(s);\n\t\tint[] ret = new int[size];\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = ((Number) s.first()).intValue();\n\t\treturn ret;\n\t\t}\n}\n\n@WarnBoxedMath(false)\nstatic public long[] long_array(int size, Object init){\n\tlong[] ret = new long[size];\n\tif(init instanceof Number)\n\t\t{\n\t\tlong f = ((Number) init).longValue();\n\t\tfor(int i = 0; i < ret.length; i++)\n\t\t\tret[i] = f;\n\t\t}\n\telse\n\t\t{\n\t\tISeq s = RT.seq(init);\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = ((Number) s.first()).longValue();\n\t\t}\n\treturn ret;\n}\n\n@WarnBoxedMath(false)\nstatic public long[] long_array(Object sizeOrSeq){\n\tif(sizeOrSeq instanceof Number)\n\t\treturn new long[((Number) sizeOrSeq).intValue()];\n\telse\n\t\t{\n\t\tISeq s = RT.seq(sizeOrSeq);\n\t\tint size = RT.count(s);\n\t\tlong[] ret = new long[size];\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = ((Number) s.first()).longValue();\n\t\treturn ret;\n\t\t}\n}\n\n@WarnBoxedMath(false)\nstatic public short[] short_array(int size, Object init){\n\tshort[] ret = new short[size];\n\tif(init instanceof Short)\n\t\t{\n\t\tshort s = (Short) init;\n\t\tfor(int i = 0; i < ret.length; i++)\n\t\t\tret[i] = s;\n\t\t}\n\telse\n\t\t{\n\t\tISeq s = RT.seq(init);\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = ((Number) s.first()).shortValue();\n\t\t}\n\treturn ret;\n}\n\n@WarnBoxedMath(false)\nstatic public short[] short_array(Object sizeOrSeq){\n\tif(sizeOrSeq instanceof Number)\n\t\treturn new short[((Number) sizeOrSeq).intValue()];\n\telse\n\t\t{\n\t\tISeq s = RT.seq(sizeOrSeq);\n\t\tint size = RT.count(s);\n\t\tshort[] ret = new short[size];\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = ((Number) s.first()).shortValue();\n\t\treturn ret;\n\t\t}\n}\n\n@WarnBoxedMath(false)\nstatic public char[] char_array(int size, Object init){\n\tchar[] ret = new char[size];\n\tif(init instanceof Character)\n\t\t{\n\t\tchar c = (Character) init;\n\t\tfor(int i = 0; i < ret.length; i++)\n\t\t\tret[i] = c;\n\t\t}\n\telse\n\t\t{\n\t\tISeq s = RT.seq(init);\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = (Character) s.first();\n\t\t}\n\treturn ret;\n}\n\n@WarnBoxedMath(false)\nstatic public char[] char_array(Object sizeOrSeq){\n\tif(sizeOrSeq instanceof Number)\n\t\treturn new char[((Number) sizeOrSeq).intValue()];\n\telse\n\t\t{\n\t\tISeq s = RT.seq(sizeOrSeq);\n\t\tint size = RT.count(s);\n\t\tchar[] ret = new char[size];\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = (Character) s.first();\n\t\treturn ret;\n\t\t}\n}\n\n@WarnBoxedMath(false)\nstatic public byte[] byte_array(int size, Object init){\n\tbyte[] ret = new byte[size];\n\tif(init instanceof Byte)\n\t\t{\n\t\tbyte b = (Byte) init;\n\t\tfor(int i = 0; i < ret.length; i++)\n\t\t\tret[i] = b;\n\t\t}\n\telse\n\t\t{\n\t\tISeq s = RT.seq(init);\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = ((Number) s.first()).byteValue();\n\t\t}\n\treturn ret;\n}\n\n@WarnBoxedMath(false)\nstatic public byte[] byte_array(Object sizeOrSeq){\n\tif(sizeOrSeq instanceof Number)\n\t\treturn new byte[((Number) sizeOrSeq).intValue()];\n\telse\n\t\t{\n\t\tISeq s = RT.seq(sizeOrSeq);\n\t\tint size = RT.count(s);\n\t\tbyte[] ret = new byte[size];\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = ((Number) s.first()).byteValue();\n\t\treturn ret;\n\t\t}\n}\n\n@WarnBoxedMath(false)\nstatic public boolean[] boolean_array(int size, Object init){\n\tboolean[] ret = new boolean[size];\n\tif(init instanceof Boolean)\n\t\t{\n\t\tboolean b = (Boolean) init;\n\t\tfor(int i = 0; i < ret.length; i++)\n\t\t\tret[i] = b;\n\t\t}\n\telse\n\t\t{\n\t\tISeq s = RT.seq(init);\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = (Boolean)s.first();\n\t\t}\n\treturn ret;\n}\n\n@WarnBoxedMath(false)\nstatic public boolean[] boolean_array(Object sizeOrSeq){\n\tif(sizeOrSeq instanceof Number)\n\t\treturn new boolean[((Number) sizeOrSeq).intValue()];\n\telse\n\t\t{\n\t\tISeq s = RT.seq(sizeOrSeq);\n\t\tint size = RT.count(s);\n\t\tboolean[] ret = new boolean[size];\n\t\tfor(int i = 0; i < size && s != null; i++, s = s.next())\n\t\t\tret[i] = (Boolean)s.first();\n\t\treturn ret;\n\t\t}\n}\n\n@WarnBoxedMath(false)\nstatic public boolean[] booleans(Object array){\n\treturn (boolean[]) array;\n}\n\n@WarnBoxedMath(false)\nstatic public byte[] bytes(Object array){\n\treturn (byte[]) array;\n}\n\n@WarnBoxedMath(false)\nstatic public char[] chars(Object array){\n\treturn (char[]) array;\n}\n\n@WarnBoxedMath(false)\nstatic public short[] shorts(Object array){\n\treturn (short[]) array;\n}\n\n@WarnBoxedMath(false)\nstatic public float[] floats(Object array){\n\treturn (float[]) array;\n}\n\n@WarnBoxedMath(false)\nstatic public double[] doubles(Object array){\n\treturn (double[]) array;\n}\n\n@WarnBoxedMath(false)\nstatic public int[] ints(Object array){\n\treturn (int[]) array;\n}\n\n@WarnBoxedMath(false)\nstatic public long[] longs(Object array){\n\treturn (long[]) array;\n}\n\nstatic public Number num(Object x){\n\treturn (Number) x;\n}\n\nstatic public Number num(float x){\n\treturn Float.valueOf(x);\n}\n\nstatic public Number num(double x){\n\treturn Double.valueOf(x);\n}\n\nstatic public double add(double x, double y){\n\treturn x + y;\n}\n\nstatic public double addP(double x, double y){\n\treturn x + y;\n}\n\nstatic public double minus(double x, double y){\n\treturn x - y;\n}\n\nstatic public double minusP(double x, double y){\n\treturn x - y;\n}\n\nstatic public double minus(double x){\n\treturn -x;\n}\n\nstatic public double minusP(double x){\n\treturn -x;\n}\n\nstatic public double inc(double x){\n\treturn x + 1;\n}\n\nstatic public double incP(double x){\n\treturn x + 1;\n}\n\nstatic public double dec(double x){\n\treturn x - 1;\n}\n\nstatic public double decP(double x){\n\treturn x - 1;\n}\n\nstatic public double multiply(double x, double y){\n\treturn x * y;\n}\n\nstatic public double multiplyP(double x, double y){\n\treturn x * y;\n}\n\nstatic public double divide(double x, double y){\n\treturn x / y;\n}\n\nstatic public boolean equiv(double x, double y){\n\treturn x == y;\n}\n\nstatic public boolean lt(double x, double y){\n\treturn x < y;\n}\n\nstatic public boolean lte(double x, double y){\n\treturn x <= y;\n}\n\nstatic public boolean gt(double x, double y){\n\treturn x > y;\n}\n\nstatic public boolean gte(double x, double y){\n\treturn x >= y;\n}\n\nstatic public boolean isPos(double x){\n\treturn x > 0;\n}\n\nstatic public boolean isNeg(double x){\n\treturn x < 0;\n}\n\nstatic public boolean isZero(double x){\n\treturn x == 0;\n}\n\nstatic int throwIntOverflow(){\n\tthrow new ArithmeticException(\"integer overflow\");\n}\n\n//static public Number num(int x){\n//\treturn Integer.valueOf(x);\n//}\n\nstatic public int unchecked_int_add(int x, int y){\n\treturn x + y;\n}\n\nstatic public int unchecked_int_subtract(int x, int y){\n\treturn x - y;\n}\n\nstatic public int unchecked_int_negate(int x){\n\treturn -x;\n}\n\nstatic public int unchecked_int_inc(int x){\n\treturn x + 1;\n}\n\nstatic public int unchecked_int_dec(int x){\n\treturn x - 1;\n}\n\nstatic public int unchecked_int_multiply(int x, int y){\n\treturn x * y;\n}\n\n//static public int add(int x, int y){\n//\tint ret = x + y;\n//\tif ((ret ^ x) < 0 && (ret ^ y) < 0)\n//\t\treturn throwIntOverflow();\n//\treturn ret;\n//}\n\n//static public int not(int x){\n//\treturn ~x;\n//}\n\nstatic public long not(Object x){\n    return not(bitOpsCast(x));\n}\nstatic public long not(long x){\n\treturn ~x;\n}\n//static public int and(int x, int y){\n//\treturn x & y;\n//}\n\nstatic public long and(Object x, Object y){\n    return and(bitOpsCast(x),bitOpsCast(y));\n}\nstatic public long and(Object x, long y){\n    return and(bitOpsCast(x),y);\n}\nstatic public long and(long x, Object y){\n    return and(x,bitOpsCast(y));\n}\nstatic public long and(long x, long y){\n\treturn x & y;\n}\n\n//static public int or(int x, int y){\n//\treturn x | y;\n//}\n\nstatic public long or(Object x, Object y){\n    return or(bitOpsCast(x),bitOpsCast(y));\n}\nstatic public long or(Object x, long y){\n    return or(bitOpsCast(x),y);\n}\nstatic public long or(long x, Object y){\n    return or(x,bitOpsCast(y));\n}\nstatic public long or(long x, long y){\n    return x | y;\n}\n\n//static public int xor(int x, int y){\n//\treturn x ^ y;\n//}\n\nstatic public long xor(Object x, Object y){\n    return xor(bitOpsCast(x),bitOpsCast(y));\n}\nstatic public long xor(Object x, long y){\n    return xor(bitOpsCast(x),y);\n}\nstatic public long xor(long x, Object y){\n    return xor(x,bitOpsCast(y));\n}\nstatic public long xor(long x, long y){\n    return x ^ y;\n}\n\nstatic public long andNot(Object x, Object y){\n    return andNot(bitOpsCast(x),bitOpsCast(y));\n}\nstatic public long andNot(Object x, long y){\n    return andNot(bitOpsCast(x),y);\n}\nstatic public long andNot(long x, Object y){\n    return andNot(x,bitOpsCast(y));\n}\nstatic public long andNot(long x, long y){\n    return x & ~y;\n}\n\nstatic public long clearBit(Object x, Object y){\n    return clearBit(bitOpsCast(x),bitOpsCast(y));\n}\nstatic public long clearBit(Object x, long y){\n    return clearBit(bitOpsCast(x),y);\n}\nstatic public long clearBit(long x, Object y){\n    return clearBit(x,bitOpsCast(y));\n}\nstatic public long clearBit(long x, long n){\n    return x & ~(1L << n);\n}\n\nstatic public long setBit(Object x, Object y){\n    return setBit(bitOpsCast(x),bitOpsCast(y));\n}\nstatic public long setBit(Object x, long y){\n    return setBit(bitOpsCast(x),y);\n}\nstatic public long setBit(long x, Object y){\n    return setBit(x,bitOpsCast(y));\n}\nstatic public long setBit(long x, long n){\n    return x | (1L << n);\n}\n\nstatic public long flipBit(Object x, Object y){\n    return flipBit(bitOpsCast(x),bitOpsCast(y));\n}\nstatic public long flipBit(Object x, long y){\n    return flipBit(bitOpsCast(x),y);\n}\nstatic public long flipBit(long x, Object y){\n    return flipBit(x,bitOpsCast(y));\n}\nstatic public long flipBit(long x, long n){\n    return x ^ (1L << n);\n}\n\nstatic public boolean testBit(Object x, Object y){\n    return testBit(bitOpsCast(x),bitOpsCast(y));\n}\nstatic public boolean testBit(Object x, long y){\n    return testBit(bitOpsCast(x),y);\n}\nstatic public boolean testBit(long x, Object y){\n    return testBit(x,bitOpsCast(y));\n}\nstatic public boolean testBit(long x, long n){\n    return (x & (1L << n)) != 0;\n}\n\n//static public int minus(int x, int y){\n//\tint ret = x - y;\n//\tif (((ret ^ x) < 0 && (ret ^ ~y) < 0))\n//\t\treturn throwIntOverflow();\n//\treturn ret;\n//}\n\n//static public int minus(int x){\n//\tif(x == Integer.MIN_VALUE)\n//\t\treturn throwIntOverflow();\n//\treturn -x;\n//}\n\n//static public int inc(int x){\n//\tif(x == Integer.MAX_VALUE)\n//\t\treturn throwIntOverflow();\n//\treturn x + 1;\n//}\n\n//static public int dec(int x){\n//\tif(x == Integer.MIN_VALUE)\n//\t\treturn throwIntOverflow();\n//\treturn x - 1;\n//}\n\n//static public int multiply(int x, int y){\n//\tint ret = x * y;\n//\tif (y != 0 && ret/y != x)\n//\t\treturn throwIntOverflow();\n//\treturn ret;\n//}\n\nstatic public int unchecked_int_divide(int x, int y){\n\treturn x / y;\n}\n\nstatic public int unchecked_int_remainder(int x, int y){\n\treturn x % y;\n}\n\n//static public boolean equiv(int x, int y){\n//\treturn x == y;\n//}\n\n//static public boolean lt(int x, int y){\n//\treturn x < y;\n//}\n\n//static public boolean lte(int x, int y){\n//\treturn x <= y;\n//}\n\n//static public boolean gt(int x, int y){\n//\treturn x > y;\n//}\n\n//static public boolean gte(int x, int y){\n//\treturn x >= y;\n//}\n\n//static public boolean isPos(int x){\n//\treturn x > 0;\n//}\n\n//static public boolean isNeg(int x){\n//\treturn x < 0;\n//}\n\n//static public boolean isZero(int x){\n//\treturn x == 0;\n//}\n\nstatic public Number num(long x){\n\treturn Long.valueOf(x);\n}\n\nstatic public long unchecked_add(long x, long y){return x + y;}\nstatic public long unchecked_minus(long x, long y){return x - y;}\nstatic public long unchecked_multiply(long x, long y){return x * y;}\nstatic public long unchecked_minus(long x){return -x;}\nstatic public long unchecked_inc(long x){return x + 1;}\nstatic public long unchecked_dec(long x){return x - 1;}\n\nstatic public Number unchecked_add(Object x, Object y){return add(x,y);}\nstatic public Number unchecked_minus(Object x, Object y){return minus(x,y);}\nstatic public Number unchecked_multiply(Object x, Object y){return multiply(x,y);}\nstatic public Number unchecked_minus(Object x){return minus(x);}\nstatic public Number unchecked_inc(Object x){return inc(x);}\nstatic public Number unchecked_dec(Object x){return dec(x);}\n\nstatic public double unchecked_add(double x, double y){return add(x,y);}\nstatic public double unchecked_minus(double x, double y){return minus(x,y);}\nstatic public double unchecked_multiply(double x, double y){return multiply(x,y);}\nstatic public double unchecked_minus(double x){return minus(x);}\nstatic public double unchecked_inc(double x){return inc(x);}\nstatic public double unchecked_dec(double x){return dec(x);}\n\nstatic public double unchecked_add(double x, Object y){return add(x,y);}\nstatic public double unchecked_minus(double x, Object y){return minus(x,y);}\nstatic public double unchecked_multiply(double x, Object y){return multiply(x,y);}\nstatic public double unchecked_add(Object x, double y){return add(x,y);}\nstatic public double unchecked_minus(Object x, double y){return minus(x,y);}\nstatic public double unchecked_multiply(Object x, double y){return multiply(x,y);}\n\nstatic public double unchecked_add(double x, long y){return add(x,y);}\nstatic public double unchecked_minus(double x, long y){return minus(x,y);}\nstatic public double unchecked_multiply(double x, long y){return multiply(x,y);}\nstatic public double unchecked_add(long x, double y){return add(x,y);}\nstatic public double unchecked_minus(long x, double y){return minus(x,y);}\nstatic public double unchecked_multiply(long x, double y){return multiply(x,y);}\n\nstatic public Number unchecked_add(long x, Object y){return add(x,y);}\nstatic public Number unchecked_minus(long x, Object y){return minus(x,y);}\nstatic public Number unchecked_multiply(long x, Object y){return multiply(x,y);}\nstatic public Number unchecked_add(Object x, long y){return add(x,y);}\nstatic public Number unchecked_minus(Object x, long y){return minus(x,y);}\nstatic public Number unchecked_multiply(Object x, long y){return multiply(x,y);}\n\nstatic public Number quotient(double x, Object y){return quotient((Object)x,y);}\nstatic public Number quotient(Object x, double y){return quotient(x,(Object)y);}\nstatic public Number quotient(long x, Object y){return quotient((Object)x,y);}\nstatic public Number quotient(Object x, long y){return quotient(x,(Object)y);}\nstatic public double quotient(double x, long y){return quotient(x,(double)y);}\nstatic public double quotient(long x, double y){return quotient((double)x,y);}\n\nstatic public Number remainder(double x, Object y){return remainder((Object)x,y);}\nstatic public Number remainder(Object x, double y){return remainder(x,(Object)y);}\nstatic public Number remainder(long x, Object y){return remainder((Object)x,y);}\nstatic public Number remainder(Object x, long y){return remainder(x,(Object)y);}\nstatic public double remainder(double x, long y){return remainder(x,(double)y);}\nstatic public double remainder(long x, double y){return remainder((double)x,y);}\n\nstatic public long add(long x, long y){\n\tlong ret = x + y;\n\tif ((ret ^ x) < 0 && (ret ^ y) < 0)\n\t\treturn throwIntOverflow();\n\treturn ret;\n}\n\nstatic public Number addP(long x, long y){\n\tlong ret = x + y;\n\tif ((ret ^ x) < 0 && (ret ^ y) < 0)\n\t\treturn addP((Number)x,(Number)y);\n\treturn num(ret);\n}\n\nstatic public long minus(long x, long y){\n\tlong ret = x - y;\n\tif (((ret ^ x) < 0 && (ret ^ ~y) < 0))\n\t\treturn throwIntOverflow();\n\treturn ret;\n}\n\nstatic public Number minusP(long x, long y){\n\tlong ret = x - y;\n\tif (((ret ^ x) < 0 && (ret ^ ~y) < 0))\n\t\treturn minusP((Number)x,(Number)y);\n\treturn num(ret);\n}\n\nstatic public long minus(long x){\n\tif(x == Long.MIN_VALUE)\n\t\treturn throwIntOverflow();\n\treturn -x;\n}\n\nstatic public Number minusP(long x){\n\tif(x == Long.MIN_VALUE)\n\t\treturn BigInt.fromBigInteger(BigInteger.valueOf(x).negate());\n\treturn num(-x);\n}\n\nstatic public long inc(long x){\n\tif(x == Long.MAX_VALUE)\n\t\treturn throwIntOverflow();\n\treturn x + 1;\n}\n\nstatic public Number incP(long x){\n\tif(x == Long.MAX_VALUE)\n\t\treturn BIGINT_OPS.inc(x);\n\treturn num(x + 1);\n}\n\nstatic public long dec(long x){\n\tif(x == Long.MIN_VALUE)\n\t\treturn throwIntOverflow();\n\treturn x - 1;\n}\n\nstatic public Number decP(long x){\n\tif(x == Long.MIN_VALUE)\n\t\treturn BIGINT_OPS.dec(x);\n\treturn num(x - 1);\n}\n\n\nstatic public long multiply(long x, long y){\n  if (x == Long.MIN_VALUE && y < 0)\n\t\treturn throwIntOverflow();\n\tlong ret = x * y;\n\tif (y != 0 && ret/y != x)\n\t\treturn throwIntOverflow();\n\treturn ret;\n}\n\nstatic public Number multiplyP(long x, long y){\n  if (x == Long.MIN_VALUE && y < 0)\n\t\treturn multiplyP((Number)x,(Number)y);\n\tlong ret = x * y;\n\tif (y != 0 && ret/y != x)\n\t\treturn multiplyP((Number)x,(Number)y);\n\treturn num(ret);\n}\n\nstatic public long quotient(long x, long y){\n\treturn x / y;\n}\n\nstatic public long remainder(long x, long y){\n\treturn x % y;\n}\n\nstatic public boolean equiv(long x, long y){\n\treturn x == y;\n}\n\nstatic public boolean lt(long x, long y){\n\treturn x < y;\n}\n\nstatic public boolean lte(long x, long y){\n\treturn x <= y;\n}\n\nstatic public boolean gt(long x, long y){\n\treturn x > y;\n}\n\nstatic public boolean gte(long x, long y){\n\treturn x >= y;\n}\n\nstatic public boolean isPos(long x){\n\treturn x > 0;\n}\n\nstatic public boolean isNeg(long x){\n\treturn x < 0;\n}\n\nstatic public boolean isZero(long x){\n\treturn x == 0;\n}\n\n/*\nstatic public class F{\n\tstatic public float add(float x, float y){\n\t\treturn x + y;\n\t}\n\n\tstatic public float subtract(float x, float y){\n\t\treturn x - y;\n\t}\n\n\tstatic public float negate(float x){\n\t\treturn -x;\n\t}\n\n\tstatic public float inc(float x){\n\t\treturn x + 1;\n\t}\n\n\tstatic public float dec(float x){\n\t\treturn x - 1;\n\t}\n\n\tstatic public float multiply(float x, float y){\n\t\treturn x * y;\n\t}\n\n\tstatic public float divide(float x, float y){\n\t\treturn x / y;\n\t}\n\n\tstatic public boolean equiv(float x, float y){\n\t\treturn x == y;\n\t}\n\n\tstatic public boolean lt(float x, float y){\n\t\treturn x < y;\n\t}\n\n\tstatic public boolean lte(float x, float y){\n\t\treturn x <= y;\n\t}\n\n\tstatic public boolean gt(float x, float y){\n\t\treturn x > y;\n\t}\n\n\tstatic public boolean gte(float x, float y){\n\t\treturn x >= y;\n\t}\n\n\tstatic public boolean pos(float x){\n\t\treturn x > 0;\n\t}\n\n\tstatic public boolean neg(float x){\n\t\treturn x < 0;\n\t}\n\n\tstatic public boolean zero(float x){\n\t\treturn x == 0;\n\t}\n\n\tstatic public float aget(float[] xs, int i){\n\t\treturn xs[i];\n\t}\n\n\tstatic public float aset(float[] xs, int i, float v){\n\t\txs[i] = v;\n\t\treturn v;\n\t}\n\n\tstatic public int alength(float[] xs){\n\t\treturn xs.length;\n\t}\n\n\tstatic public float[] aclone(float[] xs){\n\t\treturn xs.clone();\n\t}\n\n\tstatic public float[] vec(int size, Object init){\n\t\tfloat[] ret = new float[size];\n\t\tif(init instanceof Number)\n\t\t\t{\n\t\t\tfloat f = ((Number) init).floatValue();\n\t\t\tfor(int i = 0; i < ret.length; i++)\n\t\t\t\tret[i] = f;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tISeq s = RT.seq(init);\n\t\t\tfor(int i = 0; i < size && s != null; i++, s = s.rest())\n\t\t\t\tret[i] = ((Number) s.first()).floatValue();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tstatic public float[] vec(Object sizeOrSeq){\n\t\tif(sizeOrSeq instanceof Number)\n\t\t\treturn new float[((Number) sizeOrSeq).intValue()];\n\t\telse\n\t\t\t{\n\t\t\tISeq s = RT.seq(sizeOrSeq);\n\t\t\tint size = s.count();\n\t\t\tfloat[] ret = new float[size];\n\t\t\tfor(int i = 0; i < size && s != null; i++, s = s.rest())\n\t\t\t\tret[i] = ((Number) s.first()).intValue();\n\t\t\treturn ret;\n\t\t\t}\n\t}\n\n\n\tstatic public float[] vsadd(float[] x, float y){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] += y;\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vssub(float[] x, float y){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] -= y;\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vsdiv(float[] x, float y){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] /= y;\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vsmul(float[] x, float y){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= y;\n\t\treturn xs;\n\t}\n\n\tstatic public float[] svdiv(float y, float[] x){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = y / xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vsmuladd(float[] x, float y, float[] zs){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y + zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vsmulsub(float[] x, float y, float[] zs){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y - zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vsmulsadd(float[] x, float y, float z){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y + z;\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vsmulssub(float[] x, float y, float z){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y - z;\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vabs(float[] x){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = Math.abs(xs[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vnegabs(float[] x){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = -Math.abs(xs[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vneg(float[] x){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = -xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vsqr(float[] x){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vsignedsqr(float[] x){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= Math.abs(xs[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vclip(float[] x, float low, float high){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\t{\n\t\t\tif(xs[i] < low)\n\t\t\t\txs[i] = low;\n\t\t\telse if(xs[i] > high)\n\t\t\t\txs[i] = high;\n\t\t\t}\n\t\treturn xs;\n\t}\n\n\tstatic public IPersistentVector vclipcounts(float[] x, float low, float high){\n\t\tfinal float[] xs = x.clone();\n\t\tint lowc = 0;\n\t\tint highc = 0;\n\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\t{\n\t\t\tif(xs[i] < low)\n\t\t\t\t{\n\t\t\t\t++lowc;\n\t\t\t\txs[i] = low;\n\t\t\t\t}\n\t\t\telse if(xs[i] > high)\n\t\t\t\t{\n\t\t\t\t++highc;\n\t\t\t\txs[i] = high;\n\t\t\t\t}\n\t\t\t}\n\t\treturn RT.vector(xs, lowc, highc);\n\t}\n\n\tstatic public float[] vthresh(float[] x, float thresh, float otherwise){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\t{\n\t\t\tif(xs[i] < thresh)\n\t\t\t\txs[i] = otherwise;\n\t\t\t}\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vreverse(float[] x){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[xs.length - i - 1];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vrunningsum(float[] x){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 1; i < xs.length; i++)\n\t\t\txs[i] = xs[i - 1] + xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vsort(float[] x){\n\t\tfinal float[] xs = x.clone();\n\t\tArrays.sort(xs);\n\t\treturn xs;\n\t}\n\n\tstatic public float vdot(float[] xs, float[] ys){\n\t\tfloat ret = 0;\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret += xs[i] * ys[i];\n\t\treturn ret;\n\t}\n\n\tstatic public float vmax(float[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\tfloat ret = xs[0];\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret = Math.max(ret, xs[i]);\n\t\treturn ret;\n\t}\n\n\tstatic public float vmin(float[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\tfloat ret = xs[0];\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret = Math.min(ret, xs[i]);\n\t\treturn ret;\n\t}\n\n\tstatic public float vmean(float[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\treturn vsum(xs) / xs.length;\n\t}\n\n\tstatic public double vrms(float[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\tfloat ret = 0;\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret += xs[i] * xs[i];\n\t\treturn Math.sqrt(ret / xs.length);\n\t}\n\n\tstatic public float vsum(float[] xs){\n\t\tfloat ret = 0;\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret += xs[i];\n\t\treturn ret;\n\t}\n\n\tstatic public boolean vequiv(float[] xs, float[] ys){\n\t\treturn Arrays.equals(xs, ys);\n\t}\n\n\tstatic public float[] vadd(float[] x, float[] ys){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] += ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vsub(float[] x, float[] ys){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] -= ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vaddmul(float[] x, float[] ys, float[] zs){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] + ys[i]) * zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vsubmul(float[] x, float[] ys, float[] zs){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] - ys[i]) * zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vaddsmul(float[] x, float[] ys, float z){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] + ys[i]) * z;\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vsubsmul(float[] x, float[] ys, float z){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] - ys[i]) * z;\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vmulsadd(float[] x, float[] ys, float z){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] * ys[i]) + z;\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vdiv(float[] x, float[] ys){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] /= ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vmul(float[] x, float[] ys){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vmuladd(float[] x, float[] ys, float[] zs){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] * ys[i]) + zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vmulsub(float[] x, float[] ys, float[] zs){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] * ys[i]) - zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vmax(float[] x, float[] ys){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = Math.max(xs[i], ys[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vmin(float[] x, float[] ys){\n\t\tfinal float[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = Math.min(xs[i], ys[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vmap(IFn fn, float[] x) {\n\t\tfloat[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = ((Number) fn.invoke(xs[i])).floatValue();\n\t\treturn xs;\n\t}\n\n\tstatic public float[] vmap(IFn fn, float[] x, float[] ys) {\n\t\tfloat[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = ((Number) fn.invoke(xs[i], ys[i])).floatValue();\n\t\treturn xs;\n\t}\n\n}\n\nstatic public class D{\n\tstatic public double add(double x, double y){\n\t\treturn x + y;\n\t}\n\n\tstatic public double subtract(double x, double y){\n\t\treturn x - y;\n\t}\n\n\tstatic public double negate(double x){\n\t\treturn -x;\n\t}\n\n\tstatic public double inc(double x){\n\t\treturn x + 1;\n\t}\n\n\tstatic public double dec(double x){\n\t\treturn x - 1;\n\t}\n\n\tstatic public double multiply(double x, double y){\n\t\treturn x * y;\n\t}\n\n\tstatic public double divide(double x, double y){\n\t\treturn x / y;\n\t}\n\n\tstatic public boolean equiv(double x, double y){\n\t\treturn x == y;\n\t}\n\n\tstatic public boolean lt(double x, double y){\n\t\treturn x < y;\n\t}\n\n\tstatic public boolean lte(double x, double y){\n\t\treturn x <= y;\n\t}\n\n\tstatic public boolean gt(double x, double y){\n\t\treturn x > y;\n\t}\n\n\tstatic public boolean gte(double x, double y){\n\t\treturn x >= y;\n\t}\n\n\tstatic public boolean pos(double x){\n\t\treturn x > 0;\n\t}\n\n\tstatic public boolean neg(double x){\n\t\treturn x < 0;\n\t}\n\n\tstatic public boolean zero(double x){\n\t\treturn x == 0;\n\t}\n\n\tstatic public double aget(double[] xs, int i){\n\t\treturn xs[i];\n\t}\n\n\tstatic public double aset(double[] xs, int i, double v){\n\t\txs[i] = v;\n\t\treturn v;\n\t}\n\n\tstatic public int alength(double[] xs){\n\t\treturn xs.length;\n\t}\n\n\tstatic public double[] aclone(double[] xs){\n\t\treturn xs.clone();\n\t}\n\n\tstatic public double[] vec(int size, Object init){\n\t\tdouble[] ret = new double[size];\n\t\tif(init instanceof Number)\n\t\t\t{\n\t\t\tdouble f = ((Number) init).doubleValue();\n\t\t\tfor(int i = 0; i < ret.length; i++)\n\t\t\t\tret[i] = f;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tISeq s = RT.seq(init);\n\t\t\tfor(int i = 0; i < size && s != null; i++, s = s.rest())\n\t\t\t\tret[i] = ((Number) s.first()).doubleValue();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tstatic public double[] vec(Object sizeOrSeq){\n\t\tif(sizeOrSeq instanceof Number)\n\t\t\treturn new double[((Number) sizeOrSeq).intValue()];\n\t\telse\n\t\t\t{\n\t\t\tISeq s = RT.seq(sizeOrSeq);\n\t\t\tint size = s.count();\n\t\t\tdouble[] ret = new double[size];\n\t\t\tfor(int i = 0; i < size && s != null; i++, s = s.rest())\n\t\t\t\tret[i] = ((Number) s.first()).intValue();\n\t\t\treturn ret;\n\t\t\t}\n\t}\n\n\tstatic public double[] vsadd(double[] x, double y){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] += y;\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vssub(double[] x, double y){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] -= y;\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vsdiv(double[] x, double y){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] /= y;\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vsmul(double[] x, double y){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= y;\n\t\treturn xs;\n\t}\n\n\tstatic public double[] svdiv(double y, double[] x){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = y / xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vsmuladd(double[] x, double y, double[] zs){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y + zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vsmulsub(double[] x, double y, double[] zs){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y - zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vsmulsadd(double[] x, double y, double z){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y + z;\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vsmulssub(double[] x, double y, double z){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y - z;\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vabs(double[] x){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = Math.abs(xs[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vnegabs(double[] x){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = -Math.abs(xs[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vneg(double[] x){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = -xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vsqr(double[] x){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vsignedsqr(double[] x){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= Math.abs(xs[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vclip(double[] x, double low, double high){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\t{\n\t\t\tif(xs[i] < low)\n\t\t\t\txs[i] = low;\n\t\t\telse if(xs[i] > high)\n\t\t\t\txs[i] = high;\n\t\t\t}\n\t\treturn xs;\n\t}\n\n\tstatic public IPersistentVector vclipcounts(double[] x, double low, double high){\n\t\tfinal double[] xs = x.clone();\n\t\tint lowc = 0;\n\t\tint highc = 0;\n\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\t{\n\t\t\tif(xs[i] < low)\n\t\t\t\t{\n\t\t\t\t++lowc;\n\t\t\t\txs[i] = low;\n\t\t\t\t}\n\t\t\telse if(xs[i] > high)\n\t\t\t\t{\n\t\t\t\t++highc;\n\t\t\t\txs[i] = high;\n\t\t\t\t}\n\t\t\t}\n\t\treturn RT.vector(xs, lowc, highc);\n\t}\n\n\tstatic public double[] vthresh(double[] x, double thresh, double otherwise){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\t{\n\t\t\tif(xs[i] < thresh)\n\t\t\t\txs[i] = otherwise;\n\t\t\t}\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vreverse(double[] x){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[xs.length - i - 1];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vrunningsum(double[] x){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 1; i < xs.length; i++)\n\t\t\txs[i] = xs[i - 1] + xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vsort(double[] x){\n\t\tfinal double[] xs = x.clone();\n\t\tArrays.sort(xs);\n\t\treturn xs;\n\t}\n\n\tstatic public double vdot(double[] xs, double[] ys){\n\t\tdouble ret = 0;\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret += xs[i] * ys[i];\n\t\treturn ret;\n\t}\n\n\tstatic public double vmax(double[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\tdouble ret = xs[0];\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret = Math.max(ret, xs[i]);\n\t\treturn ret;\n\t}\n\n\tstatic public double vmin(double[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\tdouble ret = xs[0];\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret = Math.min(ret, xs[i]);\n\t\treturn ret;\n\t}\n\n\tstatic public double vmean(double[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\treturn vsum(xs) / xs.length;\n\t}\n\n\tstatic public double vrms(double[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\tdouble ret = 0;\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret += xs[i] * xs[i];\n\t\treturn Math.sqrt(ret / xs.length);\n\t}\n\n\tstatic public double vsum(double[] xs){\n\t\tdouble ret = 0;\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret += xs[i];\n\t\treturn ret;\n\t}\n\n\tstatic public boolean vequiv(double[] xs, double[] ys){\n\t\treturn Arrays.equals(xs, ys);\n\t}\n\n\tstatic public double[] vadd(double[] x, double[] ys){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] += ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vsub(double[] x, double[] ys){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] -= ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vaddmul(double[] x, double[] ys, double[] zs){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] + ys[i]) * zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vsubmul(double[] x, double[] ys, double[] zs){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] - ys[i]) * zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vaddsmul(double[] x, double[] ys, double z){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] + ys[i]) * z;\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vsubsmul(double[] x, double[] ys, double z){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] - ys[i]) * z;\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vmulsadd(double[] x, double[] ys, double z){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] * ys[i]) + z;\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vdiv(double[] x, double[] ys){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] /= ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vmul(double[] x, double[] ys){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vmuladd(double[] x, double[] ys, double[] zs){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] * ys[i]) + zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vmulsub(double[] x, double[] ys, double[] zs){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] * ys[i]) - zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vmax(double[] x, double[] ys){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = Math.max(xs[i], ys[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vmin(double[] x, double[] ys){\n\t\tfinal double[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = Math.min(xs[i], ys[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vmap(IFn fn, double[] x) {\n\t\tdouble[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = ((Number) fn.invoke(xs[i])).doubleValue();\n\t\treturn xs;\n\t}\n\n\tstatic public double[] vmap(IFn fn, double[] x, double[] ys) {\n\t\tdouble[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = ((Number) fn.invoke(xs[i], ys[i])).doubleValue();\n\t\treturn xs;\n\t}\n}\n\nstatic public class I{\n\tstatic public int add(int x, int y){\n\t\treturn x + y;\n\t}\n\n\tstatic public int subtract(int x, int y){\n\t\treturn x - y;\n\t}\n\n\tstatic public int negate(int x){\n\t\treturn -x;\n\t}\n\n\tstatic public int inc(int x){\n\t\treturn x + 1;\n\t}\n\n\tstatic public int dec(int x){\n\t\treturn x - 1;\n\t}\n\n\tstatic public int multiply(int x, int y){\n\t\treturn x * y;\n\t}\n\n\tstatic public int divide(int x, int y){\n\t\treturn x / y;\n\t}\n\n\tstatic public boolean equiv(int x, int y){\n\t\treturn x == y;\n\t}\n\n\tstatic public boolean lt(int x, int y){\n\t\treturn x < y;\n\t}\n\n\tstatic public boolean lte(int x, int y){\n\t\treturn x <= y;\n\t}\n\n\tstatic public boolean gt(int x, int y){\n\t\treturn x > y;\n\t}\n\n\tstatic public boolean gte(int x, int y){\n\t\treturn x >= y;\n\t}\n\n\tstatic public boolean pos(int x){\n\t\treturn x > 0;\n\t}\n\n\tstatic public boolean neg(int x){\n\t\treturn x < 0;\n\t}\n\n\tstatic public boolean zero(int x){\n\t\treturn x == 0;\n\t}\n\n\tstatic public int aget(int[] xs, int i){\n\t\treturn xs[i];\n\t}\n\n\tstatic public int aset(int[] xs, int i, int v){\n\t\txs[i] = v;\n\t\treturn v;\n\t}\n\n\tstatic public int alength(int[] xs){\n\t\treturn xs.length;\n\t}\n\n\tstatic public int[] aclone(int[] xs){\n\t\treturn xs.clone();\n\t}\n\n\tstatic public int[] vec(int size, Object init){\n\t\tint[] ret = new int[size];\n\t\tif(init instanceof Number)\n\t\t\t{\n\t\t\tint f = ((Number) init).intValue();\n\t\t\tfor(int i = 0; i < ret.length; i++)\n\t\t\t\tret[i] = f;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tISeq s = RT.seq(init);\n\t\t\tfor(int i = 0; i < size && s != null; i++, s = s.rest())\n\t\t\t\tret[i] = ((Number) s.first()).intValue();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tstatic public int[] vec(Object sizeOrSeq){\n\t\tif(sizeOrSeq instanceof Number)\n\t\t\treturn new int[((Number) sizeOrSeq).intValue()];\n\t\telse\n\t\t\t{\n\t\t\tISeq s = RT.seq(sizeOrSeq);\n\t\t\tint size = s.count();\n\t\t\tint[] ret = new int[size];\n\t\t\tfor(int i = 0; i < size && s != null; i++, s = s.rest())\n\t\t\t\tret[i] = ((Number) s.first()).intValue();\n\t\t\treturn ret;\n\t\t\t}\n\t}\n\n\tstatic public int[] vsadd(int[] x, int y){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] += y;\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vssub(int[] x, int y){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] -= y;\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vsdiv(int[] x, int y){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] /= y;\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vsmul(int[] x, int y){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= y;\n\t\treturn xs;\n\t}\n\n\tstatic public int[] svdiv(int y, int[] x){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = y / xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vsmuladd(int[] x, int y, int[] zs){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y + zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vsmulsub(int[] x, int y, int[] zs){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y - zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vsmulsadd(int[] x, int y, int z){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y + z;\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vsmulssub(int[] x, int y, int z){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y - z;\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vabs(int[] x){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = Math.abs(xs[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vnegabs(int[] x){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = -Math.abs(xs[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vneg(int[] x){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = -xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vsqr(int[] x){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vsignedsqr(int[] x){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= Math.abs(xs[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vclip(int[] x, int low, int high){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\t{\n\t\t\tif(xs[i] < low)\n\t\t\t\txs[i] = low;\n\t\t\telse if(xs[i] > high)\n\t\t\t\txs[i] = high;\n\t\t\t}\n\t\treturn xs;\n\t}\n\n\tstatic public IPersistentVector vclipcounts(int[] x, int low, int high){\n\t\tfinal int[] xs = x.clone();\n\t\tint lowc = 0;\n\t\tint highc = 0;\n\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\t{\n\t\t\tif(xs[i] < low)\n\t\t\t\t{\n\t\t\t\t++lowc;\n\t\t\t\txs[i] = low;\n\t\t\t\t}\n\t\t\telse if(xs[i] > high)\n\t\t\t\t{\n\t\t\t\t++highc;\n\t\t\t\txs[i] = high;\n\t\t\t\t}\n\t\t\t}\n\t\treturn RT.vector(xs, lowc, highc);\n\t}\n\n\tstatic public int[] vthresh(int[] x, int thresh, int otherwise){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\t{\n\t\t\tif(xs[i] < thresh)\n\t\t\t\txs[i] = otherwise;\n\t\t\t}\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vreverse(int[] x){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[xs.length - i - 1];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vrunningsum(int[] x){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 1; i < xs.length; i++)\n\t\t\txs[i] = xs[i - 1] + xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vsort(int[] x){\n\t\tfinal int[] xs = x.clone();\n\t\tArrays.sort(xs);\n\t\treturn xs;\n\t}\n\n\tstatic public int vdot(int[] xs, int[] ys){\n\t\tint ret = 0;\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret += xs[i] * ys[i];\n\t\treturn ret;\n\t}\n\n\tstatic public int vmax(int[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\tint ret = xs[0];\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret = Math.max(ret, xs[i]);\n\t\treturn ret;\n\t}\n\n\tstatic public int vmin(int[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\tint ret = xs[0];\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret = Math.min(ret, xs[i]);\n\t\treturn ret;\n\t}\n\n\tstatic public double vmean(int[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\treturn vsum(xs) / (double) xs.length;\n\t}\n\n\tstatic public double vrms(int[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\tint ret = 0;\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret += xs[i] * xs[i];\n\t\treturn Math.sqrt(ret / (double) xs.length);\n\t}\n\n\tstatic public int vsum(int[] xs){\n\t\tint ret = 0;\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret += xs[i];\n\t\treturn ret;\n\t}\n\n\tstatic public boolean vequiv(int[] xs, int[] ys){\n\t\treturn Arrays.equals(xs, ys);\n\t}\n\n\tstatic public int[] vadd(int[] x, int[] ys){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] += ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vsub(int[] x, int[] ys){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] -= ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vaddmul(int[] x, int[] ys, int[] zs){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] + ys[i]) * zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vsubmul(int[] x, int[] ys, int[] zs){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] - ys[i]) * zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vaddsmul(int[] x, int[] ys, int z){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] + ys[i]) * z;\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vsubsmul(int[] x, int[] ys, int z){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] - ys[i]) * z;\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vmulsadd(int[] x, int[] ys, int z){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] * ys[i]) + z;\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vdiv(int[] x, int[] ys){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] /= ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vmul(int[] x, int[] ys){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vmuladd(int[] x, int[] ys, int[] zs){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] * ys[i]) + zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vmulsub(int[] x, int[] ys, int[] zs){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] * ys[i]) - zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vmax(int[] x, int[] ys){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = Math.max(xs[i], ys[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vmin(int[] x, int[] ys){\n\t\tfinal int[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = Math.min(xs[i], ys[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vmap(IFn fn, int[] x) {\n\t\tint[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = ((Number) fn.invoke(xs[i])).intValue();\n\t\treturn xs;\n\t}\n\n\tstatic public int[] vmap(IFn fn, int[] x, int[] ys) {\n\t\tint[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = ((Number) fn.invoke(xs[i], ys[i])).intValue();\n\t\treturn xs;\n\t}\n\n}\n\nstatic public class L{\n\tstatic public long add(long x, long y){\n\t\treturn x + y;\n\t}\n\n\tstatic public long subtract(long x, long y){\n\t\treturn x - y;\n\t}\n\n\tstatic public long negate(long x){\n\t\treturn -x;\n\t}\n\n\tstatic public long inc(long x){\n\t\treturn x + 1;\n\t}\n\n\tstatic public long dec(long x){\n\t\treturn x - 1;\n\t}\n\n\tstatic public long multiply(long x, long y){\n\t\treturn x * y;\n\t}\n\n\tstatic public long divide(long x, long y){\n\t\treturn x / y;\n\t}\n\n\tstatic public boolean equiv(long x, long y){\n\t\treturn x == y;\n\t}\n\n\tstatic public boolean lt(long x, long y){\n\t\treturn x < y;\n\t}\n\n\tstatic public boolean lte(long x, long y){\n\t\treturn x <= y;\n\t}\n\n\tstatic public boolean gt(long x, long y){\n\t\treturn x > y;\n\t}\n\n\tstatic public boolean gte(long x, long y){\n\t\treturn x >= y;\n\t}\n\n\tstatic public boolean pos(long x){\n\t\treturn x > 0;\n\t}\n\n\tstatic public boolean neg(long x){\n\t\treturn x < 0;\n\t}\n\n\tstatic public boolean zero(long x){\n\t\treturn x == 0;\n\t}\n\n\tstatic public long aget(long[] xs, int i){\n\t\treturn xs[i];\n\t}\n\n\tstatic public long aset(long[] xs, int i, long v){\n\t\txs[i] = v;\n\t\treturn v;\n\t}\n\n\tstatic public int alength(long[] xs){\n\t\treturn xs.length;\n\t}\n\n\tstatic public long[] aclone(long[] xs){\n\t\treturn xs.clone();\n\t}\n\n\tstatic public long[] vec(int size, Object init){\n\t\tlong[] ret = new long[size];\n\t\tif(init instanceof Number)\n\t\t\t{\n\t\t\tlong f = ((Number) init).longValue();\n\t\t\tfor(int i = 0; i < ret.length; i++)\n\t\t\t\tret[i] = f;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tISeq s = RT.seq(init);\n\t\t\tfor(int i = 0; i < size && s != null; i++, s = s.rest())\n\t\t\t\tret[i] = ((Number) s.first()).longValue();\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tstatic public long[] vec(Object sizeOrSeq){\n\t\tif(sizeOrSeq instanceof Number)\n\t\t\treturn new long[((Number) sizeOrSeq).intValue()];\n\t\telse\n\t\t\t{\n\t\t\tISeq s = RT.seq(sizeOrSeq);\n\t\t\tint size = s.count();\n\t\t\tlong[] ret = new long[size];\n\t\t\tfor(int i = 0; i < size && s != null; i++, s = s.rest())\n\t\t\t\tret[i] = ((Number) s.first()).intValue();\n\t\t\treturn ret;\n\t\t\t}\n\t}\n\n\n\tstatic public long[] vsadd(long[] x, long y){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] += y;\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vssub(long[] x, long y){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] -= y;\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vsdiv(long[] x, long y){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] /= y;\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vsmul(long[] x, long y){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= y;\n\t\treturn xs;\n\t}\n\n\tstatic public long[] svdiv(long y, long[] x){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = y / xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vsmuladd(long[] x, long y, long[] zs){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y + zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vsmulsub(long[] x, long y, long[] zs){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y - zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vsmulsadd(long[] x, long y, long z){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y + z;\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vsmulssub(long[] x, long y, long z){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[i] * y - z;\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vabs(long[] x){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = Math.abs(xs[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vnegabs(long[] x){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = -Math.abs(xs[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vneg(long[] x){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = -xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vsqr(long[] x){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vsignedsqr(long[] x){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= Math.abs(xs[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vclip(long[] x, long low, long high){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\t{\n\t\t\tif(xs[i] < low)\n\t\t\t\txs[i] = low;\n\t\t\telse if(xs[i] > high)\n\t\t\t\txs[i] = high;\n\t\t\t}\n\t\treturn xs;\n\t}\n\n\tstatic public IPersistentVector vclipcounts(long[] x, long low, long high){\n\t\tfinal long[] xs = x.clone();\n\t\tint lowc = 0;\n\t\tint highc = 0;\n\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\t{\n\t\t\tif(xs[i] < low)\n\t\t\t\t{\n\t\t\t\t++lowc;\n\t\t\t\txs[i] = low;\n\t\t\t\t}\n\t\t\telse if(xs[i] > high)\n\t\t\t\t{\n\t\t\t\t++highc;\n\t\t\t\txs[i] = high;\n\t\t\t\t}\n\t\t\t}\n\t\treturn RT.vector(xs, lowc, highc);\n\t}\n\n\tstatic public long[] vthresh(long[] x, long thresh, long otherwise){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\t{\n\t\t\tif(xs[i] < thresh)\n\t\t\t\txs[i] = otherwise;\n\t\t\t}\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vreverse(long[] x){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = xs[xs.length - i - 1];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vrunningsum(long[] x){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 1; i < xs.length; i++)\n\t\t\txs[i] = xs[i - 1] + xs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vsort(long[] x){\n\t\tfinal long[] xs = x.clone();\n\t\tArrays.sort(xs);\n\t\treturn xs;\n\t}\n\n\tstatic public long vdot(long[] xs, long[] ys){\n\t\tlong ret = 0;\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret += xs[i] * ys[i];\n\t\treturn ret;\n\t}\n\n\tstatic public long vmax(long[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\tlong ret = xs[0];\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret = Math.max(ret, xs[i]);\n\t\treturn ret;\n\t}\n\n\tstatic public long vmin(long[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\tlong ret = xs[0];\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret = Math.min(ret, xs[i]);\n\t\treturn ret;\n\t}\n\n\tstatic public double vmean(long[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\treturn vsum(xs) / (double) xs.length;\n\t}\n\n\tstatic public double vrms(long[] xs){\n\t\tif(xs.length == 0)\n\t\t\treturn 0;\n\t\tlong ret = 0;\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret += xs[i] * xs[i];\n\t\treturn Math.sqrt(ret / (double) xs.length);\n\t}\n\n\tstatic public long vsum(long[] xs){\n\t\tlong ret = 0;\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\tret += xs[i];\n\t\treturn ret;\n\t}\n\n\tstatic public boolean vequiv(long[] xs, long[] ys){\n\t\treturn Arrays.equals(xs, ys);\n\t}\n\n\tstatic public long[] vadd(long[] x, long[] ys){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] += ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vsub(long[] x, long[] ys){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] -= ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vaddmul(long[] x, long[] ys, long[] zs){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] + ys[i]) * zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vsubmul(long[] x, long[] ys, long[] zs){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] - ys[i]) * zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vaddsmul(long[] x, long[] ys, long z){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] + ys[i]) * z;\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vsubsmul(long[] x, long[] ys, long z){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] - ys[i]) * z;\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vmulsadd(long[] x, long[] ys, long z){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] * ys[i]) + z;\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vdiv(long[] x, long[] ys){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] /= ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vmul(long[] x, long[] ys){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] *= ys[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vmuladd(long[] x, long[] ys, long[] zs){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] * ys[i]) + zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vmulsub(long[] x, long[] ys, long[] zs){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = (xs[i] * ys[i]) - zs[i];\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vmax(long[] x, long[] ys){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = Math.max(xs[i], ys[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vmin(long[] x, long[] ys){\n\t\tfinal long[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = Math.min(xs[i], ys[i]);\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vmap(IFn fn, long[] x) {\n\t\tlong[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = ((Number) fn.invoke(xs[i])).longValue();\n\t\treturn xs;\n\t}\n\n\tstatic public long[] vmap(IFn fn, long[] x, long[] ys) {\n\t\tlong[] xs = x.clone();\n\t\tfor(int i = 0; i < xs.length; i++)\n\t\t\txs[i] = ((Number) fn.invoke(xs[i], ys[i])).longValue();\n\t\treturn xs;\n\t}\n\n}\n*/\n\n\n//overload resolution\n//*\n\nstatic public Number add(long x, Object y){\n\treturn add((Object)x,y);\n}\n\nstatic public Number add(Object x, long y){\n\treturn add(x,(Object)y);\n}\n\nstatic public Number addP(long x, Object y){\n\treturn addP((Object)x,y);\n}\n\nstatic public Number addP(Object x, long y){\n\treturn addP(x,(Object)y);\n}\n\nstatic public double add(double x, Object y){\n\treturn add(x,((Number)y).doubleValue());\n}\n\nstatic public double add(Object x, double y){\n\treturn add(((Number)x).doubleValue(),y);\n}\n\nstatic public double add(double x, long y){\n\treturn x + y;\n}\n\nstatic public double add(long x, double y){\n\treturn x + y;\n}\n\nstatic public double addP(double x, Object y){\n\treturn addP(x,((Number)y).doubleValue());\n}\n\nstatic public double addP(Object x, double y){\n\treturn addP(((Number)x).doubleValue(),y);\n}\n\nstatic public double addP(double x, long y){\n\treturn x + y;\n}\n\nstatic public double addP(long x, double y){\n\treturn x + y;\n}\n\nstatic public Number minus(long x, Object y){\n\treturn minus((Object)x,y);\n}\n\nstatic public Number minus(Object x, long y){\n\treturn minus(x,(Object)y);\n}\n\nstatic public Number minusP(long x, Object y){\n\treturn minusP((Object)x,y);\n}\n\nstatic public Number minusP(Object x, long y){\n\treturn minusP(x,(Object)y);\n}\n\nstatic public double minus(double x, Object y){\n\treturn minus(x,((Number)y).doubleValue());\n}\n\nstatic public double minus(Object x, double y){\n\treturn minus(((Number)x).doubleValue(),y);\n}\n\nstatic public double minus(double x, long y){\n\treturn x - y;\n}\n\nstatic public double minus(long x, double y){\n\treturn x - y;\n}\n\nstatic public double minusP(double x, Object y){\n\treturn minus(x,((Number)y).doubleValue());\n}\n\nstatic public double minusP(Object x, double y){\n\treturn minus(((Number)x).doubleValue(),y);\n}\n\nstatic public double minusP(double x, long y){\n\treturn x - y;\n}\n\nstatic public double minusP(long x, double y){\n\treturn x - y;\n}\n\nstatic public Number multiply(long x, Object y){\n\treturn multiply((Object)x,y);\n}\n\nstatic public Number multiply(Object x, long y){\n\treturn multiply(x,(Object)y);\n}\n\nstatic public Number multiplyP(long x, Object y){\n\treturn multiplyP((Object)x,y);\n}\n\nstatic public Number multiplyP(Object x, long y){\n\treturn multiplyP(x,(Object)y);\n}\n\nstatic public double multiply(double x, Object y){\n\treturn multiply(x,((Number)y).doubleValue());\n}\n\nstatic public double multiply(Object x, double y){\n\treturn multiply(((Number)x).doubleValue(),y);\n}\n\nstatic public double multiply(double x, long y){\n\treturn x * y;\n}\n\nstatic public double multiply(long x, double y){\n\treturn x * y;\n}\n\nstatic public double multiplyP(double x, Object y){\n\treturn multiplyP(x,((Number)y).doubleValue());\n}\n\nstatic public double multiplyP(Object x, double y){\n\treturn multiplyP(((Number)x).doubleValue(),y);\n}\n\nstatic public double multiplyP(double x, long y){\n\treturn x * y;\n}\n\nstatic public double multiplyP(long x, double y){\n\treturn x * y;\n}\n\nstatic public Number divide(long x, Object y){\n\treturn divide((Object)x,y);\n}\n\nstatic public Number divide(Object x, long y){\n\treturn divide(x,(Object)y);\n}\n\nstatic public double divide(double x, Object y){\n\treturn x / ((Number)y).doubleValue();\n}\n\nstatic public double divide(Object x, double y){\n\treturn ((Number)x).doubleValue() / y;\n}\n\nstatic public double divide(double x, long y){\n\treturn x / y;\n}\n\nstatic public double divide(long x, double y){\n    return x / y;\n}\n\nstatic public Number divide(long x, long y){\n\treturn divide((Number)x, (Number)y);\n}\n\nstatic public boolean lt(long x, Object y){\n\treturn lt((Object)x,y);\n}\n\nstatic public boolean lt(Object x, long y){\n\treturn lt(x,(Object)y);\n}\n\nstatic public boolean lt(double x, Object y){\n\treturn x < ((Number)y).doubleValue();\n}\n\nstatic public boolean lt(Object x, double y){\n\treturn ((Number)x).doubleValue() < y;\n}\n\nstatic public boolean lt(double x, long y){\n\treturn x < y;\n}\n\nstatic public boolean lt(long x, double y){\n\treturn x < y;\n}\n\nstatic public boolean lte(long x, Object y){\n\treturn lte((Object)x,y);\n}\n\nstatic public boolean lte(Object x, long y){\n\treturn lte(x,(Object)y);\n}\n\nstatic public boolean lte(double x, Object y){\n\treturn x <= ((Number)y).doubleValue();\n}\n\nstatic public boolean lte(Object x, double y){\n\treturn ((Number)x).doubleValue() <= y;\n}\n\nstatic public boolean lte(double x, long y){\n\treturn x <= y;\n}\n\nstatic public boolean lte(long x, double y){\n\treturn x <= y;\n}\n\nstatic public boolean gt(long x, Object y){\n\treturn gt((Object)x,y);\n}\n\nstatic public boolean gt(Object x, long y){\n\treturn gt(x,(Object)y);\n}\n\nstatic public boolean gt(double x, Object y){\n\treturn x > ((Number)y).doubleValue();\n}\n\nstatic public boolean gt(Object x, double y){\n\treturn ((Number)x).doubleValue() > y;\n}\n\nstatic public boolean gt(double x, long y){\n\treturn x > y;\n}\n\nstatic public boolean gt(long x, double y){\n\treturn x > y;\n}\n\nstatic public boolean gte(long x, Object y){\n\treturn gte((Object)x,y);\n}\n\nstatic public boolean gte(Object x, long y){\n\treturn gte(x,(Object)y);\n}\n\nstatic public boolean gte(double x, Object y){\n\treturn x >= ((Number)y).doubleValue();\n}\n\nstatic public boolean gte(Object x, double y){\n\treturn ((Number)x).doubleValue() >= y;\n}\n\nstatic public boolean gte(double x, long y){\n\treturn x >= y;\n}\n\nstatic public boolean gte(long x, double y){\n\treturn x >= y;\n}\n\nstatic public boolean equiv(long x, Object y){\n\treturn equiv((Object)x,y);\n}\n\nstatic public boolean equiv(Object x, long y){\n\treturn equiv(x,(Object)y);\n}\n\nstatic public boolean equiv(double x, Object y){\n\treturn x == ((Number)y).doubleValue();\n}\n\nstatic public boolean equiv(Object x, double y){\n\treturn ((Number)x).doubleValue() == y;\n}\n\nstatic public boolean equiv(double x, long y){\n\treturn x == y;\n}\n\nstatic public boolean equiv(long x, double y){\n\treturn x == y;\n}\n\n\nstatic boolean isNaN(Object x){\n\treturn (x instanceof Double) && ((Double)x).isNaN()\n\t\t|| (x instanceof Float) && ((Float)x).isNaN();\n}\n\nstatic public double max(double x, double y){\n\treturn Math.max(x, y);\n}\n\nstatic public Object max(double x, long y){\n\tif(Double.isNaN(x)){\n\t\treturn x;\n\t}\n\tif(x > y){\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\nstatic public Object max(double x, Object y){\n\tif(Double.isNaN(x)){\n\t\treturn x;\n\t} else if(isNaN(y)){\n\t\treturn y;\n\t}\n\tif(x > ((Number)y).doubleValue()){\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\nstatic public Object max(long x, double y){\n\tif(Double.isNaN(y)){\n\t\treturn y;\n\t}\n\tif(x > y){\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\n\nstatic public long max(long x, long y){\n\tif(x > y) {\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\n\nstatic public Object max(long x, Object y){\n\tif(isNaN(y)){\n\t\treturn y;\n\t}\n\tif(gt(x,y)){\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\nstatic public Object max(Object x, long y){\n\tif(isNaN(x)){\n\t\treturn x;\n\t}\n\tif(gt(x,y)){\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\nstatic public Object max(Object x, double y){\n\tif (isNaN(x)){\n\t\treturn x;\n\t} else if(Double.isNaN(y)){\n\t\treturn y;\n\t}\n\tif(((Number)x).doubleValue() > y){\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\nstatic public Object max(Object x, Object y){\n\tif(isNaN(x)){\n\t\treturn x;\n\t} else if(isNaN(y)){\n\t\treturn y;\n\t}\n\tif(gt(x, y)) {\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\n\nstatic public double min(double x, double y){\n\treturn Math.min(x, y);\n}\n\nstatic public Object min(double x, long y){\n\tif (Double.isNaN(x)){\n\t\treturn x;\n\t}\n\tif(x < y){\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\nstatic public Object min(double x, Object y){\n\tif(Double.isNaN(x)){\n\t\treturn x;\n\t} else if(isNaN(y)){\n\t\treturn y;\n\t}\n\tif(x < ((Number)y).doubleValue()){\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\nstatic public Object min(long x, double y){\n\tif(Double.isNaN(y)){\n\t\treturn y;\n\t}\n\tif(x < y){\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\n\nstatic public long min(long x, long y){\n\tif(x < y) {\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\nstatic public Object min(long x, Object y){\n\tif(isNaN(y)){\n\t\treturn y;\n\t}\n\tif(lt(x,y)){\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\nstatic public Object min(Object x, long y){\n\tif(isNaN(x)){\n\t\treturn x;\n\t}\n\tif(lt(x,y)){\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\nstatic public Object min(Object x, double y){\n\tif(isNaN(x)){\n\t\treturn x;\n\t} else if(Double.isNaN(y)){\n\t\treturn y;\n\t}\n\tif(((Number)x).doubleValue() < y){\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\nstatic public Object min(Object x, Object y){\n\tif (isNaN(x)){\n\t\treturn x;\n\t} else if(isNaN(y)){\n\t\treturn y;\n\t}\n\tif(lt(x,y)) {\n\t\treturn x;\n\t} else {\n\t\treturn y;\n\t}\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Obj.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 25, 2006 3:44:58 PM */\n\npackage clojure.lang;\n\nimport java.io.Serializable;\n\npublic abstract class Obj implements IObj, Serializable {\n\nfinal IPersistentMap _meta;\n\npublic Obj(IPersistentMap meta){\n\tthis._meta = meta;\n}\n\npublic Obj(){\n\t_meta = null;\n}\n\nfinal public IPersistentMap meta(){\n\treturn _meta;\n}\n\nabstract public Obj withMeta(IPersistentMap meta);\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ObjC.java",
    "content": "package clojure.lang;\n\npublic class ObjC {\n  \n  public static boolean objc = false;\n  \n  public static void setObjC() {\n    objc = true;\n  }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ObjCClass.java",
    "content": "package clojure.lang;\n\npublic class ObjCClass {\n  \n  private final String name;\n\n  public ObjCClass(String name) {\n    this.name = name;\n  }\n\n  public String getName() {\n    return name;\n  }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/PersistentArrayMap.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.io.Serializable;\nimport java.util.Arrays;\nimport java.util.Iterator;\nimport java.util.Map;\n\n/**\n * Simple implementation of persistent map on an array\n * <p/>\n * Note that instances of this class are constant values\n * i.e. add/remove etc return new values\n * <p/>\n * Copies array on every change, so only appropriate for _very_small_ maps\n * <p/>\n * null keys and values are ok, but you won't be able to distinguish a null value via valAt - use contains/entryAt\n */\n\npublic class PersistentArrayMap extends APersistentMap implements IObj, IEditableCollection, IMapIterable {\n\nfinal Object[] array;\nstatic final int HASHTABLE_THRESHOLD = 16;\n\npublic static final PersistentArrayMap EMPTY = new PersistentArrayMap();\nprivate final IPersistentMap _meta;\n\nstatic public IPersistentMap create(Map other){\n\tITransientMap ret = EMPTY.asTransient();\n\tfor(Object o : other.entrySet())\n\t\t{\n\t\tMap.Entry e = (Entry) o;\n\t\tret = ret.assoc(e.getKey(), e.getValue());\n\t\t}\n\treturn ret.persistent();\n}\n\nprotected PersistentArrayMap(){\n\tthis.array = new Object[]{};\n\tthis._meta = null;\n}\n\npublic PersistentArrayMap withMeta(IPersistentMap meta){\n\treturn new PersistentArrayMap(meta, array);\n}\n\nPersistentArrayMap create(Object... init){\n\treturn new PersistentArrayMap(meta(), init);\n}\n\nIPersistentMap createHT(Object[] init){\n\treturn PersistentHashMap.create(meta(), init);\n}\n\nstatic public PersistentArrayMap createWithCheck(Object[] init){\n\tfor(int i=0;i< init.length;i += 2)\n\t\t{\n\t\tfor(int j=i+2;j<init.length;j += 2)\n\t\t\t{\n\t\t\tif(equalKey(init[i],init[j]))\n\t\t\t\tthrow new IllegalArgumentException(\"Duplicate key: \" + init[i]);\n\t\t\t}\n\t\t}\n\treturn new PersistentArrayMap(init);\n}\n\nstatic public PersistentArrayMap createAsIfByAssoc(Object[] init){\n\t// If this looks like it is doing busy-work, it is because it\n\t// is achieving these goals: O(n^2) run time like\n\t// createWithCheck(), never modify init arg, and only\n\t// allocate memory if there are duplicate keys.\n\tint n = 0;\n\tfor(int i=0;i< init.length;i += 2)\n\t\t{\n\t\tboolean duplicateKey = false;\n\t\tfor(int j=0;j<i;j += 2)\n\t\t\t{\n\t\t\tif(equalKey(init[i],init[j]))\n\t\t\t\t{\n\t\t\t\tduplicateKey = true;\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\tif(!duplicateKey)\n\t\t\tn += 2;\n\t\t}\n\tif(n < init.length)\n\t\t{\n\t\t// Create a new shorter array with unique keys, and\n\t\t// the last value associated with each key.  To behave\n\t\t// like assoc, the first occurrence of each key must\n\t\t// be used, since its metadata may be different than\n\t\t// later equal keys.\n\t\tObject[] nodups = new Object[n];\n\t\tint m = 0;\n\t\tfor(int i=0;i< init.length;i += 2)\n\t\t\t{\n\t\t\tboolean duplicateKey = false;\n\t\t\tfor(int j=0;j<m;j += 2)\n\t\t\t\t{\n\t\t\t\tif(equalKey(init[i],nodups[j]))\n\t\t\t\t\t{\n\t\t\t\t\tduplicateKey = true;\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tif(!duplicateKey)\n\t\t\t\t{\n\t\t\t\tint j;\n\t\t\t\tfor (j=init.length-2; j>=i; j -= 2)\n\t\t\t\t\t{\n\t\t\t\t\tif(equalKey(init[i],init[j]))\n\t\t\t\t\t\t{\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tnodups[m] = init[i];\n\t\t\t\tnodups[m+1] = init[j+1];\n\t\t\t\tm += 2;\n\t\t\t\t}\n\t\t\t}\n\t\tif (m != n)\n\t\t\tthrow new IllegalArgumentException(\"Internal error: m=\" + m);\n\t\tinit = nodups;\n\t\t}\n\treturn new PersistentArrayMap(init);\n}\n/**\n * This ctor captures/aliases the passed array, so do not modify later\n *\n * @param init {key1,val1,key2,val2,...}\n */\npublic PersistentArrayMap(Object[] init){\n\tthis.array = init;\n\tthis._meta = null;\n}\n\n\npublic PersistentArrayMap(IPersistentMap meta, Object[] init){\n\tthis._meta = meta;\n\tthis.array = init;\n}\n\npublic int count(){\n\treturn array.length / 2;\n}\n\npublic boolean containsKey(Object key){\n\treturn indexOf(key) >= 0;\n}\n\npublic IMapEntry entryAt(Object key){\n\tint i = indexOf(key);\n\tif(i >= 0)\n\t\treturn new MapEntry(array[i],array[i+1]);\n\treturn null;\n}\n\npublic IPersistentMap assocEx(Object key, Object val) {\n\tint i = indexOf(key);\n\tObject[] newArray;\n\tif(i >= 0)\n\t\t{\n\t\tthrow Util.runtimeException(\"Key already present\");\n\t\t}\n\telse //didn't have key, grow\n\t\t{\n\t\tif(array.length > HASHTABLE_THRESHOLD)\n\t\t\treturn createHT(array).assocEx(key, val);\n\t\tnewArray = new Object[array.length + 2];\n\t\tif(array.length > 0)\n\t\t\tSystem.arraycopy(array, 0, newArray, 2, array.length);\n\t\tnewArray[0] = key;\n\t\tnewArray[1] = val;\n\t\t}\n\treturn create(newArray);\n}\n\npublic IPersistentMap assoc(Object key, Object val){\n\tint i = indexOf(key);\n\tObject[] newArray;\n\tif(i >= 0) //already have key, same-sized replacement\n\t\t{\n\t\tif(array[i + 1] == val) //no change, no op\n\t\t\treturn this;\n\t\tnewArray = array.clone();\n\t\tnewArray[i + 1] = val;\n\t\t}\n\telse //didn't have key, grow\n\t\t{\n\t\tif(array.length > HASHTABLE_THRESHOLD)\n\t\t\treturn createHT(array).assoc(key, val);\n\t\tnewArray = new Object[array.length + 2];\n\t\tif(array.length > 0)\n\t\t\tSystem.arraycopy(array, 0, newArray, 0, array.length);\n\t\tnewArray[newArray.length-2] = key;\n\t\tnewArray[newArray.length-1] = val;\n\t\t}\n\treturn create(newArray);\n}\n\npublic IPersistentMap without(Object key){\n\tint i = indexOf(key);\n\tif(i >= 0) //have key, will remove\n\t\t{\n\t\tint newlen = array.length - 2;\n\t\tif(newlen == 0)\n\t\t\treturn empty();\n\t\tObject[] newArray = new Object[newlen];\n\t\tfor(int s = 0, d = 0; s < array.length; s += 2)\n\t\t\t{\n\t\t\tif(!equalKey(array[s], key)) //skip removal key\n\t\t\t\t{\n\t\t\t\tnewArray[d] = array[s];\n\t\t\t\tnewArray[d + 1] = array[s + 1];\n\t\t\t\td += 2;\n\t\t\t\t}\n\t\t\t}\n\t\treturn create(newArray);\n\t\t}\n\t//don't have key, no op\n\treturn this;\n}\n\npublic IPersistentMap empty(){\n\treturn (IPersistentMap) EMPTY.withMeta(meta());\n}\n\nfinal public Object valAt(Object key, Object notFound){\n\tint i = indexOf(key);\n\tif(i >= 0)\n\t\treturn array[i + 1];\n\treturn notFound;\n}\n\npublic Object valAt(Object key){\n\treturn valAt(key, null);\n}\n\npublic int capacity(){\n\treturn count();\n}\n\nprivate int indexOfObject(Object key){\n    Util.EquivPred ep = Util.equivPred(key);\n    for(int i = 0; i < array.length; i += 2)\n        {\n        if(ep.equiv(key, array[i]))\n            return i;\n        }\n\treturn -1;\n}\n\nprivate int indexOf(Object key){\n    if(key instanceof Keyword)\n        {\n        for(int i = 0; i < array.length; i += 2)\n            {\n            if(key == array[i])\n                return i;\n            }\n    \treturn -1;\n        }\n    else\n        return indexOfObject(key);\n}\n\nstatic boolean equalKey(Object k1, Object k2){\n    if(k1 instanceof Keyword)\n        return k1 == k2;\n\treturn Util.equiv(k1, k2);\n}\n\npublic Iterator iterator(){\n\treturn new Iter(array,APersistentMap.MAKE_ENTRY);\n}\n\npublic Iterator keyIterator(){\n    return new Iter(array,APersistentMap.MAKE_KEY);\n}\n\npublic Iterator valIterator() {\n    return new Iter(array,APersistentMap.MAKE_VAL);\n}\n\npublic ISeq seq(){\n\tif(array.length > 0)\n\t\treturn new Seq(array, 0);\n\treturn null;\n}\n\npublic IPersistentMap meta(){\n\treturn _meta;\n}\n\nstatic class Seq extends ASeq implements Counted{\n\tfinal Object[] array;\n\tfinal int i;\n\n\tSeq(Object[] array, int i){\n\t\tthis.array = array;\n\t\tthis.i = i;\n\t}\n\n\tpublic Seq(IPersistentMap meta, Object[] array, int i){\n\t\tsuper(meta);\n\t\tthis.array = array;\n\t\tthis.i = i;\n\t}\n\n\tpublic Object first(){\n\t\treturn new MapEntry(array[i],array[i+1]);\n\t}\n\n\tpublic ISeq next(){\n\t\tif(i + 2 < array.length)\n\t\t\treturn new Seq(array, i + 2);\n\t\treturn null;\n\t}\n\n\tpublic int count(){\n\t\treturn (array.length - i) / 2;\n\t}\n\n\tpublic Obj withMeta(IPersistentMap meta){\n\t\treturn new Seq(meta, array, i);\n\t}\n}\n\nstatic class Iter implements Iterator{\n    IFn f;\n\tObject[] array;\n\tint i;\n\n\t//for iterator\n\tIter(Object[] array, IFn f){\n\t\tthis(array, -2, f);\n\t}\n\n\t//for entryAt\n\tIter(Object[] array, int i, IFn f){\n\t\tthis.array = array;\n\t\tthis.i = i;\n        this.f = f;\n\t}\n\n\tpublic boolean hasNext(){\n\t\treturn i < array.length - 2;\n\t}\n\n\tpublic Object next(){\n\t\ti += 2;\n\t\treturn f.invoke(array[i],array[i+1]);\n\t}\n\n\tpublic void remove(){\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n}\n\npublic Object kvreduce(IFn f, Object init){\n    for(int i=0;i < array.length;i+=2){\n        init = f.invoke(init, array[i], array[i+1]);\n\t    if(RT.isReduced(init))\n\t\t    return ((IDeref)init).deref();\n        }\n    return init;\n}\n\npublic ITransientMap asTransient(){\n\treturn new TransientArrayMap(array);\n}\n\nstatic final class TransientArrayMap extends ATransientMap {\n\tvolatile int len;\n\tfinal Object[] array;\n\tvolatile Thread owner;\n\n\tpublic TransientArrayMap(Object[] array){\n\t\tthis.owner = Thread.currentThread();\n\t\tthis.array = new Object[Math.max(HASHTABLE_THRESHOLD, array.length)];\n\t\tSystem.arraycopy(array, 0, this.array, 0, array.length);\n\t\tthis.len = array.length;\n\t}\n\t\n\tprivate int indexOf(Object key){\n\t\tfor(int i = 0; i < len; i += 2)\n\t\t\t{\n\t\t\tif(equalKey(array[i], key))\n\t\t\t\treturn i;\n\t\t\t}\n\t\treturn -1;\n\t}\n\n\tITransientMap doAssoc(Object key, Object val){\n\t\tint i = indexOf(key);\n\t\tif(i >= 0) //already have key,\n\t\t\t{\n\t\t\tif(array[i + 1] != val) //no change, no op\n\t\t\t\tarray[i + 1] = val;\n\t\t\t}\n\t\telse //didn't have key, grow\n\t\t\t{\n\t\t\tif(len >= array.length)\n\t\t\t\treturn PersistentHashMap.create(array).asTransient().assoc(key, val);\n\t\t\tarray[len++] = key;\n\t\t\tarray[len++] = val;\n\t\t\t}\n\t\treturn this;\n\t}\n\n\tITransientMap doWithout(Object key) {\n\t\tint i = indexOf(key);\n\t\tif(i >= 0) //have key, will remove\n\t\t\t{\n\t\t\tif (len >= 2)\n\t\t\t\t{\n\t\t\t\t\tarray[i] = array[len - 2];\n\t\t\t\t\tarray[i + 1] = array[len - 1];\n\t\t\t\t}\n\t\t\tlen -= 2;\n\t\t\t}\n\t\treturn this;\n\t}\n\n\tObject doValAt(Object key, Object notFound) {\n\t\tint i = indexOf(key);\n\t\tif (i >= 0)\n\t\t\treturn array[i + 1];\n\t\treturn notFound;\n\t}\n\n\tint doCount() {\n\t\treturn len / 2;\n\t}\n\t\n\tIPersistentMap doPersistent(){\n\t\tensureEditable();\n\t\towner = null;\n\t\tObject[] a = new Object[len];\n\t\tSystem.arraycopy(array,0,a,0,len);\n\t\treturn new PersistentArrayMap(a);\n\t}\n\n\tvoid ensureEditable(){\n\t\tif(owner == null)\n\t\t\tthrow new IllegalAccessError(\"Transient used after persistent! call\");\n\t}\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/PersistentHashMap.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.io.Serializable;\nimport java.util.ArrayList;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.NoSuchElementException;\nimport java.util.concurrent.Callable;\nimport java.util.concurrent.atomic.AtomicReference;\n\n/*\n A persistent rendition of Phil Bagwell's Hash Array Mapped Trie\n\n Uses path copying for persistence\n HashCollision leaves vs. extended hashing\n Node polymorphism vs. conditionals\n No sub-tree pools or root-resizing\n Any errors are my own\n */\n\npublic class PersistentHashMap extends APersistentMap implements IEditableCollection, IObj, IMapIterable {\n\nfinal int count;\nfinal INode root;\nfinal boolean hasNull;\nfinal Object nullValue;\nfinal IPersistentMap _meta;\n\nfinal public static PersistentHashMap EMPTY = new PersistentHashMap(0, null, false, null);\nfinal private static Object NOT_FOUND = new Object();\n\nstatic public IPersistentMap create(Map other){\n\tITransientMap ret = EMPTY.asTransient();\n\tfor(Object o : other.entrySet())\n\t\t{\n\t\tMap.Entry e = (Entry) o;\n\t\tret = ret.assoc(e.getKey(), e.getValue());\n\t\t}\n\treturn ret.persistent();\n}\n\n/*\n * @param init {key1,val1,key2,val2,...}\n */\npublic static PersistentHashMap create(Object... init){\n\tITransientMap ret = EMPTY.asTransient();\n\tfor(int i = 0; i < init.length; i += 2)\n\t\t{\n\t\tret = ret.assoc(init[i], init[i + 1]);\n\t\t}\n\treturn (PersistentHashMap) ret.persistent();\n}\n\npublic static PersistentHashMap createWithCheck(Object... init){\n\tITransientMap ret = EMPTY.asTransient();\n\tfor(int i = 0; i < init.length; i += 2)\n\t\t{\n\t\tret = ret.assoc(init[i], init[i + 1]);\n\t\tif(ret.count() != i/2 + 1)\n\t\t\tthrow new IllegalArgumentException(\"Duplicate key: \" + init[i]);\n\t\t}\n\treturn (PersistentHashMap) ret.persistent();\n}\n\nstatic public PersistentHashMap create(ISeq items){\n\tITransientMap ret = EMPTY.asTransient();\n\tfor(; items != null; items = items.next().next())\n\t\t{\n\t\tif(items.next() == null)\n\t\t\tthrow new IllegalArgumentException(String.format(\"No value supplied for key: %s\", items.first()));\n\t\tret = ret.assoc(items.first(), RT.second(items));\n\t\t}\n\treturn (PersistentHashMap) ret.persistent();\n}\n\nstatic public PersistentHashMap createWithCheck(ISeq items){\n\tITransientMap ret = EMPTY.asTransient();\n\tfor(int i=0; items != null; items = items.next().next(), ++i)\n\t\t{\n\t\tif(items.next() == null)\n\t\t\tthrow new IllegalArgumentException(String.format(\"No value supplied for key: %s\", items.first()));\n\t\tret = ret.assoc(items.first(), RT.second(items));\n\t\tif(ret.count() != i + 1)\n\t\t\tthrow new IllegalArgumentException(\"Duplicate key: \" + items.first());\n\t\t}\n\treturn (PersistentHashMap) ret.persistent();\n}\n\n/*\n * @param init {key1,val1,key2,val2,...}\n */\npublic static PersistentHashMap create(IPersistentMap meta, Object... init){\n\treturn create(init).withMeta(meta);\n}\n\nPersistentHashMap(int count, INode root, boolean hasNull, Object nullValue){\n\tthis.count = count;\n\tthis.root = root;\n\tthis.hasNull = hasNull;\n\tthis.nullValue = nullValue;\n\tthis._meta = null;\n}\n\npublic PersistentHashMap(IPersistentMap meta, int count, INode root, boolean hasNull, Object nullValue){\n\tthis._meta = meta;\n\tthis.count = count;\n\tthis.root = root;\n\tthis.hasNull = hasNull;\n\tthis.nullValue = nullValue;\n}\n\nstatic int hash(Object k){\n\treturn Util.hasheq(k);\n}\n\npublic boolean containsKey(Object key){\n\tif(key == null)\n\t\treturn hasNull;\n\treturn (root != null) ? root.find(0, hash(key), key, NOT_FOUND) != NOT_FOUND : false;\n}\n\npublic IMapEntry entryAt(Object key){\n\tif(key == null)\n\t\treturn hasNull ? new MapEntry(null, nullValue) : null;\n\treturn (root != null) ? root.find(0, hash(key), key) : null;\n}\n\npublic IPersistentMap assoc(Object key, Object val){\n\tif(key == null) {\n\t\tif(hasNull && val == nullValue)\n\t\t\treturn this;\n\t\treturn new PersistentHashMap(meta(), hasNull ? count : count + 1, root, true, val);\n\t}\n\tBox addedLeaf = new Box(null);\n\tINode newroot = (root == null ? BitmapIndexedNode.EMPTY : root) \n\t\t\t.assoc(0, hash(key), key, val, addedLeaf);\n\tif(newroot == root)\n\t\treturn this;\n\treturn new PersistentHashMap(meta(), addedLeaf.val == null ? count : count + 1, newroot, hasNull, nullValue);\n}\n\npublic Object valAt(Object key, Object notFound){\n\tif(key == null)\n\t\treturn hasNull ? nullValue : notFound;\n\treturn root != null ? root.find(0, hash(key), key, notFound) : notFound;\n}\n\npublic Object valAt(Object key){\n\treturn valAt(key, null);\n}\n\npublic IPersistentMap assocEx(Object key, Object val) {\n\tif(containsKey(key))\n\t\tthrow Util.runtimeException(\"Key already present\");\n\treturn assoc(key, val);\n}\n\npublic IPersistentMap without(Object key){\n\tif(key == null)\n\t\treturn hasNull ? new PersistentHashMap(meta(), count - 1, root, false, null) : this;\n\tif(root == null)\n\t\treturn this;\n\tINode newroot = root.without(0, hash(key), key);\n\tif(newroot == root)\n\t\treturn this;\n\treturn new PersistentHashMap(meta(), count - 1, newroot, hasNull, nullValue); \n}\n\nstatic final Iterator EMPTY_ITER = new Iterator(){\n    public boolean hasNext(){\n        return false;\n    }\n\n    public Object next(){\n        throw new NoSuchElementException();\n    }\n\n    public void remove(){\n        throw new UnsupportedOperationException();\n    }\n};\n\nprivate Iterator iterator(final IFn f){\n    final Iterator rootIter = (root == null) ? EMPTY_ITER : root.iterator(f);\n    if(hasNull) {\n        return new Iterator() {\n            private boolean seen = false;\n            public boolean hasNext() {\n                if (!seen)\n                    return true;\n                else\n                    return rootIter.hasNext();\n            }\n\n            public Object next(){\n                if (!seen) {\n                    seen = true;\n                    return f.invoke(null, nullValue);\n                } else\n                    return rootIter.next();\n            }\n\n            public void remove(){\n                throw new UnsupportedOperationException();\n            }\n        };\n    }\n    else\n        return rootIter;\n}\n\npublic Iterator iterator(){\n    return iterator(APersistentMap.MAKE_ENTRY);\n}\n\npublic Iterator keyIterator(){\n    return iterator(APersistentMap.MAKE_KEY);\n}\n\npublic Iterator valIterator(){\n    return iterator(APersistentMap.MAKE_VAL);\n}\n\npublic Object kvreduce(IFn f, Object init){\n    init = hasNull?f.invoke(init,null,nullValue):init;\n\tif(RT.isReduced(init))\n\t\treturn ((IDeref)init).deref();\n\tif(root != null){\n\t\tinit = root.kvreduce(f,init);\n\t\tif(RT.isReduced(init))\n\t\t\treturn ((IDeref)init).deref();\n\t\telse\n\t\t\treturn init;\n\t}\n\treturn init;\n}\n\npublic Object fold(long n, final IFn combinef, final IFn reducef,\n                   IFn fjinvoke, final IFn fjtask, final IFn fjfork, final IFn fjjoin){\n\t//we are ignoring n for now\n\tCallable top = new Callable(){\n\t\tpublic Object call() throws Exception{\n\t\t\tObject ret = combinef.invoke();\n\t\t\tif(root != null)\n\t\t\t\tret = combinef.invoke(ret, root.fold(combinef,reducef,fjtask,fjfork,fjjoin));\n\t\t\treturn hasNull?\n\t\t\t       combinef.invoke(ret,reducef.invoke(combinef.invoke(),null,nullValue))\n\t\t\t       :ret;\n\t\t}\n\t};\n\treturn fjinvoke.invoke(top);\n}\n\npublic int count(){\n\treturn count;\n}\n\npublic ISeq seq(){\n\tISeq s = root != null ? root.nodeSeq() : null; \n\treturn hasNull ? new Cons(new MapEntry(null, nullValue), s) : s;\n}\n\npublic IPersistentCollection empty(){\n\treturn EMPTY.withMeta(meta());\t\n}\n\nstatic int mask(int hash, int shift){\n\t//return ((hash << shift) >>> 27);// & 0x01f;\n\treturn (hash >>> shift) & 0x01f;\n}\n\npublic PersistentHashMap withMeta(IPersistentMap meta){\n\treturn new PersistentHashMap(meta, count, root, hasNull, nullValue);\n}\n\npublic TransientHashMap asTransient() {\n\treturn new TransientHashMap(this);\n}\n\npublic IPersistentMap meta(){\n\treturn _meta;\n}\n\nstatic final class TransientHashMap extends ATransientMap {\n\tfinal AtomicReference<Thread> edit;\n\tvolatile INode root;\n\tvolatile int count;\n\tvolatile boolean hasNull;\n\tvolatile Object nullValue;\n\tfinal Box leafFlag = new Box(null);\n\n\n\tTransientHashMap(PersistentHashMap m) {\n\t\tthis(new AtomicReference<Thread>(Thread.currentThread()), m.root, m.count, m.hasNull, m.nullValue);\n\t}\n\t\n\tTransientHashMap(AtomicReference<Thread> edit, INode root, int count, boolean hasNull, Object nullValue) {\n\t\tthis.edit = edit;\n\t\tthis.root = root; \n\t\tthis.count = count; \n\t\tthis.hasNull = hasNull;\n\t\tthis.nullValue = nullValue;\n\t}\n\n\tITransientMap doAssoc(Object key, Object val) {\n\t\tif (key == null) {\n\t\t\tif (this.nullValue != val)\n\t\t\t\tthis.nullValue = val;\n\t\t\tif (!hasNull) {\n\t\t\t\tthis.count++;\n\t\t\t\tthis.hasNull = true;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n//\t\tBox leafFlag = new Box(null);\n\t\tleafFlag.val = null;\n\t\tINode n = (root == null ? BitmapIndexedNode.EMPTY : root)\n\t\t\t.assoc(edit, 0, hash(key), key, val, leafFlag);\n\t\tif (n != this.root)\n\t\t\tthis.root = n; \n\t\tif(leafFlag.val != null) this.count++;\n\t\treturn this;\n\t}\n\n\tITransientMap doWithout(Object key) {\n\t\tif (key == null) {\n\t\t\tif (!hasNull) return this;\n\t\t\thasNull = false;\n\t\t\tnullValue = null;\n\t\t\tthis.count--;\n\t\t\treturn this;\n\t\t}\n\t\tif (root == null) return this;\n//\t\tBox leafFlag = new Box(null);\n\t\tleafFlag.val = null;\n\t\tINode n = root.without(edit, 0, hash(key), key, leafFlag);\n\t\tif (n != root)\n\t\t\tthis.root = n;\n\t\tif(leafFlag.val != null) this.count--;\n\t\treturn this;\n\t}\n\n\tIPersistentMap doPersistent() {\n\t\tedit.set(null);\n\t\treturn new PersistentHashMap(count, root, hasNull, nullValue);\n\t}\n\n\tObject doValAt(Object key, Object notFound) {\n\t\tif (key == null) {\n\t\t\tif (hasNull) {\n\t\t\t\treturn nullValue;\n\t\t\t} else {\n\t\t\t\treturn notFound;\n\t\t\t}\n\t\t}\n\t\tif (root == null) {\n\t\t\treturn notFound;\n\t\t}\n\t\treturn root.find(0, hash(key), key, notFound);\n\t}\n\n\tint doCount() {\n\t\treturn count;\n\t}\n\t\n\tvoid ensureEditable(){\n\t\tif(edit.get() == null)\n\t\t\tthrow new IllegalAccessError(\"Transient used after persistent! call\");\n\t}\n}\n\nstatic interface INode extends Serializable {\n\tINode assoc(int shift, int hash, Object key, Object val, Box addedLeaf);\n\n\tINode without(int shift, int hash, Object key);\n\n\tIMapEntry find(int shift, int hash, Object key);\n\n\tObject find(int shift, int hash, Object key, Object notFound);\n\n\tISeq nodeSeq();\n\n\tINode assoc(AtomicReference<Thread> edit, int shift, int hash, Object key, Object val, Box addedLeaf);\n\n\tINode without(AtomicReference<Thread> edit, int shift, int hash, Object key, Box removedLeaf);\n\n    public Object kvreduce(IFn f, Object init);\n\n\tObject fold(IFn combinef, IFn reducef, IFn fjtask, IFn fjfork, IFn fjjoin);\n\n    // returns the result of (f [k v]) for each iterated element\n    Iterator iterator(IFn f);\n}\n\nfinal static class ArrayNode implements INode{\n\tint count;\n\tfinal INode[] array;\n\tfinal AtomicReference<Thread> edit;\n\n\tArrayNode(AtomicReference<Thread> edit, int count, INode[] array){\n\t\tthis.array = array;\n\t\tthis.edit = edit;\n\t\tthis.count = count;\n\t}\n\n\tpublic INode assoc(int shift, int hash, Object key, Object val, Box addedLeaf){\n\t\tint idx = mask(hash, shift);\n\t\tINode node = array[idx];\n\t\tif(node == null)\n\t\t\treturn new ArrayNode(null, count + 1, cloneAndSet(array, idx, BitmapIndexedNode.EMPTY.assoc(shift + 5, hash, key, val, addedLeaf)));\t\t\t\n\t\tINode n = node.assoc(shift + 5, hash, key, val, addedLeaf);\n\t\tif(n == node)\n\t\t\treturn this;\n\t\treturn new ArrayNode(null, count, cloneAndSet(array, idx, n));\n\t}\n\n\tpublic INode without(int shift, int hash, Object key){\n\t\tint idx = mask(hash, shift);\n\t\tINode node = array[idx];\n\t\tif(node == null)\n\t\t\treturn this;\n\t\tINode n = node.without(shift + 5, hash, key);\n\t\tif(n == node)\n\t\t\treturn this;\n\t\tif (n == null) {\n\t\t\tif (count <= 8) // shrink\n\t\t\t\treturn pack(null, idx);\n\t\t\treturn new ArrayNode(null, count - 1, cloneAndSet(array, idx, n));\n\t\t} else \n\t\t\treturn new ArrayNode(null, count, cloneAndSet(array, idx, n));\n\t}\n\n\tpublic IMapEntry find(int shift, int hash, Object key){\n\t\tint idx = mask(hash, shift);\n\t\tINode node = array[idx];\n\t\tif(node == null)\n\t\t\treturn null;\n\t\treturn node.find(shift + 5, hash, key); \n\t}\n\n\tpublic Object find(int shift, int hash, Object key, Object notFound){\n\t\tint idx = mask(hash, shift);\n\t\tINode node = array[idx];\n\t\tif(node == null)\n\t\t\treturn notFound;\n\t\treturn node.find(shift + 5, hash, key, notFound); \n\t}\n\t\n\tpublic ISeq nodeSeq(){\n\t\treturn Seq.create(array);\n\t}\n\n    public Iterator iterator(IFn f){\n        return new Iter(array, f);\n    }\n\n    public Object kvreduce(IFn f, Object init){\n        for(INode node : array){\n            if(node != null){\n                init = node.kvreduce(f,init);\n\t            if(RT.isReduced(init))\n\t\t            return init;\n\t            }\n\t        }\n        return init;\n    }\n\n\tpublic Object fold(final IFn combinef, final IFn reducef,\n\t                   final IFn fjtask, final IFn fjfork, final IFn fjjoin){\n\t\tList<Callable> tasks = new ArrayList();\n\t\tfor(final INode node : array){\n\t\t\tif(node != null){\n\t\t\t\ttasks.add(new Callable(){\n\t\t\t\t\tpublic Object call() throws Exception{\n\t\t\t\t\t\treturn node.fold(combinef, reducef, fjtask, fjfork, fjjoin);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\treturn foldTasks(tasks,combinef,fjtask,fjfork,fjjoin);\n\t\t}\n\n\tstatic public Object foldTasks(List<Callable> tasks, final IFn combinef,\n\t                          final IFn fjtask, final IFn fjfork, final IFn fjjoin){\n\n\t\tif(tasks.isEmpty())\n\t\t\treturn combinef.invoke();\n\n\t\tif(tasks.size() == 1){\n\t\t\tObject ret = null;\n\t\t\ttry\n\t\t\t\t{\n\t\t\t\treturn tasks.get(0).call();\n\t\t\t\t}\n\t\t\tcatch(Exception e)\n\t\t\t\t{\n\t\t\t\tthrow Util.sneakyThrow(e);\n\t\t\t\t}\n\t\t\t}\n\n\t\tList<Callable> t1 = tasks.subList(0,tasks.size()/2);\n\t\tfinal List<Callable> t2 = tasks.subList(tasks.size()/2, tasks.size());\n\n\t\tObject forked = fjfork.invoke(fjtask.invoke(new Callable() {\n\t\t\tpublic Object call() throws Exception{\n\t\t\t\treturn foldTasks(t2,combinef,fjtask,fjfork,fjjoin);\n\t\t\t}\n\t\t}));\n\n\t\treturn combinef.invoke(foldTasks(t1,combinef,fjtask,fjfork,fjjoin),fjjoin.invoke(forked));\n\t}\n\n\n\tprivate ArrayNode ensureEditable(AtomicReference<Thread> edit){\n\t\tif(this.edit == edit)\n\t\t\treturn this;\n\t\treturn new ArrayNode(edit, count, this.array.clone());\n\t}\n\t\n\tprivate ArrayNode editAndSet(AtomicReference<Thread> edit, int i, INode n){\n\t\tArrayNode editable = ensureEditable(edit);\n\t\teditable.array[i] = n;\n\t\treturn editable;\n\t}\n\n\n\tprivate INode pack(AtomicReference<Thread> edit, int idx) {\n\t\tObject[] newArray = new Object[2*(count - 1)];\n\t\tint j = 1;\n\t\tint bitmap = 0;\n\t\tfor(int i = 0; i < idx; i++)\n\t\t\tif (array[i] != null) {\n\t\t\t\tnewArray[j] = array[i];\n\t\t\t\tbitmap |= 1 << i;\n\t\t\t\tj += 2;\n\t\t\t}\n\t\tfor(int i = idx + 1; i < array.length; i++)\n\t\t\tif (array[i] != null) {\n\t\t\t\tnewArray[j] = array[i];\n\t\t\t\tbitmap |= 1 << i;\n\t\t\t\tj += 2;\n\t\t\t}\n\t\treturn new BitmapIndexedNode(edit, bitmap, newArray);\n\t}\n\n\tpublic INode assoc(AtomicReference<Thread> edit, int shift, int hash, Object key, Object val, Box addedLeaf){\n\t\tint idx = mask(hash, shift);\n\t\tINode node = array[idx];\n\t\tif(node == null) {\n\t\t\tArrayNode editable = editAndSet(edit, idx, BitmapIndexedNode.EMPTY.assoc(edit, shift + 5, hash, key, val, addedLeaf));\n\t\t\teditable.count++;\n\t\t\treturn editable;\t\t\t\n\t\t}\n\t\tINode n = node.assoc(edit, shift + 5, hash, key, val, addedLeaf);\n\t\tif(n == node)\n\t\t\treturn this;\n\t\treturn editAndSet(edit, idx, n);\n\t}\t\n\n\tpublic INode without(AtomicReference<Thread> edit, int shift, int hash, Object key, Box removedLeaf){\n\t\tint idx = mask(hash, shift);\n\t\tINode node = array[idx];\n\t\tif(node == null)\n\t\t\treturn this;\n\t\tINode n = node.without(edit, shift + 5, hash, key, removedLeaf);\n\t\tif(n == node)\n\t\t\treturn this;\n\t\tif(n == null) {\n\t\t\tif (count <= 8) // shrink\n\t\t\t\treturn pack(edit, idx);\n\t\t\tArrayNode editable = editAndSet(edit, idx, n);\n\t\t\teditable.count--;\n\t\t\treturn editable;\n\t\t}\n\t\treturn editAndSet(edit, idx, n);\n\t}\n\t\n\tstatic class Seq extends ASeq {\n\t\tfinal INode[] nodes;\n\t\tfinal int i;\n\t\tfinal ISeq s; \n\t\t\n\t\tstatic ISeq create(INode[] nodes) {\n\t\t\treturn create(null, nodes, 0, null);\n\t\t}\n\t\t\n\t\tprivate static ISeq create(IPersistentMap meta, INode[] nodes, int i, ISeq s) {\n\t\t\tif (s != null)\n\t\t\t\treturn new Seq(meta, nodes, i, s);\n\t\t\tfor(int j = i; j < nodes.length; j++)\n\t\t\t\tif (nodes[j] != null) {\n\t\t\t\t\tISeq ns = nodes[j].nodeSeq();\n\t\t\t\t\tif (ns != null)\n\t\t\t\t\t\treturn new Seq(meta, nodes, j + 1, ns);\n\t\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tprivate Seq(IPersistentMap meta, INode[] nodes, int i, ISeq s) {\n\t\t\tsuper(meta);\n\t\t\tthis.nodes = nodes;\n\t\t\tthis.i = i;\n\t\t\tthis.s = s;\n\t\t}\n\n\t\tpublic Obj withMeta(IPersistentMap meta) {\n\t\t\treturn new Seq(meta, nodes, i, s);\n\t\t}\n\n\t\tpublic Object first() {\n\t\t\treturn s.first();\n\t\t}\n\n\t\tpublic ISeq next() {\n\t\t\treturn create(null, nodes, i, s.next());\n\t\t}\n\t\t\n\t}\n\n    static class Iter implements Iterator {\n        private final INode[] array;\n        private final IFn f;\n        private int i = 0;\n        private Iterator nestedIter;\n\n        private Iter(INode[] array, IFn f){\n            this.array = array;\n            this.f = f;\n        }\n\n        public boolean hasNext(){\n            while(true)\n            {\n                if(nestedIter != null) {\n                    if(nestedIter.hasNext())\n                        return true;\n                    else\n                        nestedIter = null;\n                }\n\n                if(i < array.length)\n                {\n                    INode node = array[i++];\n                    if (node != null)\n                        nestedIter = node.iterator(f);\n                }\n                else\n                    return false;\n            }\n        }\n\n        public Object next(){\n            if(hasNext())\n                return nestedIter.next();\n            else\n                throw new NoSuchElementException();\n        }\n\n        public void remove(){\n            throw new UnsupportedOperationException();\n        }\n    }\n}\n\nfinal static class BitmapIndexedNode implements INode{\n\tstatic final BitmapIndexedNode EMPTY = new BitmapIndexedNode(null, 0, new Object[0]);\n\t\n\tint bitmap;\n\tObject[] array;\n\tfinal AtomicReference<Thread> edit;\n\n\tfinal int index(int bit){\n\t\treturn Integer.bitCount(bitmap & (bit - 1));\n\t}\n\n\tBitmapIndexedNode(AtomicReference<Thread> edit, int bitmap, Object[] array){\n\t\tthis.bitmap = bitmap;\n\t\tthis.array = array;\n\t\tthis.edit = edit;\n\t}\n\n\tpublic INode assoc(int shift, int hash, Object key, Object val, Box addedLeaf){\n\t\tint bit = bitpos(hash, shift);\n\t\tint idx = index(bit);\n\t\tif((bitmap & bit) != 0) {\n\t\t\tObject keyOrNull = array[2*idx];\n\t\t\tObject valOrNode = array[2*idx+1];\n\t\t\tif(keyOrNull == null) {\n\t\t\t\tINode n = ((INode) valOrNode).assoc(shift + 5, hash, key, val, addedLeaf);\n\t\t\t\tif(n == valOrNode)\n\t\t\t\t\treturn this;\n\t\t\t\treturn new BitmapIndexedNode(null, bitmap, cloneAndSet(array, 2*idx+1, n));\n\t\t\t} \n\t\t\tif(Util.equiv(key, keyOrNull)) {\n\t\t\t\tif(val == valOrNode)\n\t\t\t\t\treturn this;\n\t\t\t\treturn new BitmapIndexedNode(null, bitmap, cloneAndSet(array, 2*idx+1, val));\n\t\t\t} \n\t\t\taddedLeaf.val = addedLeaf;\n\t\t\treturn new BitmapIndexedNode(null, bitmap, \n\t\t\t\t\tcloneAndSet(array, \n\t\t\t\t\t\t\t2*idx, null, \n\t\t\t\t\t\t\t2*idx+1, createNode(shift + 5, keyOrNull, valOrNode, hash, key, val)));\n\t\t} else {\n\t\t\tint n = Integer.bitCount(bitmap);\n\t\t\tif(n >= 16) {\n\t\t\t\tINode[] nodes = new INode[32];\n\t\t\t\tint jdx = mask(hash, shift);\n\t\t\t\tnodes[jdx] = EMPTY.assoc(shift + 5, hash, key, val, addedLeaf);  \n\t\t\t\tint j = 0;\n\t\t\t\tfor(int i = 0; i < 32; i++)\n\t\t\t\t\tif(((bitmap >>> i) & 1) != 0) {\n\t\t\t\t\t\tif (array[j] == null)\n\t\t\t\t\t\t\tnodes[i] = (INode) array[j+1];\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tnodes[i] = EMPTY.assoc(shift + 5, hash(array[j]), array[j], array[j+1], addedLeaf);\n\t\t\t\t\t\tj += 2;\n\t\t\t\t\t}\n\t\t\t\treturn new ArrayNode(null, n + 1, nodes);\n\t\t\t} else {\n\t\t\t\tObject[] newArray = new Object[2*(n+1)];\n\t\t\t\tSystem.arraycopy(array, 0, newArray, 0, 2*idx);\n\t\t\t\tnewArray[2*idx] = key;\n\t\t\t\taddedLeaf.val = addedLeaf; \n\t\t\t\tnewArray[2*idx+1] = val;\n\t\t\t\tSystem.arraycopy(array, 2*idx, newArray, 2*(idx+1), 2*(n-idx));\n\t\t\t\treturn new BitmapIndexedNode(null, bitmap | bit, newArray);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic INode without(int shift, int hash, Object key){\n\t\tint bit = bitpos(hash, shift);\n\t\tif((bitmap & bit) == 0)\n\t\t\treturn this;\n\t\tint idx = index(bit);\n\t\tObject keyOrNull = array[2*idx];\n\t\tObject valOrNode = array[2*idx+1];\n\t\tif(keyOrNull == null) {\n\t\t\tINode n = ((INode) valOrNode).without(shift + 5, hash, key);\n\t\t\tif (n == valOrNode)\n\t\t\t\treturn this;\n\t\t\tif (n != null)\n\t\t\t\treturn new BitmapIndexedNode(null, bitmap, cloneAndSet(array, 2*idx+1, n));\n\t\t\tif (bitmap == bit) \n\t\t\t\treturn null;\n\t\t\treturn new BitmapIndexedNode(null, bitmap ^ bit, removePair(array, idx));\n\t\t}\n\t\tif(Util.equiv(key, keyOrNull))\n\t\t\t// TODO: collapse\n\t\t\treturn new BitmapIndexedNode(null, bitmap ^ bit, removePair(array, idx));\n\t\treturn this;\n\t}\n\t\n\tpublic IMapEntry find(int shift, int hash, Object key){\n\t\tint bit = bitpos(hash, shift);\n\t\tif((bitmap & bit) == 0)\n\t\t\treturn null;\n\t\tint idx = index(bit);\n\t\tObject keyOrNull = array[2*idx];\n\t\tObject valOrNode = array[2*idx+1];\n\t\tif(keyOrNull == null)\n\t\t\treturn ((INode) valOrNode).find(shift + 5, hash, key);\n\t\tif(Util.equiv(key, keyOrNull))\n\t\t\treturn new MapEntry(keyOrNull, valOrNode);\n\t\treturn null;\n\t}\n\n\tpublic Object find(int shift, int hash, Object key, Object notFound){\n\t\tint bit = bitpos(hash, shift);\n\t\tif((bitmap & bit) == 0)\n\t\t\treturn notFound;\n\t\tint idx = index(bit);\n\t\tObject keyOrNull = array[2*idx];\n\t\tObject valOrNode = array[2*idx+1];\n\t\tif(keyOrNull == null)\n\t\t\treturn ((INode) valOrNode).find(shift + 5, hash, key, notFound);\n\t\tif(Util.equiv(key, keyOrNull))\n\t\t\treturn valOrNode;\n\t\treturn notFound;\n\t}\n\n\tpublic ISeq nodeSeq(){\n\t\treturn NodeSeq.create(array);\n\t}\n\n    public Iterator iterator(IFn f){\n        return new NodeIter(array, f);\n    }\n\n    public Object kvreduce(IFn f, Object init){\n         return NodeSeq.kvreduce(array,f,init);\n    }\n\n\tpublic Object fold(IFn combinef, IFn reducef, IFn fjtask, IFn fjfork, IFn fjjoin){\n\t\treturn NodeSeq.kvreduce(array, reducef, combinef.invoke());\n\t}\n\n\tprivate BitmapIndexedNode ensureEditable(AtomicReference<Thread> edit){\n\t\tif(this.edit == edit)\n\t\t\treturn this;\n\t\tint n = Integer.bitCount(bitmap);\n\t\tObject[] newArray = new Object[n >= 0 ? 2*(n+1) : 4]; // make room for next assoc\n\t\tSystem.arraycopy(array, 0, newArray, 0, 2*n);\n\t\treturn new BitmapIndexedNode(edit, bitmap, newArray);\n\t}\n\t\n\tprivate BitmapIndexedNode editAndSet(AtomicReference<Thread> edit, int i, Object a) {\n\t\tBitmapIndexedNode editable = ensureEditable(edit);\n\t\teditable.array[i] = a;\n\t\treturn editable;\n\t}\n\n\tprivate BitmapIndexedNode editAndSet(AtomicReference<Thread> edit, int i, Object a, int j, Object b) {\n\t\tBitmapIndexedNode editable = ensureEditable(edit);\n\t\teditable.array[i] = a;\n\t\teditable.array[j] = b;\n\t\treturn editable;\n\t}\n\n\tprivate BitmapIndexedNode editAndRemovePair(AtomicReference<Thread> edit, int bit, int i) {\n\t\tif (bitmap == bit) \n\t\t\treturn null;\n\t\tBitmapIndexedNode editable = ensureEditable(edit);\n\t\teditable.bitmap ^= bit;\n\t\tSystem.arraycopy(editable.array, 2*(i+1), editable.array, 2*i, editable.array.length - 2*(i+1));\n\t\teditable.array[editable.array.length - 2] = null;\n\t\teditable.array[editable.array.length - 1] = null;\n\t\treturn editable;\n\t}\n\n\tpublic INode assoc(AtomicReference<Thread> edit, int shift, int hash, Object key, Object val, Box addedLeaf){\n\t\tint bit = bitpos(hash, shift);\n\t\tint idx = index(bit);\n\t\tif((bitmap & bit) != 0) {\n\t\t\tObject keyOrNull = array[2*idx];\n\t\t\tObject valOrNode = array[2*idx+1];\n\t\t\tif(keyOrNull == null) {\n\t\t\t\tINode n = ((INode) valOrNode).assoc(edit, shift + 5, hash, key, val, addedLeaf);\n\t\t\t\tif(n == valOrNode)\n\t\t\t\t\treturn this;\n\t\t\t\treturn editAndSet(edit, 2*idx+1, n);\n\t\t\t} \n\t\t\tif(Util.equiv(key, keyOrNull)) {\n\t\t\t\tif(val == valOrNode)\n\t\t\t\t\treturn this;\n\t\t\t\treturn editAndSet(edit, 2*idx+1, val);\n\t\t\t} \n\t\t\taddedLeaf.val = addedLeaf;\n\t\t\treturn editAndSet(edit, 2*idx, null, 2*idx+1, \n\t\t\t\t\tcreateNode(edit, shift + 5, keyOrNull, valOrNode, hash, key, val)); \n\t\t} else {\n\t\t\tint n = Integer.bitCount(bitmap);\n\t\t\tif(n*2 < array.length) {\n\t\t\t\taddedLeaf.val = addedLeaf;\n\t\t\t\tBitmapIndexedNode editable = ensureEditable(edit);\n\t\t\t\tSystem.arraycopy(editable.array, 2*idx, editable.array, 2*(idx+1), 2*(n-idx));\n\t\t\t\teditable.array[2*idx] = key;\n\t\t\t\teditable.array[2*idx+1] = val;\n\t\t\t\teditable.bitmap |= bit;\n\t\t\t\treturn editable;\n\t\t\t}\n\t\t\tif(n >= 16) {\n\t\t\t\tINode[] nodes = new INode[32];\n\t\t\t\tint jdx = mask(hash, shift);\n\t\t\t\tnodes[jdx] = EMPTY.assoc(edit, shift + 5, hash, key, val, addedLeaf);  \n\t\t\t\tint j = 0;\n\t\t\t\tfor(int i = 0; i < 32; i++)\n\t\t\t\t\tif(((bitmap >>> i) & 1) != 0) {\n\t\t\t\t\t\tif (array[j] == null)\n\t\t\t\t\t\t\tnodes[i] = (INode) array[j+1];\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tnodes[i] = EMPTY.assoc(edit, shift + 5, hash(array[j]), array[j], array[j+1], addedLeaf);\n\t\t\t\t\t\tj += 2;\n\t\t\t\t\t}\n\t\t\t\treturn new ArrayNode(edit, n + 1, nodes);\n\t\t\t} else {\n\t\t\t\tObject[] newArray = new Object[2*(n+4)];\n\t\t\t\tSystem.arraycopy(array, 0, newArray, 0, 2*idx);\n\t\t\t\tnewArray[2*idx] = key;\n\t\t\t\taddedLeaf.val = addedLeaf; \n\t\t\t\tnewArray[2*idx+1] = val;\n\t\t\t\tSystem.arraycopy(array, 2*idx, newArray, 2*(idx+1), 2*(n-idx));\n\t\t\t\tBitmapIndexedNode editable = ensureEditable(edit);\n\t\t\t\teditable.array = newArray;\n\t\t\t\teditable.bitmap |= bit;\n\t\t\t\treturn editable;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic INode without(AtomicReference<Thread> edit, int shift, int hash, Object key, Box removedLeaf){\n\t\tint bit = bitpos(hash, shift);\n\t\tif((bitmap & bit) == 0)\n\t\t\treturn this;\n\t\tint idx = index(bit);\n\t\tObject keyOrNull = array[2*idx];\n\t\tObject valOrNode = array[2*idx+1];\n\t\tif(keyOrNull == null) {\n\t\t\tINode n = ((INode) valOrNode).without(edit, shift + 5, hash, key, removedLeaf);\n\t\t\tif (n == valOrNode)\n\t\t\t\treturn this;\n\t\t\tif (n != null)\n\t\t\t\treturn editAndSet(edit, 2*idx+1, n); \n\t\t\tif (bitmap == bit) \n\t\t\t\treturn null;\n\t\t\treturn editAndRemovePair(edit, bit, idx); \n\t\t}\n\t\tif(Util.equiv(key, keyOrNull)) {\n\t\t\tremovedLeaf.val = removedLeaf;\n\t\t\t// TODO: collapse\n\t\t\treturn editAndRemovePair(edit, bit, idx); \t\t\t\n\t\t}\n\t\treturn this;\n\t}\n}\n\nfinal static class HashCollisionNode implements INode{\n\n\tfinal int hash;\n\tint count;\n\tObject[] array;\n\tfinal AtomicReference<Thread> edit;\n\tint[] keys;\n\n\tHashCollisionNode(AtomicReference<Thread> edit, int hash, int count, Object... array){\n\t\tthis.edit = edit;\n\t\tthis.hash = hash;\n\t\tthis.count = count;\n\t\tthis.array = array;\n\t}\n\t\n\tvoid ensureKeys() {\n\t  if (keys == null) {\n  \t  keys = new int[array.length];\n      for(int i = 0; i < array.length; i+=2) {\n        keys[i] = Util.hash(array[i]);\n      }  \n\t  }\n\t}\n\n\tpublic INode assoc(int shift, int hash, Object key, Object val, Box addedLeaf){\n\t\tif(hash == this.hash) {\n\t\t\tint idx = findIndex(key);\n\t\t\tif(idx != -1) {\n\t\t\t\tif(array[idx + 1] == val)\n\t\t\t\t\treturn this;\n\t\t\t\treturn new HashCollisionNode(null, hash, count, cloneAndSet(array, idx + 1, val));\n\t\t\t}\n\t\t\tObject[] newArray = new Object[2 * (count + 1)];\n\t\t\tSystem.arraycopy(array, 0, newArray, 0, 2 * count);\n\t\t\tnewArray[2 * count] = key;\n\t\t\tnewArray[2 * count + 1] = val;\n\t\t\taddedLeaf.val = addedLeaf;\n\t\t\treturn new HashCollisionNode(edit, hash, count + 1, newArray);\n\t\t}\n\t\t// nest it in a bitmap node\n\t\treturn new BitmapIndexedNode(null, bitpos(this.hash, shift), new Object[] {null, this})\n\t\t\t.assoc(shift, hash, key, val, addedLeaf);\n\t}\n\n\tpublic INode without(int shift, int hash, Object key){\n\t\tint idx = findIndex(key);\n\t\tif(idx == -1)\n\t\t\treturn this;\n\t\tif(count == 1)\n\t\t\treturn null;\n\t\treturn new HashCollisionNode(null, hash, count - 1, removePair(array, idx/2));\n\t}\n\n\tpublic IMapEntry find(int shift, int hash, Object key){\n\t\tint idx = findIndex(key);\n\t\tif(idx < 0)\n\t\t\treturn null;\n\t\tif(Util.equiv(key, array[idx]))\n\t\t\treturn new MapEntry(array[idx], array[idx+1]);\n\t\treturn null;\n\t}\n\n\tpublic Object find(int shift, int hash, Object key, Object notFound){\n\t\tint idx = findIndex(key);\n\t\tif(idx < 0)\n\t\t\treturn notFound;\n\t\tif(Util.equiv(key, array[idx]))\n\t\t\treturn array[idx+1];\n\t\treturn notFound;\n\t}\n\n\tpublic ISeq nodeSeq(){\n\t\treturn NodeSeq.create(array);\n\t}\n\n    public Iterator iterator(IFn f){\n        return new NodeIter(array, f);\n    }\n\n    public Object kvreduce(IFn f, Object init){\n         return NodeSeq.kvreduce(array,f,init);\n    }\n\n\tpublic Object fold(IFn combinef, IFn reducef, IFn fjtask, IFn fjfork, IFn fjjoin){\n\t\treturn NodeSeq.kvreduce(array, reducef, combinef.invoke());\n\t}\n\n\tpublic int findIndex(Object key){\n\t  ensureKeys();\n\t  int hash = Util.hash(key);\n    for(int i = 0; i < 2*count; i+=2)\n\t\t  {\n      if(keys[i] == hash && Util.equiv(key, array[i]))\n        return i;\n\t\t  }\n\t\treturn -1;\n\t}\n\n\tprivate HashCollisionNode ensureEditable(AtomicReference<Thread> edit){\n\t\tif(this.edit == edit)\n\t\t\treturn this;\n\t\tObject[] newArray = new Object[2*(count+1)]; // make room for next assoc\n\t\tSystem.arraycopy(array, 0, newArray, 0, 2*count);\n\t\treturn new HashCollisionNode(edit, hash, count, newArray);\n\t}\n\n\tprivate HashCollisionNode ensureEditable(AtomicReference<Thread> edit, int count, Object[] array){\n\t\tif(this.edit == edit) {\n\t\t\tthis.array = array;\n\t\t\tthis.count = count;\n\t\t\tthis.keys = null;\n\t\t\treturn this;\n\t\t}\n\t\treturn new HashCollisionNode(edit, hash, count, array);\n\t}\n\n\tprivate HashCollisionNode editAndSet(AtomicReference<Thread> edit, int i, Object a) {\n\t\tHashCollisionNode editable = ensureEditable(edit);\n\t\teditable.array[i] = a;\n\t\treturn editable;\n\t}\n\n\tprivate HashCollisionNode editAndSet(AtomicReference<Thread> edit, int i, Object a, int j, Object b) {\n\t\tHashCollisionNode editable = ensureEditable(edit);\n\t\teditable.array[i] = a;\n\t\teditable.array[j] = b;\n\t\treturn editable;\n\t}\n\n\n\tpublic INode assoc(AtomicReference<Thread> edit, int shift, int hash, Object key, Object val, Box addedLeaf){\n\t\tif(hash == this.hash) {\n\t\t\tint idx = findIndex(key);\n\t\t\tif(idx != -1) {\n\t\t\t\tif(array[idx + 1] == val)\n\t\t\t\t\treturn this;\n\t\t\t\treturn editAndSet(edit, idx+1, val); \n\t\t\t}\n\t\t\tif (array.length > 2*count) {\n\t\t\t\taddedLeaf.val = addedLeaf;\n\t\t\t\tHashCollisionNode editable = editAndSet(edit, 2*count, key, 2*count+1, val);\n\t\t\t\teditable.count++;\n\t\t\t\treturn editable;\n\t\t\t}\n\t\t\tObject[] newArray = new Object[array.length + 2];\n\t\t\tSystem.arraycopy(array, 0, newArray, 0, array.length);\n\t\t\tnewArray[array.length] = key;\n\t\t\tnewArray[array.length + 1] = val;\n\t\t\taddedLeaf.val = addedLeaf;\n\t\t\treturn ensureEditable(edit, count + 1, newArray);\n\t\t}\n\t\t// nest it in a bitmap node\n\t\treturn new BitmapIndexedNode(edit, bitpos(this.hash, shift), new Object[] {null, this, null, null})\n\t\t\t.assoc(edit, shift, hash, key, val, addedLeaf);\n\t}\t\n\n\tpublic INode without(AtomicReference<Thread> edit, int shift, int hash, Object key, Box removedLeaf){\n\t\tint idx = findIndex(key);\n\t\tif(idx == -1)\n\t\t\treturn this;\n\t\tremovedLeaf.val = removedLeaf;\n\t\tif(count == 1)\n\t\t\treturn null;\n\t\tHashCollisionNode editable = ensureEditable(edit);\n\t\teditable.array[idx] = editable.array[2*count-2];\n\t\teditable.array[idx+1] = editable.array[2*count-1];\n\t\teditable.array[2*count-2] = editable.array[2*count-1] = null;\n\t\teditable.count--;\n\t\treturn editable;\n\t}\n}\n\n/*\npublic static void main(String[] args){\n\ttry\n\t\t{\n\t\tArrayList words = new ArrayList();\n\t\tScanner s = new Scanner(new File(args[0]));\n\t\ts.useDelimiter(Pattern.compile(\"\\\\W\"));\n\t\twhile(s.hasNext())\n\t\t\t{\n\t\t\tString word = s.next();\n\t\t\twords.add(word);\n\t\t\t}\n\t\tSystem.out.println(\"words: \" + words.size());\n\t\tIPersistentMap map = PersistentHashMap.EMPTY;\n\t\t//IPersistentMap map = new PersistentTreeMap();\n\t\t//Map ht = new Hashtable();\n\t\tMap ht = new HashMap();\n\t\tRandom rand;\n\n\t\tSystem.out.println(\"Building map\");\n\t\tlong startTime = System.nanoTime();\n\t\tfor(Object word5 : words)\n\t\t\t{\n\t\t\tmap = map.assoc(word5, word5);\n\t\t\t}\n\t\trand = new Random(42);\n\t\tIPersistentMap snapshotMap = map;\n\t\tfor(int i = 0; i < words.size() / 200; i++)\n\t\t\t{\n\t\t\tmap = map.without(words.get(rand.nextInt(words.size() / 2)));\n\t\t\t}\n\t\tlong estimatedTime = System.nanoTime() - startTime;\n\t\tSystem.out.println(\"count = \" + map.count() + \", time: \" + estimatedTime / 1000000);\n\n\t\tSystem.out.println(\"Building ht\");\n\t\tstartTime = System.nanoTime();\n\t\tfor(Object word1 : words)\n\t\t\t{\n\t\t\tht.put(word1, word1);\n\t\t\t}\n\t\trand = new Random(42);\n\t\tfor(int i = 0; i < words.size() / 200; i++)\n\t\t\t{\n\t\t\tht.remove(words.get(rand.nextInt(words.size() / 2)));\n\t\t\t}\n\t\testimatedTime = System.nanoTime() - startTime;\n\t\tSystem.out.println(\"count = \" + ht.size() + \", time: \" + estimatedTime / 1000000);\n\n\t\tSystem.out.println(\"map lookup\");\n\t\tstartTime = System.nanoTime();\n\t\tint c = 0;\n\t\tfor(Object word2 : words)\n\t\t\t{\n\t\t\tif(!map.contains(word2))\n\t\t\t\t++c;\n\t\t\t}\n\t\testimatedTime = System.nanoTime() - startTime;\n\t\tSystem.out.println(\"notfound = \" + c + \", time: \" + estimatedTime / 1000000);\n\t\tSystem.out.println(\"ht lookup\");\n\t\tstartTime = System.nanoTime();\n\t\tc = 0;\n\t\tfor(Object word3 : words)\n\t\t\t{\n\t\t\tif(!ht.containsKey(word3))\n\t\t\t\t++c;\n\t\t\t}\n\t\testimatedTime = System.nanoTime() - startTime;\n\t\tSystem.out.println(\"notfound = \" + c + \", time: \" + estimatedTime / 1000000);\n\t\tSystem.out.println(\"snapshotMap lookup\");\n\t\tstartTime = System.nanoTime();\n\t\tc = 0;\n\t\tfor(Object word4 : words)\n\t\t\t{\n\t\t\tif(!snapshotMap.contains(word4))\n\t\t\t\t++c;\n\t\t\t}\n\t\testimatedTime = System.nanoTime() - startTime;\n\t\tSystem.out.println(\"notfound = \" + c + \", time: \" + estimatedTime / 1000000);\n\t\t}\n\tcatch(FileNotFoundException e)\n\t\t{\n\t\te.printStackTrace();\n\t\t}\n\n}\n*/\n\nprivate static INode[] cloneAndSet(INode[] array, int i, INode a) {\n\tINode[] clone = array.clone();\n\tclone[i] = a;\n\treturn clone;\n}\n\nprivate static Object[] cloneAndSet(Object[] array, int i, Object a) {\n\tObject[] clone = array.clone();\n\tclone[i] = a;\n\treturn clone;\n}\n\nprivate static Object[] cloneAndSet(Object[] array, int i, Object a, int j, Object b) {\n\tObject[] clone = array.clone();\n\tclone[i] = a;\n\tclone[j] = b;\n\treturn clone;\n}\n\nprivate static Object[] removePair(Object[] array, int i) {\n\tObject[] newArray = new Object[array.length - 2];\n\tSystem.arraycopy(array, 0, newArray, 0, 2*i);\n\tSystem.arraycopy(array, 2*(i+1), newArray, 2*i, newArray.length - 2*i);\n\treturn newArray;\n}\n\nprivate static INode createNode(int shift, Object key1, Object val1, int key2hash, Object key2, Object val2) {\n\tint key1hash = hash(key1);\n\tif(key1hash == key2hash)\n\t\treturn new HashCollisionNode(null, key1hash, 2, new Object[] {key1, val1, key2, val2});\n\tBox addedLeaf = new Box(null);\n\tAtomicReference<Thread> edit = new AtomicReference<Thread>();\n\treturn BitmapIndexedNode.EMPTY\n\t\t.assoc(edit, shift, key1hash, key1, val1, addedLeaf)\n\t\t.assoc(edit, shift, key2hash, key2, val2, addedLeaf);\n}\n\nprivate static INode createNode(AtomicReference<Thread> edit, int shift, Object key1, Object val1, int key2hash, Object key2, Object val2) {\n\tint key1hash = hash(key1);\n\tif(key1hash == key2hash)\n\t\treturn new HashCollisionNode(null, key1hash, 2, new Object[] {key1, val1, key2, val2});\n\tBox addedLeaf = new Box(null);\n\treturn BitmapIndexedNode.EMPTY\n\t\t.assoc(edit, shift, key1hash, key1, val1, addedLeaf)\n\t\t.assoc(edit, shift, key2hash, key2, val2, addedLeaf);\n}\n\nprivate static int bitpos(int hash, int shift){\n\treturn 1 << mask(hash, shift);\n}\n\nstatic final class NodeIter implements Iterator {\n    private static final Object NULL = new Object();\n    final Object[] array;\n    final IFn f;\n    private int i = 0;\n    private Object nextEntry = NULL;\n    private Iterator nextIter;\n\n    NodeIter(Object[] array, IFn f){\n        this.array = array;\n        this.f = f;\n    }\n\n    private boolean advance(){\n        while (i<array.length)\n        {\n            Object key = array[i];\n            Object nodeOrVal = array[i+1];\n            i += 2;\n            if (key != null)\n            {\n                nextEntry = f.invoke(key, nodeOrVal);\n                return true;\n            }\n            else if(nodeOrVal != null)\n            {\n                Iterator iter = ((INode) nodeOrVal).iterator(f);\n                if(iter != null && iter.hasNext())\n                {\n                    nextIter = iter;\n                    return true;\n                }\n            }\n        }\n        return false;\n    }\n\n    public boolean hasNext(){\n        if (nextEntry != NULL || nextIter != null)\n            return true;\n        return advance();\n    }\n\n    public Object next(){\n        Object ret = nextEntry;\n        if(ret != NULL)\n        {\n            nextEntry = NULL;\n            return ret;\n        }\n        else if(nextIter != null)\n        {\n            ret = nextIter.next();\n            if(! nextIter.hasNext())\n                nextIter = null;\n            return ret;\n        }\n        else if(advance())\n            return next();\n        throw new NoSuchElementException();\n    }\n\n    public void remove(){\n        throw new UnsupportedOperationException();\n    }\n}\n\nstatic final class NodeSeq extends ASeq {\n\tfinal Object[] array;\n\tfinal int i;\n\tfinal ISeq s;\n\t\n\tNodeSeq(Object[] array, int i) {\n\t\tthis(null, array, i, null);\n\t}\n\n\tstatic ISeq create(Object[] array) {\n\t\treturn create(array, 0, null);\n\t}\n\n    static public Object kvreduce(Object[] array, IFn f, Object init){\n         for(int i=0;i<array.length;i+=2)\n             {\n             if(array[i] != null)\n                 init = f.invoke(init, array[i], array[i+1]);\n             else\n                 {\n                 INode node = (INode) array[i+1];\n                 if(node != null)\n                     init = node.kvreduce(f,init);\n                 }\n             if(RT.isReduced(init))\n\t             return init;\n             }\n        return init;\n    }\n\n\tprivate static ISeq create(Object[] array, int i, ISeq s) {\n\t\tif(s != null)\n\t\t\treturn new NodeSeq(null, array, i, s);\n\t\tfor(int j = i; j < array.length; j+=2) {\n\t\t\tif(array[j] != null)\n\t\t\t\treturn new NodeSeq(null, array, j, null);\n\t\t\tINode node = (INode) array[j+1];\n\t\t\tif (node != null) {\n\t\t\t\tISeq nodeSeq = node.nodeSeq();\n\t\t\t\tif(nodeSeq != null)\n\t\t\t\t\treturn new NodeSeq(null, array, j + 2, nodeSeq);\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tNodeSeq(IPersistentMap meta, Object[] array, int i, ISeq s) {\n\t\tsuper(meta);\n\t\tthis.array = array;\n\t\tthis.i = i;\n\t\tthis.s = s;\n\t}\n\n\tpublic Obj withMeta(IPersistentMap meta) {\n\t\treturn new NodeSeq(meta, array, i, s);\n\t}\n\n\tpublic Object first() {\n\t\tif(s != null)\n\t\t\treturn s.first();\n\t\treturn new MapEntry(array[i], array[i+1]);\n\t}\n\n\tpublic ISeq next() {\n\t\tif(s != null)\n\t\t\treturn create(array, i, s.next());\n\t\treturn create(array, i + 2, null);\n\t}\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/PersistentHashSet.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 3, 2008 */\n\npackage clojure.lang;\n\nimport java.util.List;\n\npublic class PersistentHashSet extends APersistentSet implements IObj, IEditableCollection {\n\nstatic public final PersistentHashSet EMPTY = new PersistentHashSet(null, PersistentHashMap.EMPTY);\n\nfinal IPersistentMap _meta;\n\npublic static PersistentHashSet create(Object... init){\n\tITransientSet ret = (ITransientSet)EMPTY.asTransient();\n\tfor(int i = 0; i < init.length; i++)\n\t\t{\n\t\tret = (ITransientSet)ret.conj(init[i]);\n\t\t}\n\treturn (PersistentHashSet)ret.persistent();\n}\n\npublic static PersistentHashSet create(List init){\n\tITransientSet ret = (ITransientSet)EMPTY.asTransient();\n\tfor(Object key : init)\n\t\t{\n\t\tret = (ITransientSet) ret.conj(key);\n\t\t}\n\treturn (PersistentHashSet)ret.persistent();\n}\n\nstatic public PersistentHashSet create(ISeq items){\n\tITransientSet ret = (ITransientSet)EMPTY.asTransient();\n\tfor(; items != null; items = items.next())\n\t\t{\n\t\tret = (ITransientSet) ret.conj(items.first());\n\t\t}\n\treturn (PersistentHashSet)ret.persistent();\n}\n\npublic static PersistentHashSet createWithCheck(Object... init){\n    ITransientSet ret = (ITransientSet)EMPTY.asTransient();\n\tfor(int i = 0; i < init.length; i++)\n\t\t{\n\t\tret = (ITransientSet) ret.conj(init[i]);\n\t\tif(ret.count() != i + 1)\n\t\t\tthrow new IllegalArgumentException(\"Duplicate key: \" + init[i]);\n\t\t}\n\treturn (PersistentHashSet) ret.persistent();\n}\n\npublic static PersistentHashSet createWithCheck(List init){\n    ITransientSet ret = (ITransientSet)EMPTY.asTransient();\n\tint i=0;\n\tfor(Object key : init)\n\t\t{\n\t\tret = (ITransientSet) ret.conj(key);\n\t\tif(ret.count() != i + 1)\n\t\t\tthrow new IllegalArgumentException(\"Duplicate key: \" + key);\t\t\n\t\t++i;\n\t\t}\n    return (PersistentHashSet) ret.persistent();\n}\n\nstatic public PersistentHashSet createWithCheck(ISeq items){\n    ITransientSet ret = (ITransientSet)EMPTY.asTransient();\n\tfor(int i=0; items != null; items = items.next(), ++i)\n\t\t{\n\t\tret = (ITransientSet) ret.conj(items.first());\n\t\tif(ret.count() != i + 1)\n\t\t\tthrow new IllegalArgumentException(\"Duplicate key: \" + items.first());\n\t\t}\n    return (PersistentHashSet) ret.persistent();\n}\n\nPersistentHashSet(IPersistentMap meta, IPersistentMap impl){\n\tsuper(impl);\n\tthis._meta = meta;\n}\n\npublic IPersistentSet disjoin(Object key) {\n\tif(contains(key))\n\t\treturn new PersistentHashSet(meta(),impl.without(key));\n\treturn this;\n}\n\npublic IPersistentSet cons(Object o){\n\tif(contains(o))\n\t\treturn this;\n\treturn new PersistentHashSet(meta(),impl.assoc(o,o));\n}\n\npublic IPersistentCollection empty(){\n\treturn EMPTY.withMeta(meta());\t\n}\n\npublic PersistentHashSet withMeta(IPersistentMap meta){\n\treturn new PersistentHashSet(meta, impl);\n}\n\npublic ITransientCollection asTransient() {\n\treturn new TransientHashSet(((PersistentHashMap) impl).asTransient());\n}\n\npublic IPersistentMap meta(){\n\treturn _meta;\n}\n\nstatic final class TransientHashSet extends ATransientSet {\n\tTransientHashSet(ITransientMap impl) {\n\t\tsuper(impl);\n\t}\n\n\tpublic IPersistentCollection persistent() {\n\t\treturn new PersistentHashSet(null, impl.persistent());\n\t}\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/PersistentList.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.Iterator;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.ListIterator;\nimport java.util.NoSuchElementException;\n\npublic class PersistentList extends ASeq implements IPersistentList, IReduce, List, Counted {\n\nprivate final Object _first;\nprivate final IPersistentList _rest;\nprivate final int _count;\n\npublic static IFn creator = new RestFn(){\n\tfinal public int getRequiredArity(){\n\t\treturn 0;\n\t}\n\n\tfinal protected Object doInvoke(Object args) {\n\t\tif(args instanceof ArraySeq)\n\t\t\t{\n\t\t\tObject[] argsarray = ((ArraySeq) args).array;\n\t\t\tIPersistentList ret = EMPTY;\n\t\t\tfor(int i = argsarray.length - 1; i >= ((ArraySeq)args).i; --i)\n\t\t\t\tret = (IPersistentList) ret.cons(argsarray[i]);\n\t\t\treturn ret;\n\t\t\t}\n\t\tLinkedList list = new LinkedList();\n\t\tfor(ISeq s = RT.seq(args); s != null; s = s.next())\n\t\t\tlist.add(s.first());\n\t\treturn create(list);\n\t}\n\n};\n\nfinal public static EmptyList EMPTY = new EmptyList(null);\n\npublic PersistentList(Object first){\n\tthis._first = first;\n\tthis._rest = null;\n\n\tthis._count = 1;\n}\n\nPersistentList(IPersistentMap meta, Object _first, IPersistentList _rest, int _count){\n\tsuper(meta);\n\tthis._first = _first;\n\tthis._rest = _rest;\n\tthis._count = _count;\n}\n\npublic static IPersistentList create(List init){\n\tIPersistentList ret = EMPTY;\n\tfor(ListIterator i = init.listIterator(init.size()); i.hasPrevious();)\n\t\t{\n\t\tret = (IPersistentList) ret.cons(i.previous());\n\t\t}\n\treturn ret;\n}\n\npublic Object first(){\n\treturn _first;\n}\n\npublic ISeq next(){\n\tif(_count == 1)\n\t\treturn null;\n\treturn (ISeq) _rest;\n}\n\npublic Object peek(){\n\treturn first();\n}\n\npublic IPersistentList pop(){\n\tif(_rest == null)\n\t\treturn EMPTY.withMeta(_meta);\n\treturn _rest;\n}\n\npublic int count(){\n\treturn _count;\n}\n\npublic PersistentList cons(Object o){\n\treturn new PersistentList(meta(), o, this, _count + 1);\n}\n\npublic IPersistentCollection empty(){\n\treturn EMPTY.withMeta(meta());\n}\n\npublic PersistentList withMeta(IPersistentMap meta){\n\tif(meta != _meta)\n\t\treturn new PersistentList(meta, _first, _rest, _count);\n\treturn this;\n}\n\npublic Object reduce(IFn f) {\n\tObject ret = first();\n\tfor(ISeq s = next(); s != null; s = s.next()) {\n        ret = f.invoke(ret, s.first());\n        if (RT.isReduced(ret)) return ((IDeref)ret).deref();;\n    }\n\treturn ret;\n}\n\npublic Object reduce(IFn f, Object start) {\n\tObject ret = f.invoke(start, first());\n\tfor(ISeq s = next(); s != null; s = s.next()) {\n        if (RT.isReduced(ret)) return ((IDeref)ret).deref();\n        ret = f.invoke(ret, s.first());\n    }\n\tif (RT.isReduced(ret)) return ((IDeref)ret).deref();\n\treturn ret;\n}\n\n\n  public static class EmptyList extends Obj implements IPersistentList, List, ISeq, Counted, IHashEq{\n  public static final int hasheq = Murmur3.hashOrdered(Collections.EMPTY_LIST);\n\n\tpublic int hashCode(){\n\t\treturn 1;\n\t}\n\n\tpublic int hasheq(){\n\t\treturn hasheq;\n\t}\n\n    public boolean equals(Object o) {\n        return (o instanceof Sequential || o instanceof List) && RT.seq(o) == null;\n    }\n\n\tpublic boolean equiv(Object o){\n\t\treturn equals(o);\n\t}\n\t\n    EmptyList(IPersistentMap meta){\n\t\tsuper(meta);\n\t}\n\n        public Object first() {\n            return null;\n        }\n\n        public ISeq next() {\n            return null;\n        }\n\n        public ISeq more() {\n            return this;\n        }\n\n        public PersistentList cons(Object o){\n\t\treturn new PersistentList(meta(), o, null, 1);\n\t}\n\n\tpublic IPersistentCollection empty(){\n\t\treturn this;\n\t}\n\n\tpublic EmptyList withMeta(IPersistentMap meta){\n\t\tif(meta != meta())\n\t\t\treturn new EmptyList(meta);\n\t\treturn this;\n\t}\n\n\tpublic Object peek(){\n\t\treturn null;\n\t}\n\n\tpublic IPersistentList pop(){\n\t\tthrow new IllegalStateException(\"Can't pop empty list\");\n\t}\n\n\tpublic int count(){\n\t\treturn 0;\n\t}\n\n\tpublic ISeq seq(){\n\t\treturn null;\n\t}\n\n\n\tpublic int size(){\n\t\treturn 0;\n\t}\n\n\tpublic boolean isEmpty(){\n\t\treturn true;\n\t}\n\n\tpublic boolean contains(Object o){\n\t\treturn false;\n\t}\n\n\tpublic Iterator iterator(){\n\t\treturn new Iterator(){\n\n\t\t\tpublic boolean hasNext(){\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tpublic Object next(){\n\t\t\t\tthrow new NoSuchElementException();\n\t\t\t}\n\n\t\t\tpublic void remove(){\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t};\n\t}\n\n\tpublic Object[] toArray(){\n\t\treturn RT.EMPTY_ARRAY;\n\t}\n\n\tpublic boolean add(Object o){\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n\tpublic boolean remove(Object o){\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n\tpublic boolean addAll(Collection collection){\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n\tpublic void clear(){\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n\tpublic boolean retainAll(Collection collection){\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n\tpublic boolean removeAll(Collection collection){\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n\tpublic boolean containsAll(Collection collection){\n\t\treturn collection.isEmpty();\n\t}\n\n\tpublic Object[] toArray(Object[] objects){\n\t\tif(objects.length > 0)\n\t\t\tobjects[0] = null;\n\t\treturn objects;\n\t}\n\n\t//////////// List stuff /////////////////\n\tprivate List reify(){\n\t\treturn Collections.unmodifiableList(new ArrayList(this));\n\t}\n\n\tpublic List subList(int fromIndex, int toIndex){\n\t\treturn reify().subList(fromIndex, toIndex);\n\t}\n\n\tpublic Object set(int index, Object element){\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n\tpublic Object remove(int index){\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n\tpublic int indexOf(Object o){\n\t\tISeq s = seq();\n\t\tfor(int i = 0; s != null; s = s.next(), i++)\n\t\t\t{\n\t\t\tif(Util.equiv(s.first(), o))\n\t\t\t\treturn i;\n\t\t\t}\n\t\treturn -1;\n\t}\n\n\tpublic int lastIndexOf(Object o){\n\t\treturn reify().lastIndexOf(o);\n\t}\n\n\tpublic ListIterator listIterator(){\n\t\treturn reify().listIterator();\n\t}\n\n\tpublic ListIterator listIterator(int index){\n\t\treturn reify().listIterator(index);\n\t}\n\n\tpublic Object get(int index){\n\t\treturn RT.nth(this, index);\n\t}\n\n\tpublic void add(int index, Object element){\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n\tpublic boolean addAll(int index, Collection c){\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/PersistentQueue.java",
    "content": "/**\r\n *   Copyright (c) Rich Hickey. All rights reserved.\r\n *   The use and distribution terms for this software are covered by the\r\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n *   which can be found in the file epl-v10.html at the root of this distribution.\r\n *   By using this software in any fashion, you are agreeing to be bound by\r\n * \t the terms of this license.\r\n *   You must not remove this notice, or any other, from this software.\r\n **/\r\n\r\npackage clojure.lang;\r\n\r\nimport java.util.Collection;\r\nimport java.util.Iterator;\r\nimport java.util.NoSuchElementException;\n//import java.util.concurrent.ConcurrentLinkedQueue;\r\n\r\n/**\r\n * conses onto rear, peeks/pops from front\r\n * See Okasaki's Batched Queues\r\n * This differs in that it uses a PersistentVector as the rear, which is in-order,\r\n * so no reversing or suspensions required for persistent use\r\n */\r\n\r\npublic class PersistentQueue extends Obj implements IPersistentList, Collection, Counted, IHashEq{\r\n\r\nfinal public static PersistentQueue EMPTY = new PersistentQueue(null, 0, null, null);\r\n\r\n//*\r\nfinal int cnt;\r\nfinal ISeq f;\r\nfinal PersistentVector r;\r\n//static final int INITIAL_REAR_SIZE = 4;\r\nint _hash = -1;\r\nint _hasheq = -1;\r\n\r\nPersistentQueue(IPersistentMap meta, int cnt, ISeq f, PersistentVector r){\r\n\tsuper(meta);\r\n\tthis.cnt = cnt;\r\n\tthis.f = f;\r\n\tthis.r = r;\r\n}\r\n\r\npublic boolean equiv(Object obj){\r\n\r\n\tif(!(obj instanceof Sequential))\r\n\t\treturn false;\r\n\tISeq ms = RT.seq(obj);\r\n\tfor(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())\r\n\t\t{\r\n\t\tif(ms == null || !Util.equiv(s.first(), ms.first()))\r\n\t\t\treturn false;\r\n\t\t}\r\n\treturn ms == null;\r\n\r\n}\r\n\r\npublic boolean equals(Object obj){\r\n\r\n\tif(!(obj instanceof Sequential))\r\n\t\treturn false;\r\n\tISeq ms = RT.seq(obj);\r\n\tfor(ISeq s = seq(); s != null; s = s.next(), ms = ms.next())\r\n\t\t{\r\n\t\tif(ms == null || !Util.equals(s.first(), ms.first()))\r\n\t\t\treturn false;\r\n\t\t}\r\n\treturn ms == null;\r\n\r\n}\r\n\r\npublic int hashCode(){\r\n\tif(_hash == -1)\r\n\t\t{\r\n\t\tint hash = 1;\r\n\t\tfor(ISeq s = seq(); s != null; s = s.next())\r\n\t\t\t{\r\n\t\t\thash = 31 * hash + (s.first() == null ? 0 : Util.hash(s.first()));\r\n\t\t\t}\r\n\t\tthis._hash = hash;\r\n\t\t}\r\n\treturn _hash;\r\n}\r\n\r\npublic int hasheq() {\r\n\tif(_hasheq == -1)\r\n\t\t{\r\n//\t\tint hash = 1;\r\n//\t\tfor(ISeq s = seq(); s != null; s = s.next())\r\n//\t\t\t{\r\n//\t\t\thash = 31 * hash + Util.hasheq(s.first());\r\n//\t\t\t}\r\n//\t\tthis._hasheq = hash;\r\n\t\t_hasheq  = Murmur3.hashOrdered(this);\r\n\t\t}\r\n    return _hasheq;\r\n}\r\n\r\npublic Object peek(){\r\n\treturn RT.first(f);\r\n}\r\n\r\npublic PersistentQueue pop(){\r\n\tif(f == null)  //hmmm... pop of empty queue -> empty queue?\r\n\t\treturn this;\r\n\t//throw new IllegalStateException(\"popping empty queue\");\r\n\tISeq f1 = f.next();\r\n\tPersistentVector r1 = r;\r\n\tif(f1 == null)\r\n\t\t{\r\n\t\tf1 = RT.seq(r);\r\n\t\tr1 = null;\r\n\t\t}\r\n\treturn new PersistentQueue(meta(), cnt - 1, f1, r1);\r\n}\r\n\r\npublic int count(){\r\n\treturn cnt;\r\n}\r\n\r\npublic ISeq seq(){\r\n\tif(f == null)\r\n\t\treturn null;\r\n\treturn new Seq(f, RT.seq(r));\r\n}\r\n\r\npublic PersistentQueue cons(Object o){\r\n\tif(f == null)     //empty\r\n\t\treturn new PersistentQueue(meta(), cnt + 1, RT.list(o), null);\r\n\telse\r\n\t\treturn new PersistentQueue(meta(), cnt + 1, f, (r != null ? r : PersistentVector.EMPTY).cons(o));\r\n}\r\n\r\npublic IPersistentCollection empty(){\r\n\treturn EMPTY.withMeta(meta());\r\n}\r\n\r\npublic PersistentQueue withMeta(IPersistentMap meta){\r\n\treturn new PersistentQueue(meta, cnt, f, r);\r\n}\r\n\r\nstatic class Seq extends ASeq{\r\n\tfinal ISeq f;\r\n\tfinal ISeq rseq;\r\n\r\n\tSeq(ISeq f, ISeq rseq){\r\n\t\tthis.f = f;\r\n\t\tthis.rseq = rseq;\r\n\t}\r\n\r\n\tSeq(IPersistentMap meta, ISeq f, ISeq rseq){\r\n\t\tsuper(meta);\r\n\t\tthis.f = f;\r\n\t\tthis.rseq = rseq;\r\n\t}\r\n\r\n\tpublic Object first(){\r\n\t\treturn f.first();\r\n\t}\r\n\r\n\tpublic ISeq next(){\r\n\t\tISeq f1 = f.next();\r\n\t\tISeq r1 = rseq;\r\n\t\tif(f1 == null)\r\n\t\t\t{\r\n\t\t\tif(rseq == null)\r\n\t\t\t\treturn null;\r\n\t\t\tf1 = rseq;\r\n\t\t\tr1 = null;\r\n\t\t\t}\r\n\t\treturn new Seq(f1, r1);\r\n\t}\r\n\r\n\tpublic int count(){\r\n\t\treturn RT.count(f) + RT.count(rseq);\r\n\t}\r\n\r\n\tpublic Seq withMeta(IPersistentMap meta){\r\n\t\treturn new Seq(meta, f, rseq);\r\n\t}\r\n}\r\n\r\n// java.util.Collection implementation\r\n\r\npublic Object[] toArray(){\r\n\treturn RT.seqToArray(seq());\r\n}\r\n\r\npublic boolean add(Object o){\r\n\tthrow new UnsupportedOperationException();\r\n}\r\n\r\npublic boolean remove(Object o){\r\n\tthrow new UnsupportedOperationException();\r\n}\r\n\r\npublic boolean addAll(Collection c){\r\n\tthrow new UnsupportedOperationException();\r\n}\r\n\r\npublic void clear(){\r\n\tthrow new UnsupportedOperationException();\r\n}\r\n\r\npublic boolean retainAll(Collection c){\r\n\tthrow new UnsupportedOperationException();\r\n}\r\n\r\npublic boolean removeAll(Collection c){\r\n\tthrow new UnsupportedOperationException();\r\n}\r\n\r\npublic boolean containsAll(Collection c){\r\n\tfor(Object o : c)\r\n\t\t{\r\n\t\tif(contains(o))\r\n\t\t\treturn true;\r\n\t\t}\r\n\treturn false;\r\n}\r\n\r\npublic Object[] toArray(Object[] a){\r\n    return RT.seqToPassedArray(seq(), a);\r\n}\r\n\r\npublic int size(){\r\n\treturn count();\r\n}\r\n\r\npublic boolean isEmpty(){\r\n\treturn count() == 0;\r\n}\r\n\r\npublic boolean contains(Object o){\r\n\tfor(ISeq s = seq(); s != null; s = s.next())\r\n\t\t{\r\n\t\tif(Util.equiv(s.first(), o))\r\n\t\t\treturn true;\r\n\t\t}\r\n\treturn false;\r\n}\r\n\r\npublic Iterator iterator(){\r\n    return new Iterator(){\n        private ISeq fseq = f;\n        private final Iterator riter = r != null ? r.iterator() : null;\n\n        public boolean hasNext(){\n            return ((fseq != null && fseq.seq() != null) || (riter != null && riter.hasNext()));\n        }\n\n        public Object next(){\n            if(fseq != null)\n            {\n                Object ret = fseq.first();\n                fseq = fseq.next();\n                return ret;\n            }\n            else if(riter != null && riter.hasNext())\n                return riter.next();\n            else\n                throw new NoSuchElementException();\n        }\n\n        public void remove(){\n            throw new UnsupportedOperationException();\n        }\n    };\n}\r\n\r\n/*\r\npublic static void main(String[] args){\r\n\tif(args.length != 1)\r\n\t\t{\r\n\t\tSystem.err.println(\"Usage: PersistentQueue n\");\r\n\t\treturn;\r\n\t\t}\r\n\tint n = Integer.parseInt(args[0]);\r\n\r\n\r\n\tlong startTime, estimatedTime;\r\n\r\n\tQueue list = new LinkedList();\r\n\t//Queue list = new ConcurrentLinkedQueue();\r\n\tSystem.out.println(\"Queue\");\r\n\tstartTime = System.nanoTime();\r\n\tfor(int i = 0; i < n; i++)\r\n\t\t{\r\n\t\tlist.add(i);\r\n\t\tlist.add(i);\r\n\t\tlist.remove();\r\n\t\t}\r\n\tfor(int i = 0; i < n - 10; i++)\r\n\t\t{\r\n\t\tlist.remove();\r\n\t\t}\r\n\testimatedTime = System.nanoTime() - startTime;\r\n\tSystem.out.println(\"time: \" + estimatedTime / 1000000);\r\n\tSystem.out.println(\"peek: \" + list.peek());\r\n\r\n\r\n\tPersistentQueue q = PersistentQueue.EMPTY;\r\n\tSystem.out.println(\"PersistentQueue\");\r\n\tstartTime = System.nanoTime();\r\n\tfor(int i = 0; i < n; i++)\r\n\t\t{\r\n\t\tq = q.cons(i);\r\n\t\tq = q.cons(i);\r\n\t\tq = q.pop();\r\n\t\t}\r\n//    IPersistentList lastq = null;\r\n//    IPersistentList lastq2;\r\n\tfor(int i = 0; i < n - 10; i++)\r\n\t\t{\r\n\t\t//lastq2 = lastq;\r\n\t\t//lastq = q;\r\n\t\tq = q.pop();\r\n\t\t}\r\n\testimatedTime = System.nanoTime() - startTime;\r\n\tSystem.out.println(\"time: \" + estimatedTime / 1000000);\r\n\tSystem.out.println(\"peek: \" + q.peek());\r\n\r\n\tIPersistentList q2 = q;\r\n\tfor(int i = 0; i < 10; i++)\r\n\t\t{\r\n\t\tq2 = (IPersistentList) q2.cons(i);\r\n\t\t}\r\n//    for(ISeq s = q.seq();s != null;s = s.rest())\r\n//        System.out.println(\"q: \" + s.first().toString());\r\n//    for(ISeq s = q2.seq();s != null;s = s.rest())\r\n//        System.out.println(\"q2: \" + s.first().toString());\r\n}\r\n*/\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/PersistentStructMap.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Dec 16, 2007 */\n\npackage clojure.lang;\n\nimport java.util.Iterator;\nimport java.util.Map;\nimport java.io.Serializable;\nimport java.util.NoSuchElementException;\n\npublic class PersistentStructMap extends APersistentMap implements IObj{\n\npublic static class Def implements Serializable{\n\tfinal ISeq keys;\n\tfinal IPersistentMap keyslots;\n\n\tDef(ISeq keys, IPersistentMap keyslots){\n\t\tthis.keys = keys;\n\t\tthis.keyslots = keyslots;\n\t}\n}\n\nfinal Def def;\nfinal Object[] vals;\nfinal IPersistentMap ext;\nfinal IPersistentMap _meta;\n\n\nstatic public Def createSlotMap(ISeq keys){\n\tif(keys == null)\n\t\tthrow new IllegalArgumentException(\"Must supply keys\");\n\tint c = RT.count(keys);\n\tObject[] v = new Object[2*c];\n\tint i = 0;\n\tfor(ISeq s = keys; s != null; s = s.next(), i++)\n\t\t{\n\t\tv[2*i] =  s.first();\n\t\tv[2*i+1] = i;\n\t\t}\n\treturn new Def(keys, RT.map(v));\n}\n\nstatic public PersistentStructMap create(Def def, ISeq keyvals){\n\tObject[] vals = new Object[def.keyslots.count()];\n\tIPersistentMap ext = PersistentHashMap.EMPTY;\n\tfor(; keyvals != null; keyvals = keyvals.next().next())\n\t\t{\n\t\tif(keyvals.next() == null)\n\t\t\tthrow new IllegalArgumentException(String.format(\"No value supplied for key: %s\", keyvals.first()));\n\t\tObject k = keyvals.first();\n\t\tObject v = RT.second(keyvals);\n\t\tMap.Entry e = def.keyslots.entryAt(k);\n\t\tif(e != null)\n\t\t\tvals[(Integer) e.getValue()] = v;\n\t\telse\n\t\t\text = ext.assoc(k, v);\n\t\t}\n\treturn new PersistentStructMap(null, def, vals, ext);\n}\n\nstatic public PersistentStructMap construct(Def def, ISeq valseq){\n\tObject[] vals = new Object[def.keyslots.count()];\n\tIPersistentMap ext = PersistentHashMap.EMPTY;\n\tfor(int i = 0; i < vals.length && valseq != null; valseq = valseq.next(), i++)\n\t\t{\n\t\tvals[i] = valseq.first();\n\t\t}\n\tif(valseq != null)\n\t\tthrow new IllegalArgumentException(\"Too many arguments to struct constructor\");\n\treturn new PersistentStructMap(null, def, vals, ext);\n}\n\nstatic public IFn getAccessor(final Def def, Object key){\n\tMap.Entry e = def.keyslots.entryAt(key);\n\tif(e != null)\n\t\t{\n\t\tfinal int i = (Integer) e.getValue();\n\t\treturn new AFn(){\n\t\t\tpublic Object invoke(Object arg1) {\n\t\t\t\tPersistentStructMap m = (PersistentStructMap) arg1;\n\t\t\t\tif(m.def != def)\n\t\t\t\t\tthrow Util.runtimeException(\"Accessor/struct mismatch\");\n\t\t\t\treturn m.vals[i];\n\t\t\t}\n\t\t};\n\t\t}\n\tthrow new IllegalArgumentException(\"Not a key of struct\");\n}\n\nprotected PersistentStructMap(IPersistentMap meta, Def def, Object[] vals, IPersistentMap ext){\n\tthis._meta = meta;\n\tthis.ext = ext;\n\tthis.def = def;\n\tthis.vals = vals;\n}\n\n/**\n * Returns a new instance of PersistentStructMap using the given parameters.\n * This function is used instead of the PersistentStructMap constructor by\n * all methods that return a new PersistentStructMap.  This is done so as to\n * allow subclasses to return instances of their class from all\n * PersistentStructMap methods.\n */\nprotected PersistentStructMap makeNew(IPersistentMap meta, Def def, Object[] vals, IPersistentMap ext){\n\treturn new PersistentStructMap(meta, def, vals, ext);\n}\n\npublic IObj withMeta(IPersistentMap meta){\n\tif(meta == _meta)\n\t\treturn this;\n\treturn makeNew(meta, def, vals, ext);\n}\n\npublic IPersistentMap meta(){\n\treturn _meta;\n}\n\npublic boolean containsKey(Object key){\n\treturn def.keyslots.containsKey(key) || ext.containsKey(key);\n}\n\npublic IMapEntry entryAt(Object key){\n\tMap.Entry e = def.keyslots.entryAt(key);\n\tif(e != null)\n\t\t{\n\t\treturn new MapEntry(e.getKey(), vals[(Integer) e.getValue()]);\n\t\t}\n\treturn ext.entryAt(key);\n}\n\npublic IPersistentMap assoc(Object key, Object val){\n\tMap.Entry e = def.keyslots.entryAt(key);\n\tif(e != null)\n\t\t{\n\t\tint i = (Integer) e.getValue();\n\t\tObject[] newVals = vals.clone();\n\t\tnewVals[i] = val;\n\t\treturn makeNew(_meta, def, newVals, ext);\n\t\t}\n\treturn makeNew(_meta, def, vals, ext.assoc(key, val));\n}\n\npublic Object valAt(Object key){\n\tInteger i = (Integer) def.keyslots.valAt(key);\n\tif(i != null)\n\t\t{\n\t\treturn vals[i];\n\t\t}\n\treturn ext.valAt(key);\n}\n\npublic Object valAt(Object key, Object notFound){\n\tInteger i = (Integer) def.keyslots.valAt(key);\n\tif(i != null)\n\t\t{\n\t\treturn vals[i];\n\t\t}\n\treturn ext.valAt(key, notFound);\n}\n\npublic IPersistentMap assocEx(Object key, Object val) {\n\tif(containsKey(key))\n\t\tthrow Util.runtimeException(\"Key already present\");\n\treturn assoc(key, val);\n}\n\npublic IPersistentMap without(Object key) {\n\tMap.Entry e = def.keyslots.entryAt(key);\n\tif(e != null)\n\t\tthrow Util.runtimeException(\"Can't remove struct key\");\n\tIPersistentMap newExt = ext.without(key);\n\tif(newExt == ext)\n\t\treturn this;\n\treturn makeNew(_meta, def, vals, newExt);\n}\n\npublic Iterator iterator(){\n    return new Iterator(){\n        private ISeq ks = def.keys;\n        private Iterator extIter = ext == null ? null : ext.iterator();\n\n        public boolean hasNext(){\n            return ((ks != null && ks.seq() != null) || (extIter != null && extIter.hasNext()));\n        }\n\n        public Object next(){\n            if(ks != null)\n            {\n                Object key = ks.first();\n                ks = ks.next();\n                return entryAt(key);\n            }\n            else if(extIter != null && extIter.hasNext())\n                return extIter.next();\n            else\n                throw new NoSuchElementException();\n        }\n\n        public void remove(){\n            throw new UnsupportedOperationException();\n        }\n    };\n}\n\npublic int count(){\n\treturn vals.length + RT.count(ext);\n}\n\npublic ISeq seq(){\n\treturn new Seq(null, def.keys, vals, 0, ext);\n}\n\npublic IPersistentCollection empty(){\n\treturn construct(def, null);\n}\n\nstatic class Seq extends ASeq{\n\tfinal int i;\n\tfinal ISeq keys;\n\tfinal Object[] vals;\n\tfinal IPersistentMap ext;\n\n\n\tpublic Seq(IPersistentMap meta, ISeq keys, Object[] vals, int i, IPersistentMap ext){\n\t\tsuper(meta);\n\t\tthis.i = i;\n\t\tthis.keys = keys;\n\t\tthis.vals = vals;\n\t\tthis.ext = ext;\n\t}\n\n\tpublic Obj withMeta(IPersistentMap meta){\n\t\tif(meta != _meta)\n\t\t\treturn new Seq(meta, keys, vals, i, ext);\n\t\treturn this;\n\t}\n\n\tpublic Object first(){\n\t\treturn new MapEntry(keys.first(), vals[i]);\n\t}\n\n\tpublic ISeq next(){\n\t\tif(i + 1 < vals.length)\n\t\t\treturn new Seq(_meta, keys.next(), vals, i + 1, ext);\n\t\treturn ext.seq();\n\t}\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/PersistentTreeMap.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich May 20, 2006 */\n\npackage clojure.lang;\n\nimport java.util.*;\n\n/**\n * Persistent Red Black Tree\n * Note that instances of this class are constant values\n * i.e. add/remove etc return new values\n * <p/>\n * See Okasaki, Kahrs, Larsen et al\n */\n\npublic class PersistentTreeMap extends APersistentMap implements IObj, Reversible, Sorted{\n\npublic final Comparator comp;\npublic final Node tree;\npublic final int _count;\nfinal IPersistentMap _meta;\n\nfinal static public PersistentTreeMap EMPTY = new PersistentTreeMap();\n\nstatic public IPersistentMap create(Map other){\n\tIPersistentMap ret = EMPTY;\n\tfor(Object o : other.entrySet())\n\t\t{\n\t\tMap.Entry e = (Entry) o;\n\t\tret = ret.assoc(e.getKey(), e.getValue());\n\t\t}\n\treturn ret;\n}\n\npublic PersistentTreeMap(){\n\tthis(RT.DEFAULT_COMPARATOR);\n}\n\npublic PersistentTreeMap withMeta(IPersistentMap meta){\n\treturn new PersistentTreeMap(meta, comp, tree, _count);\n}\n\nprivate PersistentTreeMap(Comparator comp){\n\tthis(null, comp);\n}\n\n\npublic PersistentTreeMap(IPersistentMap meta, Comparator comp){\n\tthis.comp = comp;\n\tthis._meta = meta;\n\ttree = null;\n\t_count = 0;\n}\n\nPersistentTreeMap(IPersistentMap meta, Comparator comp, Node tree, int _count){\n\tthis._meta = meta;\n\tthis.comp = comp;\n\tthis.tree = tree;\n\tthis._count = _count;\n}\n\nstatic public PersistentTreeMap create(ISeq items){\n\tIPersistentMap ret = EMPTY;\n\tfor(; items != null; items = items.next().next())\n\t\t{\n\t\tif(items.next() == null)\n\t\t\tthrow new IllegalArgumentException(String.format(\"No value supplied for key: %s\", items.first()));\n\t\tret = ret.assoc(items.first(), RT.second(items));\n\t\t}\n\treturn (PersistentTreeMap) ret;\n}\n\nstatic public PersistentTreeMap create(Comparator comp, ISeq items){\n\tIPersistentMap ret = new PersistentTreeMap(comp);\n\tfor(; items != null; items = items.next().next())\n\t\t{\n\t\tif(items.next() == null)\n\t\t\tthrow new IllegalArgumentException(String.format(\"No value supplied for key: %s\", items.first()));\n\t\tret = ret.assoc(items.first(), RT.second(items));\n\t\t}\n\treturn (PersistentTreeMap) ret;\n}\n\npublic boolean containsKey(Object key){\n\treturn entryAt(key) != null;\n}\n\npublic PersistentTreeMap assocEx(Object key, Object val) {\n\tBox found = new Box(null);\n\tNode t = add(tree, key, val, found);\n\tif(t == null)   //null == already contains key\n\t\t{\n\t\tthrow Util.runtimeException(\"Key already present\");\n\t\t}\n\treturn new PersistentTreeMap(comp, t.blacken(), _count + 1, meta());\n}\n\npublic PersistentTreeMap assoc(Object key, Object val){\n\tBox found = new Box(null);\n\tNode t = add(tree, key, val, found);\n\tif(t == null)   //null == already contains key\n\t\t{\n\t\tNode foundNode = (Node) found.val;\n\t\tif(foundNode.val() == val)  //note only get same collection on identity of val, not equals()\n\t\t\treturn this;\n\t\treturn new PersistentTreeMap(comp, replace(tree, key, val), _count, meta());\n\t\t}\n\treturn new PersistentTreeMap(comp, t.blacken(), _count + 1, meta());\n}\n\n\npublic PersistentTreeMap without(Object key){\n\tBox found = new Box(null);\n\tNode t = remove(tree, key, found);\n\tif(t == null)\n\t\t{\n\t\tif(found.val == null)//null == doesn't contain key\n\t\t\treturn this;\n\t\t//empty\n\t\treturn new PersistentTreeMap(meta(), comp);\n\t\t}\n\treturn new PersistentTreeMap(comp, t.blacken(), _count - 1, meta());\n}\n\npublic ISeq seq(){\n\tif(_count > 0)\n\t\treturn Seq.create(tree, true, _count);\n\treturn null;\n}\n\npublic IPersistentCollection empty(){\n\treturn new PersistentTreeMap(meta(), comp);\t\n}\n\npublic ISeq rseq() {\n\tif(_count > 0)\n\t\treturn Seq.create(tree, false, _count);\n\treturn null;\n}\n\npublic Comparator comparator(){\n\treturn comp;\n}\n\npublic Object entryKey(Object entry){\n\treturn ((IMapEntry) entry).key();\n}\n\npublic ISeq seq(boolean ascending){\n\tif(_count > 0)\n\t\treturn Seq.create(tree, ascending, _count);\n\treturn null;\n}\n\npublic ISeq seqFrom(Object key, boolean ascending){\n\tif(_count > 0)\n\t\t{\n\t\tISeq stack = null;\n\t\tNode t = tree;\n\t\twhile(t != null)\n\t\t\t{\n\t\t\tint c = doCompare(key, t.key);\n\t\t\tif(c == 0)\n\t\t\t\t{\n\t\t\t\tstack = RT.cons(t, stack);\n\t\t\t\treturn new Seq(stack, ascending);\n\t\t\t\t}\n\t\t\telse if(ascending)\n\t\t\t\t{\n\t\t\t\tif(c < 0)\n\t\t\t\t\t{\n\t\t\t\t\tstack = RT.cons(t, stack);\n\t\t\t\t\tt = t.left();\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tt = t.right();\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tif(c > 0)\n\t\t\t\t\t{\n\t\t\t\t\tstack = RT.cons(t, stack);\n\t\t\t\t\tt = t.right();\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tt = t.left();\n\t\t\t\t}\n\t\t\t}\n\t\tif(stack != null)\n\t\t\treturn new Seq(stack, ascending);\n\t\t}\n\treturn null;\n}\n\npublic NodeIterator iterator(){\n\treturn new NodeIterator(tree, true);\n}\n\npublic Object kvreduce(IFn f, Object init){\n    if(tree != null)\n        init = tree.kvreduce(f,init);\n    if(RT.isReduced(init))\n        init = ((IDeref)init).deref();\n    return init;\n}\n\n\npublic NodeIterator reverseIterator(){\n\treturn new NodeIterator(tree, false);\n}\n\npublic Iterator keys(){\n\treturn keys(iterator());\n}\n\npublic Iterator vals(){\n\treturn vals(iterator());\n}\n\npublic Iterator keys(NodeIterator it){\n\treturn new KeyIterator(it);\n}\n\npublic Iterator vals(NodeIterator it){\n\treturn new ValIterator(it);\n}\n\npublic Object minKey(){\n\tNode t = min();\n\treturn t != null ? t.key : null;\n}\n\npublic Node min(){\n\tNode t = tree;\n\tif(t != null)\n\t\t{\n\t\twhile(t.left() != null)\n\t\t\tt = t.left();\n\t\t}\n\treturn t;\n}\n\npublic Object maxKey(){\n\tNode t = max();\n\treturn t != null ? t.key : null;\n}\n\npublic Node max(){\n\tNode t = tree;\n\tif(t != null)\n\t\t{\n\t\twhile(t.right() != null)\n\t\t\tt = t.right();\n\t\t}\n\treturn t;\n}\n\npublic int depth(){\n\treturn depth(tree);\n}\n\nint depth(Node t){\n\tif(t == null)\n\t\treturn 0;\n\treturn 1 + Math.max(depth(t.left()), depth(t.right()));\n}\n\npublic Object valAt(Object key, Object notFound){\n\tNode n = entryAt(key);\n\treturn (n != null) ? n.val() : notFound;\n}\n\npublic Object valAt(Object key){\n\treturn valAt(key, null);\n}\n\npublic int capacity(){\n\treturn _count;\n}\n\npublic int count(){\n\treturn _count;\n}\n\npublic Node entryAt(Object key){\n\tNode t = tree;\n\twhile(t != null)\n\t\t{\n\t\tint c = doCompare(key, t.key);\n\t\tif(c == 0)\n\t\t\treturn t;\n\t\telse if(c < 0)\n\t\t\tt = t.left();\n\t\telse\n\t\t\tt = t.right();\n\t\t}\n\treturn t;\n}\n\npublic int doCompare(Object k1, Object k2){\n//\tif(comp != null)\n\t\treturn comp.compare(k1, k2);\n//\treturn ((Comparable) k1).compareTo(k2);\n}\n\nNode add(Node t, Object key, Object val, Box found){\n\tif(t == null)\n\t\t{\n\t\tif(val == null)\n\t\t\treturn new Red(key);\n\t\treturn new RedVal(key, val);\n\t\t}\n\tint c = doCompare(key, t.key);\n\tif(c == 0)\n\t\t{\n\t\tfound.val = t;\n\t\treturn null;\n\t\t}\n\tNode ins = c < 0 ? add(t.left(), key, val, found) : add(t.right(), key, val, found);\n\tif(ins == null) //found below\n\t\treturn null;\n\tif(c < 0)\n\t\treturn t.addLeft(ins);\n\treturn t.addRight(ins);\n}\n\nNode remove(Node t, Object key, Box found){\n\tif(t == null)\n\t\treturn null; //not found indicator\n\tint c = doCompare(key, t.key);\n\tif(c == 0)\n\t\t{\n\t\tfound.val = t;\n\t\treturn append(t.left(), t.right());\n\t\t}\n\tNode del = c < 0 ? remove(t.left(), key, found) : remove(t.right(), key, found);\n\tif(del == null && found.val == null) //not found below\n\t\treturn null;\n\tif(c < 0)\n\t\t{\n\t\tif(t.left() instanceof Black)\n\t\t\treturn balanceLeftDel(t.key, t.val(), del, t.right());\n\t\telse\n\t\t\treturn red(t.key, t.val(), del, t.right());\n\t\t}\n\tif(t.right() instanceof Black)\n\t\treturn balanceRightDel(t.key, t.val(), t.left(), del);\n\treturn red(t.key, t.val(), t.left(), del);\n//\t\treturn t.removeLeft(del);\n//\treturn t.removeRight(del);\n}\n\nstatic Node append(Node left, Node right){\n\tif(left == null)\n\t\treturn right;\n\telse if(right == null)\n\t\treturn left;\n\telse if(left instanceof Red)\n\t\t{\n\t\tif(right instanceof Red)\n\t\t\t{\n\t\t\tNode app = append(left.right(), right.left());\n\t\t\tif(app instanceof Red)\n\t\t\t\treturn red(app.key, app.val(),\n\t\t\t\t           red(left.key, left.val(), left.left(), app.left()),\n\t\t\t\t           red(right.key, right.val(), app.right(), right.right()));\n\t\t\telse\n\t\t\t\treturn red(left.key, left.val(), left.left(), red(right.key, right.val(), app, right.right()));\n\t\t\t}\n\t\telse\n\t\t\treturn red(left.key, left.val(), left.left(), append(left.right(), right));\n\t\t}\n\telse if(right instanceof Red)\n\t\treturn red(right.key, right.val(), append(left, right.left()), right.right());\n\telse //black/black\n\t\t{\n\t\tNode app = append(left.right(), right.left());\n\t\tif(app instanceof Red)\n\t\t\treturn red(app.key, app.val(),\n\t\t\t           black(left.key, left.val(), left.left(), app.left()),\n\t\t\t           black(right.key, right.val(), app.right(), right.right()));\n\t\telse\n\t\t\treturn balanceLeftDel(left.key, left.val(), left.left(), black(right.key, right.val(), app, right.right()));\n\t\t}\n}\n\nstatic Node balanceLeftDel(Object key, Object val, Node del, Node right){\n\tif(del instanceof Red)\n\t\treturn red(key, val, del.blacken(), right);\n\telse if(right instanceof Black)\n\t\treturn rightBalance(key, val, del, right.redden());\n\telse if(right instanceof Red && right.left() instanceof Black)\n\t\treturn red(right.left().key, right.left().val(),\n\t\t           black(key, val, del, right.left().left()),\n\t\t           rightBalance(right.key, right.val(), right.left().right(), right.right().redden()));\n\telse\n\t\tthrow new UnsupportedOperationException(\"Invariant violation\");\n}\n\nstatic Node balanceRightDel(Object key, Object val, Node left, Node del){\n\tif(del instanceof Red)\n\t\treturn red(key, val, left, del.blacken());\n\telse if(left instanceof Black)\n\t\treturn leftBalance(key, val, left.redden(), del);\n\telse if(left instanceof Red && left.right() instanceof Black)\n\t\treturn red(left.right().key, left.right().val(),\n\t\t           leftBalance(left.key, left.val(), left.left().redden(), left.right().left()),\n\t\t           black(key, val, left.right().right(), del));\n\telse\n\t\tthrow new UnsupportedOperationException(\"Invariant violation\");\n}\n\nstatic Node leftBalance(Object key, Object val, Node ins, Node right){\n\tif(ins instanceof Red && ins.left() instanceof Red)\n\t\treturn red(ins.key, ins.val(), ins.left().blacken(), black(key, val, ins.right(), right));\n\telse if(ins instanceof Red && ins.right() instanceof Red)\n\t\treturn red(ins.right().key, ins.right().val(),\n\t\t           black(ins.key, ins.val(), ins.left(), ins.right().left()),\n\t\t           black(key, val, ins.right().right(), right));\n\telse\n\t\treturn black(key, val, ins, right);\n}\n\n\nstatic Node rightBalance(Object key, Object val, Node left, Node ins){\n\tif(ins instanceof Red && ins.right() instanceof Red)\n\t\treturn red(ins.key, ins.val(), black(key, val, left, ins.left()), ins.right().blacken());\n\telse if(ins instanceof Red && ins.left() instanceof Red)\n\t\treturn red(ins.left().key, ins.left().val(),\n\t\t           black(key, val, left, ins.left().left()),\n\t\t           black(ins.key, ins.val(), ins.left().right(), ins.right()));\n\telse\n\t\treturn black(key, val, left, ins);\n}\n\nNode replace(Node t, Object key, Object val){\n\tint c = doCompare(key, t.key);\n\treturn t.replace(t.key,\n\t                 c == 0 ? val : t.val(),\n\t                 c < 0 ? replace(t.left(), key, val) : t.left(),\n\t                 c > 0 ? replace(t.right(), key, val) : t.right());\n}\n\nPersistentTreeMap(Comparator comp, Node tree, int count, IPersistentMap meta){\n\tthis._meta = meta;\n\tthis.comp = comp;\n\tthis.tree = tree;\n\tthis._count = count;\n}\n\nstatic Red red(Object key, Object val, Node left, Node right){\n\tif(left == null && right == null)\n\t\t{\n\t\tif(val == null)\n\t\t\treturn new Red(key);\n\t\treturn new RedVal(key, val);\n\t\t}\n\tif(val == null)\n\t\treturn new RedBranch(key, left, right);\n\treturn new RedBranchVal(key, val, left, right);\n}\n\nstatic Black black(Object key, Object val, Node left, Node right){\n\tif(left == null && right == null)\n\t\t{\n\t\tif(val == null)\n\t\t\treturn new Black(key);\n\t\treturn new BlackVal(key, val);\n\t\t}\n\tif(val == null)\n\t\treturn new BlackBranch(key, left, right);\n\treturn new BlackBranchVal(key, val, left, right);\n}\n\npublic IPersistentMap meta(){\n\treturn _meta;\n}\n\nstatic abstract class Node extends AMapEntry{\n\tfinal Object key;\n\n\tNode(Object key){\n\t\tthis.key = key;\n\t}\n\n\tpublic Object key(){\n\t\treturn key;\n\t}\n\n\tpublic Object val(){\n\t\treturn null;\n\t}\n\n\tpublic Object getKey(){\n\t\treturn key();\n\t}\n\n\tpublic Object getValue(){\n\t\treturn val();\n\t}\n\n\tNode left(){\n\t\treturn null;\n\t}\n\n\tNode right(){\n\t\treturn null;\n\t}\n\n\tabstract Node addLeft(Node ins);\n\n\tabstract Node addRight(Node ins);\n\n\tabstract Node removeLeft(Node del);\n\n\tabstract Node removeRight(Node del);\n\n\tabstract Node blacken();\n\n\tabstract Node redden();\n\n\tNode balanceLeft(Node parent){\n\t\treturn black(parent.key, parent.val(), this, parent.right());\n\t}\n\n\tNode balanceRight(Node parent){\n\t\treturn black(parent.key, parent.val(), parent.left(), this);\n\t}\n\n\tabstract Node replace(Object key, Object val, Node left, Node right);\n\n    public Object kvreduce(IFn f, Object init){\n\t    if(left() != null){\n            init = left().kvreduce(f, init);\n\t        if(RT.isReduced(init))\n\t\t        return init;\n\t        }\n\t    init = f.invoke(init, key(), val());\n\t    if(RT.isReduced(init))\n\t\t    return init;\n\n\t    if(right() != null){\n            init = right().kvreduce(f, init);\n\t        }\n\t    return init;\n    }\n\n\n}\n\nstatic class Black extends Node{\n\tpublic Black(Object key){\n\t\tsuper(key);\n\t}\n\n\tNode addLeft(Node ins){\n\t\treturn ins.balanceLeft(this);\n\t}\n\n\tNode addRight(Node ins){\n\t\treturn ins.balanceRight(this);\n\t}\n\n\tNode removeLeft(Node del){\n\t\treturn balanceLeftDel(key, val(), del, right());\n\t}\n\n\tNode removeRight(Node del){\n\t\treturn balanceRightDel(key, val(), left(), del);\n\t}\n\n\tNode blacken(){\n\t\treturn this;\n\t}\n\n\tNode redden(){\n\t\treturn new Red(key);\n\t}\n\n\tNode replace(Object key, Object val, Node left, Node right){\n\t\treturn black(key, val, left, right);\n\t}\n\n}\n\nstatic class BlackVal extends Black{\n\tfinal Object val;\n\n\tpublic BlackVal(Object key, Object val){\n\t\tsuper(key);\n\t\tthis.val = val;\n\t}\n\n\tpublic Object val(){\n\t\treturn val;\n\t}\n\n\tNode redden(){\n\t\treturn new RedVal(key, val);\n\t}\n\n}\n\nstatic class BlackBranch extends Black{\n\tfinal Node left;\n\n\tfinal Node right;\n\n\tpublic BlackBranch(Object key, Node left, Node right){\n\t\tsuper(key);\n\t\tthis.left = left;\n\t\tthis.right = right;\n\t}\n\n\tpublic Node left(){\n\t\treturn left;\n\t}\n\n\tpublic Node right(){\n\t\treturn right;\n\t}\n\n\tNode redden(){\n\t\treturn new RedBranch(key, left, right);\n\t}\n\n}\n\nstatic class BlackBranchVal extends BlackBranch{\n\tfinal Object val;\n\n\tpublic BlackBranchVal(Object key, Object val, Node left, Node right){\n\t\tsuper(key, left, right);\n\t\tthis.val = val;\n\t}\n\n\tpublic Object val(){\n\t\treturn val;\n\t}\n\n\tNode redden(){\n\t\treturn new RedBranchVal(key, val, left, right);\n\t}\n\n}\n\nstatic class Red extends Node{\n\tpublic Red(Object key){\n\t\tsuper(key);\n\t}\n\n\tNode addLeft(Node ins){\n\t\treturn red(key, val(), ins, right());\n\t}\n\n\tNode addRight(Node ins){\n\t\treturn red(key, val(), left(), ins);\n\t}\n\n\tNode removeLeft(Node del){\n\t\treturn red(key, val(), del, right());\n\t}\n\n\tNode removeRight(Node del){\n\t\treturn red(key, val(), left(), del);\n\t}\n\n\tNode blacken(){\n\t\treturn new Black(key);\n\t}\n\n\tNode redden(){\n\t\tthrow new UnsupportedOperationException(\"Invariant violation\");\n\t}\n\n\tNode replace(Object key, Object val, Node left, Node right){\n\t\treturn red(key, val, left, right);\n\t}\n\n}\n\nstatic class RedVal extends Red{\n\tfinal Object val;\n\n\tpublic RedVal(Object key, Object val){\n\t\tsuper(key);\n\t\tthis.val = val;\n\t}\n\n\tpublic Object val(){\n\t\treturn val;\n\t}\n\n\tNode blacken(){\n\t\treturn new BlackVal(key, val);\n\t}\n\n}\n\nstatic class RedBranch extends Red{\n\tfinal Node left;\n\n\tfinal Node right;\n\n\tpublic RedBranch(Object key, Node left, Node right){\n\t\tsuper(key);\n\t\tthis.left = left;\n\t\tthis.right = right;\n\t}\n\n\tpublic Node left(){\n\t\treturn left;\n\t}\n\n\tpublic Node right(){\n\t\treturn right;\n\t}\n\n\tNode balanceLeft(Node parent){\n\t\tif(left instanceof Red)\n\t\t\treturn red(key, val(), left.blacken(), black(parent.key, parent.val(), right, parent.right()));\n\t\telse if(right instanceof Red)\n\t\t\treturn red(right.key, right.val(), black(key, val(), left, right.left()),\n\t\t\t           black(parent.key, parent.val(), right.right(), parent.right()));\n\t\telse\n\t\t\treturn super.balanceLeft(parent);\n\n\t}\n\n\tNode balanceRight(Node parent){\n\t\tif(right instanceof Red)\n\t\t\treturn red(key, val(), black(parent.key, parent.val(), parent.left(), left), right.blacken());\n\t\telse if(left instanceof Red)\n\t\t\treturn red(left.key, left.val(), black(parent.key, parent.val(), parent.left(), left.left()),\n\t\t\t           black(key, val(), left.right(), right));\n\t\telse\n\t\t\treturn super.balanceRight(parent);\n\t}\n\n\tNode blacken(){\n\t\treturn new BlackBranch(key, left, right);\n\t}\n\n}\n\n\nstatic class RedBranchVal extends RedBranch{\n\tfinal Object val;\n\n\tpublic RedBranchVal(Object key, Object val, Node left, Node right){\n\t\tsuper(key, left, right);\n\t\tthis.val = val;\n\t}\n\n\tpublic Object val(){\n\t\treturn val;\n\t}\n\n\tNode blacken(){\n\t\treturn new BlackBranchVal(key, val, left, right);\n\t}\n}\n\n\nstatic public class Seq extends ASeq{\n\tfinal ISeq stack;\n\tfinal boolean asc;\n\tfinal int cnt;\n\n\tpublic Seq(ISeq stack, boolean asc){\n\t\tthis.stack = stack;\n\t\tthis.asc = asc;\n\t\tthis.cnt = -1;\n\t}\n\n\tpublic Seq(ISeq stack, boolean asc, int cnt){\n\t\tthis.stack = stack;\n\t\tthis.asc = asc;\n\t\tthis.cnt = cnt;\n\t}\n\n\tSeq(IPersistentMap meta, ISeq stack, boolean asc, int cnt){\n\t\tsuper(meta);\n\t\tthis.stack = stack;\n\t\tthis.asc = asc;\n\t\tthis.cnt = cnt;\n\t}\n\n\tstatic Seq create(Node t, boolean asc, int cnt){\n\t\treturn new Seq(push(t, null, asc), asc, cnt);\n\t}\n\n\tstatic ISeq push(Node t, ISeq stack, boolean asc){\n\t\twhile(t != null)\n\t\t\t{\n\t\t\tstack = RT.cons(t, stack);\n\t\t\tt = asc ? t.left() : t.right();\n\t\t\t}\n\t\treturn stack;\n\t}\n\n\tpublic Object first(){\n\t\treturn stack.first();\n\t}\n\n\tpublic ISeq next(){\n\t\tNode t = (Node) stack.first();\n\t\tISeq nextstack = push(asc ? t.right() : t.left(), stack.next(), asc);\n\t\tif(nextstack != null)\n\t\t\t{\n\t\t\treturn new Seq(nextstack, asc, cnt - 1);\n\t\t\t}\n\t\treturn null;\n\t}\n\n\tpublic int count(){\n\t\tif(cnt < 0)\n\t\t\treturn super.count();\n\t\treturn cnt;\n\t}\n\n\tpublic Obj withMeta(IPersistentMap meta){\n\t\treturn new Seq(meta, stack, asc, cnt);\n\t}\n}\n\nstatic public class NodeIterator implements Iterator{\n\tStack stack = new Stack();\n\tboolean asc;\n\n\tNodeIterator(Node t, boolean asc){\n\t\tthis.asc = asc;\n\t\tpush(t);\n\t}\n\n\tvoid push(Node t){\n\t\twhile(t != null)\n\t\t\t{\n\t\t\tstack.push(t);\n\t\t\tt = asc ? t.left() : t.right();\n\t\t\t}\n\t}\n\n\tpublic boolean hasNext(){\n\t\treturn !stack.isEmpty();\n\t}\n\n\tpublic Object next(){\n\t\tNode t = (Node) stack.pop();\n\t\tpush(asc ? t.right() : t.left());\n\t\treturn t;\n\t}\n\n\tpublic void remove(){\n\t\tthrow new UnsupportedOperationException();\n\t}\n}\n\nstatic class KeyIterator implements Iterator{\n\tNodeIterator it;\n\n\tKeyIterator(NodeIterator it){\n\t\tthis.it = it;\n\t}\n\n\tpublic boolean hasNext(){\n\t\treturn it.hasNext();\n\t}\n\n\tpublic Object next(){\n\t\treturn ((Node) it.next()).key;\n\t}\n\n\tpublic void remove(){\n\t\tthrow new UnsupportedOperationException();\n\t}\n}\n\nstatic class ValIterator implements Iterator{\n\tNodeIterator it;\n\n\tValIterator(NodeIterator it){\n\t\tthis.it = it;\n\t}\n\n\tpublic boolean hasNext(){\n\t\treturn it.hasNext();\n\t}\n\n\tpublic Object next(){\n\t\treturn ((Node) it.next()).val();\n\t}\n\n\tpublic void remove(){\n\t\tthrow new UnsupportedOperationException();\n\t}\n}\n/*\nstatic public void main(String args[]){\n\tif(args.length != 1)\n\t\tSystem.err.println(\"Usage: RBTree n\");\n\tint n = Integer.parseInt(args[0]);\n\tInteger[] ints = new Integer[n];\n\tfor(int i = 0; i < ints.length; i++)\n\t\t{\n\t\tints[i] = i;\n\t\t}\n\tCollections.shuffle(Arrays.asList(ints));\n\t//force the ListMap class loading now\n//\ttry\n//\t\t{\n//\n//\t\t//PersistentListMap.EMPTY.assocEx(1, null).assocEx(2,null).assocEx(3,null);\n//\t\t}\n//\tcatch(Exception e)\n//\t\t{\n//\t\te.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.\n//\t\t}\n\tSystem.out.println(\"Building set\");\n\t//IPersistentMap set = new PersistentArrayMap();\n\t//IPersistentMap set = new PersistentHashtableMap(1001);\n\tIPersistentMap set = PersistentHashMap.EMPTY;\n\t//IPersistentMap set = new ListMap();\n\t//IPersistentMap set = new ArrayMap();\n\t//IPersistentMap set = new PersistentTreeMap();\n//\tfor(int i = 0; i < ints.length; i++)\n//\t\t{\n//\t\tInteger anInt = ints[i];\n//\t\tset = set.add(anInt);\n//\t\t}\n\tlong startTime = System.nanoTime();\n\tfor(Integer anInt : ints)\n\t\t{\n\t\tset = set.assoc(anInt, anInt);\n\t\t}\n\t//System.out.println(\"_count = \" + set.count());\n\n//\tSystem.out.println(\"_count = \" + set._count + \", min: \" + set.minKey() + \", max: \" + set.maxKey()\n//\t                   + \", depth: \" + set.depth());\n\tfor(Object aSet : set)\n\t\t{\n\t\tIMapEntry o = (IMapEntry) aSet;\n\t\tif(!set.contains(o.key()))\n\t\t\tSystem.err.println(\"Can't find: \" + o.key());\n\t\t//else if(n < 2000)\n\t\t//\tSystem.out.print(o.key().toString() + \",\");\n\t\t}\n\n\tRandom rand = new Random(42);\n\tfor(int i = 0; i < ints.length / 2; i++)\n\t\t{\n\t\tInteger anInt = ints[rand.nextInt(n)];\n\t\tset = set.without(anInt);\n\t\t}\n\n\tlong estimatedTime = System.nanoTime() - startTime;\n\tSystem.out.println();\n\n\tSystem.out.println(\"_count = \" + set.count() + \", time: \" + estimatedTime / 1000000);\n\n\tSystem.out.println(\"Building ht\");\n\tHashtable ht = new Hashtable(1001);\n\tstartTime = System.nanoTime();\n//\tfor(int i = 0; i < ints.length; i++)\n//\t\t{\n//\t\tInteger anInt = ints[i];\n//\t\tht.put(anInt,null);\n//\t\t}\n\tfor(Integer anInt : ints)\n\t\t{\n\t\tht.put(anInt, anInt);\n\t\t}\n\t//System.out.println(\"size = \" + ht.size());\n\t//Iterator it = ht.entrySet().iterator();\n\tfor(Object o1 : ht.entrySet())\n\t\t{\n\t\tMap.Entry o = (Map.Entry) o1;\n\t\tif(!ht.containsKey(o.getKey()))\n\t\t\tSystem.err.println(\"Can't find: \" + o);\n\t\t//else if(n < 2000)\n\t\t//\tSystem.out.print(o.toString() + \",\");\n\t\t}\n\n\trand = new Random(42);\n\tfor(int i = 0; i < ints.length / 2; i++)\n\t\t{\n\t\tInteger anInt = ints[rand.nextInt(n)];\n\t\tht.remove(anInt);\n\t\t}\n\testimatedTime = System.nanoTime() - startTime;\n\tSystem.out.println();\n\tSystem.out.println(\"size = \" + ht.size() + \", time: \" + estimatedTime / 1000000);\n\n\tSystem.out.println(\"set lookup\");\n\tstartTime = System.nanoTime();\n\tint c = 0;\n\tfor(Integer anInt : ints)\n\t\t{\n\t\tif(!set.contains(anInt))\n\t\t\t++c;\n\t\t}\n\testimatedTime = System.nanoTime() - startTime;\n\tSystem.out.println(\"notfound = \" + c + \", time: \" + estimatedTime / 1000000);\n\n\tSystem.out.println(\"ht lookup\");\n\tstartTime = System.nanoTime();\n\tc = 0;\n\tfor(Integer anInt : ints)\n\t\t{\n\t\tif(!ht.containsKey(anInt))\n\t\t\t++c;\n\t\t}\n\testimatedTime = System.nanoTime() - startTime;\n\tSystem.out.println(\"notfound = \" + c + \", time: \" + estimatedTime / 1000000);\n\n//\tSystem.out.println(\"_count = \" + set._count + \", min: \" + set.minKey() + \", max: \" + set.maxKey()\n//\t                   + \", depth: \" + set.depth());\n}\n*/\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/PersistentTreeSet.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 3, 2008 */\n\npackage clojure.lang;\n\nimport java.util.Comparator;\n\npublic class PersistentTreeSet extends APersistentSet implements IObj, Reversible, Sorted{\nstatic public final PersistentTreeSet EMPTY = new PersistentTreeSet(null, PersistentTreeMap.EMPTY);\nfinal IPersistentMap _meta;\n\n\nstatic public PersistentTreeSet create(ISeq items){\n\tPersistentTreeSet ret = EMPTY;\n\tfor(; items != null; items = items.next())\n\t\t{\n\t\tret = (PersistentTreeSet) ret.cons(items.first());\n\t\t}\n\treturn ret;\n}\n\nstatic public PersistentTreeSet create(Comparator comp, ISeq items){\n\tPersistentTreeSet ret = new PersistentTreeSet(null, new PersistentTreeMap(null, comp));\n\tfor(; items != null; items = items.next())\n\t\t{\n\t\tret = (PersistentTreeSet) ret.cons(items.first());\n\t\t}\n\treturn ret;\n}\n\nPersistentTreeSet(IPersistentMap meta, IPersistentMap impl){\n\tsuper(impl);\n\tthis._meta = meta;\n}\n\npublic IPersistentSet disjoin(Object key) {\n\tif(contains(key))\n\t\treturn new PersistentTreeSet(meta(),impl.without(key));\n\treturn this;\n}\n\npublic IPersistentSet cons(Object o){\n\tif(contains(o))\n\t\treturn this;\n\treturn new PersistentTreeSet(meta(),impl.assoc(o,o));\n}\n\npublic IPersistentCollection empty(){\n\treturn new PersistentTreeSet(meta(),(PersistentTreeMap)impl.empty());\n}\n\npublic ISeq rseq() {\n\treturn APersistentMap.KeySeq.create(((Reversible) impl).rseq());\n}\n\npublic PersistentTreeSet withMeta(IPersistentMap meta){\n\treturn new PersistentTreeSet(meta, impl);\n}\n\npublic Comparator comparator(){\n\treturn ((Sorted)impl).comparator();\n}\n\npublic Object entryKey(Object entry){\n\treturn entry;\n}\n\npublic ISeq seq(boolean ascending){\n\tPersistentTreeMap m = (PersistentTreeMap) impl;\n\treturn RT.keys(m.seq(ascending));\n}\n\npublic ISeq seqFrom(Object key, boolean ascending){\n\tPersistentTreeMap m = (PersistentTreeMap) impl;\n\treturn RT.keys(m.seqFrom(key,ascending));\n}\n\npublic IPersistentMap meta(){\n\treturn _meta;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/PersistentVector.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jul 5, 2007 */\n\npackage clojure.lang;\n\nimport java.io.Serializable;\nimport java.util.ArrayList;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.concurrent.atomic.AtomicReference;\n\npublic class PersistentVector extends APersistentVector implements IObj, IEditableCollection, IReduce{\n\npublic static class Node implements Serializable {\n\ttransient public final AtomicReference<Thread> edit;\n\tpublic final Object[] array;\n\n\tpublic Node(AtomicReference<Thread> edit, Object[] array){\n\t\tthis.edit = edit;\n\t\tthis.array = array;\n\t}\n\n\tNode(AtomicReference<Thread> edit){\n\t\tthis.edit = edit;\n\t\tthis.array = new Object[32];\n\t}\n}\n\nfinal static AtomicReference<Thread> NOEDIT = new AtomicReference<Thread>(null);\npublic final static Node EMPTY_NODE = new Node(NOEDIT, new Object[32]);\n\nfinal int cnt;\npublic final int shift;\npublic final Node root;\npublic final Object[] tail;\nfinal IPersistentMap _meta;\n\n\npublic final static PersistentVector EMPTY = new PersistentVector(0, 5, EMPTY_NODE, new Object[]{});\n\nprivate static final IFn TRANSIENT_VECTOR_CONJ = new AFn() {\n    public Object invoke(Object coll, Object val) {\n        return ((ITransientVector)coll).conj(val);\n    }\n    public Object invoke(Object coll) {\n        return coll;\n    }\n};\n\nstatic public PersistentVector create(IReduceInit items) {\n    TransientVector ret = EMPTY.asTransient();\n    items.reduce(TRANSIENT_VECTOR_CONJ, ret);\n    return ret.persistent();\n}\n\nstatic public PersistentVector create(ISeq items){\n    Object[] arr = new Object[32];\n    int i = 0;\n    for(;items != null && i < 32; items = items.next())\n        arr[i++] = items.first();\n\n    if(items != null) {  // >32, construct with array directly\n        PersistentVector start = new PersistentVector(32, 5, EMPTY_NODE, arr);\n        TransientVector ret = start.asTransient();\n        for (; items != null; items = items.next())\n            ret = ret.uncheckedConj(items.first());\n        return ret.persistent();\n    } else if(i == 32) {   // exactly 32, skip copy\n        return new PersistentVector(32, 5, EMPTY_NODE, arr);\n    } else {  // <32, copy to minimum array and construct\n        Object[] arr2 = new Object[i];\n        System.arraycopy(arr, 0, arr2, 0, i);\n        return new PersistentVector(i, 5, EMPTY_NODE, arr2);\n    }\n}\n\nstatic public PersistentVector create(List list){\n    int size = list.size();\n    if (size <= 32)\n        return new PersistentVector(size, 5, PersistentVector.EMPTY_NODE, list.toArray());\n\n    TransientVector ret = EMPTY.asTransient();\n    for(int i=0; i<size; i++)\n        ret = ret.uncheckedConj(list.get(i));\n    return ret.persistent();\n}\n\nstatic public PersistentVector create(Iterable items){\n    // optimize common case\n    if(items instanceof ArrayList)\n        return create((ArrayList)items);\n\n    Iterator iter = items.iterator();\n    TransientVector ret = EMPTY.asTransient();\n    while(iter.hasNext())\n        ret = ret.conj(iter.next());\n    return ret.persistent();\n}\n\nstatic public PersistentVector create(Object... items){\n\tTransientVector ret = EMPTY.asTransient();\n\tfor(Object item : items)\n\t\tret = ret.conj(item);\n\treturn ret.persistent();\n}\n\nPersistentVector(int cnt, int shift, Node root, Object[] tail){\n\tthis._meta = null;\n\tthis.cnt = cnt;\n\tthis.shift = shift;\n\tthis.root = root;\n\tthis.tail = tail;\n}\n\n\nPersistentVector(IPersistentMap meta, int cnt, int shift, Node root, Object[] tail){\n\tthis._meta = meta;\n\tthis.cnt = cnt;\n\tthis.shift = shift;\n\tthis.root = root;\n\tthis.tail = tail;\n}\n\npublic TransientVector asTransient(){\n\treturn new TransientVector(this);\n}\n\nfinal int tailoff(){\n\tif(cnt < 32)\n\t\treturn 0;\n\treturn ((cnt - 1) >>> 5) << 5;\n}\n\npublic Object[] arrayFor(int i){\n\tif(i >= 0 && i < cnt)\n\t\t{\n\t\tif(i >= tailoff())\n\t\t\treturn tail;\n\t\tNode node = root;\n\t\tfor(int level = shift; level > 0; level -= 5)\n\t\t\tnode = (Node) node.array[(i >>> level) & 0x01f];\n\t\treturn node.array;\n\t\t}\n\tthrow new IndexOutOfBoundsException();\n}\n\npublic Object nth(int i){\n\tObject[] node = arrayFor(i);\n\treturn node[i & 0x01f];\n}\n\npublic Object nth(int i, Object notFound){\n\tif(i >= 0 && i < cnt)\n\t\treturn nth(i);\n\treturn notFound;\n}\n\npublic PersistentVector assocN(int i, Object val){\n\tif(i >= 0 && i < cnt)\n\t\t{\n\t\tif(i >= tailoff())\n\t\t\t{\n\t\t\tObject[] newTail = new Object[tail.length];\n\t\t\tSystem.arraycopy(tail, 0, newTail, 0, tail.length);\n\t\t\tnewTail[i & 0x01f] = val;\n\n\t\t\treturn new PersistentVector(meta(), cnt, shift, root, newTail);\n\t\t\t}\n\n\t\treturn new PersistentVector(meta(), cnt, shift, doAssoc(shift, root, i, val), tail);\n\t\t}\n\tif(i == cnt)\n\t\treturn cons(val);\n\tthrow new IndexOutOfBoundsException();\n}\n\nprivate static Node doAssoc(int level, Node node, int i, Object val){\n\tNode ret = new Node(node.edit,node.array.clone());\n\tif(level == 0)\n\t\t{\n\t\tret.array[i & 0x01f] = val;\n\t\t}\n\telse\n\t\t{\n\t\tint subidx = (i >>> level) & 0x01f;\n\t\tret.array[subidx] = doAssoc(level - 5, (Node) node.array[subidx], i, val);\n\t\t}\n\treturn ret;\n}\n\npublic int count(){\n\treturn cnt;\n}\n\npublic PersistentVector withMeta(IPersistentMap meta){\n\treturn new PersistentVector(meta, cnt, shift, root, tail);\n}\n\npublic IPersistentMap meta(){\n\treturn _meta;\n}\n\n\npublic PersistentVector cons(Object val){\n\tint i = cnt;\n\t//room in tail?\n//\tif(tail.length < 32)\n\tif(cnt - tailoff() < 32)\n\t\t{\n\t\tObject[] newTail = new Object[tail.length + 1];\n\t\tSystem.arraycopy(tail, 0, newTail, 0, tail.length);\n\t\tnewTail[tail.length] = val;\n\t\treturn new PersistentVector(meta(), cnt + 1, shift, root, newTail);\n\t\t}\n\t//full tail, push into tree\n\tNode newroot;\n\tNode tailnode = new Node(root.edit,tail);\n\tint newshift = shift;\n\t//overflow root?\n\tif((cnt >>> 5) > (1 << shift))\n\t\t{\n\t\tnewroot = new Node(root.edit);\n\t\tnewroot.array[0] = root;\n\t\tnewroot.array[1] = newPath(root.edit,shift, tailnode);\n\t\tnewshift += 5;\n\t\t}\n\telse\n\t\tnewroot = pushTail(shift, root, tailnode);\n\treturn new PersistentVector(meta(), cnt + 1, newshift, newroot, new Object[]{val});\n}\n\nprivate Node pushTail(int level, Node parent, Node tailnode){\n\t//if parent is leaf, insert node,\n\t// else does it map to an existing child? -> nodeToInsert = pushNode one more level\n\t// else alloc new path\n\t//return  nodeToInsert placed in copy of parent\n\tint subidx = ((cnt - 1) >>> level) & 0x01f;\n\tNode ret = new Node(parent.edit, parent.array.clone());\n\tNode nodeToInsert;\n\tif(level == 5)\n\t\t{\n\t\tnodeToInsert = tailnode;\n\t\t}\n\telse\n\t\t{\n\t\tNode child = (Node) parent.array[subidx];\n\t\tnodeToInsert = (child != null)?\n\t\t                pushTail(level-5,child, tailnode)\n\t\t                :newPath(root.edit,level-5, tailnode);\n\t\t}\n\tret.array[subidx] = nodeToInsert;\n\treturn ret;\n}\n\nprivate static Node newPath(AtomicReference<Thread> edit,int level, Node node){\n\tif(level == 0)\n\t\treturn node;\n\tNode ret = new Node(edit);\n\tret.array[0] = newPath(edit, level - 5, node);\n\treturn ret;\n}\n\npublic IChunkedSeq chunkedSeq(){\n\tif(count() == 0)\n\t\treturn null;\n\treturn new ChunkedSeq(this,0,0);\n}\n\npublic ISeq seq(){\n\treturn chunkedSeq();\n}\n\n@Override\nIterator rangedIterator(final int start, final int end){\n\treturn new Iterator(){\n\t\tint i = start;\n\t\tint base = i - (i%32);\n\t\tObject[] array = (start < count())?arrayFor(i):null;\n\n\t\tpublic boolean hasNext(){\n\t\t\treturn i < end;\n\t\t\t}\n\n\t\tpublic Object next(){\n\t\t\tif(i-base == 32){\n\t\t\t\tarray = arrayFor(i);\n\t\t\t\tbase += 32;\n\t\t\t\t}\n\t\t\treturn array[i++ & 0x01f];\n\t\t\t}\n\n\t\tpublic void remove(){\n\t\t\tthrow new UnsupportedOperationException();\n\t\t}\n\t};\n}\n\npublic Iterator iterator(){return rangedIterator(0,count());}\n\npublic Object reduce(IFn f){\n    Object init;\n    if (cnt > 0)\n        init = arrayFor(0)[0];\n    else\n        return f.invoke();\n    int step = 0;\n    for(int i=0;i<cnt;i+=step){\n        Object[] array = arrayFor(i);\n        for(int j = (i==0)?1:0;j<array.length;++j){\n            init = f.invoke(init,array[j]);\n            if(RT.isReduced(init))\n\t            return ((IDeref)init).deref();\n            }\n        step = array.length;\n    }\n    return init;\n}\n\npublic Object reduce(IFn f, Object init){\n    int step = 0;\n    for(int i=0;i<cnt;i+=step){\n        Object[] array = arrayFor(i);\n        for(int j =0;j<array.length;++j){\n            init = f.invoke(init,array[j]);\n            if(RT.isReduced(init))\n\t            return ((IDeref)init).deref();\n            }\n        step = array.length;\n    }\n    return init;\n}\n\npublic Object kvreduce(IFn f, Object init){\n    int step = 0;\n    for(int i=0;i<cnt;i+=step){\n        Object[] array = arrayFor(i);\n        for(int j =0;j<array.length;++j){\n            init = f.invoke(init,j+i,array[j]);\n            if(RT.isReduced(init))\n\t            return ((IDeref)init).deref();\n            }\n        step = array.length;\n    }\n    return init;\n}\n\nstatic public final class ChunkedSeq extends ASeq implements IChunkedSeq,Counted{\n\n\tpublic final PersistentVector vec;\n\tfinal Object[] node;\n\tfinal int i;\n\tpublic final int offset;\n\n\tpublic ChunkedSeq(PersistentVector vec, int i, int offset){\n\t\tthis.vec = vec;\n\t\tthis.i = i;\n\t\tthis.offset = offset;\n\t\tthis.node = vec.arrayFor(i);\n\t}\n\n\tChunkedSeq(IPersistentMap meta, PersistentVector vec, Object[] node, int i, int offset){\n\t\tsuper(meta);\n\t\tthis.vec = vec;\n\t\tthis.node = node;\n\t\tthis.i = i;\n\t\tthis.offset = offset;\n\t}\n\n\tChunkedSeq(PersistentVector vec, Object[] node, int i, int offset){\n\t\tthis.vec = vec;\n\t\tthis.node = node;\n\t\tthis.i = i;\n\t\tthis.offset = offset;\n\t}\n\n\tpublic IChunk chunkedFirst() {\n\t\treturn new ArrayChunk(node, offset);\n\t\t}\n\n\tpublic ISeq chunkedNext(){\n\t\tif(i + node.length < vec.cnt)\n\t\t\treturn new ChunkedSeq(vec,i+ node.length,0);\n\t\treturn null;\n\t\t}\n\n\tpublic ISeq chunkedMore(){\n\t\tISeq s = chunkedNext();\n\t\tif(s == null)\n\t\t\treturn PersistentList.EMPTY;\n\t\treturn s;\n\t}\n\n\tpublic Obj withMeta(IPersistentMap meta){\n\t\tif(meta == this._meta)\n\t\t\treturn this;\n\t\treturn new ChunkedSeq(meta, vec, node, i, offset);\n\t}\n\n\tpublic Object first(){\n\t\treturn node[offset];\n\t}\n\n\tpublic ISeq next(){\n\t\tif(offset + 1 < node.length)\n\t\t\treturn new ChunkedSeq(vec, node, i, offset + 1);\n\t\treturn chunkedNext();\n\t}\n\n\tpublic int count(){\n\t\treturn vec.cnt - (i + offset);\n\t}\n}\n\npublic IPersistentCollection empty(){\n\treturn EMPTY.withMeta(meta());\n}\n\n//private Node pushTail(int level, Node node, Object[] tailNode, Box expansion){\n//\tObject newchild;\n//\tif(level == 0)\n//\t\t{\n//\t\tnewchild = tailNode;\n//\t\t}\n//\telse\n//\t\t{\n//\t\tnewchild = pushTail(level - 5, (Object[]) arr[arr.length - 1], tailNode, expansion);\n//\t\tif(expansion.val == null)\n//\t\t\t{\n//\t\t\tObject[] ret = arr.clone();\n//\t\t\tret[arr.length - 1] = newchild;\n//\t\t\treturn ret;\n//\t\t\t}\n//\t\telse\n//\t\t\tnewchild = expansion.val;\n//\t\t}\n//\t//expansion\n//\tif(arr.length == 32)\n//\t\t{\n//\t\texpansion.val = new Object[]{newchild};\n//\t\treturn arr;\n//\t\t}\n//\tObject[] ret = new Object[arr.length + 1];\n//\tSystem.arraycopy(arr, 0, ret, 0, arr.length);\n//\tret[arr.length] = newchild;\n//\texpansion.val = null;\n//\treturn ret;\n//}\n\npublic PersistentVector pop(){\n\tif(cnt == 0)\n\t\tthrow new IllegalStateException(\"Can't pop empty vector\");\n\tif(cnt == 1)\n\t\treturn EMPTY.withMeta(meta());\n\t//if(tail.length > 1)\n\tif(cnt-tailoff() > 1)\n\t\t{\n\t\tObject[] newTail = new Object[tail.length - 1];\n\t\tSystem.arraycopy(tail, 0, newTail, 0, newTail.length);\n\t\treturn new PersistentVector(meta(), cnt - 1, shift, root, newTail);\n\t\t}\n\tObject[] newtail = arrayFor(cnt - 2);\n\n\tNode newroot = popTail(shift, root);\n\tint newshift = shift;\n\tif(newroot == null)\n\t\t{\n\t\tnewroot = EMPTY_NODE;\n\t\t}\n\tif(shift > 5 && newroot.array[1] == null)\n\t\t{\n\t\tnewroot = (Node) newroot.array[0];\n\t\tnewshift -= 5;\n\t\t}\n\treturn new PersistentVector(meta(), cnt - 1, newshift, newroot, newtail);\n}\n\nprivate Node popTail(int level, Node node){\n\tint subidx = ((cnt-2) >>> level) & 0x01f;\n\tif(level > 5)\n\t\t{\n\t\tNode newchild = popTail(level - 5, (Node) node.array[subidx]);\n\t\tif(newchild == null && subidx == 0)\n\t\t\treturn null;\n\t\telse\n\t\t\t{\n\t\t\tNode ret = new Node(root.edit, node.array.clone());\n\t\t\tret.array[subidx] = newchild;\n\t\t\treturn ret;\n\t\t\t}\n\t\t}\n\telse if(subidx == 0)\n\t\treturn null;\n\telse\n\t\t{\n\t\tNode ret = new Node(root.edit, node.array.clone());\n\t\tret.array[subidx] = null;\n\t\treturn ret;\n\t\t}\n}\n\nstatic final class TransientVector extends AFn implements ITransientVector, Counted{\n\tvolatile int cnt;\n\tvolatile int shift;\n\tvolatile Node root;\n\tvolatile Object[] tail;\n\n\tTransientVector(int cnt, int shift, Node root, Object[] tail){\n\t\tthis.cnt = cnt;\n\t\tthis.shift = shift;\n\t\tthis.root = root;\n\t\tthis.tail = tail;\n\t}\n\n\tTransientVector(PersistentVector v){\n\t\tthis(v.cnt, v.shift, editableRoot(v.root), editableTail(v.tail));\n\t}\n\n\tpublic int count(){\n\t\tensureEditable();\n\t\treturn cnt;\n\t}\n\t\n\tNode ensureEditable(Node node){\n\t\tif(node.edit == root.edit)\n\t\t\treturn node;\n\t\treturn new Node(root.edit, node.array.clone());\n\t}\n\n\tvoid ensureEditable(){\n\t\tif(root.edit.get() == null)\n\t\t\tthrow new IllegalAccessError(\"Transient used after persistent! call\");\n\n//\t\troot = editableRoot(root);\n//\t\ttail = editableTail(tail);\n\t}\n\n\tstatic Node editableRoot(Node node){\n\t\treturn new Node(new AtomicReference<Thread>(Thread.currentThread()), node.array.clone());\n\t}\n\n\tpublic PersistentVector persistent(){\n\t\tensureEditable();\n//\t\tThread owner = root.edit.get();\n//\t\tif(owner != null && owner != Thread.currentThread())\n//\t\t\t{\n//\t\t\tthrow new IllegalAccessError(\"Mutation release by non-owner thread\");\n//\t\t\t}\n\t\troot.edit.set(null);\n\t\tObject[] trimmedTail = new Object[cnt-tailoff()];\n\t\tSystem.arraycopy(tail,0,trimmedTail,0,trimmedTail.length);\n\t\treturn new PersistentVector(cnt, shift, root, trimmedTail);\n\t}\n\n\tstatic Object[] editableTail(Object[] tl){\n\t\tObject[] ret = new Object[32];\n\t\tSystem.arraycopy(tl,0,ret,0,tl.length);\n\t\treturn ret;\n\t}\n\n\tpublic TransientVector conj(Object val){\n\t\tensureEditable();\n\t\treturn uncheckedConj(val);\n\t}\n\n  protected TransientVector uncheckedConj(Object val) {\n    int i = cnt;\n\t\t//room in tail?\n\t\tif(i - tailoff() < 32)\n\t\t\t{\n\t\t\ttail[i & 0x01f] = val;\n\t\t\t++cnt;\n\t\t\treturn this;\n\t\t\t}\n\t\t//full tail, push into tree\n\t\tNode newroot;\n\t\tNode tailnode = new Node(root.edit, tail);\n\t\ttail = new Object[32];\n\t\ttail[0] = val;\n\t\tint newshift = shift;\n\t\t//overflow root?\n\t\tif((cnt >>> 5) > (1 << shift))\n\t\t\t{\n\t\t\tnewroot = new Node(root.edit);\n\t\t\tnewroot.array[0] = root;\n\t\t\tnewroot.array[1] = newPath(root.edit,shift, tailnode);\n\t\t\tnewshift += 5;\n\t\t\t}\n\t\telse\n\t\t\tnewroot = pushTail(shift, root, tailnode);\n\t\troot = newroot;\n\t\tshift = newshift;\n\t\t++cnt;\n\t\treturn this;\n  }\n\n\tprivate Node pushTail(int level, Node parent, Node tailnode){\n\t\t//if parent is leaf, insert node,\n\t\t// else does it map to an existing child? -> nodeToInsert = pushNode one more level\n\t\t// else alloc new path\n\t\t//return  nodeToInsert placed in parent\n\t\tparent = ensureEditable(parent);\n\t\tint subidx = ((cnt - 1) >>> level) & 0x01f;\n\t\tNode ret = parent;\n\t\tNode nodeToInsert;\n\t\tif(level == 5)\n\t\t\t{\n\t\t\tnodeToInsert = tailnode;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tNode child = (Node) parent.array[subidx];\n\t\t\tnodeToInsert = (child != null) ?\n\t\t\t               pushTail(level - 5, child, tailnode)\n\t\t\t                               : newPath(root.edit, level - 5, tailnode);\n\t\t\t}\n\t\tret.array[subidx] = nodeToInsert;\n\t\treturn ret;\n\t}\n\n\tfinal private int tailoff(){\n\t\tif(cnt < 32)\n\t\t\treturn 0;\n\t\treturn ((cnt-1) >>> 5) << 5;\n\t}\n\n\tprivate Object[] arrayFor(int i){\n\t\tif(i >= 0 && i < cnt)\n\t\t\t{\n\t\t\tif(i >= tailoff())\n\t\t\t\treturn tail;\n\t\t\tNode node = root;\n\t\t\tfor(int level = shift; level > 0; level -= 5)\n\t\t\t\tnode = (Node) node.array[(i >>> level) & 0x01f];\n\t\t\treturn node.array;\n\t\t\t}\n\t\tthrow new IndexOutOfBoundsException();\n\t}\n\n\tprivate Object[] editableArrayFor(int i){\n\t\tif(i >= 0 && i < cnt)\n\t\t\t{\n\t\t\tif(i >= tailoff())\n\t\t\t\treturn tail;\n\t\t\tNode node = root;\n\t\t\tfor(int level = shift; level > 0; level -= 5)\n\t\t\t\tnode = ensureEditable((Node) node.array[(i >>> level) & 0x01f]);\n\t\t\treturn node.array;\n\t\t\t}\n\t\tthrow new IndexOutOfBoundsException();\n\t}\n\n\tpublic Object valAt(Object key){\n\t\t//note - relies on ensureEditable in 2-arg valAt\n\t\treturn valAt(key, null);\n\t}\n\n\tpublic Object valAt(Object key, Object notFound){\n\t\tensureEditable();\n\t\tif(Util.isInteger(key))\n\t\t\t{\n\t\t\tint i = ((Number) key).intValue();\n\t\t\tif(i >= 0 && i < cnt)\n\t\t\t\treturn nth(i);\n\t\t\t}\n\t\treturn notFound;\n\t}\n\n\tpublic Object invoke(Object arg1) {\n\t\t//note - relies on ensureEditable in nth\n\t\tif(Util.isInteger(arg1))\n\t\t\treturn nth(((Number) arg1).intValue());\n\t\tthrow new IllegalArgumentException(\"Key must be integer\");\n\t}\n\n\tpublic Object nth(int i){\n\t\tensureEditable();\n\t\tObject[] node = arrayFor(i);\n\t\treturn node[i & 0x01f];\n\t}\n\n\tpublic Object nth(int i, Object notFound){\n\t\tif(i >= 0 && i < count())\n\t\t\treturn nth(i);\n\t\treturn notFound;\n\t}\n\n\tpublic TransientVector assocN(int i, Object val){\n\t\tensureEditable();\n\t\tif(i >= 0 && i < cnt)\n\t\t\t{\n\t\t\tif(i >= tailoff())\n\t\t\t\t{\n\t\t\t\ttail[i & 0x01f] = val;\n\t\t\t\treturn this;\n\t\t\t\t}\n\n\t\t\troot = doAssoc(shift, root, i, val);\n\t\t\treturn this;\n\t\t\t}\n\t\tif(i == cnt)\n\t\t\treturn conj(val);\n\t\tthrow new IndexOutOfBoundsException();\n\t}\n\n\tpublic TransientVector assoc(Object key, Object val){\n\t\t//note - relies on ensureEditable in assocN\n\t\tif(Util.isInteger(key))\n\t\t\t{\n\t\t\tint i = ((Number) key).intValue();\n\t\t\treturn assocN(i, val);\n\t\t\t}\n\t\tthrow new IllegalArgumentException(\"Key must be integer\");\n\t}\n\n\tprivate Node doAssoc(int level, Node node, int i, Object val){\n\t\tnode = ensureEditable(node);\n\t\tNode ret = node;\n\t\tif(level == 0)\n\t\t\t{\n\t\t\tret.array[i & 0x01f] = val;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tint subidx = (i >>> level) & 0x01f;\n\t\t\tret.array[subidx] = doAssoc(level - 5, (Node) node.array[subidx], i, val);\n\t\t\t}\n\t\treturn ret;\n\t}\n\n\tpublic TransientVector pop(){\n\t\tensureEditable();\n\t\tif(cnt == 0)\n\t\t\tthrow new IllegalStateException(\"Can't pop empty vector\");\n\t\tif(cnt == 1)\n\t\t\t{\n\t\t\tcnt = 0;\n\t\t\treturn this;\n\t\t\t}\n\t\tint i = cnt - 1;\n\t\t//pop in tail?\n\t\tif((i & 0x01f) > 0)\n\t\t\t{\n\t\t\t--cnt;\n\t\t\treturn this;\n\t\t\t}\n\n\t\tObject[] newtail = editableArrayFor(cnt - 2);\n\n\t\tNode newroot = popTail(shift, root);\n\t\tint newshift = shift;\n\t\tif(newroot == null)\n\t\t\t{\n\t\t\tnewroot = new Node(root.edit);\n\t\t\t}\n\t\tif(shift > 5 && newroot.array[1] == null)\n\t\t\t{\n\t\t\tnewroot = ensureEditable((Node) newroot.array[0]);\n\t\t\tnewshift -= 5;\n\t\t\t}\n\t\troot = newroot;\n\t\tshift = newshift;\n\t\t--cnt;\n\t\ttail = newtail;\n\t\treturn this;\n\t}\n\n\tprivate Node popTail(int level, Node node){\n\t\tnode = ensureEditable(node);\n\t\tint subidx = ((cnt - 2) >>> level) & 0x01f;\n\t\tif(level > 5)\n\t\t\t{\n\t\t\tNode newchild = popTail(level - 5, (Node) node.array[subidx]);\n\t\t\tif(newchild == null && subidx == 0)\n\t\t\t\treturn null;\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tNode ret = node;\n\t\t\t\tret.array[subidx] = newchild;\n\t\t\t\treturn ret;\n\t\t\t\t}\n\t\t\t}\n\t\telse if(subidx == 0)\n\t\t\treturn null;\n\t\telse\n\t\t\t{\n\t\t\tNode ret = node;\n\t\t\tret.array[subidx] = null;\n\t\t\treturn ret;\n\t\t\t}\n\t}\n}\n/*\nstatic public void main(String[] args){\n\tif(args.length != 3)\n\t\t{\n\t\tSystem.err.println(\"Usage: PersistentVector size writes reads\");\n\t\treturn;\n\t\t}\n\tint size = Integer.parseInt(args[0]);\n\tint writes = Integer.parseInt(args[1]);\n\tint reads = Integer.parseInt(args[2]);\n//\tVector v = new Vector(size);\n\tArrayList v = new ArrayList(size);\n//\tv.setSize(size);\n\t//PersistentArray p = new PersistentArray(size);\n\tPersistentVector p = PersistentVector.EMPTY;\n//\tMutableVector mp = p.mutable();\n\n\tfor(int i = 0; i < size; i++)\n\t\t{\n\t\tv.add(i);\n//\t\tv.set(i, i);\n\t\t//p = p.set(i, 0);\n\t\tp = p.cons(i);\n//\t\tmp = mp.conj(i);\n\t\t}\n\n\tRandom rand;\n\n\trand = new Random(42);\n\tlong tv = 0;\n\tSystem.out.println(\"ArrayList\");\n\tlong startTime = System.nanoTime();\n\tfor(int i = 0; i < writes; i++)\n\t\t{\n\t\tv.set(rand.nextInt(size), i);\n\t\t}\n\tfor(int i = 0; i < reads; i++)\n\t\t{\n\t\ttv += (Integer) v.get(rand.nextInt(size));\n\t\t}\n\tlong estimatedTime = System.nanoTime() - startTime;\n\tSystem.out.println(\"time: \" + estimatedTime / 1000000);\n\tSystem.out.println(\"PersistentVector\");\n\trand = new Random(42);\n\tstartTime = System.nanoTime();\n\tlong tp = 0;\n\n//\tPersistentVector oldp = p;\n\t//Random rand2 = new Random(42);\n\n\tMutableVector mp = p.mutable();\n\tfor(int i = 0; i < writes; i++)\n\t\t{\n//\t\tp = p.assocN(rand.nextInt(size), i);\n\t\tmp = mp.assocN(rand.nextInt(size), i);\n//\t\tmp = mp.assoc(rand.nextInt(size), i);\n\t\t//dummy set to force perverse branching\n\t\t//oldp =\toldp.assocN(rand2.nextInt(size), i);\n\t\t}\n\tfor(int i = 0; i < reads; i++)\n\t\t{\n//\t\ttp += (Integer) p.nth(rand.nextInt(size));\n\t\ttp += (Integer) mp.nth(rand.nextInt(size));\n\t\t}\n//\tp = mp.immutable();\n\t//mp.cons(42);\n\testimatedTime = System.nanoTime() - startTime;\n\tSystem.out.println(\"time: \" + estimatedTime / 1000000);\n\tfor(int i = 0; i < size / 2; i++)\n\t\t{\n\t\tmp = mp.pop();\n//\t\tp = p.pop();\n\t\tv.remove(v.size() - 1);\n\t\t}\n\tp = (PersistentVector) mp.immutable();\n\t//mp.pop();  //should fail\n\tfor(int i = 0; i < size / 2; i++)\n\t\t{\n\t\ttp += (Integer) p.nth(i);\n\t\ttv += (Integer) v.get(i);\n\t\t}\n\tSystem.out.println(\"Done: \" + tv + \", \" + tp);\n\n}\n//  */\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ProxyHandler.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Oct 4, 2007 */\n\npackage clojure.lang;\n\nimport java.lang.reflect.InvocationHandler;\nimport java.lang.reflect.Method;\n\npublic class ProxyHandler implements InvocationHandler{\n//method-name-string->fn\nfinal IPersistentMap fns;\n\n\npublic ProxyHandler(IPersistentMap fns){\n\tthis.fns = fns;\n}\n\npublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable{\n\tClass rt = method.getReturnType();\n\tIFn fn = (IFn) fns.valAt(method.getName());\n\tif(fn == null)\n\t\t{\n\t\tif(rt == Void.TYPE)\n\t\t\treturn null;\n\t\telse if(method.getName().equals(\"equals\"))\n\t\t\t{\n\t\t\treturn proxy == args[0];\n\t\t\t}\n\t\telse if(method.getName().equals(\"hashCode\"))\n\t\t\t{\n\t\t\treturn System.identityHashCode(proxy);\n\t\t\t}\n\t\telse if(method.getName().equals(\"toString\"))\n\t\t\t{\n\t\t\treturn \"Proxy: \" + System.identityHashCode(proxy);\n\t\t\t}\n\t\tthrow new UnsupportedOperationException();\n\t\t}\n\tObject ret = fn.applyTo(ArraySeq.create(args));\n\tif(rt == Void.TYPE)\n\t\treturn null;\n\telse if(rt.isPrimitive())\n\t\t{\n\t\tif(rt == Character.TYPE)\n\t\t\treturn ret;\n\t\telse if(rt == Integer.TYPE)\n\t\t\treturn ((Number) ret).intValue();\n\t\telse if(rt == Long.TYPE)\n\t\t\treturn ((Number) ret).longValue();\n\t\telse if(rt == Float.TYPE)\n\t\t\treturn ((Number) ret).floatValue();\n\t\telse if(rt == Double.TYPE)\n\t\t\treturn ((Number) ret).doubleValue();\n\t\telse if(rt == Boolean.TYPE && !(ret instanceof Boolean))\n\t\t\treturn ret == null ? Boolean.FALSE : Boolean.TRUE;\n\t\telse if(rt == Byte.TYPE)\n\t\t\treturn (byte) ((Number) ret).intValue();\n\t\telse if(rt == Short.TYPE)\n\t\t\treturn (short) ((Number) ret).intValue();\n\t\t}\n\treturn ret;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/RT.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 25, 2006 4:28:27 PM */\n\npackage clojure.lang;\n\nimport java.io.FileNotFoundException;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.ObjectStreamException;\nimport java.io.OutputStreamWriter;\nimport java.io.PrintWriter;\nimport java.io.PushbackReader;\nimport java.io.Reader;\nimport java.io.Serializable;\nimport java.io.StringReader;\nimport java.io.StringWriter;\nimport java.io.Writer;\nimport java.lang.reflect.Array;\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\nimport java.net.MalformedURLException;\nimport java.net.URL;\nimport java.nio.charset.Charset;\nimport java.security.AccessController;\nimport java.security.PrivilegedAction;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Comparator;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.NoSuchElementException;\nimport java.util.RandomAccess;\nimport java.util.Set;\nimport java.util.concurrent.Callable;\nimport java.util.concurrent.atomic.AtomicInteger;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\n/*-[\n#include \"clojure/core_ns.h\"\n]-*/\n\npublic class RT {\n\n  static final public Boolean T = Boolean.TRUE;// Keyword.intern(Symbol.intern(null,\n                                               // \"t\"));\n  static final public Boolean F = Boolean.FALSE;// Keyword.intern(Symbol.intern(null,\n                                                // \"t\"));\n\n  static final public String LOADER_SUFFIX = \"__init\";\n  \n  static AtomicInteger id = new AtomicInteger(1);\n\n  // simple-symbol->class\n  final static IPersistentMap DEFAULT_IMPORTS = ObjC.objc ? map() : map(\n      // Symbol.intern(\"RT\"), \"clojure.lang.RT\",\n      // Symbol.intern(\"Num\"), \"clojure.lang.Num\",\n      // Symbol.intern(\"Symbol\"), \"clojure.lang.Symbol\",\n      // Symbol.intern(\"Keyword\"), \"clojure.lang.Keyword\",\n      // Symbol.intern(\"Var\"), \"clojure.lang.Var\",\n      // Symbol.intern(\"Ref\"), \"clojure.lang.Ref\",\n      // Symbol.intern(\"IFn\"), \"clojure.lang.IFn\",\n      // Symbol.intern(\"IObj\"), \"clojure.lang.IObj\",\n      // Symbol.intern(\"ISeq\"), \"clojure.lang.ISeq\",\n      // Symbol.intern(\"IPersistentCollection\"),\n      // \"clojure.lang.IPersistentCollection\",\n      // Symbol.intern(\"IPersistentMap\"), \"clojure.lang.IPersistentMap\",\n      // Symbol.intern(\"IPersistentList\"), \"clojure.lang.IPersistentList\",\n      // Symbol.intern(\"IPersistentVector\"), \"clojure.lang.IPersistentVector\",\n      Symbol.intern(\"Boolean\"),\n      Boolean.class,\n      Symbol.intern(\"Byte\"),\n      Byte.class,\n      Symbol.intern(\"Character\"),\n      Character.class,\n      Symbol.intern(\"Class\"),\n      Class.class,\n      Symbol.intern(\"ClassLoader\"),\n      ClassLoader.class,\n      // Symbol.intern(\"Compiler\"), Compiler.class,\n      Symbol.intern(\"Double\"), Double.class, Symbol.intern(\"Enum\"), Enum.class,\n      Symbol.intern(\"Float\"), Float.class, Symbol.intern(\"Integer\"),\n      Integer.class, Symbol.intern(\"Long\"), Long.class, Symbol.intern(\"Math\"),\n      Math.class, Symbol.intern(\"Number\"), Number.class,\n      Symbol.intern(\"Object\"), Object.class, Symbol.intern(\"Package\"),\n      Package.class, Symbol.intern(\"Runtime\"), Runtime.class,\n      Symbol.intern(\"SecurityManager\"), SecurityManager.class,\n      Symbol.intern(\"Short\"), Short.class, Symbol.intern(\"StackTraceElement\"),\n      StackTraceElement.class, Symbol.intern(\"StrictMath\"), StrictMath.class,\n      Symbol.intern(\"String\"), String.class, Symbol.intern(\"StringBuffer\"),\n      StringBuffer.class, Symbol.intern(\"StringBuilder\"), StringBuilder.class,\n      Symbol.intern(\"System\"), System.class, Symbol.intern(\"Thread\"),\n      Thread.class, Symbol.intern(\"ThreadGroup\"), ThreadGroup.class,\n      Symbol.intern(\"ThreadLocal\"), ThreadLocal.class,\n      Symbol.intern(\"Throwable\"), Throwable.class, Symbol.intern(\"Void\"),\n      Void.class, Symbol.intern(\"Appendable\"), Appendable.class,\n      Symbol.intern(\"CharSequence\"), CharSequence.class,\n      Symbol.intern(\"Cloneable\"), Cloneable.class, Symbol.intern(\"Comparable\"),\n      Comparable.class, Symbol.intern(\"Iterable\"), Iterable.class,\n      Symbol.intern(\"Readable\"), Readable.class, Symbol.intern(\"Runnable\"),\n      Runnable.class, Symbol.intern(\"Callable\"), Callable.class,\n      Symbol.intern(\"BigInteger\"), BigInteger.class,\n      Symbol.intern(\"BigDecimal\"), BigDecimal.class,\n      Symbol.intern(\"ArithmeticException\"), ArithmeticException.class,\n      Symbol.intern(\"ArrayIndexOutOfBoundsException\"),\n      ArrayIndexOutOfBoundsException.class,Symbol.intern(\"NoClassDefFoundError\"),\n      NoClassDefFoundError.class,\n      Symbol.intern(\"ArrayStoreException\"), ArrayStoreException.class,\n      Symbol.intern(\"ClassCastException\"), ClassCastException.class,\n      Symbol.intern(\"ClassNotFoundException\"), ClassNotFoundException.class,\n      Symbol.intern(\"CloneNotSupportedException\"),\n      CloneNotSupportedException.class, Symbol.intern(\"Exception\"),\n      Exception.class, Symbol.intern(\"IllegalAccessException\"),\n      IllegalAccessException.class, Symbol.intern(\"IllegalArgumentException\"),\n      IllegalArgumentException.class,\n      Symbol.intern(\"IllegalMonitorStateException\"),\n      IllegalMonitorStateException.class,\n      Symbol.intern(\"IllegalStateException\"), IllegalStateException.class,\n      Symbol.intern(\"IllegalThreadStateException\"),\n      IllegalThreadStateException.class,\n      Symbol.intern(\"IndexOutOfBoundsException\"),\n      IndexOutOfBoundsException.class, Symbol.intern(\"InstantiationException\"),\n      InstantiationException.class, Symbol.intern(\"InterruptedException\"),\n      InterruptedException.class, Symbol.intern(\"NegativeArraySizeException\"),\n      NegativeArraySizeException.class, Symbol.intern(\"NoSuchFieldException\"),\n      NoSuchFieldException.class, Symbol.intern(\"NoSuchMethodException\"),\n      NoSuchMethodException.class, Symbol.intern(\"NullPointerException\"),\n      NullPointerException.class, Symbol.intern(\"NumberFormatException\"),\n      NumberFormatException.class, Symbol.intern(\"RuntimeException\"),\n      RuntimeException.class, Symbol.intern(\"SecurityException\"),\n      SecurityException.class,\n      Symbol.intern(\"StringIndexOutOfBoundsException\"),\n      StringIndexOutOfBoundsException.class,\n      Symbol.intern(\"TypeNotPresentException\"), TypeNotPresentException.class,\n      Symbol.intern(\"UnsupportedOperationException\"),\n      UnsupportedOperationException.class,\n      Symbol.intern(\"AbstractMethodError\"), AbstractMethodError.class,\n      Symbol.intern(\"AssertionError\"), AssertionError.class,\n      Symbol.intern(\"ClassFormatError\"), ClassFormatError.class,\n      Symbol.intern(\"Error\"), Error.class,\n      Symbol.intern(\"ExceptionInInitializerError\"),\n      ExceptionInInitializerError.class, Symbol.intern(\"IllegalAccessError\"),\n      IllegalAccessError.class, Symbol.intern(\"IncompatibleClassChangeError\"),\n      IncompatibleClassChangeError.class, Symbol.intern(\"InternalError\"),\n      InternalError.class, Symbol.intern(\"LinkageError\"), LinkageError.class,\n      Symbol.intern(\"NoSuchFieldError\"), NoSuchFieldError.class,\n      Symbol.intern(\"NoSuchMethodError\"), NoSuchMethodError.class,\n      Symbol.intern(\"OutOfMemoryError\"), OutOfMemoryError.class,\n      Symbol.intern(\"ThreadDeath\"), ThreadDeath.class,\n      Symbol.intern(\"VirtualMachineError\"), VirtualMachineError.class,\n      Symbol.intern(\"Thread$UncaughtExceptionHandler\"),\n      Thread.UncaughtExceptionHandler.class, Symbol.intern(\"Thread$State\"),\n      Thread.State.class, Symbol.intern(\"Deprecated\"), Deprecated.class,\n      Symbol.intern(\"Override\"), Override.class,\n      Symbol.intern(\"SuppressWarnings\"), SuppressWarnings.class\n\n  // Symbol.intern(\"Collection\"), \"java.util.Collection\",\n  // Symbol.intern(\"Comparator\"), \"java.util.Comparator\",\n  // Symbol.intern(\"Enumeration\"), \"java.util.Enumeration\",\n  // Symbol.intern(\"EventListener\"), \"java.util.EventListener\",\n  // Symbol.intern(\"Formattable\"), \"java.util.Formattable\",\n  // Symbol.intern(\"Iterator\"), \"java.util.Iterator\",\n  // Symbol.intern(\"List\"), \"java.util.List\",\n  // Symbol.intern(\"ListIterator\"), \"java.util.ListIterator\",\n  // Symbol.intern(\"Map\"), \"java.util.Map\",\n  // Symbol.intern(\"Map$Entry\"), \"java.util.Map$Entry\",\n  // Symbol.intern(\"Observer\"), \"java.util.Observer\",\n  // Symbol.intern(\"Queue\"), \"java.util.Queue\",\n  // Symbol.intern(\"RandomAccess\"), \"java.util.RandomAccess\",\n  // Symbol.intern(\"Set\"), \"java.util.Set\",\n  // Symbol.intern(\"SortedMap\"), \"java.util.SortedMap\",\n  // Symbol.intern(\"SortedSet\"), \"java.util.SortedSet\"\n  );\n\n  // single instance of UTF-8 Charset, so as to avoid catching\n  // UnsupportedCharsetExceptions everywhere\n  static public Charset UTF8 = Charset.forName(\"UTF-8\");\n\n  static Object readTrueFalseUnknown(String s) {\n    if (s.equals(\"true\"))\n      return Boolean.TRUE;\n    else if (s.equals(\"false\"))\n      return Boolean.FALSE;\n    return Keyword.intern(null, \"unknown\");\n  }\n\n  static public final Namespace CLOJURE_NS = Namespace.findOrCreate(Symbol\n      .intern(\"clojure.core\"));\n  // static final Namespace USER_NS =\n  // Namespace.findOrCreate(Symbol.intern(\"user\"));\n  final static public Var OUT = Var.intern(CLOJURE_NS, Symbol.intern(\"*out*\"),\n      new OutputStreamWriter(System.out)).setDynamic();\n  final static public Var IN = Var.intern(CLOJURE_NS, Symbol.intern(\"*in*\"),\n      new LineNumberingPushbackReader(new InputStreamReader(System.in)))\n      .setDynamic();\n  final static public Var ERR = Var.intern(CLOJURE_NS, Symbol.intern(\"*err*\"),\n      new PrintWriter(new OutputStreamWriter(System.err), true)).setDynamic();\n  final static Keyword TAG_KEY = Keyword.intern(null, \"tag\");\n  final static Keyword CONST_KEY = Keyword.intern(null, \"const\");\n  final static public Var AGENT = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*agent*\"), null).setDynamic();\n  static Object readeval = readTrueFalseUnknown(System.getProperty(\n      \"clojure.read.eval\", \"true\"));\n  final static public Var READEVAL = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*read-eval*\"), readeval).setDynamic();\n  final static public Var DATA_READERS = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*data-readers*\"), RT.map()).setDynamic();\n  final static public Var DEFAULT_DATA_READER_FN = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*default-data-reader-fn*\"), RT.map()).setDynamic();\n  final static public Var DEFAULT_DATA_READERS = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"default-data-readers\"), RT.map());\n  final static public Var SUPPRESS_READ = Var.intern(CLOJURE_NS, Symbol.intern(\"*suppress-read*\"), null).setDynamic();\n  final static public Var ASSERT = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*assert*\"), T).setDynamic();\n  final static public Var MATH_CONTEXT = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*math-context*\"), null).setDynamic();\n  static Keyword LINE_KEY = Keyword.intern(null, \"line\");\n  static Keyword COLUMN_KEY = Keyword.intern(null, \"column\");\n  static Keyword FILE_KEY = Keyword.intern(null, \"file\");\n  static Keyword DECLARED_KEY = Keyword.intern(null, \"declared\");\n  static Keyword DOC_KEY = Keyword.intern(null, \"doc\");\n  final static public Var USE_CONTEXT_CLASSLOADER = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*use-context-classloader*\"), T).setDynamic();\n  // boolean\n  static final public Var UNCHECKED_MATH = Var.intern(\n      Namespace.findOrCreate(Symbol.intern(\"clojure.core\")),\n      Symbol.intern(\"*unchecked-math*\"), Boolean.FALSE).setDynamic();\n\n  // final static public Var CURRENT_MODULE =\n  // Var.intern(Symbol.intern(\"clojure.core\", \"current-module\"),\n  // Module.findOrCreateModule(\"clojure/user\"));\n\n  final static Symbol LOAD_FILE = Symbol.intern(\"load-file\");\n  final static Symbol IN_NAMESPACE = Symbol.intern(\"in-ns\");\n  final static Symbol NAMESPACE = Symbol.intern(\"ns\");\n  static final Symbol IDENTICAL = Symbol.intern(\"identical?\");\n  final static Var CMD_LINE_ARGS = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*command-line-args*\"), null).setDynamic();\n  // symbol\n  final public static Var CURRENT_NS = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*ns*\"), CLOJURE_NS).setDynamic();\n\n  final static Var FLUSH_ON_NEWLINE = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*flush-on-newline*\"), T).setDynamic();\n  final static Var PRINT_META = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*print-meta*\"), F).setDynamic();\n  final static Var PRINT_READABLY = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*print-readably*\"), T).setDynamic();\n  final static Var PRINT_DUP = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*print-dup*\"), F).setDynamic();\n  public final static Var WARN_ON_REFLECTION = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*warn-on-reflection*\"), F).setDynamic();\n  final static Var ALLOW_UNRESOLVED_VARS = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*allow-unresolved-vars*\"), F).setDynamic();\n\n  final static Var IN_NS_VAR = Var\n      .intern(CLOJURE_NS, Symbol.intern(\"in-ns\"), F);\n  final static Var NS_VAR = Var.intern(CLOJURE_NS, Symbol.intern(\"ns\"), F);\n  final static Var FN_LOADER_VAR = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"*fn-loader*\"), null).setDynamic();\n  static final Var PRINT_INITIALIZED = Var.intern(CLOJURE_NS,\n      Symbol.intern(\"print-initialized\"));\n  static final Var PR_ON = Var.intern(CLOJURE_NS, Symbol.intern(\"pr-on\"));\n  // final static Var IMPORTS = Var.intern(CLOJURE_NS,\n  // Symbol.intern(\"*imports*\"), DEFAULT_IMPORTS);\n  final static IFn inNamespace = new AFn() {\n    public Object invoke(Object arg1) {\n      Symbol nsname = (Symbol) arg1;\n      Namespace ns = Namespace.findOrCreate(nsname);\n      CURRENT_NS.set(ns);\n      return ns;\n    }\n  };\n\n  final static IFn bootNamespace = new AFn() {\n    public Object invoke(Object __form, Object __env, Object arg1) {\n      Symbol nsname = (Symbol) arg1;\n      Namespace ns = Namespace.findOrCreate(nsname);\n      CURRENT_NS.set(ns);\n      return ns;\n    }\n  };\n\n  public static List<String> processCommandLine(String[] args) {\n    List<String> arglist = Arrays.asList(args);\n    int split = arglist.indexOf(\"--\");\n    if (split >= 0) {\n      CMD_LINE_ARGS.bindRoot(RT.seq(arglist.subList(split + 1, args.length)));\n      return arglist.subList(0, split);\n    }\n    return arglist;\n  }\n\n  public static void dispatchInMain(final AFn fn) {\n    Var.pushThreadBindings(mapUniqueKeys(RT.var(\"clojure.core\", \"force-main-thread\"), true));\n    try {\n      if (ObjC.objc) {\n        dispatchInMainNative(fn);\n      } else {\n        fn.invoke();\n      }\n    } catch (Exception e) {\n      Var.popThreadBindings();\n    }\n  }\n  \n  public static native void dispatchInMainNative(final AFn fn) /*-[\n  if ([NSThread isMainThread]) {\n      [fn invoke];\n    } else {\n      dispatch_async(dispatch_get_main_queue(), ^{\n        [fn invoke];\n      });\n    }\n  ]-*/;\n  \n  public static void dispatchInMainSync(final AFn fn) {\n    Var.pushThreadBindings(mapUniqueKeys(RT.var(\"clojure.core\", \"force-main-thread\"), true));\n    try {\n      if (ObjC.objc) {\n        dispatchInMainSyncNative(fn);\n      } else {\n        fn.invoke();\n      }\n    } catch (Exception e) {\n      Var.popThreadBindings();\n    }\n  }\n  \n  public static native void dispatchInMainSyncNative(final AFn fn) /*-[\n    if ([NSThread isMainThread]) {\n      [fn invoke];\n    } else {\n      dispatch_sync(dispatch_get_main_queue(), ^{\n        [fn invoke];\n      });\n    }\n  ]-*/;\n  \n  // duck typing stderr plays nice with e.g. swank\n  public static PrintWriter errPrintWriter() {\n    Writer w = (Writer) ERR.deref();\n    if (w instanceof PrintWriter) {\n      return (PrintWriter) w;\n    } else {\n      return new PrintWriter(w);\n    }\n  }\n\n  static public final Object[] EMPTY_ARRAY = new Object[] {};\n  static public final Comparator DEFAULT_COMPARATOR = new DefaultComparator();\n\n  private static final class DefaultComparator implements Comparator,\n      Serializable {\n    public int compare(Object o1, Object o2) {\n      return Util.compare(o1, o2);\n    }\n\n    private Object readResolve() throws ObjectStreamException {\n      // ensures that we aren't hanging onto a new default comparator for every\n      // sorted set, etc., we deserialize\n      return DEFAULT_COMPARATOR;\n    }\n  }\n\n  public static boolean forceClass = false;\n\n  static {\n    Keyword arglistskw = Keyword.intern(null, \"arglists\");\n    Symbol namesym = Symbol.intern(\"name\");\n    OUT.setTag(Symbol.intern(\"java.io.Writer\"));\n    CURRENT_NS.setTag(Symbol.intern(\"clojure.lang.Namespace\"));\n    AGENT.setMeta(map(DOC_KEY,\n        \"The agent currently running an action on this thread, else nil\"));\n    AGENT.setTag(Symbol.intern(\"clojure.lang.Agent\"));\n    MATH_CONTEXT.setTag(Symbol.intern(\"java.math.MathContext\"));\n    Var nv = Var.intern(CLOJURE_NS, NAMESPACE, bootNamespace);\n    nv.setMacro();\n    Var v;\n    v = Var.intern(CLOJURE_NS, IN_NAMESPACE, inNamespace);\n    v.setMeta(map(\n        DOC_KEY,\n        \"Sets *ns* to the namespace named by the symbol, creating it if needed.\",\n        arglistskw, list(vector(namesym))));\n    v = Var.intern(CLOJURE_NS, LOAD_FILE, new AFn() {\n      public Object invoke(Object arg1) {\n        try {\n          return Compiler.loadFile((String) arg1);\n        } catch (IOException e) {\n          throw Util.sneakyThrow(e);\n        }\n      }\n    });\n    v.setMeta(map(\n        DOC_KEY,\n        \"Sequentially read and evaluate the set of forms contained in the file.\",\n        arglistskw, list(vector(namesym))));\n    try {\n      doInit();\n      if (ObjC.objc) {\n        loadFns();\n      } else {\n        Var.maybeLoadFromClass(\"clojure.core\", \"ns\");\n        Var.maybeLoadFromClass(\"clojure.core\", \"in-ns\");\n      }\n    } catch (Exception e) {\n      throw Util.sneakyThrow(e);\n    }\n  }\n\n  private static void doInit() {\n    try {\n      if (!ObjC.objc) {\n        RT.load(\"clojure/core\");\n        Var.pushThreadBindings(RT.mapUniqueKeys(CURRENT_NS, CURRENT_NS.deref(),\n            WARN_ON_REFLECTION, WARN_ON_REFLECTION.deref(), RT.UNCHECKED_MATH,\n            RT.UNCHECKED_MATH.deref()));\n        try {\n          Symbol USER = Symbol.intern(\"user\");\n          Symbol CLOJURE = Symbol.intern(\"clojure.core\");\n\n          Var in_ns = var(\"clojure.core\", \"in-ns\");\n          Var refer = var(\"clojure.core\", \"refer\");\n          in_ns.invoke(USER);\n          refer.invoke(CLOJURE);\n          maybeLoadResourceScript(\"user.clj\");\n        } finally {\n          Var.popThreadBindings();\n        }\n      }\n    } catch (Exception e) {\n      throw Util.sneakyThrow(e);\n    }\n  }\n\nprivate native static void loadFns() /*-[\n  Clojurecore_ns_get_VAR_();\n]-*/;\n\nstatic public void addURL(Object url) throws MalformedURLException{\n\tURL u = (url instanceof String) ? (new URL((String) url)) : (URL) url;\n\tClassLoader ccl = Thread.currentThread().getContextClassLoader();\n\tif(ccl instanceof DynamicClassLoader)\n\t\t((DynamicClassLoader)ccl).addURL(u);\n\telse\n\t\tthrow new IllegalAccessError(\"Context classloader is not a DynamicClassLoader\");\n}\n\nstatic public Keyword keyword(String ns, String name){\n\treturn Keyword.intern((Symbol.intern(ns, name)));\n}\n\nstatic public Var var(String ns, String name){\n\treturn Var.intern(Namespace.findOrCreate(Symbol.intern(null, ns)), Symbol.intern(null, name));\n}\n\nstatic public Var var(String ns, String name, Object init){\n\treturn Var.intern(Namespace.findOrCreate(Symbol.intern(null, ns)), Symbol.intern(null, name), init);\n}\n\npublic static void loadResourceScript(String name) throws IOException{\n\tloadResourceScript(name, true);\n}\n\npublic static void maybeLoadResourceScript(String name) throws IOException{\n\tloadResourceScript(name, false);\n}\n\npublic static void loadResourceScript(String name, boolean failIfNotFound) throws IOException{\n\tloadResourceScript(RT.class, name, failIfNotFound);\n}\n\npublic static void loadResourceScript(Class c, String name) throws IOException{\n\tloadResourceScript(c, name, true);\n}\n\npublic static void loadResourceScript(Class c, String name, boolean failIfNotFound) throws IOException{\n\tint slash = name.lastIndexOf('/');\n\tString file = slash >= 0 ? name.substring(slash + 1) : name;\n\tInputStream ins = resourceAsStream(baseLoader(), name);\n\tif(ins != null) {\n\t\ttry {\n\t\t\tCompiler.load(new InputStreamReader(ins, UTF8), name, file);\n\t\t}\n\t\tfinally {\n\t\t\tins.close();\n\t\t}\n\t}\n\telse if(failIfNotFound) {\n\t\tthrow new FileNotFoundException(\"Could not locate Clojure resource on classpath: \" + name);\n\t}\n}\n\nstatic public void init() {\n\tRT.errPrintWriter().println(\"No need to call RT.init() anymore\");\n}\n\nstatic public long lastModified(URL url, String libfile) throws IOException{\n  if (url.getProtocol().equals(\"jar\")) {\n    return (Long) Reflector.invokeInstanceMethod(Reflector\n        .invokeInstanceMethod(Reflector.invokeInstanceMethod(Reflector\n            .invokeInstanceMethod(url, \"openConnection\", new Object[0]),\n            \"getJarFile\", new Object[0]), \"getEntry\",\n            new Object[] { libfile }), \"getTime\", new Object[0]);\n  } else {\n    return (Long) Reflector.invokeInstanceMethod(\n        Reflector.invokeInstanceMethod(url, \"openConnection\", new Object[0]),\n        \"getLastModified\", new Object[0]);\n  }\n}\n\nstatic void compile(String cljfile) throws IOException{\n        InputStream ins = resourceAsStream(baseLoader(), cljfile);\n\tif(ins != null) {\n\t\ttry {\n\t\t\tCompiler.compile(new InputStreamReader(ins, UTF8), cljfile,\n\t\t\t                 cljfile.substring(1 + cljfile.lastIndexOf(\"/\")));\n\t\t}\n\t\tfinally {\n\t\t\tins.close();\n\t\t}\n\n\t}\n\telse\n\t\tthrow new FileNotFoundException(\"Could not locate Clojure resource on classpath: \" + cljfile);\n}\n\nstatic public void load(String scriptbase) throws IOException, ClassNotFoundException{\n\tload(scriptbase, true);\n}\n\nstatic public int nextID(){\n\treturn id.getAndIncrement();\n}\n\n// Load a library in the System ClassLoader instead of Clojure's own.\npublic static void loadLibrary(String libname){\n  Reflector.invokeStaticMethod(System.class, \"loadLibrary\", new Object[]{libname});\n}\n\n\n////////////// Collections support /////////////////////////////////\n\nprivate static final int CHUNK_SIZE = 32;\npublic static ISeq chunkIteratorSeq(final Iterator iter){\n    if(iter.hasNext()) {\n        return new LazySeq(new AFn() {\n            public Object invoke() {\n                Object[] arr = new Object[CHUNK_SIZE];\n                int n = 0;\n                while(iter.hasNext() && n < CHUNK_SIZE)\n                    arr[n++] = iter.next();\n                return new ChunkedCons(new ArrayChunk(arr, 0, n), chunkIteratorSeq(iter));\n            }\n        });\n    }\n    return null;\n}\n\nstatic public ISeq seq(Object coll){\n\tif(coll instanceof ASeq)\n\t\treturn (ASeq) coll;\n\telse if(coll instanceof LazySeq)\n\t\treturn ((LazySeq) coll).seq();\n\telse\n\t\treturn seqFrom(coll);\n}\n\nstatic ISeq seqFrom(Object coll){\n\tif(coll instanceof Seqable)\n\t\treturn ((Seqable) coll).seq();\n\telse if(coll == null)\n\t\treturn null;\n\telse if(coll instanceof Iterable)\n\t\treturn chunkIteratorSeq(((Iterable) coll).iterator());\n\telse if(coll.getClass().isArray())\n\t\treturn ArraySeq.createFromObject(coll);\n\telse if(coll instanceof CharSequence)\n\t\treturn StringSeq.create((CharSequence) coll);\n\telse if(coll instanceof Map)\n\t\treturn seq(((Map) coll).entrySet());\n\telse {\n\t\tClass c = coll.getClass();\n\t\tClass sc = c.getSuperclass();\n\t\tthrow new IllegalArgumentException(\"Don't know how to create ISeq from: \" + c.getName());\n\t}\n}\n\nstatic public Iterator iter(Object coll){\n if(coll instanceof Iterable)\n   return ((Iterable)coll).iterator();\n else if(coll == null)\n   return new Iterator(){\n     public boolean hasNext(){\n       return false;\n     }\n\n     public Object next(){\n       throw new NoSuchElementException();\n     }\n\n     public void remove(){\n       throw new UnsupportedOperationException();\n     }\n   };\n else if(coll instanceof Map){\n   return ((Map)coll).entrySet().iterator();\n }\n else if(coll instanceof String){\n   final String s = (String) coll;\n   return new Iterator(){\n     int i = 0;\n\n     public boolean hasNext(){\n       return i < s.length();\n     }\n\n     public Object next(){\n       return s.charAt(i++);\n     }\n\n     public void remove(){\n       throw new UnsupportedOperationException();\n     }\n   };\n }\n else if(coll.getClass().isArray()){\n   return ArrayIter.createFromObject(coll);\n }else\n   return iter(seq(coll));\n}\n\nstatic public Object seqOrElse(Object o) {\n\treturn seq(o) == null ? null : o;\n}\n\nstatic public ISeq keys(Object coll){\n  if(coll instanceof IPersistentMap)\n    return APersistentMap.KeySeq.createFromMap((IPersistentMap)coll);\n  else\n    return APersistentMap.KeySeq.create(seq(coll));\n}\n\nstatic public ISeq vals(Object coll){\n  if(coll instanceof IPersistentMap)\n    return APersistentMap.ValSeq.createFromMap((IPersistentMap)coll);\n  else\n    return APersistentMap.ValSeq.create(seq(coll));\n}\n\nstatic public IPersistentMap meta(Object x){\n\tif(x instanceof IMeta)\n\t\treturn ((IMeta) x).meta();\n\treturn null;\n}\n\npublic static int count(Object o){\n\tif(o instanceof Counted)\n\t\treturn ((Counted) o).count();\n\treturn countFrom(Util.ret1(o, o = null));\n}\n\nstatic int countFrom(Object o){\n\tif(o == null)\n\t\treturn 0;\n\telse if(o instanceof IPersistentCollection) {\n\t\tISeq s = seq(o);\n\t\to = null;\n\t\tint i = 0;\n\t\tfor(; s != null; s = s.next()) {\n\t\t\tif(s.getClass() != Cons.class && s instanceof Counted)\n\t\t\t\treturn i + s.count();\n\t\t\ti++;\n\t\t}\n\t\treturn i;\n\t}\n\telse if(o instanceof CharSequence)\n\t\treturn ((CharSequence) o).length();\n\telse if(o instanceof Collection)\n\t\treturn ((Collection) o).size();\n\telse if(o instanceof Map)\n\t\treturn ((Map) o).size();\n\telse if (o instanceof Map.Entry)\n\t  return 2;\n\telse if(o.getClass().isArray())\n\t\treturn Array.getLength(o);\n\n\tthrow new UnsupportedOperationException(\"count not supported on this type: \" + o.getClass().getSimpleName());\n}\n\nstatic public IPersistentCollection conj(IPersistentCollection coll, Object x){\n\tif(coll == null)\n\t\treturn new PersistentList(x);\n\treturn coll.cons(x);\n}\n\nstatic public ISeq cons(Object x, Object coll){\n\t//ISeq y = seq(coll);\n\tif(coll == null)\n\t\treturn new PersistentList(x);\n\telse if(coll instanceof ISeq)\n\t\treturn new Cons(x, (ISeq) coll);\n\telse\n\t\treturn new Cons(x, seq(coll));\n}\n\nstatic public Object first(Object x){\n\tif(x instanceof ISeq)\n\t\treturn ((ISeq) x).first();\n\tISeq seq = seq(x);\n\tif(seq == null)\n\t\treturn null;\n\treturn seq.first();\n}\n\nstatic public Object second(Object x){\n\treturn first(next(x));\n}\n\nstatic public Object third(Object x){\n\treturn first(next(next(x)));\n}\n\nstatic public Object fourth(Object x){\n\treturn first(next(next(next(x))));\n}\n\nstatic public ISeq next(Object x){\n\tif(x instanceof ISeq)\n\t\treturn ((ISeq) x).next();\n\tISeq seq = seq(x);\n\tif(seq == null)\n\t\treturn null;\n\treturn seq.next();\n}\n\nstatic public ISeq more(Object x){\n\tif(x instanceof ISeq)\n\t\treturn ((ISeq) x).more();\n\tISeq seq = seq(x);\n\tif(seq == null)\n\t\treturn PersistentList.EMPTY;\n\treturn seq.more();\n}\n\n//static public Seqable more(Object x){\n//    Seqable ret = null;\n//\tif(x instanceof ISeq)\n//\t\tret = ((ISeq) x).more();\n//    else\n//        {\n//\t    ISeq seq = seq(x);\n//\t    if(seq == null)\n//\t\t    ret = PersistentList.EMPTY;\n//\t    else\n//            ret = seq.more();\n//        }\n//    if(ret == null)\n//        ret = PersistentList.EMPTY;\n//    return ret;\n//}\n\nstatic public Object peek(Object x){\n\tif(x == null)\n\t\treturn null;\n\treturn ((IPersistentStack) x).peek();\n}\n\nstatic public Object pop(Object x){\n\tif(x == null)\n\t\treturn null;\n\treturn ((IPersistentStack) x).pop();\n}\n\nstatic public Object get(Object coll, Object key){\n\tif(coll instanceof ILookup)\n\t\treturn ((ILookup) coll).valAt(key);\n\treturn getFrom(coll, key);\n}\n\nstatic Object getFrom(Object coll, Object key){\n\tif(coll == null)\n\t\treturn null;\n\telse if(coll instanceof Map) {\n\t\tMap m = (Map) coll;\n\t\treturn m.get(key);\n\t}\n\telse if(coll instanceof IPersistentSet) {\n\t\tIPersistentSet set = (IPersistentSet) coll;\n\t\treturn set.get(key);\n\t}\n\telse if(key instanceof Number && (coll instanceof String || coll.getClass().isArray())) {\n\t\tint n = ((Number) key).intValue();\n\t\tif(n >= 0 && n < count(coll))\n\t\t\treturn nth(coll, n);\n\t\treturn null;\n\t}\n\n\treturn null;\n}\n\nstatic public Object get(Object coll, Object key, Object notFound){\n\tif(coll instanceof ILookup)\n\t\treturn ((ILookup) coll).valAt(key, notFound);\n\treturn getFrom(coll, key, notFound);\n}\n\nstatic Object getFrom(Object coll, Object key, Object notFound){\n\tif(coll == null)\n\t\treturn notFound;\n\telse if(coll instanceof Map) {\n\t\tMap m = (Map) coll;\n\t\tif(m.containsKey(key))\n\t\t\treturn m.get(key);\n\t\treturn notFound;\n\t}\n\telse if(coll instanceof IPersistentSet) {\n\t\tIPersistentSet set = (IPersistentSet) coll;\n\t\tif(set.contains(key))\n\t\t\treturn set.get(key);\n\t\treturn notFound;\n\t}\n\telse if(key instanceof Number && (coll instanceof String || coll.getClass().isArray())) {\n\t\tint n = ((Number) key).intValue();\n\t\treturn n >= 0 && n < count(coll) ? nth(coll, n) : notFound;\n\t}\n\treturn notFound;\n\n}\n\nstatic public Associative assoc(Object coll, Object key, Object val){\n\tif(coll == null)\n\t\treturn new PersistentArrayMap(new Object[]{key, val});\n\treturn ((Associative) coll).assoc(key, val);\n}\n\nstatic public Object contains(Object coll, Object key){\n\tif(coll == null)\n\t\treturn F;\n\telse if(coll instanceof Associative)\n\t\treturn ((Associative) coll).containsKey(key) ? T : F;\n\telse if(coll instanceof IPersistentSet)\n\t\treturn ((IPersistentSet) coll).contains(key) ? T : F;\n\telse if(coll instanceof Map) {\n\t\tMap m = (Map) coll;\n\t\treturn m.containsKey(key) ? T : F;\n\t}\n\telse if(coll instanceof Set) {\n\t\tSet s = (Set) coll;\n\t\treturn s.contains(key) ? T : F;\n\t}\n\telse if(key instanceof Number && (coll instanceof String || coll.getClass().isArray())) {\n\t\tint n = ((Number) key).intValue();\n\t\treturn n >= 0 && n < count(coll);\n\t}\n\tthrow new IllegalArgumentException(\"contains? not supported on type: \" + coll.getClass().getName());\n}\n\nstatic public Object find(Object coll, Object key){\n\tif(coll == null)\n\t\treturn null;\n\telse if(coll instanceof Associative)\n\t\treturn ((Associative) coll).entryAt(key);\n\telse {\n\t\tMap m = (Map) coll;\n\t\tif(m.containsKey(key))\n\t\t\treturn new MapEntry(key, m.get(key));\n\t\treturn null;\n\t}\n}\n\n//takes a seq of key,val,key,val\n\n//returns tail starting at val of matching key if found, else null\nstatic public ISeq findKey(Keyword key, ISeq keyvals) {\n\twhile(keyvals != null) {\n\t\tISeq r = keyvals.next();\n\t\tif(r == null)\n\t\t\tthrow Util.runtimeException(\"Malformed keyword argslist\");\n\t\tif(keyvals.first() == key)\n\t\t\treturn r;\n\t\tkeyvals = r.next();\n\t}\n\treturn null;\n}\n\nstatic public Object dissoc(Object coll, Object key) {\n\tif(coll == null)\n\t\treturn null;\n\treturn ((IPersistentMap) coll).without(key);\n}\n\nstatic public Object nth(Object coll, int n){\n\tif(coll instanceof Indexed)\n\t\treturn ((Indexed) coll).nth(n);\n\treturn nthFrom(Util.ret1(coll, coll = null), n);\n}\n\nstatic Object nthFrom(Object coll, int n){\n\tif(coll == null)\n\t\treturn null;\n\telse if(coll instanceof CharSequence)\n\t\treturn Character.valueOf(((CharSequence) coll).charAt(n));\n\telse if(coll.getClass().isArray())\n\t\treturn Reflector.prepRet(coll.getClass().getComponentType(),Array.get(coll, n));\n\telse if(coll instanceof RandomAccess)\n\t\treturn ((List) coll).get(n);\n\telse if(coll instanceof Matcher)\n\t\treturn ((Matcher) coll).group(n);\n\n\telse if(coll instanceof Map.Entry) {\n\t\tMap.Entry e = (Map.Entry) coll;\n\t\tif(n == 0)\n\t\t\treturn e.getKey();\n\t\telse if(n == 1)\n\t\t\treturn e.getValue();\n\t\tthrow new IndexOutOfBoundsException();\n\t}\n\n\telse if(coll instanceof Sequential) {\n\t\tISeq seq = RT.seq(coll);\n\t\tcoll = null;\n\t\tfor(int i = 0; i <= n && seq != null; ++i, seq = seq.next()) {\n\t\t\tif(i == n)\n\t\t\t\treturn seq.first();\n\t\t}\n\t\tthrow new IndexOutOfBoundsException();\n\t}\n\telse\n\t\tthrow new UnsupportedOperationException(\n\t\t\t\t\"nth not supported on this type: \" + coll.getClass().getSimpleName());\n}\n\nstatic public Object nth(Object coll, int n, Object notFound){\n\tif(coll instanceof Indexed) {\n\t\tIndexed v = (Indexed) coll;\n\t\t\treturn v.nth(n, notFound);\n\t}\n\treturn nthFrom(coll, n, notFound);\n}\n\n  static public Object objcClass(String name) {\n    if (ObjC.objc) {\n      return nativeObjcClass(name);\n    } else {\n      return new ObjCClass(name);\n    }\n  }\n  \n  static public native Object nativeObjcClass(String name) /*-[\n                                                     return NSClassFromString(name);\n                                                     ]-*/;\n\n  public static native void loadiOS(String scriptbase) /*-[\n    IOSObjectArray *parts = [[scriptbase replaceAll:@\"-\" withReplacement:@\"_\"] split:@\"/\"];\n    NSString *classname = @\"\";\n    for (int n = 0; n < parts.length - 1; n++) {\n      NSString *s = (NSString*)[parts objectAtIndex:n];\n      s = [[[s substringToIndex:1] uppercaseString] stringByAppendingString:[s substringFromIndex:1]];\n      classname = [classname stringByAppendingString:s];\n    }\n    classname = [classname stringByAppendingString:[parts objectAtIndex:parts.length-1]];\n    classname = [classname stringByAppendingString:@\"__init\"];\n    Class c = NSClassFromString(classname);\n    if (c == nil) {\n      NSLog(@\"Error loading %@\", scriptbase);\n    } else {\n      [c description]; // Force initialize\n    }\n    return;\n  ]-*/;\n\n  static public void load(String scriptbase, boolean failIfNotFound) throws IOException, ClassNotFoundException{\n    if (ObjC.objc) {\n      loadiOS(scriptbase);\n    } else {\n      String classfile = scriptbase + LOADER_SUFFIX + \".class\";\n      String cljfile = scriptbase + \".clj\";\n      String scriptfile = cljfile;\n      URL classURL = getResource(baseLoader(),classfile);\n      URL cljURL = getResource(baseLoader(), scriptfile);\n      if(cljURL == null) {\n        scriptfile = scriptbase + \".cljc\";\n        cljURL = getResource(baseLoader(), scriptfile);\n      }\n      boolean loaded = false;\n  \n      if((classURL != null &&\n          (cljURL == null\n           || lastModified(classURL, classfile) > lastModified(cljURL, scriptfile)))\n         || classURL == null) {\n        try {\n          Var.pushThreadBindings(\n              RT.mapUniqueKeys(CURRENT_NS, CURRENT_NS.deref(), Compiler.NEXT_ID, new Atom(1),\n                     WARN_ON_REFLECTION, WARN_ON_REFLECTION.deref()\n                  ,RT.UNCHECKED_MATH, RT.UNCHECKED_MATH.deref()));\n          loaded = (loadClassForName(scriptbase.replace('/', '.') + LOADER_SUFFIX) != null);\n        }\n        finally {\n          Var.popThreadBindings();\n        }\n      }\n      if(!loaded && cljURL != null) {\n        if(booleanCast(Compiler.COMPILE_FILES.deref()))\n          compile(scriptfile);\n        else\n          loadResourceScript(RT.class, scriptfile);\n      }\n      else if(!loaded && failIfNotFound)\n        throw new FileNotFoundException(String.format(\"Could not locate %s or %s on classpath.%s\", classfile, cljfile,\n          scriptbase.contains(\"_\") ? \" Please check that namespaces with dashes use underscores in the Clojure file name.\" : \"\"));\n    }\n  }\n\n  static Object nthFrom(Object coll, int n, Object notFound) {\n    if (coll == null)\n      return notFound;\n    else if (n < 0)\n      return notFound;\n\n    else if (coll instanceof CharSequence) {\n      CharSequence s = (CharSequence) coll;\n      if (n < s.length())\n        return Character.valueOf(s.charAt(n));\n      return notFound;\n    } else if (coll.getClass().isArray()) {\n      if (n < Array.getLength(coll))\n        return Reflector.prepRet(coll.getClass().getComponentType(),\n            Array.get(coll, n));\n      return notFound;\n    } else if (coll instanceof RandomAccess) {\n      List list = (List) coll;\n      if (n < list.size())\n        return list.get(n);\n      return notFound;\n    } else if (coll instanceof Matcher) {\n      Matcher m = (Matcher) coll;\n      if (n < m.groupCount())\n        return m.group(n);\n      return notFound;\n    } else if (coll instanceof Map.Entry) {\n      Map.Entry e = (Map.Entry) coll;\n      if (n == 0)\n        return e.getKey();\n      else if (n == 1)\n        return e.getValue();\n      return notFound;\n    } else if (coll instanceof Sequential) {\n      ISeq seq = RT.seq(coll);\n      coll = null;\n      for (int i = 0; i <= n && seq != null; ++i, seq = seq.next()) {\n        if (i == n)\n          return seq.first();\n      }\n      return notFound;\n    } else\n      throw new UnsupportedOperationException(\n          \"nth not supported on this type: \" + coll.getClass().getSimpleName());\n  }\n\n  static public Object assocN(int n, Object val, Object coll) {\n    if (coll == null)\n      return null;\n    else if (coll instanceof IPersistentVector)\n      return ((IPersistentVector) coll).assocN(n, val);\n    else if (coll instanceof Object[]) {\n      // hmm... this is not persistent\n      Object[] array = ((Object[]) coll);\n      array[n] = val;\n      return array;\n    } else\n      return null;\n  }\n\n  static boolean hasTag(Object o, Object tag) {\n    return Util.equals(tag, RT.get(RT.meta(o), TAG_KEY));\n  }\n\n  /**\n   * ********************* Boxing/casts ******************************\n   */\n  static public Object box(Object x) {\n    return x;\n  }\n\n  static public Character box(char x) {\n    return Character.valueOf(x);\n  }\n\n  static public Object box(boolean x) {\n    return x ? T : F;\n  }\n\n  static public Object box(Boolean x) {\n    return x;// ? T : null;\n  }\n\n  static public Number box(byte x) {\n    return x;// Num.from(x);\n  }\n\n  static public Number box(short x) {\n    return x;// Num.from(x);\n  }\n\n  static public Number box(int x) {\n    return x;// Num.from(x);\n  }\n\n  static public Number box(long x) {\n    return x;// Num.from(x);\n  }\n\n  static public Number box(float x) {\n    return x;// Num.from(x);\n  }\n\n  static public Number box(double x) {\n    return x;// Num.from(x);\n  }\n\n  static public char charCast(Object x) {\n    if (x instanceof Character)\n      return ((Character) x).charValue();\n\n    long n = ((Number) x).longValue();\n    if (n < Character.MIN_VALUE || n > Character.MAX_VALUE)\n      throw new IllegalArgumentException(\"Value out of range for char: \" + x);\n\n    return (char) n;\n  }\n\n  static public char charCast(byte x) {\n    char i = (char) x;\n    if (i != x)\n      throw new IllegalArgumentException(\"Value out of range for char: \" + x);\n    return i;\n  }\n\n  static public char charCast(short x) {\n    char i = (char) x;\n    if (i != x)\n      throw new IllegalArgumentException(\"Value out of range for char: \" + x);\n    return i;\n  }\n\n  static public char charCast(char x) {\n    return x;\n  }\n\n  static public char charCast(int x) {\n    char i = (char) x;\n    if (i != x)\n      throw new IllegalArgumentException(\"Value out of range for char: \" + x);\n    return i;\n  }\n\n  static public char charCast(long x) {\n    char i = (char) x;\n    if (i != x)\n      throw new IllegalArgumentException(\"Value out of range for char: \" + x);\n    return i;\n  }\n\n  static public char charCast(float x) {\n    if (x >= Character.MIN_VALUE && x <= Character.MAX_VALUE)\n      return (char) x;\n    throw new IllegalArgumentException(\"Value out of range for char: \" + x);\n  }\n\n  static public char charCast(double x) {\n    if (x >= Character.MIN_VALUE && x <= Character.MAX_VALUE)\n      return (char) x;\n    throw new IllegalArgumentException(\"Value out of range for char: \" + x);\n  }\n\n  static public boolean booleanCast(Object x) {\n    if (x instanceof Boolean)\n      return ((Boolean) x).booleanValue();\n    return x != null;\n  }\n\n  static public boolean booleanCast(boolean x) {\n    return x;\n  }\n\n  static public byte byteCast(Object x) {\n    if (x instanceof Byte)\n      return ((Byte) x).byteValue();\n    long n = longCast(x);\n    if (n < Byte.MIN_VALUE || n > Byte.MAX_VALUE)\n      throw new IllegalArgumentException(\"Value out of range for byte: \" + x);\n\n    return (byte) n;\n  }\n\n  static public byte byteCast(byte x) {\n    return x;\n  }\n\n  static public byte byteCast(short x) {\n    byte i = (byte) x;\n    if (i != x)\n      throw new IllegalArgumentException(\"Value out of range for byte: \" + x);\n    return i;\n  }\n\n  static public byte byteCast(int x) {\n    byte i = (byte) x;\n    if (i != x)\n      throw new IllegalArgumentException(\"Value out of range for byte: \" + x);\n    return i;\n  }\n\n  static public byte byteCast(long x) {\n    byte i = (byte) x;\n    if (i != x)\n      throw new IllegalArgumentException(\"Value out of range for byte: \" + x);\n    return i;\n  }\n\n  static public byte byteCast(float x) {\n    if (x >= Byte.MIN_VALUE && x <= Byte.MAX_VALUE)\n      return (byte) x;\n    throw new IllegalArgumentException(\"Value out of range for byte: \" + x);\n  }\n\n  static public byte byteCast(double x) {\n    if (x >= Byte.MIN_VALUE && x <= Byte.MAX_VALUE)\n      return (byte) x;\n    throw new IllegalArgumentException(\"Value out of range for byte: \" + x);\n  }\n\n  static public short shortCast(Object x) {\n    if (x instanceof Short)\n      return ((Short) x).shortValue();\n    long n = longCast(x);\n    if (n < Short.MIN_VALUE || n > Short.MAX_VALUE)\n      throw new IllegalArgumentException(\"Value out of range for short: \" + x);\n\n    return (short) n;\n  }\n\n  static public short shortCast(byte x) {\n    return x;\n  }\n\n  static public short shortCast(short x) {\n    return x;\n  }\n\n  static public short shortCast(int x) {\n    short i = (short) x;\n    if (i != x)\n      throw new IllegalArgumentException(\"Value out of range for short: \" + x);\n    return i;\n  }\n\n  static public short shortCast(long x) {\n    short i = (short) x;\n    if (i != x)\n      throw new IllegalArgumentException(\"Value out of range for short: \" + x);\n    return i;\n  }\n\n  static public short shortCast(float x) {\n    if (x >= Short.MIN_VALUE && x <= Short.MAX_VALUE)\n      return (short) x;\n    throw new IllegalArgumentException(\"Value out of range for short: \" + x);\n  }\n\n  static public short shortCast(double x) {\n    if (x >= Short.MIN_VALUE && x <= Short.MAX_VALUE)\n      return (short) x;\n    throw new IllegalArgumentException(\"Value out of range for short: \" + x);\n  }\n\n  static public int intCast(Object x) {\n    if (x == null) {\n      throw Util.sneakyThrow(new NullPointerException());\n    }\n    if (x instanceof Integer)\n      return ((Integer) x).intValue();\n    if (x instanceof Number) {\n      long n = longCast(x);\n      return intCast(n);\n    }\n    if (x instanceof Character) {\n      return ((Character) x).charValue();\n    }\n    throw Util.sneakyThrow(new ClassCastException());\n  }\n\n  static public int intCast(char x) {\n    return x;\n  }\n\n  static public int intCast(byte x) {\n    return x;\n  }\n\n  static public int intCast(short x) {\n    return x;\n  }\n\n  static public int intCast(int x) {\n    return x;\n  }\n\n  static public int intCast(float x) {\n    if (x < Integer.MIN_VALUE || x > Integer.MAX_VALUE)\n      throw new IllegalArgumentException(\"Value out of range for int: \" + x);\n    return (int) x;\n  }\n\n  static public int intCast(long x) {\n    int i = (int) x;\n    if (i != x)\n      throw new IllegalArgumentException(\"Value out of range for int: \" + x);\n    return i;\n  }\n\n  static public int intCast(double x) {\n    if (x < Integer.MIN_VALUE || x > Integer.MAX_VALUE)\n      throw new IllegalArgumentException(\"Value out of range for int: \" + x);\n    return (int) x;\n  }\n\n  static public long longCast(Object x) {\n    if (x instanceof Integer || x instanceof Long)\n      return ((Number) x).longValue();\n    else if (x instanceof BigInt) {\n      BigInt bi = (BigInt) x;\n      if (bi.bipart == null)\n        return bi.lpart;\n      else\n        throw new IllegalArgumentException(\"Value out of range for long: \" + x);\n    } else if (x instanceof BigInteger) {\n      BigInteger bi = (BigInteger) x;\n      if (bi.bitLength() < 64)\n        return bi.longValue();\n      else\n        throw new IllegalArgumentException(\"Value out of range for long: \" + x);\n    } else if (x instanceof Byte || x instanceof Short)\n      return ((Number) x).longValue();\n    else if (x instanceof Ratio)\n      return longCast(((Ratio) x).bigIntegerValue());\n    else if (x instanceof Character)\n      return longCast(((Character) x).charValue());\n    else\n      return longCast(((Number) x).doubleValue());\n  }\n\n  static public long longCast(byte x) {\n    return x;\n  }\n\n  static public long longCast(short x) {\n    return x;\n  }\n\n  static public long longCast(int x) {\n    return x;\n  }\n\n  static public long longCast(float x) {\n    if (x < Long.MIN_VALUE || x > Long.MAX_VALUE)\n      throw new IllegalArgumentException(\"Value out of range for long: \" + x);\n    return (long) x;\n  }\n\n  static public long longCast(long x) {\n    return x;\n  }\n\n  static public long longCast(double x) {\n    if (x < Long.MIN_VALUE || x > Long.MAX_VALUE)\n      throw new IllegalArgumentException(\"Value out of range for long: \" + x);\n    return (long) x;\n  }\n\n  static public float floatCast(Object x) {\n    if (x instanceof Float)\n      return ((Float) x).floatValue();\n\n    double n = ((Number) x).doubleValue();\n    if (n < -Float.MAX_VALUE || n > Float.MAX_VALUE)\n      throw new IllegalArgumentException(\"Value out of range for float: \" + x);\n\n    return (float) n;\n\n  }\n\n  static public float floatCast(byte x) {\n    return x;\n  }\n\n  static public float floatCast(short x) {\n    return x;\n  }\n\n  static public float floatCast(int x) {\n    return x;\n  }\n\n  static public float floatCast(float x) {\n    return x;\n  }\n\n  static public float floatCast(long x) {\n    return x;\n  }\n\n  static public float floatCast(double x) {\n    if (x < -Float.MAX_VALUE || x > Float.MAX_VALUE)\n      throw new IllegalArgumentException(\"Value out of range for float: \" + x);\n\n    return (float) x;\n  }\n\n  static public double doubleCast(Object x) {\n    return ((Number) x).doubleValue();\n  }\n\n  static public double doubleCast(byte x) {\n    return x;\n  }\n\n  static public double doubleCast(short x) {\n    return x;\n  }\n\n  static public double doubleCast(int x) {\n    return x;\n  }\n\n  static public double doubleCast(float x) {\n    return x;\n  }\n\n  static public double doubleCast(long x) {\n    return x;\n  }\n\n  static public double doubleCast(double x) {\n    return x;\n  }\n\n  static public byte uncheckedByteCast(Object x) {\n    return ((Number) x).byteValue();\n  }\n\n  static public byte uncheckedByteCast(byte x) {\n    return x;\n  }\n\n  static public byte uncheckedByteCast(short x) {\n    return (byte) x;\n  }\n\n  static public byte uncheckedByteCast(int x) {\n    return (byte) x;\n  }\n\n  static public byte uncheckedByteCast(long x) {\n    return (byte) x;\n  }\n\n  static public byte uncheckedByteCast(float x) {\n    return (byte) x;\n  }\n\n  static public byte uncheckedByteCast(double x) {\n    return (byte) x;\n  }\n\n  static public short uncheckedShortCast(Object x) {\n    return ((Number) x).shortValue();\n  }\n\n  static public short uncheckedShortCast(byte x) {\n    return x;\n  }\n\n  static public short uncheckedShortCast(short x) {\n    return x;\n  }\n\n  static public short uncheckedShortCast(int x) {\n    return (short) x;\n  }\n\n  static public short uncheckedShortCast(long x) {\n    return (short) x;\n  }\n\n  static public short uncheckedShortCast(float x) {\n    return (short) x;\n  }\n\n  static public short uncheckedShortCast(double x) {\n    return (short) x;\n  }\n\n  static public char uncheckedCharCast(Object x) {\n    if (x instanceof Character)\n      return ((Character) x).charValue();\n    return (char) ((Number) x).longValue();\n  }\n\n  static public char uncheckedCharCast(byte x) {\n    return (char) x;\n  }\n\n  static public char uncheckedCharCast(short x) {\n    return (char) x;\n  }\n\n  static public char uncheckedCharCast(char x) {\n    return x;\n  }\n\n  static public char uncheckedCharCast(int x) {\n    return (char) x;\n  }\n\n  static public char uncheckedCharCast(long x) {\n    return (char) x;\n  }\n\n  static public char uncheckedCharCast(float x) {\n    return (char) x;\n  }\n\n  static public char uncheckedCharCast(double x) {\n    return (char) x;\n  }\n\n  static public int uncheckedIntCast(Object x) {\n    if (x instanceof Number)\n      return ((Number) x).intValue();\n    return ((Character) x).charValue();\n  }\n\n  static public int uncheckedIntCast(byte x) {\n    return x;\n  }\n\n  static public int uncheckedIntCast(short x) {\n    return x;\n  }\n\n  static public int uncheckedIntCast(char x) {\n    return x;\n  }\n\n  static public int uncheckedIntCast(int x) {\n    return x;\n  }\n\n  static public int uncheckedIntCast(long x) {\n    return (int) x;\n  }\n\n  static public int uncheckedIntCast(float x) {\n    return (int) x;\n  }\n\n  static public int uncheckedIntCast(double x) {\n    return (int) x;\n  }\n\n  static public long uncheckedLongCast(Object x) {\n    return ((Number) x).longValue();\n  }\n\n  static public long uncheckedLongCast(byte x) {\n    return x;\n  }\n\n  static public long uncheckedLongCast(short x) {\n    return x;\n  }\n\n  static public long uncheckedLongCast(int x) {\n    return x;\n  }\n\n  static public long uncheckedLongCast(long x) {\n    return x;\n  }\n\n  static public long uncheckedLongCast(float x) {\n    return (long) x;\n  }\n\n  static public long uncheckedLongCast(double x) {\n    return (long) x;\n  }\n\n  static public float uncheckedFloatCast(Object x) {\n    return ((Number) x).floatValue();\n  }\n\n  static public float uncheckedFloatCast(byte x) {\n    return x;\n  }\n\n  static public float uncheckedFloatCast(short x) {\n    return x;\n  }\n\n  static public float uncheckedFloatCast(int x) {\n    return x;\n  }\n\n  static public float uncheckedFloatCast(long x) {\n    return x;\n  }\n\n  static public float uncheckedFloatCast(float x) {\n    return x;\n  }\n\n  static public float uncheckedFloatCast(double x) {\n    return (float) x;\n  }\n\n  static public double uncheckedDoubleCast(Object x) {\n    return ((Number) x).doubleValue();\n  }\n\n  static public double uncheckedDoubleCast(byte x) {\n    return x;\n  }\n\n  static public double uncheckedDoubleCast(short x) {\n    return x;\n  }\n\n  static public double uncheckedDoubleCast(int x) {\n    return x;\n  }\n\n  static public double uncheckedDoubleCast(long x) {\n    return x;\n  }\n\n  static public double uncheckedDoubleCast(float x) {\n    return x;\n  }\n\n  static public double uncheckedDoubleCast(double x) {\n    return x;\n  }\n\n  static public IPersistentMap map(Object... init) {\n    if (init == null)\n      return PersistentArrayMap.EMPTY;\n    else if (init.length <= PersistentArrayMap.HASHTABLE_THRESHOLD)\n      return PersistentArrayMap.createWithCheck(init);\n    return PersistentHashMap.createWithCheck(init);\n  }\n\n  static public IPersistentMap mapUniqueKeys(Object... init) {\n    if (init == null)\n      return PersistentArrayMap.EMPTY;\n    else if (init.length <= PersistentArrayMap.HASHTABLE_THRESHOLD)\n      return new PersistentArrayMap(init);\n    return PersistentHashMap.create(init);\n  }\n\n  static public IPersistentSet set(Object... init) {\n    return PersistentHashSet.createWithCheck(init);\n  }\n\n  static public IPersistentVector vector(Object... init) {\n    return LazilyPersistentVector.createOwning(init);\n  }\n\n  static public IPersistentVector subvec(IPersistentVector v, int start, int end) {\n    if (end < start || start < 0 || end > v.count())\n      throw new IndexOutOfBoundsException();\n    if (start == end)\n      return PersistentVector.EMPTY;\n    return new APersistentVector.SubVector(null, v, start, end);\n  }\n\n  /**\n   * **************************************** list support\n   * *******************************\n   */\n\n  static public ISeq list() {\n    return null;\n  }\n\n  static public ISeq list(Object arg1) {\n    return new PersistentList(arg1);\n  }\n\n  static public ISeq list(Object arg1, Object arg2) {\n    return listStar(arg1, arg2, null);\n  }\n\n  static public ISeq list(Object arg1, Object arg2, Object arg3) {\n    return listStar(arg1, arg2, arg3, null);\n  }\n\n  static public ISeq list(Object arg1, Object arg2, Object arg3, Object arg4) {\n    return listStar(arg1, arg2, arg3, arg4, null);\n  }\n\n  static public ISeq list(Object arg1, Object arg2, Object arg3, Object arg4,\n      Object arg5) {\n    return listStar(arg1, arg2, arg3, arg4, arg5, null);\n  }\n\n  static public ISeq listStar(Object arg1, ISeq rest) {\n    return (ISeq) cons(arg1, rest);\n  }\n\n  static public ISeq listStar(Object arg1, Object arg2, ISeq rest) {\n    return (ISeq) cons(arg1, cons(arg2, rest));\n  }\n\n  static public ISeq listStar(Object arg1, Object arg2, Object arg3, ISeq rest) {\n    return (ISeq) cons(arg1, cons(arg2, cons(arg3, rest)));\n  }\n\n  static public ISeq listStar(Object arg1, Object arg2, Object arg3,\n      Object arg4, ISeq rest) {\n    return (ISeq) cons(arg1, cons(arg2, cons(arg3, cons(arg4, rest))));\n  }\n\n  static public ISeq listStar(Object arg1, Object arg2, Object arg3,\n      Object arg4, Object arg5, ISeq rest) {\n    return (ISeq) cons(arg1,\n        cons(arg2, cons(arg3, cons(arg4, cons(arg5, rest)))));\n  }\n\n  static public ISeq arrayToList(Object[] a) {\n    ISeq ret = null;\n    for (int i = a.length - 1; i >= 0; --i)\n      ret = (ISeq) cons(a[i], ret);\n    return ret;\n  }\n\n  static public Object[] object_array(Object sizeOrSeq) {\n    if (sizeOrSeq instanceof Number)\n      return new Object[((Number) sizeOrSeq).intValue()];\n    else {\n      ISeq s = RT.seq(sizeOrSeq);\n      int size = RT.count(s);\n      Object[] ret = new Object[size];\n      for (int i = 0; i < size && s != null; i++, s = s.next())\n        ret[i] = s.first();\n      return ret;\n    }\n  }\n\n  static public Object[] toArray(Object coll) {\n    if (coll == null)\n      return EMPTY_ARRAY;\n    else if (coll instanceof Object[])\n      return (Object[]) coll;\n    else if (coll instanceof Collection)\n      return ((Collection) coll).toArray();\n    else if(coll instanceof Iterable) {\n      ArrayList ret = new ArrayList();\n      for(Object o : (Iterable)coll)\n        ret.add(o);\n      return ret.toArray();\n    } else if (coll instanceof Map)\n      return ((Map) coll).entrySet().toArray();\n    else if (coll instanceof String) {\n      char[] chars = ((String) coll).toCharArray();\n      Object[] ret = new Object[chars.length];\n      for (int i = 0; i < chars.length; i++)\n        ret[i] = chars[i];\n      return ret;\n    } else if (coll.getClass().isArray()) {\n      ISeq s = (seq(coll));\n      Object[] ret = new Object[count(s)];\n      for (int i = 0; i < ret.length; i++, s = s.next())\n        ret[i] = s.first();\n      return ret;\n    } else\n      throw Util.runtimeException(\"Unable to convert: \" + coll.getClass()\n          + \" to Object[]\");\n  }\n\n  static public Object[] seqToArray(ISeq seq) {\n    int len = length(seq);\n    Object[] ret = new Object[len];\n    for (int i = 0; seq != null; ++i, seq = seq.next())\n      ret[i] = seq.first();\n    return ret;\n  }\n\n  // supports java Collection.toArray(T[])\n  static public Object[] seqToPassedArray(ISeq seq, Object[] passed) {\n    Object[] dest = passed;\n    int len = count(seq);\n    if (len > dest.length) {\n      dest = (Object[]) Array.newInstance(passed.getClass().getComponentType(),\n          len);\n    }\n    for (int i = 0; seq != null; ++i, seq = seq.next())\n      dest[i] = seq.first();\n    if (len < passed.length) {\n      dest[len] = null;\n    }\n    return dest;\n  }\n\n  static public Object seqToTypedArray(ISeq seq) {\n    Class type = (seq != null) ? seq.first().getClass() : Object.class;\n    return seqToTypedArray(type, seq);\n  }\n\n  static public Object seqToTypedArray(Class type, ISeq seq) {\n    Object ret = Array.newInstance(type, length(seq));\n    if (type == Integer.TYPE) {\n      for (int i = 0; seq != null; ++i, seq = seq.next()) {\n        Array.set(ret, i, intCast(seq.first()));\n      }\n    } else if (type == Byte.TYPE) {\n      for (int i = 0; seq != null; ++i, seq = seq.next()) {\n        Array.set(ret, i, byteCast(seq.first()));\n      }\n    } else if (type == Float.TYPE) {\n      for (int i = 0; seq != null; ++i, seq = seq.next()) {\n        Array.set(ret, i, floatCast(seq.first()));\n      }\n    } else if (type == Short.TYPE) {\n      for (int i = 0; seq != null; ++i, seq = seq.next()) {\n        Array.set(ret, i, shortCast(seq.first()));\n      }\n    } else if (type == Character.TYPE) {\n      for (int i = 0; seq != null; ++i, seq = seq.next()) {\n        Array.set(ret, i, charCast(seq.first()));\n      }\n    } else {\n      for (int i = 0; seq != null; ++i, seq = seq.next()) {\n        Array.set(ret, i, seq.first());\n      }\n    }\n    return ret;\n  }\n\nstatic public int length(ISeq list){\n\tint i = 0;\n\tfor(ISeq c = list; c != null; c = c.next()) {\n\t\ti++;\n\t}\n\treturn i;\n}\n\nstatic public int boundedLength(ISeq list, int limit) {\n\tint i = 0;\n\tfor(ISeq c = list; c != null && i <= limit; c = c.next()) {\n\t\ti++;\n\t}\n\treturn i;\n}\n\n///////////////////////////////// reader support ////////////////////////////////\n\nstatic Character readRet(int ret){\n\tif(ret == -1)\n\t\treturn null;\n\treturn box((char) ret);\n}\n\nstatic public Character readChar(Reader r) throws IOException{\n\tint ret = r.read();\n\treturn readRet(ret);\n}\n\nstatic public Character peekChar(Reader r) throws IOException{\n\tint ret;\n\tif(r instanceof PushbackReader) {\n\t\tret = r.read();\n\t\t((PushbackReader) r).unread(ret);\n\t}\n\telse {\n\t\tr.mark(1);\n\t\tret = r.read();\n\t\tr.reset();\n\t}\n\n\treturn readRet(ret);\n}\n\nstatic public int getLineNumber(Reader r){\n\tif(r instanceof LineNumberingPushbackReader)\n\t\treturn ((LineNumberingPushbackReader) r).getLineNumber();\n\treturn 0;\n}\n\nstatic public int getColumnNumber(Reader r){\n\tif(r instanceof LineNumberingPushbackReader)\n\t\treturn ((LineNumberingPushbackReader) r).getColumnNumber();\n\treturn 0;\n}\n\nstatic public LineNumberingPushbackReader getLineNumberingReader(Reader r){\n\tif(isLineNumberingReader(r))\n\t\treturn (LineNumberingPushbackReader) r;\n\treturn new LineNumberingPushbackReader(r);\n}\n\nstatic public boolean isLineNumberingReader(Reader r){\n\treturn r instanceof LineNumberingPushbackReader;\n}\n\nstatic public boolean isReduced(Object r){\n\treturn r instanceof Reduced;\n}\n\nstatic public String resolveClassNameInContext(String className){\n\t//todo - look up in context var\n\treturn className;\n}\n\nstatic public boolean suppressRead(){\n  return booleanCast(SUPPRESS_READ.deref());\n}\n\nstatic public String printString(Object x){\n\ttry {\n\t\tStringWriter sw = new StringWriter();\n\t\tprint(x, sw);\n\t\treturn sw.toString();\n\t}\n\tcatch(Exception e) {\n\t\tthrow Util.sneakyThrow(e);\n\t}\n}\n\nstatic public Object readString(String s){\n  return readString(s, null);\n}\n\nstatic public Object readString(String s, Object opts) {\n  PushbackReader r = new PushbackReader(new StringReader(s));\n  return LispReader.read(r, opts);\n}\n\nstatic public void print(Object x, Writer w) throws IOException{\n\t//call multimethod\n\tif(PRINT_INITIALIZED.isBound() && RT.booleanCast(PRINT_INITIALIZED.deref()))\n\t\tPR_ON.invoke(x, w);\n//*\n\telse {\n\t\tboolean readably = booleanCast(PRINT_READABLY.deref());\n\t\tif(x instanceof Obj) {\n\t\t\tObj o = (Obj) x;\n\t\t\tif(RT.count(o.meta()) > 0 &&\n\t\t\t   ((readably && booleanCast(PRINT_META.deref()))\n\t\t\t    || booleanCast(PRINT_DUP.deref()))) {\n\t\t\t\tIPersistentMap meta = o.meta();\n\t\t\t\tw.write(\"#^\");\n\t\t\t\tif(meta.count() == 1 && meta.containsKey(TAG_KEY))\n\t\t\t\t\tprint(meta.valAt(TAG_KEY), w);\n\t\t\t\telse\n\t\t\t\t\tprint(meta, w);\n\t\t\t\tw.write(' ');\n\t\t\t}\n\t\t}\n\t\tif(x == null)\n\t\t\tw.write(\"nil\");\n\t\telse if(x instanceof ISeq || x instanceof IPersistentList) {\n\t\t\tw.write('(');\n\t\t\tprintInnerSeq(seq(x), w);\n\t\t\tw.write(')');\n\t\t}\n\t\telse if(x instanceof String) {\n\t\t\tString s = (String) x;\n\t\t\tif(!readably)\n\t\t\t\tw.write(s);\n\t\t\telse {\n\t\t\t\tw.write('\"');\n\t\t\t\t//w.write(x.toString());\n\t\t\t\tfor(int i = 0; i < s.length(); i++) {\n\t\t\t\t\tchar c = s.charAt(i);\n\t\t\t\t\tswitch(c) {\n\t\t\t\t\t\tcase '\\n':\n\t\t\t\t\t\t\tw.write(\"\\\\n\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase '\\t':\n\t\t\t\t\t\t\tw.write(\"\\\\t\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase '\\r':\n\t\t\t\t\t\t\tw.write(\"\\\\r\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase '\"':\n\t\t\t\t\t\t\tw.write(\"\\\\\\\"\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase '\\\\':\n\t\t\t\t\t\t\tw.write(\"\\\\\\\\\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase '\\f':\n\t\t\t\t\t\t\tw.write(\"\\\\f\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase '\\b':\n\t\t\t\t\t\t\tw.write(\"\\\\b\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tw.write(c);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tw.write('\"');\n\t\t\t}\n\t\t}\n\t\telse if(x instanceof IPersistentMap) {\n\t\t\tw.write('{');\n\t\t\tfor(ISeq s = seq(x); s != null; s = s.next()) {\n\t\t\t\tIMapEntry e = (IMapEntry) s.first();\n\t\t\t\tprint(e.key(), w);\n\t\t\t\tw.write(' ');\n\t\t\t\tprint(e.val(), w);\n\t\t\t\tif(s.next() != null)\n\t\t\t\t\tw.write(\", \");\n\t\t\t}\n\t\t\tw.write('}');\n\t\t}\n\t\telse if(x instanceof IPersistentVector) {\n\t\t\tIPersistentVector a = (IPersistentVector) x;\n\t\t\tw.write('[');\n\t\t\tfor(int i = 0; i < a.count(); i++) {\n\t\t\t\tprint(a.nth(i), w);\n\t\t\t\tif(i < a.count() - 1)\n\t\t\t\t\tw.write(' ');\n\t\t\t}\n\t\t\tw.write(']');\n\t\t}\n\t\telse if(x instanceof IPersistentSet) {\n\t\t\tw.write(\"#{\");\n\t\t\tfor(ISeq s = seq(x); s != null; s = s.next()) {\n\t\t\t\tprint(s.first(), w);\n\t\t\t\tif(s.next() != null)\n\t\t\t\t\tw.write(\" \");\n\t\t\t}\n\t\t\tw.write('}');\n\t\t}\n\t\telse if(x instanceof Character) {\n\t\t\tchar c = ((Character) x).charValue();\n\t\t\tif(!readably)\n\t\t\t\tw.write(c);\n\t\t\telse {\n\t\t\t\tw.write('\\\\');\n\t\t\t\tswitch(c) {\n\t\t\t\t\tcase '\\n':\n\t\t\t\t\t\tw.write(\"newline\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '\\t':\n\t\t\t\t\t\tw.write(\"tab\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ' ':\n\t\t\t\t\t\tw.write(\"space\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '\\b':\n\t\t\t\t\t\tw.write(\"backspace\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '\\f':\n\t\t\t\t\t\tw.write(\"formfeed\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '\\r':\n\t\t\t\t\t\tw.write(\"return\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tw.write(c);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(x instanceof Class) {\n\t\t\tw.write(\"#=\");\n\t\t\tw.write(((Class) x).getName());\n\t\t}\n\t\telse if(x instanceof BigDecimal && readably) {\n\t\t\tw.write(x.toString());\n\t\t\tw.write('M');\n\t\t}\n\t\telse if(x instanceof BigInt && readably) {\n\t\t\tw.write(x.toString());\n\t\t\tw.write('N');\n\t\t}\n\t\telse if(x instanceof BigInteger && readably) {\n\t\t\tw.write(x.toString());\n\t\t\tw.write(\"BIGINT\");\n\t\t}\n\t\telse if(x instanceof Var) {\n\t\t\tVar v = (Var) x;\n\t\t\tw.write(\"#=(var \" + v.ns.name + \"/\" + v.sym + \")\");\n\t\t}\n\t\telse if(x instanceof Pattern) {\n\t\t\tPattern p = (Pattern) x;\n\t\t\tw.write(\"#\\\"\" + p.pattern() + \"\\\"\");\n\t\t}\n\t\telse w.write(x.toString());\n\t}\n\t//*/\n}\n\nprivate static void printInnerSeq(ISeq x, Writer w) throws IOException{\n\tfor(ISeq s = x; s != null; s = s.next()) {\n\t\tprint(s.first(), w);\n\t\tif(s.next() != null)\n\t\t\tw.write(' ');\n\t}\n}\n\nstatic public void formatAesthetic(Writer w, Object obj) throws IOException{\n\tif(obj == null)\n\t\tw.write(\"null\");\n\telse\n\t\tw.write(obj.toString());\n}\n\nstatic public void formatStandard(Writer w, Object obj) throws IOException{\n\tif(obj == null)\n\t\tw.write(\"null\");\n\telse if(obj instanceof String) {\n\t\tw.write('\"');\n\t\tw.write((String) obj);\n\t\tw.write('\"');\n\t}\n\telse if(obj instanceof Character) {\n\t\tw.write('\\\\');\n\t\tchar c = ((Character) obj).charValue();\n\t\tswitch(c) {\n\t\t\tcase '\\n':\n\t\t\t\tw.write(\"newline\");\n\t\t\t\tbreak;\n\t\t\tcase '\\t':\n\t\t\t\tw.write(\"tab\");\n\t\t\t\tbreak;\n\t\t\tcase ' ':\n\t\t\t\tw.write(\"space\");\n\t\t\t\tbreak;\n\t\t\tcase '\\b':\n\t\t\t\tw.write(\"backspace\");\n\t\t\t\tbreak;\n\t\t\tcase '\\f':\n\t\t\t\tw.write(\"formfeed\");\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tw.write(c);\n\t\t}\n\t}\n\telse\n\t\tw.write(obj.toString());\n}\n\nstatic public Object format(Object o, String s, Object... args) throws IOException{\n\tWriter w;\n\tif(o == null)\n\t\tw = new StringWriter();\n\telse if(Util.equals(o, T))\n\t\tw = (Writer) OUT.deref();\n\telse\n\t\tw = (Writer) o;\n\tdoFormat(w, s, ArraySeq.create(args));\n\tif(o == null)\n\t\treturn w.toString();\n\treturn null;\n}\n\nstatic public ISeq doFormat(Writer w, String s, ISeq args) throws IOException{\n\tfor(int i = 0; i < s.length();) {\n\t\tchar c = s.charAt(i++);\n\t\tswitch(Character.toLowerCase(c)) {\n\t\t\tcase '~':\n\t\t\t\tchar d = s.charAt(i++);\n\t\t\t\tswitch(Character.toLowerCase(d)) {\n\t\t\t\t\tcase '%':\n\t\t\t\t\t\tw.write('\\n');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 't':\n\t\t\t\t\t\tw.write('\\t');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'a':\n\t\t\t\t\t\tif(args == null)\n\t\t\t\t\t\t\tthrow new IllegalArgumentException(\"Missing argument\");\n\t\t\t\t\t\tRT.formatAesthetic(w, RT.first(args));\n\t\t\t\t\t\targs = RT.next(args);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 's':\n\t\t\t\t\t\tif(args == null)\n\t\t\t\t\t\t\tthrow new IllegalArgumentException(\"Missing argument\");\n\t\t\t\t\t\tRT.formatStandard(w, RT.first(args));\n\t\t\t\t\t\targs = RT.next(args);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '{':\n\t\t\t\t\t\tint j = s.indexOf(\"~}\", i);    //note - does not nest\n\t\t\t\t\t\tif(j == -1)\n\t\t\t\t\t\t\tthrow new IllegalArgumentException(\"Missing ~}\");\n\t\t\t\t\t\tString subs = s.substring(i, j);\n\t\t\t\t\t\tfor(ISeq sargs = RT.seq(RT.first(args)); sargs != null;)\n\t\t\t\t\t\t\tsargs = doFormat(w, subs, sargs);\n\t\t\t\t\t\targs = RT.next(args);\n\t\t\t\t\t\ti = j + 2; //skip ~}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '^':\n\t\t\t\t\t\tif(args == null)\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '~':\n\t\t\t\t\t\tw.write('~');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new IllegalArgumentException(\"Unsupported ~ directive: \" + d);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tw.write(c);\n\t\t}\n\t}\n\treturn args;\n}\n///////////////////////////////// values //////////////////////////\n\nstatic public Object[] setValues(Object... vals){\n\t//ThreadLocalData.setValues(vals);\n\tif(vals.length > 0)\n\t\treturn vals;//[0];\n\treturn null;\n}\n\n\nstatic public ClassLoader makeClassLoader(){\n\treturn (ClassLoader) AccessController.doPrivileged(new PrivilegedAction(){\n\t\tpublic Object run(){\n            try{\n            Var.pushThreadBindings(RT.map(USE_CONTEXT_CLASSLOADER, RT.T));\n//\t\t\tgetRootClassLoader();\n\t\t\treturn new DynamicClassLoader(baseLoader());\n            }\n                finally{\n            Var.popThreadBindings();\n            }\n\t\t}\n\t});\n}\n\nstatic public ClassLoader baseLoader(){\n\tif(Compiler.LOADER.isBound())\n\t\treturn (ClassLoader) Compiler.LOADER.deref();\n\telse if(booleanCast(USE_CONTEXT_CLASSLOADER.deref()))\n\t\treturn Thread.currentThread().getContextClassLoader();\n\treturn Compiler.class.getClassLoader();\n}\n\nstatic public InputStream resourceAsStream(ClassLoader loader, String name){\n    if (loader == null) {\n      return ClassLoader.getSystemResourceAsStream(name);\n    } else {\n      return loader.getResourceAsStream(name);\n    }\n  }\n\n  static public URL getResource(ClassLoader loader, String name) {\n    if (loader == null) {\n      return ClassLoader.getSystemResource(name);\n    } else {\n      return loader.getResource(name);\n    }\n  }\n\n  static public Class classForName(String name, boolean load, ClassLoader loader) {\n    try {\n      Class c = null;\n      if (!(loader instanceof DynamicClassLoader))\n        c = DynamicClassLoader.findInMemoryClass(name);\n      if (c != null)\n        return c;\n      return Class.forName(name, load, loader);\n    } catch (ClassNotFoundException e) {\n      throw Util.sneakyThrow(e);\n    }\n  }\n  \n  static public Class classForName(String name) {\n    return classForName(name.replaceAll(\"-\", \"_\"), true, baseLoader());\n  }\n\n  static public Class classForNameNonLoading(String name) {\n    return classForName(name.replaceAll(\"-\", \"_\"), false, baseLoader());\n  }\n  \n  static public Class loadClassForName(String name){\n    try {\n      classForNameNonLoading(name);\n    } catch (Exception e) {\n      if (e instanceof ClassNotFoundException)\n        return null;\n      else\n        throw Util.sneakyThrow(e);\n    }\n    return classForName(name);\n  }\n\n  static public float aget(float[] xs, int i) {\n    return xs[i];\n  }\n\n  static public float aset(float[] xs, int i, float v) {\n    xs[i] = v;\n    return v;\n  }\n\n  static public int alength(float[] xs) {\n    return xs.length;\n  }\n\n  static public float[] aclone(float[] xs) {\n    return xs.clone();\n  }\n\n  static public double aget(double[] xs, int i) {\n    return xs[i];\n  }\n\n  static public double aset(double[] xs, int i, double v) {\n    xs[i] = v;\n    return v;\n  }\n\n  static public int alength(double[] xs) {\n    return xs.length;\n  }\n\n  static public double[] aclone(double[] xs) {\n    return xs.clone();\n  }\n\n  static public int aget(int[] xs, int i) {\n    return xs[i];\n  }\n\n  static public int aset(int[] xs, int i, int v) {\n    xs[i] = v;\n    return v;\n  }\n\n  static public int alength(int[] xs) {\n    return xs.length;\n  }\n\n  static public int[] aclone(int[] xs) {\n    return xs.clone();\n  }\n\n  static public long aget(long[] xs, int i) {\n    return xs[i];\n  }\n\n  static public long aset(long[] xs, int i, long v) {\n    xs[i] = v;\n    return v;\n  }\n\n  static public int alength(long[] xs) {\n    return xs.length;\n  }\n\n  static public long[] aclone(long[] xs) {\n    return xs.clone();\n  }\n\n  static public char aget(char[] xs, int i) {\n    return xs[i];\n  }\n\n  static public char aset(char[] xs, int i, char v) {\n    xs[i] = v;\n    return v;\n  }\n\n  static public int alength(char[] xs) {\n    return xs.length;\n  }\n\n  static public char[] aclone(char[] xs) {\n    return xs.clone();\n  }\n\n  static public byte aget(byte[] xs, int i) {\n    return xs[i];\n  }\n\n  static public byte aset(byte[] xs, int i, byte v) {\n    xs[i] = v;\n    return v;\n  }\n\n  static public int alength(byte[] xs) {\n    return xs.length;\n  }\n\n  static public byte[] aclone(byte[] xs) {\n    return xs.clone();\n  }\n\n  static public short aget(short[] xs, int i) {\n    return xs[i];\n  }\n\n  static public short aset(short[] xs, int i, short v) {\n    xs[i] = v;\n    return v;\n  }\n\n  static public int alength(short[] xs) {\n    return xs.length;\n  }\n\n  static public short[] aclone(short[] xs) {\n    return xs.clone();\n  }\n\n  static public boolean aget(boolean[] xs, int i) {\n    return xs[i];\n  }\n\n  static public boolean aset(boolean[] xs, int i, boolean v) {\n    xs[i] = v;\n    return v;\n  }\n\n  static public int alength(boolean[] xs) {\n    return xs.length;\n  }\n\n  static public boolean[] aclone(boolean[] xs) {\n    return xs.clone();\n  }\n\n  static public Object aget(Object[] xs, int i) {\n    return xs[i];\n  }\n\n  static public Object aset(Object[] xs, int i, Object v) {\n    xs[i] = v;\n    return v;\n  }\n\n  static public int alength(Object[] xs) {\n    return xs.length;\n  }\n\n  static public Object[] aclone(Object[] xs) {\n    return xs.clone();\n  }\n\n  public static native Object NSClassFromString(String s) /*-[\n                                                          return NSClassFromString(s);\n                                                          ]-*/;\n\n}"
  },
  {
    "path": "src/jvm/clojure/lang/Range.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.io.Serializable;\nimport java.util.*;\n\n/**\n * Implements generic numeric (potentially infinite) range.\n */\npublic class Range extends ASeq implements IChunkedSeq, IReduce {\n\nprivate static final int CHUNK_SIZE = 32;\n\n// Invariants guarantee this is never an \"empty\" seq\n//   assert(start != end && step != 0)\nfinal Object end;\nfinal Object start;\nfinal Object step;\nfinal BoundsCheck boundsCheck;\nprivate volatile IChunk _chunk;      // lazy\nprivate volatile ISeq _chunkNext;        // lazy\nprivate volatile ISeq _next;             // cached\n\nprivate static interface BoundsCheck extends Serializable {\n    boolean exceededBounds(Object val);\n}\n\nprivate static BoundsCheck positiveStep(final Object end) {\n    return new BoundsCheck() {\n        public boolean exceededBounds(Object val){\n            return Numbers.gte(val, end);\n        }\n    };\n}\n\nprivate static BoundsCheck negativeStep(final Object end) {\n    return new BoundsCheck() {\n        public boolean exceededBounds(Object val){\n            return Numbers.lte(val, end);\n        }\n    };\n}\n\nprivate Range(Object start, Object end, Object step, BoundsCheck boundsCheck){\n\tthis.end = end;\n\tthis.start = start;\n    this.step = step;\n    this.boundsCheck = boundsCheck;\n}\n\nprivate Range(Object start, Object end, Object step, BoundsCheck boundsCheck, IChunk chunk, ISeq chunkNext){\n    this.end = end;\n    this.start = start;\n    this.step = step;\n    this.boundsCheck = boundsCheck;\n    this._chunk = chunk;\n    this._chunkNext = chunkNext;\n}\n\nprivate Range(IPersistentMap meta, Object start, Object end, Object step, BoundsCheck boundsCheck, IChunk chunk, ISeq chunkNext){\n    super(meta);\n\tthis.end = end;\n\tthis.start = start;\n    this.step = step;\n    this.boundsCheck = boundsCheck;\n    this._chunk = chunk;\n    this._chunkNext = chunkNext;\n}\n\npublic static ISeq create(Object end) {\n    if(Numbers.isPos(end))\n        return new Range(0L, end, 1L, positiveStep(end));\n    return PersistentList.EMPTY;\n}\n\npublic static ISeq create(Object start, Object end) {\n    return create(start, end, 1L);\n}\n\npublic static ISeq create(final Object start, Object end, Object step) {\n    if((Numbers.isPos(step) && Numbers.gt(start, end)) ||\n       (Numbers.isNeg(step) && Numbers.gt(end, start)) ||\n       Numbers.equiv(start, end))\n        return PersistentList.EMPTY;\n    if(Numbers.isZero(step))\n        return Repeat.create(start);\n    return new Range(start, end, step, Numbers.isPos(step)?positiveStep(end):negativeStep(end));\n}\n\npublic Obj withMeta(IPersistentMap meta){\n\tif(meta == _meta)\n\t\treturn this;\n\treturn new Range(meta, end, start, step, boundsCheck, _chunk, _chunkNext);\n}\n\npublic Object first(){\n    return start;\n}\n\npublic void forceChunk() {\n    if(_chunk != null) return;\n\n    Object[] arr = new Object[CHUNK_SIZE];\n    int n = 0;\n    Object val = start;\n    while(n < CHUNK_SIZE) {\n        arr[n++] = val;\n        val = Numbers.addP(val, step);\n        if(boundsCheck.exceededBounds(val)) {\n            //partial last chunk\n            _chunk = new ArrayChunk(arr, 0, n);\n            return;\n        }\n    }\n\n    // full last chunk\n    if(boundsCheck.exceededBounds(val)) {\n        _chunk = new ArrayChunk(arr, 0, CHUNK_SIZE);\n        return;\n    }\n\n    // full intermediate chunk\n    _chunk = new ArrayChunk(arr, 0, CHUNK_SIZE);\n    _chunkNext = new Range(val, end, step, boundsCheck);\n}\n\npublic ISeq next() {\n    if(_next != null)\n        return _next;\n\n    forceChunk();\n    if(_chunk.count() > 1) {\n        IChunk smallerChunk = _chunk.dropFirst();\n        _next = new Range(smallerChunk.nth(0), end, step, boundsCheck, smallerChunk, _chunkNext);\n        return _next;\n    }\n    return chunkedNext();\n}\n\npublic IChunk chunkedFirst() {\n    forceChunk();\n    return _chunk;\n}\n\npublic ISeq chunkedNext() {\n    return chunkedMore().seq();\n}\n\npublic ISeq chunkedMore() {\n    forceChunk();\n    if(_chunkNext == null)\n        return PersistentList.EMPTY;\n    return _chunkNext;\n}\n\npublic Object reduce(IFn f) {\n    Object acc = start;\n    Number i = Numbers.addP(start, step);\n    while(! boundsCheck.exceededBounds(i)) {\n        acc = f.invoke(acc, i);\n        if (RT.isReduced(acc)) return ((Reduced)acc).deref();\n        i = Numbers.addP(i, step);\n    }\n    return acc;\n}\n\npublic Object reduce(IFn f, Object val) {\n    Object acc = val;\n    Object i = start;\n    while(! boundsCheck.exceededBounds(i)) {\n        acc = f.invoke(acc, i);\n        if (RT.isReduced(acc)) return ((Reduced)acc).deref();\n        i = Numbers.addP(i, step);\n    }\n    return acc;\n}\n\npublic Iterator iterator() {\n    return new RangeIterator();\n}\n\nprivate class RangeIterator implements Iterator {\n    private Object next;\n\n    public RangeIterator() {\n        this.next = start;\n    }\n\n    public boolean hasNext() {\n        return(! boundsCheck.exceededBounds(next));\n    }\n\n    public Object next() {\n        if (hasNext()) {\n            Object ret = next;\n            next = Numbers.addP(next, step);\n            return ret;\n        } else {\n            throw new NoSuchElementException();\n        }\n    }\n\n    public void remove() {\n        throw new UnsupportedOperationException();\n    }\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Ratio.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 31, 2008 */\n\npackage clojure.lang;\n\nimport java.math.BigInteger;\nimport java.math.BigDecimal;\nimport java.math.MathContext;\n\npublic class Ratio extends Number implements Comparable{\nfinal public BigInteger numerator;\nfinal public BigInteger denominator;\n\npublic Ratio(BigInteger numerator, BigInteger denominator){\n\tthis.numerator = numerator;\n\tthis.denominator = denominator;\n}\n\npublic boolean equals(Object arg0){\n\treturn arg0 != null\n\t       && arg0 instanceof Ratio\n\t       && ((Ratio) arg0).numerator.equals(numerator)\n\t       && ((Ratio) arg0).denominator.equals(denominator);\n}\n\npublic int hashCode(){\n\treturn Util.hash(numerator) ^ Util.hash(denominator);\n}\n\npublic String toString(){\n\treturn numerator.toString() + \"/\" + denominator.toString();\n}\n\npublic int intValue(){\n\treturn (int) doubleValue();\n}\n\npublic long longValue(){\n\treturn bigIntegerValue().longValue();\n}\n\npublic float floatValue(){\n\treturn (float)doubleValue();\n}\n\npublic double doubleValue(){\n\treturn decimalValue(MathContext.DECIMAL64).doubleValue();\n}\n\npublic BigDecimal decimalValue(){\n\treturn decimalValue(MathContext.UNLIMITED);\n}\n\npublic BigDecimal decimalValue(MathContext mc){\n\tBigDecimal numerator = new BigDecimal(this.numerator);\n\tBigDecimal denominator = new BigDecimal(this.denominator);\n\n\treturn numerator.divide(denominator, mc);\n}\n\npublic BigInteger bigIntegerValue(){\n\treturn numerator.divide(denominator);\n}\n\npublic int compareTo(Object o){\n\tNumber other = (Number)o;\n\treturn Numbers.compare(this, other);\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ReaderConditional.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\npublic class ReaderConditional implements ILookup {\n\npublic static final Keyword FORM_KW = Keyword.intern(\"form\");\npublic static final Keyword SPLICING_KW = Keyword.intern(\"splicing?\");\n\npublic final Object form;\npublic final Boolean splicing;\n\npublic static ReaderConditional create(Object form, boolean splicing) {\n\treturn new ReaderConditional(form, splicing);\n}\n\nprivate ReaderConditional(Object form, boolean splicing){\n\tthis.form = form;\n\tthis.splicing = splicing;\n}\n\n\npublic Object valAt(Object key) {\n\treturn valAt(key, null);\n}\n\npublic Object valAt(Object key, Object notFound) {\n\tif (FORM_KW.equals(key)) {\n\t\treturn this.form;\n\t} else if (SPLICING_KW.equals(key)) {\n\t\treturn this.splicing;\n\t} else {\n\t\treturn notFound;\n\t}\n}\n\n\n@Override\npublic boolean equals(Object o) {\n\tif (this == o) return true;\n\tif (o == null || getClass() != o.getClass()) return false;\n\n\tReaderConditional that = (ReaderConditional) o;\n\n\tif (form != null ? !form.equals(that.form) : that.form != null) return false;\n\tif (splicing != null ? !splicing.equals(that.splicing) : that.splicing != null)\n\t\treturn false;\n\treturn true;\n}\n\n@Override\npublic int hashCode() {\n\tint result = Util.hash(form);\n\tresult = 31 * result + Util.hash(splicing);\n\treturn result;\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/RecordIterator.java",
    "content": "/**\n * Copyright (c) Rich Hickey. All rights reserved.\n * The use and distribution terms for this software are covered by the\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n * which can be found in the file epl-v10.html at the root of this distribution.\n * By using this software in any fashion, you are agreeing to be bound by\n * the terms of this license.\n * You must not remove this notice, or any other, from this software.\n */\n\n/* ghadi shayban Sep 24, 2014 */\n\npackage clojure.lang;\n\nimport java.util.Iterator;\n\npublic final class RecordIterator implements Iterator {\n\n    int i = 0;\n    final int basecnt;\n    final ILookup rec;\n    final IPersistentVector basefields;\n    final Iterator extmap;\n\n    public RecordIterator (ILookup rec, IPersistentVector basefields, Iterator extmap) {\n        this.rec = rec;\n        this.basefields = basefields;\n        this.basecnt = basefields.count();\n        this.extmap = extmap;\n    }\n\n    public boolean hasNext() {\n        if (i < basecnt) {\n            return true;\n        } else {\n            return extmap.hasNext();\n        }\n    }\n\n    public Object next() {\n        if (i < basecnt) {\n            Object k = basefields.nth(i);\n            i++;\n            return new MapEntry(k, rec.valAt(k));\n        } else  {\n            return extmap.next();\n        }\n    }\n\n    public void remove() {\n        throw new UnsupportedOperationException();\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Reduced.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\npublic final class Reduced implements IDeref{\nObject val;\n\npublic Reduced(Object val){\n\tthis.val = val;\n}\n\npublic Object deref(){\n\treturn val;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Ref.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jul 25, 2007 */\n\npackage clojure.lang;\n\nimport java.util.concurrent.atomic.AtomicInteger;\nimport java.util.concurrent.atomic.AtomicLong;\nimport java.util.concurrent.locks.ReentrantReadWriteLock;\n\npublic class Ref extends ARef implements IFn, Comparable<Ref>, IRef{\n    public int compareTo(Ref ref) {\n        if(this.id == ref.id)\n            return 0;\n        else if(this.id < ref.id)\n            return -1;\n        else\n            return 1;\n    }\n\npublic int getMinHistory(){\n\treturn minHistory;\n}\n\npublic Ref setMinHistory(int minHistory){\n\tthis.minHistory = minHistory;\n\treturn this;\n}\n\npublic int getMaxHistory(){\n\treturn maxHistory;\n}\n\npublic Ref setMaxHistory(int maxHistory){\n\tthis.maxHistory = maxHistory;\n\treturn this;\n}\n\npublic static class TVal{\n\tObject val;\n\tlong point;\n\tTVal prior;\n\tTVal next;\n\n\tTVal(Object val, long point, TVal prior){\n\t\tthis.val = val;\n\t\tthis.point = point;\n\t\tthis.prior = prior;\n\t\tthis.next = prior.next;\n\t\tthis.prior.next = this;\n\t\tthis.next.prior = this;\n\t}\n\n\tTVal(Object val, long point){\n\t\tthis.val = val;\n\t\tthis.point = point;\n\t\tthis.next = this;\n\t\tthis.prior = this;\n\t}\n\n}\n\nTVal tvals;\nfinal AtomicInteger faults;\nfinal ReentrantReadWriteLock lock;\nLockingTransaction.Info tinfo;\n//IFn validator;\nfinal long id;\n\nvolatile int minHistory = 0;\nvolatile int maxHistory = 10;\n\nstatic final AtomicLong ids = new AtomicLong();\n\npublic Ref(Object initVal) {\n\tthis(initVal, null);\n}\n\npublic Ref(Object initVal,IPersistentMap meta) {\n    super(meta);\n    this.id = ids.getAndIncrement();\n\tthis.faults = new AtomicInteger();\n\tthis.lock = new ReentrantReadWriteLock();\n\ttvals = new TVal(initVal, 0);\n}\n\n//the latest val\n\n// ok out of transaction\nObject currentVal(){\n\ttry\n\t\t{\n\t\tlock.readLock().lock();\n\t\tif(tvals != null)\n\t\t\treturn tvals.val;\n\t\tthrow new IllegalStateException(this.toString() + \" is unbound.\");\n\t\t}\n\tfinally\n\t\t{\n\t\tlock.readLock().unlock();\n\t\t}\n}\n\n//*\n\npublic Object deref(){\n\tLockingTransaction t = LockingTransaction.getRunning();\n\tif(t == null)\n\t\treturn currentVal();\n\treturn t.doGet(this);\n}\n\n//void validate(IFn vf, Object val){\n//\ttry{\n//\t\tif(vf != null && !RT.booleanCast(vf.invoke(val)))\n//            throw new IllegalStateException(\"Invalid ref state\");\n//\t\t}\n//    catch(RuntimeException re)\n//        {\n//        throw re;\n//        }\n//\tcatch(Exception e)\n//\t\t{\n//\t\tthrow new IllegalStateException(\"Invalid ref state\", e);\n//\t\t}\n//}\n//\n//public void setValidator(IFn vf){\n//\ttry\n//\t\t{\n//\t\tlock.writeLock().lock();\n//\t\tvalidate(vf,currentVal());\n//\t\tvalidator = vf;\n//\t\t}\n//\tfinally\n//\t\t{\n//\t\tlock.writeLock().unlock();\n//\t\t}\n//}\n//\n//public IFn getValidator(){\n//\ttry\n//\t\t{\n//\t\tlock.readLock().lock();\n//\t\treturn validator;\n//\t\t}\n//\tfinally\n//\t\t{\n//\t\tlock.readLock().unlock();\n//\t\t}\n//}\n\npublic Object set(Object val){\n\treturn LockingTransaction.getEx().doSet(this, val);\n}\n\npublic Object commute(IFn fn, ISeq args) {\n\treturn LockingTransaction.getEx().doCommute(this, fn, args);\n}\n\npublic Object alter(IFn fn, ISeq args) {\n\tLockingTransaction t = LockingTransaction.getEx();\n\treturn t.doSet(this, fn.applyTo(RT.cons(t.doGet(this), args)));\n}\n\npublic void touch(){\n\tLockingTransaction.getEx().doEnsure(this);\n}\n\n//*/\nboolean isBound(){\n\ttry\n\t\t{\n\t\tlock.readLock().lock();\n\t\treturn tvals != null;\n\t\t}\n\tfinally\n\t\t{\n\t\tlock.readLock().unlock();\n\t\t}\n}\n\n\npublic void trimHistory(){\n\ttry\n\t\t{\n\t\tlock.writeLock().lock();\n\t\tif(tvals != null)\n\t\t\t{\n\t\t\ttvals.next = tvals;\n\t\t\ttvals.prior = tvals;\n\t\t\t}\n\t\t}\n\tfinally\n\t\t{\n\t\tlock.writeLock().unlock();\n\t\t}\n}\n\npublic int getHistoryCount(){\n\ttry\n\t\t{\n\t\tlock.writeLock().lock();\n\t\treturn histCount();\n\t\t}\n\tfinally\n\t\t{\n\t\tlock.writeLock().unlock();\n\t\t}\t\n}\n\nint histCount(){\n\tif(tvals == null)\n\t\treturn 0;\n\telse\n\t\t{\n\t\tint count = 0;\n\t\tfor(TVal tv = tvals.next;tv != tvals;tv = tv.next)\n\t\t\tcount++;\n\t\treturn count;\n\t\t}\n}\n\nfinal public IFn fn(){\n\treturn (IFn) deref();\n}\n\npublic Object call() {\n\treturn invoke();\n}\n\npublic void run(){\n\tinvoke();\n}\n\npublic Object invoke() {\n\treturn fn().invoke();\n}\n\npublic Object invoke(Object arg1) {\n\treturn fn().invoke(arg1);\n}\n\npublic Object invoke(Object arg1, Object arg2) {\n\treturn fn().invoke(arg1, arg2);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3) {\n\treturn fn().invoke(arg1, arg2, arg3);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)\n\t\t{\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13)\n\t\t{\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)\n\t\t{\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15,\n\t                   arg16);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15,\n\t                   arg16, arg17);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15,\n\t                   arg16, arg17, arg18);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19) {\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15,\n\t                   arg16, arg17, arg18, arg19);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20)\n\t\t{\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15,\n\t                   arg16, arg17, arg18, arg19, arg20);\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20,\n                     Object... args)\n\t\t{\n\treturn fn().invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15,\n\t                   arg16, arg17, arg18, arg19, arg20, args);\n}\n\npublic Object applyTo(ISeq arglist) {\n\treturn AFn.applyToHelper(this, arglist);\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Reflector.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Apr 19, 2006 */\n\npackage clojure.lang;\n\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Field;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Modifier;\nimport java.util.ArrayList;\nimport java.util.Iterator;\nimport java.util.List;\n\npublic class Reflector{\n\npublic static Object invokeInstanceMethod(Object target, String methodName, Object[] args) {\n\tClass c = target.getClass();\n\tList methods = getMethods(c, args.length, methodName, false);\n\treturn invokeMatchingMethod(methodName, methods, target, args);\n}\n\nprivate static Throwable getCauseOrElse(Exception e) {\n\tif (e.getCause() != null)\n\t\treturn e.getCause();\n\treturn e;\n}\n\nprivate static RuntimeException throwCauseOrElseException(Exception e) {\n\tif (e.getCause() != null)\n\t\tthrow Util.sneakyThrow(e.getCause());\n\tthrow Util.sneakyThrow(e);\n}\n\nprivate static String noMethodReport(String methodName, Object target){\n\t return \"No matching method found: \" + methodName\n\t\t\t+ (target==null?\"\":\" for \" + target.getClass());\n}\nstatic Object invokeMatchingMethod(String methodName, List methods, Object target, Object[] args)\n\t\t{\n\tMethod m = null;\n\tObject[] boxedArgs = null;\n\tif(methods.isEmpty())\n\t\t{\n\t\tthrow new IllegalArgumentException(noMethodReport(methodName,target));\n\t\t}\n\telse if(methods.size() == 1)\n\t\t{\n\t\tm = (Method) methods.get(0);\n\t\tboxedArgs = boxArgs(m.getParameterTypes(), args);\n\t\t}\n\telse //overloaded w/same arity\n\t\t{\n\t\tMethod foundm = null;\n\t\tfor(Iterator i = methods.iterator(); i.hasNext();)\n\t\t\t{\n\t\t\tm = (Method) i.next();\n\n\t\t\tClass[] params = m.getParameterTypes();\n\t\t\tif(isCongruent(params, args))\n\t\t\t\t{\n\t\t\t\tif(foundm == null || Compiler.subsumes(params, foundm.getParameterTypes()))\n\t\t\t\t\t{\n\t\t\t\t\tfoundm = m;\n\t\t\t\t\tboxedArgs = boxArgs(params, args);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tm = foundm;\n\t\t}\n\tif(m == null)\n\t\tthrow new IllegalArgumentException(noMethodReport(methodName,target));\n\n\tif(!Modifier.isPublic(m.getDeclaringClass().getModifiers()))\n\t\t{\n\t\t//public method of non-public class, try to find it in hierarchy\n\t\tMethod oldm = m;\n\t\tm = getAsMethodOfPublicBase(m.getDeclaringClass(), m);\n\t\tif(m == null)\n\t\t\tthrow new IllegalArgumentException(\"Can't call public method of non-public class: \" +\n\t\t\t                                    oldm.toString());\n\t\t}\n\ttry\n\t\t{\n\t\treturn prepRet(m.getReturnType(), m.invoke(target, boxedArgs));\n\t\t}\n\tcatch(Exception e)\n\t\t{\n\t\tthrow Util.sneakyThrow(getCauseOrElse(e));\n\t\t}\n\n}\n\npublic static Method getAsMethodOfPublicBase(Class c, Method m){\n\tfor(Class iface : c.getInterfaces())\n\t\t{\n\t\tfor(Method im : iface.getMethods())\n\t\t\t{\n\t\t\tif(isMatch(im, m))\n\t\t\t\t{\n\t\t\t\treturn im;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tClass sc = c.getSuperclass();\n\tif(sc == null)\n\t\treturn null;\n\tfor(Method scm : sc.getMethods())\n\t\t{\n\t\tif(isMatch(scm, m))\n\t\t\t{\n\t\t\treturn scm;\n\t\t\t}\n\t\t}\n\treturn getAsMethodOfPublicBase(sc, m);\n}\n\npublic static boolean isMatch(Method lhs, Method rhs) {\n\tif(!lhs.getName().equals(rhs.getName())\n\t\t\t|| !Modifier.isPublic(lhs.getDeclaringClass().getModifiers()))\n\t\t{\n\t\treturn false;\n\t\t}\n\n\t\tClass[] types1 = lhs.getParameterTypes();\n\t\tClass[] types2 = rhs.getParameterTypes();\n\t\tif(types1.length != types2.length)\n\t\t\treturn false;\n\n\t\tboolean match = true;\n\t\tfor (int i=0; i<types1.length; ++i)\n\t\t\t{\n\t\t\tif(!types1[i].isAssignableFrom(types2[i]))\n\t\t\t\t{\n\t\t\t\tmatch = false;\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\treturn match;\n}\n\npublic static Object invokeConstructor(Class c, Object[] args) {\n\ttry\n\t\t{\n\t\tConstructor[] allctors = c.getConstructors();\n\t\tArrayList ctors = new ArrayList();\n\t\tfor(int i = 0; i < allctors.length; i++)\n\t\t\t{\n\t\t\tConstructor ctor = allctors[i];\n\t\t\tif(ctor.getParameterTypes().length == args.length)\n\t\t\t\tctors.add(ctor);\n\t\t\t}\n\t\tif(ctors.isEmpty())\n\t\t\t{\n\t\t\tthrow new IllegalArgumentException(\"No matching ctor found\"\n\t\t\t\t+ \" for \" + c);\n\t\t\t}\n\t\telse if(ctors.size() == 1)\n\t\t\t{\n\t\t\tConstructor ctor = (Constructor) ctors.get(0);\n\t\t\treturn ctor.newInstance(boxArgs(ctor.getParameterTypes(), args));\n\t\t\t}\n\t\telse //overloaded w/same arity\n\t\t\t{\n\t\t\tfor(Iterator iterator = ctors.iterator(); iterator.hasNext();)\n\t\t\t\t{\n\t\t\t\tConstructor ctor = (Constructor) iterator.next();\n\t\t\t\tClass[] params = ctor.getParameterTypes();\n\t\t\t\tif(isCongruent(params, args))\n\t\t\t\t\t{\n\t\t\t\t\tObject[] boxedArgs = boxArgs(params, args);\n\t\t\t\t\treturn ctor.newInstance(boxedArgs);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tthrow new IllegalArgumentException(\"No matching ctor found\"\n\t\t\t\t+ \" for \" + c);\n\t\t\t}\n\t\t}\n\tcatch(Exception e)\n\t\t{\n\t\tthrow Util.sneakyThrow(getCauseOrElse(e));\n\t\t}\n}\n\npublic static Object invokeStaticMethodVariadic(String className, String methodName, Object... args) {\n\treturn invokeStaticMethod(className, methodName, args);\n\n}\n\npublic static Object invokeStaticMethod(String className, String methodName, Object[] args) {\n\tClass c = RT.classForName(className);\n\treturn invokeStaticMethod(c, methodName, args);\n}\n\npublic static Object invokeStaticMethod(Class c, String methodName, Object[] args) {\n\tif(methodName.equals(\"new\"))\n\t\treturn invokeConstructor(c, args);\n\tList methods = getMethods(c, args.length, methodName, true);\n\treturn invokeMatchingMethod(methodName, methods, null, args);\n}\n\npublic static Object getStaticField(String className, String fieldName) {\n\tClass c = RT.classForName(className);\n\treturn getStaticField(c, fieldName);\n}\n\npublic static Object getStaticField(Class c, String fieldName) {\n//\tif(fieldName.equals(\"class\"))\n//\t\treturn c;\n\tField f = getField(c, fieldName, true);\n\tif(f != null)\n\t\t{\n\t\ttry\n\t\t\t{\n\t\t\treturn prepRet(f.getType(), f.get(null));\n\t\t\t}\n\t\tcatch(IllegalAccessException e)\n\t\t\t{\n\t\t\tthrow Util.sneakyThrow(e);\n\t\t\t}\n\t\t}\n\tthrow new IllegalArgumentException(\"No matching field found: \" + fieldName\n\t\t+ \" for \" + c);\n}\n\npublic static Object setStaticField(String className, String fieldName, Object val) {\n\tClass c = RT.classForName(className);\n\treturn setStaticField(c, fieldName, val);\n}\n\npublic static Object setStaticField(Class c, String fieldName, Object val) {\n\tField f = getField(c, fieldName, true);\n\tif(f != null)\n\t\t{\n\t\ttry\n\t\t\t{\n\t\t\tf.set(null, boxArg(f.getType(), val));\n\t\t\t}\n\t\tcatch(IllegalAccessException e)\n\t\t\t{\n\t\t\tthrow Util.sneakyThrow(e);\n\t\t\t}\n\t\treturn val;\n\t\t}\n\tthrow new IllegalArgumentException(\"No matching field found: \" + fieldName\n\t\t+ \" for \" + c);\n}\n\npublic static Object getInstanceField(Object target, String fieldName) {\n\tClass c = target.getClass();\n\tField f = getField(c, fieldName, false);\n\tif(f != null)\n\t\t{\n\t\ttry\n\t\t\t{\n\t\t\treturn prepRet(f.getType(), f.get(target));\n\t\t\t}\n\t\tcatch(IllegalAccessException e)\n\t\t\t{\n\t\t\tthrow Util.sneakyThrow(e);\n\t\t\t}\n\t\t}\n\tthrow new IllegalArgumentException(\"No matching field found: \" + fieldName\n\t\t+ \" for \" + target.getClass());\n}\n\npublic static Object setInstanceField(Object target, String fieldName, Object val) {\n\tClass c = target.getClass();\n\tField f = getField(c, fieldName, false);\n\tif(f != null)\n\t\t{\n\t\ttry\n\t\t\t{\n\t\t\tf.set(target, boxArg(f.getType(), val));\n\t\t\t}\n\t\tcatch(IllegalAccessException e)\n\t\t\t{\n\t\t\tthrow Util.sneakyThrow(e);\n\t\t\t}\n\t\treturn val;\n\t\t}\n\tthrow new IllegalArgumentException(\"No matching field found: \" + fieldName\n\t\t+ \" for \" + target.getClass());\n}\n\n// not used as of Clojure 1.6, but left for runtime compatibility with\n// compiled bytecode from older versions\npublic static Object invokeNoArgInstanceMember(Object target, String name) {\n\treturn invokeNoArgInstanceMember(target, name, false);\n}\n\npublic static Object invokeNoArgInstanceMember(Object target, String name, boolean requireField) {\n\tClass c = target.getClass();\n\n\tif(requireField) {\n\t\tField f = getField(c, name, false);\n\t\tif(f != null)\n\t\t\treturn getInstanceField(target, name);\n\t\telse\n\t\t\tthrow new IllegalArgumentException(\"No matching field found: \" + name\n\t\t\t\t\t+ \" for \" + target.getClass());\n\t} else {\n\t\tList meths = getMethods(c, 0, name, false);\n\t\tif(meths.size() > 0)\n\t\t\treturn invokeMatchingMethod(name, meths, target, RT.EMPTY_ARRAY);\n\t\telse\n\t\t\treturn getInstanceField(target, name);\n\t}\n}\n\npublic static Object invokeInstanceMember(Object target, String name) {\n\t//check for field first\n\tClass c = target.getClass();\n\tField f = getField(c, name, false);\n\tif(f != null)  //field get\n\t\t{\n\t\ttry\n\t\t\t{\n\t\t\treturn prepRet(f.getType(), f.get(target));\n\t\t\t}\n\t\tcatch(IllegalAccessException e)\n\t\t\t{\n\t\t\tthrow Util.sneakyThrow(e);\n\t\t\t}\n\t\t}\n\treturn invokeInstanceMethod(target, name, RT.EMPTY_ARRAY);\n}\n\npublic static Object invokeInstanceMember(String name, Object target, Object arg1) {\n\t//check for field first\n\tClass c = target.getClass();\n\tField f = getField(c, name, false);\n\tif(f != null)  //field set\n\t\t{\n\t\ttry\n\t\t\t{\n\t\t\tf.set(target, boxArg(f.getType(), arg1));\n\t\t\t}\n\t\tcatch(IllegalAccessException e)\n\t\t\t{\n\t\t\tthrow Util.sneakyThrow(e);\n\t\t\t}\n\t\treturn arg1;\n\t\t}\n\treturn invokeInstanceMethod(target, name, new Object[]{arg1});\n}\n\npublic static Object invokeInstanceMember(String name, Object target, Object... args) {\n\treturn invokeInstanceMethod(target, name, args);\n}\n\n\nstatic public Field getField(Class c, String name, boolean getStatics){\n\tField[] allfields = c.getFields();\n\tfor(int i = 0; i < allfields.length; i++)\n\t\t{\n\t\tif(name.equals(allfields[i].getName())\n\t\t   && Modifier.isStatic(allfields[i].getModifiers()) == getStatics)\n\t\t\treturn allfields[i];\n\t\t}\n\treturn null;\n}\n\nstatic public List getMethods(Class c, int arity, String name, boolean getStatics){\n\tMethod[] allmethods = c.getMethods();\n\tArrayList methods = new ArrayList();\n\tArrayList bridgeMethods = new ArrayList();\n\tfor(int i = 0; i < allmethods.length; i++)\n\t\t{\n\t\tMethod method = allmethods[i];\n\t\tif(name.equals(method.getName())\n\t\t   && Modifier.isStatic(method.getModifiers()) == getStatics\n\t\t   && method.getParameterTypes().length == arity)\n\t\t\t{\n\t\t\ttry\n\t\t\t\t{\n\t\t\t\tif(method.isBridge()\n\t\t\t\t   && c.getMethod(method.getName(), method.getParameterTypes())\n\t\t\t\t\t\t.equals(method))\n\t\t\t\t\tbridgeMethods.add(method);\n\t\t\t\telse\n\t\t\t\t\tmethods.add(method);\n\t\t\t\t}\n\t\t\tcatch(NoSuchMethodException e)\n\t\t\t\t{\n\t\t\t\t}\n\t\t\t}\n//\t\t\t   && (!method.isBridge()\n//\t\t\t       || (c == StringBuilder.class &&\n//\t\t\t          c.getMethod(method.getName(), method.getParameterTypes())\n//\t\t\t\t\t.equals(method))))\n//\t\t\t\t{\n//\t\t\t\tmethods.add(allmethods[i]);\n//\t\t\t\t}\n\t\t}\n\n\tif(methods.isEmpty())\n\t\tmethods.addAll(bridgeMethods);\n\t\n\tif(!getStatics && c.isInterface())\n\t\t{\n\t\tallmethods = Object.class.getMethods();\n\t\tfor(int i = 0; i < allmethods.length; i++)\n\t\t\t{\n\t\t\tif(name.equals(allmethods[i].getName())\n\t\t\t   && Modifier.isStatic(allmethods[i].getModifiers()) == getStatics\n\t\t\t   && allmethods[i].getParameterTypes().length == arity)\n\t\t\t\t{\n\t\t\t\tmethods.add(allmethods[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\treturn methods;\n}\n\n\nstatic Object boxArg(Class paramType, Object arg){\n\tif(!paramType.isPrimitive())\n\t\treturn paramType.cast(arg);\n\telse if(paramType == boolean.class)\n\t\treturn Boolean.class.cast(arg);\n\telse if(paramType == char.class)\n\t\treturn Character.class.cast(arg);\n\telse if(arg instanceof Number)\n\t\t{\n\t\tNumber n = (Number) arg;\n\t\tif(paramType == int.class)\n\t\t\treturn n.intValue();\n\t\telse if(paramType == float.class)\n\t\t\treturn n.floatValue();\n\t\telse if(paramType == double.class)\n\t\t\treturn n.doubleValue();\n\t\telse if(paramType == long.class)\n\t\t\treturn n.longValue();\n\t\telse if(paramType == short.class)\n\t\t\treturn n.shortValue();\n\t\telse if(paramType == byte.class)\n\t\t\treturn n.byteValue();\n\t\t}\n\tthrow new IllegalArgumentException(\"Unexpected param type, expected: \" + paramType +\n\t                                   \", given: \" + arg.getClass().getName());\n}\n\nstatic Object[] boxArgs(Class[] params, Object[] args){\n\tif(params.length == 0)\n\t\treturn null;\n\tObject[] ret = new Object[params.length];\n\tfor(int i = 0; i < params.length; i++)\n\t\t{\n\t\tObject arg = args[i];\n\t\tClass paramType = params[i];\n\t\tret[i] = boxArg(paramType, arg);\n\t\t}\n\treturn ret;\n}\n\nstatic public boolean paramArgTypeMatch(Class paramType, Class argType){\n\tif(argType == null)\n\t\treturn !paramType.isPrimitive();\n\tif(paramType == argType || paramType.isAssignableFrom(argType))\n\t\treturn true;\n\tif(paramType == int.class)\n\t\treturn argType == Integer.class\n\t\t       || argType == long.class\n\t\t\t\t|| argType == Long.class\n\t\t\t\t|| argType == short.class\n\t\t\t\t|| argType == byte.class;// || argType == FixNum.class;\n\telse if(paramType == float.class)\n\t\treturn argType == Float.class\n\t\t\t\t|| argType == double.class;\n\telse if(paramType == double.class)\n\t\treturn argType == Double.class\n\t\t\t\t|| argType == float.class;// || argType == DoubleNum.class;\n\telse if(paramType == long.class)\n\t\treturn argType == Long.class\n\t\t\t\t|| argType == int.class\n\t\t\t\t|| argType == short.class\n\t\t\t\t|| argType == byte.class;// || argType == BigNum.class;\n\telse if(paramType == char.class)\n\t\treturn argType == Character.class;\n\telse if(paramType == short.class)\n\t\treturn argType == Short.class;\n\telse if(paramType == byte.class)\n\t\treturn argType == Byte.class;\n\telse if(paramType == boolean.class)\n\t\treturn argType == Boolean.class;\n\treturn false;\n}\n\nstatic boolean isCongruent(Class[] params, Object[] args){\n\tboolean ret = false;\n\tif(args == null)\n\t\treturn params.length == 0;\n\tif(params.length == args.length)\n\t\t{\n\t\tret = true;\n\t\tfor(int i = 0; ret && i < params.length; i++)\n\t\t\t{\n\t\t\tObject arg = args[i];\n\t\t\tClass argType = (arg == null) ? null : arg.getClass();\n\t\t\tClass paramType = params[i];\n\t\t\tret = paramArgTypeMatch(paramType, argType);\n\t\t\t}\n\t\t}\n\treturn ret;\n}\n\npublic static Object prepRet(Class c, Object x){\n\tif (!(c.isPrimitive() || c == Boolean.class))\n\t\treturn x;\n\tif(x instanceof Boolean)\n\t\treturn ((Boolean) x)?Boolean.TRUE:Boolean.FALSE;\n//\telse if(x instanceof Integer)\n//\t\t{\n//\t\treturn ((Integer)x).longValue();\n//\t\t}\n//\telse if(x instanceof Float)\n//\t\t\treturn Double.valueOf(((Float) x).doubleValue());\n\treturn x;\n}\n}"
  },
  {
    "path": "src/jvm/clojure/lang/RemoteRef.java",
    "content": "package clojure.lang;\n\n/*-[\n #include \"clojure/core_gensym.h\"\n ]-*/\n\npublic class RemoteRef extends RestFn {\n\n  private static Object nsPlaceholderString = new Object();\n\n  private static final String OBJC_REF = \"objc-ref-\";\n\n  private static final String JVM_REF = \"jvm-ref-\";\n\n  private static Atom a = new Atom(RT.map());\n  private static Atom i = new Atom(RT.map());\n\n  private static Var gensym = RT.var(\"clojure.core\", \"gensym\");\n\n  public static void reset() {\n    a.reset(RT.map());\n    i.reset(RT.map());\n  }\n\n  static {\n    register(nsPlaceholderString);\n  }\n\n  public static Object register(final Object o) {\n    if (ObjC.objc && classDescription(o).equals(\"NSPlaceholderString\")) {\n      nativeRelease(o);\n      return register(nsPlaceholderString);\n    }\n    IPersistentMap lookup = (IPersistentMap) i.deref();\n    Object curr = lookup.valAt(o);\n    if (curr == null) {\n      Object invoke = ObjC.objc ? nativeGensym(OBJC_REF) : ((AFn) gensym\n          .getRawRoot()).invoke(JVM_REF);\n      final String id = ((Symbol) invoke).getName();\n      a.swap(new AFn() {\n        @Override\n        public Object invoke(Object old) {\n          return RT.assoc(old, id, o);\n        }\n      });\n      i.swap(new AFn() {\n        @Override\n        public Object invoke(Object old) {\n          return RT.assoc(old, o, id);\n        }\n      });\n      return id;\n    } else {\n      return curr;\n    }\n  }\n\n  private static native Object classDescription(Object o) /*-[\n                                                          return [[o class] description];\n                                                          ]-*/;\n\n  private static native void nativeRelease(Object o) /*-[\n                                                     [o release];\n                                                     ]-*/;\n  \n  private static native void nativeRetain(Object o) /*-[\n  [o retain];\n  ]-*/;\n\n  private native static Object nativeGensym(String objcRef) /*-[\n                                                            return [Clojurecore_gensym_get_VAR_() invokeWithId:objcRef];\n                                                            ]-*/;\n\n  private String id;\n\n  public RemoteRef(String id) {\n    this.id = id;\n  }\n\n  public String getId() {\n    return id;\n  }\n\n  public Object get() {\n    if (ObjC.objc) {\n      if (id.startsWith(JVM_REF)) {\n        nativeRetain(this);\n        return this;\n      } else {\n        Object o = (Object) RT.get(a.deref(), id);\n        if (o.equals(nsPlaceholderString)) {\n          return allocNativeString();\n        } else {\n          return o;\n        }\n      }\n    } else {\n      if (id.startsWith(OBJC_REF)) {\n        return this;\n      } else {\n        return (Object) RT.get(a.deref(), id);\n      }\n    }\n  }\n\n  private static native Object allocNativeString() /*-[\n                                                   return [NSString alloc]; // leaks in repl\n                                                   ]-*/;\n\n  @Override\n  protected Object doInvoke(Object args) {\n    return RemoteRepl.callRemote(this, args);\n  }\n\n  @Override\n  public int getRequiredArity() {\n    return 0;\n  }\n\n  @Override\n  public boolean equals(Object f) {\n    if (f != null && f instanceof RemoteRef) {\n      return ((RemoteRef) f).id.equals(id);\n    }\n    return false;\n  }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/RemoteRepl.java",
    "content": "package clojure.lang;\n\nimport java.io.IOException;\n\n/*-[\n#include \"ReplClient.h\"\n]-*/\n\npublic class RemoteRepl {\n\n  public static boolean connected;\n\n  static Var callRemoteSel = RT.var(\"clojure.remoterepl\", \"call-remote\");\n  static Var listen = RT.var(\"clojure.remoterepl\", \"listen\");\n  \n  public static Object callRemote(Object o, Object seq) {\n    if (RemoteRepl.connected) {\n      if (ObjC.objc) {\n        return callRemoteSelNative(o, RT.seq(seq));\n      } else {\n        if (o == null) {\n          throw new NullPointerException();\n        }\n        return callRemoteSel.invoke(o, RT.seq(seq));\n      }\n    } else {\n      //throw new RuntimeException(\"RemoteRepl not connected\");\n      return null;\n    }\n  }\n\n  private native static Object callRemoteSelNative(Object o, ISeq seq) /*-[\n      return [ReplClient callRemote:o args:seq];\n  ]-*/;\n\n  public static void setConnected(boolean connected) {\n    RemoteRepl.connected = connected;\n    RemoteRef.reset();\n  }\n  \n  public static void listen() {\n    try {\n      RT.load(\"clojure/remoterepl\");\n      listen.invoke();\n    } catch (Exception e) {\n      throw Util.sneakyThrow(e);\n    }\n  }\n  \n  public native static void connect(String host, String port) /*-[\n    [ReplClient connect:host];\n  ]-*/;\n\n  public static native Object safetry(AFn fn) /*-[\n    @try {\n      return [fn invoke];\n    } \n    @catch (NSException *exception) {\n      NSLog(@\"%@\", [exception callStackSymbols]);\n      return nil;\n    }\n  ]-*/;\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Repeat.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\n/* Alex Miller, Dec 5, 2014 */\n\npublic class Repeat extends ASeq implements IReduce {\n\nprivate static final long INFINITE = -1;\n\nprivate final long count;  // always INFINITE or >0\nprivate final Object val;\nprivate volatile ISeq _next;  // cached\n\nprivate Repeat(long count, Object val){\n    this.count = count;\n    this.val = val;\n}\n\nprivate Repeat(IPersistentMap meta, long count, Object val){\n    super(meta);\n    this.count = count;\n    this.val = val;\n}\n\npublic static Repeat create(Object val){\n    return new Repeat(INFINITE, val);\n}\n\npublic static ISeq create(long count, Object val){\n    if(count <= 0)\n        return PersistentList.EMPTY;\n    return new Repeat(count, val);\n}\n\npublic Object first(){\n    return val;\n}\n\npublic ISeq next() {\n    if(_next == null) {\n        if(count > 1)\n            _next = new Repeat(count - 1, val);\n        else if(count == INFINITE)\n            _next = this;\n    }\n    return _next;\n}\n\npublic Repeat withMeta(IPersistentMap meta){\n    return new Repeat(meta, count, val);\n}\n\npublic Object reduce(IFn f){\n    Object ret = val;\n    if(count == INFINITE) {\n        while(true){\n            ret = f.invoke(ret, val);\n            if(RT.isReduced(ret))\n                return ((IDeref)ret).deref();\n        }\n    } else {\n        for(long i=1; i<count; i++) {\n            ret = f.invoke(ret, val);\n            if(RT.isReduced(ret))\n                return ((IDeref)ret).deref();\n        }\n        return ret;\n    }\n}\n\npublic Object reduce(IFn f, Object start){\n    Object ret = start;\n    if(count == INFINITE){\n        while(true){\n            ret = f.invoke(ret, val);\n            if(RT.isReduced(ret))\n                return ((IDeref)ret).deref();\n        }\n    } else {\n        for(long i=0; i<count; i++){\n            ret = f.invoke(ret, val);\n            if(RT.isReduced(ret))\n                return ((IDeref)ret).deref();\n        }\n        return ret;\n    }\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/RestFn.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\npackage clojure.lang;\n\npublic abstract class RestFn extends AFunction{\nabstract public int getRequiredArity();\n\nprotected Object doInvoke(Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object args)\n\t\t{\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object args)\n\t\t{\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object arg9, Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object arg9, Object arg10, Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object arg9, Object arg10, Object arg11, Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object args)\n\t\t{\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object args)\n\t\t{\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,\n                          Object arg14, Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,\n                          Object arg14, Object arg15, Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,\n                          Object arg14, Object arg15, Object arg16, Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,\n                          Object arg14, Object arg15, Object arg16, Object arg17, Object args) {\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,\n                          Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object args)\n\t\t{\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,\n                          Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19,\n                          Object args)\n\t\t{\n\treturn null;\n}\n\nprotected Object doInvoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                          Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13,\n                          Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19,\n                          Object arg20, Object args) {\n\treturn null;\n}\n\n\npublic Object applyTo(ISeq args) {\n\tif(RT.boundedLength(args, getRequiredArity()) <= getRequiredArity())\n\t\t{\n\t\treturn AFn.applyToHelper(this, Util.ret1(args,args = null));\n\t\t}\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(Util.ret1(args,args = null));\n\t\tcase 1:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 2:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 3:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 4:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 5:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 6:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 7:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 8:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 9:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 10:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 11:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 12:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 13:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 14:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 15:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 16:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 17:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 18:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 19:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\t\tcase 20:\n\t\t\treturn doInvoke(args.first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, (args = args.next()).first()\n\t\t\t\t\t, Util.ret1(args.next(),args=null));\n\n\t\t}\n\treturn throwArity(-1);\n}\n\npublic Object invoke() {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(null);\n\t\tdefault:\n\t\t\treturn throwArity(0);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(Util.ret1(arg1, arg1 = null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), null);\n\t\tdefault:\n\t\t\treturn throwArity(1);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), ArraySeq.create(Util.ret1(arg2, arg2 = null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), null);\n\t\tdefault:\n\t\t\treturn throwArity(2);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n\t\t\t                                Util.ret1(arg3, arg3 = null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg3, arg3 = null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                null);\n\t\tdefault:\n\t\t\treturn throwArity(3);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n\t\t\t                                Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                                Util.ret1(arg4, arg4 = null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg4, arg4 = null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                Util.ret1(arg4, arg4 = null), null);\n\t\tdefault:\n\t\t\treturn throwArity(4);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n\t\t\t                                Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n\t\t\t                                Util.ret1(arg5, arg5 = null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                                Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n\t\t\t                                Util.ret1(arg5, arg5 = null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                Util.ret1(arg4, arg4 = null), ArraySeq.create(Util.ret1(arg5, arg5 = null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null), null);\n\t\tdefault:\n\t\t\treturn throwArity(5);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n\t\t\t                                Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n\t\t\t                                Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                                Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null),\n\t\t\t                                Util.ret1(arg6, arg6 = null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg3, arg3 = null), Util.ret1(arg4, arg4 = null),\n\t\t\t                                Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null),\n\t\t\t                                Util.ret1(arg6, arg6 = null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                Util.ret1(arg4, arg4 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null),\n\t\t\t                ArraySeq.create(Util.ret1(arg6, arg6 = null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(Util.ret1(arg1, arg1 = null), Util.ret1(arg2, arg2 = null), Util.ret1(arg3, arg3 = null),\n\t\t\t                Util.ret1(arg4, arg4 = null), Util.ret1(arg5, arg5 = null), Util.ret1(arg6, arg6 = null),\n\t\t\t                null);\n\t\tdefault:\n\t\t\treturn throwArity(6);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)\n\t\t{\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(Util.ret1(arg1,arg1=null), \n                                                        Util.ret1(arg2,arg2=null), \n                                                        Util.ret1(arg3,arg3=null), \n                                                        Util.ret1(arg4,arg4=null), \n                                                        Util.ret1(arg5,arg5=null), \n                                                        Util.ret1(arg6,arg6=null), \n                                                        Util.ret1(arg7,arg7=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), ArraySeq.create(Util.ret1(arg2,arg2=null), \n                                                                                   Util.ret1(arg3,arg3=null), \n                                                                                   Util.ret1(arg4,arg4=null), \n                                                                                   Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), ArraySeq.create(Util.ret1(arg3,arg3=null), \n                                                                                   Util.ret1(arg4,arg4=null), \n                                                                                   Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), ArraySeq.create(Util.ret1(arg4,arg4=null), \n                                                                                   Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), ArraySeq.create(Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), ArraySeq.create(Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), \n                                        Util.ret1(arg6,arg6=null), ArraySeq.create(Util.ret1(arg7,arg7=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), \n                                        Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(7);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(Util.ret1(arg1,arg1=null), \n                                                        Util.ret1(arg2,arg2=null), \n                                                        Util.ret1(arg3,arg3=null), \n                                                        Util.ret1(arg4,arg4=null), \n                                                        Util.ret1(arg5,arg5=null), \n                                                        Util.ret1(arg6,arg6=null), \n                                                        Util.ret1(arg7,arg7=null), \n                                                        Util.ret1(arg8,arg8=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), ArraySeq.create(Util.ret1(arg2,arg2=null), \n                                                                                   Util.ret1(arg3,arg3=null), \n                                                                                   Util.ret1(arg4,arg4=null), \n                                                                                   Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), ArraySeq.create(Util.ret1(arg3,arg3=null), \n                                                                                   Util.ret1(arg4,arg4=null), \n                                                                                   Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), ArraySeq.create(Util.ret1(arg4,arg4=null), \n                                                                                   Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), ArraySeq.create(Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), ArraySeq.create(Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), \n                                        Util.ret1(arg6,arg6=null), ArraySeq.create(Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), \n                                        Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), ArraySeq.create(Util.ret1(arg8,arg8=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), \n                                        Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), \n                                        Util.ret1(arg8,arg8=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(8);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(Util.ret1(arg1,arg1=null), \n                                                        Util.ret1(arg2,arg2=null), \n                                                        Util.ret1(arg3,arg3=null), \n                                                        Util.ret1(arg4,arg4=null), \n                                                        Util.ret1(arg5,arg5=null), \n                                                        Util.ret1(arg6,arg6=null), \n                                                        Util.ret1(arg7,arg7=null), \n                                                        Util.ret1(arg8,arg8=null), \n                                                        Util.ret1(arg9,arg9=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), ArraySeq.create(Util.ret1(arg2,arg2=null), \n                                                                                   Util.ret1(arg3,arg3=null), \n                                                                                   Util.ret1(arg4,arg4=null), \n                                                                                   Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), ArraySeq.create(Util.ret1(arg3,arg3=null), \n                                                                                   Util.ret1(arg4,arg4=null), \n                                                                                   Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), ArraySeq.create(Util.ret1(arg4,arg4=null), \n                                                                                   Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), ArraySeq.create(Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), ArraySeq.create(Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), \n                                        Util.ret1(arg6,arg6=null), ArraySeq.create(Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), \n                                        Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), ArraySeq.create(Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), \n                                        Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), \n                                        Util.ret1(arg8,arg8=null), ArraySeq.create(Util.ret1(arg9,arg9=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), \n                                        Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), \n                                        Util.ret1(arg8,arg8=null), \n                                        Util.ret1(arg9,arg9=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(9);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(Util.ret1(arg1,arg1=null), \n                                                        Util.ret1(arg2,arg2=null), \n                                                        Util.ret1(arg3,arg3=null), \n                                                        Util.ret1(arg4,arg4=null), \n                                                        Util.ret1(arg5,arg5=null), \n                                                        Util.ret1(arg6,arg6=null), \n                                                        Util.ret1(arg7,arg7=null), \n                                                        Util.ret1(arg8,arg8=null), \n                                                        Util.ret1(arg9,arg9=null), \n                                                        Util.ret1(arg10,arg10=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), ArraySeq.create(Util.ret1(arg2,arg2=null), \n                                                                                   Util.ret1(arg3,arg3=null), \n                                                                                   Util.ret1(arg4,arg4=null), \n                                                                                   Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null), \n                                                                                   Util.ret1(arg10,arg10=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), ArraySeq.create(Util.ret1(arg3,arg3=null), \n                                                                                   Util.ret1(arg4,arg4=null), \n                                                                                   Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null), \n                                                                                   Util.ret1(arg10,arg10=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), ArraySeq.create(Util.ret1(arg4,arg4=null), \n                                                                                   Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null), \n                                                                                   Util.ret1(arg10,arg10=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), ArraySeq.create(Util.ret1(arg5,arg5=null), \n                                                                                   Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null), \n                                                                                   Util.ret1(arg10,arg10=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), ArraySeq.create(Util.ret1(arg6,arg6=null), \n                                                                                   Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null), \n                                                                                   Util.ret1(arg10,arg10=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), \n                                        Util.ret1(arg6,arg6=null), ArraySeq.create(Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null), \n                                                                                   Util.ret1(arg10,arg10=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), \n                                        Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), ArraySeq.create(Util.ret1(arg8,arg8=null), \n                                                                                   Util.ret1(arg9,arg9=null), \n                                                                                   Util.ret1(arg10,arg10=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), \n                                        Util.ret1(arg2,arg2=null), \n                                        Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), \n                                        Util.ret1(arg5,arg5=null), \n                                        Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), \n                                        Util.ret1(arg8,arg8=null), ArraySeq.create(Util.ret1(arg9,arg9=null), \n                                                                                   Util.ret1(arg10,arg10=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), ArraySeq.create(\n Util.ret1(arg10,arg10=null)));\n\t\tcase 10:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(10);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), ArraySeq.create(\n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), ArraySeq.create(\n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), ArraySeq.create(\n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), ArraySeq.create(\n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), ArraySeq.create(\n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), ArraySeq.create(\n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), ArraySeq.create(\n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), ArraySeq.create(\n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), ArraySeq.create(\n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null)));\n\t\tcase 10:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), ArraySeq.create(\n Util.ret1(arg11,arg11=null)));\n\t\tcase 11:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(11);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), ArraySeq.create(\n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), ArraySeq.create(\n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), ArraySeq.create(\n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), ArraySeq.create(\n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), ArraySeq.create(\n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), ArraySeq.create(\n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), ArraySeq.create(\n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), ArraySeq.create(\n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), ArraySeq.create(\n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null)));\n\t\tcase 10:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), ArraySeq.create(\n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null)));\n\t\tcase 11:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), ArraySeq.create(\n Util.ret1(arg12,arg12=null)));\n\t\tcase 12:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(12);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13)\n\t\t{\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(\n\t\t\t\t\tArraySeq.create(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), ArraySeq.create(\n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                      \n Util.ret1(arg13,arg13=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null)));\n\t\tcase 10:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null)));\n\t\tcase 11:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null)));\n\t\tcase 12:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg13,arg13=null)));\n\t\tcase 13:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(13);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)\n\t\t{\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), ArraySeq.create(\n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                      \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), ArraySeq.create(\n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                            \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 10:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 11:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 12:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null)));\n\t\tcase 13:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg14,arg14=null)));\n\t\tcase 14:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                null);\n\t\tdefault:\n\t\t\treturn throwArity(14);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), ArraySeq.create(\n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                      \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), ArraySeq.create(\n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                            \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), ArraySeq.create(\n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                  \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 10:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 11:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 12:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 13:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null)));\n\t\tcase 14:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg15,arg15=null)));\n\t\tcase 15:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(15);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), ArraySeq.create(\n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                      \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), ArraySeq.create(\n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                            \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), ArraySeq.create(\n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                  \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), ArraySeq.create(\n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                        \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 10:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 11:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 12:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 13:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 14:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null)));\n\t\tcase 15:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), ArraySeq.create(\n Util.ret1(arg16,arg16=null)));\n\t\tcase 16:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(16);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), ArraySeq.create(\n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                      \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), ArraySeq.create(\n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                            \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), ArraySeq.create(\n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                  \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), ArraySeq.create(\n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                        \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), ArraySeq.create(\n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                              \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 10:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 11:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 12:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 13:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 14:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 15:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), ArraySeq.create(\n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null)));\n\t\tcase 16:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), ArraySeq.create(\n Util.ret1(arg17,arg17=null)));\n\t\tcase 17:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(17);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), ArraySeq.create(\n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                      \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), ArraySeq.create(\n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                            \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), ArraySeq.create(\n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                  \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), ArraySeq.create(\n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                        \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), ArraySeq.create(\n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                              \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), ArraySeq.create(\n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                                    \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null),\n\t\t\t                                                                    \n Util.ret1(arg18,arg18=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 10:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 11:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 12:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 13:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 14:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 15:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), ArraySeq.create(\n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 16:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), ArraySeq.create(\n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null)));\n\t\tcase 17:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), ArraySeq.create(\n Util.ret1(arg18,arg18=null)));\n\t\tcase 18:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(18);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19) {\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 1:\n                    ISeq packed = PersistentList.EMPTY;\n\t\t\treturn doInvoke(\n                                        Util.ret1(arg1,arg1=null), ArraySeq.create(Util.ret1(arg2,arg2=null),\n                    Util.ret1(arg3,arg3=null),\n                    Util.ret1(arg4,arg4=null),\n                    Util.ret1(arg5,arg5=null),\n                    Util.ret1(arg6,arg6=null),\n                    Util.ret1(arg7,arg7=null),\n                    Util.ret1(arg8,arg8=null),\n                    Util.ret1(arg9,arg9=null),\n                    Util.ret1(arg10,arg10=null),\n                    Util.ret1(arg11,arg11=null),\n                    Util.ret1(arg12,arg12=null),\n                    Util.ret1(arg13,arg13=null),\n                    Util.ret1(arg14,arg14=null),\n                    Util.ret1(arg15,arg15=null),\n                    Util.ret1(arg16,arg16=null),\n                    Util.ret1(arg17,arg17=null),\n                    Util.ret1(arg18,arg18=null),\n                    Util.ret1(arg19,arg19=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), ArraySeq.create(\n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                            \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), ArraySeq.create(\n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                  \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), ArraySeq.create(\n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                        \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), ArraySeq.create(\n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                              \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null),\n\t\t\t                                                              \n Util.ret1(arg19,arg19=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), ArraySeq.create(\n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                                    \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null),\n\t\t\t                                                                    \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), ArraySeq.create(\n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                                          \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null),\n\t\t\t                                                                          \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), ArraySeq.create(\n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                                                                \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null),\n\t\t\t                                                                                \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 10:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 11:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 12:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 13:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 14:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                ArraySeq.create(\n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 15:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), ArraySeq.create(\n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 16:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), ArraySeq.create(\n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 17:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), ArraySeq.create(\n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null)));\n\t\tcase 18:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), ArraySeq.create(\n Util.ret1(arg19,arg19=null)));\n\t\tcase 19:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null), \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null),\n\t\t\t                \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(19);\n\t\t}\n\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20)\n\t\t{\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ArraySeq.create(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null), \n Util.ret1(arg20,arg20=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), ArraySeq.create(\n Util.ret1(arg2,arg2=null), \n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                      \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null), \n Util.ret1(arg20,arg20=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(\n Util.ret1(arg1,arg1=null), \n Util.ret1(arg2,arg2=null), ArraySeq.create(\n Util.ret1(arg3,arg3=null), \n Util.ret1(arg4,arg4=null), \n Util.ret1(arg5,arg5=null), \n Util.ret1(arg6,arg6=null), \n Util.ret1(arg7,arg7=null), \n Util.ret1(arg8,arg8=null), \n Util.ret1(arg9,arg9=null), \n Util.ret1(arg10,arg10=null), \n Util.ret1(arg11,arg11=null), \n Util.ret1(arg12,arg12=null),\n\t\t\t                                            \n Util.ret1(arg13,arg13=null), \n Util.ret1(arg14,arg14=null), \n Util.ret1(arg15,arg15=null), \n Util.ret1(arg16,arg16=null), \n Util.ret1(arg17,arg17=null), \n Util.ret1(arg18,arg18=null), \n Util.ret1(arg19,arg19=null), \n Util.ret1(arg20,arg20=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        ArraySeq.create(Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null),\n                                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                        Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                        Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), ArraySeq.create(Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), Util.ret1(arg7,arg7=null), \n                                                                                   Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), Util.ret1(arg10,arg10=null), \n                                                                                   Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), Util.ret1(arg13,arg13=null), \n                                                                                   Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), Util.ret1(arg16,arg16=null), \n                                                                                   Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null),\n                                                                                   Util.ret1(arg20,arg20=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), ArraySeq.create(Util.ret1(arg6,arg6=null), Util.ret1(arg7,arg7=null), \n                                                                                                              Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                                                                                              Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), \n                                                                                                              Util.ret1(arg12,arg12=null), Util.ret1(arg13,arg13=null), \n                                                                                                              Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                                                                              Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), \n                                                                                                              Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null), \n                                                                                                              Util.ret1(arg20,arg20=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        ArraySeq.create(Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null),\n                                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                        Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                        Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), ArraySeq.create(Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                                                                   Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), \n                                                                                   Util.ret1(arg12,arg12=null), Util.ret1(arg13,arg13=null), \n                                                                                   Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                                                   Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null),\n                                                                                   Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null), \n                                                                                   Util.ret1(arg20,arg20=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(\n                                        Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), ArraySeq.create(Util.ret1(arg9,arg9=null), Util.ret1(arg10,arg10=null), \n                                                                                                              Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null),\n                                                                                                              Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), \n                                                                                                              Util.ret1(arg15,arg15=null), Util.ret1(arg16,arg16=null),\n                                                                                                              Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                                                                              Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        ArraySeq.create(Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null),\n                                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null),\n                                                        Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null),\n                                                        Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 10:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), ArraySeq.create(Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                                                                     Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), \n                                                                                     Util.ret1(arg15,arg15=null), Util.ret1(arg16,arg16=null), \n                                                                                     Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                                                     Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 11:\n\t\t\treturn doInvoke(\n                                        Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), ArraySeq.create(Util.ret1(arg12,arg12=null), Util.ret1(arg13,arg13=null), \n                                                                                                                  Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                                                                                  Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), \n                                                                                                                  Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null), \n Util.ret1(arg20,arg20=null)));\n\t\tcase 12:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null),\n\t\t\t                ArraySeq.create(Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                        Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                        Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 13:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), ArraySeq.create(Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                                                     Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), \n                                                                                     Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null), \n                                                                                     Util.ret1(arg20,arg20=null)));\n\t\tcase 14:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), ArraySeq.create(Util.ret1(arg15,arg15=null), Util.ret1(arg16,arg16=null), \n                                                                                                                  Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                                                                                  Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 15:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null),\n                                        ArraySeq.create(Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                        Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 16:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                        Util.ret1(arg16,arg16=null), ArraySeq.create(Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                                                     Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 17:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                        Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), ArraySeq.create(Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null), \n                                                                                                                  Util.ret1(arg20,arg20=null)));\n\t\tcase 18:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                        Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                        ArraySeq.create(Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 19:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                        Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                        Util.ret1(arg19,arg19=null), ArraySeq.create(Util.ret1(arg20,arg20=null)));\n\t\tcase 20:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                        Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                        Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null), null);\n\t\tdefault:\n\t\t\treturn throwArity(20);\n\t\t}\n        \n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20, Object... args)\n\t\t{\n\tswitch(getRequiredArity())\n\t\t{\n\t\tcase 0:\n\t\t\treturn doInvoke(ontoArrayPrepend(args, Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                                         Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                                         Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null),\n                                                         Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                                         Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null),\n                                                         Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                         Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 1:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), ontoArrayPrepend(args, Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                                                                    Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), \n                                                                                    Util.ret1(arg6,arg6=null), Util.ret1(arg7,arg7=null), \n                                                                                    Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                                                                    Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null),\n                                                                                    Util.ret1(arg12,arg12=null), Util.ret1(arg13,arg13=null), \n                                                                                    Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                                                    Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), \n                                                                                    Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null), \n                                                                                    Util.ret1(arg20,arg20=null)));\n\t\tcase 2:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), ontoArrayPrepend(args, Util.ret1(arg3,arg3=null), \n                                                                                                               Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), \n                                                                                                               Util.ret1(arg6,arg6=null), Util.ret1(arg7,arg7=null), \n                                                                                                               Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                                                                                               Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null),\n                                                                                                               Util.ret1(arg12,arg12=null), Util.ret1(arg13,arg13=null), \n                                                                                                               Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                                                                               Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), \n                                                                                                               Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null),\n                                                                                                               Util.ret1(arg20,arg20=null)));\n\t\tcase 3:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        ontoArrayPrepend(args, Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                                         Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                                         Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                                         Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                         Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                         Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 4:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), ontoArrayPrepend(args, Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), Util.ret1(arg7,arg7=null), \n                                                                                    Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), Util.ret1(arg10,arg10=null), \n                                                                                    Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), Util.ret1(arg13,arg13=null),\n                                                                                    Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), Util.ret1(arg16,arg16=null), \n                                                                                    Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null), \n                                                                                    Util.ret1(arg20,arg20=null)));\n\t\tcase 5:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null),\n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), ontoArrayPrepend(args, Util.ret1(arg6,arg6=null), Util.ret1(arg7,arg7=null), \n                                                                                                               Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                                                                                               Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null),\n                                                                                                               Util.ret1(arg12,arg12=null), Util.ret1(arg13,arg13=null), \n                                                                                                               Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                                                                               Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null),\n                                                                                                               Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null), \n                                                                                                               Util.ret1(arg20,arg20=null)));\n\t\tcase 6:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        ontoArrayPrepend(args, Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                                         Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                                         Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                         Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                         Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 7:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null),\n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), ontoArrayPrepend(args, Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                                                                    Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null),\n                                                                                    Util.ret1(arg12,arg12=null), Util.ret1(arg13,arg13=null), \n                                                                                    Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null),\n                                                                                    Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), \n                                                                                    Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null),\n                                                                                    Util.ret1(arg20,arg20=null)));\n\t\tcase 8:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), ontoArrayPrepend(args, Util.ret1(arg9,arg9=null), Util.ret1(arg10,arg10=null), \n                                                                                                               Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                                                                                               Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), \n                                                                                                               Util.ret1(arg15,arg15=null), Util.ret1(arg16,arg16=null), \n                                                                                                               Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                                                                               Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 9:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        ontoArrayPrepend(args, Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                                         Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                         Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                         Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 10:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), ontoArrayPrepend(args, Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                                                                      Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), \n                                                                                      Util.ret1(arg15,arg15=null), Util.ret1(arg16,arg16=null), \n                                                                                      Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                                                      Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 11:\n\t\t\treturn doInvoke(\n                                        Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), ontoArrayPrepend(args, Util.ret1(arg12,arg12=null), Util.ret1(arg13,arg13=null), \n                                                                                                                   Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                                                                                   Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), \n                                                                                                                   Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null), \n                                                                                                                   Util.ret1(arg20,arg20=null)));\n\t\tcase 12:\n\t\t\treturn doInvoke(\n                                        Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null),\n                                        ontoArrayPrepend(args, Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                         Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                         Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 13:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), ontoArrayPrepend(args, Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                                                                      Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), \n                                                                                      Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null), \n                                                                                      Util.ret1(arg20,arg20=null)));\n\t\tcase 14:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), ontoArrayPrepend(args, Util.ret1(arg15,arg15=null), Util.ret1(arg16,arg16=null), \n                                                                                                                   Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                                                                                   Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 15:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                        ontoArrayPrepend(args, Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                         Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 16:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                        Util.ret1(arg16,arg16=null), ontoArrayPrepend(args, Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                                                                      Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 17:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                        Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), ontoArrayPrepend(args, Util.ret1(arg18,arg18=null), Util.ret1(arg19,arg19=null), \n                                                                                                                   Util.ret1(arg20,arg20=null)));\n\t\tcase 18:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                        Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                        ontoArrayPrepend(args, Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null)));\n\t\tcase 19:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                        Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                        Util.ret1(arg19,arg19=null), ontoArrayPrepend(args, Util.ret1(arg20,arg20=null)));\n\t\tcase 20:\n\t\t\treturn doInvoke(Util.ret1(arg1,arg1=null), Util.ret1(arg2,arg2=null), Util.ret1(arg3,arg3=null), \n                                        Util.ret1(arg4,arg4=null), Util.ret1(arg5,arg5=null), Util.ret1(arg6,arg6=null), \n                                        Util.ret1(arg7,arg7=null), Util.ret1(arg8,arg8=null), Util.ret1(arg9,arg9=null), \n                                        Util.ret1(arg10,arg10=null), Util.ret1(arg11,arg11=null), Util.ret1(arg12,arg12=null), \n                                        Util.ret1(arg13,arg13=null), Util.ret1(arg14,arg14=null), Util.ret1(arg15,arg15=null), \n                                        Util.ret1(arg16,arg16=null), Util.ret1(arg17,arg17=null), Util.ret1(arg18,arg18=null), \n                                        Util.ret1(arg19,arg19=null), Util.ret1(arg20,arg20=null), ArraySeq.create(args));\n\t\tdefault:\n\t\t\treturn throwArity(21);\n\t\t}\n\n}\n\n\nprotected static ISeq ontoArrayPrepend(Object[] array, Object... args){\n\tISeq ret = ArraySeq.create(array);\n\tfor(int i = args.length - 1; i >= 0; --i)\n\t\tret = RT.cons(args[i], ret);\n\treturn ret;\n}\n\nprotected static ISeq findKey(Object key, ISeq args){\n\twhile(args != null)\n\t\t{\n\t\tif(key == args.first())\n\t\t\treturn args.next();\n\t\targs = RT.next(args);\n\t\targs = RT.next(args);\n\t\t}\n\treturn null;\n}\n\n\n}\n\n"
  },
  {
    "path": "src/jvm/clojure/lang/RestFnWithMeta.java",
    "content": "package clojure.lang;\n\npublic class RestFnWithMeta extends RestFn {\n\n  final AFunction aFunction;\n  final IPersistentMap meta;\n\n  public RestFnWithMeta(AFunction aFunction, IPersistentMap meta) {\n    this.aFunction = aFunction;\n    this.meta = meta;\n  }\n\n  protected Object doInvoke(Object args) {\n    return aFunction.applyTo((ISeq) args);\n  }\n\n  public IPersistentMap meta() {\n    return meta;\n  }\n\n  public IObj withMeta(IPersistentMap meta) {\n    return aFunction.withMeta(meta);\n  }\n\n  public int getRequiredArity() {\n    return 0;\n  }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Reversible.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jan 5, 2008 */\n\npackage clojure.lang;\n\npublic interface Reversible{\nISeq rseq() ;\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Selector.java",
    "content": "package clojure.lang;\n\n/*-[\n#import \"NSCommon.h\"\n]-*/\n\npublic class Selector extends RestFn implements Named {\n\n  public static Object invokeSelector(String sel, Object o) {\n    return invokeSelector(sel, o, null);\n  }\n  \n  public static Object invokeSelector(String sel, Object o, Object args) {\n    if (!ObjC.objc) {\n      return RemoteRepl.callRemote(new Selector(sel), RT.cons(o, args));\n    } else {\n      if (o == null) {\n        throw new NullPointerException();\n      }\n      if (args != null && !sel.endsWith(\":\")) {\n        sel = sel + \":\";\n      }\n      return invokeSel(o, sel, RT.seq(args));\n    }\n  }\n  \n  public final String sel;\n\n  public Selector(Symbol sel) {\n    this.sel = sel.name;\n  }\n  \n  public Selector(String sel) {\n    this.sel = sel;\n  }\n\n  @Override\n  public String getNamespace() {\n    return null;\n  }\n\n  @Override\n  public String getName() {\n    return sel;\n  }\n  \n  @Override\n  protected Object doInvoke(Object o, Object args) {\n    return invokeSelector(sel, o, args);\n  }\n  \n  public static native Object invokeSel(Object object, String selector,\n      ISeq arguments) /*-[\n   return [NSCommon invokeSel:object withSelector:selector withArgs:arguments];\n  ]-*/;\n  \n  @Override\n  public int getRequiredArity() {\n    return 1;\n  }\n  \n  @Override\n  public String toString() {\n    return sel;\n  }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/SeqEnumeration.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 3, 2008 */\n\npackage clojure.lang;\n\nimport java.util.Enumeration;\n\npublic class SeqEnumeration implements Enumeration{\nISeq seq;\n\npublic SeqEnumeration(ISeq seq){\n\tthis.seq = seq;\n}\n\npublic boolean hasMoreElements(){\n\treturn seq != null;\n}\n\npublic Object nextElement(){\n\tObject ret = RT.first(seq);\n\tseq = RT.next(seq);\n\treturn ret;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/SeqIterator.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jun 19, 2007 */\n\npackage clojure.lang;\n\nimport java.util.Iterator;\nimport java.util.NoSuchElementException;\n\npublic class SeqIterator implements Iterator{\n\nstatic final Object START = new Object();\nObject seq;\nObject next;\n\npublic SeqIterator(Object o){\n\tseq = START;\n\tnext = o;\n}\n\n//preserved for binary compatibility\npublic SeqIterator(ISeq o){\n\tseq = START;\n\tnext = o;\n}\n\npublic boolean hasNext(){\n\tif(seq == START){\n\t\tseq = null;\n\t\tnext = RT.seq(next);\n\t\t}\n\telse if(seq == next)\n\t\tnext = RT.next(seq);\n\treturn next != null;\n}\n\npublic Object next() throws NoSuchElementException {\n\tif(!hasNext())\n\t\tthrow new NoSuchElementException();\n\tseq = next;\n\treturn RT.first(next);\n}\n\npublic void remove(){\nthrow new UnsupportedOperationException();\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Seqable.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jan 28, 2009 */\n\npackage clojure.lang;\n\npublic interface Seqable {\n    ISeq seq();\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Sequential.java",
    "content": "package clojure.lang;\r\n\r\n/**\r\n * Copyright (c) Rich Hickey. All rights reserved.\r\n * The use and distribution terms for this software are covered by the\r\n * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\r\n * which can be found in the file epl-v10.html at the root of this distribution.\r\n * By using this software in any fashion, you are agreeing to be bound by\r\n * the terms of this license.\r\n * You must not remove this notice, or any other, from this software.\r\n */\r\npublic interface Sequential {\r\n}\r\n"
  },
  {
    "path": "src/jvm/clojure/lang/Settable.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Dec 31, 2008 */\n\npackage clojure.lang;\n\npublic interface Settable {\n    Object doSet(Object val) ;\n    Object doReset(Object val) ;\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Sorted.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Apr 15, 2008 */\n\npackage clojure.lang;\n\nimport java.util.Comparator;\n\npublic interface Sorted{\nComparator comparator();\n\nObject entryKey(Object entry);\n\nISeq seq(boolean ascending);\n\nISeq seqFrom(Object key, boolean ascending);\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/SourceGenIntrinsics.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich 9/5/11 */\n\npackage clojure.lang;\n\nimport clojure.asm.Opcodes;\n\npublic class SourceGenIntrinsics implements Opcodes{\nstatic IPersistentMap ops = RT.map(\n \"public static double clojure.lang.Numbers.add(double,double)\", \"+\",\n \"public static long clojure.lang.Numbers.and(long,long)\", \"&\",\n \"public static long clojure.lang.Numbers.or(long,long)\", \"|\",\n \"public static long clojure.lang.Numbers.xor(long,long)\", \"^\",\n \"public static double clojure.lang.Numbers.multiply(double,double)\", \"*\",\n \"public static double clojure.lang.Numbers.divide(double,double)\", \"/\",\n \"public static long clojure.lang.Numbers.remainder(long,long)\", \"%\",\n \"public static long clojure.lang.Numbers.shiftLeft(long,long)\", \"<<\",\n \"public static long clojure.lang.Numbers.shiftRight(long,long)\", \">>\",\n \"public static long clojure.lang.Numbers.unsignedShiftRight(long,long)\", \">>>\",\n \"public static double clojure.lang.Numbers.minus(double)\", \"-\",\n \"public static double clojure.lang.Numbers.minus(double,double)\", \"-\",\n \"public static double clojure.lang.Numbers.inc(double)\", \"1+\",\n \"public static double clojure.lang.Numbers.dec(double)\", \"(-1)+\",\n \"public static long clojure.lang.Numbers.quotient(long,long)\", \"/\",\n \"public static int clojure.lang.Numbers.shiftLeftInt(int,int)\", \"<<\",\n \"public static int clojure.lang.Numbers.shiftRightInt(int,int)\", \">>\",\n \"public static int clojure.lang.Numbers.unsignedShiftRightInt(int,int)\", \">>>\",\n \"public static int clojure.lang.Numbers.unchecked_int_add(int,int)\", \"+\",\n \"public static int clojure.lang.Numbers.unchecked_int_subtract(int,int)\", \"-\",\n \"public static int clojure.lang.Numbers.unchecked_int_negate(int)\", \"-\",\n \"public static int clojure.lang.Numbers.unchecked_int_inc(int)\", \"+\",\n \"public static int clojure.lang.Numbers.unchecked_int_dec(int)\", \"-\",\n \"public static int clojure.lang.Numbers.unchecked_int_multiply(int,int)\", \"*\",\n \"public static int clojure.lang.Numbers.unchecked_int_divide(int,int)\", \"/\",\n \"public static int clojure.lang.Numbers.unchecked_int_remainder(int,int)\", \"%\",\n \"public static long clojure.lang.Numbers.unchecked_add(long,long)\", \"+\",\n \"public static double clojure.lang.Numbers.unchecked_add(double,double)\", \"+\",\n \"public static long clojure.lang.Numbers.unchecked_minus(long)\", \"-\",\n \"public static double clojure.lang.Numbers.unchecked_minus(double)\", \"-\",\n \"public static double clojure.lang.Numbers.unchecked_minus(double,double)\", \"-\",\n \"public static long clojure.lang.Numbers.unchecked_minus(long,long)\", \"-\",\n \"public static long clojure.lang.Numbers.unchecked_multiply(long,long)\", \"*\",\n \"public static double clojure.lang.Numbers.unchecked_multiply(double,double)\", \"*\",\n \"public static double clojure.lang.Numbers.unchecked_inc(double)\", \"1+\",\n \"public static long clojure.lang.Numbers.unchecked_inc(long)\", \"1+\",\n \"public static double clojure.lang.Numbers.unchecked_dec(double)\", \"(-1)+\",\n \"public static long clojure.lang.Numbers.unchecked_dec(long)\", \"(-1)+\",\n\n\n  \"public static short clojure.lang.RT.aget(short[],int)\", \"aget[]\",\n  \"public static float clojure.lang.RT.aget(float[],int)\", \"aget[]\",\n  \"public static double clojure.lang.RT.aget(double[],int)\", \"aget[]\",\n  \"public static int clojure.lang.RT.aget(int[],int)\", \"aget[]\",\n  \"public static long clojure.lang.RT.aget(long[],int)\", \"aget[]\",\n  \"public static char clojure.lang.RT.aget(char[],int)\", \"aget[]\",\n  \"public static byte clojure.lang.RT.aget(byte[],int)\", \"aget[]\",\n  \"public static boolean clojure.lang.RT.aget(boolean[],int)\", \"aget[]\",\n  \"public static java.lang.Object clojure.lang.RT.aget(java.lang.Object[],int)\", \"aget[]\",\n  \"public static int clojure.lang.RT.alength(int[])\", \"alength[]\",\n  \"public static int clojure.lang.RT.alength(long[])\", \"alength[]\",\n  \"public static int clojure.lang.RT.alength(char[])\", \"alength[]\",\n  \"public static int clojure.lang.RT.alength(java.lang.Object[])\", \"alength[]\",\n  \"public static int clojure.lang.RT.alength(byte[])\", \"alength[]\",\n  \"public static int clojure.lang.RT.alength(float[])\", \"alength[]\",\n  \"public static int clojure.lang.RT.alength(short[])\", \"alength[]\",\n  \"public static int clojure.lang.RT.alength(boolean[])\", \"alength[]\",\n  \"public static int clojure.lang.RT.alength(double[])\", \"alength[]\",\n\n \"public static double clojure.lang.RT.doubleCast(long)\", \"(double)\",\n \"public static double clojure.lang.RT.doubleCast(double)\", \"\",\n \"public static double clojure.lang.RT.doubleCast(float)\", \"(double)\",\n \"public static double clojure.lang.RT.doubleCast(int)\", \"(double)\",\n \"public static double clojure.lang.RT.doubleCast(short)\", \"(double)\",\n \"public static double clojure.lang.RT.doubleCast(byte)\", \"(double)\",\n \"public static double clojure.lang.RT.uncheckedDoubleCast(double)\", \"(double)\",\n \"public static double clojure.lang.RT.uncheckedDoubleCast(float)\", \"(double)\",\n \"public static double clojure.lang.RT.uncheckedDoubleCast(long)\", \"(double)\",\n \"public static double clojure.lang.RT.uncheckedDoubleCast(int)\", \"(double)\",\n \"public static double clojure.lang.RT.uncheckedDoubleCast(short)\", \"(double)\",\n \"public static double clojure.lang.RT.uncheckedDoubleCast(byte)\", \"(double)\",\n \"public static long clojure.lang.RT.longCast(long)\", \"\",\n \"public static long clojure.lang.RT.longCast(short)\", \"(long)\",\n \"public static long clojure.lang.RT.longCast(byte)\", \"(long)\",\n \"public static long clojure.lang.RT.longCast(int)\", \"(long)\",\n  \"public static int clojure.lang.RT.uncheckedIntCast(long)\", \"(int)\",\n  \"public static int clojure.lang.RT.uncheckedIntCast(double)\", \"(int)\",\n  \"public static int clojure.lang.RT.uncheckedIntCast(byte)\", \"\",\n  \"public static int clojure.lang.RT.uncheckedIntCast(short)\", \"\",\n  \"public static int clojure.lang.RT.uncheckedIntCast(char)\", \"\",\n  \"public static int clojure.lang.RT.uncheckedIntCast(int)\", \"\",\n  \"public static int clojure.lang.RT.uncheckedIntCast(float)\", \"(int)\",\n  \"public static long clojure.lang.RT.uncheckedLongCast(short)\", \"(long)\",\n  \"public static long clojure.lang.RT.uncheckedLongCast(float)\", \"(long)\",\n  \"public static long clojure.lang.RT.uncheckedLongCast(double)\", \"(long)\",\n  \"public static long clojure.lang.RT.uncheckedLongCast(byte)\", \"(long)\",\n  \"public static long clojure.lang.RT.uncheckedLongCast(long)\", \"\",\n  \"public static long clojure.lang.RT.uncheckedLongCast(int)\", \"(long)\"\n);\n\n//map to instructions terminated with comparator for branch to false\nstatic IPersistentMap preds = RT.map(\n  \"public static boolean clojure.lang.Numbers.lt(double,double)\", \"<\",\n  \"public static boolean clojure.lang.Numbers.lt(long,long)\", \"<\",\n  \"public static boolean clojure.lang.Numbers.equiv(double,double)\", \"==\",\n  \"public static boolean clojure.lang.Numbers.equiv(long,long)\", \"==\",\n  \"public static boolean clojure.lang.Numbers.lte(double,double)\", \"<=\",\n  \"public static boolean clojure.lang.Numbers.lte(long,long)\", \"<=\",\n  \"public static boolean clojure.lang.Numbers.gt(long,long)\", \">\",\n  \"public static boolean clojure.lang.Numbers.gt(double,double)\", \">\",\n  \"public static boolean clojure.lang.Numbers.gte(long,long)\", \">=\",\n  \"public static boolean clojure.lang.Numbers.gte(double,double)\", \">=\",\n  \"public static boolean clojure.lang.Util.equiv(long,long)\", \"==\",\n  \"public static boolean clojure.lang.Util.equiv(boolean,boolean)\", \"==\",\n  \"public static boolean clojure.lang.Util.equiv(double,double)\", \"==\",\n\n  \"public static boolean clojure.lang.Numbers.isZero(double)\", \"0.0 ==\",\n  \"public static boolean clojure.lang.Numbers.isZero(long)\", \"0L ==\",\n  \"public static boolean clojure.lang.Numbers.isPos(long)\", \"0 <\",\n  \"public static boolean clojure.lang.Numbers.isPos(double)\", \"0 <\",\n  \"public static boolean clojure.lang.Numbers.isNeg(long)\", \"0 >\",\n  \"public static boolean clojure.lang.Numbers.isNeg(double)\", \"0 >\"\n);\n}"
  },
  {
    "path": "src/jvm/clojure/lang/SourceWriter.java",
    "content": "package clojure.lang;\n\npublic class SourceWriter {\n\n  private final StringBuilder sb = new StringBuilder();\n  private int tab = 0;\n  \n  public void tab() {\n    tab++;\n  }\n  \n  public void untab() {\n    tab --;\n  }\n  \n  public void println(String l) {\n    if (tab > 0) {\n      sb.append(new String(new char[tab]).replace(\"\\0\", \" \"));\n    }\n    sb.append(l).append(\"\\n\");\n  }\n  \n  @Override\n  public String toString() {\n    return sb.toString();\n  }\n\n  public void println() {\n    sb.append(\"\\n\");\n  }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/StringEscapeUtils.java",
    "content": "/*\n * Copyright 2002-2005 The Apache Software Foundation.\n * \n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * \n *      http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage clojure.lang;\n\nimport java.io.IOException;\nimport java.io.StringWriter;\nimport java.io.Writer;\n\n/**\n * <p>Escapes and unescapes <code>String</code>s for\n * Java, Java Script, HTML, XML, and SQL.</p>\n *\n * @author Apache Jakarta Turbine\n * @author GenerationJavaCore library\n * @author Purple Technology\n * @author <a href=\"mailto:bayard@generationjava.com\">Henri Yandell</a>\n * @author <a href=\"mailto:alex@purpletech.com\">Alexander Day Chaffee</a>\n * @author Antony Riley\n * @author Helge Tesgaard\n * @author <a href=\"sean@boohai.com\">Sean Brown</a>\n * @author <a href=\"mailto:ggregory@seagullsw.com\">Gary Gregory</a>\n * @author Phil Steitz\n * @author Pete Gieser\n * @since 2.0\n * @version $Id: StringEscapeUtils.java 165657 2005-05-02 18:31:49Z ggregory $\n */\npublic class StringEscapeUtils {\n\n  public static void main(String[] args) {\n    String str = \"(\\\\d\\\\d\\\\d\\\\d)\";\n    System.out.println(str);\n    System.out.println(escapeJava(str));\n  }\n  \n    /**\n     * <p><code>StringEscapeUtils</code> instances should NOT be constructed in\n     * standard programming.</p>\n     *\n     * <p>Instead, the class should be used as:\n     * <pre>StringEscapeUtils.escapeJava(\"foo\");</pre></p>\n     *\n     * <p>This constructor is public to permit tools that require a JavaBean\n     * instance to operate.</p>\n     */\n    public StringEscapeUtils() {\n    }\n\n    // Java and JavaScript\n    //--------------------------------------------------------------------------\n    /**\n     * <p>Escapes the characters in a <code>String</code> using Java String rules.</p>\n     *\n     * <p>Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.) </p>\n     *\n     * <p>So a tab becomes the characters <code>'\\\\'</code> and\n     * <code>'t'</code>.</p>\n     *\n     * <p>The only difference between Java strings and JavaScript strings\n     * is that in JavaScript, a single quote must be escaped.</p>\n     *\n     * <p>Example:\n     * <pre>\n     * input string: He didn't say, \"Stop!\"\n     * output string: He didn't say, \\\"Stop!\\\"\n     * </pre>\n     * </p>\n     *\n     * @param str  String to escape values in, may be null\n     * @return String with escaped values, <code>null</code> if null string input\n     */\n    public static String escapeJava(String str) {\n        return escapeJavaStyleString(str, false);\n    }\n\n    /**\n     * <p>Escapes the characters in a <code>String</code> using Java String rules to\n     * a <code>Writer</code>.</p>\n     * \n     * <p>A <code>null</code> string input has no effect.</p>\n     * \n     * @see #escapeJava(java.lang.String)\n     * @param out  Writer to write escaped string into\n     * @param str  String to escape values in, may be null\n     * @throws IllegalArgumentException if the Writer is <code>null</code>\n     * @throws IOException if error occurs on underlying Writer\n     */\n    public static void escapeJava(Writer out, String str) throws IOException {\n        escapeJavaStyleString(out, str, false);\n    }\n\n    private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes) {\n        if (str == null) {\n            return null;\n        }\n        try {\n            StringWriter writer = new StringWriter(str.length() * 2);\n            escapeJavaStyleString(writer, str, escapeSingleQuotes);\n            return writer.toString();\n        } catch (IOException ioe) {\n            // this should never ever happen while writing to a StringWriter\n            ioe.printStackTrace();\n            return null;\n        }\n    }\n\n    private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote) throws IOException {\n        if (out == null) {\n            throw new IllegalArgumentException(\"The Writer must not be null\");\n        }\n        if (str == null) {\n            return;\n        }\n        int sz;\n        sz = str.length();\n        for (int i = 0; i < sz; i++) {\n            char ch = str.charAt(i);\n\n            // handle unicode\n            if (ch > 0xfff) {\n                out.write(\"\\\\u\" + hex(ch));\n            } else if (ch > 0xff) {\n                out.write(\"\\\\u0\" + hex(ch));\n            } else if (ch > 0x7f) {\n                out.write(\"\\\\u00\" + hex(ch));\n            } else if (ch < 32) {\n                switch (ch) {\n                    case '\\b':\n                        out.write('\\\\');\n                        out.write('b');\n                        break;\n                    case '\\n':\n                        out.write('\\\\');\n                        out.write('n');\n                        break;\n                    case '\\t':\n                        out.write('\\\\');\n                        out.write('t');\n                        break;\n                    case '\\f':\n                        out.write('\\\\');\n                        out.write('f');\n                        break;\n                    case '\\r':\n                        out.write('\\\\');\n                        out.write('r');\n                        break;\n                    default :\n                        if (ch > 0xf) {\n                            out.write(\"\\\\u00\" + hex(ch));\n                        } else {\n                            out.write(\"\\\\u000\" + hex(ch));\n                        }\n                        break;\n                }\n            } else {\n                switch (ch) {\n                    case '\\'':\n                        if (escapeSingleQuote) {\n                          out.write('\\\\');\n                        }\n                        out.write('\\'');\n                        break;\n                    case '\"':\n                        out.write('\\\\');\n                        out.write('\"');\n                        break;\n                    case '\\\\':\n                        out.write('\\\\');\n                        out.write('\\\\');\n                        break;\n                    default :\n                        out.write(ch);\n                        break;\n                }\n            }\n        }\n    }\n\n    /**\n     * <p>Returns an upper case hexadecimal <code>String</code> for the given\n     * character.</p>\n     * \n     * @param ch The character to convert.\n     * @return An upper case hexadecimal <code>String</code>\n     */\n    private static String hex(char ch) {\n        return Integer.toHexString(ch).toUpperCase();\n    }\n\n    /**\n     * <p>Unescapes any Java literals found in the <code>String</code>.\n     * For example, it will turn a sequence of <code>'\\'</code> and\n     * <code>'n'</code> into a newline character, unless the <code>'\\'</code>\n     * is preceded by another <code>'\\'</code>.</p>\n     * \n     * @param str  the <code>String</code> to unescape, may be null\n     * @return a new unescaped <code>String</code>, <code>null</code> if null string input\n     */\n    public static String unescapeJava(String str) {\n        if (str == null) {\n            return null;\n        }\n        try {\n            StringWriter writer = new StringWriter(str.length());\n            unescapeJava(writer, str);\n            return writer.toString();\n        } catch (IOException ioe) {\n            // this should never ever happen while writing to a StringWriter\n            ioe.printStackTrace();\n            return null;\n        }\n    }\n\n    /**\n     * <p>Unescapes any Java literals found in the <code>String</code> to a\n     * <code>Writer</code>.</p>\n     *\n     * <p>For example, it will turn a sequence of <code>'\\'</code> and\n     * <code>'n'</code> into a newline character, unless the <code>'\\'</code>\n     * is preceded by another <code>'\\'</code>.</p>\n     * \n     * <p>A <code>null</code> string input has no effect.</p>\n     * \n     * @param out  the <code>Writer</code> used to output unescaped characters\n     * @param str  the <code>String</code> to unescape, may be null\n     * @throws IllegalArgumentException if the Writer is <code>null</code>\n     * @throws IOException if error occurs on underlying Writer\n     */\n    public static void unescapeJava(Writer out, String str) throws IOException {\n        if (out == null) {\n            throw new IllegalArgumentException(\"The Writer must not be null\");\n        }\n        if (str == null) {\n            return;\n        }\n        int sz = str.length();\n        StringBuffer unicode = new StringBuffer(4);\n        boolean hadSlash = false;\n        boolean inUnicode = false;\n        for (int i = 0; i < sz; i++) {\n            char ch = str.charAt(i);\n            if (inUnicode) {\n                // if in unicode, then we're reading unicode\n                // values in somehow\n                unicode.append(ch);\n                if (unicode.length() == 4) {\n                    // unicode now contains the four hex digits\n                    // which represents our unicode character\n                    try {\n                        int value = Integer.parseInt(unicode.toString(), 16);\n                        out.write((char) value);\n                        unicode.setLength(0);\n                        inUnicode = false;\n                        hadSlash = false;\n                    } catch (NumberFormatException nfe) {\n                        throw new RuntimeException(\"Unable to parse unicode value: \" + unicode, nfe);\n                    }\n                }\n                continue;\n            }\n            if (hadSlash) {\n                // handle an escaped value\n                hadSlash = false;\n                switch (ch) {\n                    case '\\\\':\n                        out.write('\\\\');\n                        break;\n                    case '\\'':\n                        out.write('\\'');\n                        break;\n                    case '\\\"':\n                        out.write('\"');\n                        break;\n                    case 'r':\n                        out.write('\\r');\n                        break;\n                    case 'f':\n                        out.write('\\f');\n                        break;\n                    case 't':\n                        out.write('\\t');\n                        break;\n                    case 'n':\n                        out.write('\\n');\n                        break;\n                    case 'b':\n                        out.write('\\b');\n                        break;\n                    case 'u':\n                        {\n                            // uh-oh, we're in unicode country....\n                            inUnicode = true;\n                            break;\n                        }\n                    default :\n                        out.write(ch);\n                        break;\n                }\n                continue;\n            } else if (ch == '\\\\') {\n                hadSlash = true;\n                continue;\n            }\n            out.write(ch);\n        }\n        if (hadSlash) {\n            // then we're in the weird case of a \\ at the end of the\n            // string, let's output it anyway.\n            out.write('\\\\');\n        }\n    }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/StringSeq.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Dec 6, 2007 */\n\npackage clojure.lang;\n\npublic class StringSeq extends ASeq implements IndexedSeq{\npublic final CharSequence s;\npublic final int i;\n\nstatic public StringSeq create(CharSequence s){\n\tif(s.length() == 0)\n\t\treturn null;\n\treturn new StringSeq(null, s, 0);\n}\n\nStringSeq(IPersistentMap meta, CharSequence s, int i){\n\tsuper(meta);\n\tthis.s = s;\n\tthis.i = i;\n}\n\npublic Obj withMeta(IPersistentMap meta){\n\tif(meta == meta())\n\t\treturn this;\n\treturn new StringSeq(meta, s, i);\n}\n\npublic Object first(){\n\treturn Character.valueOf(s.charAt(i));\n}\n\npublic ISeq next(){\n\tif(i + 1 < s.length())\n\t\treturn new StringSeq(_meta, s, i + 1);\n\treturn null;\n}\n\npublic int index(){\n\treturn i;\n}\n\npublic int count(){\n\treturn s.length() - i;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Symbol.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Mar 25, 2006 11:42:47 AM */\n\npackage clojure.lang;\n\nimport java.io.ObjectStreamException;\nimport java.io.Serializable;\n\npublic class Symbol extends AFn implements IObj, Comparable, Named, Serializable, IHashEq{\nfinal String ns;\nfinal String name;\nprivate int _hasheq;\nfinal IPersistentMap _meta;\ntransient String _str;\n\npublic String toString(){\n\tif(_str == null){\n\t\tif(ns != null)\n\t\t\t_str = (ns + \"/\" + name);\n\t\telse\n\t\t\t_str = name;\n\t}\n\treturn _str;\n}\n\npublic String getNamespace() {\n  return ns;\n}\n\npublic String getName() {\n  return name;\n}\n\n// the create thunks preserve binary compatibility with code compiled\n// against earlier version of Clojure and can be removed (at some point).\nstatic public Symbol create(String ns, String name) {\n  return Symbol.intern(ns, name);\n}\n\nstatic public Symbol create(String nsname) {\n  return Symbol.intern(nsname);\n}\n\nstatic public Symbol intern(String ns, String name){\n\treturn new Symbol(ns, name);\n}\n\nstatic public Symbol intern(String nsname){\n\tint i = nsname.indexOf('/');\n\tif(i == -1 || nsname.equals(\"/\"))\n\t\treturn new Symbol(null, nsname);\n\telse\n\t\treturn new Symbol(nsname.substring(0, i), nsname.substring(i + 1));\n}\n\nprivate Symbol(String ns_interned, String name_interned){\n\tthis.name = name_interned;\n\tthis.ns = ns_interned;\n\tthis._meta = null;\n}\n\npublic boolean equals(Object o) {\n  if (this == o)\n    return true;\n  if (!(o instanceof Symbol))\n    return false;\n\n  Symbol symbol = (Symbol) o;\n\n  return Util.equals(ns,symbol.ns) && name.equals(symbol.name);\n}\n\npublic int hashCode(){\n\treturn Util.hashCombine(Util.hash(name), Util.hash(ns));\n}\n\npublic int hasheq() {\n\tif(_hasheq == 0){\n\t\t_hasheq = Util.hashCombine(Murmur3.hashUnencodedChars(name), Util.hash(ns));\n\t}\n\treturn _hasheq;\n}\n\npublic IObj withMeta(IPersistentMap meta){\n\treturn new Symbol(meta, ns, name);\n}\n\nprivate Symbol(IPersistentMap meta, String ns, String name){\n\tthis.name = name;\n\tthis.ns = ns;\n\tthis._meta = meta;\n}\n\npublic int compareTo(Object o){\n\tSymbol s = (Symbol) o;\n\tif(this.equals(o))\n\t\treturn 0;\n\tif(this.ns == null && s.ns != null)\n\t\treturn -1;\n\tif(this.ns != null)\n\t\t{\n\t\tif(s.ns == null)\n\t\t\treturn 1;\n\t\tint nsc = this.ns.compareTo(s.ns);\n\t\tif(nsc != 0)\n\t\t\treturn nsc;\n\t\t}\n\treturn this.name.compareTo(s.name);\n}\n\nprivate Object readResolve() throws ObjectStreamException{\n\treturn intern(ns, name);\n}\n\npublic Object invoke(Object obj) {\n\treturn RT.get(obj, this);\n}\n\npublic Object invoke(Object obj, Object notFound) {\n\treturn RT.get(obj, this, notFound);\n}\n\npublic IPersistentMap meta(){\n\treturn _meta;\n}\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/TaggedLiteral.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\npublic class TaggedLiteral implements ILookup {\n\npublic static final Keyword TAG_KW = Keyword.intern(\"tag\");\npublic static final Keyword FORM_KW = Keyword.intern(\"form\");\n\npublic final Symbol tag;\npublic final Object form;\n\npublic static TaggedLiteral create(Symbol tag, Object form) {\n\treturn new TaggedLiteral(tag, form);\n}\n\nprivate TaggedLiteral(Symbol tag, Object form){\n\tthis.tag = tag;\n\tthis.form = form;\n}\n\npublic Object valAt(Object key) {\n\treturn valAt(key, null);\n}\n\npublic Object valAt(Object key, Object notFound) {\n\tif (FORM_KW.equals(key)) {\n\t\treturn this.form;\n\t} else if (TAG_KW.equals(key)) {\n\t\treturn this.tag;\n\t} else {\n\t\treturn notFound;\n\t}\n}\n\n@Override\npublic boolean equals(Object o) {\n\tif (this == o) return true;\n\tif (o == null || getClass() != o.getClass()) return false;\n\n\tTaggedLiteral that = (TaggedLiteral) o;\n\n\tif (form != null ? !form.equals(that.form) : that.form != null) return false;\n\tif (tag != null ? !tag.equals(that.tag) : that.tag != null) return false;\n\n\treturn true;\n}\n\n@Override\npublic int hashCode() {\n\tint result = Util.hash(tag);\n\tresult = 31 * result + Util.hash(form);\n\treturn result;\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/ThreadFactory.java",
    "content": "package clojure.lang;\n\npublic interface ThreadFactory {\n  Thread newThread(java.lang.Runnable runnable);\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/TransactionalHashMap.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jul 31, 2008 */\n\npackage clojure.lang;\n\nimport java.util.concurrent.ConcurrentMap;\nimport java.util.*;\n\npublic class TransactionalHashMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>{\nfinal Ref[] bins;\n\nIPersistentMap mapAt(int bin){\n\treturn (IPersistentMap) bins[bin].deref();\n}\n\nfinal int binFor(Object k){\n\t//spread hashes, a la Cliff Click\n\tint h = Util.hash(k);\n\th ^= (h >>> 20) ^ (h >>> 12);\n\th ^= (h >>> 7) ^ (h >>> 4);\n\treturn h % bins.length;\n//\treturn Util.hash(k) % bins.length;\n}\n\nEntry entryAt(Object k){\n\treturn mapAt(binFor(k)).entryAt(k);\n}\n\npublic TransactionalHashMap() {\n\tthis(421);\n}\n\npublic TransactionalHashMap(int nBins) {\n\tbins = new Ref[nBins];\n\tfor(int i = 0; i < nBins; i++)\n\t\tbins[i] = new Ref(PersistentHashMap.EMPTY);\n}\n\npublic TransactionalHashMap(Map<? extends K, ? extends V> m) {\n\tthis(m.size());\n\tputAll(m);\n}\n\npublic int size(){\n\tint n = 0;\n\tfor(int i = 0; i < bins.length; i++)\n\t\t{\n\t\tn += mapAt(i).count();\n\t\t}\n\treturn n;\n}\n\npublic boolean isEmpty(){\n\treturn size() == 0;\n}\n\npublic boolean containsKey(Object k){\n\treturn entryAt(k) != null;\n}\n\npublic V get(Object k){\n\tEntry e = entryAt(k);\n\tif(e != null)\n\t\treturn (V) e.getValue();\n\treturn null;\n}\n\npublic V put(K k, V v){\n\tRef r = bins[binFor(k)];\n\tIPersistentMap map = (IPersistentMap) r.deref();\n\tObject ret = map.valAt(k);\n\tr.set(map.assoc(k, v));\n\treturn (V) ret;\n}\n\npublic V remove(Object k){\n\tRef r = bins[binFor(k)];\n\tIPersistentMap map = (IPersistentMap) r.deref();\n\tObject ret = map.valAt(k);\n\tr.set(map.without(k));\n\treturn (V) ret;\n}\n\npublic void putAll(Map<? extends K, ? extends V> map){\n\tfor(Iterator i = map.entrySet().iterator(); i.hasNext();)\n\t\t{\n\t\tEntry<K, V> e = (Entry) i.next();\n\t\tput(e.getKey(), e.getValue());\n\t\t}\n}\n\npublic void clear(){\n\tfor(int i = 0; i < bins.length; i++)\n\t\t{\n\t\tRef r = bins[i];\n\t\tIPersistentMap map = (IPersistentMap) r.deref();\n\t\tif(map.count() > 0)\n\t\t\t{\n\t\t\tr.set(PersistentHashMap.EMPTY);\n\t\t\t}\n\t\t}\n}\n\npublic Set<Entry<K, V>> entrySet(){\n\tfinal ArrayList<Map.Entry<K, V>> entries = new ArrayList(bins.length);\n\tfor(int i = 0; i < bins.length; i++)\n\t\t{\n\t\tIPersistentMap map = mapAt(i);\n\t\tif(map.count() > 0)\n\t\t\tentries.addAll((Collection) RT.seq(map));\n\t\t}\n\treturn new AbstractSet<Entry<K, V>>(){\n\t\tpublic Iterator iterator(){\n\t\t\treturn Collections.unmodifiableList(entries).iterator();\n\t\t}\n\n\t\tpublic int size(){\n\t\t\treturn entries.size();\n\t\t}\n\t};\n}\n\npublic V putIfAbsent(K k, V v){\n\tRef r = bins[binFor(k)];\n\tIPersistentMap map = (IPersistentMap) r.deref();\n\tEntry e = map.entryAt(k);\n\tif(e == null)\n\t\t{\n\t\tr.set(map.assoc(k, v));\n\t\treturn null;\n\t\t}\n\telse\n\t\treturn (V) e.getValue();\n}\n\npublic boolean remove(Object k, Object v){\n\tRef r = bins[binFor(k)];\n\tIPersistentMap map = (IPersistentMap) r.deref();\n\tEntry e = map.entryAt(k);\n\tif(e != null && e.getValue().equals(v))\n\t\t{\n\t\tr.set(map.without(k));\n\t\treturn true;\n\t\t}\n\treturn false;\n}\n\npublic boolean replace(K k, V oldv, V newv){\n\tRef r = bins[binFor(k)];\n\tIPersistentMap map = (IPersistentMap) r.deref();\n\tEntry e = map.entryAt(k);\n\tif(e != null && e.getValue().equals(oldv))\n\t\t{\n\t\tr.set(map.assoc(k, newv));\n\t\treturn true;\n\t\t}\n\treturn false;\n}\n\npublic V replace(K k, V v){\n\tRef r = bins[binFor(k)];\n\tIPersistentMap map = (IPersistentMap) r.deref();\n\tEntry e = map.entryAt(k);\n\tif(e != null)\n\t\t{\n\t\tr.set(map.assoc(k, v));\n\t\treturn (V) e.getValue();\n\t\t}\n\treturn null;\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/TransformerIterator.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* Alex Miller 3/3/15 */\n\npackage clojure.lang;\n\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.NoSuchElementException;\nimport java.util.Queue;\nimport java.util.LinkedList;\n\npublic class TransformerIterator implements Iterator {\n\nprivate static final Buffer EMPTY = new Empty();\nprivate static final Object NONE = new Object();\n\n// Source\nprivate final Iterator sourceIter;\nprivate final IFn xf;\nprivate final boolean multi;\n\n// Iteration state\nprivate volatile Buffer buffer = EMPTY;\nprivate volatile Object next = NONE;\nprivate volatile boolean completed = false;\n\nprivate TransformerIterator(IFn xform, Iterator sourceIter, boolean multi) {\n    this.sourceIter = sourceIter;\n    this.xf = (IFn) xform.invoke(new AFn() {\n        public Object invoke() {\n            return null;\n        }\n\n        public Object invoke(Object acc) {\n            return acc;\n        }\n\n        public Object invoke(Object acc, Object o) {\n            buffer = buffer.add(o);\n            return acc;\n        }\n    });\n    this.multi = multi;\n}\n\npublic static Iterator create(IFn xform, Iterator source) {\n    return new TransformerIterator(xform, source, false);\n}\n\npublic static Iterator createMulti(IFn xform, List sources) {\n    Iterator[] iters = new Iterator[sources.size()];\n    for(int i=0; i<sources.size(); i++)\n        iters[i] = (Iterator)sources.get(i);\n    return new TransformerIterator(xform, new MultiIterator(iters), true);\n}\n\nprivate boolean step() {\n    if(next != NONE)\n        return true;\n\n    while (next == NONE) {\n        if(buffer.isEmpty()) {\n            if(completed) {\n                return false;\n            } else if (sourceIter.hasNext()) {\n                Object iter = null;\n                if(multi)\n                    iter = xf.applyTo(RT.cons(null, sourceIter.next()));\n                else\n                    iter = xf.invoke(null, sourceIter.next());\n\n                if(RT.isReduced(iter)) {\n                    xf.invoke(null);\n                    completed = true;\n                }\n            } else {\n                xf.invoke(null);\n                completed = true;\n            }\n        } else {\n            next = buffer.remove();\n        }\n    }\n    return true;\n}\n\npublic boolean hasNext() {\n    return step();\n}\n\npublic Object next() {\n    if(hasNext()) {\n        Object ret = next;\n        next = NONE;\n        return ret;\n    }\n    throw new NoSuchElementException();\n}\n\npublic void remove() {\n    throw new UnsupportedOperationException();\n}\n\nprivate static interface Buffer {\n    Buffer add(Object o);\n    Object remove();\n    boolean isEmpty();\n}\n\nprivate static class Empty implements Buffer {\n    public Buffer add(Object o) {\n        return new Single(o);\n    }\n\n    public Object remove() {\n        throw new IllegalStateException(\"Removing object from empty buffer\");\n    }\n\n    public boolean isEmpty() {\n        return true;\n    }\n\n    public String toString() {\n        return \"Empty\";\n    }\n}\n\nprivate static class Single implements Buffer {\n    private volatile Object val;\n\n    public Single(Object o) {\n        this.val = o;\n    }\n\n    public Buffer add(Object o) {\n        if (val == NONE) {\n            val = o;\n            return this;\n        } else {\n            return new Many(val, o);\n        }\n    }\n\n    public Object remove() {\n        if(val == NONE) {\n            throw new IllegalStateException(\"Removing object from empty buffer\");\n        }\n        Object ret = val;\n        val = NONE;\n        return ret;\n    }\n\n    public boolean isEmpty() {\n        return val == NONE;\n    }\n\n    public String toString() {\n        return \"Single: \" + val;\n    }\n}\n\nprivate static class Many implements Buffer {\n    private final Queue vals = new LinkedList();\n\n    public Many(Object o1, Object o2) {\n        vals.add(o1);\n        vals.add(o2);\n    }\n\n    public Buffer add(Object o) {\n        vals.add(o);\n        return this;\n    }\n\n    public Object remove() {\n        return vals.remove();\n    }\n\n    public boolean isEmpty() {\n        return vals.isEmpty();\n    }\n\n    public String toString() {\n        return \"Many: \" + vals.toString();\n    }\n}\n\nprivate static class MultiIterator implements Iterator {\n    private final Iterator[] iters;\n\n    public MultiIterator(Iterator[] iters) {\n        this.iters = iters;\n    }\n\n    public boolean hasNext(){\n        for(Iterator iter : iters)\n            if(!iter.hasNext())\n                return false;\n        return true;\n    }\n\n    public Object next() {\n        Object[] nexts = new Object[iters.length];\n        for(int i = 0;i<iters.length;i++)\n            nexts[i] = iters[i].next();\n        return new ArraySeq(nexts,0);\n    }\n\n    public void remove() {\n        throw new UnsupportedOperationException();\n    }\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/URLClassLoader.java",
    "content": "package clojure.lang;\n\nimport java.net.URL;\n\npublic class URLClassLoader extends ClassLoader  {\n  \n  public URLClassLoader(URL[] emptyUrls, ClassLoader classLoader) {\n    super(classLoader);\n  }\n\n  public void addURL(URL url) {\n    throw new RuntimeException(url.toString());\n  }\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Util.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Apr 19, 2008 */\n\npackage clojure.lang;\n\nimport java.lang.ref.Reference;\nimport java.lang.ref.ReferenceQueue;\nimport java.math.BigInteger;\nimport java.util.Collection;\nimport java.util.Map;\nimport java.util.concurrent.ConcurrentHashMap;\n\n/*-[\n#include \"java/lang/Character.h\"\n#include \"clojure/lang/Var.h\"\n#include \"clojure/lang/Keyword.h\"\n#include \"IOSMappedClass.h\"\n#include \"IOSProtocolClass.h\"\n#include \"IOSConcreteClass.h\"\n#include \"IOSPrimitiveClass.h\"\n#include \"IOSArrayClass.h\"\n]-*/\n\npublic class Util{\n  \nprivate static native boolean skipCollection(Object k1) /*-[\n  return [k1 isMemberOfClass:[ClojureLangSymbol class]] ||\n  [k1 isMemberOfClass:[JavaLangCharacter class]] ||\n  [k1 isMemberOfClass:[NSString class]] ||\n  [k1 isMemberOfClass:[ClojureLangVar class]] ||\n  [k1 isKindOfClass:[ClojureLangKeyword class]] ||\n  [k1 isKindOfClass:[IOSMappedClass class]] ||\n  [k1 isMemberOfClass:[IOSProtocolClass class]] ||\n  [k1 isMemberOfClass:[IOSConcreteClass class]] ||\n  [k1 isMemberOfClass:[IOSArrayClass class]] ||\n  [k1 isMemberOfClass:[IOSPrimitiveClass class]];\n ]-*/;\n\nstatic public boolean equiv(Object k1, Object k2){\n\tif(k1 == k2)\n\t\treturn true;\n\tif(k1 != null)\n\t\t{\n\t\tif(k1 instanceof Number && k2 instanceof Number)\n\t\t\treturn Numbers.equal((Number)k1, (Number)k2);\n\t\telse if (ObjC.objc && skipCollection(k1))\n\t\t  return k1.equals(k2);\n\t\telse if(k1 instanceof IPersistentCollection || k2 instanceof IPersistentCollection)\n\t\t\treturn pcequiv(k1,k2);\n\t\treturn k1.equals(k2);\n\t\t}\n\treturn false;\n}\n\npublic interface EquivPred{\n    boolean equiv(Object k1, Object k2);\n}\n\nstatic EquivPred equivNull = new EquivPred() {\n        public boolean equiv(Object k1, Object k2) {\n            return k2 == null;\n        }\n    };\n\nstatic EquivPred equivEquals = new EquivPred(){\n        public boolean equiv(Object k1, Object k2) {\n            return k1.equals(k2);\n        }\n    };\n\nstatic EquivPred equivNumber = new EquivPred(){\n        public boolean equiv(Object k1, Object k2) {\n            if(k2 instanceof Number)\n                return Numbers.equal((Number) k1, (Number) k2);\n            return false;\n        }\n    };\n\nstatic EquivPred equivColl = new EquivPred(){\n        public boolean equiv(Object k1, Object k2) {\n            if (ObjC.objc && skipCollection(k1))\n              return k1.equals(k2);\n            else if(k1 instanceof IPersistentCollection || k2 instanceof IPersistentCollection)\n                return pcequiv(k1, k2);\n            return k1.equals(k2);\n        }\n    };\n\nstatic public EquivPred equivPred(Object k1){\n    if(k1 == null)\n        return equivNull;\n    else if (k1 instanceof Number)\n        return equivNumber;\n    else if (k1 instanceof String || k1 instanceof Symbol)\n        return equivEquals;\n    else if (k1 instanceof Collection || k1 instanceof Map)\n        return equivColl;\n    return equivEquals;\n}\n\nstatic public boolean equiv(long k1, long k2){\n\treturn k1 == k2;\n}\n\nstatic public boolean equiv(Object k1, long k2){\n\treturn equiv(k1, (Object)k2);\n}\n\nstatic public boolean equiv(long k1, Object k2){\n\treturn equiv((Object)k1, k2);\n}\n\nstatic public boolean equiv(double k1, double k2){\n\treturn k1 == k2;\n}\n\nstatic public boolean equiv(Object k1, double k2){\n\treturn equiv(k1, (Object)k2);\n}\n\nstatic public boolean equiv(double k1, Object k2){\n\treturn equiv((Object)k1, k2);\n}\n\nstatic public boolean equiv(boolean k1, boolean k2){\n\treturn k1 == k2;\n}\n\nstatic public boolean equiv(Object k1, boolean k2){\n\treturn equiv(k1, (Object)k2);\n}\n\nstatic public boolean equiv(boolean k1, Object k2){\n\treturn equiv((Object)k1, k2);\n}\n\nstatic public boolean equiv(char c1, char c2) {\n    return c1 == c2;\n}\n\nstatic public boolean pcequiv(Object k1, Object k2){\n\tif(k1 instanceof IPersistentCollection)\n\t\treturn ((IPersistentCollection)k1).equiv(k2);\n\treturn ((IPersistentCollection)k2).equiv(k1);\n}\n\nstatic public boolean equals(Object k1, Object k2){\n\tif(k1 == k2)\n\t\treturn true;\n\treturn k1 != null && k1.equals(k2);\n}\n\nstatic public boolean identical(Object k1, Object k2){\n\treturn k1 == k2;\n}\n\nstatic public Class classOf(Object x){\n\tif(x != null)\n\t\treturn x.getClass();\n\treturn null;\n}\n\nstatic public int compare(Object k1, Object k2){\n\tif(k1 == k2)\n\t\treturn 0;\n\tif(k1 != null)\n\t\t{\n\t\tif(k2 == null)\n\t\t\treturn 1;\n\t\tif(k1 instanceof Number)\n\t\t\treturn Numbers.compare((Number) k1, (Number) k2);\n\t\treturn ((Comparable) k1).compareTo(k2);\n\t\t}\n\treturn -1;\n}\n\nstatic public int hash(Object o){\n\tif(o == null)\n\t\treturn 0;\n\tif (ObjC.objc && o instanceof String) {\n\t  return stringHash((String) o);\n\t}\n\treturn o.hashCode();\n}\n\nprivate native static int stringHash(String s) /*-[\n  return javaStringHashCode(s);\n]-*/;\n\npublic static int hasheq(Object o){\n\tif(o == null)\n\t\treturn 0;\n\tif (ObjC.objc && skipCollection(o))\n\t  return hash(o);\n\telse if(o instanceof IHashEq)\n\t\treturn dohasheq((IHashEq) o);\t\n\tif(o instanceof Number)\n\t\treturn Numbers.hasheq((Number)o);\n\tif(o instanceof String)\n\t\treturn Murmur3.hashInt(hash(o));\n\treturn hash(o);\n}\n\nprivate static int dohasheq(IHashEq o) {\n\treturn o.hasheq();\n}\n\nstatic public int hashCombine(int seed, int hash){\n\t//a la boost\n\tseed ^= hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);\n\treturn seed;\n}\n\nstatic public boolean isPrimitive(Class c){\n\treturn c != null && c.isPrimitive() && !(c == Void.TYPE);\n}\n\nstatic public boolean isInteger(Object x){\n\treturn x instanceof Integer\n\t\t\t|| x instanceof Long\n\t        || x instanceof BigInt\n\t\t\t|| x instanceof BigInteger;\n}\n\nstatic public Object ret1(Object ret, Object nil){\n\t\treturn ret;\n}\n\nstatic public ISeq ret1(ISeq ret, Object nil){\n\t\treturn ret;\n}\n\nstatic public <K,V> void clearCache(ReferenceQueue rq, ConcurrentHashMap<K, Reference<V>> cache){\n\t\t//cleanup any dead entries\n\tif(rq.poll() != null)\n\t\t{\n\t\twhile(rq.poll() != null)\n\t\t\t;\n\t\tfor(Map.Entry<K, Reference<V>> e : cache.entrySet())\n\t\t\t{\n            Reference<V> val = e.getValue();\n\t\t\tif(val != null && val.get() == null)\n\t\t\t\tcache.remove(e.getKey(), val);\n\t\t\t}\n\t\t}\n}\n\nstatic public RuntimeException runtimeException(String s){\n\treturn new RuntimeException(s);\n}\n\nstatic public RuntimeException runtimeException(String s, Throwable e){\n\treturn new RuntimeException(s, e);\n}\n\n/**\n * Throw even checked exceptions without being required\n * to declare them or catch them. Suggested idiom:\n * <p>\n * <code>throw sneakyThrow( some exception );</code>\n */\nstatic public RuntimeException sneakyThrow(Throwable t) {\n    // http://www.mail-archive.com/javaposse@googlegroups.com/msg05984.html\n\tif (t == null)\n\t\tthrow new NullPointerException();\n\tUtil.<RuntimeException>sneakyThrow0(t);\n\treturn null;\n}\n\n@SuppressWarnings(\"unchecked\")\nstatic private <T extends Throwable> void sneakyThrow0(Throwable t) throws T {\n\tthrow (T) t;\n}\n\npublic static void trow(Throwable sneakyThrow) {\n  Util.sneakyThrow(sneakyThrow);\n}\n\n}\n\n"
  },
  {
    "path": "src/jvm/clojure/lang/Var.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Jul 31, 2007 */\n\npackage clojure.lang;\n\nimport java.util.concurrent.atomic.AtomicBoolean;\n\n\npublic final class Var extends ARef implements IFn, IRef, Settable{\n\npublic static class TBox{\n\nvolatile Object val;\nfinal Thread thread;\n\npublic TBox(Thread t, Object val){\n\tthis.thread = t;\n\tthis.val = val;\n}\n}\n\nstatic public class Unbound extends AFn{\n\tfinal public Var v;\n\n\tpublic Unbound(Var v){\n\t\tthis.v = v;\n\t}\n\n\tpublic String toString(){\n\t\treturn \"Unbound: \" + v;\n\t}\n\n\tpublic Object throwArity(int n){\n\t\tthrow new IllegalStateException(\"Attempting to call unbound fn: \" + v);\n\t}\n}\n\nstatic class Frame{\n\tfinal static Frame TOP = new Frame(PersistentHashMap.EMPTY, null);\n\t//Var->TBox\n\tAssociative bindings;\n\t//Var->val\n//\tAssociative frameBindings;\n\tFrame prev;\n\n\tpublic Frame(Associative bindings, Frame prev){\n//\t\tthis.frameBindings = frameBindings;\n\t\tthis.bindings = bindings;\n\t\tthis.prev = prev;\n\t}\n\n    \tprotected Object clone() {\n\t\treturn new Frame(this.bindings, null);\n    \t}\n\n}\n\nstatic final ThreadLocal<Frame> dvals = new ThreadLocal<Frame>(){\n\n\tprotected Frame initialValue(){\n\t\treturn Frame.TOP;\n\t}\n};\n\nstatic public volatile int rev = 0;\n\nstatic Keyword privateKey = Keyword.intern(null, \"private\");\nstatic IPersistentMap privateMeta = new PersistentArrayMap(new Object[]{privateKey, Boolean.TRUE});\nstatic Keyword macroKey = Keyword.intern(null, \"macro\");\nstatic Keyword nameKey = Keyword.intern(null, \"name\");\nstatic Keyword forceKey = Keyword.intern(null, \"force\");\nstatic Keyword nsKey = Keyword.intern(null, \"ns\");\n//static Keyword tagKey = Keyword.intern(null, \"tag\");\n\nvolatile Object root;\n\nvolatile boolean dynamic = false;\ntransient final AtomicBoolean threadBound;\npublic final Symbol sym;\npublic final Namespace ns;\n\n//IPersistentMap _meta;\n\npublic static Object getThreadBindingFrame(){\n\treturn dvals.get();\n}\n\npublic static Object cloneThreadBindingFrame(){\n\treturn dvals.get().clone();\n}\n\npublic static void resetThreadBindingFrame(Object frame){\n\tdvals.set((Frame) frame);\n}\n\npublic Var setDynamic(){\n\tthis.dynamic = true;\n\treturn this;\n}\n\npublic Var setDynamic(boolean b){\n\tthis.dynamic = b;\n\treturn this;\n}\n\npublic final boolean isDynamic(){\n\treturn dynamic;\n}\n\npublic static Var intern(Namespace ns, Symbol sym, Object root){\n\treturn intern(ns, sym, root, true);\n}\n\npublic static Var intern(Namespace ns, Symbol sym, Object root, boolean replaceRoot){\n\tVar dvout = ns.intern(sym);\n\tif(!dvout.hasRoot() || replaceRoot)\n\t\tdvout.bindRoot(root);\n\treturn dvout;\n}\n\n\npublic String toString(){\n\tif(ns != null)\n\t\treturn \"#'\" + ns.name + \"/\" + sym;\n\treturn \"#<Var: \" + (sym != null ? sym.toString() : \"--unnamed--\") + \">\";\n}\n\npublic static Var find(Symbol nsQualifiedSym){\n\tif(nsQualifiedSym.ns == null)\n\t\tthrow new IllegalArgumentException(\"Symbol must be namespace-qualified\");\n\tNamespace ns = Namespace.find(Symbol.intern(nsQualifiedSym.ns));\n\tif(ns == null)\n\t\tthrow new IllegalArgumentException(\"No such namespace: \" + nsQualifiedSym.ns);\n\treturn ns.findInternedVar(Symbol.intern(nsQualifiedSym.name));\n}\n\npublic static Var intern(Symbol nsName, Symbol sym){\n\tNamespace ns = Namespace.findOrCreate(nsName);\n\treturn intern(ns, sym);\n}\n\npublic static Var internPrivate(String nsName, String sym){\n\tNamespace ns = Namespace.findOrCreate(Symbol.intern(nsName));\n\tVar ret = intern(ns, Symbol.intern(sym));\n\tret.setMeta(privateMeta);\n\treturn ret;\n}\n\npublic static Var intern(Namespace ns, Symbol sym){\n  Var v = ns.intern(sym);\n  if (!v.isBound() && !ObjC.objc) {\n    maybeLoadFromClass(ns.toString(), sym.toString());\n  }\n  return v;\n}\n\npublic static Var maybeLoadFromClass(String ns, String sym){\n  String ns_sym = buildClassName(ns, sym);\n  try {\n    Class c = Class.forName(ns_sym);\n    Var v = (Var) c.getDeclaredField(\"VAR\").get(null);\n    return v;\n  } catch (Throwable e) {\n    return null;\n  }\n}\n\nprivate static String buildClassName(String ns, String sym) {\n  return clojure.lang.Compiler.munge(ns + Compiler.DOLLAR + sym.replace(\".\", \"_DOT_\"));\n}\n\npublic void maybeLoad() {\n  if (ObjC.objc) {\n    throw new RuntimeException(\"Dynamic loading not available on objc\");\n    //loadFromClass(buildClassName(ns.toString(), sym.toString()));\n  } else {\n    maybeLoadFromClass(ns.toString(), sym.toString());\n  }\n}\n\n\n//private native void loadFromClass(String clazz) /*-[\n//  IOSObjectArray *parts = [clazz split:@\"\\\\.\"];\n//  NSString *classname = @\"\";\n//  for (int n = 0; n < parts.count - 1; n++) {\n//    NSString *s = (NSString*)[parts objectAtIndex:n];\n//    classname = [classname stringByAppendingString:[[[s substringToIndex:1] uppercaseString] stringByAppendingString:[s substringFromIndex:1]]];\n//  }\n//  classname = [classname stringByAppendingString:[parts objectAtIndex:parts.count-1]];\n//  [NSClassFromString(classname) VAR];\n//]-*/;\n\npublic static Var create(){\n\treturn new Var(null, null);\n}\n\npublic static Var create(Object root){\n\treturn new Var(null, null, root);\n}\n\nVar(Namespace ns, Symbol sym){\n\tthis.ns = ns;\n\tthis.sym = sym;\n\tthis.threadBound = new AtomicBoolean(false);\n\tthis.root = new Unbound(this);\n\tsetMeta(PersistentHashMap.EMPTY);\n}\n\nVar(Namespace ns, Symbol sym, Object root){\n\tthis(ns, sym);\n\tthis.root = root;\n\t++rev;\n}\n\npublic boolean isBound(){\n\treturn hasRoot() || (threadBound.get() && dvals.get().bindings.containsKey(this));\n}\n\nfinal public Object get(){\n\tif(!threadBound.get())\n\t\treturn root;\n\treturn deref();\n}\n\nfinal public Object deref(){\n\tTBox b = getThreadBinding();\n\tif(b != null)\n\t\treturn b.val;\n\treturn root;\n}\n\npublic void setValidator(IFn vf){\n\tif(hasRoot())\n\t\tvalidate(vf, root);\n\tvalidator = vf;\n}\n\npublic Object alter(IFn fn, ISeq args) {\n\tset(fn.applyTo(RT.cons(deref(), args)));\n\treturn this;\n}\n\npublic Object set(Object val){\n\tvalidate(getValidator(), val);\n\tTBox b = getThreadBinding();\n\tif(b != null)\n\t\t{\n\t\tif(Thread.currentThread() != b.thread)\n\t\t\tthrow new IllegalStateException(String.format(\"Can't set!: %s from non-binding thread\", sym));\n\t\treturn (b.val = val);\n\t\t}\n\t// TODO!\n\tif (!ObjC.objc) {\n\t  throw new IllegalStateException(String.format(\"Can't change/establish root binding of: %s with set\", sym));\n\t} else {\n\t  return null;\n\t}\n}\n\npublic Object doSet(Object val)  {\n    return set(val);\n    }\n\npublic Object doReset(Object val)  {\n    bindRoot(val);\n    return val;\n    }\n\npublic void setMeta(IPersistentMap m) {\n    resetMeta(m);\n}\n\n@Override\npublic IPersistentMap meta() {\n    // ensure these basis keys\n    return super.meta().assoc(nameKey, sym).assoc(nsKey, ns);\n}\n\npublic void setMacro() {\n    alterMeta(assoc, RT.list(macroKey, RT.T));\n}\n\npublic boolean isMacro(){\n\treturn RT.booleanCast(meta().valAt(macroKey));\n}\n\n//public void setExported(boolean state){\n//\t_meta = _meta.assoc(privateKey, state);\n//}\n\npublic boolean isPublic(){\n\treturn !RT.booleanCast(meta().valAt(privateKey));\n}\n\nfinal public Object getRawRoot(){\n\t\treturn root;\n}\n\npublic Object getTag(){\n\treturn meta().valAt(RT.TAG_KEY);\n}\n\npublic void setTag(Symbol tag) {\n    alterMeta(assoc, RT.list(RT.TAG_KEY, tag));\n}\n\nfinal public boolean hasRoot(){\n\treturn !(root instanceof Unbound);\n}\n\n//binding root always clears macro flag\nsynchronized public void bindRoot(Object root){\n\tvalidate(getValidator(), root);\n\tObject oldroot = this.root;\n\tthis.root = root;\n\t++rev;\n    notifyWatches(oldroot,this.root);\n}\n\nsynchronized void swapRoot(Object root){\n\tvalidate(getValidator(), root);\n\tObject oldroot = this.root;\n\tthis.root = root;\n\t++rev;\n    notifyWatches(oldroot,root);\n}\n\nsynchronized public void unbindRoot(){\n\tthis.root = new Unbound(this);\n\t++rev;\n}\n\nsynchronized public void commuteRoot(IFn fn) {\n\tObject newRoot = fn.invoke(root);\n\tvalidate(getValidator(), newRoot);\n\tObject oldroot = root;\n\tthis.root = newRoot;\n\t++rev;\n    notifyWatches(oldroot,newRoot);\n}\n\nsynchronized public Object alterRoot(IFn fn, ISeq args) {\n\tObject newRoot = fn.applyTo(RT.cons(root, args));\n\tvalidate(getValidator(), newRoot);\n\tObject oldroot = root;\n\tthis.root = newRoot;\n\t++rev;\n    notifyWatches(oldroot,newRoot);\n\treturn newRoot;\n}\n\npublic static void pushThreadBindings(Associative bindings){\n\tFrame f = dvals.get();\n\tAssociative bmap = f.bindings;\n\tfor(ISeq bs = bindings.seq(); bs != null; bs = bs.next())\n\t\t{\n\t\tIMapEntry e = (IMapEntry) bs.first();\n\t\tVar v = (Var) e.key();\n\t\tif(!v.dynamic)\n\t\t\tthrow new IllegalStateException(String.format(\"Can't dynamically bind non-dynamic var: %s/%s\", v.ns, v.sym));\n\t\tv.validate(v.getValidator(), e.val());\n\t\tv.threadBound.set(true);\n\t\tbmap = bmap.assoc(v, new TBox(Thread.currentThread(), e.val()));\n\t\t}\n\tdvals.set(new Frame(bmap, f));\n}\n\npublic static void popThreadBindings(){\n    Frame f = dvals.get().prev;\n    if (f == null) {\n        throw new IllegalStateException(\"Pop without matching push\");\n    } else if (f == Frame.TOP) {\n        dvals.remove();\n    } else {\n        dvals.set(f);\n    }\n}\n\npublic static Associative getThreadBindings(){\n\tFrame f = dvals.get();\n\tIPersistentMap ret = PersistentHashMap.EMPTY;\n\tfor(ISeq bs = f.bindings.seq(); bs != null; bs = bs.next())\n\t\t{\n\t\tIMapEntry e = (IMapEntry) bs.first();\n\t\tVar v = (Var) e.key();\n\t\tTBox b = (TBox) e.val();\n\t\tret = ret.assoc(v, b.val);\n\t\t}\n\treturn ret;\n}\n\npublic final TBox getThreadBinding(){\n\tif(threadBound.get())\n\t\t{\n\t\tIMapEntry e = dvals.get().bindings.entryAt(this);\n\t\tif(e != null)\n\t\t\treturn (TBox) e.val();\n\t\t}\n\treturn null;\n}\n\nfinal public IFn fn(){\n\treturn (IFn) deref();\n}\n\npublic Object call() {\n\treturn invoke();\n}\n\npublic void run(){\n        invoke();\n}\n\npublic Object invoke() {\n\treturn fn().invoke();\n}\n\npublic Object invoke(Object arg1) {\n    return fn().invoke(Util.ret1(arg1,arg1=null));\n}\n\npublic Object invoke(Object arg1, Object arg2) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)\n\t\t{\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null),\n                       Util.ret1(arg10,arg10=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null),\n                       Util.ret1(arg10,arg10=null),\n                       Util.ret1(arg11,arg11=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null),\n                       Util.ret1(arg10,arg10=null),\n                       Util.ret1(arg11,arg11=null),\n                       Util.ret1(arg12,arg12=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13)\n\t\t{\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null),\n                       Util.ret1(arg10,arg10=null),\n                       Util.ret1(arg11,arg11=null),\n                       Util.ret1(arg12,arg12=null),\n                       Util.ret1(arg13,arg13=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14)\n\t\t{\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null),\n                       Util.ret1(arg10,arg10=null),\n                       Util.ret1(arg11,arg11=null),\n                       Util.ret1(arg12,arg12=null),\n                       Util.ret1(arg13,arg13=null),\n                       Util.ret1(arg14,arg14=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null),\n                       Util.ret1(arg10,arg10=null),\n                       Util.ret1(arg11,arg11=null),\n                       Util.ret1(arg12,arg12=null),\n                       Util.ret1(arg13,arg13=null),\n                       Util.ret1(arg14,arg14=null),\n                       Util.ret1(arg15,arg15=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null),\n                       Util.ret1(arg10,arg10=null),\n                       Util.ret1(arg11,arg11=null),\n                       Util.ret1(arg12,arg12=null),\n                       Util.ret1(arg13,arg13=null),\n                       Util.ret1(arg14,arg14=null),\n                       Util.ret1(arg15,arg15=null),\n                       Util.ret1(arg16,arg16=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null),\n                       Util.ret1(arg10,arg10=null),\n                       Util.ret1(arg11,arg11=null),\n                       Util.ret1(arg12,arg12=null),\n                       Util.ret1(arg13,arg13=null),\n                       Util.ret1(arg14,arg14=null),\n                       Util.ret1(arg15,arg15=null),\n                       Util.ret1(arg16,arg16=null),\n                       Util.ret1(arg17,arg17=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null),\n                       Util.ret1(arg10,arg10=null),\n                       Util.ret1(arg11,arg11=null),\n                       Util.ret1(arg12,arg12=null),\n                       Util.ret1(arg13,arg13=null),\n                       Util.ret1(arg14,arg14=null),\n                       Util.ret1(arg15,arg15=null),\n                       Util.ret1(arg16,arg16=null),\n                       Util.ret1(arg17,arg17=null),\n                       Util.ret1(arg18,arg18=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19) {\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null),\n                       Util.ret1(arg10,arg10=null),\n                       Util.ret1(arg11,arg11=null),\n                       Util.ret1(arg12,arg12=null),\n                       Util.ret1(arg13,arg13=null),\n                       Util.ret1(arg14,arg14=null),\n                       Util.ret1(arg15,arg15=null),\n                       Util.ret1(arg16,arg16=null),\n                       Util.ret1(arg17,arg17=null),\n                       Util.ret1(arg18,arg18=null),\n                       Util.ret1(arg19,arg19=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20)\n\t\t{\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null),\n                       Util.ret1(arg10,arg10=null),\n                       Util.ret1(arg11,arg11=null),\n                       Util.ret1(arg12,arg12=null),\n                       Util.ret1(arg13,arg13=null),\n                       Util.ret1(arg14,arg14=null),\n                       Util.ret1(arg15,arg15=null),\n                       Util.ret1(arg16,arg16=null),\n                       Util.ret1(arg17,arg17=null),\n                       Util.ret1(arg18,arg18=null),\n                       Util.ret1(arg19,arg19=null),\n                       Util.ret1(arg20,arg20=null));\n}\n\npublic Object invoke(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7,\n                     Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14,\n                     Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20,\n                     Object... args)\n\t\t{\n    return fn().invoke(Util.ret1(arg1,arg1=null),\n                       Util.ret1(arg2,arg2=null),\n                       Util.ret1(arg3,arg3=null),\n                       Util.ret1(arg4,arg4=null),\n                       Util.ret1(arg5,arg5=null),\n                       Util.ret1(arg6,arg6=null),\n                       Util.ret1(arg7,arg7=null),\n                       Util.ret1(arg8,arg8=null),\n                       Util.ret1(arg9,arg9=null),\n                       Util.ret1(arg10,arg10=null),\n                       Util.ret1(arg11,arg11=null),\n                       Util.ret1(arg12,arg12=null),\n                       Util.ret1(arg13,arg13=null),\n                       Util.ret1(arg14,arg14=null),\n                       Util.ret1(arg15,arg15=null),\n                       Util.ret1(arg16,arg16=null),\n                       Util.ret1(arg17,arg17=null),\n                       Util.ret1(arg18,arg18=null),\n                       Util.ret1(arg19,arg19=null),\n                       Util.ret1(arg20,arg20=null),\n                       (Object[])Util.ret1(args, args=null));\n}\n\npublic Object applyTo(ISeq arglist) {\n\treturn AFn.applyToHelper(this, arglist);\n}\n\nstatic IFn assoc = new AFn(){\n    @Override\n    public Object invoke(Object m, Object k, Object v)  {\n        return RT.assoc(m, k, v);\n    }\n};\nstatic IFn dissoc = new AFn() {\n    @Override\n    public Object invoke(Object c, Object k)  {\n            return RT.dissoc(c, k);\n    }\n};\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/Volatile.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nfinal public class Volatile implements IDeref {\n\nvolatile Object val;\n\npublic Volatile(Object val){\n  this.val = val;\n}\n\npublic Object deref() {\n  return val;\n}\n\npublic Object reset(Object newval) {\n  return this.val = newval;\n}\n\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/WarnBoxedMath.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure.lang;\n\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Target;\n\n@Retention(RetentionPolicy.RUNTIME)\n@Target(ElementType.METHOD)\npublic @interface WarnBoxedMath {\n    boolean value() default true;\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/XMLHandler.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\n/* rich Dec 17, 2007 */\n\npackage clojure.lang;\n\nimport org.xml.sax.Attributes;\nimport org.xml.sax.ContentHandler;\nimport org.xml.sax.Locator;\nimport org.xml.sax.SAXException;\nimport org.xml.sax.helpers.DefaultHandler;\n\npublic class XMLHandler extends DefaultHandler{\nContentHandler h;\n\n\npublic XMLHandler(ContentHandler h){\n\tthis.h = h;\n}\n\npublic void setDocumentLocator(Locator locator){\n\th.setDocumentLocator(locator);\n}\n\npublic void startDocument() throws SAXException{\n\th.startDocument();\n}\n\npublic void endDocument() throws SAXException{\n\th.endDocument();\n}\n\npublic void startPrefixMapping(String prefix, String uri) throws SAXException{\n\th.startPrefixMapping(prefix, uri);\n}\n\npublic void endPrefixMapping(String prefix) throws SAXException{\n\th.endPrefixMapping(prefix);\n}\n\npublic void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException{\n\th.startElement(uri, localName, qName, atts);\n}\n\npublic void endElement(String uri, String localName, String qName) throws SAXException{\n\th.endElement(uri, localName, qName);\n}\n\npublic void characters(char ch[], int start, int length) throws SAXException{\n\th.characters(ch, start, length);\n}\n\npublic void ignorableWhitespace(char ch[], int start, int length) throws SAXException{\n\th.ignorableWhitespace(ch, start, length);\n}\n\npublic void processingInstruction(String target, String data) throws SAXException{\n\th.processingInstruction(target, data);\n}\n\npublic void skippedEntity(String name) throws SAXException{\n\th.skippedEntity(name);\n}\n\n/*\npublic static void main(String[] args){\n\ttry\n\t\t{\n\t\tContentHandler dummy = new DefaultHandler();\n\t\tSAXParserFactory f =  SAXParserFactory.newInstance();\n\t\t//f.setNamespaceAware(true);\n\t\tSAXParser p = f.newSAXParser();\n\t\tp.parse(\"http://arstechnica.com/journals.rssx\",new XMLHandler(dummy));\n\t\t}\n\tcatch(Exception e)\n\t\t{\n\t\te.printStackTrace();\n\t\t}\n}\n//*/\n}\n"
  },
  {
    "path": "src/jvm/clojure/lang/package.html",
    "content": "<html>\n\n<!--\nCopyright (c) Rich Hickey and Contributors. All rights reserved.\nThe use and distribution terms for this software are covered by the\nEclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\nwhich can be found in the file epl-v10.html at the root of this distribution.\nBy using this software in any fashion, you are agreeing to be bound by\nthe terms of this license.\nYou must not remove this notice, or any other, from this software.\n-->\n\n<body>Clojure language implementation.\n\n<p>The clojure.lang package holds the implementation for Clojure.\nThe only class considered part of the public API is\n{@link clojure.lang.IFn}. All other classes should be considered\nimplementation details.</p>\n\n</body>\n</html>\n"
  },
  {
    "path": "src/jvm/clojure/main.java",
    "content": "/**\n *   Copyright (c) Rich Hickey. All rights reserved.\n *   The use and distribution terms for this software are covered by the\n *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n *   which can be found in the file epl-v10.html at the root of this distribution.\n *   By using this software in any fashion, you are agreeing to be bound by\n * \t the terms of this license.\n *   You must not remove this notice, or any other, from this software.\n **/\n\npackage clojure;\n\nimport clojure.lang.RT;\nimport clojure.lang.Symbol;\nimport clojure.lang.Var;\n\npublic class main{\n\nfinal static private Symbol CLOJURE_MAIN = Symbol.intern(\"clojure.main\");\nfinal static private Var REQUIRE = RT.var(\"clojure.core\", \"require\");\nfinal static private Var MAIN = RT.var(\"clojure.main\", \"main\");\n\npublic static void main(String[] args) {\n    REQUIRE.invoke(CLOJURE_MAIN);\n    MAIN.applyTo(RT.seq(args));\n}\n}"
  },
  {
    "path": "src/jvm/com/google/j2objc/annotations/ReflectionSupport.java",
    "content": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.j2objc.annotations;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n/**\n * Annotation that specifies the level of reflection support for a particular\n * class.\n *\n * @author Keith Stanger\n */\n@Target({ ElementType.TYPE, ElementType.PACKAGE })\n@Retention(RetentionPolicy.SOURCE)\npublic @interface ReflectionSupport {\n\n  /**\n   * Enumerates the available levels of reflection support.\n   */\n  enum Level {\n    /*\n     * No metadata is emitted, so reflection support is limited to the\n     * information that can be obtained from the Objective-C runtime.\n     */\n    NATIVE_ONLY,\n    /*\n     * Additional metadata is emitted, allowing for full reflection support.\n     */\n    FULL\n  }\n\n  Level value();\n}"
  },
  {
    "path": "src/objc/Cst502Socket.h",
    "content": "/**\n * Cst502Socket.m - Simple objective-c class for manipulating stream sockets.\n * Purpose: demonstrate stream sockets in Objective-C.\n * These examples are buildable on MacOSX and GNUstep on top of Windows7\n * Cst502 Emerging Languages and Programming Technologies\n * See http://pooh.poly.asu.edu/Cst502\n * @author Tim Lindquist (Tim.Lindquist@asu.edu), ASU Polytechnic, Engineering\n * @version December 2011\n */\n#import <Foundation/Foundation.h>\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <errno.h>\n#include <string.h>\n#include <sys/types.h>\n#include <signal.h>\n\n#if defined(WINGS)\n#define _WIN32_WINNT 0x0501\n#include <ws2tcpip.h>\n#include <winsock2.h>\n#else\n#include <sys/wait.h>\n#include <netdb.h>\n#include <unistd.h>\n#include <sys/param.h>\n#include <sys/socket.h>\n#include <netinet/in.h>\n#include <arpa/inet.h>\n#endif /* !WINGS */\n#define BACKLOG 10  /* queue size for pending connect requests */\n#define MAXDATASIZE 4096 /* 4K bytes maximum with a single receive */\n\n/**\n * Cst502Socket.h - objective-c class for manipulating stream sockets.\n * Purpose: demonstrate stream sockets in Objective-C.\n * These examples are buildable on MacOSX and GNUstep on top of Windows7\n * Cst502 Emerging Languages and Programming Technologies\n * See http://pooh.poly.asu.edu/Cst502\n * @author Tim Lindquist (Tim.Lindquist@asu.edu), ASU Polytechnic, Engineering\n * @version December 2011\n * based on the simple server and client sockets in C by Jeez.\n */\n\n@interface Cst502ServerSocket : NSObject {\n   int sockfd, new_fd, rv;\n   BOOL connected;\n   struct addrinfo hints, *servinfo, *p;\n   struct sockaddr_storage their_addr;\n   socklen_t sin_size;\n   struct in_addr address;\n}\n- (id) initWithPort: (NSString*) port;\n- (BOOL) accept;\n- (int) sendBytes: (char*) byteMsg OfLength: (int) msgLength Index: (int) at;\n- (NSString*) receiveBytes: (char*) byteMsg\n                  maxBytes: (int) max\n                   beginAt: (int) at;\n- (BOOL) close;\n@end\n\n@interface Cst502ClientSocket : NSObject {\n   BOOL connected;\n   int sockfd, numbytes, rv;\n   struct addrinfo hints, *servinfo, *p;\n   NSString *hostName, *portNum;\n   char s[INET6_ADDRSTRLEN];\n}\n- (id) initWithHost: (NSString*) host portNumber: (NSString*) port;\n- (BOOL) connect;\n- (int) sendBytes: (char*) byteMsg OfLength: (int) msgLength Index: (int) at;\n- (NSString*) receiveBytes: (char*) byteMsg\n                  maxBytes: (int) max\n                   beginAt: (int) at;\n- (void) sendString: (NSString*)s;\n- (BOOL) close;\n@end\n\n"
  },
  {
    "path": "src/objc/Cst502Socket.m",
    "content": "#import \"Cst502Socket.h\"\n#define PORT \"4444\"\n\n/**\n * Cst502Socket.m - objective-c class for manipulating stream sockets.\n * Purpose: demonstrate stream sockets in Objective-C.\n * These examples are buildable on MacOSX and GNUstep on top of Windows7\n * Cst502 Emerging Languages and Programming Technologies\n * See http://pooh.poly.asu.edu/Cst502\n * @author Tim Lindquist (Tim.Lindquist@asu.edu), ASU Polytechnic, Engineering\n * based on the simple server and client sockets in C by Jeez.\n * @version December 2011\n */\n\n// get sockaddr, IPv4 or IPv6:\nvoid *get_in_addr(struct sockaddr *sa){\n    if (sa->sa_family == AF_INET) {\n        return &(((struct sockaddr_in*)sa)->sin_addr);\n    }\n    return &(((struct sockaddr_in6*)sa)->sin6_addr);\n}\n\n@implementation Cst502ServerSocket\n\n- (id) initWithPort: (NSString*) port{\n   self = [super init];\n   int ret = 0;\n   memset(&hints, 0, sizeof hints);\n   hints.ai_family = AF_INET;\n   hints.ai_socktype = SOCK_STREAM;\n   hints.ai_flags = AI_PASSIVE; // use my IP\n   const char* portStr = [port UTF8String];\n   if ((rv = getaddrinfo(NULL, portStr, &hints, &servinfo)) != 0) {\n      fprintf(stderr, \"getaddrinfo: %s\\n\", gai_strerror(rv));\n      ret = 1;\n   }else{\n      for(p = servinfo; p != NULL; p = p->ai_next) {\n         if ((sockfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP))==-1){\n            perror(\"server: socket create error\");\n            continue;\n         }\n         if (bind(sockfd, p->ai_addr, p->ai_addrlen) == -1) {\n#if defined(WINGS)\n         closesocket(sockfd);\n#else\n         close(sockfd);\n#endif\n            perror(\"server: bind error\");\n            continue;\n         }\n         break;\n      }\n      if (p == NULL)  {\n         fprintf(stderr, \"server: failed to bind\\n\");\n         ret = 2;\n      }else{\n         freeaddrinfo(servinfo); // all done with this structure\n         if (listen(sockfd, BACKLOG) == -1) {\n            perror(\"server: listen error\");\n            ret = 3;\n         }\n      }\n      if (ret == 0){\n         return self;\n      }\n   }\n   return nil;\n}\n\n- (BOOL) accept {\n   BOOL ret = YES;\n#if defined(WINGS)\n   new_fd = accept(sockfd, NULL, NULL);\n#else\n   new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size);\n#endif\n   if (new_fd == -1) {\n      perror(\"server: accept error\");\n      ret = NO;\n   }\n   connected = ret;\n   return ret;\n}\n\n- (int) sendBytes: (char*) byteMsg OfLength: (int) msgLength Index: (int) at{\n   int ret = send(new_fd, byteMsg, msgLength, 0);\n   if(ret == -1){\n      NSLog(@\"error sending bytes\");\n   }\n   return ret;\n}\n\n- (NSString* ) receiveBytes: (char*) byteMsg\n                   maxBytes: (int) max\n                    beginAt: (int) at {\n   int ret = recv(new_fd, byteMsg, max-1, at);\n   if(ret == -1){\n      NSLog(@\"server error receiving bytes\");\n   }\n   byteMsg[ret+at] = '\\0';\n   NSString * retStr = [NSString stringWithUTF8String: byteMsg];\n   return retStr;\n}\n\n- (BOOL) close{\n#if defined(WINGS)\n   closesocket(new_fd);\n#else\n   close(new_fd);\n#endif\n   connected = NO;\n   return YES;\n}\n\n- (void) dealloc {\n#if defined(WINGS)\n   closesocket(sockfd);\n#else\n   close(sockfd);\n#endif\n   [super dealloc];\n}\n\n@end\n\n@implementation Cst502ClientSocket\n- (id) initWithHost: (NSString*) host portNumber: (NSString*) port {\n   self = [super init];\n   hostName = host;\n   [hostName retain];\n   portNum = port;\n   [portNum retain];\n   return self;\n}\n\n- (BOOL) connect {\n   connected = YES;\n   memset(&hints, 0, sizeof hints);\n   hints.ai_family = AF_UNSPEC;\n   hints.ai_socktype = SOCK_STREAM;\n   if ((rv = getaddrinfo([hostName UTF8String], [portNum UTF8String],\n                         &hints, &servinfo)) != 0) {\n      fprintf(stderr, \"client error getting host address: %s\\n\",\n              gai_strerror(rv));\n      connected = NO;\n   }\n   // loop through all the results and connect to the first we can\n   for(p = servinfo; p != NULL; p = p->ai_next) {\n      if ((sockfd = socket(p->ai_family,p->ai_socktype,p->ai_protocol)) == -1){\n         perror(\"client error creating socket\");\n         connected = NO;\n         continue;\n      }\n      int callret = connect(sockfd, p->ai_addr, p->ai_addrlen);\n      if (callret == -1) {\n#if defined(WINGS)\n         closesocket(sockfd);\n#else\n         close(sockfd);\n#endif\n#if defined(WINGS)\n         //printf(\"client failed to connect.\\n\");\n#else\n         inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr),\n                   s, sizeof s);\n//         printf(\"client failed to connect to %s\\n\", s);\n#endif\n         //perror(\"client error connecting\");\n         connected = NO;\n         continue;\n      }\n      break;\n   }\n   if (p == NULL) {\n //     printf(\"client failed to connect\\n\");\n      connected = NO;\n   }else{\n#if defined(WINGS)\n      //printf(\"client connected\\n\");\n#else\n      inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr),\n                s, sizeof s);\n      //printf(\"client connected to %s\\n\", s);\n#endif\n      connected = YES;\n   }\n   return connected;\n}\n\n- (int) sendBytes: (char*) byteMsg OfLength: (int) msgLength Index: (int) at{\n   int ret = send(sockfd, byteMsg, msgLength, 0);\n   if(ret == -1){\n      NSLog(@\"client error sending bytes\");\n   }\n   return ret;\n}\n\n- (NSString*) receiveBytes: (char*) byteMsg\n                  maxBytes: (int) max\n                   beginAt: (int) at {\n   int ret = recv(sockfd, byteMsg, max-1, at);\n   if(ret == -1){\n      NSLog(@\"client error receiving bytes\");\n   }\n   byteMsg[ret+at] = '\\0';\n   NSString * retStr = [NSString stringWithUTF8String: byteMsg];\n   return retStr;\n}\n\n- (void) sendString: (NSString*)str {\n    [self sendBytes:(char*)[str UTF8String] OfLength:[str length] Index:0];\n}\n\n- (BOOL) close{\n   connected = NO;\n   return YES;\n}\n\n- (void) dealloc {\n   [hostName release];\n   [portNum release];\n   [super dealloc];\n}\n\n@end\n\n"
  },
  {
    "path": "src/objc/NSCommon.h",
    "content": "//\n//  NSCommon.h\n//  sample\n//\n//  Created by Gal Dolber on 2/4/14.\n//  Copyright (c) 2014 clojure-objc. All rights reserved.\n//\n\n// Supported types\n// -------------------\n// float\n// long long\n// long\n// char\n// short\n// int\n// double\n// long double\n// unsigned long long\n// unsigned long\n// unsigned char\n// unsigned short\n// unsigned int\n// bool\n// CGPoint\n// NSRange\n// UIEdgeInsets\n// CGSize\n// CGAffineTransform\n// CATransform3D\n// UIOffset\n// CGRect\n// id\n// void\n\n#import <Foundation/Foundation.h>\n#import \"clojure/lang/AFn.h\"\n#import \"clojure/lang/Atom.h\"\n\nstatic ClojureLangAtom *dynamicClasses;\n\n#define to_char(c)\\\n[(JavaLangCharacter*)c charValue]\\\n\n// Necessary for inline functions\nstatic NSMutableDictionary *global_functions;\n\n#define register_fn(n)\\\n[global_functions setObject:[NSValue valueWithPointer:n] forKey:@#n];\\\n\nstatic const char void_type = 'v';\nstatic const char float_type = 'f';\nstatic const char longlong_type = 'q';\nstatic const char long_type = 'l';\nstatic const char char_type = 'c';\nstatic const char short_type = 's';\nstatic const char int_type = 'i';\nstatic const char double_type = 'd';\nstatic const char longdouble_type = 'D';\nstatic const char ulonglong_type = 'Q';\nstatic const char ulong_type = 'L';\nstatic const char uchar_type = 'C';\nstatic const char ushort_type = 'S';\nstatic const char uint_type = 'I';\nstatic const char bool_type = 'b';\nstatic const char cgpoint_type = 'P';\nstatic const char nsrange_type = 'N';\nstatic const char uiedge_type = 'E';\nstatic const char cgsize_type = 'Z';\nstatic const char cgaffinetransform_type = 'A';\nstatic const char catransform3d_type = 'T';\nstatic const char uioffset_type = 'O';\nstatic const char cgrect_type = 'R';\nstatic const char id_type = 'p';\nstatic const char pointer_type = 'Y';\n\nchar signatureToType(const char* c);\n\nid signaturesToTypes(NSMethodSignature* sig, BOOL skip);\n\nconst char* makeSignature(id types);\n\nvoid* callWithArgs(void **argsp, id sself, id types, ClojureLangAFn *fn);\n\nvoid callWithInvocation(NSInvocation *invocation, id sself, id types, ClojureLangAFn *fn);\n\n@interface NSCommon : NSObject\n\n+(BOOL)cgfloatIsDouble;\n\n+(id)ccall:(id)name types:(id)types args:(id)args;\n\n+(id)invokeFun:(NSString*)fun withSelf:(id)object withSelector:(NSString*)selector withArgs:(id<ClojureLangISeq>)arguments;\n\n+(id)invokeSel:(id)object withSelector:(NSString*)selector withArgs:(id<ClojureLangISeq>)arguments;\n\n+(id)invokeSuperSel:(id)object withDispatchClass:(id)clazz withSelector:(NSString*)selector withArgs:(id<ClojureLangISeq>)arguments;\n\n@end\n"
  },
  {
    "path": "src/objc/NSCommon.m",
    "content": "//\n//  NSCommon.m\n//  sample\n//\n//  Created by Gal Dolber on 2/4/14.\n//  Copyright (c) 2014 clojure-objc. All rights reserved.\n//\n\n#import \"NSCommon.h\"\n#import \"clojure/lang/RemoteRepl.h\"\n#import \"clojure/lang/AFn.h\"\n#import \"clojure/lang/RT.h\"\n#import \"clojure/lang/Atom.h\"\n#import \"clojure/lang/PersistentVector.h\"\n#import \"clojure/lang/PersistentHashMap.h\"\n#import \"clojure/lang/Selector.h\"\n#import \"clojure/lang/Var.h\"\n#import \"java/lang/Character.h\"\n#import \"java/lang/Boolean.h\"\n#import \"java/lang/Integer.h\"\n#import \"java/lang/Double.h\"\n#import \"java/lang/Float.h\"\n#import \"java/lang/Long.h\"\n#import \"java/lang/Short.h\"\n#import \"ffi.h\"\n#import \"objc/runtime.h\"\n#import \"objc/message.h\"\n#import <UIKit/UIKit.h>\n#import \"WeakRef.h\"\n#import <dlfcn.h>\n\nstatic id cons;\nstatic id fconj;\nstatic id assoc;\n\nstatic bool classIsDynamic(Class clazz) {\n    return [ClojureLangRT getWithId:[dynamicClasses deref] withId:NSStringFromClass(clazz)] != nil;\n}\n\n#if CGFLOAT_IS_DOUBLE\n#define CGFloatFFI &ffi_type_double\n#else\n#define CGFloatFFI &ffi_type_float\n#endif\n\nstatic ffi_type CGPointFFI = (ffi_type){\n    .size = 0,\n    .alignment = 0,\n    .type = FFI_TYPE_STRUCT,\n    .elements = (ffi_type * [3]){CGFloatFFI, CGFloatFFI, NULL}};\n\nstatic ffi_type CGSizeFFI = (ffi_type){\n    .size = 0,\n    .alignment = 0,\n    .type = FFI_TYPE_STRUCT,\n    .elements = (ffi_type * [3]){CGFloatFFI, CGFloatFFI, NULL}};\n\nstatic ffi_type CGRectFFI = (ffi_type){\n    .size = 0,\n    .alignment = 0,\n    .type = FFI_TYPE_STRUCT,\n    .elements = (ffi_type * [3]){&CGPointFFI, &CGSizeFFI, NULL}};\n\nstatic ffi_type NSRangeFFI = (ffi_type){\n    .size = 0,\n    .alignment = 0,\n    .type = FFI_TYPE_STRUCT,\n    .elements = (ffi_type * [3]){&ffi_type_uint, &ffi_type_uint, NULL}};\n\nstatic ffi_type UIEdgeInsetsFFI = (ffi_type){\n    .size = 0,\n    .alignment = 0,\n    .type = FFI_TYPE_STRUCT,\n    .elements = (ffi_type * [5]){CGFloatFFI, CGFloatFFI, CGFloatFFI, CGFloatFFI, NULL}};\n\nstatic ffi_type UIOffsetFFI = (ffi_type){\n    .size = 0,\n    .alignment = 0,\n    .type = FFI_TYPE_STRUCT,\n    .elements = (ffi_type * [3]){CGFloatFFI, CGFloatFFI, NULL}};\n\nstatic ffi_type CATransform3DFFI = (ffi_type){\n    .size = 0,\n    .alignment = 0,\n    .type = FFI_TYPE_STRUCT,\n    .elements = (ffi_type * [17]){\n        CGFloatFFI, CGFloatFFI, CGFloatFFI, CGFloatFFI,\n        CGFloatFFI, CGFloatFFI, CGFloatFFI, CGFloatFFI,\n        CGFloatFFI, CGFloatFFI, CGFloatFFI, CGFloatFFI,\n        CGFloatFFI, CGFloatFFI, CGFloatFFI, CGFloatFFI,\n        NULL}};\n\nstatic ffi_type CGAffineTransformFFI = (ffi_type){\n    .size = 0,\n    .alignment = 0,\n    .type = FFI_TYPE_STRUCT,\n    .elements = (ffi_type * [7]){\n        CGFloatFFI, CGFloatFFI, CGFloatFFI, CGFloatFFI, CGFloatFFI, CGFloatFFI, NULL}};\n\nconst char* encode_type(char d) {\n    switch (d) {\n        case void_type: return @encode(void);\n        case float_type: return @encode(float);\n        case long_type: return @encode(long);\n        case longlong_type: return @encode(long long);\n        case char_type: return @encode(char);\n        case short_type: return @encode(short);\n        case int_type: return @encode(int);\n        case double_type: return @encode(double);\n        case longdouble_type: return @encode(long double);\n        case ulong_type: return @encode(unsigned long);\n        case ulonglong_type: return @encode(unsigned long long);\n        case uchar_type: return @encode(unsigned char);\n        case ushort_type: return @encode(unsigned short);\n        case uint_type: return @encode(unsigned int);\n        case bool_type: return @encode(BOOL);\n        case id_type: return @encode(id);\n        case cgpoint_type: return @encode(CGPoint);\n        case nsrange_type: return @encode(NSRange);\n        case uiedge_type: return @encode(UIEdgeInsets);\n        case cgsize_type: return @encode(CGSize);\n        case cgaffinetransform_type: return @encode(CGAffineTransform);\n        case catransform3d_type: return @encode(CATransform3D);\n        case uioffset_type: return @encode(UIOffset);\n        case cgrect_type: return @encode(CGRect);\n        case pointer_type: return @encode(void*);\n    }\n    return @encode(id);\n}\n\nvoid * ffi_type_for_type(char type) {\n    switch (type) {\n        case void_type: return &ffi_type_void;\n        case float_type: return &ffi_type_float;\n        case longlong_type: return &ffi_type_sint64;\n        case long_type: return &ffi_type_slong;\n        case char_type: return &ffi_type_schar;\n        case short_type: return &ffi_type_sshort;\n        case int_type: return &ffi_type_sint;\n        case double_type: return &ffi_type_double;\n        case longdouble_type: return &ffi_type_longdouble;\n        case ulonglong_type: return &ffi_type_uint64;\n        case ulong_type: return &ffi_type_ulong;\n        case uchar_type: return &ffi_type_uchar;\n        case ushort_type: return &ffi_type_ushort;\n        case uint_type: return &ffi_type_uint;\n        case bool_type: return &ffi_type_schar;\n        case cgpoint_type: return &CGPointFFI;\n        case nsrange_type: return &NSRangeFFI;\n        case uiedge_type: return &UIEdgeInsetsFFI;\n        case cgsize_type: return &CGSizeFFI;\n        case cgaffinetransform_type: return &CGAffineTransformFFI;\n        case catransform3d_type: return &CATransform3DFFI;\n        case uioffset_type: return &UIOffsetFFI;\n        case cgrect_type: return &CGRectFFI;\n        default: return &ffi_type_pointer;\n    }\n}\n\nint sizeof_type(char c) {\n    switch (c) {\n        case void_type: return sizeof(void);\n        case float_type: return sizeof(float);\n        case long_type: return sizeof(long);\n        case longlong_type: return sizeof(long long);\n        case char_type: return sizeof(char);\n        case short_type: return sizeof(short);\n        case int_type: return sizeof(int);\n        case double_type: return sizeof(double);\n        case longdouble_type: return sizeof(long double);\n        case ulong_type: return sizeof(unsigned long);\n        case ulonglong_type: return sizeof(unsigned long long);\n        case uchar_type: return sizeof(unsigned char);\n        case ushort_type: return sizeof(unsigned short);\n        case uint_type: return sizeof(unsigned int);\n        case bool_type: return sizeof(BOOL);\n        case cgpoint_type: return sizeof(CGPoint);\n        case nsrange_type: return sizeof(NSRange);\n        case uiedge_type: return sizeof(UIEdgeInsets);\n        case cgsize_type: return sizeof(CGSize);\n        case cgaffinetransform_type: return sizeof(CGAffineTransform);\n        case catransform3d_type: return sizeof(CATransform3D);\n        case uioffset_type: return sizeof(UIOffset);\n        case cgrect_type: return sizeof(CGRect);\n        case pointer_type: return sizeof(void*);\n    }\n    return sizeof(id);\n}\n\nid signaturesToTypes(NSMethodSignature* sig, BOOL skip) {\n    id types = ClojureLangPersistentVector_get_EMPTY_();\n    types = [fconj invokeWithId:types withId:[[[JavaLangCharacter alloc] initWithChar:signatureToType([sig methodReturnType])] autorelease]];\n    for (int n = 0; n < [sig numberOfArguments]; n++) {\n        if (!skip || (n != 0 && n != 1)) {\n            types = [fconj invokeWithId:types withId:[[[JavaLangCharacter alloc] initWithChar: signatureToType([sig getArgumentTypeAtIndex:n])] autorelease]];\n        }\n    }\n    return types;\n}\n\n// https://developer.apple.com/library/mac/documentation/cocoa/conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html\nchar signatureToType(const char* c) {\n    switch (*c) {\n        case _C_CONST:                        // const\n        case 'n':                             // in\n        case 'N':                             // inout\n        case 'o':                             // out\n        case 'O':                             // bycopy\n        case 'R':                             // byref\n        case 'V':                             // oneway\n            c++;\n            return signatureToType(c);\n        case _C_FLT: return float_type;\n        case _C_LNG_LNG: return longlong_type;\n        case _C_LNG: return long_type;\n        case _C_CHR: return char_type;\n        case _C_SHT: return short_type;\n        case _C_INT: return int_type;\n        case _C_BOOL: return bool_type;\n        case _C_DBL: return double_type;\n        case _C_ULNG_LNG: return ulonglong_type;\n        case _C_ULNG: return ulong_type;\n        case _C_UCHR: return uchar_type;\n        case _C_USHT: return ushort_type;\n        case _C_UINT: return uint_type;\n        case _C_VOID: return void_type;\n        case 'D': return longdouble_type;\n        case _C_CHARPTR:\n        case _C_SEL:\n        case _C_PTR:\n            return pointer_type;\n        case _C_CLASS:\n        case _C_ID:\n        case _C_UNDEF:\n            return id_type;\n        case _C_STRUCT_B: {\n            if (strcmp(c, @encode(CGPoint)) == 0) {\n                return cgpoint_type;\n            } else if (strcmp(c, @encode(NSRange)) == 0) {\n                return nsrange_type;\n            } else if (strcmp(c, @encode(UIEdgeInsets)) == 0) {\n                return uiedge_type;\n            } else if (strcmp(c, @encode(CGSize)) == 0) {\n                return  cgsize_type;\n            } else if (strcmp(c, @encode(CGAffineTransform)) == 0) {\n                return cgaffinetransform_type;\n            } else if (strcmp(c, @encode(CATransform3D)) == 0) {\n                return catransform3d_type;\n            } else if (strcmp(c, @encode(UIOffset)) == 0) {\n                return uioffset_type;\n            } else if (strcmp(c, @encode(CGRect)) == 0) {\n                return cgrect_type;\n            }\n        }\n    }\n    @throw [NSException exceptionWithName:@\"Type signature not found\" reason:[NSString stringWithUTF8String:c] userInfo:nil];\n}\n\nvoid * malloc_ret(char c) {\n    if (c == void_type) {\n        return malloc(sizeof_type(id_type));\n    }\n    return malloc(sizeof_type(c));\n}\n\n// https://developer.apple.com/library/ios/documentation/Xcode/Conceptual/iPhoneOSABIReference/iPhoneOSABIReference.pdf\nBOOL use_stret(char ret) {\n    switch (ret) {\n        case cgrect_type:\n        case cgpoint_type:\n        case nsrange_type:\n        case uiedge_type:\n        case cgsize_type:\n        case cgaffinetransform_type:\n        case catransform3d_type:\n        case uioffset_type: {\n#if TARGET_IPHONE_SIMULATOR\n            return sizeof_type(ret) > 8;\n#else\n            return sizeof_type(ret) >= 8;\n#endif\n            break;\n        }\n    }\n    return NO;\n}\n\n#define pval(type)\\\n(type)*((type*)argsp[j])\\\n\nvoid* callWithArgs(void **argsp, id sself, id types, ClojureLangAFn *fn) {\n    id args = ClojureLangPersistentVector_get_EMPTY_();\n    args = [fconj invokeWithId:args withId:[WeakRef from:sself]];\n    ClojureLangPersistentVector *typesa = [ClojureLangPersistentVector createWithClojureLangISeq:types];\n    char retType = to_char([typesa nthWithInt:0]);\n    long typesc = [typesa count];\n    for (int n = 2; n < typesc; n++) {\n        id val = nil;\n        int j = n - 2;\n        switch (to_char([typesa nthWithInt:n])) {\n            case void_type: {\n                break;\n            }\n            case float_type: {\n                val = [ClojureLangRT boxWithFloat:pval(float)];\n                break;\n            }\n            case longlong_type: {\n                val = [ClojureLangRT boxWithLong:pval(long long)];\n                break;\n            }\n            case long_type: {\n                val = [ClojureLangRT boxWithLong:pval(long)];\n                break;\n            }\n            case char_type: {\n                char c = pval(char);\n                val = c == YES ? JavaLangBoolean_get_TRUE__() : (c == NO ? JavaLangBoolean_get_FALSE__() : [ClojureLangRT boxWithChar:pval(char)]);\n                break;\n            }\n            case short_type: {\n                val = [ClojureLangRT boxWithShort:pval(short)];\n                break;\n            }\n            case int_type: {\n                val = [ClojureLangRT boxWithInt:pval(int)];\n                break;\n            }\n            case longdouble_type: {\n                val = [ClojureLangRT boxWithDouble:pval(long double)];\n                break;\n            }\n            case double_type: {\n                val = [ClojureLangRT boxWithDouble:pval(double)];\n                break;\n            }\n            case ulong_type: {\n                val = [ClojureLangRT boxWithLong:pval(unsigned long)];\n                break;\n            }\n            case ulonglong_type: {\n                val = [ClojureLangRT boxWithLong:pval(unsigned long long)];\n                break;\n            }\n            case uchar_type: {\n                val = [ClojureLangRT boxWithChar:pval(unsigned char)];\n                break;\n            }\n            case ushort_type: {\n                val = [ClojureLangRT boxWithShort:pval(unsigned short)];\n                break;\n            }\n            case uint_type: {\n                val = [ClojureLangRT boxWithInt:pval(unsigned int)];\n                break;\n            }\n            case bool_type: {\n                val = pval(char) == YES ? JavaLangBoolean_get_TRUE__() : JavaLangBoolean_get_FALSE__();\n                break;\n            }\n            case id_type: {\n                val = pval(void*);\n                break;\n            }\n            case cgpoint_type: {\n                val = [NSValue valueWithCGPoint:pval(CGPoint)];\n                break;\n            }\n            case nsrange_type: {\n                val = [NSValue valueWithRange:pval(NSRange)];\n                break;\n            }\n            case uiedge_type: {\n                val = [NSValue valueWithUIEdgeInsets:pval(UIEdgeInsets)];\n                break;\n            }\n            case cgsize_type: {\n                val = [NSValue valueWithCGSize:pval(CGSize)];\n                break;\n            }\n            case cgaffinetransform_type: {\n                val = [NSValue valueWithCGAffineTransform:pval(CGAffineTransform)];\n                break;\n            }\n            case catransform3d_type: {\n                val = [NSValue valueWithCATransform3D:pval(CATransform3D)];\n                break;\n            }\n            case uioffset_type: {\n                val = [NSValue valueWithUIOffset:pval(UIOffset)];\n                break;\n            }\n            case cgrect_type: {\n                val = [NSValue valueWithCGRect:pval(CGRect)];\n                break;\n            }\n            case pointer_type: {\n                val = [NSValue valueWithPointer:pval(void*)];\n                break;\n            }\n            default: @throw [NSException exceptionWithName:@\"Error\"\n                                                    reason:[NSString stringWithFormat:@\"%@\",\n                                                            [typesa nthWithInt:n]] userInfo:nil];\n        }\n        args = [fconj invokeWithId:args withId:val];\n        free(argsp[j]);\n    }\n    \n    id v = [fn applyToWithClojureLangISeq:[ClojureLangRT seqWithId:args]];\n    void * ret;\n    \n    switch (retType) {\n        case void_type: {\n            id r = nil;\n            ret = &r;\n            break;\n        }\n        case float_type: {\n            float o = [ClojureLangRT floatCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case longlong_type: {\n            long long o = [ClojureLangRT longCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case long_type: {\n            long o = (long)[ClojureLangRT longCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case char_type: {\n            char o = [ClojureLangRT charCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case short_type: {\n            short o = [ClojureLangRT shortCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case int_type: {\n            int o = [ClojureLangRT intCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case longdouble_type: {\n            long double o = [ClojureLangRT doubleCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case double_type: {\n            double o = [ClojureLangRT doubleCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case ulong_type: {\n            unsigned long o = (unsigned long)[ClojureLangRT longCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case ulonglong_type: {\n            unsigned long long o = [ClojureLangRT longCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case uchar_type: {\n            unsigned char o = [ClojureLangRT charCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case ushort_type: {\n            unsigned short o = [ClojureLangRT shortCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case uint_type: {\n            unsigned int o = [ClojureLangRT intCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case bool_type: {\n            BOOL o = [ClojureLangRT booleanCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case id_type: {\n            ret = &v;\n            break;\n        }\n        case cgpoint_type: {\n            CGPoint o = [((NSValue*) v) CGPointValue];\n            ret = &o;\n            break;\n        }\n        case nsrange_type: {\n            NSRange o = [((NSValue*) v) rangeValue];\n            ret = &o;\n            break;\n        }\n        case uiedge_type: {\n            UIEdgeInsets o = [((NSValue*) v) UIEdgeInsetsValue];\n            ret = &o;\n            break;\n        }\n        case cgsize_type: {\n            CGSize o = [((NSValue*) v) CGSizeValue];\n            ret = &o;\n            break;\n        }\n        case cgaffinetransform_type: {\n            CGAffineTransform o = [((NSValue*) v) CGAffineTransformValue];\n            ret = &o;\n            break;\n        }\n        case catransform3d_type: {\n            CATransform3D o = [((NSValue*) v) CATransform3DValue];\n            ret = &o;\n            break;\n        }\n        case uioffset_type: {\n            UIOffset o = [((NSValue*) v) UIOffsetValue];\n            ret = &o;\n            break;\n        }\n        case cgrect_type: {\n            CGRect o = [((NSValue*) v) CGRectValue];\n            ret = &o;\n            break;\n        }\n        case pointer_type: {\n            void* o = [((NSValue*) v) pointerValue];\n            ret = &o;\n            break;\n        }\n        default: {\n            @throw [NSException exceptionWithName:@\"Missing type\" reason:[NSString stringWithFormat:@\"%c\", retType] userInfo:nil];\n        }\n    }\n    \n    return ret;\n}\n\nvoid callWithInvocation(NSInvocation *invocation, id sself, id types, ClojureLangAFn *fn) {\n    id args = ClojureLangPersistentVector_get_EMPTY_();\n    args = [fconj invokeWithId:args withId:[WeakRef from:sself]];\n    IOSObjectArray *typesa = [ClojureLangRT toArrayWithId:types];\n    char retType = to_char([typesa objectAtIndex:0]);\n    long typesc = [typesa length];\n    for (int n = 1; n < typesc; n++) {\n        id val = nil;\n        int j = n + 1;\n        switch (to_char([typesa objectAtIndex:n])) {\n            case void_type: {\n                break;\n            }\n            case float_type: {\n                float v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithFloat:v];\n                break;\n            }\n            case longlong_type: {\n                long long v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithLong:v];\n                break;\n            }\n            case long_type: {\n                long v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithLong:v];\n                break;\n            }\n            case char_type: {\n                char v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithChar:v];\n                break;\n            }\n            case short_type: {\n                short v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithShort:v];\n                break;\n            }\n            case int_type: {\n                int v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithInt:v];\n                break;\n            }\n            case longdouble_type: {\n                long double v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithDouble:v];\n                break;\n            }\n            case double_type: {\n                double v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithDouble:v];\n                break;\n            }\n            case ulong_type: {\n                unsigned long v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithLong:v];\n                break;\n            }\n            case ulonglong_type: {\n                unsigned long long v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithLong:v];\n                break;\n            }\n            case uchar_type: {\n                unsigned char v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithChar:v];\n                break;\n            }\n            case ushort_type: {\n                unsigned short v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithShort:v];\n                break;\n            }\n            case uint_type: {\n                unsigned int v;\n                [invocation getArgument:&v atIndex: j];\n                val = [ClojureLangRT boxWithInt:v];\n                break;\n            }\n            case bool_type: {\n                char v;\n                [invocation getArgument:&v atIndex: j];\n                val = v == YES ? JavaLangBoolean_get_TRUE__() : JavaLangBoolean_get_FALSE__();\n                break;\n            }\n            case id_type: {\n                void * v;\n                [invocation getArgument:&v atIndex:j];\n                val = v;\n                break;\n            }\n            case cgpoint_type: {\n                CGPoint v;\n                [invocation getArgument:&v atIndex: j];\n                val = [NSValue valueWithCGPoint:v];\n                break;\n            }\n            case nsrange_type: {\n                NSRange v;\n                [invocation getArgument:&v atIndex: j];\n                val = [NSValue valueWithRange:v];\n                break;\n            }\n            case uiedge_type: {\n                UIEdgeInsets v;\n                [invocation getArgument:&v atIndex: j];\n                val = [NSValue valueWithUIEdgeInsets:v];\n                break;\n            }\n            case cgsize_type: {\n                CGSize v;\n                [invocation getArgument:&v atIndex: j];\n                val = [NSValue valueWithCGSize:v];\n                break;\n            }\n            case cgaffinetransform_type: {\n                CGAffineTransform v;\n                [invocation getArgument:&v atIndex: j];\n                val = [NSValue valueWithCGAffineTransform:v];\n                break;\n            }\n            case catransform3d_type: {\n                CATransform3D v;\n                [invocation getArgument:&v atIndex: j];\n                val = [NSValue valueWithCATransform3D:v];\n                break;\n            }\n            case uioffset_type: {\n                UIOffset v;\n                [invocation getArgument:&v atIndex: j];\n                val = [NSValue valueWithUIOffset:v];\n                break;\n            }\n            case cgrect_type: {\n                CGRect v;\n                [invocation getArgument:&v atIndex: j];\n                val = [NSValue valueWithCGRect:v];\n                break;\n            }\n            case pointer_type: {\n                void* v;\n                [invocation getArgument:&v atIndex: j];\n                val = [NSValue valueWithPointer:v];\n                break;\n            }\n            default: @throw [NSException exceptionWithName:@\"Error\"\n                                                    reason:[NSString stringWithFormat:@\"%@\",\n                                                            [typesa objectAtIndex:n]] userInfo:nil];\n        }\n        args = [fconj invokeWithId:args withId:val];\n    }\n    id v = [fn applyToWithClojureLangISeq:[ClojureLangRT seqWithId:args]];\n    \n    void * ret;\n    \n    switch (retType) {\n        case void_type: {\n            id r = nil;\n            ret = &r;\n            break;\n        }\n        case float_type: {\n            float o = [ClojureLangRT floatCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case longlong_type: {\n            long long o = [ClojureLangRT longCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case long_type: {\n            long o = (long)[ClojureLangRT longCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case char_type: {\n            char o = [ClojureLangRT charCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case short_type: {\n            short o = [ClojureLangRT shortCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case int_type: {\n            int o = [ClojureLangRT intCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case double_type: {\n            double o = [ClojureLangRT doubleCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case longdouble_type: {\n            long double o = [ClojureLangRT doubleCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case ulong_type: {\n            unsigned long o = (unsigned long)[ClojureLangRT longCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case ulonglong_type: {\n            unsigned long long o = [ClojureLangRT longCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case uchar_type: {\n            unsigned char o = [ClojureLangRT charCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case ushort_type: {\n            unsigned short o = [ClojureLangRT shortCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case uint_type: {\n            unsigned int o = [ClojureLangRT intCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case bool_type: {\n            BOOL o = [ClojureLangRT booleanCastWithId:v];\n            ret = &o;\n            break;\n        }\n        case id_type: {\n            ret = &v;\n            break;\n        }\n        case cgpoint_type: {\n            CGPoint o = [((NSValue*) v) CGPointValue];\n            ret = &o;\n            break;\n        }\n        case nsrange_type: {\n            NSRange o = [((NSValue*) v) rangeValue];\n            ret = &o;\n            break;\n        }\n        case uiedge_type: {\n            UIEdgeInsets o = [((NSValue*) v) UIEdgeInsetsValue];\n            ret = &o;\n            break;\n        }\n        case cgsize_type: {\n            CGSize o = [((NSValue*) v) CGSizeValue];\n            ret = &o;\n            break;\n        }\n        case cgaffinetransform_type: {\n            CGAffineTransform o = [((NSValue*) v) CGAffineTransformValue];\n            ret = &o;\n            break;\n        }\n        case catransform3d_type: {\n            CATransform3D o = [((NSValue*) v) CATransform3DValue];\n            ret = &o;\n            break;\n        }\n        case uioffset_type: {\n            UIOffset o = [((NSValue*) v) UIOffsetValue];\n            ret = &o;\n            break;\n        }\n        case cgrect_type: {\n            CGRect o = [((NSValue*) v) CGRectValue];\n            ret = &o;\n            break;\n        }\n        case pointer_type: {\n            void* o = [((NSValue*) v) pointerValue];\n            ret = &o;\n            break;\n        }\n        default: {\n            @throw [NSException exceptionWithName:@\"Missing type\" reason:[NSString stringWithFormat:@\"%c\", retType] userInfo:nil];\n        }\n    }\n    if (retType != 'v') {\n        [invocation setReturnValue:ret];\n    }\n}\n\nid boxValue(void* val, char type) {\n    id result;\n    switch (type) {\n        case void_type: {\n            return [NSNull null];\n        }\n        case float_type: {\n            return [ClojureLangRT boxWithFloat:*(float*)val];\n        }\n        case long_type: {\n            return [ClojureLangRT boxWithLong:(long)*(long*)val];\n        }\n        case longlong_type: {\n            return [ClojureLangRT boxWithLong:*(long long*)val];\n        }\n        case char_type: {\n            if (*(char*)val == YES) {\n                return JavaLangBoolean_get_TRUE__();\n            } else if (*(char*)val == NO) {\n                return JavaLangBoolean_get_FALSE__();\n            } else {\n                return [ClojureLangRT boxWithChar:*(char*)val];\n            }\n        }\n        case short_type: {\n            return [ClojureLangRT boxWithShort:*(short*)val];\n        }\n        case int_type: {\n            return [ClojureLangRT boxWithInt:*(int*)val];\n        }\n        case double_type: {\n            return [ClojureLangRT boxWithDouble:*(double*)val];\n        }\n        case longdouble_type: {\n            return [ClojureLangRT boxWithDouble:*(long double*)val];\n        }\n        case ulong_type: {\n            return [ClojureLangRT boxWithLong:(unsigned long)*(unsigned long*)val];\n        }\n        case ulonglong_type: {\n            return [ClojureLangRT boxWithLong:(unsigned long long)*(unsigned long long*)val];\n        }\n        case uchar_type: {\n            return [ClojureLangRT boxWithChar:*(unsigned char*)val];\n        }\n        case ushort_type: {\n            return [ClojureLangRT boxWithShort:*(unsigned short*)val];\n        }\n        case uint_type: {\n            return [ClojureLangRT boxWithInt:*(unsigned int*)val];\n        }\n        case bool_type: {\n            return *(char*)val == YES ? JavaLangBoolean_get_TRUE__() : JavaLangBoolean_get_FALSE__();\n        }\n        case cgpoint_type: {\n            return [NSValue valueWithCGPoint:*(CGPoint*)val];\n        }\n        case nsrange_type: {\n            return [NSValue valueWithRange:*(NSRange*)val];\n        }\n        case uiedge_type: {\n            return [NSValue valueWithUIEdgeInsets:*(UIEdgeInsets*)val];\n        }\n        case cgsize_type: {\n            return [NSValue valueWithCGSize:*(CGSize*)val];\n        }\n        case cgaffinetransform_type: {\n            return [NSValue valueWithCGAffineTransform:*(CGAffineTransform*)val];\n        }\n        case catransform3d_type: {\n            return [NSValue valueWithCATransform3D:*(CATransform3D*)val];\n        }\n        case uioffset_type: {\n            return [NSValue valueWithUIOffset:*(UIOffset*)val];\n        }\n        case cgrect_type: {\n            return [NSValue valueWithCGRect:*(CGRect*)val];\n        }\n        case pointer_type: {\n            return [NSValue valueWithPointer:val];\n        }\n        default: {\n            return *(void**)val;\n        }\n    }\n}\n\n#define make_pointer(e,type)\\\ntype o = e;\\\ntype *p = malloc(sizeof(type));\\\n*p = o;\\\nargument_values[n] = p;\\\nbreak;\\\n\nstatic id ccallWithFn(void* fn, ClojureLangPersistentVector *types, id args) {\n    if (![args isKindOfClass:[ClojureLangPersistentVector class]]) {\n        args = [ClojureLangPersistentVector createWithClojureLangISeq:args];\n    }\n    char retType = to_char([types nthWithInt:0]);\n    void *result_value = malloc_ret(retType);\n    \n    long count = [(ClojureLangPersistentVector*)args count];\n    ffi_type **argument_types = (ffi_type **) malloc ((count + 1) * sizeof(ffi_type *));\n    void **argument_values = (void **) malloc ((count + 1) * sizeof(void *));\n    for (int n=0; n < count; n++) {\n        char type = to_char([types nthWithInt:n+1]);\n        argument_types[n] = ffi_type_for_type(type);\n        id v = [args nthWithInt: n];\n        switch (type) {\n            case void_type: {\n                make_pointer([NSNull null], id);\n            }\n            case float_type: {\n                make_pointer([ClojureLangRT floatCastWithId:v], float);\n            }\n            case longlong_type: {\n                make_pointer([ClojureLangRT longCastWithId:v], long long);\n            }\n            case long_type: {\n                make_pointer((long)[ClojureLangRT longCastWithId:v], long);\n            }\n            case char_type: {\n                if ([v isKindOfClass:[JavaLangBoolean class]]) {\n                    make_pointer([ClojureLangRT booleanCastWithId:v], BOOL);\n                } else {\n                    make_pointer([ClojureLangRT charCastWithId:v], char);\n                }\n            }\n            case short_type: {\n                make_pointer([ClojureLangRT shortCastWithId:v], short);\n            }\n            case int_type: {\n                make_pointer([ClojureLangRT intCastWithId:v], int);\n            }\n            case double_type: {\n                make_pointer([ClojureLangRT doubleCastWithId:v], double);\n            }\n            case longdouble_type: {\n                make_pointer([ClojureLangRT doubleCastWithId:v], long double);\n            }\n            case ulong_type: {\n                make_pointer((unsigned long)[ClojureLangRT longCastWithId:v], unsigned long);\n            }\n            case ulonglong_type: {\n                make_pointer([ClojureLangRT longCastWithId:v], unsigned long long);\n            }\n            case uchar_type: {\n                make_pointer([ClojureLangRT charCastWithId:v], unsigned char);\n            }\n            case ushort_type: {\n                make_pointer([ClojureLangRT shortCastWithId:v], unsigned short);\n            }\n            case uint_type: {\n                make_pointer([ClojureLangRT intCastWithId:v], unsigned int);\n            }\n            case bool_type: {\n                make_pointer([ClojureLangRT booleanCastWithId:v], BOOL);\n            }\n            case id_type: {\n                make_pointer([v isKindOfClass:[WeakRef class]] ? [(WeakRef*)v deref] : v, id);\n            }\n            case cgpoint_type: {\n                make_pointer([((NSValue*) v) CGPointValue], CGPoint);\n            }\n            case nsrange_type: {\n                make_pointer([((NSValue*) v) rangeValue], NSRange);\n            }\n            case uiedge_type: {\n                make_pointer([((NSValue*) v) UIEdgeInsetsValue], UIEdgeInsets);\n            }\n            case cgsize_type: {\n                make_pointer([((NSValue*) v) CGSizeValue], CGSize);\n            }\n            case cgaffinetransform_type: {\n                make_pointer([((NSValue*) v) CGAffineTransformValue], CGAffineTransform);\n                break;\n            }\n            case catransform3d_type: {\n                make_pointer([((NSValue*) v) CATransform3DValue], CATransform3D);\n            }\n            case uioffset_type: {\n                make_pointer([((NSValue*) v) UIOffsetValue], UIOffset);\n            }\n            case cgrect_type: {\n                make_pointer([((NSValue*) v) CGRectValue], CGRect);\n            }\n            case pointer_type: {\n                if ([v isKindOfClass:[ClojureLangSelector class]]) {\n                    make_pointer(NSSelectorFromString([(ClojureLangSelector*)v getName]), SEL);\n                } else {\n                    make_pointer([((NSValue*) v) pointerValue], void*);\n                }\n            }\n            default: {\n                @throw [NSException exceptionWithName:@\"Type not found\" reason:[NSString stringWithFormat:@\"%c\", type] userInfo:nil];\n            }\n        }\n    }\n    \n    ffi_cif c;\n    ffi_type *result_type = ffi_type_for_type(retType);\n    int status = ffi_prep_cif(&c, FFI_DEFAULT_ABI, (unsigned int) count, result_type, argument_types);\n    if (status != FFI_OK) {\n        NSLog(@\"Failed to prepare cif structure\");\n    }\n    ffi_call(&c, fn, result_value, argument_values);\n    for (int n=0; n < count; n++) {\n        free(argument_values[n]);\n    }\n    free(argument_types);\n    free(argument_values);\n    \n    id result = boxValue(result_value, retType);\n    free(result_value);\n    return result;\n}\n\nconst char* makeSignature(id types) {\n    BOOL first = YES;\n    NSString *s = @\"\";\n    IOSObjectArray *array = [ClojureLangRT toArrayWithId:types];\n    long c = [array length];\n    for (int n = 0; n < c; n++) {\n        s = [s stringByAppendingString:[NSString stringWithFormat:@\"%s\", encode_type(to_char([array objectAtIndex:n]))]];\n        if (first) {\n            s = [s stringByAppendingString:@\"@:\"];\n            first = NO;\n        }\n    }\n    return [s UTF8String];\n}\n\n\n@implementation NSCommon\n\n+(BOOL)cgfloatIsDouble {\n#if CGFLOAT_IS_DOUBLE\n    return YES;\n#else\n    return NO;\n#endif\n}\n\n+(void)initialize {\n    assoc = [ClojureLangRT varWithNSString:@\"clojure.core\" withNSString:@\"assoc\"];\n    cons = [ClojureLangRT varWithNSString:@\"clojure.core\" withNSString:@\"cons\"];\n    fconj = [ClojureLangRT varWithNSString:@\"clojure.core\" withNSString:@\"conj\"];\n    global_functions = [NSMutableDictionary new];\n    register_fn(objc_msgSend);\n#ifndef __arm64__\n    register_fn(objc_msgSend_stret);\n#endif\n    register_fn(CGRectMake);\n    register_fn(CGPointMake);\n    register_fn(CGSizeMake);\n    register_fn(CGVectorMake);\n    register_fn(UIEdgeInsetsMake);\n    register_fn(UIEdgeInsetsInsetRect);\n    register_fn(UIOffsetMake);\n    register_fn(UIEdgeInsetsEqualToEdgeInsets);\n    register_fn(UIOffsetEqualToOffset);\n}\n\n+(id)ccall:(id)name types:(ClojureLangPersistentVector*)types args:(id)args {\n    NSValue *val = [global_functions objectForKey:name];\n    void *fn;\n    if (val != nil) {\n        fn = [val pointerValue];\n    } else {\n        fn = dlsym(RTLD_DEFAULT, [name UTF8String]);\n        if (fn == nil) {\n            @throw [NSException exceptionWithName:@\"Function not found\" reason:name userInfo:nil];\n        }\n        [global_functions setObject:[NSValue valueWithPointer:fn] forKey:name];\n    }\n    \n    return ccallWithFn(fn, types, args);\n}\n\n#if TARGET_CPU_X86\n#define dispatch_fastf(params, ...) \\\ncase float_type: { \\\nfloat r = objc_msgSend_fpret(object, sel, ##__VA_ARGS__); \\\nreturn [[[JavaLangFloat alloc] initWithFloat:r] autorelease]; \\\n} \\\ncase double_type: { \\\ndouble r = objc_msgSend_fpret(object, sel, ##__VA_ARGS__); \\\nreturn [[[JavaLangDouble alloc] initWithDouble:r] autorelease]; \\\n} \\\ncase longdouble_type: { \\\nlong double r = objc_msgSend_fpret(object, sel, ##__VA_ARGS__); \\\nreturn [[[JavaLangDouble alloc] initWithDouble:r] autorelease]; \\\n}\n#elif TARGET_CPU_X86_64\n#define dispatch_fastf(params, ...) \\\ncase float_type: { \\\nreturn [ClojureLangRT boxWithFloat:((float(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n}\\\ncase double_type: { \\\nreturn [ClojureLangRT boxWithDouble:((double(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n}\\\ncase longdouble_type: { \\\nreturn [ClojureLangRT boxWithDouble:((long double(*)params)objc_msgSend_fpret)(object, sel, ##__VA_ARGS__)]; \\\n}\n#else\n#define dispatch_fastf(params, ...) \\\ncase float_type: { \\\nvoid* val = objc_msgSend(object, sel, ##__VA_ARGS__); \\\nreturn [ClojureLangRT boxWithFloat:*(float*)&val]; \\\n}\\\ncase double_type: { \\\nreturn [ClojureLangRT boxWithDouble:((double(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n}\\\ncase longdouble_type: { \\\nreturn [ClojureLangRT boxWithDouble:((long double(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n}\n#endif\n\n#define dispatch_fast(params, ...) \\\nswitch (ret) { \\\ncase void_type: { \\\nobjc_msgSend(object, sel, ##__VA_ARGS__); \\\nreturn nil;\\\n} \\\ncase int_type: { \\\nreturn [ClojureLangRT boxWithInt:((int(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n} \\\ncase bool_type: { \\\nreturn ((BOOL(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__) == YES ? JavaLangBoolean_get_TRUE__() : JavaLangBoolean_get_FALSE__(); \\\n} \\\ncase id_type: { \\\nreturn ((id(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__); \\\n} \\\ncase pointer_type: { \\\nreturn [NSValue valueWithPointer:((void*(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)];\\\n} \\\ncase longlong_type: { \\\nreturn [ClojureLangRT boxWithLong:((long long(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n} \\\ncase long_type: { \\\nreturn [ClojureLangRT boxWithLong:((long(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n} \\\ncase char_type: { \\\nchar charv = ((char(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__); \\\nreturn charv == YES ? JavaLangBoolean_get_TRUE__() : (charv == NO ? JavaLangBoolean_get_FALSE__() : [ClojureLangRT boxWithChar:charv]); \\\n} \\\ncase short_type: { \\\nreturn [ClojureLangRT boxWithShort:((short(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n} \\\ncase ulong_type: { \\\nreturn [ClojureLangRT boxWithLong:((unsigned long(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n} \\\ncase ulonglong_type: { \\\nreturn [ClojureLangRT boxWithLong:((unsigned long long(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n} \\\ncase uchar_type: { \\\nreturn [ClojureLangRT boxWithChar:((unsigned char(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n} \\\ncase ushort_type: { \\\nreturn [ClojureLangRT boxWithShort:((unsigned short(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n} \\\ncase uint_type: { \\\nreturn [ClojureLangRT boxWithInt:((unsigned int(*)params)objc_msgSend)(object, sel, ##__VA_ARGS__)]; \\\n} \\\ncase cgrect_type: { \\\nreturn [NSValue valueWithCGRect:((CGRect(*)params)fun)(object, sel, ##__VA_ARGS__)];\\\n}\\\ncase cgsize_type: {\\\nreturn [NSValue valueWithCGSize:((CGSize(*)params)fun)(object, sel, ##__VA_ARGS__)];\\\n}\\\ncase cgpoint_type: {\\\nreturn [NSValue valueWithCGPoint:((CGPoint(*)params)fun)(object, sel, ##__VA_ARGS__)];\\\n}\\\ncase nsrange_type: {\\\nreturn [NSValue valueWithRange:((NSRange(*)params)fun)(object, sel, ##__VA_ARGS__)];\\\n}\\\ncase uiedge_type: {\\\nreturn [NSValue valueWithUIEdgeInsets:((UIEdgeInsets(*)params)fun)(object, sel, ##__VA_ARGS__)];\\\n}\\\ncase cgaffinetransform_type: {\\\nreturn [NSValue valueWithCGAffineTransform:((CGAffineTransform(*)params)fun)(object, sel, ##__VA_ARGS__)];\\\n}\\\ncase catransform3d_type: {\\\nreturn [NSValue valueWithCATransform3D:((CATransform3D(*)params)fun)(object, sel, ##__VA_ARGS__)];\\\n}\\\ncase uioffset_type: {\\\nreturn [NSValue valueWithUIOffset:((UIOffset(*)params)fun)(object, sel, ##__VA_ARGS__)];\\\n}\\\ndispatch_fastf(params, ##__VA_ARGS__) \\\n}\\\n\n+ (id) invokeSel:(id)object withSelector:(NSString*)selector withArgs:(id<ClojureLangISeq>)arguments {\n    if ([object isKindOfClass:[NSString class]] && ClojureLangRemoteRepl_get_connected_()) {\n        if (([selector isEqualToString:@\"autorelease\"])) {\n            return object;\n        } else if ([selector isEqualToString:@\"release\"]) {\n            return nil;\n        }\n    }\n    \n    SEL sel = NSSelectorFromString(selector);\n    NSMethodSignature *sig = [([object isKindOfClass:[WeakRef class]] ? [(WeakRef*)object deref] : object) methodSignatureForSelector:sel];\n    if (sig == nil) {\n        @throw([NSException exceptionWithName:@\"Error invoking objc method. Selector not found\" reason:selector userInfo:nil]);\n    }\n    char ret = signatureToType([sig methodReturnType]);\n#ifndef __arm64__\n    bool stret = use_stret(ret);\n#else\n    bool stret = NO;\n#endif\n    object = [object isKindOfClass:[WeakRef class]] ? [object deref] : object;\n#ifndef __arm64__\n    void *fun;\n    if (stret) {\n        fun = objc_msgSend_stret;\n    } else {\n#if TARGET_CPU_X86\n        if (ret == float_type || ret == double_type || ret == longdouble_type) {\n            fun = objc_msgSend_fpret;\n        } else {\n#endif\n            fun = objc_msgSend;\n#if TARGET_CPU_X86\n        }\n#endif\n    }\n#else\n    void *fun;\n    if (ret == longdouble_type) {\n        fun = objc_msgSend_fpret;\n    } else {\n        fun = objc_msgSend;\n    }\n#endif\n    // TODO: ulonglong return fails with dispatch_fast\n    if (ret != ulonglong_type) {\n        switch ([arguments count]) {\n            case 0: {\n                dispatch_fast((id, SEL));\n                break;\n            }\n                \n            case 1: {\n                id v = [arguments first];\n                switch (signatureToType([sig getArgumentTypeAtIndex:2])) {\n                    case id_type: {\n                        dispatch_fast((id, SEL, id), (id)([v isKindOfClass:[WeakRef class]] ? [(WeakRef*)v deref] : v));\n                    }\n                    case int_type: {\n                        dispatch_fast((id, SEL, int), [ClojureLangRT intCastWithId:v]);\n                    }\n                    case uint_type: {\n                        dispatch_fast((id, SEL, unsigned int), [ClojureLangRT intCastWithId:v]);\n                    }\n                    case ulonglong_type: {\n                        dispatch_fast((id, SEL, unsigned long long), (unsigned long long)[ClojureLangRT longCastWithId:v]);\n                    }\n                    case ulong_type: {\n                        dispatch_fast((id, SEL, unsigned long), (unsigned long)[ClojureLangRT longCastWithId:v]);\n                    }\n                    case long_type: {\n                        dispatch_fast((id, SEL, long), (long)[ClojureLangRT longCastWithId:v]);\n                    }\n                    case longlong_type: {\n                        dispatch_fast((id, SEL, long long), (long long)[ClojureLangRT longCastWithId:v]);\n                    }\n                    case float_type: {\n                        float f = [ClojureLangRT floatCastWithId:v];\n                        // float required special handling\n                        dispatch_fast((id, SEL, int), *(int*)&f);\n                    }\n                    case uchar_type: {\n                        dispatch_fast((id, SEL, unsigned char), (unsigned char)[ClojureLangRT charCastWithId:v]);\n                    }\n                    case char_type: {\n                        dispatch_fast((id, SEL, char), v == JavaLangBoolean_get_TRUE__() ? YES :\n                                  (v == JavaLangBoolean_get_FALSE__() ? NO : [ClojureLangRT charCastWithId:v]));\n                    }\n                    case ushort_type: {\n                        dispatch_fast((id, SEL, unsigned short), (unsigned short)[ClojureLangRT shortCastWithId:v]);\n                    }\n                    case short_type: {\n                        dispatch_fast((id, SEL, short), [ClojureLangRT shortCastWithId:v]);\n                    }\n                    case double_type: {\n                        dispatch_fast((id, SEL, double), [ClojureLangRT doubleCastWithId:v]);\n                    }\n                    case longdouble_type: {\n                        dispatch_fast((id, SEL, long double), (long double)[ClojureLangRT doubleCastWithId:v]);\n                    }\n                    case bool_type: {\n                        dispatch_fast((id, SEL, bool), [ClojureLangRT booleanCastWithId:v]);\n                    }\n                    case pointer_type: {\n                        dispatch_fast((id, SEL, void*), [v isKindOfClass:[ClojureLangSelector class]] ? NSSelectorFromString  ([(ClojureLangSelector*)v getName]) : [(NSValue*)v pointerValue]);\n                    }\n                    case cgpoint_type: {\n                        dispatch_fast((id, SEL, CGPoint), [(NSValue*)v CGPointValue]);\n                    }\n                    case nsrange_type: {\n                        dispatch_fast((id, SEL, NSRange), [(NSValue*)v rangeValue]);\n                    }\n                    case uiedge_type: {\n                        dispatch_fast((id, SEL, UIEdgeInsets), [(NSValue*)v UIEdgeInsetsValue]);\n                    }\n                    case cgsize_type: {\n                        dispatch_fast((id, SEL, CGSize), [(NSValue*)v CGSizeValue]);\n                    }\n                    case cgaffinetransform_type: {\n                        dispatch_fast((id, SEL, CGAffineTransform), [(NSValue*)v CGAffineTransformValue]);\n                    }\n                    case catransform3d_type: {\n                        dispatch_fast((id, SEL, CATransform3D), [(NSValue*)v CATransform3DValue]);\n                    }\n                    case uioffset_type: {\n                        dispatch_fast((id, SEL, UIOffset), [(NSValue*)v UIOffsetValue]);\n                    }\n                    case cgrect_type: {\n                        dispatch_fast((id, SEL, CGRect), [(NSValue*)v CGRectValue]);\n                    }\n                }\n                break;\n            }\n        }\n    }\n    \n    if ([selector isEqualToString:@\"ccall:types:args:\"]) {\n        return [NSCommon ccall:[ClojureLangRT nthFromWithId:arguments withInt:0] types:[ClojureLangRT nthFromWithId:arguments withInt:1] args:[ClojureLangRT nthFromWithId:arguments withInt:2]];\n    }\n    return ccallWithFn(fun, signaturesToTypes(sig, NO), [cons invokeWithId:object withId:[cons invokeWithId:[NSValue valueWithPointer:sel] withId:arguments]]);\n}\n\n+ (id) invokeSuperSel:(id)object withDispatchClass:(id)clazz withSelector:(NSString*)selector\n             withArgs:(id<ClojureLangISeq>)arguments {\n    SEL sel = NSSelectorFromString(selector);\n    clazz = clazz == nil ? [object superclass] : [NSClassFromString(clazz) superclass];\n    if (classIsDynamic(clazz)) {\n        objc_setAssociatedObject(object, \"__dispatch_class__\", clazz, 1);\n    }\n    struct objc_super superData = {object, clazz};\n    \n    NSMethodSignature *sig = [object methodSignatureForSelector:sel];\n    if (sig == nil) {\n        @throw([NSException exceptionWithName:@\"Error invoking superclass objc method. Selector not found\" reason:selector userInfo:nil]);\n    }\n    id types = [assoc invokeWithId:signaturesToTypes(sig, NO) withId:[[[JavaLangInteger alloc] initWithInt:1] autorelease] withId:[[[JavaLangCharacter alloc] initWithChar:pointer_type] autorelease]];\n    id args = [cons invokeWithId:[NSValue valueWithPointer:sel] withId:arguments];\n    args = [cons invokeWithId:[NSValue valueWithPointer:(void*)&superData] withId:args];\n#ifndef __arm64__\n    void *s;\n    if (use_stret(signatureToType([sig methodReturnType]))) {\n        s = objc_msgSendSuper_stret;\n    } else {\n        s = objc_msgSendSuper;\n    }\n#else\n    void *s = FFI_FN(objc_msgSendSuper);\n#endif\n    return ccallWithFn(s, types, args);\n}\n\n+ (id) invokeFun:(NSString*)fun withSelf:(id)object withSelector:(NSString*)selector withArgs:(id<ClojureLangISeq>)arguments {\n    SEL sel = NSSelectorFromString(selector);\n    NSMethodSignature *sig = [([object isKindOfClass:[WeakRef class]] ? [(WeakRef*)object deref] : object) methodSignatureForSelector:sel];\n    if (sig == nil) {\n        @throw([NSException exceptionWithName:@\"Error invoking objc method. Selector not found\" reason:selector userInfo:nil]);\n    }\n    id args = [cons invokeWithId:[NSValue valueWithPointer:NSSelectorFromString(selector)] withId:arguments];\n    args = [cons invokeWithId:object withId:args];\n    return [NSCommon ccall:fun types:signaturesToTypes(sig, NO) args:args];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/NSProxyImpl.h",
    "content": "#import <Foundation/Foundation.h>\n#import \"clojure/lang/APersistentMap.h\"\n\n@interface NSProxyImpl: NSObject\n\n- (id) initWithClass:(NSString*)clazz map:(ClojureLangAPersistentMap*) m;\n\n@end\n"
  },
  {
    "path": "src/objc/NSProxyImpl.m",
    "content": "#import \"NSProxyImpl.h\"\n#import \"clojure/lang/AFn.h\"\n#import \"clojure/lang/RT.h\"\n#import \"clojure/lang/PersistentVector.h\"\n#import \"clojure/lang/Selector.h\"\n#import \"clojure/lang/Var.h\"\n#import \"NSCommon.h\"\n#import <UIKit/UIKit.h>\n\n@implementation NSProxyImpl {\n    ClojureLangAPersistentMap *map;\n    Class clazz;\n    id instance;\n}\n\n- (id) initWithClass:(NSString*)c map:(ClojureLangAPersistentMap*) m\n{\n    self = [super init];\n    if (self) {\n        map = [m retain];\n        if (c == nil) {\n            clazz = [NSObject class];\n        } else {\n            clazz = NSClassFromString(c);\n        }\n        instance = [[clazz alloc] init];\n    }\n    return self;\n}\n\n- (void) forwardInvocation:(NSInvocation *)invocation\n{\n    id r = [map valAtWithId:NSStringFromSelector([invocation selector])];\n    if (r == nil) {\n        [invocation invokeWithTarget:instance];\n    } else {\n        callWithInvocation(invocation, self, [ClojureLangRT firstWithId:r], [ClojureLangRT secondWithId:r]);\n    }\n}\n\n-(NSMethodSignature *)methodSignatureForSelector:(SEL)sel {\n    if ([NSStringFromSelector(sel) isEqualToString: @\"initWithClass:map:\"] ||\n        [NSStringFromSelector(sel) isEqualToString: @\"class\"] ||\n        [NSStringFromSelector(sel) isEqualToString: @\"alloc\"] ||\n        [NSStringFromSelector(sel) isEqualToString: @\"retain\"] ||\n        [NSStringFromSelector(sel) isEqualToString: @\"retainCount\"] ||\n        [NSStringFromSelector(sel) isEqualToString: @\"release\"] ||\n        [NSStringFromSelector(sel) isEqualToString: @\"dealloc\"]) {\n        return [NSProxyImpl instanceMethodSignatureForSelector:sel];\n    }\n    id r = [map valAtWithId:NSStringFromSelector(sel)];\n    if (r == nil) {\n        return [clazz instanceMethodSignatureForSelector:sel];\n    } else {\n        return [NSMethodSignature signatureWithObjCTypes:makeSignature([ClojureLangRT firstWithId:r])];\n    }\n}\n\n-(BOOL)respondsToSelector:(SEL)sel {\n    if ([map valAtWithId:NSStringFromSelector(sel)] != nil || [instance respondsToSelector:sel]) {\n        return YES;\n    }\n    return NO;\n}\n\n\n-(id)retain {\n    id r = [map valAtWithId:@\"retain\"];\n    if (r != nil) {\n        [(ClojureLangAFn*)[ClojureLangRT secondWithId:r] invokeWithId:self];\n    }\n    return [super retain];\n}\n\n-(oneway void)release {\n    id r = [map valAtWithId:@\"release\"];\n    if (r != nil) {\n        [(ClojureLangAFn*)[ClojureLangRT secondWithId:r] invokeWithId:self];\n    }\n    [super release];\n}\n\n-(NSUInteger)retainCount {\n    id r = [map valAtWithId:@\"retainCount\"];\n    if (r != nil) {\n        [(ClojureLangAFn*)[ClojureLangRT secondWithId:r] invokeWithId:self];\n    }\n    return [super retainCount];\n}\n\n-(void)dealloc {\n    id r = [map valAtWithId:@\"dealloc\"];\n    if (r != nil) {\n        [(ClojureLangAFn*)[ClojureLangRT secondWithId:r] invokeWithId:self];\n    }\n    [instance release];\n    [map release];\n    [super dealloc];\n}\n\n-(NSString*)description {\n    id r = [map valAtWithId:@\"description\"];\n    if (r != nil) {\n        return [(ClojureLangAFn*)[ClojureLangRT secondWithId:r] invokeWithId:self];\n    } else {\n        return [instance description];\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/objc/NSSocketImpl.h",
    "content": "//\n//  NSSocketImpl.h\n//  sample\n//\n//  Created by Gal Dolber on 2/1/14.\n//  Copyright (c) 2014 clojure-objc. All rights reserved.\n//\n\n#import <Foundation/Foundation.h>\n\n@interface NSSocketImpl : NSObject\n\n- (id) initWithHost:(NSString*)hostName withPort:(NSString*)portNum;\n\n- (id) read;\n\n- (void) println: (NSString*) s;\n\n-(void)close;\n\n@end\n"
  },
  {
    "path": "src/objc/NSSocketImpl.m",
    "content": "//\n//  NSSocketImpl.m\n//  sample\n//\n//  Created by Gal Dolber on 2/1/14.\n//  Copyright (c) 2014 clojure-objc. All rights reserved.\n//\n\n#import \"NSSocketImpl.h\"\n#import \"clojure/lang/RT.h\"\n#import \"clojure/lang/Var.h\"\n#import \"clojure/lang/Selector.h\"\n#import \"clojure/lang/ISeq.h\"\n#import \"clojure/lang/ObjC.h\"\n#import \"clojure/lang/Selector.h\"\n#import \"Cst502Socket.h\"\n#import <UIKit/UIKit.h>\n\n@implementation NSSocketImpl {\n    Cst502ClientSocket* cs;\n}\n\n- (id) initWithHost:(NSString*)hostName withPort:(NSString*)portNum {\n    self = [super init];\n    if (self) {\n        cs = [[Cst502ClientSocket alloc] initWithHost: hostName\n                                           portNumber: portNum];\n        [self reconnect];\n    }\n    return self;\n}\n\n- (void) reconnect {\n    while(![cs connect]) {\n        NSLog(@\"Error connecting... will try again in 5 second\");\n        [NSThread sleepForTimeInterval:5];\n    }\n}\n\n- (id) read {\n    fflush (stdout);\n    char *buf = malloc(12);\n    NSString *a = [[cs receiveBytes:buf maxBytes:12 beginAt:0] stringByTrimmingCharactersInSet:\n                   [NSCharacterSet whitespaceCharacterSet]];\n    /*if ([@\"\" isEqualToString:a]) {\n     [self reconnect];\n     return [self read];\n     }*/\n    int size = [a intValue] + 2;\n    free(buf);\n    buf = malloc(size);\n    a = [cs receiveBytes:buf maxBytes:size beginAt:0];\n    free(buf);\n    return a;\n}\n\n- (void) println: (NSString*) s {\n    [cs sendString: s];\n    fflush (stdout);\n}\n\n-(void)dealloc {\n    [cs release];\n    [super dealloc];\n}\n\n-(void)close {\n    [cs close];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/NSTypeImpl.h",
    "content": "//\n//  NSTypeImpl.h\n//  sample\n//\n//  Created by Gal Dolber on 2/4/14.\n//  Copyright (c) 2014 clojure-objc. All rights reserved.\n//\n\n#import <Foundation/Foundation.h>\n#import \"clojure/lang/APersistentMap.h\"\n#import \"clojure/lang/PersistentVector.h\"\n#import \"clojure/lang/PersistentHashMap.h\"\n\n@interface NSTypeImpl : NSObject\n\n+(Class) makeClassWithName:(NSString*)name superclass:(NSString*)s map:(ClojureLangAPersistentMap*)m;\n\n@end\n"
  },
  {
    "path": "src/objc/NSTypeImpl.m",
    "content": "//\n//  NSTypeImpl.m\n//  sample\n//\n//  Created by Gal Dolber on 2/4/14.\n//  Copyright (c) 2014 clojure-objc. All rights reserved.\n//\n\n#import \"NSTypeImpl.h\"\n#import \"objc/runtime.h\"\n#import \"objc/message.h\"\n#import \"clojure/lang/Atom.h\"\n#import \"java/lang/RuntimeException.h\"\n#import \"java/lang/Character.h\"\n#import \"clojure/lang/RT.h\"\n#import \"NSCommon.h\"\n#import <UIKit/UIKit.h>\n\n#define va_arg_p(type)\\\n    {\\\n    type v = va_arg(ap, type); \\\n    type* vp = malloc(sizeof(type)); \\\n    memcpy(vp, &v, sizeof(type)); \\\n    args[n] = vp; \\\n    break;\\\n    }\\\n\n#define dispatch_args(self, sel, type) \\\n    va_list ap; \\\n    va_start(ap, sel); \\\n    Class dispatchClass = objc_getAssociatedObject(self, \"__dispatch_class__\"); \\\n    objc_setAssociatedObject(self, \"__dispatch_class__\", nil, 0); \\\n    if (dispatchClass == nil) { \\\n        dispatchClass = [self class]; \\\n    } \\\n    id o = [ClojureLangRT getWithId:[dynamicClasses deref] withId:NSStringFromClass(dispatchClass)]; \\\n    id pair = [ClojureLangRT getWithId:o withId:NSStringFromSelector(sel)]; \\\n    id fn = [ClojureLangRT secondWithId:pair]; \\\n    while (fn == nil) { \\\n        dispatchClass = [dispatchClass superclass]; \\\n        o = [ClojureLangRT getWithId:[dynamicClasses deref] withId:NSStringFromClass(dispatchClass)]; \\\n        pair = [ClojureLangRT getWithId:o withId:NSStringFromSelector(sel)]; \\\n        fn = [ClojureLangRT secondWithId:pair]; \\\n        if (o == nil) { \\\n            break; \\\n        } \\\n    } \\\n    if (fn == nil) { \\\n        @throw [NSException exceptionWithName:NSStringFromClass(dispatchClass) reason:NSStringFromSelector(sel) userInfo:nil]; \\\n    } \\\n    id types = [ClojureLangRT firstWithId:pair];\\\n    id sig;\\\n    if (types == nil) { \\\n        sig = [self methodSignatureForSelector:sel]; \\\n        types = signaturesToTypes(sig, YES); \\\n    } else {\\\n        sig = [NSMethodSignature signatureWithObjCTypes:makeSignature(types)];\\\n    }\\\n    id retType = [ClojureLangRT firstWithId:types]; \\\n    IOSObjectArray *typesa = [ClojureLangRT toArrayWithId:[ClojureLangRT nextWithId:types]]; \\\n    long c = [typesa length]; \\\n    void **args = (void **) malloc ((c + 1) * sizeof(void *)); \\\n    for (int n = 0; n < c; n++) { \\\n        switch (to_char([typesa objectAtIndex:n])) { \\\n            case float_type: va_arg_p(double)\\\n            case longlong_type: va_arg_p(long long)\\\n            case long_type: va_arg_p(long)\\\n            case char_type: va_arg_p(int)\\\n            case short_type: va_arg_p(int)\\\n            case int_type: va_arg_p(int)\\\n            case double_type: va_arg_p(double)\\\n            case ulong_type: va_arg_p(unsigned long)\\\n            case ulonglong_type: va_arg_p(unsigned long long)\\\n            case uchar_type: va_arg_p(int)\\\n            case ushort_type: va_arg_p(int)\\\n            case uint_type: va_arg_p(unsigned int)\\\n            case bool_type: va_arg_p(int)\\\n            case id_type: va_arg_p(id)\\\n            case cgpoint_type: va_arg_p(CGPoint)\\\n            case nsrange_type: va_arg_p(NSRange)\\\n            case uiedge_type: va_arg_p(UIEdgeInsets)\\\n            case cgsize_type: va_arg_p(CGSize)\\\n            case cgaffinetransform_type: va_arg_p(CGAffineTransform)\\\n            case catransform3d_type: va_arg_p(CATransform3D)\\\n            case uioffset_type: va_arg_p(UIOffset)\\\n            case cgrect_type: va_arg_p(CGRect)\\\n            case pointer_type: va_arg_p(void*)\\\n        } \\\n    } \\\n    va_end(ap); \\\n    type* rp = callWithArgs(args, self, [ClojureLangRT consWithId:retType withId:types], fn); \\\n\n#define dispatch_args_r(self, sel, type)\\\n    dispatch_args(self, sel, type);\\\n    type r = *rp; \\\n    free(args); \\\n    return r;\\\n\nvoid dispatch_void(id self, SEL sel, ...) {\n    dispatch_args(self, sel, void);\n    free(args);\n}\n\nfloat dispatch_float(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, float);\n}\n\nlong long  dispatch_longlong(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, long long);\n}\n\nlong dispatch_long(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, long);\n}\n\nchar dispatch_char(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, char);\n}\n\nshort dispatch_short(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, short);\n}\n\nint dispatch_int(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, int);\n}\n\ndouble dispatch_double(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, double);\n}\n\nunsigned long long dispatch_unsigned_longlong(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, unsigned long long);\n}\n\nunsigned long dispatch_unsigned_long(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, unsigned long);\n}\n\nunsigned char dispatch_unsigned_char(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, unsigned char);\n}\n\nunsigned short dispatch_unsigned_short(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, unsigned short);\n}\n\nunsigned int dispatch_unsigned_int(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, unsigned int);\n}\n\nbool dispatch_bool(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, BOOL);\n}\n\nCGPoint dispatch_CGPoint(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, CGPoint);\n}\n\nNSRange dispatch_NSRange(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, NSRange);\n}\n\nUIEdgeInsets dispatch_UIEdgeInsets(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, UIEdgeInsets);\n}\n\nCGSize dispatch_CGSize(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, CGSize);\n}\n\nCGAffineTransform dispatch_CGAffineTransform(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, CGAffineTransform);\n}\n\nCATransform3D dispatch_CATransform3D(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, CATransform3D);\n}\n\nUIOffset dispatch_UIOffset(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, UIOffset);\n}\n\nCGRect dispatch_CGRect(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, CGRect);\n}\n\nid dispatch_id(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, id);\n}\n\nvoid* dispatch_pointer(id self, SEL sel, ...) {\n    dispatch_args_r(self, sel, void*);\n}\n\nIMP getDispatch(char c) {\n    switch (c) {\n        case void_type: return (IMP)dispatch_void;\n        case float_type: return (IMP)dispatch_float;\n        case long_type: return (IMP)dispatch_long;\n        case longlong_type: return (IMP)dispatch_longlong;\n        case char_type: return (IMP)dispatch_char;\n        case short_type: return (IMP)dispatch_short;\n        case int_type: return (IMP)dispatch_int;\n        case double_type: return (IMP)dispatch_double;\n        case ulong_type: return (IMP)dispatch_unsigned_long;\n        case ulonglong_type: return (IMP)dispatch_unsigned_longlong;\n        case uchar_type: return (IMP)dispatch_unsigned_char;\n        case ushort_type: return (IMP)dispatch_unsigned_short;\n        case uint_type: return (IMP)dispatch_unsigned_int;\n        case bool_type: return (IMP)dispatch_bool;\n        case cgpoint_type: return (IMP)dispatch_CGPoint;\n        case nsrange_type: return (IMP)dispatch_NSRange;\n        case uiedge_type: return (IMP)dispatch_UIEdgeInsets;\n        case cgsize_type: return (IMP)dispatch_CGSize;\n        case cgaffinetransform_type: return (IMP)dispatch_CGAffineTransform;\n        case catransform3d_type: return (IMP)dispatch_CATransform3D;\n        case uioffset_type: return (IMP)dispatch_UIOffset;\n        case cgrect_type: return (IMP)dispatch_CGRect;\n        case pointer_type: return (IMP)dispatch_pointer;\n    }\n    return (IMP)dispatch_id;\n}\n\n@implementation NSTypeImpl\n\n+(void)initialize {\n    dynamicClasses = [[ClojureLangAtom alloc] initWithId:ClojureLangPersistentHashMap_get_EMPTY_()];\n}\n\n+(Class) makeClassWithName:(NSString*)name superclass:(NSString*)s map:(ClojureLangAPersistentMap*)m {\n    [dynamicClasses swapWithClojureLangIFn:[[ClojureLangRT varWithNSString:@\"clojure.core\" withNSString:@\"assoc\"] deref]\n                                    withId:name withId:m];\n    Class superc = NSClassFromString(s);\n    Class clazz = objc_allocateClassPair(superc, [name UTF8String], 0);\n    BOOL wasDefined = NO;\n    if (clazz == nil) {\n        wasDefined = YES;\n        clazz = NSClassFromString(name);\n    }\n    id seq = [m seq];\n    while (seq != nil) {\n        id f = [ClojureLangRT firstWithId:seq];\n        SEL sel = NSSelectorFromString([ClojureLangRT firstWithId:f]);\n        id types = [ClojureLangRT firstWithId:[ClojureLangRT secondWithId:f]];\n        void * d;\n        const char * enc;\n        if (types == nil) {\n            Method method = class_getInstanceMethod(superc, sel);\n            char ret[256];\n            method_getReturnType(method, ret, 256);\n            d = getDispatch(signatureToType(ret));\n            enc = method_getTypeEncoding(method);\n        } else {\n            id r = [ClojureLangRT firstWithId:types];\n            d = getDispatch(to_char(r));\n            enc = makeSignature(types);\n        }\n        class_replaceMethod(clazz, sel, d, enc);\n        seq = [ClojureLangRT nextWithId:seq];\n    }\n    \n    if (!wasDefined) {\n        objc_registerClassPair(clazz);\n    }\n    return clazz;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/ReplClient.h",
    "content": "//\n//  ReplClient.h\n//  mpos\n//\n//  Created by Gal Dolber on 4/12/14.\n//  Copyright (c) 2014 zuldi. All rights reserved.\n//\n\n#import <Foundation/Foundation.h>\n\n@interface ReplClient : NSObject\n\n+(void) connect: (NSString*) host;\n+(id) callRemote:(id)sel args:(id)args;\n\n@end\n"
  },
  {
    "path": "src/objc/ReplClient.m",
    "content": "//\n//  ReplClient.m\n//  mpos\n//\n//  Created by Gal Dolber on 4/12/14.\n//  Copyright (c) 2014 zuldi. All rights reserved.\n//\n\n#import \"ReplClient.h\"\n#import \"clojure/lang/RemoteRepl.h\"\n#import \"clojure/lang/RT.h\"\n#import \"clojure/lang/Keyword.h\"\n#import \"clojure/lang/AFn.h\"\n#import \"clojure/lang/PersistentHashMap.h\"\n#import \"clojure/lang/Var.h\"\n#import \"clojure/lang/Atom.h\"\n#import \"NSSocketImpl.h\"\n#import \"clojure/core_keyword.h\"\n#import \"clojure/core_pr_str.h\"\n#import \"clojure/core_vector.h\"\n#import \"clojure/core_vec.h\"\n#import \"clojure/core_assoc.h\"\n#import \"clojure/core_dissoc.h\"\n\nstatic NSSocketImpl *nssocket;\nstatic NSSocketImpl *nssocket2;\nstatic ClojureLangAtom *responses;\n\n@implementation ReplClient\n\n+(void) processCall2:(NSSocketImpl*)socket msg:(id)msg {\n    @try {\n        id i = [ClojureLangRT firstWithId:msg];\n        id s = [ClojureLangRT secondWithId:msg];\n        id args = [ClojureLangRT thirdWithId:msg];\n        id r = [(ClojureLangAFn*)s applyToWithClojureLangISeq:[ClojureLangRT seqWithId:args]];\n        [responses swapWithClojureLangIFn:Clojurecore_assoc_get_VAR_() withId:i withId:r];\n        [socket println:[Clojurecore_pr_str_get_VAR_() invokeWithId:[Clojurecore_vector_get_VAR_() invokeWithId:i withId:r]]];\n    }\n    @catch (NSException *exception) {\n        [socket println:[Clojurecore_pr_str_get_VAR_() invokeWithId:[NSString stringWithFormat:@\"%@\",[exception callStackSymbols]]]];\n        NSLog(@\"%@\", exception);\n    }\n}\n\n+(void) processCall:(NSSocketImpl*)socket msg:(id)msg {\n    if ([ReplClient maybeRetry:socket msg:msg]) {\n        return;\n    }\n    id runInMain = [ClojureLangRT firstWithId:msg];\n    msg = [ClojureLangRT nextWithId:msg];\n    if ([ClojureLangRT booleanCastWithId:runInMain]) {\n        if ([NSThread isMainThread]) {\n            [ReplClient processCall2:socket msg:msg];\n        } else {\n            dispatch_sync(dispatch_get_main_queue(), ^{\n                [ReplClient processCall2:socket msg:msg];\n            });\n        }\n    } else {\n        dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{\n            [ReplClient processCall2:socket msg:msg];\n        });\n    }\n}\n\n+(BOOL) maybeRetry:(NSSocketImpl*)socket msg:(id) msg {\n    if ([[ClojureLangRT firstWithId:msg] isEqual:[ClojureLangKeyword internWithNSString:@\"retry\"]]) {\n        id i = [ClojureLangRT secondWithId:msg];\n        id r = [[responses deref] valAtWithId:i];\n        [socket println:[Clojurecore_pr_str_get_VAR_() invokeWithId:[Clojurecore_vector_get_VAR_() invokeWithId:i withId:r]]];\n        return YES;\n    } else {\n        return NO;\n    }\n}\n\n+(void) connect: (NSString*) host {\n    responses = [[ClojureLangAtom alloc] initWithId:ClojureLangPersistentHashMap_get_EMPTY_()];\n    nssocket = [[NSSocketImpl alloc] initWithHost:host withPort:@\"35813\"];\n    nssocket2 = [[NSSocketImpl alloc] initWithHost:host withPort:@\"35814\"];\n    [ClojureLangRemoteRepl setConnectedWithBoolean:YES];\n    dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{\n        while (true) {\n            [ReplClient processCall:nssocket msg:[ClojureLangRT readStringWithNSString:[nssocket read]]];\n        }\n    });\n}\n\n+(id) callRemote:(id)sel args:(id)args {\n    args = [Clojurecore_vec_get_VAR_() invokeWithId:args];\n    id i = [[ReplClient randomUUID] description];\n    [nssocket2 println:[Clojurecore_pr_str_get_VAR_()\n                            invokeWithId:[Clojurecore_vector_get_VAR_()\n                            invokeWithId:[ClojureLangRT boxWithBoolean:[NSThread isMainThread]] withId:i withId:sel withId:args]]];\n    while (true) {\n        id v = [ClojureLangRT readStringWithNSString:[nssocket2 read]];\n        if (![ReplClient maybeRetry:nssocket2 msg:v]) {\n            if ([ClojureLangRT countWithId:v] == 4) {\n                [ReplClient processCall:nssocket2 msg:v];\n            } else {\n                return [ClojureLangRT secondWithId:v];\n            }\n        }\n    }\n}\n\n+ (NSString *)randomUUID {\n    CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);\n    NSString *uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid);\n    CFRelease(uuid);\n    return uuidString;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/WeakRef.h",
    "content": "//\n//  WeakRef.h\n//  sample\n//\n//  Created by Gal Dolber on 2/14/14.\n//  Copyright (c) 2014 clojure-objc. All rights reserved.\n//\n\n#import <Foundation/Foundation.h>\n\n@interface WeakRef : NSObject\n\n-(id)initWith:(id)o;\n\n-(id)deref;\n\n+(WeakRef*)from:(id)o;\n\n-(BOOL)isEqual:(id)f;\n\n@end\n"
  },
  {
    "path": "src/objc/WeakRef.m",
    "content": "//\n//  WeakRef.m\n//  sample\n//\n//  Created by Gal Dolber on 2/14/14.\n//  Copyright (c) 2014 clojure-objc. All rights reserved.\n//\n\n#import \"WeakRef.h\"\n#import \"clojure/lang/RT.h\"\n#import \"clojure/lang/Var.h\"\n#import \"clojure/lang/PersistentHashMap.h\"\n#import \"clojure/lang/Atom.h\"\n\n@implementation WeakRef {\n    NSValue *val;\n}\n\n-(id)initWith:(id)o {\n    self = [super init];\n    if (self) {\n        val = [[NSValue valueWithNonretainedObject:o] retain];\n    }\n    return self;\n}\n\n-(id)deref {\n    return [val nonretainedObjectValue];\n}\n\n+(WeakRef*)from:(id)o {\n    return [[[WeakRef alloc] initWith:o] autorelease];\n}\n\n- (BOOL)isEqual:(id)f {\n    if (f != nil && [f isKindOfClass:[WeakRef class]]) {\n        return [[(WeakRef*)f deref] isEqual:[self deref]];\n    }\n    return NO;\n}\n\n-(NSString *)description {\n    return [[val nonretainedObjectValue] description];\n}\n\n-(void)dealloc {\n    [val release];\n    [super dealloc];\n}\n\n@end\n"
  },
  {
    "path": "src/resources/clojure/version.properties",
    "content": "version=${version}"
  },
  {
    "path": "src/script/run_test.clj",
    "content": "(System/setProperty \"java.awt.headless\" \"true\")\n(require\n '[clojure.test :as test]\n '[clojure.tools.namespace.find :as ns])\n(def namespaces (ns/find-namespaces-in-dir (java.io.File. \"test\")))\n(doseq [ns namespaces] (require ns))\n(let [summary (apply test/run-tests namespaces)]\n  (System/exit (if (test/successful? summary) 0 -1)))\n"
  },
  {
    "path": "src/script/run_test_generative.clj",
    "content": "(System/setProperty \"java.awt.headless\" \"true\")\n(when-not (System/getProperty \"clojure.test.generative.msec\")\n  (System/setProperty \"clojure.test.generative.msec\" \"60000\"))\n(require '[clojure.test.generative.runner :as runner])\n(runner/-main \"test\")\n"
  },
  {
    "path": "test/clojure/test_clojure/agents.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Shawn Hoover\n\n(ns clojure.test-clojure.agents\n  (:use clojure.test)\n  (:import [java.util.concurrent CountDownLatch TimeUnit]))\n\n;; tests are fragile. If wait fails, could indicate that\n;; build box is thrashing.\n(def fragile-wait 1000)\n\n(deftest handle-all-throwables-during-agent-actions\n  ;; Bug fixed in r1198; previously hung Clojure or didn't report agent errors\n  ;; after OutOfMemoryError, yet wouldn't execute new actions.\n  (let [agt (agent nil)]\n    (send agt (fn [state] (throw (Throwable. \"just testing Throwables\"))))\n    (try\n     ;; Let the action finish; eat the \"agent has errors\" error that bubbles up\n     (await-for fragile-wait agt)\n     (catch RuntimeException _))\n    (is (instance? Throwable (first (agent-errors agt))))\n    (is (= 1 (count (agent-errors agt))))\n\n    ;; And now send an action that should work\n    (clear-agent-errors agt)\n    (is (= nil @agt))\n    (send agt nil?)\n    (is (true? (await-for fragile-wait agt)))\n    (is (true? @agt))))\n\n(deftest default-modes\n  (is (= :fail (error-mode (agent nil))))\n  (is (= :continue (error-mode (agent nil :error-handler println)))))\n\n(deftest continue-handler\n  (let [err (atom nil)\n        agt (agent 0 :error-mode :continue :error-handler #(reset! err %&))]\n    (send agt /)\n    (is (true? (await-for fragile-wait agt)))\n    (is (= 0 @agt))\n    (is (nil? (agent-error agt)))\n    (is (= agt (first @err)))\n  (is (true? (instance? ArithmeticException (second @err))))))\n\n\n;; TODO: make these tests deterministic (i.e. not sleep and hope)\n\n#_(deftest fail-handler\n  (let [err (atom nil)\n        agt (agent 0 :error-mode :fail :error-handler #(reset! err %&))]\n    (send agt /)\n    (Thread/sleep 100)\n    (is (true? (instance? ArithmeticException (agent-error agt))))\n    (is (= 0 @agt))\n    (is (= agt (first @err)))\n    (is (true? (instance? ArithmeticException (second @err))))\n    (is (thrown? RuntimeException (send agt inc)))))\n\n(deftest can-send-from-error-handler-before-popping-action-that-caused-error\n  (let [latch (CountDownLatch. 1)\n        target-agent (agent :before-error)\n        handler (fn [agt err]\n                  (send target-agent\n                        (fn [_] (.countDown latch))))\n        failing-agent (agent nil :error-handler handler)]\n    (send failing-agent (fn [_] (throw (RuntimeException.))))\n    (is (.await latch 10 TimeUnit/SECONDS))))\n\n(deftest can-send-to-self-from-error-handler-before-popping-action-that-caused-error\n  (let [latch (CountDownLatch. 1)\n        handler (fn [agt err]\n                  (send *agent*\n                        (fn [_] (.countDown latch))))\n        failing-agent (agent nil :error-handler handler)]\n    (send failing-agent (fn [_] (throw (RuntimeException.))))\n    (is (.await latch 10 TimeUnit/SECONDS))))\n\n#_(deftest restart-no-clear\n  (let [p (promise)\n        agt (agent 1 :error-mode :fail)]\n    (send agt (fn [v] @p))\n    (send agt /)\n    (send agt inc)\n    (send agt inc)\n    (deliver p 0)\n    (Thread/sleep 100)\n    (is (= 0 @agt))\n    (is (= ArithmeticException (class (agent-error agt))))\n    (restart-agent agt 10)\n    (is (true? (await-for fragile-wait agt)))\n    (is (= 12 @agt))\n    (is (nil? (agent-error agt)))))\n\n#_(deftest restart-clear\n  (let [p (promise)\n        agt (agent 1 :error-mode :fail)]\n    (send agt (fn [v] @p))\n    (send agt /)\n    (send agt inc)\n    (send agt inc)\n    (deliver p 0)\n    (Thread/sleep 100)\n    (is (= 0 @agt))\n    (is (= ArithmeticException (class (agent-error agt))))\n    (restart-agent agt 10 :clear-actions true)\n    (is (true? (await-for fragile-wait agt)))\n    (is (= 10 @agt))\n    (is (nil? (agent-error agt)))\n    (send agt inc)\n    (is (true? (await-for fragile-wait agt)))\n    (is (= 11 @agt))\n    (is (nil? (agent-error agt)))))\n\n#_(deftest invalid-restart\n  (let [p (promise)\n        agt (agent 2 :error-mode :fail :validator even?)]\n    (is (thrown? RuntimeException (restart-agent agt 4)))\n    (send agt (fn [v] @p))\n    (send agt (partial + 2))\n    (send agt (partial + 2))\n    (deliver p 3)\n    (Thread/sleep 100)\n    (is (= 2 @agt))\n    (is (= IllegalStateException (class (agent-error agt))))\n    (is (thrown? RuntimeException (restart-agent agt 5)))\n    (restart-agent agt 6)\n    (is (true? (await-for fragile-wait agt)))\n    (is (= 10 @agt))\n    (is (nil? (agent-error agt)))))\n\n(deftest earmuff-agent-bound\n  (let [a (agent 1)]\n    (send a (fn [_] *agent*))\n    (await a)\n    (is (= a @a))))\n\n(def ^:dynamic *bind-me* :root-binding)\n\n(deftest thread-conveyance-to-agents\n  (let [a (agent nil)]\n    (doto (Thread.\n           (fn []\n             (binding [*bind-me* :thread-binding]\n               (send a (constantly *bind-me*)))\n             (await a)))\n      (.start)\n      (.join))\n    (is (= @a :thread-binding))))\n\n;; check for a race condition that was causing seque to leak threads from the\n;; send-off pool. Specifically, if we consume all items from the seque, and\n;; the LBQ continues to grow, it means there was an agent action blocking on\n;; the .put, which would block indefinitely outside of this test.\n(deftest seque-threads\n  (let [queue-size 5\n        slow-seq (for [x (take (* 2 queue-size) (iterate inc 0))]\n                   (do (Thread/sleep 25)\n                       x))\n        small-lbq (java.util.concurrent.LinkedBlockingQueue. queue-size)\n        worker (seque small-lbq slow-seq)]\n    (doall worker)\n    (is (= worker slow-seq))\n    (Thread/sleep 250) ;; make sure agents have time to run or get blocked\n    (let [queue-backlog (.size small-lbq)]\n      (is (<= 0 queue-backlog queue-size))\n      (when-not (zero? queue-backlog)\n        (.take small-lbq)\n        (Thread/sleep 250) ;; see if agent was blocking, indicating a thread leak\n        (is (= (.size small-lbq)\n               (dec queue-backlog)))))))\n\n;; Check for a deadlock condition when one seque was fed into another\n;; seque.  Note that this test does not throw an exception or\n;; otherwise fail if the issue is not fixed -- it simply deadlocks and\n;; hangs until killed.\n(deftest seque-into-seque-deadlock\n  (is (= (range 10) (seque 3 (seque 3 (range 10))))))\n\n; http://clojure.org/agents\n\n; agent\n; deref, @-reader-macro, agent-errors\n; send send-off clear-agent-errors\n; await await-for\n; set-validator get-validator\n; add-watch remove-watch\n; shutdown-agents\n\n"
  },
  {
    "path": "test/clojure/test_clojure/annotations/java_5.clj",
    "content": ";; java 5 annotation tests\n(in-ns 'clojure.test-clojure.annotations)\n\n(import [java.lang.annotation Annotation Retention RetentionPolicy Target ElementType])\n(definterface Foo (foo []))\n\n(deftype #^{Deprecated true\n            Retention RetentionPolicy/RUNTIME}\n  Bar [#^int a\n       #^{:tag int\n          Deprecated true\n          Retention RetentionPolicy/RUNTIME} b]\n  Foo (#^{Deprecated true\n          Retention RetentionPolicy/RUNTIME}\n       foo [this] 42))\n\n(defn annotation->map\n  \"Converts a Java annotation (which conceals data)\n   into a map (which makes is usable). Not lazy.\n   Works recursively. Returns non-annotations unscathed.\"\n  [#^java.lang.annotation.Annotation o]\n  (cond\n   (instance? Annotation o)\n   (let [type (.annotationType o)\n         itfs (-> (into #{type} (supers type)) (disj java.lang.annotation.Annotation))\n         data-methods (into #{} (mapcat #(.getDeclaredMethods %) itfs))]\n     (into\n      {:annotationType (.annotationType o)}\n      (map\n       (fn [m] [(keyword (.getName m)) (annotation->map (.invoke m o nil))])\n       data-methods)))\n   (or (sequential? o) (.isArray (class o)))\n   (map annotation->map o)\n     :else o))\n\n(def expected-annotations\n  #{{:annotationType java.lang.annotation.Retention, :value RetentionPolicy/RUNTIME}\n    {:annotationType java.lang.Deprecated}})\n\n(deftest test-annotations-on-type\n  (is (=\n       expected-annotations\n       (into #{} (map annotation->map (.getAnnotations Bar))))))\n\n(deftest test-annotations-on-field\n  (is (=\n       expected-annotations\n       (into #{} (map annotation->map (.getAnnotations (.getField Bar \"b\")))))))\n\n(deftest test-annotations-on-method\n  (is (=\n       expected-annotations\n       (into #{} (map annotation->map (.getAnnotations (.getMethod Bar \"foo\" nil)))))))\n\n(gen-class :name foo.Bar\n           :extends clojure.lang.Box\n           :constructors {^{Deprecated true} [Object] [Object]}\n           :init init\n           :prefix \"foo\")\n\n(defn foo-init [obj]\n  [[obj] nil])\n\n(deftest test-annotations-on-constructor\n  (is (some #(instance? Deprecated %)\n            (for [ctor (.getConstructors (Class/forName \"foo.Bar\"))\n                  annotation (.getAnnotations ctor)]\n              annotation))))\n"
  },
  {
    "path": "test/clojure/test_clojure/annotations/java_6.clj",
    "content": ";; java 6 annotation tests\n(in-ns 'clojure.test-clojure.annotations)\n\n(import [java.lang.annotation Annotation Retention RetentionPolicy Target ElementType]\n        [javax.xml.ws WebServiceRef WebServiceRefs])\n(definterface Foo (foo []))\n\n(deftype #^{Deprecated true\n            ;Retention RetentionPolicy/RUNTIME\n            javax.annotation.processing.SupportedOptions [\"foo\" \"bar\" \"baz\"]\n            javax.xml.ws.soap.Addressing {:enabled false :required true}\n            WebServiceRefs [(WebServiceRef {:name \"fred\" :type String})\n                            (WebServiceRef {:name \"ethel\" :mappedName \"lucy\"})]}\n  Bar [#^int a\n       #^{:tag int\n          Deprecated true\n          ;Retention RetentionPolicy/RUNTIME\n          ;javax.annotation.processing.SupportedOptions [\"foo\" \"bar\" \"baz\"]\n          ;javax.xml.ws.soap.Addressing {:enabled false :required true}\n          ;WebServiceRefs [(WebServiceRef {:name \"fred\" :type String})\n          ;                  (WebServiceRef {:name \"ethel\" :mappedName \"lucy\"})]\n          }\n       b]\n  Foo (#^{Deprecated true\n          ;Retention RetentionPolicy/RUNTIME\n          ;javax.annotation.processing.SupportedOptions [\"foo\" \"bar\" \"baz\"]\n          ;javax.xml.ws.soap.Addressing {:enabled false :required true}\n          ;WebServiceRefs [(WebServiceRef {:name \"fred\" :type String})\n          ;                (WebServiceRef {:name \"ethel\" :mappedName \"lucy\"})]\n          }\n       foo [this] 42))\n\n(defn annotation->map\n  \"Converts a Java annotation (which conceals data)\n   into a map (which makes is usable). Not lazy.\n   Works recursively. Returns non-annotations unscathed.\"\n  [#^java.lang.annotation.Annotation o]\n  (cond\n   (instance? Annotation o)\n   (let [type (.annotationType o)\n         itfs (-> (into #{type} (supers type)) (disj java.lang.annotation.Annotation))\n         data-methods (into #{} (mapcat #(.getDeclaredMethods %) itfs))]\n     (into\n      {:annotationType (.annotationType o)}\n      (map\n       (fn [m] [(keyword (.getName m)) (annotation->map (.invoke m o nil))])\n       data-methods)))\n   (or (sequential? o) (.isArray (class o)))\n   (map annotation->map o)\n     :else o))\n\n(def expected-annotations\n  #{{:annotationType java.lang.annotation.Retention, :value RetentionPolicy/RUNTIME}\n    {:annotationType javax.xml.ws.WebServiceRefs,\n     :value [{:annotationType javax.xml.ws.WebServiceRef, :name \"fred\", :mappedName \"\", :type java.lang.String, :wsdlLocation \"\", :value java.lang.Object}\n             {:annotationType javax.xml.ws.WebServiceRef, :name \"ethel\", :mappedName \"lucy\", :type java.lang.Object, :wsdlLocation \"\", :value java.lang.Object}]}\n    {:annotationType javax.xml.ws.soap.Addressing, :enabled false, :required true}\n    {:annotationType javax.annotation.processing.SupportedOptions, :value [\"foo\" \"bar\" \"baz\"]}\n    {:annotationType java.lang.Deprecated}})\n\n(deftest test-annotations-on-type\n  (is (=\n       expected-annotations\n       (into #{} (map annotation->map (.getAnnotations Bar))))))\n\n(deftest test-annotations-on-field\n  (is (=\n       expected-annotations\n       (into #{} (map annotation->map (.getAnnotations (.getField Bar \"b\")))))))\n\n(deftest test-annotations-on-method\n  (is (=\n       expected-annotations\n       (into #{} (map annotation->map (.getAnnotations (.getMethod Bar \"foo\" nil)))))))\n\n(gen-class :name foo.Bar\n           :extends clojure.lang.Box\n           :constructors {^{Deprecated true} [Object] [Object]}\n           :init init\n           :prefix \"foo\")\n\n(defn foo-init [obj]\n  [[obj] nil])\n\n(deftest test-annotations-on-constructor\n  (is (some #(instance? Deprecated %)\n            (for [ctor (.getConstructors (Class/forName \"foo.Bar\"))\n                  annotation (.getAnnotations ctor)]\n              annotation))))\n"
  },
  {
    "path": "test/clojure/test_clojure/annotations.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Authors: Stuart Halloway, Rich Hickey\n\n(ns clojure.test-clojure.annotations\n  (:use clojure.test))\n\n(case (System/getProperty \"java.specification.version\")\n      \"1.6\" (load \"annotations/java_6\")\n      nil)\n\n"
  },
  {
    "path": "test/clojure/test_clojure/api.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns clojure.test-clojure.api\n  (:require [clojure.test.generative :refer (defspec)]\n            [clojure.test-clojure.generators :as cgen])\n  (:import clojure.lang.IFn\n           clojure.java.api.Clojure\n           clojure.lang.Var))\n\n(set! *warn-on-reflection* true)\n\n(defn roundtrip\n  \"Print an object and read it back with Clojure/read\"\n  [o]\n  (binding [*print-length* nil\n            *print-dup* nil\n            *print-level* nil]\n    (Clojure/read (pr-str o))))\n\n(defn api-var-str\n  [^Var v]\n  (Clojure/var (str (.name (.ns v)))\n               (str (.sym v))))\n\n(defn api-var\n  [^Var v]\n  (Clojure/var (.name (.ns v))\n               (.sym v)))\n\n(defspec api-can-read\n  roundtrip\n  [^{:tag cgen/ednable} o]\n  (when-not (= o %)\n    (throw (ex-info \"Value cannot roundtrip with Clojure/read\" {:printed o :read %}))))\n\n(defspec api-can-find-var\n  api-var\n  [^{:tag cgen/var} v]\n  (when-not (= v %)\n    (throw (ex-info \"Var cannot roundtrip through Clojure/var\" {:from v :to %}))))\n\n(defspec api-can-find-var-str\n  api-var-str\n  [^{:tag cgen/var} v]\n  (when-not (= v %)\n    (throw (ex-info \"Var cannot roundtrip strings through Clojure/var\" {:from v :to %}))))\n\n\n"
  },
  {
    "path": "test/clojure/test_clojure/atoms.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;;Author: Frantisek Sodomka\n\n(ns clojure.test-clojure.atoms\n  (:use clojure.test))\n\n; http://clojure.org/atoms\n\n; atom\n; deref, @-reader-macro\n; swap! reset!\n; compare-and-set!\n\n"
  },
  {
    "path": "test/clojure/test_clojure/clojure_set.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Frantisek Sodomka\n\n\n(ns clojure.test-clojure.clojure-set\n  (:use clojure.test)\n  (:require [clojure.set :as set]))\n\n(deftest test-union\n  (are [x y] (= x y)\n      (set/union) #{}\n\n      ; identity\n      (set/union #{}) #{}\n      (set/union #{1}) #{1}\n      (set/union #{1 2 3}) #{1 2 3}\n\n      ; 2 sets, at least one is empty\n      (set/union #{} #{}) #{}\n      (set/union #{} #{1}) #{1}\n      (set/union #{} #{1 2 3}) #{1 2 3}\n      (set/union #{1} #{}) #{1}\n      (set/union #{1 2 3} #{}) #{1 2 3}\n\n      ; 2 sets\n      (set/union #{1} #{2}) #{1 2}\n      (set/union #{1} #{1 2}) #{1 2}\n      (set/union #{2} #{1 2}) #{1 2}\n      (set/union #{1 2} #{3}) #{1 2 3}\n      (set/union #{1 2} #{2 3}) #{1 2 3}\n\n      ; 3 sets, some are empty\n      (set/union #{} #{} #{}) #{}\n      (set/union #{1} #{} #{}) #{1}\n      (set/union #{} #{1} #{}) #{1}\n      (set/union #{} #{} #{1}) #{1}\n      (set/union #{1 2} #{2 3} #{}) #{1 2 3}\n\n      ; 3 sets\n      (set/union #{1 2} #{3 4} #{5 6}) #{1 2 3 4 5 6}\n      (set/union #{1 2} #{2 3} #{1 3 4}) #{1 2 3 4}\n\n      ; different data types\n      (set/union #{1 2} #{:a :b} #{nil} #{false true} #{\\c \"abc\"} #{[] [1 2]}\n        #{{} {:a 1}} #{#{} #{1 2}})\n          #{1 2 :a :b nil false true \\c \"abc\" [] [1 2] {} {:a 1} #{} #{1 2}}\n\n      ; different types of sets\n      (set/union (hash-set) (hash-set 1 2) (hash-set 2 3))\n          (hash-set 1 2 3)\n      (set/union (sorted-set) (sorted-set 1 2) (sorted-set 2 3))\n          (sorted-set 1 2 3)\n      (set/union (hash-set) (hash-set 1 2) (hash-set 2 3)\n        (sorted-set) (sorted-set 4 5) (sorted-set 5 6))\n          (hash-set 1 2 3 4 5 6)  ; also equals (sorted-set 1 2 3 4 5 6)\n))\n\n(deftest test-intersection\n  ; at least one argument is needed\n  (is (thrown? IllegalArgumentException (set/intersection)))\n  \n  (are [x y] (= x y)\n      ; identity\n      (set/intersection #{}) #{}\n      (set/intersection #{1}) #{1}\n      (set/intersection #{1 2 3}) #{1 2 3}\n      \n      ; 2 sets, at least one is empty\n      (set/intersection #{} #{}) #{}\n      (set/intersection #{} #{1}) #{}\n      (set/intersection #{} #{1 2 3}) #{}\n      (set/intersection #{1} #{}) #{}\n      (set/intersection #{1 2 3} #{}) #{}\n\n      ; 2 sets\n      (set/intersection #{1 2} #{1 2}) #{1 2}\n      (set/intersection #{1 2} #{3 4}) #{}\n      (set/intersection #{1 2} #{1}) #{1}\n      (set/intersection #{1 2} #{2}) #{2}\n      (set/intersection #{1 2 4} #{2 3 4 5}) #{2 4}\n\n      ; 3 sets, some are empty\n      (set/intersection #{} #{} #{}) #{}\n      (set/intersection #{1} #{} #{}) #{}\n      (set/intersection #{1} #{1} #{}) #{}\n      (set/intersection #{1} #{} #{1}) #{}\n      (set/intersection #{1 2} #{2 3} #{}) #{}\n\n      ; 3 sets\n      (set/intersection #{1 2} #{2 3} #{5 2}) #{2}\n      (set/intersection #{1 2 3} #{1 3 4} #{1 3}) #{1 3}\n      (set/intersection #{1 2 3} #{3 4 5} #{8 2 3}) #{3}\n\n      ; different types of sets\n      (set/intersection (hash-set 1 2) (hash-set 2 3)) #{2}\n      (set/intersection (sorted-set 1 2) (sorted-set 2 3)) #{2}\n      (set/intersection\n        (hash-set 1 2) (hash-set 2 3)\n        (sorted-set 1 2) (sorted-set 2 3)) #{2} ))\n\n(deftest test-difference\n  (are [x y] (= x y)\n      ; identity\n      (set/difference #{}) #{}\n      (set/difference #{1}) #{1}\n      (set/difference #{1 2 3}) #{1 2 3}\n\n      ; 2 sets\n      (set/difference #{1 2} #{1 2}) #{}\n      (set/difference #{1 2} #{3 4}) #{1 2}\n      (set/difference #{1 2} #{1}) #{2}\n      (set/difference #{1 2} #{2}) #{1}\n      (set/difference #{1 2 4} #{2 3 4 5}) #{1}\n\n       ; 3 sets\n      (set/difference #{1 2} #{2 3} #{5 2}) #{1}\n      (set/difference #{1 2 3} #{1 3 4} #{1 3}) #{2}\n      (set/difference #{1 2 3} #{3 4 5} #{8 2 3}) #{1} ))\n\n(deftest test-select\n  (are [x y] (= x y)\n    (set/select integer? #{}) #{}\n    (set/select integer? #{1 2}) #{1 2}\n    (set/select integer? #{1 2 :a :b :c}) #{1 2}\n    (set/select integer? #{:a :b :c}) #{}) )\n\n(def compositions\n  #{{:name \"Art of the Fugue\" :composer \"J. S. Bach\"}\n    {:name \"Musical Offering\" :composer \"J. S. Bach\"}\n    {:name \"Requiem\" :composer \"Giuseppe Verdi\"}\n    {:name \"Requiem\" :composer \"W. A. Mozart\"}})\n\n(deftest test-project\n  (are [x y] (= x y)\n    (set/project compositions [:name]) #{{:name \"Art of the Fugue\"}\n                                         {:name \"Requiem\"}\n                                         {:name \"Musical Offering\"}}\n    (set/project compositions [:composer]) #{{:composer \"W. A. Mozart\"}\n                                             {:composer \"Giuseppe Verdi\"}\n                                             {:composer \"J. S. Bach\"}}\n    (set/project compositions [:year]) #{{}}\n    (set/project #{{}} [:name]) #{{}} ))\n\n(deftest test-rename\n  (are [x y] (= x y)\n    (set/rename compositions {:name :title}) #{{:title \"Art of the Fugue\" :composer \"J. S. Bach\"}\n                                               {:title \"Musical Offering\" :composer \"J. S. Bach\"}\n                                               {:title \"Requiem\" :composer \"Giuseppe Verdi\"}\n                                               {:title \"Requiem\" :composer \"W. A. Mozart\"}}\n    (set/rename compositions {:year :decade}) #{{:name \"Art of the Fugue\" :composer \"J. S. Bach\"}\n                                                {:name \"Musical Offering\" :composer \"J. S. Bach\"}\n                                                {:name \"Requiem\" :composer \"Giuseppe Verdi\"}\n                                                {:name \"Requiem\" :composer \"W. A. Mozart\"}}\n    (set/rename #{{}} {:year :decade}) #{{}}))\n\n(deftest test-rename-keys\n  (are [x y] (= x y)\n       (set/rename-keys {:a \"one\" :b \"two\"} {:a :z}) {:z \"one\" :b \"two\"}\n       (set/rename-keys {:a \"one\" :b \"two\"} {:a :z :c :y}) {:z \"one\" :b \"two\"}\n       (set/rename-keys {:a \"one\" :b \"two\" :c \"three\"} {:a :b :b :a}) {:a \"two\" :b \"one\" :c \"three\"}))\n\n(deftest test-index\n  (are [x y] (= x y)\n    (set/index  #{{:c 2} {:b 1} {:a 1 :b 2}} [:b]) {{:b 2} #{{:a 1 :b 2}}, {:b 1} #{{:b 1}} {} #{{:c 2}}}\n  ))\n\n(deftest test-join\n  (are [x y] (= x y)\n    (set/join compositions compositions) compositions\n    (set/join compositions #{{:name \"Art of the Fugue\" :genre \"Classical\"}})\n                           #{{:name \"Art of the Fugue\" :composer \"J. S. Bach\" :genre \"Classical\"}}\n    ))\n\n(deftest test-map-invert\n  (are [x y] (= x y)\n       (set/map-invert {:a \"one\" :b \"two\"}) {\"one\" :a \"two\" :b}))\n\n(deftest test-subset?\n  (are [sub super] (set/subset? sub super)\n       #{} #{}\n       #{} #{1}\n       #{1} #{1}\n       #{1 2} #{1 2}\n       #{1 2} #{1 2 42}\n       #{false} #{false}\n       #{nil}   #{nil}\n       #{nil}   #{nil false}\n       #{1 2 nil} #{1 2 nil 4})\n  (are [notsub super] (not (set/subset? notsub super))\n       #{1} #{}\n       #{2} #{1}\n       #{1 3} #{1}\n       #{nil} #{false}\n       #{false} #{nil}\n       #{false nil} #{nil}\n       #{1 2 nil}   #{1 2}))\n\n(deftest test-superset?\n  (are [super sub] (set/superset? super sub)\n       #{} #{}\n       #{1} #{}\n       #{1} #{1}\n       #{1 2} #{1 2}\n       #{1 2 42} #{1 2}\n       #{false}  #{false}\n       #{nil}    #{nil}\n       #{false nil} #{false}\n       #{1 2 4 nil false} #{1 2 nil})\n  (are [notsuper sub] (not (set/superset? notsuper sub))\n       #{} #{1}\n       #{2} #{1}\n       #{1} #{1 3}\n       #{nil} #{false}\n       #{false} #{nil}\n       #{nil}   #{false nil}\n       #{nil 2 3} #{false nil 2 3}))\n\n"
  },
  {
    "path": "test/clojure/test_clojure/clojure_walk.clj",
    "content": "(ns clojure.test-clojure.clojure-walk\n  (:require [clojure.walk :as w])\n  (:use clojure.test))\n\n(deftest t-prewalk-replace\n  (is (= (w/prewalk-replace {:a :b} [:a {:a :a} (list 3 :c :a)])\n         [:b {:b :b} (list 3 :c :b)])))\n\n(deftest t-postwalk-replace \n  (is (= (w/postwalk-replace {:a :b} [:a {:a :a} (list 3 :c :a)])\n         [:b {:b :b} (list 3 :c :b)])))\n\n(deftest t-stringify-keys\n  (is (= (w/stringify-keys {:a 1, nil {:b 2 :c 3}, :d 4})\n         {\"a\" 1, nil {\"b\" 2 \"c\" 3}, \"d\" 4})))\n\n(deftest t-prewalk-order\n  (is (= (let [a (atom [])]\n           (w/prewalk (fn [form] (swap! a conj form) form)\n                      [1 2 {:a 3} (list 4 [5])])\n           @a)\n         [[1 2 {:a 3} (list 4 [5])]\n          1 2 {:a 3} [:a 3] :a 3 (list 4 [5])\n          4 [5] 5])))\n\n(deftest t-postwalk-order\n  (is (= (let [a (atom [])]\n           (w/postwalk (fn [form] (swap! a conj form) form)\n                      [1 2 {:a 3} (list 4 [5])])\n           @a)\n         [1 2\n          :a 3 [:a 3] {:a 3}\n          4 5 [5] (list 4 [5])\n          [1 2 {:a 3} (list 4 [5])]])))\n\n(defrecord Foo [a b c])\n\n(deftest walk\n         \"Checks that walk returns the correct result and type of collection\"\n         (let [colls ['(1 2 3)\n                      [1 2 3]\n                      #{1 2 3}\n                      (sorted-set-by > 1 2 3)\n                      {:a 1, :b 2, :c 3}\n                      (sorted-map-by > 1 10, 2 20, 3 30)\n                      (->Foo 1 2 3)\n                      (map->Foo {:a 1 :b 2 :c 3 :extra 4})]]\n           (doseq [c colls]\n             (let [walked (w/walk identity identity c)]\n               (is (= c walked))\n               (is (= (type c) (type walked)))\n               (if (map? c)\n                 (is (= (w/walk #(update-in % [1] inc) #(reduce + (vals %)) c)\n                        (reduce + (map (comp inc val) c))))\n                 (is (= (w/walk inc #(reduce + %) c)\n                        (reduce + (map inc c)))))\n               (when (or (instance? clojure.lang.PersistentTreeMap c)\n                         (instance? clojure.lang.PersistentTreeSet c))\n                 (is (= (.comparator c) (.comparator walked))))))))\n\n"
  },
  {
    "path": "test/clojure/test_clojure/clojure_xml.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;;Author: Frantisek Sodomka\n\n\n(ns clojure.test-clojure.clojure-xml\n  (:use clojure.test)\n  (:require [clojure.xml :as xml]))\n\n\n; parse\n\n; emit-element\n; emit\n\n"
  },
  {
    "path": "test/clojure/test_clojure/clojure_zip.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka\n\n\n(ns clojure.test-clojure.clojure-zip\n  (:use clojure.test)\n  (:require [clojure.zip :as zip]))\n\n\n; zipper\n;\n; seq-zip\n; vector-zip\n; xml-zip\n;\n; node\n; branch?\n; children\n; make-node\n; path\n; lefts\n; rights\n; down\n; up\n; root\n; right\n; rightmost\n; left\n; leftmost\n;\n; insert-left\n; insert-right\n; replace\n; edit\n; insert-child\n; append-child\n; next\n; prev\n; end?\n; remove\n\n"
  },
  {
    "path": "test/clojure/test_clojure/compilation/examples.clj",
    "content": ";;   Copyright (c) Rich Hickey. All rights reserved.\n;;   The use and distribution terms for this software are covered by the\n;;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;;   which can be found in the file epl-v10.html at the root of this distribution.\n;;   By using this software in any fashion, you are agreeing to be bound by\n;;   the terms of this license.\n;;   You must not remove this notice, or any other, from this software.\n\n(ns clojure.test-clojure.compilation.examples)\n\n(eval '(deftype X []))\n(deftype T [])\n"
  },
  {
    "path": "test/clojure/test_clojure/compilation/line_number_examples.clj",
    "content": "(ns clojure.test-clojure.compilation.line-number-examples\n  \"Example code taken from Paul Stadig and updated by Daniel Solano Gómez.\n\n  Original source at:\n    https://github.com/pjstadig/clojure-line-numbers/blob/master/src/clojure_line_numbers/core.clj\"\n  (:import (clojure.lang PersistentHashMap)))\n\n(defrecord Thing [field ^long primitive])\n\n(defn instance-field\n  \"I throw an exception in an instance field form.\"\n  []\n  (.field\n   ^Thing (identity nil)))\n\n(defn instance-field-reflected\n  \"I throw an exception in an instance field form.\"\n  []\n  (.field\n   (identity nil)))\n\n(defn instance-field-unboxed\n  \"I throw an exception in an instance field form.\"\n  ^long []\n  (.primitive\n   ^Thing (identity nil)))\n\n#_(defn instance-field-assign\n   \"I throw an exception in an instance field assignment form.\"\n   []\n   (set!\n    (.field\n     ^Thing (identity nil))\n    (identity nil)))\n\n#_(defn instance-field-assign-reflected\n   \"I throw an exception in an instance field assignment form.\"\n   []\n   (set!\n    (.field\n     (identity nil))\n    (identity nil)))\n\n#_(defn static-field-assign\n   \"I throw an exception in a static field assignment form.\"\n   []\n   (set!\n    PersistentHashMap/EMPTY\n    (identity nil)))\n\n(defn instance-method\n  \"I throw an exception in an instance method form.\"\n  []\n  (.without\n   ^PersistentHashMap (identity nil)\n   :key))\n\n(defn instance-method-reflected\n  \"I throw an exception in an instance method form.\"\n  []\n  (.without\n   (identity nil)\n   :key))\n\n(defn instance-method-unboxed\n  \"I throw an exception in an instance method form.\"\n  ^long []\n  (.count\n   ^PersistentHashMap (identity nil)))\n\n(defn static-method\n  \"I throw an exception in a static method form.\"\n  []\n  (PersistentHashMap/create\n   ^java.util.Map (identity nil)))\n\n(defn static-method-reflected\n  \"I throw an exception in a static method form.\"\n  []\n  (String/copyValueOf\n   (identity nil)))\n\n(defn static-method-unboxed\n  \"I throw an exception in a static method form.\"\n  ^long []\n  (Long/parseLong\n   ^String (identity nil)))\n\n(defn invoke\n  \"I throw an exception in an invoke form.\"\n  []\n  ((identity nil)\n   (identity nil)))\n\n(defn threading\n  \"I throw an exception in a threading form.\"\n  []\n  (-> :foo\n      (identity)\n      (identity)\n      ((identity nil))\n      (identity)\n      (identity)))\n\n(defn keyword-invoke\n  \"I throw an exception in a keyword invoke.\"\n  []\n  (letfn [(get-map []\n            (let [t (transient {})]\n              (persistent! t)\n              t))]\n    (:foo\n     (get-map))))\n\n(defn invoke-cast\n  \"I throw an exception casting to IFn in an invoke form.\"\n  []\n  ;; This code formatting is intentional.\n  (\n   (identity 1)\n   (identity nil)))\n"
  },
  {
    "path": "test/clojure/test_clojure/compilation.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka\n\n\n(ns clojure.test-clojure.compilation\n  (:import (clojure.lang Compiler Compiler$CompilerException))\n  (:require [clojure.test.generative :refer (defspec)]\n            [clojure.data.generators :as gen]\n            [clojure.test-clojure.compilation.line-number-examples :as line])\n  (:use clojure.test\n        [clojure.test-helper :only (should-not-reflect should-print-err-message)]))\n\n; http://clojure.org/compilation\n\n; compile\n; gen-class, gen-interface\n\n\n(deftest test-compiler-metadata\n  (let [m (meta #'when)]\n    (are [x y]  (= x y)\n        (list? (:arglists m)) true\n        (> (count (:arglists m)) 0) true\n\n        (string? (:doc m)) true\n        (> (.length (:doc m)) 0) true\n\n        (string? (:file m)) true\n        (> (.length (:file m)) 0) true\n\n        (integer? (:line m)) true\n        (> (:line m) 0) true\n\n        (integer? (:column m)) true\n        (> (:column m) 0) true\n\n        (:macro m) true\n        (:name m) 'when )))\n\n(deftest test-embedded-constants\n  (testing \"Embedded constants\"\n    (is (eval `(= Boolean/TYPE ~Boolean/TYPE)))\n    (is (eval `(= Byte/TYPE ~Byte/TYPE)))\n    (is (eval `(= Character/TYPE ~Character/TYPE)))\n    (is (eval `(= Double/TYPE ~Double/TYPE)))\n    (is (eval `(= Float/TYPE ~Float/TYPE)))\n    (is (eval `(= Integer/TYPE ~Integer/TYPE)))\n    (is (eval `(= Long/TYPE ~Long/TYPE)))\n    (is (eval `(= Short/TYPE ~Short/TYPE)))))\n\n(deftest test-compiler-resolution\n  (testing \"resolve nonexistent class create should return nil (assembla #262)\"\n    (is (nil? (resolve 'NonExistentClass.)))))\n\n(deftest test-no-recur-across-try\n  (testing \"don't recur to function from inside try\"\n    (is (thrown? Compiler$CompilerException\n                 (eval '(fn [x] (try (recur 1)))))))\n  (testing \"don't recur to loop from inside try\"\n    (is (thrown? Compiler$CompilerException\n                 (eval '(loop [x 5]\n                          (try (recur 1)))))))\n  (testing \"don't recur to loop from inside of catch inside of try\"\n    (is (thrown? Compiler$CompilerException\n                 (eval '(loop [x 5]\n                          (try\n                            (catch Exception e\n                              (recur 1))))))))\n  (testing \"don't recur to loop from inside of finally inside of try\"\n    (is (thrown? Compiler$CompilerException\n                 (eval '(loop [x 5]\n                          (try\n                            (finally\n                              (recur 1))))))))\n  (testing \"don't get confused about what the recur is targeting\"\n    (is (thrown? Compiler$CompilerException\n                 (eval '(loop [x 5]\n                          (try (fn [x]) (recur 1)))))))\n  (testing \"don't allow recur across binding\"\n    (is (thrown? Compiler$CompilerException\n                 (eval '(fn [x] (binding [+ *] (recur 1)))))))\n  (testing \"allow loop/recur inside try\"\n    (is (= 0 (eval '(try (loop [x 3]\n                           (if (zero? x) x (recur (dec x)))))))))\n  (testing \"allow loop/recur fully inside catch\"\n    (is (= 3 (eval '(try\n                      (throw (Exception.))\n                      (catch Exception e\n                        (loop [x 0]\n                          (if (< x 3) (recur (inc x)) x))))))))\n  (testing \"allow loop/recur fully inside finally\"\n    (is (= \"012\" (eval '(with-out-str\n                          (try\n                            :return-val-discarded-because-of-with-out-str\n                            (finally (loop [x 0]\n                                       (when (< x 3)\n                                         (print x)\n                                         (recur (inc x)))))))))))\n  (testing \"allow fn/recur inside try\"\n    (is (= 0 (eval '(try\n                      ((fn [x]\n                         (if (zero? x)\n                           x\n                           (recur (dec x))))\n                       3)))))))\n\n;; disabled until build box can call java from mvn\n#_(deftest test-numeric-dispatch\n  (is (= \"(int, int)\" (TestDispatch/someMethod (int 1) (int 1))))\n  (is (= \"(int, long)\" (TestDispatch/someMethod (int 1) (long 1))))\n  (is (= \"(long, long)\" (TestDispatch/someMethod (long 1) (long 1)))))\n\n(deftest test-CLJ-671-regression\n  (testing \"that the presence of hints does not cause the compiler to infinitely loop\"\n    (letfn [(gcd [x y]\n              (loop [x (long x) y (long y)]\n                (if (== y 0)\n                  x\n                  (recur y ^Long(rem x y)))))]\n      (is (= 4 (gcd 8 100))))))\n\n;; ensure proper use of hints / type decls\n\n(defn hinted\n  (^String [])\n  (^Integer [a])\n  (^java.util.List [a & args]))\n\n;; fn names need to be fully-qualified because should-not-reflect evals its arg in a throwaway namespace\n\n(deftest recognize-hinted-arg-vector\n  (should-not-reflect #(.substring (clojure.test-clojure.compilation/hinted) 0))\n  (should-not-reflect #(.floatValue (clojure.test-clojure.compilation/hinted \"arg\")))\n  (should-not-reflect #(.size (clojure.test-clojure.compilation/hinted :many :rest :args :here))))\n\n(defn ^String hinting-conflict ^Integer [])\n\n(deftest calls-use-arg-vector-hint\n  (should-not-reflect #(.floatValue (clojure.test-clojure.compilation/hinting-conflict)))\n  (should-print-err-message #\"(?s)Reflection warning.*\"\n    #(.substring (clojure.test-clojure.compilation/hinting-conflict) 0)))\n\n(deftest deref-uses-var-tag\n  (should-not-reflect #(.substring clojure.test-clojure.compilation/hinting-conflict 0))\n  (should-print-err-message #\"(?s)Reflection warning.*\"\n    #(.floatValue clojure.test-clojure.compilation/hinting-conflict)))\n\n(defn ^String legacy-hinting [])\n\n(deftest legacy-call-hint\n  (should-not-reflect #(.substring (clojure.test-clojure.compilation/legacy-hinting) 0)))\n\n(defprotocol HintedProtocol\n  (hintedp ^String [a]\n           ^Integer [a b]))\n\n(deftest hinted-protocol-arg-vector\n  (should-not-reflect #(.substring (clojure.test-clojure.compilation/hintedp \"\") 0))\n  (should-not-reflect #(.floatValue (clojure.test-clojure.compilation/hintedp :a :b))))\n\n(defn primfn\n  (^long [])\n  (^double [a]))\n\n(deftest primitive-return-decl\n  (should-not-reflect #(loop [k 5] (recur (clojure.test-clojure.compilation/primfn))))\n  (should-not-reflect #(loop [k 5.0] (recur (clojure.test-clojure.compilation/primfn 0))))\n\n  (should-print-err-message #\"(?s).*k is not matching primitive.*\"\n    #(loop [k (clojure.test-clojure.compilation/primfn)] (recur :foo))))\n\n#_(deftest CLJ-1154-use-out-after-compile\n  ;; This test creates a dummy file to compile, sets up a dummy\n  ;; compiled output directory, and a dummy output stream, and\n  ;; verifies the stream is still usable after compiling.\n  (spit \"test/dummy.clj\" \"(ns dummy)\")\n  (try\n    (let [compile-path (System/getProperty \"clojure.compile.path\")\n          tmp (java.io.File. \"tmp\")\n          new-out (java.io.OutputStreamWriter. (java.io.ByteArrayOutputStream.))]\n      (binding [clojure.core/*out* new-out]\n        (try\n          (.mkdir tmp)\n          (System/setProperty \"clojure.compile.path\" \"tmp\")\n          (clojure.lang.Compile/main (into-array [\"dummy\"]))\n          (println \"this should still work without throwing an exception\" )\n          (finally\n            (if compile-path\n              (System/setProperty \"clojure.compile.path\" compile-path)\n              (System/clearProperty \"clojure.compile.path\"))\n            (doseq [f (.listFiles tmp)]\n              (.delete f))\n            (.delete tmp)))))\n    (finally\n      (doseq [f (.listFiles (java.io.File. \"test\"))\n              :when (re-find #\"dummy.clj\" (str f))]\n        (.delete f)))))\n\n(deftest CLJ-1184-do-in-non-list-test\n  (testing \"do in a vector throws an exception\"\n    (is (thrown? Compiler$CompilerException\n                 (eval '[do 1 2 3]))))\n  (testing \"do in a set throws an exception\"\n    (is (thrown? Compiler$CompilerException\n                 (eval '#{do}))))\n\n  ;; compile uses a separate code path so we have to call it directly\n  ;; to test it\n  (letfn [(compile [s]\n            (spit \"test/clojure/bad_def_test.clj\" (str \"(ns clojure.bad-def-test)\\n\" s))\n            (try\n             (binding [*compile-path* \"test\"]\n               (clojure.core/compile 'clojure.bad-def-test))\n             (finally\n               (doseq [f (.listFiles (java.io.File. \"test/clojure\"))\n                       :when (re-find #\"bad_def_test\" (str f))]\n                 (.delete f)))))]\n    (testing \"do in a vector throws an exception in compilation\"\n      (is (thrown? Compiler$CompilerException (compile \"[do 1 2 3]\"))))\n    (testing \"do in a set throws an exception in compilation\"\n      (is (thrown? Compiler$CompilerException (compile \"#{do}\"))))))\n\n(defn gen-name []\n  ;; Not all names can be correctly demunged. Skip names that contain\n  ;; a munge word as they will not properly demunge.\n  (let [munge-words (remove clojure.string/blank?\n                            (conj (map #(clojure.string/replace % \"_\" \"\")\n                                       (vals Compiler/CHAR_MAP)) \"_\"))]\n    (first (filter (fn [n] (not-any? #(>= (.indexOf n %) 0) munge-words))\n                   (repeatedly #(name (gen/symbol (constantly 10))))))))\n\n(defn munge-roundtrip [n]\n  (Compiler/demunge (Compiler/munge n)))\n\n(defspec test-munge-roundtrip\n  munge-roundtrip\n  [^{:tag clojure.test-clojure.compilation/gen-name} n]\n  (assert (= n %)))\n\n(deftest test-fnexpr-type-hint\n  (testing \"CLJ-1378: FnExpr should be allowed to override its reported class with a type hint.\"\n    (is (thrown? Compiler$CompilerException\n                 (load-string \"(.submit (java.util.concurrent.Executors/newCachedThreadPool) #())\")))\n    (is (try (load-string \"(.submit (java.util.concurrent.Executors/newCachedThreadPool) ^Runnable #())\")\n             (catch Compiler$CompilerException e nil)))))\n\n;(defrecord Y [a])\n;#clojure.test_clojure.compilation.Y[1]\n(defrecord Y [b])\n#clojure.test_clojure.compilation.Y[1]\n\n(binding [*compile-path* \"target/test-classes\"]\n  (compile 'clojure.test-clojure.compilation.examples))\n\n\n(deftest test-compiler-line-numbers\n  (let [fails-on-line-number? (fn [expected function]\n                                 (try\n                                   (function)\n                                   nil\n                                   (catch Throwable t\n                                     (let [frames (filter #(= \"line_number_examples.clj\" (.getFileName %))\n                                                          (.getStackTrace t))\n                                           _ (if (zero? (count frames))\n                                               (.printStackTrace t)\n                                               )\n                                           actual (.getLineNumber ^StackTraceElement (first frames))]\n                                       (= expected actual)))))]\n    (is (fails-on-line-number?  13 line/instance-field))\n    (is (fails-on-line-number?  19 line/instance-field-reflected))\n    (is (fails-on-line-number?  25 line/instance-field-unboxed))\n    ;(is (fails-on-line-number?  32 line/instance-field-assign))\n    ;(is (fails-on-line-number?  40 line/instance-field-assign-reflected))\n    ;(is (fails-on-line-number?  47 line/static-field-assign))\n    (is (fails-on-line-number?  54 line/instance-method))\n    (is (fails-on-line-number?  61 line/instance-method-reflected))\n    (is (fails-on-line-number?  68 line/instance-method-unboxed))\n    (is (fails-on-line-number?  74 line/static-method))\n    (is (fails-on-line-number?  80 line/static-method-reflected))\n    (is (fails-on-line-number?  86 line/static-method-unboxed))\n    (is (fails-on-line-number?  92 line/invoke))\n    (is (fails-on-line-number? 101 line/threading))\n    (is (fails-on-line-number? 112 line/keyword-invoke))\n    (is (fails-on-line-number? 119 line/invoke-cast))))\n\n(deftest CLJ-979\n  (is (= clojure.test_clojure.compilation.examples.X\n         (class (clojure.test-clojure.compilation.examples/->X))))\n  (is (.b (clojure.test_clojure.compilation.Y. 1)))\n  (is (= clojure.test_clojure.compilation.examples.T\n         (class (clojure.test_clojure.compilation.examples.T.))\n         (class (clojure.test-clojure.compilation.examples/->T)))))\n\n(deftest clj-1568\n  (let [compiler-fails-at?\n          (fn [row col source]\n            (try\n              (Compiler/load (java.io.StringReader. source) (name (gensym \"clj-1568.example-\")) \"clj-1568.example\")\n              nil\n              (catch Compiler$CompilerException e\n                (re-find (re-pattern (str \"^.*:\" row \":\" col \"\\\\)$\"))\n                         (.getMessage e)))))]\n    (testing \"with error in the initial form\"\n      (are [row col source] (compiler-fails-at? row col source)\n           ;; note that the spacing of the following string is important\n           1  4 \"   (.foo nil)\"\n           2 18 \"\n                 (/ 1 0)\"))\n    (testing \"with error in an non-initial form\"\n      (are [row col source] (compiler-fails-at? row col source)\n           ;; note that the spacing of the following string is important\n           3 18 \"(:foo {})\n\n                 (.foo nil)\"\n           4 20 \"(ns clj-1568.example)\n\n\n                   (/ 1 0)\"))))\n"
  },
  {
    "path": "test/clojure/test_clojure/control.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka, Mike Hinchey, Stuart Halloway\n\n;;\n;;  Test \"flow control\" constructs.\n;;\n\n(ns clojure.test-clojure.control\n  (:use clojure.test\n        clojure.test-helper))\n\n;; *** Helper functions ***\n\n(defn maintains-identity [f]\n  (are [x] (= (f x) x)\n      nil\n      false true\n      0 42\n      0.0 3.14\n      2/3\n      0M 1M\n      \\c\n      \"\" \"abc\"\n      'sym\n      :kw\n      () '(1 2)\n      [] [1 2]\n      {} {:a 1 :b 2}\n      #{} #{1 2} ))\n\n\n; http://clojure.org/special_forms\n; http://clojure.org/macros\n\n(deftest test-do\n  (are [x y] (= x y)\n      ; no params => nil\n      (do) nil\n\n      ; return last\n      (do 1) 1\n      (do 1 2) 2\n      (do 1 2 3 4 5) 5\n\n      ; evaluate and return last\n      (let [a (atom 0)]\n        (do (reset! a (+ @a 1))   ; 1\n            (reset! a (+ @a 1))   ; 2\n            (reset! a (+ @a 1))   ; 3\n            @a))  3 )\n\n  ; identity (= (do x) x)\n  (maintains-identity (fn [_] (do _))) )\n\n\n;; loop/recur\n(deftest test-loop\n  (are [x y] (= x y)\n       1 (loop []\n           1)\n       3 (loop [a 1]\n           (if (< a 3)\n             (recur (inc a))\n             a))\n       [2 4 6] (loop [a []\n                      b [1 2 3]]\n                 (if (seq b)\n                   (recur (conj a (* 2 (first b)))\n                          (next b))\n                   a))\n       [6 4 2] (loop [a ()\n                      b [1 2 3]]\n                 (if (seq b)\n                   (recur (conj a (* 2 (first b)))\n                          (next b))\n                   a))\n       )\n  )\n\n\n;; throw, try\n\n; if: see logic.clj\n\n(deftest test-when\n  (are [x y] (= x y)\n       1 (when true 1)\n       nil (when true)\n       nil (when false)\n       nil (when false (exception))\n       ))\n\n(deftest test-when-not\n  (are [x y] (= x y)\n       1 (when-not false 1)\n       nil (when-not true)\n       nil (when-not false)\n       nil (when-not true (exception))\n       ))\n\n(deftest test-if-not\n  (are [x y] (= x y)\n       1 (if-not false 1)\n       1 (if-not false 1 (exception))\n       nil (if-not true 1)\n       2 (if-not true 1 2)\n       nil (if-not true (exception))\n       1 (if-not true (exception) 1)\n       ))\n\n(deftest test-when-let\n  (are [x y] (= x y)\n       1 (when-let [a 1]\n           a)\n       2 (when-let [[a b] '(1 2)]\n           b)\n       nil (when-let [a false]\n             (exception))\n       ))\n\n(deftest test-if-let\n  (are [x y] (= x y)\n       1 (if-let [a 1]\n           a)\n       2 (if-let [[a b] '(1 2)]\n           b)\n       nil (if-let [a false]\n             (exception))\n       1 (if-let [a false]\n           a 1)\n       1 (if-let [[a b] nil]\n             b 1)\n       1 (if-let [a false]\n           (exception)\n           1)\n       ))\n\n(deftest test-when-first\n  (are [x y] (= x y)\n       1 (when-first [a [1 2]]\n           a)\n       2 (when-first [[a b] '((1 2) 3)]\n           b)\n       nil (when-first [a nil]\n             (exception))\n       ))\n\n(deftest test-if-some\n  (are [x y] (= x y)\n       1 (if-some [a 1] a)\n       false (if-some [a false] a)\n       nil (if-some [a nil] (exception))\n       3 (if-some [[a b] [1 2]] (+ a b))\n       1 (if-some [[a b] nil] b 1)\n       1 (if-some [a nil] (exception) 1)))\n\n(deftest test-when-some\n  (are [x y] (= x y)\n       1 (when-some [a 1] a)\n       2 (when-some [[a b] [1 2]] b)\n       false (when-some [a false] a)\n       nil (when-some [a nil] (exception))))\n\n(deftest test-cond\n  (are [x y] (= x y)\n      (cond) nil\n\n      (cond nil true) nil\n      (cond false true) nil\n\n      (cond true 1 true (exception)) 1\n      (cond nil 1 false 2 true 3 true 4) 3\n      (cond nil 1 false 2 true 3 true (exception)) 3 )\n\n  ; false\n  (are [x]  (= (cond x :a true :b) :b)\n      nil false )\n\n  ; true\n  (are [x]  (= (cond x :a true :b) :a)\n      true\n      0 42\n      0.0 3.14\n      2/3\n      0M 1M\n      \\c\n      \"\" \"abc\"\n      'sym\n      :kw\n      () '(1 2)\n      [] [1 2]\n      {} {:a 1 :b 2}\n      #{} #{1 2} )\n\n  ; evaluation\n  (are [x y] (= x y)\n      (cond (> 3 2) (+ 1 2) true :result true (exception)) 3\n      (cond (< 3 2) (+ 1 2) true :result true (exception)) :result )\n\n  ; identity (= (cond true x) x)\n  (maintains-identity (fn [_] (cond true _))) )\n\n\n(deftest test-condp\n  (are [x] (= :pass x)\n       (condp = 1\n         1 :pass\n         2 :fail)\n       (condp = 1\n         2 :fail\n         1 :pass)\n       (condp = 1\n         2 :fail\n         :pass)\n       (condp = 1\n         :pass)\n       (condp = 1\n         2 :fail\n         ;; doc of condp says result-expr is returned\n         ;; shouldn't it say similar to cond: \"evaluates and returns\n         ;; the value of the corresponding expr and doesn't evaluate any of the\n         ;; other tests or exprs.\"\n         (identity :pass))\n       (condp + 1\n         1 :>> #(if (= % 2) :pass :fail))\n       (condp + 1\n         1 :>> #(if (= % 3) :fail :pass))\n       )\n  (is (thrown? IllegalArgumentException\n               (condp = 1)\n               ))\n  (is (thrown? IllegalArgumentException\n               (condp = 1\n                 2 :fail)\n               ))\n  )\n\n\n; [for, doseq (for.clj)]\n\n(deftest test-dotimes\n  ;; dotimes always returns nil\n  (is (= nil (dotimes [n 1] n)))\n  ;; test using an atom since dotimes is for modifying\n  ;; test executes n times\n  (is (= 3\n         (let [a (atom 0)]\n           (dotimes [n 3]\n             (swap! a inc))\n           @a)\n         ))\n  ;; test all values of n\n  (is (= [0 1 2]\n         (let [a (atom [])]\n           (dotimes [n 3]\n             (swap! a conj n))\n           @a)))\n  (is (= []\n         (let [a (atom [])]\n           (dotimes [n 0]\n             (swap! a conj n))\n           @a)))\n  )\n\n(deftest test-while\n  (is (= nil (while nil (throw (Exception. \"never\")))))\n  (is (= [0 nil]\n         ;; a will dec to 0\n         ;; while always returns nil\n         (let [a (atom 3)\n               w (while (pos? @a)\n                   (swap! a dec))]\n           [@a w])))\n  (is (thrown? Exception (while true (throw (Exception. \"expected to throw\")))))\n  )\n\n; locking, monitor-enter, monitor-exit\n\n; case\n(comment\n(deftest test-case\n  (testing \"can match many kinds of things\"\n    (let [two 2\n          test-fn\n          #(case %\n                 1 :number\n                 \"foo\" :string\n                 \\a :char\n                 pow :symbol\n                 :zap :keyword\n                 (2 \\b \"bar\") :one-of-many\n                 [1 2] :sequential-thing\n                 {:a 2} :map\n                 {:r 2 :d 2} :droid\n                 #{2 3 4 5} :set\n                 [1 [[[2]]]] :deeply-nested\n                 nil :nil\n                 :default)]\n      (are [result input] (= result (test-fn input))\n           :number 1\n           :string \"foo\"\n           :char \\a\n           :keyword :zap\n           :symbol 'pow\n           :one-of-many 2\n           :one-of-many \\b\n           :one-of-many \"bar\"\n           :sequential-thing [1 2]\n           :sequential-thing (list 1 2)\n           :sequential-thing [1 two]\n           :map {:a 2}\n           :map {:a two}\n           :set #{2 3 4 5}\n           :set #{two 3 4 5}\n           :default #{2 3 4 5 6}\n           :droid {:r 2 :d 2}\n           :deeply-nested [1 [[[two]]]]\n           :nil nil\n           :default :anything-not-appearing-above)))\n  (testing \"throws IllegalArgumentException if no match\"\n    (is (thrown-with-msg?\n          IllegalArgumentException #\"No matching clause: 2\"\n          (case 2 1 :ok))))\n  (testing \"sorting doesn't matter\"\n    (let [test-fn\n          #(case %\n                {:b 2 :a 1} :map\n                #{3 2 1} :set\n                :default)]\n      (are [result input] (= result (test-fn input))\n           :map {:a 1 :b 2}\n           :map (sorted-map :a 1 :b 2)\n           :set #{3 2 1}\n           :set (sorted-set 2 1 3))))\n  (testing \"test number equivalence\"\n    (is (= :1 (case 1N 1 :1 :else))))\n  (comment\n   (testing \"test warn when boxing/hashing expr for all-ints case\"\n     (should-print-err-message\n      #\"Performance warning, .*:\\d+ - case has int tests, but tested expression is not primitive..*\\r?\\n\"\n      (let [x (Object.)] (case x 1 1 2)))))\n  (testing \"test correct behavior on sparse ints\"\n    (are [result input] (= result (case input\n                                    2r1000000000000000000000000000000 :big\n                                    1 :small\n                                    :else))\n         :small 1\n         :big 1073741824\n         :else 2)\n    (are [result input] (= result (case input\n                                    1 :small\n                                    2r1000000000000000000000000000000 :big\n                                    :else))\n         :small 1\n         :big 1073741824\n         :else 2))\n  (testing \"test emits return types\"\n    (should-not-reflect (Long. (case 1 1 1))) ; new Long(long)\n    (should-not-reflect (Long. (case 1 1 \"1\")))) ; new Long(String)\n  (testing \"non-equivalence of chars and nums\"\n    (are [result input] (= result (case input 97 :97 :else))\n      :else \\a\n      :else (char \\a)\n      :97 (int \\a))\n    (are [result input] (= result (case input \\a :a :else))\n      :else 97\n      :else 97N\n      :a (char 97)))\n  (testing \"test error on duplicate test constants\"\n    (is (thrown-with-msg?\n          IllegalArgumentException\n          #\"Duplicate case test constant: 1\"\n          (eval `(case 0 1 :x 1 :y)))))\n  (testing \"test correct behaviour on Number truncation\"\n    (let [^Object x (Long. 8589934591)  ; force bindings to not be emitted as a primitive long\n          ^Object y (Long. -1)]\n      (is (= :diff (case x -1 :oops :diff)))\n      (is (= :same (case y -1 :same :oops)))))\n  (testing \"test correct behavior on hash collision\"\n    ;; case uses Java .hashCode to put values into hash buckets.\n    (is (== (.hashCode 1) (.hashCode 9223372039002259457N)))\n    (are [result input] (= result (case input\n                                    1 :long\n                                    9223372039002259457N :big\n                                    :else))\n         :long 1\n         :big 9223372039002259457N\n         :else 4294967296\n         :else 2)\n    (are [result input] (= result (case input\n                                    9223372039002259457N :big\n                                    1 :long\n                                    :else))\n         :long 1\n         :big 9223372039002259457N\n         :else 4294967296\n         :else 2)\n    (are [result input] (= result (case input\n                                    0 :zero\n                                    -1 :neg1\n                                    2 :two\n                                    :oops :OOPS))\n         :zero 0\n         :neg1 -1\n         :two 2\n         :OOPS :oops)\n    (are [result input] (= result (case input\n                                    1204766517646190306 :a\n                                    1 :b\n                                    -2 :c\n                                    :d))\n         :a 1204766517646190306\n         :b 1\n         :c -2\n         :d 4294967296\n         :d 3))\n  (comment\n    (testing \"test warn for hash collision\"\n      (should-print-err-message\n       #\"Performance warning, .*:\\d+ - hash collision of some case test constants; if selected, those entries will be tested sequentially..*\\r?\\n\"\n       (case 1 1 :long 9223372039002259457N :big 2))))\n  (testing \"test constants are *not* evaluated\"\n    (let [test-fn\n          ;; never write code like this...\n          #(case %\n                 (throw (RuntimeException. \"boom\")) :piece-of-throw-expr\n                 :no-match)]\n      (are [result input] (= result (test-fn input))\n           :piece-of-throw-expr 'throw\n           :piece-of-throw-expr '[RuntimeException. \"boom\"]\n           :no-match nil))))\n)\n"
  },
  {
    "path": "test/clojure/test_clojure/data.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns clojure.test-clojure.data\n  (:use clojure.data clojure.test)\n  (import java.util.HashSet))\n\n(deftest diff-test\n  (are [d x y] (= d (diff x y))\n       [nil nil nil] nil nil\n       [1 2 nil] 1 2\n       [nil nil [1 2 3]] [1 2 3] '(1 2 3)\n       [1 [:a :b] nil] 1 [:a :b]\n       [{:a 1} :b nil] {:a 1} :b\n       [:team #{:p1 :p2} nil] :team #{:p1 :p2}\n       [{0 :a} [:a] nil] {0 :a} [:a]\n       [nil [nil 2] [1]] [1] [1 2]\n       [nil nil [1 2]] [1 2] (into-array [1 2])\n       [#{:a} #{:b} #{:c :d}] #{:a :c :d} #{:b :c :d}\n       [nil nil {:a 1}] {:a 1} {:a 1}\n       [{:a #{2}} {:a #{4}} {:a #{3}}] {:a #{2 3}} {:a #{3 4}}\n       [#{1} #{3} #{2}] (HashSet. [1 2]) (HashSet. [2 3])\n       [nil nil [1 2]] [1 2] (into-array [1 2])\n       [nil nil [1 2]] (into-array [1 2]) [1 2]\n       [{:a {:c [1]}} {:a {:c [0]}} {:a {:c [nil 2] :b 1}}] {:a {:b 1 :c [1 2]}} {:a {:b 1 :c [0 2]}}\n       [{:a nil} {:a false} {:b nil :c false}] {:a nil :b nil :c false} {:a false :b nil :c false}))\n\n"
  },
  {
    "path": "test/clojure/test_clojure/data_structures.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka\n\n\n(ns clojure.test-clojure.data-structures\n  (:use clojure.test\n        [clojure.test.generative :exclude (is)])\n  (:require [clojure.test-clojure.generators :as cgen]\n            [clojure.data.generators :as gen]\n            [clojure.string :as string]))\n\n\n;; *** Helper functions ***\n\n(defn diff [s1 s2]\n  (seq (reduce disj (set s1) (set s2))))\n\n\n;; *** Generative ***\n(defspec subcollection-counts-are-consistent\n  identity\n  [^{:tag cgen/ednable-collection} coll]\n  (let [n (count coll)]\n    (dotimes [i n]\n      (is (= n\n             (+ i (count (nthnext coll i)))\n             (+ i (count (drop i coll))))))))\n\n(defn- transient? [x]\n  (instance? clojure.lang.ITransientCollection x))\n\n(defn gen-transient-set-action []\n  (gen/rand-nth [[#(conj! %1 %2) #(conj %1 %2) (gen/uniform -100 100)]\n                 [#(disj! %1 %2) #(disj %1 %2) (gen/uniform -100 100)]\n                 [#(deref (future (conj! %1 %2))) #(conj %1 %2) (gen/uniform -100 100)]\n                 [#(deref (future (disj! %1 %2))) #(disj %1 %2) (gen/uniform -100 100)]\n                 [persistent! identity]\n                 [identity transient]]))\n\n(defn gen-transient-set-actions []\n  (gen/reps #(gen/uniform 0 100) gen-transient-set-action))\n\n(defn tempty? [t]\n  (= (count t) 0))\n\n(defn gen-transient-vector-action []\n  (gen/rand-nth [[#(conj! %1 %2) #(conj %1 %2) (gen/uniform -100 100)]\n                 [(fn [v _] (if (tempty? v) v (pop! v)))\n                  (fn [v _] (if (tempty? v) v (pop v)))\n                  (gen/uniform -100 100)]\n                 [#(deref (future (conj! %1 %2))) #(conj %1 %2) (gen/uniform -100 100)]\n                 [(fn [v _] (if (tempty? v) v (deref (future (pop! v)))))\n                  (fn [v _] (if (tempty? v) v (pop v)))\n                  (gen/uniform -100 100)]\n                 [persistent! identity]\n                 [identity transient]]))\n\n(defn gen-transient-vector-actions []\n  (gen/reps #(gen/uniform 0 100) gen-transient-vector-action))\n\n(defn gen-transient-map-action []\n  (gen/rand-nth [[#(assoc! %1 %2 %2) #(assoc %1 %2 %2) (gen/uniform -100 100)]\n                 [#(dissoc! %1 %2) #(dissoc %1 %2) (gen/uniform -100 100)]\n                 [#(deref (future (assoc! %1 %2 %2))) #(assoc %1 %2 %2) (gen/uniform -100 100)]\n                 [#(deref (future (dissoc! %1 %2))) #(dissoc %1 %2) (gen/uniform -100 100)]\n                 [persistent! identity]\n                 [identity transient]]))\n\n(defn gen-transient-map-actions []\n  (gen/reps #(gen/uniform 0 100) gen-transient-map-action))\n\n(defn assert-same-collection [a b]\n  (assert (= (count a) (count b) (.size a) (.size b)))\n  (assert (= a b))\n  (assert (= b a))\n  (assert (.equals ^Object a b))\n  (assert (.equals ^Object b a))\n  (assert (= (hash a) (hash b)))\n  (assert (= (.hashCode ^Object a) (.hashCode ^Object b)))\n  (assert (= a\n             (into (empty a) a)\n             (into (empty b) b)\n             (into (empty a) b)\n             (into (empty b) a))))\n\n(defn apply-actions [coll actions]\n  (reduce (fn [c [tfunc pfunc & args]]\n            (apply (if (transient? c) tfunc pfunc) c args))\n          coll\n          actions))\n\n(defn to-persistent [c]\n  (if (transient? c) (persistent! c) c))\n\n(defspec same-output-persistent-transient-set\n  identity\n  [^{:tag clojure.test-clojure.data-structures/gen-transient-set-actions} actions]\n  (assert-same-collection\n   (to-persistent (apply-actions #{} actions))\n   (to-persistent (apply-actions #{} actions))))\n\n(defspec same-output-persistent-transient-vector\n  identity\n  [^{:tag clojure.test-clojure.data-structures/gen-transient-vector-actions} actions]\n  (assert-same-collection\n   (to-persistent (apply-actions [] actions))\n   (to-persistent (apply-actions [] actions))))\n\n(defspec same-output-persistent-transient-map\n  identity\n  [^{:tag clojure.test-clojure.data-structures/gen-transient-map-actions} actions]\n  (assert-same-collection\n   (to-persistent (apply-actions clojure.lang.PersistentArrayMap/EMPTY actions))\n   (to-persistent (apply-actions clojure.lang.PersistentArrayMap/EMPTY actions)))\n  (assert-same-collection\n   (to-persistent (apply-actions clojure.lang.PersistentHashMap/EMPTY actions))\n   (to-persistent (apply-actions clojure.lang.PersistentHashMap/EMPTY actions))))\n\n;; *** General ***\n\n(defstruct equality-struct :a :b)\n\n(deftest test-equality\n  ; nil is not equal to any other value\n  (are [x] (not (= nil x))\n      true false\n      0 0.0\n      \\space\n      \"\" #\"\"\n      () [] #{} {}\n      (lazy-seq nil)  ; SVN 1292: fixed (= (lazy-seq nil) nil)\n      (lazy-seq ())\n      (lazy-seq [])\n      (lazy-seq {})\n      (lazy-seq #{})\n      (lazy-seq \"\")\n      (lazy-seq (into-array []))\n      (new Object) )\n\n  ; numbers equality across types (see tests below - NOT IMPLEMENTED YET)\n\n  ; ratios\n  (is (== 1/2 0.5))\n  (is (== 1/1000 0.001))\n  (is (not= 2/3 0.6666666666666666))\n\n  ; vectors equal other seqs by items equality\n  (are [x y] (= x y)\n      '() []        ; regression fixed in r1208; was not equal\n      '(1) [1]\n      '(1 2) [1 2]\n\n      [] '()        ; same again, but vectors first\n      [1] '(1)\n      [1 2] '(1 2) )\n  (is (not= [1 2] '(2 1)))  ; order of items matters\n\n  ; list and vector vs. set and map\n  (are [x y] (not= x y)\n      ; only () equals []\n      () #{}\n      () {}\n      [] #{}\n      [] {}\n      #{} {}\n      ; only '(1) equals [1]\n      '(1) #{1}\n      [1] #{1} )\n\n  ; sorted-map, hash-map and array-map - classes differ, but content is equal\n\n;; TODO: reimplement all-are with new do-template?\n;;   (all-are (not= (class _1) (class _2))\n;;       (sorted-map :a 1)\n;;       (hash-map   :a 1)\n;;       (array-map  :a 1))\n;;   (all-are (= _1 _2)\n;;       (sorted-map)\n;;       (hash-map)\n;;       (array-map))\n;;   (all-are (= _1 _2)\n;;       (sorted-map :a 1)\n;;       (hash-map   :a 1)\n;;       (array-map  :a 1))\n;;   (all-are (= _1 _2)\n;;       (sorted-map :a 1 :z 3 :c 2)\n;;       (hash-map   :a 1 :z 3 :c 2)\n;;       (array-map  :a 1 :z 3 :c 2))\n\n  ; struct-map vs. sorted-map, hash-map and array-map\n  (are [x] (and (not= (class (struct equality-struct 1 2)) (class x))\n                (= (struct equality-struct 1 2) x))\n      (sorted-map-by compare :a 1 :b 2)\n      (sorted-map :a 1 :b 2)\n      (hash-map   :a 1 :b 2)\n      (array-map  :a 1 :b 2))\n\n  ; sorted-set vs. hash-set\n  (is (not= (class (sorted-set 1)) (class (hash-set 1))))\n  (are [x y] (= x y)\n      (sorted-set-by <) (hash-set)\n      (sorted-set-by < 1) (hash-set 1)\n      (sorted-set-by < 3 2 1) (hash-set 3 2 1)\n      (sorted-set) (hash-set)\n      (sorted-set 1) (hash-set 1)\n      (sorted-set 3 2 1) (hash-set 3 2 1) ))\n\n\n;; *** Collections ***\n\n(deftest test-count\n  (let [EMPTY clojure.lang.PersistentQueue/EMPTY]\n    (are [x y] (= (count x) y)\n         EMPTY 0\n         (into EMPTY [:a :b]) 2\n         (-> (into EMPTY [:a :b]) pop pop) 0\n\n         nil 0\n\n         () 0\n         '(1) 1\n         '(1 2 3) 3\n\n         [] 0\n         [1] 1\n         [1 2 3] 3\n\n         #{} 0\n         #{1} 1\n         #{1 2 3} 3\n\n         {} 0\n         {:a 1} 1\n         {:a 1 :b 2 :c 3} 3\n\n         \"\" 0\n         \"a\" 1\n         \"abc\" 3\n\n         (into-array []) 0\n         (into-array [1]) 1\n         (into-array [1 2 3]) 3\n\n         (java.util.ArrayList. ^clojure.lang.IPersistentVector []) 0\n         (java.util.ArrayList. ^clojure.lang.IPersistentVector [1]) 1\n         (java.util.ArrayList. ^clojure.lang.IPersistentVector [1 2 3]) 3\n\n         (java.util.HashMap. ^clojure.lang.IPersistentMap {}) 0\n         (java.util.HashMap. ^clojure.lang.IPersistentMap {:a 1}) 1\n         (java.util.HashMap. ^clojure.lang.IPersistentMap {:a 1 :b 2 :c 3}) 3 ))\n\n  ; different types\n  (are [x]  (= (count [x]) 1)\n      nil true false\n      0 0.0 \"\" \\space\n      () [] #{} {}  ))\n\n\n(deftest test-conj\n  ; doesn't work on strings or arrays\n  (is (thrown? ClassCastException (conj \"\" \\a)))\n  (is (thrown? ClassCastException (conj (into-array []) 1)))\n\n  (are [x y] (= x y)\n      (conj nil 1) '(1)\n      (conj nil 3 2 1) '(1 2 3)\n\n      (conj nil nil) '(nil)\n      (conj nil nil nil) '(nil nil)\n      (conj nil nil nil 1) '(1 nil nil)\n\n      ; list -> conj puts the item at the front of the list\n      (conj () 1) '(1)\n      (conj () 1 2) '(2 1)\n\n      (conj '(2 3) 1) '(1 2 3)\n      (conj '(2 3) 1 4 3) '(3 4 1 2 3)\n\n      (conj () nil) '(nil)\n      (conj () ()) '(())\n\n      ; vector -> conj puts the item at the end of the vector\n      (conj [] 1) [1]\n      (conj [] 1 2) [1 2]\n\n      (conj [2 3] 1) [2 3 1]\n      (conj [2 3] 1 4 3) [2 3 1 4 3]\n\n      (conj [] nil) [nil]\n      (conj [] []) [[]]\n\n      ; map -> conj expects another (possibly single entry) map as the item,\n      ;   and returns a new map which is the old map plus the entries\n      ;   from the new, which may overwrite entries of the old.\n      ;   conj also accepts a MapEntry or a vector of two items (key and value).\n      (conj {} {}) {}\n      (conj {} {:a 1}) {:a 1}\n      (conj {} {:a 1 :b 2}) {:a 1 :b 2}\n      (conj {} {:a 1 :b 2} {:c 3}) {:a 1 :b 2 :c 3}\n      (conj {} {:a 1 :b 2} {:a 3 :c 4}) {:a 3 :b 2 :c 4}\n\n      (conj {:a 1} {:a 7}) {:a 7}\n      (conj {:a 1} {:b 2}) {:a 1 :b 2}\n      (conj {:a 1} {:a 7 :b 2}) {:a 7 :b 2}\n      (conj {:a 1} {:a 7 :b 2} {:c 3}) {:a 7 :b 2 :c 3}\n      (conj {:a 1} {:a 7 :b 2} {:b 4 :c 5}) {:a 7 :b 4 :c 5}\n\n      (conj {} (first {:a 1})) {:a 1}           ; MapEntry\n      (conj {:a 1} (first {:b 2})) {:a 1 :b 2}\n      (conj {:a 1} (first {:a 7})) {:a 7}\n      (conj {:a 1} (first {:b 2}) (first {:a 5})) {:a 5 :b 2}\n\n      (conj {} [:a 1]) {:a 1}                   ; vector\n      (conj {:a 1} [:b 2]) {:a 1 :b 2}\n      (conj {:a 1} [:a 7]) {:a 7}\n      (conj {:a 1} [:b 2] [:a 5]) {:a 5 :b 2}\n\n      (conj {} {nil {}}) {nil {}}\n      (conj {} {{} nil}) {{} nil}\n      (conj {} {{} {}}) {{} {}}\n\n      ; set\n      (conj #{} 1) #{1}\n      (conj #{} 1 2 3) #{1 2 3}\n\n      (conj #{2 3} 1) #{3 1 2}\n      (conj #{3 2} 1) #{1 2 3}\n\n      (conj #{2 3} 2) #{2 3}\n      (conj #{2 3} 2 3) #{2 3}\n      (conj #{2 3} 4 1 2 3) #{1 2 3 4}\n\n      (conj #{} nil) #{nil}\n      (conj #{} #{}) #{#{}} ))\n\n\n;; *** Lists and Vectors ***\n\n(deftest test-peek\n  ; doesn't work for sets and maps\n  (is (thrown? ClassCastException (peek #{1})))\n  (is (thrown? ClassCastException (peek {:a 1})))\n\n  (are [x y] (= x y)\n      (peek nil) nil\n\n      ; list = first\n      (peek ()) nil\n      (peek '(1)) 1\n      (peek '(1 2 3)) 1\n\n      (peek '(nil)) nil     ; special cases\n      (peek '(1 nil)) 1\n      (peek '(nil 2)) nil\n      (peek '(())) ()\n      (peek '(() nil)) ()\n      (peek '(() 2 nil)) ()\n\n      ; vector = last\n      (peek []) nil\n      (peek [1]) 1\n      (peek [1 2 3]) 3\n\n      (peek [nil]) nil      ; special cases\n      (peek [1 nil]) nil\n      (peek [nil 2]) 2\n      (peek [[]]) []\n      (peek [[] nil]) nil\n      (peek [[] 2 nil]) nil ))\n\n\n(deftest test-pop\n  ; doesn't work for sets and maps\n  (is (thrown? ClassCastException (pop #{1})))\n  (is (thrown? ClassCastException (pop #{:a 1})))\n\n  ; collection cannot be empty\n  (is (thrown? IllegalStateException (pop ())))\n  (is (thrown? IllegalStateException (pop [])))\n\n  (are [x y] (= x y)\n      (pop nil) nil\n\n      ; list - pop first\n      (pop '(1)) ()\n      (pop '(1 2 3)) '(2 3)\n\n      (pop '(nil)) ()\n      (pop '(1 nil)) '(nil)\n      (pop '(nil 2)) '(2)\n      (pop '(())) ()\n      (pop '(() nil)) '(nil)\n      (pop '(() 2 nil)) '(2 nil)\n\n      ; vector - pop last\n      (pop [1]) []\n      (pop [1 2 3]) [1 2]\n\n      (pop [nil]) []\n      (pop [1 nil]) [1]\n      (pop [nil 2]) [nil]\n      (pop [[]]) []\n      (pop [[] nil]) [[]]\n      (pop [[] 2 nil]) [[] 2] ))\n\n\n;; *** Lists (IPersistentList) ***\n\n(deftest test-list\n  (are [x]  (list? x)\n      ()\n      '()\n      (list)\n      (list 1 2 3) )\n\n  ; order is important\n  (are [x y] (not (= x y))\n      (list 1 2) (list 2 1)\n      (list 3 1 2) (list 1 2 3) )\n\n  (are [x y] (= x y)\n      '() ()\n      (list) '()\n      (list 1) '(1)\n      (list 1 2) '(1 2)\n\n      ; nesting\n      (list 1 (list 2 3) (list 3 (list 4 5 (list 6 (list 7)))))\n        '(1 (2 3) (3 (4 5 (6 (7)))))\n\n      ; different data structures\n      (list true false nil)\n        '(true false nil)\n      (list 1 2.5 2/3 \"ab\" \\x 'cd :kw)\n        '(1 2.5 2/3 \"ab\" \\x cd :kw)\n      (list (list 1 2) [3 4] {:a 1 :b 2} #{:c :d})\n        '((1 2) [3 4] {:a 1 :b 2} #{:c :d})\n\n      ; evaluation\n      (list (+ 1 2) [(+ 2 3) 'a] (list (* 2 3) 8))\n        '(3 [5 a] (6 8))\n\n      ; special cases\n      (list nil) '(nil)\n      (list 1 nil) '(1 nil)\n      (list nil 2) '(nil 2)\n      (list ()) '(())\n      (list 1 ()) '(1 ())\n      (list () 2) '(() 2) ))\n\n\n;; *** Maps (IPersistentMap) ***\n\n(deftest test-find\n  (are [x y] (= x y)\n      (find {} :a) nil\n\n      (find {:a 1} :a) [:a 1]\n      (find {:a 1} :b) nil\n      (find {nil 1} nil) [nil 1]\n\n      (find {:a 1 :b 2} :a) [:a 1]\n      (find {:a 1 :b 2} :b) [:b 2]\n      (find {:a 1 :b 2} :c) nil\n\n      (find {} nil) nil\n      (find {:a 1} nil) nil\n      (find {:a 1 :b 2} nil) nil ))\n\n\n(deftest test-contains?\n  ; contains? is designed to work preferably on maps and sets\n  (are [x y] (= x y)\n      (contains? {} :a) false\n      (contains? {} nil) false\n\n      (contains? {:a 1} :a) true\n      (contains? {:a 1} :b) false\n      (contains? {:a 1} nil) false\n      (contains? {nil 1} nil) true\n\n      (contains? {:a 1 :b 2} :a) true\n      (contains? {:a 1 :b 2} :b) true\n      (contains? {:a 1 :b 2} :c) false\n      (contains? {:a 1 :b 2} nil) false\n\n      ; sets\n      (contains? #{} 1) false\n      (contains? #{} nil) false\n\n      (contains? #{1} 1) true\n      (contains? #{1} 2) false\n      (contains? #{1} nil) false\n\n      (contains? #{1 2 3} 1) true\n      (contains? #{1 2 3} 3) true\n      (contains? #{1 2 3} 10) false\n      (contains? #{1 2 3} nil) false)\n\n  ; contains? also works on java.util.Map and java.util.Set.\n  (are [x y] (= x y)\n      (contains? (java.util.HashMap. {}) :a) false\n      (contains? (java.util.HashMap. {}) nil) false\n\n      (contains? (java.util.HashMap. {:a 1}) :a) true\n      (contains? (java.util.HashMap. {:a 1}) :b) false\n      (contains? (java.util.HashMap. {:a 1}) nil) false\n\n      (contains? (java.util.HashMap. {:a 1 :b 2}) :a) true\n      (contains? (java.util.HashMap. {:a 1 :b 2}) :b) true\n      (contains? (java.util.HashMap. {:a 1 :b 2}) :c) false\n      (contains? (java.util.HashMap. {:a 1 :b 2}) nil) false\n\n      ; sets\n      (contains? (java.util.HashSet. #{}) 1) false\n      (contains? (java.util.HashSet. #{}) nil) false\n\n      (contains? (java.util.HashSet. #{1}) 1) true\n      (contains? (java.util.HashSet. #{1}) 2) false\n      (contains? (java.util.HashSet. #{1}) nil) false\n\n      (contains? (java.util.HashSet. #{1 2 3}) 1) true\n      (contains? (java.util.HashSet. #{1 2 3}) 3) true\n      (contains? (java.util.HashSet. #{1 2 3}) 10) false\n      (contains? (java.util.HashSet. #{1 2 3}) nil) false)\n\n  ; numerically indexed collections (e.g. vectors and Java arrays)\n  ; => test if the numeric key is WITHIN THE RANGE OF INDEXES\n  (are [x y] (= x y)\n      (contains? [] 0) false\n      (contains? [] -1) false\n      (contains? [] 1) false\n\n      (contains? [1] 0) true\n      (contains? [1] -1) false\n      (contains? [1] 1) false\n\n      (contains? [1 2 3] 0) true\n      (contains? [1 2 3] 2) true\n      (contains? [1 2 3] 3) false\n      (contains? [1 2 3] -1) false\n\n      ; arrays\n      (contains? (into-array []) 0) false\n      (contains? (into-array []) -1) false\n      (contains? (into-array []) 1) false\n\n      (contains? (into-array [1]) 0) true\n      (contains? (into-array [1]) -1) false\n      (contains? (into-array [1]) 1) false\n\n      (contains? (into-array [1 2 3]) 0) true\n      (contains? (into-array [1 2 3]) 2) true\n      (contains? (into-array [1 2 3]) 3) false\n      (contains? (into-array [1 2 3]) -1) false)\n\n  ; 'contains?' will not operate on non-associative things\n  (are [x]  (is (thrown? Exception (contains? x 1)))\n       '(1 2 3)\n       3))\n\n\n(deftest test-keys\n  (are [x y] (= x y)      ; other than map data structures\n      (keys ()) nil\n      (keys []) nil\n      (keys #{}) nil\n      (keys \"\") nil )\n\n  (are [x y] (= x y)\n      ; (class {:a 1}) => clojure.lang.PersistentArrayMap\n      (keys {}) nil\n      (keys {:a 1}) '(:a)\n      (keys {nil 1}) '(nil)\n      (diff (keys {:a 1 :b 2}) '(:a :b)) nil              ; (keys {:a 1 :b 2}) '(:a :b)\n\n      ; (class (sorted-map :a 1)) => clojure.lang.PersistentTreeMap\n      (keys (sorted-map)) nil\n      (keys (sorted-map :a 1)) '(:a)\n      (diff (keys (sorted-map :a 1 :b 2)) '(:a :b)) nil   ; (keys (sorted-map :a 1 :b 2)) '(:a :b)\n\n      ; (class (hash-map :a 1)) => clojure.lang.PersistentHashMap\n      (keys (hash-map)) nil\n      (keys (hash-map :a 1)) '(:a)\n      (diff (keys (hash-map :a 1 :b 2)) '(:a :b)) nil )   ; (keys (hash-map :a 1 :b 2)) '(:a :b)\n\n  (let [m {:a 1 :b 2}\n        k (keys m)]\n    (is (= {:hi :there} (meta (with-meta k {:hi :there}))))))\n\n\n(deftest test-vals\n  (are [x y] (= x y)      ; other than map data structures\n      (vals ()) nil\n      (vals []) nil\n      (vals #{}) nil\n      (vals \"\") nil )\n\n  (are [x y] (= x y)\n      ; (class {:a 1}) => clojure.lang.PersistentArrayMap\n      (vals {}) nil\n      (vals {:a 1}) '(1)\n      (vals {nil 1}) '(1)\n      (diff (vals {:a 1 :b 2}) '(1 2)) nil              ; (vals {:a 1 :b 2}) '(1 2)\n\n      ; (class (sorted-map :a 1)) => clojure.lang.PersistentTreeMap\n      (vals (sorted-map)) nil\n      (vals (sorted-map :a 1)) '(1)\n      (diff (vals (sorted-map :a 1 :b 2)) '(1 2)) nil   ; (vals (sorted-map :a 1 :b 2)) '(1 2)\n\n      ; (class (hash-map :a 1)) => clojure.lang.PersistentHashMap\n      (vals (hash-map)) nil\n      (vals (hash-map :a 1)) '(1)\n      (diff (vals (hash-map :a 1 :b 2)) '(1 2)) nil )   ; (vals (hash-map :a 1 :b 2)) '(1 2)\n\n  (let [m {:a 1 :b 2}\n        v (vals m)]\n    (is (= {:hi :there} (meta (with-meta v {:hi :there}))))))\n\n\n(deftest test-key\n  (are [x]  (= (key (first (hash-map x :value))) x)\n      nil\n      false true\n      0 42\n      0.0 3.14\n      2/3\n      0M 1M\n      \\c\n      \"\" \"abc\"\n      'sym\n      :kw\n      () '(1 2)\n      [] [1 2]\n      {} {:a 1 :b 2}\n      #{} #{1 2} ))\n\n\n(deftest test-val\n  (are [x]  (= (val (first (hash-map :key x))) x)\n      nil\n      false true\n      0 42\n      0.0 3.14\n      2/3\n      0M 1M\n      \\c\n      \"\" \"abc\"\n      'sym\n      :kw\n      () '(1 2)\n      [] [1 2]\n      {} {:a 1 :b 2}\n      #{} #{1 2} ))\n\n(deftest test-get\n  (let [m {:a 1, :b 2, :c {:d 3, :e 4}, :f nil, :g false, nil {:h 5}}]\n    (is (thrown? IllegalArgumentException (get-in {:a 1} 5)))\n    (are [x y] (= x y)\n         (get m :a) 1\n         (get m :e) nil\n         (get m :e 0) 0\n         (get m nil) {:h 5}\n         (get m :b 0) 2\n         (get m :f 0) nil\n\n         (get-in m [:c :e]) 4\n         (get-in m '(:c :e)) 4\n         (get-in m [:c :x]) nil\n         (get-in m [:f]) nil\n         (get-in m [:g]) false\n         (get-in m [:h]) nil\n         (get-in m []) m\n         (get-in m nil) m\n\n         (get-in m [:c :e] 0) 4\n         (get-in m '(:c :e) 0) 4\n         (get-in m [:c :x] 0) 0\n         (get-in m [:b] 0) 2\n         (get-in m [:f] 0) nil\n         (get-in m [:g] 0) false\n         (get-in m [:h] 0) 0\n         (get-in m [:x :y] {:y 1}) {:y 1}\n         (get-in m [] 0) m\n         (get-in m nil 0) m)))\n\n(deftest test-nested-map-destructuring\n  (let [sample-map {:a 1 :b {:a 2}}\n        {ao1 :a {ai1 :a} :b} sample-map\n        {ao2 :a {ai2 :a :as m1} :b :as m2} sample-map\n        {ao3 :a {ai3 :a :as m} :b :as m} sample-map\n        {{ai4 :a :as m} :b ao4 :a :as m} sample-map]\n    (are [i o] (and (= i 2)\n                    (= o 1))\n         ai1 ao1\n         ai2 ao2\n         ai3 ao3\n         ai4 ao4)))\n\n;; *** Sets ***\n\n(deftest test-hash-set\n  (are [x] (set? x)\n      #{}\n      #{1 2}\n      (hash-set)\n      (hash-set 1 2) )\n\n  ; order isn't important\n  (are [x y] (= x y)\n      #{1 2} #{2 1}\n      #{3 1 2} #{1 2 3}\n      (hash-set 1 2) (hash-set 2 1)\n      (hash-set 3 1 2) (hash-set 1 2 3) )\n\n\n  (are [x y] (= x y)\n      ; equal classes\n      (class #{}) (class (hash-set))\n      (class #{1 2}) (class (hash-set 1 2))\n\n      ; creating\n      (hash-set) #{}\n      (hash-set 1) #{1}\n      (hash-set 1 2) #{1 2}\n\n      ; nesting\n      (hash-set 1 (hash-set 2 3) (hash-set 3 (hash-set 4 5 (hash-set 6 (hash-set 7)))))\n        #{1 #{2 3} #{3 #{4 5 #{6 #{7}}}}}\n\n      ; different data structures\n      (hash-set true false nil)\n        #{true false nil}\n      (hash-set 1 2.5 2/3 \"ab\" \\x 'cd :kw)\n        #{1 2.5 2/3 \"ab\" \\x 'cd :kw}\n      (hash-set (list 1 2) [3 4] {:a 1 :b 2} #{:c :d})\n        #{'(1 2) [3 4] {:a 1 :b 2} #{:c :d}}\n\n      ; evaluation\n      (hash-set (+ 1 2) [(+ 2 3) :a] (hash-set (* 2 3) 8))\n        #{3 [5 :a] #{6 8}}\n\n      ; special cases\n      (hash-set nil) #{nil}\n      (hash-set 1 nil) #{1 nil}\n      (hash-set nil 2) #{nil 2}\n      (hash-set #{}) #{#{}}\n      (hash-set 1 #{}) #{1 #{}}\n      (hash-set #{} 2) #{#{} 2}\n      (hash-set (Integer. -1)) (hash-set (Long. -1))))\n\n\n(deftest test-sorted-set\n  ; only compatible types can be used\n  (is (thrown? ClassCastException (sorted-set 1 \"a\")))\n  (is (thrown? ClassCastException (sorted-set '(1 2) [3 4])))\n\n  ; creates set?\n  (are [x] (set? x)\n       (sorted-set)\n       (sorted-set 1 2) )\n\n  ; equal and unique\n  (are [x] (and (= (sorted-set x) #{x})\n                (= (sorted-set x x) (sorted-set x)))\n      nil\n      false true\n      0 42\n      0.0 3.14\n      2/3\n      0M 1M\n      \\c\n      \"\" \"abc\"\n      'sym\n      :kw\n      ()  ; '(1 2)\n      [] [1 2]\n      {}  ; {:a 1 :b 2}\n      #{} ; #{1 2}\n  )\n  ; cannot be cast to java.lang.Comparable\n  (is (thrown? ClassCastException (sorted-set '(1 2) '(1 2))))\n  (is (thrown? ClassCastException (sorted-set {:a 1 :b 2} {:a 1 :b 2})))\n  (is (thrown? ClassCastException (sorted-set #{1 2} #{1 2})))\n\n  (are [x y] (= x y)\n      ; generating\n      (sorted-set) #{}\n      (sorted-set 1) #{1}\n      (sorted-set 1 2) #{1 2}\n\n      ; sorting\n      (seq (sorted-set 5 4 3 2 1)) '(1 2 3 4 5)\n\n      ; special cases\n      (sorted-set nil) #{nil}\n      (sorted-set 1 nil) #{nil 1}\n      (sorted-set nil 2) #{nil 2}\n      (sorted-set #{}) #{#{}} ))\n\n\n(deftest test-sorted-set-by\n  ; only compatible types can be used\n  ; NB: not a ClassCastException, but a RuntimeException is thrown,\n  ; requires discussion on whether this should be symmetric with test-sorted-set\n  (is (thrown? Exception (sorted-set-by < 1 \"a\")))\n  (is (thrown? Exception (sorted-set-by < '(1 2) [3 4])))\n\n  ; creates set?\n  (are [x] (set? x)\n       (sorted-set-by <)\n       (sorted-set-by < 1 2) )\n\n  ; equal and unique\n  (are [x] (and (= (sorted-set-by compare x) #{x})\n                (= (sorted-set-by compare x x) (sorted-set-by compare x)))\n      nil\n      false true\n      0 42\n      0.0 3.14\n      2/3\n      0M 1M\n      \\c\n      \"\" \"abc\"\n      'sym\n      :kw\n      ()  ; '(1 2)\n      [] [1 2]\n      {}  ; {:a 1 :b 2}\n      #{} ; #{1 2}\n  )\n  ; cannot be cast to java.lang.Comparable\n  ; NB: not a ClassCastException, but a RuntimeException is thrown,\n  ; requires discussion on whether this should be symmetric with test-sorted-set\n  (is (thrown? Exception (sorted-set-by compare '(1 2) '(1 2))))\n  (is (thrown? Exception (sorted-set-by compare {:a 1 :b 2} {:a 1 :b 2})))\n  (is (thrown? Exception (sorted-set-by compare #{1 2} #{1 2})))\n\n  (are [x y] (= x y)\n      ; generating\n      (sorted-set-by >) #{}\n      (sorted-set-by > 1) #{1}\n      (sorted-set-by > 1 2) #{1 2}\n\n      ; sorting\n      (seq (sorted-set-by < 5 4 3 2 1)) '(1 2 3 4 5)\n\n      ; special cases\n      (sorted-set-by compare nil) #{nil}\n      (sorted-set-by compare 1 nil) #{nil 1}\n      (sorted-set-by compare nil 2) #{nil 2}\n      (sorted-set-by compare #{}) #{#{}} ))\n\n\n(deftest test-set\n  ; set?\n  (are [x] (set? (set x))\n      () '(1 2)\n      [] [1 2]\n      #{} #{1 2}\n      {} {:a 1 :b 2}\n      (into-array []) (into-array [1 2])\n      \"\" \"abc\" )\n\n  ; unique\n  (are [x] (= (set [x x]) #{x})\n      nil\n      false true\n      0 42\n      0.0 3.14\n      2/3\n      0M 1M\n      \\c\n      \"\" \"abc\"\n      'sym\n      :kw\n      () '(1 2)\n      [] [1 2]\n      {} {:a 1 :b 2}\n      #{} #{1 2} )\n\n  ; conversion\n  (are [x y] (= (set x) y)\n      () #{}\n      '(1 2) #{1 2}\n\n      [] #{}\n      [1 2] #{1 2}\n\n      #{} #{}         ; identity\n      #{1 2} #{1 2}   ; identity\n\n      {} #{}\n      {:a 1 :b 2} #{[:a 1] [:b 2]}\n\n      (into-array []) #{}\n      (into-array [1 2]) #{1 2}\n\n      \"\" #{}\n      \"abc\" #{\\a \\b \\c} ))\n\n\n(deftest test-disj\n  ; doesn't work on lists, vectors or maps\n  (is (thrown? ClassCastException (disj '(1 2) 1)))\n  (is (thrown? ClassCastException (disj [1 2] 1)))\n  (is (thrown? ClassCastException (disj {:a 1} :a)))\n\n  ; identity\n  (are [x] (= (disj x) x)\n      nil\n      #{}\n      #{1 2 3}\n      ; different data types\n      #{nil\n        false true\n        0 42\n        0.0 3.14\n        2/3\n        0M 1M\n        \\c\n        \"\" \"abc\"\n        'sym\n        :kw\n        [] [1 2]\n        {} {:a 1 :b 2}\n        #{} #{1 2}} )\n\n  ; type identity\n  (are [x] (= (class (disj x)) (class x))\n      (hash-set)\n      (hash-set 1 2)\n      (sorted-set)\n      (sorted-set 1 2) )\n\n  (are [x y] (= x y)\n      (disj nil :a) nil\n      (disj nil :a :b) nil\n\n      (disj #{} :a) #{}\n      (disj #{} :a :b) #{}\n\n      (disj #{:a} :a) #{}\n      (disj #{:a} :a :b) #{}\n      (disj #{:a} :c) #{:a}\n\n      (disj #{:a :b :c :d} :a) #{:b :c :d}\n      (disj #{:a :b :c :d} :a :d) #{:b :c}\n      (disj #{:a :b :c :d} :a :b :c) #{:d}\n      (disj #{:a :b :c :d} :d :a :c :b) #{}\n\n      (disj #{nil} :a) #{nil}\n      (disj #{nil} #{}) #{nil}\n      (disj #{nil} nil) #{}\n\n      (disj #{#{}} nil) #{#{}}\n      (disj #{#{}} #{}) #{}\n      (disj #{#{nil}} #{nil}) #{} ))\n\n\n;; *** Queues ***\n\n(deftest test-queues\n  (let [EMPTY clojure.lang.PersistentQueue/EMPTY]\n    (are [x y] (= x y)\n      EMPTY EMPTY\n      (into EMPTY (range 50)) (into EMPTY (range 50))\n      (conj EMPTY (Long. -1)) (conj EMPTY (Integer. -1))\n      (hash (conj EMPTY (Long. -1))) (hash (conj EMPTY (Integer. -1)))\n      (hash [1 2 3]) (hash (conj EMPTY 1 2 3))\n      (range 5) (into EMPTY (range 5))\n      (range 1 6) (-> EMPTY\n                    (into (range 6))\n                    pop))\n    (are [x y] (not= x y)\n      (range 5) (into EMPTY (range 6))\n      (range 6) (into EMPTY (range 5))\n      (range 0 6) (-> EMPTY\n                    (into (range 6))\n                    pop)\n      (range 1 6) (-> EMPTY\n                    (into (range 7))\n                    pop))))\n\n\n(deftest test-duplicates\n  (let [equal-sets-incl-meta (fn [s1 s2]\n                               (and (= s1 s2)\n                                    (let [ss1 (sort s1)\n                                          ss2 (sort s2)]\n                                      (every? identity\n                                              (map #(and (= %1 %2)\n                                                         (= (meta %1) (meta %2)))\n                                                   ss1 ss2)))))\n        all-equal-sets-incl-meta (fn [& ss]\n                                   (every? (fn [[s1 s2]]\n                                             (equal-sets-incl-meta s1 s2))\n                                           (partition 2 1 ss)))\n        equal-maps-incl-meta (fn [m1 m2]\n                               (and (= m1 m2)\n                                    (equal-sets-incl-meta (set (keys m1))\n                                                          (set (keys m2)))\n                                    (every? #(= (meta (m1 %)) (meta (m2 %)))\n                                            (keys m1))))\n        all-equal-maps-incl-meta (fn [& ms]\n                                   (every? (fn [[m1 m2]]\n                                             (equal-maps-incl-meta m1 m2))\n                                           (partition 2 1 ms)))\n        cmp-first #(> (first %1) (first %2))\n        x1 (with-meta [1] {:me \"x\"})\n        y2 (with-meta [2] {:me \"y\"})\n        z3a (with-meta [3] {:me \"z3a\"})\n        z3b (with-meta [3] {:me \"z3b\"})\n        v4a (with-meta [4] {:me \"v4a\"})\n        v4b (with-meta [4] {:me \"v4b\"})\n        v4c (with-meta [4] {:me \"v4c\"})\n        w5a (with-meta [5] {:me \"w5a\"})\n        w5b (with-meta [5] {:me \"w5b\"})\n        w5c (with-meta [5] {:me \"w5c\"})]\n\n    ;; Sets\n    (is (thrown? IllegalArgumentException\n                 (read-string \"#{1 2 3 4 1 5}\")))\n    ;; If there are duplicate items when doing (conj #{} x1 x2 ...),\n    ;; the behavior is that the metadata of the first item is kept.\n    (are [s x] (all-equal-sets-incl-meta s\n                                         (apply conj #{} x)\n                                         (set x)\n                                         (apply hash-set x)\n                                         (apply sorted-set x)\n                                         (apply sorted-set-by cmp-first x))\n      #{x1 y2} [x1 y2]\n      #{x1 z3a} [x1 z3a z3b]\n      #{w5b}    [w5b w5a w5c]\n      #{z3a x1} [z3a z3b x1])\n\n    ;; Maps\n    (is (thrown? IllegalArgumentException\n                 (read-string \"{:a 1, :b 2, :a -1, :c 3}\")))\n    ;; If there are duplicate keys when doing (assoc {} k1 v1 k2 v2\n    ;; ...), the behavior is that the metadata of the first duplicate\n    ;; key is kept, but mapped to the last value with an equal key\n    ;; (where metadata of keys are not compared).\n    (are [h x] (all-equal-maps-incl-meta h\n                                         (apply assoc {} x)\n                                         (apply hash-map x)\n                                         (apply sorted-map x)\n                                         (apply sorted-map-by cmp-first x)\n                                         (apply array-map x))\n      {x1 2, z3a 4} [x1 2, z3a 4]\n      {x1 2, z3a 5} [x1 2, z3a 4, z3b 5]\n      {z3a 5}       [z3a 2, z3a 4, z3b 5]\n      {z3b 4, x1 5} [z3b 2, z3a 4, x1 5]\n      {z3b v4b, x1 5} [z3b v4a, z3a v4b, x1 5]\n      {x1 v4a, w5a v4c, v4a z3b, y2 2} [x1 v4a, w5a v4a, w5b v4b,\n                                        v4a z3a, y2 2, v4b z3b, w5c v4c])))\n\n\n(deftest test-assoc\n  (are [x y] (= x y)\n       [4] (assoc [] 0 4)\n       [5 -7] (assoc [] 0 5 1 -7)\n       {:a 1} (assoc {} :a 1)\n       {nil 1} (assoc {} nil 1)\n       {:a 2 :b -2} (assoc {} :b -2 :a 2))\n  (is (thrown? IllegalArgumentException (assoc [] 0 5 1)))\n  (is (thrown? IllegalArgumentException (assoc {} :b -2 :a))))\n\n(defn is-same-collection [a b]\n  (let [msg (format \"(class a)=%s (class b)=%s a=%s b=%s\"\n                    (.getName (class a)) (.getName (class b)) a b)]\n    (is (= (count a) (count b) (.size a) (.size b)) msg)\n    (is (= a b) msg)\n    (is (= b a) msg)\n    (is (.equals ^Object a b) msg)\n    (is (.equals ^Object b a) msg)\n    (is (= (hash a) (hash b)) msg)\n    (is (= (.hashCode ^Object a) (.hashCode ^Object b)) msg)))\n\n(deftest ordered-collection-equality-test\n  (let [empty-colls [ []\n                      '()\n                      (lazy-seq)\n                      clojure.lang.PersistentQueue/EMPTY\n                      (vector-of :long) ]]\n    (doseq [c1 empty-colls, c2 empty-colls]\n      (is-same-collection c1 c2)))\n  (let [colls1 [ [-3 :a \"7th\"]\n                 '(-3 :a \"7th\")\n                 (lazy-seq (cons -3\n                   (lazy-seq (cons :a\n                     (lazy-seq (cons \"7th\" nil))))))\n                 (into clojure.lang.PersistentQueue/EMPTY\n                       [-3 :a \"7th\"])\n                 (sequence (map identity) [-3 :a \"7th\"]) ]]\n    (doseq [c1 colls1, c2 colls1]\n      (is-same-collection c1 c2)))\n  (is-same-collection [-3 1 7] (vector-of :long -3 1 7)))\n\n(defn case-indendent-string-cmp [s1 s2]\n  (compare (string/lower-case s1) (string/lower-case s2)))\n\n(deftest set-equality-test\n  (let [empty-sets [ #{}\n                     (hash-set)\n                     (sorted-set)\n                     (sorted-set-by case-indendent-string-cmp) ]]\n    (doseq [s1 empty-sets, s2 empty-sets]\n      (is-same-collection s1 s2)))\n  (let [sets1 [ #{\"Banana\" \"apple\" \"7th\"}\n                (hash-set \"Banana\" \"apple\" \"7th\")\n                (sorted-set \"Banana\" \"apple\" \"7th\")\n                (sorted-set-by case-indendent-string-cmp \"Banana\" \"apple\" \"7th\") ]]\n    (doseq [s1 sets1, s2 sets1]\n      (is-same-collection s1 s2))))\n\n(deftest map-equality-test\n  (let [empty-maps [ {}\n                     (hash-map)\n                     (array-map)\n                     (sorted-map)\n                     (sorted-map-by case-indendent-string-cmp) ]]\n    (doseq [m1 empty-maps, m2 empty-maps]\n      (is-same-collection m1 m2)))\n  (let [maps1 [ {\"Banana\" \"like\", \"apple\" \"love\", \"7th\" \"indifferent\"}\n                (hash-map \"Banana\" \"like\", \"apple\" \"love\", \"7th\" \"indifferent\")\n                (array-map \"Banana\" \"like\", \"apple\" \"love\", \"7th\" \"indifferent\")\n                (sorted-map \"Banana\" \"like\", \"apple\" \"love\", \"7th\" \"indifferent\")\n                (sorted-map-by case-indendent-string-cmp\n                               \"Banana\" \"like\", \"apple\" \"love\", \"7th\" \"indifferent\") ]]\n    (doseq [m1 maps1, m2 maps1]\n      (is-same-collection m1 m2))))\n\n;; *** Collection hashes ***\n;; See: http://clojure.org/data_structures#hash\n\n(defn hash-ordered [collection]\n  (-> (reduce (fn [acc e] (unchecked-add-int (unchecked-multiply-int 31 acc) (hash e)))\n              1\n              collection)\n      (mix-collection-hash (count collection))))\n\n(defn hash-unordered [collection]\n  (-> (reduce unchecked-add-int 0 (map hash collection))\n      (mix-collection-hash (count collection))))\n\n(defn gen-elements\n  []\n  (gen/vec gen/anything))\n\n(defspec ordered-collection-hashes-match\n  identity\n  [^{:tag clojure.test-clojure.data-structures/gen-elements} elem]\n  (let [v (vec elem)\n        l (apply list elem)]\n    (is (= (hash v)\n           (hash l)\n           (hash (map identity elem))\n           (hash-ordered elem)))))\n\n(defspec unordered-set-hashes-match\n  identity\n  [^{:tag clojure.test-clojure.data-structures/gen-elements} elem]\n  (let [unique-elem (distinct elem)\n        s (into #{} unique-elem)]\n    (is (= (hash s)\n           (hash-unordered unique-elem)))))\n\n(deftest ireduce-reduced\n  (let [f (fn [_ a] (if (= a 5) (reduced \"foo\")))]\n    (is (= \"foo\" (.reduce ^clojure.lang.IReduce (list 1 2 3 4 5) f)))\n    (is (= \"foo\" (.reduce ^clojure.lang.IReduce (seq (long-array [1 2 3 4 5])) f)))))\n\n(defn seq-iter-match\n  [^clojure.lang.Seqable seqable ^Iterable iterable]\n  (if (nil? iterable)\n    (when (not (nil? (seq seqable)))\n      (throw (ex-info \"Null iterable but seq has elements\"\n                      {:pos 0 :seqable seqable :iterable iterable})))\n    (let [i (.iterator iterable)]\n      (loop [s (seq seqable)\n             n 0]\n        (if (seq s)\n          (do\n            (when-not (.hasNext i)\n              (throw (ex-info \"Iterator exhausted before seq\"\n                              {:pos n :seqable seqable :iterable iterable})))\n              (when-not (= (.next i) (first s))\n                (throw (ex-info \"Iterator and seq did not match\"\n                                {:pos n :seqable seqable :iterable iterable})))\n                (recur (rest s) (inc n)))\n          (when (.hasNext i)\n            (throw (ex-info \"Seq exhausted before iterator\"\n                            {:pos n :seqable seqable :iterable iterable}))))))))\n\n(deftest test-seq-iter-match\n  (let [maps (mapcat #(vector (apply array-map %)\n                              (apply hash-map %)\n                              (apply sorted-map %))\n                     [[] [nil 1] [nil 1 2 3] [1 2 3 4]])]\n    (doseq [m maps]\n      (seq-iter-match m m)\n      (seq-iter-match (keys m) (keys m))\n      (seq-iter-match (vals m) (vals m))\n      (seq-iter-match (rest (keys m)) (rest (keys m)))\n      (seq-iter-match (rest (vals m)) (rest (vals m))))))\n\n(defn gen-map\n  []\n  (gen/hash-map (rand-nth cgen/ednable-scalars) (rand-nth cgen/ednable-scalars)))\n\n(defspec seq-and-iter-match-for-maps\n  identity\n  [^{:tag clojure.test-clojure.data-structures/gen-map} m]\n  (seq-iter-match m m))\n\n(defn gen-set\n  []\n  (gen/set (rand-nth cgen/ednable-scalars)))\n\n(defspec seq-and-iter-match-for-sets\n  identity\n  [^{:tag clojure.test-clojure.data-structures/gen-set} s]\n  (seq-iter-match s s))\n\n(defn gen-queue\n  []\n  (into clojure.lang.PersistentQueue/EMPTY\n        (gen/vec (rand-nth cgen/ednable-scalars))))\n\n(defspec seq-and-iter-match-for-queues\n  identity\n  [^{:tag clojure.test-clojure.data-structures/gen-queue} q]\n  (seq-iter-match q q))\n\n(defrecord Rec [a b])\n\n(defn gen-record\n  []\n  (let [r (->Rec (gen/int) (gen/int))]\n       (gen/one-of r\n                   (merge r (gen-map)))))\n\n(defspec seq-and-iter-match-for-records\n         identity\n         [^{:tag clojure.test-clojure.data-structures/gen-record} r]\n         (seq-iter-match r r))\n\n(defspec seq-and-iter-match-for-keys\n         identity\n         [^{:tag clojure.test-clojure.data-structures/gen-map} m]\n         (seq-iter-match (keys m) (keys m)))\n\n(defspec seq-and-iter-match-for-vals\n         identity\n         [^{:tag clojure.test-clojure.data-structures/gen-map} m]\n         (seq-iter-match (vals m) (vals m)))\n\n(defstruct test-struct :a :b)\n\n(defn gen-struct\n  []\n  (let [s (struct test-struct (gen/int) (gen/int))]\n    (gen/one-of s\n                (assoc s (rand-nth cgen/ednable-scalars) (rand-nth cgen/ednable-scalars)))))\n\n(defspec seq-and-iter-match-for-structs\n         identity\n         [^{:tag clojure.test-clojure.data-structures/gen-struct} s]\n         (seq-iter-match s s))"
  },
  {
    "path": "test/clojure/test_clojure/def.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns clojure.test-clojure.def\n  (:use clojure.test clojure.test-helper\n        clojure.test-clojure.protocols))\n\n(deftest defn-error-messages\n  (testing \"multiarity syntax invalid parameter declaration\"\n    (is (fails-with-cause? \n          IllegalArgumentException \n          #\"Parameter declaration \\\"arg1\\\" should be a vector\"\n          (eval-in-temp-ns (defn foo (arg1 arg2))))))\n\n  (testing \"multiarity syntax invalid signature\"\n    (is (fails-with-cause? \n          IllegalArgumentException \n          #\"Invalid signature \\\"\\[a b\\]\\\" should be a list\"\n          (eval-in-temp-ns (defn foo \n                             ([a] 1)\n                             [a b])))))\n\n  (testing \"assume single arity syntax\"\n    (is (fails-with-cause? \n          IllegalArgumentException \n          #\"Parameter declaration \\\"a\\\" should be a vector\"\n          (eval-in-temp-ns (defn foo a)))))\n\n  (testing \"bad name\"\n    (is (fails-with-cause? \n          IllegalArgumentException \n          #\"First argument to defn must be a symbol\"\n          (eval-in-temp-ns (defn \"bad docstring\" testname [arg1 arg2])))))\n         \n  (testing \"missing parameter/signature\"\n    (is (fails-with-cause? \n          IllegalArgumentException \n          #\"Parameter declaration missing\"\n          (eval-in-temp-ns (defn testname)))))\n\n  (testing \"allow trailing map\"\n    (is (eval-in-temp-ns (defn a \"asdf\" ([a] 1) {:a :b}))))\n\n  (testing \"don't allow interleaved map\"\n    (is (fails-with-cause? \n          IllegalArgumentException \n          #\"Invalid signature \\\"\\{:a :b\\}\\\" should be a list\"\n          (eval-in-temp-ns (defn a \"asdf\" ([a] 1) {:a :b} ([] 1)))))))\n\n(deftest non-dynamic-warnings\n  (testing \"no warning for **\"\n    (is (empty? (with-err-print-writer\n                  (eval-in-temp-ns (defn ** ([a b] (Math/pow (double a) (double b)))))))))\n  (testing \"warning for *hello*\"\n    (is (not (empty? (with-err-print-writer\n                       (eval-in-temp-ns (def *hello* \"hi\"))))))))\n\n(deftest dynamic-redefinition\n  ;; too many contextual things for this kind of caching to work...\n  (testing \"classes are never cached, even if their bodies are the same\"\n    (is (= :b\n          (eval\n            '(do\n               (defmacro my-macro [] :a)\n               (defn do-macro [] (my-macro))\n               (defmacro my-macro [] :b)\n               (defn do-macro [] (my-macro))\n               (do-macro)))))))\n\n(deftest nested-dynamic-declaration\n  (testing \"vars :dynamic meta data is applied immediately to vars declared anywhere\"\n    (is (= 10\n          (eval\n            '(do\n               (list\n                 (declare ^:dynamic p)\n                 (defn q [] @p))\n               (binding [p (atom 10)]\n                 (q))))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/delays.clj",
    "content": "(ns clojure.test-clojure.delays\n  (:use clojure.test))\n\n(deftest calls-once\n  (let [a (atom 0)\n        d (delay (swap! a inc))]\n    (is (= 0 @a))\n    (is (= 1 @d))\n    (is (= 1 @d))\n    (is (= 1 @a))))\n\n(deftest saves-exceptions\n  (let [f #(do (throw (Exception. \"broken\"))\n               1)\n        d (delay (f))\n        try-call #(try\n                    @d\n                    (catch Exception e e))\n        first-result (try-call)]\n    (is (instance? Exception first-result))\n    (is (identical? first-result (try-call)))))\n"
  },
  {
    "path": "test/clojure/test_clojure/edn.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Stuart Halloway\n\n\n(ns clojure.test-clojure.edn\n  (:require [clojure.test.generative :refer (defspec)]\n            [clojure.test-clojure.generators :as cgen]\n            [clojure.edn :as edn]))\n\n(defn roundtrip\n  \"Print an object and read it back as edn. Returns rather than throws\n   any exceptions.\"\n  [o]\n  (binding [*print-length* nil\n            *print-dup* nil\n            *print-level* nil]\n    (try\n     (-> o pr-str edn/read-string)\n     (catch Throwable t t))))\n\n(defspec types-that-should-roundtrip\n  roundtrip\n  [^{:tag cgen/ednable} o]\n  (when-not (= o %)\n    (throw (ex-info \"Value cannot roundtrip, see ex-data\" {:printed o :read %}))))\n\n(defspec types-that-should-not-roundtrip\n  roundtrip\n  [^{:tag cgen/non-ednable} o]\n  (when-not (instance? Throwable %)\n    (throw (ex-info \"edn/read should have thrown, see ex-data\" {:printed o :read %}))))\n"
  },
  {
    "path": "test/clojure/test_clojure/errors.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Tests for error handling and messages\n\n(ns clojure.test-clojure.errors\n  (:use clojure.test)\n  (:import clojure.lang.ArityException))\n\n(defn f0 [] 0)\n\n(defn f1 [a] a)\n\n;; Function name that includes many special characters to test demunge\n(defn f2:+><->!#%&*|b [x] x)\n\n(defmacro m0 [] `(identity 0))\n\n(defmacro m1 [a] `(inc ~a))\n\n(deftest arity-exception\n  ;; IllegalArgumentException is pre-1.3\n  (is (thrown-with-msg? IllegalArgumentException #\"Wrong number of args \\(1\\) passed to\"\n        (f0 1)))\n  (is (thrown-with-msg? ArityException #\"Wrong number of args \\(0\\) passed to\"\n        (f1)))\n  (is (thrown-with-msg? ArityException #\"Wrong number of args \\(1\\) passed to\"\n        (macroexpand `(m0 1))))\n  (is (thrown-with-msg? ArityException #\"Wrong number of args \\(2\\) passed to\"\n        (macroexpand `(m1 1 2))))\n  (is (thrown-with-msg? ArityException #\"\\Qerrors-f2:+><->!#%&*|b\\E\"\n        (f2:+><->!#%&*|b 1 2))\n        \"ArityException messages should demunge function names\"))\n\n(deftest assert-arg-messages\n  ; used to ensure that error messages properly use local names for macros\n  (refer 'clojure.core :rename '{with-open renamed-with-open})\n  \n  ; would have used `are` here, but :line meta on &form doesn't survive successive macroexpansions\n  (doseq [[msg-regex-str form] [[\"if-let .* in %s:\\\\d+\" '(if-let [a 5\n                                                                  b 6]\n                                                           true nil)]\n                                [\"let .* in %s:\\\\d+\" '(let [a])] \n                                [\"let .* in %s:\\\\d+\" '(let (a))]\n                                [\"renamed-with-open .* in %s:\\\\d+\" '(renamed-with-open [a])]]]\n    (is (thrown-with-msg? IllegalArgumentException\n                          (re-pattern (format msg-regex-str *ns*))\n                          (macroexpand form)))))\n\n(deftest extract-ex-data\n  (try\n   (throw (ex-info \"example error\" {:foo 1}))\n   (catch Throwable t\n     (is (= {:foo 1} (ex-data t)))))\n  (is (nil? (ex-data (RuntimeException. \"example non ex-data\")))))\n\n(deftest Throwable->map-test\n  (testing \"base functionality\"\n    (let [{:keys [cause via trace]} (Throwable->map\n                                     (Exception. \"I am a string literal\"))]\n      (is (= cause \"I am a string literal\"))\n      (is (= 1 (count via)))\n      (is (vector? via))\n      (is (= [\"I am a string literal\"] (map :message via)))))\n  (testing \"causes\"\n    (let [{:keys [cause via trace]} (Throwable->map\n                                     (Exception. \"I am not a number\"\n                                                 (Exception. \"double two\")))]\n      (is (= cause \"double two\"))\n      (is (= [\"I am not a number\" \"double two\"]\n             (map :message via)))))\n  (testing \"ex-data\"\n    (let [{[{:keys [data]}] :via\n           data-top-level :data}\n          (Throwable->map (ex-info \"ex-info\"\n                                   {:some \"data\"}))]\n      (is (= data data-top-level {:some \"data\"})))))\n"
  },
  {
    "path": "test/clojure/test_clojure/evaluation.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n\n;;  Tests for the Clojure functions documented at the URL:\n;;\n;;    http://clojure.org/Evaluation\n;;\n;;  by J. McConnell\n;;  Created 22 October 2008\n\n(ns clojure.test-clojure.evaluation\n  (:use clojure.test))\n\n(import '(java.lang Boolean)\n        '(clojure.lang Compiler Compiler$CompilerException))\n\n(defmacro test-that\n  \"Provides a useful way for specifying the purpose of tests. If the first-level\n  forms are lists that make a call to a clojure.test function, it supplies the\n  purpose as the msg argument to those functions. Otherwise, the purpose just\n  acts like a comment and the forms are run unchanged.\"\n  [purpose & test-forms]\n  (let [tests (map\n                #(if (= (:ns (meta (resolve (first %))))\n                        (the-ns 'clojure.test))\n                   (concat % (list purpose))\n                   %)\n                test-forms)]\n    `(do ~@tests)))\n\n(deftest Eval\n  (is (= (eval '(+ 1 2 3)) (Compiler/eval '(+ 1 2 3))))\n  (is (= (eval '(list 1 2 3)) '(1 2 3)))\n  (is (= (eval '(list + 1 2 3)) (list clojure.core/+ 1 2 3)))\n  (test-that \"Non-closure fns are supported as code\"\n             (is (= (eval (eval '(list + 1 2 3))) 6)))\n  (is (= (eval (list '+ 1 2 3)) 6)))\n\n; not using Clojure's RT/classForName since a bug in it could hide a bug in\n; eval's resolution\n(defn class-for-name [name]\n  (java.lang.Class/forName name))\n\n(defmacro in-test-ns [& body]\n  `(binding [*ns* *ns*]\n     (in-ns 'clojure.test-clojure.evaluation)\n     ~@body))\n\n;;; Literals tests ;;;\n\n(defmacro #^{:private true} evaluates-to-itself? [expr]\n  `(let [v# ~expr\n         q# (quote ~expr)]\n     (is (= (eval q#) q#) (str q# \" does not evaluate to itself\"))))\n\n(deftest Literals\n  ; Strings, numbers, characters, nil and keywords should evaluate to themselves\n  (evaluates-to-itself? \"test\")\n  (evaluates-to-itself? \"test\n                        multi-line\n                        string\")\n  (evaluates-to-itself? 1)\n  (evaluates-to-itself? 1.0)\n  (evaluates-to-itself? 1.123456789)\n  (evaluates-to-itself? 1/2)\n  (evaluates-to-itself? 1M)\n  (evaluates-to-itself? 999999999999999999)\n  (evaluates-to-itself? \\a)\n  (evaluates-to-itself? \\newline)\n  (evaluates-to-itself? nil)\n  (evaluates-to-itself? :test)\n  ; Boolean literals should evaluate to Boolean.{TRUE|FALSE}\n  (is (identical? (eval true) Boolean/TRUE))\n  (is (identical? (eval false) Boolean/FALSE)))\n\n;;; Symbol resolution tests ;;;\n\n(def foo \"abc\")\n(in-ns 'resolution-test)\n(def bar 123)\n(def #^{:private true} baz 456)\n(in-ns 'clojure.test-clojure.evaluation)\n\n(defn a-match? [re s] (not (nil? (re-matches re s))))\n\n(defmacro throws-with-msg\n  ([re form] `(throws-with-msg ~re ~form Exception))\n  ([re form x] `(throws-with-msg\n                  ~re\n                  ~form\n                  ~(if (instance? Exception x) x Exception)\n                  ~(if (instance? String x) x nil)))\n  ([re form class msg]\n       `(let [ex# (try\n                    ~form\n                    (catch ~class e# e#)\n                    (catch Exception e#\n                      (let [cause# (.getCause e#)]\n                        (if (= ~class (class cause#)) cause# (throw e#)))))]\n          (is (a-match? ~re (.toString ex#))\n              (or ~msg\n                  (str \"Expected exception that matched \" (pr-str ~re)\n                       \", but got exception with message: \\\"\" ex#))))))\n\n(deftest SymbolResolution\n  (test-that\n    \"If a symbol is namespace-qualified, the evaluated value is the value\n     of the binding of the global var named by the symbol\"\n    (is (= (eval 'resolution-test/bar) 123)))\n\n  (test-that\n    \"It is an error if there is no global var named by the symbol\"\n    (throws-with-msg\n      #\".*Unable to resolve symbol: bar.*\" (eval 'bar)))\n\n  (test-that\n    \"It is an error if the symbol reference is to a non-public var in a\n    different namespace\"\n    (throws-with-msg\n      #\".*resolution-test/baz is not public.*\"\n      (eval 'resolution-test/baz)\n      Compiler$CompilerException))\n\n  (test-that\n    \"If a symbol is package-qualified, its value is the Java class named by the\n    symbol\"\n    (is (= (eval 'java.lang.Math) (class-for-name \"java.lang.Math\"))))\n\n  (test-that\n    \"If a symbol is package-qualified, it is an error if there is no Class named\n    by the symbol\"\n    (is (thrown? Compiler$CompilerException (eval 'java.lang.FooBar))))\n\n  (test-that\n    \"If a symbol is not qualified, the following applies, in this order:\n\n      1. If it names a special form it is considered a special form, and must\n         be utilized accordingly.\n\n      2. A lookup is done in the current namespace to see if there is a mapping\n         from the symbol to a class. If so, the symbol is considered to name a\n         Java class object.\n\n      3. If in a local scope (i.e. in a function definition), a lookup is done\n         to see if it names a local binding (e.g. a function argument or\n         let-bound name). If so, the value is the value of the local binding.\n\n      4. A lookup is done in the current namespace to see if there is a mapping\n         from the symbol to a var. If so, the value is the value of the binding\n         of the var referred-to by the symbol.\n\n      5. It is an error.\"\n\n    ; First\n    (doall (for [form '(def if do let quote var fn loop recur throw try\n                         monitor-enter monitor-exit)]\n             (is (thrown? Compiler$CompilerException (eval form)))))\n    (let [if \"foo\"]\n      (is (thrown? Compiler$CompilerException (eval 'if)))\n\n    ; Second\n      (is (= (eval 'Boolean) (class-for-name \"java.lang.Boolean\"))))\n    (let [Boolean \"foo\"]\n      (is (= (eval 'Boolean) (class-for-name \"java.lang.Boolean\"))))\n\n    ; Third\n    (is (= (eval '(let [foo \"bar\"] foo)) \"bar\"))\n\n    ; Fourth\n    (in-test-ns (is (= (eval 'foo) \"abc\")))\n    (is (thrown? Compiler$CompilerException (eval 'bar))) ; not in this namespace\n\n    ; Fifth\n    (is (thrown? Compiler$CompilerException (eval 'foobar)))))\n\n;;; Metadata tests ;;;\n\n(defstruct struct-with-symbols (with-meta 'k {:a \"A\"}))\n\n(deftest Metadata\n\n  (test-that\n    \"find returns key symbols and their metadata\"\n    (let [s (struct struct-with-symbols 1)]\n      (is (= {:a \"A\"} (meta (first (find s 'k))))))))\n\n;;; Collections tests ;;;\n(def x 1)\n(def y 2)\n\n(deftest Collections\n  (in-test-ns\n    (test-that\n      \"Vectors and Maps yield vectors and (hash) maps whose contents are the\n      evaluated values of the objects they contain.\"\n      (is (= (eval '[x y 3]) [1 2 3]))\n      (is (= (eval '{:x x :y y :z 3}) {:x 1 :y 2 :z 3}))\n      (is (instance? clojure.lang.IPersistentMap (eval '{:x x :y y})))))\n\n  (in-test-ns\n    (test-that\n      \"Metadata maps yield maps whose contents are the evaluated values of\n      the objects they contain. If a vector or map has metadata, the evaluated\n      metadata map will become the metadata of the resulting value.\"\n      (is (= (eval #^{:x x} '[x y]) #^{:x 1} [1 2]))))\n\n  (test-that\n    \"An empty list () evaluates to an empty list.\"\n    (is (= (eval '()) ()))\n    (is (empty? (eval ())))\n    (is (= (eval (list)) ())))\n\n  ;aargh, fragile tests, please fix\n  #_(test-that\n    \"Non-empty lists are considered calls\"\n    (is (thrown? Compiler$CompilerException (eval '(1 2 3))))))\n\n(deftest Macros)\n\n(deftest Loading)\n"
  },
  {
    "path": "test/clojure/test_clojure/fn.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Ambrose Bonnaire-Sergeant\n\n(ns clojure.test-clojure.fn\n  (:use clojure.test))\n\n(deftest fn-error-checking\n  (testing \"bad arglist\"\n    (is (fails-with-cause? java.lang.IllegalArgumentException \n          #\"Parameter declaration a should be a vector\"\n          (eval '(fn \"a\" a)))))\n\n  (testing \"treat first param as args\"\n    (is (fails-with-cause? java.lang.IllegalArgumentException \n          #\"Parameter declaration a should be a vector\"\n          (eval '(fn \"a\" [])))))\n\n  (testing \"looks like listy signature, but malformed declaration\"\n    (is (fails-with-cause? java.lang.IllegalArgumentException\n          #\"Parameter declaration 1 should be a vector\"\n          (eval '(fn (1))))))\n\n  (testing \"checks each signature\"\n    (is (fails-with-cause? java.lang.IllegalArgumentException\n          #\"Parameter declaration a should be a vector\"\n          (eval '(fn\n                   ([a] 1)\n                   (\"a\" 2))))))\n\n  (testing \"correct name but invalid args\"\n    (is (fails-with-cause? java.lang.IllegalArgumentException\n          #\"Parameter declaration a should be a vector\"\n          (eval '(fn a \"a\")))))\n\n  (testing \"first sig looks multiarity, rest of sigs should be lists\"\n    (is (fails-with-cause? java.lang.IllegalArgumentException \n          #\"Invalid signature \\[a b\\] should be a list\"\n          (eval '(fn a\n                   ([a] 1)\n                   [a b])))))\n  \n  (testing \"missing parameter declaration\"\n    (is (fails-with-cause? java.lang.IllegalArgumentException \n          #\"Parameter declaration missing\"\n          (eval '(fn a))))\n    (is (fails-with-cause? java.lang.IllegalArgumentException \n          #\"Parameter declaration missing\"\n          (eval '(fn))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/for.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;;  Tests for the Clojure 'for' macro\n;;\n;;  by Chouser\n;;  Created Dec 2008\n\n(ns clojure.test-clojure.for\n  (:use clojure.test))\n\n(deftest Docstring-Example\n  (is (= (take 100 (for [x (range 100000000)\n                         y (range 1000000) :while (< y x)]\n                     [x y]))\n         '([1 0] [2 0] [2 1] [3 0] [3 1] [3 2] [4 0] [4 1] [4 2] [4 3]\n           [5 0] [5 1] [5 2] [5 3] [5 4]\n           [6 0] [6 1] [6 2] [6 3] [6 4] [6 5]\n           [7 0] [7 1] [7 2] [7 3] [7 4] [7 5] [7 6]\n           [8 0] [8 1] [8 2] [8 3] [8 4] [8 5] [8 6] [8 7]\n           [9 0] [9 1] [9 2] [9 3] [9 4] [9 5] [9 6] [9 7] [9 8]\n           [10 0] [10 1] [10 2] [10 3] [10 4] [10 5] [10 6] [10 7] [10 8] [10 9]\n           [11 0] [11 1] [11 2] [11 3] [11 4] [11 5] [11 6] [11 7] [11 8] [11 9]\n             [11 10]\n           [12 0] [12 1] [12 2] [12 3] [12 4] [12 5] [12 6] [12 7] [12 8] [12 9]\n             [12 10] [12 11]\n           [13 0] [13 1] [13 2] [13 3] [13 4] [13 5] [13 6] [13 7] [13 8] [13 9]\n             [13 10] [13 11] [13 12]\n           [14 0] [14 1] [14 2] [14 3] [14 4] [14 5] [14 6] [14 7] [14 8]))))\n\n(defmacro deftest-both [txt & ises]\n  `(do\n     (deftest ~(symbol (str \"For-\" txt)) ~@ises)\n     (deftest ~(symbol (str \"Doseq-\" txt))\n              ~@(map (fn [[x-is [x-= [x-for binds body] value]]]\n                       (when (and (= x-is 'is) (= x-= '=) (= x-for 'for))\n                         `(is (= (let [acc# (atom [])]\n                                   (doseq ~binds (swap! acc# conj ~body))\n                                   @acc#)\n                                 ~value))))\n                     ises))))\n\n(deftest-both When\n  (is (= (for [x (range 10) :when (odd? x)] x) '(1 3 5 7 9)))\n  (is (= (for [x (range 4) y (range 4) :when (odd? y)] [x y])\n         '([0 1] [0 3] [1 1] [1 3] [2 1] [2 3] [3 1] [3 3])))\n  (is (= (for [x (range 4) y (range 4) :when (odd? x)] [x y])\n         '([1 0] [1 1] [1 2] [1 3] [3 0] [3 1] [3 2] [3 3])))\n  (is (= (for [x (range 4) :when (odd? x) y (range 4)] [x y])\n         '([1 0] [1 1] [1 2] [1 3] [3 0] [3 1] [3 2] [3 3])))\n  (is (= (for [x (range 5) y (range 5) :when (< x y)] [x y])\n         '([0 1] [0 2] [0 3] [0 4] [1 2] [1 3] [1 4] [2 3] [2 4] [3 4]))))\n\n(defn only\n  \"Returns a lazy seq of increasing ints starting at 0.  Trying to get\n  the nth+1 value of the seq throws an exception.  This is meant to\n  help detecting over-eagerness in lazy seq consumers.\"\n  [n]\n  (lazy-cat (range n)\n            (throw (Exception. \"consumer went too far in lazy seq\"))))\n\n(deftest-both While\n  (is (= (for [x (only 6) :while (< x 5)] x) '(0 1 2 3 4)))\n  (is (= (for [x (range 4) y (only 4) :while (< y 3)] [x y])\n         '([0 0] [0 1] [0 2] [1 0] [1 1] [1 2]\n           [2 0] [2 1] [2 2] [3 0] [3 1] [3 2])))\n  (is (= (for [x (range 4) y (range 4) :while (< x 3)] [x y])\n         '([0 0] [0 1] [0 2] [0 3] [1 0] [1 1] [1 2] [1 3]\n           [2 0] [2 1] [2 2] [2 3])))\n  (is (= (for [x (only 4) :while (< x 3) y (range 4)] [x y])\n         '([0 0] [0 1] [0 2] [0 3] [1 0] [1 1] [1 2] [1 3]\n           [2 0] [2 1] [2 2] [2 3])))\n  (is (= (for [x (range 4) y (range 4) :while (even? x)] [x y])\n         '([0 0] [0 1] [0 2] [0 3] [2 0] [2 1] [2 2] [2 3])))\n  (is (= (for [x (only 2) :while (even? x) y (range 4)] [x y])\n         '([0 0] [0 1] [0 2] [0 3])))\n  (is (= (for [x (range 4) y (only 4) :while (< y x)] [x y])\n         '([1 0] [2 0] [2 1] [3 0] [3 1] [3 2]))))\n\n(deftest-both While-and-When\n  (is (= (for [x (only 6) :while (< x 5) y (range 4) :when (odd? y)] [x y])\n         '([0 1] [0 3] [1 1] [1 3] [2 1] [2 3] [3 1] [3 3] [4 1] [4 3])))\n  (is (= (for [x (range 4) :when (odd? x) y (only 6) :while (< y 5)] [x y])\n         '([1 0] [1 1] [1 2] [1 3] [1 4] [3 0] [3 1] [3 2] [3 3] [3 4])))\n  (is (= (for [x (only 6) :while (< x 5) y (range 4) :when (odd? (+ x y))]\n           [x y])\n         '([0 1] [0 3] [1 0] [1 2] [2 1] [2 3] [3 0] [3 2] [4 1] [4 3])))\n  (is (= (for [x (range 4) :when (odd? x) y (only 2) :while (odd? (+ x y))]\n           [x y])\n         '([1 0] [3 0]))))\n\n(deftest-both While-and-When-Same-Binding\n  (is (= (for [x (only 6) :while (< x 5) :when (odd? x)] x) '(1 3)))\n  (is (= (for [x (only 6)\n               :while (< x 5) ; if :while is false, :when should not be evaled\n               :when (do (if (< x 5) (odd? x)))] x) '(1 3)))\n  (is (= (for [a (range -2 5)\n               :when (not= a 0) ; :when may guard :while\n               :while (> (Math/abs (/ 1.0 a)) 1/3)] a) '(-2 -1 1 2))))\n\n(deftest-both Nesting\n  (is (= (for [x '(a b) y (interpose x '(1 2)) z (list x y)] [x y z])\n         '([a 1 a] [a 1 1] [a a a] [a a a] [a 2 a] [a 2 2]\n           [b 1 b] [b 1 1] [b b b] [b b b] [b 2 b] [b 2 2])))\n  (is (= (for [x ['a nil] y [x 'b]] [x y])\n         '([a a] [a b] [nil nil] [nil b]))))\n\n(deftest-both Destructuring\n  (is (= (for [{:syms [a b c]} (map #(zipmap '(a b c) (range % 5)) (range 3))\n               x [a b c]]\n           (Integer. (str a b c x)))\n         '(120 121 122 1231 1232 1233 2342 2343 2344))))\n\n(deftest-both Let\n  (is (= (for [x (range 3) y (range 3) :let [z (+ x y)] :when (odd? z)] [x y z])\n         '([0 1 1] [1 0 1] [1 2 3] [2 1 3])))\n  (is (= (for [x (range 6) :let [y (rem x 2)] :when (even? y) z [8 9]] [x z])\n         '([0 8] [0 9] [2 8] [2 9] [4 8] [4 9]))))\n\n; :while must skip all subsequent chunks as well as the remainder of\n; the current chunk:\n(deftest-both Chunked-While\n  (is (= (for [x (range 100) :while (even? x)] x) '(0))))\n"
  },
  {
    "path": "test/clojure/test_clojure/genclass/examples.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns ^{:doc \"Test classes that are AOT-compile for the tests in\n           clojure.test-clojure.genclass.\"\n      :author \"Stuart Halloway, Daniel Solano Gómez\"}\n  clojure.test-clojure.genclass.examples)\n\n(definterface ExampleInterface\n  (foo [a])\n  (foo [a b])\n  (foo [a #^int b]))\n\n(gen-class :name clojure.test_clojure.genclass.examples.ExampleClass\n           :implements [clojure.test_clojure.genclass.examples.ExampleInterface])\n\n;; -foo-Object unimplemented to test missing fn case\n\n(defn -foo-Object-Object\n  [_ o1 o2]\n  \"foo with o, o\")\n\n(defn -foo-Object-int\n  [_ o i]\n  \"foo with o, i\")\n\n(declare -toString)\n\n(gen-class :name ^{Deprecated {}\n                   ;SuppressWarnings [\"Warning1\"] ; discarded\n                   ;java.lang.annotation.Target []\n                   }\n                 clojure.test_clojure.genclass.examples.ExampleAnnotationClass\n           :prefix \"annot-\"\n           :methods [[;^{Deprecated {}\n                      ;  Override {}} ;discarded\n                      foo [;^{java.lang.annotation.Retention java.lang.annotation.RetentionPolicy/SOURCE\n                           ;  java.lang.annotation.Target    [java.lang.annotation.ElementType/TYPE\n                           ;                                  java.lang.annotation.ElementType/PARAMETER]}\n                           String] void]])\n\n(comment (gen-class :name clojure.test_clojure.genclass.examples.ProtectedFinalTester\n                    :extends java.lang.ClassLoader\n                    :main false\n                    :prefix \"pf-\"\n                    ; Cannot do this with java sources\n                    ;:exposes-methods {findSystemClass superFindSystemClass}\n                    ))\n\n(defn pf-findSystemClass\n  \"This function should never be called.\"\n  [_ name]\n  clojure.lang.RT)\n\n(definterface ArrayDefInterface\n  ; primitive array sugar\n  (^void takesByteArray [^bytes a])\n  (^void takesCharArray [^chars a])\n  (^void takesShortArray [^shorts a])\n  (^void takesIntArray [^ints a])\n  (^void takesLongArray [^longs a])\n  (^void takesFloatArray [^floats a])\n  (^void takesDoubleArray [^doubles a])\n  (^void takesBooleanArray [^booleans a])\n  ; raw primitive arrays\n  (^\"[B\" returnsByteArray [])\n  (^\"[C\" returnsCharArray [])\n  (^\"[I\" returnsIntArray [])\n  (^\"[S\" returnsShortArray [])\n  (^\"[J\" returnsLongArray [])\n  (^\"[F\" returnsFloatArray [])\n  (^\"[D\" returnsDoubleArray [])\n  (^\"[Z\" returnsBooleanArray []))\n\n(definterface UsesPreviousInterfaceFromThisFile\n  (^clojure.test-clojure.genclass.examples.ArrayDefInterface\n   identity\n   [^clojure.test-clojure.genclass.examples.ArrayDefInterface a]))\n\n(gen-interface\n  :name clojure.test_clojure.genclass.examples.ArrayGenInterface\n  :methods [; sugar\n            [takesByteArray [bytes] void]\n            [takesCharArray [chars] void]\n            [takesShortArray [shorts] void]\n            [takesIntArray [ints] void]\n            [takesLongArray [longs] void]\n            [takesFloatArray [floats] void]\n            [takesDoubleArray [doubles] void]\n            [takesBooleanArray [booleans] void]\n            ; raw primitive types\n            [returnsByteArray [] \"[B\"]\n            [returnsCharArray [] \"[C\"]\n            [returnsShortArray [] \"[S\"]\n            [returnsIntArray [] \"[I\"]\n            [returnsLongArray [] \"[J\"]\n            [returnsFloatArray [] \"[F\"]\n            [returnsDoubleArray [] \"[D\"]\n            [returnsBooleanArray [] \"[Z\"]])\n"
  },
  {
    "path": "test/clojure/test_clojure/genclass.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns ^{:doc \"Tests for clojure.core/gen-class\"\n      :author \"Stuart Halloway, Daniel Solano Gómez\"}\n  clojure.test-clojure.genclass\n  (:use clojure.test clojure.test-helper)\n  (:require clojure.test_clojure.genclass.examples)\n  (:import [clojure.test_clojure.genclass.examples\n            ExampleClass\n            ExampleAnnotationClass\n            ArrayDefInterface\n            ArrayGenInterface]\n\n           [java.lang.annotation ElementType\n                                 Retention\n                                 RetentionPolicy\n                                 Target]))\n\n(deftest arg-support\n  (let [example (ExampleClass.)\n        o (Object.)]\n    (is (= \"foo with o, o\" (.foo example o o)))\n    (is (= \"foo with o, i\" (.foo example o (int 1))))\n    (is (thrown? java.lang.UnsupportedOperationException (.foo example o)))))\n\n(deftest name-munging\n  (testing \"mapping from Java fields to Clojure vars\"\n    (is (= #'clojure.test-clojure.genclass.examples/-foo-Object-int\n           (get-field ExampleClass 'foo_Object_int__var)))\n    (is (= #'clojure.test-clojure.genclass.examples/-toString\n           (get-field ExampleClass 'toString__var)))))\n\n;todo - fix this, it depends on the order of things out of a hash-map\n#_(deftest test-annotations\n  (let [annot-class ExampleAnnotationClass\n        foo-method          (.getDeclaredMethod annot-class \"foo\" (into-array [String]))]\n    (testing \"Class annotations:\"\n      (is (= 2 (count (.getDeclaredAnnotations annot-class))))\n      (testing \"@Deprecated\"\n        (let [deprecated (.getAnnotation annot-class Deprecated)]\n          (is deprecated)))\n      (testing \"@Target([])\"\n        (let [resource (.getAnnotation annot-class Target)]\n          (is (= 0 (count (.value resource)))))))\n    (testing \"Method annotations:\"\n      (testing \"@Deprecated void foo(String):\"\n        (is (= 1 (count (.getDeclaredAnnotations foo-method))))\n        (is (.getAnnotation foo-method Deprecated))))\n    (testing \"Parameter annotations:\"\n      (let [param-annots (.getParameterAnnotations foo-method)]\n        (is (= 1 (alength param-annots)))\n        (let [first-param-annots (aget param-annots 0)]\n          (is (= 2 (alength first-param-annots)))\n          (testing \"void foo(@Retention(…) String)\"\n            (let [retention (aget first-param-annots 0)]\n              (is (instance? Retention retention))\n              (= RetentionPolicy/SOURCE (.value retention))))\n          (testing \"void foo(@Target(…) String)\"\n            (let [target (aget first-param-annots 1)]\n              (is (instance? Target target))\n              (is (= [ElementType/TYPE ElementType/PARAMETER] (seq (.value target)))))))))))\n\n(deftest genclass-option-validation\n  (is (fails-with-cause? IllegalArgumentException #\"Not a valid method name: has-hyphen\"\n        (@#'clojure.core/validate-generate-class-options {:methods '[[fine [] void] [has-hyphen [] void]]}))))\n\n(deftest interface-array-type-hints\n  (let [array-types       {:ints     (class (int-array 0))\n                           :bytes    (class (byte-array 0))\n                           :shorts   (class (short-array 0))\n                           :chars    (class (char-array 0))\n                           :longs    (class (long-array 0))\n                           :floats   (class (float-array 0))\n                           :doubles  (class (double-array 0))\n                           :booleans (class (boolean-array 0))\n                           :maps     (class (into-array java.util.Map []))}\n        array-types       (assoc array-types\n                                 :maps-2d (class (into-array (:maps array-types) [])))\n        method-with-name  (fn [name methods] (first (filter #(= name (.getName %)) methods)))\n        parameter-type    (fn [method] (first (.getParameterTypes method)))\n        return-type       (fn [method] (.getReturnType method))]\n    (testing \"definterface\"\n      (let [method-with-name #(method-with-name % (.getMethods ArrayDefInterface))]\n        (testing \"sugar primitive array hints\"\n          (are [name type] (= (type array-types)\n                              (parameter-type (method-with-name name)))\n               \"takesByteArray\"    :bytes\n               \"takesCharArray\"    :chars\n               \"takesShortArray\"   :shorts\n               \"takesIntArray\"     :ints\n               \"takesLongArray\"    :longs\n               \"takesFloatArray\"   :floats\n               \"takesDoubleArray\"  :doubles\n               \"takesBooleanArray\" :booleans))\n        (testing \"raw primitive array hints\"\n          (are [name type] (= (type array-types)\n                              (return-type (method-with-name name)))\n               \"returnsByteArray\"    :bytes\n               \"returnsCharArray\"    :chars\n               \"returnsShortArray\"   :shorts\n               \"returnsIntArray\"     :ints\n               \"returnsLongArray\"    :longs\n               \"returnsFloatArray\"   :floats\n               \"returnsDoubleArray\"  :doubles\n               \"returnsBooleanArray\" :booleans))))\n    (testing \"gen-interface\"\n      (let [method-with-name #(method-with-name % (.getMethods ArrayGenInterface))]\n        (testing \"sugar primitive array hints\"\n          (are [name type] (= (type array-types)\n                              (parameter-type (method-with-name name)))\n               \"takesByteArray\"    :bytes\n               \"takesCharArray\"    :chars\n               \"takesShortArray\"   :shorts\n               \"takesIntArray\"     :ints\n               \"takesLongArray\"    :longs\n               \"takesFloatArray\"   :floats\n               \"takesDoubleArray\"  :doubles\n               \"takesBooleanArray\" :booleans))\n        (testing \"raw primitive array hints\"\n          (are [name type] (= (type array-types)\n                              (return-type (method-with-name name)))\n               \"returnsByteArray\"    :bytes\n               \"returnsCharArray\"    :chars\n               \"returnsShortArray\"   :shorts\n               \"returnsIntArray\"     :ints\n               \"returnsLongArray\"    :longs\n               \"returnsFloatArray\"   :floats\n               \"returnsDoubleArray\"  :doubles\n               \"returnsBooleanArray\" :booleans))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/generators.clj",
    "content": "(ns clojure.test-clojure.generators\n  (:require [clojure.data.generators :as gen])\n  (:refer-clojure :exclude [namespace]))\n\n(defn var-value-source\n  \"Generates a scalar suitable for an initial var value.\"\n  []\n  (let [v (gen/scalar)]\n    (if (symbol? v)\n      `(quote ~v)\n      v)))\n\n(defn var-source\n  [n]\n  `(def ~(symbol (str \"var\" n))\n     ~(var-value-source)))\n\n(defn record-source\n  [n]\n  (let [rname (str \"ExampleRecord\" \"-\" n)\n        fldct (gen/geometric 0.1)]\n    `(defrecord ~(symbol rname) ~(vec (map #(symbol (str \"f\" %)) (range fldct))))))\n\n(defn generate-namespaces\n  \"Returns a map with :nses, :vars, :records\"\n  [{:keys [nses vars-per-ns records-per-ns]}]\n  (let [nses (mapv #(create-ns (symbol (str \"clojure.generated.ns\" %)))\n                   (range nses))\n        _ (doseq [ns nses] (binding [*ns* ns] (refer 'clojure.core)))\n        make-in-ns (fn [ns src] (binding [*ns* ns] (eval src)))\n        vars (->> (mapcat\n                   (fn [ns]\n                     (map\n                      #(make-in-ns ns (var-source %))\n                      (range vars-per-ns)))\n                   nses)\n                  (into []))\n        records (->> (mapcat\n                      (fn [ns]\n                        (map\n                         #(make-in-ns ns (record-source %))\n                         (range records-per-ns)))\n                      nses)\n                     (into []))]\n    {:nses nses\n     :vars vars\n     :records records}))\n\n(def shared-generation\n  (delay (generate-namespaces {:nses 5 :vars-per-ns 5 :records-per-ns 5})))\n\n(defn namespace\n  []\n  (gen/rand-nth (:nses @shared-generation)))\n\n(defn var\n  []\n  (gen/rand-nth (:vars @shared-generation)))\n\n(defn record\n  []\n  (gen/rand-nth (:records @shared-generation)))\n\n(def keyword-pool\n  (delay\n   (binding [gen/*rnd* (java.util.Random. 42)]\n     (into [] (repeatedly 1000 gen/keyword)))))\n\n(defn keyword-from-pool\n  []\n  (gen/rand-nth @keyword-pool))\n\n(def symbol-pool\n  (delay\n   (binding [gen/*rnd* (java.util.Random. 42)]\n     (into [] (repeatedly 1000 gen/symbol)))))\n\n(defn symbol-from-pool\n  []\n  (gen/rand-nth @keyword-pool))\n\n(def ednable-scalars\n  [(constantly nil)\n   gen/byte\n   gen/long\n   gen/boolean\n   gen/printable-ascii-char\n   gen/string\n   symbol-from-pool\n   keyword-from-pool\n   gen/uuid\n   gen/date\n   gen/ratio\n   gen/bigint\n   gen/bigdec])\n\n(defn- call-through\n  \"Recursively call x until it doesn't return a function.\"\n  [x]\n  (if (fn? x)\n    (recur (x))\n    x))\n\n(defn ednable-scalar\n  []\n  (call-through (rand-nth ednable-scalars)))\n\n(def ednable-collections\n  [[gen/vec [ednable-scalars]]\n   [gen/set [ednable-scalars]]\n   [gen/hash-map [ednable-scalars ednable-scalars]]])\n\n(defn ednable-collection\n  []\n  (let [[coll args] (rand-nth ednable-collections)]\n    (apply coll (map rand-nth args))))\n\n(defn ednable\n  []\n  (gen/one-of ednable-scalar ednable-collection))\n\n(defn non-ednable\n  \"Generate something that can be printed with *print-dup*, but\n   cannot be read back via edn/read.\"\n  []\n  (gen/one-of namespace var))\n\n(defn dup-readable\n  \"Generate something that requires print-dup to be printed in\n   a roundtrippable way.\"\n  []\n  (gen/one-of namespace var))\n"
  },
  {
    "path": "test/clojure/test_clojure/java/io.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns clojure.test-clojure.java.io\n  (:use clojure.test clojure.java.io\n        [clojure.test-helper :only [platform-newlines]])\n  (:import (java.io File BufferedInputStream\n                    FileInputStream InputStreamReader InputStream\n                    FileOutputStream OutputStreamWriter OutputStream\n                    ByteArrayInputStream ByteArrayOutputStream)\n           (java.net URL URI Socket ServerSocket)))\n\n(defn temp-file\n  [prefix suffix]\n  (doto (File/createTempFile prefix suffix)\n    (.deleteOnExit)))\n\n;; does not work on IBM JDK\n#_(deftest test-spit-and-slurp\n  (let [f (temp-file \"clojure.java.io\" \"test\")\n        content (apply str (concat \"a\" (repeat 500 \"\\u226a\\ud83d\\ude03\")))]\n    (spit f content)\n    (is (= content (slurp f)))\n    ;; UTF-16 must be last for the following test\n    (doseq [enc [ \"UTF-8\" \"UTF-16BE\" \"UTF-16LE\" \"UTF-16\" ]]\n      (spit f content :encoding enc)\n      (is (= content (slurp f :encoding enc))))\n    (testing \"deprecated arity\"\n      (is (=\n           (platform-newlines \"WARNING: (slurp f enc) is deprecated, use (slurp f :encoding enc).\\n\")\n           (with-out-str\n             (is (= content (slurp f \"UTF-16\")))))))))\n\n(deftest test-streams-defaults\n  (let [f (temp-file \"clojure.java.io\" \"test-reader-writer\")\n        content \"testing\"]\n    (try\n      (is (thrown? Exception (reader (Object.))))\n      (is (thrown? Exception (writer (Object.))))\n\n      (are [write-to read-from] (= content (do\n                                             (spit write-to content :encoding \"UTF-8\")\n                                             (slurp read-from :encoding \"UTF-8\")))\n           f f\n           (.getAbsolutePath f) (.getAbsolutePath f)\n           (.toURL f) (.toURL f)\n           (.toURI f) (.toURI f)\n           (FileOutputStream. f) (FileInputStream. f)\n           (OutputStreamWriter. (FileOutputStream. f) \"UTF-8\") (reader f :encoding \"UTF-8\")\n           f (FileInputStream. f)\n           (writer f :encoding \"UTF-8\") (InputStreamReader. (FileInputStream. f) \"UTF-8\"))\n\n      (is (= content (slurp (.getBytes content \"UTF-8\"))))\n      (is (= content (slurp (.toCharArray content))))\n      (finally\n       (.delete f)))))\n\n(defn bytes-should-equal [byte-array-1 byte-array-2 msg]\n  (is (= @#'clojure.java.io/byte-array-type (class byte-array-1) (class byte-array-2)) msg)\n  (is (= (into []  byte-array-1) (into []  byte-array-2)) msg))\n\n(defn data-fixture\n  \"in memory fixture data for tests\"\n  [encoding]\n  (let [s (apply str (concat \"a\" (repeat 500 \"\\u226a\\ud83d\\ude03\")))\n        bs (.getBytes s encoding)\n        cs (.toCharArray s)\n        i (ByteArrayInputStream. bs)\n        ;; Make UTF-8 encoding explicit for the InputStreamReader and\n        ;; OutputStreamWriter, since some JVMs use a different default\n        ;; encoding.\n        r (InputStreamReader. i \"UTF-8\")\n        o (ByteArrayOutputStream.)\n        w (OutputStreamWriter. o \"UTF-8\")]\n    {:bs bs\n     :i i\n     :r r\n     :o o\n     :s s\n     :cs cs\n     :w w}))\n\n(deftest test-copy\n  (dorun\n   (for [{:keys [in out flush] :as test}\n         [{:in :i :out :o}\n          {:in :i :out :w}\n          {:in :r :out :o}\n          {:in :r :out :w}\n          {:in :cs :out :o}\n          {:in :cs :out :w}\n          {:in :bs :out :o}\n          {:in :bs :out :w}]\n         \n         opts\n         [{} {:buffer-size 16} {:buffer-size 256}]]\n     (let [{:keys [s o] :as d} (data-fixture \"UTF-8\")]\n       (apply copy (in d) (out d) (flatten (vec opts)))\n       #_(when (= out :w) (.flush (:w d)))\n       (.flush (out d))\n       (bytes-should-equal (.getBytes s \"UTF-8\")\n                           (.toByteArray o)\n                           (str \"combination \" test opts))))))\n;; does not work on IBM JDK\n#_(deftest test-copy-encodings\n  (doseq [enc [ \"UTF-8\" \"UTF-16\" \"UTF-16BE\" \"UTF-16LE\" ]]\n    (testing (str \"from inputstream \" enc \" to writer UTF-8\")\n      (let [{:keys [i s o w bs]} (data-fixture enc)]\n        (copy i w :encoding enc :buffer-size 16)\n        (.flush w)\n        (bytes-should-equal (.getBytes s \"UTF-8\") (.toByteArray o) \"\")))\n    (testing (str \"from reader UTF-8 to output-stream \" enc)\n      (let [{:keys [r o s]} (data-fixture \"UTF-8\")]\n        (copy r o :encoding enc :buffer-size 16)\n        (bytes-should-equal (.getBytes s enc) (.toByteArray o) \"\")))))\n\n(deftest test-as-file\n  (are [result input] (= result (as-file input))\n       (File. \"foo\") \"foo\"\n       (File. \"bar\") (File. \"bar\")\n       (File. \"baz\") (URL. \"file:baz\")\n       (File. \"bar+baz\") (URL. \"file:bar+baz\")\n       (File. \"bar baz qux\") (URL. \"file:bar%20baz%20qux\")\n       (File. \"quux\") (URI. \"file:quux\")\n       (File. \"abcíd/foo.txt\") (URL. \"file:abc%c3%add/foo.txt\")\n       nil nil))\n\n(deftest test-resources-with-spaces\n  (let [file-with-spaces (temp-file \"test resource 2\" \"txt\")\n        url (as-url (.getParentFile file-with-spaces))\n        loader (java.net.URLClassLoader. (into-array [url]))\n        r (resource (.getName file-with-spaces) loader)]\n    (is (= r (as-url file-with-spaces)))\n    (spit r \"foobar\")\n    (is (= \"foobar\" (slurp r)))))\n\n(deftest test-file\n  (are [result args] (= (File. result) (apply file args))\n       \"foo\" [\"foo\"]\n       \"foo/bar\" [\"foo\" \"bar\"]\n       \"foo/bar/baz\" [\"foo\" \"bar\" \"baz\"]))\n(deftest test-as-url\n  (are [file-part input] (= (URL. (str \"file:\" file-part)) (as-url input))\n       \"foo\" \"file:foo\"\n       \"baz\" (URL. \"file:baz\")\n       \"quux\" (URI. \"file:quux\"))\n  (is (nil? (as-url nil))))\n\n(deftest test-delete-file\n  (let [file (temp-file \"test\" \"deletion\")\n        not-file (File. (str (java.util.UUID/randomUUID)))]\n    (delete-file (.getAbsolutePath file))\n    (is (not (.exists file)))\n    (is (thrown? java.io.IOException (delete-file not-file)))\n    (is (= :silently (delete-file not-file :silently)))))\n\n(deftest test-as-relative-path\n  (testing \"strings\"\n    (is (= \"foo\" (as-relative-path \"foo\"))))\n  (testing \"absolute path strings are forbidden\"\n    (is (thrown? IllegalArgumentException (as-relative-path (.getAbsolutePath (File. \"baz\"))))))\n  (testing \"relative File paths\"\n    (is (= \"bar\" (as-relative-path (File. \"bar\")))))\n  (testing \"absolute File paths are forbidden\"\n    (is (thrown? IllegalArgumentException (as-relative-path (File. (.getAbsolutePath (File. \"quux\"))))))))\n\n(defn stream-should-have [stream expected-bytes msg]\n  (let [actual-bytes (byte-array (alength expected-bytes))]\n    (.read stream actual-bytes)\n    (is (= -1 (.read stream)) (str msg \" : should be end of stream\"))\n    (is (= (seq expected-bytes) (seq actual-bytes)) (str msg \" : byte arrays should match\"))))\n\n(deftest test-input-stream\n  (let [file (temp-file \"test-input-stream\" \"txt\")\n        content (apply str (concat \"a\" (repeat 500 \"\\u226a\\ud83d\\ude03\")))\n        bytes (.getBytes content \"UTF-8\")]\n    (spit file content)\n    (doseq [[expr msg]\n            [[file File]\n             [(FileInputStream. file) FileInputStream]\n             [(BufferedInputStream. (FileInputStream. file)) BufferedInputStream]\n             [(.. file toURI) URI]\n             [(.. file toURI toURL) URL]\n             [(.. file toURI toURL toString) \"URL as String\"]\n             [(.. file toString) \"File as String\"]]]\n      (with-open [s (input-stream expr)]\n        (stream-should-have s bytes msg)))))\n\n(deftest test-streams-buffering\n  (let [data (.getBytes \"\")]\n    (is (instance? java.io.BufferedReader (reader data)))\n    (is (instance? java.io.BufferedWriter (writer (java.io.ByteArrayOutputStream.))))\n    (is (instance? java.io.BufferedInputStream (input-stream data)))\n    (is (instance? java.io.BufferedOutputStream (output-stream (java.io.ByteArrayOutputStream.))))))\n\n(deftest test-resource\n  (is (nil? (resource \"non/existent/resource\")))\n  (is (instance? URL (resource \"clojure/core.clj\")))\n  (let [file (temp-file \"test-resource\" \"txt\")\n        url (as-url (.getParentFile file))\n        loader (java.net.URLClassLoader. (into-array [url]))]\n    (is (nil? (resource \"non/existent/resource\" loader)))\n    (is (instance? URL (resource (.getName file) loader)))))\n\n(deftest test-make-parents\n  (let [tmp (System/getProperty \"java.io.tmpdir\")]\n    (delete-file (file tmp \"test-make-parents\" \"child\" \"grandchild\") :silently)\n    (delete-file (file tmp \"test-make-parents\" \"child\") :silently)\n    (delete-file (file tmp \"test-make-parents\") :silently)\n    (make-parents tmp \"test-make-parents\" \"child\" \"grandchild\")\n    (is (.isDirectory (file tmp \"test-make-parents\" \"child\")))\n    (is (not (.isDirectory (file tmp \"test-make-parents\" \"child\" \"grandchild\"))))\n    (delete-file (file tmp \"test-make-parents\" \"child\"))\n    (delete-file (file tmp \"test-make-parents\"))))\n\n(deftest test-socket-iofactory\n  (let [server-socket (ServerSocket. 0)\n        client-socket (Socket. \"localhost\" (.getLocalPort server-socket))]\n    (try\n      (is (instance? InputStream (input-stream client-socket)))\n      (is (instance? OutputStream (output-stream client-socket)))\n      (finally (.close server-socket)\n               (.close client-socket)))))\n"
  },
  {
    "path": "test/clojure/test_clojure/java/javadoc.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns clojure.test-clojure.java.javadoc\n  (:use clojure.test\n\t[clojure.java.javadoc :as j])\n  (:import (java.io File)))\n\n(deftest javadoc-url-test\n  (testing \"for a core api\"\n    (binding [*feeling-lucky* false]\n      (are [x y] (= x (#'j/javadoc-url y))\n           nil \"foo.Bar\"\n           (str *core-java-api* \"java/lang/String.html\") \"java.lang.String\")))\n  (testing \"for a remote javadoc\"\n    (binding [*remote-javadocs* (ref (sorted-map \"java.\" \"http://example.com/\"))]\n      (is (= \"http://example.com/java/lang/Number.html\" (#'j/javadoc-url \"java.lang.Number\"))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/java/shell.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns clojure.test-clojure.java.shell\n  (:use clojure.test\n\t[clojure.java.shell :as sh])\n  (:import (java.io File)))\n\n(def platform-enc (.name (java.nio.charset.Charset/defaultCharset)))\n(def default-enc \"UTF-8\")\n\n(deftest test-parse-args\n  (are [x y] (= x y)\n       [[] {:in-enc default-enc :out-enc default-enc :dir nil :env nil}] (#'sh/parse-args [])\n       [[\"ls\"] {:in-enc default-enc :out-enc default-enc :dir nil :env nil}] (#'sh/parse-args [\"ls\"])\n       [[\"ls\" \"-l\"] {:in-enc default-enc :out-enc default-enc :dir nil :env nil}] (#'sh/parse-args [\"ls\" \"-l\"])\n       [[\"ls\"] {:in-enc default-enc :out-enc \"ISO-8859-1\" :dir nil :env nil}] (#'sh/parse-args [\"ls\" :out-enc \"ISO-8859-1\"])\n       [[] {:in-enc platform-enc :out-enc platform-enc :dir nil :env nil}] (#'sh/parse-args [:in-enc platform-enc :out-enc platform-enc])))\n  \n(deftest test-with-sh-dir\n  (are [x y] (= x y)\n    nil *sh-dir*\n    \"foo\" (with-sh-dir \"foo\" *sh-dir*)))\n\n(deftest test-with-sh-env\n  (are [x y] (= x y)\n    nil *sh-env*\n    {:KEY \"VAL\"} (with-sh-env {:KEY \"VAL\"} *sh-env*)))\n\n(deftest test-as-env-strings\n  (are [x y] (= x y)\n    nil (#'sh/as-env-strings nil)\n    [\"FOO=BAR\"] (seq (#'sh/as-env-strings {\"FOO\" \"BAR\"}))\n    [\"FOO_SYMBOL=BAR\"] (seq (#'sh/as-env-strings {'FOO_SYMBOL \"BAR\"}))\n    [\"FOO_KEYWORD=BAR\"] (seq (#'sh/as-env-strings {:FOO_KEYWORD \"BAR\"}))))\n\n"
  },
  {
    "path": "test/clojure/test_clojure/java_interop.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka\n\n\n(ns clojure.test-clojure.java-interop\n  (:use clojure.test))\n\n; http://clojure.org/java_interop\n; http://clojure.org/compilation\n\n\n(deftest test-dot\n  ; (.instanceMember instance args*)\n  (are [x] (= x \"FRED\")\n      (.toUpperCase \"fred\")\n      (. \"fred\" toUpperCase)\n      (. \"fred\" (toUpperCase)) )\n\n  (are [x] (= x true)\n      (.startsWith \"abcde\" \"ab\")\n      (. \"abcde\" startsWith \"ab\")\n      (. \"abcde\" (startsWith \"ab\")) )\n\n  ; (.instanceMember Classname args*)\n  (are [x] (= x \"java.lang.String\")\n      (.getName String)\n      (. (identity String) getName)\n      (. (identity String) (getName)) )\n\n  ; (Classname/staticMethod args*)\n  (are [x] (= x 7)\n      (Math/abs -7)\n      (. Math abs -7)\n      (. Math (abs -7)) )\n\n  ; (. target -prop)\n  (let [p (java.awt.Point. 1 2)]\n    (are [x y] (= x y)\n       1 (.-x p)\n       2 (.-y p)\n       1 (. p -x)\n       2 (. p -y)\n       1 (. (java.awt.Point. 1 2) -x)\n       2 (. (java.awt.Point. 1 2) -y)))\n\n  ; Classname/staticField\n  (are [x] (= x 2147483647)\n      Integer/MAX_VALUE\n      (. Integer MAX_VALUE) ))\n\n(definterface I (a []))\n(deftype T [a] I (a [_] \"method\"))\n\n(deftest test-reflective-field-name-ambiguous\n  (let [t (->T \"field\")]\n    (is (= \"method\" (. ^T t a)))\n    (is (= \"field\" (. ^T t -a)))\n    (is (= \"method\" (. t a)))\n    (is (= \"field\" (. t -a)))\n    (is (thrown? IllegalArgumentException (. t -BOGUS)))))\n\n(deftest test-double-dot\n  (is (= (.. System (getProperties) (get \"os.name\"))\n         (. (. System (getProperties)) (get \"os.name\")))))\n\n\n(deftest test-doto\n  (let [m (doto (new java.util.HashMap)\n            (.put \"a\" 1)\n            (.put \"b\" 2))]\n    (are [x y] (= x y)\n        (class m) java.util.HashMap\n        m {\"a\" 1 \"b\" 2} )))\n\n\n(deftest test-new\n  ; Integer\n  (are [expr cls value] (and (= (class expr) cls)\n                            (= expr value))\n      (new java.lang.Integer 42) java.lang.Integer 42\n      (java.lang.Integer. 123) java.lang.Integer 123 )\n\n  ; Date\n  (are [x] (= (class x) java.util.Date)\n      (new java.util.Date)\n      (java.util.Date.) ))\n\n\n(deftest test-instance?\n  ; evaluation\n  (are [x y] (= x y)\n      (instance? java.lang.Integer (+ 1 2)) false\n      (instance? java.lang.Long (+ 1 2)) true )\n\n  ; different types\n  (are [type literal] (instance? literal type)\n      1   java.lang.Long\n      1.0 java.lang.Double\n      1M  java.math.BigDecimal\n      \\a  java.lang.Character\n      \"a\" java.lang.String )\n\n  ; it is a Long, nothing else\n  (are [x y] (= (instance? x 42) y)\n      java.lang.Integer false\n      java.lang.Long true\n      java.lang.Character false\n      java.lang.String false )\n\n  ; test compiler macro\n  (is (let [Long String] (instance? Long \"abc\")))\n  (is (thrown? clojure.lang.ArityException (instance? Long))))\n\n; set!\n\n; memfn\n\n\n(comment\n  (deftest test-bean\n    (let [b (bean java.awt.Color/black)]\n      (are [x y] (= x y)\n           (map? b) true\n\n           (:red b) 0\n           (:green b) 0\n           (:blue b) 0\n           (:RGB b) -16777216\n\n           (:alpha b) 255\n           (:transparency b) 1\n\n           (:missing b) nil\n           (:missing b :default) :default\n           (get b :missing) nil\n           (get b :missing :default) :default\n\n           (:class b) java.awt.Color ))))\n\n(comment\n(deftest test-iterable-bean\n  (is (.iterator ^Iterable (bean (java.util.Date.))))\n  (is (hash (bean (java.util.Date.))))))\n\n; proxy, proxy-super\n\n(deftest test-proxy-chain\n  (testing \"That the proxy functions can chain\"\n    (are [x y] (= x y)\n        (-> (get-proxy-class Object)\n            construct-proxy\n            (init-proxy {})\n            (update-proxy {\"toString\" (fn [_] \"chain chain chain\")})\n            str)\n        \"chain chain chain\"\n\n        (-> (proxy [Object] [] (toString [] \"superfuzz bigmuff\"))\n            (update-proxy {\"toString\" (fn [_] \"chain chain chain\")})\n            str)\n        \"chain chain chain\")))\n\n\n(deftest test-bases\n  (are [x y] (= x y)\n      (bases java.lang.Math)\n        (list java.lang.Object)\n      (bases java.util.Collection)\n        (list java.lang.Iterable)\n      (bases java.lang.Object)\n        nil\n      (bases java.lang.Comparable)\n        nil\n      (bases java.lang.Integer)\n        (list java.lang.Number java.lang.Comparable) ))\n\n(deftest test-supers\n  (are [x y] (= x y)\n      (supers java.lang.Math)\n        #{java.lang.Object}\n      (supers java.lang.Integer)\n        #{java.lang.Number java.lang.Object\n          java.lang.Comparable java.io.Serializable} ))\n\n(deftest test-proxy-super\n  (let [d (proxy [java.util.BitSet] []\n            (flip [bitIndex]\n              (try\n                (proxy-super flip bitIndex)\n                (catch IndexOutOfBoundsException e\n                  (throw (IllegalArgumentException. \"replaced\"))))))]\n    ;; normal call\n    (is (nil? (.flip d 0)))\n    ;; exception should use proxied form and return IllegalArg\n    (is (thrown? IllegalArgumentException (.flip d -1)))\n    ;; same behavior on second call\n    (is (thrown? IllegalArgumentException (.flip d -1)))))\n\n; Arrays: [alength] aget aset [make-array to-array into-array to-array-2d aclone]\n;   [float-array, int-array, etc]\n;   amap, areduce\n\n(defmacro deftest-type-array [type-array type]\n  `(deftest ~(symbol (str \"test-\" type-array))\n      ; correct type\n      #_(is (= (class (first (~type-array [1 2]))) (class (~type 1))))\n\n      ; given size (and empty)\n      (are [x] (and (= (alength (~type-array x)) x)\n                    (= (vec (~type-array x)) (repeat x 0)))\n          0 1 5 )\n\n      ; copy of a sequence\n      (are [x] (and (= (alength (~type-array x)) (count x))\n                    (= (vec (~type-array x)) x))\n          []\n          [1]\n          [1 -2 3 0 5] )\n\n      ; given size and init-value\n      (are [x] (and (= (alength (~type-array x 42)) x)\n                    (= (vec (~type-array x 42)) (repeat x 42)))\n          0 1 5 )\n\n      ; given size and init-seq\n      (are [x y z] (and (= (alength (~type-array x y)) x)\n                        (= (vec (~type-array x y)) z))\n          0 [] []\n          0 [1] []\n          0 [1 2 3] []\n          1 [] [0]\n          1 [1] [1]\n          1 [1 2 3] [1]\n          5 [] [0 0 0 0 0]\n          5 [1] [1 0 0 0 0]\n          5 [1 2 3] [1 2 3 0 0]\n          5 [1 2 3 4 5] [1 2 3 4 5]\n          5 [1 2 3 4 5 6 7] [1 2 3 4 5] )))\n\n(deftest-type-array int-array int)\n(deftest-type-array long-array long)\n;todo, fix, test broken for float/double, should compare to 1.0 2.0 etc\n#_(deftest-type-array float-array float)\n#_(deftest-type-array double-array double)\n\n; separate test for exceptions (doesn't work with above macro...)\n(deftest test-type-array-exceptions\n  (are [x] (thrown? NegativeArraySizeException x)\n       (int-array -1)\n       (long-array -1)\n       (float-array -1)\n       (double-array -1) ))\n\n\n(deftest test-make-array\n  ; negative size\n  (is (thrown? NegativeArraySizeException (make-array Integer -1)))\n\n  ; one-dimensional\n  (are [x] (= (alength (make-array Integer x)) x)\n      0 1 5 )\n\n  (let [a (make-array Long 5)]\n    (aset a 3 42)\n    (are [x y] (= x y)\n        (aget a 3) 42\n        (class (aget a 3)) Long ))\n\n  ; multi-dimensional\n  (let [a (make-array Long 3 2 4)]\n    (aset a 0 1 2 987)\n    (are [x y] (= x y)\n        (alength a) 3\n        (alength (first a)) 2\n        (alength (first (first a))) 4\n\n        (aget a 0 1 2) 987\n        (class (aget a 0 1 2)) Long )))\n\n\n(deftest test-to-array\n  (let [v [1 \"abc\" :kw \\c []]\n        a (to-array v)]\n    (are [x y] (= x y)\n        ; length\n        (alength a) (count v)\n\n        ; content\n        (vec a) v\n        (class (aget a 0)) (class (nth v 0))\n        (class (aget a 1)) (class (nth v 1))\n        (class (aget a 2)) (class (nth v 2))\n        (class (aget a 3)) (class (nth v 3))\n        (class (aget a 4)) (class (nth v 4)) ))\n\n  ; different kinds of collections\n  (are [x] (and (= (alength (to-array x)) (count x))\n                (= (vec (to-array x)) (vec x)))\n      ()\n      '(1 2)\n      []\n      [1 2]\n      (sorted-set)\n      (sorted-set 1 2)\n\n      (int-array 0)\n      (int-array [1 2 3])\n\n      (to-array [])\n      (to-array [1 2 3]) ))\n\n(defn queue [& contents]\n  (apply conj (clojure.lang.PersistentQueue/EMPTY) contents))\n\n(defn array-typed-equals [expected actual]\n  (and (= (class expected) (class actual))\n       (java.util.Arrays/equals expected actual)))\n\n(defmacro test-to-passed-array-for [collection-type]\n  `(deftest ~(symbol (str \"test-to-passed-array-for-\" collection-type))\n     (let [string-array# (make-array String 5)\n           shorter# (~collection-type \"1\" \"2\" \"3\")\n           same-length# (~collection-type \"1\" \"2\" \"3\" \"4\" \"5\")\n           longer# (~collection-type \"1\" \"2\" \"3\" \"4\" \"5\" \"6\")]\n       (are [expected actual] (array-typed-equals expected actual)\n            (into-array String [\"1\" \"2\" \"3\" nil nil]) (.toArray shorter# string-array#)\n            (into-array String [\"1\" \"2\" \"3\" \"4\" \"5\"]) (.toArray same-length# string-array#)\n            (into-array String [\"1\" \"2\" \"3\" \"4\" \"5\" \"6\"]) (.toArray longer# string-array#)))))\n\n\n(test-to-passed-array-for vector)\n(test-to-passed-array-for list)\n;;(test-to-passed-array-for hash-set)\n(test-to-passed-array-for queue)\n\n(deftest test-into-array\n  ; compatible types only\n  (is (thrown? IllegalArgumentException (into-array [1 \"abc\" :kw])))\n  (is (thrown? IllegalArgumentException (into-array [1.2 4])))\n  (is (thrown? IllegalArgumentException (into-array [(byte 2) (short 3)])))\n  (is (thrown? IllegalArgumentException (into-array Byte/TYPE [100000000000000])))\n\n  ; simple case\n  (let [v [1 2 3 4 5]\n        a (into-array v)]\n    (are [x y] (= x y)\n        (alength a) (count v)\n        (vec a) v\n        (class (first a)) (class (first v)) ))\n\n  (is (= \\a (aget (into-array Character/TYPE [\\a \\b \\c]) 0)))\n\n  (let [types [Integer/TYPE\n               Byte/TYPE\n               Float/TYPE\n               Short/TYPE\n               Double/TYPE\n               Long/TYPE]\n        values [(byte 2) (short 3) (int 4) 5]]\n    (for [t types]\n      (let [a (into-array t values)]\n        (is (== (aget a 0) 2))\n        (is (== (aget a 1) 3))\n        (is (== (aget a 2) 4))\n        (is (== (aget a 3) 5)))))\n\n  ; different kinds of collections\n  (are [x] (and (= (alength (into-array x)) (count x))\n                (= (vec (into-array x)) (vec x))\n                (= (alength (into-array Long/TYPE x)) (count x))\n                (= (vec (into-array Long/TYPE x)) (vec x)))\n      ()\n      '(1 2)\n      []\n      [1 2]\n      (sorted-set)\n      (sorted-set 1 2)\n\n      (int-array 0)\n      (int-array [1 2 3])\n\n      (to-array [])\n      (to-array [1 2 3]) ))\n\n\n(deftest test-to-array-2d\n  ; needs to be a collection of collection(s)\n  (is (thrown? Exception (to-array-2d [1 2 3])))\n\n  ; ragged array\n  (let [v [[1] [2 3] [4 5 6]]\n        a (to-array-2d v)]\n    (are [x y] (= x y)\n        (alength a) (count v)\n        (alength (aget a 0)) (count (nth v 0))\n        (alength (aget a 1)) (count (nth v 1))\n        (alength (aget a 2)) (count (nth v 2))\n\n        (vec (aget a 0)) (nth v 0)\n        (vec (aget a 1)) (nth v 1)\n        (vec (aget a 2)) (nth v 2) ))\n\n  ; empty array\n  (let [a (to-array-2d [])]\n    (are [x y] (= x y)\n        (alength a) 0\n        (vec a) [] )))\n\n\n(deftest test-alength\n  (are [x] (= (alength x) 0)\n      (int-array 0)\n      (long-array 0)\n      (float-array 0)\n      (double-array 0)\n      (boolean-array 0)\n      (byte-array 0)\n      (char-array 0)\n      (short-array 0)\n      (make-array Integer/TYPE 0)\n      (to-array [])\n      (into-array [])\n      (to-array-2d []) )\n\n  (are [x] (= (alength x) 1)\n      (int-array 1)\n      (long-array 1)\n      (float-array 1)\n      (double-array 1)\n      (boolean-array 1)\n      (byte-array 1)\n      (char-array 1)\n      (short-array 1)\n      (make-array Integer/TYPE 1)\n      (to-array [1])\n      (into-array [1])\n      (to-array-2d [[1]]) )\n\n  (are [x] (= (alength x) 3)\n      (int-array 3)\n      (long-array 3)\n      (float-array 3)\n      (double-array 3)\n      (boolean-array 3)\n      (byte-array 3)\n      (char-array 3)\n      (short-array 3)\n      (make-array Integer/TYPE 3)\n      (to-array [1 \"a\" :k])\n      (into-array [1 2 3])\n      (to-array-2d [[1] [2 3] [4 5 6]]) ))\n\n\n(deftest test-aclone\n  ; clone all arrays except 2D\n  (are [x] (and (= (alength (aclone x)) (alength x))\n                (= (vec (aclone x)) (vec x)))\n      (int-array 0)\n      (long-array 0)\n      (float-array 0)\n      (double-array 0)\n      (boolean-array 0)\n      (byte-array 0)\n      (char-array 0)\n      (short-array 0)\n      (make-array Integer/TYPE 0)\n      (to-array [])\n      (into-array [])\n\n      (int-array [1 2 3])\n      (long-array [1 2 3])\n      (float-array [1 2 3])\n      (double-array [1 2 3])\n      (boolean-array [true false])\n      (byte-array [(byte 1) (byte 2)])\n      (byte-array [1 2])\n      (byte-array 2 [1 2])\n      (char-array [\\a \\b \\c])\n      (short-array [(short 1) (short 2)])\n      (short-array [1 2])\n      (short-array 2 [1 2])\n      (make-array Integer/TYPE 3)\n      (to-array [1 \"a\" :k])\n      (into-array [1 2 3]) )\n\n  ; clone 2D\n  (are [x] (and (= (alength (aclone x)) (alength x))\n                (= (map alength (aclone x)) (map alength x))\n                (= (map vec (aclone x)) (map vec x)))\n      (to-array-2d [])\n      (to-array-2d [[1] [2 3] [4 5 6]]) ))\n\n\n; Type Hints, *warn-on-reflection*\n;   #^ints, #^floats, #^longs, #^doubles\n\n; Coercions: [int, long, float, double, char, boolean, short, byte]\n;   num\n;   ints/longs/floats/doubles\n\n(deftest test-boolean\n  (are [x y] (and (instance? java.lang.Boolean (boolean x))\n                  (= (boolean x) y))\n      nil false\n      false false\n      true true\n\n      0 true\n      1 true\n      () true\n      [1] true\n\n      \"\" true\n      \\space true\n      :kw true ))\n\n\n(deftest test-char\n  ; int -> char\n  (is (instance? java.lang.Character (char 65)))\n\n  ; char -> char\n  (is (instance? java.lang.Character (char \\a)))\n  (is (= (char \\a) \\a)))\n\n;; Note: More coercions in numbers.clj\n"
  },
  {
    "path": "test/clojure/test_clojure/keywords.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n(ns clojure.test-clojure.keywords\n  (:use clojure.test))\n\n(let [this-ns (str (.name *ns*))]\n  (deftest test-find-keyword\n    :foo\n    ::foo\n    (let [absent-keyword-sym (gensym \"absent-keyword-sym\")]\n      (are [result lookup] (= result (find-keyword lookup))\n           :foo :foo\n           :foo 'foo\n           :foo \"foo\"\n           nil absent-keyword-sym\n           nil (str absent-keyword-sym))\n      (are [result lookup] (= result (find-keyword this-ns lookup))\n           ::foo \"foo\"\n           nil (str absent-keyword-sym)))))\n"
  },
  {
    "path": "test/clojure/test_clojure/logic.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka\n\n;;\n;;  Created 1/29/2009\n\n(ns clojure.test-clojure.logic\n  (:use clojure.test\n        [clojure.test-helper :only (exception)]))\n\n\n;; *** Tests ***\n\n(deftest test-if\n  ; true/false/nil\n  (are [x y] (= x y)\n      (if true :t) :t\n      (if true :t :f) :t\n      (if true :t (exception)) :t\n\n      (if false :t) nil\n      (if false :t :f) :f\n      (if false (exception) :f) :f\n\n      (if nil :t) nil\n      (if nil :t :f) :f\n      (if nil (exception) :f) :f )\n\n  ; zero/empty is true\n  (are [x] (= (if x :t :f) :t)\n      (byte 0)\n      (short 0)\n      (int 0)\n      (long 0)\n      (bigint 0)\n      (float 0)\n      (double 0)\n      (bigdec 0)\n\n      0/2\n      \"\"\n      #\"\"\n      (symbol \"\")\n\n      ()\n      []\n      {}\n      #{}\n      (into-array []) )\n\n  ; anything except nil/false is true\n  (are [x]  (= (if x :t :f) :t)\n      (byte 2)\n      (short 2)\n      (int 2)\n      (long 2)\n      (bigint 2)\n      (float 2)\n      (double 2)\n      (bigdec 2)\n\n      2/3\n      \\a\n      \"abc\"\n      #\"a*b\"\n      'abc\n      :kw\n\n      '(1 2)\n      [1 2]\n      {:a 1 :b 2}\n      #{1 2}\n      (into-array [1 2])\n\n      (new java.util.Date) ))\n\n\n(deftest test-nil-punning\n  (are [x y]  (= (if x :no :yes) y)\n    (first []) :yes\n    (next [1]) :yes\n    (rest [1]) :no\n\n    (butlast [1]) :yes\n\n    (seq nil) :yes\n    (seq []) :yes\n\n    (sequence nil) :no\n    (sequence []) :no\n\n    (lazy-seq nil) :no\n    (lazy-seq []) :no\n\n    (filter #(> % 10) [1 2 3]) :no\n    (map identity []) :no\n    (apply concat []) :no\n\n    (concat) :no\n    (concat []) :no\n\n    (reverse nil) :no\n    (reverse []) :no\n\n    (sort nil) :no\n    (sort []) :no ))\n\n\n(deftest test-and\n  (are [x y] (= x y)\n      (and) true\n      (and true) true\n      (and nil) nil\n      (and false) false\n\n      (and true nil) nil\n      (and true false) false\n\n      (and 1 true :kw 'abc \"abc\") \"abc\"\n\n      (and 1 true :kw nil 'abc \"abc\") nil\n      (and 1 true :kw nil (exception) 'abc \"abc\") nil\n\n      (and 1 true :kw 'abc \"abc\" false) false\n      (and 1 true :kw 'abc \"abc\" false (exception)) false ))\n\n\n(deftest test-or\n  (are [x y] (= x y)\n      (or) nil\n      (or true) true\n      (or nil) nil\n      (or false) false\n\n      (or nil false true) true\n      (or nil false 1 2) 1\n      (or nil false \"abc\" :kw) \"abc\"\n\n      (or false nil) nil\n      (or nil false) false\n      (or nil nil nil false) false\n\n      (or nil true false) true\n      (or nil true (exception) false) true\n      (or nil false \"abc\" (exception)) \"abc\" ))\n\n\n(deftest test-not\n;  (is (thrown? IllegalArgumentException (not)))\n  (are [x] (= (not x) true)\n      nil\n      false )\n  (are [x]  (= (not x) false)\n      true\n\n      ; numbers\n      0\n      0.0\n      42\n      1.2\n      0/2\n      2/3\n\n      ; characters\n      \\space\n      \\tab\n      \\a\n\n      ; strings\n      \"\"\n      \"abc\"\n\n      ; regexes\n      #\"\"\n      #\"a*b\"\n\n      ; symbols\n      (symbol \"\")\n      'abc\n\n      ; keywords\n      :kw\n\n      ; collections/arrays\n      ()\n      '(1 2)\n      []\n      [1 2]\n      {}\n      {:a 1 :b 2}\n      #{}\n      #{1 2}\n      (into-array [])\n      (into-array [1 2])\n\n      ; Java objects\n      (new java.util.Date) ))\n\n(deftest test-some?\n  (are [expected x] (= expected (some? x))\n       false nil\n       true false\n       true 0\n       true \"abc\"\n       true []))\n"
  },
  {
    "path": "test/clojure/test_clojure/macros.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka\n\n(ns clojure.test-clojure.macros\n  (:use clojure.test))\n\n; http://clojure.org/macros\n\n; ->\n; defmacro definline macroexpand-1 macroexpand\n\n\n;; -> and ->> should not be dependent on the meaning of their arguments\n\n(defmacro c\n  [arg]\n  (if (= 'b (first arg))\n    :foo\n    :bar))\n\n(deftest ->test\n  (let [a 2, b identity]\n    (is (= (-> a b c)\n           (c (b a))))))\n\n(deftest ->>test\n  (let [a 2, b identity]\n    (is (= (->> a b c)\n           (c (b a))))))\n\n(deftest ->metadata-test\n  (testing \"a trivial form\"\n    (is (= {:hardy :har :har :-D}\n           (meta (macroexpand-1 (list `-> (with-meta\n                                            'quoted-symbol\n                                            {:hardy :har :har :-D})))))))\n  (testing \"a nontrivial form\"\n    (let [a (with-meta 'a {:foo :bar})\n          b (with-meta '(b c d) {:bar :baz})\n          e (with-meta 'e {:baz :quux})\n          expanded (macroexpand-1 (list `-> a b e))]\n      (is (= expanded '(e (b a c d))))\n      (is (= {:baz :quux} (meta (first expanded))))\n      (is (= {:bar :baz} (meta (second expanded))))\n      (is (= {:foo :bar} (meta (second (second expanded))))))))\n\n\n(deftest ->>metadata-test\n  (testing \"a trivial form\"\n    (is (= {:hardy :har :har :-D}\n           (meta (macroexpand-1 (list `->> (with-meta\n                                             'quoted-symbol\n                                             {:hardy :har :har :-D})))))))\n  (testing \"a non-trivial form\"\n    (let [a (with-meta 'a {:foo :bar})\n          b (with-meta '(b c d) {:bar :baz})\n          e (with-meta 'e {:baz :quux})\n          expanded (macroexpand-1 (list `->> a b e))]\n      (is (= expanded '(e (b c d a))))\n      (is (= {:baz :quux} (meta (first expanded))))\n      (is (= {:bar :baz} (meta (second expanded))))\n      (is (= {:foo :bar} (meta (last (second expanded))))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/main.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Stuart Halloway\n\n\n(ns clojure.test-clojure.main\n  (:use clojure.test\n        [clojure.test-helper :only [platform-newlines]])\n  (:require [clojure.main :as main]))\n\n(deftest eval-opt\n  (testing \"evals and prints forms\"\n    (is (= (platform-newlines \"2\\n4\\n\") (with-out-str (#'clojure.main/eval-opt \"(+ 1 1) (+ 2 2)\")))))\n\n  (testing \"skips printing nils\"\n    (is (= (platform-newlines \":a\\n:c\\n\") (with-out-str (#'clojure.main/eval-opt \":a nil :c\")))))\n\n  (testing \"does not block access to *in* (#299)\"\n    (with-in-str \"(+ 1 1)\"\n      (is (= (platform-newlines \"(+ 1 1)\\n\") (with-out-str (#'clojure.main/eval-opt \"(read)\")))))))\n\n(defmacro with-err-str\n  \"Evaluates exprs in a context in which *err* is bound to a fresh\n  StringWriter.  Returns the string created by any nested printing\n  calls.\"\n  [& body]\n  `(let [s# (new java.io.StringWriter)\n         p# (new java.io.PrintWriter s#)]\n     (binding [*err* p#]\n       ~@body\n       (str s#))))\n\n(defn run-repl-and-return-err\n  \"Run repl, swallowing stdout and returing stderr.\"\n  [in-str]\n  (with-err-str\n    (with-out-str\n      (with-in-str in-str\n        (main/repl)))))\n\n;argh - test fragility, please fix\n#_(deftest repl-exception-safety\n  (testing \"catches and prints exception on bad equals\"\n    (is (re-matches #\"java\\.lang\\.NullPointerException\\r?\\n\"\n           (run-repl-and-return-err\n            \"(proxy [Object] [] (equals [o] (.toString nil)))\")))))\n"
  },
  {
    "path": "test/clojure/test_clojure/metadata.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Authors: Stuart Halloway, Frantisek Sodomka\n\n(ns clojure.test-clojure.metadata\n  (:use clojure.test\n        [clojure.test-helper :only (eval-in-temp-ns)])\n  (:require [clojure.set :as set]))\n\n(def public-namespaces\n  '[clojure.core\n    clojure.pprint\n    ;clojure.inspector\n    clojure.set\n    clojure.stacktrace\n    clojure.test\n    clojure.walk\n    clojure.xml\n    clojure.zip\n    clojure.java.io\n    ;clojure.java.browse\n    ;clojure.java.javadoc\n    ;clojure.java.shell\n    clojure.string\n    clojure.data])\n\n(doseq [ns public-namespaces]\n  (require ns))\n\n(def public-vars\n  (mapcat #(vals (ns-publics %)) public-namespaces))\n\n(def public-vars-with-docstrings\n  (filter (comp :doc meta) public-vars))\n\n(def public-vars-with-docstrings-not-generated\n  (remove #(re-find #\"^->[A-Z]\" (name (.sym %))) public-vars-with-docstrings))\n\n(deftest public-vars-with-docstrings-have-added\n  (is (= [] (remove (comp :added meta) public-vars-with-docstrings-not-generated))))\n\n(deftest interaction-of-def-with-metadata\n  (testing \"initial def sets metadata\"\n    (let [v (eval-in-temp-ns\n             (def ^{:a 1} foo 0)\n             #'foo)]\n      (is (= 1 (-> v meta :a)))))\n  #_(testing \"subsequent declare doesn't overwrite metadata\"\n    (let [v (eval-in-temp-ns\n             (def ^{:b 2} bar 0)\n             (declare bar)\n             #'bar)]\n      (is (= 2 (-> v meta :b))))\n    (testing \"when compiled\"\n      (let [v (eval-in-temp-ns\n               (def ^{:c 3} bar 0)\n               (defn declare-bar []\n                 (declare bar))\n               (declare-bar)\n               #'bar)]\n        (is (= 3 (-> v meta :c))))))\n  (testing \"subsequent def with init-expr *does* overwrite metadata\"\n    (let [v (eval-in-temp-ns\n             (def ^{:d 4} quux 0)\n             (def quux 1)\n             #'quux)]\n      (is (nil? (-> v meta :d))))\n    (testing \"when compiled\"\n      (let [v (eval-in-temp-ns\n               (def ^{:e 5} quux 0)\n               (defn def-quux []\n                 (def quux 1))\n               (def-quux)\n               #'quux)]\n        (is (nil? (-> v meta :e))))))\n  (testing \"IllegalArgumentException should not be thrown\"\n    (testing \"when defining var whose value is calculated with a primitive fn.\"\n      (testing \"This case fails without a fix for CLJ-852\"\n        (is (eval-in-temp-ns\n             (defn foo ^long [^long x] x)\n             (def x (inc (foo 10))))))\n      (testing \"This case should pass even without a fix for CLJ-852\"\n        (is (eval-in-temp-ns\n             (defn foo ^long [^long x] x)\n             (def x (foo (inc 10)))))))))\n \n (deftest fns-preserve-metadata-on-maps\n   (let [xm {:a 1 :b -7}\n         x (with-meta {:foo 1 :bar 2} xm)\n         ym {:c \"foo\"}\n         y (with-meta {:baz 4 :guh x} ym)]\n \n     (is (= xm (meta (:guh y))))\n     (is (= xm (meta (reduce #(assoc %1 %2 (inc %2)) x (range 1000)))))\n     (is (= xm (meta (-> x (dissoc :foo) (dissoc :bar)))))\n     (let [z (assoc-in y [:guh :la] 18)]\n       (is (= ym (meta z)))\n       (is (= xm (meta (:guh z)))))\n     (let [z (update-in y [:guh :bar] inc)]\n       (is (= ym (meta z)))\n       (is (= xm (meta (:guh z)))))\n     (is (= xm (meta (get-in y [:guh]))))\n     (is (= xm (meta (into x y))))\n     (is (= ym (meta (into y x))))\n     \n     (is (= xm (meta (merge x y))))\n     (is (= ym (meta (merge y x))))\n     (is (= xm (meta (merge-with + x y))))\n     (is (= ym (meta (merge-with + y x))))\n \n     (is (= xm (meta (select-keys x [:bar]))))\n     (is (= xm (meta (set/rename-keys x {:foo :new-foo}))))\n \n     ;; replace returns a seq when given a set.  Can seqs have\n     ;; metadata?\n     \n     ;; TBD: rseq, subseq, and rsubseq returns seqs.  If it is even\n     ;; possible to put metadata on a seq, does it make sense that the\n     ;; seqs returned by these functions should have the same metadata\n     ;; as the sorted collection on which they are called?\n     ))\n \n (deftest fns-preserve-metadata-on-vectors\n   (let [xm {:a 1 :b -7}\n         x (with-meta [1 2 3] xm)\n         ym {:c \"foo\"}\n         y (with-meta [4 x 6] ym)]\n \n     (is (= xm (meta (y 1))))\n     (is (= xm (meta (assoc x 1 \"one\"))))\n     (is (= xm (meta (reduce #(conj %1 %2) x (range 1000)))))\n     (is (= xm (meta (pop (pop (pop x))))))\n     (let [z (assoc-in y [1 2] 18)]\n       (is (= ym (meta z)))\n       (is (= xm (meta (z 1)))))\n     (let [z (update-in y [1 2] inc)]\n       (is (= ym (meta z)))\n       (is (= xm (meta (z 1)))))\n     (is (= xm (meta (get-in y [1]))))\n     (is (= xm (meta (into x y))))\n     (is (= ym (meta (into y x))))\n \n     (is (= xm (meta (replace {2 \"two\"} x))))\n     (is (= [1 \"two\" 3] (replace {2 \"two\"} x)))\n \n     ;; TBD: Currently subvec drops metadata.  Should it preserve it?\n     ;;(is (= xm (meta (subvec x 2 3))))\n \n     ;; TBD: rseq returns a seq.  If it is even possible to put\n     ;; metadata on a seq, does it make sense that the seqs returned by\n     ;; these functions should have the same metadata as the sorted\n     ;; collection on which they are called?\n     ))\n \n (deftest fns-preserve-metadata-on-sets\n   ;; TBD: Do tests independently for set, hash-set, and sorted-set,\n   ;; perhaps with a loop here.\n   (let [xm {:a 1 :b -7}\n         x (with-meta #{1 2 3} xm)\n         ym {:c \"foo\"}\n         y (with-meta #{4 x 6} ym)]\n \n     (is (= xm (meta (y #{3 2 1}))))\n     (is (= xm (meta (reduce #(conj %1 %2) x (range 1000)))))\n     (is (= xm (meta (-> x (disj 1) (disj 2) (disj 3)))))\n     (is (= xm (meta (into x y))))\n     (is (= ym (meta (into y x))))\n \n     (is (= xm (meta (set/select even? x))))\n     (let [cow1m {:what \"betsy cow\"}\n           cow1 (with-meta {:name \"betsy\" :id 33} cow1m)\n           cow2m {:what \"panda cow\"}\n           cow2 (with-meta {:name \"panda\" :id 34} cow2m)\n           cowsm {:what \"all the cows\"}\n           cows (with-meta #{cow1 cow2} cowsm)\n           cow-names (set/project cows [:name])\n           renamed (set/rename cows {:id :number})]\n       (is (= cowsm (meta cow-names)))\n       (is (= cow1m (meta (first (filter #(= \"betsy\" (:name %)) cow-names)))))\n       (is (= cow2m (meta (first (filter #(= \"panda\" (:name %)) cow-names)))))\n       (is (= cowsm (meta renamed)))\n       (is (= cow1m (meta (first (filter #(= \"betsy\" (:name %)) renamed)))))\n       (is (= cow2m (meta (first (filter #(= \"panda\" (:name %)) renamed))))))\n \n     ;; replace returns a seq when given a set.  Can seqs have\n     ;; metadata?\n \n     ;; union: Currently returns the metadata of the largest input set.\n     ;; This is an artifact of union's current implementation.  I doubt\n     ;; any explicit design decision was made to do so.  Like join,\n     ;; there doesn't seem to be much reason to prefer the metadata of\n     ;; one input set over another, if at least two input sets are\n     ;; given, but perhaps defining it to always return a set with the\n     ;; metadata of the first input set would be reasonable?\n \n     ;; intersection: Returns metadata of the smallest input set.\n     ;; Otherwise similar to union.\n \n     ;; difference: Seems to always return a set with metadata of first\n     ;; input set.  Seems reasonable.  Not sure we want to add a test\n     ;; for it, if it is an accident of the current implementation.\n \n     ;; join, index, map-invert: Currently always returns a value with\n     ;; no metadata.  This seems reasonable.\n     ))\n\n(deftest defn-primitive-args\n  (testing \"Hinting the arg vector of a primitive-taking fn with a non-primitive type should not result in AbstractMethodError when invoked.\"\n    (testing \"CLJ-850 is fixed when this case passes.\"\n      (is (= \"foo\"\n             (eval-in-temp-ns\n              (defn f ^String [^String s ^long i] s)\n              (f \"foo\" 1)))))\n    (testing \"These cases should pass, even without a fix for CLJ-850.\"\n      (is (= \"foo\"\n             (eval-in-temp-ns\n              (defn f ^String [^String s] s)\n              (f \"foo\"))))\n      (is (= 1\n             (eval-in-temp-ns\n              (defn f ^long [^String s ^long i] i)\n              (f \"foo\" 1))))\n      (is (= 1\n             (eval-in-temp-ns\n              (defn f ^long [^long i] i)\n              (f 1)))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/multimethods.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka, Robert Lachlan\n\n(ns clojure.test-clojure.multimethods\n  (:use clojure.test [clojure.test-helper :only (with-var-roots)])\n  (:require [clojure.set :as set]))\n\n; http://clojure.org/multimethods\n\n; defmulti\n; defmethod\n; remove-method\n; prefer-method\n; methods\n; prefers\n\n(defmacro for-all\n  [& args]\n  `(dorun (for ~@args)))\n\n(defn hierarchy-tags\n  \"Return all tags in a derivation hierarchy\"\n  [h]\n  (set/select\n   #(instance? clojure.lang.Named %)\n   (reduce into #{} (map keys (vals h)))))\n\n(defn transitive-closure\n  \"Return all objects reachable by calling f starting with o,\n   not including o itself. f should return a collection.\"\n  [o f]\n  (loop [results #{}\n         more #{o}]\n    (let [new-objects (set/difference more results)]\n      (if (seq new-objects)\n        (recur (set/union results more) (reduce into #{} (map f new-objects)))\n        (disj results o)))))\n\n(defn tag-descendants\n  \"Set of descedants which are tags (i.e. Named).\"\n  [& args]\n  (set/select\n   #(instance? clojure.lang.Named %)\n   (or (apply descendants args) #{})))\n\n(defn assert-valid-hierarchy\n  [h]\n  (let [tags (hierarchy-tags h)]\n    (testing \"ancestors are the transitive closure of parents\"\n      (for-all [tag tags]\n        (is (= (transitive-closure tag #(parents h %))\n               (or (ancestors h tag) #{})))))\n    (testing \"ancestors are transitive\"\n      (for-all [tag tags]\n        (is (= (transitive-closure tag #(ancestors h %))\n               (or (ancestors h tag) #{})))))\n    (testing \"tag descendants are transitive\"\n      (for-all [tag tags]\n        (is (= (transitive-closure tag #(tag-descendants h %))\n               (or (tag-descendants h tag) #{})))))\n    (testing \"a tag isa? all of its parents\"\n      (for-all [tag tags\n               :let [parents (parents h tag)]\n               parent parents]\n        (is (isa? h tag parent))))\n    (testing \"a tag isa? all of its ancestors\"\n      (for-all [tag tags\n               :let [ancestors (ancestors h tag)]\n               ancestor ancestors]\n        (is (isa? h tag ancestor))))\n    (testing \"all my descendants have me as an ancestor\"\n      (for-all [tag tags\n               :let [descendants (descendants h tag)]\n                descendant descendants]\n        (is (isa? h descendant tag))))\n    (testing \"there are no cycles in parents\"\n      (for-all [tag tags]\n        (is (not (contains? (transitive-closure tag #(parents h %)) tag)))))\n    (testing \"there are no cycles in descendants\"\n      (for-all [tag tags]\n        (is (not (contains? (descendants h tag) tag)))))))\n\n(def family\n  (reduce #(apply derive (cons %1 %2)) (make-hierarchy)\n          [[::parent-1 ::ancestor-1]\n           [::parent-1 ::ancestor-2]\n           [::parent-2 ::ancestor-2]\n           [::child ::parent-2]\n           [::child ::parent-1]]))\n\n(deftest cycles-are-forbidden\n  (testing \"a tag cannot be its own parent\"\n    (is (thrown-with-msg? Throwable #\"\\(not= tag parent\\)\"\n          (derive family ::child ::child))))\n  (testing \"a tag cannot be its own ancestor\"\n    (is (thrown-with-msg? Throwable #\"Cyclic derivation: :clojure.test-clojure.multimethods/child has :clojure.test-clojure.multimethods/ancestor-1 as ancestor\"\n          (derive family ::ancestor-1 ::child)))))\n\n(deftest using-diamond-inheritance\n  (let [diamond (reduce #(apply derive (cons %1 %2)) (make-hierarchy)\n                        [[::mammal ::animal]\n                         [::bird ::animal]\n                         [::griffin ::mammal]\n                         [::griffin ::bird]])\n        bird-no-more (underive diamond ::griffin ::bird)]\n    (assert-valid-hierarchy diamond)\n    (assert-valid-hierarchy bird-no-more)\n    (testing \"a griffin is a mammal, indirectly through mammal and bird\"\n      (is (isa? diamond ::griffin ::animal)))\n    (testing \"a griffin is a bird\"\n      (is (isa? diamond ::griffin ::bird)))\n    (testing \"after underive, griffin is no longer a bird\"\n      (is (not (isa? bird-no-more ::griffin ::bird))))\n    (testing \"but it is still an animal, via mammal\"\n      (is (isa? bird-no-more ::griffin ::animal)))))\n\n(deftest derivation-world-bridges-to-java-inheritance\n  (let [h (derive (make-hierarchy) java.util.Map ::map)]\n    (testing \"a Java class can be isa? a tag\"\n      (is (isa? h java.util.Map ::map)))\n    (testing \"if a Java class isa? a tag, so are its subclasses...\"\n      (is (isa? h java.util.HashMap ::map)))\n    (testing \"...but not its superclasses!\"\n      (is (not (isa? h java.util.Collection ::map))))))\n\n(deftest global-hierarchy-test\n  (with-var-roots {#'clojure.core/global-hierarchy (make-hierarchy)}\n    (assert-valid-hierarchy @#'clojure.core/global-hierarchy)\n    (testing \"when you add some derivations...\"\n      (derive ::lion ::cat)\n      (derive ::manx ::cat)\n      (assert-valid-hierarchy @#'clojure.core/global-hierarchy))\n    (testing \"...isa? sees the derivations\"\n      (is (isa? ::lion ::cat))\n      (is (not (isa? ::cat ::lion))))\n    (testing \"... you can traverse the derivations\"\n      (is (= #{::manx ::lion} (descendants ::cat)))\n      (is (= #{::cat} (parents ::manx)))\n      (is (= #{::cat} (ancestors ::manx))))\n    (testing \"then, remove a derivation...\"\n      (underive ::manx ::cat))\n    (testing \"... traversals update accordingly\"\n      (is (= #{::lion} (descendants ::cat)))\n      (is (nil? (parents ::manx)))\n      (is (nil? (ancestors ::manx))))))\n\n#_(defmacro for-all\n  \"Better than the actual for-all, if only it worked.\"\n  [& args]\n  `(reduce\n    #(and %1 %2)\n    (map true? (for ~@args))))\n\n(deftest basic-multimethod-test\n  (testing \"Check basic dispatch\"\n    (defmulti too-simple identity)\n    (defmethod too-simple :a [x] :a)\n    (defmethod too-simple :b [x] :b)\n    (defmethod too-simple :default [x] :default)\n    (is (= :a (too-simple :a)))\n    (is (= :b (too-simple :b)))\n    (is (= :default (too-simple :c))))\n  (testing \"Remove a method works\"\n    (remove-method too-simple :a)\n    (is (= :default (too-simple :a))))\n  (testing \"Add another method works\"\n    (defmethod too-simple :d [x] :d)\n    (is (= :d (too-simple :d)))))\n\n(deftest isA-multimethod-test\n  (testing \"Dispatch on isA\"\n    ;; Example from the multimethod docs.\n    (derive java.util.Map ::collection)\n    (derive java.util.Collection ::collection)\n    (defmulti foo class)\n    (defmethod foo ::collection [c] :a-collection)\n    (defmethod foo String [s] :a-string)\n    (is (= :a-collection (foo [])))\n    (is (= :a-collection (foo (java.util.HashMap.))))\n    (is (= :a-string (foo \"bar\")))))\n\n(deftest preferences-multimethod-test\n (testing \"Multiple method match dispatch error is caught\"\n    ;; Example from the multimethod docs.\n    (derive ::rect ::shape)\n    (defmulti bar (fn [x y] [x y]))\n    (defmethod bar [::rect ::shape] [x y] :rect-shape)\n    (defmethod bar [::shape ::rect] [x y] :shape-rect)\n    (is (thrown? java.lang.IllegalArgumentException\n                 (bar ::rect ::rect))))\n (testing \"The prefers method returns empty table w/ no prefs\"\n   (= {} (prefers bar)))\n (testing \"Adding a preference to resolve it dispatches correctly\"\n   (prefer-method bar [::rect ::shape] [::shape ::rect])\n   (is (= :rect-shape (bar ::rect ::rect))))\n (testing \"The prefers method now returns the correct table\"\n   (is (= {[::rect ::shape] #{[::shape ::rect]}} (prefers bar)))))\n\n(deftest remove-all-methods-test\n  (testing \"Core function remove-all-methods works\"\n    (defmulti simple1 identity)\n    (defmethod simple1 :a [x] :a)\n    (defmethod simple1 :b [x] :b)\n    (is (= {} (methods (remove-all-methods simple1))))))\n\n(deftest methods-test\n  (testing \"Core function methods works\"\n    (defmulti simple2 identity)\n    (defmethod simple2 :a [x] :a)\n    (defmethod simple2 :b [x] :b)\n    (is (= #{:a :b} (into #{} (keys (methods simple2)))))\n    (is (= :a ((:a (methods simple2)) 1)))\n    (defmethod simple2 :c [x] :c)\n    (is (= #{:a :b :c} (into #{} (keys (methods simple2)))))\n    (remove-method simple2 :a)\n    (is (= #{:b :c} (into #{} (keys (methods simple2)))))))\n\n(deftest get-method-test\n  (testing \"Core function get-method works\"\n    (defmulti simple3 identity)\n    (defmethod simple3 :a [x] :a)\n    (defmethod simple3 :b [x] :b)\n    (is (fn? (get-method simple3 :a)))\n    (is (= (:a ((get-method simple3 :a) 1))))\n    (is (fn? (get-method simple3 :b)))\n    (is (= (:b ((get-method simple3 :b) 1))))\n    (is (nil? (get-method simple3 :c)))))\n"
  },
  {
    "path": "test/clojure/test_clojure/ns_libs.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Authors: Frantisek Sodomka, Stuart Halloway\n\n(ns clojure.test-clojure.ns-libs\n  (:use clojure.test))\n\n; http://clojure.org/namespaces\n\n; in-ns ns create-ns\n; alias import intern refer\n; all-ns find-ns\n; ns-name ns-aliases ns-imports ns-interns ns-map ns-publics ns-refers\n; resolve ns-resolve namespace\n; ns-unalias ns-unmap remove-ns\n\n\n; http://clojure.org/libs\n\n; require use\n; loaded-libs\n\n(deftest test-alias\n\t(is (thrown-with-msg? Exception #\"No namespace: epicfail found\" (alias 'bogus 'epicfail))))\n\t\n(deftest test-require\n         (is (thrown? Exception (require :foo)))\n         (is (thrown? Exception (require))))\n\n(deftest test-use\n         (is (thrown? Exception (use :foo)))\n         (is (thrown? Exception (use))))\n\n(deftest reimporting-deftypes\n  (let [inst1 (binding [*ns* *ns*]\n                (eval '(do (ns exporter)\n                           (defrecord ReimportMe [a])\n                           (ns importer)\n                           (import exporter.ReimportMe)\n                           (ReimportMe. 1))))\n        inst2 (binding [*ns* *ns*]\n                (eval '(do (ns exporter)\n                           (defrecord ReimportMe [a b])\n                           (ns importer)\n                           (import exporter.ReimportMe)\n                           (ReimportMe. 1 2))))]\n    (testing \"you can reimport a changed class and see the changes\"\n      (is (= [:a] (keys inst1)))\n      (is (= [:a :b] (keys inst2))))\n    ;fragile tests, please fix\n    #_(testing \"you cannot import same local name from a different namespace\"\n      (is (thrown? clojure.lang.Compiler$CompilerException\n                  #\"ReimportMe already refers to: class exporter.ReimportMe in namespace: importer\"\n                  (binding [*ns* *ns*]\n                    (eval '(do (ns exporter-2)\n                               (defrecord ReimportMe [a b])\n                               (ns importer)\n                               (import exporter-2.ReimportMe)\n                               (ReimportMe. 1 2)))))))))\n\n(deftest naming-types\n  (testing \"you cannot use a name already referred from another namespace\"\n    (is (thrown? IllegalStateException\n                 #\"String already refers to: class java.lang.String\"\n                 (definterface String)))\n    (is (thrown? IllegalStateException\n                 #\"StringBuffer already refers to: class java.lang.StringBuffer\"\n                 (deftype StringBuffer [])))\n    (is (thrown? IllegalStateException\n                 #\"Integer already refers to: class java.lang.Integer\"\n                 (defrecord Integer [])))))\n\n(deftest resolution\n  (let [s (gensym)]\n    (are [result expr] (= result expr)\n         #'clojure.core/first (ns-resolve 'clojure.core 'first)\n         nil (ns-resolve 'clojure.core s)\n         nil (ns-resolve 'clojure.core {'first :local-first} 'first)\n         nil (ns-resolve 'clojure.core {'first :local-first} s))))\n  \n(deftest refer-error-messages\n  (let [temp-ns (gensym)]\n    (binding [*ns* *ns*]\n      (in-ns temp-ns)\n      (eval '(def ^{:private true} hidden-var)))\n    #_(testing \"referring to something that does not exist\"\n       (is (thrown-with-msg? IllegalAccessError #\"nonexistent-var does not exist\"\n             (refer temp-ns :only '(nonexistent-var)))))\n    #_(testing \"referring to something non-public\"\n       (is (thrown-with-msg? IllegalAccessError #\"hidden-var is not public\"\n             (refer temp-ns :only '(hidden-var)))))))\n\n(deftest test-defrecord-deftype-err-msg\n  (is (thrown-with-msg? clojure.lang.Compiler$CompilerException\n                        #\"defrecord and deftype fields must be symbols, user\\.MyRecord had: :shutdown-fn, compiling:\"\n                        (eval '(defrecord MyRecord [:shutdown-fn]))))\n  (is (thrown-with-msg? clojure.lang.Compiler$CompilerException\n                        #\"defrecord and deftype fields must be symbols, user\\.MyType had: :key1, compiling:\"\n                        (eval '(deftype MyType [:key1])))))\n"
  },
  {
    "path": "test/clojure/test_clojure/numbers.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Stephen C. Gilardi\n;;  scgilardi (gmail)\n;;  Created 30 October 2008\n;;\n\n(ns clojure.test-clojure.numbers\n  (:use clojure.test\n        [clojure.test.generative :exclude (is)]\n        clojure.template)\n  (:require [clojure.data.generators :as gen]\n            [clojure.test-helper :as helper]))\n\n\n; TODO:\n; ==\n; and more...\n\n\n;; *** Types ***\n\n\n(deftest Coerced-BigDecimal\n  (doseq [v [(bigdec 3) (bigdec (inc (bigint Long/MAX_VALUE)))]]\n    (are [x] (true? x)\n     (instance? BigDecimal v)\n     (number? v)\n     (decimal? v)\n     (not (float? v)))))\n\n(deftest BigInteger-conversions\n  (doseq [coerce-fn [bigint biginteger]]\n    (doseq [v (map coerce-fn [ Long/MAX_VALUE\n                              13178456923875639284562345789M\n                              13178456923875639284562345789N\n                              Float/MAX_VALUE\n                              (- Float/MAX_VALUE)\n                              Double/MAX_VALUE\n                              (- Double/MAX_VALUE)\n                              (* 2 (bigdec Double/MAX_VALUE)) ])]\n      (are [x] (true? x)\n        (integer? v)\n        (number? v)\n        (not (decimal? v))\n        (not (float? v))))))\n\n(defn all-pairs-equal [equal-var vals]\n  (doseq [val1 vals]\n    (doseq [val2 vals]\n      (is (equal-var val1 val2)\n          (str \"Test that \" val1 \" (\" (class val1) \") \"\n               equal-var \" \" val2 \" (\" (class val2) \")\")))))\n\n(defn all-pairs-hash-consistent-with-= [vals]\n  (doseq [val1 vals]\n    (doseq [val2 vals]\n      (when (= val1 val2)\n        (is (= (hash val1) (hash val2))\n            (str \"Test that (hash \" val1 \") (\" (class val1) \") \"\n                 \" = (hash \" val2 \") (\" (class val2) \")\"))))))\n\n(deftest equality-tests\n  ;; = only returns true for numbers that are in the same category,\n  ;; where category is one of INTEGER, FLOATING, DECIMAL, RATIO.\n  (all-pairs-equal #'= [(byte 2) (short 2) (int 2) (long 2)\n                        (bigint 2) (biginteger 2)])\n  (all-pairs-equal #'= [(float 2.0) (double 2.0)])\n  (all-pairs-equal #'= [2.0M 2.00M])\n  (all-pairs-equal #'= [(float 1.5) (double 1.5)])\n  (all-pairs-equal #'= [1.50M 1.500M])\n  (all-pairs-equal #'= [0.0M 0.00M])\n  (all-pairs-equal #'= [(/ 1 2) (/ 2 4)])\n\n  ;; No BigIntegers or floats in following tests, because hash\n  ;; consistency with = for them is out of scope for Clojure\n  ;; (CLJ-1036).\n  (all-pairs-hash-consistent-with-= [(byte 2) (short 2) (int 2) (long 2)\n                                     (bigint 2)\n                                     (double 2.0) 2.0M 2.00M])\n  (all-pairs-hash-consistent-with-= [(/ 3 2) (double 1.5) 1.50M 1.500M])\n  (all-pairs-hash-consistent-with-= [(double 0.0) 0.0M 0.00M])\n\n  ;; == tests for numerical equality, returning true even for numbers\n  ;; in different categories.\n  (all-pairs-equal #'== [(byte 0) (short 0) (int 0) (long 0)\n                         (bigint 0) (biginteger 0)\n                         (float 0.0) (double 0.0) 0.0M 0.00M])\n  (all-pairs-equal #'== [(byte 2) (short 2) (int 2) (long 2)\n                         (bigint 2) (biginteger 2)\n                         (float 2.0) (double 2.0) 2.0M 2.00M])\n  (all-pairs-equal #'== [(/ 3 2) (float 1.5) (double 1.5) 1.50M 1.500M]))\n\n(deftest unchecked-cast-num-obj\n  (do-template [prim-array cast]\n    (are [n]\n      (let [a (prim-array 1)]\n        (aset a 0 (cast n)))\n      (Byte. Byte/MAX_VALUE)\n      (Short. Short/MAX_VALUE)\n      (Integer. Integer/MAX_VALUE)\n      (Long. Long/MAX_VALUE)\n      (Float. Float/MAX_VALUE)\n      (Double. Double/MAX_VALUE))\n    byte-array\n    unchecked-byte\n    short-array\n    unchecked-short\n    char-array\n    unchecked-char\n    int-array\n    unchecked-int\n    long-array\n    unchecked-long\n    float-array\n    unchecked-float\n    double-array\n    unchecked-double))\n\n(deftest unchecked-cast-num-prim\n  (do-template [prim-array cast]\n    (are [n]\n      (let [a (prim-array 1)]\n        (aset a 0 (cast n)))\n      Byte/MAX_VALUE\n      Short/MAX_VALUE\n      Integer/MAX_VALUE\n      Long/MAX_VALUE\n      Float/MAX_VALUE\n      Double/MAX_VALUE)\n    byte-array\n    unchecked-byte\n    short-array\n    unchecked-short\n    char-array\n    unchecked-char\n    int-array\n    unchecked-int\n    long-array\n    unchecked-long\n    float-array\n    unchecked-float\n    double-array\n    unchecked-double))\n\n(deftest unchecked-cast-char\n  ; in keeping with the checked cast functions, char and Character can only be cast to int\n  (is (unchecked-int (char 0xFFFF)))\n  (is (let [c (char 0xFFFF)] (unchecked-int c)))) ; force primitive char\n\n(def expected-casts\n  [\n   [:input           [-1            0           1           Byte/MAX_VALUE  Short/MAX_VALUE  Integer/MAX_VALUE  Long/MAX_VALUE         Float/MAX_VALUE    Double/MAX_VALUE]]\n   [char             [:error        (char 0)    (char 1)    (char 127)      (char 32767)     :error             :error                 :error             :error]]\n   [unchecked-char   [(char 65535)  (char 0)    (char 1)    (char 127)      (char 32767)     (char 65535)       (char 65535)           (char 65535)       (char 65535)]]\n   [byte             [-1            0           1           Byte/MAX_VALUE  :error           :error             :error                 :error             :error]]\n   [unchecked-byte   [-1            0           1           Byte/MAX_VALUE  -1               -1                 -1                     -1                 -1]]\n   [short            [-1            0           1           Byte/MAX_VALUE  Short/MAX_VALUE  :error             :error                 :error             :error]]\n   [unchecked-short  [-1            0           1           Byte/MAX_VALUE  Short/MAX_VALUE  -1                 -1                     -1                 -1]]\n   [int              [-1            0           1           Byte/MAX_VALUE  Short/MAX_VALUE  Integer/MAX_VALUE  :error                 :error             :error]]\n   [unchecked-int    [-1            0           1           Byte/MAX_VALUE  Short/MAX_VALUE  Integer/MAX_VALUE  -1                     Integer/MAX_VALUE  Integer/MAX_VALUE]]\n   [long             [-1            0           1           Byte/MAX_VALUE  Short/MAX_VALUE  Integer/MAX_VALUE  Long/MAX_VALUE         :error             :error]]\n   [unchecked-long   [-1            0           1           Byte/MAX_VALUE  Short/MAX_VALUE  Integer/MAX_VALUE  Long/MAX_VALUE         Long/MAX_VALUE     Long/MAX_VALUE]]\n                                                                                             ;; 2.14748365E9 if when float/double conversion is avoided...\n   [float            [-1.0          0.0         1.0         127.0           32767.0          2.147483648E9      9.223372036854776E18   Float/MAX_VALUE    :error]]\n   [unchecked-float  [-1.0          0.0         1.0         127.0           32767.0          2.147483648E9      9.223372036854776E18   Float/MAX_VALUE    Float/POSITIVE_INFINITY]]\n   [double           [-1.0          0.0         1.0         127.0           32767.0          2.147483647E9      9.223372036854776E18   Float/MAX_VALUE    Double/MAX_VALUE]]\n   [unchecked-double [-1.0          0.0         1.0         127.0           32767.0          2.147483647E9      9.223372036854776E18   Float/MAX_VALUE    Double/MAX_VALUE]]])\n\n(deftest test-expected-casts\n  (let [[[_ inputs] & expectations] expected-casts]\n    (doseq [[f vals] expectations]\n      (let [wrapped (fn [x]\n                      (try\n                       (f x)\n                       (catch IllegalArgumentException e :error)))]\n        (is (= vals (map wrapped inputs)))))))\n\n;; *** Functions ***\n\n(defonce DELTA 1e-12)\n\n(deftest test-add\n  (are [x y] (= x y)\n      (+) 0\n      (+ 1) 1\n      (+ 1 2) 3\n      (+ 1 2 3) 6\n\n      (+ -1) -1\n      (+ -1 -2) -3\n      (+ -1 +2 -3) -2\n\n      (+ 1 -1) 0\n      (+ -1 1) 0\n\n      (+ 2/3) 2/3\n      (+ 2/3 1) 5/3\n      (+ 2/3 1/3) 1 )\n\n  (are [x y] (< (- x y) DELTA)\n      (+ 1.2) 1.2\n      (+ 1.1 2.4) 3.5\n      (+ 1.1 2.2 3.3) 6.6 )\n\n  (is (> (+ Integer/MAX_VALUE 10) Integer/MAX_VALUE))  ; no overflow\n  (is (thrown? ClassCastException (+ \"ab\" \"cd\"))) )    ; no string concatenation\n\n\n(deftest test-subtract\n  (is (thrown? IllegalArgumentException (-)))\n  (are [x y] (= x y)\n      (- 1) -1\n      (- 1 2) -1\n      (- 1 2 3) -4\n\n      (- -2) 2\n      (- 1 -2) 3\n      (- 1 -2 -3) 6\n\n      (- 1 1) 0\n      (- -1 -1) 0\n\n      (- 2/3) -2/3\n      (- 2/3 1) -1/3\n      (- 2/3 1/3) 1/3 )\n\n  (are [x y] (< (- x y) DELTA)\n      (- 1.2) -1.2\n      (- 2.2 1.1) 1.1\n      (- 6.6 2.2 1.1) 3.3 )\n\n  (is (< (- Integer/MIN_VALUE 10) Integer/MIN_VALUE)) )  ; no underflow\n\n\n(deftest test-multiply\n  (are [x y] (= x y)\n      (*) 1\n      (* 2) 2\n      (* 2 3) 6\n      (* 2 3 4) 24\n\n      (* -2) -2\n      (* 2 -3) -6\n      (* 2 -3 -1) 6\n\n      (* 1/2) 1/2\n      (* 1/2 1/3) 1/6\n      (* 1/2 1/3 -1/4) -1/24 )\n\n  (are [x y] (< (- x y) DELTA)\n      (* 1.2) 1.2\n      (* 2.0 1.2) 2.4\n      (* 3.5 2.0 1.2) 8.4 )\n\n  (is (> (* 3 (int (/ Integer/MAX_VALUE 2.0))) Integer/MAX_VALUE)) )  ; no overflow\n\n(deftest test-multiply-longs-at-edge\n  (are [x] (= x 9223372036854775808N)\n       (*' -1 Long/MIN_VALUE)\n       (*' Long/MIN_VALUE -1)\n       (* -1N Long/MIN_VALUE)\n       (* Long/MIN_VALUE -1N)\n       (* -1 (bigint Long/MIN_VALUE))\n       (* (bigint Long/MIN_VALUE) -1))\n  (is (thrown? ArithmeticException (* Long/MIN_VALUE -1)))\n  (is (thrown? ArithmeticException (* -1 Long/MIN_VALUE))))\n\n(deftest test-ratios-simplify-to-ints-where-appropriate\n  (testing \"negative denominator (assembla #275)\"\n    (is (integer? (/ 1 -1/2)))\n    (is (integer? (/ 0 -1/2)))))\n\n(deftest test-divide\n  (are [x y] (= x y)\n      (/ 1) 1\n      (/ 2) 1/2\n      (/ 3 2) 3/2\n      (/ 4 2) 2\n      (/ 24 3 2) 4\n      (/ 24 3 2 -1) -4\n\n      (/ -1) -1\n      (/ -2) -1/2\n      (/ -3 -2) 3/2\n      (/ -4 -2) 2\n      (/ -4 2) -2 )\n\n  (are [x y] (< (- x y) DELTA)\n      (/ 4.5 3) 1.5\n      (/ 4.5 3.0 3.0) 0.5 )\n\n  (is (thrown? ArithmeticException (/ 0)))\n  (is (thrown? ArithmeticException (/ 2 0)))\n  (is (thrown? IllegalArgumentException (/))) )\n\n\n;; mod\n;; http://en.wikipedia.org/wiki/Modulo_operation\n;; http://mathforum.org/library/drmath/view/52343.html\n;;\n;; is mod correct?\n;; http://groups.google.com/group/clojure/browse_frm/thread/2a0ee4d248f3d131#\n;;\n;; Issue 23: mod (modulo) operator\n;; http://code.google.com/p/clojure/issues/detail?id=23\n\n(deftest test-mod\n  ; wrong number of args\n;  (is (thrown? IllegalArgumentException (mod)))\n;  (is (thrown? IllegalArgumentException (mod 1)))\n;  (is (thrown? IllegalArgumentException (mod 3 2 1)))\n\n  ; divide by zero\n  (comment\n  (is (thrown? ArithmeticException (mod 9 0)))\n  (is (thrown? ArithmeticException (mod 0 0)))\n  )\n\n  (are [x y] (= x y)\n    (mod 4 2) 0\n    (mod 3 2) 1\n    (mod 6 4) 2\n    (mod 0 5) 0\n\n    (mod 2 1/2) 0\n    (mod 2/3 1/2) 1/6\n    (mod 1 2/3) 1/3\n\n    (mod 4.0 2.0) 0.0\n    (mod 4.5 2.0) 0.5\n\n    ; |num| > |div|, num != k * div\n    (mod 42 5) 2      ; (42 / 5) * 5 + (42 mod 5)        = 8 * 5 + 2        = 42\n    (mod 42 -5) -3    ; (42 / -5) * (-5) + (42 mod -5)   = -9 * (-5) + (-3) = 42\n    (mod -42 5) 3     ; (-42 / 5) * 5 + (-42 mod 5)      = -9 * 5 + 3       = -42\n    (mod -42 -5) -2   ; (-42 / -5) * (-5) + (-42 mod -5) = 8 * (-5) + (-2)  = -42\n\n    ; |num| > |div|, num = k * div\n    (mod 9 3) 0       ; (9 / 3) * 3 + (9 mod 3) = 3 * 3 + 0 = 9\n    (mod 9 -3) 0\n    (mod -9 3) 0\n    (mod -9 -3) 0\n\n    ; |num| < |div|\n    (mod 2 5) 2       ; (2 / 5) * 5 + (2 mod 5)        = 0 * 5 + 2          = 2\n    (mod 2 -5) -3     ; (2 / -5) * (-5) + (2 mod -5)   = (-1) * (-5) + (-3) = 2\n    (mod -2 5) 3      ; (-2 / 5) * 5 + (-2 mod 5)      = (-1) * 5 + 3       = -2\n    (mod -2 -5) -2    ; (-2 / -5) * (-5) + (-2 mod -5) = 0 * (-5) + (-2)    = -2\n\n    ; num = 0, div != 0\n    (mod 0 3) 0       ; (0 / 3) * 3 + (0 mod 3) = 0 * 3 + 0 = 0\n    (mod 0 -3) 0\n\n    ; large args\n    (mod 3216478362187432 432143214) 120355456\n  )\n)\n\n;; rem & quot\n;; http://en.wikipedia.org/wiki/Remainder\n\n(deftest test-rem\n  ; wrong number of args\n;  (is (thrown? IllegalArgumentException (rem)))\n;  (is (thrown? IllegalArgumentException (rem 1)))\n;  (is (thrown? IllegalArgumentException (rem 3 2 1)))\n\n  ; divide by zero\n  (comment\n  (is (thrown? ArithmeticException (rem 9 0)))\n  (is (thrown? ArithmeticException (rem 0 0)))\n  )\n\n  (are [x y] (= x y)\n    (rem 4 2) 0\n    (rem 3 2) 1\n    (rem 6 4) 2\n    (rem 0 5) 0\n\n    (rem 2 1/2) 0\n    (rem 2/3 1/2) 1/6\n    (rem 1 2/3) 1/3\n\n    (rem 4.0 2.0) 0.0\n    (rem 4.5 2.0) 0.5\n\n    ; |num| > |div|, num != k * div\n    (rem 42 5) 2      ; (8 * 5) + 2 == 42\n    (rem 42 -5) 2     ; (-8 * -5) + 2 == 42\n    (rem -42 5) -2    ; (-8 * 5) + -2 == -42\n    (rem -42 -5) -2   ; (8 * -5) + -2 == -42\n\n    ; |num| > |div|, num = k * div\n    (rem 9 3) 0\n    (rem 9 -3) 0\n    (rem -9 3) 0\n    (rem -9 -3) 0\n\n    ; |num| < |div|\n    (rem 2 5) 2\n    (rem 2 -5) 2\n    (rem -2 5) -2\n    (rem -2 -5) -2\n\n    ; num = 0, div != 0\n    (rem 0 3) 0\n    (rem 0 -3) 0\n  )\n)\n\n(deftest test-quot\n  ; wrong number of args\n;  (is (thrown? IllegalArgumentException (quot)))\n;  (is (thrown? IllegalArgumentException (quot 1)))\n;  (is (thrown? IllegalArgumentException (quot 3 2 1)))\n\n  ; divide by zero\n  (comment\n  (is (thrown? ArithmeticException (quot 9 0)))\n  (is (thrown? ArithmeticException (quot 0 0)))\n  )\n\n  (are [x y] (= x y)\n    (quot 4 2) 2\n    (quot 3 2) 1\n    (quot 6 4) 1\n    (quot 0 5) 0\n\n    (quot 2 1/2) 4\n    (quot 2/3 1/2) 1\n    (quot 1 2/3) 1\n\n    (quot 4.0 2.0) 2.0\n    (quot 4.5 2.0) 2.0\n\n    ; |num| > |div|, num != k * div\n    (quot 42 5) 8     ; (8 * 5) + 2 == 42\n    (quot 42 -5) -8   ; (-8 * -5) + 2 == 42\n    (quot -42 5) -8   ; (-8 * 5) + -2 == -42\n    (quot -42 -5) 8   ; (8 * -5) + -2 == -42\n\n    ; |num| > |div|, num = k * div\n    (quot 9 3) 3\n    (quot 9 -3) -3\n    (quot -9 3) -3\n    (quot -9 -3) 3\n\n    ; |num| < |div|\n    (quot 2 5) 0\n    (quot 2 -5) 0\n    (quot -2 5) 0\n    (quot -2 -5) 0\n\n    ; num = 0, div != 0\n    (quot 0 3) 0\n    (quot 0 -3) 0\n  )\n)\n\n\n;; *** Predicates ***\n\n;; pos? zero? neg?\n\n(deftest test-pos?-zero?-neg?\n  (let [nums [[(byte 2) (byte 0) (byte -2)]\n              [(short 3) (short 0) (short -3)]\n              [(int 4) (int 0) (int -4)]\n              [(long 5) (long 0) (long -5)]\n              [(bigint 6) (bigint 0) (bigint -6)]\n              [(float 7) (float 0) (float -7)]\n              [(double 8) (double 0) (double -8)]\n              [(bigdec 9) (bigdec 0) (bigdec -9)]\n              [2/3 0 -2/3]]\n        pred-result [[pos?  [true false false]]\n                     [zero? [false true false]]\n                     [neg?  [false false true]]] ]\n    (doseq [pr pred-result]\n      (doseq [n nums]\n        (is (= (map (first pr) n) (second pr))\n          (pr-str (first pr) n))))))\n\n\n;; even? odd?\n\n(deftest test-even?\n  (are [x] (true? x)\n    (even? -4)\n    (not (even? -3))\n    (even? 0)\n    (not (even? 5))\n    (even? 8))\n  (is (thrown? IllegalArgumentException (even? 1/2)))\n  (is (thrown? IllegalArgumentException (even? (double 10)))))\n\n(deftest test-odd?\n  (are [x] (true? x)\n    (not (odd? -4))\n    (odd? -3)\n    (not (odd? 0))\n    (odd? 5)\n    (not (odd? 8)))\n  (is (thrown? IllegalArgumentException (odd? 1/2)))\n  (is (thrown? IllegalArgumentException (odd? (double 10)))))\n\n(defn- expt\n  \"clojure.contrib.math/expt is a better and much faster impl, but this works.\nMath/pow overflows to Infinity.\"\n  [x n] (apply *' (replicate n x)))\n\n(deftest test-bit-shift-left\n  (are [x y] (= x y)\n       2r10 (bit-shift-left 2r1 1)\n       2r100 (bit-shift-left 2r1 2)\n       2r1000 (bit-shift-left 2r1 3)\n       2r00101110 (bit-shift-left 2r00010111 1)\n       2r00101110 (apply bit-shift-left [2r00010111 1])\n       0 (bit-shift-left 2r10 -1) ; truncated to least 6-bits, 63\n       (expt 2 32) (bit-shift-left 1 32)\n       (expt 2 16) (bit-shift-left 1 10000) ; truncated to least 6-bits, 16\n       )\n  (is (thrown? IllegalArgumentException (bit-shift-left 1N 1))))\n\n(deftest test-bit-shift-right\n  (are [x y] (= x y)\n       2r0 (bit-shift-right 2r1 1)\n       2r010 (bit-shift-right 2r100 1)\n       2r001 (bit-shift-right 2r100 2)\n       2r000 (bit-shift-right 2r100 3)\n       2r0001011 (bit-shift-right 2r00010111 1)\n       2r0001011 (apply bit-shift-right [2r00010111 1])\n       0 (bit-shift-right 2r10 -1) ; truncated to least 6-bits, 63\n       1 (bit-shift-right (expt 2 32) 32)\n       1 (bit-shift-right (expt 2 16) 10000) ; truncated to least 6-bits, 16\n       -1 (bit-shift-right -2r10 1)\n       )\n  (is (thrown? IllegalArgumentException (bit-shift-right 1N 1))))\n\n(deftest test-unsigned-bit-shift-right\n  (are [x y] (= x y)\n       2r0 (unsigned-bit-shift-right 2r1 1)\n       2r010 (unsigned-bit-shift-right 2r100 1)\n       2r001 (unsigned-bit-shift-right 2r100 2)\n       2r000 (unsigned-bit-shift-right 2r100 3)\n       2r0001011 (unsigned-bit-shift-right 2r00010111 1)\n       2r0001011 (apply unsigned-bit-shift-right [2r00010111 1])\n       0 (unsigned-bit-shift-right 2r10 -1) ; truncated to least 6-bits, 63\n       1 (unsigned-bit-shift-right (expt 2 32) 32)\n       1 (unsigned-bit-shift-right (expt 2 16) 10000) ; truncated to least 6-bits, 16\n       9223372036854775807 (unsigned-bit-shift-right -2r10 1)\n       )\n  (is (thrown? IllegalArgumentException (unsigned-bit-shift-right 1N 1))))\n\n(deftest test-bit-clear\n  (is (= 2r1101 (bit-clear 2r1111 1)))\n  (is (= 2r1101 (bit-clear 2r1101 1))))\n\n(deftest test-bit-set\n  (is (= 2r1111 (bit-set 2r1111 1)))\n  (is (= 2r1111 (bit-set 2r1101 1))))\n\n(deftest test-bit-flip\n  (is (= 2r1101 (bit-flip 2r1111 1)))\n  (is (= 2r1111 (bit-flip 2r1101 1))))\n\n(deftest test-bit-test\n  (is (true? (bit-test 2r1111 1)))\n  (is (false? (bit-test 2r1101 1))))\n\n;; arrays\n(deftest test-array-types\n  (are [x y z] (= (Class/forName x) (class y) (class z))\n       \"[Z\" (boolean-array 1) (booleans (boolean-array 1 true))\n       \"[B\" (byte-array 1) (bytes (byte-array 1 (byte 1)))\n       \"[C\" (char-array 1) (chars (char-array 1 \\a))\n       \"[S\" (short-array 1) (shorts (short-array 1 (short 1)))\n       \"[F\" (float-array 1) (floats (float-array 1 1))\n       \"[D\" (double-array 1) (doubles (double-array 1 1))\n       \"[I\" (int-array 1) (ints (int-array 1 1))\n       \"[J\" (long-array 1) (longs (long-array 1 1))))\n\n\n(deftest test-ratios\n  (is (== (denominator 1/2) 2))\n  (is (== (numerator 1/2) 1))\n  (is (= (bigint (/ 100000000000000000000 3)) 33333333333333333333))\n  (is (= (long 10000000000000000000/3) 3333333333333333333)))\n\n(deftest test-arbitrary-precision-subtract\n  (are [x y] (= x y)\n       9223372036854775808N (-' 0 -9223372036854775808)\n       clojure.lang.BigInt  (class (-' 0 -9223372036854775808))\n       java.lang.Long       (class (-' 0 -9223372036854775807))))\n\n(deftest test-min-max\n  (testing \"min/max on different numbers of floats and doubles\"\n    (are [xmin xmax a]\n         (and (= (Float. xmin) (min (Float. a)))\n              (= (Float. xmax) (max (Float. a)))\n              (= xmin (min a))\n              (= xmax (max a)))\n         0.0 0.0 0.0)\n    (are [xmin xmax a b]\n         (and (= (Float. xmin) (min (Float. a) (Float. b)))\n              (= (Float. xmax) (max (Float. a) (Float. b)))\n              (= xmin (min a b))\n              (= xmax (max a b)))\n         -1.0  0.0  0.0 -1.0\n         -1.0  0.0 -1.0  0.0\n         0.0  1.0  0.0  1.0\n         0.0  1.0  1.0  0.0)\n    (are [xmin xmax a b c]\n         (and (= (Float. xmin) (min (Float. a) (Float. b) (Float. c)))\n              (= (Float. xmax) (max (Float. a) (Float. b) (Float. c)))\n              (= xmin (min a b c))\n              (= xmax (max a b c)))\n         -1.0  1.0  0.0  1.0 -1.0\n         -1.0  1.0  0.0 -1.0  1.0\n         -1.0  1.0 -1.0  1.0  0.0))\n  (testing \"min/max preserves type of winner\"\n    (is (= java.lang.Long (class (max 10))))\n    (is (= java.lang.Long (class (max 1.0 10))))\n    (is (= java.lang.Long (class (max 10 1.0))))\n    (is (= java.lang.Long (class (max 10 1.0 2.0))))\n    (is (= java.lang.Long (class (max 1.0 10 2.0))))\n    (is (= java.lang.Long (class (max 1.0 2.0 10))))\n    (is (= java.lang.Double (class (max 1 2 10.0 3 4 5))))\n    (is (= java.lang.Long (class (min 10))))\n    (is (= java.lang.Long (class (min 1.0 -10))))\n    (is (= java.lang.Long (class (min -10 1.0))))\n    (is (= java.lang.Long (class (min -10 1.0 2.0))))\n    (is (= java.lang.Long (class (min 1.0 -10 2.0))))\n    (is (= java.lang.Long (class (min 1.0 2.0 -10))))\n    (is (= java.lang.Double (class (min 1 2 -10.0 3 4 5))))))\n\n(deftest clj-868\n  (testing \"min/max: NaN is contagious\"\n    (letfn [(fnan? [^Float x] (Float/isNaN x))\n            (dnan? [^double x] (Double/isNaN x))]\n      (are [minmax]\n           (are [nan? nan zero]\n                (every? nan? (map minmax\n                                  [ nan zero zero]\n                                  [zero  nan zero]\n                                  [zero zero  nan]))\n                fnan?  Float/NaN  (Float. 0.0)\n                dnan? Double/NaN          0.0)\n           min\n           max))))\n\n(defn integer\n  \"Distribution of integers biased towards the small, but\n   including all longs.\"\n  []\n  (gen/one-of #(gen/uniform -1 32) gen/byte gen/short gen/int gen/long))\n\n(defn longable?\n  [n]\n  (try\n   (long n)\n   true\n   (catch Exception _)))\n\n(defspec integer-commutative-laws\n  (partial map identity)\n  [^{:tag `integer} a ^{:tag `integer} b]\n  (if (longable? (+' a b))\n    (assert (= (+ a b) (+ b a)\n               (+' a b) (+' b a)\n               (unchecked-add a b) (unchecked-add b a)))\n    (assert (= (+' a b) (+' b a))))\n  (if (longable? (*' a b))\n    (assert (= (* a b) (* b a)\n               (*' a b) (*' b a)\n               (unchecked-multiply a b) (unchecked-multiply b a)))\n    (assert (= (*' a b) (*' b a)))))\n\n(defspec integer-associative-laws\n  (partial map identity)\n  [^{:tag `integer} a ^{:tag `integer} b ^{:tag `integer} c]\n  (if (every? longable? [(+' a b) (+' b c) (+' a b c)])\n    (assert (= (+ (+ a b) c) (+ a (+ b c))\n               (+' (+' a b) c) (+' a (+' b c))\n               (unchecked-add (unchecked-add a b) c) (unchecked-add a (unchecked-add b c))))\n    (assert (= (+' (+' a b) c) (+' a (+' b c))\n               (+ (+ (bigint a) b) c) (+ a (+ (bigint b) c)))))\n  (if (every? longable? [(*' a b) (*' b c) (*' a b c)])\n    (assert (= (* (* a b) c) (* a (* b c))\n               (*' (*' a b) c) (*' a (*' b c))\n               (unchecked-multiply (unchecked-multiply a b) c) (unchecked-multiply a (unchecked-multiply b c))))\n    (assert (= (*' (*' a b) c) (*' a (*' b c))\n               (* (* (bigint a) b) c) (* a (* (bigint b) c))))))\n\n(defspec integer-distributive-laws\n  (partial map identity)\n  [^{:tag `integer} a ^{:tag `integer} b ^{:tag `integer} c]\n  (if (every? longable? [(*' a (+' b c)) (+' (*' a b) (*' a c))\n                         (*' a b) (*' a c) (+' b c)])\n    (assert (= (* a (+ b c)) (+ (* a b) (* a c))\n               (*' a (+' b c)) (+' (*' a b) (*' a c))\n               (unchecked-multiply a (+' b c)) (+' (unchecked-multiply a b) (unchecked-multiply a c))))\n    (assert (= (*' a (+' b c)) (+' (*' a b) (*' a c))\n               (* a (+ (bigint b) c)) (+ (* (bigint a) b) (* (bigint a) c))))))\n\n(defspec addition-undoes-subtraction\n  (partial map identity)\n  [^{:tag `integer} a ^{:tag `integer} b]\n  (if (longable? (-' a b))\n    (assert (= a\n               (-> a (- b) (+ b))\n               (-> a (unchecked-subtract b) (unchecked-add b)))))\n  (assert (= a\n             (-> a (-' b) (+' b)))))\n\n(defspec quotient-and-remainder\n  (fn [a b] (sort [a b]))\n  [^{:tag `integer} a ^{:tag `integer} b]\n  (when-not (zero? (second %))\n    (let [[a d] %\n          q (quot a d)\n          r (rem a d)]\n      (assert (= a\n                 (+ (* q d) r)\n                 (unchecked-add (unchecked-multiply q d) r))))))\n\n(defmacro check-warn-on-box [warn? form]\n  `(do (binding [*unchecked-math* :warn-on-boxed]\n                (is (= ~warn?\n                       (boolean\n                         (re-find #\"^Boxed math warning\"\n                                  (helper/with-err-string-writer\n                                    (helper/eval-in-temp-ns ~form)))))))\n       (binding [*unchecked-math* true]\n                (is (false?\n                      (boolean\n                        (re-find #\"^Boxed math warning\"\n                                 (helper/with-err-string-writer\n                                   (helper/eval-in-temp-ns ~form)))))))\n       (binding [*unchecked-math* false]\n                (is (false?\n                      (boolean\n                        (re-find #\"^Boxed math warning\"\n                                 (helper/with-err-string-writer\n                                   (helper/eval-in-temp-ns ~form)))))))))\n\n(deftest warn-on-boxed\n  (check-warn-on-box true (#(inc %) 2))\n  (check-warn-on-box false (#(inc ^long %) 2))\n  (check-warn-on-box false (long-array 5))\n  (check-warn-on-box true (> (first (range 3)) 0))\n  (check-warn-on-box false (> ^long (first (range 3)) 0)))\n\n\n(deftest comparisons\n  (let [small-numbers [1 1.0 (Integer. 1) (Float. 1.0) 9/10 1N 1M]\n        big-numbers [10 10.0 (Integer. 10) (Float. 10.0) 99/10 10N 10N]]\n    (doseq [small small-numbers big big-numbers]\n      (is (< small big))\n      (is (not (< big small)))\n      (is (not (< small small)))\n      (is (< (int small) (int big)))\n      (is (not (< (int big) (int small))))\n      (is (not (< (int small) (int small))))\n      (is (< (double small) (double big)))\n      (is (not (< (double big) (double small))))\n      (is (not (< (double small) (double small))))\n      (is (<= small big))\n      (is (<= small small))\n      (is (not (<= big small)))\n      (is (<= (int small) (int big)))\n      (is (<= (int small) (int small)))\n      (is (not (<= (int big) (int small))))\n      (is (<= (double small) (double big)))\n      (is (<= (double small) (double small)))\n      (is (not (<= (double big) (double small))))\n      (is (> big small))\n      (is (not (> small big)))\n      (is (not (> small small)))\n      (is (> (int big) (int small)))\n      (is (not (> (int small) (int big))))\n      (is (not (> (int small) (int small))))\n      (is (> (double big) (double small)))\n      (is (not (> (double small) (double big))))\n      (is (not (> (double small) (double small))))\n      (is (>= big small))\n      (is (>= small small))\n      (is (not (>= small big)))\n      (is (>= (int big) (int small)))\n      (is (>= (int small) (int small)))\n      (is (not (>= (int small) (int big))))\n      (is (>= (double big) (double small)))\n      (is (>= (double small) (double small)))\n      (is (not (>= (double small) (double big)))))))\n\n(deftest test-nan-comparison\n  (are [x y] (= x y)\n       (< 1000 Double/NaN) (< 1000 (Double. Double/NaN))\n       (<= 1000 Double/NaN) (<= 1000 (Double. Double/NaN))\n       (> 1000 Double/NaN) (> 1000 (Double. Double/NaN))\n       (>= 1000 Double/NaN) (>= 1000 (Double. Double/NaN))))\n"
  },
  {
    "path": "test/clojure/test_clojure/other_functions.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka\n\n\n(ns clojure.test-clojure.other-functions\n  (:use clojure.test))\n\n; http://clojure.org/other_functions\n\n; [= not= (tests in data_structures.clj and elsewhere)]\n\n\n(deftest test-identity\n  ; exactly 1 argument needed\n;  (is (thrown? IllegalArgumentException (identity)))\n;  (is (thrown? IllegalArgumentException (identity 1 2)))\n\n  (are [x] (= (identity x) x)\n      nil\n      false true\n      0 42\n      0.0 3.14\n      2/3\n      0M 1M\n      \\c\n      \"\" \"abc\"\n      'sym\n      :kw\n      () '(1 2)\n      [] [1 2]\n      {} {:a 1 :b 2}\n      #{} #{1 2} )\n\n  ; evaluation\n  (are [x y] (= (identity x) y)\n      (+ 1 2) 3\n      (> 5 0) true ))\n\n\n(deftest test-name\n  (are [x y] (= x (name y))\n       \"foo\" :foo\n       \"bar\" 'bar\n       \"quux\" \"quux\"))\n\n(deftest test-fnil\n  (let [f1 (fnil vector :a)\n        f2 (fnil vector :a :b)\n        f3 (fnil vector :a :b :c)]\n    (are [result input] (= result [(apply f1 input) (apply f2 input) (apply f3 input)])\n         [[1 2 3 4] [1 2 3 4] [1 2 3 4]]  [1 2 3 4]\n         [[:a 2 3 4] [:a 2 3 4] [:a 2 3 4]] [nil 2 3 4]\n         [[:a nil 3 4] [:a :b 3 4] [:a :b 3 4]] [nil nil 3 4]\n         [[:a nil nil 4] [:a :b nil 4] [:a :b :c 4]] [nil nil nil 4]\n         [[:a nil nil nil] [:a :b nil nil] [:a :b :c nil]] [nil nil nil nil]))\n  (are [x y] (= x y)\n       ((fnil + 0) nil 42) 42\n       ((fnil conj []) nil 42) [42]\n       (reduce #(update-in %1 [%2] (fnil inc 0)) {} \n               [\"fun\" \"counting\" \"words\" \"fun\"])\n       {\"words\" 1, \"counting\" 1, \"fun\" 2}\n       (reduce #(update-in %1 [(first %2)] (fnil conj []) (second %2)) {} \n               [[:a 1] [:a 2] [:b 3]])\n       {:b [3], :a [1 2]}))\n\n; time assert comment doc\n\n; partial\n; comp\n\n(deftest test-comp\n  (let [c0 (comp)]\n    (are [x] (= (identity x) (c0 x))\n         nil\n         42\n         [1 2 3]\n         #{}\n         :foo)\n    (are [x y] (= (identity x) (c0 y))\n         (+ 1 2 3) 6\n         (keyword \"foo\") :foo)))\n\n; complement\n\n(deftest test-complement\n  (let [not-contains? (complement contains?)]\n    (is (= true (not-contains? [2 3 4] 5)))\n    (is (= false (not-contains? [2 3 4] 2))))\n  (let [first-elem-not-1? (complement (fn [x] (= 1 (first x))))]\n    (is (= true (first-elem-not-1? [2 3])))\n    (is (= false (first-elem-not-1? [1 2])))))\n\n; constantly\n\n(deftest test-constantly\n  (let [c0 (constantly 10)]\n    (are [x] (= 10 (c0 x))\n         nil\n         42\n         \"foo\")))\n;juxt\n\n(deftest test-juxt\n  ;; juxt for colls\n  (let [m0 {:a 1 :b 2}\n        a0 [1 2]]\n    (is (= [1 2] ((juxt :a :b) m0)))\n    (is (= [2 1] ((juxt fnext first) a0))))\n  ;; juxt for fns\n  (let [a1 (fn [a] (+ 2 a))\n        b1 (fn [b] (* 2 b))]\n    (is (= [5 6] ((juxt a1 b1) 3)))))\n\n;partial\n\n(deftest test-partial\n  (let [p0 (partial inc)\n        p1 (partial + 20)\n        p2 (partial conj [1 2])]\n    (is (= 41 (p0 40)))\n    (is (= 40 (p1 20)))\n    (is (= [1 2 3] (p2 3)))))\n\n; every-pred\n(deftest test-every-pred\n  (are [result expr] (= result expr)\n   ;; 1 pred\n   true     ((every-pred even?))\n   true     ((every-pred even?) 2)\n   true     ((every-pred even?) 2 4)\n   true     ((every-pred even?) 2 4 6)\n   true     ((every-pred even?) 2 4 6 8)\n   true     ((every-pred even?) 2 4 6 8 10)\n   false    ((every-pred odd?) 2)\n   false    ((every-pred odd?) 2 4)\n   false    ((every-pred odd?) 2 4 6)\n   false    ((every-pred odd?) 2 4 6 8)\n   false    ((every-pred odd?) 2 4 6 8 10)\n   ;; 2 preds\n   true     ((every-pred even? number?))\n   true     ((every-pred even? number?) 2)\n   true     ((every-pred even? number?) 2 4)\n   true     ((every-pred even? number?) 2 4 6)\n   true     ((every-pred even? number?) 2 4 6 8)\n   true     ((every-pred even? number?) 2 4 6 8 10)\n   false    ((every-pred number? odd?) 2)\n   false    ((every-pred number? odd?) 2 4)\n   false    ((every-pred number? odd?) 2 4 6)\n   false    ((every-pred number? odd?) 2 4 6 8)\n   false    ((every-pred number? odd?) 2 4 6 8 10)\n   ;; 2 preds, short-circuiting\n   false    ((every-pred number? odd?) 1 :a)\n   false    ((every-pred number? odd?) 1 3 :a)\n   false    ((every-pred number? odd?) 1 3 5 :a)\n   false    ((every-pred number? odd?) 1 3 5 7 :a)\n   false    ((every-pred number? odd?) 1 :a 3 5 7)\n   ;; 3 preds\n   true     ((every-pred even? number? #(> % 0)))\n   true     ((every-pred even? number? #(> % 0)) 2)\n   true     ((every-pred even? number? #(> % 0)) 2 4)\n   true     ((every-pred even? number? #(> % 0)) 2 4 6)\n   true     ((every-pred even? number? #(> % 0)) 2 4 6 8)\n   true     ((every-pred even? number? #(> % 0)) 2 4 6 8 10)\n   true     ((every-pred number? even? #(> % 0)) 2 4 6 8 10 12)\n   false    ((every-pred number? odd? #(> % 0)) 2)\n   false    ((every-pred number? odd? #(> % 0)) 2 4)\n   false    ((every-pred number? odd? #(> % 0)) 2 4 6)\n   false    ((every-pred number? odd? #(> % 0)) 2 4 6 8)\n   false    ((every-pred number? odd? #(> % 0)) 2 4 6 8 10)\n   false    ((every-pred number? odd? #(> % 0)) 2 4 6 8 -10)\n   ;; 3 preds, short-circuiting\n   false    ((every-pred number? odd? #(> % 0)) 1 :a)\n   false    ((every-pred number? odd? #(> % 0)) 1 3 :a)\n   false    ((every-pred number? odd? #(> % 0)) 1 3 5 :a)\n   false    ((every-pred number? odd? #(> % 0)) 1 3 5 7 :a)\n   false    ((every-pred number? odd? #(> % 0)) 1 :a 3 5 7)\n   ;; 4 preds\n   true     ((every-pred even? number? #(> % 0) #(<= % 12)))\n   true     ((every-pred even? number? #(> % 0) #(<= % 12)) 2)\n   true     ((every-pred even? number? #(> % 0) #(<= % 12)) 2 4)\n   true     ((every-pred even? number? #(> % 0) #(<= % 12)) 2 4 6)\n   true     ((every-pred even? number? #(> % 0) #(<= % 12)) 2 4 6 8)\n   true     ((every-pred even? number? #(> % 0) #(<= % 12)) 2 4 6 8 10)\n   true     ((every-pred number? even? #(> % 0) #(<= % 12)) 2 4 6 8 10 12)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12)) 2)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12)) 2 4)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12)) 2 4 6)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12)) 2 4 6 8)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12)) 2 4 6 8 10)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12)) 2 4 6 8 14)\n   ;; 4 preds, short-circuiting\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12)) 1 :a)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12)) 1 3 :a)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12)) 1 3 5 :a)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12)) 1 3 5 7 :a)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12)) 1 :a 3 5 7)\n   ;; 5 preds\n   true     ((every-pred even? number? #(> % 0) #(<= % 12) #(zero? (rem % 2))))\n   true     ((every-pred even? number? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2)\n   true     ((every-pred even? number? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4)\n   true     ((every-pred even? number? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6)\n   true     ((every-pred even? number? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6 8)\n   true     ((every-pred even? number? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6 8 10)\n   true     ((every-pred number? even? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6 8 10 12)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6 8)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6 8 10)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6 8 13)\n   ;; 5 preds, short-circuiting\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 1 :a)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 1 3 :a)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 1 3 5 :a)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 1 3 5 7 :a)\n   false    ((every-pred number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 1 :a 3 5 7)\n   ;; truthiness\n   true     (reduce #(and % %2)\n                    (for [i (range 1 25)]\n                      (apply (apply every-pred (repeat i identity))\n                             (range i))))))\n\n; some-fn\n\n(deftest test-some-fn\n  (are [result] (identity result)\n   ;; 1 pred\n   (not ((some-fn even?)))\n   ((some-fn even?) 2)\n   ((some-fn even?) 2 4)\n   ((some-fn even?) 2 4 6)\n   ((some-fn even?) 2 4 6 8)\n   ((some-fn even?) 2 4 6 8 10)\n   (not ((some-fn odd?) 2))\n   (not ((some-fn odd?) 2 4))\n   (not ((some-fn odd?) 2 4 6))\n   (not ((some-fn odd?) 2 4 6 8))\n   (not ((some-fn odd?) 2 4 6 8 10))\n   ;; 2 preds\n   (not ((some-fn even? number?)))\n   ((some-fn even? number?) 2)\n   ((some-fn even? number?) 2 4)\n   ((some-fn even? number?) 2 4 6)\n   ((some-fn even? number?) 2 4 6 8)\n   ((some-fn even? number?) 2 4 6 8 10)\n   ((some-fn number? odd?) 2)\n   ((some-fn number? odd?) 2 4)\n   ((some-fn number? odd?) 2 4 6)\n   ((some-fn number? odd?) 2 4 6 8)\n   ((some-fn number? odd?) 2 4 6 8 10)\n   ;; 2 preds, short-circuiting\n   ((some-fn number? odd?) 1 :a)\n   ((some-fn number? odd?) 1 3 :a)\n   ((some-fn number? odd?) 1 3 5 :a)\n   ((some-fn number? odd?) 1 3 5 7 :a)\n   ((some-fn number? odd?) 1 :a 3 5 7)\n   ;; 3 preds\n   (not ((some-fn even? number? #(> % 0))))\n   ((some-fn even? number? #(> % 0)) 2)\n   ((some-fn even? number? #(> % 0)) 2 4)\n   ((some-fn even? number? #(> % 0)) 2 4 6)\n   ((some-fn even? number? #(> % 0)) 2 4 6 8)\n   ((some-fn even? number? #(> % 0)) 2 4 6 8 10)\n   ((some-fn number? even? #(> % 0)) 2 4 6 8 10 12)\n   ((some-fn number? odd? #(> % 0)) 2)\n   ((some-fn number? odd? #(> % 0)) 2 4)\n   ((some-fn number? odd? #(> % 0)) 2 4 6)\n   ((some-fn number? odd? #(> % 0)) 2 4 6 8)\n   ((some-fn number? odd? #(> % 0)) 2 4 6 8 10)\n   ((some-fn number? odd? #(> % 0)) 2 4 6 8 -10)\n   ;; 3 preds, short-circuiting\n   ((some-fn number? odd? #(> % 0)) 1 :a)\n   ((some-fn number? odd? #(> % 0)) 1 3 :a)\n   ((some-fn number? odd? #(> % 0)) 1 3 5 :a)\n   ((some-fn number? odd? #(> % 0)) 1 :a 3 5 7)\n   ;; 4 preds\n   (not ((some-fn even? number? #(> % 0) #(<= % 12))))\n   ((some-fn even? number? #(> % 0) #(<= % 12)) 2)\n   ((some-fn even? number? #(> % 0) #(<= % 12)) 2 4)\n   ((some-fn even? number? #(> % 0) #(<= % 12)) 2 4 6)\n   ((some-fn even? number? #(> % 0) #(<= % 12)) 2 4 6 8)\n   ((some-fn even? number? #(> % 0) #(<= % 12)) 2 4 6 8 10)\n   ((some-fn number? even? #(> % 0) #(<= % 12)) 2 4 6 8 10 12)\n   ((some-fn number? odd? #(> % 0) #(<= % 12)) 2)\n   ((some-fn number? odd? #(> % 0) #(<= % 12)) 2 4)\n   ((some-fn number? odd? #(> % 0) #(<= % 12)) 2 4 6)\n   ((some-fn number? odd? #(> % 0) #(<= % 12)) 2 4 6 8)\n   ((some-fn number? odd? #(> % 0) #(<= % 12)) 2 4 6 8 10)\n   ((some-fn number? odd? #(> % 0) #(<= % 12)) 2 4 6 8 14)\n   ;; 4 preds, short-circuiting\n   ((some-fn number? odd? #(> % 0) #(<= % 12)) 1 :a)\n   ((some-fn number? odd? #(> % 0) #(<= % 12)) 1 3 :a)\n   ((some-fn number? odd? #(> % 0) #(<= % 12)) 1 3 5 :a)\n   ((some-fn number? odd? #(> % 0) #(<= % 12)) 1 3 5 7 :a)\n   ((some-fn number? odd? #(> % 0) #(<= % 12)) 1 :a 3 5 7)\n   ;; 5 preds\n   (not ((some-fn even? number? #(> % 0) #(<= % 12) #(zero? (rem % 2)))))\n   ((some-fn even? number? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2)\n   ((some-fn even? number? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4)\n   ((some-fn even? number? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6)\n   ((some-fn even? number? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6 8)\n   ((some-fn even? number? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6 8 10)\n   ((some-fn number? even? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6 8 10 12)\n   ((some-fn number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2)\n   ((some-fn number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4)\n   ((some-fn number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6)\n   ((some-fn number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6 8)\n   ((some-fn number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6 8 10)\n   ((some-fn number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 2 4 6 8 13)\n   ;; 5 preds, short-circuiting\n   ((some-fn number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 1 :a)\n   ((some-fn number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 1 3 :a)\n   ((some-fn number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 1 3 5 :a)\n   ((some-fn number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 1 3 5 7 :a)\n   ((some-fn number? odd? #(> % 0) #(<= % 12) #(zero? (rem % 2))) 1 :a 3 5 7)\n   ;; truthiness\n   (reduce #(or % %2)\n           (conj\n             (vec\n               (for [i (range 1 25)]\n                 (apply (apply some-fn (repeat i (comp not boolean))) (range i))))\n                 true))))\n\n; Printing\n; pr prn print println newline\n; pr-str prn-str print-str println-str [with-out-str (vars.clj)]\n\n; Regex Support\n; re-matcher re-find re-matches re-groups re-seq\n\n; update\n\n(deftest test-update\n  (are [result expr] (= result expr)\n    {:a [1 2]}   (update {:a [1]} :a conj 2)\n    [1]          (update [0] 0 inc)\n    ;; higher-order usage\n    {:a {:b 2}}  (update-in {:a {:b 1}} [:a] update :b inc)\n    ;; missing field = nil\n    {:a 1 :b nil} (update {:a 1} :b identity)\n    ;; 4 hard-coded arities\n    {:a 1} (update {:a 1} :a +)\n    {:a 2} (update {:a 1} :a + 1)\n    {:a 3} (update {:a 1} :a + 1 1)\n    {:a 4} (update {:a 1} :a + 1 1 1)\n    ;; rest arity\n    {:a 5} (update {:a 1} :a + 1 1 1 1)\n    {:a 6} (update {:a 1} :a + 1 1 1 1 1)))\n"
  },
  {
    "path": "test/clojure/test_clojure/parallel.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka\n\n\n(ns clojure.test-clojure.parallel\n  (:use clojure.test))\n\n;; !! Tests for the parallel library will be in a separate file clojure_parallel.clj !!\n\n; future-call\n; future\n; pmap\n; pcalls\n; pvalues\n\n\n;; pmap\n;;\n(deftest pmap-does-its-thing\n  ;; regression fixed in r1218; was OutOfMemoryError\n  (is (= '(1) (pmap inc [0]))))\n\n\n(def ^:dynamic *test-value* 1)\n\n(deftest future-fn-properly-retains-conveyed-bindings\n  (let [a (atom [])]\n    (binding [*test-value* 2]\n      @(future (dotimes [_ 3]\n                 ;; we need some binding to trigger binding pop\n                 (binding [*print-dup* false]\n                   (swap! a conj *test-value*))))\n      (is (= [2 2 2] @a)))))\n"
  },
  {
    "path": "test/clojure/test_clojure/pprint/test_cl_format.clj",
    "content": ";;; test_cl_format.clj -- part of the pretty printer for Clojure\n\n;   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Tom Faulhaber\n;; April 3, 2009\n\n;; This test set tests the basic cl-format functionality\n\n\n(in-ns 'clojure.test-clojure.pprint)\n\n(def format cl-format)\n\n;; TODO tests for ~A, ~D, etc.\n;; TODO add tests for ~F, etc.: 0.0, 9.9999 with rounding, 9.9999E99 with rounding\n\n(simple-tests d-tests\n  (cl-format nil \"~D\" 0) \"0\"\n  (cl-format nil \"~D\" 2e6) \"2000000\"\n  (cl-format nil \"~D\" 2000000) \"2000000\"\n  (cl-format nil \"~:D\" 2000000) \"2,000,000\"\n  (cl-format nil \"~D\" 1/2) \"1/2\"\n  (cl-format nil \"~D\" 'fred) \"fred\"\n)\n\n(simple-tests base-tests\n  (cl-format nil \"~{~2r~^ ~}~%\" (range 10))\n  \"0 1 10 11 100 101 110 111 1000 1001\\n\"\n  (with-out-str\n    (dotimes [i 35]\n      (binding [*print-base* (+ i 2)]       ;print the decimal number 40 \n        (write 40)                          ;in each base from 2 to 36\n        (if (zero? (mod i 10)) (prn) (cl-format true \" \")))))\n  \"101000\n1111 220 130 104 55 50 44 40 37 34\n31 2c 2a 28 26 24 22 20 1j 1i\n1h 1g 1f 1e 1d 1c 1b 1a 19 18\n17 16 15 14 \"\n  (with-out-str\n    (doseq [pb [2 3 8 10 16]]               \n      (binding [*print-radix* true      ;print the integer 10 and \n            *print-base* pb]            ;the ratio 1/10 in bases 2, \n        (cl-format true \"~&~S  ~S~%\" 10 1/10))))        ;3, 8, 10, 16\n  \"#b1010  #b1/1010\\n#3r101  #3r1/101\\n#o12  #o1/12\\n10.  #10r1/10\\n#xa  #x1/a\\n\")\n\n\n\n(simple-tests cardinal-tests\n  (cl-format nil \"~R\" 0) \"zero\"\n  (cl-format nil \"~R\" 4) \"four\"\n  (cl-format nil \"~R\" 15) \"fifteen\"\n  (cl-format nil \"~R\" -15) \"minus fifteen\"\n  (cl-format nil \"~R\" 25) \"twenty-five\"\n  (cl-format nil \"~R\" 20) \"twenty\"\n  (cl-format nil \"~R\" 200) \"two hundred\"\n  (cl-format nil \"~R\" 203) \"two hundred three\"\n\n  (cl-format nil \"~R\" 44879032)\n  \"forty-four million, eight hundred seventy-nine thousand, thirty-two\"\n\n  (cl-format nil \"~R\" -44879032)\n  \"minus forty-four million, eight hundred seventy-nine thousand, thirty-two\"\n  \n  (cl-format nil \"~R = ~:*~:D\" 44000032)\n  \"forty-four million, thirty-two = 44,000,032\"\n\n  (cl-format nil \"~R = ~:*~:D\" 448790329480948209384389429384029384029842098420989842094)\n  \"four hundred forty-eight septendecillion, seven hundred ninety sexdecillion, three hundred twenty-nine quindecillion, four hundred eighty quattuordecillion, nine hundred forty-eight tredecillion, two hundred nine duodecillion, three hundred eighty-four undecillion, three hundred eighty-nine decillion, four hundred twenty-nine nonillion, three hundred eighty-four octillion, twenty-nine septillion, three hundred eighty-four sextillion, twenty-nine quintillion, eight hundred forty-two quadrillion, ninety-eight trillion, four hundred twenty billion, nine hundred eighty-nine million, eight hundred forty-two thousand, ninety-four = 448,790,329,480,948,209,384,389,429,384,029,384,029,842,098,420,989,842,094\"\n\n  (cl-format nil \"~R = ~:*~:D\" 448790329480948209384389429384029384029842098420989842094490320942058747587584758375847593475)\n  \"448,790,329,480,948,209,384,389,429,384,029,384,029,842,098,420,989,842,094,490,320,942,058,747,587,584,758,375,847,593,475 = 448,790,329,480,948,209,384,389,429,384,029,384,029,842,098,420,989,842,094,490,320,942,058,747,587,584,758,375,847,593,475\"\n\n  (cl-format nil \"~R = ~:*~:D\" 2e6)\n  \"two million = 2,000,000\"\n\n  (cl-format nil \"~R = ~:*~:D\" 200000200000)\n  \"two hundred billion, two hundred thousand = 200,000,200,000\")\n\n(simple-tests ordinal-tests\n  (cl-format nil \"~:R\" 0) \"zeroth\"\n  (cl-format nil \"~:R\" 4) \"fourth\"\n  (cl-format nil \"~:R\" 15) \"fifteenth\"\n  (cl-format nil \"~:R\" -15) \"minus fifteenth\"\n  (cl-format nil \"~:R\" 25) \"twenty-fifth\"\n  (cl-format nil \"~:R\" 20) \"twentieth\"\n  (cl-format nil \"~:R\" 200) \"two hundredth\"\n  (cl-format nil \"~:R\" 203) \"two hundred third\"\n\n  (cl-format nil \"~:R\" 44879032)\n  \"forty-four million, eight hundred seventy-nine thousand, thirty-second\"\n\n  (cl-format nil \"~:R\" -44879032)\n  \"minus forty-four million, eight hundred seventy-nine thousand, thirty-second\"\n  \n  (cl-format nil \"~:R = ~:*~:D\" 44000032)\n  \"forty-four million, thirty-second = 44,000,032\"\n\n  (cl-format nil \"~:R = ~:*~:D\" 448790329480948209384389429384029384029842098420989842094)\n  \"four hundred forty-eight septendecillion, seven hundred ninety sexdecillion, three hundred twenty-nine quindecillion, four hundred eighty quattuordecillion, nine hundred forty-eight tredecillion, two hundred nine duodecillion, three hundred eighty-four undecillion, three hundred eighty-nine decillion, four hundred twenty-nine nonillion, three hundred eighty-four octillion, twenty-nine septillion, three hundred eighty-four sextillion, twenty-nine quintillion, eight hundred forty-two quadrillion, ninety-eight trillion, four hundred twenty billion, nine hundred eighty-nine million, eight hundred forty-two thousand, ninety-fourth = 448,790,329,480,948,209,384,389,429,384,029,384,029,842,098,420,989,842,094\"\n  (cl-format nil \"~:R = ~:*~:D\" 448790329480948209384389429384029384029842098420989842094490320942058747587584758375847593475)\n  \"448,790,329,480,948,209,384,389,429,384,029,384,029,842,098,420,989,842,094,490,320,942,058,747,587,584,758,375,847,593,475th = 448,790,329,480,948,209,384,389,429,384,029,384,029,842,098,420,989,842,094,490,320,942,058,747,587,584,758,375,847,593,475\"\n  (cl-format nil \"~:R = ~:*~:D\" 448790329480948209384389429384029384029842098420989842094490320942058747587584758375847593471)\n  \"448,790,329,480,948,209,384,389,429,384,029,384,029,842,098,420,989,842,094,490,320,942,058,747,587,584,758,375,847,593,471st = 448,790,329,480,948,209,384,389,429,384,029,384,029,842,098,420,989,842,094,490,320,942,058,747,587,584,758,375,847,593,471\"\n  (cl-format nil \"~:R = ~:*~:D\" 2e6)\n  \"two millionth = 2,000,000\")\n\n(simple-tests ordinal1-tests\n  (cl-format nil \"~:R\" 1) \"first\"\n  (cl-format nil \"~:R\" 11) \"eleventh\"\n  (cl-format nil \"~:R\" 21) \"twenty-first\"\n  (cl-format nil \"~:R\" 20) \"twentieth\"\n  (cl-format nil \"~:R\" 220) \"two hundred twentieth\"\n  (cl-format nil \"~:R\" 200) \"two hundredth\"\n  (cl-format nil \"~:R\" 999) \"nine hundred ninety-ninth\"\n  )\n\n(simple-tests roman-tests\n  (cl-format nil \"~@R\" 3) \"III\"\n  (cl-format nil \"~@R\" 4) \"IV\"\n  (cl-format nil \"~@R\" 9) \"IX\"\n  (cl-format nil \"~@R\" 29) \"XXIX\"\n  (cl-format nil \"~@R\" 429) \"CDXXIX\"\n  (cl-format nil \"~@:R\" 429) \"CCCCXXVIIII\"\n  (cl-format nil \"~@:R\" 3429) \"MMMCCCCXXVIIII\"\n  (cl-format nil \"~@R\" 3429) \"MMMCDXXIX\"\n  (cl-format nil \"~@R\" 3479) \"MMMCDLXXIX\"\n  (cl-format nil \"~@R\" 3409) \"MMMCDIX\"\n  (cl-format nil \"~@R\" 300) \"CCC\"\n  (cl-format nil \"~@R ~D\" 300 20) \"CCC 20\"\n  (cl-format nil \"~@R\" 5000) \"5,000\"\n  (cl-format nil \"~@R ~D\" 5000 20) \"5,000 20\"\n  (cl-format nil \"~@R\" \"the quick\") \"the quick\")\n\n(simple-tests c-tests\n  (cl-format nil \"~{~c~^, ~}~%\" \"hello\") \"h, e, l, l, o\\n\"\n  (cl-format nil \"~{~:c~^, ~}~%\" \"hello\") \"h, e, l, l, o\\n\"\n  (cl-format nil \"~@C~%\" \\m) \"\\\\m\\n\"\n  (cl-format nil \"~@C~%\" (char 222)) \"\\\\Þ\\n\"\n  (cl-format nil \"~@C~%\" (char 8)) \"\\\\backspace\\n\"\n  (cl-format nil \"~@C~%\" (char 3)) \"\\\\\u0003\\n\")\n\n(simple-tests e-tests\n  (cl-format nil \"*~E*\" 0.0) \"*0.0E+0*\"\n  (cl-format nil \"*~6E*\" 0.0) \"*0.0E+0*\"\n  (cl-format nil \"*~6,0E*\" 0.0) \"* 0.E+0*\"\n  (cl-format nil \"*~7,2E*\" 0.0) \"*0.00E+0*\"\n  (cl-format nil \"*~5E*\" 0.0) \"*0.E+0*\"\n  (cl-format nil \"*~10,2,2,,'?E*\" 2.8E120) \"*??????????*\"\n  (cl-format nil \"*~10,2E*\" 9.99999) \"*   1.00E+1*\"\n  (cl-format nil \"*~10,2E*\" 9.99999E99) \"* 1.00E+100*\"\n  (cl-format nil \"*~10,2,2E*\" 9.99999E99) \"* 1.00E+100*\"\n  (cl-format nil \"*~10,2,2,,'?E*\" 9.99999E99) \"*??????????*\"\n  )\n  \n(simple-tests $-tests\n  (cl-format nil \"~$\" 22.3) \"22.30\"\n  (cl-format nil \"~$\" 22.375) \"22.38\"\n  (cl-format nil \"~3,5$\" 22.375) \"00022.375\"\n  (cl-format nil \"~3,5,8$\" 22.375) \"00022.375\"\n  (cl-format nil \"~3,5,10$\" 22.375) \" 00022.375\"\n  (cl-format nil \"~3,5,14@$\" 22.375) \"    +00022.375\"\n  (cl-format nil \"~3,5,14@$\" 22.375) \"    +00022.375\"\n  (cl-format nil \"~3,5,14@:$\" 22.375) \"+    00022.375\"\n  (cl-format nil \"~3,,14@:$\" 0.375) \"+        0.375\"\n  (cl-format nil \"~1,1$\" -12.0) \"-12.0\"\n  (cl-format nil \"~1,1$\" 12.0) \"12.0\"\n  (cl-format nil \"~1,1$\" 12.0) \"12.0\"\n  (cl-format nil \"~1,1@$\" 12.0) \"+12.0\"\n  (cl-format nil \"~1,1,8,' @:$\" 12.0) \"+   12.0\"\n  (cl-format nil \"~1,1,8,' @$\" 12.0) \"   +12.0\"\n  (cl-format nil \"~1,1,8,' :$\" 12.0) \"    12.0\"\n  (cl-format nil \"~1,1,8,' $\" 12.0) \"    12.0\"\n  (cl-format nil \"~1,1,8,' @:$\" -12.0) \"-   12.0\"\n  (cl-format nil \"~1,1,8,' @$\" -12.0) \"   -12.0\"\n  (cl-format nil \"~1,1,8,' :$\" -12.0) \"-   12.0\"\n  (cl-format nil \"~1,1,8,' $\" -12.0) \"   -12.0\"\n  (cl-format nil \"~1,1$\" 0.001) \"0.0\"\n  (cl-format nil \"~2,1$\" 0.001) \"0.00\"\n  (cl-format nil \"~1,1,6$\" 0.001) \"   0.0\"\n  (cl-format nil \"~1,1,6$\" 0.0015) \"   0.0\"\n  (cl-format nil \"~2,1,6$\" 0.005) \"  0.01\"\n  (cl-format nil \"~2,1,6$\" 0.01) \"  0.01\"\n  (cl-format nil \"~$\" 0.099) \"0.10\"\n  (cl-format nil \"~1$\" 0.099) \"0.1\"\n  (cl-format nil \"~1$\" 0.1) \"0.1\"\n  (cl-format nil \"~1$\" 0.99) \"1.0\"\n  (cl-format nil \"~1$\" -0.99) \"-1.0\")\n\n(simple-tests f-tests\n  (cl-format nil \"~,1f\" -12.0) \"-12.0\"\n  (cl-format nil \"~,0f\" 9.4) \"9.\"\n  (cl-format nil \"~,0f\" 9.5) \"10.\"\n  (cl-format nil \"~,0f\" -0.99) \"-1.\"\n  (cl-format nil \"~,1f\" -0.99) \"-1.0\"\n  (cl-format nil \"~,2f\" -0.99) \"-0.99\"\n  (cl-format nil \"~,3f\" -0.99) \"-0.990\"\n  (cl-format nil \"~,0f\" 0.99) \"1.\"\n  (cl-format nil \"~,1f\" 0.99) \"1.0\"\n  (cl-format nil \"~,2f\" 0.99) \"0.99\"\n  (cl-format nil \"~,3f\" 0.99) \"0.990\"\n  (cl-format nil \"~,3f\" -0.099) \"-0.099\"\n  (cl-format nil \"~,4f\" -0.099) \"-0.0990\"\n  (cl-format nil \"~,5f\" -0.099) \"-0.09900\"\n  (cl-format nil \"~,3f\" 0.099) \"0.099\"\n  (cl-format nil \"~,4f\" 0.099) \"0.0990\"\n  (cl-format nil \"~,5f\" 0.099) \"0.09900\"\n  (cl-format nil \"~f\" -1) \"-1.0\"\n  (cl-format nil \"~2f\" -1) \"-1.\"\n  (cl-format nil \"~3f\" -1) \"-1.\"\n  (cl-format nil \"~4f\" -1) \"-1.0\"\n  (cl-format nil \"~8f\" -1) \"    -1.0\"\n  (cl-format nil \"~2f\" -0.0099) \"-0.\"\n  (cl-format nil \"~3f\" -0.0099) \"-0.\"\n  (cl-format nil \"~4f\" -0.0099) \"-.01\"\n  (cl-format nil \"~5f\" -0.0099) \"-0.01\"\n  (cl-format nil \"~6f\" -0.0099) \"-.0099\"\n  (cl-format nil \"~1f\" 0.0099) \"0.\"\n  (cl-format nil \"~2f\" 0.0099) \"0.\"\n  (cl-format nil \"~3f\" 0.0099) \".01\"\n  (cl-format nil \"~4f\" 0.0099) \"0.01\"\n  (cl-format nil \"~5f\" 0.0099) \".0099\"\n  (cl-format nil \"~6f\" 0.0099) \"0.0099\"\n  (cl-format nil \"~1f\" -0.099) \"-.1\"\n  (cl-format nil \"~2f\" -0.099) \"-.1\"\n  (cl-format nil \"~3f\" -0.099) \"-.1\"\n  (cl-format nil \"~4f\" -0.099) \"-0.1\"\n  (cl-format nil \"~5f\" -0.099) \"-.099\"\n  (cl-format nil \"~6f\" -0.099) \"-0.099\"\n  (cl-format nil \"~1f\" 0.099) \".1\"\n  (cl-format nil \"~2f\" 0.099) \".1\"\n  (cl-format nil \"~3f\" 0.099) \"0.1\"\n  (cl-format nil \"~4f\" 0.099) \".099\"\n  (cl-format nil \"~5f\" 0.099) \"0.099\"\n  (cl-format nil \"~1f\" -0.99) \"-1.\"\n  (cl-format nil \"~2f\" -0.99) \"-1.\"\n  (cl-format nil \"~3f\" -0.99) \"-1.\"\n  (cl-format nil \"~4f\" -0.99) \"-.99\"\n  (cl-format nil \"~5f\" -0.99) \"-0.99\"\n  (cl-format nil \"~1f\" 0.99) \"1.\"\n  (cl-format nil \"~2f\" 0.99) \"1.\"\n  (cl-format nil \"~3f\" 0.99) \".99\"\n  (cl-format nil \"~4f\" 0.99) \"0.99\"\n  (cl-format nil \"~1f\" 111.11111) \"111.\"\n  (cl-format nil \"~4f\" 111.11111) \"111.\"\n  (cl-format nil \"~5f\" 111.11111) \"111.1\"\n  (cl-format nil \"~1f\" -111.11111) \"-111.\"\n  (cl-format nil \"~5f\" -111.11111) \"-111.\"\n  (cl-format nil \"~6f\" -111.11111) \"-111.1\"\n  (cl-format nil \"~1f\" 555.55555) \"556.\"\n  (cl-format nil \"~4f\" 555.55555) \"556.\"\n  (cl-format nil \"~5f\" 555.55555) \"555.6\"\n  (cl-format nil \"~8f\" 555.55555) \"555.5556\"\n  (cl-format nil \"~1f\" -555.55555) \"-556.\"\n  (cl-format nil \"~5f\" -555.55555) \"-556.\"\n  (cl-format nil \"~6f\" -555.55555) \"-555.6\"\n  (cl-format nil \"~8f\" -555.55555) \"-555.556\"\n  (cl-format nil \"~1f\" 999.999) \"1000.\"\n  (cl-format nil \"~5f\" 999.999) \"1000.\"\n  (cl-format nil \"~6f\" 999.999) \"1000.0\"\n  (cl-format nil \"~7f\" 999.999) \"999.999\"\n  (cl-format nil \"~8f\" 999.999) \" 999.999\"\n  (cl-format nil \"~1f\" -999.999) \"-1000.\"\n  (cl-format nil \"~6f\" -999.999) \"-1000.\"\n  (cl-format nil \"~7f\" -999.999) \"-1000.0\"\n  (cl-format nil \"~8f\" -999.999) \"-999.999\"\n  (cl-format nil \"~5,2f\" 111.11111) \"111.11\"\n  (cl-format nil \"~3,1f\" -0.0099) \"-.0\"\n  (cl-format nil \"~6,4f\" -0.0099) \"-.0099\"\n  (cl-format nil \"~6,5f\" -0.0099) \"-.00990\"\n  (cl-format nil \"~6,6f\" -0.0099) \"-.009900\"\n  (cl-format nil \"~6,4f\" 0.0099) \"0.0099\"\n  (cl-format nil \"~6,5f\" 0.0099) \".00990\"\n  (cl-format nil \"~6,6f\" 0.0099) \".009900\"\n  (cl-format nil \"~2,1f\" 0.0099) \".0\"\n  (cl-format nil \"~6,2f\" -111.11111) \"-111.11\"\n  (cl-format nil \"~6,3f\" -111.11111) \"-111.111\"\n  (cl-format nil \"~8,5f\" -111.11111) \"-111.11111\"\n  (cl-format nil \"~12,10f\" 1.23456789014) \"1.2345678901\"\n  (cl-format nil \"~12,10f\" 1.23456789016) \"1.2345678902\"\n  (cl-format nil \"~13,10f\" -1.23456789014) \"-1.2345678901\"\n  (cl-format nil \"~13,10f\" -1.23456789016) \"-1.2345678902\"\n  (cl-format nil \"~1,1f\" 0.1) \".1\")\n\n(simple-tests ampersand-tests\n  (cl-format nil \"The quick brown ~a jumped over ~d lazy dogs\" 'elephant 5)\n  \"The quick brown elephant jumped over 5 lazy dogs\"\n  (cl-format nil \"The quick brown ~&~a jumped over ~d lazy dogs\" 'elephant 5)\n  \"The quick brown \\nelephant jumped over 5 lazy dogs\"\n  (cl-format nil (platform-newlines \"The quick brown ~&~a jumped\\n~& over ~d lazy dogs\") 'elephant 5)\n  \"The quick brown \\nelephant jumped\\n over 5 lazy dogs\"\n  (cl-format nil (platform-newlines \"~&The quick brown ~&~a jumped\\n~& over ~d lazy dogs\") 'elephant 5)\n  \"The quick brown \\nelephant jumped\\n over 5 lazy dogs\"\n  (cl-format nil (platform-newlines \"~3&The quick brown ~&~a jumped\\n~& over ~d lazy dogs\") 'elephant 5)\n  \"\\n\\nThe quick brown \\nelephant jumped\\n over 5 lazy dogs\"\n  (cl-format nil \"~@{~&The quick brown ~a jumped over ~d lazy dogs~}\" 'elephant 5 'fox 10)\n  \"The quick brown elephant jumped over 5 lazy dogs\\nThe quick brown fox jumped over 10 lazy dogs\"\n  (cl-format nil \"I ~[don't ~:;d~&o ~]have one~%\" 0) \"I don't have one\\n\"\n  (cl-format nil \"I ~[don't ~:;d~&o ~]have one~%\" 1) \"I d\\no have one\\n\")\n\n(simple-tests t-tests\n  (cl-format nil \"~@{~&~A~8,4T~:*~A~}\" \n             'a 'aa 'aaa 'aaaa 'aaaaa 'aaaaaa 'aaaaaaa 'aaaaaaaa 'aaaaaaaaa 'aaaaaaaaaa)\n  \"a       a\\naa      aa\\naaa     aaa\\naaaa    aaaa\\naaaaa   aaaaa\\naaaaaa  aaaaaa\\naaaaaaa aaaaaaa\\naaaaaaaa    aaaaaaaa\\naaaaaaaaa   aaaaaaaaa\\naaaaaaaaaa  aaaaaaaaaa\"\n  (cl-format nil \"~@{~&~A~,4T~:*~A~}\" \n             'a 'aa 'aaa 'aaaa 'aaaaa 'aaaaaa 'aaaaaaa 'aaaaaaaa 'aaaaaaaaa 'aaaaaaaaaa)\n  \"a    a\\naa   aa\\naaa  aaa\\naaaa aaaa\\naaaaa    aaaaa\\naaaaaa   aaaaaa\\naaaaaaa  aaaaaaa\\naaaaaaaa aaaaaaaa\\naaaaaaaaa    aaaaaaaaa\\naaaaaaaaaa   aaaaaaaaaa\"\n  (cl-format nil \"~@{~&~A~2,6@T~:*~A~}\" 'a 'aa 'aaa 'aaaa 'aaaaa 'aaaaaa 'aaaaaaa 'aaaaaaaa 'aaaaaaaaa 'aaaaaaaaaa)\n  \"a     a\\naa    aa\\naaa   aaa\\naaaa  aaaa\\naaaaa       aaaaa\\naaaaaa      aaaaaa\\naaaaaaa     aaaaaaa\\naaaaaaaa    aaaaaaaa\\naaaaaaaaa   aaaaaaaaa\\naaaaaaaaaa  aaaaaaaaaa\"\n)\n\n(simple-tests paren-tests\n  (cl-format nil \"~(PLEASE SPEAK QUIETLY IN HERE~)\") \"please speak quietly in here\"\n  (cl-format nil \"~@(PLEASE SPEAK QUIETLY IN HERE~)\") \"Please speak quietly in here\"\n  (cl-format nil \"~@:(but this Is imporTant~)\") \"BUT THIS IS IMPORTANT\"\n  (cl-format nil \"~:(the greAt gatsby~)!\") \"The Great Gatsby!\"\n  ;; Test cases from CLtL 18.3 - string-upcase, et al.\n  (cl-format nil \"~@:(~A~)\" \"Dr. Livingstone, I presume?\") \"DR. LIVINGSTONE, I PRESUME?\" \n  (cl-format nil \"~(~A~)\" \"Dr. Livingstone, I presume?\") \"dr. livingstone, i presume?\" \n  (cl-format nil \"~:(~A~)\" \" hello \") \" Hello \" \n  (cl-format nil \"~:(~A~)\" \"occlUDeD cASEmenTs FOreSTAll iNADVertent DEFenestraTION\") \n  \"Occluded Casements Forestall Inadvertent Defenestration\" \n  (cl-format nil \"~:(~A~)\" 'kludgy-hash-search) \"Kludgy-Hash-Search\" \n  (cl-format nil \"~:(~A~)\" \"DON'T!\") \"Don'T!\"     ;not \"Don't!\" \n  (cl-format nil \"~:(~A~)\" \"pipe 13a, foo16c\") \"Pipe 13a, Foo16c\"\n  (cl-format nil \"~:(~A~)\" nil) \"Nil\"\n  (cl-format nil \"~:(~A~)\" \"\") \"\"\n)\n\n(simple-tests square-bracket-tests\n  ;; Tests for format without modifiers\n  (cl-format nil \"I ~[don't ~]have one~%\" 0) \"I don't have one\\n\"\n  (cl-format nil \"I ~[don't ~]have one~%\" 1) \"I have one\\n\"\n  (cl-format nil \"I ~[don't ~;do ~]have one~%\" 0) \"I don't have one\\n\"\n  (cl-format nil \"I ~[don't ~;do ~]have one~%\" 1) \"I do have one\\n\"\n  (cl-format nil \"I ~[don't ~;do ~]have one~%\" 2) \"I have one\\n\"\n  (cl-format nil \"I ~[don't ~:;do ~]have one~%\" 0) \"I don't have one\\n\"\n  (cl-format nil \"I ~[don't ~:;do ~]have one~%\" 1) \"I do have one\\n\"\n  (cl-format nil \"I ~[don't ~:;do ~]have one~%\" 2) \"I do have one\\n\"\n  (cl-format nil \"I ~[don't ~:;do ~]have one~%\" 700) \"I do have one\\n\"\n\n  ;; Tests for format with a colon \n  (cl-format nil \"I ~:[don't ~;do ~]have one~%\" true) \"I do have one\\n\"\n  (cl-format nil \"I ~:[don't ~;do ~]have one~%\" 700) \"I do have one\\n\"\n  (cl-format nil \"I ~:[don't ~;do ~]have one~%\" '(a b)) \"I do have one\\n\"\n  (cl-format nil \"I ~:[don't ~;do ~]have one~%\" nil) \"I don't have one\\n\"\n  (cl-format nil \"I ~:[don't ~;do ~]have one~%\" false) \"I don't have one\\n\"\n\n  ;; Tests for format with an at sign\n  (cl-format nil \"We had ~D wins~@[ (out of ~D tries)~].~%\" 15 nil) \"We had 15 wins.\\n\"\n  (cl-format nil \"We had ~D wins~@[ (out of ~D tries)~].~%\" 15 17)\n  \"We had 15 wins (out of 17 tries).\\n\"\n\n  ;; Format tests with directives\n  (cl-format nil \"Max ~D: ~[Blue team ~D~;Red team ~D~:;No team ~A~].~%\" 15, 0, 7)\n  \"Max 15: Blue team 7.\\n\"\n  (cl-format nil \"Max ~D: ~[Blue team ~D~;Red team ~D~:;No team ~A~].~%\" 15, 1, 12)\n  \"Max 15: Red team 12.\\n\"\n  (cl-format nil \"Max ~D: ~[Blue team ~D~;Red team ~D~:;No team ~A~].~%\" \n             15, -1, \"(system failure)\")\n  \"Max 15: No team (system failure).\\n\"\n\n  ;; Nested format tests\n  (cl-format nil \"Max ~D: ~[Blue team ~D~:[~; (complete success)~]~;Red team ~D~:;No team ~].~%\" \n             15, 0, 7, true)\n  \"Max 15: Blue team 7 (complete success).\\n\"\n  (cl-format nil \"Max ~D: ~[Blue team ~D~:[~; (complete success)~]~;Red team ~D~:;No team ~].~%\" \n             15, 0, 7, false)\n  \"Max 15: Blue team 7.\\n\"\n\n  ;; Test the selector as part of the argument\n  (cl-format nil \"The answer is ~#[nothing~;~D~;~D out of ~D~:;something crazy~].\")\n  \"The answer is nothing.\"\n  (cl-format nil \"The answer is ~#[nothing~;~D~;~D out of ~D~:;something crazy~].\" 4)\n  \"The answer is 4.\"\n  (cl-format nil \"The answer is ~#[nothing~;~D~;~D out of ~D~:;something crazy~].\" 7 22)\n  \"The answer is 7 out of 22.\"\n  (cl-format nil \"The answer is ~#[nothing~;~D~;~D out of ~D~:;something crazy~].\" 1 2 3 4)\n  \"The answer is something crazy.\"\n)\n\n(simple-tests curly-brace-plain-tests\n  ;; Iteration from sublist\n  (cl-format nil \"Coordinates are~{ [~D,~D]~}~%\" [ 0, 1, 1, 0, 3, 5, 2, 1 ])\n  \"Coordinates are [0,1] [1,0] [3,5] [2,1]\\n\"\n\n  (cl-format nil \"Coordinates are~2{ [~D,~D]~}~%\" [ 0, 1, 1, 0, 3, 5, 2, 1 ])\n  \"Coordinates are [0,1] [1,0]\\n\"\n\n  (cl-format nil \"Coordinates are~{ ~#[none~;<~D>~:;[~D,~D]~]~}~%\" [ ])\n  \"Coordinates are\\n\"\n\n  (cl-format nil \"Coordinates are~{ ~#[none~;<~D>~:;[~D,~D]~]~:}~%\" [ ])\n  \"Coordinates are none\\n\"\n\n  (cl-format nil \"Coordinates are~{ ~#[none~;<~D>~:;[~D,~D]~]~:}~%\" [2 3 1])\n  \"Coordinates are [2,3] <1>\\n\"\n\n  (cl-format nil \"Coordinates are~{~:}~%\" \"\" [])\n  \"Coordinates are\\n\"\n\n  (cl-format nil \"Coordinates are~{~:}~%\" \" ~#[none~;<~D>~:;[~D,~D]~]\" [2 3 1])\n  \"Coordinates are [2,3] <1>\\n\"\n\n  (cl-format nil \"Coordinates are~{~:}~%\" \" ~#[none~;<~D>~:;[~D,~D]~]\" [ ])\n  \"Coordinates are none\\n\"\n)\n\n\n(simple-tests curly-brace-colon-tests\n  ;; Iteration from list of sublists\n  (cl-format nil \"Coordinates are~:{ [~D,~D]~}~%\" [ [0, 1], [1, 0], [3, 5], [2, 1] ])\n  \"Coordinates are [0,1] [1,0] [3,5] [2,1]\\n\"\n\n  (cl-format nil \"Coordinates are~:{ [~D,~D]~}~%\" [ [0, 1, 0], [1, 0, 12], [3, 5], [2, 1] ])\n  \"Coordinates are [0,1] [1,0] [3,5] [2,1]\\n\"\n\n  (cl-format nil \"Coordinates are~2:{ [~D,~D]~}~%\" [ [0, 1], [1, 0], [3, 5], [2, 1] ])\n  \"Coordinates are [0,1] [1,0]\\n\"\n\n  (cl-format nil \"Coordinates are~:{ ~#[none~;<~D>~:;[~D,~D]~]~}~%\" [ ])\n  \"Coordinates are\\n\"\n\n  (cl-format nil \"Coordinates are~:{ ~#[none~;<~D>~:;[~D,~D]~]~:}~%\" [ ])\n  \"Coordinates are none\\n\"\n\n  (cl-format nil \"Coordinates are~:{ ~#[none~;<~D>~:;[~D,~D]~]~:}~%\" [[2 3] [1]])\n  \"Coordinates are [2,3] <1>\\n\"\n\n  (cl-format nil \"Coordinates are~:{~:}~%\" \"\" [])\n  \"Coordinates are\\n\"\n\n  (cl-format nil \"Coordinates are~:{~:}~%\" \" ~#[none~;<~D>~:;[~D,~D]~]\" [[2 3] [1]])\n  \"Coordinates are [2,3] <1>\\n\"\n\n  (cl-format nil \"Coordinates are~:{~:}~%\" \" ~#[none~;<~D>~:;[~D,~D]~]\" [ ])\n  \"Coordinates are none\\n\"\n)\n\n(simple-tests curly-brace-at-tests\n  ;; Iteration from main list\n  (cl-format nil \"Coordinates are~@{ [~D,~D]~}~%\"  0, 1, 1, 0, 3, 5, 2, 1)\n  \"Coordinates are [0,1] [1,0] [3,5] [2,1]\\n\"\n\n  (cl-format nil \"Coordinates are~2@{ [~D,~D]~}~%\" 0, 1, 1, 0, 3, 5, 2, 1)\n  \"Coordinates are [0,1] [1,0]\\n\"\n\n  (cl-format nil \"Coordinates are~@{ ~#[none~;<~D>~:;[~D,~D]~]~}~%\")\n  \"Coordinates are\\n\"\n\n  (cl-format nil \"Coordinates are~@{ ~#[none~;<~D>~:;[~D,~D]~]~:}~%\")\n  \"Coordinates are none\\n\"\n\n  (cl-format nil \"Coordinates are~@{ ~#[none~;<~D>~:;[~D,~D]~]~:}~%\" 2 3 1)\n  \"Coordinates are [2,3] <1>\\n\"\n\n  (cl-format nil \"Coordinates are~@{~:}~%\" \"\")\n  \"Coordinates are\\n\"\n\n  (cl-format nil \"Coordinates are~@{~:}~%\" \" ~#[none~;<~D>~:;[~D,~D]~]\" 2 3 1)\n  \"Coordinates are [2,3] <1>\\n\"\n\n  (cl-format nil \"Coordinates are~@{~:}~%\" \" ~#[none~;<~D>~:;[~D,~D]~]\")\n  \"Coordinates are none\\n\"\n)\n\n(simple-tests curly-brace-colon-at-tests\n  ;; Iteration from sublists on the main arg list\n  (cl-format nil \"Coordinates are~@:{ [~D,~D]~}~%\"  [0, 1], [1, 0], [3, 5], [2, 1] )\n  \"Coordinates are [0,1] [1,0] [3,5] [2,1]\\n\"\n\n  (cl-format nil \"Coordinates are~@:{ [~D,~D]~}~%\" [0, 1, 0], [1, 0, 12], [3, 5], [2, 1] )\n  \"Coordinates are [0,1] [1,0] [3,5] [2,1]\\n\"\n\n  (cl-format nil \"Coordinates are~2@:{ [~D,~D]~}~%\" [0, 1], [1, 0], [3, 5], [2, 1])\n  \"Coordinates are [0,1] [1,0]\\n\"\n\n  (cl-format nil \"Coordinates are~@:{ ~#[none~;<~D>~:;[~D,~D]~]~}~%\")\n  \"Coordinates are\\n\"\n\n  (cl-format nil \"Coordinates are~@:{ ~#[none~;<~D>~:;[~D,~D]~]~:}~%\")\n  \"Coordinates are none\\n\"\n\n  (cl-format nil \"Coordinates are~@:{ ~#[none~;<~D>~:;[~D,~D]~]~:}~%\" [2 3] [1])\n  \"Coordinates are [2,3] <1>\\n\"\n\n  (cl-format nil \"Coordinates are~@:{~:}~%\" \"\")\n  \"Coordinates are\\n\"\n\n  (cl-format nil \"Coordinates are~@:{~:}~%\" \" ~#[none~;<~D>~:;[~D,~D]~]\" [2 3] [1])\n  \"Coordinates are [2,3] <1>\\n\"\n\n  (cl-format nil \"Coordinates are~@:{~:}~%\" \" ~#[none~;<~D>~:;[~D,~D]~]\")\n  \"Coordinates are none\\n\"\n)\n\n;; TODO tests for ~^ in ~[ constructs and other brackets\n;; TODO test ~:^ generates an error when used improperly\n;; TODO test ~:^ works in ~@:{...~}\n(let [aseq '(a quick brown fox jumped over the lazy dog)\n      lseq (mapcat identity (for [x aseq] [x (.length (name x))]))]\n  (simple-tests up-tests\n    (cl-format nil \"~{~a~^, ~}\" aseq) \"a, quick, brown, fox, jumped, over, the, lazy, dog\"\n    (cl-format nil \"~{~a~0^, ~}\" aseq) \"a\"\n    (cl-format nil \"~{~a~#,3^, ~}\" aseq) \"a, quick, brown, fox, jumped, over\"\n    (cl-format nil \"~{~a~v,3^, ~}\" lseq) \"a, quick, brown, fox\"\n    (cl-format nil \"~{~a~3,v,4^, ~}\" lseq) \"a, quick, brown, fox\"\n))\n\n(simple-tests angle-bracket-tests\n  (cl-format nil \"~<foo~;bar~;baz~>\") \"foobarbaz\"\n  (cl-format nil \"~20<foo~;bar~;baz~>\") \"foo      bar     baz\"\n  (cl-format nil \"~,,2<foo~;bar~;baz~>\") \"foo  bar  baz\"\n  (cl-format nil \"~20<~A~;~A~;~A~>\" \"foo\" \"bar\" \"baz\") \"foo      bar     baz\"\n  (cl-format nil \"~20:<~A~;~A~;~A~>\" \"foo\" \"bar\" \"baz\") \"    foo    bar   baz\"\n  (cl-format nil \"~20@<~A~;~A~;~A~>\" \"foo\" \"bar\" \"baz\") \"foo    bar    baz   \"\n  (cl-format nil \"~20@:<~A~;~A~;~A~>\" \"foo\" \"bar\" \"baz\") \"   foo   bar   baz  \"\n  (cl-format nil \"~10,,2<~A~;~A~;~A~>\" \"foo\" \"bar\" \"baz\") \"foo  bar  baz\"\n  (cl-format nil \"~10,10,2<~A~;~A~;~A~>\" \"foo\" \"bar\" \"baz\") \"foo      bar     baz\"\n  (cl-format nil \"~10,10<~A~;~A~;~A~>\" \"foo\" \"bar\" \"baz\") \"foo barbaz\"\n  (cl-format nil \"~20<~A~;~^~A~;~^~A~>\" \"foo\" \"bar\" \"baz\") \"foo      bar     baz\"\n  (cl-format nil \"~20<~A~;~^~A~;~^~A~>\" \"foo\" \"bar\") \"foo              bar\"\n  (cl-format nil \"~20@<~A~;~^~A~;~^~A~>\" \"foo\") \"foo                 \"\n  (cl-format nil \"~20:<~A~;~^~A~;~^~A~>\" \"foo\") \"                 foo\"\n)\n\n(simple-tests angle-bracket-max-column-tests\n  (cl-format nil \"~%;; ~{~<~%;; ~1,50:; ~A~>~}.~%\" (into [] (.split \"This function computes the circular thermodynamic coefficient of the thrombulator angle for use in determining the reaction distance\" \"\\\\s\")))\n  \"\\n;;  This function computes the circular\\n;;  thermodynamic coefficient of the thrombulator\\n;;  angle for use in determining the reaction\\n;;  distance.\\n\"\n(cl-format true \"~%;; ~{~<~%;; ~:; ~A~>~}.~%\" (into [] (.split \"This function computes the circular thermodynamic coefficient of the thrombulator angle for use in determining the reaction distance.\" \"\\\\s\"))))\n\n(defn list-to-table [aseq column-width]\n  (let [stream (get-pretty-writer (java.io.StringWriter.))]\n    (binding [*out* stream]\n     (doseq [row aseq]\n       (doseq [col row]\n         (cl-format true \"~4D~7,vT\" col column-width))\n       (prn)))\n    (.flush stream)\n    (.toString (:base @@(:base @@stream)))))\n\n(simple-tests column-writer-test\n  (list-to-table (map #(vector % (* % %) (* % % %)) (range 1 21)) 8)\n  \"   1      1       1    \\n   2      4       8    \\n   3      9      27    \\n   4     16      64    \\n   5     25     125    \\n   6     36     216    \\n   7     49     343    \\n   8     64     512    \\n   9     81     729    \\n  10    100    1000    \\n  11    121    1331    \\n  12    144    1728    \\n  13    169    2197    \\n  14    196    2744    \\n  15    225    3375    \\n  16    256    4096    \\n  17    289    4913    \\n  18    324    5832    \\n  19    361    6859    \\n  20    400    8000    \\n\")\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;; The following tests are the various examples from the format\n;; documentation in Common Lisp, the Language, 2nd edition, Chapter 22.3\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(defn expt [base pow] (reduce * (repeat pow base)))\n\n(let [x 5, y \"elephant\", n 3]\n  (simple-tests cltl-intro-tests\n   (format nil \"foo\")  \"foo\" \n   (format nil \"The answer is ~D.\" x)  \"The answer is 5.\" \n   (format nil \"The answer is ~3D.\" x)  \"The answer is   5.\" \n   (format nil \"The answer is ~3,'0D.\" x)  \"The answer is 005.\" \n   (format nil \"The answer is ~:D.\" (expt 47 x)) \"The answer is 229,345,007.\"\n   (format nil \"Look at the ~A!\" y)  \"Look at the elephant!\" \n   (format nil \"Type ~:C to ~A.\" (char 4) \"delete all your files\") \n   \"Type Control-D to delete all your files.\"\n   (format nil \"~D item~:P found.\" n)  \"3 items found.\"\n   (format nil \"~R dog~:[s are~; is~] here.\" n (= n 1)) \"three dogs are here.\"\n   (format nil \"~R dog~:*~[s are~; is~:;s are~] here.\" n) \"three dogs are here.\"\n   (format nil \"Here ~[are~;is~:;are~] ~:*~R pupp~:@P.\" n) \"Here are three puppies.\"))\n \n(simple-tests cltl-B-tests\n  ;; CLtL didn't have the colons here, but the spec requires them\n  (format nil \"~,,' ,4:B\" 0xFACE) \"1111 1010 1100 1110\" \n  (format nil \"~,,' ,4:B\" 0x1CE) \"1 1100 1110\" \n  (format nil \"~19,,' ,4:B\" 0xFACE) \"1111 1010 1100 1110\" \n  ;; This one was a nice idea, but nothing in the spec supports it working this way\n  ;; (and SBCL doesn't work this way either)\n  ;(format nil \"~19,,' ,4:B\" 0x1CE) \"0000 0001 1100 1110\")\n  )\n\n(simple-tests cltl-P-tests\n  (format nil \"~D tr~:@P/~D win~:P\" 7 1) \"7 tries/1 win\" \n  (format nil \"~D tr~:@P/~D win~:P\" 1 0) \"1 try/0 wins\" \n  (format nil \"~D tr~:@P/~D win~:P\" 1 3) \"1 try/3 wins\")\n\n(defn foo [x] \n  (format nil \"~6,2F|~6,2,1,'*F|~6,2,,'?F|~6F|~,2F|~F\" \n          x x x x x x))\n\n;; big-pos-ratio is a ratio value that is larger than\n;; Double/MAX_VALUE, and has a non-terminating decimal representation\n;; if you attempt to represent it exactly.\n(def big-pos-ratio (/ (* 4 (bigint (. BigDecimal valueOf Double/MAX_VALUE))) 3))\n(def big-neg-ratio (- big-pos-ratio))\n;; tiny-pos-ratio is a ratio between 0 and Double/MIN_VALUE.\n(def tiny-pos-ratio (/ 1 (bigint (apply str (cons \"1\" (repeat 340 \"0\"))))))\n(def tiny-neg-ratio (- tiny-pos-ratio))\n\n(simple-tests cltl-F-tests\n  (cl-format false \"~10,3f\" 4/5) \"     0.800\"\n  (binding [*math-context* java.math.MathContext/DECIMAL128]\n    (cl-format false \"~10,3f\" big-pos-ratio)) \"239692417981642093333333333333333300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000\"\n  (binding [*math-context* java.math.MathContext/DECIMAL128]\n    (cl-format false \"~10,3f\" big-neg-ratio)) \"-239692417981642093333333333333333300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000\"\n  (binding [*math-context* java.math.MathContext/DECIMAL128]\n    (cl-format false \"~10,3f\" tiny-pos-ratio)) \"     0.000\"\n  (binding [*math-context* java.math.MathContext/DECIMAL128]\n    (cl-format false \"~10,3f\" tiny-neg-ratio)) \"    -0.000\"\n  (foo 3.14159)  \"  3.14| 31.42|  3.14|3.1416|3.14|3.14159\" \n  (foo 314159/100000)\n                 \"  3.14| 31.42|  3.14|3.1416|3.14|3.14159\"\n  (foo -3.14159) \" -3.14|-31.42| -3.14|-3.142|-3.14|-3.14159\" \n  (foo 100.0)    \"100.00|******|100.00| 100.0|100.00|100.0\" \n  (foo 1234.0)   \"1234.00|******|??????|1234.0|1234.00|1234.0\" \n  (foo 0.006)    \"  0.01|  0.06|  0.01| 0.006|0.01|0.006\")\n\n(defn foo-e [x] \n  (format nil \n          \"~9,2,1,,'*E|~10,3,2,2,'?,,'$E|~9,3,2,-2,'%@E|~9,2E\" \n          x x x x)) \n\n;; Clojure doesn't support float/double differences in representation\n(simple-tests cltl-E-tests\n  (cl-format false \"~10,3e\" 4/5) \"  8.000E-1\"\n  (binding [*math-context* java.math.MathContext/DECIMAL128]\n    (cl-format false \"~10,3e\" big-pos-ratio)) \"2.397E+308\"\n  (binding [*math-context* java.math.MathContext/DECIMAL128]\n    (cl-format false \"~10,3e\" big-neg-ratio)) \"-2.397E+308\"\n  (binding [*math-context* java.math.MathContext/DECIMAL128]\n    (cl-format false \"~10,3e\" tiny-pos-ratio)) \"1.000E-340\"\n  (binding [*math-context* java.math.MathContext/DECIMAL128]\n    (cl-format false \"~10,3e\" tiny-neg-ratio)) \"-1.000E-340\"\n  (foo-e 0.0314159) \"  3.14E-2| 31.42$-03|+.003E+01|  3.14E-2\"  ; Added this one \n  (foo-e 314159/10000000)\n                    \"  3.14E-2| 31.42$-03|+.003E+01|  3.14E-2\"\n  (foo-e 3.14159)  \"  3.14E+0| 31.42$-01|+.003E+03|  3.14E+0\" \n  (foo-e -3.14159) \" -3.14E+0|-31.42$-01|-.003E+03| -3.14E+0\"\n  (foo-e 1100.0)   \"  1.10E+3| 11.00$+02|+.001E+06|  1.10E+3\" \n; In Clojure, this is identical to the above\n;  (foo-e 1100.0L0) \"  1.10L+3| 11.00$+02|+.001L+06|  1.10L+3\" \n  (foo-e 1.1E13)   \"*********| 11.00$+12|+.001E+16| 1.10E+13\" \n  (foo-e 1.1E120)  \"*********|??????????|%%%%%%%%%|1.10E+120\" \n; Clojure doesn't support real numbers this large\n;  (foo-e 1.1L1200) \"*********|??????????|%%%%%%%%%|1.10L+1200\"\n)\n\n(simple-tests cltl-E-scale-tests\n  (map\n    (fn [k] (format nil \"Scale factor ~2D~:*: |~13,6,2,VE|\" \n                    (- k 5) 3.14159))              ;Prints 13 lines \n    (range 13))\n  '(\"Scale factor -5: | 0.000003E+06|\"\n    \"Scale factor -4: | 0.000031E+05|\"\n    \"Scale factor -3: | 0.000314E+04|\"\n    \"Scale factor -2: | 0.003142E+03|\"\n    \"Scale factor -1: | 0.031416E+02|\"\n    \"Scale factor  0: | 0.314159E+01|\"\n    \"Scale factor  1: | 3.141590E+00|\"\n    \"Scale factor  2: | 31.41590E-01|\"\n    \"Scale factor  3: | 314.1590E-02|\"\n    \"Scale factor  4: | 3141.590E-03|\"\n    \"Scale factor  5: | 31415.90E-04|\"\n    \"Scale factor  6: | 314159.0E-05|\"\n    \"Scale factor  7: | 3141590.E-06|\"))\n\n(defn foo-g [x] \n  (format nil \n          \"~9,2,1,,'*G|~9,3,2,3,'?,,'$G|~9,3,2,0,'%G|~9,2G\" \n          x x x x)) \n\n;; Clojure doesn't support float/double differences in representation\n(simple-tests cltl-G-tests\n  (cl-format false \"~10,3g\" 4/5)  \" 0.800    \"\n  (binding [*math-context* java.math.MathContext/DECIMAL128]\n    (cl-format false \"~10,3g\" big-pos-ratio)) \"2.397E+308\"\n  (binding [*math-context* java.math.MathContext/DECIMAL128]\n    (cl-format false \"~10,3g\" big-neg-ratio)) \"-2.397E+308\"\n  (binding [*math-context* java.math.MathContext/DECIMAL128]\n    (cl-format false \"~10,3g\" tiny-pos-ratio)) \"1.000E-340\"\n  (binding [*math-context* java.math.MathContext/DECIMAL128]\n    (cl-format false \"~10,3g\" tiny-neg-ratio)) \"-1.000E-340\"\n  (foo-g 0.0314159) \"  3.14E-2|314.2$-04|0.314E-01|  3.14E-2\" \n  (foo-g 314159/10000000)\n                    \"  3.14E-2|314.2$-04|0.314E-01|  3.14E-2\"\n  (foo-g 0.314159)  \"  0.31   |0.314    |0.314    | 0.31    \" \n  (foo-g 3.14159)   \"   3.1   | 3.14    | 3.14    |  3.1    \" \n  (foo-g 31.4159)   \"   31.   | 31.4    | 31.4    |  31.    \" \n  (foo-g 314.159)   \"  3.14E+2| 314.    | 314.    |  3.14E+2\" \n  (foo-g 3141.59)   \"  3.14E+3|314.2$+01|0.314E+04|  3.14E+3\" \n; In Clojure, this is identical to the above\n;  (foo-g 3141.59L0) \"  3.14L+3|314.2$+01|0.314L+04|  3.14L+3\" \n  (foo-g 3.14E12)   \"*********|314.0$+10|0.314E+13| 3.14E+12\" \n  (foo-g 3.14E120)  \"*********|?????????|%%%%%%%%%|3.14E+120\" \n; Clojure doesn't support real numbers this large\n;  (foo-g 3.14L1200) \"*********|?????????|%%%%%%%%%|3.14L+1200\"\n)\n\n(defn type-clash-error [fun nargs argnum right-type wrong-type]\n  (format nil ;; CLtL has this format string slightly wrong\n          \"~&Function ~S requires its ~:[~:R ~;~*~]~\n           argument to be of type ~S,~%but it was called ~\n           with an argument of type ~S.~%\" \n          fun (= nargs 1) argnum right-type wrong-type)) \n\n(simple-tests cltl-Newline-tests\n  (type-clash-error 'aref nil 2 'integer 'vector)\n\"Function aref requires its second argument to be of type integer,\nbut it was called with an argument of type vector.\\n\"\n  (type-clash-error 'car 1 1 'list 'short-float)\n\"Function car requires its argument to be of type list,\nbut it was called with an argument of type short-float.\\n\")\n\n(simple-tests cltl-?-tests\n  (format nil \"~? ~D\" \"<~A ~D>\" '(\"Foo\" 5) 7) \"<Foo 5> 7\" \n  (format nil \"~? ~D\" \"<~A ~D>\" '(\"Foo\" 5 14) 7) \"<Foo 5> 7\"\n  (format nil \"~@? ~D\" \"<~A ~D>\" \"Foo\" 5 7) \"<Foo 5> 7\" \n  (format nil \"~@? ~D\" \"<~A ~D>\" \"Foo\" 5 14 7) \"<Foo 5> 14\")\n\n(defn f [n] (format nil \"~@(~R~) error~:P detected.\" n)) \n\n(simple-tests cltl-paren-tests\n  (format nil \"~@R ~(~@R~)\" 14 14) \"XIV xiv\" \n  (f 0) \"Zero errors detected.\" \n  (f 1) \"One error detected.\" \n  (f 23) \"Twenty-three errors detected.\")\n\n(let [*print-level* nil *print-length* 5] \n  (simple-tests cltl-bracket-tests\n    (format nil \"~@[ print level = ~D~]~@[ print length = ~D~]\" \n            *print-level* *print-length*) \n    \" print length = 5\"))\n\n(let [foo \"Items:~#[ none~; ~S~; ~S and ~S~\n           ~:;~@{~#[~; and~] ~\n           ~S~^,~}~].\"]\n  (simple-tests cltl-bracket1-tests\n    (format nil foo) \"Items: none.\" \n    (format nil foo 'foo) \"Items: foo.\" \n    (format nil foo 'foo 'bar) \"Items: foo and bar.\" \n    (format nil foo 'foo 'bar 'baz) \"Items: foo, bar, and baz.\" \n    (format nil foo 'foo 'bar 'baz 'quux) \"Items: foo, bar, baz, and quux.\"))\n\n(simple-tests cltl-curly-bracket-tests\n  (format nil \n        \"The winners are:~{ ~S~}.\" \n        '(fred harry jill)) \n  \"The winners are: fred harry jill.\" \n\n  (format nil \"Pairs:~{ <~S,~S>~}.\" '(a 1 b 2 c 3)) \n  \"Pairs: <a,1> <b,2> <c,3>.\"\n\n  (format nil \"Pairs:~:{ <~S,~S>~}.\" '((a 1) (b 2) (c 3))) \n  \"Pairs: <a,1> <b,2> <c,3>.\"\n\n  (format nil \"Pairs:~@{ <~S,~S>~}.\" 'a 1 'b 2 'c 3) \n  \"Pairs: <a,1> <b,2> <c,3>.\"\n\n  (format nil \"Pairs:~:@{ <~S,~S>~}.\" '(a 1) '(b 2) '(c 3)) \n  \"Pairs: <a,1> <b,2> <c,3>.\")\n\n(simple-tests cltl-angle-bracket-tests\n  (format nil \"~10<foo~;bar~>\")           \"foo    bar\" \n  (format nil \"~10:<foo~;bar~>\")          \"  foo  bar\" \n  (format nil \"~10:@<foo~;bar~>\")         \"  foo bar \" \n  (format nil \"~10<foobar~>\")             \"    foobar\" \n  (format nil \"~10:<foobar~>\")            \"    foobar\" \n  (format nil \"~10@<foobar~>\")            \"foobar    \" \n  (format nil \"~10:@<foobar~>\")           \"  foobar  \")\n\n(let [donestr \"Done.~^  ~D warning~:P.~^  ~D error~:P.\"\n      tellstr \"~@{~@(~@[~R~^ ~]~A~)~}.\"] ;; The CLtL example is a little wrong here\n\n  (simple-tests cltl-up-tests\n    (format nil donestr) \"Done.\" \n    (format nil donestr 3) \"Done.  3 warnings.\" \n    (format nil donestr 1 5) \"Done.  1 warning.  5 errors.\"\n    (format nil tellstr 23) \"Twenty-three.\" \n    (format nil tellstr nil \"losers\") \"Losers.\" \n    (format nil tellstr 23 \"losers\") \"Twenty-three losers.\"\n    (format nil \"~15<~S~;~^~S~;~^~S~>\" 'foo) \n    \"            foo\" \n    (format nil \"~15<~S~;~^~S~;~^~S~>\" 'foo 'bar) \n    \"foo         bar\" \n    (format nil \"~15<~S~;~^~S~;~^~S~>\" 'foo 'bar 'baz) \n    \"foo   bar   baz\"))\n\n(simple-tests cltl-up-x3j13-tests\n  (format nil \n          \"~:{/~S~^ ...~}\" \n          '((hot dog) (hamburger) (ice cream) (french fries))) \n  \"/hot .../hamburger/ice .../french ...\"\n  (format nil \n          \"~:{/~S~:^ ...~}\" \n          '((hot dog) (hamburger) (ice cream) (french fries))) \n  \"/hot .../hamburger .../ice .../french\"\n\n  (format nil \n          \"~:{/~S~#:^ ...~}\"  ;; This is wrong in CLtL\n          '((hot dog) (hamburger) (ice cream) (french fries))) \n  \"/hot .../hamburger\")\n\n(simple-tests pprint-table-tests\n  (with-out-str\n    (print-table [:b :a]\n                 [{:a 1 :b {:a 'is-a} :c [\"hi\" \"there\"]}\n                  {:b 5 :a 7 :c \"dog\" :d -700}]))\n  \"\n|        :b | :a |\n|-----------+----|\n| {:a is-a} |  1 |\n|         5 |  7 |\n\"\n  (with-out-str\n    (print-table [:a :e :d :c]\n                 [{:a 54.7e17 :b {:a 'is-a} :c [\"hi\" \"there\"]}\n                  {:b 5 :a -2/3 :c \"dog\" :d 'panda}]))\n  \"\n|      :a | :e |    :d |             :c |\n|---------+----+-------+----------------|\n| 5.47E18 |    |       | [\\\"hi\\\" \\\"there\\\"] |\n|    -2/3 |    | panda |            dog |\n\"\n  )\n"
  },
  {
    "path": "test/clojure/test_clojure/pprint/test_helper.clj",
    "content": ";;; test_helper.clj -- part of the pretty printer for Clojure\n\n;   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Tom Faulhaber\n;; April 3, 2009\n\n\n;; This is just a macro to make my tests a little cleaner\n\n(ns clojure.test-clojure.pprint.test-helper\n  (:use [clojure.test :only (deftest is)]\n        [clojure.test-helper :only [platform-newlines]]))\n\n(defn- back-match [x y] (re-matches y x))\n\n(defmacro simple-tests [name & test-pairs]\n  `(deftest ~name\n     ~@(for [[x y] (partition 2 test-pairs)]\n         (cond \n          (instance? java.util.regex.Pattern y)\n          `(is (#'clojure.test-clojure.pprint.test-helper/back-match ~x ~y))\n          (instance? java.lang.String y) `(is (= ~x (platform-newlines ~y)))\n          :else `(is (= ~x ~y))))))\n\n"
  },
  {
    "path": "test/clojure/test_clojure/pprint/test_pretty.clj",
    "content": ";;; test_pretty.clj -- part of the pretty printer for Clojure\n\n;   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Tom Faulhaber\n;; April 3, 2009\n\n\n(in-ns 'clojure.test-clojure.pprint)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;;\n;;; Unit tests for the pretty printer\n;;;\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(simple-tests xp-fill-test\n  (binding [*print-pprint-dispatch* simple-dispatch\n            *print-right-margin* 38\n            *print-miser-width* nil]\n    (cl-format nil \"(let ~:<~@{~:<~w ~_~w~:>~^ ~:_~}~:>~_ ...)~%\"\n               '((x 4) (*print-length* nil) (z 2) (list nil))))\n  \"(let ((x 4) (*print-length* nil)\\n      (z 2) (list nil))\\n ...)\\n\"\n\n  (binding [*print-pprint-dispatch* simple-dispatch\n            *print-right-margin* 22]\n    (cl-format nil \"(let ~:<~@{~:<~w ~_~w~:>~^ ~:_~}~:>~_ ...)~%\"\n               '((x 4) (*print-length* nil) (z 2) (list nil))))\n  \"(let ((x 4)\\n      (*print-length*\\n       nil)\\n      (z 2)\\n      (list nil))\\n ...)\\n\")\n\n(simple-tests xp-miser-test\n  (binding [*print-pprint-dispatch* simple-dispatch\n            *print-right-margin* 10, *print-miser-width* 9]\n    (cl-format nil \"~:<LIST ~@_~W ~@_~W ~@_~W~:>\" '(first second third)))\n  \"(LIST\\n first\\n second\\n third)\"\n\n  (binding [*print-pprint-dispatch* simple-dispatch\n            *print-right-margin* 10, *print-miser-width* 8]\n    (cl-format nil \"~:<LIST ~@_~W ~@_~W ~@_~W~:>\" '(first second third)))\n  \"(LIST first second third)\")\n\n(simple-tests mandatory-fill-test\n  (cl-format nil\n             \"<pre>~%~<Usage: ~:I~@{*~a*~^~:@_~}~:>~%</pre>~%\"\n             [ \"hello\" \"gooodbye\" ])\n  \"<pre>\nUsage: *hello*\n       *gooodbye*\n</pre>\n\")\n\n(simple-tests prefix-suffix-test\n  (binding [*print-pprint-dispatch* simple-dispatch\n            *print-right-margin* 10, *print-miser-width* 10]\n    (cl-format nil \"~<{~;LIST ~@_~W ~@_~W ~@_~W~;}~:>\" '(first second third)))\n  \"{LIST\\n first\\n second\\n third}\")\n\n(simple-tests pprint-test\n  (binding [*print-pprint-dispatch* simple-dispatch]\n    (write '(defn foo [x y] \n              (let [result (* x y)] \n                (if (> result 400) \n                  (cl-format true \"That number is too big\")\n                  (cl-format true \"The  result of ~d x ~d is ~d\" x y result))))\n           :stream nil))\n  \"(defn\n foo\n [x y]\n (let\n  [result (* x y)]\n  (if\n   (> result 400)\n   (cl-format true \\\"That number is too big\\\")\n   (cl-format true \\\"The  result of ~d x ~d is ~d\\\" x y result))))\"\n\n  (with-pprint-dispatch code-dispatch\n    (write '(defn foo [x y] \n              (let [result (* x y)] \n                (if (> result 400) \n                  (cl-format true \"That number is too big\")\n                  (cl-format true \"The  result of ~d x ~d is ~d\" x y result))))\n           :stream nil))\n  \"(defn foo [x y]\n  (let [result (* x y)]\n    (if (> result 400)\n      (cl-format true \\\"That number is too big\\\")\n      (cl-format true \\\"The  result of ~d x ~d is ~d\\\" x y result))))\"\n\n  (binding [*print-pprint-dispatch* simple-dispatch\n            *print-right-margin* 15] \n    (write '(fn (cons (car x) (cdr y))) :stream nil))\n  \"(fn\\n (cons\\n  (car x)\\n  (cdr y)))\"\n\n  (with-pprint-dispatch code-dispatch\n    (binding [*print-right-margin* 52] \n      (write \n       '(add-to-buffer this (make-buffer-blob (str (char c)) nil))\n       :stream nil)))\n  \"(add-to-buffer\\n  this\\n  (make-buffer-blob (str (char c)) nil))\"\n  )\n\n\n\n(simple-tests pprint-reader-macro-test\n  (with-pprint-dispatch code-dispatch\n    (write (read-string \"(map #(first %) [[1 2 3] [4 5 6] [7]])\")\n\t   :stream nil))\n  \"(map #(first %) [[1 2 3] [4 5 6] [7]])\"\n\n  (with-pprint-dispatch code-dispatch\n    (write (read-string \"@@(ref (ref 1))\")\n\t   :stream nil))\n  \"@@(ref (ref 1))\"\n\n  (with-pprint-dispatch code-dispatch\n    (write (read-string \"'foo\")\n\t   :stream nil))\n  \"'foo\"\n)\n\n(defmacro code-block\n  \"Read a string then print it with code-dispatch and succeed if it comes out the same\"\n  [test-name & blocks]\n  `(simple-tests ~test-name\n     ~@(apply concat\n              (for [block blocks]\n                `[(str/split-lines\n                   (with-out-str\n                     (with-pprint-dispatch code-dispatch\n                       (pprint (read-string ~block)))))\n                  (str/split-lines ~block)]))))\n\n(code-block code-block-tests\n  \"(defn cl-format\n  \\\"An implementation of a Common Lisp compatible format function\\\"\n  [stream format-in & args]\n  (let [compiled-format (if (string? format-in)\n                          (compile-format format-in)\n                          format-in)\n        navigator (init-navigator args)]\n    (execute-format stream compiled-format navigator)))\"\n\n \"(defn pprint-defn [writer alis]\n  (if (next alis)\n    (let [[defn-sym defn-name & stuff] alis\n          [doc-str stuff] (if (string? (first stuff))\n                            [(first stuff) (next stuff)]\n                            [nil stuff])\n          [attr-map stuff] (if (map? (first stuff))\n                             [(first stuff) (next stuff)]\n                             [nil stuff])]\n      (pprint-logical-block\n        writer\n        :prefix\n        \\\"(\\\"\n        :suffix\n        \\\")\\\"\n        (cl-format true \\\"~w ~1I~@_~w\\\" defn-sym defn-name)\n        (if doc-str (cl-format true \\\" ~_~w\\\" doc-str))\n        (if attr-map (cl-format true \\\" ~_~w\\\" attr-map))\n        (cond\n          (vector? (first stuff)) (single-defn\n                                    stuff\n                                    (or doc-str attr-map))\n          :else (multi-defn stuff (or doc-str attr-map)))))\n    (pprint-simple-code-list writer alis)))\")\n\n(code-block ns-macro-test\n  \"(ns slam.hound.stitch\n  (:use [slam.hound.prettify :only [prettify]]))\"\n  \n  \"(ns slam.hound.prettify\n  \\\"Format a namespace declaration using pretty print with custom dispatch.\\\"\n  (:use [clojure.pprint :only [cl-format code-dispatch formatter-out\n                               pprint pprint-logical-block\n                               pprint-newline with-pprint-dispatch\n                               write-out]]))\"\n\n  \"(ns autodoc.build-html\n  \\\"This is the namespace that builds the HTML pages themselves.\nIt is implemented with a number of custom enlive templates.\\\"\n  {:skip-wiki true, :author \\\"Tom Faulhaber\\\"}\n  (:refer-clojure :exclude [empty complement])\n  (:import [java.util.jar JarFile]\n           [java.io File FileWriter BufferedWriter StringReader\n                    BufferedInputStream BufferedOutputStream\n                    ByteArrayOutputStream FileReader FileInputStream]\n           [java.util.regex Pattern])\n  (:require [clojure.string :as str])\n  (:use [net.cgrand.enlive-html :exclude (deftemplate)]\n        [clojure.java.io :only (as-file file writer)]\n        [clojure.java.shell :only (sh)]\n        [clojure.pprint :only (pprint cl-format pprint-ident\n                               pprint-logical-block set-pprint-dispatch\n                               get-pretty-writer fresh-line)]\n        [clojure.data.json :only (pprint-json)]\n        [autodoc.collect-info :only (contrib-info)]\n        [autodoc.params :only (params expand-classpath)])\n  (:use clojure.set clojure.java.io clojure.data clojure.java.browse\n        clojure.inspector clojure.zip clojure.stacktrace))\")\n\n(defn tst-pprint\n  \"A helper function to pprint to a string with a restricted right margin\"\n  [right-margin obj]\n  (binding [*print-right-margin* right-margin\n            *print-pretty* true]\n    (write obj :stream nil)))\n\n;;; A bunch of predefined data to print\n(def future-filled (future-call (fn [] 100)))\n@future-filled\n(def future-unfilled (future-call (fn [] (.acquire (java.util.concurrent.Semaphore. 0)))))\n(def promise-filled (promise))\n(deliver promise-filled '(first second third))\n(def promise-unfilled (promise))\n(def basic-agent (agent '(first second third)))\n(def basic-atom (atom '(first second third)))\n(def basic-ref (ref '(first second third)))\n(def delay-forced (delay '(first second third)))\n(force delay-forced)\n(def delay-unforced (delay '(first second third)))\n(defrecord pprint-test-rec [a b c])\n\n(simple-tests pprint-datastructures-tests\n ;(tst-pprint 20 future-filled) #\"#<Future@[0-9a-f]+: \\r?\\n  100>\"\n ;(tst-pprint 20 future-unfilled) #\"#<Future@[0-9a-f]+: \\r?\\n  :pending>\"\n ;(tst-pprint 20 promise-filled) #\"#<Promise@[0-9a-f]+: \\r?\\n  \\(first\\r?\\n   second\\r?\\n   third\\)>\"\n ;; This hangs currently, cause we can't figure out whether a promise is filled\n ;;(tst-pprint 20 promise-unfilled) #\"#<Promise@[0-9a-f]+: \\r?\\n  :pending>\"\n (tst-pprint 20 basic-agent) #\"#<Agent@[0-9a-f]+: \\r?\\n  \\(first\\r?\\n   second\\r?\\n   third\\)>\"\n (tst-pprint 20 basic-atom) #\"#<Atom@[0-9a-f]+: \\r?\\n  \\(first\\r?\\n   second\\r?\\n   third\\r?\\)>\"\n (tst-pprint 20 basic-ref) #\"#<Ref@[0-9a-f]+: \\r?\\n  \\(first\\r?\\n   second\\r?\\n   third\\)>\"\n (tst-pprint 20 delay-forced) #\"#<Delay@[0-9a-f]+: \\r?\\n  \\(first\\r?\\n   second\\r?\\n   third\\)>\"\n ;; Currently no way not to force the delay\n ;;(tst-pprint 20 delay-unforced) #\"#<Delay@[0-9a-f]+: \\n  :pending>\"\n (tst-pprint 20 (pprint-test-rec. 'first 'second 'third)) \"{:a first,\\n :b second,\\n :c third}\"\n\n ;; basic java arrays: fails owing to assembla ticket #346\n ;;(tst-pprint 10 (int-array (range 7))) \"[0,\\n 1,\\n 2,\\n 3,\\n 4,\\n 5,\\n 6]\"\n (tst-pprint 15 (reduce conj clojure.lang.PersistentQueue/EMPTY (range 10)))\n \"<-(0\\n   1\\n   2\\n   3\\n   4\\n   5\\n   6\\n   7\\n   8\\n   9)-<\"\n )\n\n\n;;; Some simple tests of dispatch\n\n(defmulti \n  test-dispatch\n  \"A test dispatch method\"\n  {:added \"1.2\" :arglists '[[object]]} \n  #(and (seq %) (not (string? %))))\n\n(defmethod test-dispatch true [avec]\n  (pprint-logical-block :prefix \"[\" :suffix \"]\"\n    (loop [aseq (seq avec)]\n      (when aseq\n\t(write-out (first aseq))\n\t(when (next aseq)\n\t  (.write ^java.io.Writer *out* \" \")\n\t  (pprint-newline :linear)\n\t  (recur (next aseq)))))))\n\n(defmethod test-dispatch false [aval] (pr aval))\n\n(simple-tests dispatch-tests\n  (with-pprint-dispatch test-dispatch\n    (with-out-str \n      (pprint '(\"hello\" \"there\"))))\n  \"[\\\"hello\\\" \\\"there\\\"]\\n\"\n)\n\n(simple-tests print-length-tests\n  (binding [*print-length* 1] (with-out-str (pprint '(a b c d e f))))\n  \"(a ...)\\n\"\n  (binding [*print-length* 2] (with-out-str (pprint '(a b c d e f))))\n  \"(a b ...)\\n\"\n  (binding [*print-length* 6] (with-out-str (pprint '(a b c d e f))))\n  \"(a b c d e f)\\n\"\n  (binding [*print-length* 8] (with-out-str (pprint '(a b c d e f))))\n  \"(a b c d e f)\\n\"\n\n  (binding [*print-length* 1] (with-out-str (pprint [1 2 3 4 5 6])))\n  \"[1 ...]\\n\"\n  (binding [*print-length* 2] (with-out-str (pprint [1 2 3 4 5 6])))\n  \"[1 2 ...]\\n\"\n  (binding [*print-length* 6] (with-out-str (pprint [1 2 3 4 5 6])))\n  \"[1 2 3 4 5 6]\\n\"\n  (binding [*print-length* 8] (with-out-str (pprint [1 2 3 4 5 6])))\n  \"[1 2 3 4 5 6]\\n\"\n\n  (binding [*print-length* 1] (with-out-str (pprint (sorted-set 1 2 3 4 5 6))))\n  \"#{1 ...}\\n\"\n  (binding [*print-length* 2] (with-out-str (pprint (sorted-set 1 2 3 4 5 6))))\n  \"#{1 2 ...}\\n\"\n  (binding [*print-length* 6] (with-out-str (pprint (sorted-set 1 2 3 4 5 6))))\n  \"#{1 2 3 4 5 6}\\n\"\n  (binding [*print-length* 8] (with-out-str (pprint (sorted-set 1 2 3 4 5 6))))\n  \"#{1 2 3 4 5 6}\\n\"\n\n  (binding [*print-length* 1] (with-out-str (pprint (sorted-map 1 2, 3 4, 5 6, 7 8, 9 10, 11 12))))\n  \"{1 2, ...}\\n\"\n  (binding [*print-length* 2] (with-out-str (pprint (sorted-map 1 2, 3 4, 5 6, 7 8, 9 10, 11 12))))\n  \"{1 2, 3 4, ...}\\n\"\n  (binding [*print-length* 6] (with-out-str (pprint (sorted-map 1 2, 3 4, 5 6, 7 8, 9 10, 11 12))))\n  \"{1 2, 3 4, 5 6, 7 8, 9 10, 11 12}\\n\"\n  (binding [*print-length* 8] (with-out-str (pprint (sorted-map 1 2, 3 4, 5 6, 7 8, 9 10, 11 12))))\n  \"{1 2, 3 4, 5 6, 7 8, 9 10, 11 12}\\n\"\n\n\n  (binding [*print-length* 1] (with-out-str (pprint (int-array [1 2 3 4 5 6]))))\n  \"[1, ...]\\n\"\n  (binding [*print-length* 2] (with-out-str (pprint (int-array [1 2 3 4 5 6]))))\n  \"[1, 2, ...]\\n\"\n  (binding [*print-length* 6] (with-out-str (pprint (int-array [1 2 3 4 5 6]))))\n  \"[1, 2, 3, 4, 5, 6]\\n\"\n  (binding [*print-length* 8] (with-out-str (pprint (int-array [1 2 3 4 5 6]))))\n  \"[1, 2, 3, 4, 5, 6]\\n\"\n  )\n\n(defn- flush-alerting-writer\n  [o]\n  (let [flush-count-atom (atom 0)]\n    [\n      (proxy [java.io.BufferedWriter] [o]\n        (flush []\n          (proxy-super flush)\n          (swap! flush-count-atom inc)))\n      flush-count-atom]))\n\n(deftest test-flush-underlying-prn\n  []\n  (let [[out flush-count-atom] (flush-alerting-writer (java.io.StringWriter.))]\n    (binding [*out* out\n              *flush-on-newline* true]\n      (prn (range 50))\n      (prn (range 50)))\n    (is (= @flush-count-atom 2) \"println flushes on newline\")))\n\n(deftest test-flush-underlying-pprint\n  []\n  (let [[out flush-count-atom] (flush-alerting-writer (java.io.StringWriter.))]\n    (binding [*out* out\n              *flush-on-newline* true]\n      (pprint (range 50))\n      (pprint (range 50)))\n    (is (= @flush-count-atom 2) \"pprint flushes on newline\")))\n\n(deftest test-noflush-underlying-prn\n  []\n  (let [[out flush-count-atom] (flush-alerting-writer (java.io.StringWriter.))]\n    (binding [*out* out\n              *flush-on-newline* nil]\n      (prn (range 50))\n      (prn (range 50)))\n    (is (= @flush-count-atom 0) \"println flushes on newline\")))\n\n(deftest test-noflush-underlying-pprint\n  []\n  (let [[out flush-count-atom] (flush-alerting-writer (java.io.StringWriter.))]\n    (binding [*out* out\n              *flush-on-newline* nil]\n      (pprint (range 50))\n      (pprint (range 50)))\n    (is (= @flush-count-atom 0) \"pprint flushes on newline\")))\n\n"
  },
  {
    "path": "test/clojure/test_clojure/pprint.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Tom Faulhaber\n\n(ns clojure.test-clojure.pprint\n  (:refer-clojure :exclude [format])\n  (:require [clojure.string :as str])\n  (:use [clojure.test :only (deftest is are run-tests)]\n        [clojure.test-helper :only [platform-newlines]]\n        clojure.test-clojure.pprint.test-helper\n        clojure.pprint))\n\n(load \"pprint/test_cl_format\")\n(load \"pprint/test_pretty\")\n"
  },
  {
    "path": "test/clojure/test_clojure/predicates.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka\n\n;;\n;;  Created 1/28/2009\n\n(ns clojure.test-clojure.predicates\n  (:use clojure.test))\n\n\n;; *** Type predicates ***\n\n(def myvar 42)\n\n(def sample-data {\n  :nil nil\n\n  :bool-true true\n  :bool-false false\n\n  :byte   (byte 7)\n  :short  (short 7)\n  :int    (int 7)\n  :long   (long 7)\n  :bigint (bigint 7)\n  :float  (float 7)\n  :double (double 7)\n  :bigdec (bigdec 7)\n\n  :ratio 2/3\n\n  :character \\a\n  :symbol 'abc\n  :keyword :kw\n\n  :empty-string \"\"\n  :empty-regex #\"\"\n  :empty-list ()\n  :empty-lazy-seq (lazy-seq nil)\n  :empty-vector []\n  :empty-map {}\n  :empty-set #{}\n  :empty-array (into-array [])\n\n  :string \"abc\"\n  :regex #\"a*b\"\n  :list '(1 2 3)\n  :lazy-seq (lazy-seq [1 2 3])\n  :vector [1 2 3]\n  :map {:a 1 :b 2 :c 3}\n  :set #{1 2 3}\n  :array (into-array [1 2 3])\n\n  :fn (fn [x] (* 2 x))\n\n  :class java.util.Date\n  :object (new java.util.Date)\n\n  :var (var myvar)\n  :delay (delay (+ 1 2))\n})\n\n\n(def type-preds {\n  nil? [:nil]\n\n  true?  [:bool-true]\n  false? [:bool-false]\n  ; boolean?\n\n  integer?  [:byte :short :int :long :bigint]\n  float?    [:float :double]\n  decimal?  [:bigdec]\n  ratio?    [:ratio]\n  rational? [:byte :short :int :long :bigint :ratio :bigdec]\n  number?   [:byte :short :int :long :bigint :ratio :bigdec :float :double]\n\n  ; character?\n  symbol?  [:symbol]\n  keyword? [:keyword]\n\n  string? [:empty-string :string]\n  ; regex?\n\n  list?   [:empty-list   :list]\n  vector? [:empty-vector :vector]\n  map?    [:empty-map    :map]\n  set?    [:empty-set    :set]\n\n  coll? [:empty-list     :list\n         :empty-lazy-seq :lazy-seq\n         :empty-vector   :vector\n         :empty-map      :map\n         :empty-set      :set]\n\n  seq?  [:empty-list     :list\n         :empty-lazy-seq :lazy-seq]\n  ; array?\n\n  fn?  [:fn]\n  ifn? [:fn\n        :empty-vector :vector :empty-map :map :empty-set :set\n        :keyword :symbol :var]\n\n  class? [:class]\n  var?   [:var]\n  delay? [:delay]\n})\n\n\n;; Test all type predicates against all data types\n;;\n(defn- get-fn-name [f]\n  (str\n    (apply str (nthnext (first (.split (str f) \"_\"))\n                        (count \"clojure.core$\")))\n    \"?\"))\n\n(deftest test-type-preds\n  (doseq [tp type-preds]\n    (doseq [dt sample-data]\n      (if (some #(= % (first dt)) (second tp))\n        (is ((first tp) (second dt))\n          (pr-str (list (get-fn-name (first tp)) (second dt))))\n        (is (not ((first tp) (second dt)))\n          (pr-str (list 'not (list (get-fn-name (first tp)) (second dt)))))))))\n\n\n;; Additional tests:\n;; http://groups.google.com/group/clojure/browse_thread/thread/537761a06edb4b06/bfd4f0705b746a38\n;;\n(deftest test-string?-more\n  (are [x] (not (string? x))\n    (new java.lang.StringBuilder \"abc\")\n    (new java.lang.StringBuffer \"xyz\")))\n"
  },
  {
    "path": "test/clojure/test_clojure/printer.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Stephen C. Gilardi\n\n;;  clojure.test-clojure.printer\n;;\n;;  scgilardi (gmail)\n;;  Created 29 October 2008\n\n(ns clojure.test-clojure.printer\n  (:use clojure.test))\n\n(deftest print-length-empty-seq\n  (let [coll () val \"()\"]\n    (is (= val (binding [*print-length* 0] (print-str coll))))\n    (is (= val (binding [*print-length* 1] (print-str coll))))))\n\n(deftest print-length-seq\n  (let [coll (range 5)\n        length-val '((0 \"(...)\")\n                     (1 \"(0 ...)\")\n                     (2 \"(0 1 ...)\")\n                     (3 \"(0 1 2 ...)\")\n                     (4 \"(0 1 2 3 ...)\")\n                     (5 \"(0 1 2 3 4)\"))]\n    (doseq [[length val] length-val]\n      (binding [*print-length* length]\n        (is (= val (print-str coll)))))))\n\n(deftest print-length-empty-vec\n  (let [coll [] val \"[]\"]\n    (is (= val (binding [*print-length* 0] (print-str coll))))\n    (is (= val (binding [*print-length* 1] (print-str coll))))))\n\n(deftest print-length-vec\n  (let [coll [0 1 2 3 4]\n        length-val '((0 \"[...]\")\n                     (1 \"[0 ...]\")\n                     (2 \"[0 1 ...]\")\n                     (3 \"[0 1 2 ...]\")\n                     (4 \"[0 1 2 3 ...]\")\n                     (5 \"[0 1 2 3 4]\"))]\n    (doseq [[length val] length-val]\n      (binding [*print-length* length]\n        (is (= val (print-str coll)))))))\n\n(deftest print-level-seq\n  (let [coll '(0 (1 (2 (3 (4)))))\n        level-val '((0 \"#\")\n                    (1 \"(0 #)\")\n                    (2 \"(0 (1 #))\")\n                    (3 \"(0 (1 (2 #)))\")\n                    (4 \"(0 (1 (2 (3 #))))\")\n                    (5 \"(0 (1 (2 (3 (4)))))\"))]\n    (doseq [[level val] level-val]\n      (binding [*print-level* level]\n        (is (= val (print-str coll)))))))\n\n(deftest print-level-length-coll\n  (let [coll '(if (member x y) (+ (first x) 3) (foo (a b c d \"Baz\")))\n        level-length-val\n        '((0 1 \"#\")\n          (1 1 \"(if ...)\")\n          (1 2 \"(if # ...)\")\n          (1 3 \"(if # # ...)\")\n          (1 4 \"(if # # #)\")\n          (2 1 \"(if ...)\")\n          (2 2 \"(if (member x ...) ...)\")\n          (2 3 \"(if (member x y) (+ # 3) ...)\")\n          (3 2 \"(if (member x ...) ...)\")\n          (3 3 \"(if (member x y) (+ (first x) 3) ...)\")\n          (3 4 \"(if (member x y) (+ (first x) 3) (foo (a b c d ...)))\")\n          (3 5 \"(if (member x y) (+ (first x) 3) (foo (a b c d Baz)))\"))]\n    (doseq [[level length val] level-length-val]\n      (binding [*print-level* level\n                *print-length* length]\n        (is (= val (print-str coll)))))))\n\n(deftest print-dup-expected\n  (are [x s] (= s (binding [*print-dup* true] (print-str x)))\n       1 \"1\"\n       1.0 \"1.0\"\n       1N \"1N\"\n       (java.math.BigInteger. \"1\") \"#=(java.math.BigInteger. \\\"1\\\")\"\n       1M \"1M\"\n       \"hi\" \"\\\"hi\\\"\"))\n\n(deftest print-dup-readable\n  (are [form] (let [x form]\n                (= x (read-string (binding [*print-dup* true] (print-str x)))))\n       1\n       1.0\n       1N\n       1M\n       \"hi\"))\n\n(def ^{:foo :anything} var-with-meta 42)\n(def ^{:type :anything} var-with-type 666)\n\n(deftest print-var\n  (are [x s] (= s (pr-str x))\n       #'pr-str  \"#'clojure.core/pr-str\"\n       #'var-with-meta \"#'clojure.test-clojure.printer/var-with-meta\"\n       #'var-with-type \"#'clojure.test-clojure.printer/var-with-type\"))\n\n(deftest print-meta\n  (are [x s] (binding [*print-meta* true] \n               (let [pstr (pr-str x)]\n                 (and (.endsWith pstr s)\n                      (.startsWith pstr \"^\")\n                      (.contains pstr (pr-str (meta x))))))\n       #'pr-str  \"#'clojure.core/pr-str\"\n       #'var-with-meta \"#'clojure.test-clojure.printer/var-with-meta\"\n       #'var-with-type \"#'clojure.test-clojure.printer/var-with-type\"))\n\n(defn ^:private ednize-stack-trace-element\n  [^StackTraceElement ste]\n  [(symbol (.getClassName ste))\n   (symbol (.getMethodName ste))\n   (.getFileName ste)\n   (.getLineNumber ste)])\n\n(defn ^:private ednize-throwable-data\n  [throwable-data]\n  (-> throwable-data\n      (update :via (fn [vias]\n                     (map (fn [via]\n                            (-> via\n                                (update :type #(symbol (.getName %)))\n                                (update :at ednize-stack-trace-element)))\n                          vias)))\n      (update :trace #(map ednize-stack-trace-element %))))\n\n(deftest print-throwable\n  (binding [*data-readers* {'error identity}]\n    (are [e] (= (-> e Throwable->map ednize-throwable-data)\n                (-> e pr-str read-string))\n         (Exception. \"heyo\")\n         (Throwable. \"I can a throwable\"\n                     (Exception. \"chain 1\"\n                                 (Exception. \"chan 2\")))\n         (ex-info \"an ex-info\" {:with \"its\" :data 29})\n         (Exception. \"outer\"\n                     (ex-info \"an ex-info\" {:with \"data\"}\n                              (Error. \"less outer\"\n                                      (ex-info \"the root\"\n                                               {:with \"even\" :more 'data})))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/protocols/examples.clj",
    "content": "(ns clojure.test-clojure.protocols.examples)\n\n(defprotocol ExampleProtocol\n  \"example protocol used by clojure tests\"\n\n  (foo [a] \"method with one arg\")\n  (bar [a b] \"method with two args\")\n  (^String baz [a] [a b] \"method with multiple arities\")\n  (with-quux [a] \"method name with a hyphen\"))\n\n(defprotocol MarkerProtocol\n  \"a protocol with no methods\")\n\n(defprotocol MarkerProtocol2)\n\n(definterface ExampleInterface\n  (hinted [^int i])\n  (hinted [^String s]))\n\n"
  },
  {
    "path": "test/clojure/test_clojure/protocols/hash_collisions.clj",
    "content": "(ns clojure.test-clojure.protocols.hash-collisions\n  (:use clojure.test))\n\n(defprotocol TestProtocolA\n  (method-a [this] \"Test method A\"))\n\n(defprotocol TestProtocolB\n  (method-b [this] \"Test method B\"))\n\n(deftype TestType1 [])\n(deftype TestType2 [])\n(deftype TestType3 [])\n(deftype TestType4 [])\n(deftype TestType5 [])\n(deftype TestType6 [])\n(deftype TestType7 [])\n(deftype TestType8 [])\n(deftype TestType9 [])\n(deftype TestType10 [])\n(deftype TestType11 [])\n(deftype TestType12 [])\n(deftype TestType13 [])\n(deftype TestType14 [])\n(deftype TestType15 [])\n\n(def original-hash hash)\n\n(defn colliding-hash\n  \"Mock hash function which returns identical hash codes for the\n  classes TestType1 and TestType2, normal hashes for everything else.\"\n  [x]\n  (if (or (= x TestType1) (= x TestType2))\n    999 ;; artificial hash code, to cause a collision\n    (original-hash x)))\n\n(deftest protocols-with-hash-collisions\n  (with-redefs [hash colliding-hash]\n    (extend TestType1 TestProtocolA {:method-a (constantly 1)})\n    (extend TestType2 TestProtocolA {:method-a (constantly 2)})\n    (is (= 1 (method-a (TestType1.))))\n    (is (= 2 (method-a (TestType2.))))))\n\n(defn no-min-hash-in-13-bits\n  \"Mock hash function which returns hash codes for the classes\n  TestType1 through TestType15 such that they cannot be compressed\n  into a 13-bit min-hash table. Returns normal hashes for everything\n  else.\"\n  [x]\n  (cond\n   (= x TestType1) 1\n   (= x TestType2) 2\n   (= x TestType3) 4\n   (= x TestType4) 8\n   (= x TestType5) 16\n   (= x TestType6) 32\n   (= x TestType7) 64\n   (= x TestType8) 128\n   (= x TestType9) 256\n   (= x TestType10) 512\n   (= x TestType11) 1024\n   (= x TestType12) 2048\n   (= x TestType13) 4096\n   (= x TestType14) 8192\n   (= x TestType15) 16384\n   :else (original-hash x)))\n\n(deftest protocols-with-no-min-hash-in-13-bits\n  (with-redefs [hash no-min-hash-in-13-bits]\n    (extend TestType1 TestProtocolB {:method-b (constantly 1)})\n    (extend TestType2 TestProtocolB {:method-b (constantly 2)})\n    (extend TestType3 TestProtocolB {:method-b (constantly 3)})\n    (extend TestType4 TestProtocolB {:method-b (constantly 4)})\n    (extend TestType5 TestProtocolB {:method-b (constantly 5)})\n    (extend TestType6 TestProtocolB {:method-b (constantly 6)})\n    (extend TestType7 TestProtocolB {:method-b (constantly 7)})\n    (extend TestType8 TestProtocolB {:method-b (constantly 8)})\n    (extend TestType9 TestProtocolB {:method-b (constantly 9)})\n    (extend TestType10 TestProtocolB {:method-b (constantly 10)})\n    (extend TestType11 TestProtocolB {:method-b (constantly 11)})\n    (extend TestType12 TestProtocolB {:method-b (constantly 12)})\n    (extend TestType13 TestProtocolB {:method-b (constantly 13)})\n    (extend TestType14 TestProtocolB {:method-b (constantly 14)})\n    (extend TestType15 TestProtocolB {:method-b (constantly 15)})\n    (is (= 1 (method-b (TestType1.))))\n    (is (= 2 (method-b (TestType2.))))\n    (is (= 3 (method-b (TestType3.))))\n    (is (= 4 (method-b (TestType4.))))\n    (is (= 5 (method-b (TestType5.))))\n    (is (= 6 (method-b (TestType6.))))\n    (is (= 7 (method-b (TestType7.))))\n    (is (= 8 (method-b (TestType8.))))\n    (is (= 9 (method-b (TestType9.))))\n    (is (= 10 (method-b (TestType10.))))\n    (is (= 11 (method-b (TestType11.))))\n    (is (= 12 (method-b (TestType12.))))\n    (is (= 13 (method-b (TestType13.))))\n    (is (= 14 (method-b (TestType14.))))\n    (is (= 15 (method-b (TestType15.))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/protocols/more_examples.clj",
    "content": "(ns clojure.test-clojure.protocols.more-examples)\n\n(defprotocol SimpleProtocol\n  \"example protocol used by clojure tests. Note that\n   foo collides with examples/ExampleProtocol.\"\n\n  (foo [a] \"\"))\n"
  },
  {
    "path": "test/clojure/test_clojure/protocols.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Stuart Halloway\n\n(ns clojure.test-clojure.protocols\n  (:use clojure.test clojure.test-clojure.protocols.examples)\n  (:require [clojure.test-clojure.protocols.more-examples :as other]\n            [clojure.set :as set]\n            clojure.test-helper)\n  (:import [clojure.test_clojure.protocols.examples ExampleInterface]))\n\n;; temporary hack until I decide how to cleanly reload protocol\n;; this no longer works\n(defn reload-example-protocols\n  []\n  (alter-var-root #'clojure.test-clojure.protocols.examples/ExampleProtocol\n                  assoc :impls {})\n  (alter-var-root #'clojure.test-clojure.protocols.more-examples/SimpleProtocol\n                  assoc :impls {})\n  (require :reload\n           'clojure.test-clojure.protocols.examples\n           'clojure.test-clojure.protocols.more-examples))\n\n(defn method-names\n  \"return sorted list of method names on a class\"\n  [c]\n  (->> (.getMethods c)\n     (map #(.getName %))\n     (sort)))\n\n(defrecord EmptyRecord [])\n(defrecord TestRecord [a b])\n(defn r\n  ([a b] (TestRecord. a b))\n  ([a b meta ext] (TestRecord. a b meta ext)))\n(defrecord MapEntry [k v]\n  java.util.Map$Entry\n  (getKey [_] k)\n  (getValue [_] v))\n\n(deftest protocols-test\n  (testing \"protocol fns have useful metadata\"\n    (let [common-meta {:ns (find-ns 'clojure.test-clojure.protocols.examples)\n                       :protocol #'ExampleProtocol}]\n      (are [m f] (= (merge (quote m) common-meta)\n                    (meta (var f)))\n           {:name foo :arglists ([a]) :doc \"method with one arg\"} foo\n           {:name bar :arglists ([a b]) :doc \"method with two args\"} bar\n           {:name baz :arglists ([a] [a b]) :doc \"method with multiple arities\" :tag String} baz\n           {:name with-quux :arglists ([a]) :doc \"method name with a hyphen\"} with-quux)))\n  (testing \"protocol fns throw IllegalArgumentException if no impl matches\"\n    (is (thrown-with-msg?\n          IllegalArgumentException\n          #\"No implementation of method: :foo of protocol: #'clojure.test-clojure.protocols.examples/ExampleProtocol found for class: java.lang.Long\"\n          (foo 10))))\n  (testing \"protocols generate a corresponding interface using _ instead of - for method names\"\n    (is (= [\"bar\" \"baz\" \"baz\" \"foo\" \"with_quux\"] (method-names clojure.test_clojure.protocols.examples.ExampleProtocol))))\n  (testing \"protocol will work with instances of its interface (use for interop, not in Clojure!)\"\n    (let [obj (proxy [clojure.test_clojure.protocols.examples.ExampleProtocol] []\n                (foo [] \"foo!\"))]\n      (is (= \"foo!\" (.foo obj)) \"call through interface\")\n      (is (= \"foo!\" (foo obj)) \"call through protocol\")))\n  (testing \"you can implement just part of a protocol if you want\"\n    (let [obj (reify ExampleProtocol\n                     (baz [a b] \"two-arg baz!\"))]\n      (is (= \"two-arg baz!\" (baz obj nil)))\n      (is (thrown? AbstractMethodError (baz obj)))))\n  (testing \"error conditions checked when defining protocols\"\n    (is (thrown-with-msg?\n         Exception\n         #\"Definition of function m in protocol badprotdef must take at least one arg.\"\n         (eval '(defprotocol badprotdef (m [])))))\n    (is (thrown-with-msg?\n         Exception\n         #\"Function m in protocol badprotdef was redefined. Specify all arities in single definition.\"\n         (eval '(defprotocol badprotdef (m [this arg]) (m [this arg1 arg2]))))))\n  (testing \"you can redefine a protocol with different methods\"\n    (eval '(defprotocol Elusive (old-method [x])))\n    (eval '(defprotocol Elusive (new-method [x])))\n    (is (= :new-method (eval '(new-method (reify Elusive (new-method [x] :new-method))))))\n    (is (fails-with-cause? IllegalArgumentException #\"No method of interface: .*\\.Elusive found for function: old-method of protocol: Elusive \\(The protocol method may have been defined before and removed\\.\\)\"\n          (eval '(old-method (reify Elusive (new-method [x] :new-method))))))))\n\n(deftype HasMarkers []\n  ExampleProtocol\n  (foo [this] \"foo\")\n  MarkerProtocol\n  MarkerProtocol2)\n\n(deftype WillGetMarker []\n  ExampleProtocol\n  (foo [this] \"foo\"))\n\n(extend-type WillGetMarker MarkerProtocol)\n\n(deftest marker-tests\n  (testing \"That a marker protocol has no methods\"\n    (is (= '() (method-names clojure.test_clojure.protocols.examples.MarkerProtocol))))\n  (testing \"That types with markers are reportedly satifying them.\"\n    (let [hm (HasMarkers.)\n          wgm (WillGetMarker.)]\n      (is (satisfies? MarkerProtocol hm))\n      (is (satisfies? MarkerProtocol2 hm))\n      (is (satisfies? MarkerProtocol wgm)))))\n\n(deftype ExtendTestWidget [name])\n(deftype HasProtocolInline []\n  ExampleProtocol\n  (foo [this] :inline))\n(deftest extend-test\n  (testing \"you can extend a protocol to a class\"\n    (extend String ExampleProtocol\n            {:foo identity})\n    (is (= \"pow\" (foo \"pow\"))))\n  (testing \"you can have two methods with the same name. Just use namespaces!\"\n    (extend String other/SimpleProtocol\n     {:foo (fn [s] (.toUpperCase s))})\n    (is (= \"POW\" (other/foo \"pow\"))))\n  (testing \"you can extend deftype types\"\n    (extend\n     ExtendTestWidget\n     ExampleProtocol\n     {:foo (fn [this] (str \"widget \" (.name this)))})\n    (is (= \"widget z\" (foo (ExtendTestWidget. \"z\"))))))\n\n(deftest record-marker-interfaces\n  (testing \"record? and type? return expected result for IRecord and IType\"\n    (let [r (TestRecord. 1 2)]\n      (is (record? r)))))\n\n(deftest illegal-extending\n  (testing \"you cannot extend a protocol to a type that implements the protocol inline\"\n    (is (fails-with-cause? IllegalArgumentException #\".*HasProtocolInline already directly implements interface\"\n          (eval '(extend clojure.test_clojure.protocols.HasProtocolInline\n                         clojure.test-clojure.protocols.examples/ExampleProtocol\n                         {:foo (fn [_] :extended)})))))\n  (testing \"you cannot extend to an interface\"\n    (is (fails-with-cause? IllegalArgumentException #\"interface clojure.test_clojure.protocols.examples.ExampleProtocol is not a protocol\"\n          (eval '(extend clojure.test_clojure.protocols.HasProtocolInline\n                         clojure.test_clojure.protocols.examples.ExampleProtocol\n                         {:foo (fn [_] :extended)}))))))\n\n(deftype ExtendsTestWidget []\n  ExampleProtocol)\n#_(deftest extends?-test\n  (reload-example-protocols)\n  (testing \"returns false if a type does not implement the protocol at all\"\n    (is (false? (extends? other/SimpleProtocol ExtendsTestWidget))))\n  (testing \"returns true if a type implements the protocol directly\" ;; semantics changed 4/15/2010\n    (is (true? (extends? ExampleProtocol ExtendsTestWidget))))\n  (testing \"returns true if a type explicitly extends protocol\"\n    (extend\n     ExtendsTestWidget\n     other/SimpleProtocol\n     {:foo identity})\n    (is (true? (extends? other/SimpleProtocol ExtendsTestWidget)))))\n\n(deftype ExtendersTestWidget [])\n#_(deftest extenders-test\n  (reload-example-protocols)\n  (testing \"a fresh protocol has no extenders\"\n    (is (nil? (extenders ExampleProtocol))))\n  (testing \"extending with no methods doesn't count!\"\n    (deftype Something [])\n    (extend ::Something ExampleProtocol)\n    (is (nil? (extenders ExampleProtocol))))\n  (testing \"extending a protocol (and including an impl) adds an entry to extenders\"\n    (extend ExtendersTestWidget ExampleProtocol {:foo identity})\n    (is (= [ExtendersTestWidget] (extenders ExampleProtocol)))))\n\n(deftype SatisfiesTestWidget []\n  ExampleProtocol)\n#_(deftest satisifies?-test\n  (reload-example-protocols)\n  (let [whatzit (SatisfiesTestWidget.)]\n    (testing \"returns false if a type does not implement the protocol at all\"\n      (is (false? (satisfies? other/SimpleProtocol whatzit))))\n    (testing \"returns true if a type implements the protocol directly\"\n      (is (true? (satisfies? ExampleProtocol whatzit))))\n    (testing \"returns true if a type explicitly extends protocol\"\n      (extend\n       SatisfiesTestWidget\n       other/SimpleProtocol\n       {:foo identity})\n      (is (true? (satisfies? other/SimpleProtocol whatzit)))))  )\n\n(deftype ReExtendingTestWidget [])\n#_(deftest re-extending-test\n  (reload-example-protocols)\n  (extend\n   ReExtendingTestWidget\n   ExampleProtocol\n   {:foo (fn [_] \"first foo\")\n    :baz (fn [_] \"first baz\")})\n  (testing \"if you re-extend, the old implementation is replaced (not merged!)\"\n    (extend\n     ReExtendingTestWidget\n     ExampleProtocol\n     {:baz (fn [_] \"second baz\")\n      :bar (fn [_ _] \"second bar\")})\n    (let [whatzit (ReExtendingTestWidget.)]\n      (is (thrown? IllegalArgumentException (foo whatzit)))\n      (is (= \"second bar\" (bar whatzit nil)))\n      (is (= \"second baz\" (baz whatzit))))))\n\n(defrecord DefrecordObjectMethodsWidgetA [a])\n(defrecord DefrecordObjectMethodsWidgetB [a])\n(deftest defrecord-object-methods-test\n  (testing \"= depends on fields and type\"\n    (is (true? (= (DefrecordObjectMethodsWidgetA. 1) (DefrecordObjectMethodsWidgetA. 1))))\n    (is (false? (= (DefrecordObjectMethodsWidgetA. 1) (DefrecordObjectMethodsWidgetA. 2))))\n    (is (false? (= (DefrecordObjectMethodsWidgetA. 1) (DefrecordObjectMethodsWidgetB. 1))))))\n\n(deftest defrecord-acts-like-a-map\n  (let [rec (r 1 2)]\n    (is (.equals (r 1 3 {} {:c 4}) (merge rec {:b 3 :c 4})))\n    (is (.equals {:foo 1 :b 2} (set/rename-keys rec {:a :foo})))\n    (is (.equals {:a 11 :b 2 :c 10} (merge-with + rec {:a 10 :c 10})))))\n\n(deftest degenerate-defrecord-test\n  (let [empty (EmptyRecord.)]\n    (is (nil? (seq empty)))\n    (is (not (.containsValue empty :a)))))\n\n(deftest defrecord-interfaces-test\n  (testing \"java.util.Map\"\n    (let [rec (r 1 2)]\n      (is (= 2 (.size rec)))\n      (is (= 3 (.size (assoc rec :c 3))))\n      (is (not (.isEmpty rec)))\n      (is (.isEmpty (EmptyRecord.)))\n      (is (.containsKey rec :a))\n      (is (not (.containsKey rec :c)))\n      (is (.containsValue rec 1))\n      (is (not (.containsValue rec 3)))\n      (is (= 1 (.get rec :a)))\n      (is (thrown? UnsupportedOperationException (.put rec :a 1)))\n      (is (thrown? UnsupportedOperationException (.remove rec :a)))\n      (is (thrown? UnsupportedOperationException (.putAll rec {})))\n      (is (thrown? UnsupportedOperationException (.clear rec)))\n      (is (= #{:a :b} (.keySet rec)))\n      (is (= #{1 2} (set (.values rec))))\n      (is (= #{[:a 1] [:b 2]} (.entrySet rec)))\n\n      ))\n  (testing \"IPersistentCollection\"\n    (testing \".cons\"\n      (let [rec (r 1 2)]\n        (are [x] (= rec (.cons rec x))\n             nil {})\n        (is (= (r 1 3) (.cons rec {:b 3})))\n        (is (= (r 1 4) (.cons rec [:b 4])))\n        (is (= (r 1 5) (.cons rec (MapEntry. :b 5))))))))\n\n(defrecord RecordWithSpecificFieldNames [this_ that k m o])\n(deftest defrecord-with-specific-field-names\n  (let [rec (new RecordWithSpecificFieldNames 1 2 3 4 5)]\n    (is (= rec rec))\n    (is (= 1 (:this_ (with-meta rec {:foo :bar}))))\n    (is (= 3 (get rec :k)))\n    (is (= (seq rec) '([:this_ 1] [:that 2] [:k 3] [:m 4] [:o 5])))\n    (is (= (dissoc rec :k) {:this_ 1, :that 2, :m 4, :o 5}))))\n\n(defrecord RecordToTestStatics1 [a])\n(defrecord RecordToTestStatics2 [a b])\n(defrecord RecordToTestStatics3 [a b c])\n(defrecord RecordToTestBasis [a b c])\n(defrecord RecordToTestBasisHinted [^String a ^Long b c])\n(defrecord RecordToTestHugeBasis [a b c d e f g h i j k l m n o p q r s t u v w x y z])\n(defrecord TypeToTestBasis [a b c])\n(defrecord TypeToTestBasisHinted [^String a ^Long b c])\n\n(deftest test-statics\n  (testing \"that a record has its generated static methods\"\n    (let [r1 (RecordToTestStatics1. 1)\n          r2 (RecordToTestStatics2. 1 2)\n          r3 (RecordToTestStatics3. 1 2 3)\n          rn (RecordToTestStatics3. 1 nil nil)]\n      (testing \"that a record created with the ctor equals one by the static factory method\"\n        (is (= r1    (RecordToTestStatics1/create {:a 1})))\n        (is (= r2    (RecordToTestStatics2/create {:a 1 :b 2})))\n        (is (= r3    (RecordToTestStatics3/create {:a 1 :b 2 :c 3})))\n        (is (= rn    (RecordToTestStatics3/create {:a 1}))))\n      (testing \"that a literal record equals one by the static factory method\"\n        (is (= #clojure.test_clojure.protocols.RecordToTestStatics1{:a 1} (RecordToTestStatics1/create {:a 1})))\n        (is (= #clojure.test_clojure.protocols.RecordToTestStatics2{:a 1 :b 2} (RecordToTestStatics2/create {:a 1 :b 2})))\n        (is (= #clojure.test_clojure.protocols.RecordToTestStatics3{:a 1 :b 2 :c 3} (RecordToTestStatics3/create {:a 1 :b 2 :c 3})))\n        (is (= #clojure.test_clojure.protocols.RecordToTestStatics3{:a 1} (RecordToTestStatics3/create {:a 1})))\n        (is (= #clojure.test_clojure.protocols.RecordToTestStatics3{:a 1 :b nil :c nil} (RecordToTestStatics3/create {:a 1}))))))\n  (testing \"that records and types have a sane generated basis method\"\n    (let [rb  (clojure.test_clojure.protocols.RecordToTestBasis/getBasis)\n          rbh (clojure.test_clojure.protocols.RecordToTestBasisHinted/getBasis)\n          rhg (clojure.test_clojure.protocols.RecordToTestHugeBasis/getBasis)\n          tb (clojure.test_clojure.protocols.TypeToTestBasis/getBasis)\n          tbh (clojure.test_clojure.protocols.TypeToTestBasisHinted/getBasis)]\n      (is (= '[a b c] rb))\n      (is (= '[a b c] rb))\n      (is (= '[a b c d e f g h i j k l m n o p q r s t u v w x y z] rhg))\n      (testing \"that record basis hinting looks as we expect\"\n        (is (= (:tag (meta (rbh 0))) 'String))\n        (is (= (:tag (meta (rbh 1))) 'Long))\n        (is (nil? (:tag (meta (rbh 2))))))\n      (testing \"that type basis hinting looks as we expect\"\n        (is (= (:tag (meta (tbh 0))) 'String))\n        (is (= (:tag (meta (tbh 1))) 'Long))\n        (is (nil? (:tag (meta (tbh 2)))))))))\n\n(defrecord RecordToTestFactories [a b c])\n(defrecord RecordToTestA [a])\n(defrecord RecordToTestB [b])\n(defrecord RecordToTestHugeFactories [a b c d e f g h i j k l m n o p q r s t u v w x y z])\n(defrecord RecordToTestDegenerateFactories [])\n\n(deftest test-record-factory-fns\n  (testing \"if the definition of a defrecord generates the appropriate factory functions\"\n    (let [r    (RecordToTestFactories. 1 2 3)\n          r-n  (RecordToTestFactories. nil nil nil)\n          huge (RecordToTestHugeFactories. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26)\n          r-a  (map->RecordToTestA {:a 1 :b 2})\n          r-b  (map->RecordToTestB {:a 1 :b 2})\n          r-d  (RecordToTestDegenerateFactories.)]\n      (testing \"that a record created with the ctor equals one by the positional factory fn\"\n        (is (= r    (->RecordToTestFactories 1 2 3)))\n        (is (= huge (->RecordToTestHugeFactories 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26))))\n      (testing \"that a record created with the ctor equals one by the map-> factory fn\"\n        (is (= r    (map->RecordToTestFactories {:a 1 :b 2 :c 3})))\n        (is (= r-n  (map->RecordToTestFactories {})))\n        (is (= r    (map->RecordToTestFactories (map->RecordToTestFactories {:a 1 :b 2 :c 3}))))\n        (is (= r-n  (map->RecordToTestFactories (map->RecordToTestFactories {}))))\n        (is (= r-d  (map->RecordToTestDegenerateFactories {})))\n        (is (= r-d  (map->RecordToTestDegenerateFactories\n                     (map->RecordToTestDegenerateFactories {})))))\n      (testing \"that ext maps work correctly\"\n        (is (= (assoc r :xxx 42)  (map->RecordToTestFactories {:a 1 :b 2 :c 3 :xxx 42})))\n        (is (= (assoc r :xxx 42)  (map->RecordToTestFactories (map->RecordToTestFactories\n                                                               {:a 1 :b 2 :c 3 :xxx 42}))))\n        (is (= (assoc r-n :xxx 42) (map->RecordToTestFactories {:xxx 42})))\n        (is (= (assoc r-n :xxx 42) (map->RecordToTestFactories (map->RecordToTestFactories\n  {:xxx 42}))))\n        (is (= (assoc r-d :xxx 42) (map->RecordToTestDegenerateFactories {:xxx 42})))\n        (is (= (assoc r-d :xxx 42) (map->RecordToTestDegenerateFactories\n                                    (map->RecordToTestDegenerateFactories {:xxx 42})))))\n      (testing \"record equality\"\n        (is (not= r-a r-b))\n        (is (= (into {} r-a) (into {} r-b)))\n        (is (not= (into {} r-a) r-b))\n        (is (= (map->RecordToTestA {:a 1 :b 2})\n               (map->RecordToTestA (map->RecordToTestB {:a 1 :b 2}))))\n        (is (= (map->RecordToTestA {:a 1 :b 2 :c 3})\n               (map->RecordToTestA (map->RecordToTestB {:a 1 :b 2 :c 3}))))\n        (is (= (map->RecordToTestA {:a 1 :d 4})\n               (map->RecordToTestA (map->RecordToTestDegenerateFactories {:a 1 :d 4}))))\n        (is (= r-n (map->RecordToTestFactories (java.util.HashMap.))))\n        (is (= r-a (map->RecordToTestA (into {} r-b))))\n        (is (= r-a (map->RecordToTestA r-b)))\n        (is (not= r-a (map->RecordToTestB r-a)))\n        (is (= r (assoc r-n :a 1 :b 2 :c 3)))\n        (is (not= r-a (assoc r-n :a 1 :b 2)))\n        (is (not= (assoc r-b :c 3 :d 4) (assoc r-n :a 1 :b 2 :c 3 :d 4)))\n        (is (= (into {} (assoc r-b :c 3 :d 4)) (into {} (assoc r-n :a 1 :b 2 :c 3 :d 4))))\n        (is (= (assoc r :d 4) (assoc r-n :a 1 :b 2 :c 3 :d 4))))\n      (testing \"that factory functions have docstrings\"\n        ;; just test non-nil to avoid overspecifiying what's in the docstring\n        (is (false? (-> ->RecordToTestFactories var meta :doc nil?)))\n        (is (false? (->  map->RecordToTestFactories var meta :doc nil?))))\n      (testing \"that a literal record equals one by the positional factory fn\"\n        (is (= #clojure.test_clojure.protocols.RecordToTestFactories{:a 1 :b 2 :c 3} (->RecordToTestFactories 1 2 3)))\n        (is (= #clojure.test_clojure.protocols.RecordToTestFactories{:a 1 :b nil :c nil} (->RecordToTestFactories 1 nil nil)))\n        (is (= #clojure.test_clojure.protocols.RecordToTestFactories{:a [] :b {} :c ()} (->RecordToTestFactories [] {} ()))))\n      (testing \"that a literal record equals one by the map-> factory fn\"\n        (is (= #clojure.test_clojure.protocols.RecordToTestFactories{:a 1 :b 2 :c 3} (map->RecordToTestFactories {:a 1 :b 2 :c 3})))\n        (is (= #clojure.test_clojure.protocols.RecordToTestFactories{:a 1 :b nil :c nil} (map->RecordToTestFactories {:a 1})))\n        (is (= #clojure.test_clojure.protocols.RecordToTestFactories{:a nil :b nil :c nil} (map->RecordToTestFactories {})))))))\n\n(defn compare-huge-types\n  [hugeL hugeR]\n  (and\n   (= (.a hugeL) (.a hugeR))\n   (= (.b hugeL) (.b hugeR))\n   (= (.c hugeL) (.c hugeR))\n   (= (.d hugeL) (.d hugeR))\n   (= (.e hugeL) (.e hugeR))\n   (= (.f hugeL) (.f hugeR))\n   (= (.g hugeL) (.g hugeR))\n   (= (.h hugeL) (.h hugeR))\n   (= (.i hugeL) (.i hugeR))\n   (= (.j hugeL) (.j hugeR))\n   (= (.k hugeL) (.k hugeR))\n   (= (.l hugeL) (.l hugeR))\n   (= (.m hugeL) (.m hugeR))\n   (= (.n hugeL) (.n hugeR))\n   (= (.o hugeL) (.o hugeR))\n   (= (.p hugeL) (.p hugeR))\n   (= (.q hugeL) (.q hugeR))\n   (= (.r hugeL) (.r hugeR))\n   (= (.s hugeL) (.s hugeR))\n   (= (.t hugeL) (.t hugeR))\n   (= (.u hugeL) (.u hugeR))\n   (= (.v hugeL) (.v hugeR))\n   (= (.w hugeL) (.w hugeR))\n   (= (.x hugeL) (.x hugeR))\n   (= (.y hugeL) (.y hugeR))\n   (= (.z hugeL) (.z hugeR))))\n\n(deftype TypeToTestFactory [a])\n(defrecord TypeToTestHugeFactories [a b c d e f g h i j k l m n o p q r s t u v w x y z])\n\n(deftest deftype-factory-fn\n  (testing \"that the ->T factory is gen'd for a deftype and that it works\"\n    (is (= (.a (TypeToTestFactory. 42)) (.a (->TypeToTestFactory 42))))\n    (is (compare-huge-types\n         (TypeToTestHugeFactories.  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26)\n         (->TypeToTestHugeFactories 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26))))\n  (testing \"that the generated factory checks arity constraints\"\n    (is (thrown? clojure.lang.ArityException (->TypeToTestHugeFactories 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25)))\n    (is (thrown? clojure.lang.ArityException (->TypeToTestHugeFactories 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27)))))\n\n(deftest test-ctor-literals\n  (testing \"that constructor calls to print-dup'able classes are supported as literals\"\n    (is (= \"Hi\" #java.lang.String[\"Hi\"]))\n    (is (= 42 #java.lang.Long[42]))\n    (is (= 42 #java.lang.Long[\"42\"]))\n    (is (= [:a 42] #clojure.lang.MapEntry[:a 42])))\n  (testing \"that constructor literals are embeddable\"\n    (is (= 42 #java.lang.Long[#java.lang.String[\"42\"]])))\n  (testing \"that constructor literals work for deftypes too\"\n    (is (= (.a (TypeToTestFactory. 42)) (.a #clojure.test_clojure.protocols.TypeToTestFactory[42])))\n    (is (compare-huge-types\n         (TypeToTestHugeFactories.  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26)\n         #clojure.test_clojure.protocols.TypeToTestHugeFactories[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26]))))\n\n(defrecord RecordToTestLiterals [a])\n(defrecord TestNode [v l r])\n(deftype TypeToTestLiterals [a])\n(def lang-str \"en\")\n(deftest exercise-literals\n  (testing \"that ctor literals can be used in common 'places'\"\n    (is (= (RecordToTestLiterals. ()) #clojure.test_clojure.protocols.RecordToTestLiterals[()]))\n    (is (= (.a (TypeToTestLiterals. ())) (.a #clojure.test_clojure.protocols.TypeToTestLiterals[()])))\n    (is (= (RecordToTestLiterals. 42) (into #clojure.test_clojure.protocols.RecordToTestLiterals[0] {:a 42})))\n    (is (= (RecordToTestLiterals. (RecordToTestLiterals. 42))  (RecordToTestLiterals. #clojure.test_clojure.protocols.RecordToTestLiterals[42])))\n    (is (= (RecordToTestLiterals. (RecordToTestLiterals. 42))  (->RecordToTestLiterals #clojure.test_clojure.protocols.RecordToTestLiterals[42])))\n    (is (= (RecordToTestLiterals. (RecordToTestLiterals. 42))\n           #clojure.test_clojure.protocols.RecordToTestLiterals[#clojure.test_clojure.protocols.RecordToTestLiterals[42]]))\n    (is (= (TestNode. 1\n                      (TestNode. 2\n                                 (TestNode. 3\n                                            nil\n                                            nil)\n                                 nil)\n                      (TestNode. 4\n                                 (TestNode. 5\n                                            (TestNode. 6\n                                                       nil\n                                                       nil)\n                                            nil)\n                                 (TestNode. 7\n                                            nil\n                                            nil)))\n           #clojure.test_clojure.protocols.TestNode{:v 1\n                                                    :l #clojure.test_clojure.protocols.TestNode{:v 2\n                                                                                                :l #clojure.test_clojure.protocols.TestNode{:v 3 :l nil :r nil}\n                                                                                                :r nil}\n                                                    :r #clojure.test_clojure.protocols.TestNode{:v 4\n                                                                                                :l #clojure.test_clojure.protocols.TestNode{:v 5\n                                                                                                                                            :l #clojure.test_clojure.protocols.TestNode{:v 6 :l nil :r nil}\n                                                                                                                                            :r nil}\n                                                                                                :r #clojure.test_clojure.protocols.TestNode{:v 7 :l nil :r nil}}})))\n\n  (testing \"that records and types are evalable\"\n    (is (= (RecordToTestLiterals. 42) (eval #clojure.test_clojure.protocols.RecordToTestLiterals[42])))\n    (is (= (RecordToTestLiterals. 42) (eval #clojure.test_clojure.protocols.RecordToTestLiterals{:a 42})))\n    (is (= (RecordToTestLiterals. 42) (eval (RecordToTestLiterals. 42))))\n    (is (= (RecordToTestLiterals. (RecordToTestLiterals. 42))\n           (eval #clojure.test_clojure.protocols.RecordToTestLiterals[#clojure.test_clojure.protocols.RecordToTestLiterals[42]])))\n    (is (= (RecordToTestLiterals. (RecordToTestLiterals. 42))\n           (eval #clojure.test_clojure.protocols.RecordToTestLiterals[#clojure.test_clojure.protocols.RecordToTestLiterals{:a 42}])))\n    (is (= (RecordToTestLiterals. (RecordToTestLiterals. 42))\n           (eval #clojure.test_clojure.protocols.RecordToTestLiterals{:a #clojure.test_clojure.protocols.RecordToTestLiterals[42]})))\n    (is (= 42 (.a (eval #clojure.test_clojure.protocols.TypeToTestLiterals[42])))))\n\n  (testing \"that ctor literals only work with constants or statics\"\n    (is (thrown? Exception (read-string \"#java.util.Locale[(str 'en)]\")))\n    (is (thrown? Exception (read-string \"(let [s \\\"en\\\"] #java.util.Locale[(str 'en)])\")))\n    (is (thrown? Exception (read-string \"#clojure.test_clojure.protocols.RecordToTestLiterals{(keyword \\\"a\\\") 42}\"))))\n\n  (testing \"that ctors can have whitespace after class name but before {\"\n    (is (= (RecordToTestLiterals. 42)\n           (read-string \"#clojure.test_clojure.protocols.RecordToTestLiterals   {:a 42}\"))))\n\n  (testing \"that the correct errors are thrown with malformed literals\"\n    (is (thrown-with-msg?\n          Exception\n          #\"Unreadable constructor form.*\"\n          (read-string \"#java.util.Locale(\\\"en\\\")\")))\n    (is (thrown-with-msg?\n          Exception\n          #\"Unexpected number of constructor arguments.*\"\n          (read-string \"#java.util.Locale[\\\"\\\" \\\"\\\" \\\"\\\" \\\"\\\"]\")))\n    (is (thrown? Exception (read-string \"#java.util.Nachos(\\\"en\\\")\")))))\n\n(defrecord RecordToTestPrinting [a b])\n(deftest defrecord-printing\n  (testing \"that the default printer gives the proper representation\"\n    (let [r   (RecordToTestPrinting. 1 2)]\n      (is (= \"#clojure.test_clojure.protocols.RecordToTestPrinting{:a 1, :b 2}\"\n             (pr-str r)))\n      (is (= \"#clojure.test_clojure.protocols.RecordToTestPrinting[1, 2]\"\n             (binding [*print-dup* true] (pr-str r))))\n      (is (= \"#clojure.test_clojure.protocols.RecordToTestPrinting{:a 1, :b 2}\"\n             (binding [*print-dup* true *verbose-defrecords* true] (pr-str r)))))))\n\n(defrecord RecordToTest__ [__a ___b])\n(defrecord TypeToTest__   [__a ___b])\n\n(deftest test-record-and-type-field-names\n  (testing \"that types and records allow names starting with double-underscore.\n            This is a regression test for CLJ-837.\"\n    (let [r (RecordToTest__. 1 2)\n          t (TypeToTest__. 3 4)]\n      (are [x y] (= x y)\n           1 (:__a r)\n           2 (:___b r)\n           3 (.__a t)\n           4 (.___b t)))))\n\n(defrecord RecordToTestLongHint [^long a])\n(defrecord RecordToTestByteHint [^byte a])\n(defrecord RecordToTestBoolHint [^boolean a])\n(defrecord RecordToTestCovariantHint [^String a]) ;; same for arrays also\n(deftype TypeToTestLongHint [^long a])\n(deftype TypeToTestByteHint [^byte a])\n\n(deftest hinting-test\n  (testing \"that primitive hinting requiring no coercion works as expected\"\n    (is (= (RecordToTestLongHint. 42) #clojure.test_clojure.protocols.RecordToTestLongHint{:a 42}))\n    (is (= (RecordToTestLongHint. 42) #clojure.test_clojure.protocols.RecordToTestLongHint[42]))\n    (is (= (RecordToTestLongHint. 42) (clojure.test_clojure.protocols.RecordToTestLongHint/create {:a 42})))\n    (is (= (RecordToTestLongHint. 42) (map->RecordToTestLongHint {:a 42})))\n    (is (= (RecordToTestLongHint. 42) (->RecordToTestLongHint 42)))\n    (is (= (.a (TypeToTestLongHint. 42)) (.a (->TypeToTestLongHint (long 42)))))\n    (testing \"that invalid primitive types on hinted defrecord fields fails\"\n      (is (thrown?\n            ClassCastException\n            (read-string \"#clojure.test_clojure.protocols.RecordToTestLongHint{:a \\\"\\\"}\")))\n      (is (thrown?\n            IllegalArgumentException\n            (read-string \"#clojure.test_clojure.protocols.RecordToTestLongHint[\\\"\\\"]\")))\n      (is (thrown?\n            IllegalArgumentException\n            (read-string \"#clojure.test_clojure.protocols.TypeToTestLongHint[\\\"\\\"]\")))\n      (is (thrown?\n            ClassCastException\n            (clojure.test_clojure.protocols.RecordToTestLongHint/create {:a \"\"})))\n      (is (thrown?\n            ClassCastException\n            (map->RecordToTestLongHint {:a \"\"})))\n      (is (thrown?\n            ClassCastException\n            (->RecordToTestLongHint \"\")))))\n  (testing \"that primitive hinting requiring coercion works as expected\"\n    (is (= (RecordToTestByteHint. 42) (clojure.test_clojure.protocols.RecordToTestByteHint/create {:a (byte 42)})))\n    (is (= (RecordToTestByteHint. 42) (map->RecordToTestByteHint {:a (byte 42)})))\n    (is (= (RecordToTestByteHint. 42) (->RecordToTestByteHint (byte 42))))\n    (is (= (.a (TypeToTestByteHint. 42)) (.a (->TypeToTestByteHint (byte 42))))))\n  (testing \"that primitive hinting for non-numerics works as expected\"\n    (is (= (RecordToTestBoolHint. true) #clojure.test_clojure.protocols.RecordToTestBoolHint{:a true}))\n    (is (= (RecordToTestBoolHint. true) #clojure.test_clojure.protocols.RecordToTestBoolHint[true]))\n    (is (= (RecordToTestBoolHint. true) (clojure.test_clojure.protocols.RecordToTestBoolHint/create {:a true})))\n    (is (= (RecordToTestBoolHint. true) (map->RecordToTestBoolHint {:a true})))\n    (is (= (RecordToTestBoolHint. true) (->RecordToTestBoolHint true))))\n  (testing \"covariant hints -- deferred\"))\n\n(deftest reify-test\n  (testing \"of an interface\"\n    (let [s :foo\n          r (reify\n             java.util.List\n             (contains [_ o] (= s o)))]\n      (testing \"implemented methods\"\n        (is (true? (.contains r :foo)))\n        (is (false? (.contains r :bar))))\n      (testing \"unimplemented methods\"\n        (is (thrown? AbstractMethodError (.add r :baz))))))\n  (testing \"of two interfaces\"\n    (let [r (reify\n             java.util.List\n             (contains [_ o] (= :foo o))\n             java.util.Collection\n             (isEmpty [_] false))]\n      (is (true? (.contains r :foo)))\n      (is (false? (.contains r :bar)))\n      (is (false? (.isEmpty r)))))\n  (testing \"you can't define a method twice\"\n    (is (thrown? Exception\n         (eval '(reify\n                 java.util.List\n                 (size [_] 10)\n                 java.util.Collection\n                 (size [_] 20))))))\n  (testing \"you can't define a method not on an interface/protocol/j.l.Object\"\n    (is (thrown? Exception\n         (eval '(reify java.util.List (foo [_]))))))\n  (testing \"of a protocol\"\n    (let [r (reify\n             ExampleProtocol\n             (bar [this o] o)\n             (baz [this] 1)\n             (baz [this o] 2))]\n      (= :foo (.bar r :foo))\n      (= 1 (.baz r))\n      (= 2 (.baz r nil))))\n  (testing \"destructuring in method def\"\n    (let [r (reify\n             ExampleProtocol\n             (bar [this [_ _ item]] item))]\n      (= :c (.bar r [:a :b :c]))))\n  (testing \"methods can recur\"\n    (let [r (reify\n             java.util.List\n             (get [_ index]\n                  (if (zero? index)\n                    :done\n                    (recur (dec index)))))]\n      (is (= :done (.get r 0)))\n      (is (= :done (.get r 1)))))\n  (testing \"disambiguating with type hints\"\n    (testing \"you must hint an overloaded method\"\n      (is (thrown? Exception\n            (eval '(reify clojure.test_clojure.protocols.examples.ExampleInterface (hinted [_ o]))))))\n    (testing \"hinting\"\n      (let [r (reify\n               ExampleInterface\n               (hinted [_ ^int i] (inc i))\n               (hinted [_ ^String s] (str s s)))]\n        (is (= 2 (.hinted r 1)))\n        (is (= \"xoxo\" (.hinted r \"xo\")))))))\n\n\n; see CLJ-845\n(defprotocol SyntaxQuoteTestProtocol\n  (sqtp [p]))\n\n(defmacro try-extend-type [c]\n  `(extend-type ~c\n     SyntaxQuoteTestProtocol\n     (sqtp [p#] p#)))\n\n(defmacro try-extend-protocol [c]\n  `(extend-protocol SyntaxQuoteTestProtocol\n     ~c\n     (sqtp [p#] p#)))\n\n(try-extend-type String)\n(try-extend-protocol clojure.lang.Keyword)\n\n(deftest test-no-ns-capture\n  (is (= \"foo\" (sqtp \"foo\")))\n  (is (= :foo (sqtp :foo))))\n\n\n(defprotocol Dasherizer\n  (-do-dashed [this]))\n(deftype Dashed []\n  Dasherizer\n  (-do-dashed [this] 10))\n\n(deftest test-leading-dashes\n  (is (= 10 (-do-dashed (Dashed.))))\n  (is (= [10] (map -do-dashed [(Dashed.)]))))\n"
  },
  {
    "path": "test/clojure/test_clojure/reader.cljc",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Stephen C. Gilardi\n\n;;\n;;  Tests for the Clojure functions documented at the URL:\n;;\n;;    http://clojure.org/Reader\n;;\n;;  scgilardi (gmail)\n;;  Created 22 October 2008\n\n(ns clojure.test-clojure.reader\n  (:use clojure.test)\n  (:use [clojure.instant :only [read-instant-date\n                                read-instant-calendar\n                                read-instant-timestamp]])\n  (:require clojure.walk\n            [clojure.test.generative :refer (defspec)]\n            [clojure.test-clojure.generators :as cgen])\n  (:import [clojure.lang BigInt Ratio]\n           java.io.File\n           java.util.TimeZone))\n\n;; Symbols\n\n(deftest Symbols\n  (is (= 'abc (symbol \"abc\")))\n  (is (= '*+!-_? (symbol \"*+!-_?\")))\n  (is (= 'abc:def:ghi (symbol \"abc:def:ghi\")))\n  (is (= 'abc/def (symbol \"abc\" \"def\")))\n  (is (= 'abc.def/ghi (symbol \"abc.def\" \"ghi\")))\n  (is (= 'abc/def.ghi (symbol \"abc\" \"def.ghi\")))\n  (is (= 'abc:def/ghi:jkl.mno (symbol \"abc:def\" \"ghi:jkl.mno\")))\n  (is (instance? clojure.lang.Symbol 'alphabet))\n  )\n\n;; Literals\n\n(deftest Literals\n  ; 'nil 'false 'true are reserved by Clojure and are not symbols\n  (is (= 'nil nil))\n  (is (= 'false false))\n  (is (= 'true true)) )\n\n;; Strings\n\n(defn temp-file\n  [prefix suffix]\n  (File/createTempFile prefix suffix)\n  ;(doto (.deleteOnExit)) not implemented in objc\n  )\n\n(defn read-from\n  [source file form]\n  (if (= :string source)\n    (read-string form)\n    (do\n      (spit file form)\n      (load-file (str file)))))\n\n(defn code-units\n  [s]\n  (and (instance? String s) (map int s)))\n\n(deftest Strings\n  (is (= \"abcde\" (str \\a \\b \\c \\d \\e)))\n  (is (= \"abc\n  def\" (str \\a \\b \\c \\newline \\space \\space \\d \\e \\f)))\n  (let [f (temp-file \"clojure.core-reader\" \"test\")]\n    (doseq [source [:string :file]]\n      (testing (str \"Valid string literals read from \" (name source))\n        (are [x form] (= x (code-units\n                            (read-from source f (str \"\\\"\" form \"\\\"\"))))\n             [] \"\"\n             [34] \"\\\\\\\"\"\n             [10] \"\\\\n\"\n\n             [0] \"\\\\0\"\n             [0] \"\\\\000\"\n             [3] \"\\\\3\"\n             [3] \"\\\\03\"\n             [3] \"\\\\003\"\n             [0 51] \"\\\\0003\"\n             [3 48] \"\\\\0030\"\n             [0377] \"\\\\377\"\n             [0 56] \"\\\\0008\"\n\n             [0] \"\\\\u0000\"\n             [0xd7ff] \"\\\\ud7ff\"\n             [0xd800] \"\\\\ud800\"\n             [0xdfff] \"\\\\udfff\"\n             [0xe000] \"\\\\ue000\"\n             [0xffff] \"\\\\uffff\"\n             [4 49] \"\\\\u00041\"))\n      (testing (str \"Errors reading string literals from \" (name source))\n        (are [err msg form] (thrown-with-msg? err msg\n                              (read-from source f (str \"\\\"\" form \"\\\"\")))\n             Exception #\"EOF while reading string\" \"\\\\\"\n             Exception #\"Unsupported escape character: \\\\o\" \"\\\\o\"\n\n             Exception #\"Octal escape sequence must be in range \\[0, 377\\]\" \"\\\\400\"\n             Exception #\"Invalid digit: 8\" \"\\\\8\"\n             Exception #\"Invalid digit: 8\" \"\\\\8000\"\n             Exception #\"Invalid digit: 8\" \"\\\\0800\"\n             Exception #\"Invalid digit: 8\" \"\\\\0080\"\n             Exception #\"Invalid digit: a\" \"\\\\2and\"\n\n             Exception #\"Invalid unicode escape: \\\\u\" \"\\\\u\"\n             Exception #\"Invalid unicode escape: \\\\ug\" \"\\\\ug\"\n             Exception #\"Invalid unicode escape: \\\\ug\" \"\\\\ug000\"\n             Exception #\"Invalid character length: 1, should be: 4\" \"\\\\u0\"\n             Exception #\"Invalid character length: 3, should be: 4\" \"\\\\u004\"\n             Exception #\"Invalid digit: g\" \"\\\\u004g\")))))\n\n;; Numbers\n\n(deftest Numbers\n\n  ; Read Integer\n  (is (instance? Long 2147483647))\n  (is (instance? Long +1))\n  (is (instance? Long 1))\n  (is (instance? Long +0))\n  (is (instance? Long 0))\n  (is (instance? Long -0))\n  (is (instance? Long -1))\n  (is (instance? Long -2147483648))\n\n  ; Read Long\n  (is (instance? Long 2147483648))\n  (is (instance? Long -2147483649))\n  (is (instance? Long 9223372036854775807))\n  (is (instance? Long -9223372036854775808))\n\n  ;; Numeric constants of different types don't wash out. Regression fixed in\n  ;; r1157. Previously the compiler saw 0 and 0.0 as the same constant and\n  ;; caused the sequence to be built of Doubles.\n  (let [x 0.0]\n    (let [sequence (loop [i 0 l '()]\n                     (if (< i 5)\n                       (recur (inc i) (conj l i))\n                       l))]\n      (is (= [4 3 2 1 0] sequence))\n      (is (every? #(instance? Long %)\n                  sequence))))\n\n  ; Read BigInteger\n  (is (instance? BigInt 9223372036854775808))\n  (is (instance? BigInt -9223372036854775809))\n  (is (instance? BigInt 10000000000000000000000000000000000000000000000000))\n  (is (instance? BigInt -10000000000000000000000000000000000000000000000000))\n\n  ; Read Double\n  (is (instance? Double +1.0e+1))\n  (is (instance? Double +1.e+1))\n  (is (instance? Double +1e+1))\n\n  (is (instance? Double +1.0e1))\n  (is (instance? Double +1.e1))\n  (is (instance? Double +1e1))\n\n  (is (instance? Double +1.0e-1))\n  (is (instance? Double +1.e-1))\n  (is (instance? Double +1e-1))\n\n  (is (instance? Double 1.0e+1))\n  (is (instance? Double 1.e+1))\n  (is (instance? Double 1e+1))\n\n  (is (instance? Double 1.0e1))\n  (is (instance? Double 1.e1))\n  (is (instance? Double 1e1))\n\n  (is (instance? Double 1.0e-1))\n  (is (instance? Double 1.e-1))\n  (is (instance? Double 1e-1))\n\n  (is (instance? Double -1.0e+1))\n  (is (instance? Double -1.e+1))\n  (is (instance? Double -1e+1))\n\n  (is (instance? Double -1.0e1))\n  (is (instance? Double -1.e1))\n  (is (instance? Double -1e1))\n\n  (is (instance? Double -1.0e-1))\n  (is (instance? Double -1.e-1))\n  (is (instance? Double -1e-1))\n\n  (is (instance? Double +1.0))\n  (is (instance? Double +1.))\n\n  (is (instance? Double 1.0))\n  (is (instance? Double 1.))\n\n  (is (instance? Double +0.0))\n  (is (instance? Double +0.))\n\n  (is (instance? Double 0.0))\n  (is (instance? Double 0.))\n\n  (is (instance? Double -0.0))\n  (is (instance? Double -0.))\n\n  (is (instance? Double -1.0))\n  (is (instance? Double -1.))\n\n  ; Read BigDecimal\n  (is (instance? BigDecimal 9223372036854775808M))\n  (is (instance? BigDecimal -9223372036854775809M))\n  (is (instance? BigDecimal 2147483647M))\n  (is (instance? BigDecimal +1M))\n  (is (instance? BigDecimal 1M))\n  (is (instance? BigDecimal +0M))\n  (is (instance? BigDecimal 0M))\n  (is (instance? BigDecimal -0M))\n  (is (instance? BigDecimal -1M))\n  (is (instance? BigDecimal -2147483648M))\n\n  (is (instance? BigDecimal +1.0e+1M))\n  (is (instance? BigDecimal +1.e+1M))\n  (is (instance? BigDecimal +1e+1M))\n\n  (is (instance? BigDecimal +1.0e1M))\n  (is (instance? BigDecimal +1.e1M))\n  (is (instance? BigDecimal +1e1M))\n\n  (is (instance? BigDecimal +1.0e-1M))\n  (is (instance? BigDecimal +1.e-1M))\n  (is (instance? BigDecimal +1e-1M))\n\n  (is (instance? BigDecimal 1.0e+1M))\n  (is (instance? BigDecimal 1.e+1M))\n  (is (instance? BigDecimal 1e+1M))\n\n  (is (instance? BigDecimal 1.0e1M))\n  (is (instance? BigDecimal 1.e1M))\n  (is (instance? BigDecimal 1e1M))\n\n  (is (instance? BigDecimal 1.0e-1M))\n  (is (instance? BigDecimal 1.e-1M))\n  (is (instance? BigDecimal 1e-1M))\n\n  (is (instance? BigDecimal -1.0e+1M))\n  (is (instance? BigDecimal -1.e+1M))\n  (is (instance? BigDecimal -1e+1M))\n\n  (is (instance? BigDecimal -1.0e1M))\n  (is (instance? BigDecimal -1.e1M))\n  (is (instance? BigDecimal -1e1M))\n\n  (is (instance? BigDecimal -1.0e-1M))\n  (is (instance? BigDecimal -1.e-1M))\n  (is (instance? BigDecimal -1e-1M))\n\n  (is (instance? BigDecimal +1.0M))\n  (is (instance? BigDecimal +1.M))\n\n  (is (instance? BigDecimal 1.0M))\n  (is (instance? BigDecimal 1.M))\n\n  (is (instance? BigDecimal +0.0M))\n  (is (instance? BigDecimal +0.M))\n\n  (is (instance? BigDecimal 0.0M))\n  (is (instance? BigDecimal 0.M))\n\n  (is (instance? BigDecimal -0.0M))\n  (is (instance? BigDecimal -0.M))\n\n  (is (instance? BigDecimal -1.0M))\n  (is (instance? BigDecimal -1.M))\n\n  (is (instance? Ratio 1/2))\n  (is (instance? Ratio -1/2))\n  (is (instance? Ratio +1/2))\n)\n\n;; Characters\n\n(deftest t-Characters\n  (let [f (temp-file \"clojure.core-reader\" \"test\")]\n    (doseq [source [:string :file]]\n      (testing (str \"Valid char literals read from \" (name source))\n        (are [x form] (= x (read-from source f form))\n             (first \"o\") \"\\\\o\"\n             (char 0) \"\\\\o0\"\n             (char 0) \"\\\\o000\"\n             (char 047) \"\\\\o47\"\n             (char 0377) \"\\\\o377\"\n\n             (first \"u\") \"\\\\u\"\n             (first \"A\") \"\\\\u0041\"\n             (char 0) \"\\\\u0000\"\n             (char 0xd7ff) \"\\\\ud7ff\"\n             (char 0xe000) \"\\\\ue000\"\n             (char 0xffff) \"\\\\uffff\"))\n      (testing (str \"Errors reading char literals from \" (name source))\n        (are [err msg form] (thrown-with-msg? err msg (read-from source f form))\n             Exception #\"EOF while reading character\" \"\\\\\"\n             Exception #\"Unsupported character: \\\\00\" \"\\\\00\"\n             Exception #\"Unsupported character: \\\\0009\" \"\\\\0009\"\n\n             Exception #\"Invalid digit: 8\" \"\\\\o378\"\n             Exception #\"Octal escape sequence must be in range \\[0, 377\\]\" \"\\\\o400\"\n             Exception #\"Invalid digit: 8\" \"\\\\o800\"\n             Exception #\"Invalid digit: a\" \"\\\\oand\"\n             Exception #\"Invalid octal escape sequence length: 4\" \"\\\\o0470\"\n\n             Exception #\"Invalid unicode character: \\\\u0\" \"\\\\u0\"\n             Exception #\"Invalid unicode character: \\\\ug\" \"\\\\ug\"\n             Exception #\"Invalid unicode character: \\\\u000\" \"\\\\u000\"\n             Exception #\"Invalid character constant: \\\\ud800\" \"\\\\ud800\"\n             Exception #\"Invalid character constant: \\\\udfff\" \"\\\\udfff\"\n             Exception #\"Invalid unicode character: \\\\u004\" \"\\\\u004\"\n             Exception #\"Invalid unicode character: \\\\u00041\" \"\\\\u00041\"\n             Exception #\"Invalid digit: g\" \"\\\\u004g\")))))\n\n;; nil\n\n(deftest t-nil)\n\n;; Booleans\n\n(deftest t-Booleans)\n\n;; Keywords\n\n(deftest t-Keywords\n  (is (= :abc (keyword \"abc\")))\n  (is (= :abc (keyword 'abc)))\n  (is (= :*+!-_? (keyword \"*+!-_?\")))\n  (is (= :abc:def:ghi (keyword \"abc:def:ghi\")))\n  (is (= :abc/def (keyword \"abc\" \"def\")))\n  (is (= :abc/def (keyword 'abc/def)))\n  (is (= :abc.def/ghi (keyword \"abc.def\" \"ghi\")))\n  (is (= :abc/def.ghi (keyword \"abc\" \"def.ghi\")))\n  (is (= :abc:def/ghi:jkl.mno (keyword \"abc:def\" \"ghi:jkl.mno\")))\n  (is (instance? clojure.lang.Keyword :alphabet))\n  )\n\n(deftest reading-keywords\n  (are [x y] (= x (binding [*ns* (the-ns 'clojure.core)] (read-string y)))\n       :foo \":foo\"\n       :foo/bar \":foo/bar\"\n       :clojure.core/foo \"::foo\")\n  (are [err msg form] (thrown-with-msg? err msg (read-string form))\n       Exception #\"Invalid token: foo:\" \"foo:\"\n       Exception #\"Invalid token: :bar/\" \":bar/\"\n       Exception #\"Invalid token: ::does.not/exist\" \"::does.not/exist\"))\n;; Lists\n\n(deftest t-Lists)\n\n;; Vectors\n\n(deftest t-Vectors)\n\n;; Maps\n\n(deftest t-Maps)\n\n;; Sets\n\n(deftest t-Sets)\n\n;; Macro characters\n\n;; Quote (')\n\n(deftest t-Quote)\n\n;; Character (\\)\n\n(deftest t-Character)\n\n;; Comment (;)\n\n(deftest t-Comment)\n\n;; Deref (@)\n\n(deftest t-Deref)\n\n;; Dispatch (#)\n\n;; #{} - see Sets above\n\n;; Regex patterns (#\"pattern\")\n\n(deftest t-Regex)\n\n;; Metadata (^ or #^ (deprecated))\n\n(deftest t-line-column-numbers\n  (let [code \"(ns reader-metadata-test\n  (:require [clojure.java.io\n             :refer (resource reader)]))\n\n(let [a 5]\n  ^:added-metadata\n  (defn add-5\n    [x]\n    (reduce + x (range a))))\"\n        stream (clojure.lang.LineNumberingPushbackReader.\n                 (java.io.StringReader. code))\n        top-levels (take-while identity (repeatedly #(read stream false nil)))\n        expected-metadata '{ns {:line 1, :column 1}\n                            :require {:line 2, :column 3}\n                            resource {:line 3, :column 21}\n                            let {:line 5, :column 1}\n                            defn {:line 6, :column 3 :added-metadata true}\n                            reduce {:line 9, :column 5}\n                            range {:line 9, :column 17}}\n        verified-forms (atom 0)]\n    (doseq [form top-levels]\n      (clojure.walk/postwalk\n        #(when (list? %)\n           (is (= (expected-metadata (first %))\n                  (meta %)))\n           (is (->> (meta %)\n                 vals\n                 (filter number?)\n                 (every? (partial instance? Integer))))\n           (swap! verified-forms inc))\n        form))\n    ;; sanity check against e.g. reading returning ()\n    (is (= (count expected-metadata) @verified-forms))))\n\n(deftest set-line-number\n  (let [r (clojure.lang.LineNumberingPushbackReader. *in*)]\n    (.setLineNumber r 100)\n    (is (= 100 (.getLineNumber r)))))\n\n(deftest t-Metadata\n  (is (= (meta '^:static ^:awesome ^{:static false :bar :baz} sym) {:awesome true, :bar :baz, :static true})))\n\n;; Var-quote (#')\n\n(deftest t-Var-quote)\n\n;; Anonymous function literal (#())\n\n(deftest t-Anonymouns-function-literal)\n\n;; Syntax-quote (`, note, the \"backquote\" character), Unquote (~) and\n;; Unquote-splicing (~@)\n\n(deftest t-Syntax-quote\n  (are [x y] (= x y)\n      `() ()    ; was NPE before SVN r1337\n  ))\n\n;; (read)\n;; (read stream)\n;; (read stream eof-is-error)\n;; (read stream eof-is-error eof-value)\n;; (read stream eof-is-error eof-value is-recursive)\n\n(deftest t-read)\n\n(comment\n(deftest division\n  (is (= clojure.core// /))\n  (binding [*ns* *ns*]\n    (eval '(do (ns foo\n                 (:require [clojure.core :as bar])\n                 (:use [clojure.test]))\n               (is (= clojure.core// bar//))))))\n)\n\n(deftest Instants\n  (testing \"Instants are read as java.util.Date by default\"\n    (is (= java.util.Date (class #inst \"2010-11-12T13:14:15.666\"))))\n  (let [s \"#inst \\\"2010-11-12T13:14:15.666-06:00\\\"\"]\n    (binding [*data-readers* {'inst read-instant-date}]\n      (testing \"read-instant-date produces java.util.Date\"\n        (is (= java.util.Date (class (read-string s)))))\n      (testing \"java.util.Date instants round-trips\"\n        (is (= (-> s read-string)\n               (-> s read-string pr-str read-string))))\n      (testing \"java.util.Date instants round-trip throughout the year\"\n        (doseq [month (range 1 13) day (range 1 29) hour (range 1 23)]\n          (let [s (format \"#inst \\\"2010-%02d-%02dT%02d:14:15.666-06:00\\\"\" month day hour)]\n            (is (= (-> s read-string)\n                   (-> s read-string pr-str read-string))))))\n      (testing \"java.util.Date handling DST in time zones\"\n        (let [dtz (TimeZone/getDefault)]\n          (try\n            ;; A timezone with DST in effect during 2010-11-12\n            (TimeZone/setDefault (TimeZone/getTimeZone \"Australia/Sydney\"))\n            (is (= (-> s read-string)\n                   (-> s read-string pr-str read-string)))\n            (finally (TimeZone/setDefault dtz)))))\n      (testing \"java.util.Date should always print in UTC\"\n        (let [d (read-string s)\n              pstr (print-str d)\n              len (.length pstr)]\n          (is (= (subs pstr (- len 7)) \"-00:00\\\"\")))))\n    (binding [*data-readers* {'inst read-instant-calendar}]\n      (testing \"read-instant-calendar produces java.util.Calendar\"\n        (is (instance? java.util.Calendar (read-string s))))\n      (testing \"java.util.Calendar round-trips\"\n        (is (= (-> s read-string)\n               (-> s read-string pr-str read-string))))\n      (testing \"java.util.Calendar remembers timezone in literal\"\n        (is (= \"#inst \\\"2010-11-12T13:14:15.666-06:00\\\"\"\n               (-> s read-string pr-str)))\n        (is (= (-> s read-string)\n               (-> s read-string pr-str read-string))))\n      (testing \"java.util.Calendar preserves milliseconds\"\n        (is (= 666 (-> s read-string\n                       (.get java.util.Calendar/MILLISECOND)))))))\n  (let [s \"#inst \\\"2010-11-12T13:14:15.123456789\\\"\"\n        s2 \"#inst \\\"2010-11-12T13:14:15.123\\\"\"\n        s3 \"#inst \\\"2010-11-12T13:14:15.123456789123\\\"\"]\n    (binding [*data-readers* {'inst read-instant-timestamp}]\n      (testing \"read-instant-timestamp produces java.sql.Timestamp\"\n        (is (= java.sql.Timestamp (class (read-string s)))))\n      (testing \"java.sql.Timestamp preserves nanoseconds\"\n        (is (= 123456789 (-> s read-string .getNanos)))\n        (is (= 123456789 (-> s read-string pr-str read-string .getNanos)))\n        ;; truncate at nanos for s3\n        (is (= 123456789 (-> s3 read-string pr-str read-string .getNanos))))\n      (testing \"java.sql.Timestamp should compare nanos\"\n        (is (= (read-string s) (read-string s3)))\n        (is (not= (read-string s) (read-string s2)))))\n    (binding [*data-readers* {'inst read-instant-date}]\n      (testing \"read-instant-date should truncate at milliseconds\"\n        (is (= (read-string s) (read-string s2)) (read-string s3)))))\n  (let [s \"#inst \\\"2010-11-12T03:14:15.123+05:00\\\"\"\n        s2 \"#inst \\\"2010-11-11T22:14:15.123Z\\\"\"]\n    (binding [*data-readers* {'inst read-instant-date}]\n      (testing \"read-instant-date should convert to UTC\"\n        (is (= (read-string s) (read-string s2)))))\n    (binding [*data-readers* {'inst read-instant-timestamp}]\n      (testing \"read-instant-timestamp should convert to UTC\"\n        (is (= (read-string s) (read-string s2)))))\n    (binding [*data-readers* {'inst read-instant-calendar}]\n      (testing \"read-instant-calendar should preserve timezone\"\n        (is (not= (read-string s) (read-string s2)))))))\n\n;; UUID Literals\n;; #uuid \"550e8400-e29b-41d4-a716-446655440000\"\n\n(deftest UUID\n  (is (= java.util.UUID (class #uuid \"550e8400-e29b-41d4-a716-446655440000\")))\n  (is (.equals #uuid \"550e8400-e29b-41d4-a716-446655440000\"\n               #uuid \"550e8400-e29b-41d4-a716-446655440000\"))\n  (is (not (identical? #uuid \"550e8400-e29b-41d4-a716-446655440000\"\n                       #uuid \"550e8400-e29b-41d4-a716-446655440000\")))\n  (is (= 4 (.version #uuid \"550e8400-e29b-41d4-a716-446655440000\")))\n  (is (= (print-str #uuid \"550e8400-e29b-41d4-a716-446655440000\")\n         \"#uuid \\\"550e8400-e29b-41d4-a716-446655440000\\\"\")))\n\n(deftest unknown-tag\n  (let [my-unknown (fn [tag val] {:unknown-tag tag :value val})\n        throw-on-unknown (fn [tag val] (throw (RuntimeException. (str \"No data reader function for tag \" tag))))\n        my-uuid (partial my-unknown 'uuid)\n        u \"#uuid \\\"550e8400-e29b-41d4-a716-446655440000\\\"\"\n        s \"#never.heard.of/some-tag [1 2]\" ]\n    (binding [*data-readers* {'uuid my-uuid}\n              *default-data-reader-fn* my-unknown]\n      (testing \"Unknown tag\"\n        (is (= (read-string s)\n               {:unknown-tag 'never.heard.of/some-tag\n                :value [1 2]})))\n      (testing \"Override uuid tag\"\n        (is (= (read-string u)\n               {:unknown-tag 'uuid\n                :value \"550e8400-e29b-41d4-a716-446655440000\"}))))\n\n    (binding [*default-data-reader-fn* throw-on-unknown]\n      (testing \"Unknown tag with custom throw-on-unknown\"\n        (are [err msg form] (thrown-with-msg? err msg (read-string form))\n             Exception #\"No data reader function for tag foo\" \"#foo [1 2]\"\n             Exception #\"No data reader function for tag bar/foo\" \"#bar/foo [1 2]\"\n             Exception #\"No data reader function for tag bar.baz/foo\" \"#bar.baz/foo [1 2]\")))\n\n    (testing \"Unknown tag out-of-the-box behavior (like Clojure 1.4)\"\n      (are [err msg form] (thrown-with-msg? err msg (read-string form))\n           Exception #\"No reader function for tag foo\" \"#foo [1 2]\"\n           Exception #\"No reader function for tag bar/foo\" \"#bar/foo [1 2]\"\n           Exception #\"No reader function for tag bar.baz/foo\" \"#bar.baz/foo [1 2]\"))))\n\n\n(defn roundtrip\n  \"Print an object and read it back. Returns rather than throws\n   any exceptions.\"\n  [o]\n  (binding [*print-length* nil\n            *print-dup* nil\n            *print-level* nil]\n    (try\n     (-> o pr-str read-string)\n     (catch Throwable t t))))\n\n(defn roundtrip-dup\n  \"Print an object with print-dup and read it back.\n   Returns rather than throws any exceptions.\"\n  [o]\n  (binding [*print-length* nil\n            *print-dup* true\n            *print-level* nil]\n    (try\n     (-> o pr-str read-string)\n     (catch Throwable t t))))\n\n(defspec types-that-should-roundtrip\n  roundtrip\n  [^{:tag cgen/ednable} o]\n  (when-not (= o %)\n    (throw (ex-info \"Value cannot roundtrip, see ex-data\" {:printed o :read %}))))\n\n(defspec types-that-need-dup-to-roundtrip\n  roundtrip-dup\n  [^{:tag cgen/dup-readable} o]\n  (when-not (= o %)\n    (throw (ex-info \"Value cannot roundtrip, see ex-data\" {:printed o :read %}))))\n\n(defrecord TestRecord [x y])\n\n(deftest preserve-read-cond-test\n  (let [x (read-string {:read-cond :preserve} \"#?(:clj foo :cljs bar)\" )]\n       (is (reader-conditional? x))\n       (is (not (:splicing? x)))\n       (is (= :foo (get x :no-such-key :foo)))\n       (is (= (:form x) '(:clj foo :cljs bar)))\n       (is (= x (reader-conditional '(:clj foo :cljs bar) false))))\n  (let [x (read-string {:read-cond :preserve} \"#?@(:clj [foo])\" )]\n       (is (reader-conditional? x))\n       (is (:splicing? x))\n       (is (= :foo (get x :no-such-key :foo)))\n       (is (= (:form x) '(:clj [foo])))\n       (is (= x (reader-conditional '(:clj [foo]) true))))\n  (is (thrown-with-msg? RuntimeException #\"No reader function for tag\"\n                        (read-string {:read-cond :preserve} \"#js {:x 1 :y 2}\" )))\n  (let [x (read-string {:read-cond :preserve} \"#?(:cljs #js {:x 1 :y 2})\")\n        [platform tl] (:form x)]\n       (is (reader-conditional? x))\n       (is (tagged-literal? tl))\n       (is (= 'js (:tag tl)))\n       (is (= {:x 1 :y 2} (:form tl)))\n       (is (= :foo (get tl :no-such-key :foo)))\n       (is (= tl (tagged-literal 'js {:x 1 :y 2}))))\n  (testing \"print form roundtrips\"\n           (doseq [s [\"#?(:clj foo :cljs bar)\"\n                      \"#?(:cljs #js {:x 1, :y 2})\"\n                      \"#?(:clj #clojure.test_clojure.reader.TestRecord [42 85])\"]]\n                  (is (= s (pr-str (read-string {:read-cond :preserve} s)))))))\n\n(deftest reader-conditionals\n  (testing \"basic read-cond\"\n    (is (= '[foo-form]\n           (read-string {:read-cond :allow :features #{:foo}} \"[#?(:foo foo-form :bar bar-form)]\")))\n    (is (= '[bar-form]\n           (read-string {:read-cond :allow :features #{:bar}} \"[#?(:foo foo-form :bar bar-form)]\")))\n    (is (= '[foo-form]\n           (read-string {:read-cond :allow :features #{:foo :bar}} \"[#?(:foo foo-form :bar bar-form)]\")))\n    (is (= '[]\n           (read-string {:read-cond :allow :features #{:baz}} \"[#?( :foo foo-form :bar bar-form)]\"))))\n  (testing \"environmental features\"\n    (is (= \"clojure\" #?(:clj \"clojure\" :cljs \"clojurescript\" :default \"default\"))))\n  (testing \"default features\"\n    (is (= \"default\" #?(:clj-clr \"clr\" :cljs \"cljs\" :default \"default\"))))\n  (testing \"splicing\"\n    (is (= [] [#?@(:clj [])]))\n    (is (= [:a] [#?@(:clj [:a])]))\n    (is (= [:a :b] [#?@(:clj [:a :b])]))\n    (is (= [:a :b :c] [#?@(:clj [:a :b :c])]))\n    (is (= [:a :b :c] [#?@(:clj [:a :b :c])])))\n  (testing \"nested splicing\"\n    (is (= [:a :b :c :d :e]\n           [#?@(:clj [:a #?@(:clj [:b #?@(:clj [:c]) :d]):e])]))\n    (is (= '(+ 1 (+ 2 3))\n           '(+ #?@(:clj [1 (+ #?@(:clj [2 3]))]))))\n    (is (= '(+ (+ 2 3) 1)\n           '(+ #?@(:clj [(+ #?@(:clj [2 3])) 1]))))\n    (is (= [:a [:b [:c] :d] :e]\n           [#?@(:clj [:a [#?@(:clj [:b #?@(:clj [[:c]]) :d])] :e])])))\n  (testing \"bypass unknown tagged literals\"\n    (is (= [1 2 3] #?(:cljs #js [1 2 3] :clj [1 2 3])))\n    (is (= :clojure #?(:foo #some.nonexistent.Record {:x 1} :clj :clojure))))\n  (testing \"error cases\"\n    (is (thrown-with-msg? RuntimeException #\"Feature should be a keyword\" (read-string {:read-cond :allow} \"#?((+ 1 2) :a)\")))\n    (is (thrown-with-msg? RuntimeException #\"even number of forms\" (read-string {:read-cond :allow} \"#?(:cljs :a :clj)\")))\n    (is (thrown-with-msg? RuntimeException #\"read-cond-splicing must implement\" (read-string {:read-cond :allow} \"#?@(:clj :a)\")))\n    (is (thrown-with-msg? RuntimeException #\"is reserved\" (read-string {:read-cond :allow} \"#?@(:foo :a :else :b)\")))\n    (is (thrown-with-msg? RuntimeException #\"must be a list\" (read-string {:read-cond :allow} \"#?[:foo :a :else :b]\")))\n    (is (thrown-with-msg? RuntimeException #\"Conditional read not allowed\" (read-string {:read-cond :BOGUS} \"#?[:clj :a :default nil]\")))\n    (is (thrown-with-msg? RuntimeException #\"Conditional read not allowed\" (read-string \"#?[:clj :a :default nil]\")))\n    (is (thrown-with-msg? RuntimeException #\"Reader conditional splicing not allowed at the top level\" (read-string {:read-cond :allow} \"#?@(:clj [1 2])\")))\n    (is (thrown-with-msg? RuntimeException #\"Reader conditional splicing not allowed at the top level\" (read-string {:read-cond :allow} \"#?@(:clj [1])\")))\n    (is (thrown-with-msg? RuntimeException #\"Reader conditional splicing not allowed at the top level\" (read-string {:read-cond :allow} \"#?@(:clj []) 1\"))))\n  (testing \"clj-1698-regression\"\n    (let [opts {:features #{:clj} :read-cond :allow}]\n      (is (= 1 (read-string opts \"#?(:cljs {'a 1 'b 2} :clj 1)\")))\n      (is (= 1 (read-string opts \"#?(:cljs (let [{{b :b} :a {d :d} :c} {}]) :clj 1)\")))\n      (is (= '(def m {}) (read-string opts \"(def m #?(:cljs ^{:a :b} {} :clj  ^{:a :b} {}))\")))\n      (is (= '(def m {}) (read-string opts \"(def m #?(:cljs ^{:a :b} {} :clj ^{:a :b} {}))\")))\n      (is (= 1 (read-string opts \"#?(:cljs {:a #_:b :c} :clj 1)\"))))))\n\n(deftest eof-option\n  (is (= 23 (read-string {:eof 23} \"\")))\n  (is (= 23 (read {:eof 23} (clojure.lang.LineNumberingPushbackReader.\n                             (java.io.StringReader. \"\"))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/reducers.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Tassilo Horn\n\n(ns clojure.test-clojure.reducers\n  (:require [clojure.core.reducers :as r]\n            [clojure.test.generative :refer (defspec)]\n            [clojure.data.generators :as gen])\n  (:use clojure.test))\n\n(defmacro defequivtest\n  ;; f is the core fn, r is the reducers equivalent, rt is the reducible ->\n  ;; coll transformer\n  [name [f r rt] fns]\n  `(deftest ~name\n     (let [c# (range -100 1000)]\n       (doseq [fn# ~fns]\n         (is (= (~f fn# c#)\n                (~rt (~r fn# c#))))))))\n\n(defequivtest test-map\n  [map r/map #(into [] %)]\n  [inc dec #(Math/sqrt (Math/abs %))])\n\n(defequivtest test-mapcat\n  [mapcat r/mapcat #(into [] %)]\n  [(fn [x] [x])\n   (fn [x] [x (inc x)])\n   (fn [x] [x (inc x) x])])\n\n(deftest test-mapcat-obeys-reduced\n  (is (= [1 \"0\" 2 \"1\" 3]\n        (->> (concat (range 100) (lazy-seq (throw (Exception. \"Too eager\"))))\n          (r/mapcat (juxt inc str))\n          (r/take 5)\n          (into [])))))\n\n(defequivtest test-reduce\n  [reduce r/reduce identity]\n  [+' *'])\n\n(defequivtest test-filter\n  [filter r/filter #(into [] %)]\n  [even? odd? #(< 200 %) identity])\n\n\n(deftest test-sorted-maps\n  (let [m (into (sorted-map)\n                '{1 a, 2 b, 3 c, 4 d})]\n    (is (= \"1a2b3c4d\" (reduce-kv str \"\" m))\n        \"Sorted maps should reduce-kv in sorted order\")\n    (is (= 1 (reduce-kv (fn [acc k v]\n                          (reduced (+ acc k)))\n                        0 m))\n        \"Sorted maps should stop reduction when asked\")))\n\n(deftest test-nil\n  (is (= {:k :v} (reduce-kv assoc {:k :v} nil)))\n  (is (= 0 (r/fold + nil))))\n\n(defn gen-num []\n  (gen/uniform 0 2000))\n\n(defn reduced-at-probe\n  [m p]\n  (reduce-kv (fn [_ k v] (when (== p k) (reduced :foo))) nil m))\n\n(defspec reduced-always-returns\n  (fn [probe to-end]\n    (let [len (+ probe to-end 1)\n          nums (range len)\n          m (zipmap nums nums)]\n      (reduced-at-probe m probe)))\n  [^{:tag `gen-num} probe ^{:tag `gen-num} to-end]\n  (assert (= :foo %)))\n\n(deftest test-fold-runtime-exception\n  (is (thrown? IndexOutOfBoundsException\n               (let [test-map-count 1234\n                     k-fail (rand-int test-map-count)]\n                 (r/fold (fn ([])\n                           ([ret [k v]])\n                           ([ret k v] (when (= k k-fail)\n                                        (throw (IndexOutOfBoundsException.)))))\n                         (zipmap (range test-map-count) (repeat :dummy)))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/reflect.clj",
    "content": "(ns clojure.test-clojure.reflect\n  (:use clojure.data [clojure.reflect :as reflect] clojure.test clojure.pprint)\n  (:import [clojure.reflect AsmReflector JavaReflector]))\n\n(defn nodiff\n  [x y]\n  (let [[x-only y-only common] (diff x y)]\n    (when (or x-only y-only)\n      (is false (with-out-str (pprint {:x-only x-only\n                                       :y-only y-only\n                                       :common common}))))))\n\n#_(deftest compare-reflect-and-asm\n  (let [cl (.getContextClassLoader (Thread/currentThread))\n        asm-reflector (AsmReflector. cl)\n        java-reflector (JavaReflector. cl)]\n    (doseq [classname '[java.lang.Runnable\n                        java.lang.Object\n                        java.io.FileInputStream\n                        clojure.lang.Compiler\n                        clojure.lang.PersistentVector\n                        java.lang.SuppressWarnings]]\n      (nodiff (type-reflect classname :reflector asm-reflector)\n              (type-reflect classname :reflector java-reflector)))))\n\n(deftest field-descriptor->class-symbol-test\n  (are [s d] (= s (@#'reflect/field-descriptor->class-symbol d))\n       'clojure.asm.Type<><> \"[[Lclojure/asm/Type;\"\n       'int \"I\"\n       'java.lang.Object \"Ljava.lang.Object;\"))\n\n(deftest internal-name->class-symbol-test\n  (are [s n] (= s (@#'reflect/internal-name->class-symbol n))\n       'java.lang.Exception \"java/lang/Exception\"))\n"
  },
  {
    "path": "test/clojure/test_clojure/refs.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka\n\n\n(ns clojure.test-clojure.refs\n  (:use clojure.test))\n\n; http://clojure.org/refs\n\n; ref\n; deref, @-reader-macro\n; dosync io!\n; ensure ref-set alter commute\n; set-validator get-validator\n\n"
  },
  {
    "path": "test/clojure/test_clojure/repl/example.clj",
    "content": "(ns clojure.test-clojure.repl.example)\n\n;; sample namespace for repl tests, don't add anything here\n(defn foo [])\n(defn bar [])\n"
  },
  {
    "path": "test/clojure/test_clojure/repl.clj",
    "content": "(ns clojure.test-clojure.repl\n  (:use clojure.test\n        clojure.repl\n        [clojure.test-helper :only [platform-newlines]]\n        clojure.test-clojure.repl.example)\n  (:require [clojure.string :as str]))\n\n(deftest test-doc\n  (testing \"with namespaces\"\n    (is (= \"clojure.pprint\"\n           (second (str/split-lines (with-out-str (doc clojure.pprint))))))))\n\n(deftest test-source\n  (is (= \"(defn foo [])\" (source-fn 'clojure.test-clojure.repl.example/foo)))\n  (is (= (platform-newlines \"(defn foo [])\\n\") (with-out-str (source clojure.test-clojure.repl.example/foo))))\n  (is (nil? (source-fn 'non-existent-fn))))\n\n(deftest test-source-read-eval-unknown\n  (is (thrown? IllegalStateException (binding [*read-eval* :unknown] (source reduce)))))\n\n(deftest test-source-read-eval-false\n  (is (binding [*read-eval* false] (with-out-str (source reduce)))))\n\n(deftest test-dir\n  (is (thrown? Exception (dir-fn 'non-existent-ns)))\n  (is (= '[bar foo] (dir-fn 'clojure.test-clojure.repl.example)))\n  (is (= (platform-newlines \"bar\\nfoo\\n\") (with-out-str (dir clojure.test-clojure.repl.example)))))\n\n(deftest test-apropos\n  (testing \"with a regular expression\"\n    (is (= '[clojure.core/defmacro] (apropos #\"^defmacro$\")))\n    (is (some #{'clojure.core/defmacro} (apropos #\"def.acr.\")))\n    (is (= [] (apropos #\"nothing-has-this-name\"))))\n\n  (testing \"with a string\"\n    (is (some #{'clojure.core/defmacro} (apropos \"defmacro\")))\n    (is (some #{'clojure.core/defmacro} (apropos \"efmac\")))\n    (is (= [] (apropos \"nothing-has-this-name\"))))\n\n  (testing \"with a symbol\"\n    (is (some #{'clojure.core/defmacro} (apropos 'defmacro)))\n    (is (some #{'clojure.core/defmacro} (apropos 'efmac)))\n    (is (= [] (apropos 'nothing-has-this-name)))))\n\n\n(defmacro call-ns \n  \"Call ns with a unique namespace name. Return the result of calling ns\"\n  []  `(ns a#))\n(defmacro call-ns-sym \n  \"Call ns wih a unique namespace name. Return the namespace symbol.\"\n  [] `(do (ns a#) 'a#))\n\n(deftest test-dynamic-ns\n  (testing \"a call to ns returns nil\"\n   (is (= nil (call-ns))))\n  (testing \"requiring a dynamically created ns should not throw an exception\"\n    (is (= nil (let [a (call-ns-sym)] (require a))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/rt.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Stuart Halloway\n\n(ns clojure.test-clojure.rt\n  (:require clojure.set)\n  (:use clojure.test clojure.test-helper))\n(comment\n(defn bare-rt-print\n  \"Return string RT would print prior to print-initialize\"\n  [x]\n  (with-out-str\n    (try\n     (push-thread-bindings {#'clojure.core/print-initialized false})\n     (clojure.lang.RT/print x *out*)\n     (finally\n      (pop-thread-bindings)))))\n\n(deftest rt-print-prior-to-print-initialize\n  (testing \"pattern literals\"\n    (is (= \"#\\\"foo\\\"\" (bare-rt-print #\"foo\")))))\n\n(deftest error-messages\n  (testing \"binding a core var that already refers to something\"\n    (should-print-err-message\n     #\"WARNING: prefers already refers to: #'clojure.core/prefers in namespace: .*\\r?\\n\"\n     (defn prefers [] (throw (RuntimeException. \"rebound!\")))))\n  (testing \"reflection cannot resolve field\"\n    (should-print-err-message\n     #\"Reflection warning, .*:\\d+:\\d+ - reference to field blah can't be resolved\\.\\r?\\n\"\n     (defn foo [x] (.blah x))))\n  (testing \"reflection cannot resolve field on known class\"\n    (should-print-err-message\n     #\"Reflection warning, .*:\\d+:\\d+ - reference to field blah on java\\.lang\\.String can't be resolved\\.\\r?\\n\"\n     (defn foo [^String x] (.blah x))))\n  (testing \"reflection cannot resolve instance method because it is missing\"\n    (should-print-err-message\n     #\"Reflection warning, .*:\\d+:\\d+ - call to method zap on java\\.lang\\.String can't be resolved \\(no such method\\)\\.\\r?\\n\"\n     (defn foo [^String x] (.zap x 1))))\n  (testing \"reflection cannot resolve instance method because it has incompatible argument types\"\n    (should-print-err-message\n     #\"Reflection warning, .*:\\d+:\\d+ - call to method getBytes on java\\.lang\\.String can't be resolved \\(argument types: java\\.util\\.regex\\.Pattern\\)\\.\\r?\\n\"\n     (defn foo [^String x] (.getBytes x #\"boom\"))))\n  (testing \"reflection cannot resolve instance method because it has unknown argument types\"\n    (should-print-err-message\n     #\"Reflection warning, .*:\\d+:\\d+ - call to method getBytes on java\\.lang\\.String can't be resolved \\(argument types: unknown\\)\\.\\r?\\n\"\n     (defn foo [^String x y] (.getBytes x y))))\n  (testing \"reflection error prints correctly for nil arguments\"\n    (should-print-err-message\n     #\"Reflection warning, .*:\\d+:\\d+ - call to method divide on java\\.math\\.BigDecimal can't be resolved \\(argument types: unknown, unknown\\)\\.\\r?\\n\"\n     (defn foo [a] (.divide 1M a nil))))\n  (testing \"reflection cannot resolve instance method because target class is unknown\"\n    (should-print-err-message\n     #\"Reflection warning, .*:\\d+:\\d+ - call to method zap can't be resolved \\(target class is unknown\\)\\.\\r?\\n\"\n     (defn foo [x] (.zap x 1))))\n  (testing \"reflection cannot resolve static method\"\n    (should-print-err-message\n     #\"Reflection warning, .*:\\d+:\\d+ - call to static method valueOf on java\\.lang\\.Integer can't be resolved \\(argument types: java\\.util\\.regex\\.Pattern\\)\\.\\r?\\n\"\n     (defn foo [] (Integer/valueOf #\"boom\"))))\n  (testing \"reflection cannot resolve constructor\"\n    (should-print-err-message\n     #\"Reflection warning, .*:\\d+:\\d+ - call to java\\.lang\\.String ctor can't be resolved\\.\\r?\\n\"\n     (defn foo [] (String. 1 2 3)))))\n\n(def example-var)\n(deftest binding-root-clears-macro-metadata\n  (alter-meta! #'example-var assoc :macro true)\n  (is (contains? (meta #'example-var) :macro))\n  (.bindRoot #'example-var 0)\n  (is (not (contains? (meta #'example-var) :macro))))\n\n(deftest last-var-wins-for-core\n  (testing \"you can replace a core name, with warning\"\n    (let [ns (temp-ns)\n        replacement (gensym)]\n      (with-err-string-writer (intern ns 'prefers replacement))\n      (is (= replacement @('prefers (ns-publics ns))))))\n  (testing \"you can replace a name you defined before\"\n    (let [ns (temp-ns)\n          s (gensym)\n          v1 (intern ns 'foo s)\n          v2 (intern ns 'bar s)]\n      (with-err-string-writer (.refer ns 'flatten v1))\n      (.refer ns 'flatten v2)\n      (is (= v2 (ns-resolve ns 'flatten)))))\n  (testing \"you cannot intern over an existing non-core name\"\n    (let [ns (temp-ns 'clojure.set)\n          replacement (gensym)]\n      (is (thrown? IllegalStateException\n                   (intern ns 'subset? replacement)))\n      (is (nil? ('subset? (ns-publics ns))))\n      (is (= #'clojure.set/subset? ('subset? (ns-refers ns))))))\n  (testing \"you cannot refer over an existing non-core name\"\n    (let [ns (temp-ns 'clojure.set)\n          replacement (gensym)]\n      (is (thrown? IllegalStateException\n                   (.refer ns 'subset? #'clojure.set/intersection)))\n      (is (nil? ('subset? (ns-publics ns))))\n      (is (= #'clojure.set/subset? ('subset? (ns-refers ns)))))))\n)\n"
  },
  {
    "path": "test/clojure/test_clojure/sequences.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka\n; Contributors: Stuart Halloway\n\n(ns clojure.test-clojure.sequences\n  (:require [clojure.test :refer :all]\n            [clojure.test.check.generators :as gen]\n            [clojure.test.check.properties :as prop]\n            [clojure.test.check.clojure-test :refer (defspec)])\n  (:import clojure.lang.IReduce))\n\n;; *** Tests ***\n\n; TODO:\n; apply, map, filter, remove\n; and more...\n\n(deftest test-reduce-from-chunked-into-unchunked\n  (= [1 2 \\a \\b] (into [] (concat [1 2] \"ab\"))))\n \n(deftest test-reduce\n  (let [int+ (fn [a b] (+ (int a) (int b)))\n        arange (range 1 100) ;; enough to cross nodes\n        avec (into [] arange)\n        alist (into () arange)\n        obj-array (into-array arange)\n        int-array (into-array Integer/TYPE (map #(Integer. (int %)) arange))\n        long-array (into-array Long/TYPE arange)\n        float-array (into-array Float/TYPE arange)\n        char-array (into-array Character/TYPE (map char arange))\n        double-array (into-array Double/TYPE arange)\n        byte-array (into-array Byte/TYPE (map byte arange))\n        int-vec (into (vector-of :int) arange)\n        long-vec (into (vector-of :long) arange)\n        float-vec (into (vector-of :float) arange)\n        char-vec (into (vector-of :char) (map char arange))\n        double-vec (into (vector-of :double) arange)\n        byte-vec (into (vector-of :byte) (map byte arange))\n        all-true (into-array Boolean/TYPE (repeat 10 true))]\n    (is (== 4950\n           (reduce + arange)\n           (reduce + avec)\n           (.reduce ^IReduce avec +)\n           (reduce + alist)\n           (reduce + obj-array)\n           (reduce + int-array)\n           (reduce + long-array)\n           (reduce + float-array)\n           (reduce int+ char-array)\n           (reduce + double-array)\n           (reduce int+ byte-array)\n           (reduce + int-vec)\n           (reduce + long-vec)\n           (reduce + float-vec)\n           (reduce int+ char-vec)\n           (reduce + double-vec)\n           (reduce int+ byte-vec)))\n    (is (== 4951\n           (reduce + 1 arange)\n           (reduce + 1 avec)\n           (.reduce ^IReduce avec + 1)\n           (reduce + 1 alist)\n           (reduce + 1 obj-array)\n           (reduce + 1 int-array)\n           (reduce + 1 long-array)\n           (reduce + 1 float-array)\n           (reduce int+ 1 char-array)\n           (reduce + 1 double-array)\n           (reduce int+ 1 byte-array)\n           (reduce + 1 int-vec)\n           (reduce + 1 long-vec)\n           (reduce + 1 float-vec)\n           (reduce int+ 1 char-vec)\n           (reduce + 1 double-vec)\n           (reduce int+ 1 byte-vec)))\n    (is (= true\n           (reduce #(and %1 %2) all-true)\n           (reduce #(and %1 %2) true all-true)))))\n\n(deftest test-into-IReduceInit\n  (let [iri (reify clojure.lang.IReduceInit\n              (reduce [_ f start]\n                (reduce f start (range 5))))]\n    (is (= [0 1 2 3 4] (into [] iri)))))\n\n;; CLJ-1237 regression test\n(deftest reduce-with-varying-impls\n  (is (= 1000000\n         (->> (repeat 500000 (cons 1 [1]))\n              (apply concat)\n              (reduce +))))\n\n  (is (= 4500000\n         (->> (range 100000)\n              (mapcat (fn [_] (java.util.ArrayList. (range 10))))\n              (reduce +)))))\n\n(deftest test-equality\n  ; lazy sequences\n  (are [x y] (= x y)\n      ; fixed SVN 1288 - LazySeq and EmptyList equals/equiv\n      ; http://groups.google.com/group/clojure/browse_frm/thread/286d807be9cae2a5#\n      (map inc nil) ()\n      (map inc ()) ()\n      (map inc []) ()\n      (map inc #{}) ()\n      (map inc {}) ()\n      (sequence (map inc) (range 10)) (range 1 11)\n      (range 1 11) (sequence (map inc) (range 10))))\n\n\n(deftest test-lazy-seq\n  (are [x] (seq? x)\n      (lazy-seq nil)\n      (lazy-seq [])\n      (lazy-seq [1 2]))\n\n  (is (not (.equals (lazy-seq [3]) (lazy-seq [3N]))))\n\n  (are [x y] (= x y)\n      (lazy-seq nil) ()\n      (lazy-seq [nil]) '(nil)\n\n      (lazy-seq ()) ()\n      (lazy-seq []) ()\n      (lazy-seq #{}) ()\n      (lazy-seq {}) ()\n      (lazy-seq \"\") ()\n      (lazy-seq (into-array [])) ()\n\n      (lazy-seq [3]) [3N]\n      (lazy-seq (list 1 2)) '(1 2)\n      (lazy-seq [1 2]) '(1 2)\n      (lazy-seq (sorted-set 1 2)) '(1 2)\n      (lazy-seq (sorted-map :a 1 :b 2)) '([:a 1] [:b 2])\n      (lazy-seq \"abc\") '(\\a \\b \\c)\n      (lazy-seq (into-array [1 2])) '(1 2) ))\n\n\n(deftest test-seq\n  (is (not (seq? (seq []))))\n  (is (seq? (seq [1 2])))\n  (is (not (.equals (seq [3]) (seq [3N]))))\n  \n  (are [x y] (= x y)\n    (seq nil) nil\n    (seq [nil]) '(nil)\n\n    (seq ()) nil\n    (seq []) nil\n    (seq #{}) nil\n    (seq {}) nil\n    (seq \"\") nil\n    (seq (into-array [])) nil\n\n    (seq [3]) [3N]\n    (seq (list 1 2)) '(1 2)\n    (seq [1 2]) '(1 2)\n    (seq (sorted-set 1 2)) '(1 2)\n    (seq (sorted-map :a 1 :b 2)) '([:a 1] [:b 2])\n    (seq \"abc\") '(\\a \\b \\c)\n    (seq (into-array [1 2])) '(1 2) ))\n\n\n(deftest test-cons\n  (is (thrown? IllegalArgumentException (cons 1 2)))\n  (are [x y] (= x y)\n    (cons 1 nil) '(1)\n    (cons nil nil) '(nil)\n\n    (cons \\a nil) '(\\a)\n    (cons \\a \"\") '(\\a)\n    (cons \\a \"bc\") '(\\a \\b \\c)\n\n    (cons 1 ()) '(1)\n    (cons 1 '(2 3)) '(1 2 3)\n\n    (cons 1 []) [1]\n    (cons 1 [2 3]) [1 2 3]\n\n    (cons 1 #{}) '(1)\n    (cons 1 (sorted-set 2 3)) '(1 2 3)\n\n    (cons 1 (into-array [])) '(1)\n    (cons 1 (into-array [2 3])) '(1 2 3) ))\n\n\n(deftest test-empty\n  (are [x y] (and (= (empty x) y)\n                  (= (class (empty x)) (class y)))\n      nil nil\n\n      () ()\n      '(1 2) ()\n\n      [] []\n      [1 2] []\n\n      {} {}\n      {:a 1 :b 2} {}\n\n      (sorted-map) (sorted-map)\n      (sorted-map :a 1 :b 2) (sorted-map)\n\n      #{} #{}\n      #{1 2} #{}\n\n      (sorted-set) (sorted-set)\n      (sorted-set 1 2) (sorted-set)\n\n      (seq ()) nil      ; (seq ()) => nil\n      (seq '(1 2)) ()\n\n      (seq []) nil      ; (seq []) => nil\n      (seq [1 2]) ()\n\n      (seq \"\") nil      ; (seq \"\") => nil\n      (seq \"ab\") ()\n\n      (lazy-seq ()) ()\n      (lazy-seq '(1 2)) ()\n\n      (lazy-seq []) ()\n      (lazy-seq [1 2]) ()\n\n      ; non-coll, non-seq => nil\n      42 nil\n      1.2 nil\n      \"abc\" nil ))\n\n;Tests that the comparator is preserved\n;The first element should be the same in each set if preserved.\n(deftest test-empty-sorted\n  (let [inv-compare (comp - compare)]\n    (are [x y] (= (first (into (empty x) x)) \n\t\t  (first y))\n\t (sorted-set 1 2 3) (sorted-set 1 2 3)\n\t (sorted-set-by inv-compare 1 2 3) (sorted-set-by inv-compare 1 2 3)\n\n\t (sorted-map 1 :a 2 :b 3 :c) (sorted-map 1 :a 2 :b 3 :c)\n\t (sorted-map-by inv-compare 1 :a 2 :b 3 :c) (sorted-map-by inv-compare 1 :a 2 :b 3 :c))))\n\n\n(deftest test-not-empty\n  ; empty coll/seq => nil\n  (are [x] (= (not-empty x) nil)\n      ()\n      []\n      {}\n      #{}\n      (seq ())\n      (seq [])\n      (lazy-seq ())\n      (lazy-seq []) )\n\n  ; non-empty coll/seq => identity\n  (are [x] (and (= (not-empty x) x)\n                (= (class (not-empty x)) (class x)))\n      '(1 2)\n      [1 2]\n      {:a 1}\n      #{1 2}\n      (seq '(1 2))\n      (seq [1 2])\n      (lazy-seq '(1 2))\n      (lazy-seq [1 2]) ))\n\n\n(deftest test-first\n  ;(is (thrown? Exception (first)))\n  (is (thrown? IllegalArgumentException (first true)))\n  (is (thrown? IllegalArgumentException (first false)))\n  (is (thrown? IllegalArgumentException (first 1)))\n  ;(is (thrown? IllegalArgumentException (first 1 2)))\n  (is (thrown? IllegalArgumentException (first \\a)))\n  (is (thrown? IllegalArgumentException (first 's)))\n  (is (thrown? IllegalArgumentException (first :k)))\n  (are [x y] (= x y)\n    (first nil) nil\n\n    ; string\n    (first \"\") nil\n    (first \"a\") \\a\n    (first \"abc\") \\a\n\n    ; list\n    (first ()) nil\n    (first '(1)) 1\n    (first '(1 2 3)) 1\n\n    (first '(nil)) nil\n    (first '(1 nil)) 1\n    (first '(nil 2)) nil\n    (first '(())) ()\n    (first '(() nil)) ()\n    (first '(() 2 nil)) ()\n\n    ; vector\n    (first []) nil\n    (first [1]) 1\n    (first [1 2 3]) 1\n\n    (first [nil]) nil\n    (first [1 nil]) 1\n    (first [nil 2]) nil\n    (first [[]]) []\n    (first [[] nil]) []\n    (first [[] 2 nil]) []\n\n    ; set\n    (first #{}) nil\n    (first #{1}) 1\n    (first (sorted-set 1 2 3)) 1\n\n    (first #{nil}) nil\n    (first (sorted-set 1 nil)) nil\n    (first (sorted-set nil 2)) nil\n    (first #{#{}}) #{}\n    (first (sorted-set #{} nil)) nil\n    ;(first (sorted-set #{} 2 nil)) nil\n\n    ; map\n    (first {}) nil\n    (first (sorted-map :a 1)) '(:a 1)\n    (first (sorted-map :a 1 :b 2 :c 3)) '(:a 1)\n\n    ; array\n    (first (into-array [])) nil\n    (first (into-array [1])) 1\n    (first (into-array [1 2 3])) 1\n    (first (to-array [nil])) nil\n    (first (to-array [1 nil])) 1\n    (first (to-array [nil 2])) nil ))\n\n\n(deftest test-next\n ; (is (thrown? IllegalArgumentException (next)))\n  (is (thrown? IllegalArgumentException (next true)))\n  (is (thrown? IllegalArgumentException (next false)))\n  (is (thrown? IllegalArgumentException (next 1)))\n  ;(is (thrown? IllegalArgumentException (next 1 2)))\n  (is (thrown? IllegalArgumentException (next \\a)))\n  (is (thrown? IllegalArgumentException (next 's)))\n  (is (thrown? IllegalArgumentException (next :k)))\n  (are [x y] (= x y)\n    (next nil) nil\n\n    ; string\n    (next \"\") nil\n    (next \"a\") nil\n    (next \"abc\") '(\\b \\c)\n\n    ; list\n    (next ()) nil\n    (next '(1)) nil\n    (next '(1 2 3)) '(2 3)\n\n    (next '(nil)) nil\n    (next '(1 nil)) '(nil)\n    (next '(1 ())) '(())\n    (next '(nil 2)) '(2)\n    (next '(())) nil\n    (next '(() nil)) '(nil)\n    (next '(() 2 nil)) '(2 nil)\n\n    ; vector\n    (next []) nil\n    (next [1]) nil\n    (next [1 2 3]) [2 3]\n\n    (next [nil]) nil\n    (next [1 nil]) [nil]\n    (next [1 []]) [[]]\n    (next [nil 2]) [2]\n    (next [[]]) nil\n    (next [[] nil]) [nil]\n    (next [[] 2 nil]) [2 nil]\n\n    ; set\n    (next #{}) nil\n    (next #{1}) nil\n    (next (sorted-set 1 2 3)) '(2 3)\n\n    (next #{nil}) nil\n    (next (sorted-set 1 nil)) '(1)\n    (next (sorted-set nil 2)) '(2)\n    (next #{#{}}) nil\n    (next (sorted-set #{} nil)) '(#{})\n    ;(next (sorted-set #{} 2 nil)) #{}\n\n    ; map\n    (next {}) nil\n    (next (sorted-map :a 1)) nil\n    (next (sorted-map :a 1 :b 2 :c 3)) '((:b 2) (:c 3))\n\n    ; array\n    (next (into-array [])) nil\n    (next (into-array [1])) nil\n    (next (into-array [1 2 3])) '(2 3)\n\n    (next (to-array [nil])) nil\n    (next (to-array [1 nil])) '(nil)\n    ;(next (to-array [1 (into-array [])])) (list (into-array []))\n    (next (to-array [nil 2])) '(2)\n    (next (to-array [(into-array [])])) nil\n    (next (to-array [(into-array []) nil])) '(nil)\n    (next (to-array [(into-array []) 2 nil])) '(2 nil) ))\n\n\n(deftest test-last\n  (are [x y] (= x y)\n      (last nil) nil\n\n      ; list\n      (last ()) nil\n      (last '(1)) 1\n      (last '(1 2 3)) 3\n\n      (last '(nil)) nil\n      (last '(1 nil)) nil\n      (last '(nil 2)) 2\n      (last '(())) ()\n      (last '(() nil)) nil\n      (last '(() 2 nil)) nil\n\n      ; vector\n      (last []) nil\n      (last [1]) 1\n      (last [1 2 3]) 3\n\n      (last [nil]) nil\n      (last [1 nil]) nil\n      (last [nil 2]) 2\n      (last [[]]) []\n      (last [[] nil]) nil\n      (last [[] 2 nil]) nil\n\n      ; set\n      (last #{}) nil\n      (last #{1}) 1\n      (last (sorted-set 1 2 3)) 3\n\n      (last #{nil}) nil\n      (last (sorted-set 1 nil)) 1\n      (last (sorted-set nil 2)) 2\n      (last #{#{}}) #{}\n      (last (sorted-set #{} nil)) #{}\n      ;(last (sorted-set #{} 2 nil)) nil\n\n      ; map\n      (last {}) nil\n      (last (sorted-map :a 1)) [:a 1]\n      (last (sorted-map :a 1 :b 2 :c 3)) [:c 3]\n\n      ; string\n      (last \"\") nil\n      (last \"a\") \\a\n      (last \"abc\") \\c\n\n      ; array\n      (last (into-array [])) nil\n      (last (into-array [1])) 1\n      (last (into-array [1 2 3])) 3\n      (last (to-array [nil])) nil\n      (last (to-array [1 nil])) nil\n      (last (to-array [nil 2])) 2 ))\n\n\n;; (ffirst coll) = (first (first coll))\n;;\n(deftest test-ffirst\n;  (is (thrown? IllegalArgumentException (ffirst)))\n  (are [x y] (= x y)\n    (ffirst nil) nil\n\n    (ffirst ()) nil\n    (ffirst '((1 2) (3 4))) 1\n\n    (ffirst []) nil\n    (ffirst [[1 2] [3 4]]) 1\n\n    (ffirst {}) nil\n    (ffirst {:a 1}) :a\n\n    (ffirst #{}) nil\n    (ffirst #{[1 2]}) 1 ))\n\n\n;; (fnext coll) = (first (next coll)) = (second coll)\n;;\n(deftest test-fnext\n;  (is (thrown? IllegalArgumentException (fnext)))\n  (are [x y] (= x y)\n    (fnext nil) nil\n\n    (fnext ()) nil\n    (fnext '(1)) nil\n    (fnext '(1 2 3 4)) 2\n\n    (fnext []) nil\n    (fnext [1]) nil\n    (fnext [1 2 3 4]) 2\n\n    (fnext {}) nil\n    (fnext (sorted-map :a 1)) nil\n    (fnext (sorted-map :a 1 :b 2)) [:b 2]\n\n    (fnext #{}) nil\n    (fnext #{1}) nil\n    (fnext (sorted-set 1 2 3 4)) 2 ))\n\n\n;; (nfirst coll) = (next (first coll))\n;;\n(deftest test-nfirst\n;  (is (thrown? IllegalArgumentException (nfirst)))\n  (are [x y] (= x y)\n    (nfirst nil) nil\n\n    (nfirst ()) nil\n    (nfirst '((1 2 3) (4 5 6))) '(2 3)\n\n    (nfirst []) nil\n    (nfirst [[1 2 3] [4 5 6]]) '(2 3)\n\n    (nfirst {}) nil\n    (nfirst {:a 1}) '(1)\n\n    (nfirst #{}) nil\n    (nfirst #{[1 2]}) '(2) ))\n\n\n;; (nnext coll) = (next (next coll))\n;;\n(deftest test-nnext\n;  (is (thrown? IllegalArgumentException (nnext)))\n  (are [x y] (= x y)\n    (nnext nil) nil\n\n    (nnext ()) nil\n    (nnext '(1)) nil\n    (nnext '(1 2)) nil\n    (nnext '(1 2 3 4)) '(3 4)\n\n    (nnext []) nil\n    (nnext [1]) nil\n    (nnext [1 2]) nil\n    (nnext [1 2 3 4]) '(3 4)\n\n    (nnext {}) nil\n    (nnext (sorted-map :a 1)) nil\n    (nnext (sorted-map :a 1 :b 2)) nil\n    (nnext (sorted-map :a 1 :b 2 :c 3 :d 4)) '([:c 3] [:d 4])\n\n    (nnext #{}) nil\n    (nnext #{1}) nil\n    (nnext (sorted-set 1 2)) nil\n    (nnext (sorted-set 1 2 3 4)) '(3 4) ))\n\n\n(deftest test-nth\n  ; maps, sets are not supported\n  (is (thrown? UnsupportedOperationException (nth {} 0)))\n  (is (thrown? UnsupportedOperationException (nth {:a 1 :b 2} 0)))\n  (is (thrown? UnsupportedOperationException (nth #{} 0)))\n  (is (thrown? UnsupportedOperationException (nth #{1 2 3} 0)))\n\n  ; out of bounds\n  (is (thrown? IndexOutOfBoundsException (nth '() 0)))\n  (is (thrown? IndexOutOfBoundsException (nth '(1 2 3) 5)))\n  (is (thrown? IndexOutOfBoundsException (nth '() -1)))\n  (is (thrown? IndexOutOfBoundsException (nth '(1 2 3) -1)))\n\n  (is (thrown? IndexOutOfBoundsException (nth [] 0)))\n  (is (thrown? IndexOutOfBoundsException (nth [1 2 3] 5)))\n  (is (thrown? IndexOutOfBoundsException (nth [] -1)))\n  (is (thrown? IndexOutOfBoundsException (nth [1 2 3] -1)))  ; ???\n\n  (is (thrown? IndexOutOfBoundsException (nth (into-array []) 0)))\n  (is (thrown? IndexOutOfBoundsException (nth (into-array [1 2 3]) 5)))\n  (is (thrown? IndexOutOfBoundsException (nth (into-array []) -1)))\n  (is (thrown? IndexOutOfBoundsException (nth (into-array [1 2 3]) -1)))\n\n  (is (thrown? StringIndexOutOfBoundsException (nth \"\" 0)))\n  (is (thrown? StringIndexOutOfBoundsException (nth \"abc\" 5)))\n  (is (thrown? StringIndexOutOfBoundsException (nth \"\" -1)))\n  (is (thrown? StringIndexOutOfBoundsException (nth \"abc\" -1)))\n\n  (is (thrown? IndexOutOfBoundsException (nth (java.util.ArrayList. []) 0)))\n  (is (thrown? IndexOutOfBoundsException (nth (java.util.ArrayList. [1 2 3]) 5)))\n  (is (thrown? IndexOutOfBoundsException (nth (java.util.ArrayList. []) -1)))       ; ???\n  (is (thrown? IndexOutOfBoundsException (nth (java.util.ArrayList. [1 2 3]) -1)))  ; ???\n\n  (are [x y] (= x y)\n      (nth '(1) 0) 1\n      (nth '(1 2 3) 0) 1\n      (nth '(1 2 3 4 5) 1) 2\n      (nth '(1 2 3 4 5) 4) 5\n      (nth '(1 2 3) 5 :not-found) :not-found\n\n      (nth [1] 0) 1\n      (nth [1 2 3] 0) 1\n      (nth [1 2 3 4 5] 1) 2\n      (nth [1 2 3 4 5] 4) 5\n      (nth [1 2 3] 5 :not-found) :not-found\n\n      (nth (into-array [1]) 0) 1\n      (nth (into-array [1 2 3]) 0) 1\n      (nth (into-array [1 2 3 4 5]) 1) 2\n      (nth (into-array [1 2 3 4 5]) 4) 5\n      (nth (into-array [1 2 3]) 5 :not-found) :not-found\n\n      (nth \"a\" 0) \\a\n      (nth \"abc\" 0) \\a\n      (nth \"abcde\" 1) \\b\n      (nth \"abcde\" 4) \\e\n      (nth \"abc\" 5 :not-found) :not-found\n\n      (nth (java.util.ArrayList. [1]) 0) 1\n      (nth (java.util.ArrayList. [1 2 3]) 0) 1\n      (nth (java.util.ArrayList. [1 2 3 4 5]) 1) 2\n      (nth (java.util.ArrayList. [1 2 3 4 5]) 4) 5\n      (nth (java.util.ArrayList. [1 2 3]) 5 :not-found) :not-found )\n\n  ; regex Matchers\n  (let [m (re-matcher #\"(a)(b)\" \"ababaa\")]\n    (re-find m) ; => [\"ab\" \"a\" \"b\"]\n    (are [x y] (= x y)\n        (nth m 0) \"ab\"\n        (nth m 1) \"a\"\n        (nth m 2) \"b\"\n        (nth m 3 :not-found) :not-found\n        (nth m -1 :not-found) :not-found )\n    (is (thrown? IndexOutOfBoundsException (nth m 3)))\n    (is (thrown? IndexOutOfBoundsException (nth m -1))))\n\n  (let [m (re-matcher #\"c\" \"ababaa\")]\n    (re-find m) ; => nil\n    (are [x y] (= x y)\n        (nth m 0 :not-found) :not-found\n        (nth m 2 :not-found) :not-found\n        (nth m -1 :not-found) :not-found )\n    (is (thrown? IllegalStateException (nth m 0)))\n    (is (thrown? IllegalStateException (nth m 2)))\n    (is (thrown? IllegalStateException (nth m -1)))))\n\n\n; distinct was broken for nil & false:\n;   fixed in rev 1278:\n;   http://code.google.com/p/clojure/source/detail?r=1278\n;\n(deftest test-distinct\n  (are [x y] (= x y)\n      (distinct ()) ()\n      (distinct '(1)) '(1)\n      (distinct '(1 2 3)) '(1 2 3)\n      (distinct '(1 2 3 1 1 1)) '(1 2 3)\n      (distinct '(1 1 1 2)) '(1 2)\n      (distinct '(1 2 1 2)) '(1 2)\n\n      (distinct []) ()\n      (distinct [1]) '(1)\n      (distinct [1 2 3]) '(1 2 3)\n      (distinct [1 2 3 1 2 2 1 1]) '(1 2 3)\n      (distinct [1 1 1 2]) '(1 2)\n      (distinct [1 2 1 2]) '(1 2)\n\n      (distinct \"\") ()\n      (distinct \"a\") '(\\a)\n      (distinct \"abc\") '(\\a \\b \\c)\n      (distinct \"abcabab\") '(\\a \\b \\c)\n      (distinct \"aaab\") '(\\a \\b)\n      (distinct \"abab\") '(\\a \\b) )\n\n  (are [x] (= (distinct [x x]) [x])\n      nil\n      false true\n      0 42\n      0.0 3.14\n      2/3\n      0M 1M\n      \\c\n      \"\" \"abc\"\n      'sym\n      :kw\n      () '(1 2)\n      [] [1 2]\n      {} {:a 1 :b 2}\n      #{} #{1 2} ))\n\n\n(deftest test-interpose\n  (are [x y] (= x y)\n    (interpose 0 []) ()\n    (interpose 0 [1]) '(1)\n    (interpose 0 [1 2]) '(1 0 2)\n    (interpose 0 [1 2 3]) '(1 0 2 0 3) ))\n\n\n(deftest test-interleave\n  (are [x y] (= x y)\n    (interleave [1 2] [3 4]) '(1 3 2 4)\n\n    (interleave [1] [3 4]) '(1 3)\n    (interleave [1 2] [3]) '(1 3)\n\n    (interleave [] [3 4]) ()\n    (interleave [1 2] []) ()\n    (interleave [] []) ()\n\n    (interleave [1]) '(1)\n\n    (interleave) () ))\n\n\n(deftest test-zipmap\n  (are [x y] (= x y)\n    (zipmap [:a :b] [1 2]) {:a 1 :b 2}\n\n    (zipmap [:a] [1 2]) {:a 1}\n    (zipmap [:a :b] [1]) {:a 1}\n\n    (zipmap [] [1 2]) {}\n    (zipmap [:a :b] []) {}\n    (zipmap [] []) {} ))\n\n\n(deftest test-concat\n  (are [x y] (= x y)\n    (concat) ()\n\n    (concat []) ()\n    (concat [1 2]) '(1 2)\n\n    (concat [1 2] [3 4]) '(1 2 3 4)\n    (concat [] [3 4]) '(3 4)\n    (concat [1 2] []) '(1 2)\n    (concat [] []) ()\n\n    (concat [1 2] [3 4] [5 6]) '(1 2 3 4 5 6) ))\n\n\n(deftest test-cycle\n  (are [x y] (= x y)\n    (cycle []) ()\n\n    (take 3 (cycle [1])) '(1 1 1)\n    (take 5 (cycle [1 2 3])) '(1 2 3 1 2)\n\n    (take 3 (cycle [nil])) '(nil nil nil)\n\n    (transduce (take 5) + (cycle [1])) 5\n    (transduce (take 5) + 2 (cycle [1])) 7\n    (transduce (take 5) + (cycle [3 7])) 23\n    (transduce (take 5) + 2 (cycle [3 7])) 25\n\n    (take 2 (cycle (map #(/ 42 %) '(2 1 0)))) '(21 42)\n    (first (next (cycle (map #(/ 42 %) '(2 1 0))))) 42\n    (into [] (take 2) (cycle (map #(/ 42 %) '(2 1 0)))) '(21 42)))\n\n\n(deftest test-partition\n  (are [x y] (= x y)\n    (partition 2 [1 2 3]) '((1 2))\n    (partition 2 [1 2 3 4]) '((1 2) (3 4))\n    (partition 2 []) ()\n\n    (partition 2 3 [1 2 3 4 5 6 7]) '((1 2) (4 5))\n    (partition 2 3 [1 2 3 4 5 6 7 8]) '((1 2) (4 5) (7 8))\n    (partition 2 3 []) ()\n\n    (partition 1 []) ()\n    (partition 1 [1 2 3]) '((1) (2) (3))\n\n    (partition 5 [1 2 3]) ()\n\n;    (partition 0 [1 2 3]) (repeat nil)   ; infinite sequence of nil\n    (partition -1 [1 2 3]) ()\n    (partition -2 [1 2 3]) () )\n\n    ;; reduce\n    (is (= [1 2 4 8 16] (map #(reduce * (repeat % 2)) (range 5))))\n    (is (= [3 6 12 24 48] (map #(reduce * 3 (repeat % 2)) (range 5))))\n\n    ;; equality and hashing\n    (is (= (repeat 5 :x) (repeat 5 :x)))\n    (is (= (repeat 5 :x) '(:x :x :x :x :x)))\n    (is (= (hash (repeat 5 :x)) (hash '(:x :x :x :x :x))))\n    (is (= (assoc (array-map (repeat 1 :x) :y) '(:x) :z) {'(:x) :z}))\n    (is (= (assoc (hash-map (repeat 1 :x) :y) '(:x) :z) {'(:x) :z})))\n\n\n(deftest test-iterate\n      (are [x y] (= x y)\n           (take 0 (iterate inc 0)) ()\n           (take 1 (iterate inc 0)) '(0)\n           (take 2 (iterate inc 0)) '(0 1)\n           (take 5 (iterate inc 0)) '(0 1 2 3 4) )\n\n      ;; test other fns\n      (is (= '(:foo 42 :foo 42) (take 4 (iterate #(if (= % :foo) 42 :foo) :foo))))\n      (is (= '(1 false true true) (take 4 (iterate #(instance? Boolean %) 1))))\n      (is (= '(256 128 64 32 16 8 4 2 1 0) (take 10 (iterate #(quot % 2) 256))))\n      (is (= '(0 true) (take 2 (iterate zero? 0))))\n      (is (= 2 (first (next (next (iterate inc 0))))))\n      (is (= [1 2 3] (into [] (take 3) (next (iterate inc 0)))))\n\n      ;; reduce via transduce\n      (is (= (transduce (take 5) + (iterate #(* 2 %) 2)) 62))\n      (is (= (transduce (take 5) + 1 (iterate #(* 2 %) 2)) 63)) )\n\n\n(deftest test-reverse\n  (are [x y] (= x y)\n    (reverse nil) ()    ; since SVN 1294\n    (reverse []) ()\n    (reverse [1]) '(1)\n    (reverse [1 2 3]) '(3 2 1) ))\n\n\n(deftest test-take\n  (are [x y] (= x y)\n    (take 1 [1 2 3 4 5]) '(1)\n    (take 3 [1 2 3 4 5]) '(1 2 3)\n    (take 5 [1 2 3 4 5]) '(1 2 3 4 5)\n    (take 9 [1 2 3 4 5]) '(1 2 3 4 5)\n\n    (take 0 [1 2 3 4 5]) ()\n    (take -1 [1 2 3 4 5]) ()\n    (take -2 [1 2 3 4 5]) () ))\n\n\n(deftest test-drop\n  (are [x y] (= x y)\n    (drop 1 [1 2 3 4 5]) '(2 3 4 5)\n    (drop 3 [1 2 3 4 5]) '(4 5)\n    (drop 5 [1 2 3 4 5]) ()\n    (drop 9 [1 2 3 4 5]) ()\n\n    (drop 0 [1 2 3 4 5]) '(1 2 3 4 5)\n    (drop -1 [1 2 3 4 5]) '(1 2 3 4 5)\n    (drop -2 [1 2 3 4 5]) '(1 2 3 4 5) ))\n\n\n(deftest test-take-nth\n  (are [x y] (= x y)\n     (take-nth 1 [1 2 3 4 5]) '(1 2 3 4 5)\n     (take-nth 2 [1 2 3 4 5]) '(1 3 5)\n     (take-nth 3 [1 2 3 4 5]) '(1 4)\n     (take-nth 4 [1 2 3 4 5]) '(1 5)\n     (take-nth 5 [1 2 3 4 5]) '(1)\n     (take-nth 9 [1 2 3 4 5]) '(1)\n\n     ; infinite seq of 1s = (repeat 1)\n     ;(take-nth 0 [1 2 3 4 5])\n     ;(take-nth -1 [1 2 3 4 5])\n     ;(take-nth -2 [1 2 3 4 5])\n  ))\n\n\n(deftest test-take-while\n  (are [x y] (= x y)\n    (take-while pos? []) ()\n    (take-while pos? [1 2 3 4]) '(1 2 3 4)\n    (take-while pos? [1 2 3 -1]) '(1 2 3)\n    (take-while pos? [1 -1 2 3]) '(1)\n    (take-while pos? [-1 1 2 3]) ()\n    (take-while pos? [-1 -2 -3]) () ))\n\n\n(deftest test-drop-while\n  (are [x y] (= x y)\n    (drop-while pos? []) ()\n    (drop-while pos? [1 2 3 4]) ()\n    (drop-while pos? [1 2 3 -1]) '(-1)\n    (drop-while pos? [1 -1 2 3]) '(-1 2 3)\n    (drop-while pos? [-1 1 2 3]) '(-1 1 2 3)\n    (drop-while pos? [-1 -2 -3]) '(-1 -2 -3) ))\n\n\n(deftest test-butlast\n  (are [x y] (= x y)\n    (butlast []) nil\n    (butlast [1]) nil\n    (butlast [1 2 3]) '(1 2) ))\n\n\n(deftest test-drop-last\n  (are [x y] (= x y)\n    ; as butlast\n    (drop-last []) ()\n    (drop-last [1]) ()\n    (drop-last [1 2 3]) '(1 2)\n\n    ; as butlast, but lazy\n    (drop-last 1 []) ()\n    (drop-last 1 [1]) ()\n    (drop-last 1 [1 2 3]) '(1 2)\n\n    (drop-last 2 []) ()\n    (drop-last 2 [1]) ()\n    (drop-last 2 [1 2 3]) '(1)\n\n    (drop-last 5 []) ()\n    (drop-last 5 [1]) ()\n    (drop-last 5 [1 2 3]) ()\n\n    (drop-last 0 []) ()\n    (drop-last 0 [1]) '(1)\n    (drop-last 0 [1 2 3]) '(1 2 3)\n\n    (drop-last -1 []) ()\n    (drop-last -1 [1]) '(1)\n    (drop-last -1 [1 2 3]) '(1 2 3)\n\n    (drop-last -2 []) ()\n    (drop-last -2 [1]) '(1)\n    (drop-last -2 [1 2 3]) '(1 2 3) ))\n\n\n(deftest test-split-at\n  (is (vector? (split-at 2 [])))\n  (is (vector? (split-at 2 [1 2 3])))\n\n  (are [x y] (= x y)\n    (split-at 2 []) [() ()]\n    (split-at 2 [1 2 3 4 5]) [(list 1 2) (list 3 4 5)]\n\n    (split-at 5 [1 2 3]) [(list 1 2 3) ()]\n    (split-at 0 [1 2 3]) [() (list 1 2 3)]\n    (split-at -1 [1 2 3]) [() (list 1 2 3)]\n    (split-at -5 [1 2 3]) [() (list 1 2 3)] ))\n\n\n(deftest test-split-with\n  (is (vector? (split-with pos? [])))\n  (is (vector? (split-with pos? [1 2 -1 0 3 4])))\n\n  (are [x y] (= x y)\n    (split-with pos? []) [() ()]\n    (split-with pos? [1 2 -1 0 3 4]) [(list 1 2) (list -1 0 3 4)]\n\n    (split-with pos? [-1 2 3 4 5]) [() (list -1 2 3 4 5)]\n    (split-with number? [1 -2 \"abc\" \\x]) [(list 1 -2) (list \"abc\" \\x)] ))\n\n\n(deftest test-repeat\n  ;(is (thrown? IllegalArgumentException (repeat)))\n\n  ; infinite sequence => use take\n  (are [x y] (= x y)\n      (take 0 (repeat 7)) ()\n      (take 1 (repeat 7)) '(7)\n      (take 2 (repeat 7)) '(7 7)\n      (take 5 (repeat 7)) '(7 7 7 7 7) )\n\n  ; limited sequence\n  (are [x y] (= x y)\n      (repeat 0 7) ()\n      (repeat 1 7) '(7)\n      (repeat 2 7) '(7 7)\n      (repeat 5 7) '(7 7 7 7 7)\n\n      (repeat -1 7) ()\n      (repeat -3 7) () )\n\n  ; test different data types\n  (are [x] (= (repeat 3 x) (list x x x))\n      nil\n      false true\n      0 42\n      0.0 3.14\n      2/3\n      0M 1M\n      \\c\n      \"\" \"abc\"\n      'sym\n      :kw\n      () '(1 2)\n      [] [1 2]\n      {} {:a 1 :b 2}\n      #{} #{1 2} ))\n\n(defspec longrange-equals-range 100\n  (prop/for-all [start gen/int\n                 end gen/int\n                 step gen/s-pos-int]\n                (= (clojure.lang.Range/create start end step)\n                   (clojure.lang.LongRange/create start end step))))\n\n(deftest test-range\n  (are [x y] (= x y)\n      (take 100 (range)) (range 100)\n\n      (range 0) ()   ; exclusive end!\n      (range 1) '(0)\n      (range 5) '(0 1 2 3 4)\n\n      (range -1) ()\n      (range -3) ()\n\n      (range 2.5) '(0 1 2)\n      (range 7/3) '(0 1 2)\n\n      (range 0 3) '(0 1 2)\n      (range 0 1) '(0)\n      (range 0 0) ()\n      (range 0 -3) ()\n\n      (range 3 6) '(3 4 5)\n      (range 3 4) '(3)\n      (range 3 3) ()\n      (range 3 1) ()\n      (range 3 0) ()\n      (range 3 -2) ()\n\n      (range -2 5) '(-2 -1 0 1 2 3 4)\n      (range -2 0) '(-2 -1)\n      (range -2 -1) '(-2)\n      (range -2 -2) ()\n      (range -2 -5) ()\n\n      (take 3 (range 3 9 0)) '(3 3 3)\n      (take 3 (range 9 3 0)) '(9 9 9)\n      (range 0 0 0) ()\n      (range 3 9 1) '(3 4 5 6 7 8)\n      (range 3 9 2) '(3 5 7)\n      (range 3 9 3) '(3 6)\n      (range 3 9 10) '(3)\n      (range 3 9 -1) ()\n      (range 10 10 -1) ()\n      (range 10 9 -1) '(10)\n      (range 10 8 -1) '(10 9)\n      (range 10 7 -1) '(10 9 8)\n      (range 10 0 -2) '(10 8 6 4 2)\n\n      (take 100 (range)) (take 100 (iterate inc 0))\n\n      (range 1/2 5 1/3) '(1/2 5/6 7/6 3/2 11/6 13/6 5/2 17/6 19/6 7/2 23/6 25/6 9/2 29/6)\n      (range 0.5 8 1.2) '(0.5 1.7 2.9 4.1 5.3 6.5 7.7)\n      (range 0.5 -4 -2) '(0.5 -1.5 -3.5)\n      (take 3 (range Long/MAX_VALUE Double/POSITIVE_INFINITY)) '(9223372036854775807 9223372036854775808N 9223372036854775809N)\n\n      (reduce + (take 100 (range))) 4950\n      (reduce + 0 (take 100 (range))) 4950\n      (reduce + (range 100)) 4950\n      (reduce + 0 (range 100)) 4950\n      (reduce + (range 0.0 100.0)) 4950.0\n      (reduce + 0 (range 0.0 100.0)) 4950.0\n\n      (reduce + (iterator-seq (.iterator (range 100)))) 4950\n      (reduce + (iterator-seq (.iterator (range 0.0 100.0 1.0)))) 4950.0 ))\n\n(defn unlimited-range-create [& args]\n  (let [[arg1 arg2 arg3] args]\n    (case (count args)\n      1 (clojure.lang.Range/create arg1)\n      2 (clojure.lang.Range/create arg1 arg2)\n      3 (clojure.lang.Range/create arg1 arg2 arg3))))\n\n(deftest test-longrange-corners\n  (let [lmax Long/MAX_VALUE\n        lmax-1 (- Long/MAX_VALUE 1)\n        lmax-2 (- Long/MAX_VALUE 2)\n        lmax-31 (- Long/MAX_VALUE 31)\n        lmax-32 (- Long/MAX_VALUE 32)\n        lmax-33 (- Long/MAX_VALUE 33)\n        lmin Long/MIN_VALUE\n        lmin+1 (+ Long/MIN_VALUE 1)\n        lmin+2 (+ Long/MIN_VALUE 2)\n        lmin+31 (+ Long/MIN_VALUE 31)\n        lmin+32 (+ Long/MIN_VALUE 32)\n        lmin+33 (+ Long/MIN_VALUE 33)]\n    (doseq [range-args [ [lmax-2 lmax]\n                         [lmax-33 lmax]\n                         [lmax-33 lmax-31]\n                         [lmin+2 lmin -1]\n                         [lmin+33 lmin -1]\n                         [lmin+33 lmin+31 -1]\n                         [lmin lmax lmax]\n                         [lmax lmin lmin]\n                         [-1 lmax lmax]\n                         [1 lmin lmin]]]\n    (is (= (apply unlimited-range-create range-args)\n           (apply range range-args))\n        (apply str \"from (range \" (concat (interpose \" \" range-args) \")\"))))))\n\n(deftest test-empty?\n  (are [x] (empty? x)\n    nil\n    ()\n    (lazy-seq nil)    ; => ()\n    []\n    {}\n    #{}\n    \"\"\n    (into-array []) )\n\n  (are [x] (not (empty? x))\n    '(1 2)\n    (lazy-seq [1 2])\n    [1 2]\n    {:a 1 :b 2}\n    #{1 2}\n    \"abc\"\n    (into-array [1 2]) ))\n\n\n(deftest test-every?\n  ; always true for nil or empty coll/seq\n  (are [x] (= (every? pos? x) true)\n      nil\n      () [] {} #{}\n      (lazy-seq [])\n      (into-array []) )\n\n  (are [x y] (= x y)\n      true (every? pos? [1])\n      true (every? pos? [1 2])\n      true (every? pos? [1 2 3 4 5])\n\n      false (every? pos? [-1])\n      false (every? pos? [-1 -2])\n      false (every? pos? [-1 -2 3])\n      false (every? pos? [-1 2])\n      false (every? pos? [1 -2])\n      false (every? pos? [1 2 -3])\n      false (every? pos? [1 2 -3 4]) )\n\n  (are [x y] (= x y)\n      true (every? #{:a} [:a :a])\n;!      false (every? #{:a} [:a :b])   ; Issue 68: every? returns nil instead of false\n;!      false (every? #{:a} [:b :b])   ; http://code.google.com/p/clojure/issues/detail?id=68\n  ))\n\n\n(deftest test-not-every?\n  ; always false for nil or empty coll/seq\n  (are [x] (= (not-every? pos? x) false)\n      nil\n      () [] {} #{}\n      (lazy-seq [])\n      (into-array []) )\n\n  (are [x y] (= x y)\n      false (not-every? pos? [1])\n      false (not-every? pos? [1 2])\n      false (not-every? pos? [1 2 3 4 5])\n\n      true (not-every? pos? [-1])\n      true (not-every? pos? [-1 -2])\n      true (not-every? pos? [-1 -2 3])\n      true (not-every? pos? [-1 2])\n      true (not-every? pos? [1 -2])\n      true (not-every? pos? [1 2 -3])\n      true (not-every? pos? [1 2 -3 4]) )\n\n  (are [x y] (= x y)\n      false (not-every? #{:a} [:a :a])\n      true (not-every? #{:a} [:a :b])\n      true (not-every? #{:a} [:b :b]) ))\n\n\n(deftest test-not-any?\n  ; always true for nil or empty coll/seq\n  (are [x] (= (not-any? pos? x) true)\n      nil\n      () [] {} #{}\n      (lazy-seq [])\n      (into-array []) )\n\n  (are [x y] (= x y)\n      false (not-any? pos? [1])\n      false (not-any? pos? [1 2])\n      false (not-any? pos? [1 2 3 4 5])\n\n      true (not-any? pos? [-1])\n      true (not-any? pos? [-1 -2])\n\n      false (not-any? pos? [-1 -2 3])\n      false (not-any? pos? [-1 2])\n      false (not-any? pos? [1 -2])\n      false (not-any? pos? [1 2 -3])\n      false (not-any? pos? [1 2 -3 4]) )\n\n  (are [x y] (= x y)\n      false (not-any? #{:a} [:a :a])\n      false (not-any? #{:a} [:a :b])\n      true (not-any? #{:a} [:b :b]) ))\n\n\n(deftest test-some\n  ;; always nil for nil or empty coll/seq\n  (are [x] (= (some pos? x) nil)\n       nil\n       () [] {} #{}\n       (lazy-seq [])\n       (into-array []))\n  \n  (are [x y] (= x y)\n       nil (some nil nil)\n       \n       true (some pos? [1])\n       true (some pos? [1 2])\n       \n       nil (some pos? [-1])\n       nil (some pos? [-1 -2])\n       true (some pos? [-1 2])\n       true (some pos? [1 -2])\n       \n       :a (some #{:a} [:a :a])\n       :a (some #{:a} [:b :a])\n       nil (some #{:a} [:b :b])\n       \n       :a (some #{:a} '(:a :b))\n       :a (some #{:a} #{:a :b})\n       ))\n\n(deftest test-flatten-present\n  (are [expected nested-val] (= (flatten nested-val) expected)\n       ;simple literals\n       [] nil\n       [] 1\n       [] 'test\n       [] :keyword\n       [] 1/2\n       [] #\"[\\r\\n]\"\n       [] true\n       [] false\n       ;vectors\n       [1 2 3 4 5] [[1 2] [3 4 [5]]]\n       [1 2 3 4 5] [1 2 3 4 5]\n       [#{1 2} 3 4 5] [#{1 2} 3 4 5]\n       ;sets\n       [] #{}\n       [] #{#{1 2} 3 4 5}\n       [] #{1 2 3 4 5}\n       [] #{#{1 2} 3 4 5}\n       ;lists\n       [] '()\n       [1 2 3 4 5] `(1 2 3 4 5)\n       ;maps\n       [] {:a 1 :b 2}\n       [:a 1 :b 2] (sort-by key {:a 1 :b 2})\n       [] {[:a :b] 1 :c 2}\n       [:a :b 1 :c 2] (sort-by val {[:a :b] 1 :c 2})\n       [:a 1 2 :b 3] (sort-by key {:a [1 2] :b 3})\n       ;Strings\n       [] \"12345\"\n       [\\1 \\2 \\3 \\4 \\5] (seq \"12345\")\n       ;fns\n       [] count\n       [count even? odd?] [count even? odd?]))\n\n(deftest test-group-by\n  (is (= (group-by even? [1 2 3 4 5]) \n\t {false [1 3 5], true [2 4]})))\n\n(deftest test-partition-by\n  (are [test-seq] (= (partition-by (comp even? count) test-seq)\n\t\t     [[\"a\"] [\"bb\" \"cccc\" \"dd\"] [\"eee\" \"f\"] [\"\" \"hh\"]])\n       [\"a\" \"bb\" \"cccc\" \"dd\" \"eee\" \"f\" \"\" \"hh\"]\n       '(\"a\" \"bb\" \"cccc\" \"dd\" \"eee\" \"f\" \"\" \"hh\"))\n  (is (=(partition-by #{\\a \\e \\i \\o \\u} \"abcdefghijklm\")\n       [[\\a] [\\b \\c \\d] [\\e] [\\f \\g \\h] [\\i] [\\j \\k \\l \\m]])))\n\n(deftest test-frequencies\n  (are [expected test-seq] (= (frequencies test-seq) expected)\n       {\\p 2, \\s 4, \\i 4, \\m 1} \"mississippi\"\n       {1 4 2 2 3 1} [1 1 1 1 2 2 3]\n       {1 4 2 2 3 1} '(1 1 1 1 2 2 3)))\n\n(deftest test-reductions\n  (is (= (reductions + nil)\n         [0]))\n  (is (= (reductions + [1 2 3 4 5])\n\t [1 3 6 10 15]))\n  (is (= (reductions + 10 [1 2 3 4 5])\n\t [10 11 13 16 20 25])))\n\n(deftest test-reductions-obeys-reduced\n  (is (= [0 :x]\n         (reductions (constantly (reduced :x))\n                     (range))))\n  (is (= [:x]\n         (reductions (fn [acc x] x)\n                     (reduced :x)\n                     (range))))\n  (is (= [2 6 12 12]\n         (reductions (fn [acc x]\n                       (if (= x :stop)\n                         (reduced acc)\n                         (+ acc x)))\n                     [2 4 6 :stop 8 10]))))\n\n(deftest test-rand-nth-invariants\n  (let [elt (rand-nth [:a :b :c :d])]\n    (is (#{:a :b :c :d} elt))))\n\n(deftest test-partition-all\n  (is (= (partition-all 4 [1 2 3 4 5 6 7 8 9])\n\t [[1 2 3 4] [5 6 7 8] [9]]))\n  (is (= (partition-all 4 2 [1 2 3 4 5 6 7 8 9])\n\t [[1 2 3 4] [3 4 5 6] [5 6 7 8] [7 8 9] [9]])))\n\n(deftest test-shuffle-invariants\n  (is (= (count (shuffle [1 2 3 4])) 4))\n  (let [shuffled-seq (shuffle [1 2 3 4])]\n    (is (every? #{1 2 3 4} shuffled-seq))))\n\n(deftest test-ArrayIter\n  (are [arr expected]\n    (let [iter (clojure.lang.ArrayIter/createFromObject arr)]\n      (loop [accum []]\n        (if (.hasNext iter)\n          (recur (conj accum (.next iter)))\n          (is (= expected accum)))))\n    nil []\n    (object-array [\"a\" \"b\" \"c\"]) [\"a\" \"b\" \"c\"]\n    (boolean-array [false true false]) [false true false]\n    (byte-array [1 2]) [(byte 1) (byte 2)]\n    (short-array [1 2]) [1 2]\n    (int-array [1 2]) [1 2]\n    (long-array [1 2]) [1 2]\n    (float-array [2.0 -2.5]) [2.0 -2.5]\n    (double-array [1.2 -3.5]) [1.2 -3.5]\n    (char-array [\\H \\i]) [\\H \\i]))\n\n(deftest CLJ-1633\n  (is (= ((fn [& args] (apply (fn [a & b] (apply list b)) args)) 1 2 3) '(2 3))))\n\n(deftest test-subseq\n  (let [s1 (range 100)\n        s2 (into (sorted-set) s1)]\n    (is (= s1 (seq s2)))\n    (doseq [i (range 100)]\n      (is (= s1 (concat (subseq s2 < i) (subseq s2 >= i))))\n      (is (= (reverse s1) (concat (rsubseq s2 >= i) (rsubseq s2 < i)))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/serialization.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;; Author: Chas Emerick\n;;         cemerick@snowtide.com\n\n(ns clojure.test-clojure.serialization\n  (:use clojure.test)\n  (:import (java.io ObjectOutputStream ObjectInputStream\n             ByteArrayOutputStream ByteArrayInputStream)))\n\n(defn- serialize\n  \"Serializes a single object, returning a byte array.\"\n  [v]\n  (with-open [bout (ByteArrayOutputStream.)\n              oos (ObjectOutputStream. bout)]\n    (.writeObject oos v)\n    (.flush oos)\n    (.toByteArray bout)))\n\n(defn- deserialize\n  \"Deserializes and returns a single object from the given byte array.\"\n  [bytes]\n  (with-open [ois (-> bytes ByteArrayInputStream. ObjectInputStream.)]\n    (.readObject ois)))\n\n(defrecord SerializationRecord [a b c])\n(defstruct SerializationStruct :a :b :c)\n\n(defn- build-via-transient\n  [coll]\n  (persistent!\n    (reduce conj! (transient coll) (map vec (partition 2 (range 1000))))))\n\n(defn- roundtrip\n  [v]\n  (let [rt (-> v serialize deserialize)\n        rt-seq (-> v seq serialize deserialize)]\n    (and (= v rt)\n      (= (seq v) (seq rt))\n      (= (seq v) rt-seq))))\n\n(deftest sequable-serialization\n  (are [val] (roundtrip val)\n    ; lists and related\n    (list)\n    (apply list (range 10))\n    (cons 0 nil)\n    (clojure.lang.Cons. 0 nil)\n\n    ; vectors\n    []\n    (into [] (range 10))\n    (into [] (range 25))\n    (into [] (range 100))\n    (into [] (range 500))\n    (into [] (range 1000))\n\n    ; maps\n    {}\n    {:a 5 :b 0}\n    (apply array-map (range 100))\n    (apply hash-map (range 100))\n\n    ; sets\n    #{}\n    #{'a 'b 'c}\n    (set (range 10))\n    (set (range 25))\n    (set (range 100))\n    (set (range 500))\n    (set (range 1000))\n    (sorted-set)\n    (sorted-set 'a 'b 'c)\n    (apply sorted-set (reverse (range 10)))\n    (apply sorted-set (reverse (range 25)))\n    (apply sorted-set (reverse (range 100)))\n    (apply sorted-set (reverse (range 500)))\n    (apply sorted-set (reverse (range 1000)))\n\n    ; queues\n    clojure.lang.PersistentQueue/EMPTY\n    (into clojure.lang.PersistentQueue/EMPTY (range 50))\n\n    ; lazy seqs\n    (lazy-seq nil)\n    (lazy-seq (list* (range 50)))\n\n    ; transient / persistent! round-trip\n    (build-via-transient [])\n    (build-via-transient {})\n    (build-via-transient #{})\n\n    ; array-seqs\n    (seq (make-array Object 10))\n    (seq (make-array Boolean/TYPE 10))\n    (seq (make-array Byte/TYPE 10))\n    (seq (make-array Character/TYPE 10))\n    (seq (make-array Double/TYPE 10))\n    (seq (make-array Float/TYPE 10))\n    (seq (make-array Integer/TYPE 10))\n    (seq (make-array Long/TYPE 10))\n\n    ; \"records\"\n    (SerializationRecord. 0 :foo (range 20))\n    (struct SerializationStruct 0 :foo (range 20))\n\n    ; misc seqs\n    (seq \"s11n\")\n    (range 50)\n    (rseq (apply sorted-set (reverse (range 100))))\n\n    ;; partially realized chunked range\n    (let [r (range 50)]\n      (nth r 35)\n      r)))\n\n(deftest misc-serialization\n  (are [v] (= v (-> v serialize deserialize))\n    25/3\n    :keyword\n    ::namespaced-keyword\n    'symbol))\n\n(deftest tostringed-bytes\n  (let [rt #(-> % serialize seq)\n        s1 (rt 'sym123)\n        k1 (rt :kw123)\n        _ (.toString 'sym123)\n        _ (.toString :kw123)\n        s2 (rt 'sym123)\n        k2 (rt :kw123)]\n    (is (= s1 s2))\n    (is (= k1 k2))))\n\n(deftest interned-serializations\n  (are [v] (identical? v (-> v serialize deserialize))\n    clojure.lang.RT/DEFAULT_COMPARATOR\n    \n    ; namespaces just get deserialized back into the same-named ns in the present runtime\n    ; (they're referred to by defrecord instances)\n    *ns*))\n\n(deftest function-serialization\n  (let [capture 5]\n    (are [f] (= capture ((-> f serialize deserialize)))\n      (constantly 5)\n      (fn [] 5)\n      #(do 5)\n      (constantly capture)\n      (fn [] capture)\n      #(do capture))))\n\n(deftest check-unserializable-objects\n  (are [t] (thrown? java.io.NotSerializableException (serialize t))\n    ;; transients\n    (transient [])\n    (transient {})\n    (transient #{})\n\n    ;; reference types\n    (atom nil)\n    (ref nil)\n    (agent nil)\n    #'+\n\n    ;; stateful seqs\n    (enumeration-seq (java.util.Collections/enumeration (range 50)))\n    (iterator-seq (.iterator (range 50)))))"
  },
  {
    "path": "test/clojure/test_clojure/special.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka\n\n;;\n;;  Test special forms, macros and metadata\n;;\n\n(ns clojure.test-clojure.special\n  (:use clojure.test))\n\n; http://clojure.org/special_forms\n\n; let, letfn\n; quote\n; var\n; fn\n\n(deftest multiple-keys-in-destructuring\n  (let [foo (fn [& {:keys [x]}] x)\n        bar (fn [& options] (apply foo :x :b options))]\n    (is (= (bar) :b))\n    (is (= (bar :x :a) :a))))\n\n(deftest empty-list-with-:as-destructuring\n  (let [{:as x} '()]\n    (is (= {} x))))\n\n(deftest keywords-in-destructuring\n  (let [{:keys [:a :b]} {:a 1 :b 2}]\n    (is (= 1 a))\n    (is (= 2 b))))\n\n(deftest namespaced-keywords-in-destructuring\n  (let [{:keys [:a/b :c/d]} {:a/b 1 :c/d 2}]\n    (is (= 1 b))\n    (is (= 2 d))))\n\n(deftest namespaced-keys-in-destructuring\n  (let [{:keys [a/b c/d]} {:a/b 1 :c/d 2}]\n    (is (= 1 b))\n    (is (= 2 d))))\n\n(deftest namespaced-syms-in-destructuring\n  (let [{:syms [a/b c/d]} {'a/b 1 'c/d 2}]\n    (is (= 1 b))\n    (is (= 2 d))))\n\n(deftest keywords-not-allowed-in-let-bindings\n  (is (thrown-with-msg? Exception #\"Unsupported binding key: :a\"\n                        (eval '(let [:a 1] a))))\n  (is (thrown-with-msg? Exception #\"Unsupported binding key: :a/b\"\n                        (eval '(let [:a/b 1] b)))))\n\n(require '[clojure.string :as s])\n(deftest resolve-keyword-ns-alias-in-destructuring\n  (let [{:keys [::s/x ::s/y]} {:clojure.string/x 1 :clojure.string/y 2}]\n    (is (= x 1))\n    (is (= y 2))))\n"
  },
  {
    "path": "test/clojure/test_clojure/string.clj",
    "content": "(ns clojure.test-clojure.string\n  (:require [clojure.string :as s])\n  (:use clojure.test))\n\n(deftest t-split\n  (is (= [\"a\" \"b\"] (s/split \"a-b\" #\"-\")))\n  (is (= [\"a\" \"b-c\"] (s/split \"a-b-c\" #\"-\" 2)))\n  (is (vector? (s/split \"abc\" #\"-\"))))\n\n(deftest t-reverse\n  (is (= \"tab\" (s/reverse \"bat\"))))\n\n(deftest t-replace\n  (is (= \"faabar\" (s/replace \"foobar\" \\o \\a)))\n  (is (= \"foobar\" (s/replace \"foobar\" \\z \\a)))\n  (is (= \"barbarbar\" (s/replace \"foobarfoo\" \"foo\" \"bar\")))\n  (is (= \"foobarfoo\" (s/replace \"foobarfoo\" \"baz\" \"bar\")))\n  (is (= \"f$$d\" (s/replace \"food\" \"o\" \"$\")))\n  (is (= \"f\\\\\\\\d\" (s/replace \"food\" \"o\" \"\\\\\")))\n  (is (= \"barbarbar\" (s/replace \"foobarfoo\" #\"foo\" \"bar\")))\n  (is (= \"foobarfoo\" (s/replace \"foobarfoo\" #\"baz\" \"bar\")))\n  (is (= \"f$$d\" (s/replace \"food\" #\"o\" (s/re-quote-replacement \"$\"))))\n  (is (= \"f\\\\\\\\d\" (s/replace \"food\" #\"o\" (s/re-quote-replacement \"\\\\\"))))\n  (is (= \"FOObarFOO\" (s/replace \"foobarfoo\" #\"foo\" s/upper-case)))\n  (is (= \"foobarfoo\" (s/replace \"foobarfoo\" #\"baz\" s/upper-case)))\n  (is (= \"OObarOO\" (s/replace \"foobarfoo\" #\"f(o+)\" (fn [[m g1]] (s/upper-case g1)))))\n  (is (= \"baz\\\\bang\\\\\" (s/replace \"bazslashbangslash\" #\"slash\" (constantly \"\\\\\")))))\n\n(deftest t-replace-first\n  (is (= \"faobar\" (s/replace-first \"foobar\" \\o \\a)))\n  (is (= \"foobar\" (s/replace-first \"foobar\" \\z \\a)))\n  (is (= \"z.ology\" (s/replace-first \"zoology\" \\o \\.)))\n  (is (= \"barbarfoo\" (s/replace-first \"foobarfoo\" \"foo\" \"bar\")))\n  (is (= \"foobarfoo\" (s/replace-first \"foobarfoo\" \"baz\" \"bar\")))\n  (is (= \"f$od\" (s/replace-first \"food\" \"o\" \"$\")))\n  (is (= \"f\\\\od\" (s/replace-first \"food\" \"o\" \"\\\\\")))\n  (is (= \"barbarfoo\" (s/replace-first \"foobarfoo\" #\"foo\" \"bar\")))\n  (is (= \"foobarfoo\" (s/replace-first \"foobarfoo\" #\"baz\" \"bar\")))\n  (is (= \"f$od\" (s/replace-first \"food\" #\"o\" (s/re-quote-replacement \"$\"))))\n  (is (= \"f\\\\od\" (s/replace-first \"food\" #\"o\" (s/re-quote-replacement \"\\\\\"))))\n  (is (= \"FOObarfoo\" (s/replace-first \"foobarfoo\" #\"foo\" s/upper-case)))\n  (is (= \"foobarfoo\" (s/replace-first \"foobarfoo\" #\"baz\" s/upper-case)))\n  (is (= \"OObarfoo\" (s/replace-first \"foobarfoo\" #\"f(o+)\" (fn [[m g1]] (s/upper-case g1)))))\n  (is (= \"baz\\\\bangslash\" (s/replace-first \"bazslashbangslash\" #\"slash\" (constantly \"\\\\\")))))\n\n(deftest t-join\n  (are [x coll] (= x (s/join coll))\n       \"\" nil\n       \"\" []\n       \"1\" [1]\n       \"12\" [1 2])\n  (are [x sep coll] (= x (s/join sep coll))\n       \"1,2,3\" \\, [1 2 3]\n       \"\" \\, []\n       \"1\" \\, [1]\n       \"1 and-a 2 and-a 3\" \" and-a \" [1 2 3]))\n\n(deftest t-trim-newline\n  (is (= \"foo\" (s/trim-newline \"foo\\n\")))\n  (is (= \"foo\" (s/trim-newline \"foo\\r\\n\")))\n  (is (= \"foo\" (s/trim-newline \"foo\")))\n  (is (= \"\" (s/trim-newline \"\"))))\n\n(deftest t-capitalize\n  (is (= \"Foobar\" (s/capitalize \"foobar\")))\n  (is (= \"Foobar\" (s/capitalize \"FOOBAR\"))))\n\n(deftest t-triml\n  (is (= \"foo \" (s/triml \" foo \")))\n  (is (= \"\" (s/triml \"   \")))\n  (is (= \"bar\" (s/triml \"\\u2002 \\tbar\"))))\n\n(deftest t-trimr\n  (is (= \" foo\" (s/trimr \" foo \")))\n  (is (= \"\" (s/trimr \"   \")))\n  (is (= \"bar\" (s/trimr \"bar\\t \\u2002\"))))\n\n(deftest t-trim\n  (is (= \"foo\" (s/trim \"  foo  \\r\\n\")))\n  (is (= \"bar\" (s/trim \"\\u2000bar\\t \\u2002\"))))\n\n(deftest t-upper-case\n  (is (= \"FOOBAR\" (s/upper-case \"Foobar\"))))\n\n(deftest t-lower-case\n  (is (= \"foobar\" (s/lower-case \"FooBar\"))))\n\n(deftest nil-handling\n  (are [f args] (thrown? NullPointerException (apply f args))\n       s/reverse [nil]\n       s/replace [nil #\"foo\" \"bar\"]\n       s/replace-first [nil #\"foo\" \"bar\"]\n       s/re-quote-replacement [nil]\n       s/capitalize [nil]\n       s/upper-case [nil]\n       s/lower-case [nil]\n       s/split [nil #\"-\"]\n       s/split [nil #\"-\" 1]\n       s/trim [nil]\n       s/triml [nil]\n       s/trimr [nil]\n       s/trim-newline [nil]))\n\n(deftest char-sequence-handling\n  (are [result f args] (let [[^CharSequence s & more] args]\n                         (= result (apply f (StringBuffer. s) more)))\n       \"paz\" s/reverse [\"zap\"]\n       \"foo:bar\" s/replace [\"foo-bar\" \\- \\:]\n       \"ABC\" s/replace [\"abc\" #\"\\w\" s/upper-case]\n       \"faa\" s/replace [\"foo\" #\"o\" (StringBuffer. \"a\")]\n       \"baz::quux\" s/replace-first [\"baz--quux\" #\"--\" \"::\"]\n       \"baz::quux\" s/replace-first [\"baz--quux\" (StringBuffer. \"--\") (StringBuffer. \"::\")]\n       \"zim-zam\" s/replace-first [\"zim zam\" #\" \" (StringBuffer. \"-\")]\n       \"\\\\\\\\ \\\\$\" s/re-quote-replacement [\"\\\\ $\"]\n       \"Pow\" s/capitalize [\"POW\"]\n       \"BOOM\" s/upper-case [\"boom\"]\n       \"whimper\" s/lower-case [\"whimPER\"]\n       [\"foo\" \"bar\"] s/split [\"foo-bar\" #\"-\"]\n       \"calvino\" s/trim [\"  calvino  \"]\n       \"calvino  \" s/triml [\"  calvino  \"]\n       \"  calvino\" s/trimr [\"  calvino  \"]\n       \"the end\" s/trim-newline [\"the end\\r\\n\\r\\r\\n\"]\n       true s/blank? [\" \"]\n       [\"a\" \"b\"] s/split-lines [\"a\\nb\"]\n       \"fa la la\" s/escape [\"fo lo lo\" {\\o \\a}]))\n\n(deftest t-escape\n  (is (= \"&lt;foo&amp;bar&gt;\"\n         (s/escape \"<foo&bar>\" {\\& \"&amp;\" \\< \"&lt;\" \\> \"&gt;\"})))\n  (is (= \" \\\\\\\"foo\\\\\\\" \"\n         (s/escape \" \\\"foo\\\" \" {\\\" \"\\\\\\\"\"})))\n  (is (= \"faabor\"\n         (s/escape \"foobar\" {\\a \\o, \\o \\a}))))\n\n(deftest t-blank\n  (is (s/blank? nil))\n  (is (s/blank? \"\"))\n  (is (s/blank? \" \"))\n  (is (s/blank? \" \\t \\n  \\r \"))\n  (is (not (s/blank? \"  foo  \"))))\n\n(deftest t-split-lines\n  (let [result (s/split-lines \"one\\ntwo\\r\\nthree\")]\n    (is (= [\"one\" \"two\" \"three\"] result))\n    (is (vector? result)))\n  (is (= (list \"foo\") (s/split-lines \"foo\"))))\n\n"
  },
  {
    "path": "test/clojure/test_clojure/test.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;;; test_clojure/test.clj: unit tests for test.clj\n\n;; by Stuart Sierra\n;; January 16, 2009\n\n;; Thanks to Chas Emerick, Allen Rohner, and Stuart Halloway for\n;; contributions and suggestions.\n\n\n(ns clojure.test-clojure.test\n  (:use clojure.test)\n  (:require [clojure.stacktrace :as stack]))\n\n(deftest can-test-symbol\n  (let [x true]\n    (is x \"Should pass\"))\n  (let [x false]\n    (is x \"Should fail\")))\n\n(deftest can-test-boolean\n  (is true \"Should pass\")\n  (is false \"Should fail\"))\n\n(deftest can-test-nil\n  (is nil \"Should fail\"))\n\n(deftest can-test-=\n  (is (= 2 (+ 1 1)) \"Should pass\")\n  (is (= 3 (+ 2 2)) \"Should fail\"))\n\n(deftest can-test-instance\n  (is (instance? Long (+ 2 2)) \"Should pass\")\n  (is (instance? Float (+ 1 1)) \"Should fail\"))\n\n(deftest can-test-thrown\n  (is (thrown? ArithmeticException (/ 1 0)) \"Should pass\")\n  ;; No exception is thrown:\n  (is (thrown? Exception (+ 1 1)) \"Should fail\")\n  ;; Wrong class of exception is thrown:\n  (is (thrown? ArithmeticException (throw (RuntimeException.))) \"Should error\"))\n\n(deftest can-test-thrown-with-msg\n  (is (thrown-with-msg? ArithmeticException #\"Divide by zero\" (/ 1 0)) \"Should pass\")\n  ;; Wrong message string:\n  (is (thrown-with-msg? ArithmeticException #\"Something else\" (/ 1 0)) \"Should fail\")\n  ;; No exception is thrown:\n  (is (thrown? Exception (+ 1 1)) \"Should fail\")\n  ;; Wrong class of exception is thrown:\n  (is (thrown-with-msg? IllegalArgumentException #\"Divide by zero\" (/ 1 0)) \"Should error\"))\n\n(deftest can-catch-unexpected-exceptions\n  (is (= 1 (throw (Exception.))) \"Should error\"))\n\n(deftest can-test-method-call\n  (is (.startsWith \"abc\" \"a\") \"Should pass\")\n  (is (.startsWith \"abc\" \"d\") \"Should fail\"))\n\n(deftest can-test-anonymous-fn\n  (is (#(.startsWith % \"a\") \"abc\") \"Should pass\")\n  (is (#(.startsWith % \"d\") \"abc\") \"Should fail\"))\n\n(deftest can-test-regexps\n  (is (re-matches #\"^ab.*$\" \"abbabba\") \"Should pass\")\n  (is (re-matches #\"^cd.*$\" \"abbabba\") \"Should fail\")\n  (is (re-find #\"ab\" \"abbabba\") \"Should pass\")\n  (is (re-find #\"cd\" \"abbabba\") \"Should fail\"))\n\n(deftest clj-1102-empty-stack-trace-should-not-throw-exceptions\n  (let [empty-stack (into-array (Class/forName \"java.lang.StackTraceElement\")\n                                [])\n        t (doto (Exception.) (.setStackTrace empty-stack))]\n    (is (map? (#'clojure.test/file-and-line t 0)) \"Should pass\")\n    (is (string? (with-out-str (stack/print-stack-trace t))) \"Should pass\")))\n\n(deftest #^{:has-meta true} can-add-metadata-to-tests\n  (is (:has-meta (meta #'can-add-metadata-to-tests)) \"Should pass\"))\n\n;; still have to declare the symbol before testing unbound symbols\n(declare does-not-exist)\n\n#_(deftest can-test-unbound-symbol\n  (is (= nil does-not-exist) \"Should error\"))\n\n#_(deftest can-test-unbound-function\n  (is (does-not-exist) \"Should error\"))\n\n\n;; Here, we create an alternate version of test/report, that\n;; compares the event with the message, then calls the original\n;; 'report' with modified arguments.\n\n(declare ^:dynamic original-report)\n\n(defn custom-report [data]\n  (let [event (:type data)\n        msg (:message data)\n        expected (:expected data)\n        actual (:actual data)\n        passed (cond\n                 (= event :fail) (= msg \"Should fail\")\n                 (= event :pass) (= msg \"Should pass\")\n                 (= event :error) (= msg \"Should error\")\n                 :else true)]\n    (if passed\n      (original-report {:type :pass, :message msg,\n                        :expected expected, :actual actual})\n      (original-report {:type :fail, :message (str msg \" but got \" event)\n                        :expected expected, :actual actual}))))\n\n;; test-ns-hook will be used by test/test-ns to run tests in this\n;; namespace.\n(defn test-ns-hook []\n  (binding [original-report report\n            report custom-report]\n    (test-all-vars (find-ns 'clojure.test-clojure.test))))\n"
  },
  {
    "path": "test/clojure/test_clojure/test_fixtures.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n;\n;;; test_fixtures.clj: unit tests for fixtures in test.clj\n\n;; by Stuart Sierra\n;; March 28, 2009\n\n(ns clojure.test-clojure.test-fixtures\n  (:use clojure.test))\n\n(declare ^:dynamic *a* ^:dynamic *b* ^:dynamic *c* ^:dynamic *d*)\n\n(def ^:dynamic *n* 0)\n\n(defn fixture-a [f]\n  (binding [*a* 3] (f)))\n\n(defn fixture-b [f]\n  (binding [*b* 5] (f)))\n\n(defn fixture-c [f]\n  (binding [*c* 7] (f)))\n\n(defn fixture-d [f]\n  (binding [*d* 11] (f)))\n\n(defn inc-n-fixture [f]\n  (binding [*n* (inc *n*)] (f)))\n\n(def side-effects (atom 0))\n(defn side-effecting-fixture [f]\n  (swap! side-effects inc)\n  (f))\n\n(use-fixtures :once fixture-a fixture-b)\n\n(use-fixtures :each fixture-c fixture-d inc-n-fixture side-effecting-fixture)\n(use-fixtures :each fixture-c fixture-d inc-n-fixture side-effecting-fixture)\n\n(deftest can-use-once-fixtures\n  (is (= 3 *a*))\n  (is (= 5 *b*)))\n\n(deftest can-use-each-fixtures\n  (is (= 7 *c*))\n  (is (= 11 *d*)))\n\n(deftest use-fixtures-replaces\n  (is (= *n* 1)))\n\n(deftest can-run-a-single-test-with-fixtures\n  ;; We have to use a side-effecting fixture to test that the fixtures are\n  ;; running, in order to distinguish fixtures run because of our call to\n  ;; test-vars below from the same fixtures running prior to this test\n  (let [side-effects-so-far @side-effects\n        reported (atom [])]\n    (binding [report (fn [m] (swap! reported conj (:type m)))]\n      (test-vars [#'can-use-each-fixtures]))\n    (is (= [:begin-test-var :pass :pass :end-test-var] @reported))\n    (is (= (inc side-effects-so-far) @side-effects))))\n\n(defn should-not-trigger-fixtures [])\n\n(deftest a-var-lacking-test-meta-should-not-trigger-fixtures\n  (let [side-effects-so-far @side-effects]\n    (test-vars [#'should-not-trigger-fixtures])\n    (is (= side-effects-so-far @side-effects))))\n"
  },
  {
    "path": "test/clojure/test_clojure/transducers.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Alex Miller\n\n(ns clojure.test-clojure.transducers\n  (:require [clojure.string :as s]\n            [clojure.test :refer :all]\n            [clojure.test.check :as chk]\n            [clojure.test.check.generators :as gen]\n            [clojure.test.check.properties :as prop]\n            [clojure.test.check.clojure-test :as ctest]))\n\n(defmacro fbind [source-gen f]\n  `(gen/fmap\n     (fn [s#]\n       {:desc (list '~f (:name s#))\n        :seq  (partial ~f (:val s#))\n        :xf   (~f (:val s#))})\n     ~source-gen))\n\n(defmacro pickfn [& fns]\n  `(gen/elements\n     [~@(for [f fns] `{:val ~f :name '~f})]))\n\n(defn literal\n  [g]\n  (gen/fmap\n    (fn [s] {:val s :name s})\n    g))\n\n;; These $ versions are \"safe\" when used with possibly mixed numbers, sequences, etc\n\n(defn- inc$ [n]\n  (if (number? n) (inc n) 1))\n\n(defn- dec$ [n]\n  (if (number? n) (dec n) 1))\n\n(defn- odd?$ [n]\n  (if (number? n) (odd? n) false))\n\n(defn- pos?$ [n]\n  (if (number? n) (pos? n) false))\n\n(defn- empty?$ [s]\n  (if (instance? clojure.lang.Seqable s) (empty? s) false))\n\n(def gen-mapfn\n  (pickfn inc$ dec$))\n\n(def gen-mapcatfn\n  (pickfn vector\n          #(if (instance? clojure.lang.Seqable %) (partition-all 3 %) (vector %))))\n\n(def gen-predfn\n  (pickfn odd?$ pos?$ empty?$ sequential?))\n\n(def gen-indexedfn\n  (pickfn (fn [index item] index)\n          (fn [index item] item)\n          (fn [index item] (if (number? item) (+ index item) index))))\n\n(def gen-take (fbind (literal gen/s-pos-int) take))\n(def gen-drop (fbind (literal gen/pos-int) drop))\n(def gen-drop-while (fbind gen-predfn drop-while))\n(def gen-map (fbind gen-mapfn map))\n(def gen-mapcat (fbind gen-mapcatfn mapcat))\n(def gen-filter (fbind gen-predfn filter))\n(def gen-remove (fbind gen-predfn remove))\n(def gen-keep (fbind gen-predfn keep))\n(def gen-partition-all (fbind (literal gen/s-pos-int) partition-all))\n(def gen-partition-by (fbind gen-predfn partition-by))\n(def gen-take-while (fbind gen-predfn take-while))\n(def gen-take-nth (fbind (literal gen/s-pos-int) take-nth))\n(def gen-keep-indexed (fbind gen-indexedfn keep-indexed))\n(def gen-map-indexed (fbind gen-indexedfn map-indexed))\n(def gen-replace (fbind (literal (gen/return (hash-map (range 100) (range 1 100)))) replace))\n(def gen-distinct (gen/return {:desc 'distinct :seq (partial distinct) :xf (distinct)}))\n(def gen-dedupe (gen/return {:desc 'dedupe :seq (partial dedupe) :xf (dedupe)}))\n(def gen-interpose (fbind (literal gen/s-pos-int) interpose))\n\n(def gen-action\n  (gen/one-of [gen-take gen-drop gen-map gen-mapcat\n               gen-filter gen-remove gen-keep\n               gen-partition-all gen-partition-by gen-take-while\n               gen-take-nth gen-drop-while\n               gen-keep-indexed gen-map-indexed\n               gen-distinct gen-dedupe gen-interpose]))\n\n(def gen-actions\n  (gen/vector gen-action 1 5))\n\n(def gen-coll\n  (gen/vector gen/int))\n\n(defn apply-as-seq [coll actions]\n  (doall\n    (loop [s coll\n           [action & actions'] actions]\n          (if action\n            (recur ((:seq action) s) actions')\n            s))))\n\n(defn apply-as-xf-seq\n  [coll actions]\n  (doall (sequence (apply comp (map :xf actions)) coll)))\n\n(defn apply-as-xf-into\n  [coll actions]\n  (into [] (apply comp (map :xf actions)) coll))\n\n(defn apply-as-xf-eduction\n  [coll actions]\n  (into [] (eduction (apply comp (map :xf actions)) coll)))\n\n(defn apply-as-xf-transduce\n  [coll actions]\n  (transduce (apply comp (map :xf actions)) conj coll))\n\n(defmacro return-exc [& forms]\n  `(try ~@forms (catch Throwable e# e#)))\n\n(defn build-results\n  [coll actions]\n  (let [s (return-exc (apply-as-seq coll actions))\n        xs (return-exc (apply-as-xf-seq coll actions))\n        xi (return-exc (apply-as-xf-into coll actions))\n        xe (return-exc (apply-as-xf-eduction coll actions))\n        xt (return-exc (apply-as-xf-transduce coll actions))]\n    {:coll    coll\n     :actions (concat '(->> coll) (map :desc actions))\n     :s       s\n     :xs      xs\n     :xi      xi\n     :xe      xe\n     :xt      xt}))\n\n(def result-gen\n  (gen/fmap\n    (fn [[c a]] (build-results c a))\n    (gen/tuple gen-coll gen-actions)))\n\n(defn result-good?\n  [{:keys [s xs xi xe xt]}]\n  (= s xs xi xe xt))\n\n(deftest seq-and-transducer\n  (let [res (chk/quick-check\n              200000\n              (prop/for-all* [result-gen] result-good?))]\n    (when-not (:result res)\n      (is\n        (:result res)\n        (->\n          res\n          :shrunk\n          :smallest\n          first\n          clojure.pprint/pprint\n          with-out-str)))))\n\n(deftest test-transduce\n  (let [long+ (fn ([a b] (+ (long a) (long b)))\n                ([a] a)\n                ([] 0))\n        mapinc (map inc)\n        mapinclong (map (comp inc long))\n        arange (range 100)\n        avec (into [] arange)\n        alist (into () arange)\n        obj-array (into-array arange)\n        int-array (into-array Integer/TYPE (map #(Integer. (int %)) arange))\n        long-array (into-array Long/TYPE arange)\n        float-array (into-array Float/TYPE arange)\n        char-array (into-array Character/TYPE (map char arange))\n        double-array (into-array Double/TYPE arange)\n        byte-array (into-array Byte/TYPE (map byte arange))\n        int-vec (into (vector-of :int) arange)\n        long-vec (into (vector-of :long) arange)\n        float-vec (into (vector-of :float) arange)\n        char-vec (into (vector-of :char) (map char arange))\n        double-vec (into (vector-of :double) arange)\n        byte-vec (into (vector-of :byte) (map byte arange))]\n    (is (== 5050\n            (transduce mapinc + arange)\n            (transduce mapinc + avec)\n            (transduce mapinc + alist)\n            (transduce mapinc + obj-array)\n            (transduce mapinc + int-array)\n            (transduce mapinc + long-array)\n            (transduce mapinc + float-array)\n            (transduce mapinclong + char-array)\n            (transduce mapinc + double-array)\n            (transduce mapinclong + byte-array)\n            (transduce mapinc + int-vec)\n            (transduce mapinc + long-vec)\n            (transduce mapinc + float-vec)\n            (transduce mapinclong + char-vec)\n            (transduce mapinc + double-vec)\n            (transduce mapinclong + byte-vec)\n            ))\n    (is (== 5051\n            (transduce mapinc + 1 arange)\n            (transduce mapinc + 1 avec)\n            (transduce mapinc + 1 alist)\n            (transduce mapinc + 1 obj-array)\n            (transduce mapinc + 1 int-array)\n            (transduce mapinc + 1 long-array)\n            (transduce mapinc + 1 float-array)\n            (transduce mapinclong + 1 char-array)\n            (transduce mapinc + 1 double-array)\n            (transduce mapinclong + 1 byte-array)\n            (transduce mapinc + 1 int-vec)\n            (transduce mapinc + 1 long-vec)\n            (transduce mapinc + 1 float-vec)\n            (transduce mapinclong + 1 char-vec)\n            (transduce mapinc + 1 double-vec)\n            (transduce mapinclong + 1 byte-vec)))))\n\n(deftest test-dedupe\n  (are [x y] (= (transduce (dedupe) conj x) y)\n             [] []\n             [1] [1]\n             [1 2 3] [1 2 3]\n             [1 2 3 1 2 2 1 1] [1 2 3 1 2 1]\n             [1 1 1 2] [1 2]\n             [1 1 1 1] [1]\n\n             \"\" []\n             \"a\" [\\a]\n             \"aaaa\" [\\a]\n             \"aabaa\" [\\a \\b \\a]\n             \"abba\" [\\a \\b \\a]\n\n             [nil nil nil] [nil]\n             [1 1.0 1.0M 1N] [1 1.0 1.0M 1N]\n             [0.5 0.5] [0.5]))\n\n(deftest test-cat\n  (are [x y] (= (transduce cat conj x) y)\n             [] []\n             [[1 2]] [1 2]\n             [[1 2] [3 4]] [1 2 3 4]\n             [[] [3 4]] [3 4]\n             [[1 2] []] [1 2]\n             [[] []] []\n             [[1 2] [3 4] [5 6]] [1 2 3 4 5 6]))\n\n(deftest test-partition-all\n  (are [n coll y] (= (transduce (partition-all n) conj coll) y)\n                  2 [1 2 3] '((1 2) (3))\n                  2 [1 2 3 4] '((1 2) (3 4))\n                  2 [] ()\n                  1 [] ()\n                  1 [1 2 3] '((1) (2) (3))\n                  5 [1 2 3] '((1 2 3))))\n\n(deftest test-take\n  (are [n y] (= (transduce (take n) conj [1 2 3 4 5]) y)\n             1 '(1)\n             3 '(1 2 3)\n             5 '(1 2 3 4 5)\n             9 '(1 2 3 4 5)\n             0 ()\n             -1 ()\n             -2 ()))\n\n(deftest test-drop\n  (are [n y] (= (transduce (drop n) conj [1 2 3 4 5]) y)\n             1 '(2 3 4 5)\n             3 '(4 5)\n             5 ()\n             9 ()\n             0 '(1 2 3 4 5)\n             -1 '(1 2 3 4 5)\n             -2 '(1 2 3 4 5)))\n\n(deftest test-take-nth\n  (are [n y] (= (transduce (take-nth n) conj [1 2 3 4 5]) y)\n             1 '(1 2 3 4 5)\n             2 '(1 3 5)\n             3 '(1 4)\n             4 '(1 5)\n             5 '(1)\n             9 '(1)))\n\n(deftest test-take-while\n  (are [coll y] (= (transduce (take-while pos?) conj coll) y)\n                [] ()\n                [1 2 3 4] '(1 2 3 4)\n                [1 2 3 -1] '(1 2 3)\n                [1 -1 2 3] '(1)\n                [-1 1 2 3] ()\n                [-1 -2 -3] ()))\n\n(deftest test-drop-while\n  (are [coll y] (= (transduce (drop-while pos?) conj coll) y)\n                [] ()\n                [1 2 3 4] ()\n                [1 2 3 -1] '(-1)\n                [1 -1 2 3] '(-1 2 3)\n                [-1 1 2 3] '(-1 1 2 3)\n                [-1 -2 -3] '(-1 -2 -3)))\n\n(deftest test-re-reduced\n  (is (= [:a] (transduce (take 1) conj [:a])))\n  (is (= [:a] (transduce (comp (take 1) (take 1)) conj [:a])))\n  (is (= [:a] (transduce (comp (take 1) (take 1) (take 1)) conj [:a])))\n  (is (= [:a] (transduce (comp (take 1) (take 1) (take 1) (take 1)) conj [:a])))\n  (is (= [[:a]] (transduce (comp (partition-by keyword?) (take 1)) conj [] [:a])))\n  (is (= [[:a]] (sequence (comp (partition-by keyword?) (take 1)) [:a])))\n  (is (= [[[:a]]] (sequence (comp (partition-by keyword?) (take 1)  (partition-by keyword?) (take 1)) [:a])))\n  (is (= [[0]] (transduce (comp (take 1) (partition-all 3) (take 1)) conj [] (range 15))))\n  (is (= [1] (transduce (take 1) conj (seq (long-array [1 2 3 4]))))))\n\n(deftest test-sequence-multi-xform\n  (is (= [11 12 13 14] (sequence (map +) [1 2 3 4] (repeat 10))))\n  (is (= [11 12 13 14] (sequence (map +) (repeat 10) [1 2 3 4])))\n  (is (= [31 32 33 34] (sequence (map +) (repeat 10) (repeat 20) [1 2 3 4]))))\n\n(deftest test-eduction\n  (testing \"one xform\"\n    (is (= [1 2 3 4 5]\n           (eduction (map inc) (range 5)))))\n  (testing \"multiple xforms\"\n    (is (= [\"2\" \"4\"]\n           (eduction (map inc) (filter even?) (map str) (range 5)))))\n  (testing \"materialize at the end\"\n    (is (= [1 1 1 1 2 2 2 3 3 4]\n          (->> (range 5)\n            (eduction (mapcat range) (map inc))\n            sort)))\n    (is (= [1 1 2 1 2 3 1 2 3 4]\n          (vec (->> (range 5)\n                 (eduction (mapcat range) (map inc))\n                 to-array))))\n    (is (= {1 4, 2 3, 3 2, 4 1}\n          (->> (range 5)\n            (eduction (mapcat range) (map inc))\n            frequencies)))\n    (is (= [\"drib\" \"god\" \"hsif\" \"kravdraa\" \"tac\"]\n          (->> [\"cat\" \"dog\" \"fish\" \"bird\" \"aardvark\"]\n            (eduction (map clojure.string/reverse))\n            (sort-by first)))))\n  (testing \"expanding transducer with nils\"\n           (is (= '(1 2 3 nil 4 5 6 nil)\n                  (eduction cat [[1 2 3 nil] [4 5 6 nil]])))))\n\n(deftest test-eduction-completion\n  (testing \"eduction completes inner xformed reducing fn\"\n    (is (= [[0 1 2] [3 4 5] [6 7]]\n           (into []\n                 (comp cat (partition-all 3))\n                 (eduction (partition-all 5) (range 8))))))\n  (testing \"outer reducing fn completed only once\"\n    (let [counter (atom 0)\n          ;; outer rfn\n          rf      (completing conj #(do (swap! counter inc)\n                                        (vec %)))\n          coll    (eduction  (map inc) (range 5))\n          res     (transduce (map str) rf [] coll)]\n      (is (= 1 @counter))\n      (is (= [\"1\" \"2\" \"3\" \"4\" \"5\"] res)))))\n\n(deftest test-distinct\n  (are [out in] (= out (sequence (distinct in)) (sequence (distinct) in))\n       [] []\n       (range 10) (range 10)\n       [0] (repeat 10 0)\n       [0 1 2] [0 0 1 1 2 2 1 1 0 0]\n       [1] [1 1N]))\n\n(deftest test-interpose\n  (are [out in] (= out (sequence (interpose :s) in))\n       [] (range 0)\n       [0] (range 1)\n       [0 :s 1] (range 2)\n       [0 :s 1 :s 2] (range 3))\n  (testing \"Can end reduction on separator or input\"\n    (let [expected (interpose :s (range))]\n      (dotimes [i 10]\n        (is (= (take i expected)\n          (sequence (comp (interpose :s) (take i))\n                    (range))))))))\n\n(deftest test-map-indexed\n  (is (= []\n         (sequence (map-indexed vector) [])))\n  (is (= [[0 1] [1 2] [2 3] [3 4]]\n         (sequence (map-indexed vector) (range 1 5)))))"
  },
  {
    "path": "test/clojure/test_clojure/transients.clj",
    "content": "(ns clojure.test-clojure.transients\n  (:use clojure.test))\n\n(deftest popping-off\n  (testing \"across a node boundary\"\n    (are [n] \n      (let [v (-> (range n) vec)]\n        (= (subvec v 0 (- n 2)) (-> v transient pop! pop! persistent!)))\n      33 (+ 32 (inc (* 32 32))) (+ 32 (inc (* 32 32 32)))))\n  (testing \"off the end\"\n    (is (thrown-with-msg? IllegalStateException #\"Can't pop empty vector\"\n          (-> [] transient pop!))))\n  (testing \"copying array from a non-editable when put in tail position\")\n    (is (= 31 (let [pv (vec (range 34))]\n                (-> pv transient pop! pop! pop! (conj! 42))\n                (nth pv 31)))))\n\n(defn- hash-obj [hash]\n  (reify Object (hashCode [this] hash)))\n\n(deftest dissocing\n  (testing \"dissocing colliding keys\"\n    (is (= [0 {}] (let [ks (concat (range 7) [(hash-obj 42) (hash-obj 42)])\n                        m (zipmap ks ks)\n                        dm (persistent! (reduce dissoc! (transient m) (keys m)))]\n                    [(count dm) dm])))))\n\n(deftest test-disj!\n  (testing \"disjoin multiple items in one call\"\n    (is (= #{5 20} (-> #{5 10 15 20} transient (disj! 10 15) persistent!)))))\n\n(deftest empty-transient\n  (is (= false (.contains (transient #{}) :bogus-key))))\n\n(deftest persistent-assoc-on-collision\n  (testing \"Persistent assoc on a collision node which underwent a transient dissoc\"\n    (let [a (reify Object (hashCode [_] 42))\n          b (reify Object (hashCode [_] 42))]\n      (is (= (-> #{a b} transient (disj! a) persistent! (conj a))\n            (-> #{a b} transient (disj! a) persistent! (conj a)))))))\n\n(deftest transient-mod-after-persistent\n  (let [v [1 2 3]\n        t (transient v)\n        t2 (conj! t 4)\n        p (persistent! t2)]\n    (is (= [1 2 3 4] p))\n    (is (thrown? IllegalAccessError (conj! t2 5)))))\n\n(deftest transient-mod-ok-across-threads\n  (let [v [1 2 3]\n        t (transient v)\n        t2 @(future (conj! t 4))\n        p (persistent! t2)]\n    (is (= [1 2 3 4] p))))\n"
  },
  {
    "path": "test/clojure/test_clojure/try_catch.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Paul M Bauer \n\n(ns clojure.test-clojure.try-catch\n  (:use clojure.test)\n  (:import [clojure.test ReflectorTryCatchFixture \n                         ReflectorTryCatchFixture$Cookies]))\n\n(defn- get-exception [expression]\n  (try (eval expression)\n    nil\n    (catch java.lang.Throwable t\n      t)))\n\n(deftest catch-receives-checked-exception-from-eval\n  (are [expression expected-exception] (= expected-exception\n                                          (type (get-exception expression)))\n    \"Eh, I'm pretty safe\" nil\n    '(java.io.FileReader. \"CAFEBABEx0/idonotexist\") java.io.FileNotFoundException))\n\n\n(defn fail [x]\n  (ReflectorTryCatchFixture/fail x))\n\n(defn make-instance []\n  (ReflectorTryCatchFixture.))\n\n(deftest catch-receives-checked-exception-from-reflective-call\n  (is (thrown-with-msg? ReflectorTryCatchFixture$Cookies #\"Long\" (fail 1)))\n  (is (thrown-with-msg? ReflectorTryCatchFixture$Cookies #\"Double\" (fail 1.0)))\n  (is (thrown-with-msg? ReflectorTryCatchFixture$Cookies #\"Wrapped\"\n        (.failWithCause (make-instance) 1.0))))\n"
  },
  {
    "path": "test/clojure/test_clojure/vars.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Frantisek Sodomka, Stephen C. Gilardi\n\n\n(ns clojure.test-clojure.vars\n  (:use clojure.test))\n\n; http://clojure.org/vars\n\n; def\n; defn defn- defonce\n\n; declare intern binding find-var var\n\n(def ^:dynamic a)\n(deftest test-binding\n  (are [x y] (= x y)\n      (eval `(binding [a 4] a)) 4     ; regression in Clojure SVN r1370\n  ))\n\n; var-get var-set alter-var-root [var? (predicates.clj)]\n; with-in-str with-out-str\n; with-open\n\n(deftest test-with-local-vars\n  (let [factorial (fn [x]\n                    (with-local-vars [acc 1, cnt x]\n                      (while (> @cnt 0)\n                        (var-set acc (* @acc @cnt))\n                        (var-set cnt (dec @cnt)))\n                      @acc))]\n    (is (= (factorial 5) 120))))\n\n(deftest test-with-precision\n  (are [x y] (= x y)\n       (with-precision 4 (+ 3.5555555M 1)) 4.556M\n       (with-precision 6 (+ 3.5555555M 1)) 4.55556M\n       (with-precision 6 :rounding CEILING     (+ 3.5555555M 1)) 4.55556M\n       (with-precision 6 :rounding FLOOR       (+ 3.5555555M 1)) 4.55555M\n       (with-precision 6 :rounding HALF_UP     (+ 3.5555555M 1)) 4.55556M\n       (with-precision 6 :rounding HALF_DOWN   (+ 3.5555555M 1)) 4.55556M\n       (with-precision 6 :rounding HALF_EVEN   (+ 3.5555555M 1)) 4.55556M\n       (with-precision 6 :rounding UP          (+ 3.5555555M 1)) 4.55556M\n       (with-precision 6 :rounding DOWN        (+ 3.5555555M 1)) 4.55555M\n       (with-precision 6 :rounding UNNECESSARY (+ 3.5555M 1))    4.5555M))\n\n#_(deftest test-settable-math-context\n   (is (=\n        (clojure.main/with-bindings\n          (set! *math-context* (java.math.MathContext. 8))\n          (+ 3.55555555555555M 1))\n        4.5555556M)))\n\n; set-validator get-validator\n\n; doc find-doc test\n\n(def stub-me :original)\n\n(deftest test-with-redefs-fn\n  (let [p (promise)]\n    (with-redefs-fn {#'stub-me :temp}\n      (fn []\n        (.start (Thread. #(deliver p stub-me)))\n        @p))\n    (is (= :temp @p))\n    (is (= :original stub-me))))\n\n(deftest test-with-redefs\n  (let [p (promise)]\n    (with-redefs [stub-me :temp]\n      (.start (Thread. #(deliver p stub-me)))\n      @p)\n    (is (= :temp @p))\n    (is (= :original stub-me))))\n\n(deftest test-with-redefs-throw\n  (let [p (promise)]\n    (is (thrown? Exception\n      (with-redefs [stub-me :temp]\n        (deliver p stub-me)\n        (throw (Exception. \"simulated failure in with-redefs\")))))\n    (is (= :temp @p))\n    (is (= :original stub-me))))\n\n(def ^:dynamic dynamic-var 1)\n\n(deftest test-with-redefs-inside-binding\n  (binding [dynamic-var 2]\n    (is (= 2 dynamic-var))\n    (with-redefs [dynamic-var 3]\n      (is (= 2 dynamic-var))))\n  (is (= 1 dynamic-var)))"
  },
  {
    "path": "test/clojure/test_clojure/vectors.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n; Author: Stuart Halloway, Daniel Solano Gómez\n\n(ns clojure.test-clojure.vectors\n  (:use clojure.test))\n\n(deftest test-reversed-vec\n  (let [r (range 6)\n        v (into (vector-of :int) r)\n        reversed (.rseq v)]\n    (testing \"returns the right impl\"\n      (is (= clojure.lang.APersistentVector$RSeq (class reversed))))\n    (testing \"RSeq methods\"\n      (is (= [5 4 3 2 1 0] reversed))\n      (is (= 5 (.index reversed)))\n      (is (= 5 (.first reversed)))\n      (is (= [4 3 2 1 0] (.next reversed)))\n      (is (= [3 2 1 0] (.. reversed next next)))\n      (is (= 6 (.count reversed))))\n    (testing \"clojure calling through\"\n      (is (= 5 (first reversed)))\n      (is (= 5 (nth reversed 0))))\n    (testing \"empty reverses to nil\"\n      (is (nil? (.. v empty rseq))))))\n\n(deftest test-vecseq\n  (let [r (range 100)\n        vs (into (vector-of :int) r)\n        vs-1 (next vs)\n        vs-32 (.chunkedNext (seq vs))]\n    (testing \"=\"\n      (are [a b] (= a b)\n           vs vs\n           vs-1 vs-1\n           vs-32 vs-32)\n      (are [a b] (not= a b)\n           vs vs-1\n           vs-1 vs\n           vs vs-32\n           vs-32 vs))\n    (testing \"IPersistentCollection.empty\"\n      (are [a] (identical? clojure.lang.PersistentList/EMPTY (.empty (seq a)))\n           vs vs-1 vs-32))\n    (testing \"IPersistentCollection.cons\"\n      (are [result input] (= result (.cons input :foo))\n           [:foo 1] (seq (into (vector-of :int) [1]))))\n    (testing \"IPersistentCollection.count\"\n      (are [ct s] (= ct (.count (seq s)))\n           100 vs\n           99 vs-1\n           68 vs-32)\n      ;; can't manufacture this scenario: ASeq defers to Counted, but\n      ;; LazySeq doesn't, so Counted never gets checked on reified seq below\n      #_(testing \"hops to counted when available\"\n        (is (= 200\n               (.count (concat\n                        (seq vs)\n                        (reify clojure.lang.ISeq\n                               (seq [this] this)\n                               clojure.lang.Counted\n                               (count [_] 100))))))))\n    (testing \"IPersistentCollection.equiv\"\n      (are [a b] (true? (.equiv a b))\n           vs vs\n           vs-1 vs-1\n           vs-32 vs-32\n           vs r)\n      (are [a b] (false? (.equiv a b))\n           vs vs-1\n           vs-1 vs\n           vs vs-32\n           vs-32 vs\n           vs nil))\n    (testing \"internal-reduce\"\n      (is (= [99] (into [] (drop 99 vs)))))))\n\n(deftest test-primitive-subvector-reduce\n  ;; regression test for CLJ-1082\n  (is (== 60 (let [prim-vec (into (vector-of :long) (range 1000))]\n               (reduce + (subvec prim-vec 10 15))))))\n\n(deftest test-vec-compare\n  (let [nums      (range 1 100)\n        ; randomly replaces a single item with the given value\n        rand-replace  (fn[val]\n                        (let [r (rand-int 99)]\n                          (concat (take r nums) [val] (drop (inc r) nums))))\n        ; all num sequences in map\n        num-seqs      {:standard       nums\n                       :empty          '()\n                       ; different lengths\n                       :longer         (concat nums [100])\n                       :shorter        (drop-last nums)\n                       ; greater by value\n                       :first-greater  (concat [100] (next nums))\n                       :last-greater   (concat (drop-last nums) [100])\n                       :rand-greater-1 (rand-replace 100)\n                       :rand-greater-2 (rand-replace 100)\n                       :rand-greater-3 (rand-replace 100)\n                       ; lesser by value\n                       :first-lesser   (concat [0] (next nums))\n                       :last-lesser    (concat (drop-last nums) [0])\n                       :rand-lesser-1  (rand-replace 0)\n                       :rand-lesser-2  (rand-replace 0)\n                       :rand-lesser-3  (rand-replace 0)}\n        ; a way to create compare values based on num-seqs\n        create-vals   (fn[base-val]\n                        (zipmap (keys num-seqs)\n                                (map #(into base-val %1) (vals num-seqs))))\n        ; Vecs made of int primitives\n        int-vecs      (create-vals (vector-of :int))\n        ; Vecs made of long primitives\n        long-vecs     (create-vals (vector-of :long))\n        ; standard boxing vectors\n        regular-vecs  (create-vals [])\n        ; the standard int Vec for comparisons\n        int-vec       (:standard int-vecs)]\n    (testing \"compare\"\n      (testing \"identical\"\n        (is (= 0 (compare int-vec int-vec))))\n      (testing \"equivalent\"\n        (are [x y] (= 0 (compare x y))\n             ; standard\n             int-vec (:standard long-vecs)\n             (:standard long-vecs) int-vec\n             int-vec (:standard regular-vecs)\n             (:standard regular-vecs) int-vec\n             ; empty\n             (:empty int-vecs) (:empty long-vecs)\n             (:empty long-vecs) (:empty int-vecs)))\n      (testing \"lesser\"\n        (are [x] (= -1 (compare int-vec x))\n             (:longer int-vecs)\n             (:longer long-vecs)\n             (:longer regular-vecs)\n             (:first-greater int-vecs)\n             (:first-greater long-vecs)\n             (:first-greater regular-vecs)\n             (:last-greater int-vecs)\n             (:last-greater long-vecs)\n             (:last-greater regular-vecs)\n             (:rand-greater-1 int-vecs)\n             (:rand-greater-1 long-vecs)\n             (:rand-greater-1 regular-vecs)\n             (:rand-greater-2 int-vecs)\n             (:rand-greater-2 long-vecs)\n             (:rand-greater-2 regular-vecs)\n             (:rand-greater-3 int-vecs)\n             (:rand-greater-3 long-vecs)\n             (:rand-greater-3 regular-vecs))\n        (are [x] (= -1 (compare x int-vec))\n             nil\n             (:empty int-vecs)\n             (:empty long-vecs)\n             (:empty regular-vecs)\n             (:shorter int-vecs)\n             (:shorter long-vecs)\n             (:shorter regular-vecs)\n             (:first-lesser int-vecs)\n             (:first-lesser long-vecs)\n             (:first-lesser regular-vecs)\n             (:last-lesser int-vecs)\n             (:last-lesser long-vecs)\n             (:last-lesser regular-vecs)\n             (:rand-lesser-1 int-vecs)\n             (:rand-lesser-1 long-vecs)\n             (:rand-lesser-1 regular-vecs)\n             (:rand-lesser-2 int-vecs)\n             (:rand-lesser-2 long-vecs)\n             (:rand-lesser-2 regular-vecs)\n             (:rand-lesser-3 int-vecs)\n             (:rand-lesser-3 long-vecs)\n             (:rand-lesser-3 regular-vecs)))\n      (testing \"greater\"\n        (are [x] (= 1 (compare int-vec x))\n             nil\n             (:empty int-vecs)\n             (:empty long-vecs)\n             (:empty regular-vecs)\n             (:shorter int-vecs)\n             (:shorter long-vecs)\n             (:shorter regular-vecs)\n             (:first-lesser int-vecs)\n             (:first-lesser long-vecs)\n             (:first-lesser regular-vecs)\n             (:last-lesser int-vecs)\n             (:last-lesser long-vecs)\n             (:last-lesser regular-vecs)\n             (:rand-lesser-1 int-vecs)\n             (:rand-lesser-1 long-vecs)\n             (:rand-lesser-1 regular-vecs)\n             (:rand-lesser-2 int-vecs)\n             (:rand-lesser-2 long-vecs)\n             (:rand-lesser-2 regular-vecs)\n             (:rand-lesser-3 int-vecs)\n             (:rand-lesser-3 long-vecs)\n             (:rand-lesser-3 regular-vecs))\n        (are [x] (= 1 (compare x int-vec))\n             (:longer int-vecs)\n             (:longer long-vecs)\n             (:longer regular-vecs)\n             (:first-greater int-vecs)\n             (:first-greater long-vecs)\n             (:first-greater regular-vecs)\n             (:last-greater int-vecs)\n             (:last-greater long-vecs)\n             (:last-greater regular-vecs)\n             (:rand-greater-1 int-vecs)\n             (:rand-greater-1 long-vecs)\n             (:rand-greater-1 regular-vecs)\n             (:rand-greater-2 int-vecs)\n             (:rand-greater-2 long-vecs)\n             (:rand-greater-2 regular-vecs)\n             (:rand-greater-3 int-vecs)\n             (:rand-greater-3 long-vecs)\n             (:rand-greater-3 regular-vecs))))\n    (testing \"Comparable.compareTo\"\n      (testing \"incompatible\"\n        (is (thrown? NullPointerException (.compareTo int-vec nil)))\n        (are [x] (thrown? ClassCastException (.compareTo int-vec x))\n             '()\n             {}\n             #{}\n             (sorted-set)\n             (sorted-map)\n             nums\n             1))\n      (testing \"identical\"\n        (is (= 0 (.compareTo int-vec int-vec))))\n      (testing \"equivalent\"\n        (are [x] (= 0 (.compareTo int-vec x))\n             (:standard long-vecs)\n             (:standard regular-vecs)))\n      (testing \"lesser\"\n        (are [x] (= -1 (.compareTo int-vec x))\n             (:longer int-vecs)\n             (:longer long-vecs)\n             (:longer regular-vecs)\n             (:first-greater int-vecs)\n             (:first-greater long-vecs)\n             (:first-greater regular-vecs)\n             (:last-greater int-vecs)\n             (:last-greater long-vecs)\n             (:last-greater regular-vecs)\n             (:rand-greater-1 int-vecs)\n             (:rand-greater-1 long-vecs)\n             (:rand-greater-1 regular-vecs)\n             (:rand-greater-2 int-vecs)\n             (:rand-greater-2 long-vecs)\n             (:rand-greater-2 regular-vecs)\n             (:rand-greater-3 int-vecs)\n             (:rand-greater-3 long-vecs)\n             (:rand-greater-3 regular-vecs)))\n      (testing \"greater\"\n        (are [x] (= 1 (.compareTo int-vec x))\n             (:empty int-vecs)\n             (:empty long-vecs)\n             (:empty regular-vecs)\n             (:shorter int-vecs)\n             (:shorter long-vecs)\n             (:shorter regular-vecs)\n             (:first-lesser int-vecs)\n             (:first-lesser long-vecs)\n             (:first-lesser regular-vecs)\n             (:last-lesser int-vecs)\n             (:last-lesser long-vecs)\n             (:last-lesser regular-vecs)\n             (:rand-lesser-1 int-vecs)\n             (:rand-lesser-1 long-vecs)\n             (:rand-lesser-1 regular-vecs)\n             (:rand-lesser-2 int-vecs)\n             (:rand-lesser-2 long-vecs)\n             (:rand-lesser-2 regular-vecs)\n             (:rand-lesser-3 int-vecs)\n             (:rand-lesser-3 long-vecs)\n             (:rand-lesser-3 regular-vecs))))))\n\n(deftest test-vec-associative\n  (let [empty-v (vector-of :long)\n        v       (into empty-v (range 1 6))]\n    (testing \"Associative.containsKey\"\n      (are [x] (.containsKey v x)\n           0 1 2 3 4)\n      (are [x] (not (.containsKey v x))\n           -1 -100 nil [] \"\" #\"a\" #{} 5 100)\n      (are [x] (not (.containsKey empty-v x))\n           0 1))\n    (testing \"contains?\"\n      (are [x] (contains? v x)\n           0 2 4)\n      (are [x] (not (contains? v x))\n           -1 -100 nil \"\" 5 100)\n      (are [x] (not (contains? empty-v x))\n           0 1))\n    (testing \"Associative.entryAt\"\n      (are [idx val] (= (clojure.lang.MapEntry. idx val)\n                        (.entryAt v idx))\n           0 1\n           2 3\n           4 5)\n      (are [idx] (nil? (.entryAt v idx))\n           -5 -1 5 10 nil \"\")\n      (are [idx] (nil? (.entryAt empty-v idx))\n           0 1))))\n\n(deftest test-vec-creation\n  (testing \"Plain (vector-of :type)\"\n    (are [x] (and (empty? x) (instance? clojure.core.Vec x))\n         (vector-of :boolean)\n         (vector-of :byte)\n         (vector-of :short)\n         (vector-of :int)\n         (vector-of :long)\n         (vector-of :float)\n         (vector-of :double)\n         (vector-of :char))\n    (testing \"with invalid type argument\"\n      (are [x] (thrown? NullPointerException x)\n           (vector-of nil)\n           (vector-of Float/TYPE)\n           (vector-of 'int)\n           (vector-of \"\"))))\n  (testing \"vector-like (vector-of :type x1 x2 x3 … xn)\"\n    (are [vec gvec] (and (instance? clojure.core.Vec gvec)\n                         (= (into (vector-of :int) vec) gvec)\n                         (= vec gvec)\n                         (= (hash vec) (hash gvec)))\n         [1] (vector-of :int 1)\n         [1 2] (vector-of :int 1 2)\n         [1 2 3] (vector-of :int 1 2 3)\n         [1 2 3 4] (vector-of :int 1 2 3 4)\n         [1 2 3 4 5] (vector-of :int 1 2 3 4 5)\n         [1 2 3 4 5 6] (vector-of :int 1 2 3 4 5 6)\n         (apply vector (range 1000)) (apply vector-of :int (range 1000))\n         [1 2 3] (vector-of :int 1M 2.0 3.1)\n         [97 98 99] (vector-of :int \\a \\b \\c))\n    (testing \"with null values\"\n      (are [x] (thrown? NullPointerException x)\n        (vector-of :int nil)\n        (vector-of :int 1 nil)\n        (vector-of :int 1 2 nil)\n        (vector-of :int 1 2 3 nil)\n        (vector-of :int 1 2 3 4 nil)\n        (vector-of :int 1 2 3 4 5 nil)\n        (vector-of :int 1 2 3 4 5 6 nil)))\n    (testing \"with unsupported values\"\n      (are [x] (thrown? ClassCastException x)\n           (vector-of :int true)\n           (vector-of :int 1 2 3 4 5 false)\n           (vector-of :int {:a 1 :b 2})\n           (vector-of :int [1 2 3 4] [5 6])\n           (vector-of :int '(1 2 3 4))\n           (vector-of :int #{1 2 3 4})\n           (vector-of :int (sorted-set 1 2 3 4))\n           (vector-of :int 1 2 \"3\")\n           (vector-of :int \"1\" \"2\" \"3\")))))\n\n(deftest empty-vector-equality\n  (let [colls [[] (vector-of :long) '()]]\n    (doseq [c1 colls, c2 colls]\n      (is (= c1 c2))\n      (is (.equals c1 c2)))))\n\n(defn =vec\n  [expected v] (and (vector? v) (= expected v)))\n\n(deftest test-mapv\n  (are [r c1] (=vec r (mapv + c1))\n       [1 2 3] [1 2 3])\n  (are [r c1 c2] (=vec r (mapv + c1 c2))\n       [2 3 4] [1 2 3] (repeat 1))\n  (are [r c1 c2 c3] (=vec r (mapv + c1 c2 c3))\n       [3 4 5] [1 2 3] (repeat 1) (repeat 1))\n  (are [r c1 c2 c3 c4] (=vec r (mapv + c1 c2 c3 c4))\n       [4 5 6] [1 2 3] [1 1 1] [1 1 1] [1 1 1]))\n\n(deftest test-filterv\n  (are [r c1] (=vec r (filterv even? c1))\n       [] [1 3 5]\n       [2 4] [1 2 3 4 5]))\n\n(deftest test-subvec\n  (let [v1 (vec (range 100))\n        v2 (subvec v1 50 57)]\n    (is (thrown? IndexOutOfBoundsException (v2 -1)))\n    (is (thrown? IndexOutOfBoundsException (v2 7)))\n    (is (= (v1 50) (v2 0)))\n    (is (= (v1 56) (v2 6)))))\n\n(deftest test-vec\n  (is (= [1 2] (vec (first {1 2}))))\n  (is (= [0 1 2 3] (vec [0 1 2 3])))\n  (is (= [0 1 2 3] (vec (list 0 1 2 3))))\n  (is (= [0 1 2 3] (vec (sorted-set 0 1 2 3))))\n  (is (= [[1 2] [3 4]] (vec (sorted-map 1 2 3 4))))\n  (is (= [0 1 2 3] (vec (range 4))))\n  (is (= [\\a \\b \\c \\d] (vec \"abcd\")))\n  (is (= [0 1 2 3] (vec (object-array (range 4)))))\n  (is (= [1 2 3 4] (vec (eduction (map inc) (range 4)))))\n  (is (= [0 1 2 3] (vec (reify clojure.lang.IReduceInit\n                          (reduce [_ f start]\n                            (reduce f start (range 4))))))))\n"
  },
  {
    "path": "test/clojure/test_clojure/volatiles.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n\n;;Author: Alex Miller\n\n(ns clojure.test-clojure.volatiles\n  (:use clojure.test))\n\n(deftest volatile-basics\n  (let [vol (volatile! \"abc\")]\n    (is (volatile? vol))\n    (is (= \"abc\" @vol))\n    (is (= \"def\" (vreset! vol \"def\")))\n    (is (= \"def\" @vol))))\n\n(deftest volatile-vswap!\n  (let [vol (volatile! 10)]\n    (is (= 11 (vswap! vol inc)))\n    (is (= 11 @vol)))\n  (let [vol (volatile! 10)]\n    (is (= 20 (vswap! vol + 10)))\n    (is (= 20 @vol)))\n  (let [vol (volatile! 10)]\n    (is (= 25 (vswap! vol + 10 5)))\n    (is (= 25 @vol))))\n\n"
  },
  {
    "path": "test/clojure/test_helper.clj",
    "content": ";   Copyright (c) Rich Hickey. All rights reserved.\n;   The use and distribution terms for this software are covered by the\n;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;   which can be found in the file epl-v10.html at the root of this distribution.\n;   By using this software in any fashion, you are agreeing to be bound by\n;   the terms of this license.\n;   You must not remove this notice, or any other, from this software.\n;\n\n;;  clojure.test-helper\n;;\n;;  Utility functions shared by various tests in the Clojure\n;;  test suite\n;;\n;;  tomfaulhaber (gmail)\n;;  Created 04 November 2010\n\n(ns clojure.test-helper\n  (:use clojure.test))\n\n(let [nl (System/getProperty \"line.separator\")] \n  (defn platform-newlines [s] (.replace s \"\\n\" nl)))\n\n(defn temp-ns\n  \"Create and return a temporary ns, using clojure.core + uses\"\n  [& uses]\n  (binding [*ns* *ns*]\n    (in-ns (gensym))\n    (apply clojure.core/use 'clojure.core uses)\n    *ns*))\n\n(defmacro eval-in-temp-ns [& forms]\n  `(binding [*ns* *ns*]\n     (in-ns (gensym))\n     (clojure.core/use 'clojure.core)\n     (eval\n      '(do ~@forms))))\n\n(defn causes\n  [^Throwable throwable]\n  (loop [causes []\n         t throwable]\n    (if t (recur (conj causes t) (.getCause t)) causes)))\n\n;; this is how I wish clojure.test/thrown? worked...\n;; Does body throw expected exception, anywhere in the .getCause chain?\n(defmethod assert-expr 'fails-with-cause?\n  [msg [_ exception-class msg-re & body :as form]]\n  `(try\n   ~@body\n   (report {:type :fail, :message ~msg, :expected '~form, :actual nil})\n   (catch Throwable t#\n     (if (some (fn [cause#]\n                 (and\n                  (= ~exception-class (class cause#))\n                  (re-find ~msg-re (.getMessage cause#))))\n               (causes t#))\n       (report {:type :pass, :message ~msg,\n                :expected '~form, :actual t#})\n       (report {:type :fail, :message ~msg,\n                :expected '~form, :actual t#})))))\n\n\n(defn get-field\n  \"Access to private or protected field.  field-name is a symbol or\n  keyword.\"\n  ([klass field-name]\n     (get-field klass field-name nil))\n  ([klass field-name inst]\n     (-> klass (.getDeclaredField (name field-name))\n         (doto (.setAccessible true))\n         (.get inst))))\n\n(defn set-var-roots\n  [maplike]\n  (doseq [[var val] maplike]\n    (alter-var-root var (fn [_] val))))\n\n(defn with-var-roots*\n  \"Temporarily set var roots, run block, then put original roots back.\"\n  [root-map f & args]\n  (let [originals (doall (map (fn [[var _]] [var @var]) root-map))]\n    (set-var-roots root-map)\n    (try\n     (apply f args)\n     (finally\n      (set-var-roots originals)))))\n\n(defmacro with-var-roots\n  [root-map & body]\n  `(with-var-roots* ~root-map (fn [] ~@body)))\n\n(defn exception\n  \"Use this function to ensure that execution of a program doesn't\n  reach certain point.\"\n  []\n  (throw (new Exception \"Exception which should never occur\")))\n\n(defmacro with-err-print-writer\n  \"Evaluate with err pointing to a temporary PrintWriter, and\n   return err contents as a string.\"\n  [& body]\n  `(let [s# (java.io.StringWriter.)\n         p# (java.io.PrintWriter. s#)]\n     (binding [*err* p#]\n       ~@body\n       (str s#))))\n\n(defmacro with-err-string-writer\n  \"Evaluate with err pointing to a temporary StringWriter, and\n   return err contents as a string.\"\n  [& body]\n  `(let [s# (java.io.StringWriter.)]\n     (binding [*err* s#]\n       ~@body\n       (str s#))))\n\n(defmacro should-print-err-message\n  \"Turn on all warning flags, and test that error message prints\n   correctly for all semi-reasonable bindings of *err*.\"\n  [msg-re form]\n  `(binding [*warn-on-reflection* true]\n    (is (re-matches ~msg-re (with-err-string-writer (eval-in-temp-ns ~form))))\n    (is (re-matches ~msg-re (with-err-print-writer (eval-in-temp-ns ~form))))))\n\n(defmacro should-not-reflect\n  \"Turn on all warning flags, and test that reflection does not occur\n   (as identified by messages to *err*).\"\n  [form]\n  `(binding [*warn-on-reflection* true]\n     (is (nil? (re-find #\"^Reflection warning\" (with-err-string-writer (eval-in-temp-ns ~form)))))\n     (is (nil? (re-find #\"^Reflection warning\" (with-err-print-writer (eval-in-temp-ns ~form)))))))\n"
  },
  {
    "path": "test/java/clojure/test/ReflectorTryCatchFixture.java",
    "content": "package clojure.test;\n\npublic class ReflectorTryCatchFixture {\n\n\tpublic static void fail(Long x) throws Cookies {\n\t\tthrow new Cookies(\"Long\");\n\t}\n\t\n\tpublic static void fail(Double y) throws Cookies {\n\t\tthrow new Cookies(\"Double\");\n\t}\n\t\n        public void failWithCause(Double y) throws Cookies {\n                throw new Cookies(\"Wrapped\", new Cookies(\"Cause\"));\n\t}\n\t\n\tpublic static class Cookies extends Exception {\n                public Cookies(String msg, Throwable cause) { super(msg, cause); }\n\t\tpublic Cookies(String msg) { super(msg); }\n\t}\n\n}\n"
  },
  {
    "path": "test/java/compilation/TestDispatch.java",
    "content": "package compilation;\n\npublic class TestDispatch {\n    public static String someMethod (int a, int b) {\n        return \"(int, int)\";\n    }\n    \n    public static String someMethod (int a, long b) {\n        return \"(int, long)\";\n    }\n    \n    public static String someMethod (long a, long b) {\n        return \"(long, long)\";\n    }\n}"
  },
  {
    "path": "test/java/java/util/jar/JarEntry.java",
    "content": "package java.util.jar;\n\npublic class JarEntry {\n\n}\n"
  },
  {
    "path": "test/java/java/util/jar/JarFile.java",
    "content": "// Empty stub to run tests\npackage java.util.jar;\n\nimport java.io.File;\nimport java.io.InputStream;\nimport java.util.Enumeration;\nimport java.util.zip.ZipEntry;\n\n\npublic class JarFile {\n\n  public JarFile(File file) {\n    throw new RuntimeException();\n  }\n\n  public Enumeration entries() {\n    throw new RuntimeException();\n  }\n\n  public InputStream getInputStream(ZipEntry zipEntry) {\n    throw new RuntimeException();\n  }\n\n  public ZipEntry getEntry(String string) {\n    throw new RuntimeException();\n  }\n}"
  },
  {
    "path": "test/objc/NSCommonTest.h",
    "content": "//\n//  NSCommonTest.h\n//  mpos\n//\n//  Created by Gal Dolber on 4/10/14.\n//  Copyright (c) 2014 zuldi. All rights reserved.\n//\n\n#import <Foundation/Foundation.h>\n\n@interface NSCommonTest : NSObject\n\n+ (void) runtests;\n\n@end\n"
  },
  {
    "path": "test/objc/NSCommonTest.m",
    "content": "//\n//  NSCommonTest.m\n//  mpos\n//\n//  Created by Gal Dolber on 4/10/14.\n//  Copyright (c) 2014 zuldi. All rights reserved.\n//\n\n#import \"NSCommonTest.h\"\n#import \"NSCommon.h\"\n#import \"clojure/lang/RT.h\"\n\n@implementation NSCommonTest\n\n+(void) voidm {\n}\n\n+(float) floatm: (float)f {\n    return f;\n}\n\n+(long long) longlongm:(long long) l {\n    return l;\n}\n\n+(long) longm:(long) l {\n    return l;\n}\n\n+(char) charm:(char) c {\n    return c;\n}\n\n+(short) shortm:(short)d {\n    return d;\n}\n\n+(int) intm:(int)i {\n    return i;\n}\n\n+(double) doublem:(double)d {\n    return d;\n}\n\n+(long double) longdoublem:(long double)d {\n    return d;\n}\n\n+(unsigned long long) ulonglongm:(unsigned long long)l {\n    return l;\n}\n\n+(unsigned long) ulongm:(unsigned long)l {\n    return l;\n}\n\n+(unsigned char) ucharm:(unsigned char)l {\n    return l;\n}\n\n+(unsigned short) ushortm:(unsigned short)l {\n    return l;\n}\n\n+(unsigned int) uintm:(unsigned int)l {\n    return l;\n}\n\n+(BOOL) boolm:(BOOL)e {\n    return e;\n}\n\n+(CGPoint) cgpointm:(CGPoint)c {\n    return c;\n}\n\n+(NSRange) nsrangem:(NSRange)e {\n    return e;\n}\n\n+(UIEdgeInsets) uiedgem:(UIEdgeInsets)e {\n    return e;\n}\n\n+(CGSize) cgsizem:(CGSize)e {\n    return e;\n}\n\n+(CGAffineTransform) cgam:(CGAffineTransform)e {\n    return e;\n}\n\n+(CATransform3D) cam:(CATransform3D)e {\n    return e;\n}\n\n+(UIOffset) uioffsetm:(UIOffset)e {\n    return e;\n}\n\n+(CGRect) cgrectm:(CGRect)e {\n    return e;\n}\n\n+(id) idm:(id)e {\n    return e;\n}\n\n+(void*) pointerm:(void*)b {\n    return b;\n}\n\n#define check(sel, vv) \\\n{\\\nid v = vv; \\\nid r =[NSCommon invokeSel:[NSCommonTest class] withSelector:sel withArgs:[ClojureLangRT listWithId:v]];\\\nif (![r isEqual:v]) {\\\nNSLog(@\"%@ FAILED. EXPECTED %@ GOT %@\", sel, v, r);\\\n} \\\n}\\\n\n+ (void) runtests {\n    CFTimeInterval tt = CACurrentMediaTime();\n    //for (int n = 0; n < 10000; n++) {\n        check(@\"floatm:\", [ClojureLangRT boxWithFloat:12.2]);\n        check(@\"longm:\", [ClojureLangRT boxWithLong:1223]);\n        check(@\"charm:\", [ClojureLangRT boxWithChar:'s']);\n        check(@\"shortm:\", [ClojureLangRT boxWithShort:23]);\n        check(@\"intm:\", [ClojureLangRT boxWithInt:12]);\n        check(@\"doublem:\", [ClojureLangRT boxWithDouble:23.4]);\n        check(@\"longdoublem:\", [ClojureLangRT boxWithDouble:23.4]);\n        check(@\"ulonglongm:\", [ClojureLangRT boxWithLong:234]);\n        check(@\"ulongm:\", [ClojureLangRT boxWithLong:234]);\n        check(@\"ucharm:\", [ClojureLangRT boxWithChar:'2']);\n        check(@\"ushortm:\", [ClojureLangRT boxWithShort:23]);\n        check(@\"uintm:\", [ClojureLangRT boxWithInt:23]);\n        check(@\"boolm:\", [ClojureLangRT boxWithBoolean:YES]);\n        check(@\"cgpointm:\", [NSValue valueWithCGPoint:CGPointMake(13, 13)]);\n        check(@\"nsrangem:\", [NSValue valueWithRange:NSRangeFromString(@\"{1,23}\")]);\n        check(@\"uiedgem:\", [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(13, 23, 44, 12)]);\n        check(@\"cgsizem:\", [NSValue valueWithCGSize:CGSizeMake(13, 54)]);\n        check(@\"cgam:\", [NSValue valueWithCGAffineTransform:CGAffineTransformMakeRotation(23)]);\n        check(@\"cam:\", [NSValue valueWithCATransform3D:CATransform3DIdentity]);\n        check(@\"uioffsetm:\", [NSValue valueWithUIOffset:UIOffsetMake(24, 55)]);\n        check(@\"cgrectm:\", [NSValue valueWithCGRect:CGRectMake(24, 55, 33, 56)]);\n        check(@\"idm:\", @23);\n        id c = @23;\n        check(@\"pointerm:\", [NSValue valueWithPointer:&c]);\n    //}\n    NSLog(@\"%f\", CACurrentMediaTime() - tt);\n}\n\n@end\n"
  }
]