mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-18 14:50:56 +00:00
recursively update variable table size
This commit is contained in:
+24
-9
@@ -82,9 +82,7 @@ public class Scope {
|
|||||||
int num = numSize;
|
int num = numSize;
|
||||||
indices.put(check(id), Pair.of(num, ReturnType.NUMBER));
|
indices.put(check(id), Pair.of(num, ReturnType.NUMBER));
|
||||||
numSize++;
|
numSize++;
|
||||||
if(parent != null) {
|
updateNumSize(numSize);
|
||||||
parent.numSize = FastMath.max(parent.numSize, numSize);
|
|
||||||
}
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,9 +90,7 @@ public class Scope {
|
|||||||
int str = strSize;
|
int str = strSize;
|
||||||
indices.put(check(id), Pair.of(str, ReturnType.STRING));
|
indices.put(check(id), Pair.of(str, ReturnType.STRING));
|
||||||
strSize++;
|
strSize++;
|
||||||
if(parent != null) {
|
updateStrSize(strSize);
|
||||||
parent.strSize = FastMath.max(parent.strSize, strSize);
|
|
||||||
}
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,12 +98,31 @@ public class Scope {
|
|||||||
int bool = boolSize;
|
int bool = boolSize;
|
||||||
indices.put(check(id), Pair.of(bool, ReturnType.BOOLEAN));
|
indices.put(check(id), Pair.of(bool, ReturnType.BOOLEAN));
|
||||||
boolSize++;
|
boolSize++;
|
||||||
if(parent != null) {
|
updateBoolSize(boolSize);
|
||||||
parent.boolSize = FastMath.max(parent.boolSize, boolSize);
|
|
||||||
}
|
|
||||||
return bool;
|
return bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateBoolSize(int size) {
|
||||||
|
this.boolSize = FastMath.max(boolSize, size);
|
||||||
|
if(parent != null) {
|
||||||
|
parent.updateBoolSize(size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateNumSize(int size) {
|
||||||
|
this.numSize = FastMath.max(numSize, size);
|
||||||
|
if(parent != null) {
|
||||||
|
parent.updateNumSize(size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStrSize(int size) {
|
||||||
|
this.strSize = FastMath.max(strSize, size);
|
||||||
|
if(parent != null) {
|
||||||
|
parent.updateStrSize(size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getIndex(String id) {
|
public int getIndex(String id) {
|
||||||
return indices.get(id).getLeft();
|
return indices.get(id).getLeft();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user