Changeset 2164

Show
Ignore:
Timestamp:
07/02/08 12:56:22 (2 months ago)
Author:
jmaessen
Message:

[Libraries]
Changed Integral to be a parametric type Integral[\I\]. This
hopefully is a start to resolving some problems Guy and I were having
integrating unsigned integer types.

Note that this means that the Number hierarchy is no longer strictly
closed (since we can't write a comprises clause that mentions
Integral[\I\]). As a result you may find that you need to add
"excludes { Number }" to traits involving some of the crazier sorts of
overloading (mostly involving overloadings at numeric and non-numeric
types). Several tests were changed as a result.

Two bugs were tickled: one was an oversight in exclusion checking (it
turns out checking a subtype condition one-sidedly wasn't good enough,
as our transitive guarantees are quite strong enough for this to find
an obvious exclusion relationship). The other was a known bug in
static constraint solving, now raising its head in a place where
wasn't previously occurring; this is Ticket #143.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Library/FortressLibrary.fsi

    r2150 r2164  
    265265    opr juxtaposition(self, other:Self): Self 
    266266    (** Exponentiation need only deal with natural exponents. **) 
    267     opr ^(self, other:Integral): Self 
     267    opr ^(self, other:ZZ64): Self 
    268268end 
    269269 
     
    320320end 
    321321 
    322 trait RR64 extends Number comprises { Float, Integral, FloatLiteral } 
     322trait RR64 extends Number comprises { Float, AnyIntegral, FloatLiteral } 
    323323    (** returns true if the value is an IEEE NaN **) 
    324324    getter isNaN(): Boolean 
     
    335335    (** obtain the raw bits of the IEEE floating-point representation of this value. **) 
    336336    getter rawBits():ZZ64 
     337    (** next higher IEEE float **) 
     338    getter nextUp():RR64 
     339    (** next lower IEEE float **) 
     340    getter nextDown():RR64 
    337341    (** %MINNUM% and %MAXNUM% return a numeric result where possible (avoiding NaN). 
    338342        Note that %MINNUM% and %MAX% form a lattice with NaN at the top, and 
     
    342346end 
    343347 
    344 trait Integral extends { StandardTotalOrder[\Integral\], RR64 } 
     348trait AnyIntegral extends { RR64 } end 
     349 
     350trait Integral[\I extends Integral[\I\]\] extends { StandardTotalOrder[\I\], AnyIntegral } 
    345351        comprises { ZZ64, IntLiteral } 
    346     opr =(self, b:Integral):Boolean 
    347     opr <(self, b:Integral):Boolean 
    348  
    349     opr -(self):ZZ64 
    350     opr +(self,b:Integral):ZZ64 
    351     opr -(self,b:Integral):ZZ64 
    352     opr DOT(self,b:Integral):ZZ64 
    353     opr TIMES(self,b:Integral):ZZ64 
    354     opr juxtaposition(self,b:Integral):ZZ64 
    355     opr DIV(self,b:Integral):ZZ64 
    356     opr REM(self,b:Integral):ZZ64 
    357     opr MOD(self,b:Integral):ZZ64 
    358     opr GCD(self,b:Integral):ZZ64 
    359     opr LCM(self,b:Integral):ZZ64 
    360     opr CHOOSE(self,b:Integral):ZZ64 
    361     opr BITAND(self,b:Integral):ZZ64 
    362     opr BITOR(self,b:Integral):ZZ64 
    363     opr BITXOR(self,b:Integral):ZZ64 
    364     opr LSHIFT(self,b:Integral):ZZ64 
    365     opr RSHIFT(self,b:Integral):ZZ64 
    366     opr BITNOT(self):ZZ64 
    367     opr ^(self, b:Integral):Number 
     352    getter zero(): I 
     353    getter one(): I 
     354 
     355    opr -(self):I 
     356    opr +(self,b:I):I 
     357    opr -(self,b:I):I 
     358    opr DOT(self,b:I):I 
     359    opr TIMES(self,b:I):I 
     360    opr juxtaposition(self,b:I):I 
     361    opr DIV(self,b:I):I 
     362    opr REM(self,b:I):I 
     363    opr MOD(self,b:I):I 
     364    opr GCD(self,b:I):I 
     365    opr LCM(self,b:I):I 
     366    opr CHOOSE(self,b:I):I 
     367    opr BITAND(self,b:I):I 
     368    opr BITOR(self,b:I):I 
     369    opr BITXOR(self,b:I):I 
     370    opr LSHIFT(self,b:ZZ64):I 
     371    opr RSHIFT(self,b:ZZ64):I 
     372    opr BITNOT(self):I 
     373    opr ^(self, b:ZZ64):RR64 
     374end 
     375 
     376trait ZZ64 extends { Integral[\ZZ64\] } comprises { Long, ZZ32 } 
    368377    narrow(self):ZZ32 
    369 end 
    370  
    371 trait ZZ64 extends Integral comprises { Long, ZZ32 } 
    372378end 
    373379 
     
    451457        the predicate p are retained.  Natural order and cross product 
    452458        properties are otherwise preserved. **) 
    453     filter(f: E -> Condition[\()\]): Generator[\E\]  
     459    filter(f: E -> Condition[\()\]): Generator[\E\] 
    454460 
    455461    (** Cross product of two generators.  This is specifically 
     
    16311637    getter g(): Generator[\E\] 
    16321638    getter p(): E -> Condition[\()\] 
    1633     getter toString(): String  
     1639    getter toString(): String 
    16341640    generate[\R\](r:Reduction[\R\], m: E->R): R 
    16351641    reduce(r: Reduction[\E\]): E 
    1636     filter(p': E -> Condition[\()\]): FilterGenerator[\E\]  
     1642    filter(p': E -> Condition[\()\]): FilterGenerator[\E\] 
    16371643    seq(self) 
    16381644end 
     
    17371743 
    17381744(** The %#% and %:% operators serve as factories for parallel ranges. **) 
    1739 opr #[\I extends Integral\](lo:I, ex:I): Range[\I\] 
     1745opr #[\I extends AnyIntegral\](lo:I, ex:I): Range[\I\] 
    17401746opr #(lo:IntLiteral, ex:IntLiteral): Range[\ZZ32\] 
    1741 opr #[\I extends Integral, J extends Integral\] 
     1747opr #[\I extends AnyIntegral, J extends AnyIntegral\] 
    17421748     (lo:(I,J), ex:(I,J)): Range[\(I,J)\] 
    1743 opr #[\I extends Integral, J extends Integral, K extends Integral\] 
     1749opr #[\I extends AnyIntegral, J extends AnyIntegral, K extends AnyIntegral\] 
    17441750     (lo:(I,J,K), ex:(I,J,K)): Range[\(I,J,K)\] 
    1745 opr :[\I extends Integral\](lo:I, hi:I): FullRange[\I\] 
     1751opr :[\I extends AnyIntegral\](lo:I, hi:I): FullRange[\I\] 
    17461752opr :(lo:IntLiteral, ex:IntLiteral): FullRange[\ZZ32\] 
    1747 opr :[\I extends Integral, J extends Integral\] 
     1753opr :[\I extends AnyIntegral, J extends AnyIntegral\] 
    17481754     (lo:(I,J), hi:(I,J)): Range[\(I,J)\] 
    1749 opr :[\I extends Integral, J extends Integral, K extends Integral\] 
     1755opr :[\I extends AnyIntegral, J extends AnyIntegral, K extends AnyIntegral\] 
    17501756     (lo:(I,J,K), hi:(I,J,K)): Range[\(I,J,K)\] 
    17511757 
  • trunk/Library/FortressLibrary.fss

    r2163 r2164  
    318318    opr juxtaposition(self, other:Self): Self = self TIMES other 
    319319    (** Exponentiation need only deal with natural exponents. **) 
    320     opr ^(self, other:Integral): Self 
     320    opr ^(self, other:ZZ64): Self 
    321321end 
    322322 
     
    397397        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Float$Pow") 
    398398    (** Shouldn't need this extra declaration. **) 
    399     opr ^(self, b:Integral):RR64 = 
     399    opr ^(self, b:ZZ64):RR64 = 
    400400        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Float$Pow") 
    401401    sin(self):RR64 = 
     
    429429end 
    430430 
    431 trait RR64 extends Number comprises { Float, Integral, FloatLiteral } 
     431trait RR64 extends Number comprises { Float, AnyIntegral, FloatLiteral } 
    432432    (** returns true if the value is an IEEE NaN **) 
    433433    getter isNaN(): Boolean = 
     
    480480end 
    481481 
    482 trait Integral extends { StandardTotalOrder[\Integral\], RR64 } 
     482trait AnyIntegral extends { RR64 } end 
     483 
     484trait Integral[\I extends Integral[\I\]\] extends { StandardTotalOrder[\I\], AnyIntegral } 
    483485        comprises { ZZ64, IntLiteral } 
    484     getter zero(): Number = widen(0) 
    485     getter one(): Number = widen(1) 
    486  
    487     opr =(self, b:Integral):Boolean = 
    488         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Eq") 
    489     opr =/=(self, b:Integral): Boolean = NOT (self=b) 
    490  
    491     opr <(self, b:Integral):Boolean = 
    492         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Less") 
    493  
    494     opr -(self):ZZ64 = 
    495         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Negate") 
    496     opr +(self,b:Integral):ZZ64 = 
    497         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Add") 
    498     opr -(self,b:Integral):ZZ64 = 
    499         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Sub") 
    500     opr DOT(self,b:Integral):ZZ64 = 
    501         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Mul") 
    502     opr TIMES(self,b:Integral):ZZ64 = 
    503         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Mul") 
    504     opr juxtaposition(self,b:Integral):ZZ64 = 
    505         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Mul") 
    506     opr DIV(self,b:Integral):ZZ64 = 
    507         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Div") 
    508     opr REM(self,b:Integral):ZZ64 = 
    509         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Rem") 
    510     opr MOD(self,b:Integral):ZZ64 = 
    511         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Mod") 
    512     opr GCD(self,b:Integral):ZZ64 = 
    513         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Gcd") 
    514     opr LCM(self,b:Integral):ZZ64 = 
    515         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Lcm") 
    516     opr CHOOSE(self,b:Integral):ZZ64 = 
    517         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Choose") 
    518     opr BITAND(self,b:Integral):ZZ64 = 
    519         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$BitAnd") 
    520     opr BITOR(self,b:Integral):ZZ64 = 
    521         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$BitOr") 
    522     opr BITXOR(self,b:Integral):ZZ64 = 
    523         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$BitXor") 
    524     opr LSHIFT(self,b:Integral):ZZ64 = 
    525         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$LShift") 
    526     opr RSHIFT(self,b:Integral):ZZ64 = 
    527         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$RShift") 
    528     opr BITNOT(self):ZZ64 = 
    529         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$BitNot") 
    530     opr ^(self, b:Integral):RR64 = 
    531         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Pow") 
    532     narrow(self):ZZ32 = 
    533         builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$FromLong") 
    534 end 
    535  
    536 trait ZZ64 extends { StandardTotalOrder[\ZZ64\], Integral } comprises { Long, ZZ32 } 
     486    getter zero(): I 
     487    getter one(): I 
     488 
     489    opr -(self):I 
     490    opr +(self,b:I):I 
     491    opr -(self,b:I):I 
     492    opr DOT(self,b:I):I 
     493    opr TIMES(self,b:I):I 
     494    opr juxtaposition(self,b:I):I 
     495    opr DIV(self,b:I):I 
     496    opr REM(self,b:I):I 
     497    opr MOD(self,b:I):I 
     498    opr GCD(self,b:I):I 
     499    opr LCM(self,b:I):I 
     500    opr CHOOSE(self,b:I):I 
     501    opr BITAND(self,b:I):I 
     502    opr BITOR(self,b:I):I 
     503    opr BITXOR(self,b:I):I 
     504    opr LSHIFT(self,b:ZZ64):I 
     505    opr RSHIFT(self,b:ZZ64):I 
     506    opr BITNOT(self):I 
     507    opr ^(self, b:ZZ64):RR64 
     508end 
     509 
     510trait ZZ64 extends { Integral[\ZZ64\] } comprises { Long, ZZ32 } 
     511    getter zero(): ZZ64 = widen(0) 
     512    getter one(): ZZ64 = widen(1) 
     513 
    537514    opr |x:ZZ64| : ZZ64 = if x>=0 then x else -x end 
    538515 
     
    541518    opr <(self, b:ZZ64):Boolean = 
    542519        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Less") 
     520 
     521    opr -(self):ZZ64 = 
     522        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Negate") 
     523    opr +(self,b:ZZ64):ZZ64 = 
     524        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Add") 
     525    opr -(self,b:ZZ64):ZZ64 = 
     526        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Sub") 
     527    opr DOT(self,b:ZZ64):ZZ64 = 
     528        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Mul") 
     529    opr TIMES(self,b:ZZ64):ZZ64 = 
     530        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Mul") 
     531    opr juxtaposition(self,b:ZZ64):ZZ64 = 
     532        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Mul") 
     533    opr DIV(self,b:ZZ64):ZZ64 = 
     534        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Div") 
     535    opr REM(self,b:ZZ64):ZZ64 = 
     536        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Rem") 
     537    opr MOD(self,b:ZZ64):ZZ64 = 
     538        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Mod") 
     539    opr GCD(self,b:ZZ64):ZZ64 = 
     540        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Gcd") 
     541    opr LCM(self,b:ZZ64):ZZ64 = 
     542        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Lcm") 
     543    opr CHOOSE(self,b:ZZ64):ZZ64 = 
     544        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Choose") 
     545    opr BITAND(self,b:ZZ64):ZZ64 = 
     546        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$BitAnd") 
     547    opr BITOR(self,b:ZZ64):ZZ64 = 
     548        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$BitOr") 
     549    opr BITXOR(self,b:ZZ64):ZZ64 = 
     550        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$BitXor") 
     551    opr LSHIFT(self,b:ZZ64):ZZ64 = 
     552        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$LShift") 
     553    opr RSHIFT(self,b:ZZ64):ZZ64 = 
     554        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$RShift") 
     555    opr BITNOT(self):ZZ64 = 
     556        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$BitNot") 
     557    opr ^(self, b:ZZ64):RR64 = 
     558        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$Pow") 
     559    narrow(self):ZZ32 = 
     560        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.Long$FromLong") 
    543561end 
    544562 
     
    17091727        __Proxy[\ZZ32\] => vector[\T,s0\]() 
    17101728        __Proxy[\ZZ64\] => vector[\T,s0\]() 
    1711         __Proxy[\Integral\] => vector[\T,s0\]() 
    17121729        __Proxy[\RR64\] => vector[\T,s0\]() 
    17131730        __Proxy[\Number\] => vector[\T,s0\]() 
     
    20062023        __Proxy[\ZZ32\] => matrix[\T,s0,s1\]() 
    20072024        __Proxy[\ZZ64\] => matrix[\T,s0,s1\]() 
    2008         __Proxy[\Integral\] => matrix[\T,s0,s1\]() 
    20092025        __Proxy[\RR64\] => matrix[\T,s0,s1\]() 
    20102026        __Proxy[\Number\] => matrix[\T,s0,s1\]() 
     
    27452761  end 
    27462762 
    2747 opr PCMP(a:Integral, b:Integral): TotalComparison = a CMP b 
     2763opr PCMP(a:Number, b:Number): TotalComparison = a CMP b 
    27482764 
    27492765(** Non-traditional subtraction of bounds, elementwise on tuples **) 
     
    27602776  end 
    27612777 
    2762 opr SUBTR[\T extends Integral\](a:T, b:T):T = 1 + a - b 
     2778opr SUBTR[\T extends MultiplicativeRing[\T\]\](a:T, b:T):T = a.one() + a - b 
    27632779 
    27642780(** join upper and lower bounds comparisons (total or partial) to 
     
    29662982generators.  They generate |self| numbers, incrementing by 1, starting 
    29672983with lower() (that's the canonical ordering). *) 
    2968 trait ScalarRange[\N extends Integral\] 
     2984trait ScalarRange[\N extends Integral[\N\]\] 
    29692985        extends { FullRange[\N\] } 
    29702986        comprises { ParRange[\N\], SeqRange[\N\] } 
     
    29873003end 
    29883004 
    2989 value object ParRange[\N extends Integral\](lo:N, ex:N) 
     3005value object ParRange[\N extends Integral[\N\]\](lo:N, ex:N) 
    29903006        extends ScalarRange[\N\] 
    29913007    getter extent() = ex 
     
    30573073        end 
    30583074end 
    3059 value object SeqRange[\N extends Integral\](lo:N, ex:N) 
     3075value object SeqRange[\N extends Integral[\N\]\](lo:N, ex:N) 
    30603076        extends { ScalarRange[\N\], SequentialGenerator[\N\] } 
    30613077    getter extent() = ex 
     
    30903106end 
    30913107 
    3092 object Tuple2Range[\N extends Integral, M extends Integral\] 
     3108object Tuple2Range[\N extends Integral[\N\], M extends Integral[\M\]\] 
    30933109                  (l1:N,l2:M,x1:N,x2:M) 
    30943110        extends { TupleRange[\(N,M)\], DelegatedIndexed[\(N,M),(N,M)\] } 
     
    31223138end 
    31233139 
    3124 object Tuple3Range[\N1 extends Integral, N2 extends Integral, N3 extends Integral\] 
     3140object Tuple3Range[\N1 extends Integral[\N1\], N2 extends Integral[\N2\], N3 extends Integral[\N3\]\] 
    31253141                  (l1:N1,l2:N2,l3:N3,x1:N1,x2:N2,x3:N3) 
    31263142        extends { TupleRange[\(N1,N2,N3)\], 
     
    31603176 
    31613177(** The # and : operators serve as factories for parallel ranges. **) 
    3162 opr #[\I extends Integral\](lo:I, ex:I): ParRange[\I\] = ParRange[\I\](lo,ex) 
     3178opr #[\I extends AnyIntegral\](lo:I, ex:I): ParRange[\I\] = ParRange[\I\](lo,ex) 
     3179(* 
    31633180opr #(lo:IntLiteral, ex:IntLiteral): ParRange[\ZZ32\] = ParRange[\ZZ32\](lo,ex) 
    3164 opr #[\I extends Integral, J extends Integral\] 
     3181*) 
     3182opr #[\I extends AnyIntegral, J extends AnyIntegral\] 
    31653183     (lo:(I,J), ex:(I,J)): Tuple2Range[\I,J\] = 
    31663184    do (l1,l2)=lo; (x1,x2)=ex; Tuple2Range[\I,J\](l1,l2,x1,x2) end 
    3167 opr #[\I extends Integral, J extends Integral, K extends Integral\] 
     3185opr #[\I extends AnyIntegral, J extends AnyIntegral, K extends AnyIntegral\] 
    31683186     (lo:(I,J,K), ex:(I,J,K)): Tuple3Range[\I,J,K\] = 
    31693187    do (l1,l2,l3)=lo; (x1,x2,x3)=ex; Tuple3Range[\I,J,K\](l1,l2,l3,x1,x2,x3) end 
    31703188 
    3171 opr :[\I extends Integral\](lo:I, hi:I): ParRange[\I\] = 
     3189opr :[\I extends AnyIntegral\](lo:I, hi:I): ParRange[\I\] = 
    31723190        ParRange[\I\](lo,hi-lo+1) 
     3191(* 
    31733192opr :(lo:IntLiteral, hi:IntLiteral): ParRange[\ZZ32\] = 
    31743193        ParRange[\ZZ32\](lo,hi-lo+1) 
    3175 opr :[\I extends Integral, J extends Integral\] 
     3194*) 
     3195opr :[\I extends AnyIntegral, J extends AnyIntegral\] 
    31763196     (lo:(I,J), hi:(I,J)): Tuple2Range[\I,J\] = 
    31773197    do (l1,l2)=lo; (h1,h2)=hi; Tuple2Range[\I,J\](l1,l2,h1-l1+1,h2-l2+1) end 
    3178 opr :[\I extends Integral, J extends Integral, K extends Integral\] 
     3198opr :[\I extends AnyIntegral, J extends AnyIntegral, K extends AnyIntegral\] 
    31793199     (lo:(I,J,K), hi:(I,J,K)): Tuple3Range[\I,J,K\] = do 
    31803200    (l1,l2,l3)=lo; (h1,h2,h3)=hi 
  • trunk/ProjectFortress/LibraryBuiltin/FortressBuiltin.fsi

    r2159 r2164  
    2525 
    2626value object ZZ32 extends ZZ64 
     27    getter zero(): Number 
     28    getter one(): Number 
     29 
     30    opr |self| : ZZ32 
    2731    opr =(self, b:ZZ32):Boolean 
    2832    opr <(self, b:ZZ32):Boolean 
     
    4246    opr BITOR(self,b:ZZ32):ZZ32 
    4347    opr BITXOR(self,b:ZZ32):ZZ32 
    44     opr LSHIFT(self,b:Integral):ZZ32 
    45     opr RSHIFT(self,b:Integral):ZZ32 
     48    opr LSHIFT(self,b:ZZ64):ZZ32 
     49    opr RSHIFT(self,b:ZZ64):ZZ32 
    4650    opr BITNOT(self):ZZ32 
    47     opr ^(self, b:Integral):Number 
     51    opr ^(self, b:ZZ64):RR64 
    4852    widen(self):ZZ64 
    4953    partitionL(self):ZZ32 
     
    5357end 
    5458 
    55 object IntLiteral extends Integral 
     59object IntLiteral extends Integral[\IntLiteral\] 
    5660    opr =(self, b: IntLiteral):Boolean 
    5761    opr <(self, other:IntLiteral): Boolean 
     
    7579    opr BITOR(self, b: IntLiteral): IntLiteral 
    7680    opr BITXOR(self, b: IntLiteral): IntLiteral 
    77     opr LSHIFT(self, b:Integral): IntLiteral 
    78     opr RSHIFT(self, b:Integral): IntLiteral 
     81    opr LSHIFT(self, b:ZZ64): IntLiteral 
     82    opr RSHIFT(self, b:ZZ64): IntLiteral 
    7983    opr BITNOT(self): IntLiteral 
    80     opr ^(self, b:Integral):Number 
     84    opr ^(self, b:ZZ64):RR64 
    8185end 
    8286 
  • trunk/ProjectFortress/LibraryBuiltin/FortressBuiltin.fss

    r2163 r2164  
    2929 
    3030value object ZZ32 extends { StandardTotalOrder[\ZZ32\], ZZ64 } 
    31     getter zero(): Number = 0 
    32     getter one(): Number = 1 
     31    getter zero(): ZZ32 = 0 
     32    getter one(): ZZ32 = 1 
    3333 
    3434    opr |self| : ZZ32 = if self>=0 then self else -self end 
     
    6666    opr BITXOR(self,b:ZZ32):ZZ32 = 
    6767        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.ZZ32$BitXor") 
    68     opr LSHIFT(self,b:Integral):ZZ32 = 
     68    opr LSHIFT(self,b:ZZ64):ZZ32 = 
    6969        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.ZZ32$LShift") 
    70     opr RSHIFT(self,b:Integral):ZZ32 = 
     70    opr RSHIFT(self,b:ZZ64):ZZ32 = 
    7171        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.ZZ32$RShift") 
    7272    opr BITNOT(self):ZZ32 = 
    7373        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.ZZ32$BitNot") 
    74     opr ^(self, b:Integral):RR64 = 
     74    opr ^(self, b:ZZ64):RR64 = 
    7575        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.ZZ32$Pow") 
    7676    widen(self):ZZ64 = 
     
    8383end 
    8484 
    85 object IntLiteral extends Integral 
     85object IntLiteral extends Integral[\IntLiteral\] 
     86    getter zero(): IntLiteral = 
     87        1934791870947204798109283471902037419 - 1934791870947204798109283471902037419 
     88    getter one(): IntLiteral = zero() + 1 
    8689    opr |self| : ZZ32 = if self>=0 then self else -self end 
    8790    opr =(self, b: IntLiteral):Boolean = 
     
    104107        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.IntLiteral$Mul") 
    105108    opr juxtaposition(self, b: IntLiteral): IntLiteral = 
     109        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.IntLiteral$Mul") 
     110    opr TIMES(self, b: IntLiteral): IntLiteral = 
    106111        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.IntLiteral$Mul") 
    107112    opr DIV(self, b: IntLiteral): IntLiteral = 
     
    123128    opr BITXOR(self, b: IntLiteral): IntLiteral = 
    124129        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.IntLiteral$BitXor") 
    125     opr LSHIFT(self, b:Integral): IntLiteral = 
     130    opr LSHIFT(self, b:ZZ64): IntLiteral = 
    126131        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.IntLiteral$LShift") 
    127     opr RSHIFT(self, b:Integral): IntLiteral = 
     132    opr RSHIFT(self, b:ZZ64): IntLiteral = 
    128133        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.IntLiteral$RShift") 
    129134    opr BITNOT(self): IntLiteral = 
    130135        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.IntLiteral$BitNot") 
    131     opr ^(self, b:Integral):RR64 = 
     136    opr ^(self, b:ZZ64):RR64 = 
    132137        builtinPrimitive("com.sun.fortress.interpreter.glue.prim.IntLiteral$Pow") 
    133138end 
  • trunk/ProjectFortress/demos/lutx.fss

    r1009 r2164  
    2424 
    2525 
    26 opr MAXMIN[\N extends Number, I extends Integral\](a:(N,I),b:(N,I)):(N,I) = do 
     26opr MAXMIN[\N extends Number, I extends AnyIntegral\](a:(N,I),b:(N,I)):(N,I) = do 
    2727  (x1,n1) = a 
    2828  (x2,n2) = b 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/StaticJUTest.java

    r2163 r2164  
    2727 
    2828public class StaticJUTest extends TestCaseWrapper { 
    29      
     29 
    3030    private final static String STATIC_TESTS_DIR = ProjectProperties.BASEDIR + "static_tests/"; 
    3131    private final static List<String> FAILING_DISAMBIGUATOR = Arrays.asList(); 
    3232    private final static List<String> FAILING_TYPE_CHECKER = Arrays.asList( 
    3333        /* "XXXMultipleRefErrors.fss", 
    34        "GenericFunctionCall.fss", 
     34        "GenericFunctionCall.fss", 
    3535        "CrossOverloaded.fss", 
    3636        "SimpleObject.fss", 
     
    4747        "MethodInvocationStaticInfer1.fss", 
    4848        "MethodInvocationStaticInfer2.fss", 
    49         "While.fss" 
     49        "While.fss", 
     50        "PlusEq.fss" // Regression after library change: See ticket #143 
    5051    ); 
    51      
     52 
    5253    public static TestSuite suite() { 
    5354        return new StaticTestSuite("StaticJUTest", 
    5455                                   STATIC_TESTS_DIR, 
    5556                                   FAILING_DISAMBIGUATOR, 
    56                                    FAILING_TYPE_CHECKER);      
     57                                   FAILING_TYPE_CHECKER); 
    5758    } 
    5859} 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/types/FType.java

    r1895 r2164  
    173173 
    174174    private void computeTransitiveExcludes() { 
     175        exclDump("Computing transitive excludes for ",this,":"); 
    175176        for (FType t : getExtends()) { 
    176177            for (FType x : t.getExcludes()) { 
    177178                addExclude(x); 
    178                 exclDump(" ",t," excludes ",x); 
     179                exclDump(t," excludes ",x,"; "); 
    179180            } 
    180181        } 
     
    229230            return true; 
    230231        if (excludesOtherSimply(other)) { 
    231             exclDump("Ought to return true now."); 
    232232            return true; 
    233233        } 
     
    282282        } 
    283283        // Next, check that a supertype of other isn't excluded by us. 
     284        exclDump("\nChecking for supertype exclusion of ",this,": "); 
    284285        for (FType t1 : other.getTransitiveExtends()) { 
    285286            if (excludes.contains(t1)) { 
     
    288289                return true; 
    289290            } 
     291            exclDump("Not ",t1,"; "); 
     292        } 
     293        // And vice versa. 
     294        exclDump("\nChecking for supertype exclusion of ",other,": "); 
     295        Set<FType> oexcl = other.getExcludes(); 
     296        for (FType t1 : this.getTransitiveExtends()) { 
     297            if (oexcl.contains(t1)) { 
     298                exclDumpln("Excludes supertype ", t1, "."); 
     299                addExclude(other); 
     300                return true; 
     301            } 
     302            exclDump("Not ",t1,"; "); 
    290303        } 
    291304        // We shouldn't need to check the other way 'round by reflexivity. 
     
    300313        for (FType t1 : getTransitiveComprises()) { 
    301314            for (FType t2 : other.getTransitiveComprises()) { 
    302                 exclDump("Checking extends of comprised ",t1," and ",t2); 
     315                exclDump("Checking extends of comprised ",t1," and ",t2,"; "); 
    303316                if (!t1.excludesOther(t2)) { 
    304317                    return false; 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/OverloadedFunction.java

    r1895 r2164  
    7474 
    7575    static final boolean DUMP_EXCLUSION = false; 
    76     static int excl_skip = 1000000
     76    static int excl_skip = 100000
    7777 
    7878    public static void exclDump(Object... os) { 
     
    500500                } 
    501501            } 
    502              
     502 
    503503 
    504504            describeOverloadingFailure(o1, o2, within, pl1, 
     
    526526            if (p1better < 0 && p2better < 0 && selfIndex < 0) 
    527527                return false; 
    528              
     528 
    529529            if (result1Subtype2Failure || result2Subtype1Failure) 
    530530                return false; 
     
    582582                error(o1, o2, within, explanation); 
    583583            } 
    584              
     584 
    585585            if (result1Subtype2Failure) { 
    586586                String explanation = errorMsg("Overloading of ", o1, " and ", o2, 
  • trunk/ProjectFortress/tests/BitTwiddle.fss

    r1665 r2164  
    1919export Executable 
    2020 
    21 doit[\I extends Integral\](n:I,sz:ZZ64) = do 
     21doit[\I extends Integral[\I\]\](n:I,sz:ZZ64) = do 
    2222  n_bar = BITNOT n 
    2323  z : I = 0 
     
    5151  doit(n,32) 
    5252  println("ZZ32 OK") 
    53   doit[\ZZ64\](n',64) 
     53  doit(n',64) 
    5454  println("ZZ64 OK") 
    5555end 
  • trunk/ProjectFortress/tests/asifTest.fss

    r2155 r2164  
    107107    (* Mixed generic and overloaded method, at supertype. *) 
    108108    typecase z = (3 asif RR64) + 17 of 
    109         Integral => println("FAIL, got ZZ32 " z) 
     109        ZZ64 => println("FAIL, got ZZ64 " z) 
    110110        RR64 => println("PASS, got RR64 " z) 
    111111        else => println("Got unknown typed " z) 
  • trunk/ProjectFortress/tests/initOrder.fss

    r54 r2164  
    2424 
    2525(* Everything must extend this trait, or the bug will disappear. *) 
    26 trait S 
     26trait S excludes { Number } 
    2727end 
    2828 
  • trunk/ProjectFortress/tests/overloadTest7.fss

    r1074 r2164  
    2323   derived automatically for any two object types. 
    2424 
    25    Ought to work as of r1071 *) 
     25   Ought to work as of r1071 
    2626 
    27 trait notRR64 (* excludes {RR64} *) end 
     27   But now doesn't anymore, as RR64 is no longer closed due to absence 
     28   of where clauses preventing Integral closure. *) 
     29 
     30trait notRR64 excludes {RR64} end 
    2831 
    2932trait super extends {notRR64} end 
  • trunk/ProjectFortress/tests/overloadTest8.fss

    r1074 r2164  
    2323   derived automatically for any two object types. 
    2424 
    25    Ought to work as of r1071 *) 
     25   Ought to work as of r1071 
    2626 
    27 trait notRR64 (* excludes {RR64} *) end 
     27   But now doesn't anymore, as RR64 is no longer closed due to absence 
     28   of where clauses preventing Integral closure. *) 
     29 
     30trait notRR64 excludes {RR64} end 
    2831 
    2932trait super extends {notRR64} end 
  • trunk/ProjectFortress/tests/tupleInfer.fss

    r2 r2164  
    2020 
    2121(* Tests that we can instantiate generics inside tuples *) 
    22 opr MAXMIN[\N extends Number, I extends Integral\](a:(N,I),b:(N,I)):(N,I) = a 
     22opr MAXMIN[\N extends Number, I extends AnyIntegral\](a:(N,I),b:(N,I)):(N,I) = a 
    2323 
    2424run(args:String...):()=do