comparison src/jscomp.sml @ 850:1c2f335297b7

Fix a variable capture bug in nested JavaScript; some more list stuff
author Adam Chlipala <adamc@hcoop.net>
date Tue, 16 Jun 2009 17:52:44 -0400
parents 0f7e2cca6d9b
children ae9e22822ec5
comparison
equal deleted inserted replaced
849:e571fb150a9f 850:1c2f335297b7
978 | EJavaScript (Source _, e) => 978 | EJavaScript (Source _, e) =>
979 (foundJavaScript := true; 979 (foundJavaScript := true;
980 jsE inner (e, st)) 980 jsE inner (e, st))
981 | EJavaScript (_, e) => 981 | EJavaScript (_, e) =>
982 let 982 let
983 val locals = List.tabulate
984 (varDepth e,
985 fn i => str ("var _" ^ Int.toString (len + inner + i) ^ ";"))
986
983 val (e, st) = jsE inner (e, st) 987 val (e, st) = jsE inner (e, st)
984 in 988 in
985 foundJavaScript := true; 989 foundJavaScript := true;
986 (strcat [str "cs(function(){return ", 990 (strcat (str "cs(function(){"
987 compact inner e, 991 :: locals
988 str "})"], 992 @ [str "return ",
993 compact inner e,
994 str "})"]),
989 st) 995 st)
990 end 996 end
991 997
992 | EClosure _ => unsupported "EClosure" 998 | EClosure _ => unsupported "EClosure"
993 | EQuery _ => unsupported "Query" 999 | EQuery _ => unsupported "Query"