Skip to content

Commit 850ce41

Browse files
author
Daniel Kroening
committed
move java_method_typet
This will allow us to use it in java_class_typet.
1 parent 70cfdd5 commit 850ce41

File tree

1 file changed

+96
-96
lines changed

1 file changed

+96
-96
lines changed

jbmc/src/java_bytecode/java_types.h

Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,102 @@ inline bool can_cast_type<annotated_typet>(const typet &)
9999
return true;
100100
}
101101

102+
class java_method_typet : public code_typet
103+
{
104+
public:
105+
using code_typet::parameterst;
106+
using code_typet::parametert;
107+
108+
/// Constructs a new code type, i.e. method type
109+
/// \param _parameters: the vector of method parameters
110+
/// \param _return_type: the return type
111+
java_method_typet(parameterst &&_parameters, typet &&_return_type)
112+
: code_typet(std::move(_parameters), std::move(_return_type))
113+
{
114+
set(ID_C_java_method_type, true);
115+
}
116+
117+
/// Constructs a new code type, i.e. method type
118+
/// \param _parameters: the vector of method parameters
119+
/// \param _return_type: the return type
120+
java_method_typet(parameterst &&_parameters, const typet &_return_type)
121+
: code_typet(std::move(_parameters), _return_type)
122+
{
123+
set(ID_C_java_method_type, true);
124+
}
125+
126+
const std::vector<irep_idt> throws_exceptions() const
127+
{
128+
std::vector<irep_idt> exceptions;
129+
for(const auto &e : find(ID_exceptions_thrown_list).get_sub())
130+
exceptions.push_back(e.id());
131+
return exceptions;
132+
}
133+
134+
void add_throws_exceptions(irep_idt exception)
135+
{
136+
add(ID_exceptions_thrown_list).get_sub().push_back(irept(exception));
137+
}
138+
139+
bool get_is_final() const
140+
{
141+
return get_bool(ID_final);
142+
}
143+
144+
void set_is_final(bool is_final)
145+
{
146+
set(ID_final, is_final);
147+
}
148+
149+
bool get_native() const
150+
{
151+
return get_bool(ID_is_native_method);
152+
}
153+
154+
void set_native(bool is_native)
155+
{
156+
set(ID_is_native_method, is_native);
157+
}
158+
159+
bool get_is_varargs() const
160+
{
161+
return get_bool(ID_is_varargs_method);
162+
}
163+
164+
void set_is_varargs(bool is_varargs)
165+
{
166+
set(ID_is_varargs_method, is_varargs);
167+
}
168+
169+
bool is_synthetic() const
170+
{
171+
return get_bool(ID_synthetic);
172+
}
173+
174+
void set_is_synthetic(bool is_synthetic)
175+
{
176+
set(ID_synthetic, is_synthetic);
177+
}
178+
};
179+
180+
template <>
181+
inline bool can_cast_type<java_method_typet>(const typet &type)
182+
{
183+
return type.id() == ID_code && type.get_bool(ID_C_java_method_type);
184+
}
185+
186+
inline const java_method_typet &to_java_method_type(const typet &type)
187+
{
188+
PRECONDITION(can_cast_type<java_method_typet>(type));
189+
return static_cast<const java_method_typet &>(type);
190+
}
191+
192+
inline java_method_typet &to_java_method_type(typet &type)
193+
{
194+
PRECONDITION(can_cast_type<java_method_typet>(type));
195+
return static_cast<java_method_typet &>(type);
196+
}
197+
102198
class java_class_typet:public class_typet
103199
{
104200
public:
@@ -352,102 +448,6 @@ inline bool can_cast_type<java_class_typet>(const typet &type)
352448
return can_cast_type<class_typet>(type);
353449
}
354450

355-
class java_method_typet : public code_typet
356-
{
357-
public:
358-
using code_typet::parameterst;
359-
using code_typet::parametert;
360-
361-
/// Constructs a new code type, i.e. method type
362-
/// \param _parameters: the vector of method parameters
363-
/// \param _return_type: the return type
364-
java_method_typet(parameterst &&_parameters, typet &&_return_type)
365-
: code_typet(std::move(_parameters), std::move(_return_type))
366-
{
367-
set(ID_C_java_method_type, true);
368-
}
369-
370-
/// Constructs a new code type, i.e. method type
371-
/// \param _parameters: the vector of method parameters
372-
/// \param _return_type: the return type
373-
java_method_typet(parameterst &&_parameters, const typet &_return_type)
374-
: code_typet(std::move(_parameters), _return_type)
375-
{
376-
set(ID_C_java_method_type, true);
377-
}
378-
379-
const std::vector<irep_idt> throws_exceptions() const
380-
{
381-
std::vector<irep_idt> exceptions;
382-
for(const auto &e : find(ID_exceptions_thrown_list).get_sub())
383-
exceptions.push_back(e.id());
384-
return exceptions;
385-
}
386-
387-
void add_throws_exceptions(irep_idt exception)
388-
{
389-
add(ID_exceptions_thrown_list).get_sub().push_back(irept(exception));
390-
}
391-
392-
bool get_is_final() const
393-
{
394-
return get_bool(ID_final);
395-
}
396-
397-
void set_is_final(bool is_final)
398-
{
399-
set(ID_final, is_final);
400-
}
401-
402-
bool get_native() const
403-
{
404-
return get_bool(ID_is_native_method);
405-
}
406-
407-
void set_native(bool is_native)
408-
{
409-
set(ID_is_native_method, is_native);
410-
}
411-
412-
bool get_is_varargs() const
413-
{
414-
return get_bool(ID_is_varargs_method);
415-
}
416-
417-
void set_is_varargs(bool is_varargs)
418-
{
419-
set(ID_is_varargs_method, is_varargs);
420-
}
421-
422-
bool is_synthetic() const
423-
{
424-
return get_bool(ID_synthetic);
425-
}
426-
427-
void set_is_synthetic(bool is_synthetic)
428-
{
429-
set(ID_synthetic, is_synthetic);
430-
}
431-
};
432-
433-
template <>
434-
inline bool can_cast_type<java_method_typet>(const typet &type)
435-
{
436-
return type.id() == ID_code && type.get_bool(ID_C_java_method_type);
437-
}
438-
439-
inline const java_method_typet &to_java_method_type(const typet &type)
440-
{
441-
PRECONDITION(can_cast_type<java_method_typet>(type));
442-
return static_cast<const java_method_typet &>(type);
443-
}
444-
445-
inline java_method_typet &to_java_method_type(typet &type)
446-
{
447-
PRECONDITION(can_cast_type<java_method_typet>(type));
448-
return static_cast<java_method_typet &>(type);
449-
}
450-
451451
/// This is a specialization of reference_typet.
452452
/// The subtype is guaranteed to be a struct_tag_typet.
453453
class java_reference_typet : public reference_typet

0 commit comments

Comments
 (0)