[Nice-commit] Nice/src/bossa/syntax ConstantExp.java,1.48,1.49
Brought to you by:
bonniot
From: <ar...@us...> - 2003-11-24 17:27:25
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv5224/F:/nice/src/bossa/syntax Modified Files: ConstantExp.java Log Message: treat negative numbers as constants. Index: ConstantExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ConstantExp.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** ConstantExp.java 24 Nov 2003 13:20:44 -0000 1.48 --- ConstantExp.java 24 Nov 2003 17:27:22 -0000 1.49 *************** *** 64,67 **** --- 64,72 ---- return ((Number) this.value).intValue() == 0; } + + public boolean isNumber() + { + return this.value instanceof Number && !(this.value instanceof Character); + } void computeType() *************** *** 178,182 **** } ! return new ConstantExp(type, tc, object, value+"", location); } --- 183,188 ---- } ! return new ConstantExp(type, tc, object, ! ""+value+(isLong ? "L" : ""), location); } *************** *** 192,196 **** try{ - //long value = Long.decode(rep).longValue(); long value = parse(rep); return makeInt(value, isLong, representation.location()); --- 198,201 ---- *************** *** 202,205 **** --- 207,220 ---- } } + + public ConstantExp makeNegative() + { + LocatedString newRepres = new LocatedString("-"+representation, location()); + + if (value instanceof Float || value instanceof Double) + return ConstantExp.makeFloating(newRepres); + + return ConstantExp.makeNumber(newRepres); + } private static long parse(String rep) throws NumberFormatException *************** *** 250,254 **** { float value = Float.parseFloat(repres); ! return new ConstantExp(PrimitiveType.floatTC, new Float(value), value+"", representation.location()); } --- 265,269 ---- { float value = Float.parseFloat(repres); ! return new ConstantExp(PrimitiveType.floatTC, new Float(value), value+"f", representation.location()); } |