aboutsummaryrefslogtreecommitdiffstats
path: root/main/utils
diff options
context:
space:
mode:
Diffstat (limited to 'main/utils')
-rw-r--r--main/utils/Counter.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/main/utils/Counter.java b/main/utils/Counter.java
index a0bf0fd..9783adf 100644
--- a/main/utils/Counter.java
+++ b/main/utils/Counter.java
@@ -6,22 +6,37 @@ package com.jantuomi.interpreter.main.utils;
public class Counter {
private int value = 0;
+ public int getRecursionDepth() {
+ return recursionDepth;
+ }
+
+ private int recursionDepth = 0;
+
public int advance() {
- value = value + 1;
- return value;
+ return ++value;
+ }
+
+ public int deeper() {
+ return ++recursionDepth;
+ }
+
+ public int shallower() {
+ return --recursionDepth;
}
public int getValue() {
return value;
}
- public void setValue(int value) {
- this.value = value;
+ public void assign(Counter other) {
+ value = other.value;
+ recursionDepth = other.recursionDepth;
}
public Counter clone() {
Counter c = new Counter();
c.value = value;
+ c.recursionDepth = recursionDepth;
return c;
}
}