Re: [libertyeiffel] Reentrant deep_twin
- From:
- Cyril Adrian
- Date:
- 2012-01-02 @ 15:19
Hi Paolo, all,
First of all, happy new year to all our Liberty Eiffelists :-)
2011/11/11 Paolo Redaelli <paolo.redaelli@gmail.com>
> **
> Cyril can you please give me some hints on how to add a new built-in?
>
A built-in is a multipart beast. You need to know:
- how to define the function
- how to call the function
for each supported back-end (currently, C, maybe Java, and the interpreter).
Let's talk C only: in src/smarteiffel/generation/c
In SmartEiffel parlance, a function call is the "mapping" of the function.
The class C_MAPPER takes care of that by either generating a function call
or inlining the code. For some builtins, the "call" is replaced by some
inline code. That's *not* the case for *deep_twin*.
For *deep_twin*, we need a "wrapper" (a helper function): see
C_NATIVE_NEED_WRAPPER.visit_native_built_in
Therefore, the mapping is the standard one (i.e. generation of a C function
call to a C function that will also be generated).
The content of the wrapper itself is defined in
C_LIVE_TYPE_COMPILER.visit_run_feature_8 which prepares the signature and
calls cpp.native_function_mapper.compile(visited)
The latter contains the code generation you spotted :-)
Cheers,
*Cyril ADRIAN*
*http://www.cadrian.net/cyril*
[image: Facebook] <https://www.facebook.com/cyril.adrian> [image:
Twitter]<https://twitter.com/cadbart> [image:
LinkedIn] <http://fr.linkedin.com/in/cadrian> [image: Google
Plus]<https://plus.google.com/100388810006463519079/posts> [image:
Google
Calendar]<https://www.google.com/calendar/embed?src=1t93vvvrdc26ee0f83p0cunj60%40group.calendar.google.com&ctz=Europe/Paris>
Contact me: [image: Google Talk] cyril.adrian@gmail.com
[image: Twitter] <http://twitter.com/cadbart> Latest tweet: [Liberty]
http://t.co/Vauhqtfj Cyril Adrian - working on pointers
Follow @cadbart <http://twitter.com/cadbart> Reply
<http://twitter.com/?status=@cadbart%20&in_reply_to_status_id=153502349699190800&in_reply_to=cadbart>
Retweet
<http://twitter.com/?status=RT%20%40cadbart%3A%20%5BLiberty%5D%20http%3A%2F%2Ft.co%2FVauhqtfj%20Cyril%20Adrian%20-%20working%20on%20pointers>
16:46 Jan-01<http://twitter.com/cadbart/statuses/153502349699190787>
Get this email app!
<http://www.wisestamp.com/apps/twitter?utm_source=extension&utm_medium=email&utm_term=twitter&utm_campaign=apps>
[image: Google Plus] <http://plus.google.com/100388810006463519079> My
latest G+: LinkedIn est décidément de plus en plus
intrusif....<http://plus.google.com/100388810006463519079/posts/fB4C49eLbr1/>
My G+ <http://plus.google.com/100388810006463519079> -
Posts<http://plus.google.com/100388810006463519079/posts/>- Add
to Circles <http://plus.google.com/100388810006463519079/about/> - 09:50
Dec-21 <http://plus.google.com/100388810006463519079>
Get this email app!
<http://www.wisestamp.com/apps/plus?utm_source=extension&utm_medium=email&utm_term=plus&utm_campaign=apps>
[image: My QR VCard]
Get a signature like this.
<http://r1.wisestamp.com/r/landing?promo=17&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_17>
CLICK
HERE.<http://r1.wisestamp.com/r/landing?promo=17&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_17>
Re: [libertyeiffel] Reentrant deep_twin
- From:
- Paolo Redaelli
- Date:
- 2012-01-03 @ 17:05
Il 02/01/2012 16:19, Cyril ADRIAN ha scritto:
> Hi Paolo, all,
>
> First of all, happy new year to all our Liberty Eiffelists :-)
>
> 2011/11/11 Paolo Redaelli <paolo.redaelli@gmail.com
> <mailto:paolo.redaelli@gmail.com>>
>
> Cyril can you please give me some hints on how to add a new built-in?
>
>
> A built-in is a multipart beast. You need to know:
> - how to define the function
> - how to call the function
>
> for each supported back-end (currently, C, maybe Java, and the
> interpreter).
>
> Let's talk C only: in src/smarteiffel/generation/c
>
> In SmartEiffel parlance, a function call is the "mapping" of the
> function. The class C_MAPPER takes care of that by either generating a
> function call or inlining the code. For some builtins, the "call" is
> replaced by some inline code. That's *_not_* the case for /deep_twin/.
>
> For /deep_twin/, we need a "wrapper" (a helper function): see
> C_NATIVE_NEED_WRAPPER.visit_native_built_in
> Therefore, the mapping is the standard one (i.e. generation of a C
> function call to a C function that will also be generated).
>
> The content of the wrapper itself is defined in
> C_LIVE_TYPE_COMPILER.visit_run_feature_8 which prepares the signature
> and calls cpp.native_function_mapper.compile(visited)
>
> The latter contains the code generation you spotted :-)
>
Thank you very much! The informations you gave here are (almost) exactly
what I need; in fact I may leave reentrant_deep_twin under the wood of
the (C) runtime but it may be useful to expose it at Eiffel level to
allow for implementation with other backends....
Re: [libertyeiffel] Reentrant deep_twin
- From:
-
- Date:
- 2012-01-03 @ 07:28
Hi all,
Happy near year to all and long life to Liberty.
--
Christophe
----------
----- Mail original -----
De: "Cyril ADRIAN" <cyril.adrian@gmail.com>
À: libertyeiffel@librelist.com
Envoyé: Lundi 2 Janvier 2012 16:19:11
Objet: Re: [libertyeiffel] Reentrant deep_twin
Hi Paolo, all,
First of all, happy new year to all our Liberty Eiffelists :-)
Cheers,
Cyril A DRIAN