aboutsummaryrefslogtreecommitdiffstats
path: root/main/utils/Counter.java
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2016-06-15 21:56:03 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2016-07-26 19:46:51 +0300
commitf441022881945db08846e09a8f3bfee2f8cfa95d (patch)
tree3b565c6902e5b5b6c351df89fe1d58b00d79f091 /main/utils/Counter.java
parent12eeefcdba1ee392f033f51e6b9826eaae3c4de6 (diff)
Add interpreter and AST
Diffstat (limited to 'main/utils/Counter.java')
-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;
}
}