Skip to content

Commit

Permalink
Check for sentinels regardless of AcceptsError
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Apr 18, 2022
1 parent bdbebae commit 8c6886f
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ private void generateCode(MethodDefinition methodDefinition) throws IOException
for (MethodDefinition.ArgumentDefinition arg : methodDefinition.getArguments()) {
if (arg.shouldCheckErrors()) {
String condName = mkArgumentInternalVarName(arg) + DATAFLOW_ERROR_PROFILE;
String branchName = mkArgumentInternalVarName(arg) + PANIC_SENTINEL_PROFILE;
out.println(
" private final ConditionProfile "
+ condName
+ " = ConditionProfile.createCountingProfile();");
}

if (arg.isPositional() && !arg.isThis()) {
String branchName = mkArgumentInternalVarName(arg) + PANIC_SENTINEL_PROFILE;
out.println(" private final BranchProfile " + branchName + " = BranchProfile.create();");
}

Expand Down Expand Up @@ -270,8 +273,8 @@ private void generateCode(MethodDefinition methodDefinition) throws IOException

private void generateArgumentRead(
PrintWriter out, MethodDefinition.ArgumentDefinition arg, String argsArray) {
String argReference = argsArray + "[" + arg.getPosition() + "]";
if (arg.shouldCheckErrors()) {
String argReference = argsArray + "[" + arg.getPosition() + "]";
String condProfile = mkArgumentInternalVarName(arg) + DATAFLOW_ERROR_PROFILE;
out.println(
" if ("
Expand All @@ -283,9 +286,11 @@ private void generateArgumentRead(
+ argReference
+ ");\n"
+ " }");
}
if (!arg.isThis()) {
String branchProfile = mkArgumentInternalVarName(arg) + PANIC_SENTINEL_PROFILE;
out.println(
" else if (TypesGen.isPanicSentinel("
" if (TypesGen.isPanicSentinel("
+ argReference
+ ")) {\n"
+ " "
Expand Down Expand Up @@ -366,7 +371,9 @@ private void generateCheckedArgumentRead(
private boolean generateWarningsCheck(
PrintWriter out, List<MethodDefinition.ArgumentDefinition> arguments, String argumentsArray) {
List<MethodDefinition.ArgumentDefinition> argsToCheck =
arguments.stream().filter(ArgumentDefinition::shouldCheckWarnings).collect(Collectors.toList());
arguments.stream()
.filter(ArgumentDefinition::shouldCheckWarnings)
.collect(Collectors.toList());
if (argsToCheck.isEmpty()) {
return false;
} else {
Expand Down

0 comments on commit 8c6886f

Please sign in to comment.