Advertisement
PifyZ

Untitled

Jul 13th, 2014
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 0.85 KB | None | 0 0
  1. package;
  2.  
  3. class Funclass {
  4.     public static function main():Void {
  5.         var vm:VM = new VM();
  6.         var myScript:VMScope;
  7.  
  8.         var script:String = sys.io.File.getContent("n_test.fc");
  9.  
  10.         while (true) {
  11.             Sys.stdout().writeString("> ");
  12.             script = Sys.stdin().readLine();
  13.             myScript = vm.loadScript(script);
  14.  
  15.             myScript.register("print", new PrintDelegate());
  16.             myScript.exec();
  17.  
  18.             Sys.stdout().writeString("\n\n");
  19.         }
  20.     }
  21. }
  22.  
  23. class PrintDelegate implements IVMDelegate {
  24.     public function new() {}
  25.  
  26.     public function exec(scope:VMScope, params:Array<VMValue>):VMValue {
  27.         if (params[0].type == VMValue.TYPE_FLOAT) {
  28.             params[0].dataStr = Std.string(params[0].dataFloat);
  29.         }
  30.  
  31.         #if flash
  32.             trace("$ " + params[0].dataStr);
  33.         #else
  34.             Sys.stdout().writeString("$ " + params[0].dataStr);
  35.         #end
  36.  
  37.         return VMValue.createFloat(0.0);
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement