[vala/wip/transform] Fix foreach on inline allocated arrays



commit ab5942915cb4e254030b84df741856c0da32f8e3
Author: Luca Bruno <lucabru src gnome org>
Date:   Sat Mar 15 11:17:55 2014 +0100

    Fix foreach on inline allocated arrays

 codegen/valaccodetransformer.vala |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodetransformer.vala b/codegen/valaccodetransformer.vala
index 7d8d5e8..0c7d6ef 100644
--- a/codegen/valaccodetransformer.vala
+++ b/codegen/valaccodetransformer.vala
@@ -223,8 +223,14 @@ public class Vala.CCodeTransformer : CodeTransformer {
 
        public override void visit_foreach_statement (ForeachStatement stmt) {
                begin_replace_statement (stmt);
-               
-               var collection = b.add_temp_declaration (stmt.collection.value_type, stmt.collection);
+
+               string collection;
+               var collection_type = copy_type (stmt.collection.value_type);
+               if (collection_type is ArrayType && (((ArrayType) collection_type).inline_allocated)) {
+                       collection = stmt.collection.to_string ();
+               } else {
+                       collection = b.add_temp_declaration (collection_type, stmt.collection);
+               }
 
                stmt.body.remove_local_variable (stmt.element_variable);
                stmt.element_variable.checked = false;


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