MCPcopy Index your code
hub / github.com/clojure/clojure / emitBody

Method emitBody

src/jvm/clojure/lang/Compiler.java:6401–6442  ·  view source on GitHub ↗
(ObjExpr objx, GeneratorAdapter gen, Class retClass, Expr body)

Source from the content-addressed store, hash-verified

6399 }
6400
6401 static void emitBody(ObjExpr objx, GeneratorAdapter gen, Class retClass, Expr body) {
6402 MaybePrimitiveExpr be = (MaybePrimitiveExpr) body;
6403 if(Util.isPrimitive(retClass) && be.canEmitPrimitive())
6404 {
6405 Class bc = maybePrimitiveType(be);
6406 if(bc == retClass)
6407 be.emitUnboxed(C.RETURN, objx, gen);
6408 else if(retClass == long.class && bc == int.class)
6409 {
6410 be.emitUnboxed(C.RETURN, objx, gen);
6411 gen.visitInsn(I2L);
6412 }
6413 else if(retClass == double.class && bc == float.class)
6414 {
6415 be.emitUnboxed(C.RETURN, objx, gen);
6416 gen.visitInsn(F2D);
6417 }
6418 else if(retClass == int.class && bc == long.class)
6419 {
6420 be.emitUnboxed(C.RETURN, objx, gen);
6421 gen.invokeStatic(RT_TYPE, Method.getMethod("int intCast(long)"));
6422 }
6423 else if(retClass == float.class && bc == double.class)
6424 {
6425 be.emitUnboxed(C.RETURN, objx, gen);
6426 gen.visitInsn(D2F);
6427 }
6428 else
6429 throw new IllegalArgumentException("Mismatched primitive return, expected: "
6430 + retClass + ", had: " + be.getJavaClass());
6431 }
6432 else
6433 {
6434 body.emit(C.RETURN, objx, gen);
6435 if(retClass == void.class)
6436 {
6437 gen.pop();
6438 }
6439 else
6440 gen.unbox(Type.getType(retClass));
6441 }
6442 }
6443 abstract int numParams();
6444 abstract String getMethodName();
6445 abstract Type getReturnType();

Callers 3

doEmitStaticMethod · 0.80
doEmitPrimMethod · 0.80
emitMethod · 0.80

Calls 12

isPrimitiveMethod · 0.95
canEmitPrimitiveMethod · 0.95
emitUnboxedMethod · 0.95
getMethodMethod · 0.95
getTypeMethod · 0.95
maybePrimitiveTypeMethod · 0.80
unboxMethod · 0.80
getJavaClassMethod · 0.65
emitMethod · 0.65
popMethod · 0.65
visitInsnMethod · 0.45
invokeStaticMethod · 0.45

Tested by

no test coverage detected