20#ifndef REALM_CODEDESC_H
21#define REALM_CODEDESC_H
70 const T &
as(
void)
const;
89#define REALM_TYPE_KINDS(__func__) \
90 __func__(OpaqueKind, OpaqueFields, f_opaque) __func__( \
91 IntegerKind, IntegerFields, \
92 f_integer) __func__(FloatingPointKind, FloatingPointFields, \
93 f_float) __func__(PointerKind, PointerFields, \
94 f_pointer) __func__(FunctionPointerKind, \
95 FunctionPointerFields, \
101#define KINDS_ENUM(k, f, n) k,
107#define FIELDOBJ_METHODS(classname) \
108 void destroy(void); \
109 void copy_from(const classname &rhs); \
110 bool is_equal(const classname &rhs) const; \
111 template <typename S> \
112 bool serialize(S &s) const; \
113 template <typename S> \
114 bool deserialize(S &s)
149#undef FIELDOBJ_METHODS
153#define FIELDS_ENTRY(k, f, n) f n;
162 Type(
Kind _kind,
size_t _size_bits,
size_t _alignment_bits);
176 IntegerType(
size_t _size_bits,
bool _signed,
size_t _alignment_bits = 0);
187 size_t _alignment_bits = 0);
202 size_t _alignment_bits = 0);
204 size_t _size_bits = 0,
size_t _alignment_bits = 0);
206 const Type &_param2_type,
size_t _size_bits = 0,
207 size_t _alignment_bits = 0);
209 const Type &_param2_type,
const Type &_param3_type,
210 size_t _size_bits = 0,
size_t _alignment_bits = 0);
212 const Type &_param2_type,
const Type &_param3_type,
213 const Type &_param4_type,
size_t _size_bits = 0,
214 size_t _alignment_bits = 0);
216 const Type &_param2_type,
const Type &_param3_type,
217 const Type &_param4_type,
const Type &_param5_type,
218 size_t _size_bits = 0,
size_t _alignment_bits = 0);
220 const Type &_param2_type,
const Type &_param3_type,
221 const Type &_param4_type,
const Type &_param5_type,
222 const Type &_param6_type,
size_t _size_bits = 0,
223 size_t _alignment_bits = 0);
234 template <
typename T>
236 template <
typename T>
257 template <
typename T>
288 template <
typename T>
296 template <
typename S>
299 template <
typename S>
310 template <
typename S>
313 template <
typename S>
333 template <
typename S>
340 virtual void print(std::ostream &os)
const = 0;
343 template <
typename S>
375 const std::type_info &target_impl_type) = 0;
379 const std::type_info &target_impl_type);
382 const std::type_info &target_impl_type) = 0;
386 const std::type_info &target_impl_type);
389 template <
typename TARGET_TYPE>
392 template <
typename TARGET_TYPE>
395 template <
typename TARGET_TYPE>
398 template <
typename TARGET_TYPE>
420 template <
typename T>
423 return reinterpret_cast<T
>(fnptr);
426 template <
typename S>
429 template <
typename S>
440 virtual void print(std::ostream &os)
const;
446#ifdef REALM_USE_DLFCN
449 DSOReferenceImplementation(
const std::string &_dso_name,
450 const std::string &_symbol_name);
452 virtual ~DSOReferenceImplementation(
void);
456 virtual bool is_portable(
void)
const;
458 template <
typename S>
461 template <
typename S>
465 DSOReferenceImplementation(
void);
468 DSOReferenceImplementation>
471 virtual void print(std::ostream &os)
const;
473#ifdef REALM_USE_DLADDR
475 static DSOReferenceImplementation *
479 std::string dso_name, symbol_name;
487 DSOCodeTranslator(
void);
489 virtual ~DSOCodeTranslator(
void);
491 virtual bool can_translate(
const std::type_info &source_impl_type,
492 const std::type_info &target_impl_type);
494 virtual CodeImplementation *translate(
const CodeImplementation *source,
495 const std::type_info &target_impl_type);
498 virtual bool can_translate(
const CodeDescriptor &source_codedesc,
499 const std::type_info &target_impl_type);
501 virtual CodeImplementation *translate(
const CodeDescriptor &source_codedesc,
502 const std::type_info &target_impl_type);
505 std::map<std::string, void *> modules_loaded;
511#include "realm/codedesc.inl"
513#undef REALM_TYPE_KINDS
Definition codedesc.h:249
CodeDescriptor & operator=(const CodeDescriptor &rhs)
const T * find_impl(void) const
void copy_from(const CodeDescriptor &rhs)
bool has_portable_implementations(void) const
CodeDescriptor & set_type(const Type &_t)
friend std::ostream & operator<<(std::ostream &os, const CodeDescriptor &cd)
CodeDescriptor(const Type &_t)
std::vector< CodeProperty * > m_props
Definition codedesc.h:307
bool serialize(S &serializer, bool portable) const
CodeDescriptor & add_implementation(CodeImplementation *impl)
std::vector< CodeImplementation * > m_impls
Definition codedesc.h:306
bool create_portable_implementation(void)
Type m_type
Definition codedesc.h:305
const std::vector< CodeImplementation * > & implementations(void) const
const std::vector< CodeProperty * > & properties(void) const
CodeDescriptor(const CodeDescriptor &rhs)
CodeDescriptor & add_property(CodeProperty *prop)
bool deserialize(S &deserializer)
const Type & type(void) const
Definition codedesc.h:317
virtual bool is_portable(void) const =0
static CodeImplementation * deserialize_new(S &deserializer)
virtual CodeImplementation * clone(void) const =0
friend std::ostream & operator<<(std::ostream &os, const CodeImplementation &ci)
virtual ~CodeImplementation(void)
virtual void print(std::ostream &os) const =0
Definition codedesc.h:347
virtual ~CodeProperty(void)
virtual bool is_portable(void) const =0
virtual CodeProperty * clone(void) const =0
Definition codedesc.h:367
CodeTranslator(const std::string &_name)
bool can_translate(const std::type_info &source_impl_type)
TARGET_TYPE * translate(const CodeDescriptor &source_codedesc)
virtual CodeImplementation * translate(const CodeDescriptor &source_codedesc, const std::type_info &target_impl_type)
virtual CodeImplementation * translate(const CodeImplementation *source, const std::type_info &target_impl_type)=0
virtual bool can_translate(const std::type_info &source_impl_type, const std::type_info &target_impl_type)=0
std::string name
Definition codedesc.h:401
virtual bool can_translate(const CodeDescriptor &source_codedesc, const std::type_info &target_impl_type)
bool can_translate(const CodeDescriptor &source_codedesc)
virtual ~CodeTranslator(void)
TARGET_TYPE * translate(const CodeImplementation *source)
Definition codedesc.h:408
static Serialization::PolymorphicSerdezSubclass< CodeImplementation, FunctionPointerImplementation > serdez_subclass
Definition codedesc.h:438
static CodeImplementation * deserialize_new(S &deserializer)
virtual bool is_portable(void) const
virtual ~FunctionPointerImplementation(void)
virtual CodeImplementation * clone(void) const
T get_impl(void) const
Definition codedesc.h:421
virtual void print(std::ostream &os) const
FunctionPointerImplementation(void(*_fnptr)())
bool serialize(S &serializer) const
REALM_INTERNAL_API_EXTERNAL_LINKAGE FunctionPointerImplementation(void)
Definition codedesc.h:196
static const Type::Kind KIND
Definition codedesc.h:198
FunctionPointerType(const Type &_return_type, const Type &_param1_type, const Type &_param2_type, const Type &_param3_type, const Type &_param4_type, const Type &_param5_type, size_t _size_bits=0, size_t _alignment_bits=0)
const Type & return_type(void) const
std::vector< Type > & param_types(void)
FunctionPointerType(const Type &_return_type, const Type &_param1_type, const Type &_param2_type, const Type &_param3_type, const Type &_param4_type, const Type &_param5_type, const Type &_param6_type, size_t _size_bits=0, size_t _alignment_bits=0)
FunctionPointerType(const Type &_return_type, const Type &_param1_type, const Type &_param2_type, const Type &_param3_type, size_t _size_bits=0, size_t _alignment_bits=0)
const std::vector< Type > & param_types(void) const
FunctionPointerType(const Type &_return_type, const Type &_param1_type, const Type &_param2_type, size_t _size_bits=0, size_t _alignment_bits=0)
FunctionPointerType(const Type &_return_type, const Type &_param1_type, const Type &_param2_type, const Type &_param3_type, const Type &_param4_type, size_t _size_bits=0, size_t _alignment_bits=0)
FunctionPointerType(const Type &_return_type, const Type &_param1_type, size_t _size_bits=0, size_t _alignment_bits=0)
FunctionPointerType(const Type &_return_type, size_t _size_bits=0, size_t _alignment_bits=0)
Definition codedesc.h:172
const bool & is_signed(void) const
static const Type::Kind KIND
Definition codedesc.h:174
IntegerType(size_t _size_bits, bool _signed, size_t _alignment_bits=0)
Definition codedesc.h:165
static const Type::Kind KIND
Definition codedesc.h:167
OpaqueType(size_t _size_bits, size_t _alignment_bits=0)
Definition codedesc.h:182
const bool & is_const(void) const
PointerType(const Type &_base_type, bool _const=false, size_t _size_bits=0, size_t _alignment_bits=0)
const Type & base_type(void) const
static const Type::Kind KIND
Definition codedesc.h:184
Definition serialize.h:363
const size_t & size_bits(void) const
friend bool deserialize(S &os, Type &t)
void copy_from(const Type &rhs)
Type & operator=(const Type &rhs)
Kind
Definition codedesc.h:99
@ InvalidKind
Definition codedesc.h:100
friend std::ostream & operator<<(std::ostream &os, const Type &t)
size_t & alignment_bits(void)
CommonFields f_common
Definition codedesc.h:152
bool operator==(const Type &rhs) const
const size_t & alignment_bits(void) const
static Type from_cpp_value(const T &value)
friend bool serialize(S &os, const Type &t)
bool operator!=(const Type &rhs) const
Type(Kind _kind, size_t _size_bits, size_t _alignment_bits)
bool is_valid(void) const
static Type from_cpp_type(void)
#define FIELDS_ENTRY(k, f, n)
Definition codedesc.h:153
#define KINDS_ENUM(k, f, n)
Definition codedesc.h:101
#define REALM_TYPE_KINDS(__func__)
Definition codedesc.h:89
#define REALM_INTERNAL_API_EXTERNAL_LINKAGE
Definition compiler_support.h:218
#define REALM_PUBLIC_API
Definition compiler_support.h:217
Type from_cpp_value(const T &value)
Definition activemsg.h:38
bool serialize(S &serdez, const ByteArrayRef &a)
bool deserialize(S &serdez, ByteArray &a)
Definition codedesc.h:115
FIELDOBJ_METHODS(CommonFields)
Kind kind
Definition codedesc.h:116
size_t alignment_bits
Definition codedesc.h:118
size_t size_bits
Definition codedesc.h:117
Definition codedesc.h:132
FIELDOBJ_METHODS(FloatingPointFields)
Definition codedesc.h:143
std::vector< Type > * param_types
Definition codedesc.h:145
FIELDOBJ_METHODS(FunctionPointerFields)
Type * return_type
Definition codedesc.h:144
Definition codedesc.h:127
bool is_signed
Definition codedesc.h:128
FIELDOBJ_METHODS(IntegerFields)
Definition codedesc.h:122
FIELDOBJ_METHODS(OpaqueFields)
Definition codedesc.h:137
FIELDOBJ_METHODS(PointerFields)
bool is_const
Definition codedesc.h:139
Type * base_type
Definition codedesc.h:138