X-Git-Url: http://deadsoftware.ru/gitweb?p=dsw-obn.git;a=blobdiff_plain;f=test.c;h=297da8de9a9c9d21c05fe7db43989753f35613cb;hp=6b6d335760a57a4fd9e5ca68af3c95b849c96d38;hb=c15b86365824545bdee7d813ce0c796f1bdff592;hpb=679da1b129ba6077d1c44ebdf260d3813afdcf65 diff --git a/test.c b/test.c index 6b6d335..297da8d 100644 --- a/test.c +++ b/test.c @@ -1,15 +1,19 @@ #include "oberon.h" #include "generator.h" + +#include #include -static const char source[] = +static char source_test[] = "MODULE Test;" + "IMPORT I := Imported;" "TYPE" " Callback = PROCEDURE() : INTEGER;" "" "VAR" " cb : Callback;" " i : INTEGER;" + " r : I.Rider;" "" "PROCEDURE RelBack;" "BEGIN" @@ -20,18 +24,48 @@ static const char source[] = " i := ABS(-1);" " i := cb();" " RelBack;" + " 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(); - mod = oberon_compile_module(ctx, source); - //mod -> begin(); + 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;