DEADSOFTWARE

Исправлен экспорт полей и экспорт для "только чтения"
[dsw-obn.git] / test.c
1 #include "oberon.h"
2 #include "generator.h"
4 #include <string.h>
5 #include <assert.h>
7 static char source_test[] =
8 "MODULE Test;"
9 "IMPORT I := Imported;"
10 "VAR"
11 " x, y : I.Rider;"
12 "PROCEDURE Proc(x, y, z : INTEGER);"
13 "BEGIN"
14 " x := 1;"
15 "END Proc;"
16 "BEGIN;"
17 " y.i := 1;"
18 " I.a[0] := 1;"
19 "END Test."
20 ;
22 static char source_imported[] =
23 "MODULE Imported;"
24 "TYPE"
25 " Rider* = RECORD i*, j-, k : INTEGER; END;"
26 "VAR"
27 " i- : INTEGER;"
28 " a* : ARRAY 3 OF INTEGER;"
29 ""
30 "PROCEDURE Ln*;"
31 "END Ln;"
32 ""
33 "BEGIN;"
34 " i := 1;"
35 " a[0] := 555;"
36 "END Imported."
37 ;
39 static oberon_context_t * ctx;
40 static oberon_module_t * mod;
42 static const char *
43 import_module(const char * name)
44 {
45 if(strcmp(name, "Test") == 0)
46 {
47 return source_test;
48 }
49 else if(strcmp(name, "Imported") == 0)
50 {
51 return source_imported;
52 }
53 else
54 {
55 return NULL;
56 }
57 }
59 int
60 main(int argc, char ** argv)
61 {
62 ctx = oberon_create_context(import_module);
63 mod = oberon_compile_module(ctx, source_test);
64 oberon_generate_code(ctx);
65 oberon_generator_dump(ctx, "dump.txt");
66 oberon_destroy_context(ctx);
67 return 0;
68 }