Example #1
0
 /**
  * Runs the script, returns what script returns
  * @param array values from array will be added to global object
  * @return mixed
  */
 public function run(array $vars = array())
 {
     $this->compile();
     if (!class_exists('JS')) {
         require_once __DIR__ . '/image.php';
     }
     if ($this->entryPoint === NULL) {
         $this->entryPoint = eval($this->compiled);
     }
     $global = JS::$global;
     // FIXME: no copy
     foreach ($vars as $k => $v) {
         $global->properties[$k] = JS::fromNative($v);
         $global->attributes[$k] = JS::WRITABLE | JS::ENUMERABLE | JS::CONFIGURABLE;
     }
     return JS::toNative(call_user_func($this->entryPoint, $global));
 }