2007-12-30 17:41:49 +01:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
|
|
class.h
|
|
|
|
|
|
|
|
|
|
Class management
|
|
|
|
|
|
|
|
|
|
(c) 2000-2007 Benoit Minisini <gambas@users.sourceforge.net>
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
2008-08-14 21:42:27 +02:00
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-12-30 17:41:49 +01:00
|
|
|
|
the Free Software Foundation; either version 1, or (at your option)
|
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2008-08-14 21:42:27 +02:00
|
|
|
|
GNU General Public License for more details.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-08-14 21:42:27 +02:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-12-30 17:41:49 +01:00
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef __GBC_CLASS_H
|
|
|
|
|
#define __GBC_CLASS_H
|
|
|
|
|
|
|
|
|
|
#include "gbc_type.h"
|
|
|
|
|
#include "gb_table.h"
|
|
|
|
|
#include "gbc_trans.h"
|
|
|
|
|
|
|
|
|
|
#define FUNC_INIT_STATIC 0
|
|
|
|
|
#define FUNC_INIT_DYNAMIC 1
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
TYPE type;
|
|
|
|
|
int value;
|
|
|
|
|
}
|
|
|
|
|
PACKED
|
|
|
|
|
CLASS_SYMBOL_INFO;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
SYMBOL symbol;
|
|
|
|
|
CLASS_SYMBOL_INFO global;
|
|
|
|
|
CLASS_SYMBOL_INFO local;
|
|
|
|
|
int class;
|
|
|
|
|
int unknown;
|
|
|
|
|
unsigned used : 1;
|
|
|
|
|
unsigned _reserved : 31;
|
|
|
|
|
}
|
|
|
|
|
PACKED
|
|
|
|
|
CLASS_SYMBOL;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
TRANS_PARAM PARAM;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
TYPE type;
|
|
|
|
|
int index;
|
|
|
|
|
int pos;
|
|
|
|
|
int size;
|
|
|
|
|
}
|
|
|
|
|
VARIABLE;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
int num;
|
|
|
|
|
int param;
|
|
|
|
|
}
|
|
|
|
|
VARIABLE_INIT;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
TYPE type;
|
|
|
|
|
int index;
|
|
|
|
|
int value;
|
|
|
|
|
int line;
|
2008-01-06 19:49:23 +01:00
|
|
|
|
int64_t lvalue;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
}
|
|
|
|
|
CONSTANT;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
TYPE type; // Return value datatype
|
2008-01-19 18:52:05 +01:00
|
|
|
|
int name; // Function name index in class symbol table
|
|
|
|
|
|
|
|
|
|
char nparam; // Maximum number of arguments
|
|
|
|
|
char npmin; // Minimum number of arguments
|
|
|
|
|
char vararg; // If this function accepts extra arguments
|
[DEVELOPMENT ENVIRONMENT]
* BUG: Use TextEdit.RichText insted of TextEdit.Text.
* BUG: END SUB can be the end of a method. The class analyze now takes
that into account.
[HELP]
* BUG: Fixed the generated treeview.
[COMPILER]
* OPT: The NOT operator used just at the beginning of a conditional
expression is optimized. Consequently, an expression like 'IF NOT 2' is
now equivalent to 'IF 2 = 0' and not to 'IF (NOT 2) <> 0' as before. In
other words, the boolean conversion is now done before the NOT, and not
after. The following instructions are concerned: IF, WHILE, UNTIL.
* NEW: BYREF is new keyword that is a more readable synonymous of '@'.
[GB.DB.FORM]
* BUG: Correctly manage data controls inside TabStrip-like containers.
* BUG: Setting the focus on a non-initialized DataControl does not raise
an error anymore.
[GB.GTK]
* BUG: HSplitter.Layout and VSplitter.Layout now work correctly. It is a
list of children widths, hidden children having a zero width.
* BUG: Window arrangement is done before the Open event is raised, as in
gb.qt.
* BUG: Keyboard, focus and mouse events now work correctly on Window and
DrawingArea controls.
[GB.QT]
* BUG: HSplitter.Layout and VSplitter.Layout now work correctly. It is a
list of children widths, hidden children having a zero width.
* BUG: Many warning fixes.
* BUG: Now the Control.Visible property works like in gb.gtk, i.e. it
returns if the control was not explicitely hidden.
git-svn-id: svn://localhost/gambas/trunk@1060 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-02-06 01:25:48 +01:00
|
|
|
|
char _reserved;
|
2008-01-19 18:52:05 +01:00
|
|
|
|
short nlocal; // Local variable count
|
|
|
|
|
short nctrl; // Control structure variable count
|
2008-02-24 17:29:02 +01:00
|
|
|
|
uint64_t byref; // Byref mask
|
2008-01-19 18:52:05 +01:00
|
|
|
|
PARAM *local; // Datatypes of local variables
|
|
|
|
|
PARAM *param; // Datatypes of arguments
|
|
|
|
|
|
|
|
|
|
PATTERN *start; // Starts compilation from there
|
|
|
|
|
int line; // ...which is this line
|
|
|
|
|
ushort *code; // Compile bytecode
|
[DEVELOPMENT ENVIRONMENT]
* BUG: Use TextEdit.RichText insted of TextEdit.Text.
* BUG: END SUB can be the end of a method. The class analyze now takes
that into account.
[HELP]
* BUG: Fixed the generated treeview.
[COMPILER]
* OPT: The NOT operator used just at the beginning of a conditional
expression is optimized. Consequently, an expression like 'IF NOT 2' is
now equivalent to 'IF 2 = 0' and not to 'IF (NOT 2) <> 0' as before. In
other words, the boolean conversion is now done before the NOT, and not
after. The following instructions are concerned: IF, WHILE, UNTIL.
* NEW: BYREF is new keyword that is a more readable synonymous of '@'.
[GB.DB.FORM]
* BUG: Correctly manage data controls inside TabStrip-like containers.
* BUG: Setting the focus on a non-initialized DataControl does not raise
an error anymore.
[GB.GTK]
* BUG: HSplitter.Layout and VSplitter.Layout now work correctly. It is a
list of children widths, hidden children having a zero width.
* BUG: Window arrangement is done before the Open event is raised, as in
gb.qt.
* BUG: Keyboard, focus and mouse events now work correctly on Window and
DrawingArea controls.
[GB.QT]
* BUG: HSplitter.Layout and VSplitter.Layout now work correctly. It is a
list of children widths, hidden children having a zero width.
* BUG: Many warning fixes.
* BUG: Now the Control.Visible property works like in gb.gtk, i.e. it
returns if the control was not explicitely hidden.
git-svn-id: svn://localhost/gambas/trunk@1060 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-02-06 01:25:48 +01:00
|
|
|
|
|
2008-03-17 15:54:17 +01:00
|
|
|
|
short *pos_line; // Bytecode position of each code line
|
|
|
|
|
|
2008-01-19 18:52:05 +01:00
|
|
|
|
ushort ncode; // Number of instructions
|
[DEVELOPMENT ENVIRONMENT]
* BUG: Use TextEdit.RichText insted of TextEdit.Text.
* BUG: END SUB can be the end of a method. The class analyze now takes
that into account.
[HELP]
* BUG: Fixed the generated treeview.
[COMPILER]
* OPT: The NOT operator used just at the beginning of a conditional
expression is optimized. Consequently, an expression like 'IF NOT 2' is
now equivalent to 'IF 2 = 0' and not to 'IF (NOT 2) <> 0' as before. In
other words, the boolean conversion is now done before the NOT, and not
after. The following instructions are concerned: IF, WHILE, UNTIL.
* NEW: BYREF is new keyword that is a more readable synonymous of '@'.
[GB.DB.FORM]
* BUG: Correctly manage data controls inside TabStrip-like containers.
* BUG: Setting the focus on a non-initialized DataControl does not raise
an error anymore.
[GB.GTK]
* BUG: HSplitter.Layout and VSplitter.Layout now work correctly. It is a
list of children widths, hidden children having a zero width.
* BUG: Window arrangement is done before the Open event is raised, as in
gb.qt.
* BUG: Keyboard, focus and mouse events now work correctly on Window and
DrawingArea controls.
[GB.QT]
* BUG: HSplitter.Layout and VSplitter.Layout now work correctly. It is a
list of children widths, hidden children having a zero width.
* BUG: Many warning fixes.
* BUG: Now the Control.Visible property works like in gb.gtk, i.e. it
returns if the control was not explicitely hidden.
git-svn-id: svn://localhost/gambas/trunk@1060 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-02-06 01:25:48 +01:00
|
|
|
|
ushort ncode_max; // Size of the bytecode allocation
|
2008-01-19 18:52:05 +01:00
|
|
|
|
|
|
|
|
|
short last_code; // Last compiled bytecode position
|
2008-03-17 15:54:17 +01:00
|
|
|
|
short last_code2; // Last last compiled bytecode position
|
2008-01-19 18:52:05 +01:00
|
|
|
|
short stack; // Needed stack
|
|
|
|
|
short finally; // FINALLY position
|
|
|
|
|
short catch; // CATCH position
|
2008-03-17 15:54:17 +01:00
|
|
|
|
short _reserved2;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
}
|
|
|
|
|
PACKED
|
|
|
|
|
FUNCTION;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
TYPE type; /* type de la valeur de retour */
|
|
|
|
|
int name; /* index du nom de la fonction dans la table des symboles de la classe */
|
|
|
|
|
PARAM *param; /* Liste des param<61>res */
|
|
|
|
|
short nparam; /* nombre de param<61>res */
|
|
|
|
|
short _reserved;
|
|
|
|
|
}
|
|
|
|
|
PACKED
|
|
|
|
|
EVENT;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
TYPE type; /* type de la valeur de retour */
|
|
|
|
|
int name; /* function name index */
|
|
|
|
|
PARAM *param; /* Liste des param<61>res */
|
|
|
|
|
short nparam; /* nombre de param<61>res */
|
|
|
|
|
short _reserved;
|
|
|
|
|
int library; /* library name index */
|
|
|
|
|
int alias; /* library function name index */
|
|
|
|
|
}
|
|
|
|
|
PACKED
|
|
|
|
|
EXTFUNC;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
TYPE type; /* property type */
|
|
|
|
|
int name; /* property name */
|
|
|
|
|
int line; /* the line where the property is declared */
|
|
|
|
|
int comment; /* property string description, added to datatype */
|
|
|
|
|
short read; /* read function */
|
|
|
|
|
short write; /* write function */
|
|
|
|
|
}
|
|
|
|
|
PACKED
|
|
|
|
|
PROPERTY;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
TYPE type; /* Type du tableau */
|
|
|
|
|
int ndim; /* nombre de dimensions */
|
|
|
|
|
int dim[MAX_ARRAY_DIM]; /* dimensions du tableau */
|
|
|
|
|
}
|
|
|
|
|
CLASS_ARRAY;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
int nfield; /* nombre de champs dans la structure */
|
|
|
|
|
VARIABLE *field; /* champs de la structure */
|
|
|
|
|
}
|
|
|
|
|
CLASS_STRUCT;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
int index;
|
|
|
|
|
bool used;
|
2008-05-13 14:52:06 +02:00
|
|
|
|
bool exported;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
}
|
|
|
|
|
CLASS_REF;
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
|
struct {
|
|
|
|
|
TABLE *table; /* symbol table */
|
|
|
|
|
TABLE *string; /* strings table */
|
|
|
|
|
char *name; /* class name */
|
|
|
|
|
short parent; /* parent class */
|
|
|
|
|
unsigned exported : 1; /* class is exported */
|
|
|
|
|
unsigned autocreate : 1; /* class is auto-creatable */
|
|
|
|
|
unsigned optional : 1; /* class is optional */
|
|
|
|
|
unsigned nocreate : 1; /* class cannot be instanciated */
|
|
|
|
|
unsigned _reserved : 12;
|
|
|
|
|
VARIABLE *stat; /* static variables */
|
|
|
|
|
VARIABLE *dyn; /* dynamic variables */
|
|
|
|
|
CONSTANT *constant; /* constants */
|
|
|
|
|
CLASS_REF *class; /* classes */
|
2008-08-31 02:32:21 +02:00
|
|
|
|
int *unknown; /* unknown symbols */
|
2007-12-30 17:41:49 +01:00
|
|
|
|
FUNCTION *function; /* functions */
|
2008-08-31 02:32:21 +02:00
|
|
|
|
int size_stat; /* static variables total size */
|
|
|
|
|
int size_dyn; /* dynamic variables total size */
|
2007-12-30 17:41:49 +01:00
|
|
|
|
EVENT *event; /* events */
|
|
|
|
|
PROPERTY *prop; /* properties */
|
|
|
|
|
EXTFUNC *ext_func; /* extern functions */
|
|
|
|
|
CLASS_ARRAY *array; /* array definitions */
|
|
|
|
|
CLASS_STRUCT *structure; /* structs definitions */
|
2008-08-31 02:32:21 +02:00
|
|
|
|
char **names; /* when some symbols must be created like object arrays */
|
2007-12-30 17:41:49 +01:00
|
|
|
|
}
|
|
|
|
|
CLASS;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define CLASS_get_symbol(class, ind) ((CLASS_SYMBOL *)TABLE_get_symbol((class)->table, ind))
|
|
|
|
|
|
|
|
|
|
#define FUNCTION_is_procedure(func) (TYPE_get_id((func)->type) == T_VOID)
|
|
|
|
|
#define FUNCTION_is_static(func) (TYPE_is_static((func)->type))
|
|
|
|
|
|
2008-05-13 14:52:06 +02:00
|
|
|
|
void CLASS_create(CLASS **result);
|
|
|
|
|
void CLASS_delete(CLASS **class);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-05-13 14:52:06 +02:00
|
|
|
|
CLASS_SYMBOL *CLASS_declare(CLASS *class, int index, boolean global);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-05-13 14:52:06 +02:00
|
|
|
|
void CLASS_add_function(CLASS *class, TRANS_FUNC *decl);
|
|
|
|
|
void CLASS_add_event(CLASS *class, TRANS_EVENT *decl);
|
|
|
|
|
void CLASS_add_property(CLASS *class, TRANS_PROPERTY *prop);
|
|
|
|
|
void CLASS_add_extern(CLASS *class, TRANS_EXTERN *decl);
|
|
|
|
|
void CLASS_add_declaration(CLASS *class, TRANS_DECL *decl);
|
|
|
|
|
int CLASS_add_constant(CLASS *class, TRANS_DECL *decl);
|
|
|
|
|
int CLASS_add_class(CLASS *class, int index);
|
|
|
|
|
int CLASS_add_class_unused(CLASS *class, int index);
|
|
|
|
|
int CLASS_add_class_exported(CLASS *class, int index);
|
2008-09-01 01:45:47 +02:00
|
|
|
|
int CLASS_add_class_exported_unused(CLASS *class, int index);
|
2008-05-13 14:52:06 +02:00
|
|
|
|
bool CLASS_exist_class(CLASS *class, int index);
|
|
|
|
|
int CLASS_add_unknown(CLASS *class, int index);
|
|
|
|
|
int CLASS_add_array(CLASS *class, TRANS_ARRAY *array);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-08-31 02:32:21 +02:00
|
|
|
|
int CLASS_get_array_class(CLASS *class, int type, int value);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-05-13 14:52:06 +02:00
|
|
|
|
void FUNCTION_add_pos_line(void);
|
|
|
|
|
char *FUNCTION_get_fake_name(int func);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-05-13 14:52:06 +02:00
|
|
|
|
int CLASS_add_symbol(CLASS *class, const char *name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
2008-05-13 14:52:06 +02:00
|
|
|
|
void CLASS_sort_declaration(CLASS *class);
|
|
|
|
|
void CLASS_check_properties(CLASS *class);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
/* gbc_dump.c */
|
|
|
|
|
|
2008-09-22 01:22:07 +02:00
|
|
|
|
PUBLIC void CLASS_dump(void);
|
|
|
|
|
PUBLIC void CLASS_export(void);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
|
#endif
|