aboutsummaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-08-18 00:18:46 -0700
committerGraydon Hoare <[email protected]>2010-08-18 00:18:46 -0700
commit9277f551d34d4891cf440316d5d10e1457310b0d (patch)
tree2481e0c9427e6953c4152866467f7ff9fe09cb98 /src/boot
parentAdded simple deadlock detection in the scheduler. (diff)
downloadrust-9277f551d34d4891cf440316d5d10e1457310b0d.tar.xz
rust-9277f551d34d4891cf440316d5d10e1457310b0d.zip
Add support for casting native types.
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/me/semant.ml3
-rw-r--r--src/boot/me/type.ml14
2 files changed, 10 insertions, 7 deletions
diff --git a/src/boot/me/semant.ml b/src/boot/me/semant.ml
index a3a8abdf..a4b02806 100644
--- a/src/boot/me/semant.ml
+++ b/src/boot/me/semant.ml
@@ -1012,7 +1012,8 @@ let type_is_unsigned_2s_complement t =
| Ast.TY_mach TY_u64
| Ast.TY_char
| Ast.TY_uint
- | Ast.TY_bool -> true
+ | Ast.TY_bool
+ | Ast.TY_native _ -> true
| _ -> false
;;
diff --git a/src/boot/me/type.ml b/src/boot/me/type.ml
index b2d5a622..3d035edc 100644
--- a/src/boot/me/type.ml
+++ b/src/boot/me/type.ml
@@ -101,11 +101,11 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
if not (is_integer (fundamental_ty actual)) then
type_error "integer" actual
in
- let demand_bool_or_char_or_integer (actual:Ast.ty) : unit =
+ let demand_bool_or_char_or_integer_or_native (actual:Ast.ty) : unit =
match fundamental_ty actual with
- Ast.TY_bool | Ast.TY_char -> ()
+ Ast.TY_bool | Ast.TY_char | Ast.TY_native _ -> ()
| ty when is_integer ty -> ()
- | _ -> type_error "bool, char, or integer" actual
+ | _ -> type_error "bool, char, integer or native" actual
in
let demand_number (actual:Ast.ty) : unit =
match fundamental_ty actual with
@@ -634,9 +634,11 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
ty
| Ast.EXPR_unary (Ast.UNOP_cast dst_ty_id, atom) ->
(* TODO: probably we want to handle more cases here *)
- demand_bool_or_char_or_integer (check_atom atom);
- let dst_ty = dst_ty_id.Common.node in
- demand_bool_or_char_or_integer dst_ty;
+ demand_bool_or_char_or_integer_or_native (check_atom atom);
+ let dst_ty =
+ Hashtbl.find cx.Semant.ctxt_all_cast_types dst_ty_id.Common.id
+ in
+ demand_bool_or_char_or_integer_or_native dst_ty;
dst_ty
in