diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg index 1e17be3e8..6fe64b812 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg @@ -453,7 +453,7 @@ Sync(s) ::= "sync();" ThrowNoViableAlt(t) ::= "throw new NoViableAltException(this);" TestSetInline(s) ::= << - - })> && ((1L \<\< ( - )) & ( - ))}; separator=" | ">)) != 0}; separator=" || "> +}; separator=" || "> >> // Java language spec 15.19 - shift operators mask operands rather than overflow to 0... need range test @@ -461,6 +461,16 @@ testShiftInRange(shiftAmount) ::= << (() & ~0x3f) == 0 >> +// produces smaller bytecode only when bits.ttypes contains more than two items +bitsetBitfieldComparison(s, bits) ::= <% +( - })> && ((1L \<\< ( - )) & ( - ))}; separator=" | ">)) != 0) +%> + +// produces more efficient bytecode when bits.ttypes contains at most two items +bitsetInlineComparison(s, bits) ::= <% +==}; separator=" || "> +%> + cases(ttypes) ::= << :}; separator="\n"> >>