Class BddPeepholeVisitor

java.lang.Object
software.amazon.awssdk.codegen.poet.rules.RewriteRuleExpressionVisitor
software.amazon.awssdk.codegen.poet.rules.bdd.BddPeepholeVisitor
All Implemented Interfaces:
RuleExpressionVisitor<RuleExpression>

public final class BddPeepholeVisitor extends RewriteRuleExpressionVisitor
BDD-only peephole optimization pass. Rewrites endpoint rule expressions into synthetic function calls that the BDD code generators emit as allocation-free native Java.

This runs before PrepareForCodegenVisitor on the BDD path only, so the tree-based rules code generation is unaffected.

Optimizations applied:

  • stringEquals(coalesce(substring(str, X, Y, reverse), ""), literal)RulesFunctions.substringEquals(str, X, Y, reverse, literal), which compares in place instead of allocating the substring and the coalesce varargs array. The helper reproduces substring's semantics exactly, including its rejection of non-ASCII input, so the rewrite cannot change which branch a rule takes.
  • coalesce(boolExpr, boolLiteral)__coalesceBoolean(expr, default)
  • ite(cond, ifTrue, ifFalse)__ite(cond, ifTrue, ifFalse)
  • isValidHostLabel(str, boolLiteral)__isValidHostLabel(str, allowDots)

Synthetic function names are prefixed with __ so they cannot collide with endpoint rule standard library function names. Those in isCustomEmitted(String) are emitted as inline Java by the code generators; __substringEquals is instead registered as a real function in RuleRuntimeTypeMirror and emitted by the ordinary static-call path.