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

Method doEmitPrim

src/jvm/clojure/lang/Compiler.java:6175–6243  ·  view source on GitHub ↗
(ObjExpr fn, ClassVisitor cv)

Source from the content-addressed store, hash-verified

6173 }
6174
6175 public void doEmitPrim(ObjExpr fn, ClassVisitor cv){
6176 Type returnType;
6177 if (retClass == double.class || retClass == long.class)
6178 returnType = getReturnType();
6179 else returnType = OBJECT_TYPE;
6180 Method ms = new Method("invokePrim", returnType, argtypes);
6181
6182 GeneratorAdapter gen = new GeneratorAdapter(ACC_PUBLIC + ACC_FINAL,
6183 ms,
6184 null,
6185 //todo don't hardwire this
6186 EXCEPTION_TYPES,
6187 cv);
6188 gen.visitCode();
6189
6190 Label loopLabel = gen.mark();
6191 gen.visitLineNumber(line, loopLabel);
6192 try
6193 {
6194 Var.pushThreadBindings(RT.map(LOOP_LABEL, loopLabel, METHOD, this));
6195 emitBody(objx, gen, retClass, body);
6196
6197 Label end = gen.mark();
6198 gen.visitLocalVariable("this", "Ljava/lang/Object;", null, loopLabel, end, 0);
6199 for(ISeq lbs = argLocals.seq(); lbs != null; lbs = lbs.next())
6200 {
6201 LocalBinding lb = (LocalBinding) lbs.first();
6202 gen.visitLocalVariable(lb.name, argtypes[lb.idx-1].getDescriptor(), null, loopLabel, end, lb.idx);
6203 }
6204 }
6205 finally
6206 {
6207 Var.popThreadBindings();
6208 }
6209
6210 gen.returnValue();
6211 //gen.visitMaxs(1, 1);
6212 gen.endMethod();
6213
6214 //generate the regular invoke, calling the prim method
6215 Method m = new Method(getMethodName(), OBJECT_TYPE, getArgTypes());
6216
6217 gen = new GeneratorAdapter(ACC_PUBLIC,
6218 m,
6219 null,
6220 //todo don't hardwire this
6221 EXCEPTION_TYPES,
6222 cv);
6223 gen.visitCode();
6224 gen.loadThis();
6225 for(int i = 0; i < argtypes.length; i++)
6226 {
6227 gen.loadArg(i);
6228 HostExpr.emitUnboxArg(fn, gen, argclasses[i]);
6229 }
6230 gen.invokeInterface(Type.getType("L"+prim+";"), ms);
6231 Type targetReturnType = getReturnType();
6232 if(Type.LONG_TYPE.equals(targetReturnType) || Type.DOUBLE_TYPE.equals(targetReturnType)) {

Callers 1

emitMethod · 0.95

Calls 15

getReturnTypeMethod · 0.95
markMethod · 0.95
pushThreadBindingsMethod · 0.95
mapMethod · 0.95
nextMethod · 0.95
firstMethod · 0.95
popThreadBindingsMethod · 0.95
returnValueMethod · 0.95
endMethodMethod · 0.95
getMethodNameMethod · 0.95
getArgTypesMethod · 0.95
loadThisMethod · 0.95

Tested by

no test coverage detected