@ -202,10 +202,6 @@ let get_test_operator op =
| ` Lt -> Binop . Lt
| ` Ne -> Binop . Ne
type defined_status =
| Defined of Cfg . Procdesc . t
| Called of Cfg . Procdesc . t
let is_java_native cm =
( cm . Javalib . cm_implementation = Javalib . Native )
@ -233,13 +229,18 @@ let update_init_loc cn ms loc_start =
with Not_found -> init_loc_map := ( JBasics . ClassMap . add cn loc_start ! init_loc_map )
(* * Creates a procedure description. *)
let create_procdesc source_file program linereader cfg tenv m =
let create_procdesc source_file program linereader icfg m : Cfg . Procdesc . t option =
let cfg = icfg . JContext . cfg in
let tenv = icfg . JContext . tenv in
let cn , ms = JBasics . cms_split ( Javalib . get_class_method_signature m ) in
let proc_name_java = JTransType . get_method_procname cn ms ( JTransType . get_method_kind m ) in
let proc_name = Procname . Java proc_name_java in
if JClasspath . is_model proc_name then
begin
(* do not translate the method if there is a model for it *)
JUtils . log " Skipping method with a model: %s@. " ( Procname . to_string proc_name )
JUtils . log " Skipping method with a model: %s@. " ( Procname . to_string proc_name ) ;
None
end
else
let trans_access = function
| ` Default -> PredSymb . Default
@ -247,6 +248,7 @@ let create_procdesc source_file program linereader cfg tenv m =
| ` Private -> PredSymb . Private
| ` Protected -> PredSymb . Protected in
try
let procdesc =
match m with
| Javalib . AbstractMethod am -> (* create a procdesc with empty body *)
let formals =
@ -273,9 +275,11 @@ let create_procdesc source_file program linereader cfg tenv m =
let exit_node = Cfg . Node . create cfg Location . dummy exit_kind [] procdesc in
Cfg . Node . set_succs_exn cfg start_node [ exit_node ] [ exit_node ] ;
Cfg . Procdesc . set_start_node procdesc start_node ;
Cfg . Procdesc . set_exit_node procdesc exit_node
Cfg . Procdesc . set_exit_node procdesc exit_node ;
procdesc
| Javalib . ConcreteMethod cm when is_java_native cm ->
let formals = formals_from_signature program tenv cn ms ( JTransType . get_method_kind m ) in
let formals =
formals_from_signature program tenv cn ms ( JTransType . get_method_kind m ) in
let method_annotation =
JAnnotation . translate_method proc_name_java cm . Javalib . cm_annotations in
let proc_attributes =
@ -288,7 +292,7 @@ let create_procdesc source_file program linereader cfg tenv m =
method_annotation ;
ret_type = JTransType . return_type program tenv ms ;
} in
ignore ( Cfg . Procdesc . create cfg proc_attributes )
Cfg . Procdesc . create cfg proc_attributes ;
| Javalib . ConcreteMethod cm ->
let impl = get_implementation cm in
let locals , formals = locals_formals program tenv cn impl in
@ -327,10 +331,13 @@ let create_procdesc source_file program linereader cfg tenv m =
Cfg . Procdesc . set_start_node procdesc start_node ;
Cfg . Procdesc . set_exit_node procdesc exit_node ;
Cfg . Node . add_locals_ret_declaration start_node locals ;
procdesc in
Some procdesc
with JBir . Subroutine | JBasics . Class_structure_error _ ->
L . err
L . std err
" create_procdesc raised JBir.Subroutine or JBasics.Class_structure_error on %a@. "
Procname . pp proc_name
Procname . pp proc_name ;
None
let builtin_new =
Exp . Const ( Const . Cfun ModelBuiltins . __new )