(Node cond, Node ifTrue, Node ifFalse, int lineno, int column)
| 1967 | } |
| 1968 | |
| 1969 | private static Node createIf(Node cond, Node ifTrue, Node ifFalse, int lineno, int column) { |
| 1970 | int condStatus = isAlwaysDefinedBoolean(cond); |
| 1971 | if (condStatus == ALWAYS_TRUE_BOOLEAN) { |
| 1972 | return ifTrue; |
| 1973 | } else if (condStatus == ALWAYS_FALSE_BOOLEAN) { |
| 1974 | if (ifFalse != null) { |
| 1975 | return ifFalse; |
| 1976 | } |
| 1977 | // Replace if (false) xxx by empty block |
| 1978 | return new Node(Token.BLOCK, lineno, column); |
| 1979 | } |
| 1980 | |
| 1981 | Node result = new Node(Token.BLOCK, lineno, column); |
| 1982 | Node ifNotTarget = Node.newTarget(); |
| 1983 | Jump IFNE = new Jump(Token.IFNE, cond); |
| 1984 | IFNE.target = ifNotTarget; |
| 1985 | |
| 1986 | result.addChildToBack(IFNE); |
| 1987 | result.addChildrenToBack(ifTrue); |
| 1988 | |
| 1989 | if (ifFalse != null) { |
| 1990 | Node endTarget = Node.newTarget(); |
| 1991 | result.addChildToBack(makeJump(Token.GOTO, endTarget)); |
| 1992 | result.addChildToBack(ifNotTarget); |
| 1993 | result.addChildrenToBack(ifFalse); |
| 1994 | result.addChildToBack(endTarget); |
| 1995 | } else { |
| 1996 | result.addChildToBack(ifNotTarget); |
| 1997 | } |
| 1998 | |
| 1999 | if (cond.getFirstChild() != null) { |
| 2000 | Node conditionalChild = cond.getFirstChild(); |
| 2001 | result.setLineColumnNumber(conditionalChild.getLineno(), conditionalChild.getColumn()); |
| 2002 | } |
| 2003 | |
| 2004 | return result; |
| 2005 | } |
| 2006 | |
| 2007 | private static Node createCondExpr(Node cond, Node ifTrue, Node ifFalse) { |
| 2008 | int condStatus = isAlwaysDefinedBoolean(cond); |
no test coverage detected