Ignore:
Timestamp:
Mar 2, 2011, 3:27:41 PM (9 years ago)
Author:
ayache
Message:

Update of D2.2 from Paris.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/languages.ml

    r486 r619  
    199199(* FIXME *)
    200200let instrument costs_mapping = function
    201   | AstClight p ->
    202     AstClight (ClightAnnotator.instrument p costs_mapping)
     201  | AstClight p ->
     202    let (p', cost_incr) = ClightAnnotator.instrument p costs_mapping in
     203    (AstClight p', cost_incr)
    203204  | AstCminor p ->
    204     AstCminor (CminorAnnotator.instrument p costs_mapping)
     205    let (p', cost_incr) = CminorAnnotator.instrument p costs_mapping in
     206    (AstCminor p', cost_incr)
    205207  | p ->
    206208    Error.warning "during instrumentation"
     
    208210         "Instrumentation is not implemented for source language `%s'."
    209211         (to_string (language_of_ast p)));
    210     p
     212    (p, "")
    211213
    212214let annotate input_ast final =
     
    232234    ASMPrinter.print_program p
    233235
    234 let save filename ast =
    235   let output_filename =
    236     Misc.SysExt.alternative
    237       (Filename.chop_extension filename
    238        ^ "." ^ extension (language_of_ast ast))
    239   in
     236let save exact_output filename ast =
     237  let ext_chopped_filename =
     238    if exact_output then filename
     239    else
     240      try Filename.chop_extension filename
     241      with Invalid_argument ("Filename.chop_extension") -> filename in
     242  let ext_filename =
     243    ext_chopped_filename ^ "." ^ extension (language_of_ast ast) in
     244  let output_filename =
     245    if exact_output then ext_filename
     246    else Misc.SysExt.alternative ext_filename in
    240247  let cout = open_out output_filename in
    241248  output_string cout (string_output ast);
     
    243250  close_out cout
    244251
    245 let interpret = function
     252let save_cost_incr filename cost_incr =
     253  let cout = open_out (filename ^ ".cerco") in
     254  output_string cout cost_incr;
     255  flush cout;
     256  close_out cout
     257
     258let interpret print_result = function
    246259  | AstClight p ->
    247     ClightInterpret.interpret false p
     260    ClightInterpret.interpret print_result p
    248261  | AstCminor p ->
    249     CminorInterpret.interpret false
     262    CminorInterpret.interpret print_result
    250263  | AstRTLabs p ->
    251     RTLabsInterpret.interpret p
     264    RTLabsInterpret.interpret print_result p
    252265  | AstRTL p ->
    253     RTLInterpret.interpret p
     266    RTLInterpret.interpret print_result p
    254267  | AstERTL p ->
    255     ERTLInterpret.interpret p
     268    ERTLInterpret.interpret print_result p
    256269  | AstLTL p ->
    257     LTLInterpret.interpret p
     270    LTLInterpret.interpret print_result p
    258271  | AstLIN p ->
    259     LINInterpret.interpret p
     272    LINInterpret.interpret print_result p
    260273  | AstASM p ->
    261     ASMInterpret.interpret p
     274    ASMInterpret.interpret print_result p
Note: See TracChangeset for help on using the changeset viewer.