yberreby / rgo

[STALLED] A Go compiler, written in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Constant propogation and evaluation

MovingtoMars opened this issue · comments

commented

Go constants are complex. They remain untyped until given a type (although they may have a kind, ie. integer/float/string).

This library looks promising.

https://github.com/golang/go/blob/master/src/go/constant/value.go

commented

Constant evaluation should probably be its own module. Should it be a submodule of the parser submodule? Or maybe a more semantically-related module?

It should definitely be separate. Each pass should be as small and self-contained as possible. Constant propagation is not part of parsing.

PS: I have to go now; thanks for the flat TokenKind PR!