Skip to content

Commit 37e39bf

Browse files
committed
Updated to Java commit 4036c77 (2012.03.13): added compiler-options map, moved elide-meta to use that, added disable-locals-clearing
1 parent 45e550a commit 37e39bf

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

Clojure/Clojure.Compile/Compile.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ static class Compile
2929
const string PATH_PROP = "CLOJURE_COMPILE_PATH";
3030
const string REFLECTION_WARNING_PROP = "CLOJURE_COMPILE_WARN_ON_REFLECTION";
3131
const string UNCHECKED_MATH_PROP = "CLOJURE_COMPILE_UNCHECKED_MATH";
32-
const string ELIDE_META_PROP = "CLOJURE_ELIDE_META";
3332

3433
static void Main(string[] args)
3534
{
@@ -54,15 +53,27 @@ static void Main(string[] args)
5453
bool warnOnReflection = warnVal == null ? false : warnVal.Equals("true");
5554
string mathVal = Environment.GetEnvironmentVariable(UNCHECKED_MATH_PROP);
5655
bool uncheckedMath = mathVal == null ? false : mathVal.Equals("true");
57-
object elide = RT.readString(Environment.GetEnvironmentVariable(ELIDE_META_PROP) ?? "nil");
56+
57+
object compilerOptions = null;
58+
foreach (DictionaryEntry kv in Environment.GetEnvironmentVariables())
59+
{
60+
String name = (String)kv.Key;
61+
String v = (String)kv.Value;
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+
}
5869

5970
try
6071
{
6172
Var.pushThreadBindings(RT.map(
6273
Compiler.CompilePathVar, path,
6374
RT.WarnOnReflectionVar, warnOnReflection,
6475
RT.UncheckedMathVar, uncheckedMath,
65-
Compiler.ElideMetaVar,elide
76+
Compiler.CompilerOptionsVar, compilerOptions
6677
));
6778

6879
Stopwatch sw = new Stopwatch();

Clojure/Clojure.Source/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

Clojure/Clojure/CljCompiler/Compiler.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ public static class Compiler
8888
//static readonly Keyword OnKeyword = Keyword.intern(null, "on");
8989
internal static readonly Keyword DynamicKeyword = Keyword.intern("dynamic");
9090

91+
internal static readonly Keyword DisableLocalsClearingKeyword = Keyword.intern("disable-locals-clearing");
92+
internal static readonly Keyword ElideMetaKeyword = Keyword.intern("elide-meta");
93+
9194

9295
#endregion
9396

@@ -151,14 +154,17 @@ public static class Compiler
151154
internal static readonly Var CompilerContextVar = Var.create(null).setDynamic();
152155
internal static readonly Var CompilerActiveVar = Var.create(false).setDynamic();
153156

157+
public static readonly Var CompilerOptionsVar = Var.intern(Namespace.findOrCreate(Symbol.intern("clojure.core")),
158+
Symbol.intern("*compiler-options*"), null).setDynamic();
154159

155-
// collection of keys
156-
public static readonly Var ElideMetaVar = Var.intern(Namespace.findOrCreate(Symbol.intern("clojure.core")),
157-
Symbol.intern("*elide-meta*"), null).setDynamic();
160+
public static object GetCompilerOption(Keyword k)
161+
{
162+
return RT.get(CompilerOptionsVar.deref(), k);
163+
}
158164

159165
public static object ElideMeta(object m)
160166
{
161-
ICollection<Object> elides = (ICollection<Object>)ElideMetaVar.get();
167+
ICollection<Object> elides = (ICollection<Object>)GetCompilerOption(ElideMetaKeyword);
162168
if (elides != null)
163169
{
164170
foreach (object k in elides)

0 commit comments

Comments
 (0)