|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.common.Root scale.clef.Node scale.clef.decl.Declaration scale.clef.decl.ValueDecl scale.clef.decl.FieldDecl
public class FieldDecl
This class represents a component of an aggregate data structure.
$Id: FieldDecl.java,v 1.40 2007-10-04 19:58:04 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Constructor Summary | |
---|---|
FieldDecl(java.lang.String name,
Type type)
|
|
FieldDecl(java.lang.String name,
Type type,
long fieldOffset)
|
|
FieldDecl(java.lang.String name,
Type type,
long fieldOffset,
int fieldAlignment)
|
|
FieldDecl(java.lang.String name,
Type type,
long fieldOffset,
int fieldAlignment,
Expression initialValue)
Create a declaration of a field of a structure. |
|
FieldDecl(java.lang.String name,
Type type,
long fieldOffset,
int fieldAlignment,
Expression initialValue,
int bits)
Create a declaration of a field of a structure. |
Method Summary | |
---|---|
Accessibility |
accessibility()
Return the declaration accessibility. |
Declaration |
copy(java.lang.String name)
Return a copy of this Declaration but with a different name. |
int |
getBitOffset()
Return the bit offset from the appropriate (word) boundary in the structure. |
int |
getBits()
Return the number of bits specified for the field - 0 means none specified. |
int |
getFieldAlignment()
Return the required field alignment for the field. |
long |
getFieldOffset()
Return the required field offset for the field. |
Expression |
getInitialValue()
Return the initializer for the field. |
AggregateType |
getMyStruct()
Return the class that this field belong to, if applicable. |
boolean |
isFieldDecl()
Return true if FieldDecl instance. |
boolean |
isPackedField(Machine machine)
Return true if the field is not aligned on a natural boundary for its type. |
FieldDecl |
returnFieldDecl()
R a FieldDecl instance or null . |
void |
setAccessibility(Accessibility accessibility)
Specify the accessibility of the declaration. |
void |
setBitOffset(int bitOffset)
Set the bit offset from the appropriate (word) boundary in the structure. |
void |
setBits(int bits,
int bitOffset)
Set the number of bits specified for the field - 0 means none specified. |
void |
setFieldAlignment(int fieldAlignment)
Set the required field alignment for the field. |
void |
setFieldOffset(long fieldOffset)
Set the required field offset for the field. |
void |
setFieldTargetAttributes(long fieldOffset,
int fieldAlignment,
int bitOffset)
Set the target attributes of the field. |
protected void |
setInitialValue(Expression i)
Specify the initializer for the field. |
void |
setMyStruct(AggregateType n)
Specify the structure to which this FieldDecl belongs. |
java.lang.String |
toStringSpecial()
This method allows sub-classes to provide class specific stuff to the string. |
void |
visit(Predicate p)
Process a node by calling its associated routine. |
Methods inherited from class scale.clef.decl.ValueDecl |
---|
getChild, getConstantValue, getValue, isConst, isValueDecl, numChildren, returnValueDecl, setValue |
Methods inherited from class scale.clef.Node |
---|
getSourceLineNumber, setAnnotationLevel, setReportLevel, setSourceLineNumber, toString, toString, toStringChildren |
Methods inherited from class scale.common.Root |
---|
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayName, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, removeAnnotation, removeAnnotations, toStringAnnotations, toStringClass, trace, trace, trace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FieldDecl(java.lang.String name, Type type, long fieldOffset, int fieldAlignment, Expression initialValue, int bits)
name
- is the name of the fieldtype
- is the type of the fieldfieldOffset
- is the offset in bytes of the field in the
structurefieldAlignment
- is the required alignment of the field in
the structureinitialValue
- is the initial value for the fieldbits
- specifies the size of a C bit fieldpublic FieldDecl(java.lang.String name, Type type, long fieldOffset, int fieldAlignment, Expression initialValue)
name
- is the name of the fieldtype
- is the type of the fieldfieldOffset
- is the offset in bytes of the field in the
structurefieldAlignment
- is the required alignment of the field in
the structureinitialValue
- is the initial value for the fieldpublic FieldDecl(java.lang.String name, Type type, long fieldOffset, int fieldAlignment)
public FieldDecl(java.lang.String name, Type type, long fieldOffset)
public FieldDecl(java.lang.String name, Type type)
Method Detail |
---|
public final void setAccessibility(Accessibility accessibility)
setAccessibility
in class Declaration
accessibility
- is the accessibility of the declarationAccessibility
public final Accessibility accessibility()
accessibility
in class Declaration
Accessibility
public final int getBits()
public final void setBits(int bits, int bitOffset)
public final int getBitOffset()
public final void setBitOffset(int bitOffset)
public final long getFieldOffset()
public final void setFieldOffset(long fieldOffset)
public final int getFieldAlignment()
public final void setFieldAlignment(int fieldAlignment)
public final void setFieldTargetAttributes(long fieldOffset, int fieldAlignment, int bitOffset)
public void visit(Predicate p)
Node
Each class has a visit(Predicate p)
method. For
example, in class ABC
:
public void visit(Predicate p) { p.visitABC(this); }and the class that implements
Predicate
has a method
public void visitABC(Node n) { ABC a = (ABC) n; ... }Thus, the class that implements
Predicate
can call
n.visit(this);where
n
is a Node
sub-class without
determining which specific sub-class n
is.
The visit pattern basically avoids implementing a large
switch
statement or defining different methods
in each class for some purpose.
visit
in class ValueDecl
Predicate
public final Expression getInitialValue()
protected final void setInitialValue(Expression i)
public final AggregateType getMyStruct()
public final void setMyStruct(AggregateType n)
n
- the aggregate structure (record or class) to which I belongpublic java.lang.String toStringSpecial()
Node
toStringSpecial
in class Declaration
public Declaration copy(java.lang.String name)
copy
in class Declaration
public boolean isPackedField(Machine machine)
public final boolean isFieldDecl()
Declaration
isFieldDecl
in class Declaration
public final FieldDecl returnFieldDecl()
Declaration
FieldDecl
instance or null
.
returnFieldDecl
in class Declaration
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |