Skip to content

Commit 4036c77

Browse files
committed
added compiler-options map, moved elide-meta to use that, added disable-locals-clearing
1 parent 0131c58 commit 4036c77

File tree

4 files changed

+41
-14
lines changed

4 files changed

+41
-14
lines changed

build.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
failonerror="true"
4848
fork="true">
4949
<sysproperty key="clojure.compile.path" value="${build}"/>
50-
<!--<sysproperty key="clojure.elide.meta" value="[:doc :file :line :added :static :private :arglists]"/>-->
50+
<!--<sysproperty key="clojure.compiler.elide-meta" value="[:doc :file :line :added]"/>-->
51+
<!--<sysproperty key="clojure.compiler.disable-locals-clearing" value="true"/>-->
5152
<!-- <sysproperty key="clojure.compile.warn-on-reflection" value="true"/> -->
5253
<arg value="clojure.core"/>
5354
<arg value="clojure.core.protocols"/>
@@ -86,7 +87,8 @@
8687
failonerror="true"
8788
fork="true">
8889
<sysproperty key="clojure.compile.path" value="${test-classes}"/>
89-
<!--<sysproperty key="clojure.elide.meta" value="[:doc]"/>-->
90+
<!--<sysproperty key="clojure.compiler.elide-meta" value="[:doc]"/>-->
91+
<!--<sysproperty key="clojure.compiler.disable-locals-clearing" value="true"/>-->
9092
<arg value="clojure.test-clojure.protocols.examples"/>
9193
<arg value="clojure.test-clojure.genclass.examples"/>
9294
</java>

src/clj/clojure/core.clj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5707,8 +5707,12 @@
57075707
coercions will be done without overflow checks. Default: false."
57085708
{:added "1.3"})
57095709

5710-
(add-doc-and-meta *elide-meta*
5711-
"Bind to a collection of metadata keys to elide during compilation.
5710+
(add-doc-and-meta *compiler-options*
5711+
"A map of keys to options.
5712+
Note, when binding dynamically make sure to merge with previous value.
5713+
Supported options:
5714+
:elide-meta - a collection of metadata keys to elide during compilation.
5715+
:disable-locals-clearing - set to true to disable clearing, useful for using a debugger
57125716
Alpha, subject to change."
57135717
{:added "1.4"})
57145718

src/jvm/clojure/lang/Compile.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import java.io.OutputStreamWriter;
1515
import java.io.PrintWriter;
1616
import java.io.IOException;
17+
import java.util.ArrayList;
18+
import java.util.Enumeration;
19+
import java.util.Map;
1720

1821
// Compiles libs and generates class files stored within the directory
1922
// named by the Java System property "clojure.compile.path". Arguments are
@@ -25,13 +28,12 @@ public class Compile{
2528
private static final String PATH_PROP = "clojure.compile.path";
2629
private static final String REFLECTION_WARNING_PROP = "clojure.compile.warn-on-reflection";
2730
private static final String UNCHECKED_MATH_PROP = "clojure.compile.unchecked-math";
28-
private static final String ELIDE_META_PROP = "clojure.elide.meta";
2931

3032
private static final Var compile_path = RT.var("clojure.core", "*compile-path*");
3133
private static final Var compile = RT.var("clojure.core", "compile");
3234
private static final Var warn_on_reflection = RT.var("clojure.core", "*warn-on-reflection*");
3335
private static final Var unchecked_math = RT.var("clojure.core", "*unchecked-math*");
34-
private static final Var elide_meta = RT.var("clojure.core", "*elide-meta*");
36+
private static final Var compiler_options = RT.var("clojure.core", "*compiler-options*");
3537

3638
public static void main(String[] args) throws IOException{
3739

@@ -50,14 +52,27 @@ public static void main(String[] args) throws IOException{
5052

5153
boolean warnOnReflection = System.getProperty(REFLECTION_WARNING_PROP, "false").equals("true");
5254
boolean uncheckedMath = System.getProperty(UNCHECKED_MATH_PROP, "false").equals("true");
53-
Object elide = RT.readString(System.getProperty(ELIDE_META_PROP, "nil"));
55+
56+
Object compilerOptions = null;
57+
58+
for(Map.Entry e : System.getProperties().entrySet())
59+
{
60+
String name = (String) e.getKey();
61+
String v = (String) e.getValue();
62+
if(name.startsWith("clojure.compiler."))
63+
{
64+
compilerOptions = RT.assoc(compilerOptions
65+
,RT.keyword(null,name.substring(1 + name.lastIndexOf('.')))
66+
,RT.readString(v));
67+
}
68+
}
5469

5570
try
5671
{
5772
Var.pushThreadBindings(RT.map(compile_path, path,
5873
warn_on_reflection, warnOnReflection,
5974
unchecked_math, uncheckedMath,
60-
elide_meta, elide));
75+
compiler_options, compilerOptions));
6176

6277
for(String lib : args)
6378
{

src/jvm/clojure/lang/Compiler.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,23 @@ public class Compiler implements Opcodes{
239239
static final public Var ADD_ANNOTATIONS = Var.intern(Namespace.findOrCreate(Symbol.intern("clojure.core")),
240240
Symbol.intern("add-annotations"));
241241

242-
//collection of keys
243-
static final public Var ELIDE_META = Var.intern(Namespace.findOrCreate(Symbol.intern("clojure.core")),
244-
Symbol.intern("*elide-meta*"), null).setDynamic();
242+
static final public Keyword disableLocalsClearingKey = Keyword.intern("disable-locals-clearing");
243+
static final public Keyword elideMetaKey = Keyword.intern("elide-meta");
244+
245+
static final public Var COMPILER_OPTIONS = Var.intern(Namespace.findOrCreate(Symbol.intern("clojure.core")),
246+
Symbol.intern("*compiler-options*"), null).setDynamic();
247+
248+
static public Object getCompilerOption(Keyword k){
249+
return RT.get(COMPILER_OPTIONS.deref(),k);
250+
}
245251

246252
static Object elideMeta(Object m){
247-
Collection<Object> elides = (Collection<Object>) ELIDE_META.get();
253+
Collection<Object> elides = (Collection<Object>) getCompilerOption(elideMetaKey);
248254
if(elides != null)
249255
{
250256
for(Object k : elides)
251257
{
252-
//System.out.println("Eliding:" + k + " : " + RT.get(m, k));
258+
// System.out.println("Eliding:" + k + " : " + RT.get(m, k));
253259
m = RT.dissoc(m, k);
254260
}
255261
// System.out.println("Remaining: " + RT.keys(m));
@@ -5450,7 +5456,7 @@ public static class LocalBinding{
54505456
public final String name;
54515457
public final boolean isArg;
54525458
public final PathNode clearPathRoot;
5453-
public boolean canBeCleared = true;
5459+
public boolean canBeCleared = !RT.booleanCast(getCompilerOption(disableLocalsClearingKey));
54545460
public boolean recurMistmatch = false;
54555461

54565462
public LocalBinding(int num, Symbol sym, Symbol tag, Expr init, boolean isArg,PathNode clearPathRoot)

0 commit comments

Comments
 (0)