Changeset 194
- Timestamp:
- 10/20/09 16:44:00 (5 weeks ago)
- Files:
-
- 1 modified
-
trunk/tools/log2sqlite/log2sqlite_optim.ml (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/log2sqlite/log2sqlite_optim.ml
r191 r194 5 5 open Sqlite3 6 6 open Sqlite3.Rc 7 7 open Str 8 open List 9 10 exception BadLocation of string 8 11 let filename = ref None 9 12 … … 13 16 14 17 let refs_num = ref 0 18 19 let conf_opt_order = ref 0 15 20 16 21 let anonymous s = … … 70 75 value, refId) 71 76 values("^quote_ref_loc^","^quote_kind^","^quote_keyLoc^","^quote_bool_val^","^string_of_int(!refs_num)^");" in 77 72 78 exec db insert_q; 73 79 () … … 79 85 List.iter (insert_keys db loc_str) keys; 80 86 () 87 88 89 let refLoc_token refLocation= 90 match refLocation with 91 Location(file_path, line, col) -> 92 let split_path = Str.split (regexp "/") file_path in 93 let file_name = nth split_path (length split_path - 1) in 94 let tmp_str = "\""^file_name^"\", "^string_of_int(line)^", 95 "^string_of_int(col) in 96 (match string_match (regexp ".*c$") file_name 0 with 97 true -> "\"Regular\", "^tmp_str 98 | false -> "\"Header\", "^tmp_str) 81 99 82 100 let insert_new_ref db kind location name defLoc use_cond movb mova convb … … 87 105 let conva_field = conv_conva conva in 88 106 let insert_update = 89 "INSERT INTO ref(id, kind, name, refLoc, defLoc, useCond, movableBefore, 107 "INSERT INTO ref(id, kind, name, refLoc, fileKind, fileName, lineNum, 108 colNum, defLoc, useCond, movableBefore, 90 109 convertibleBefore, convertibleAfter) values( 91 110 "^string_of_int(!refs_num)^",\" "^ kind_field 92 ^"\",\""^name^"\",\""^conv_location location^"\",\""^conv_defLoc 111 ^"\",\""^name^"\",\""^conv_location location^"\", "^refLoc_token 112 location^" , \""^conv_defLoc 93 113 defLoc^"\",\""^ conv_use_cond 94 114 use_cond^"\",\""^movb_field^"\",\""^convb_field^"\",\""^conva_field^"\");" 95 115 in 96 refs_num := !refs_num + 1; 97 insert_ref:=!insert_ref^insert_update 98 116 insert_ref:=!insert_ref^insert_update; 117 refs_num := !refs_num + 1 99 118 (**conv_mova db mova location**) 100 119 … … 102 121 let loc = "\""^conv_location location^"\"" in 103 122 let confOpt = "\""^configOption^"\"" in 104 let insert_q = "INSERT INTO "^table^"(refLocation, configOption, refId) values 105 ("^loc^","^confOpt^", "^string_of_int(!refs_num)^");" in 123 let insert_q = "INSERT INTO "^table^"(refLocation, configOption, 124 confOpt_order, refId) values 125 ("^loc^","^confOpt^", "^string_of_int(!conf_opt_order)^", "^string_of_int(!refs_num)^");" in 126 conf_opt_order := !conf_opt_order + 1; 106 127 exec db insert_q; 107 128 () 108 129 130 131 let re_init_conf_opt_order = 132 conf_opt_order := 0 109 133 110 134 let insert_defconfOpts db location def_copt = 111 135 match def_copt with 112 Some(ConfOpt(c)) -> List.iter (insert_confOpts db location "defConfOpts")136 Some(ConfOpt(c)) -> re_init_conf_opt_order; List.iter (insert_confOpts db location "defConfOpts") 113 137 c; 114 138 () … … 117 141 let insert_uconfOpts db location use_copt = 118 142 match use_copt with 119 Some(ConfOpt(c)) -> List.iter (insert_confOpts db location "usageConfOpts")143 Some(ConfOpt(c)) -> re_init_conf_opt_order; List.iter (insert_confOpts db location "usageConfOpts") 120 144 c; 121 145 () … … 150 174 match x with 151 175 | Log(file_list) -> 152 Printf.printf "NEW LOG ";153 176 List.iter (conv_file db) file_list 154 177 … … 176 199 let references = 177 200 exec db "CREATE TABLE IF NOT EXISTS ref (id INTEGER PRIMARY KEY, 178 kind TEXT, name TEXT, refLoc TEXT, defLoc TEXT, useCond TEXT, 201 kind TEXT, name TEXT, refLoc TEXT, fileKind TEXT, fileName TEXT, 202 lineNum INTEGER, colNum INTEGER, defLoc TEXT, useCond TEXT, 179 203 movableBefore BOOLEAN, convertibleBefore BOOLEAN, 180 204 convertibleAfter BOOLEAN); " in … … 183 207 value BOOL, refId INTEGER); " in 184 208 let usageConfOpts = exec db "CREATE TABLE IF NOT EXISTS usageConfOpts ( 185 id INTEGER PRIMARY KEY 186 ASC, refLocation TEXT, configOption TEXT, refId INTEGER); " in209 id INTEGER PRIMARY KEY ASC, refLocation TEXT, configOption TEXT, 210 confOpt_order INTEGER, refId INTEGER); " in 187 211 let defConfOpts = exec db "CREATE TABLE IF NOT EXISTS defConfOpts ( id 188 212 INTEGER PRIMARY KEY 189 ASC, refLocation TEXT, configOption TEXT, refId INTEGER); " in213 ASC, refLocation TEXT, configOption TEXT, confOpt_order INTEGER, refId INTEGER); " in 190 214 Printf.printf "Checking creations\n"; 191 215 creation_check references afterKeys usageConfOpts defConfOpts;
