In the L_Array language, the abstract syntax includes (make-vector exp exp), where both arguments can be complex expressions. This would appear to include the case where the first exp happens to be a (read) invocation (or a Var bound to a read invocation).
When rewriting the expose_allocation pass for L_Array, the book suggests that we generate code for L_Array in a manner analogous to the case for L_Tup, which, among other things, generates a Collect node that accepts a plain integer (and not an Int AST node). In the case of L_Tup, the integer is always known at compile time, since in the compiler pass, we can simply count the entries passed into (vector entry-0 entry-1...), so it is fine to create a Collect AST node with that known length; however, for L_Array, if the specified length is a complex expression that cannot be known at compile time (such as a (read) invocation), then Collect in its present form does not seem appropriate. This is confusing to me, especially since it is stated in the text that AllocateArray takes a complex subexpression; possibly I am simply missing the right way to rewrite expose_allocation for L_Array.
In the L_Array language, the abstract syntax includes
(make-vector exp exp), where both arguments can be complex expressions. This would appear to include the case where the firstexphappens to be a(read)invocation (or aVarbound to areadinvocation).When rewriting the
expose_allocationpass for L_Array, the book suggests that we generate code for L_Array in a manner analogous to the case for L_Tup, which, among other things, generates aCollectnode that accepts a plain integer (and not anIntAST node). In the case of L_Tup, the integer is always known at compile time, since in the compiler pass, we can simply count the entries passed into(vector entry-0 entry-1...), so it is fine to create aCollectAST node with that known length; however, for L_Array, if the specified length is a complex expression that cannot be known at compile time (such as a(read)invocation), thenCollectin its present form does not seem appropriate. This is confusing to me, especially since it is stated in the text thatAllocateArraytakes a complex subexpression; possibly I am simply missing the right way to rewriteexpose_allocationfor L_Array.