[vala/wip/transform: 88/99] Fix parsing temporary variables. Use statements()
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/transform: 88/99] Fix parsing temporary variables. Use statements()
- Date: Sun, 9 Feb 2014 22:45:42 +0000 (UTC)
commit 3eeeb41b22de339ce85910b1bc681833c7df4561
Author: Luca Bruno <lucabru src gnome org>
Date: Sun Feb 2 23:59:10 2014 +0100
Fix parsing temporary variables. Use statements()
codegen/valaccodetransformer.vala | 15 ++++++---------
vala/valaparser.vala | 10 +++++++---
2 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/codegen/valaccodetransformer.vala b/codegen/valaccodetransformer.vala
index 4f2abe7..52d5a4e 100644
--- a/codegen/valaccodetransformer.vala
+++ b/codegen/valaccodetransformer.vala
@@ -224,13 +224,10 @@ public class Vala.CCodeTransformer : CodeTransformer {
}
b.add_else ();
statements (@"$notfirst = true;");
- /* b.add_assignment (expression (notfirst), expression ("true")); */
b.close ();
if (stmt.condition != null && !always_true (stmt.condition)) {
- b.open_if (new UnaryExpression (UnaryOperator.LOGICAL_NEGATION,
stmt.condition, stmt.source_reference));
- b.add_break ();
- b.close ();
+ statements (@"if (!$(stmt.condition)) break;");
}
b.add_statement (stmt.body);
@@ -374,11 +371,11 @@ public class Vala.CCodeTransformer : CodeTransformer {
begin_replace_expression (expr);
var result = b.add_temp_declaration (expr.value_type);
- b.open_if (expr.condition);
- b.add_assignment (expression (result), expr.true_expression);
- b.add_else ();
- b.add_assignment (expression (result), expr.false_expression);
- b.close ();
+ statements (@"if ($(expr.condition)) {
+ $result = $(expr.true_expression);
+ } else {
+ $result = $(expr.false_expression);
+ }");
replacement = return_temp_access (result, expr.value_type, target_type, formal_target_type);
end_replace_expression (replacement);
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 6fdafab..3a95249 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -271,6 +271,12 @@ public class Vala.Parser : CodeVisitor {
}
break;
default:
+ if (compiler_code && current () == TokenType.DOT) {
+ next();
+ next();
+ return;
+ }
+
throw new ParseError.SYNTAX (get_error ("expected identifier"));
}
}
@@ -404,10 +410,8 @@ public class Vala.Parser : CodeVisitor {
void skip_symbol_name () throws ParseError {
if (compiler_code && accept (TokenType.DOT)) {
// temporary variable
- next ();
- next ();
- accept (TokenType.DOT);
}
+
do {
skip_identifier ();
} while (accept (TokenType.DOT) || accept (TokenType.DOUBLE_COLON));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]