[vala/staging: 8/12] vala: Add dedicated CastExpression.silent() constructor
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 8/12] vala: Add dedicated CastExpression.silent() constructor
- Date: Fri, 15 Dec 2017 08:23:58 +0000 (UTC)
commit ccf5fd33bedb50cd05cceab146a08fbcd511a603
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Dec 14 17:25:10 2017 +0100
vala: Add dedicated CastExpression.silent() constructor
vala/valacastexpression.vala | 17 +++++++++++++----
vala/valagenieparser.vala | 4 ++--
vala/valaparser.vala | 8 ++++----
3 files changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/vala/valacastexpression.vala b/vala/valacastexpression.vala
index f9e3d30..ecf093d 100644
--- a/vala/valacastexpression.vala
+++ b/vala/valacastexpression.vala
@@ -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;
}
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index f9aba46..8c92e95 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -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;
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 6228ba9..2423e22 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]