Class StaticTypesStatementWriter
java.lang.Object
org.codehaus.groovy.classgen.asm.StatementWriter
org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter
A class to write out the optimized statements.
-
Field Summary
Fields inherited from class org.codehaus.groovy.classgen.asm.StatementWriter
controller -
Constructor Summary
ConstructorsConstructorDescriptionCreates a statement writer that favors statically typed loop and block generation. -
Method Summary
Modifier and TypeMethodDescriptionvoidwriteBlockStatement(BlockStatement statement) Generates bytecode for a block statement by visiting each contained statement.protected voidwriteForInLoop(ForStatement loop) Generates bytecode for a for-in loop by callingiterator()on the collection expression and delegating loop control toStatementWriter.writeForInLoopControlAndBlock(org.codehaus.groovy.ast.stmt.ForStatement).protected voidwriteIsCaseComparison(CaseStatement caseStatement, int selectorIndex, ClassNode selectorType) Emits theisCasecall the type checker selected, so a label in statement position resolves the same method it would in a switch expression (GROOVY-12407).voidwriteSwitch(SwitchStatement statement) Emits a jump table when the selector and labels are constants of a typejavacwould switch on, matching what a statically compiled switch expression already gets (GROOVY-12405).Methods inherited from class org.codehaus.groovy.classgen.asm.StatementWriter
defineLoopIndexVariable, incrementForLoopIndexVariable, storeForLoopVariable, writeAssert, writeBreak, writeContinue, writeDoWhileLoop, writeExpressionStatement, writeForInLoopControlAndBlock, writeForLoopWithClosureList, writeForStatement, writeIfElse, writeIteratorHasNext, writeIteratorNext, writeLoopBackEdge, writeReturn, writeStatementLabel, writeSynchronized, writeThrow, writeTryCatchFinally, writeWhileLoop
-
Constructor Details
-
StaticTypesStatementWriter
Creates a statement writer that favors statically typed loop and block generation.
-
-
Method Details
-
writeBlockStatement
Generates bytecode for a block statement by visiting each contained statement. Pushes the block's variable scope, emits the statements, and pops afterward. Named labels on the block create a breakable region so thatbreak labelwithin the block jumps to the end of it.- Overrides:
writeBlockStatementin classStatementWriter- Parameters:
statement- the block statement to compile
-
writeSwitch
Emits a jump table when the selector and labels are constants of a typejavacwould switch on, matching what a statically compiled switch expression already gets (GROOVY-12405). Anything else, including repeated labels, falls back to the sequentialisCasechain.- Overrides:
writeSwitchin classStatementWriter- Parameters:
statement- the switch statement to compile
-
writeIsCaseComparison
protected void writeIsCaseComparison(CaseStatement caseStatement, int selectorIndex, ClassNode selectorType) Emits theisCasecall the type checker selected, so a label in statement position resolves the same method it would in a switch expression (GROOVY-12407). Arms with no selected target, includingcase nulland anything underTypeCheckingMode.SKIP, keep the dynamic comparison.- Overrides:
writeIsCaseComparisonin classStatementWriter- Parameters:
caseStatement- the arm whose label is being testedselectorIndex- local variable slot holding the switch selectorselectorType- type of that slot
-
writeForInLoop
Generates bytecode for a for-in loop by callingiterator()on the collection expression and delegating loop control toStatementWriter.writeForInLoopControlAndBlock(org.codehaus.groovy.ast.stmt.ForStatement).- Overrides:
writeForInLoopin classStatementWriter- Parameters:
loop- the for-in statement to compile
-