[vala/staging: 3/3] codegen: Replace some unfortunate asserts with internal error reports



commit a617f41413dec4da1891bfd5a1d4553465370017
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Jan 23 21:36:12 2019 +0100

    codegen: Replace some unfortunate asserts with internal error reports

 codegen/valaccodebasemodule.vala   | 6 ++++--
 codegen/valaccodemethodmodule.vala | 3 ++-
 codegen/valagtypemodule.vala       | 4 ++--
 3 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 5b23c6179..32f42c992 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5644,14 +5644,16 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                        } else if (cleft is CCodeConstant) {
                                                left = ((CCodeConstant) cleft).name;
                                        } else {
-                                               assert_not_reached ();
+                                               Report.error (expr.source_reference, "internal: Unsupported 
expression");
+                                               left = "NULL";
                                        }
                                        if (cright is CCodeIdentifier) {
                                                right = ((CCodeIdentifier) cright).name;
                                        } else if (cright is CCodeConstant) {
                                                right = ((CCodeConstant) cright).name;
                                        } else {
-                                               assert_not_reached ();
+                                               Report.error (expr.source_reference, "internal: Unsupported 
expression");
+                                               right = "NULL";
                                        }
 
                                        set_cvalue (expr, new CCodeConstant ("%s %s".printf (left, right)));
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index a341dc843..fcf12def3 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -960,7 +960,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                        } else if (parent_type is Enum) {
                                this_type = new EnumValueType ((Enum) parent_type);
                        } else {
-                               assert_not_reached ();
+                               Report.error (parent_type.source_reference, "internal: Unsupported symbol 
type");
+                               this_type = new InvalidType ();
                        }
 
                        generate_type_declaration (this_type, decl_space);
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index babab2d76..3274b904d 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -275,7 +275,7 @@ public class Vala.GTypeModule : GErrorModule {
                                        var f = (Field) s;
                                        generate_struct_field_declaration (cl, f, instance_struct, 
type_struct, decl_space, ref has_struct_member);
                                } else {
-                                       assert_not_reached ();
+                                       Report.error (s.source_reference, "internal: Unsupported symbol");
                                }
                        }
                } else {
@@ -2199,7 +2199,7 @@ public class Vala.GTypeModule : GErrorModule {
                                        type_struct.add_declaration (vdecl);
                                }
                        } else {
-                               assert_not_reached ();
+                               Report.error (sym.source_reference, "internal: Unsupported symbol");
                        }
                }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]