Make record extension more concise.

This commit is contained in:
evancz 2013-01-30 03:56:21 -08:00
parent d0dad209a4
commit ea8ff3835e

View file

@ -182,9 +182,7 @@ recordToJS e cmds =
, ret "r" ]) ++ "()"
addField (x,e) = ((++add) . assign "v") `liftM` toJS' e
where add = concat [ "\nif ('", x, "' in r) {"
, "\n r.", x, " = [v].concat(r.", x, ");"
, "\n} else { r.", x, " = [v]; }" ]
where add = concat [ "\n r.", x, " = '", x, "' in r ? [v].concat(r.", x, ") : [v];" ]
setField (x,e) = do
let rx = "r." ++ x
set <- globalAssign (rx ++ "[0]") `liftM` toJS' e