Changes between Initial Version and Version 1 of NewFrontEnd


Ignore:
Timestamp:
2017-01-24T16:54:57+01:00 (8 years ago)
Author:
adrpo
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NewFrontEnd

    v1 v1  
     1== New FrontEnd ==
     2
     3This page gathers all the information about the new front-end. See also #4138
     4
     5=== Debugging ===
     6Weather you use MDT (make sure you keep it updated) or OMEdit you need to compile the source code with CFLAGS=-g to be able to debug the compiler.
     7Delete OMCompiler/Compiler/boot/build and then rebuild with CFLAGS=-g
     8
     9=== Implementation details ===
     10
     11The new frontend is divided into multiple (mostly) separate phases.
     12The main entry point of the frontend is NFInst.instClassInProgram, which consists of four phases:
     13 
     14  * Lookup the class to instantiate (lookup might do some limited instantiation).
     15  * Instantiate the class.
     16  * Type the class.
     17  * Flatten the class.
     18
     19So simply checking how far the instantiation gets in instClassInProgram will help narrow issues down considerably.
     20We do of course want proper error messages, so feel free to add error messages, internal errors or just "IMPLEMENT ME" printouts as appropriate.
     21
     22The instantiation itself is divided into three recursive phases:
     23
     24  * partialInstClass (creates a scope for the class, and separates out components etc.)
     25  * expandClass (looks up and expands extends clauses)
     26  * instClass (instantiates the components)
     27
     28A class only needs to be expanded for lookup to be possible, so the lookup will expand classes if necessary. There are two helper functions for this, instantiate which does all three phases and expand which only does the first two.
     29
     30Something important to know about the instantiation is that InstNodes are mutable, i.e. the class or component in them are stored in an array of length 1. Without mutable nodes it would be very difficult to maintain the trees. It also means that one has to be a bit careful with how the nodes are handled.
     31
     32One example of this is that expanded classes are generic, i.e. they do not have modifiers and such applied. Whenever a class is expanded, by the instantiation or the lookup, it will therefore be updated in the class tree and reused. Similarly, whenever a class is fully instantiated, e.g. when instantiating a component, it will not be updated in the class tree since a fully instantiated class is unique for each component. It will instead be cloned, fully instantiated and then stored in the component whose type it is.
     33
     34Also, even though I might talk about the class tree or the instance tree they are not actually separate trees, but rather one combined tree made up of InstNodes (e.g. each component knows its parent component, each components type knows its parent class, and so on).
     35