# HG changeset patch # User Adam Chlipala # Date 1274987452 14400 # Node ID e8d68fd8ed4b691ad407fd12674f34a3b864f7f5 # Parent 79b2bcac6200ca19275dfc5a7d51535d6b4e0fc3 Consider view declarations while shaking diff -r 79b2bcac6200 -r e8d68fd8ed4b demo/crud.ur --- a/demo/crud.ur Thu May 27 10:56:52 2010 -0400 +++ b/demo/crud.ur Thu May 27 15:10:52 2010 -0400 @@ -167,7 +167,7 @@
- end + end and main () = ls <- list (); diff -r 79b2bcac6200 -r e8d68fd8ed4b src/mono_shake.sml --- a/src/mono_shake.sml Thu May 27 10:56:52 2010 -0400 +++ b/src/mono_shake.sml Thu May 27 15:10:52 2010 -0400 @@ -58,6 +58,7 @@ | ((DDatabase {expunge = n1, initialize = n2, ...}, _), (page_cs, page_es)) => (page_cs, IS.addList (page_es, [n1, n2])) | ((DTask (e1, e2), _), st) => usedVars (usedVars st e2) e1 + | ((DView (_, _, e), _), st) => usedVars st e | ((DPolicy pol, _), st) => let val e1 = case pol of diff -r 79b2bcac6200 -r e8d68fd8ed4b src/shake.sml --- a/src/shake.sml Thu May 27 10:56:52 2010 -0400 +++ b/src/shake.sml Thu May 27 15:10:52 2010 -0400 @@ -1,4 +1,4 @@ -(* Copyright (c) 2008, Adam Chlipala +(* Copyright (c) 2008-2010, Adam Chlipala * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,6 +85,12 @@ in (usedE, usedC) end + | ((DView (_, _, _, e, c), _), (usedE, usedC)) => + let + val usedC = usedVarsC usedC c + in + usedVars (usedE, usedC) e + end | ((DTask (e1, e2), _), st) => if !sliceDb then st diff -r 79b2bcac6200 -r e8d68fd8ed4b src/urweb.grm --- a/src/urweb.grm Thu May 27 10:56:52 2010 -0400 +++ b/src/urweb.grm Thu May 27 15:10:52 2010 -0400 @@ -184,6 +184,26 @@ PAnnot (_, t) => t | _ => (CWild (KType, loc), loc) +fun tnamesOf (e, _) = + case e of + EApp (e1, e2) => tnamesOf e1 @ tnamesOf e2 + | ECApp (e, c as (CName _, _)) => + let + fun isFt (e, _) = + case e of + EVar (["Basis"], "sql_from_table", _) => true + | EVar ([], "sql_from_table", _) => true + | ECApp (e, _) => isFt e + | EApp (e, _) => isFt e + | EDisjointApp e => isFt e + | _ => false + in + (if isFt e then [c] else []) @ tnamesOf e + end + | ECApp (e, _) => tnamesOf e + | EDisjointApp e => tnamesOf e + | _ => [] + %% %header (functor UrwebLrValsFn(structure Token : TOKEN)) @@ -1540,7 +1560,7 @@ end) fitem : table' ([#1 table'], #2 table') - | LBRACE LBRACE eexp RBRACE RBRACE ([], eexp) + | LBRACE LBRACE eexp RBRACE RBRACE (tnamesOf eexp, eexp) | fitem JOIN fitem ON sqlexp (let val loc = s (fitem1left, sqlexpright) diff -r 79b2bcac6200 -r e8d68fd8ed4b tests/fitem.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/fitem.ur Thu May 27 15:10:52 2010 -0400 @@ -0,0 +1,6 @@ +table t : { A : int, B : string } +table u : { A : int, C : float } + +val q : sql_query [] [T = [A = int, B = string], U = [C = option float]] [] = + (SELECT t.A, t.B, u.C + FROM {{sql_left_join (FROM t) (FROM u) (WHERE TRUE)}}) diff -r 79b2bcac6200 -r e8d68fd8ed4b tests/fitem.urp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/fitem.urp Thu May 27 15:10:52 2010 -0400 @@ -0,0 +1,1 @@ +fitem