index 7149026862087a8f63577916ffd361e8b89b08ef..5b2fc48e91e4e54175f56baa5dd1ea247781bcb3 100644 (file)
--- a/test.c
+++ b/test.c
#include "oberon.h"
-#include <assert.h>
+#include "generator.h"
-static oberon_type_t integer = { "INTEGER", OBERON_TYPE_INTEGER, sizeof(int) };
-static oberon_type_t boolean = { "BOOLEAN", OBERON_TYPE_BOOLEAN, sizeof(int) };
+#include <string.h>
+#include <assert.h>
-static const char source[] =
+static char source_test[] =
"MODULE Test;"
+ "IMPORT I := Imported;"
"VAR"
- " k : INTEGER;"
- " i : INTEGER;"
- " b : BOOLEAN;"
+ " x : I.Rider;"
"BEGIN"
- " k := 10;"
- " i := k;"
- " b := TRUE;"
+ " I.Ln;"
"END Test."
;
+static char source_imported[] =
+ "MODULE Imported;"
+ "TYPE"
+ " Rider* = RECORD i : INTEGER; END;"
+ ""
+ "PROCEDURE Ln*;"
+ "END Ln;"
+ ""
+ "BEGIN;"
+ "END Imported."
+;
+
static oberon_context_t * ctx;
static oberon_module_t * mod;
+static const char *
+import_module(const char * name)
+{
+ if(strcmp(name, "Test") == 0)
+ {
+ return source_test;
+ }
+ else if(strcmp(name, "Imported") == 0)
+ {
+ return source_imported;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
int
main(int argc, char ** argv)
{
- ctx = oberon_create_context();
- oberon_register_global_type(ctx, &integer);
- oberon_register_global_type(ctx, &boolean);
- mod = oberon_compile_module(ctx, source);
+ ctx = oberon_create_context(import_module);
+ mod = oberon_compile_module(ctx, source_test);
+ oberon_generate_code(ctx);
+ oberon_generator_dump(ctx, "dump.txt");
oberon_destroy_context(ctx);
return 0;
}