X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Foberon.c;h=251a7df597c9887a7d2d319940bc99d70a812c35;hb=7bb96abf74bcb31d9a3ecb820b0b6565813bf324;hp=382f4f182b2e98ca1032a7f720cc575e58ae9fc5;hpb=2a0d7e7fbb7dcccc65f98301a0627ee47c755f2f;p=dsw-obn.git diff --git a/src/oberon.c b/src/oberon.c index 382f4f1..251a7df 100644 --- a/src/oberon.c +++ b/src/oberon.c @@ -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; } @@ -2087,9 +2090,9 @@ oberon_type(oberon_context_t * ctx, oberon_type_t ** type) 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); @@ -2198,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"); } @@ -2698,6 +2702,8 @@ oberon_parse_module(oberon_context_t * ctx) { oberon_error(ctx, "module name not matched"); } + + oberon_generator_fini_module(ctx -> mod); } // =======================================================================