[Gambas-user] interpreter?
Benoît Minisini
gambas at ...1...
Thu Jan 23 20:35:25 CET 2003
Le Mercredi 22 Janvier 2003 21:31, Jochen Georges a écrit :
> On Tuesday 21 January 2003 21:45, you wrote:
> > Le Lundi 20 Janvier 2003 14:34, Jochen Georges a écrit :
> > > hi benoit and gambas-gourmets,
>
> ...snip
>
> > The interpreter loads in memory the files generated by the
> > compiler, and then executes them, as needed. The functions and
> > sub you have typed in the editor became "gambas p-code". The
> > gambas p-code is like an assembler that can be interpreted by the
> > gambas interpreter only. Nothing is transformed into C++, nor
> > executed directly by the processor.
>
> thanks for that answer, it is a bit clearer for me now.
> but two questions left:
>
> 111
> the gambas source is compiled and then interpreted?
>
> 222
>
> a gambas component is written in c++:
> it is an interface between gambas and qt
> it translates this
> Button1 Button
> X = 8
> Y = 96
> Width = 304
> Height = 80
> Text = "Button1"
> to that
> Knopf::Knopf( QWidget* parent = 0, const char* name = 0 ) :
> QWidget(parent, name) {
> btn = new QPushButton( this, "btn");
> btn->setGeometry(8, 96, 304, 80);
> btn->setText( tr( "Button1" ) );
> connect( btn, SIGNAL(clicked()), this,
> SLOT(whateverText()));
> } //knopf
>
> if this is right,
>
> who starts the translations, the compiler or the interpreter?
>
>
> thanks for any hint.
>
> beste gruesse
> jochen
>
It is not translated, it is interpreted.
The following stuff:
{ Button1 Button
X = 8
Y = 96
Width = 304
Height = 80
Text = "Button1"
}
is transformed by the compiler into the following code:
hButton = NEW Button(...) AS "Button1"
hButton.X = 8
hButton.Y = 96
hButton.Width = 304
...
And then is compiled into p-code.
When the interpreter is running this code, the gb.qt component is first
loaded. This component tells the interpreter that to instanciate the Button
class, it must call the C++ function "CBUTTON_new", for example, in the
component.
This function then makes the corresponding Qt calls, so that the button is
created as well.
There is no translation from Gambas source code to C++ source code. The C++
code is compiled into components, the Gambas source code is compiled into
Gambas p-code files, and the interpreter interprets these p-code files and
call method into compiled components.
--
Benoît Minisini
mailto:gambas at ...1...
More information about the User
mailing list