DEADSOFTWARE

Добавлены встроенные процедуры
[dsw-obn.git] / oberon.h
index 02547cd70be76f7ffdaeb60097fa5fe89cc5dd87..09a24c98caeaa08f59b50e8b562035b261acd9d7 100644 (file)
--- a/oberon.h
+++ b/oberon.h
@@ -3,34 +3,43 @@
 
 #include <libgccjit.h>
 
-/*
- * Стуктуры данных генератора
- */
+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;
+
+struct gen_proc_s
+{
+        gcc_jit_function * gcc_func;
+};
 
-typedef struct
+struct gen_type_s
 {
-       gcc_jit_function * gcc_func;
-} gen_proc_t;
+        gcc_jit_type * gcc_type;
+        gcc_jit_struct * gcc_struct;
+};
 
-typedef struct
+struct gen_var_s
 {
-       gcc_jit_type * gcc_type;
-       gcc_jit_struct * gcc_struct;
-} gen_type_t;
+        gcc_jit_lvalue * gcc_lvalue;
+        gcc_jit_param * gcc_param;
+        gcc_jit_field * gcc_field;
+};
 
-typedef struct
+struct gen_block_s
 {
-       gcc_jit_lvalue * gcc_lvalue;
-       gcc_jit_param * gcc_param;
-       gcc_jit_field * gcc_field;
-} gen_var_t;
+        gcc_jit_block * gcc_block;
+       gen_block_t * up;
+};
 
-typedef struct
+struct gen_context_s
 {
-       gcc_jit_context * gcc_context;
-       gcc_jit_block * gcc_block;
-       gcc_jit_result * gcc_result;
-} gen_context_t;
+        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;
@@ -57,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;
 };
 
 /*
@@ -127,6 +139,11 @@ enum
        OBERON_CLASS_FIELD
 };
 
+enum
+{
+       OBERON_SYSPROC_ABS
+};
+
 /*
  * Структура oberon_object_s (oberon_object_t) описывает все
  * объявления которые могут иметь имя. От констант, до процедур.
@@ -137,12 +154,26 @@ 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 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;
@@ -195,9 +226,6 @@ struct oberon_context_s
        char * string;
        int integer;
 
-       int has_return;
-       oberon_type_t * result_type;
-
        oberon_scope_t * decl;
        oberon_module_t * mod;
 
@@ -224,15 +252,22 @@ enum
 
 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,