diff --git a/oberon.c b/oberon.c
index b7ffd0ea73ab2b9cd366a04d96a2b1e16a80a94d..3837bf5b92702c744bcf7b883ff73395826063a8 100644 (file)
--- a/oberon.c
+++ b/oberon.c
oberon_object_t * param = fn -> decl;
for(int i = 0; i < num_args; i++)
{
+ if(param -> class == OBERON_CLASS_VAR_PARAM)
+ {
+ if(arg -> is_item)
+ {
+ switch(arg -> item.mode)
+ {
+ case MODE_VAR:
+ case MODE_INDEX:
+ case MODE_FIELD:
+ // Допустимо разыменование?
+ //case MODE_DEREF:
+ break;
+ default:
+ oberon_error(ctx, "var-parameter accept only variables");
+ break;
+ }
+ }
+ }
oberon_autocast_to(ctx, arg, param -> type);
arg = arg -> next;
param = param -> next;
@@ -790,14 +808,12 @@ oberon_make_array_selector(oberon_context_t * ctx, oberon_expr_t * desig, oberon
oberon_type_t * base;
base = desig -> result -> base;
- // TODO check ranges
-
- printf("oberon_make_array_selector: index class %i\n", index -> result -> class);
if(index -> result -> class != OBERON_TYPE_INTEGER)
{
oberon_error(ctx, "index must be integer");
}
+ // Статическая проверка границ массива
if(index -> is_item)
{
if(index -> item.mode == MODE_INTEGER)
// PARSER
// =======================================================================
+static void oberon_decl_seq(oberon_context_t * ctx);
static void oberon_statement_seq(oberon_context_t * ctx);
static void
if(ctx -> token == COLON)
{
oberon_assert_token(ctx, COLON);
+ // TODO get by qualident
oberon_type(ctx, &signature -> base);
}
}
oberon_assert_token(ctx, SEMICOLON);
- oberon_generate_begin_proc(ctx, proc);
+ oberon_decl_seq(ctx);
+ oberon_generator_init_type(ctx, signature);
+ oberon_generator_init_proc(ctx, proc);
- // TODO declarations
+ oberon_generate_begin_proc(ctx, proc);
if(ctx -> token == BEGIN)
{
@@ -1984,6 +2004,11 @@ oberon_assign(oberon_context_t * ctx, oberon_expr_t * src, oberon_expr_t * dst)
static void
oberon_make_call(oberon_context_t * ctx, oberon_expr_t * desig)
{
+ if(desig -> result -> class != OBERON_TYPE_VOID)
+ {
+ oberon_error(ctx, "procedure with result");
+ }
+
oberon_autocast_call(ctx, desig);
oberon_generate_call_proc(ctx, desig);
}