Skip to content

Commit 841d407

Browse files
author
Daniel Kroening
committed
formatter for Java
1 parent fdf802a commit 841d407

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

src/java_bytecode/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ SRC = bytecode_info.cpp \
2222
java_class_loader_limit.cpp \
2323
java_enum_static_init_unwind_handler.cpp \
2424
java_entry_point.cpp \
25+
java_formatter.cpp \
2526
java_local_variable_table.cpp \
2627
java_object_factory.cpp \
2728
java_pointer_casts.cpp \

src/java_bytecode/java_formatter.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*******************************************************************\
2+
3+
Module:
4+
5+
Author: Daniel Kroening, [email protected]
6+
7+
\*******************************************************************/
8+
9+
#include "java_formatter.h"
10+
11+
#include "expr2java.h"
12+
13+
#include <ostream>
14+
15+
std::ostream &java_formattert::format(std::ostream &os, const exprt &expr)
16+
{
17+
return os << expr2java(expr, ns);
18+
}
19+
20+
std::ostream &java_formattert::format(std::ostream &os, const typet &type)
21+
{
22+
return os << type2java(type, ns);
23+
}
24+
25+
std::ostream &
26+
java_formattert::format(std::ostream &os, const source_locationt &loc)
27+
{
28+
return os << loc;
29+
}

src/java_bytecode/java_formatter.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*******************************************************************\
2+
3+
Module:
4+
5+
Author: Daniel Kroening, [email protected]
6+
7+
\*******************************************************************/
8+
9+
#ifndef CPROVER_JAVA_FORMATTER_H
10+
#define CPROVER_JAVA_FORMATTER_H
11+
12+
#include <util/formatter.h>
13+
14+
class java_formattert : public formattert
15+
{
16+
public:
17+
explicit java_formattert(const namespacet &_ns) : ns(_ns)
18+
{
19+
}
20+
21+
std::ostream &format(std::ostream &, const exprt &) override;
22+
std::ostream &format(std::ostream &, const typet &) override;
23+
std::ostream &format(std::ostream &, const source_locationt &) override;
24+
25+
const namespacet &ns;
26+
};
27+
28+
#endif // CPROVER_JAVA_FORMATTER_H

0 commit comments

Comments
 (0)