mirror of
https://github.com/aNNiMON/Own-Programming-Language-Tutorial.git
synced 2024-09-20 00:34:20 +03:00
Call stack for class constructor
This commit is contained in:
parent
368cc8612c
commit
5267ff6144
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user