[Nice-commit] Nice/src/bossa/syntax ConstantExp.java,1.50,1.51 Pattern.java,1.89,1.90 PrimitiveType.
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-08-05 19:01:29
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv389/F:/nice/src/bossa/syntax Modified Files: ConstantExp.java Pattern.java PrimitiveType.java Log Message: Don't use special tc's for testing boolean patterns. Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** Pattern.java 4 Aug 2004 17:09:07 -0000 1.89 --- Pattern.java 5 Aug 2004 19:01:18 -0000 1.90 *************** *** 327,336 **** return false; - if (that.atBool()) - return this.atBool() && (this.atTrue() == that.atTrue()); - - if (this.atBool()) - return that.tc == PrimitiveType.boolTC; - if (this.atEnum() && that.atEnum()) return this.atValue.equals(that.atValue); --- 327,330 ---- *************** *** 351,356 **** return this.atIntValue() && that.matchesCompareValue(this.atValue.longValue()); ! if (that.atNonBoolValue()) ! return this.atNonBoolValue() && this.atValue.equals(that.atValue); if (this.tc == that.tc) --- 345,350 ---- return this.atIntValue() && that.matchesCompareValue(this.atValue.longValue()); ! if (that.atValue != null && !that.atNull() &&!that.atIntCompare()) ! return (this.atValue != null && !this.atNull() &&!this.atIntCompare()) && this.atValue.equals(that.atValue); if (this.tc == that.tc) *************** *** 373,377 **** if (this.atBool() && that.atBool()) ! return this.atTrue() ^ that.atTrue(); if (this.atReference() && that.atReference()) --- 367,371 ---- if (this.atBool() && that.atBool()) ! return ! this.atValue.equals(that.atValue); if (this.atReference() && that.atReference()) *************** *** 429,433 **** return false; ! if (atNonBoolValue() && !atEnum() ) return false; --- 423,427 ---- return false; ! if ((atValue != null) && ! atTypeMatchingValue()) return false; *************** *** 435,454 **** return Typing.testRigidLeq(tag, PrimitiveType.longTC); - if (tag == PrimitiveType.trueBoolTC) - { - if (atBool()) - return atTrue(); - - return tc == PrimitiveType.boolTC; - } - - if (tag == PrimitiveType.falseBoolTC) - { - if (atBool()) - return atFalse(); - - return tc == PrimitiveType.boolTC; - } - if (exactlyAt) return Typing.testRigidLeq(tag, tc) && Typing.testRigidLeq(tc, tag); --- 429,432 ---- *************** *** 465,469 **** return val.value instanceof Number && matchesCompareValue(val.longValue()); ! return atNonBoolValue() && atValue.equals(val); } --- 443,450 ---- return val.value instanceof Number && matchesCompareValue(val.longValue()); ! if (atNull()) ! return false; ! ! return (atValue != null) && atValue.equals(val); } *************** *** 523,529 **** { List res = new LinkedList(); - if (!atEnum()) - return res; List symbols = ((EnumDefinition)((EnumDefinition.EnumSymbol)atValue.value).getDefinition()).symbols; for (Iterator it = symbols.iterator(); it.hasNext(); ) --- 504,516 ---- { List res = new LinkedList(); + if (atBool()) + { + res.add(ConstantExp.makeBoolean(true, location)); + res.add(ConstantExp.makeBoolean(false, location)); + return res; + } + + // atEnum() List symbols = ((EnumDefinition)((EnumDefinition.EnumSymbol)atValue.value).getDefinition()).symbols; for (Iterator it = symbols.iterator(); it.hasNext(); ) *************** *** 769,773 **** if (atBool()) { ! if (atFalse()) return Gen.boolNotExp(parameter); --- 756,760 ---- if (atBool()) { ! if (atValue.isFalse()) return Gen.boolNotExp(parameter); *************** *** 832,838 **** atValue.value instanceof Character); } - public boolean atNonBoolValue() { - return atValue != null && !atBool() && !atNull() &&!atIntCompare(); - } public boolean atNull() { return (atValue != null) && atValue.isNull(); } /** This pattern only specifies that the vlaue is not null. --- 819,822 ---- *************** *** 846,851 **** return atValue != null && tc == PrimitiveType.boolTC; } - public boolean atTrue() { return atValue != null && atValue.isTrue(); } - public boolean atFalse() { return atValue != null && atValue.isFalse(); } public boolean atString() { return atValue instanceof StringConstantExp; } public boolean atReference() { return atValue != null && atValue.value instanceof VarSymbol; } --- 830,833 ---- *************** *** 853,856 **** public boolean atIntCompare() { return compareKind > 0;} public boolean atLess() { return compareKind == LT || compareKind == LE; } ! public boolean atTypeMatchingValue() { return atEnum() || atIntCompare(); } } --- 835,840 ---- public boolean atIntCompare() { return compareKind > 0;} public boolean atLess() { return compareKind == LT || compareKind == LE; } ! public boolean atTypeMatchingValue() { return atEnum() || atIntCompare() || atBool();} ! public boolean atSimpleValue() { return atString() || (atIntValue() && ! atIntCompare()); } ! public boolean atEnumerableValue() { return atBool() || atEnum(); } } Index: PrimitiveType.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/PrimitiveType.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PrimitiveType.java 30 Jul 2004 19:08:45 -0000 1.12 --- PrimitiveType.java 5 Aug 2004 19:01:18 -0000 1.13 *************** *** 95,100 **** { boolTC = tc; - trueBoolTC = new TypeConstructor("true"); - falseBoolTC = new TypeConstructor("false"); boolType = Monotype.sure(new MonotypeConstructor(tc, null)); boolPolytype = new Polytype(boolType); --- 95,98 ---- *************** *** 165,170 **** public static TypeConstructor byteTC, charTC, intTC, longTC, boolTC, shortTC, doubleTC, floatTC, arrayTC, voidTC; - //these two only for dispatch testing booleans - public static TypeConstructor trueBoolTC, falseBoolTC; public static mlsub.typing.Monotype byteType, charType, intType, longType, boolType, shortType, doubleType, floatType, voidType; --- 163,166 ---- Index: ConstantExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ConstantExp.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** ConstantExp.java 30 Jul 2004 19:08:45 -0000 1.50 --- ConstantExp.java 5 Aug 2004 19:01:18 -0000 1.51 *************** *** 313,316 **** --- 313,322 ---- } + public boolean equals(Object other) + { + return other instanceof ConstantExp.Boolean && + (isTrue() == ((ConstantExp.Boolean)other).isTrue()); + } + private QuoteExp compiledValue; } *************** *** 326,329 **** --- 332,338 ---- public boolean equals(Object other) { + if (other instanceof ConstantExp.Boolean) + return false; + return other instanceof ConstantExp && value.equals(((ConstantExp)other).value); |