[vala/staging: 9/12] vala: Add dedicated BinaryExpression.chained() constructor
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 9/12] vala: Add dedicated BinaryExpression.chained() constructor
- Date: Fri, 15 Dec 2017 08:24:03 +0000 (UTC)
commit d1a346d3892fb1e4202093a390aeac5963b920e0
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Dec 14 17:38:38 2017 +0100
vala: Add dedicated BinaryExpression.chained() constructor
codegen/valaccodebasemodule.vala | 4 ++--
vala/valabinaryexpression.vala | 15 ++++++++++++---
vala/valaparser.vala | 16 ++++++++--------
3 files changed, 22 insertions(+), 13 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 56ff942..7c8edb4 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5303,14 +5303,14 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var cright = get_cvalue (expr.right);
CCodeExpression? left_chain = null;
- if (expr.chained) {
+ if (expr.is_chained) {
var lbe = (BinaryExpression) expr.left;
var temp_decl = get_temp_variable (lbe.right.target_type, true, null, false);
emit_temp_var (temp_decl);
var cvar = get_variable_cexpression (temp_decl.name);
var clbe = (CCodeBinaryExpression) get_cvalue (lbe);
- if (lbe.chained) {
+ if (lbe.is_chained) {
clbe = (CCodeBinaryExpression) clbe.right;
}
ccode.add_assignment (cvar, get_cvalue (lbe.right));
diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala
index afdc756..ecfdda5 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -58,7 +58,7 @@ public class Vala.BinaryExpression : Expression {
}
}
- public bool chained;
+ public bool is_chained { get; private set; }
private Expression _left;
private Expression _right;
@@ -76,6 +76,15 @@ public class Vala.BinaryExpression : Expression {
operator = op;
left = _left;
right = _right;
+ is_chained = false;
+ source_reference = source;
+ }
+
+ public BinaryExpression.chained (BinaryOperator op, Expression _left, Expression _right,
SourceReference? source = null) {
+ operator = op;
+ left = _left;
+ right = _right;
+ is_chained = true;
source_reference = source;
}
@@ -425,7 +434,7 @@ public class Vala.BinaryExpression : Expression {
} else {
DataType resulting_type;
- if (chained) {
+ if (is_chained) {
var lbe = (BinaryExpression) left;
resulting_type = context.analyzer.get_arithmetic_result_type
(lbe.right.target_type, right.target_type);
} else {
@@ -438,7 +447,7 @@ public class Vala.BinaryExpression : Expression {
return false;
}
- if (!chained) {
+ if (!is_chained) {
left.target_type = resulting_type.copy ();
}
right.target_type = resulting_type.copy ();
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 2423e22..de3ee64 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -1266,10 +1266,10 @@ public class Vala.Parser : CodeVisitor {
case BinaryOperator.GREATER_THAN_OR_EQUAL:
next ();
var right = parse_shift_expression ();
- left = new BinaryExpression (operator, left, right, get_src (begin));
- if (!first) {
- var be = (BinaryExpression) left;
- be.chained = true;
+ if (first) {
+ left = new BinaryExpression (operator, left, right, get_src (begin));
+ } else {
+ left = new BinaryExpression.chained (operator, left, right, get_src
(begin));
}
first = false;
break;
@@ -1278,10 +1278,10 @@ public class Vala.Parser : CodeVisitor {
// ignore >> and >>= (two tokens due to generics)
if (current () != TokenType.OP_GT && current () != TokenType.OP_GE) {
var right = parse_shift_expression ();
- left = new BinaryExpression (operator, left, right, get_src (begin));
- if (!first) {
- var be = (BinaryExpression) left;
- be.chained = true;
+ if (first) {
+ left = new BinaryExpression (operator, left, right, get_src
(begin));
+ } else {
+ left = new BinaryExpression.chained (operator, left, right,
get_src (begin));
}
first = false;
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]