Add const where read was used
This commit is contained in:
parent
dbecda87da
commit
5d65b66155
|
@ -440,9 +440,9 @@ void java_bytecode_parsert::rClassFile()
|
|||
{
|
||||
parse_tree.loading_successful=false;
|
||||
|
||||
u4 magic = read<u4>();
|
||||
const u4 magic = read<u4>();
|
||||
UNUSED_u2(minor_version);
|
||||
u2 major_version = read<u2>();
|
||||
const u2 major_version = read<u2>();
|
||||
|
||||
if(magic!=0xCAFEBABE)
|
||||
{
|
||||
|
@ -460,9 +460,9 @@ void java_bytecode_parsert::rClassFile()
|
|||
|
||||
classt &parsed_class=parse_tree.parsed_class;
|
||||
|
||||
u2 access_flags = read<u2>();
|
||||
u2 this_class = read<u2>();
|
||||
u2 super_class = read<u2>();
|
||||
const u2 access_flags = read<u2>();
|
||||
const u2 this_class = read<u2>();
|
||||
const u2 super_class = read<u2>();
|
||||
|
||||
parsed_class.is_abstract=(access_flags&ACC_ABSTRACT)!=0;
|
||||
parsed_class.is_enum=(access_flags&ACC_ENUM)!=0;
|
||||
|
@ -489,7 +489,7 @@ void java_bytecode_parsert::rClassFile()
|
|||
if(field.is_enum)
|
||||
parse_tree.parsed_class.enum_elements++;
|
||||
|
||||
u2 attributes_count = read<u2>();
|
||||
const u2 attributes_count = read<u2>();
|
||||
|
||||
for(std::size_t j=0; j<attributes_count; j++)
|
||||
rclass_attribute(parsed_class);
|
||||
|
@ -653,7 +653,7 @@ void java_bytecode_parsert::get_annotation_value_class_refs(const exprt &value)
|
|||
|
||||
void java_bytecode_parsert::rconstant_pool()
|
||||
{
|
||||
u2 constant_pool_count = read<u2>();
|
||||
const u2 constant_pool_count = read<u2>();
|
||||
if(constant_pool_count==0)
|
||||
{
|
||||
error() << "invalid constant_pool_count" << eom;
|
||||
|
@ -714,7 +714,7 @@ void java_bytecode_parsert::rconstant_pool()
|
|||
|
||||
case CONSTANT_Utf8:
|
||||
{
|
||||
u2 bytes = read<u2>();
|
||||
const u2 bytes = read<u2>();
|
||||
std::string s;
|
||||
s.resize(bytes);
|
||||
for(std::string::iterator s_it=s.begin(); s_it!=s.end(); s_it++)
|
||||
|
@ -866,7 +866,7 @@ void java_bytecode_parsert::rconstant_pool()
|
|||
|
||||
void java_bytecode_parsert::rinterfaces(classt &parsed_class)
|
||||
{
|
||||
u2 interfaces_count = read<u2>();
|
||||
const u2 interfaces_count = read<u2>();
|
||||
|
||||
for(std::size_t i=0; i<interfaces_count; i++)
|
||||
parsed_class.implements.push_back(
|
||||
|
@ -875,16 +875,16 @@ void java_bytecode_parsert::rinterfaces(classt &parsed_class)
|
|||
|
||||
void java_bytecode_parsert::rfields(classt &parsed_class)
|
||||
{
|
||||
u2 fields_count = read<u2>();
|
||||
const u2 fields_count = read<u2>();
|
||||
|
||||
for(std::size_t i=0; i<fields_count; i++)
|
||||
{
|
||||
fieldt &field=parsed_class.add_field();
|
||||
|
||||
u2 access_flags = read<u2>();
|
||||
u2 name_index = read<u2>();
|
||||
u2 descriptor_index = read<u2>();
|
||||
u2 attributes_count = read<u2>();
|
||||
const u2 access_flags = read<u2>();
|
||||
const u2 name_index = read<u2>();
|
||||
const u2 descriptor_index = read<u2>();
|
||||
const u2 attributes_count = read<u2>();
|
||||
|
||||
field.name=pool_entry(name_index).s;
|
||||
field.is_static=(access_flags&ACC_STATIC)!=0;
|
||||
|
@ -917,7 +917,7 @@ void java_bytecode_parsert::rfields(classt &parsed_class)
|
|||
void java_bytecode_parsert::rbytecode(
|
||||
methodt::instructionst &instructions)
|
||||
{
|
||||
u4 code_length = read<u4>();
|
||||
const u4 code_length = read<u4>();
|
||||
|
||||
u4 address;
|
||||
size_t bytecode_index=0; // index of bytecode instruction
|
||||
|
@ -976,7 +976,7 @@ void java_bytecode_parsert::rbytecode(
|
|||
|
||||
case 'b': // a signed byte
|
||||
{
|
||||
s1 c = read<u1>();
|
||||
const s1 c = read<u1>();
|
||||
instruction.args.push_back(from_integer(c, signedbv_typet(8)));
|
||||
}
|
||||
address+=1;
|
||||
|
@ -984,7 +984,7 @@ void java_bytecode_parsert::rbytecode(
|
|||
|
||||
case 'o': // two byte branch offset, signed
|
||||
{
|
||||
s2 offset = read<u2>();
|
||||
const s2 offset = read<u2>();
|
||||
// By converting the signed offset into an absolute address (by adding
|
||||
// the current address) the number represented becomes unsigned.
|
||||
instruction.args.push_back(
|
||||
|
@ -995,7 +995,7 @@ void java_bytecode_parsert::rbytecode(
|
|||
|
||||
case 'O': // four byte branch offset, signed
|
||||
{
|
||||
s4 offset = read<u4>();
|
||||
const s4 offset = read<u4>();
|
||||
// By converting the signed offset into an absolute address (by adding
|
||||
// the current address) the number represented becomes unsigned.
|
||||
instruction.args.push_back(
|
||||
|
@ -1008,13 +1008,13 @@ void java_bytecode_parsert::rbytecode(
|
|||
{
|
||||
if(wide_instruction)
|
||||
{
|
||||
u2 v = read<u2>();
|
||||
const u2 v = read<u2>();
|
||||
instruction.args.push_back(from_integer(v, unsignedbv_typet(16)));
|
||||
address += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
u1 v = read<u1>();
|
||||
const u1 v = read<u1>();
|
||||
instruction.args.push_back(from_integer(v, unsignedbv_typet(8)));
|
||||
address += 1;
|
||||
}
|
||||
|
@ -1026,17 +1026,17 @@ void java_bytecode_parsert::rbytecode(
|
|||
// local variable index (two bytes) plus two signed bytes
|
||||
if(wide_instruction)
|
||||
{
|
||||
u2 v = read<u2>();
|
||||
const u2 v = read<u2>();
|
||||
instruction.args.push_back(from_integer(v, unsignedbv_typet(16)));
|
||||
s2 c = read<u2>();
|
||||
const s2 c = read<u2>();
|
||||
instruction.args.push_back(from_integer(c, signedbv_typet(16)));
|
||||
address+=4;
|
||||
}
|
||||
else // local variable index (one byte) plus one signed byte
|
||||
{
|
||||
u1 v = read<u1>();
|
||||
const u1 v = read<u1>();
|
||||
instruction.args.push_back(from_integer(v, unsignedbv_typet(8)));
|
||||
s1 c = read<u1>();
|
||||
const s1 c = read<u1>();
|
||||
instruction.args.push_back(from_integer(c, signedbv_typet(8)));
|
||||
address+=2;
|
||||
}
|
||||
|
@ -1044,11 +1044,11 @@ void java_bytecode_parsert::rbytecode(
|
|||
|
||||
case 'I': // two byte constant_pool index plus two bytes
|
||||
{
|
||||
u2 c = read<u2>();
|
||||
const u2 c = read<u2>();
|
||||
instruction.args.push_back(constant(c));
|
||||
u1 b1 = read<u1>();
|
||||
const u1 b1 = read<u1>();
|
||||
instruction.args.push_back(from_integer(b1, unsignedbv_typet(8)));
|
||||
u1 b2 = read<u1>();
|
||||
const u1 b2 = read<u1>();
|
||||
instruction.args.push_back(from_integer(b2, unsignedbv_typet(8)));
|
||||
}
|
||||
address+=4;
|
||||
|
@ -1066,7 +1066,7 @@ void java_bytecode_parsert::rbytecode(
|
|||
}
|
||||
|
||||
// now default value
|
||||
s4 default_value = read<u4>();
|
||||
const s4 default_value = read<u4>();
|
||||
// By converting the signed offset into an absolute address (by adding
|
||||
// the current address) the number represented becomes unsigned.
|
||||
instruction.args.push_back(
|
||||
|
@ -1074,13 +1074,13 @@ void java_bytecode_parsert::rbytecode(
|
|||
address+=4;
|
||||
|
||||
// number of pairs
|
||||
u4 npairs = read<u4>();
|
||||
const u4 npairs = read<u4>();
|
||||
address+=4;
|
||||
|
||||
for(std::size_t i=0; i<npairs; i++)
|
||||
{
|
||||
s4 match = read<u4>();
|
||||
s4 offset = read<u4>();
|
||||
const s4 match = read<u4>();
|
||||
const s4 offset = read<u4>();
|
||||
instruction.args.push_back(
|
||||
from_integer(match, signedbv_typet(32)));
|
||||
// By converting the signed offset into an absolute address (by adding
|
||||
|
@ -1104,17 +1104,17 @@ void java_bytecode_parsert::rbytecode(
|
|||
}
|
||||
|
||||
// now default value
|
||||
s4 default_value = read<u4>();
|
||||
const s4 default_value = read<u4>();
|
||||
instruction.args.push_back(
|
||||
from_integer(base_offset+default_value, signedbv_typet(32)));
|
||||
address+=4;
|
||||
|
||||
// now low value
|
||||
s4 low_value = read<u4>();
|
||||
const s4 low_value = read<u4>();
|
||||
address+=4;
|
||||
|
||||
// now high value
|
||||
s4 high_value = read<u4>();
|
||||
const s4 high_value = read<u4>();
|
||||
address+=4;
|
||||
|
||||
// there are high-low+1 offsets, and they are signed
|
||||
|
@ -1133,9 +1133,9 @@ void java_bytecode_parsert::rbytecode(
|
|||
|
||||
case 'm': // multianewarray: constant-pool index plus one unsigned byte
|
||||
{
|
||||
u2 c = read<u2>(); // constant-pool index
|
||||
const u2 c = read<u2>(); // constant-pool index
|
||||
instruction.args.push_back(constant(c));
|
||||
u1 dimensions = read<u1>(); // number of dimensions
|
||||
const u1 dimensions = read<u1>(); // number of dimensions
|
||||
instruction.args.push_back(
|
||||
from_integer(dimensions, unsignedbv_typet(8)));
|
||||
address+=3;
|
||||
|
@ -1164,7 +1164,7 @@ void java_bytecode_parsert::rbytecode(
|
|||
|
||||
case 's': // a signed short
|
||||
{
|
||||
s2 s = read<u2>();
|
||||
const s2 s = read<u2>();
|
||||
instruction.args.push_back(from_integer(s, signedbv_typet(16)));
|
||||
}
|
||||
address+=2;
|
||||
|
@ -1185,8 +1185,8 @@ void java_bytecode_parsert::rbytecode(
|
|||
|
||||
void java_bytecode_parsert::rmethod_attribute(methodt &method)
|
||||
{
|
||||
u2 attribute_name_index = read<u2>();
|
||||
u4 attribute_length = read<u4>();
|
||||
const u2 attribute_name_index = read<u2>();
|
||||
const u4 attribute_length = read<u4>();
|
||||
|
||||
irep_idt attribute_name=pool_entry(attribute_name_index).s;
|
||||
|
||||
|
@ -1200,7 +1200,7 @@ void java_bytecode_parsert::rmethod_attribute(methodt &method)
|
|||
else
|
||||
rbytecode(method.instructions);
|
||||
|
||||
u2 exception_table_length = read<u2>();
|
||||
const u2 exception_table_length = read<u2>();
|
||||
if(skip_instructions)
|
||||
skip_bytes(exception_table_length * 8u);
|
||||
else
|
||||
|
@ -1209,8 +1209,8 @@ void java_bytecode_parsert::rmethod_attribute(methodt &method)
|
|||
|
||||
for(std::size_t e = 0; e < exception_table_length; e++)
|
||||
{
|
||||
u2 start_pc = read<u2>();
|
||||
u2 end_pc = read<u2>();
|
||||
const u2 start_pc = read<u2>();
|
||||
const u2 end_pc = read<u2>();
|
||||
|
||||
// From the class file format spec ("4.7.3. The Code Attribute" for
|
||||
// Java8)
|
||||
|
@ -1219,8 +1219,8 @@ void java_bytecode_parsert::rmethod_attribute(methodt &method)
|
|||
"The start_pc must be less than the end_pc as this is the range the "
|
||||
"exception is active");
|
||||
|
||||
u2 handler_pc = read<u2>();
|
||||
u2 catch_type = read<u2>();
|
||||
const u2 handler_pc = read<u2>();
|
||||
const u2 catch_type = read<u2>();
|
||||
method.exception_table[e].start_pc = start_pc;
|
||||
method.exception_table[e].end_pc = end_pc;
|
||||
method.exception_table[e].handler_pc = handler_pc;
|
||||
|
@ -1267,7 +1267,7 @@ void java_bytecode_parsert::rmethod_attribute(methodt &method)
|
|||
}
|
||||
else if(attribute_name=="Signature")
|
||||
{
|
||||
u2 signature_index = read<u2>();
|
||||
const u2 signature_index = read<u2>();
|
||||
method.signature=id2string(pool_entry(signature_index).s);
|
||||
}
|
||||
else if(attribute_name=="RuntimeInvisibleAnnotations" ||
|
||||
|
@ -1279,7 +1279,7 @@ void java_bytecode_parsert::rmethod_attribute(methodt &method)
|
|||
attribute_name == "RuntimeInvisibleParameterAnnotations" ||
|
||||
attribute_name == "RuntimeVisibleParameterAnnotations")
|
||||
{
|
||||
u1 parameter_count = read<u1>();
|
||||
const u1 parameter_count = read<u1>();
|
||||
// There may be attributes for both runtime-visible and runtime-invisible
|
||||
// annotations, the length of either array may be longer than the other as
|
||||
// trailing parameters without annotations are omitted.
|
||||
|
@ -1300,14 +1300,14 @@ void java_bytecode_parsert::rmethod_attribute(methodt &method)
|
|||
|
||||
void java_bytecode_parsert::rfield_attribute(fieldt &field)
|
||||
{
|
||||
u2 attribute_name_index = read<u2>();
|
||||
u4 attribute_length = read<u4>();
|
||||
const u2 attribute_name_index = read<u2>();
|
||||
const u4 attribute_length = read<u4>();
|
||||
|
||||
irep_idt attribute_name=pool_entry(attribute_name_index).s;
|
||||
|
||||
if(attribute_name=="Signature")
|
||||
{
|
||||
u2 signature_index = read<u2>();
|
||||
const u2 signature_index = read<u2>();
|
||||
field.signature=id2string(pool_entry(signature_index).s);
|
||||
}
|
||||
else if(attribute_name=="RuntimeInvisibleAnnotations" ||
|
||||
|
@ -1321,8 +1321,8 @@ void java_bytecode_parsert::rfield_attribute(fieldt &field)
|
|||
|
||||
void java_bytecode_parsert::rcode_attribute(methodt &method)
|
||||
{
|
||||
u2 attribute_name_index = read<u2>();
|
||||
u4 attribute_length = read<u4>();
|
||||
const u2 attribute_name_index = read<u2>();
|
||||
const u4 attribute_length = read<u4>();
|
||||
|
||||
irep_idt attribute_name=pool_entry(attribute_name_index).s;
|
||||
|
||||
|
@ -1341,12 +1341,12 @@ void java_bytecode_parsert::rcode_attribute(methodt &method)
|
|||
instruction_map[it->address]=it;
|
||||
}
|
||||
|
||||
u2 line_number_table_length = read<u2>();
|
||||
const u2 line_number_table_length = read<u2>();
|
||||
|
||||
for(std::size_t i=0; i<line_number_table_length; i++)
|
||||
{
|
||||
u2 start_pc = read<u2>();
|
||||
u2 line_number = read<u2>();
|
||||
const u2 start_pc = read<u2>();
|
||||
const u2 line_number = read<u2>();
|
||||
|
||||
// annotate the bytecode program
|
||||
instruction_mapt::const_iterator it=
|
||||
|
@ -1358,17 +1358,17 @@ void java_bytecode_parsert::rcode_attribute(methodt &method)
|
|||
}
|
||||
else if(attribute_name=="LocalVariableTable")
|
||||
{
|
||||
u2 local_variable_table_length = read<u2>();
|
||||
const u2 local_variable_table_length = read<u2>();
|
||||
|
||||
method.local_variable_table.resize(local_variable_table_length);
|
||||
|
||||
for(std::size_t i=0; i<local_variable_table_length; i++)
|
||||
{
|
||||
u2 start_pc = read<u2>();
|
||||
u2 length = read<u2>();
|
||||
u2 name_index = read<u2>();
|
||||
u2 descriptor_index = read<u2>();
|
||||
u2 index = read<u2>();
|
||||
const u2 start_pc = read<u2>();
|
||||
const u2 length = read<u2>();
|
||||
const u2 name_index = read<u2>();
|
||||
const u2 descriptor_index = read<u2>();
|
||||
const u2 index = read<u2>();
|
||||
|
||||
method.local_variable_table[i].index=index;
|
||||
method.local_variable_table[i].name=pool_entry(name_index).s;
|
||||
|
@ -1384,13 +1384,13 @@ void java_bytecode_parsert::rcode_attribute(methodt &method)
|
|||
}
|
||||
else if(attribute_name=="StackMapTable")
|
||||
{
|
||||
u2 stack_map_entries = read<u2>();
|
||||
const u2 stack_map_entries = read<u2>();
|
||||
|
||||
method.stack_map_table.resize(stack_map_entries);
|
||||
|
||||
for(size_t i=0; i<stack_map_entries; i++)
|
||||
{
|
||||
u1 frame_type = read<u1>();
|
||||
const u1 frame_type = read<u1>();
|
||||
if(frame_type<=63)
|
||||
{
|
||||
method.stack_map_table[i].type=methodt::stack_map_table_entryt::SAME;
|
||||
|
@ -1414,7 +1414,7 @@ void java_bytecode_parsert::rcode_attribute(methodt &method)
|
|||
method.stack_map_table[i].locals.resize(0);
|
||||
method.stack_map_table[i].stack.resize(1);
|
||||
methodt::verification_type_infot verification_type_info;
|
||||
u2 offset_delta = read<u2>();
|
||||
const u2 offset_delta = read<u2>();
|
||||
read_verification_type_info(verification_type_info);
|
||||
method.stack_map_table[i].stack[0]=verification_type_info;
|
||||
method.stack_map_table[i].offset_delta=offset_delta;
|
||||
|
@ -1424,7 +1424,7 @@ void java_bytecode_parsert::rcode_attribute(methodt &method)
|
|||
method.stack_map_table[i].type=methodt::stack_map_table_entryt::CHOP;
|
||||
method.stack_map_table[i].locals.resize(0);
|
||||
method.stack_map_table[i].stack.resize(0);
|
||||
u2 offset_delta = read<u2>();
|
||||
const u2 offset_delta = read<u2>();
|
||||
method.stack_map_table[i].offset_delta=offset_delta;
|
||||
}
|
||||
else if(frame_type==251)
|
||||
|
@ -1433,7 +1433,7 @@ void java_bytecode_parsert::rcode_attribute(methodt &method)
|
|||
=methodt::stack_map_table_entryt::SAME_EXTENDED;
|
||||
method.stack_map_table[i].locals.resize(0);
|
||||
method.stack_map_table[i].stack.resize(0);
|
||||
u2 offset_delta = read<u2>();
|
||||
const u2 offset_delta = read<u2>();
|
||||
method.stack_map_table[i].offset_delta=offset_delta;
|
||||
}
|
||||
else if(252<=frame_type && frame_type<=254)
|
||||
|
@ -1442,7 +1442,7 @@ void java_bytecode_parsert::rcode_attribute(methodt &method)
|
|||
method.stack_map_table[i].type=methodt::stack_map_table_entryt::APPEND;
|
||||
method.stack_map_table[i].locals.resize(new_locals);
|
||||
method.stack_map_table[i].stack.resize(0);
|
||||
u2 offset_delta = read<u2>();
|
||||
const u2 offset_delta = read<u2>();
|
||||
method.stack_map_table[i].offset_delta=offset_delta;
|
||||
for(size_t k=0; k<new_locals; k++)
|
||||
{
|
||||
|
@ -1456,9 +1456,9 @@ void java_bytecode_parsert::rcode_attribute(methodt &method)
|
|||
else if(frame_type==255)
|
||||
{
|
||||
method.stack_map_table[i].type=methodt::stack_map_table_entryt::FULL;
|
||||
u2 offset_delta = read<u2>();
|
||||
const u2 offset_delta = read<u2>();
|
||||
method.stack_map_table[i].offset_delta=offset_delta;
|
||||
u2 number_locals = read<u2>();
|
||||
const u2 number_locals = read<u2>();
|
||||
method.stack_map_table[i].locals.resize(number_locals);
|
||||
for(size_t k=0; k<(size_t) number_locals; k++)
|
||||
{
|
||||
|
@ -1468,7 +1468,7 @@ void java_bytecode_parsert::rcode_attribute(methodt &method)
|
|||
method.stack_map_table[i].locals.back();
|
||||
read_verification_type_info(v);
|
||||
}
|
||||
u2 number_stack_items = read<u2>();
|
||||
const u2 number_stack_items = read<u2>();
|
||||
method.stack_map_table[i].stack.resize(number_stack_items);
|
||||
for(size_t k=0; k<(size_t) number_stack_items; k++)
|
||||
{
|
||||
|
@ -1490,7 +1490,7 @@ void java_bytecode_parsert::rcode_attribute(methodt &method)
|
|||
void java_bytecode_parsert::read_verification_type_info(
|
||||
methodt::verification_type_infot &v)
|
||||
{
|
||||
u1 tag = read<u1>();
|
||||
const u1 tag = read<u1>();
|
||||
switch(tag)
|
||||
{
|
||||
case VTYPE_INFO_TOP:
|
||||
|
@ -1530,7 +1530,7 @@ void java_bytecode_parsert::read_verification_type_info(
|
|||
void java_bytecode_parsert::rRuntimeAnnotation_attribute(
|
||||
annotationst &annotations)
|
||||
{
|
||||
u2 num_annotations = read<u2>();
|
||||
const u2 num_annotations = read<u2>();
|
||||
|
||||
for(u2 number=0; number<num_annotations; number++)
|
||||
{
|
||||
|
@ -1543,7 +1543,7 @@ void java_bytecode_parsert::rRuntimeAnnotation_attribute(
|
|||
void java_bytecode_parsert::rRuntimeAnnotation(
|
||||
annotationt &annotation)
|
||||
{
|
||||
u2 type_index = read<u2>();
|
||||
const u2 type_index = read<u2>();
|
||||
annotation.type=type_entry(type_index);
|
||||
relement_value_pairs(annotation.element_value_pairs);
|
||||
}
|
||||
|
@ -1551,12 +1551,12 @@ void java_bytecode_parsert::rRuntimeAnnotation(
|
|||
void java_bytecode_parsert::relement_value_pairs(
|
||||
annotationt::element_value_pairst &element_value_pairs)
|
||||
{
|
||||
u2 num_element_value_pairs = read<u2>();
|
||||
const u2 num_element_value_pairs = read<u2>();
|
||||
element_value_pairs.resize(num_element_value_pairs);
|
||||
|
||||
for(auto &element_value_pair : element_value_pairs)
|
||||
{
|
||||
u2 element_name_index = read<u2>();
|
||||
const u2 element_name_index = read<u2>();
|
||||
element_value_pair.element_name=pool_entry(element_name_index).s;
|
||||
element_value_pair.value = get_relement_value();
|
||||
}
|
||||
|
@ -1570,7 +1570,7 @@ void java_bytecode_parsert::relement_value_pairs(
|
|||
/// enum, Class type, array or another annotation.
|
||||
exprt java_bytecode_parsert::get_relement_value()
|
||||
{
|
||||
u1 tag = read<u1>();
|
||||
const u1 tag = read<u1>();
|
||||
|
||||
switch(tag)
|
||||
{
|
||||
|
@ -1584,7 +1584,7 @@ exprt java_bytecode_parsert::get_relement_value()
|
|||
|
||||
case 'c':
|
||||
{
|
||||
u2 class_info_index = read<u2>();
|
||||
const u2 class_info_index = read<u2>();
|
||||
return symbol_exprt::typeless(pool_entry(class_info_index).s);
|
||||
}
|
||||
|
||||
|
@ -1599,7 +1599,7 @@ exprt java_bytecode_parsert::get_relement_value()
|
|||
|
||||
case '[':
|
||||
{
|
||||
u2 num_values = read<u2>();
|
||||
const u2 num_values = read<u2>();
|
||||
exprt::operandst values;
|
||||
values.reserve(num_values);
|
||||
for(std::size_t i=0; i<num_values; i++)
|
||||
|
@ -1611,13 +1611,13 @@ exprt java_bytecode_parsert::get_relement_value()
|
|||
|
||||
case 's':
|
||||
{
|
||||
u2 const_value_index = read<u2>();
|
||||
const u2 const_value_index = read<u2>();
|
||||
return string_constantt(pool_entry(const_value_index).s);
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
u2 const_value_index = read<u2>();
|
||||
const u2 const_value_index = read<u2>();
|
||||
return constant(const_value_index);
|
||||
}
|
||||
}
|
||||
|
@ -1639,8 +1639,8 @@ void java_bytecode_parsert::rinner_classes_attribute(
|
|||
const u4 &attribute_length)
|
||||
{
|
||||
std::string name = parsed_class.name.c_str();
|
||||
u2 number_of_classes = read<u2>();
|
||||
u4 number_of_bytes_to_be_read = number_of_classes * 8 + 2;
|
||||
const u2 number_of_classes = read<u2>();
|
||||
const u4 number_of_bytes_to_be_read = number_of_classes * 8 + 2;
|
||||
INVARIANT(
|
||||
number_of_bytes_to_be_read == attribute_length,
|
||||
"The number of bytes to be read for the InnerClasses attribute does not "
|
||||
|
@ -1656,10 +1656,10 @@ void java_bytecode_parsert::rinner_classes_attribute(
|
|||
|
||||
for(int i = 0; i < number_of_classes; i++)
|
||||
{
|
||||
u2 inner_class_info_index = read<u2>();
|
||||
u2 outer_class_info_index = read<u2>();
|
||||
u2 inner_name_index = read<u2>();
|
||||
u2 inner_class_access_flags = read<u2>();
|
||||
const u2 inner_class_info_index = read<u2>();
|
||||
const u2 outer_class_info_index = read<u2>();
|
||||
const u2 inner_name_index = read<u2>();
|
||||
const u2 inner_class_access_flags = read<u2>();
|
||||
|
||||
std::string inner_class_info_name =
|
||||
class_infot(pool_entry(inner_class_info_index))
|
||||
|
@ -1713,12 +1713,12 @@ void java_bytecode_parsert::rinner_classes_attribute(
|
|||
/// and returns a vector of exceptions.
|
||||
std::vector<irep_idt> java_bytecode_parsert::rexceptions_attribute()
|
||||
{
|
||||
u2 number_of_exceptions = read<u2>();
|
||||
const u2 number_of_exceptions = read<u2>();
|
||||
|
||||
std::vector<irep_idt> exceptions;
|
||||
for(size_t i = 0; i < number_of_exceptions; i++)
|
||||
{
|
||||
u2 exception_index_table = read<u2>();
|
||||
const u2 exception_index_table = read<u2>();
|
||||
const irep_idt exception_name =
|
||||
constant(exception_index_table).type().get(ID_C_base_name);
|
||||
exceptions.push_back(exception_name);
|
||||
|
@ -1728,14 +1728,14 @@ std::vector<irep_idt> java_bytecode_parsert::rexceptions_attribute()
|
|||
|
||||
void java_bytecode_parsert::rclass_attribute(classt &parsed_class)
|
||||
{
|
||||
u2 attribute_name_index = read<u2>();
|
||||
u4 attribute_length = read<u4>();
|
||||
const u2 attribute_name_index = read<u2>();
|
||||
const u4 attribute_length = read<u4>();
|
||||
|
||||
irep_idt attribute_name=pool_entry(attribute_name_index).s;
|
||||
|
||||
if(attribute_name=="SourceFile")
|
||||
{
|
||||
u2 sourcefile_index = read<u2>();
|
||||
const u2 sourcefile_index = read<u2>();
|
||||
irep_idt sourcefile_name;
|
||||
|
||||
std::string fqn(id2string(parsed_class.name));
|
||||
|
@ -1767,7 +1767,7 @@ void java_bytecode_parsert::rclass_attribute(classt &parsed_class)
|
|||
}
|
||||
else if(attribute_name=="Signature")
|
||||
{
|
||||
u2 signature_index = read<u2>();
|
||||
const u2 signature_index = read<u2>();
|
||||
parsed_class.signature=id2string(pool_entry(signature_index).s);
|
||||
get_dependencies_from_generic_parameters(
|
||||
parsed_class.signature.value(),
|
||||
|
@ -1801,7 +1801,7 @@ void java_bytecode_parsert::rclass_attribute(classt &parsed_class)
|
|||
|
||||
void java_bytecode_parsert::rmethods(classt &parsed_class)
|
||||
{
|
||||
u2 methods_count = read<u2>();
|
||||
const u2 methods_count = read<u2>();
|
||||
|
||||
for(std::size_t j=0; j<methods_count; j++)
|
||||
rmethod(parsed_class);
|
||||
|
@ -1826,9 +1826,9 @@ void java_bytecode_parsert::rmethod(classt &parsed_class)
|
|||
{
|
||||
methodt &method=parsed_class.add_method();
|
||||
|
||||
u2 access_flags = read<u2>();
|
||||
u2 name_index = read<u2>();
|
||||
u2 descriptor_index = read<u2>();
|
||||
const u2 access_flags = read<u2>();
|
||||
const u2 name_index = read<u2>();
|
||||
const u2 descriptor_index = read<u2>();
|
||||
|
||||
method.is_final=(access_flags&ACC_FINAL)!=0;
|
||||
method.is_static=(access_flags&ACC_STATIC)!=0;
|
||||
|
@ -1849,7 +1849,7 @@ void java_bytecode_parsert::rmethod(classt &parsed_class)
|
|||
(method.is_protected?1:0)+
|
||||
(method.is_private?1:0);
|
||||
DATA_INVARIANT(flags<=1, "at most one of public, protected, private");
|
||||
u2 attributes_count = read<u2>();
|
||||
const u2 attributes_count = read<u2>();
|
||||
|
||||
for(std::size_t j=0; j<attributes_count; j++)
|
||||
rmethod_attribute(method);
|
||||
|
@ -1899,7 +1899,7 @@ java_bytecode_parse(
|
|||
/// many variables as present in the LVT can be in the LVTT.
|
||||
void java_bytecode_parsert::parse_local_variable_type_table(methodt &method)
|
||||
{
|
||||
u2 local_variable_type_table_length = read<u2>();
|
||||
const u2 local_variable_type_table_length = read<u2>();
|
||||
|
||||
INVARIANT(
|
||||
local_variable_type_table_length<=method.local_variable_table.size(),
|
||||
|
@ -1907,11 +1907,11 @@ void java_bytecode_parsert::parse_local_variable_type_table(methodt &method)
|
|||
"than the local variable table.");
|
||||
for(std::size_t i=0; i<local_variable_type_table_length; i++)
|
||||
{
|
||||
u2 start_pc = read<u2>();
|
||||
u2 length = read<u2>();
|
||||
u2 name_index = read<u2>();
|
||||
u2 signature_index = read<u2>();
|
||||
u2 index = read<u2>();
|
||||
const u2 start_pc = read<u2>();
|
||||
const u2 length = read<u2>();
|
||||
const u2 name_index = read<u2>();
|
||||
const u2 signature_index = read<u2>();
|
||||
const u2 index = read<u2>();
|
||||
|
||||
bool found=false;
|
||||
for(auto &lvar : method.local_variable_table)
|
||||
|
@ -1984,17 +1984,17 @@ java_bytecode_parsert::parse_method_handle(const method_handle_infot &entry)
|
|||
/// currently parsed
|
||||
void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
|
||||
{
|
||||
u2 num_bootstrap_methods = read<u2>();
|
||||
const u2 num_bootstrap_methods = read<u2>();
|
||||
for(size_t bootstrap_method_index = 0;
|
||||
bootstrap_method_index < num_bootstrap_methods;
|
||||
++bootstrap_method_index)
|
||||
{
|
||||
u2 bootstrap_methodhandle_ref = read<u2>();
|
||||
const u2 bootstrap_methodhandle_ref = read<u2>();
|
||||
const pool_entryt &entry = pool_entry(bootstrap_methodhandle_ref);
|
||||
|
||||
method_handle_infot method_handle{entry};
|
||||
|
||||
u2 num_bootstrap_arguments = read<u2>();
|
||||
const u2 num_bootstrap_arguments = read<u2>();
|
||||
debug() << "INFO: parse BootstrapMethod handle " << num_bootstrap_arguments
|
||||
<< " #args" << eom;
|
||||
|
||||
|
|
Loading…
Reference in New Issue