cprover
java_bytecode_convert_method.cpp File Reference

JAVA Bytecode Language Conversion. More...

#include "bytecode_info.h"
#include "java_bytecode_convert_method.h"
#include "java_bytecode_convert_method_class.h"
#include "java_static_initializers.h"
#include "java_string_library_preprocess.h"
#include "java_string_literal_expr.h"
#include "java_types.h"
#include "java_utils.h"
#include "pattern.h"
#include "remove_exceptions.h"
#include <util/arith_tools.h>
#include <util/c_types.h>
#include <util/expr_initializer.h>
#include <util/ieee_float.h>
#include <util/invariant.h>
#include <util/namespace.h>
#include <util/prefix.h>
#include <util/simplify_expr.h>
#include <util/std_expr.h>
#include <util/string2int.h>
#include <util/threeval.h>
#include <goto-programs/cfg.h>
#include <goto-programs/class_hierarchy.h>
#include <goto-programs/remove_returns.h>
#include <goto-programs/resolve_inherited_component.h>
#include <analyses/cfg_dominators.h>
#include <analyses/uncaught_exceptions_analysis.h>
#include <algorithm>
#include <functional>
#include <limits>
#include <regex>
#include <unordered_set>
+ Include dependency graph for java_bytecode_convert_method.cpp:

Go to the source code of this file.

Functions

static void assign_parameter_names (java_method_typet &ftype, const irep_idt &name_prefix, symbol_table_baset &symbol_table)
 Iterates through the parameters of the function type ftype, finds a new new name for each parameter and renames them in ftype.parameters() as well as in the symbol_table. More...
 
static bool is_constructor (const irep_idt &method_name)
 
java_method_typet member_type_lazy (const std::string &descriptor, const optionalt< std::string > &signature, const std::string &class_name, const std::string &method_name, message_handlert &message_handler)
 Returns the member type for a method, based on signature or descriptor. More...
 
void java_bytecode_convert_method_lazy (const symbolt &class_symbol, const irep_idt &method_identifier, const java_bytecode_parse_treet::methodt &m, symbol_tablet &symbol_table, message_handlert &message_handler)
 This creates a method symbol in the symtab, but doesn't actually perform method conversion just yet. More...
 
static irep_idt get_method_identifier (const irep_idt &class_identifier, const java_bytecode_parse_treet::methodt &method)
 
static irep_idt get_if_cmp_operator (const u1 bytecode)
 
static member_exprt to_member (const exprt &pointer, const fieldref_exprt &field_reference, const namespacet &ns)
 Build a member exprt for accessing a specific field that may come from a base class. More...
 
static void gather_symbol_live_ranges (java_bytecode_convert_methodt::method_offsett pc, const exprt &e, std::map< irep_idt, java_bytecode_convert_methodt::variablet > &result)
 
static std::size_t get_bytecode_type_width (const typet &ty)
 
void java_bytecode_initialize_parameter_names (symbolt &method_symbol, const java_bytecode_parse_treet::methodt::local_variable_tablet &local_variable_table, symbol_table_baset &symbol_table)
 This uses a cut-down version of the logic in java_bytecode_convert_methodt::convert to initialize symbols for the parameters and update the parameters in the type of method_symbol with names read from the local_variable_table read from the bytecode. More...
 
void java_bytecode_convert_method (const symbolt &class_symbol, const java_bytecode_parse_treet::methodt &method, symbol_table_baset &symbol_table, message_handlert &message_handler, size_t max_array_length, bool throw_assertion_error, optionalt< ci_lazy_methods_neededt > needed_lazy_methods, java_string_library_preprocesst &string_preprocess, const class_hierarchyt &class_hierarchy, bool threading_support)
 

Detailed Description

JAVA Bytecode Language Conversion.

Definition in file java_bytecode_convert_method.cpp.

Function Documentation

◆ assign_parameter_names()

static void assign_parameter_names ( java_method_typet ftype,
const irep_idt name_prefix,
symbol_table_baset symbol_table 
)
static

Iterates through the parameters of the function type ftype, finds a new new name for each parameter and renames them in ftype.parameters() as well as in the symbol_table.

Parameters
[in,out]ftypeFunction type whose parameters should be named.
name_prefixPrefix for parameter names, typically the parent function's name.
[in,out]symbol_tableGlobal symbol table.
Returns
Assigns parameter names (side-effects on ftype) to function stub parameters, which are initially nameless as method conversion hasn't happened. Also creates symbols in symbol_table.

Definition at line 65 of file java_bytecode_convert_method.cpp.

◆ gather_symbol_live_ranges()

static void gather_symbol_live_ranges ( java_bytecode_convert_methodt::method_offsett  pc,
const exprt e,
std::map< irep_idt, java_bytecode_convert_methodt::variablet > &  result 
)
static

Definition at line 911 of file java_bytecode_convert_method.cpp.

◆ get_bytecode_type_width()

static std::size_t get_bytecode_type_width ( const typet ty)
static

Definition at line 965 of file java_bytecode_convert_method.cpp.

◆ get_if_cmp_operator()

static irep_idt get_if_cmp_operator ( const u1  bytecode)
static

Definition at line 596 of file java_bytecode_convert_method.cpp.

◆ get_method_identifier()

static irep_idt get_method_identifier ( const irep_idt class_identifier,
const java_bytecode_parse_treet::methodt method 
)
static

Definition at line 399 of file java_bytecode_convert_method.cpp.

◆ is_constructor()

static bool is_constructor ( const irep_idt method_name)
static

Definition at line 97 of file java_bytecode_convert_method.cpp.

◆ java_bytecode_convert_method()

void java_bytecode_convert_method ( const symbolt class_symbol,
const java_bytecode_parse_treet::methodt method,
symbol_table_baset symbol_table,
message_handlert message_handler,
size_t  max_array_length,
bool  throw_assertion_error,
optionalt< ci_lazy_methods_neededt needed_lazy_methods,
java_string_library_preprocesst string_preprocess,
const class_hierarchyt class_hierarchy,
bool  threading_support 
)

Definition at line 3081 of file java_bytecode_convert_method.cpp.

◆ java_bytecode_convert_method_lazy()

void java_bytecode_convert_method_lazy ( const symbolt class_symbol,
const irep_idt method_identifier,
const java_bytecode_parse_treet::methodt m,
symbol_tablet symbol_table,
message_handlert message_handler 
)

This creates a method symbol in the symtab, but doesn't actually perform method conversion just yet.

The caller should call java_bytecode_convert_method later to give the symbol/method a body.

Parameters
class_symbolThe class this method belongs to
method_identifierThe fully qualified method name, including type descriptor (e.g. "x.y.z.f:(I)")
mThe parsed method object to convert.
symbol_tableThe global symbol table (will be modified).
message_handlerA message handler to collect warnings.

Definition at line 304 of file java_bytecode_convert_method.cpp.

◆ java_bytecode_initialize_parameter_names()

void java_bytecode_initialize_parameter_names ( symbolt method_symbol,
const java_bytecode_parse_treet::methodt::local_variable_tablet local_variable_table,
symbol_table_baset symbol_table 
)

This uses a cut-down version of the logic in java_bytecode_convert_methodt::convert to initialize symbols for the parameters and update the parameters in the type of method_symbol with names read from the local_variable_table read from the bytecode.

Remarks
This is useful for pre-initialization for methods generated by the string solver
Parameters
method_symbolThe symbol for the method for which to initialize the parameters
local_variable_tableThe local variable table containing the bytecode for the parameters
symbol_tableThe symbol table into which to insert symbols for the parameters

Definition at line 3003 of file java_bytecode_convert_method.cpp.

◆ member_type_lazy()

java_method_typet member_type_lazy ( const std::string &  descriptor,
const optionalt< std::string > &  signature,
const std::string &  class_name,
const std::string &  method_name,
message_handlert message_handler 
)

Returns the member type for a method, based on signature or descriptor.

Parameters
descriptordescriptor of the method
signaturesignature of the method
class_namestring containing the name of the corresponding class
method_namestring containing the name of the method
message_handlermessage handler to collect warnings
Returns
the constructed member type

Definition at line 217 of file java_bytecode_convert_method.cpp.

◆ to_member()

static member_exprt to_member ( const exprt pointer,
const fieldref_exprt field_reference,
const namespacet ns 
)
static

Build a member exprt for accessing a specific field that may come from a base class.

Parameters
pointerThe expression to access the field on.
field_referenceA getfield/setfield instruction produced by the bytecode parser.
nsGlobal namespace
Returns
A member expression accessing the field, through base class components if necessary.

Definition at line 622 of file java_bytecode_convert_method.cpp.