|
@@ -217,16 +217,20 @@ let assemble program =
|
|
|
[InlineComment (Label (endlabel), node2str node)]
|
|
[InlineComment (Label (endlabel), node2str node)]
|
|
|
|
|
|
|
|
(* Arrays *)
|
|
(* Arrays *)
|
|
|
- | Allocate (dec, dims, _) ->
|
|
|
|
|
|
|
+ | Allocate (dec, [dim], _) ->
|
|
|
let store = match (depthof dec, depthof node) with
|
|
let store = match (depthof dec, depthof node) with
|
|
|
| (0, _) -> Store (typeof dec, Glob, indexof dec)
|
|
| (0, _) -> Store (typeof dec, Glob, indexof dec)
|
|
|
| (a, b) when a = b -> Store (typeof dec, Current, indexof dec)
|
|
| (a, b) when a = b -> Store (typeof dec, Current, indexof dec)
|
|
|
| _ -> raise InvalidNode
|
|
| _ -> raise InvalidNode
|
|
|
in
|
|
in
|
|
|
- trav_all dims @
|
|
|
|
|
- [NewArray (basetypeof dec, List.length dims);
|
|
|
|
|
|
|
+ trav dim @
|
|
|
|
|
+ [NewArray (basetypeof dec);
|
|
|
InlineComment (store, node2str node)]
|
|
InlineComment (store, node2str node)]
|
|
|
|
|
|
|
|
|
|
+ | Allocate _ ->
|
|
|
|
|
+ raise (FatalError (NodeMsg (node, "invalid number of array dimensions \
|
|
|
|
|
+ (should be one-dimensional)")))
|
|
|
|
|
+
|
|
|
| VarUse (dec, Some dims, _) ->
|
|
| VarUse (dec, Some dims, _) ->
|
|
|
let load = match (depthof dec, depthof node) with
|
|
let load = match (depthof dec, depthof node) with
|
|
|
| (0, _) -> Load (typeof dec, Glob, indexof dec)
|
|
| (0, _) -> Load (typeof dec, Glob, indexof dec)
|