fc0033339d03fff36dbd6f52ba6989c3df777c0c
7 static char source_test
[] =
14 " p : POINTER TO ARRAY 3 OF INTEGER;"
16 "PROCEDURE ChParam(VAR i : INTEGER);"
32 static char source_out
[] =
34 "(* Interface to outer program ;) *)"
37 // " Char- : PROCEDURE(ch : CHAR);"
38 // " String- : PROCEDURE(str : ARRAY OF CHAR)"
39 // " Int- : PROCEDURE(i, n : LONGINT);"
40 " Int- : PROCEDURE(i, n : INTEGER);"
41 // " Real- : PROCEDURE(x : REAL; n : INTEGER);"
42 // " LongReal- : PROCEDURE(x : LONGREAL; n : INTEGER);"
47 static oberon_context_t
* ctx
;
48 static oberon_module_t
* mod
;
51 import_module(const char * name
)
53 if(strcmp(name
, "Test") == 0)
57 else if(strcmp(name
, "Out") == 0)
67 typedef void (*TOutOpen
)();
68 static TOutOpen
* OutOpenPtr
;
73 typedef void (*TOutInt
)(int, int);
74 static TOutInt
* OutIntPtr
;
75 void ImplOutInt(int i
, int n
)
78 snprintf(number
, 22, "%i", i
);
79 int len
= strlen(number
);
80 for(int i
= 0; i
< n
- len
; i
++)
87 typedef void (*TOutLn
)();
88 static TOutLn
* OutLnPtr
;
94 void init_system_modules()
96 OutOpenPtr
= oberon_generator_get_var(ctx
, "Out_Open");
97 *OutOpenPtr
= ImplOutOpen
;
98 OutIntPtr
= oberon_generator_get_var(ctx
, "Out_Int");
99 *OutIntPtr
= ImplOutInt
;
100 OutLnPtr
= oberon_generator_get_var(ctx
, "Out_Ln");
101 *OutLnPtr
= ImplOutLn
;
106 void (*begin
)() = oberon_generator_get_procedure(ctx
, "Test_BEGIN");
111 main(int argc
, char ** argv
)
113 ctx
= oberon_create_context(import_module
);
114 mod
= oberon_compile_module(ctx
, source_test
);
116 oberon_generate_code(ctx
);
118 init_system_modules();
120 oberon_generator_dump(ctx
, "dump.txt");
124 oberon_destroy_context(ctx
);