1
0

IMplement STOP

This commit is contained in:
otya128
2017-07-04 20:28:49 +09:00
parent e5e784a9da
commit bb586dbb55
6 changed files with 31 additions and 1 deletions

View File

@@ -2747,3 +2747,11 @@ class CallBG : Code
callback(vm); callback(vm);
} }
} }
class Stop : Code
{
override void execute(VM vm)
{
vm.petitcomputer.stop();
}
}

View File

@@ -1294,6 +1294,15 @@ class Compiler
case NodeType.CallBG: case NodeType.CallBG:
compileCallBG(cast(otya.smilebasic.node.CallBG)i, s); compileCallBG(cast(otya.smilebasic.node.CallBG)i, s);
break; break;
case NodeType.StopStatement:
{
if (isDirectMode)
{
throw new CantUseFromDirectMode();
}
genCode(new Stop());
break;
}
default: default:
stderr.writeln("Compile:NotImpl ", i.type); stderr.writeln("Compile:NotImpl ", i.type);
} }

View File

@@ -150,7 +150,6 @@ class Console
imEditInfo.editingText = e; imEditInfo.editingText = e;
imEditInfo.start = s; imEditInfo.start = s;
imEditInfo.length = l; imEditInfo.length = l;
writefln("%s,%s,%s", e, s, l);
} }
bool showCursor; bool showCursor;

View File

@@ -53,6 +53,7 @@ enum NodeType
Linput, Linput,
CallSprite, CallSprite,
CallBG, CallBG,
StopStatement,
} }
abstract class Node abstract class Node
{ {
@@ -715,3 +716,11 @@ class CallBG : Statement
this.type = NodeType.CallBG; this.type = NodeType.CallBG;
} }
} }
class StopStatement : Statement
{
this(SourceLocation loc)
{
super.location = loc;
this.type = NodeType.StopStatement;
}
}

View File

@@ -83,6 +83,7 @@ class Lexical
reserved["UNTIL"] = TokenType.Until; reserved["UNTIL"] = TokenType.Until;
reserved["SWAP"] = TokenType.Swap; reserved["SWAP"] = TokenType.Swap;
reserved["LINPUT"] = TokenType.Linput; reserved["LINPUT"] = TokenType.Linput;
reserved["STOP"] = TokenType.Stop;
reserved.rehash(); reserved.rehash();
} }
this(wstring input) this(wstring input)
@@ -1144,6 +1145,9 @@ class Parser
return swapStatement(); return swapStatement();
case TokenType.Linput: case TokenType.Linput:
return linputStatement(); return linputStatement();
case TokenType.Stop:
node = new StopStatement(lex.location);
break;
default: default:
syntaxError(); syntaxError();
break; break;

View File

@@ -77,6 +77,7 @@ enum TokenType
Dim, Dim,
Constant, Constant,
Linput, Linput,
Stop,
} }
enum TokenValueType enum TokenValueType