[vala/0.54] parser: Clean up creation of constant declaration
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.54] parser: Clean up creation of constant declaration
- Date: Wed, 9 Feb 2022 13:02:37 +0000 (UTC)
commit f12d96ac7967aa48ff0faa5bff777b22280a7048
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Feb 6 14:29:55 2022 +0100
parser: Clean up creation of constant declaration
vala/valaparser.vala | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 4d860f859..34418afe7 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2913,6 +2913,7 @@ public class Vala.Parser : CodeVisitor {
string id = parse_identifier ();
type = parse_inline_array_type (type);
+ var src = get_src (begin);
// constant arrays don't own their element
unowned ArrayType? array_type = type as ArrayType;
@@ -2920,7 +2921,13 @@ public class Vala.Parser : CodeVisitor {
array_type.element_type.value_owned = false;
}
- var c = new Constant (id, type, null, get_src (begin), comment);
+ Expression? initializer = null;
+ if (accept (TokenType.ASSIGN)) {
+ initializer = parse_expression ();
+ }
+ expect (TokenType.SEMICOLON);
+
+ var c = new Constant (id, type, initializer, src, comment);
c.access = access;
if (ModifierFlags.EXTERN in flags) {
c.is_extern = true;
@@ -2938,11 +2945,6 @@ public class Vala.Parser : CodeVisitor {
Report.error (c.source_reference, "`owned' is not allowed on constants");
}
- if (accept (TokenType.ASSIGN)) {
- c.value = parse_expression ();
- }
- expect (TokenType.SEMICOLON);
-
parent.add_constant (c);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]