Mercurial > urweb
diff src/monoize.sml @ 105:da760c34f5ed
Stringifying attributes
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 10 Jul 2008 15:19:06 -0400 |
parents | b1e5398a7f30 |
children | d101cb1efe55 |
line wrap: on
line diff
--- a/src/monoize.sml Thu Jul 10 15:04:32 2008 -0400 +++ b/src/monoize.sml Thu Jul 10 15:19:06 2008 -0400 @@ -79,6 +79,15 @@ val dummyExp = (L'.EPrim (Prim.Int 0), E.dummySpan) +fun attrifyExp (e, tAll as (t, loc)) = + case t of + L'.TFfi ("Basis", "string") => e + | L'.TFfi ("Basis", "int") => (L'.EFfiApp ("Basis", "attrifyInt", [e]), loc) + | L'.TFfi ("Basis", "float") => (L'.EFfiApp ("Basis", "attrifyFloat", [e]), loc) + | _ => (E.errorAt loc "Don't know how to encode attribute type"; + Print.eprefaces' [("Type", MonoPrint.p_typ MonoEnv.empty tAll)]; + dummyExp) + fun monoExp env (all as (e, loc)) = let fun poly () = @@ -140,13 +149,13 @@ val s = (L'.EPrim (Prim.String (String.concat ["<", tag])), loc) in - foldl (fn ((x, e, _), s) => + foldl (fn ((x, e, t), s) => let val xp = " " ^ lowercaseFirst x ^ "=\"" in (L'.EStrcat (s, (L'.EStrcat ((L'.EPrim (Prim.String xp), loc), - (L'.EStrcat (e, + (L'.EStrcat (attrifyExp (e, t), (L'.EPrim (Prim.String "\""), loc)), loc)), loc)), loc)