about summary refs log tree commit diff
path: root/boot/ir.c
diff options
context:
space:
mode:
Diffstat (limited to 'boot/ir.c')
-rw-r--r--boot/ir.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/boot/ir.c b/boot/ir.c
index 4bdfc6e..6ea055e 100644
--- a/boot/ir.c
+++ b/boot/ir.c
@@ -444,19 +444,33 @@ struct Import
     struct Span span;
 };
 
-enum Diagnostic_Severity
-{
-    DIAGNOSTIC_NOTE,
-    DIAGNOSTIC_WARNING,
-    DIAGNOSTIC_ERROR,
-};
-
-// TODO: we might want to take this out to be used for other passes.
-struct Diagnostic
-{
-    enum Diagnostic_Severity severity;
+enum Lower_Error_Kind
+{
+    LOWER_ERROR_NONE,
+    LOWER_ERROR_UNDEFINED_TYPE,
+    LOWER_ERROR_DUPLICATE_TYPE,
+    LOWER_ERROR_DUPLICATE_FUNCTION,
+    LOWER_ERROR_NAME_SHADOWS,
+    LOWER_ERROR_TYPE_CYCLE,
+    LOWER_ERROR_ASSIGNMENT_AS_EXPRESSION,
+    LOWER_ERROR_RANGE_OUTSIDE_LOOP,
+    LOWER_ERROR_CONSTRUCT_SUBJECT_NOT_NAME,
+    LOWER_ERROR_TYPE_EXPRESSION_IN_BODY,
+    LOWER_ERROR_UNSUPPORTED_TOP_LEVEL,
+    LOWER_ERROR_UNKNOWN_LOOP_STYLE,
+    LOWER_ERROR_UNKNOWN_COMPOUND_ASSIGN,
+    LOWER_ERROR_UNIMPLEMENTED,
+};
+
+struct Lower_Error
+{
+    enum Lower_Error_Kind kind;
     struct Span span;
-    struct String message;
+    
+    // per-error details, meaning depends on each error kind!
+    struct String name;
+    struct String detail;
+    Array(Type_Id) cycle_chain;
 };
 
 // a single translation unit.
@@ -472,7 +486,7 @@ struct Unit
     Array(Type_Id) type_emission_order;
 
     bool had_error;
-    Array(struct Diagnostic) diagnostics;
+    Array(struct Lower_Error) lower_errors;
 };
 
 REGION(struct Type, type)
@@ -655,10 +669,6 @@ ir_make_construct(Type_Id type_id, Array(struct Construct_Field) fields, struct
     return expression_new(EXPRESSION_CONSTRUCT, v, span);
 }
 
-// type-ref constructors.
-// `bare` is the no-modifier form; `pointer` wraps one `&` modifier; `with_mods`
-// takes a fully-formed mods array (caller owns it).
-
 struct Type_Ref
 type_ref_bare(Type_Id type_id)
 {