summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortpratley <timothypratley@gmail.com>2009-08-01 23:06:27 +1000
committerChouser <chouser@n01se.net>2009-09-28 21:12:37 -0400
commit86d8a952daee73bf7b7b0c5a41c7ad3faf27c038 (patch)
tree010b63f44466899949903f4b0e22b110acafd98b
parenta2d986693592e321e7978f914c3ba4f563da6af3 (diff)
embedded constants, refs #164
Primitive Class objects are now handled explicitly eg: (eval `(make-array ~Byte/TYPE 2)) Signed-off-by: Chouser <chouser@n01se.net>
-rw-r--r--src/jvm/clojure/lang/Compiler.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java
index 604b42e5..e9ba4335 100644
--- a/src/jvm/clojure/lang/Compiler.java
+++ b/src/jvm/clojure/lang/Compiler.java
@@ -3287,8 +3287,27 @@ static public class FnExpr implements Expr{
}
else if(value instanceof Class)
{
- gen.push(((Class) value).getName());
- gen.invokeStatic(Type.getType(Class.class), Method.getMethod("Class forName(String)"));
+ Class cc = (Class)value;
+ if(cc.isPrimitive())
+ {
+ Type bt;
+ if ( cc == boolean.class ) bt = Type.getType(Boolean.class);
+ else if ( cc == byte.class ) bt = Type.getType(Byte.class);
+ else if ( cc == char.class ) bt = Type.getType(Character.class);
+ else if ( cc == double.class ) bt = Type.getType(Double.class);
+ else if ( cc == float.class ) bt = Type.getType(Float.class);
+ else if ( cc == int.class ) bt = Type.getType(Integer.class);
+ else if ( cc == long.class ) bt = Type.getType(Long.class);
+ else if ( cc == short.class ) bt = Type.getType(Short.class);
+ else throw new RuntimeException(
+ "Can't embed unknown primitive in code: " + value);
+ gen.getStatic( bt, "TYPE", Type.getType(Class.class) );
+ }
+ else
+ {
+ gen.push(cc.getName());
+ gen.invokeStatic(Type.getType(Class.class), Method.getMethod("Class forName(String)"));
+ }
}
else if(value instanceof Symbol)
{