Handle complex Qt types to read or write widget properties
Program example:
Dim s As size
s.setSize( 140,50)
button1.size = s
Steps to handle assignment statements
1) Prepare left side
findIdentifierDescription + createVariableAddress
(if variable)
2) Prepare right side
3) Read right side
moveVariableValue( READMODE)
4) Write left side
Write complex component property
Line button1.size = s
1) Compute address of component button1
2) Compute address of component (memory) s
3) none
4) Call method to change component value to variant (getVariant)
and set Property with QObject::setProperty(
variant )
Runtime information needed for 4:
Pointer to getVariant method in s component
Pointer to button1 description (actually the pointer to the widget which
is in the runtime description)
type of property
name of property
Read complex component property
s = button1.size
1) Compute address of component address s
2) Compute address of button component (runtime gui)
3) Call QObject::property( ) and call setVariant to change to comp property
4) Write new pointer to component memory
Initializer method s = Size( 140, 50)
1) Compute address of component s
2) none
3) Call init method which creates and returns pointer to new component
4) Write pointer to new component.
-------------------------------------------------------------------------------------------------------
Structure for component access
COMP_ACCESS_DESC -> comp_type Dim component or GUI component
read access or write access
COMP_ACCESS_DESC -> access_type
Call method, access comp property, call QT method, access QT
property
read/ write complex property, call init method
implement for Interpreter / Compiler
-Dim component
property
read
write
method
event
- Gui component
property
user defined
read
write
QT
read
write
method
qt method
event
qt event
parse varname.propname (read or write)
or varname.methodname( par1expr, par2expr...)
or comp_var_name
or comp_gui_name
or guiname.propname
or guiname.methodname( par1expr1, par2expr2 ...)
or comp_var( initpar1, initpar2...)
Syntax Examples:
var = variable of simple type like integer
compvar = variable with component type
-> Dim compvar As comptype or component created with Formdesigner
compvar = comp( 3 )
comp.method1( 2, 4)
var = comp.method( 2 )
var = Date.static_method( )
comp.prop1 = 5
var = comp.prop3
Information for code generation will be created
in three steps.
1) find description for Identifier found in parser (function findIdentifierDescription)
2) create code to put address of variable on address stack (interpreter)
or ebx stack (compiler) (function createVariableAddress)
3) create code to move variable value (function moveVariableValue)
For an assignment statement idf1 = idf2 the order will be
read idf1
- findIdentifierDescription for idf1
- createVariableAddress for idf1
- read = and call parseExpression for right side
- read var2
- find IdentifierDescription of idf2
- create VariableAddress for idf2
- create Code to read value of var2 with moveVariableValue
in read-mode
- create code to write value of var2 with moveVariableValue in
write mode
The problem is that writing the value of var1 must be suspended until the
right side of the = has completly been parsed and the matching code has been
generated. Therefore a description of every detail that is needed to create
the code to write the left side will be stored in memory. The starting structure
is FACT_DESC with it's access type and the sub_desc_ptr. The access_type
describes the type of the substructure and sub_desc_ptr is normally a pointer
to the substructure.
Parser structure description
FACT_DESC
access_type = TYPE_COMPONENT
sub_desc_ptr = COMP_ACCESS_DESC
Contents of COMP_ACCESS_DESC structure in parser
static methods / init method ??
access_type
TYPE_COMPMETH for method calls
TYPE_COMPPROP for property access
TYPE_QTCOMPMETH for qt methods
TYPE_QTCOMPPROP for qt properties
TYPE_COMPONENT for access to whole
component (without .)
comp_type
TYPE_GUICOMP for GUI components
TYPE_DIMCOMP for components created with
"Dim varname As compname"
TYPE_SCOMPONENT for static component access
gui_desc_ptr = pointer to GUI_HEADER of component for
Gui components
class_desc_ptr = pointer to COMP_HEADER for Dim components
sub_desc_ptr
COMP_PROPERTY if access to property
COMP_METHOD if access-type = TYPE_COMPMETH
Call to Qt method willl immediatly create code and set TFLAG_CODE_READY
interpreter-code
CODE_GUIMCALL
+ (long) pointer to runtime-gui structure of
GUI component
+ (short) function number
Dim component
Get address of variable
read component address from variable memory (indaccess)
Gui component
Get address of GUI runtime description (static place or label)