Ejemplo n.º 1
0
 function __construct($engine, array $options)
 {
     if (!extension_loaded('luasandbox')) {
         throw new Scribunto_LuaInterpreterNotFoundError('The luasandbox extension is not present, this engine cannot be used.');
     }
     $this->engine = $engine;
     $this->sandbox = new LuaSandbox();
     $this->sandbox->setMemoryLimit($options['memoryLimit']);
     $this->sandbox->setCPULimit($options['cpuLimit']);
     if (is_callable(array($this->sandbox, 'enableProfiler'))) {
         if (!isset($options['profilerPeriod'])) {
             $options['profilerPeriod'] = 0.02;
         }
         if ($options['profilerPeriod']) {
             $this->profilerEnabled = true;
             $this->sandbox->enableProfiler($options['profilerPeriod']);
         }
     }
 }