|
@@ -69,11 +69,6 @@ let rec multiply = function
|
|
|
| [node] -> node
|
|
| [node] -> node
|
|
|
| hd :: tl -> Binop (Mul, hd, multiply tl, [Type Int])
|
|
| hd :: tl -> Binop (Mul, hd, multiply tl, [Type Int])
|
|
|
|
|
|
|
|
-let rec multiply_all = function
|
|
|
|
|
- | [] -> raise InvalidNode
|
|
|
|
|
- | [node] -> node
|
|
|
|
|
- | hd :: tl -> Binop (Mul, hd, multiply_all tl, [])
|
|
|
|
|
-
|
|
|
|
|
let rec expand depth dims =
|
|
let rec expand depth dims =
|
|
|
let rec do_expand dims = function
|
|
let rec do_expand dims = function
|
|
|
| [] -> raise InvalidNode
|
|
| [] -> raise InvalidNode
|
|
@@ -105,17 +100,18 @@ and dim_reduce depth = function
|
|
|
| VarDec (ArrayDims (ctype, _), name, None, ann) ->
|
|
| VarDec (ArrayDims (ctype, _), name, None, ann) ->
|
|
|
VarDec (Array ctype, name, None, ann)
|
|
VarDec (Array ctype, name, None, ann)
|
|
|
|
|
|
|
|
- (* Increase nesting depth when goiing into function *)
|
|
|
|
|
|
|
+ (* Increase nesting depth when going into function *)
|
|
|
| FunDef (export, ret_type, name, params, body, ann) ->
|
|
| FunDef (export, ret_type, name, params, body, ann) ->
|
|
|
let trav = dim_reduce (depth + 1) in
|
|
let trav = dim_reduce (depth + 1) in
|
|
|
FunDef (export, ret_type, name, List.map trav params, trav body, ann)
|
|
FunDef (export, ret_type, name, List.map trav params, trav body, ann)
|
|
|
|
|
|
|
|
(* Expand indices when dereferencing *)
|
|
(* Expand indices when dereferencing *)
|
|
|
| VarUse (dec, Some values, ann) ->
|
|
| VarUse (dec, Some values, ann) ->
|
|
|
- begin match typeof dec with
|
|
|
|
|
- | ArrayDims (_, dims) ->
|
|
|
|
|
- VarUse (dec, Some [expand depth dims values], ann)
|
|
|
|
|
- | _ -> raise InvalidNode
|
|
|
|
|
|
|
+ begin
|
|
|
|
|
+ match typeof dec with
|
|
|
|
|
+ | ArrayDims (_, dims) ->
|
|
|
|
|
+ VarUse (dec, Some [expand depth dims values], ann)
|
|
|
|
|
+ | _ -> raise InvalidNode
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
(* Expand indices when assigning to array index *)
|
|
(* Expand indices when assigning to array index *)
|