Skip to content

Collect AST node should accept a complex expression in order to cooperate with L_Array #31

@leungbk

Description

@leungbk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions