Skip to content

The library manager

KevinMazet edited this page Jan 6, 2014 · 9 revisions

The GOOL library manager and its usage are described in Libraries support.

Architecture of the library manager

GOOL grand scheme Get rescalable picture here.

Chain of event

When recognizing the input program (in the input language's Recognizer)

At the beginning of the visitCompilationUnit method, the RecognizerMatcher gets initialized with a call to RecognizerMatcher.init(String inputLang) that specifies to the RecognizerMatcher which input language is used. Within this call, the ClassMatchTable and the MethodMatchTable of the RecognizerMatcher may be initialized with the "default libraries" if specified by the Input import matching file of the input language.

When visiting an import, the RecognizerMatcher.matchImport method is called with the import string as parameter. The RecognizerMatcher then checks the Input import matching file to find a GOOL library class name matched with this import. If it succeeds, then the ClassMatchTable and the MethodMatchTable are updated with the recognized GOOL class and its methods, and the GOOL library class name is returned. If it does not find any corresponding GOOL class, the null pointer is returned and the import is registered as an UnrecognizedDependency.

When typing an expression, the RecognizerMatcher.matchClass method is called with the type name as a String. The RecognizerMatcher then checks the ClassMatchTable and returns the name of the corresponding GOOL library class if there is one. Then, this GOOL library class is registered as a RecognizedDependency.

When visiting a method call, the RecognizerMatcher.matchMethod method is called with the method's signature as a String. The RecognizerMatcher then checks the MethodMatchTable and returns the name of the corresponding GOOL method if there is one. Then, the corresponding GOOL class is registered as a RecognizedDependency.

At the end of the visitCompilationUnit method (once all GOOL classes have been built), a call to GoolLibraryClassAstBuilder.init is done. Then, for all RecognizedDependency in the GOOL ASTs made, the GoolLibraryClassAstBuilder.buildGoolClass method is called with the name of the GOOL library class contained in the RecognizedDependency. Finally, the Recognizer gets all the ASTs of the GOOL library classes with GoolLibraryClassAstBuilder.getBuiltAsts and adds them with the others so that they get generated as well.

When generating the output program (in the output language's Generator)

To be done.