Преглед на файлове

Fixed bug in dimreduce where value of VarLet would not always be traversed

Taddeus Kroes преди 12 години
родител
ревизия
e605087b5b
променени са 2 файла, в които са добавени 10 реда и са изтрити 9 реда
  1. 3 2
      phases/dimreduce.ml
  2. 7 7
      test/testsuite/assignment/15_matrixMult.cvc

+ 3 - 2
phases/dimreduce.ml

@@ -88,15 +88,16 @@ and dim_reduce depth = function
     begin match typeof dec with
     | ArrayDims (_, dims) ->
       VarUse (dec, Some [expand depth dims values], ann)
-    | _ -> node
+    | _ -> raise InvalidNode
     end
 
   (* Expand indices when assigning to array index *)
   | VarLet (dec, Some values, value, ann) as node ->
     begin match typeof dec with
     | ArrayDims (_, dims) ->
+      let value = dim_reduce depth value in
       VarLet (dec, Some [expand depth dims values], value, ann)
-    | _ -> node
+    | _ -> raise InvalidNode
     end
 
   | node -> transform_children (dim_reduce depth) node

+ 7 - 7
test/testsuite/assignment/15_matrixMult.cvc

@@ -13,14 +13,14 @@ export int main()
 	//Read dimensions of matrix from input
 	int rowsMatrixA =5;
 	int colMatrixA = 5;
-	
+
 	int rowsMatrixB =5;
 	int colMatrixB = 5;
-	
+
 	int[rowsMatrixA, colMatrixA] matrixA;
 	int[rowsMatrixB, colMatrixB] matrixB;
 	int[rowsMatrixA, colMatrixB] matrixProduct;
-	
+
 	//Product cannot be done if the following condition does not stand
 	if (colMatrixA == rowsMatrixB)
 	{
@@ -35,7 +35,8 @@ export int main()
 			}
 			printNewlines(1);
 		}
-		
+        printNewlines(1);
+
 		//Fill in Matrix B
 		for (int i = 0, rowsMatrixB)
 		{
@@ -47,7 +48,8 @@ export int main()
 			}
 			printNewlines(1);
 		}
-		
+        printNewlines(1);
+
 		//Do Multiplication
 		for (int i = 0, rowsMatrixA)
 		{
@@ -71,8 +73,6 @@ export int main()
 			}
 			printNewlines(1);
 		}
-
-		
 	}
 	return 0;
 }