Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package;
- class Funclass {
- public static function main():Void {
- var vm:VM = new VM();
- var myScript:VMScope;
- var script:String = sys.io.File.getContent("n_test.fc");
- while (true) {
- Sys.stdout().writeString("> ");
- script = Sys.stdin().readLine();
- myScript = vm.loadScript(script);
- myScript.register("print", new PrintDelegate());
- myScript.exec();
- Sys.stdout().writeString("\n\n");
- }
- }
- }
- class PrintDelegate implements IVMDelegate {
- public function new() {}
- public function exec(scope:VMScope, params:Array<VMValue>):VMValue {
- if (params[0].type == VMValue.TYPE_FLOAT) {
- params[0].dataStr = Std.string(params[0].dataFloat);
- }
- #if flash
- trace("$ " + params[0].dataStr);
- #else
- Sys.stdout().writeString("$ " + params[0].dataStr);
- #end
- return VMValue.createFloat(0.0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement