[vala/wip/transform: 85/131] Do not handle binary expressions without parent statement



commit 7ac655bb498cf120bfbe947c389fbf1253a77300
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu Feb 9 13:45:57 2012 +0100

    Do not handle binary expressions without parent statement

 codegen/valaccodetransformer.vala | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodetransformer.vala b/codegen/valaccodetransformer.vala
index cdbe3a279..92df673ec 100644
--- a/codegen/valaccodetransformer.vala
+++ b/codegen/valaccodetransformer.vala
@@ -210,8 +210,6 @@ public class Vala.CCodeTransformer : CodeTransformer {
                // convert to simple loop
                push_builder (new CodeBuilder (context, stmt, stmt.source_reference));
 
-               var block = new Block (stmt.source_reference);
-
                // initializer
                foreach (var init_expr in stmt.get_initializer ()) {
                        b.add_expression (init_expr);
@@ -401,10 +399,16 @@ public class Vala.CCodeTransformer : CodeTransformer {
        }
 
        public override void visit_binary_expression (BinaryExpression expr) {
+               var parent_statement = expr.parent_statement;
+               if (parent_statement == null) {
+                       base.visit_binary_expression (expr);
+                       return;
+               }
+
                Expression replacement = null;
                var old_parent_node = expr.parent_node;
                var target_type = expr.target_type != null ? expr.target_type.copy () : null;
-               push_builder (new CodeBuilder (context, expr.parent_statement, expr.source_reference));
+               push_builder (new CodeBuilder (context, parent_statement, expr.source_reference));
 
                if (context.analyzer.get_current_non_local_symbol (expr) is Block
                    && (expr.operator == BinaryOperator.AND || expr.operator == BinaryOperator.OR)) {


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