]> Joshua Wise's Git repositories - snipe.git/blobdiff - trans/trans.sml
Fix up for MLton build.
[snipe.git] / trans / trans.sml
index d8807f03def58f35ee4ce85c7e29d368b7175098..ec66fd5f4507cb8df767ae89babaacbb572d5e72 100644 (file)
@@ -97,7 +97,9 @@ struct
       fun trans_exp env vartypes (A.Var(id)) =
         (* after type-checking, id must be declared; do not guard lookup *)
             T.TEMP (Symbol.look' env id)
+        | trans_exp env vartypes (A.Cast (ty, e)) = trans_exp env vartypes e (* lurrr *)
         | trans_exp env vartypes (A.ConstExp c) = T.CONST(c)
+        | trans_exp env vartypes (A.StringExp s) = T.STRING(Stringref.new s)
         | trans_exp env vartypes (A.OpExp(oper, [e1, e2])) =
             T.BINOP(trans_oper oper, trans_exp env vartypes e1, trans_exp env vartypes e2)
         | trans_exp env vartypes (A.OpExp(oper, [e])) =
@@ -129,8 +131,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 +166,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
This page took 0.026899 seconds and 4 git commands to generate.