[vala/wip/fast-vapi: 5/7] parser: Improve source-location for local Constant declarations
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/fast-vapi: 5/7] parser: Improve source-location for local Constant declarations
- Date: Wed, 10 Apr 2019 12:22:43 +0000 (UTC)
commit bd28a5db56b3cfb3ed1927b0f54227555be2588e
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Apr 10 14:12:21 2019 +0200
parser: Improve source-location for local Constant declarations
vala/valaparser.vala | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 93b3a7984..3e90fb113 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -1846,6 +1846,7 @@ public class Vala.Parser : CodeVisitor {
}
void parse_local_constant_declarations (Block block) throws ParseError {
+ var begin = get_location ();
expect (TokenType.CONST);
var constant_type = parse_type (false, false);
@@ -1855,10 +1856,17 @@ public class Vala.Parser : CodeVisitor {
array_type.element_type.value_owned = false;
}
+ bool is_first = true;
do {
+ if (!is_first) {
+ begin = get_location ();
+ } else {
+ is_first = false;
+ }
+
DataType type_copy = constant_type.copy ();
var local = parse_local_constant (type_copy);
- block.add_statement (new DeclarationStatement (local, local.source_reference));
+ block.add_statement (new DeclarationStatement (local, get_src (begin)));
block.add_local_constant (local);
local.active = false;
} while (accept (TokenType.COMMA));
@@ -1868,13 +1876,13 @@ public class Vala.Parser : CodeVisitor {
Constant parse_local_constant (DataType constant_type) throws ParseError {
var begin = get_location ();
string id = parse_identifier ();
-
var type = parse_inline_array_type (constant_type);
+ var src = get_src (begin);
expect (TokenType.ASSIGN);
var initializer = parse_expression ();
- return new Constant (id, type, initializer, get_src (begin));
+ return new Constant (id, type, initializer, src);
}
Statement parse_expression_statement () throws ParseError {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]