Call stack for class constructor

This commit is contained in:
aNNiMON 2023-10-04 19:38:12 +03:00 committed by Victor Melnik
parent 368cc8612c
commit 5267ff6144

View File

@ -40,7 +40,9 @@ public class ClassInstanceValue implements Value {
public void callConstructor(Value[] args) {
if (constructor != null) {
CallStack.enter("class " + className, constructor, null);
constructor.execute(args);
CallStack.exit();
}
}
@ -64,18 +66,18 @@ public class ClassInstanceValue implements Value {
@Override
public int asInt() {
throw new TypeException("Cannot cast class to integer");
throw new TypeException("Cannot cast class " + className + " to integer");
}
@Override
public double asNumber() {
throw new TypeException("Cannot cast class to integer");
throw new TypeException("Cannot cast class " + className + " to number");
}
@Override
public String asString() {
if (toString != null) {
return toString.execute(new Value[] {}).asString();
return toString.execute(new Value[0]).asString();
}
return className + "@" + thisMap;
}