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

Method buildThunk

src/jvm/clojure/lang/Compiler.java:1241–1262  ·  view source on GitHub ↗
(C context, QualifiedMethodExpr qmexpr)

Source from the content-addressed store, hash-verified

1239
1240 // TBD: caching/reuse of thunks
1241 private static FnExpr buildThunk(C context, QualifiedMethodExpr qmexpr) {
1242 // When qualified symbol has param-tags:
1243 // (fn invoke__Class_meth ([this? args*] (methodSymbol this? args*)))
1244 // When no param-tags:
1245 // (fn invoke__Class_meth ([this?] (methodSymbol this?))
1246 // ([this? arg1] (methodSymbol this? arg1)) ...)
1247 IPersistentCollection form = PersistentVector.EMPTY;
1248 Symbol instanceParam = qmexpr.kind == MethodKind.INSTANCE ? THIS : null;
1249 String thunkName = "invoke__" + qmexpr.c.getSimpleName() + "_" + qmexpr.methodSymbol.name;
1250 Set arities = (qmexpr.hintedSig != null) ? PersistentHashSet.create(qmexpr.hintedSig.size())
1251 : aritySet(qmexpr.c, qmexpr.methodName, qmexpr.kind);
1252
1253 for(Object a : arities) {
1254 int arity = (int) a;
1255 IPersistentVector params = buildParams(instanceParam, arity);
1256 ISeq body = RT.listStar(qmexpr.methodSymbol, params.seq());
1257 form = RT.conj(form, RT.list(params, body));
1258 }
1259
1260 ISeq thunkForm = RT.listStar(Symbol.intern("fn"), Symbol.intern(thunkName), RT.seq(form));
1261 return (FnExpr) analyzeSeq(context, thunkForm, thunkName);
1262 }
1263
1264 private static IPersistentVector buildParams(Symbol instanceParam, int arity) {
1265 IPersistentVector params = PersistentVector.EMPTY;

Callers 2

evalMethod · 0.95
emitMethod · 0.95

Calls 11

createMethod · 0.95
aritySetMethod · 0.95
buildParamsMethod · 0.95
listStarMethod · 0.95
conjMethod · 0.95
listMethod · 0.95
internMethod · 0.95
seqMethod · 0.95
analyzeSeqMethod · 0.80
seqMethod · 0.65
sizeMethod · 0.45

Tested by

no test coverage detected