abstract class CodeConsumer
extends java.lang.Object
CodeGenerator
,
CodePrinter
,
InlineCostEstimator
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
sawFunction |
(package private) boolean |
statementNeedsEnded |
(package private) boolean |
statementStarted |
Constructor and Description |
---|
CodeConsumer() |
Modifier and Type | Method and Description |
---|---|
(package private) void |
add(java.lang.String newcode) |
(package private) void |
addConstant(java.lang.String newcode) |
(package private) void |
addIdentifier(java.lang.String identifier) |
(package private) void |
addNumber(double x) |
(package private) void |
addOp(java.lang.String op,
boolean binOp) |
(package private) abstract void |
append(java.lang.String str)
Appends a string to the code, keeping track of the current line length.
|
(package private) void |
appendBlockEnd() |
(package private) void |
appendBlockStart() |
(package private) void |
appendOp(java.lang.String op,
boolean binOp) |
(package private) void |
beginBlock() |
(package private) void |
beginCaseBody() |
(package private) boolean |
breakAfterBlockFor(Node n,
boolean statementContext) |
(package private) boolean |
continueProcessing()
Provides a means of interrupting the CodeGenerator.
|
(package private) void |
endBlock() |
(package private) void |
endBlock(boolean shouldEndLine) |
(package private) void |
endCaseBody() |
(package private) void |
endClass(boolean statementContext) |
(package private) void |
endFile()
Called when we're at the end of a file.
|
(package private) void |
endFunction(boolean statementContext) |
(package private) void |
endLine() |
(package private) void |
endSourceMapping(Node node)
Finishes the source mapping for the given
node at the current position.
|
(package private) void |
endStatement()
Indicates the end of a statement and a ';' may need to be added.
|
(package private) void |
endStatement(boolean needSemiColon) |
(package private) abstract char |
getLastChar()
Retrieve the last character of the last string sent to append.
|
(package private) static boolean |
isNegativeZero(double x) |
(package private) static boolean |
isWordChar(char ch) |
(package private) void |
listSeparator() |
(package private) void |
maybeCutLine() |
(package private) void |
maybeEndStatement()
This is to be called when we're in a statement.
|
(package private) void |
maybeInsertSpace()
Allows a consumer to insert spaces in locations where it is unnecessary
but may improve the readability of the code.
|
(package private) void |
maybeLineBreak() |
(package private) void |
notePreferredLineBreak() |
(package private) boolean |
shouldPreserveExtraBlocks()
If the body of a for loop or the then clause of an if statement has
a single statement, should it be wrapped in a block? Doing so can
help when pretty-printing the code, and permits putting a debugging
breakpoint on the statement inside the condition.
|
(package private) void |
startNewLine() |
(package private) void |
startSourceMapping(Node node)
Starts the source mapping for the given
node at the current position.
|
boolean statementNeedsEnded
boolean statementStarted
boolean sawFunction
void startSourceMapping(Node node)
void endSourceMapping(Node node)
boolean continueProcessing()
abstract char getLastChar()
void addIdentifier(java.lang.String identifier)
abstract void append(java.lang.String str)
startNewLine()
.void appendBlockStart()
void appendBlockEnd()
void startNewLine()
void maybeLineBreak()
void maybeCutLine()
void endLine()
void notePreferredLineBreak()
void beginBlock()
void endBlock()
void endBlock(boolean shouldEndLine)
void listSeparator()
void endStatement()
void endStatement(boolean needSemiColon)
void maybeEndStatement()
void endFunction(boolean statementContext)
void endClass(boolean statementContext)
void beginCaseBody()
void endCaseBody()
void add(java.lang.String newcode)
void appendOp(java.lang.String op, boolean binOp)
void addOp(java.lang.String op, boolean binOp)
void addNumber(double x)
void addConstant(java.lang.String newcode)
static boolean isNegativeZero(double x)
static boolean isWordChar(char ch)
boolean shouldPreserveExtraBlocks()
void maybeInsertSpace()
boolean breakAfterBlockFor(Node n, boolean statementContext)
void endFile()