summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 42da6ba)
raw | patch | inline | side by side (parent: 42da6ba)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 24 Jul 2017 19:24:00 +0000 (22:24 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 24 Jul 2017 19:24:00 +0000 (22:24 +0300) |
.gitignore | patch | blob | history | |
generator.c | patch | blob | history | |
generator.h | patch | blob | history | |
notes | patch | blob | history | |
oberon.c | patch | blob | history | |
test.c | patch | blob | history |
diff --git a/.gitignore b/.gitignore
index f47cb2045f130d56b12a40b1ab207bd492281c17..bbbc7ed94402c43a37c1fddd5e9bd0d0b86d1a1f 100644 (file)
--- a/.gitignore
+++ b/.gitignore
*.out
+dump.txt
diff --git a/generator.c b/generator.c
index 4ffba1173bf23582df014dea6d89d290656afcd3..e4970fd995b0e5af87d12cb93f5c6d36bfe24359 100644 (file)
--- a/generator.c
+++ b/generator.c
{ 1, .binary_op = GCC_JIT_BINARY_OP_PLUS },
{ 1, .binary_op = GCC_JIT_BINARY_OP_MINUS },
+ { 1, .binary_op = GCC_JIT_BINARY_OP_MULT },
{ 1, .binary_op = GCC_JIT_BINARY_OP_DIVIDE },
{ 1, .binary_op = GCC_JIT_BINARY_OP_MODULO },
{ 1, .binary_op = GCC_JIT_BINARY_OP_LOGICAL_AND },
gen_context -> gcc_result = gcc_result;
ctx -> mod -> begin = gcc_jit_result_get_code(gcc_result, "BEGIN");
}
+
+void
+oberon_generator_dump(oberon_context_t * ctx, char * path)
+{
+ gen_context_t * gen_context = ctx -> gen_context;
+ gcc_jit_context * gcc_context = gen_context -> gcc_context;
+ gcc_jit_context_dump_to_file(gcc_context, path, 0);
+}
diff --git a/generator.h b/generator.h
index 6a7321ba50d2e5b7349c2bcc499c138ae8004926..2957aa8368a75796f6c023772c937792c66c0fcc 100644 (file)
--- a/generator.h
+++ b/generator.h
*/
void oberon_generate_code(oberon_context_t * ctx);
+void oberon_generator_dump(oberon_context_t * ctx, char * path);
+
index 0925eb083c763703c3ab831bee7d3f12eb7992f0..0d9dbdc989a434fc381b5efbaf0af99603bc9f39 100644 (file)
--- a/notes
+++ b/notes
- нету автокаста в присвоении и передачи параметров
- нету локальных объявлений в процедурах
- нету свёртки констант
-- нету полного контроля return
-- нету типа procedure
+- нету не работает присваивание к переменным-процедурам.
- нету указателей
- нету расширения типа
- нету var-параметров в генераторе
diff --git a/oberon.c b/oberon.c
index 2b4e09f5e8a3ca7e95e4923a6d4773fa9e5202bf..bd5498bbccc06ee9a4ac7ff684ca9f2532149bf9 100644 (file)
--- a/oberon.c
+++ b/oberon.c
@@ -653,6 +653,14 @@ oberon_autocast_to(oberon_context_t * ctx, oberon_expr_t * expr, oberon_type_t *
oberon_error(ctx, "incompatible size");
}
}
+ else if(pref -> class == OBERON_TYPE_RECORD)
+ {
+ if(expr -> result != pref)
+ {
+ printf("oberon_autocast_to: rec %p != %p\n", expr -> result, pref);
+ oberon_error(ctx, "incompatible record types");
+ }
+ }
// TODO cast
index 42526b66791c035ca854e2221050f26eeac893e5..178327ecf317a2ad3298036bf70b59a620c1af39 100644 (file)
--- a/test.c
+++ b/test.c
#include "oberon.h"
+#include "generator.h"
#include <assert.h>
static const char source[] =
"MODULE Test;"
- "CONST"
- " con = 3;"
""
"TYPE"
" MyInt = INTEGER;"
- " MyArr = ARRAY con OF MyInt;"
- " MyRec = RECORD a : MyInt; b : MyInt; END;"
- " MyProc = PROCEDURE;"
- ""
- "VAR"
- " k : INTEGER;"
- " i : INTEGER;"
- " b : BOOLEAN;"
- " arr : MyArr;"
- " rec : MyRec;"
- " proc : MyProc;"
- ""
- "PROCEDURE Tier;"
- "BEGIN"
- " k := 314 + con;"
- "END Tier;"
- ""
- "PROCEDURE Tier2(x : INTEGER; y : INTEGER);"
- "BEGIN"
- " k := x + y;"
- "END Tier2;"
- ""
- "PROCEDURE Tier3(x : INTEGER) : INTEGER;"
- "BEGIN"
- " RETURN x * x * x;"
- "END Tier3;"
+ " MyRec = RECORD"
+ " a : MyInt;"
+ " END;"
+ " MyRecPtr = POINTER TO MyRec;"
""
"BEGIN"
- " k := 1;"
- " i := k;"
- " b := (TRUE # FALSE);"
- " Tier();"
- " Tier2(21, 13);"
- " k := Tier3(2);"
- " arr[0] := 1;"
- " arr[1] := arr[0];"
- " rec.a := 1;"
- " rec.b := rec.a;"
+ " "
"END Test."
;
ctx = oberon_create_context();
mod = oberon_compile_module(ctx, source);
//mod -> begin();
+ oberon_generator_dump(ctx, "dump.txt");
oberon_destroy_context(ctx);
return 0;
}