[vala] Replace `yields' by `async' method modifier
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Replace `yields' by `async' method modifier
- Date: Sun, 13 Sep 2009 15:29:20 +0000 (UTC)
commit 7fe449fc8069b5635074f74049647fc1cf53b1bc
Author: Jürg Billeter <j bitron ch>
Date: Sun Sep 13 11:05:08 2009 +0200
Replace `yields' by `async' method modifier
vala/valacodewriter.vala | 4 ++++
vala/valaparser.vala | 22 ++++++++++++++--------
vala/valascanner.vala | 6 +++---
vala/valatokentype.vala | 8 ++++----
4 files changed, 25 insertions(+), 15 deletions(-)
---
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index 736513f..5a9cb10 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -902,6 +902,10 @@ public class Vala.CodeWriter : CodeVisitor {
} else if (m.overrides) {
write_string ("override ");
}
+
+ if (m.coroutine) {
+ write_string ("async ");
+ }
if (!(m is CreationMethod)) {
write_return_type (m.return_type);
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index fa5bc3d..9dfe7d3 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -57,7 +57,8 @@ public class Vala.Parser : CodeVisitor {
NEW = 1 << 4,
OVERRIDE = 1 << 5,
STATIC = 1 << 6,
- VIRTUAL = 1 << 7
+ VIRTUAL = 1 << 7,
+ ASYNC = 1 << 8
}
public Parser () {
@@ -168,6 +169,7 @@ public class Vala.Parser : CodeVisitor {
switch (current ()) {
case TokenType.ABSTRACT:
case TokenType.AS:
+ case TokenType.ASYNC:
case TokenType.BASE:
case TokenType.BREAK:
case TokenType.CASE:
@@ -233,7 +235,6 @@ public class Vala.Parser : CodeVisitor {
case TokenType.WEAK:
case TokenType.WHILE:
case TokenType.YIELD:
- case TokenType.YIELDS:
next ();
return;
case TokenType.INTEGER_LITERAL:
@@ -2208,6 +2209,9 @@ public class Vala.Parser : CodeVisitor {
} else if (ModifierFlags.CLASS in flags) {
method.binding = MemberBinding.CLASS;
}
+ if (ModifierFlags.ASYNC in flags) {
+ method.coroutine = true;
+ }
if (ModifierFlags.NEW in flags) {
method.hides = true;
}
@@ -2249,9 +2253,6 @@ public class Vala.Parser : CodeVisitor {
} while (accept (TokenType.COMMA));
}
expect (TokenType.CLOSE_PARENS);
- if (accept (TokenType.YIELDS)) {
- method.coroutine = true;
- }
if (accept (TokenType.THROWS)) {
do {
method.add_error_type (parse_type ());
@@ -2758,6 +2759,10 @@ public class Vala.Parser : CodeVisitor {
next ();
flags |= ModifierFlags.ABSTRACT;
break;
+ case TokenType.ASYNC:
+ next ();
+ flags |= ModifierFlags.ASYNC;
+ break;
case TokenType.CLASS:
next ();
flags |= ModifierFlags.CLASS;
@@ -2848,6 +2853,9 @@ public class Vala.Parser : CodeVisitor {
|| ModifierFlags.OVERRIDE in flags) {
Report.error (method.source_reference, "abstract, virtual, and override modifiers are not applicable to creation methods");
}
+ if (ModifierFlags.ASYNC in flags) {
+ method.coroutine = true;
+ }
expect (TokenType.OPEN_PARENS);
if (current () != TokenType.CLOSE_PARENS) {
do {
@@ -2856,9 +2864,6 @@ public class Vala.Parser : CodeVisitor {
} while (accept (TokenType.COMMA));
}
expect (TokenType.CLOSE_PARENS);
- if (accept (TokenType.YIELDS)) {
- method.coroutine = true;
- }
if (accept (TokenType.THROWS)) {
do {
method.add_error_type (parse_type ());
@@ -3035,6 +3040,7 @@ public class Vala.Parser : CodeVisitor {
bool is_declaration_keyword (TokenType type) {
switch (type) {
case TokenType.ABSTRACT:
+ case TokenType.ASYNC:
case TokenType.CLASS:
case TokenType.CONST:
case TokenType.DELEGATE:
diff --git a/vala/valascanner.vala b/vala/valascanner.vala
index a38c480..628ad52 100644
--- a/vala/valascanner.vala
+++ b/vala/valascanner.vala
@@ -155,6 +155,9 @@ public class Vala.Scanner {
break;
case 5:
switch (begin[0]) {
+ case 'a':
+ if (matches (begin, "async")) return TokenType.ASYNC;
+ break;
case 'b':
if (matches (begin, "break")) return TokenType.BREAK;
break;
@@ -252,9 +255,6 @@ public class Vala.Scanner {
break;
}
break;
- case 'y':
- if (matches (begin, "yields")) return TokenType.YIELDS;
- break;
}
break;
case 7:
diff --git a/vala/valatokentype.vala b/vala/valatokentype.vala
index 0b80e46..d22c07b 100644
--- a/vala/valatokentype.vala
+++ b/vala/valatokentype.vala
@@ -1,6 +1,6 @@
/* valatokentype.vala
*
- * Copyright (C) 2008 Jürg Billeter
+ * Copyright (C) 2008-2009 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -36,6 +36,7 @@ public enum Vala.TokenType {
ASSIGN_PERCENT,
ASSIGN_SHIFT_LEFT,
ASSIGN_SUB,
+ ASYNC,
BASE,
BITWISE_AND,
BITWISE_OR,
@@ -143,8 +144,7 @@ public enum Vala.TokenType {
VOLATILE,
WEAK,
WHILE,
- YIELD,
- YIELDS;
+ YIELD;
public weak string to_string () {
switch (this) {
@@ -160,6 +160,7 @@ public enum Vala.TokenType {
case ASSIGN_PERCENT: return "`%='";
case ASSIGN_SHIFT_LEFT: return "`<<='";
case ASSIGN_SUB: return "`-='";
+ case ASYNC: return "`async'";
case BASE: return "`base'";
case BITWISE_AND: return "`&'";
case BITWISE_OR: return "`|'";
@@ -264,7 +265,6 @@ public enum Vala.TokenType {
case WEAK: return "`weak'";
case WHILE: return "`while'";
case YIELD: return "`yield'";
- case YIELDS: return "`yields'";
default: return "unknown token";
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]