comparison src/prepare.sml @ 486:8e055bbbd28b

Remove some allocation
author Adam Chlipala <adamc@hcoop.net>
date Sun, 09 Nov 2008 18:19:47 -0500
parents 4efab85405be
children 0fd65c50e0e2
comparison
equal deleted inserted replaced
485:3ce20b0b6914 486:8e055bbbd28b
174 in 174 in
175 ((ELet (x, t, e1, e2), loc), sns) 175 ((ELet (x, t, e1, e2), loc), sns)
176 end 176 end
177 177
178 | EQuery {exps, tables, rnum, state, query, body, initial, ...} => 178 | EQuery {exps, tables, rnum, state, query, body, initial, ...} =>
179 (case prepString (query, [], 0) of 179 let
180 NONE => (e, sns) 180 val (body, sns) = prepExp (body, sns)
181 | SOME (ss, n) => 181 in
182 ((EQuery {exps = exps, tables = tables, rnum = rnum, 182 case prepString (query, [], 0) of
183 state = state, query = query, body = body, 183 NONE =>
184 initial = initial, prepared = SOME (#2 sns)}, loc), 184 ((EQuery {exps = exps, tables = tables, rnum = rnum,
185 ((String.concat (rev ss), n) :: #1 sns, #2 sns + 1))) 185 state = state, query = query, body = body,
186 initial = initial, prepared = SOME (#2 sns)}, loc),
187 sns)
188 | SOME (ss, n) =>
189 ((EQuery {exps = exps, tables = tables, rnum = rnum,
190 state = state, query = query, body = body,
191 initial = initial, prepared = SOME (#2 sns)}, loc),
192 ((String.concat (rev ss), n) :: #1 sns, #2 sns + 1))
193 end
186 194
187 | EDml {dml, ...} => 195 | EDml {dml, ...} =>
188 (case prepString (dml, [], 0) of 196 (case prepString (dml, [], 0) of
189 NONE => (e, sns) 197 NONE => (e, sns)
190 | SOME (ss, n) => 198 | SOME (ss, n) =>
191 ((EDml {dml = dml, prepared = SOME (#2 sns)}, loc), 199 ((EDml {dml = dml, prepared = SOME (#2 sns)}, loc),
192 ((String.concat (rev ss), n) :: #1 sns, #2 sns + 1))) 200 ((String.concat (rev ss), n) :: #1 sns, #2 sns + 1)))
193 201
194 | ENextval {seq, ...} => 202 | ENextval {seq, ...} =>
195 let 203 let
196 val s = (EFfiApp ("Basis", "strcat", [seq, (EPrim (Prim.String "')"), loc)]), loc) 204 val s = case seq of
197 val s = (EFfiApp ("Basis", "strcat", [(EPrim (Prim.String "SELECT NEXTVAL('"), loc), s]), loc) 205 (EPrim (Prim.String s), loc) =>
206 (EPrim (Prim.String ("SELECT NEXTVAL('" ^ s ^ "')")), loc)
207 | _ =>
208 let
209 val s' = (EFfiApp ("Basis", "strcat", [seq, (EPrim (Prim.String "')"), loc)]), loc)
210 in
211 (EFfiApp ("Basis", "strcat", [(EPrim (Prim.String "SELECT NEXTVAL('"), loc), s']), loc)
212 end
198 in 213 in
199 case prepString (s, [], 0) of 214 case prepString (s, [], 0) of
200 NONE => (e, sns) 215 NONE => (e, sns)
201 | SOME (ss, n) => 216 | SOME (ss, n) =>
202 ((ENextval {seq = seq, prepared = SOME (#2 sns)}, loc), 217 ((ENextval {seq = seq, prepared = SOME (#2 sns)}, loc),