# HG changeset patch # User Adam Chlipala # Date 1230844302 18000 # Node ID a8be5a2068a539e46d89f4581ef973e16cbba277 # Parent 8f8771f32909c1a37b1321885ce95c074bb00c39 Injecting strings and bools diff -r 8f8771f32909 -r a8be5a2068a5 src/jscomp.sml --- a/src/jscomp.sml Thu Jan 01 15:59:02 2009 -0500 +++ b/src/jscomp.sml Thu Jan 01 16:11:42 2009 -0500 @@ -162,10 +162,24 @@ (EFfiApp ("Basis", "htmlifyInt", [e]), loc)] | TRecord [] => str loc "null" - | TFfi ("Basis", "string") => e + | TFfi ("Basis", "string") => (EFfiApp ("Basis", "jsifyString", [e]), loc) | TFfi ("Basis", "int") => (EFfiApp ("Basis", "htmlifyInt", [e]), loc) | TFfi ("Basis", "float") => (EFfiApp ("Basis", "htmlifyFloat", [e]), loc) + | TFfi ("Basis", "bool") => (ECase (e, + [((PCon (Enum, PConFfi {mod = "Basis", + datatyp = "bool", + con = "True", + arg = NONE}, NONE), loc), + str loc "true"), + ((PCon (Enum, PConFfi {mod = "Basis", + datatyp = "bool", + con = "False", + arg = NONE}, NONE), loc), + str loc "false")], + {disc = (TFfi ("Basis", "bool"), loc), + result = (TFfi ("Basis", "string"), loc)}), loc) + | _ => (EM.errorAt loc "Don't know how to embed type in JavaScript"; Print.prefaces "Can't embed" [("t", MonoPrint.p_typ MonoEnv.empty t)]; str loc "ERROR") diff -r 8f8771f32909 -r a8be5a2068a5 tests/jsinj.ur --- a/tests/jsinj.ur Thu Jan 01 15:59:02 2009 -0500 +++ b/tests/jsinj.ur Thu Jan 01 16:11:42 2009 -0500 @@ -5,6 +5,8 @@ cookie int : int cookie float : float +cookie string : string +cookie bool : bool fun main () : transaction page = n <- getCookie int; @@ -15,10 +17,24 @@ f <- return (getOpt f 1.23); sf <- source 4.56; + s <- getCookie string; + s <- return (getOpt s "Hi"); + ss <- source "Bye"; + + b <- getCookie bool; + b <- return (getOpt b True); + sb <- source False; + return {[n]}}/> CHANGE
{[f]}}/> CHANGE
+ + {[s]}}/> + CHANGE
+ + {[b]}}/> + CHANGE