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