Exemplo n.º 1
0
 private void throwExceptionForNoStackElement(int size, ClassNode targetType, boolean coerce) {
   if (size > 0) return;
   StringBuilder sb = new StringBuilder();
   sb.append("Internal compiler error while compiling ")
       .append(controller.getSourceUnit().getName())
       .append("\n");
   MethodNode methodNode = controller.getMethodNode();
   if (methodNode != null) {
     sb.append("Method: ");
     sb.append(methodNode);
     sb.append("\n");
   }
   ConstructorNode constructorNode = controller.getConstructorNode();
   if (constructorNode != null) {
     sb.append("Constructor: ");
     sb.append(methodNode);
     sb.append("\n");
   }
   sb.append("Line ").append(controller.getLineNumber()).append(",");
   sb.append(" expecting ")
       .append(coerce ? "coercion" : "casting")
       .append(" to ")
       .append(targetType.toString(false));
   sb.append(" but operand stack is empty");
   throw new ArrayIndexOutOfBoundsException(sb.toString());
 }
Exemplo n.º 2
0
 private ClassNode popWithMessage(int last) {
   try {
     return stack.remove(last);
   } catch (ArrayIndexOutOfBoundsException ai) {
     String method =
         controller.getMethodNode() == null
             ? controller.getConstructorNode().getTypeDescriptor()
             : controller.getMethodNode().getTypeDescriptor();
     throw new GroovyBugError(
         "Error while popping argument from operand stack tracker in class "
             + controller.getClassName()
             + " method "
             + method
             + ".");
   }
 }