Ignore:
Timestamp:
Mar 7, 2011, 11:10:57 AM (10 years ago)
Author:
ayache
Message:

Hex output not too long for mcu anymore. Readable output added.

File:
1 edited

Legend:

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

    r619 r640  
    4747
    4848let extension = function
    49   | ASM      -> "s"
    50   | Clight   -> "c"
    51   | language -> to_string language
     49  | ASM      -> ["s" ; "hex"]
     50  | Clight   -> ["c"]
     51  | language -> [to_string language]
    5252
    5353let parse = function
     
    200200let instrument costs_mapping = function
    201201  | AstClight p ->
    202     let (p', cost_incr) = ClightAnnotator.instrument p costs_mapping in
    203     (AstClight p', cost_incr)
     202    let (p', cost_id, cost_incr) = ClightAnnotator.instrument p costs_mapping in
     203    (AstClight p', cost_id, cost_incr)
    204204  | AstCminor p ->
    205     let (p', cost_incr) = CminorAnnotator.instrument p costs_mapping in
    206     (AstCminor p', cost_incr)
     205    let (p', cost_id, cost_incr) = CminorAnnotator.instrument p costs_mapping in
     206    (AstCminor p', cost_id, cost_incr)
    207207  | p ->
    208208    Error.warning "during instrumentation"
     
    210210         "Instrumentation is not implemented for source language `%s'."
    211211         (to_string (language_of_ast p)));
    212     (p, "")
     212    (p, "", "")
    213213
    214214let annotate input_ast final =
     
    218218let string_output = function
    219219  | AstClight p ->
    220     ClightPrinter.print_program p
     220    [ClightPrinter.print_program p]
    221221  | AstCminor p ->
    222     CminorPrinter.print_program p
     222    [CminorPrinter.print_program p]
    223223  | AstRTLabs p ->
    224     RTLabsPrinter.print_program p
     224    [RTLabsPrinter.print_program p]
    225225  | AstRTL p ->
    226     RTLPrinter.print_program p
     226    [RTLPrinter.print_program p]
    227227  | AstERTL p ->
    228     ERTLPrinter.print_program p
     228    [ERTLPrinter.print_program p]
    229229  | AstLTL p ->
    230     LTLPrinter.print_program p
     230    [LTLPrinter.print_program p]
    231231  | AstLIN p ->
    232     LINPrinter.print_program p
     232    [LINPrinter.print_program p]
    233233  | AstASM p ->
    234     ASMPrinter.print_program p
     234    [Pretty.print_program p ; ASMPrinter.print_program p]
    235235
    236236let save exact_output filename ast =
     
    240240      try Filename.chop_extension filename
    241241      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
    247   let cout = open_out output_filename in
    248   output_string cout (string_output ast);
    249   flush cout;
    250   close_out cout
    251 
    252 let save_cost_incr filename cost_incr =
     242  let ext_filenames =
     243    List.map (fun ext -> ext_chopped_filename ^ "." ^ ext)
     244      (extension (language_of_ast ast)) in
     245  let output_filenames =
     246    if exact_output then ext_filenames
     247    else List.map Misc.SysExt.alternative ext_filenames in
     248  let output_strings = string_output ast in
     249  let f filename s =
     250    let cout = open_out filename in
     251    output_string cout s;
     252    flush cout;
     253    close_out cout in
     254  List.iter2 f output_filenames output_strings
     255
     256let save_cost filename cost_id cost_incr =
    253257  let cout = open_out (filename ^ ".cerco") in
    254   output_string cout cost_incr;
     258  output_string cout (cost_id ^ "\n");
     259  output_string cout (cost_incr ^ "\n");
    255260  flush cout;
    256261  close_out cout
Note: See TracChangeset for help on using the changeset viewer.