MCPcopy Create free account
hub / github.com/mozilla/rhino / endCheck

Method endCheck

rhino/src/main/java/org/mozilla/javascript/Node.java:881–934  ·  view source on GitHub ↗

endCheck() examines the body of a function, doing a basic reachability analysis and returns a combination of flags END_ flags that indicate how the function execution can terminate. These constitute only the pessimistic set of termination conditions. It is possible that at runtime certain code paths

()

Source from the content-addressed store, hash-verified

879 * @return logical OR of END_* flags
880 */
881 private int endCheck() {
882 switch (type) {
883 case Token.BREAK:
884 return endCheckBreak();
885
886 case Token.EXPR_VOID:
887 if (this.first != null) return first.endCheck();
888 return END_DROPS_OFF;
889
890 case Token.YIELD:
891 case Token.YIELD_STAR:
892 return END_YIELDS;
893
894 case Token.CONTINUE:
895 case Token.THROW:
896 return END_UNREACHED;
897
898 case Token.RETURN:
899 if (this.first != null) return END_RETURNS_VALUE;
900 return END_RETURNS;
901
902 case Token.TARGET:
903 if (next != null) return next.endCheck();
904 return END_DROPS_OFF;
905
906 case Token.LOOP:
907 return endCheckLoop();
908
909 case Token.LOCAL_BLOCK:
910 case Token.BLOCK:
911 // there are several special kinds of blocks
912 if (first == null) return END_DROPS_OFF;
913
914 switch (first.type) {
915 case Token.LABEL:
916 return first.endCheckLabel();
917
918 case Token.IFNE:
919 return first.endCheckIf();
920
921 case Token.SWITCH:
922 return first.endCheckSwitch();
923
924 case Token.TRY:
925 return first.endCheckTry();
926
927 default:
928 return endCheckBlock();
929 }
930
931 default:
932 return END_DROPS_OFF;
933 }
934 }
935
936 public boolean hasSideEffects() {
937 switch (type) {

Callers 5

endCheckIfMethod · 0.95
endCheckBlockMethod · 0.95
endCheckLoopMethod · 0.80
endCheckLabelMethod · 0.80

Calls 7

endCheckBreakMethod · 0.95
endCheckLoopMethod · 0.95
endCheckBlockMethod · 0.95
endCheckLabelMethod · 0.80
endCheckIfMethod · 0.80
endCheckSwitchMethod · 0.80
endCheckTryMethod · 0.80

Tested by

no test coverage detected