예제 #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());
 }
예제 #2
0
 public ClassNode getTopOperand() {
   int size = stack.size();
   try {
     if (size == 0) throw new ArrayIndexOutOfBoundsException("size==0");
   } catch (ArrayIndexOutOfBoundsException ai) {
     System.err.println("index problem in " + controller.getSourceUnit().getName());
     throw ai;
   }
   return stack.get(size - 1);
 }
예제 #3
0
 /** replace top level element with new element of given type */
 public void replace(ClassNode type) {
   int size = stack.size();
   try {
     if (size == 0) throw new ArrayIndexOutOfBoundsException("size==0");
   } catch (ArrayIndexOutOfBoundsException ai) {
     System.err.println("index problem in " + controller.getSourceUnit().getName());
     throw ai;
   }
   stack.set(size - 1, type);
 }