Re: GEC Compilation of Externals
"Brian Heilig" <Brian.Heilig-tdt4z+Mb/[email protected]>
| Newsgroups | gmane.comp.lang.eiffel.gobo.general |
|---|---|
| Message-ID | <[email protected]> |
Franck wrote:
> Could gec generate "return ALIAS-CONTENT;" if there's
> no 'return' in the alias content. Then it can be both
> ECMA- and legacy 'compliant'. (With a warning for the
> legacy case.)
>
> It is nasty but the heuristics should work nearly all
> the time: I can't think of a useful counter-example where
> there'd be no return in the alias and you do not want
> one generated (well there might be a counter example
> I did not think of...).
The disadvantage to the ECMA approach with inline functions is that
things like stack tracing and assertions are more difficult to
implement. Take a look at the code generated by SE and ISE when the
Eiffel routine is implemented as Eric suggested:
SE without assertions:
/*COM_TIMEOUTS*/
void r232make_new_unshared(T232* C){
{T230*n=((T230*)se_malloc(sizeof(*n))/*8*/);
*n=M230;
r230make_new_unshared(n,/*l274c4\com_timeouts.e*/return (sizeof
(struct _COMMTIMEOUTS));
/*l274c4\com_timeouts.e*/);
/*SFN*/(C->_managed_data/*0*/)=((T0*)n);
}
}
SE with assertions:
/*COM_TIMEOUTS*/
T2 r232sizeof(se_dump_stack*caller){
T2 R=0;
...
R=(return (sizeof (struct _COMMTIMEOUTS)););
...
return R;
}
And ISE generates this code:
EIF_INTEGER_32 Fa9f3k0 (EIF_REFERENCE Current)
{
...
EIF_INTEGER_32 Result = (EIF_INTEGER_32) 0;
...
Result = (EIF_INTEGER_32)(return (sizeof (struct _COMMTIMEOUTS)););
...
return Result;
}
I agree Franck that you could implement legacy and ECMA as you
suggested. The ECMA style introduces other difficulties that will need
to be accounted for.
I'd like to suggest the following change to ECMA. I don't want to
confuse the situation more, but I think it's a good idea.
First the content of C_text must be a sequence of valid C statements.
If you want to return a value you can assign the value to $Result as in...
sizeof: INTEGER is
-- Size to allocate (in bytes)
external
"C inline use <windows.h>"
alias
"$Result = sizeof (struct _COMMTIMEOUTS);"
end
This would generate:
EIF_INTEGER_32 Fa9f3k0 (EIF_REFERENCE Current)
{
...
EIF_INTEGER_32 Result = (EIF_INTEGER_32) 0;
...
Result = sizeof (struct _COMMTIMEOUTS);
...
return Result;
}
Similar to what Franck suggested, if $Result does not appear in C_text
then you can assume it's an expression to support the legacy style.
Brian
------------------------ Yahoo! Groups Sponsor --------------------~-->
Home is just a click away. Make Yahoo! your home page now.
http://us.click.yahoo.com/DHchtC/3FxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->
To Post a message, send it to: [email protected]
To Unsubscribe, send a blank message to: gobo-eiffel-unsubscribe-B11MqFFcr06IwRZHo2/[email protected]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/gobo-eiffel/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/