fabianschuiki / moore

A hardware compiler based on LLHD and CIRCT
http://www.llhd.io
Apache License 2.0
246 stars 31 forks source link

Implement RST visitor #211

Open fabianschuiki opened 3 years ago

fabianschuiki commented 3 years ago

At the moment we have the AST and a corresponding visitor on that AST. The ResolutionVisitor, which ensures all names have been resolved and, more importantly, diagnostics related to names have been emitted early, uses this ast::Visitor. The AST however contains ambiguities, which now shows up for example in SubroutinePort. Resolving names is possible for one variant of the ambiguity (anonymous port with a named type), but not possible for the other (named port with implicit type). The ResolutionVisitor should rather be a rst::Visitor, which goes over the AST with resolved ambiguities.

It's not yet quite clear how to do this. Intuitively one would want to "inherit" from the ast::Visitor and "override" a few of the callbacks (the ones which may walk over ambiguities) in order to resolve them up front before calling corresonding functions for the resolved node. Not sure how to do this in Rust without just re-implementing the whole trait, though.