001    package AST;
002    
003    import java.util.Collection;
004    import java.util.ArrayList;
005    import java.util.HashSet;
006    /**
007     * @apilevel internal
008     * @ast class
009     * @declaredat ASTNode:4
010     */
011    public class ASTNode$State extends java.lang.Object {
012    
013      /**
014       * @apilevel internal
015       */
016      public boolean LAST_CYCLE = false;
017    
018    
019      /**
020       * @apilevel internal
021       */
022      public boolean IN_CIRCLE = false;
023    
024    
025    
026      /**
027       * @apilevel internal
028       */
029      public int CIRCLE_INDEX = 1;
030    
031    
032    
033      /**
034       * @apilevel internal
035       */
036      public boolean CHANGE = false;
037    
038    
039    
040      /**
041       * @apilevel internal
042       */
043      public boolean RESET_CYCLE = false;
044    
045    
046    
047      /**
048       * @apilevel internal
049       */
050      static public class CircularValue {
051        Object value;
052        int visited = -1;
053      }
054    
055    
056    
057      /**
058       * @apilevel internal
059       */
060      public static final int REWRITE_CHANGE = 1;
061    
062    
063    
064      /**
065       * @apilevel internal
066       */
067      public static final int REWRITE_NOCHANGE = 2;
068    
069    
070    
071      /**
072       * @apilevel internal
073       */
074      public static final int REWRITE_INTERRUPT = 3;
075    
076    
077    
078      public int boundariesCrossed = 0;
079    
080    
081    
082      // state code
083      private int[] stack;
084    
085    
086    
087      private int pos;
088    
089    
090    
091      public ASTNode$State() {
092        stack = new int[64];
093        pos = 0;
094      }
095    
096    
097    
098      private void ensureSize(int size) {
099        if(size < stack.length)
100          return;
101        int[] newStack = new int[stack.length * 2];
102        System.arraycopy(stack, 0, newStack, 0, stack.length);
103        stack = newStack;
104      }
105    
106    
107    
108      public void push(int i) {
109        ensureSize(pos+1);
110        stack[pos++] = i;
111      }
112    
113    
114    
115      public int pop() {
116        return stack[--pos];
117      }
118    
119    
120    
121      public int peek() {
122        return stack[pos-1];
123      }
124    
125    
126    
127      /**
128       * @apilevel internal
129       */
130      static class IdentityHashSet extends java.util.AbstractSet implements java.util.Set {
131    
132        public IdentityHashSet(int initialCapacity) {
133          map = new java.util.IdentityHashMap(initialCapacity);
134        }
135    
136        private java.util.IdentityHashMap map;
137    
138        private static final Object PRESENT = new Object();
139    
140        public java.util.Iterator iterator() {
141          return map.keySet().iterator();
142        }
143    
144        public int size() {
145          return map.size();
146        }
147    
148        public boolean isEmpty() {
149          return map.isEmpty();
150        }
151    
152        public boolean contains(Object o) {
153          return map.containsKey(o);
154        }
155    
156        public boolean add(Object o) {
157          return map.put(o, PRESENT)==null;
158        }
159    
160        public boolean remove(Object o) {
161          return map.remove(o)==PRESENT;
162        }
163    
164        public void clear() {
165          map.clear();
166        }
167      }
168    
169    protected int duringTypeAnalysis = 0;
170    
171    public void reset() {
172        IN_CIRCLE = false;
173        CIRCLE_INDEX = 1;
174        CHANGE = false;
175        LAST_CYCLE = false;
176    
177        boundariesCrossed = 0;
178        if(duringTypeAnalysis != 0) {
179          System.out.println("Warning: resetting duringTypeAnalysis");
180          duringTypeAnalysis = 0;
181        }
182    
183      }
184    
185    
186    }