cv.visitInsn(ICONST_0);
cv.visitInsn(IRETURN);
cv.visitMaxs(0, 0);
}
private void generateIniSHMethod(HomeContext gc) {
CodeVisitor cv = gc.cv.visitMethod(ACC_PUBLIC, "initSH", "()V", null, null);
String sqJCN = getJVMClassName(getQueryClass());
for (Iterator it = gc.sc.name2query.values().iterator(); it.hasNext();) {
SpeedoPredefinedQuery q = (SpeedoPredefinedQuery) it.next();
//sq = new SpeedoQuery();
cv.visitTypeInsn(NEW, sqJCN);
cv.visitInsn(DUP);
cv.visitMethodInsn(INVOKESPECIAL, sqJCN, "<init>", "()V");
cv.visitVarInsn(ASTORE, 1); //Always use the same variable 1
if (q.query != null) {
cv.visitVarInsn(ALOAD, 1);
cv.visitLdcInsn(q.query);
cv.visitMethodInsn(INVOKEVIRTUAL, sqJCN, "defineWith", "(Ljava/lang/String;)V");
}
if (q.filter != null) {
cv.visitVarInsn(ALOAD, 1);
cv.visitLdcInsn(q.filter);
cv.visitMethodInsn(INVOKEVIRTUAL, sqJCN, "setFilter", "(Ljava/lang/String;)V");
}
if (q.declareImports != null) {
cv.visitVarInsn(ALOAD, 1);
cv.visitLdcInsn(q.declareImports);
cv.visitMethodInsn(INVOKEVIRTUAL, sqJCN, "declareImports", "(Ljava/lang/String;)V");
}
if (q.declareParameters != null) {
cv.visitVarInsn(ALOAD, 1);
cv.visitLdcInsn(q.declareParameters);
cv.visitMethodInsn(INVOKEVIRTUAL, sqJCN, "declareParameters", "(Ljava/lang/String;)V");
}
if (q.declareVariables != null) {
cv.visitVarInsn(ALOAD, 1);
cv.visitLdcInsn(q.declareVariables);
cv.visitMethodInsn(INVOKEVIRTUAL, sqJCN, "declareVariables", "(Ljava/lang/String;)V");
}
cv.visitVarInsn(ALOAD, 1);
cv.visitInsn(q.ignoreCache ? ICONST_1 : ICONST_0);
cv.visitMethodInsn(INVOKEVIRTUAL, sqJCN, "setIgnoreCache", "(Z)V");
cv.visitVarInsn(ALOAD, 1);
cv.visitInsn(q.resultUnique ? ICONST_1 : ICONST_0);
cv.visitMethodInsn(INVOKEVIRTUAL, sqJCN, "setUnique", "(Z)V");
cv.visitVarInsn(ALOAD, 1);
Util.visitLongConstant(cv, q.rangeFirst);
Util.visitLongConstant(cv, q.rangeLast);
cv.visitMethodInsn(INVOKEVIRTUAL, sqJCN, "setRange", "(JJ)V");
if (q.ordering != null) {
cv.visitVarInsn(ALOAD, 1);
cv.visitLdcInsn(q.ordering);
cv.visitMethodInsn(INVOKEVIRTUAL, sqJCN, "setOrdering", "(Ljava/lang/String;)V");
}
if (q.resultClass != null) {
cv.visitVarInsn(ALOAD, 1);
cv.visitLdcInsn(q.resultClass);
cv.visitMethodInsn(INVOKEVIRTUAL, sqJCN, "setResultClass", "(Ljava/lang/String;)V");
}
cv.visitVarInsn(ALOAD, 1);
cv.visitInsn(q.includeSubclasses ? ICONST_1 : ICONST_0);
cv.visitMethodInsn(INVOKEVIRTUAL, sqJCN, "setIncludeSubClasses", "(Z)V");
//addNamedQuery("${nq.name}", sq);
cv.visitVarInsn(ALOAD, 0);
cv.visitLdcInsn(q.name);
cv.visitVarInsn(ALOAD, 1);
cv.visitMethodInsn(INVOKEVIRTUAL, gc.classToWriteJCN,
"addNamedQuery", "(Ljava/lang/String;L" + sqJCN + ";)V");
}
cv.visitInsn(RETURN);
cv.visitMaxs(0, 0);
}