]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Add dedicated CastExpression.silent() constructor
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Dec 2017 16:25:10 +0000 (17:25 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Dec 2017 19:17:43 +0000 (20:17 +0100)
vala/valacastexpression.vala
vala/valagenieparser.vala
vala/valaparser.vala

index f9e3d3009b554b7207252dde3be1765c7836de44..ecf093dc571728c0e09405e43443a19a53e5a689 100644 (file)
@@ -52,9 +52,9 @@ public class Vala.CastExpression : Expression {
        /**
         * Checked casts return NULL instead of raising an error.
         */
-       public bool is_silent_cast { get; set; }
+       public bool is_silent_cast { get; private set; }
 
-       public bool is_non_null_cast { get; set; }
+       public bool is_non_null_cast { get; private set; }
 
        private Expression _inner;
 
@@ -67,10 +67,19 @@ public class Vala.CastExpression : Expression {
         * @param type_reference  target type
         * @return                newly created cast expression
         */
-       public CastExpression (Expression inner, DataType type_reference, SourceReference source_reference, bool is_silent_cast) {
+       public CastExpression (Expression inner, DataType type_reference, SourceReference source_reference) {
                this.type_reference = type_reference;
                this.source_reference = source_reference;
-               this.is_silent_cast = is_silent_cast;
+               this.is_silent_cast = false;
+               this.is_non_null_cast = false;
+               this.inner = inner;
+       }
+
+       public CastExpression.silent (Expression inner, DataType type_reference, SourceReference source_reference) {
+               this.type_reference = type_reference;
+               this.source_reference = source_reference;
+               this.is_silent_cast = true;
+               this.is_non_null_cast = false;
                this.inner = inner;
        }
 
index f9aba46ffc056d8d5cec1b43828286ee4126f448..8c92e95991f725bd1f1dafb3b46ef437bb8f86f0 100644 (file)
@@ -1277,7 +1277,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                                        case TokenType.PARAMS:
                                        case TokenType.YIELD:
                                                var inner = parse_unary_expression ();
-                                               return new CastExpression (inner, type, get_src (begin), false);
+                                               return new CastExpression (inner, type, get_src (begin));
                                        default:
                                                break;
                                        }
@@ -1450,7 +1450,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                                case TokenType.AS:
                                        next ();
                                        var type = parse_type (true, false);
-                                       left = new CastExpression (left, type, get_src (begin), true);
+                                       left = new CastExpression.silent (left, type, get_src (begin));
                                        break;
                                default:
                                        found = false;
index 6228ba98ede7b39ae364ced65b4205d85e773ba5..2423e22cb87c751a584dd0ff1c80f5979f47ffe8 100644 (file)
@@ -1112,17 +1112,17 @@ public class Vala.Parser : CodeVisitor {
                                                case TokenType.IDENTIFIER:
                                                case TokenType.PARAMS:
                                                        var inner = parse_unary_expression ();
-                                                       return new CastExpression (inner, type, get_src (begin), false);
+                                                       return new CastExpression (inner, type, get_src (begin));
                                                case TokenType.STAR:
                                                        next ();
                                                        var op = parse_unary_expression ();
                                                        var inner = new PointerIndirection (op, get_src (begin));
-                                                       return new CastExpression (inner, type, get_src (begin), false);
+                                                       return new CastExpression (inner, type, get_src (begin));
                                                case TokenType.BITWISE_AND:
                                                        next ();
                                                        var op = parse_unary_expression ();
                                                        var inner = new AddressofExpression (op, get_src (begin));
-                                                       return new CastExpression (inner, type, get_src (begin), false);
+                                                       return new CastExpression (inner, type, get_src (begin));
                                                default:
                                                        break;
                                                }
@@ -1299,7 +1299,7 @@ public class Vala.Parser : CodeVisitor {
                                case TokenType.AS:
                                        next ();
                                        var type = parse_type (true, false);
-                                       left = new CastExpression (left, type, get_src (begin), true);
+                                       left = new CastExpression.silent (left, type, get_src (begin));
                                        break;
                                default:
                                        found = false;