X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=oberon.h;h=ef9ad7f1c891223eb2241ef8d4020e3855a50645;hb=d1b4e7fdab92589146e19cf4b8b402edf4d6b33d;hp=becdd78e6cf530ec53d67ab0ce1ed9b86ab818ef;hpb=063ba732ee8778c34a3781270b18d52481dbf0cd;p=dsw-obn.git diff --git a/oberon.h b/oberon.h index becdd78..ef9ad7f 100644 --- a/oberon.h +++ b/oberon.h @@ -3,33 +3,43 @@ #include -/* - * Стуктуры данных генератора - */ +typedef struct gen_proc_s gen_proc_t; +typedef struct gen_type_s gen_type_t; +typedef struct gen_var_s gen_var_t; +typedef struct gen_block_s gen_block_t; +typedef struct gen_context_s gen_context_t; -typedef struct +struct gen_proc_s { gcc_jit_function * gcc_func; -} gen_proc_t; +}; -typedef struct +struct gen_type_s { gcc_jit_type * gcc_type; -} gen_type_t; + gcc_jit_struct * gcc_struct; +}; -typedef struct +struct gen_var_s { - char stub[16]; - gcc_jit_lvalue * gcc_lvalue; - gcc_jit_param * gcc_param; -} gen_var_t; + gcc_jit_lvalue * gcc_lvalue; + gcc_jit_param * gcc_param; + gcc_jit_field * gcc_field; +}; -typedef struct +struct gen_block_s { - gcc_jit_context * gcc_context; - gcc_jit_block * gcc_block; - gcc_jit_result * gcc_result; -} gen_context_t; + gcc_jit_block * gcc_block; + gen_block_t * up; +}; + +struct gen_context_s +{ + gcc_jit_context * gcc_context; + gcc_jit_result * gcc_result; + gen_block_t * block; + unsigned record_count; +}; typedef struct oberon_type_s oberon_type_t; typedef struct oberon_object_s oberon_object_t; @@ -56,6 +66,9 @@ struct oberon_scope_s oberon_context_t * ctx; oberon_object_t * list; oberon_scope_t * up; + + oberon_object_t * parent; + int local; }; /* @@ -69,7 +82,9 @@ enum OBERON_TYPE_INTEGER, OBERON_TYPE_BOOLEAN, OBERON_TYPE_PROCEDURE, - OBERON_TYPE_ARRAY + OBERON_TYPE_ARRAY, + OBERON_TYPE_RECORD, + OBERON_TYPE_POINTER }; /* @@ -95,12 +110,14 @@ struct oberon_type_s int class; int size; - int dim; - int num_decl; oberon_type_t * base; oberon_object_t * decl; + oberon_module_t * module; + + int recursive; + int initialized; gen_type_t * gen_type; }; @@ -120,7 +137,9 @@ enum OBERON_CLASS_PROC, OBERON_CLASS_PARAM, OBERON_CLASS_VAR_PARAM, - OBERON_CLASS_CONST + OBERON_CLASS_CONST, + OBERON_CLASS_FIELD, + OBERON_CLASS_MODULE }; /* @@ -133,15 +152,34 @@ enum * next -- ссылка на следующий объект в списке. */ +typedef oberon_expr_t * (*GenerateFuncCallback)(oberon_context_t *, int, oberon_expr_t *); +typedef void (*GenerateProcCallback)(oberon_context_t *, int, oberon_expr_t *); + struct oberon_object_s { char * name; int class; + int export; + int read_only; + + int local; + int linked; + int initialized; + + oberon_object_t * parent; + + oberon_scope_t * scope; // for proc + int has_return; // for proc + int sysproc; + GenerateFuncCallback genfunc; + GenerateProcCallback genproc; oberon_type_t * type; oberon_item_t * value; oberon_object_t * next; + oberon_module_t * module; + gen_var_t * gen_var; gen_proc_t * gen_proc; }; @@ -157,10 +195,11 @@ struct oberon_object_s struct oberon_module_s { char * name; + int ready; oberon_scope_t * decl; - void (* begin)(); + oberon_module_t * next; }; /* @@ -180,8 +219,11 @@ struct oberon_module_s * world_scope -- область видимости "мир" - выше модуля. */ +typedef const char * (*ModuleImportCallback)(const char * name); + struct oberon_context_s { + /*** SCANER DATA ***/ const char * code; int code_index; @@ -189,18 +231,20 @@ struct oberon_context_s int token; char * string; int integer; + /*** END SCANER DATA ***/ - int has_return; - oberon_type_t * result_type; - + /*** PARSER DATA ***/ oberon_scope_t * decl; oberon_module_t * mod; + /*** END PARSER DATA ***/ oberon_type_t * int_type; oberon_type_t * bool_type; oberon_type_t * void_type; + oberon_type_t * void_ptr_type; oberon_scope_t * world_scope; - + oberon_module_t * module_list; + ModuleImportCallback import_module; gen_context_t * gen_context; }; @@ -209,20 +253,31 @@ enum MODE_VAR, MODE_INTEGER, MODE_BOOLEAN, - MODE_CALL + MODE_CALL, + MODE_INDEX, + MODE_FIELD, + MODE_DEREF, + MODE_NIL }; enum { - OP_LOGIC_NOT, OP_UNARY_MINUS, + OP_BITWISE_NOT, + OP_LOGIC_NOT, + OP_ABS, + OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, + OP_BITWISE_AND, + OP_BITWISE_XOR, + OP_BITWISE_OP, OP_LOGIC_AND, OP_LOGIC_OR, + OP_EQ, OP_NEQ, OP_LSS, @@ -236,12 +291,15 @@ struct oberon_item_s int is_item; // == 1 oberon_type_t * result; oberon_expr_t * next; + int read_only; int mode; int integer; int boolean; oberon_object_t * var; + oberon_item_t * parent; + int num_args; oberon_expr_t * args; }; @@ -251,6 +309,7 @@ struct oberon_oper_s int is_item; // == 0 oberon_type_t * result; oberon_expr_t * next; + int read_only; int op; oberon_expr_t * left; @@ -263,13 +322,14 @@ union oberon_expr_u int is_item; oberon_type_t * result; oberon_expr_t * next; + int read_only; }; oberon_item_t item; oberon_oper_t oper; }; -oberon_context_t * oberon_create_context(); +oberon_context_t * oberon_create_context(ModuleImportCallback import_module); void oberon_destroy_context(oberon_context_t * ctx); void oberon_register_global_type(oberon_context_t * ctx, oberon_type_t * type); oberon_module_t * oberon_compile_module(oberon_context_t * ctx, const char * code);