+ oberon_define_type(ctx -> world_scope, "INTEGER", ctx -> int_type, 1);
+
+ ctx -> bool_type = oberon_new_type_boolean(sizeof(bool));
+ oberon_define_type(ctx -> world_scope, "BOOLEAN", ctx -> bool_type, 1);
+
+ ctx -> real_type = oberon_new_type_real(sizeof(float));
+ oberon_define_type(ctx -> world_scope, "REAL", ctx -> real_type, 1);
+}
+
+static void
+oberon_new_intrinsic(oberon_context_t * ctx, char * name, GenerateFuncCallback f, GenerateProcCallback p)
+{
+ oberon_object_t * proc;
+ proc = oberon_define_object(ctx -> decl, name, OBERON_CLASS_PROC, 1, 0);
+ proc -> sysproc = 1;
+ proc -> genfunc = f;
+ proc -> genproc = p;
+ proc -> type = oberon_new_type_ptr(OBERON_TYPE_PROCEDURE);
+}
+
+static oberon_expr_t *
+oberon_make_abs_call(oberon_context_t * ctx, int num_args, oberon_expr_t * list_args)
+{
+ if(num_args < 1)
+ {
+ oberon_error(ctx, "too few arguments");
+ }
+
+ if(num_args > 1)
+ {
+ oberon_error(ctx, "too mach arguments");
+ }
+
+ oberon_expr_t * arg;
+ arg = list_args;
+
+ oberon_type_t * result_type;
+ result_type = arg -> result;
+
+ if(result_type -> class != OBERON_TYPE_INTEGER)
+ {
+ oberon_error(ctx, "ABS accepts only integers");
+ }
+
+
+ oberon_expr_t * expr;
+ expr = oberon_new_operator(OP_ABS, result_type, arg, NULL);
+ return expr;
+}
+
+static void
+oberon_make_new_call(oberon_context_t * ctx, int num_args, oberon_expr_t * list_args)
+{
+ if(num_args < 1)
+ {
+ oberon_error(ctx, "too few arguments");
+ }
+
+ oberon_expr_t * dst;
+ dst = list_args;
+
+ oberon_type_t * type;
+ type = dst -> result;
+
+ if(type -> class != OBERON_TYPE_POINTER)
+ {
+ oberon_error(ctx, "not a pointer");
+ }
+
+ type = type -> base;
+
+ oberon_expr_t * src;
+ src = oberon_new_item(MODE_NEW, dst -> result, 0);
+ src -> item.num_args = 0;
+ src -> item.args = NULL;
+
+ int max_args = 1;
+ if(type -> class == OBERON_TYPE_ARRAY)
+ {
+ if(type -> size == 0)
+ {
+ oberon_type_t * x = type;
+ while(x -> class == OBERON_TYPE_ARRAY)
+ {
+ if(x -> size == 0)
+ {
+ max_args += 1;
+ }
+ x = x -> base;
+ }
+ }
+
+ if(num_args < max_args)
+ {
+ oberon_error(ctx, "too few arguments");
+ }
+
+ if(num_args > max_args)
+ {
+ oberon_error(ctx, "too mach arguments");
+ }
+
+ int num_sizes = max_args - 1;
+ oberon_expr_t * size_list = list_args -> next;
+
+ oberon_expr_t * arg = size_list;
+ for(int i = 0; i < max_args - 1; i++)
+ {
+ if(arg -> result -> class != OBERON_TYPE_INTEGER)
+ {
+ oberon_error(ctx, "size must be integer");
+ }
+ arg = arg -> next;
+ }
+
+ src -> item.num_args = num_sizes;
+ src -> item.args = size_list;
+ }
+ else if(type -> class != OBERON_TYPE_RECORD)
+ {
+ oberon_error(ctx, "oberon_make_new_call: wat");
+ }
+
+ if(num_args > max_args)
+ {
+ oberon_error(ctx, "too mach arguments");
+ }