public class Field_c extends Expr_c implements Field
Field
is an immutable representation of a Java field
access. It consists of field name and may also have either a
Type
or an Expr
containing the field being
accessed.Term.Instance
Modifier and Type | Field and Description |
---|---|
protected FieldInstance |
fi |
protected Id |
name |
protected Receiver |
target |
protected boolean |
targetImplicit |
exceptions, reachable
Constructor and Description |
---|
Field_c(Position pos,
Receiver target,
Id name) |
Field_c(Position pos,
Receiver target,
Id name,
Ext ext) |
Modifier and Type | Method and Description |
---|---|
<T> java.util.List<T> |
acceptCFG(CFGBuilder<?> v,
java.util.List<T> succs)
Visit this term in evaluation order, calling v.edge() for each successor
in succs, if data flows on that edge.
|
Node |
buildTypes(TypeBuilder tb)
Collects classes, methods, and fields from the AST rooted at this node
and constructs type objects for these.
|
protected void |
checkConsistency(Context c)
Check the consistency of the implicit target inserted by the compiler by
asserting that the FieldInstance in the Context for this field's name is
the same as the FieldInstance we assigned to this field.
|
Node |
checkConstants(ConstantChecker cc)
Check if the node is a compile-time constant.
|
Type |
childExpectedType(Expr child,
AscriptionVisitor av)
Get the expected type of a child expression of
this . |
java.lang.Object |
constantValue(Lang lang)
Return the constant value of the expression, if any.
|
boolean |
constantValueSet(Lang lang)
Return true iff the compiler has determined whether this expression has a
constant value.
|
Node |
copy(NodeFactory nf)
Produce a copy of this node using the given NodeFactory.
|
void |
dump(CodeWriter w)
Dump the AST node for debugging purposes.
|
Node |
extRewrite(ExtensionRewriter rw)
Rewrite the AST for the compilation in this language.
|
NodeVisitor |
extRewriteEnter(ExtensionRewriter rw)
Rewrite the AST for the compilation in this language.
|
FieldInstance |
fieldInstance()
Get the type object for the field.
|
Field |
fieldInstance(FieldInstance fi)
Set the type object for the field.
|
protected <N extends Field_c> |
fieldInstance(N n,
FieldInstance fi) |
Term |
firstChild()
Return the first direct subterm performed when evaluating this term.
|
Flags |
flags()
Return the access flags of the variable, or Flags.NONE
|
Id |
id()
Return the name of the variable.
|
Field |
id(Id name)
Set the field's name.
|
protected <N extends Field_c> |
id(N n,
Id name) |
boolean |
isConstant(Lang lang)
Return whether the expression evaluates to a constant.
|
boolean |
isTargetImplicit()
Returns whether the target of this field is implicit, that is if the
target is either "this" or a classname, and the source code did not
explicitly provide a target.
|
java.lang.String |
name()
Return the name of the variable.
|
Field |
name(java.lang.String name)
Set the field's name.
|
Precedence |
precedence()
Get the precedence of the expression.
|
void |
prettyPrint(CodeWriter w,
PrettyPrinter tr)
Pretty-print the AST using the given
CodeWriter . |
protected <N extends Field_c> |
reconstruct(N n,
Receiver target,
Id name)
Reconstruct the field.
|
Receiver |
target()
Get the field's container object or type.
|
protected <N extends Field_c> |
target(N n,
Receiver target) |
Field |
target(Receiver target)
Set the field's container object or type.
|
Field |
targetImplicit(boolean targetImplicit)
Set whether the target of the field is implicit.
|
protected <N extends Field_c> |
targetImplicit(N n,
boolean targetImplicit) |
java.util.List<Type> |
throwTypes(TypeSystem ts)
List of Types of exceptions that might get thrown.
|
java.lang.String |
toString() |
Node |
typeCheck(TypeChecker tc)
Type check the AST.
|
VarInstance |
varInstance()
Return the type object for the variable.
|
Node |
visitChildren(NodeVisitor v)
Visit the children of the node.
|
booleanValue, byteValue, charValue, constantValue, constantValueSet, doubleValue, floatValue, intValue, isConstant, isTypeChecked, lastLang, longValue, printSubExpr, printSubExpr, shortValue, stringValue, type, type, type
exceptionCheck, exceptions, exceptions, exceptions, listChild, reachable, reachable, reachable
addDecls, buildTypesEnter, copy, copy, copyIfNeeded, del, del, disambiguate, disambiguateEnter, disambiguateOverride, dump, dump, dump, dump, enterChildScope, enterScope, error, error, error, exceptionCheckEnter, ext, ext, ext, ext, isDisambiguated, lang, position, position, position, prettyPrint, prettyPrint, prettyPrint, prettyPrint, print, printBlock, printSubStmt, translate, typeCheckEnter, typeCheckOverride, visit, visitChild, visitEdge, visitList
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
constantValue, constantValueSet, isConstant, printSubExpr, printSubExpr, type
del, del, error, error, ext, ext, ext, ext, isDisambiguated, isTypeChecked, position, position, visit, visitEdge
addDecls, buildTypesEnter, copy, disambiguate, disambiguateEnter, disambiguateOverride, dump, dump, dump, dump, enterChildScope, enterScope, exceptionCheck, exceptionCheckEnter, lang, prettyPrint, prettyPrint, prettyPrint, prettyPrint, translate, typeCheckEnter, typeCheckOverride, visitChild, visitList
exceptions, exceptions, reachable, reachable
protected Receiver target
protected Id name
protected FieldInstance fi
protected boolean targetImplicit
public Precedence precedence()
Expr
precedence
in interface Expr
precedence
in class Expr_c
public Receiver target()
Field
public Field target(Receiver target)
Field
public Id id()
NamedVariable
id
in interface NamedVariable
public java.lang.String name()
NamedVariable
name
in interface NamedVariable
public Field name(java.lang.String name)
Field
public Flags flags()
NamedVariable
flags
in interface NamedVariable
flags
in interface Variable
public VarInstance varInstance()
NamedVariable
varInstance
in interface NamedVariable
public FieldInstance fieldInstance()
Field
fieldInstance
in interface Field
public Field fieldInstance(FieldInstance fi)
Field
fieldInstance
in interface Field
protected <N extends Field_c> N fieldInstance(N n, FieldInstance fi)
public boolean isTargetImplicit()
Field
isTargetImplicit
in interface Field
public Field targetImplicit(boolean targetImplicit)
Field
targetImplicit
in interface Field
protected <N extends Field_c> N targetImplicit(N n, boolean targetImplicit)
protected <N extends Field_c> N reconstruct(N n, Receiver target, Id name)
public Node visitChildren(NodeVisitor v)
NodeOps
visitChildren
in interface NodeOps
visitChildren
in class Node_c
v
- The visitor that will traverse/rewrite the AST.this
.public Node buildTypes(TypeBuilder tb) throws SemanticException
NodeOps
TypeSystem
.
This method is called by the leave()
method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this
or a new copy of the node which will be
installed as a child of the node's parent.buildTypes
in interface NodeOps
buildTypes
in class Expr_c
tb
- The visitor which adds new type objects to the
TypeSystem
.SemanticException
public Node typeCheck(TypeChecker tc) throws SemanticException
NodeOps
leave()
method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this
or a new copy of the node which will be
installed as a child of the node's parent.typeCheck
in interface NodeOps
typeCheck
in class Node_c
tc
- The type checking visitor.SemanticException
public Node checkConstants(ConstantChecker cc) throws SemanticException
NodeOps
leave()
method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this
or a new copy of the node which will be
installed as a child of the node's parent.checkConstants
in interface NodeOps
checkConstants
in class Node_c
cc
- The constant checking visitor.SemanticException
public Type childExpectedType(Expr child, AscriptionVisitor av)
NodeOps
this
.
The expected type is determined by the context in that the child occurs
(e.g., for x = e
, the expected type of e
is
the declared type of x
.
The expected type should impose the least constraints on the child's
type that are allowed by the parent node.childExpectedType
in interface NodeOps
childExpectedType
in class Node_c
child
- A child expression of this node.av
- An ascription visitor.child
.public void prettyPrint(CodeWriter w, PrettyPrinter tr)
Node_c
CodeWriter
.prettyPrint
in interface NodeOps
prettyPrint
in class Node_c
w
- The code writer to which to write.tr
- The pretty printer. This is not a visitor.public void dump(CodeWriter w)
Node
public Term firstChild()
TermOps
firstChild
in interface TermOps
firstChild
in class Term_c
public <T> java.util.List<T> acceptCFG(CFGBuilder<?> v, java.util.List<T> succs)
TermOps
public java.util.List<Type> throwTypes(TypeSystem ts)
NodeOps
throwTypes
in interface NodeOps
throwTypes
in class Node_c
public NodeVisitor extRewriteEnter(ExtensionRewriter rw) throws SemanticException
NodeOps
enter()
method of the
visitor. The method should perform work that should be done
before visiting the children of the node. The method may return
this
or a new copy of the node on which
visitChildren()
and leave()
will be
invoked.extRewriteEnter
in interface NodeOps
extRewriteEnter
in class Node_c
rw
- The visitor.SemanticException
public Node extRewrite(ExtensionRewriter rw) throws SemanticException
NodeOps
leave()
method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this
or a new copy of the node which will be
installed as a child of the node's parent.extRewrite
in interface NodeOps
extRewrite
in class Expr_c
rw
- The visitor.SemanticException
public boolean constantValueSet(Lang lang)
ExprOps
isConstant()
is valid only if
constantValueSet()
is true.constantValueSet
in interface ExprOps
constantValueSet
in class Expr_c
public boolean isConstant(Lang lang)
ExprOps
constantValueSet()
is true.isConstant
in interface ExprOps
isConstant
in class Expr_c
public java.lang.Object constantValue(Lang lang)
ExprOps
isConstant()
is true.constantValue
in interface ExprOps
constantValue
in class Expr_c
protected void checkConsistency(Context c)