Debian Codegraph @

rhino/src/org/mozilla/javascript/ast/Loop.java

raw symbols SCIP
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 package org.mozilla.javascript.ast;
8
9 /**
10 * Abstract base type for loops.
11 */
12 public abstract class Loop extends Scope {
13
14 protected AstNode body;
15 protected int lp = -1;
16 protected int rp = -1;
17
18 public Loop() {
19 }
20
21 public Loop(int pos) {
22 super(pos);
23 }
24
25 public Loop(int pos, int len) {
26 super(pos, len);
27 }
28
29 /**
30 * Returns loop body
31 */
32 public AstNode getBody() {
33 return body;
34 }
35
36 /**
37 * Sets loop body. Sets the parent of the body to this loop node,
38 * and updates its offset to be relative. Extends the length of this
39 * node to include the body.
40 */
41 public void setBody(AstNode body) {
42 this.body = body;
43 int end = body.getPosition() + body.getLength();
44 this.setLength(end - this.getPosition());
45 body.setParent(this);
46 }
47
48 /**
49 * Returns left paren position, -1 if missing
50 */
51 public int getLp() {
52 return lp;
53 }
54
55 /**
56 * Sets left paren position
57 */
58 public void setLp(int lp) {
59 this.lp = lp;
60 }
61
62 /**
63 * Returns right paren position, -1 if missing
64 */
65 public int getRp() {
66 return rp;
67 }
68
69 /**
70 * Sets right paren position
71 */
72 public void setRp(int rp) {
73 this.rp = rp;
74 }
75
76 /**
77 * Sets both paren positions
78 */
79 public void setParens(int lp, int rp) {
80 this.lp = lp;
81 this.rp = rp;
82 }
83 }