solang icon indicating copy to clipboard operation
solang copied to clipboard

The CFG needs a proper representation for pointers

Open LucasSte opened this issue 3 years ago • 3 comments

The CFG does not have an effective way to represent pointers, consequently, some constructs are not correctly implemented. One example is the Type::BufferPointer that originates after we advance a pointer to the struct vector data area. The nonexistence of a pointer representation also forestalls the correct generation of system calls that require pointers as arguments.

LucasSte avatar Aug 09 '22 15:08 LucasSte

We do an awful lot of pointer conversions (like making a value a pointer by saving it on the stack) in emit. Ideally we would not do this at all in emit.

seanyoung avatar Aug 09 '22 16:08 seanyoung

In the CFG, Type::Struct() means a pointer to a struct. How do we represent the type after an Expression::Load?

LucasSte avatar Aug 10 '22 12:08 LucasSte

I think that is one of the things that needs fixing. Type::Struct(..) should be exactly a struct, and Expression::Load(..) should take a pointer argument (e.g Type::Ref(Type::Struct()) or maybe we should rename it Type::Ptr(..)

seanyoung avatar Aug 10 '22 12:08 seanyoung