|
27 | 27 |
|
28 | 28 | (* chutil *) |
29 | 29 | open CHFormatStringParser |
| 30 | +open CHTraceResult |
30 | 31 | open CHUtil |
31 | 32 |
|
32 | 33 | (* bchlib *) |
@@ -497,34 +498,42 @@ let rec get_arm_struct_field_locations |
497 | 498 | (parameter_location_t list * arm_argument_state_t) = |
498 | 499 | let fieldstate = aa_state in |
499 | 500 | let bftype = resolve_type (get_struct_field_type bfinfo) in |
500 | | - let (bfsize, bfoffset) = |
501 | | - match (get_struct_field_size bfinfo, |
502 | | - get_struct_field_offset bfinfo) with |
503 | | - | (Some s, Some o) -> (s, o) |
504 | | - | _ -> |
| 501 | + match bftype with |
| 502 | + | Error e -> |
| 503 | + raise |
| 504 | + (BCH_failure |
| 505 | + (LBLOCK [ |
| 506 | + STR "Problem with type resolution: "; |
| 507 | + STR (String.concat "; " e)])) |
| 508 | + | Ok bftype -> |
| 509 | + let (bfsize, bfoffset) = |
| 510 | + match (get_struct_field_size bfinfo, |
| 511 | + get_struct_field_offset bfinfo) with |
| 512 | + | (Some s, Some o) -> (s, o) |
| 513 | + | _ -> |
| 514 | + raise |
| 515 | + (BCH_failure |
| 516 | + (LBLOCK [ |
| 517 | + STR "get_arm_struct_field_locations: "; |
| 518 | + STR "no layout provided: "; |
| 519 | + fieldinfo_to_pretty bfinfo])) in |
| 520 | + if (is_int bftype || is_pointer bftype) && bfsize = 4 then |
| 521 | + let (loc, naas) = |
| 522 | + get_int_paramloc_next_state bfsize bftype fieldstate in |
| 523 | + ([loc], naas) |
| 524 | + else if is_int bftype && bfsize < 4 then |
| 525 | + let (loc, naas) = |
| 526 | + get_int_paramlocpart_next_state bfsize bftype bfoffset fieldstate in |
| 527 | + ([loc], naas) |
| 528 | + else if is_array_type bftype then |
| 529 | + get_arm_array_locations bfsize bftype bfoffset fieldstate |
| 530 | + else |
505 | 531 | raise |
506 | 532 | (BCH_failure |
507 | 533 | (LBLOCK [ |
508 | 534 | STR "get_arm_struct_field_locations: "; |
509 | | - STR "no layout provided: "; |
510 | | - fieldinfo_to_pretty bfinfo])) in |
511 | | - if (is_int bftype || is_pointer bftype) && bfsize = 4 then |
512 | | - let (loc, naas) = |
513 | | - get_int_paramloc_next_state bfsize bftype fieldstate in |
514 | | - ([loc], naas) |
515 | | - else if is_int bftype && bfsize < 4 then |
516 | | - let (loc, naas) = |
517 | | - get_int_paramlocpart_next_state bfsize bftype bfoffset fieldstate in |
518 | | - ([loc], naas) |
519 | | - else if is_array_type bftype then |
520 | | - get_arm_array_locations bfsize bftype bfoffset fieldstate |
521 | | - else |
522 | | - raise |
523 | | - (BCH_failure |
524 | | - (LBLOCK [ |
525 | | - STR "get_arm_struct_field_locations: "; |
526 | | - STR "not yet implemented: "; |
527 | | - btype_to_pretty bftype])) |
| 535 | + STR "not yet implemented: "; |
| 536 | + btype_to_pretty bftype])) |
528 | 537 |
|
529 | 538 |
|
530 | 539 | and get_arm_array_locations |
@@ -572,27 +581,36 @@ let arm_vfp_params (funargs: bfunarg_t list): fts_parameter_t list = |
572 | 581 | let (_, _, params) = |
573 | 582 | List.fold_left |
574 | 583 | (fun (index, aa_state, params) (name, btype, _) -> |
575 | | - let btype = resolve_type btype in |
576 | | - let tysize = size_of_btype btype in |
577 | | - (* assume no packing at the argument top level *) |
578 | | - let size = if tysize < 4 then 4 else tysize in |
579 | | - let (param, new_state) = |
580 | | - if (is_int btype || is_pointer btype || is_enum btype) && size = 4 then |
581 | | - get_arm_int_param_next_state size name btype aa_state index |
582 | | - else if (is_int btype || is_pointer btype) then |
583 | | - get_long_int_param_next_state size name btype aa_state index |
584 | | - else if is_float btype then |
585 | | - get_float_param_next_state size name btype aa_state index |
586 | | - else if (is_struct_type btype ) |
587 | | - && (get_struct_type_compinfo btype).bcstruct then |
588 | | - get_arm_struct_param_next_state size name btype aa_state index |
589 | | - else |
590 | | - raise |
591 | | - (BCH_failure |
592 | | - (LBLOCK [ |
593 | | - STR "vfp_params: Not yet implemented; "; |
594 | | - btype_to_pretty btype])) in |
595 | | - (index + 1, new_state, param :: params)) |
| 584 | + let btype_r = resolve_type btype in |
| 585 | + let tysize_r = tbind size_of_btype btype_r in |
| 586 | + match btype_r, tysize_r with |
| 587 | + | Error e, _ |
| 588 | + | _, Error e -> |
| 589 | + raise |
| 590 | + (BCH_failure |
| 591 | + (LBLOCK [ |
| 592 | + STR "Problem with type resolution: "; |
| 593 | + STR (String.concat "; " e)])) |
| 594 | + | Ok btype, Ok tysize -> |
| 595 | + (* assume no packing at the argument top level *) |
| 596 | + let size = if tysize < 4 then 4 else tysize in |
| 597 | + let (param, new_state) = |
| 598 | + if (is_int btype || is_pointer btype || is_enum btype) && size = 4 then |
| 599 | + get_arm_int_param_next_state size name btype aa_state index |
| 600 | + else if (is_int btype || is_pointer btype) then |
| 601 | + get_long_int_param_next_state size name btype aa_state index |
| 602 | + else if is_float btype then |
| 603 | + get_float_param_next_state size name btype aa_state index |
| 604 | + else if (is_struct_type btype ) |
| 605 | + && (get_struct_type_compinfo btype).bcstruct then |
| 606 | + get_arm_struct_param_next_state size name btype aa_state index |
| 607 | + else |
| 608 | + raise |
| 609 | + (BCH_failure |
| 610 | + (LBLOCK [ |
| 611 | + STR "vfp_params: Not yet implemented; "; |
| 612 | + btype_to_pretty btype])) in |
| 613 | + (index + 1, new_state, param :: params)) |
596 | 614 | (1, aas_start_state, []) funargs in |
597 | 615 | params |
598 | 616 |
|
@@ -684,17 +702,22 @@ let get_arm_format_spec_parameters |
684 | 702 | promote_int ftype |
685 | 703 | else |
686 | 704 | ftype in |
687 | | - let size = size_of_btype ftype in |
| 705 | + let size_r = size_of_btype ftype in |
688 | 706 | let name = "vararg_" ^ (string_of_int varargindex) in |
689 | 707 | let (param, new_state) = |
690 | | - match size with |
691 | | - | 4 -> get_arm_int_param_next_state size name ftype aas nxtindex |
692 | | - | 8 -> get_long_int_param_next_state size name ftype aas varargindex |
693 | | - | _ -> |
| 708 | + match size_r with |
| 709 | + | Ok 4 -> get_arm_int_param_next_state 4 name ftype aas nxtindex |
| 710 | + | Ok 8 -> get_long_int_param_next_state 8 name ftype aas varargindex |
| 711 | + | Ok size -> |
| 712 | + raise |
| 713 | + (BCH_failure |
| 714 | + (LBLOCK [ |
| 715 | + STR "Var-arg size: "; INT size; STR " not supported"])) |
| 716 | + | Error e -> |
694 | 717 | raise |
695 | 718 | (BCH_failure |
696 | 719 | (LBLOCK [ |
697 | | - STR "Var-arg size: "; INT size; STR " not supported"])) in |
| 720 | + STR "Error in var-args: "; STR (String.concat "; " e)])) in |
698 | 721 | (new_state, param :: accpars, varargindex + 1, nxtindex + 1)) |
699 | 722 | (fmtaas, [], 1, nextindex) argspecs in |
700 | 723 | pars |
0 commit comments