Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/common/int-lit.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/common/int-lit.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4587, Sun Sep 18 19:58:38 2016 UTC revision 4588, Mon Sep 19 02:13:20 2016 UTC
# Line 10  Line 10 
10    
11      type t = IntInf.int      type t = IntInf.int
12    
13      (* set the precision of tje Diderot "int" type to be 64-bits *)
14        val setDiderotLongInt : unit -> unit
15    
16      val fromInt : int -> t      val fromInt : int -> t
17    
18      (* minimum and maximum values that are representable as Diderot ints *)
19        val minInt : unit -> t
20        val maxInt : unit -> t
21    
22    (* arithmetic *)    (* arithmetic *)
23      val add : t * t -> t      val add : t * t -> t
24      val sub : t * t -> t      val sub : t * t -> t
# Line 20  Line 27 
27      val modulo : t * t -> t      val modulo : t * t -> t
28      val neg : t -> t      val neg : t -> t
29    
30    (* range checks *)    (* is an integer in range for the Diderot "int" type? *)
31      val isInt32 : t -> bool     (* representable in 32-bits *)      val inRange : t -> bool
     val isInt64 : t -> bool     (* representable in 64-bits *)  
32    
33    (* equality, comparisons, and hashing functions *)    (* equality, comparisons, and hashing functions *)
34      val same : (t * t) -> bool      val same : (t * t) -> bool
# Line 37  Line 43 
43    
44      val fromInt = IntInf.fromInt      val fromInt = IntInf.fromInt
45    
46      (* set the precision of tje Diderot "int" type to be 64-bits *)
47        val isLongInt = ref false
48        fun setDiderotLongInt () = isLongInt := true
49    
50      (* minimum and maximum values that are representable as Diderot ints *)
51        fun minInt () : t = if !isLongInt then ~0x8000000000000000 else ~0x80000000
52        fun maxInt () : t = if !isLongInt then  0x7fffffffffffffff else  0x7fffffff
53    
54    (* arithmetic *)    (* arithmetic *)
55      val add = IntInf.+      val add = IntInf.+
56      val sub = IntInf.-      val sub = IntInf.-
# Line 46  Line 60 
60      val neg = IntInf.~      val neg = IntInf.~
61    
62    (* range checks *)    (* range checks *)
63      fun isInt32 (n : IntInf.int) =      fun inRange (n : IntInf.int) = if !isLongInt
64            (~0x80000000 <= n) andalso (n < 0x100000000)            then (~0x8000000000000000 <= n) andalso (n <= 0x7fffffffffffffff)
65      fun isInt64 (n : IntInf.int) =            else (~0x80000000 <= n) andalso (n <= 0x7fffffff)
           (~0x8000000000000000 <= n) andalso (n < 0x10000000000000000)  
66    
67    (* equality, comparisons, and hashing functions *)    (* equality, comparisons, and hashing functions *)
68      fun same (a : IntInf.int, b) = (a = b)      fun same (a : IntInf.int, b) = (a = b)

Legend:
Removed from v.4587  
changed lines
  Added in v.4588

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0