Skip to content

Commit b0f2b9a

Browse files
author
Daniel Kroening
committed
use error()
1 parent 2c80686 commit b0f2b9a

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

src/java_bytecode/java_bytecode_convert.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ class java_bytecode_convertt:public messaget
160160
exprt::operandst pop(unsigned n)
161161
{
162162
if(stack.size()<n)
163-
throw "malformed bytecode (pop too high)";
163+
{
164+
error() << "malformed bytecode (pop too high)" << eom;
165+
throw 0;
166+
}
164167

165168
exprt::operandst operands;
166169
operands.resize(n);
@@ -188,7 +191,7 @@ class java_bytecode_convertt:public messaget
188191
codet convert_instructions(
189192
const instructionst &, const code_typet &);
190193

191-
static const bytecode_infot &get_bytecode_info(const irep_idt &statement);
194+
const bytecode_infot &get_bytecode_info(const irep_idt &statement);
192195

193196
void generate_class_stub(const irep_idt &class_name);
194197
void add_array_types();
@@ -249,7 +252,10 @@ void java_bytecode_convertt::convert(const classt &c)
249252

250253
// add before we do members
251254
if(symbol_table.move(new_symbol, class_symbol))
252-
throw "failed to add class symbol "+id2string(new_symbol.name);
255+
{
256+
error() << "failed to add class symbol " << new_symbol.name << eom;
257+
throw 0;
258+
}
253259

254260
// now do members
255261
for(const auto & it : c.fields)
@@ -542,7 +548,10 @@ void java_bytecode_convertt::convert(
542548
new_symbol.value=gen_zero(member_type);
543549

544550
if(symbol_table.add(new_symbol))
545-
throw "failed to add static field symbol";
551+
{
552+
error() << "failed to add static field symbol" << eom;
553+
throw 0;
554+
}
546555
}
547556
}
548557

@@ -564,8 +573,9 @@ const bytecode_infot &java_bytecode_convertt::get_bytecode_info(
564573
for(const bytecode_infot *p=bytecode_info; p->mnemonic!=0; p++)
565574
if(statement==p->mnemonic) return *p;
566575

567-
throw std::string("failed to find bytecode mnemonic `")+
568-
id2string(statement)+"'";
576+
error() << "failed to find bytecode mnemonic `"
577+
<< statement << '\'' << eom;
578+
throw 0;
569579
}
570580

571581
namespace {

src/java_bytecode/java_bytecode_typecheck_expr.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ void java_bytecode_typecheckt::typecheck_expr_java_string_literal(exprt &expr)
124124
new_symbol.is_lvalue=true;
125125

126126
if(symbol_table.add(new_symbol))
127-
throw "failed to add string literal symbol to symbol table";
127+
{
128+
error() << "failed to add string literal symbol to symbol table" << eom;
129+
throw 0;
130+
}
128131
}
129132

130133
expr=address_of_exprt(
@@ -153,7 +156,6 @@ void java_bytecode_typecheckt::typecheck_expr_symbol(symbol_exprt &expr)
153156

154157
if(s_it==symbol_table.symbols.end())
155158
{
156-
#if 1
157159
assert(has_prefix(id2string(identifier), "java::"));
158160

159161
// no, create the symbol
@@ -175,13 +177,10 @@ void java_bytecode_typecheckt::typecheck_expr_symbol(symbol_exprt &expr)
175177
}
176178

177179
if(symbol_table.add(new_symbol))
178-
throw "failed to add expression symbol to symbol table";
179-
#else
180-
str << "failed to find expression symbol `"
181-
<< identifier << "' in symbol table";
182-
throw 0;
183-
184-
#endif
180+
{
181+
error() << "failed to add expression symbol to symbol table" << eom;
182+
throw 0;
183+
}
185184
}
186185
else
187186
{

0 commit comments

Comments
 (0)