| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package org.mozilla.javascript.ast; |
| 8 |
|
| 9 |
import org.mozilla.javascript.Node; |
| 10 |
import org.mozilla.javascript.Token; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
public class Jump extends AstNode { |
| 20 |
|
| 21 |
public Node target; |
| 22 |
private Node target2; |
| 23 |
private Jump jumpNode; |
| 24 |
|
| 25 |
public Jump() { |
| 26 |
type = Token.ERROR; |
| 27 |
} |
| 28 |
|
| 29 |
public Jump(int nodeType) { |
| 30 |
type = nodeType; |
| 31 |
} |
| 32 |
|
| 33 |
public Jump(int type, int lineno) { |
| 34 |
this(type); |
| 35 |
setLineno(lineno); |
| 36 |
} |
| 37 |
|
| 38 |
public Jump(int type, Node child) { |
| 39 |
this(type); |
| 40 |
addChildToBack(child); |
| 41 |
} |
| 42 |
|
| 43 |
public Jump(int type, Node child, int lineno) { |
| 44 |
this(type, child); |
| 45 |
setLineno(lineno); |
| 46 |
} |
| 47 |
|
| 48 |
public Jump getJumpStatement() |
| 49 |
{ |
| 50 |
if (type != Token.BREAK && type != Token.CONTINUE) codeBug(); |
| 51 |
return jumpNode; |
| 52 |
} |
| 53 |
|
| 54 |
public void setJumpStatement(Jump jumpStatement) |
| 55 |
{ |
| 56 |
if (type != Token.BREAK && type != Token.CONTINUE) codeBug(); |
| 57 |
if (jumpStatement == null) codeBug(); |
| 58 |
if (this.jumpNode != null) codeBug(); |
| 59 |
this.jumpNode = jumpStatement; |
| 60 |
} |
| 61 |
|
| 62 |
public Node getDefault() |
| 63 |
{ |
| 64 |
if (type != Token.SWITCH) codeBug(); |
| 65 |
return target2; |
| 66 |
} |
| 67 |
|
| 68 |
public void setDefault(Node defaultTarget) |
| 69 |
{ |
| 70 |
if (type != Token.SWITCH) codeBug(); |
| 71 |
if (defaultTarget.getType() != Token.TARGET) codeBug(); |
| 72 |
if (target2 != null) codeBug(); |
| 73 |
target2 = defaultTarget; |
| 74 |
} |
| 75 |
|
| 76 |
public Node getFinally() |
| 77 |
{ |
| 78 |
if (type != Token.TRY) codeBug(); |
| 79 |
return target2; |
| 80 |
} |
| 81 |
|
| 82 |
public void setFinally(Node finallyTarget) |
| 83 |
{ |
| 84 |
if (type != Token.TRY) codeBug(); |
| 85 |
if (finallyTarget.getType() != Token.TARGET) codeBug(); |
| 86 |
if (target2 != null) codeBug(); |
| 87 |
target2 = finallyTarget; |
| 88 |
} |
| 89 |
|
| 90 |
public Jump getLoop() |
| 91 |
{ |
| 92 |
if (type != Token.LABEL) codeBug(); |
| 93 |
return jumpNode; |
| 94 |
} |
| 95 |
|
| 96 |
public void setLoop(Jump loop) |
| 97 |
{ |
| 98 |
if (type != Token.LABEL) codeBug(); |
| 99 |
if (loop == null) codeBug(); |
| 100 |
if (jumpNode != null) codeBug(); |
| 101 |
jumpNode = loop; |
| 102 |
} |
| 103 |
|
| 104 |
public Node getContinue() |
| 105 |
{ |
| 106 |
if (type != Token.LOOP) codeBug(); |
| 107 |
return target2; |
| 108 |
} |
| 109 |
|
| 110 |
public void setContinue(Node continueTarget) |
| 111 |
{ |
| 112 |
if (type != Token.LOOP) codeBug(); |
| 113 |
if (continueTarget.getType() != Token.TARGET) codeBug(); |
| 114 |
if (target2 != null) codeBug(); |
| 115 |
target2 = continueTarget; |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
@Override |
| 124 |
public void visit(NodeVisitor visitor) { |
| 125 |
throw new UnsupportedOperationException(this.toString()); |
| 126 |
} |
| 127 |
|
| 128 |
@Override |
| 129 |
public String toSource(int depth) { |
| 130 |
throw new UnsupportedOperationException(this.toString()); |
| 131 |
} |
| 132 |
} |