Displaying 5 results from an estimated 5 matches for "thunk_iterator_m_next".
2012 Mar 15
3
[LLVMdev] Using JIT code to code a program to call C++
...and that one way to call C++ functions is to wrap them in C thunks:
extern "C" {
void thunk_item_M_new( item *addr ) {
new( addr ) item;
}
void thunk_singleton_iterator_M_new( singleton_iterator *addr, item *i ) {
new( addr ) singleton_iterator( *i );
}
bool thunk_iterator_M_next( item_iterator *that, item *result ) {
return that->next( result );
}
} // extern "C"
The first problem is how to allocate an item from LLVM. I know how to create StructTypes and add fields to them, but I don't have to have to parallel the C++ class layout -- that's...
2012 Mar 21
1
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...ss item_iterator {
> public:
> virtual ~item_iterator();
> virtual bool next( item *result ) = 0;
> };
>
> I'm aware that LLVM doesn't know anything about C++ and that one way to call C++ functions is to wrap them in C thunks:
>
> extern "C" bool thunk_iterator_M_next( void *v_that, void *v_result ) {
> item_iterator *const that = static_cast<item_iterator*>( v_that );
> item *const result = static_cast<item*>( v_result );
> return that->next( result );
> }
>
> extern "C" void thunk_iterator_M_delete( void *...
2012 Mar 22
1
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...lic:
>> virtual ~item_iterator();
>> virtual bool next( item *result ) = 0;
>> };
>>
>> I'm aware that LLVM doesn't know anything about C++ and that one way to call C++ functions is to wrap them in C thunks:
>>
>> extern "C" bool thunk_iterator_M_next( void *v_that, void *v_result ) {
>> item_iterator *const that = static_cast<item_iterator*>( v_that );
>> item *const result = static_cast<item*>( v_result );
>> return that->next( result );
>> }
>>
>> extern "C" void thunk_i...
2012 Mar 22
0
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...ed code.
Unfortunately, I'm not following. How is having the code that catches all exceptions in a separate function different from what I proposed (putting the try/catch in the thunks)? (Ideally, I want to minimize layers of function calls.) Again for reference:
extern "C" bool thunk_iterator_M_next( void *v_that, void *v_result,
dtor_pairs *dtors ) {
try {
item_iterator *const that = static_cast<item_iterator*>( v_that );
item *const result = static_cast<item*>( v_result );
return that->next( result );
}
catch ( .....
2012 Mar 23
2
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...eally, I want to minimize layers of function calls.) Again for reference:
>
No reason. But if you have the 'try{}catch(...){}', then it should run the d'tors for you. There's no reason for you to have a "run_dtors" function there.
-bw
> extern "C" bool thunk_iterator_M_next( void *v_that, void *v_result,
> dtor_pairs *dtors ) {
> try {
> item_iterator *const that = static_cast<item_iterator*>( v_that );
> item *const result = static_cast<item*>( v_result );
> return that->next( res...