コード例 #1
0
ファイル: CodeGen.java プロジェクト: JimoLucy/javassist
  /* op is either =, %=, &=, *=, /=, +=, -=, ^=, |=, <<=, >>=, or >>>=.
   *
   * expr and var can be null.
   */
  private void atVariableAssign(
      Expr expr, int op, Variable var, Declarator d, ASTree right, boolean doDup)
      throws CompileError {
    int varType = d.getType();
    int varArray = d.getArrayDim();
    String varClass = d.getClassName();
    int varNo = getLocalVar(d);

    if (op != '=') atVariable(var);

    // expr is null if the caller is atDeclarator().
    if (expr == null && right instanceof ArrayInit)
      atArrayVariableAssign((ArrayInit) right, varType, varArray, varClass);
    else atAssignCore(expr, op, right, varType, varArray, varClass);

    if (doDup)
      if (is2word(varType, varArray)) bytecode.addOpcode(DUP2);
      else bytecode.addOpcode(DUP);

    if (varArray > 0) bytecode.addAstore(varNo);
    else if (varType == DOUBLE) bytecode.addDstore(varNo);
    else if (varType == FLOAT) bytecode.addFstore(varNo);
    else if (varType == LONG) bytecode.addLstore(varNo);
    else if (isRefType(varType)) bytecode.addAstore(varNo);
    else bytecode.addIstore(varNo);

    exprType = varType;
    arrayDim = varArray;
    className = varClass;
  }
コード例 #2
0
ファイル: CodeGen.java プロジェクト: JimoLucy/javassist
  private void atArrayAssign(Expr expr, int op, Expr array, ASTree right, boolean doDup)
      throws CompileError {
    arrayAccess(array.oprand1(), array.oprand2());

    if (op != '=') {
      bytecode.addOpcode(DUP2);
      bytecode.addOpcode(getArrayReadOp(exprType, arrayDim));
    }

    int aType = exprType;
    int aDim = arrayDim;
    String cname = className;

    atAssignCore(expr, op, right, aType, aDim, cname);

    if (doDup)
      if (is2word(aType, aDim)) bytecode.addOpcode(DUP2_X2);
      else bytecode.addOpcode(DUP_X2);

    bytecode.addOpcode(getArrayWriteOp(aType, aDim));
    exprType = aType;
    arrayDim = aDim;
    className = cname;
  }