From 29987b56e1dafff4a850eef4e668a364340fc59b Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 5 Aug 2010 10:04:11 -0700 Subject: Move 'as' precedence up to just above relational; support indexing str and vec by all integral types. Closes #94. --- src/boot/me/trans.ml | 3 ++- src/boot/me/type.ml | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/boot/me') diff --git a/src/boot/me/trans.ml b/src/boot/me/trans.ml index f2bb2287..f54a5d65 100644 --- a/src/boot/me/trans.ml +++ b/src/boot/me/trans.ml @@ -914,7 +914,8 @@ let trans_visitor let atop = trans_atom at in let unit_sz = ty_sz_in_current_frame ty in let idx = next_vreg_cell word_sty in - emit (Il.binary Il.UMUL idx atop unit_sz); + mov idx atop; + emit (Il.binary Il.UMUL idx (Il.Cell idx) unit_sz); let elt_mem = trans_bounds_check (deref cell) (Il.Cell idx) in (Il.Mem (elt_mem, referent_type abi ty), ty) in diff --git a/src/boot/me/type.ml b/src/boot/me/type.ml index 787855f0..23210ea1 100644 --- a/src/boot/me/type.ml +++ b/src/boot/me/type.ml @@ -380,19 +380,20 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) = sprintf_itype () | `Type (Ast.TY_vec ty_vec), Ast.COMP_atom atom -> - demand Ast.TY_int (check_atom atom); + demand_integer (check_atom atom); LTYPE_mono ty_vec | `Type (Ast.TY_vec _), _ -> - Common.err None "the vector type '%a' must be indexed via an int" + Common.err None + "the vector type '%a' must be indexed by an integral type" sprintf_itype () | `Type Ast.TY_str, Ast.COMP_atom atom -> - demand Ast.TY_int (check_atom atom); + demand_integer (check_atom atom); LTYPE_mono (Ast.TY_mach Common.TY_u8) | `Type Ast.TY_str, _ -> - Common.err None "strings must be indexed via an int" + Common.err None "strings must be indexed by an integral type" | `Type (Ast.TY_box ty_box), Ast.COMP_deref -> LTYPE_mono ty_box -- cgit v1.2.3