Add StackOver/UnderFlow
This commit is contained in:
1 parent
654cd1b439
commit
46fb83483b
2 files changed
+19
-6
No files matched your search
+3
-6
@@ -176,8 +176,7 @@ class VM
|
||||
{
|
||||
if(stacki >= this.stack.length)
|
||||
{
|
||||
writeln("Stack OF");
|
||||
readln();
|
||||
throw new StackOverFlow();
|
||||
}
|
||||
stack[stacki++] = value;
|
||||
}
|
||||
@@ -193,8 +192,7 @@ class VM
|
||||
{
|
||||
if(stacki <= bp)
|
||||
{
|
||||
writeln("Stack underflow");
|
||||
readln();
|
||||
throw new StackUnderFlow();
|
||||
}
|
||||
value = stack[--stacki];
|
||||
}
|
||||
@@ -202,8 +200,7 @@ class VM
|
||||
{
|
||||
if(stacki <= bp)
|
||||
{
|
||||
writeln("Stack underflow");
|
||||
readln();
|
||||
throw new StackUnderFlow();
|
||||
}
|
||||
--stacki;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,22 @@ class IllegalFunctionCall : SmileBasicError
|
||||
super("Illegal function call(" ~ func ~ ")");
|
||||
}
|
||||
}
|
||||
class StackOverFlow : SmileBasicError
|
||||
{
|
||||
this()
|
||||
{
|
||||
this.errnum = 5;
|
||||
super("Stack overflow");
|
||||
}
|
||||
}
|
||||
class StackUnderFlow : SmileBasicError
|
||||
{
|
||||
this()
|
||||
{
|
||||
this.errnum = 6;
|
||||
super("Stack underflow");
|
||||
}
|
||||
}
|
||||
class TypeMismatch : SmileBasicError
|
||||
{
|
||||
this()
|
||||
|
||||
Reference in new issue
Block a user