 Timestamp:
 Oct 17, 2011, 2:08:27 PM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Deliverables/D2.2/8051indexedlabelsbranch/src/cminor/cminorInterpret.ml
r1357 r1392 28 28 Ct_stop 29 29  Ct_cont of statement*continuation 30  Ct_ind_inc of CostLabel.index*continuation 31  Ct_endblock of continuation 30 (*  Ct_endblock of continuation *) 32 31  Ct_returnto of 33 32 ident option*internal_function*Val.address*local_env*continuation … … 62 61  St_seq _ > "sequence" 63 62  St_ifthenelse (e, _, _) > "if (" ^ (string_of_expr e) ^ ")" 64  St_loop _ > "loop"63 (*  St_loop _ > "loop" 65 64  St_block _ > "block" 66  St_exit n > "exit " ^ (string_of_int n) 65  St_exit n > "exit " ^ (string_of_int n) *) 67 66  St_switch (e, _, _) > "switch (" ^ (string_of_expr e) ^ ")" 68 67  St_return None > "return" … … 74 73 "cost " ^ lbl 75 74  St_ind_0 (i, _) > "reset " ^ string_of_int i ^ " to 0" 76  St_ind_inc ( _, i) > "postincrement " ^ string_of_int i75  St_ind_inc (i, _) > "postincrement " ^ string_of_int i 77 76 78 77 let print_state = function … … 233 232 234 233 let rec callcont = function 235  Ct_cont(_,k)  Ct_endblock k  Ct_ind_inc(_,k) > callcont k234  Ct_cont(_,k) (* Ct_endblock k *) > callcont k 236 235  (Ct_stop  Ct_returnto _) as k > k 237 236 … … 245 244  St_seq(s1,s2) > 246 245 (match fdlbl (Ct_cont(s2,k)) s1 with 247 248 246 None > fdlbl k s2 247  Some(v) > Some(v) 249 248 ) 250 249  St_ifthenelse(_,s1,s2) > 251 250 (match fdlbl k s1 with 252 253 251 None > fdlbl k s2 252  Some(v) > Some(v) 254 253 ) 255  St_loop(s) > fdlbl (Ct_cont(St_loop(s),k)) s254 (*  St_loop(s) > fdlbl (Ct_cont(St_loop(s),k)) s 256 255  St_block(s) > fdlbl (Ct_endblock(k)) s 257  St_exit(_) > None 256  St_exit(_) > None *) 258 257  St_switch(_,_,_) > None 259 258  St_return(_) > None 260  St_label(l,s) > if l=lbl then Some((s,k)) else None259  St_label(l,s) when l = lbl > Some((s,k)) 261 260  St_goto(_) > None 262  St_cost (_,s)  St_ind_0(_,s)  St_ind_inc(s,_) > fdlbl k s 261  St_cost(_,s)  St_label(_,s) 262  St_ind_0(_,s)  St_ind_inc(_,s) > fdlbl k s 263 263 in match fdlbl k st with 264 264 None > assert false (*Wrong label*) … … 274 274 let eval_stmt f k sigma e m i s = match s, k with 275 275  St_skip,Ct_cont(s,k) > (State_regular(f, s, k, sigma, e, m, i),[]) 276  St_skip,Ct_endblock(k) > (State_regular(f, St_skip, k, sigma, e, m, i),[])276 (*  St_skip,Ct_endblock(k) > (State_regular(f, St_skip, k, sigma, e, m, i),[]) *) 277 277  St_skip, (Ct_returnto _ as k) > 278 278 (State_return (Val.undef,k,Mem.free m sigma,i),[]) 279  St_skip,Ct_ind_inc(ind,k) >280 CostLabel.continue_loop i ind;281 (State_regular(f, s, k, sigma, e, m, i),[])282 279  St_skip,Ct_stop > 283 280 (State_return (Val.undef,Ct_stop,Mem.free m sigma,i),[]) … … 304 301 else error "undefined conditional value." in 305 302 (State_regular(f,next_stmt,k,sigma,e,m,i),l) 306  St_loop(s),_ > (State_regular(f,s,Ct_cont((St_loop s),k),sigma,e,m,i),[])303 (*  St_loop(s),_ > (State_regular(f,s,Ct_cont((St_loop s),k),sigma,e,m,i),[]) 307 304  St_block(s),_ > (State_regular(f,s,(Ct_endblock k),sigma,e,m,i),[]) 308 305  St_exit(n),Ct_cont(s,k) > (State_regular(f,(St_exit n),k,sigma,e,m,i),[]) 309 306  St_exit(0),Ct_endblock(k) > (State_regular(f,St_skip,k,sigma,e,m,i),[]) 310 307  St_exit(n),Ct_endblock(k) > 311 (State_regular(f,(St_exit (n1)),k,sigma,e,m,i),[]) 308 (State_regular(f,(St_exit (n1)),k,sigma,e,m,i),[]) *) 312 309  St_label(_,s),_ > (State_regular(f,s,k,sigma,e,m,i),[]) 313  St_goto(lbl),_ > 310  St_goto(lbl),_ > 314 311 let (s2,k2) = findlabel lbl f.f_body (callcont k) in 315 312 (State_regular(f,s2,k2,sigma,e,m,i),[]) … … 318 315 if Val.is_int v then 319 316 try 320 let v = Val.to_int v in 321 let nb_exit = 322 if List.mem_assoc v lst then List.assoc v lst 323 else def in 324 (State_regular(f, St_exit nb_exit,k, sigma, e, m, i),l) 317 let v = Val.to_int v in 318 let lbl = 319 try 320 List.assoc v lst 321 with 322  Not_found > def in 323 let (s',k') = findlabel lbl f.f_body (callcont k) in 324 (State_regular(f, s', k', sigma, e, m, i),l) 325 325 with _ > error "int value too big." 326 326 else error "undefined switch value." … … 337 337 CostLabel.enter_loop i ind; 338 338 (State_regular(f,s,k,sigma,e,m,i), []) 339  St_ind_inc(s,ind),_ > 340 (State_regular(f,s,Ct_ind_inc(ind,k),sigma,e,m,i), []) 341  _ > error "state malformation." 339  St_ind_inc(ind,s),_ > 340 CostLabel.continue_loop i ind; 341 (State_regular(f,s,k,sigma,e,m,i), []) 342 (*  _ > error "state malformation." *) 342 343 343 344
Note: See TracChangeset
for help on using the changeset viewer.