diff --git a/SMILEBASIC/VM.d b/SMILEBASIC/VM.d index 7d84aac..7762a6b 100644 --- a/SMILEBASIC/VM.d +++ b/SMILEBASIC/VM.d @@ -2182,3 +2182,22 @@ class Pop : Code vm.decSP(); } } + +class Exec : Code +{ + override void execute(VM vm) + { + Value arg; + vm.pop(arg); + } +} + +class Use : Code +{ + override void execute(VM vm) + { + Value arg; + vm.pop(arg); + } +} + diff --git a/SMILEBASIC/compiler.d b/SMILEBASIC/compiler.d index c9d997c..821778a 100644 --- a/SMILEBASIC/compiler.d +++ b/SMILEBASIC/compiler.d @@ -933,6 +933,16 @@ class Compiler { genCode(new SetX(x.func, false)); } + void compileExec(otya.smilebasic.node.Exec exec, Scope sc) + { + compileExpression(exec.expression, sc); + genCode(new otya.smilebasic.vm.Exec); + } + void compileUse(otya.smilebasic.node.Use use, Scope sc) + { + compileExpression(use.expression, sc); + genCode(new otya.smilebasic.vm.Use); + } void compileStatement(Statement i, Scope s) { switch(i.type) @@ -1201,6 +1211,12 @@ class Compiler case NodeType.XOff: compileXOff(cast(XOff)i, s); break; + case NodeType.Exec: + compileExec(cast(otya.smilebasic.node.Exec)i, s); + break; + case NodeType.Use: + compileUse(cast(otya.smilebasic.node.Use)i, s); + break; default: stderr.writeln("Compile:NotImpl ", i.type); } diff --git a/SMILEBASIC/node.d b/SMILEBASIC/node.d index aa73b2b..bce53f4 100644 --- a/SMILEBASIC/node.d +++ b/SMILEBASIC/node.d @@ -48,6 +48,8 @@ enum NodeType VarRef, XOn, XOff, + Exec, + Use, } abstract class Node { @@ -653,4 +655,23 @@ class XOff : Statement this.func = func; } } - +class Exec : Statement +{ + Expression expression; + this(Expression e, SourceLocation loc) + { + super.location = loc; + expression = e; + this.type = NodeType.Exec; + } +} +class Use : Statement +{ + Expression expression; + this(Expression e, SourceLocation loc) + { + super.location = loc; + expression = e; + this.type = NodeType.Use; + } +} diff --git a/SMILEBASIC/parser.d b/SMILEBASIC/parser.d index 5e3d0fa..4f09c76 100644 --- a/SMILEBASIC/parser.d +++ b/SMILEBASIC/parser.d @@ -1111,14 +1111,14 @@ class Parser { lex.popFront(); auto expr = expression(); - writeln("NOTIMPL:USE"); + return new Use(expr, lex.location); } break; case TokenType.Exec: { lex.popFront(); auto expr = expression(); - writeln("NOTIMPL:EXEC"); + return new Exec(expr, lex.location); } break; case TokenType.Swap: