public static ASTree getConstantFieldValue(CtField f) { if (f == null) return null; Object value = f.getConstantValue(); if (value == null) return null; if (value instanceof String) return new StringL((String)value); else if (value instanceof Double || value instanceof Float) { int token = (value instanceof Double) ? DoubleConstant : FloatConstant; return new DoubleConst(((Number)value).doubleValue(), token); } else if (value instanceof Number) { int token = (value instanceof Long) ? LongConstant : IntConstant; return new IntConst(((Number)value).longValue(), token); } else if (value instanceof Boolean) return new Keyword(((Boolean)value).booleanValue() ? TokenId.TRUE : TokenId.FALSE); else return null; }
public static ASTree getConstantFieldValue(CtField f) { if (f == null) return null; Object value = f.getConstantValue(); if (value == null) return null; if (value instanceof String) return new StringL((String)value); else if (value instanceof Double || value instanceof Float) { int token = (value instanceof Double) ? DoubleConstant : FloatConstant; return new DoubleConst(((Number)value).doubleValue(), token); } else if (value instanceof Number) { int token = (value instanceof Long) ? LongConstant : IntConstant; return new IntConst(((Number)value).longValue(), token); } else if (value instanceof Boolean) return new Keyword(((Boolean)value).booleanValue() ? TokenId.TRUE : TokenId.FALSE); else return null; }
private boolean isConstant(BinExpr expr, int op, ASTree left, ASTree right) throws CompileError { left = stripPlusExpr(left); right = stripPlusExpr(right); ASTree newExpr = null; if (left instanceof StringL && right instanceof StringL && op == '+') newExpr = new StringL(((StringL)left).get() + ((StringL)right).get()); else if (left instanceof IntConst) newExpr = ((IntConst)left).compute(op, right); else if (left instanceof DoubleConst) newExpr = ((DoubleConst)left).compute(op, right); if (newExpr == null) return false; // not a constant expression else { expr.setOperator('+'); expr.setOprand1(newExpr); expr.setOprand2(null); newExpr.accept(this); // for setting exprType, arrayDim, ... return true; } }
private boolean isConstant(BinExpr expr, int op, ASTree left, ASTree right) throws CompileError { left = stripPlusExpr(left); right = stripPlusExpr(right); ASTree newExpr = null; if (left instanceof StringL && right instanceof StringL && op == '+') newExpr = new StringL(((StringL)left).get() + ((StringL)right).get()); else if (left instanceof IntConst) newExpr = ((IntConst)left).compute(op, right); else if (left instanceof DoubleConst) newExpr = ((DoubleConst)left).compute(op, right); if (newExpr == null) return false; // not a constant expression expr.setOperator('+'); expr.setOprand1(newExpr); expr.setOprand2(null); newExpr.accept(this); // for setting exprType, arrayDim, ... return true; }
return new Variable(name, decl); // local variable case StringL : return new StringL(lex.getString()); case NEW : return parseNew(tbl);
return new Variable(name, decl); // local variable case StringL : return new StringL(lex.getString()); case NEW : return parseNew(tbl);
public static ASTree getConstantFieldValue(CtField f) { if (f == null) return null; Object value = f.getConstantValue(); if (value == null) return null; if (value instanceof String) return new StringL((String)value); else if (value instanceof Double || value instanceof Float) { int token = (value instanceof Double) ? DoubleConstant : FloatConstant; return new DoubleConst(((Number)value).doubleValue(), token); } else if (value instanceof Number) { int token = (value instanceof Long) ? LongConstant : IntConstant; return new IntConst(((Number)value).longValue(), token); } else if (value instanceof Boolean) return new Keyword(((Boolean)value).booleanValue() ? TokenId.TRUE : TokenId.FALSE); else return null; }
public static ASTree getConstantFieldValue(CtField f) { if (f == null) return null; Object value = f.getConstantValue(); if (value == null) return null; if (value instanceof String) return new StringL((String)value); else if (value instanceof Double || value instanceof Float) { int token = (value instanceof Double) ? DoubleConstant : FloatConstant; return new DoubleConst(((Number)value).doubleValue(), token); } else if (value instanceof Number) { int token = (value instanceof Long) ? LongConstant : IntConstant; return new IntConst(((Number)value).longValue(), token); } else if (value instanceof Boolean) return new Keyword(((Boolean)value).booleanValue() ? TokenId.TRUE : TokenId.FALSE); else return null; }
public static ASTree getConstantFieldValue(CtField f) { if (f == null) return null; Object value = f.getConstantValue(); if (value == null) return null; if (value instanceof String) return new StringL((String)value); else if (value instanceof Double || value instanceof Float) { int token = (value instanceof Double) ? DoubleConstant : FloatConstant; return new DoubleConst(((Number)value).doubleValue(), token); } else if (value instanceof Number) { int token = (value instanceof Long) ? LongConstant : IntConstant; return new IntConst(((Number)value).longValue(), token); } else if (value instanceof Boolean) return new Keyword(((Boolean)value).booleanValue() ? TokenId.TRUE : TokenId.FALSE); else return null; }
public static ASTree getConstantFieldValue(CtField f) { if (f == null) return null; Object value = f.getConstantValue(); if (value == null) return null; if (value instanceof String) return new StringL((String)value); else if (value instanceof Double || value instanceof Float) { int token = (value instanceof Double) ? DoubleConstant : FloatConstant; return new DoubleConst(((Number)value).doubleValue(), token); } else if (value instanceof Number) { int token = (value instanceof Long) ? LongConstant : IntConstant; return new IntConst(((Number)value).longValue(), token); } else if (value instanceof Boolean) return new Keyword(((Boolean)value).booleanValue() ? TokenId.TRUE : TokenId.FALSE); else return null; }
public static ASTree getConstantFieldValue(CtField f) { if (f == null) return null; Object value = f.getConstantValue(); if (value == null) return null; if (value instanceof String) return new StringL((String)value); else if (value instanceof Double || value instanceof Float) { int token = (value instanceof Double) ? DoubleConstant : FloatConstant; return new DoubleConst(((Number)value).doubleValue(), token); } else if (value instanceof Number) { int token = (value instanceof Long) ? LongConstant : IntConstant; return new IntConst(((Number)value).longValue(), token); } else if (value instanceof Boolean) return new Keyword(((Boolean)value).booleanValue() ? TokenId.TRUE : TokenId.FALSE); else return null; }
private boolean isConstant(BinExpr expr, int op, ASTree left, ASTree right) throws CompileError { left = stripPlusExpr(left); right = stripPlusExpr(right); ASTree newExpr = null; if (left instanceof StringL && right instanceof StringL && op == '+') newExpr = new StringL(((StringL)left).get() + ((StringL)right).get()); else if (left instanceof IntConst) newExpr = ((IntConst)left).compute(op, right); else if (left instanceof DoubleConst) newExpr = ((DoubleConst)left).compute(op, right); if (newExpr == null) return false; // not a constant expression else { expr.setOperator('+'); expr.setOprand1(newExpr); expr.setOprand2(null); newExpr.accept(this); // for setting exprType, arrayDim, ... return true; } }
private boolean isConstant(BinExpr expr, int op, ASTree left, ASTree right) throws CompileError { left = stripPlusExpr(left); right = stripPlusExpr(right); ASTree newExpr = null; if (left instanceof StringL && right instanceof StringL && op == '+') newExpr = new StringL(((StringL)left).get() + ((StringL)right).get()); else if (left instanceof IntConst) newExpr = ((IntConst)left).compute(op, right); else if (left instanceof DoubleConst) newExpr = ((DoubleConst)left).compute(op, right); if (newExpr == null) return false; // not a constant expression else { expr.setOperator('+'); expr.setOprand1(newExpr); expr.setOprand2(null); newExpr.accept(this); // for setting exprType, arrayDim, ... return true; } }
private boolean isConstant(BinExpr expr, int op, ASTree left, ASTree right) throws CompileError { left = stripPlusExpr(left); right = stripPlusExpr(right); ASTree newExpr = null; if (left instanceof StringL && right instanceof StringL && op == '+') newExpr = new StringL(((StringL)left).get() + ((StringL)right).get()); else if (left instanceof IntConst) newExpr = ((IntConst)left).compute(op, right); else if (left instanceof DoubleConst) newExpr = ((DoubleConst)left).compute(op, right); if (newExpr == null) return false; // not a constant expression else { expr.setOperator('+'); expr.setOprand1(newExpr); expr.setOprand2(null); newExpr.accept(this); // for setting exprType, arrayDim, ... return true; } }
private boolean isConstant(BinExpr expr, int op, ASTree left, ASTree right) throws CompileError { left = stripPlusExpr(left); right = stripPlusExpr(right); ASTree newExpr = null; if (left instanceof StringL && right instanceof StringL && op == '+') newExpr = new StringL(((StringL)left).get() + ((StringL)right).get()); else if (left instanceof IntConst) newExpr = ((IntConst)left).compute(op, right); else if (left instanceof DoubleConst) newExpr = ((DoubleConst)left).compute(op, right); if (newExpr == null) return false; // not a constant expression else { expr.setOperator('+'); expr.setOprand1(newExpr); expr.setOprand2(null); newExpr.accept(this); // for setting exprType, arrayDim, ... return true; } }
private boolean isConstant(BinExpr expr, int op, ASTree left, ASTree right) throws CompileError { left = stripPlusExpr(left); right = stripPlusExpr(right); ASTree newExpr = null; if (left instanceof StringL && right instanceof StringL && op == '+') newExpr = new StringL(((StringL)left).get() + ((StringL)right).get()); else if (left instanceof IntConst) newExpr = ((IntConst)left).compute(op, right); else if (left instanceof DoubleConst) newExpr = ((DoubleConst)left).compute(op, right); if (newExpr == null) return false; // not a constant expression else { expr.setOperator('+'); expr.setOprand1(newExpr); expr.setOprand2(null); newExpr.accept(this); // for setting exprType, arrayDim, ... return true; } }
return new Variable(name, decl); // local variable case StringL : return new StringL(lex.getString()); case NEW : return parseNew(tbl);
return new Variable(name, decl); // local variable case StringL : return new StringL(lex.getString()); case NEW : return parseNew(tbl);
return new Variable(name, decl); // local variable case StringL : return new StringL(lex.getString()); case NEW : return parseNew(tbl);
return new Variable(name, decl); // local variable case StringL : return new StringL(lex.getString()); case NEW : return parseNew(tbl);