spicy icon indicating copy to clipboard operation
spicy copied to clipboard

Codegen for globals incorrectly assumes some cxx::Block

Open bbannier opened this issue 5 years ago • 0 comments

When generating C++ code for globals we might invoke code which assumes that a block exists does not hold.

The GlobalsVisitor first constructs lists of all cxx::declaration::Globals by dispatching on itself. The visitors handling global data invoke CodeGen::compile in order to compute types for GlobalVariables or Constants, or values for initialization in case of Constants.

If any of the code paths generated by these creates a temporary, it is assumed that we are in a cxx::Block (here and here. At the point we dispatch to GlobalsVisitor we however haven't created a scope, yet; this happens later, only if we generate an implementation.

This is an issue with the implementation of BuiltinFunction nodes. Its Visitor currently constructs a statement expression in order to guarantee a block; not doing that leads to failures of spicy/types/port/ops.spicy and spicy/types/port/ops.hlt.

bbannier avatar Feb 16 '21 12:02 bbannier