Thread View: chorus.os.chorus
1 messages
1 total messages
Started by Eric Valette
Thu, 03 Jan 1991 11:00
Cfront 2.0 an inline functions
Author: Eric Valette
Date: Thu, 03 Jan 1991 11:00
Date: Thu, 03 Jan 1991 11:00
122 lines
2576 bytes
2576 bytes
/*
* The following small c++ program has been translated to c using
* one Cfront 2.0 port. If you look at generated c code, you will
* see that the code generated for inlines member functions is different
* for local variables and global variables (it is also true for global
* pointers).
*
* Could someone explain me why ?
*
* PS: I think that the code is ineffective. Tell me if I am wrong.
*
*/
/* Small C++ program
* --------------------------------------------------------------------------
*
*/
class example {
private :
int a;
public :
int getVal() {return a;}
void setVal(int val) {a = val;}
};
example glob;
void f()
{
example loc;
int a = 1;
int b = 2;
int resu;
loc.setVal(1);
resu = loc.getVal();
glob.setVal(1);
resu = glob.getVal();
}
/*
* Generated C code
* -------------------------------------------------------------------------
*
*/
/* <<AT&T C++ Translator 2.00.02 08/25/89>> */
/* < kt34.cxx > */
char *__vec_new ();
char __vec_delete ();
typedef int (*__vptp)();
struct __mptr {
short d;
short i;
__vptp f;
};
struct example { /* sizeof example == 4 */
int a__7example ;
};
struct example glob = {
0 };
char f__Fv ()
{
struct example __1loc ;
int __1a ;
int __1b ;
int __1resu ;
struct example *__0__Xthis00a3jpkk ;
struct example *__0__Xthis0020bpkk ;
__1a = 1 ;
__1b = 2 ;
( ((&__1loc )->a__7example = 1 ), (((char )0 ))) ;
__1resu = ( (&__1loc )->a__7example ) ;
/*
* for local variables the c code is what I expected.
*/
( (__0__Xthis00a3jpkk = (&glob )), ( (__0__Xthis00a3jpkk ->a__7example = 1 ), (((char )0 ))) ) ;
__1resu = ( (__0__Xthis0020bpkk = (&glob )), ( __0__Xthis0020bpkk ->a__7example ) ) ;
/*
* Why two copies? Why into two different local variables?
*/
}
/*
* Thanks for answers and happy new year.
*/
--
__
/ ` Eric Valette
/-- __ o _. Chorus Systemes
(___, / (_(_(__ 6 avenue Gustave Eiffel
F-78182, St-Quentin-en-Yvelines-Cedex
Tel: +33 (1) 30 64 82 00 Fax: +33 (1) 30 57 00 66
E-mail: ev@chorus.fr or ev%chorus.fr@mcsun.EU.net
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads