Skip to content

Commit a00b34a

Browse files
author
Daniel Kroening
committed
more for instanceof
1 parent dded7f9 commit a00b34a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/java_bytecode/expr2java.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class expr2javat:public expr2ct
3636
protected:
3737
virtual std::string convert(const exprt &src, unsigned &precedence);
3838
virtual std::string convert_java_this(const exprt &src, unsigned precedence);
39+
virtual std::string convert_java_instanceof(const exprt &src, unsigned precedence);
3940
virtual std::string convert_java_new(const exprt &src, unsigned precedence);
4041
virtual std::string convert_code_java_delete(const exprt &src, unsigned precedence);
4142
virtual std::string convert_struct(const exprt &src, unsigned &precedence);
@@ -348,6 +349,31 @@ std::string expr2javat::convert_java_this(
348349

349350
/*******************************************************************\
350351
352+
Function: expr2javat::convert_java_instanceof
353+
354+
Inputs:
355+
356+
Outputs:
357+
358+
Purpose:
359+
360+
\*******************************************************************/
361+
362+
std::string expr2javat::convert_java_instanceof(
363+
const exprt &src,
364+
unsigned precedence)
365+
{
366+
if(src.operands().size()!=2)
367+
{
368+
unsigned precedence;
369+
return convert_norep(src, precedence);
370+
}
371+
372+
return convert(src.op0())+" instanceof "+convert(src.op1().type());
373+
}
374+
375+
/*******************************************************************\
376+
351377
Function: expr2javat::convert_java_new
352378
353379
Inputs:
@@ -432,6 +458,8 @@ std::string expr2javat::convert(
432458
{
433459
if(src.id()=="java-this")
434460
return convert_java_this(src, precedence=15);
461+
if(src.id()=="java_instanceof")
462+
return convert_java_instanceof(src, precedence=15);
435463
else if(src.id()==ID_side_effect &&
436464
(src.get(ID_statement)==ID_java_new ||
437465
src.get(ID_statement)==ID_java_new_array))

src/java_bytecode/java_bytecode_convert.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,13 @@ codet java_bytecode_convertt::convert_instructions(
14671467
op[0].type().get_unsigned_int(ID_width)==32)
14681468
pop(1);
14691469
}
1470+
else if(statement=="instanceof")
1471+
{
1472+
assert(op.size()==1 && results.size()==1);
1473+
1474+
results[0]=
1475+
binary_predicate_exprt(op[0], "java_instanceof", arg0);
1476+
}
14701477
else
14711478
{
14721479
c=codet(statement);

0 commit comments

Comments
 (0)