@Override public void visitConstructorCallExpression(ConstructorCallExpression call) { if (call.getNodeMetaData(StatementMeta.class)!=null) return; super.visitConstructorCallExpression(call); // we cannot a target for the constructor call, since we cannot easily // check the meta class of the other class // setMethodTarget(call, "<init>", call.getArguments(), false); }
private boolean writeDirectConstructorCall(ConstructorCallExpression call) { if (!controller.isFastPath()) return false; StatementMeta meta = call.getNodeMetaData(StatementMeta.class); ConstructorNode cn = null; if (meta!=null) cn = (ConstructorNode) meta.target; if (cn==null) return false; String ownerDescriptor = prepareConstructorCall(cn); TupleExpression args = makeArgumentList(call.getArguments()); loadArguments(args.getExpressions(), cn.getParameters()); finnishConstructorCall(cn, ownerDescriptor, args.getExpressions().size()); return true; }
Expression transformConstructorCall(final ConstructorCallExpression expr) { ConstructorNode node = (ConstructorNode) expr.getNodeMetaData(DIRECT_METHOD_CALL_TARGET); if (node == null) return expr; Parameter[] params = node.getParameters();
@Override public void visitConstructorCallExpression(final ConstructorCallExpression call) { super.visitConstructorCallExpression(call); MethodNode target = (MethodNode) call.getNodeMetaData(DIRECT_METHOD_CALL_TARGET); if (target==null && call.getLineNumber()>0) { addError("Target constructor for constructor call expression hasn't been set", call); } else { if (target==null) { // try to find a target ArgumentListExpression argumentListExpression = InvocationWriter.makeArgumentList(call.getArguments()); List<Expression> expressions = argumentListExpression.getExpressions(); ClassNode[] args = new ClassNode[expressions.size()]; for (int i = 0; i < args.length; i++) { args[i] = typeChooser.resolveType(expressions.get(i), classNode); } MethodNode constructor = findMethodOrFail(call, call.isSuperCall() ? classNode.getSuperClass() : classNode, "<init>", args); call.putNodeMetaData(DIRECT_METHOD_CALL_TARGET, constructor); target = constructor; } } if (target!=null) { memorizeInitialExpressions(target); } }
@Override public void writeInvokeConstructor(final ConstructorCallExpression call) { MethodNode mn = call.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET); if (mn == null) { super.writeInvokeConstructor(call); if (declaringClass != classNode) { MethodNode bridge = null; if (call.getNodeMetaData(StaticTypesMarker.PV_METHODS_ACCESS) != null) { Map<MethodNode, MethodNode> bridgeMethods = declaringClass.getNodeMetaData(StaticCompilationMetadataKeys.PRIVATE_BRIDGE_METHODS); bridge = bridgeMethods != null ? bridgeMethods.get(cn) : null;
@Override public void writeSpecialConstructorCall(final ConstructorCallExpression call) { MethodNode mn = call.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET); if (mn==null) { super.writeSpecialConstructorCall(call); return; } controller.getCompileStack().pushInSpecialConstructorCall(); ConstructorNode cn; if (mn instanceof ConstructorNode) { cn = (ConstructorNode) mn; } else { cn = new ConstructorNode(mn.getModifiers(), mn.getParameters(), mn.getExceptions(), mn.getCode()); cn.setDeclaringClass(mn.getDeclaringClass()); } // load "this" controller.getMethodVisitor().visitVarInsn(ALOAD, 0); String ownerDescriptor = BytecodeHelper.getClassInternalName(cn.getDeclaringClass()); TupleExpression args = makeArgumentList(call.getArguments()); int before = controller.getOperandStack().getStackLength(); loadArguments(args.getExpressions(), cn.getParameters()); finnishConstructorCall(cn, ownerDescriptor, controller.getOperandStack().getStackLength() - before); // on a special call, there's no object on stack controller.getOperandStack().remove(1); controller.getCompileStack().pop(); }
@Override public void visitConstructorCallExpression(ConstructorCallExpression call) { if (call.getNodeMetaData(StatementMeta.class)!=null) return; super.visitConstructorCallExpression(call); // we cannot a target for the constructor call, since we cannot easily // check the meta class of the other class // setMethodTarget(call, "<init>", call.getArguments(), false); }
private boolean writeDirectConstructorCall(ConstructorCallExpression call) { if (!controller.isFastPath()) return false; StatementMeta meta = (StatementMeta) call.getNodeMetaData(StatementMeta.class); ConstructorNode cn = null; if (meta!=null) cn = (ConstructorNode) meta.target; if (cn==null) return false; String ownerDescriptor = prepareConstructorCall(cn); TupleExpression args = makeArgumentList(call.getArguments()); loadArguments(args.getExpressions(), cn.getParameters()); finnishConstructorCall(cn, ownerDescriptor, args.getExpressions().size()); return true; }