use of org.codehaus.groovy.classgen.asm.CompileStack in project groovy-core by groovy.
the class InvokeDynamicWriter method finishIndyCall.
private void finishIndyCall(Handle bsmHandle, String methodName, String sig, int numberOfArguments, Object... bsmArgs) {
CompileStack compileStack = controller.getCompileStack();
OperandStack operandStack = controller.getOperandStack();
controller.getMethodVisitor().visitInvokeDynamicInsn(methodName, sig, bsmHandle, bsmArgs);
operandStack.replace(ClassHelper.OBJECT_TYPE, numberOfArguments);
compileStack.popLHS();
}
use of org.codehaus.groovy.classgen.asm.CompileStack in project groovy-core by groovy.
the class InvokeDynamicWriter method prepareIndyCall.
private String prepareIndyCall(Expression receiver, boolean implicitThis) {
CompileStack compileStack = controller.getCompileStack();
OperandStack operandStack = controller.getOperandStack();
compileStack.pushLHS(false);
// load normal receiver as first argument
compileStack.pushImplicitThis(implicitThis);
receiver.visit(controller.getAcg());
compileStack.popImplicitThis();
return "(" + getTypeDescription(operandStack.getTopOperand());
}
use of org.codehaus.groovy.classgen.asm.CompileStack in project groovy by apache.
the class InvokeDynamicWriter method prepareIndyCall.
private String prepareIndyCall(Expression receiver, boolean implicitThis) {
CompileStack compileStack = controller.getCompileStack();
OperandStack operandStack = controller.getOperandStack();
compileStack.pushLHS(false);
// load normal receiver as first argument
compileStack.pushImplicitThis(implicitThis);
receiver.visit(controller.getAcg());
compileStack.popImplicitThis();
return "(" + getTypeDescription(operandStack.getTopOperand());
}
use of org.codehaus.groovy.classgen.asm.CompileStack in project groovy by apache.
the class InvokeDynamicWriter method finishIndyCall.
private void finishIndyCall(Handle bsmHandle, String methodName, String sig, int numberOfArguments, Object... bsmArgs) {
CompileStack compileStack = controller.getCompileStack();
OperandStack operandStack = controller.getOperandStack();
controller.getMethodVisitor().visitInvokeDynamicInsn(methodName, sig, bsmHandle, bsmArgs);
operandStack.replace(ClassHelper.OBJECT_TYPE, numberOfArguments);
compileStack.popLHS();
}
use of org.codehaus.groovy.classgen.asm.CompileStack in project groovy by apache.
the class StaticTypesStatementWriter method writeForInLoop.
@Override
protected void writeForInLoop(final ForStatement loop) {
controller.getAcg().onLineNumber(loop, "visitForLoop");
writeStatementLabel(loop);
CompileStack compileStack = controller.getCompileStack();
MethodVisitor mv = controller.getMethodVisitor();
OperandStack operandStack = controller.getOperandStack();
compileStack.pushLoop(loop.getVariableScope(), loop.getStatementLabels());
// Identify type of collection
TypeChooser typeChooser = controller.getTypeChooser();
Expression collectionExpression = loop.getCollectionExpression();
ClassNode collectionType = typeChooser.resolveType(collectionExpression, controller.getClassNode());
Parameter loopVariable = loop.getVariable();
int size = operandStack.getStackLength();
if (collectionType.isArray() && loopVariable.getOriginType().equals(collectionType.getComponentType())) {
writeOptimizedForEachLoop(compileStack, operandStack, mv, loop, collectionExpression, collectionType, loopVariable);
} else if (ENUMERATION_CLASSNODE.equals(collectionType)) {
writeEnumerationBasedForEachLoop(compileStack, operandStack, mv, loop, collectionExpression, collectionType, loopVariable);
} else {
writeIteratorBasedForEachLoop(compileStack, operandStack, mv, loop, collectionExpression, collectionType, loopVariable);
}
operandStack.popDownTo(size);
compileStack.pop();
}
Aggregations