[Nice-commit] Nice/stdlib/nice/lang/inline CompOp.java,1.4,1.5
Brought to you by:
bonniot
From: <ar...@us...> - 2003-09-01 20:17:38
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang/inline In directory sc8-pr-cvs1:/tmp/cvs-serv24373/F:/nice/stdlib/nice/lang/inline Modified Files: CompOp.java Log Message: Give a warning when comparing an expression with an literal outside of its range. Index: CompOp.java =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/inline/CompOp.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CompOp.java 21 Mar 2003 23:32:35 -0000 1.4 --- CompOp.java 1 Sep 2003 20:17:31 -0000 1.5 *************** *** 22,26 **** @author Daniel Bonniot */ ! public class CompOp extends Procedure2 implements Inlineable,Branchable { private final static int --- 22,26 ---- @author Daniel Bonniot */ ! public class CompOp extends Procedure2 implements Branchable, bossa.syntax.Macro { private final static int *************** *** 137,140 **** --- 137,166 ---- return retType; } + + public void checkSpecialRequirements(bossa.syntax.Expression[] arguments) + { + bossa.syntax.ConstantExp literalexp = null; + bossa.syntax.Expression otherexp = null; + if (arguments[0] instanceof bossa.syntax.ConstantExp && + ! (arguments[1] instanceof bossa.syntax.ConstantExp)) + { + literalexp = (bossa.syntax.ConstantExp)arguments[0]; + otherexp = arguments[1]; + } + else if (arguments[1] instanceof bossa.syntax.ConstantExp && + ! (arguments[0] instanceof bossa.syntax.ConstantExp)) + { + literalexp = (bossa.syntax.ConstantExp)arguments[1]; + otherexp = arguments[0]; + } + + if (literalexp != null) + { + mlsub.typing.TypeConstructor tc = nice.tools.code.Types.equivalent(otherexp.getType().getMonotype()).head(); + if (mlsub.typing.Typing.testRigidLeq(tc, literalexp.tc) && + ! (mlsub.typing.Typing.testRigidLeq(literalexp.tc, tc))) + bossa.util.User.warning(otherexp, "Comparing a value with a constant outside the range of that value"); + } + } // Interpretation |