|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavafe.ast.ASTNode
ASTNode
is the root of the abstract syntax tree node
hierarchy. Every class representing a node in the AST is a (direct
or indirect) subclass of this class.
In designing our AST classes, the following, broad approach was taken:
ExprName
or MethodName
. A later
pass replaces these nodes with either VariableAccess
or concrete subclasses of FieldAccess
or
MethodInvocation
.
TypeName
,
VariableAccess
, (three subclasses of)
FieldAccess
, (three subclasses of)
MethodInvocation
, ConstructorInvocation
,
and NewInstanceExpr
. All nodes except
TypeName
have a field named decl
of the
approriate type that is initialized to null
and is
filled in by name resolution. For TypeName
we use a
decoration rather than a field to avoid a dependency on the
javafe.tc
package.
Measurements:
Node abstract classes: 13
Node concrete classes: 59
Sequence classes: 12
Total classes: 84
Input to code generator: 842 lines of code (513 excluding comments)
Code generator: 993 (675)
Total lines of code: 1835 (1188)
Output of code generator: 4298
The complete list of subclasses is shown below. The names of
subclasses of this class correspond (in general) to the syntactic
units that they represent. Any exceptions to this rule are
documented. All non-leaf classes are abstract. In parenthesis,
the names and types of fields holding the locally-defined children
classes are listed; a postfix *
on a type indicates a
sequence. Square brackets indicate optional elements; the only
these fields can be null.
ASTNode CompilationUnit ([Name pkgName], [LexicalPragma* lexicalPragmas], ImportDecl* imports, TypeDecl* elems) ImportDecl () SingleTypeImport (TypeName typeName) OnDemandImport (Name pkgName) TypeDecl (int modifiers, [ModifierPragma* pmodifiers], Identifier id, [TypeModifierPragma* tmodifiers], TypeName* superInterfaces, TypeDeclElem* elems) ClassDecl ([TypeName superClass]) InterfaceDecl () TypeDeclElem () NOTE: This is an interface TypeDecl FieldDecl RoutineDecl (int modifiers, [ModifierPragma* pmodifiers], FormalParaDecl* args, TypeName* raises, [BlockStmt body]) ConstructorDecl ([TypeModifierPragma* tmodifiers]) MethodDecl (Identifier id, Type returnType) InitBlock (int modifiers, [ModifierPragma* pmodifiers], BlockStmt block) TypeDeclElemPragma () GenericVarDecl (int modifiers, [ModifierPragma* pmodifiers], Identifier id, Type type) LocalVarDecl ([VarInit init]) FieldDecl ([VarInit init]) FormalParaDecl () Stmt () GenericBlockStmt (Stmt* stmts) BlockStmt () SwitchStmt (Expr expr) AssertStmt (Expr expr, String l) VarDeclStmt (LocalVarDecl decl) ClassDeclStmt (ClassDecl anonDecl) WhileStmt (Expr expr, Stmt stmt) DoStmt (Expr expr, Stmt stmt) SynchronizeStmt (Expr expr, BlockStmt stmt) EvalStmt (Expr expr) ReturnStmt ([Expr expr]) ThrowStmt (Expr expr) BranchStmt ([Identifier label]) BreakStmt () ContinueStmt () LabelStmt (Identifier label, Stmt stmt) IfStmt (Expr expr, Stmt thn, Stmt els) ForStmt (Stmt* forInit, Expr test, Expr* forUpdate, Stmt body) SkipStmt () SwitchLabel ([Expr expr]) TryFinallyStmt (Stmt tryClause, Stmt finallyClause) TryCatchStmt (Stmt tryClause, CatchClause* catchClauses) StmtPragma () ConstructorInvocation (boolean superCall, [Expr enclosingInstance], Expr* args) CatchClause (FormalParaDecl arg, Stmt body) VarInit () ArrayInit (VarInit* elems) Expr () ThisExpr (Type classPrefix) LiteralExpr (int tag, [Object value]) ArrayRefExpr (Expr array, Expr index) NewInstanceExpr ([Expr enclosingInstance], TypeName type, Expr* args, [ClassDecl decl]) NewArrayExpr (Type type, Expr* dims, [ArrayInit init]) CondExpr (Expr test, Expr thn, Expr els) InstanceOfExpr (Expr expr, Type type) CastExpr (Expr expr, Type type) BinaryExpr (int op, Expr left, Expr right) UnaryExpr (int op, Expr expr) ParenExpr (Expr expr) AmbiguousVariableAccess (Name name) VariableAccess (Identifier id) FieldAccess (ObjectDesignator od, Identifier id) AmbiguousMethodInvocation (Name name, Expr* args) MethodInvocation (ObjectDesignator od, Identifier id, Expr* args) ClassLiteral (Type type) ObjectDesignator () // "expr.", "type." or "super." ExprObjectDesignator (Expr expr) TypeObjectDesignator (Type type) SuperObjectDesignator () Type () ErrorType() // was previously represented as a PrimitiveType PrimitiveType (int tag) TypeName (Name name) ArrayType (Type elemType) Name () SimpleName (Identifier id) CompoundName (Identifier* ids) ModifierPragma () LexicalPragma () TypeModifierPragma ()
Field Summary | |
(package private) java.lang.Object[] |
decorations
The decorations that have been attached to this node. |
Constructor Summary | |
protected |
ASTNode()
Construct a raw ASTNode whose class invariant(s) have not yet been established. |
Method Summary | |
abstract void |
accept(Visitor v)
Accept a visit from v . |
abstract java.lang.Object |
accept(VisitorArgResult v,
java.lang.Object o)
|
void |
check()
|
abstract java.lang.Object |
childAt(int i)
Return the first-but-ith child of a node. |
abstract int |
childCount()
Return the number of children a node has. |
java.lang.Object |
clone()
Clone node, where the clone has the same decorations as original. |
java.lang.Object |
clone(boolean b)
|
java.lang.Object[] |
getDecorations()
|
int |
getEndLoc()
|
abstract int |
getStartLoc()
|
abstract int |
getTag()
Return the tag of a node. |
void |
setDecorations(java.lang.Object[] d)
|
abstract java.lang.String |
toString()
Return a string representation of this .
|
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
java.lang.Object[] decorations
ASTDecoration
class. There are different ways to implement decorations; this
way is not space-efficient, but it's pretty fast.
Constructor Detail |
protected ASTNode()
Method Detail |
public abstract int getStartLoc()
public int getEndLoc()
public java.lang.Object clone(boolean b)
public java.lang.Object clone()
public java.lang.Object[] getDecorations()
public void setDecorations(java.lang.Object[] d)
public abstract int childCount()
public abstract java.lang.Object childAt(int i)
public abstract int getTag()
public abstract java.lang.String toString()
this
.
Meant for debugging use only, not for presentation.
public abstract void accept(Visitor v)
v
. This method simply
calls the method of v
corresponding to the
allocated type of this
, passing this
as the argument. See the design patterns book.
public abstract java.lang.Object accept(VisitorArgResult v, java.lang.Object o)
public void check()
|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |