Feldspar / feldspar-compiler

This is the compiler for the Feldspar Language.
Other
22 stars 5 forks source link

Missing epilogue? #201

Open emilaxelsson opened 9 years ago

emilaxelsson commented 9 years ago

The epilogue is discarded from the generated code here. confiscateBigBlock resets the epilogue in the CodeWriter so the epilogue is only present in the result of the bind, but there it is ignored (the second wildcard).

(Note: I have just changed the type of confiscateBigBlock a bit but the code is equivalent to how it was before.)

I'm a bit lost in the code generation. Where should the epilogue go?

@pjonsson, @emwap

pjonsson commented 9 years ago

I don't have everything cached in my head but I think epilogues typically contain memory deallocation and similar constructs. You might have found a bug, or maybe local functions typically have variables that have a larger scope. Without having looked carefully at it my guess is that it should be at the end of the block defined in the tellDef on line 282.

emilaxelsson commented 9 years ago

OK, thanks. I guess the right thing to do is to make some examples (or maybe there already are some) and check the generated code. I'll leave the issue open until I have time to do this.

pjonsson commented 9 years ago

Yes, a future that contains something that allocates memory (sequential perhaps?) that is not immediately written into the result array is my guess. My second guess is a future that has a local future inside its body and waits for that future before returning.