[vala/wip/issue/327: 47/64] Some code-style and logic fixes
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue/327: 47/64] Some code-style and logic fixes
- Date: Tue, 21 Apr 2020 18:36:07 +0000 (UTC)
commit b47442bd979244b5eb921379cc095ce19b799723
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Mar 28 10:00:23 2020 +0100
Some code-style and logic fixes
vala/valaparser.vala | 7 ++-----
vala/valatokentype.vala | 1 +
vala/valawithstatement.vala | 25 +++++++++++++------------
3 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index e86fec48f..c2d53aae7 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2271,11 +2271,8 @@ public class Vala.Parser : CodeVisitor {
var expr = parse_expression ();
expect (TokenType.CLOSE_PARENS);
var src = get_src (begin);
- Block? stmt = null;
- if (current () != TokenType.SEMICOLON) {
- stmt = parse_embedded_statement ("with", false);
- }
- return new WithStatement (expr, stmt, src);
+ var body = parse_embedded_statement ("with", false);
+ return new WithStatement (expr, body, src);
}
string parse_attribute_value () throws ParseError {
diff --git a/vala/valatokentype.vala b/vala/valatokentype.vala
index 7124c049a..9cc6d1c74 100644
--- a/vala/valatokentype.vala
+++ b/vala/valatokentype.vala
@@ -287,6 +287,7 @@ public enum Vala.TokenType {
case VOLATILE: return "`volatile'";
case WEAK: return "`weak'";
case WHILE: return "`while'";
+ case WITH: return "`with'";
case YIELD: return "`yield'";
default: return "unknown token";
}
diff --git a/vala/valawithstatement.vala b/vala/valawithstatement.vala
index 049c92805..0a012ab47 100644
--- a/vala/valawithstatement.vala
+++ b/vala/valawithstatement.vala
@@ -1,4 +1,4 @@
-/* valalockstatement.vala
+/* valawithtatement.vala
*
* Copyright (C) 2020 Nick Schrader
*
@@ -24,22 +24,22 @@ using GLib;
public class Vala.WithStatement : Symbol, Statement {
/**
- * Expression representing the expression to be locked.
+ * Expression representing the type of body's dominant scope.
*/
public Expression expression {
get { return _expression; }
- set {
+ private set {
_expression = value;
_expression.parent_node = this;
}
}
/**
- * The statement during its execution the expression is locked.
+ * The block which dominant scope is type of expression.
*/
- public Block? body {
+ public Block body {
get { return _body; }
- set {
+ private set {
_body = value;
if (_body != null) {
_body.parent_node = this;
@@ -50,18 +50,18 @@ public class Vala.WithStatement : Symbol, Statement {
private Expression _expression;
private Block _body;
- public WithStatement (Expression expression, Block? body, SourceReference? source_reference = null) {
- base(null, source_reference);
+ public WithStatement (Expression expression, Block body, SourceReference? source_reference = null) {
+ base (null, source_reference);
+ this.expression = expression;
this.body = body;
this.source_reference = source_reference;
- this.expression = expression;
}
public override void accept (CodeVisitor visitor) {
visitor.visit_with_statement (this);
}
- public override void accept_children(CodeVisitor visitor) {
+ public override void accept_children (CodeVisitor visitor) {
expression.accept (visitor);
if (body != null) {
body.accept (visitor);
@@ -75,15 +75,16 @@ public class Vala.WithStatement : Symbol, Statement {
}
public override bool check (CodeContext context) {
- expression.check(context);
+ expression.check (context);
var old_symbol = context.analyzer.current_symbol;
owner = context.analyzer.current_symbol.scope;
context.analyzer.current_symbol = this;
- body.check(context);
+ body.check (context);
context.analyzer.current_symbol = old_symbol;
+
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]