Simple types
BO Boolean
BY Byte
SH Short
IN Integer
LO Long
FL Float
DB Double
XD XDouble
ST P String
EN Enum
OB (P) Object
CC P Class (Whole)
CP Class Property
UD P User defined struct
AR P Array
Simple type
Structs
Pointer type
Array
User defined struct
Subtypes
val parameter
ref parameter
class (whole)
class property
object
user defined struct
simple
pointer
struct
array of simple type
array of structs
array of pointer type
---------------------------------------------------------------------------------------------------------
Use as global var
Use as sublocal var
Use as formlocal var
Use as classlocal var
Use as valpar
Use as refpar
Use in Class property
Use as classlocal
Use in user defined structure
Use in Array
(Use in component property)
Test:
Load and save normal value
Load and save as refpar, valpar in call and in method
Load and save as classlocal and property
Load and save as complocal and component property
----------------------------------------------------------------------------------------------------------
Simplification:
Pointer types will only be passed to functions as reference
parameter
this includes
arrays, structs, strings, classpointer, comppointer
Structures may include pointer types and arrays
Classes may include pointer types
Arrays may include structures and pointer types
------------------------------------------------------------------
type description is
TYENT_SIMPLE = 01 = (simple type entry)
TYENT_ARRAY = 02 = (array type (repeat n * type))
TYENT_STRUCT = 03 = (struct type (list different types)) (this includes
components and classes as whole or part)
TYENT_xxx (other type like method )
store as
char type_type
char length of typedescription in byte
type_type =
01..20 simple type
21 array type
22 TYPE_STRUCT struct type
23 TYPE_VSTRUCT Variable of type struct
24 TYPE_PSTRUCT Pointer to whole structure memory (used
for assign structure)
25 TYPE_COMP component type
26 TYPE_VCOMP Variable of type component memory
27 TYPE_CLASS class type
28 TYPE_VCLASS Variable of type class
Definitions of simple type
short typenumber
TYPE_BYTE 01 byte
TYPE_SHORT 02 short
TYPE_INTEGER 03 integer
TYPE_LONG 04 long
05 string
06 float
07 double
08 xdouble
09 object
...
20 TYPE_LASTSIMPLE
Complex types
array type
# dimensions (short)
# entries for each dimension (short)
description subtype (type description)
Open question: Store multidimensional arrays as n times one dimensional
array with n typedefs or single typedef.
struct type
a) description
# subtypes
n * description of subtypes
b) Variable of type struct
23 TYPE_VSTRUCT
long Pointer to structure description entry 22 ...
--------------------------------------------------------------------------
VAR_DESC for variable declaration stores Pointer to type description
---------------------------------------------------------------------------
Examples:
Dim i as integer
simple integer type stored as 01 04 00 03
1 Byte 01 TYENT_SIMPLE
1 Byte 4 = length of type description
2 Byte short TYPE_INTEGER 03
---------------------------------------------------------------------------
Bearbeitung einzelner Variablentypen
- SD) Syntax definition
- FT) Format of type description
- SV) Storing the variable description
- PF) Function calls in parser
- RF) Runtime functions / Code generated
a) as global var
- intp read
- intp write
- comp read
- comp write
b) as formlocal var
- intp read
- intp write
- comp read
- comp write
c) as sublocal var
- intp read
- intp write
- comp read
- comp write
d) whole class
as classlocal
var
- intp read
- in class
- outside of class
- intp write
- in class
- outside of class
- comp read
- in class
- outside of class
- comp write
- in class
- outside of class
e) as class property
- intp read
- in class
- outside of class
- intp write
- in class
- outside of class
- comp read
- in class
- outside of class
- comp write
- in class
- outside of class
f) value parameter
- intp read
- function call
- in function
- intp write
- function call
- in function
- comp read
- function call
- in function
- comp write
- function call
- in function
g) ref parameter
- intp read
- function call
- in function
- intp write
- function call
- in function
- comp read
- function call
- in function
- comp write
- function call
- in function
h) func return
- intp read
- in function
- outside of function
- intp write
- in function
- outside of function
- comp read
- in function
- outside of function
- comp write
- in function
- outside of function
i) read component property
- intp read
- intp write
- comp read
- comp write
j) read component local
- intp read
- comp read
- struct whole
- intp read
- intp write
- comp read
- comp write
- struct subcomponent
- intp read
- intp write
- comp read
- comp write
- array whole
- intp read
- intp write
- comp read
- comp write
- array component
- intp
read
- intp write
- comp read
- comp write
Global variables
Formlocal variables
Sublocal variables
Classlocal variables
Parameter
Global variables
Definition: "Public I As Integer" outside of function and class definition
Format in parser
variable stored as global
simple integer type stored as 01 04 00 03
Code generated:
Interpreter:
CODE_ADRGLB (+ long offset of variable
in global memory)
CODE_RD_BYTE (Je
nach valuelaenge unterschiedlich)
CODE_WR_BYTE
1) Simple types byte, short, int, long, float, double, xdouble
Syntax Definition)
Dim I As Short
Dim I As Integer ...
Format of type description) entfällt
Storage format for variable description in parser
simple integer type stored as 01 04 00 03
1 Byte 01 TYENT_SIMPLE
1 Byte 4 = length of type description
2 Byte short TYPE_INTEGER 03
Function calls in parser)
parse_var.cpp:pa_parse_vardef
Formlocal variables
Definition: "Dim I As Integer" outside of function and class definition
Format in parser
variable stored as global
simple integer type stored as 01 04 00 03
Code generated:
Interpreter:
CODE_ADRGLB (+ long offset of variable
in global memory)
CODE_RD_BYTE (Je
nach valuelaenge unterschiedlich)
CODE_WR_BYTE
1) Simple types byte, short, int, long, float, double, xdouble
Syntax Definition)
Dim I As Short
Dim I As Integer ...
Format of type description) entfällt
Storage format for variable description in parser
simple integer type stored as 01 04 00 03
1 Byte 01 TYENT_SIMPLE
1 Byte 4 = length of type description
2 Byte short TYPE_INTEGER 03
Function calls in parser)
parse_var.cpp:pa_parse_vardef
Sublocal variables
Definition: "Dim I As Integer" in function body
Format in parser
variable stored as global
simple integer type stored as 01 04 00 03
Code generated:
Interpreter:
CODE_ADRGLB (+ long offset of variable
in global memory)
CODE_RD_BYTE (Je
nach valuelaenge unterschiedlich)
CODE_WR_BYTE
1) Simple types byte, short, int, long, float, double, xdouble
Syntax Definition)
Dim I As Short
Dim I As Integer ...
Format of type description) entfällt
Storage format for variable description in parser
simple integer type stored as 01 04 00 03
1 Byte 01 TYENT_SIMPLE
1 Byte 4 = length of type description
2 Byte short TYPE_INTEGER 03
Function calls in parser)
parse_var.cpp:pa_parse_vardef
Classlocal variables
Definition: "Dim I As Integer" in class body (outside of method definition)
Format in parser
variable stored as global
simple integer type stored as 01 04 00 03
Code generated:
Interpreter:
CODE_ADRGLB (+ long offset of variable
in global memory)
CODE_RD_BYTE (Je
nach valuelaenge unterschiedlich)
CODE_WR_BYTE
1) Simple types byte, short, int, long, float, double, xdouble
Syntax Definition)
Dim I As Short
Dim I As Integer ...
Format of type description) entfällt
Storage format for variable description in parser
simple integer type stored as 01 04 00 03
1 Byte 01 TYENT_SIMPLE
1 Byte 4 = length of type description
2 Byte short TYPE_INTEGER 03
Function calls in parser)
parse_var.cpp:pa_parse_vardef
2) Object types
3) Global, Modlocal, Sublocal,
4) Classes
5) Components
6) User defined structures
7) Arrays
-------------------------------------------------------------------------------------------------------
Handling Object variables
-------------------------------------------------------------------------------------------------------
Handling operators
-------------------------------------------------------------------------------------------------------
Handling Function calls
------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
Type description
Simple type
1 Byte 01 TYENT_SIMPLE
1 Byte 3 = length of type description
1 Byte <type-specifier> 03
<type-specifier> = TYPE_BYTE, TYPE_SHORT, TYPE_INTEGER, TYPE_LONG
...
Ptr Struct type
1 Byte 03 TYENT_STRUCT
1 Byte Length of type definition
1 Long Pointer to Struct description
Ptr struct entry (Pointer to struct needed? Offset of entry is
stored in entry)
1 Byte 04 TYENT_ESTRUCT
1 Byte Length of type definition
1 Long Pointer to Struct entry description
Struct description (created by precompiler)
1 Byte # of subentries
for each subentry
- # length of name for subentry
- name for subentry
- long offset for subentry
- type description for subentry
Const description
Enum description
Array Type
1 Byte 02 TYENT_ARRAY
1 Byte Length of type description (includes all sub descriptions)
1 Byte number of dimensions
n * long number of entries for each dimension
### Type description for entrytype ###
----------------------------------------------------------------------------------------------------------
Code generation
Compute address of simple type value
If constant value insert code to load value on comp_stack at runtime.
If enum change name to value and treat like constant value.
Address start:
global var: get address of global var
sublocal var: get address of sublocal var
value parameter: get address of sublocal var that has been reserved
for the parameter value
in sub start: create code to read/write value and put in sublocal
var
read/write in subroutine: create access to sublocal var
ref:-parameter
in method get address of sublocal
var that has been reserved for the parameter value
create code to dereference address on adr-stack (Indirect
access)
call method (how to handle constant in
parameter ??)
don't read value for address on address stack (keep address
in sublocal var)
subroutine return
in method
handle like sublocal var reserved for return value (init value=
0 on funcstart)
call method
retreave return value from comp_stack
formlocal var: get address of formlocal var
classreference (class.comp): get address of class (get pointer to
class description)
exec class element access function to evaluate following
class component with class description
component reference (comp.subcomp): get address of component memory (get
pointer to component description)
exec component element access function to evaluate
following class component with class description
If structure component (get pointer to structure description)
add offset of component to current address
If array element
evaluate position of element x in array and add offset of element
x to current address
If simple type
Create read/write value code