Example #1
0
 public IGoal[] init() {
   ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
   CastExpression castExpression = (CastExpression) typedGoal.getExpression();
   int operator = castExpression.getCastType();
   switch (operator) {
     case CastExpression.TYPE_INT:
     case CastExpression.TYPE_REAL:
       result = new SimpleType(SimpleType.TYPE_NUMBER);
       break;
     case CastExpression.TYPE_STRING:
       result = new SimpleType(SimpleType.TYPE_STRING);
       break;
     case CastExpression.TYPE_ARRAY:
       result = new SimpleType(SimpleType.TYPE_ARRAY);
       break;
     case CastExpression.TYPE_OBJECT:
       return new IGoal[] {
         new ExpressionTypeGoal(typedGoal.getContext(), castExpression.getExpr())
       };
     case CastExpression.TYPE_BOOL:
       result = new SimpleType(SimpleType.TYPE_BOOLEAN);
       break;
     case CastExpression.TYPE_UNSET:
       result = new SimpleType(SimpleType.TYPE_NULL);
       break;
     default:
       throw new IllegalArgumentException();
   }
   return IGoal.NO_GOALS;
 }
  public IGoal[] init() {
    ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
    ArrayCreation arrayCreation = (ArrayCreation) typedGoal.getExpression();

    List<IGoal> subGoals = new LinkedList<IGoal>();
    for (ArrayElement arrayElement : arrayCreation.getElements()) {
      subGoals.add(new ExpressionTypeGoal(typedGoal.getContext(), arrayElement.getValue()));
    }
    return subGoals.toArray(new IGoal[subGoals.size()]);
  }