StateNode.java revision 953:221a84ef44c0
133965Sjdp/* 2218822Sdim * Permission is hereby granted, free of charge, to any person obtaining a copy of 3218822Sdim * this software and associated documentation files (the "Software"), to deal in 433965Sjdp * the Software without restriction, including without limitation the rights to 533965Sjdp * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 633965Sjdp * of the Software, and to permit persons to whom the Software is furnished to do 733965Sjdp * so, subject to the following conditions: 833965Sjdp * 933965Sjdp * The above copyright notice and this permission notice shall be included in all 1033965Sjdp * copies or substantial portions of the Software. 1133965Sjdp * 1233965Sjdp * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1333965Sjdp * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1433965Sjdp * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1533965Sjdp * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1633965Sjdp * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 1733965Sjdp * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 1833965Sjdp * SOFTWARE. 1933965Sjdp */ 2033965Sjdppackage jdk.nashorn.internal.runtime.regexp.joni.ast; 21218822Sdim 22218822Sdimimport jdk.nashorn.internal.runtime.regexp.joni.constants.NodeStatus; 2333965Sjdp 2433965Sjdppublic abstract class StateNode extends Node implements NodeStatus { 2533965Sjdp protected int state; 2633965Sjdp 2733965Sjdp @Override 2833965Sjdp public String toString(final int level) { 2933965Sjdp return "\n state: " + stateToString(); 3033965Sjdp } 3133965Sjdp 3233965Sjdp public String stateToString() { 3333965Sjdp final StringBuilder states = new StringBuilder(); 34130561Sobrien if (isMinFixed()) states.append("MIN_FIXED "); 3533965Sjdp if (isMaxFixed()) states.append("MAX_FIXED "); 3633965Sjdp if (isMark1()) states.append("MARK1 "); 37218822Sdim if (isMark2()) states.append("MARK2 "); 3833965Sjdp if (isMemBackrefed()) states.append("MEM_BACKREFED "); 3933965Sjdp if (isStopBtSimpleRepeat()) states.append("STOP_BT_SIMPLE_REPEAT "); 40218822Sdim if (isRecursion()) states.append("RECURSION "); 4133965Sjdp if (isCalled()) states.append("CALLED "); 4233965Sjdp if (isAddrFixed()) states.append("ADDR_FIXED "); 4333965Sjdp if (isInRepeat()) states.append("IN_REPEAT "); 4433965Sjdp if (isNestLevel()) states.append("NEST_LEVEL "); 4533965Sjdp if (isByNumber()) states.append("BY_NUMBER "); 4633965Sjdp 4733965Sjdp return states.toString(); 4833965Sjdp } 4933965Sjdp 5033965Sjdp public boolean isMinFixed() { 5133965Sjdp return (state & NST_MIN_FIXED) != 0; 5233965Sjdp } 5333965Sjdp 5433965Sjdp public void setMinFixed() { 5533965Sjdp state |= NST_MIN_FIXED; 5633965Sjdp } 5733965Sjdp 5833965Sjdp public boolean isMaxFixed() { 5933965Sjdp return (state & NST_MAX_FIXED) != 0; 6033965Sjdp } 6133965Sjdp 6233965Sjdp public void setMaxFixed() { 6333965Sjdp state |= NST_MAX_FIXED; 64218822Sdim } 65218822Sdim 6633965Sjdp public boolean isCLenFixed() { 6733965Sjdp return (state & NST_CLEN_FIXED) != 0; 6833965Sjdp } 6933965Sjdp 7033965Sjdp public void setCLenFixed() { 7133965Sjdp state |= NST_CLEN_FIXED; 7233965Sjdp } 7378828Sobrien 7433965Sjdp public boolean isMark1() { 7589857Sobrien return (state & NST_MARK1) != 0; 7689857Sobrien } 7789857Sobrien 7889857Sobrien public void setMark1() { 7933965Sjdp state |= NST_MARK1; 8089857Sobrien } 81218822Sdim 8233965Sjdp public boolean isMark2() { 83218822Sdim return (state & NST_MARK2) != 0; 8489857Sobrien } 8589857Sobrien 86218822Sdim public void setMark2() { 8733965Sjdp state |= NST_MARK2; 88218822Sdim } 8989857Sobrien 9089857Sobrien public void clearMark2() { 9133965Sjdp state &= ~NST_MARK2; 9289857Sobrien } 9333965Sjdp 94218822Sdim public boolean isMemBackrefed() { 95218822Sdim return (state & NST_MEM_BACKREFED) != 0; 9633965Sjdp } 9789857Sobrien 9889857Sobrien public void setMemBackrefed() { 9989857Sobrien state |= NST_MEM_BACKREFED; 10089857Sobrien } 10189857Sobrien 10289857Sobrien public boolean isStopBtSimpleRepeat() { 10389857Sobrien return (state & NST_STOP_BT_SIMPLE_REPEAT) != 0; 10489857Sobrien } 10589857Sobrien 106218822Sdim public void setStopBtSimpleRepeat() { 10733965Sjdp state |= NST_STOP_BT_SIMPLE_REPEAT; 108130561Sobrien } 109130561Sobrien 110130561Sobrien public boolean isRecursion() { 111130561Sobrien return (state & NST_RECURSION) != 0; 112130561Sobrien } 113130561Sobrien 114130561Sobrien public void setRecursion() { 115130561Sobrien state |= NST_RECURSION; 116130561Sobrien } 117130561Sobrien 118130561Sobrien public boolean isCalled() { 119130561Sobrien return (state & NST_CALLED) != 0; 120130561Sobrien } 121130561Sobrien 122130561Sobrien public void setCalled() { 123130561Sobrien state |= NST_CALLED; 124130561Sobrien } 125130561Sobrien 126130561Sobrien public boolean isAddrFixed() { 127130561Sobrien return (state & NST_ADDR_FIXED) != 0; 128130561Sobrien } 129130561Sobrien 130130561Sobrien public void setAddrFixed() { 131130561Sobrien state |= NST_ADDR_FIXED; 132130561Sobrien } 133130561Sobrien 134130561Sobrien public boolean isInRepeat() { 135130561Sobrien return (state & NST_IN_REPEAT) != 0; 136130561Sobrien } 137130561Sobrien 138130561Sobrien public void setInRepeat() { 139218822Sdim state |= NST_IN_REPEAT; 140130561Sobrien } 141130561Sobrien 142130561Sobrien public boolean isNestLevel() { 143130561Sobrien return (state & NST_NEST_LEVEL) != 0; 144130561Sobrien } 145130561Sobrien 146130561Sobrien public void setNestLevel() { 147130561Sobrien state |= NST_NEST_LEVEL; 14833965Sjdp } 14933965Sjdp 15033965Sjdp public boolean isByNumber() { 15133965Sjdp return (state & NST_BY_NUMBER) != 0; 15233965Sjdp } 15333965Sjdp 15433965Sjdp public void setByNumber() { 15533965Sjdp state |= NST_BY_NUMBER; 15633965Sjdp } 157218822Sdim 15833965Sjdp} 15933965Sjdp