Permalink
Browse files

don't box static method returns in statement context

  • Loading branch information...
1 parent 9b702a0 commit 099aa8615c378fee98a492837cc0415abd3a6087 @richhickey richhickey committed Sep 8, 2010
Showing with 14 additions and 3 deletions.
  1. +14 −3 src/jvm/clojure/lang/Compiler.java
@@ -1483,7 +1483,18 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
Method m = new Method(methodName, Type.getReturnType(method), Type.getArgumentTypes(method));
gen.invokeStatic(type, m);
//if(context != C.STATEMENT || method.getReturnType() == Void.TYPE)
- HostExpr.emitBoxReturn(objx, gen, method.getReturnType());
+ Class retClass = method.getReturnType();
+ if(context == C.STATEMENT)
+ {
+ if(retClass == long.class || retClass == double.class)
+ gen.pop2();
+ else if(retClass != void.class)
+ gen.pop();
+ }
+ else
+ {
+ HostExpr.emitBoxReturn(objx, gen, method.getReturnType());
+ }
}
else
{
@@ -1497,9 +1508,9 @@ public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
method.emitClearLocals(gen);
}
gen.invokeStatic(REFLECTOR_TYPE, invokeStaticMethodMethod);
+ if(context == C.STATEMENT)
+ gen.pop();
}
- if(context == C.STATEMENT)
- gen.pop();
}
public boolean hasJavaClass(){

0 comments on commit 099aa86

Please sign in to comment.