private static DoubleConst compute(int op, double value1, double value2, int newType) { double newValue; switch (op) { case '+' : newValue = value1 + value2; break; case '-' : newValue = value1 - value2; break; case '*' : newValue = value1 * value2; break; case '/' : newValue = value1 / value2; break; case '%' : newValue = value1 % value2; break; default : return null; } return new DoubleConst(newValue, newType); } }
private DoubleConst compute0(int op, DoubleConst right) { int newType; if (this.type == TokenId.DoubleConstant || right.type == TokenId.DoubleConstant) newType = TokenId.DoubleConstant; else newType = TokenId.FloatConstant; return compute(op, this.value, right.value, newType); }
private boolean isConstant(Expr expr, int op, ASTree oprand) { oprand = stripPlusExpr(oprand); if (oprand instanceof IntConst) { IntConst c = (IntConst)oprand; long v = c.get(); if (op == '-') v = -v; else if (op == '~') v = ~v; else return false; c.set(v); } else if (oprand instanceof DoubleConst) { DoubleConst c = (DoubleConst)oprand; if (op == '-') c.set(-c.get()); else return false; } else return false; expr.setOperator('+'); return true; }
public void atDoubleConst(DoubleConst d) throws CompileError { arrayDim = 0; if (d.getType() == DoubleConstant) exprType = DOUBLE; else exprType = FLOAT; } }
int getConstantValue2(ConstPool cp, CtClass type, ASTree tree) { if (type.isPrimitive()) { if (tree instanceof IntConst) { long value = ((IntConst)tree).get(); if (type == CtClass.doubleType) return cp.addDoubleInfo((double)value); else if (type == CtClass.floatType) return cp.addFloatInfo((float)value); else if (type == CtClass.longType) return cp.addLongInfo(value); else if (type != CtClass.voidType) return cp.addIntegerInfo((int)value); } else if (tree instanceof DoubleConst) { double value = ((DoubleConst)tree).get(); if (type == CtClass.floatType) return cp.addFloatInfo((float)value); else if (type == CtClass.doubleType) return cp.addDoubleInfo(value); } } else if (tree instanceof StringL && type.getName().equals(javaLangString)) return cp.addStringInfo(((StringL)tree).get()); return 0; } }
private boolean isConstant(Expr expr, int op, ASTree oprand) { oprand = stripPlusExpr(oprand); if (oprand instanceof IntConst) { IntConst c = (IntConst)oprand; long v = c.get(); if (op == '-') v = -v; else if (op == '~') v = ~v; else return false; c.set(v); } else if (oprand instanceof DoubleConst) { DoubleConst c = (DoubleConst)oprand; if (op == '-') c.set(-c.get()); else return false; } else return false; expr.setOperator('+'); return true; }
@Override public void atDoubleConst(DoubleConst d) throws CompileError { arrayDim = 0; if (d.getType() == DoubleConstant) exprType = DOUBLE; else exprType = FLOAT; } }
int getConstantValue2(ConstPool cp, CtClass type, ASTree tree) { if (type.isPrimitive()) { if (tree instanceof IntConst) { long value = ((IntConst)tree).get(); if (type == CtClass.doubleType) return cp.addDoubleInfo(value); else if (type == CtClass.floatType) return cp.addFloatInfo(value); else if (type == CtClass.longType) return cp.addLongInfo(value); else if (type != CtClass.voidType) return cp.addIntegerInfo((int)value); } else if (tree instanceof DoubleConst) { double value = ((DoubleConst)tree).get(); if (type == CtClass.floatType) return cp.addFloatInfo((float)value); else if (type == CtClass.doubleType) return cp.addDoubleInfo(value); } } else if (tree instanceof StringL && type.getName().equals(javaLangString)) return cp.addStringInfo(((StringL)tree).get()); return 0; } }
private DoubleConst compute0(int op, DoubleConst right) { double value1 = (double)this.value; double value2 = right.value; double newValue; switch (op) { case '+' : newValue = value1 + value2; break; case '-' : newValue = value1 - value2; break; case '*' : newValue = value1 * value2; break; case '/' : newValue = value1 / value2; break; case '%' : newValue = value1 % value2; break; default : return null; } return new DoubleConst(newValue, right.type); } }
private boolean isConstant(Expr expr, int op, ASTree oprand) { oprand = stripPlusExpr(oprand); if (oprand instanceof IntConst) { IntConst c = (IntConst)oprand; long v = c.get(); if (op == '-') v = -v; else if (op == '~') v = ~v; else return false; c.set(v); } else if (oprand instanceof DoubleConst) { DoubleConst c = (DoubleConst)oprand; if (op == '-') c.set(-c.get()); else return false; } else return false; expr.setOperator('+'); return true; }
private DoubleConst compute0(int op, IntConst right) { return compute(op, this.value, (double)right.value, this.type); }
public void atDoubleConst(DoubleConst d) throws CompileError { arrayDim = 0; if (d.getType() == DoubleConstant) exprType = DOUBLE; else exprType = FLOAT; } }
int getConstantValue2(ConstPool cp, CtClass type, ASTree tree) { if (type.isPrimitive()) { if (tree instanceof IntConst) { long value = ((IntConst)tree).get(); if (type == CtClass.doubleType) return cp.addDoubleInfo((double)value); else if (type == CtClass.floatType) return cp.addFloatInfo((float)value); else if (type == CtClass.longType) return cp.addLongInfo(value); else if (type != CtClass.voidType) return cp.addIntegerInfo((int)value); } else if (tree instanceof DoubleConst) { double value = ((DoubleConst)tree).get(); if (type == CtClass.floatType) return cp.addFloatInfo((float)value); else if (type == CtClass.doubleType) return cp.addDoubleInfo(value); } } else if (tree instanceof StringL && type.getName().equals(javaLangString)) return cp.addStringInfo(((StringL)tree).get()); return 0; } }
private DoubleConst compute0(int op, DoubleConst right) { double value1 = this.value; double value2 = right.value; double newValue; switch (op) { case '+' : newValue = value1 + value2; break; case '-' : newValue = value1 - value2; break; case '*' : newValue = value1 * value2; break; case '/' : newValue = value1 / value2; break; case '%' : newValue = value1 % value2; break; default : return null; } return new DoubleConst(newValue, right.type); } }