public class SourcePrinter extends Visitor
print(Type) and
print(Type,String) methods.| Modifier and Type | Field and Description |
|---|---|
protected Type |
base
The base type.
|
protected java.util.List<Type> |
derived
The list of derived types, with the outer-most type first.
|
protected java.lang.String |
name
The optional variable name.
|
protected boolean |
needsSpace
The flag for whether the next token needs to be preceded by a
space.
|
protected Printer |
printer
The printer utility.
|
| Constructor and Description |
|---|
SourcePrinter(Printer printer)
Create a new source printer.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addDerived(Type type)
Add the specified type to the list of derived types.
|
static boolean |
hasAttributes(Type type)
Determine whether the specified type or any wrapped types have
any printable attributes.
|
static boolean |
isPrintable(Attribute att)
Determine whether the specified attribute is printable.
|
void |
print(Type type)
Print the specified type.
|
void |
print(Type type,
java.lang.String variable)
Print the specified type and variable as a declaration.
|
protected void |
printArray(Type type)
Print the specified array type.
|
protected void |
printAttributes(Type type)
Print the attributes for the specified type and any wrapped
types.
|
protected void |
printDerived()
Emit any derived types.
|
protected void |
printFunction(Type type)
Print the specified function type.
|
protected void |
printPointer(Type type)
Print the specified pointer type.
|
protected void |
setVariable(java.lang.String variable)
Set the variable name.
|
protected void |
space()
Emit a space.
|
void |
visit(AliasT t)
Print the specified alias type.
|
void |
visit(ArrayT t)
Print the specified array type.
|
void |
visit(Attribute att)
Print the specified attribute.
|
void |
visit(ClassOrInterfaceT t)
Print the specified class or interface type.
|
void |
visit(EnumT t)
Print the specified enum type.
|
void |
visit(ErrorT t)
Print the specified error type.
|
void |
visit(FunctionT t)
Print the specified function type.
|
void |
visit(InternalT t)
Print the specified internal type.
|
void |
visit(NumberT t)
Print the specified number type.
|
void |
visit(PointerT t)
Print the specified pointer type.
|
void |
visit(StructT t)
Print the specified struct type.
|
void |
visit(UnionT t)
Print the specified union type.
|
void |
visit(VariableT t)
Print the specified variable type.
|
void |
visit(VoidT t)
Print the specified void type.
|
void |
visit(WrappedT t)
Print the specified wrapped type.
|
dispatch, equals, hashCode, iterate, map, mapInPlace, unableToVisit, visitprotected final Printer printer
protected Type base
protected java.util.List<Type> derived
protected java.lang.String name
protected boolean needsSpace
public SourcePrinter(Printer printer)
printer - The printer utility.public void print(Type type)
VariableT, this method prints a declaration for that
type's name. Otherwise, it prints an abstract declaration. Note
that the printed declaration is not followed by any
delimiter such as a semicolon.type - The type.java.lang.IllegalArgumentException - Signals that the specified type
contains an error type or more than one field, member,
parameter, or variable type.public void print(Type type, java.lang.String variable)
type - The type.variable - The variable name.java.lang.IllegalArgumentException - Signals that the specified type
contains a field, member, parameter, variable, or error type.protected void setVariable(java.lang.String variable)
variable - The variable name.java.lang.IllegalArgumentException - Signals a duplicate variable
name.protected void addDerived(Type type)
type - The type.protected void space()
needsSpace flag is set, this
method emits the space and clears the flag.protected void printDerived()
protected void printPointer(Type type)
type - The pointer type, which may be wrappedprotected void printArray(Type type)
type - The array type, which may be wrapped.protected void printFunction(Type type)
type - The function type, which may be wrapped.public static boolean isPrintable(Attribute att)
att - The attribute.true if the attribute is printable.public static boolean hasAttributes(Type type)
type - The type.true if the type or any wrapped types have
any printable attributes.protected void printAttributes(Type type)
type - The type.public void visit(Attribute att)
public void visit(VoidT t)
public void visit(NumberT t)
public void visit(StructT t)
public void visit(UnionT t)
public void visit(EnumT t)
public void visit(ClassOrInterfaceT t)
public void visit(AliasT t)
public void visit(InternalT t)
public void visit(PointerT t)
public void visit(ArrayT t)
public void visit(FunctionT t)
public void visit(VariableT t)
public void visit(WrappedT t)
public void visit(ErrorT t)
Copyright © 2014. All Rights Reserved.