Enable termination token.
This commit is contained in:
@@ -83,11 +83,11 @@ pub enum EvalAltResult {
|
||||
ErrorTooManyModules(Position),
|
||||
/// Call stack over maximum limit.
|
||||
ErrorStackOverflow(Position),
|
||||
/// Data value over maximum size limit. Wrapped values are the type name, maximum size and current size.
|
||||
ErrorDataTooLarge(String, usize, usize, Position),
|
||||
/// The script is prematurely terminated.
|
||||
ErrorTerminated(Position),
|
||||
/// Run-time error encountered. Wrapped value is the error.
|
||||
/// Data value over maximum size limit. Wrapped value is the type name.
|
||||
ErrorDataTooLarge(String, Position),
|
||||
/// The script is prematurely terminated. Wrapped value is the termination token.
|
||||
ErrorTerminated(Dynamic, Position),
|
||||
/// Run-time error encountered. Wrapped value is the error token.
|
||||
ErrorRuntime(Dynamic, Position),
|
||||
|
||||
/// Breaking out of loops - not an error if within a loop.
|
||||
@@ -135,8 +135,8 @@ impl EvalAltResult {
|
||||
Self::ErrorTooManyOperations(_) => "Too many operations",
|
||||
Self::ErrorTooManyModules(_) => "Too many modules imported",
|
||||
Self::ErrorStackOverflow(_) => "Stack overflow",
|
||||
Self::ErrorDataTooLarge(_, _, _, _) => "Data size exceeds maximum limit",
|
||||
Self::ErrorTerminated(_) => "Script terminated.",
|
||||
Self::ErrorDataTooLarge(_, _) => "Data size exceeds maximum limit",
|
||||
Self::ErrorTerminated(_,_) => "Script terminated.",
|
||||
Self::ErrorRuntime(_, _) => "Runtime error",
|
||||
Self::LoopBreak(true, _) => "Break statement not inside a loop",
|
||||
Self::LoopBreak(false, _) => "Continue statement not inside a loop",
|
||||
@@ -185,7 +185,7 @@ impl fmt::Display for EvalAltResult {
|
||||
| Self::ErrorTooManyOperations(_)
|
||||
| Self::ErrorTooManyModules(_)
|
||||
| Self::ErrorStackOverflow(_)
|
||||
| Self::ErrorTerminated(_) => f.write_str(desc)?,
|
||||
| Self::ErrorTerminated(_, _) => f.write_str(desc)?,
|
||||
|
||||
Self::ErrorRuntime(d, _) if d.is::<ImmutableString>() => {
|
||||
let s = d.as_str().unwrap();
|
||||
@@ -237,9 +237,7 @@ impl fmt::Display for EvalAltResult {
|
||||
"String index {} is out of bounds: only {} characters in the string",
|
||||
index, max
|
||||
)?,
|
||||
Self::ErrorDataTooLarge(typ, max, size, _) => {
|
||||
write!(f, "{} ({}) exceeds the maximum limit ({})", typ, size, max)?
|
||||
}
|
||||
Self::ErrorDataTooLarge(typ, _) => write!(f, "{} exceeds maximum limit", typ)?,
|
||||
}
|
||||
|
||||
// Do not write any position if None
|
||||
@@ -297,8 +295,8 @@ impl EvalAltResult {
|
||||
Self::ErrorTooManyOperations(_)
|
||||
| Self::ErrorTooManyModules(_)
|
||||
| Self::ErrorStackOverflow(_)
|
||||
| Self::ErrorDataTooLarge(_, _, _, _)
|
||||
| Self::ErrorTerminated(_) => false,
|
||||
| Self::ErrorDataTooLarge(_, _)
|
||||
| Self::ErrorTerminated(_, _) => false,
|
||||
|
||||
Self::LoopBreak(_, _) | Self::Return(_, _) => unreachable!(),
|
||||
}
|
||||
@@ -313,9 +311,9 @@ impl EvalAltResult {
|
||||
Self::ErrorTooManyOperations(_)
|
||||
| Self::ErrorTooManyModules(_)
|
||||
| Self::ErrorStackOverflow(_)
|
||||
| Self::ErrorDataTooLarge(_, _, _, _) => true,
|
||||
| Self::ErrorDataTooLarge(_, _) => true,
|
||||
|
||||
Self::ErrorTerminated(_) => true,
|
||||
Self::ErrorTerminated(_, _) => true,
|
||||
|
||||
Self::LoopBreak(_, _) | Self::Return(_, _) => unreachable!(),
|
||||
|
||||
@@ -349,8 +347,8 @@ impl EvalAltResult {
|
||||
| Self::ErrorTooManyOperations(pos)
|
||||
| Self::ErrorTooManyModules(pos)
|
||||
| Self::ErrorStackOverflow(pos)
|
||||
| Self::ErrorDataTooLarge(_, _, _, pos)
|
||||
| Self::ErrorTerminated(pos)
|
||||
| Self::ErrorDataTooLarge(_, pos)
|
||||
| Self::ErrorTerminated(_, pos)
|
||||
| Self::ErrorRuntime(_, pos)
|
||||
| Self::LoopBreak(_, pos)
|
||||
| Self::Return(_, pos) => *pos,
|
||||
@@ -383,8 +381,8 @@ impl EvalAltResult {
|
||||
| Self::ErrorTooManyOperations(pos)
|
||||
| Self::ErrorTooManyModules(pos)
|
||||
| Self::ErrorStackOverflow(pos)
|
||||
| Self::ErrorDataTooLarge(_, _, _, pos)
|
||||
| Self::ErrorTerminated(pos)
|
||||
| Self::ErrorDataTooLarge(_, pos)
|
||||
| Self::ErrorTerminated(_, pos)
|
||||
| Self::ErrorRuntime(_, pos)
|
||||
| Self::LoopBreak(_, pos)
|
||||
| Self::Return(_, pos) => *pos = new_position,
|
||||
|
Reference in New Issue
Block a user