2008 November 21, Friday


Semantic Tree - DNode

 

DNode is a super-type for all declaration/definition nodes.
Usually, a declaration node has a name, thus, every DNode implement ISymbol interface. Additionally, DNode has a field for an unique name withing declaration scope, which is usually the same as it's symbol text, but may be different if there are several DNodes with the same name (or no name) in the same scope.
Next, declarations have arbitrary information attached to it - metadata (annotations). Metadatas are stored in MetaSet container, holded by DNode-s (also, MetaSet is a field in DeclGroup syntax node, which is used to share common metadata and base type for a group of declarations, like in "@public String a, b, c[];" declaration). Many metadata has no fields and are used as flag, for example - @abstract, @static, @volatile and so on. For faster check if a DNode has or has no a flag set, a MetaSet instance has a field of bits to hold these flags when they are set.
  • TypeDecl - new type declaration nodes.
  • Method - new method/function declaration nodes.
    • MethodImpl - regular method's implementation.
    • Constructor - instance or a class constructor, which has additional calls to super-constructor, known/initial states of fields, allows to modify final/sealed fields and so on.
  • Label - a code label declaration.
  • Var - variable and values, like local variables and method's formal parameters, fields, global variables and named constants, values for enumerated types and so on. Has type of the variable/value and an initializer.
    • LVar - local variable.
    • Field - an instance or class variable.
    • Pattern - a pattern-match declaration for select/match/switch cases or multimethod's parameters and so on.
Declarations and metadatas are used in adding extensions to the language, because virtually every new semantic nodes needs a way to be declared somehow - as a new meaning (using a new DNode declaration) or as a property or a modification attached to existing DNodes (i.e. as a metadata of declarations).