]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Move some errors from signal-module to the semantic-analyzer pass
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 22 Sep 2018 16:39:36 +0000 (18:39 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 22 Sep 2018 19:54:28 +0000 (21:54 +0200)
codegen/valagsignalmodule.vala
vala/valadynamicsignal.vala
vala/valaelementaccess.vala
vala/valasignal.vala

index f9a3b9faff9a392d1b46741c1aa02dce7474caad..486f2c3596b400f7bad5a192efc4ab9d06f395f6 100644 (file)
@@ -112,12 +112,6 @@ public class Vala.GSignalModule : GObjectModule {
                        return get_signal_canonical_constant (sig);
                }
 
-               if (detail_expr.value_type is NullType || !detail_expr.value_type.compatible (string_type)) {
-                       node.error = true;
-                       Report.error (detail_expr.source_reference, "only string details are supported");
-                       return null;
-               }
-
                if (detail_expr is StringLiteral) {
                        return get_signal_canonical_constant (sig, ((StringLiteral) detail_expr).eval ());
                }
@@ -143,12 +137,6 @@ public class Vala.GSignalModule : GObjectModule {
        }
 
        private CCodeExpression? get_detail_cexpression (Expression detail_expr, CodeNode node) {
-               if (detail_expr.value_type is NullType || !detail_expr.value_type.compatible (string_type)) {
-                       node.error = true;
-                       Report.error (detail_expr.source_reference, "only string details are supported");
-                       return null;
-               }
-
                var detail_cexpr = get_cvalue (detail_expr);
                CCodeFunctionCall detail_ccall;
                if (is_constant_ccode_expression (detail_cexpr)) {
@@ -162,25 +150,6 @@ public class Vala.GSignalModule : GObjectModule {
        }
 
        public override void visit_signal (Signal sig) {
-               // parent_symbol may be null for dynamic signals
-
-               var cl = sig.parent_symbol as Class;
-               if (cl != null && cl.is_compact) {
-                       sig.error = true;
-                       Report.error (sig.source_reference, "Signals are not supported in compact classes");
-                       return;
-               }
-
-               if (cl != null) {
-                       foreach (DataType base_type in cl.get_base_types ()) {
-                               if (SemanticAnalyzer.symbol_lookup_inherited (base_type.data_type, sig.name) is Signal) {
-                                       sig.error = true;
-                                       Report.error (sig.source_reference, "Signals with the same name as a signal in a base type are not supported");
-                                       return;
-                               }
-                       }
-               }
-
                if (signal_enum != null && sig.parent_symbol is TypeSymbol) {
                        signal_enum.add_value (new CCodeEnumValue ("%s_%s_SIGNAL".printf (get_ccode_upper_case_name ((TypeSymbol) sig.parent_symbol), get_ccode_upper_case_name (sig))));
                }
index c3cae8b0691f4375cfc0ae706af117ce1502e961..c250dac2021a134ab7bd2e79a1d4f3d0e7fa9db6 100644 (file)
@@ -34,8 +34,4 @@ public class Vala.DynamicSignal : Signal {
                base (name, return_type, source_reference, comment);
                this.dynamic_type = dynamic_type;
        }
-
-       public override bool check (CodeContext context) {
-               return true;
-       }
 }
index 755eaf6ee78215843ab1be339462e3af6a9758a2..62cd1a65d833970c475bd7d6da65032cca2971d1 100644 (file)
@@ -132,7 +132,16 @@ public class Vala.ElementAccess : Expression {
                                Report.error (source_reference, "Element access with more than one dimension is not supported for signals");
                                return false;
                        }
-                       get_indices ().get (0).target_type = context.analyzer.string_type.copy ();
+
+                       var detail_expr = get_indices ().get (0);
+                       detail_expr.target_type = context.analyzer.string_type.copy ();
+                       detail_expr.check (context);
+
+                       if (detail_expr.value_type is NullType || !detail_expr.value_type.compatible (context.analyzer.string_type)) {
+                               error = true;
+                               Report.error (detail_expr.source_reference, "only string details are supported");
+                               return false;
+                       }
                }
 
                foreach (Expression index in get_indices ()) {
index 9e971b6f8edd44584ed729acdcac443da977c7aa..fa32cbe64c9cd86b7c51e9c3772f35702a3dfd17 100644 (file)
@@ -181,6 +181,28 @@ public class Vala.Signal : Symbol, Callable {
 
                checked = true;
 
+               // parent_symbol may be null for dynamic signals
+               var parent_cl = parent_symbol as Class;
+               if (parent_cl != null && parent_cl.is_compact) {
+                       error = true;
+                       Report.error (source_reference, "Signals are not supported in compact classes");
+                       return false;
+               }
+
+               if (parent_cl != null) {
+                       foreach (DataType base_type in parent_cl.get_base_types ()) {
+                               if (SemanticAnalyzer.symbol_lookup_inherited (base_type.data_type, name) is Signal) {
+                                       error = true;
+                                       Report.error (source_reference, "Signals with the same name as a signal in a base type are not supported");
+                                       return false;
+                               }
+                       }
+               }
+
+               if (this is DynamicSignal) {
+                       return !error;
+               }
+
                return_type.check (context);
 
                foreach (Parameter param in parameters) {