Home » openjdk-7 » net.nosica » compiler » semantic »



FeedSymbolVisitor   Visitor to extract all member symbols of a type e.g :
class Toto {
int i = 0;
int test() { return i; }
sub display();
Will extract one member : of type int with an initializer '= 0'
Will extract two methods :
  • method test that returns and int and takes nothing in input
  • method display that returns nothing and takes nothing as input
code | html
FeedTypeVisitor   Extract all type information of type e.g.  code | html
MethodNameHelper     code | html
SyntaxToSymbolHelper     code | html
TypeCheckVisitor   Type checking expressions : quite simple ??

In each expression node :
  • Get the return type waited for this node from the stack
  • For each accept call to a subnode
    • push waited return type for this subnode
    • call accept on this subnode
    • get type returned by the sub node
  • Check that each sub node is conforming well accordingly to the expression being visited
  • Determine the return type of this node
  • Check that the computed return type and the waited return type are compatible
  • Return the computed type

Note 1 : If a waited return type for a particular subnode cannot be computed,
push a special "Unresolved type" instead of
Note 2 : During comparison of two types, if one (and only one) of the types is "Unresolved Type"
say types are compatible and return the other one
Note 3 : If two types are incompatible, this is an ambiguous expression ==> Error.
Note 4 : PrimaryExpression is very different from the other expressions, we will have to use
a different techniques.

Flow control :

Each expression that control flow must :
  • generates its first label as a label that will be the target of continue statement
  • generates its first label as a label that has a reference to the end label for break statement
code | html
TypeCheckerHelper     code | html