[vala/0.52] parser: Clean up creation of constant declaration
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.52] parser: Clean up creation of constant declaration
- Date: Thu, 17 Feb 2022 08:46:58 +0000 (UTC)
commit c471c0ade380b708a160bb7dd83ca6afb8e5e83b
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 8661565f3..4f9b99160 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2879,6 +2879,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;
@@ -2886,7 +2887,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;
@@ -2904,11 +2911,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]