blob: 9783adf8c97f96dacc516d449f1b0a08e655426a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package com.jantuomi.interpreter.main.utils;
/**
* Created by jan on 13.6.2016.
*/
public class Counter {
private int value = 0;
public int getRecursionDepth() {
return recursionDepth;
}
private int recursionDepth = 0;
public int advance() {
return ++value;
}
public int deeper() {
return ++recursionDepth;
}
public int shallower() {
return --recursionDepth;
}
public int getValue() {
return 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;
}
}
|