Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added compiler-options map, moved elide-meta to use that, added disab…

…le-locals-clearing
  • Loading branch information...
commit 4036c7720949cb21ccf53c5c7c54ed1daaff2fda 1 parent 0131c58
Rich Hickey authored March 13, 2012
6  build.xml
@@ -47,7 +47,8 @@
47 47
           failonerror="true"
48 48
           fork="true">
49 49
       <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"/>-->
51 52
       <!-- <sysproperty key="clojure.compile.warn-on-reflection" value="true"/> -->
52 53
       <arg value="clojure.core"/>
53 54
       <arg value="clojure.core.protocols"/>
@@ -86,7 +87,8 @@
86 87
           failonerror="true"
87 88
 	  fork="true">
88 89
       <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"/>-->
90 92
       <arg value="clojure.test-clojure.protocols.examples"/>
91 93
       <arg value="clojure.test-clojure.genclass.examples"/>
92 94
     </java>
8  src/clj/clojure/core.clj
@@ -5707,8 +5707,12 @@
5707 5707
   coercions will be done without overflow checks. Default: false."
5708 5708
   {:added "1.3"})
5709 5709
 
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
5712 5716
   Alpha, subject to change."
5713 5717
   {:added "1.4"})
5714 5718
 
23  src/jvm/clojure/lang/Compile.java
@@ -14,6 +14,9 @@
14 14
 import java.io.OutputStreamWriter;
15 15
 import java.io.PrintWriter;
16 16
 import java.io.IOException;
  17
+import java.util.ArrayList;
  18
+import java.util.Enumeration;
  19
+import java.util.Map;
17 20
 
18 21
 // Compiles libs and generates class files stored within the directory
19 22
 // named by the Java System property "clojure.compile.path". Arguments are
@@ -25,13 +28,12 @@
25 28
 private static final String PATH_PROP = "clojure.compile.path";
26 29
 private static final String REFLECTION_WARNING_PROP = "clojure.compile.warn-on-reflection";
27 30
 private static final String UNCHECKED_MATH_PROP = "clojure.compile.unchecked-math";
28  
-private static final String ELIDE_META_PROP = "clojure.elide.meta";
29 31
 
30 32
 private static final Var compile_path = RT.var("clojure.core", "*compile-path*");
31 33
 private static final Var compile = RT.var("clojure.core", "compile");
32 34
 private static final Var warn_on_reflection = RT.var("clojure.core", "*warn-on-reflection*");
33 35
 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*");
35 37
 
36 38
 public static void main(String[] args) throws IOException{
37 39
 
@@ -50,14 +52,27 @@ public static void main(String[] args) throws IOException{
50 52
 
51 53
     boolean warnOnReflection = System.getProperty(REFLECTION_WARNING_PROP, "false").equals("true");
52 54
     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
+		}
54 69
 
55 70
 	try
56 71
 		{
57 72
                Var.pushThreadBindings(RT.map(compile_path, path,
58 73
                        warn_on_reflection, warnOnReflection,
59 74
                        unchecked_math, uncheckedMath,
60  
-                       elide_meta, elide));
  75
+                       compiler_options, compilerOptions));
61 76
 
62 77
 		for(String lib : args)
63 78
         {
18  src/jvm/clojure/lang/Compiler.java
@@ -239,17 +239,23 @@
239 239
 static final public Var ADD_ANNOTATIONS = Var.intern(Namespace.findOrCreate(Symbol.intern("clojure.core")),
240 240
                                             Symbol.intern("add-annotations"));
241 241
 
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
+}
245 251
 
246 252
 static Object elideMeta(Object m){
247  
-        Collection<Object> elides = (Collection<Object>) ELIDE_META.get();
  253
+        Collection<Object> elides = (Collection<Object>) getCompilerOption(elideMetaKey);
248 254
         if(elides != null)
249 255
             {
250 256
             for(Object k : elides)
251 257
                 {
252  
-                //System.out.println("Eliding:" + k + " : " + RT.get(m, k));
  258
+//                System.out.println("Eliding:" + k + " : " + RT.get(m, k));
253 259
                 m = RT.dissoc(m, k);
254 260
                 }
255 261
 //            System.out.println("Remaining: " + RT.keys(m));
@@ -5450,7 +5456,7 @@ void emitClearLocalsOld(GeneratorAdapter gen){
5450 5456
 	public final String name;
5451 5457
 	public final boolean isArg;
5452 5458
     public final PathNode clearPathRoot;
5453  
-	public boolean canBeCleared = true;
  5459
+	public boolean canBeCleared = !RT.booleanCast(getCompilerOption(disableLocalsClearingKey));
5454 5460
 	public boolean recurMistmatch = false;
5455 5461
 
5456 5462
     public LocalBinding(int num, Symbol sym, Symbol tag, Expr init, boolean isArg,PathNode clearPathRoot)

0 notes on commit 4036c77

Please sign in to comment.
Something went wrong with that request. Please try again.