예제 #1
0
  private void atStringPlusEq(Expr expr, int type, int dim, String cname, ASTree right)
      throws CompileError {
    if (!jvmJavaLangString.equals(cname)) badAssign(expr);

    convToString(type, dim); // the value might be null.
    right.accept(this);
    convToString(exprType, arrayDim);
    bytecode.addInvokevirtual(javaLangString, "concat", "(Ljava/lang/String;)Ljava/lang/String;");
    exprType = CLASS;
    arrayDim = 0;
    className = jvmJavaLangString;
  }
예제 #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.
  }