Пример #1
0
 public void atCastExpr(CastExpr expr) throws CompileError {
   String cname = resolveClassName(expr.getClassName());
   String toClass = checkCastExpr(expr, cname);
   int srcType = exprType;
   exprType = expr.getType();
   arrayDim = expr.getArrayDim();
   className = cname;
   if (toClass == null) atNumCastExpr(srcType, exprType); // built-in type
   else bytecode.addCheckcast(toClass);
 }
Пример #2
0
  protected void atAssignCore(Expr expr, int op, ASTree right, int type, int dim, String cname)
      throws CompileError {
    if (op == PLUS_E && dim == 0 && type == CLASS) atStringPlusEq(expr, type, dim, cname, right);
    else {
      right.accept(this);
      if (invalidDim(exprType, arrayDim, className, type, dim, cname, false)
          || (op != '=' && dim > 0)) badAssign(expr);

      if (op != '=') {
        int token = assignOps[op - MOD_E];
        int k = lookupBinOp(token);
        if (k < 0) fatal();

        atArithBinExpr(expr, token, k, type);
      }
    }

    if (op != '=' || (dim == 0 && !isRefType(type))) atNumCastExpr(exprType, type);

    // type check should be done here.
  }