[vala/wip/transform: 89/102] Fix parsing temporary variables. Use statements()



commit ec8c71195d1e4702623ee800f9c69234e3d67f62
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              |    8 +++++---
 2 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/codegen/valaccodetransformer.vala b/codegen/valaccodetransformer.vala
index 77e06c7..fa0448c 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 9228da0..faf585f 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -271,6 +271,11 @@ public class Vala.Parser : CodeVisitor {
                        }
                        break;
                default:
+                       if (compiler_code && current () == TokenType.DOT) {
+                               next();
+                               next();
+                               return;
+                       }
                        throw new ParseError.SYNTAX ("expected identifier");
                }
        }
@@ -404,9 +409,6 @@ 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 ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]