Explorar el Código

Variable declarations are now again moved to the beginning of the function body

Taddeus Kroes hace 12 años
padre
commit
81894d4b01

+ 1 - 3
phases/desug.ml

@@ -160,8 +160,7 @@ let rec move_inits = function
       Program (init_func :: decls, ann)
     end
 
-  (* DISABLED, interleaved declarations and assignments are allowed in the
-   * intermediate representation
+  (* Split local variable initialisations in declaration and assignment *)
   | FunDef (export, ret_type, name, params, Block body, ann) ->
     let rec place_inits inits = function
       | VarDecs lst :: tl ->
@@ -173,7 +172,6 @@ let rec move_inits = function
     in
     let body = Block (place_inits [] body) in
     FunDef (export, ret_type, name, params, body, ann)
-  *)
 
   | node -> transform_children move_inits node
 

+ 0 - 12
test/basic/functional/var_init_advanced.cvc

@@ -1,12 +0,0 @@
-extern void printInt(int val);
-extern void printNewlines(int num);
-
-int b = 1;
-
-export int main() {
-    int a = b;
-    int b;          // Redefines "b" later than assignment "a = b"
-    printInt(a);    // 1
-    printNewlines(1);
-    return 0;
-}

+ 0 - 1
test/basic/functional/var_init_advanced.out

@@ -1 +0,0 @@
-1