diff --git a/SMILEBASIC/VM.d b/SMILEBASIC/VM.d index 11135d5..ec6304f 100644 --- a/SMILEBASIC/VM.d +++ b/SMILEBASIC/VM.d @@ -2747,3 +2747,11 @@ class CallBG : Code callback(vm); } } + +class Stop : Code +{ + override void execute(VM vm) + { + vm.petitcomputer.stop(); + } +} diff --git a/SMILEBASIC/compiler.d b/SMILEBASIC/compiler.d index cff7358..c0ca624 100644 --- a/SMILEBASIC/compiler.d +++ b/SMILEBASIC/compiler.d @@ -1294,6 +1294,15 @@ class Compiler case NodeType.CallBG: compileCallBG(cast(otya.smilebasic.node.CallBG)i, s); break; + case NodeType.StopStatement: + { + if (isDirectMode) + { + throw new CantUseFromDirectMode(); + } + genCode(new Stop()); + break; + } default: stderr.writeln("Compile:NotImpl ", i.type); } diff --git a/SMILEBASIC/console.d b/SMILEBASIC/console.d index 05c59b0..2eaf5fe 100644 --- a/SMILEBASIC/console.d +++ b/SMILEBASIC/console.d @@ -150,7 +150,6 @@ class Console imEditInfo.editingText = e; imEditInfo.start = s; imEditInfo.length = l; - writefln("%s,%s,%s", e, s, l); } bool showCursor; diff --git a/SMILEBASIC/node.d b/SMILEBASIC/node.d index 57e6306..04026c7 100644 --- a/SMILEBASIC/node.d +++ b/SMILEBASIC/node.d @@ -53,6 +53,7 @@ enum NodeType Linput, CallSprite, CallBG, + StopStatement, } abstract class Node { @@ -715,3 +716,11 @@ class CallBG : Statement this.type = NodeType.CallBG; } } +class StopStatement : Statement +{ + this(SourceLocation loc) + { + super.location = loc; + this.type = NodeType.StopStatement; + } +} diff --git a/SMILEBASIC/parser.d b/SMILEBASIC/parser.d index e286e6f..70232eb 100644 --- a/SMILEBASIC/parser.d +++ b/SMILEBASIC/parser.d @@ -83,6 +83,7 @@ class Lexical reserved["UNTIL"] = TokenType.Until; reserved["SWAP"] = TokenType.Swap; reserved["LINPUT"] = TokenType.Linput; + reserved["STOP"] = TokenType.Stop; reserved.rehash(); } this(wstring input) @@ -1144,6 +1145,9 @@ class Parser return swapStatement(); case TokenType.Linput: return linputStatement(); + case TokenType.Stop: + node = new StopStatement(lex.location); + break; default: syntaxError(); break; diff --git a/SMILEBASIC/token.d b/SMILEBASIC/token.d index 8ad5bcb..d842bfb 100644 --- a/SMILEBASIC/token.d +++ b/SMILEBASIC/token.d @@ -77,6 +77,7 @@ enum TokenType Dim, Constant, Linput, + Stop, } enum TokenValueType