X-Git-Url: http://git.joshuawise.com/snipe.git/blobdiff_plain/4f528370c7d70f4fd271c7ce5eee517284852940..2ab9671fde5297fc59583361f152e812e66c2d17:/trans/trans.sml diff --git a/trans/trans.sml b/trans/trans.sml index d8807f0..73968d9 100644 --- a/trans/trans.sml +++ b/trans/trans.sml @@ -129,8 +129,12 @@ struct | trans_exp env vartypes (A.ArrIndex(exp1, exp2)) = let val asubk = T.BINOP(T.ADD, trans_exp env vartypes exp1, - T.BINOP(T.MUL, trans_exp env vartypes exp2, - T.CONST(Word32.fromInt(sizeof (deref (typeof' vartypes exp1)))))) + if sizeof (deref (typeof' vartypes exp1)) = 1 + then trans_exp env vartypes exp2 + else T.BINOP(T.MUL, trans_exp env vartypes exp2, + T.CONST(Word32.fromInt(sizeof (deref (typeof' vartypes exp1)))) + ) + ) val tipo = deref (typeof' vartypes exp1) val d = if not (Flag.isset Flags.safe) @@ -160,7 +164,9 @@ struct end | trans_exp env vartypes (A.NewArr(tipo, exp)) = let - val size = T.BINOP(T.MUL, trans_exp env vartypes exp, T.CONST(Word32.fromInt(sizeof tipo))) + val size = if (sizeof tipo) = 1 + then trans_exp env vartypes exp + else T.BINOP(T.MUL, trans_exp env vartypes exp, T.CONST(Word32.fromInt(sizeof tipo))) val t1 = T.TEMP (Temp.new "allocated address") val ts = T.TEMP (Temp.new "size") in