aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-12-05 00:22:30 +0000
committerGinger Bill <bill@gingerbill.org>2016-12-05 00:22:30 +0000
commit88aa74bbb9043f4ffe843beacb0984c06a1dfff3 (patch)
treec823d029d6a6d0c5fcf755b194bc7b3a0d9ca678
parent8ec9811d7a552e96600286a58b5b5303b79f88ed (diff)
Remove multiple messages for cyclic type errors.
-rw-r--r--code/demo.odin6
-rw-r--r--src/checker/types.c16
2 files changed, 15 insertions, 7 deletions
diff --git a/code/demo.odin b/code/demo.odin
index 4198c1468..0e5c215ad 100644
--- a/code/demo.odin
+++ b/code/demo.odin
@@ -1,4 +1,3 @@
-// #import "game.odin";
#import "fmt.odin";
A :: type struct {
@@ -11,8 +10,9 @@ C :: type struct {
a: A;
};
-
main :: proc() {
- fmt.println(123);
+ fmt.println(size_of(A));
+ fmt.println(size_of(B));
+ fmt.println(size_of(C));
}
diff --git a/src/checker/types.c b/src/checker/types.c
index 91847b477..f65f9cefe 100644
--- a/src/checker/types.c
+++ b/src/checker/types.c
@@ -153,6 +153,7 @@ typedef struct Type {
TYPE_KINDS
#undef TYPE_KIND
};
+ bool failure;
} Type;
// NOTE(bill): Internal sizes of certain types
@@ -1073,10 +1074,11 @@ TypePath *type_path_push(TypePath *tp, Type *t) {
// NOTE(bill): This will only print if the path count > 1
error(e->token, "\t%.*s", LIT(t->Named.name));
tp->failure = true;
+ t->failure = true;
// NOTE(bill): Just quit immediately
// TODO(bill): Try and solve this gracefully
- gb_exit(1);
+ // gb_exit(1);
}
}
@@ -1113,12 +1115,12 @@ i64 align_formula(i64 size, i64 align) {
}
i64 type_size_of(BaseTypeSizes s, gbAllocator allocator, Type *t) {
- i64 align;
+ i64 size;
TypePath path = {0};
type_path_init(&path);
- align = type_size_of_internal(s, allocator, t, &path);
+ size = type_size_of_internal(s, allocator, t, &path);
type_path_free(&path);
- return align;
+ return size;
}
i64 type_align_of(BaseTypeSizes s, gbAllocator allocator, Type *t) {
@@ -1132,6 +1134,9 @@ i64 type_align_of(BaseTypeSizes s, gbAllocator allocator, Type *t) {
i64 type_align_of_internal(BaseTypeSizes s, gbAllocator allocator, Type *t, TypePath *path) {
+ if (t->failure) {
+ return FAILURE_ALIGNMENT;
+ }
t = base_type(t);
switch (t->kind) {
@@ -1297,6 +1302,9 @@ bool type_set_offsets(BaseTypeSizes s, gbAllocator allocator, Type *t) {
}
i64 type_size_of_internal(BaseTypeSizes s, gbAllocator allocator, Type *t, TypePath *path) {
+ if (t->failure) {
+ return FAILURE_SIZE;
+ }
t = base_type(t);
switch (t->kind) {
case Type_Basic: {