Closed AtomCrafty closed 1 year ago
Mario tells me that he's still working on overhauling the tests (hence the checks are failing), and the PR is a bit too large and monolithic to do a proper line-by-line review. However, I've been using the new analysis in the MLIR code generator tool, and it works great there. @eyck WDYT, any objections to merging this soon?
No objections at all.
AFAIK this comes from the XText seeding and Xtext uses them,,,.
How to interface with the analyzer API
The one-stop solution for all of your analysis needs should be the
analysis.CoreDslAnalyzer.analyze
method. It takes theDescriptionContent
representing the file you want to analyze, as well as aValidationMessageAcceptor
. The latter is used to report any errors found during analysis. The method returns anAnalysisResults
instance that contains a map from each root ISA to its correspondingAnalysisContext
, which in turn can be used to access all analysis results, like types, constant values, storage classes, etc. for said root ISA.If you need more granular access, you can call the various methods on
analysis.CoreDslConstantExpressionEvaluator
andanalysis.CoreDslTypeProvider
. The entire analysis API consists of static methods, so you won't need to instantiate any of the classes providing analysis services. All API methods instead require theAnalysisContext
for the ISA currently being analyzed. This context can be obtained via theanalysis.CoreDslElaborator.elaborate
method, which executes the elaboration phase for a given ISA to prepare it for analysis.Data provided by the analysis
Each data point can be retrieved through one of the
AnalysisContext.get*
methods. Please be advised that these functions will always either return a value set during analysis or throw an exception in case no such value was set. Use the correspondingis*Set
method to check whether a value was set for a given node if you are not certain it has to be.Rough outline of the internal changes
typing.DataType
replaced bytype.*Type
typing.TypeProvider
replaced byanalysis.CoreDslTypeProvider
interpreter.CoreDslInterpreter
replaced byanalysis.CoreDslConstantExpressionEvaluator
interpreter.EvaluationContext
replaced byanalysis.AnalysisContext
util.BigIntegerWithRadix
replaced byutil.TypedBigInteger