DEADSOFTWARE

JVM: Реализованы переменные-процедуры в генераторе
[dsw-obn.git] / src / oberon.c
index d636fba6b19d253c65a167420a25f21547bef892..251a7df597c9887a7d2d319940bc99d70a812c35 100644 (file)
@@ -64,7 +64,7 @@ enum {
 //   UTILS
 // ======================================================================= 
 
-void
+static void
 oberon_error(oberon_context_t * ctx, const char * fmt, ...)
 {
        va_list ptr;
@@ -131,8 +131,9 @@ oberon_open_scope(oberon_context_t * ctx)
 
        if(scope -> up)
        {
-               scope -> parent = scope -> up -> parent;
                scope -> local = scope -> up -> local;
+               scope -> parent = scope -> up -> parent;
+               scope -> parent_type = scope -> up -> parent_type;
        }
 
        ctx -> decl = scope;
@@ -168,6 +169,7 @@ oberon_define_object(oberon_scope_t * scope, char * name, int class, int export,
        newvar -> read_only = read_only;
        newvar -> local = scope -> local;
        newvar -> parent = scope -> parent;
+       newvar -> parent_type = scope -> parent_type;
        newvar -> module = scope -> ctx -> mod;
 
        x -> next = newvar;
@@ -1527,6 +1529,12 @@ oberon_simple_expr(oberon_context_t * ctx)
        }
 
        expr = oberon_term_expr(ctx);
+
+       if(minus)
+       {
+               expr = oberon_make_unary_op(ctx, MINUS, expr);
+       }
+
        while(ISADDOP(ctx -> token))
        {
                int token = ctx -> token;
@@ -1536,11 +1544,6 @@ oberon_simple_expr(oberon_context_t * ctx)
                expr = oberon_make_bin_op(ctx, token, expr, inter);
        }
 
-       if(minus)
-       {
-               expr = oberon_make_unary_op(ctx, MINUS, expr);
-       }
-
        return expr;
 }
 
@@ -2083,12 +2086,13 @@ oberon_type(oberon_context_t * ctx, oberon_type_t ** type)
                oberon_type_t * rec;
                rec = *type;
                rec -> class = OBERON_TYPE_RECORD;
+               rec -> module = ctx -> mod;
 
                oberon_scope_t * record_scope;
                record_scope = oberon_open_scope(ctx);
-               // TODO parent object
-               //record_scope -> parent = NULL;
                record_scope -> local = 1;
+               record_scope -> parent = NULL;
+               record_scope -> parent_type = rec;
 
                oberon_assert_token(ctx, RECORD);
                oberon_field_list(ctx, rec);
@@ -2197,7 +2201,8 @@ oberon_prevent_recursive_pointer(oberon_context_t * ctx, oberon_type_t * type)
                oberon_error(ctx, "recursive pointer declaration");
        }
 
-       if(type -> base -> class == OBERON_TYPE_POINTER)
+       if(type -> class == OBERON_TYPE_POINTER
+               && type -> base -> class == OBERON_TYPE_POINTER)
        {
                oberon_error(ctx, "attempt to make pointer to pointer");
        }
@@ -2672,6 +2677,8 @@ oberon_parse_module(oberon_context_t * ctx)
        oberon_assert_token(ctx, SEMICOLON);
        ctx -> mod -> name = name1;
 
+       oberon_generator_init_module(ctx, ctx -> mod);
+
        if(ctx -> token == IMPORT)
        {
                oberon_import_list(ctx);
@@ -2695,6 +2702,8 @@ oberon_parse_module(oberon_context_t * ctx)
        {
                oberon_error(ctx, "module name not matched");
        }
+
+       oberon_generator_fini_module(ctx -> mod);
 }
 
 // =======================================================================