Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/compiler/FLINT/trans/literal-to-num.sml
ViewVC logotype

View of /sml/trunk/compiler/FLINT/trans/literal-to-num.sml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 4813 - (download) (annotate)
Wed Sep 12 23:55:25 2018 UTC (10 months ago) by jhr
File size: 1295 byte(s)
  merging in changes from the arith64 branch: mostly removal of the broken
  CPS checking code plus more "64BIT:" comments.
(* literal-to-num.sml
 * COPYRIGHT (c) 2017 The Fellowship of SML/NJ (http://www.smlnj.org)
 * All rights reserved.
 * Conversions from integer/word literals (which are represented as
 * arbitrary precision ints) to fixed size.
 * This structure is a hack, which should be replaced by a parameterized
 * numeric types.

signature LITERAL_TO_NUM =

    val int64  : IntInf.int -> IntInf.int * IntInf.int

    val word64 : IntInf.int -> IntInf.int * IntInf.int

    val isNegative : IntInf.int -> bool

    val repDigits : IntInf.int -> word list  (* expose representation *)

    val lowVal : IntInf.int -> int option

structure LiteralToNum : LITERAL_TO_NUM =

(* 64BIT: will go away once FLINT knows about 64-bit ints *)
    fun int64 i =
	  (IntInf.andb(IntInf.~>>(i, 0w32), 0xffffffff), IntInf.andb(i, 0xffffffff))

(* 64BIT: will go away once FLINT knows about 64-bit words *)
    fun word64 i = (IntInf.~>>(i, 0w32), IntInf.andb(i, 0xffffffff))

    fun isNegative (i : IntInf.int) = (i < 0)

	fun unBI (CoreIntInf.BI x) = x
    val repDigits = #digits o unBI o CoreIntInf.concrete
    fun lowVal i = let
	  val l = CoreIntInf.lowValue i
	    if l = CoreIntInf.neg_base_as_int then NONE else SOME l
    end (* local *)


ViewVC Help
Powered by ViewVC 1.0.0