Mercurial > urweb
comparison src/cjr_print.sml @ 439:322c8620bbdf
Marshaling time to SQL
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 30 Oct 2008 15:11:37 -0400 |
parents | 1c27f03d9bd2 |
children | bb27c7efcd90 |
comparison
equal
deleted
inserted
replaced
438:1c27f03d9bd2 | 439:322c8620bbdf |
---|---|
411 datatype sql_type = | 411 datatype sql_type = |
412 Int | 412 Int |
413 | Float | 413 | Float |
414 | String | 414 | String |
415 | Bool | 415 | Bool |
416 | Time | |
416 | 417 |
417 fun p_sql_type t = | 418 fun p_sql_type t = |
418 string (case t of | 419 string (case t of |
419 Int => "uw_Basis_int" | 420 Int => "uw_Basis_int" |
420 | Float => "uw_Basis_float" | 421 | Float => "uw_Basis_float" |
421 | String => "uw_Basis_string" | 422 | String => "uw_Basis_string" |
422 | Bool => "uw_Basis_bool") | 423 | Bool => "uw_Basis_bool" |
424 | Time => "uw_Basis_time") | |
423 | 425 |
424 fun getPargs (e, _) = | 426 fun getPargs (e, _) = |
425 case e of | 427 case e of |
426 EPrim (Prim.String _) => [] | 428 EPrim (Prim.String _) => [] |
427 | EFfiApp ("Basis", "strcat", [e1, e2]) => getPargs e1 @ getPargs e2 | 429 | EFfiApp ("Basis", "strcat", [e1, e2]) => getPargs e1 @ getPargs e2 |
428 | 430 |
429 | EFfiApp ("Basis", "sqlifyInt", [e]) => [(e, Int)] | 431 | EFfiApp ("Basis", "sqlifyInt", [e]) => [(e, Int)] |
430 | EFfiApp ("Basis", "sqlifyFloat", [e]) => [(e, Float)] | 432 | EFfiApp ("Basis", "sqlifyFloat", [e]) => [(e, Float)] |
431 | EFfiApp ("Basis", "sqlifyString", [e]) => [(e, String)] | 433 | EFfiApp ("Basis", "sqlifyString", [e]) => [(e, String)] |
432 | EFfiApp ("Basis", "sqlifyBool", [e]) => [(e, Bool)] | 434 | EFfiApp ("Basis", "sqlifyBool", [e]) => [(e, Bool)] |
435 | EFfiApp ("Basis", "sqlifyTime", [e]) => [(e, Time)] | |
433 | ECase (e, _, _) => [(e, Bool)] | 436 | ECase (e, _, _) => [(e, Bool)] |
434 | 437 |
435 | _ => raise Fail "CjrPrint: getPargs" | 438 | _ => raise Fail "CjrPrint: getPargs" |
436 | 439 |
437 fun p_ensql t e = | 440 fun p_ensql t e = |
438 case t of | 441 case t of |
439 Int => box [string "uw_Basis_attrifyInt(ctx, ", e, string ")"] | 442 Int => box [string "uw_Basis_attrifyInt(ctx, ", e, string ")"] |
440 | Float => box [string "uw_Basis_attrifyFloat(ctx, ", e, string ")"] | 443 | Float => box [string "uw_Basis_attrifyFloat(ctx, ", e, string ")"] |
441 | String => e | 444 | String => e |
442 | Bool => box [string "(", e, string " ? \"TRUE\" : \"FALSE\")"] | 445 | Bool => box [string "(", e, string " ? \"TRUE\" : \"FALSE\")"] |
443 | 446 | Time => box [string "uw_Basis_sqlifyTime(ctx, ", e, string ")"] |
444 fun p_ensql_len t e = | |
445 case t of | |
446 Int => string "sizeof(uw_Basis_int)" | |
447 | Float => string "sizeof(uw_Basis_float)" | |
448 | String => box [string "strlen(", e, string ")"] | |
449 | Bool => string "sizeof(uw_Basis_bool)" | |
450 | 447 |
451 fun notLeaky env allowHeapAllocated = | 448 fun notLeaky env allowHeapAllocated = |
452 let | 449 let |
453 fun nl (t, _) = | 450 fun nl (t, _) = |
454 case t of | 451 case t of |