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) {
|
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user