Skip to content

Commit 5267ff6

Browse files
committed
Call stack for class constructor
1 parent 368cc86 commit 5267ff6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ownlang-parser/src/main/java/com/annimon/ownlang/lib/ClassInstanceValue.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ public void addMethod(String name, ClassMethod method) {
4040

4141
public void callConstructor(Value[] args) {
4242
if (constructor != null) {
43+
CallStack.enter("class " + className, constructor, null);
4344
constructor.execute(args);
45+
CallStack.exit();
4446
}
4547
}
4648

@@ -64,18 +66,18 @@ public Object raw() {
6466

6567
@Override
6668
public int asInt() {
67-
throw new TypeException("Cannot cast class to integer");
69+
throw new TypeException("Cannot cast class " + className + " to integer");
6870
}
6971

7072
@Override
7173
public double asNumber() {
72-
throw new TypeException("Cannot cast class to integer");
74+
throw new TypeException("Cannot cast class " + className + " to number");
7375
}
7476

7577
@Override
7678
public String asString() {
7779
if (toString != null) {
78-
return toString.execute(new Value[] {}).asString();
80+
return toString.execute(new Value[0]).asString();
7981
}
8082
return className + "@" + thisMap;
8183
}

0 commit comments

Comments
 (0)