comparison src/jscomp.sml @ 827:497c7dbcc695

Fix variable adjustment bug in fn/case alternation
author Adam Chlipala <adamc@hcoop.net>
date Thu, 28 May 2009 13:47:05 -0400
parents 395a5d450cc0
children 20fe00fd81da
comparison
equal deleted inserted replaced
826:78504d97410b 827:497c7dbcc695
911 val (e, st) = jsE inner (e', st) 911 val (e, st) = jsE inner (e', st)
912 912
913 val len = inner + len 913 val len = inner + len
914 val normalVars = List.tabulate (normalDepth, fn n => "_" ^ Int.toString (n + len)) 914 val normalVars = List.tabulate (normalDepth, fn n => "_" ^ Int.toString (n + len))
915 val patVars = List.tabulate (depth, fn n => "d" ^ Int.toString n) 915 val patVars = List.tabulate (depth, fn n => "d" ^ Int.toString n)
916 val caseVars = ListUtil.mapi (fn (i, _) => "c" ^ Int.toString i) pes
916 in 917 in
917 (strcat (str "(function (){ var " 918 (strcat (str "(function (){ var "
918 :: str (String.concatWith "," (normalVars @ patVars) ^ ";d0=") 919 :: str (String.concatWith "," (normalVars @ patVars @ caseVars) ^ ";d0=")
919 :: e 920 :: e
920 :: str ";\nreturn (" 921 :: str ";\nreturn ("
921 :: List.revAppend (cases, 922 :: List.revAppend (cases,
922 [str "c0()) } ())"])), st) 923 [str "c0()) } ())"])), st)
923 end 924 end