From cb04275afa8c72a10ca5893de27dc0228d29ea8c Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 1 Jul 2010 09:35:48 -0700 Subject: [PATCH] Add machine-dependent 'float' type. --- doc/rust.texi | 22 ++++++++++++++++++---- src/boot/fe/lexer.mll | 1 + src/boot/fe/token.ml | 2 ++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/doc/rust.texi b/doc/rust.texi index f9d6e3e04ff..47ee7cfbe56 100644 --- a/doc/rust.texi +++ b/doc/rust.texi @@ -647,9 +647,10 @@ The keywords are: @tab @code{type} @tab @code{true} @tab @code{false} -@item @code{any} -@tab @code{int} +@tab @code{any} +@item @code{int} @tab @code{uint} +@tab @code{float} @tab @code{char} @tab @code{bool} @item @code{u8} @@ -1750,6 +1751,7 @@ Rust; they cannot be used as user-defined identifiers in any context. * Ref.Type.Any:: An open sum of every possible type. * Ref.Type.Mach:: Machine-level types. * Ref.Type.Int:: The machine-dependent integer types. +* Ref.Type.Float:: The machine-dependent floating-point types. * Ref.Type.Prim:: Primitive types. * Ref.Type.Big:: The arbitrary-precision integer type. * Ref.Type.Text:: Strings and characters. @@ -1842,9 +1844,21 @@ The Rust type @code{int}@footnote{A Rust @code{int} is analogous to a C99 target-machine-dependent size. Its size, in bits, is equal to the size of the rust type @code{uint} on the same target machine. +@node Ref.Type.Float +@subsection Ref.Type.Float + +The Rust type @code{float} is a machine-specific type equal to one of the +supported Rust floating-point machine types (@code{f32} or @code{f64}). It is +the largest floating-point type that is directly supported by hardware on the +target machine, or if the target machine has no floating-point hardware +support, the largest floating-point type supported by the software +floating-point library used to support the other floating-point machine types. + +Note that due to the preference for hardware-supported floating point, the +type @code{float} may not be equal to the largest @emph{supported} +floating-point type. -@page @node Ref.Type.Prim @subsection Ref.Type.Prim @@ -1863,7 +1877,7 @@ The boolean type @code{bool} with values @code{true} and @code{false}. @item The machine types. @item -The machine-dependent integer types. +The machine-dependent integer and floating-point types. @end itemize diff --git a/src/boot/fe/lexer.mll b/src/boot/fe/lexer.mll index 4e4e845cfb9..6430821de15 100644 --- a/src/boot/fe/lexer.mll +++ b/src/boot/fe/lexer.mll @@ -79,6 +79,7 @@ ("int", INT); ("uint", UINT); + ("float", FLOAT); ("char", CHAR); ("str", STR); diff --git a/src/boot/fe/token.ml b/src/boot/fe/token.ml index 636e1ac2179..446e5262a70 100644 --- a/src/boot/fe/token.ml +++ b/src/boot/fe/token.ml @@ -118,6 +118,7 @@ type token = | BOOL | INT | UINT + | FLOAT | CHAR | STR | MACH of Common.ty_mach @@ -267,6 +268,7 @@ let rec string_of_tok t = | BOOL -> "bool" | INT -> "int" | UINT -> "uint" + | FLOAT -> "float" | CHAR -> "char" | STR -> "str" | MACH m -> Common.string_of_ty_mach m