@Test public void testReturnsRemoved() throws Exception { final String program = "int foo() {" + " int x = 2;" + " int y = 3;" + " x = y;" + " if (x == y) {" + " return 2;" + " }" + " if (x > y) {" + " if (y > 4) {" + " x = 3;" + " return 5;" + " } else {" + " while(x < y) {" + " x++;" + " if (x == y) {" + " return 3;" + " }" + " x++;" + " }" + " }" + " return 0;" + " }" + "}"; final String expected = "int foo() {" + " bool foo_has_returned = false;" + " int foo_return_value;" + " int x = 2;" + " int y = 3;" + " x = y;" + " if (x == y) {" + " {" + " foo_return_value = 2;" + " foo_has_returned = true;" + " }" + " }" + " if(!foo_has_returned) {" + " if (x > y) {" + " if (y > 4) {" + " x = 3;" + " {" + " foo_return_value = 5;" + " foo_has_returned = true;" + " }" + " } else {" + " while((!foo_has_returned) && x < y) {" + " x++;" + " if (x == y) {" + " {" + " foo_return_value = 3;" + " foo_has_returned = true;" + " }" + " }" + " if(!foo_has_returned) {" + " x++;" + " }" + " }" + " }" + " if(!foo_has_returned) {" + " {" + " foo_return_value = 0;" + " foo_has_returned = true;" + " }" + " }" + " }" + " }" + " return foo_return_value;" + "}"; final TranslationUnit tu = ParseHelper.parse(program); final FunctionDefinition fd = findFunctionDefinition(tu, "foo"); ReturnRemover.removeReturns(fd, ShadingLanguageVersion.ESSL_300); CompareAstsDuplicate.assertEqualAsts(expected, tu); }
public static void removeReturns(FunctionDefinition fd, ShadingLanguageVersion shadingLanguageVersion) throws CannotRemoveReturnsException { new ReturnRemover(fd, shadingLanguageVersion).doRemoveReturns(); }
ReturnRemover { public static void removeReturns(FunctionDefinition fd, ShadingLanguageVersion shadingLanguageVersion) throws CannotRemoveReturnsException { new ReturnRemover(fd, shadingLanguageVersion).doRemoveReturns(); } }
ReturnRemover { public static void removeReturns(FunctionDefinition fd, ShadingLanguageVersion shadingLanguageVersion) throws CannotRemoveReturnsException { new ReturnRemover(fd, shadingLanguageVersion).doRemoveReturns(); } private  ReturnRemover(FunctionDefinition fd, ShadingLanguageVersion shadingLanguageVersion); }
ReturnRemover { public static void removeReturns(FunctionDefinition fd, ShadingLanguageVersion shadingLanguageVersion) throws CannotRemoveReturnsException { new ReturnRemover(fd, shadingLanguageVersion).doRemoveReturns(); } private  ReturnRemover(FunctionDefinition fd, ShadingLanguageVersion shadingLanguageVersion); static void removeReturns(FunctionDefinition fd, ShadingLanguageVersion
      shadingLanguageVersion); }
ReturnRemover { public static void removeReturns(FunctionDefinition fd, ShadingLanguageVersion shadingLanguageVersion) throws CannotRemoveReturnsException { new ReturnRemover(fd, shadingLanguageVersion).doRemoveReturns(); } private  ReturnRemover(FunctionDefinition fd, ShadingLanguageVersion shadingLanguageVersion); static void removeReturns(FunctionDefinition fd, ShadingLanguageVersion
      shadingLanguageVersion);  }