Esempio n. 1
0
 protected function registerCoreConstants(ConstantStore $constants)
 {
     $coreConstants = array('null' => null, 'true' => true, 'false' => false);
     foreach ($coreConstants as $name => $value) {
         $constants->register($name, Zval::factory($value), false);
     }
 }
Esempio n. 2
0
 public function compileReturn($value)
 {
     if (is_array($value)) {
         $result = array();
         foreach ($value as $key => $item) {
             $result[$key] = $this->compileReturn($item);
         }
         return Engine\Zval::factory($result);
     } else {
         return Engine\Zval::factory($value);
     }
 }
Esempio n. 3
0
 protected function registerConstants(\PHPPHP\Engine\Executor $executor)
 {
     $store = $executor->getConstantStore();
     foreach (get_defined_constants(true) as $group => $set) {
         if ($group == 'user') {
             continue;
         }
         foreach ($set as $name => $value) {
             if (!$store->exists($name)) {
                 $store->register($name, Zval::factory($value));
             }
         }
     }
 }
Esempio n. 4
0
 public function register(\PHPPHP\Engine\Executor $executor)
 {
     $functionStore = $executor->getFunctionStore();
     foreach ($this->getFunctions() as $name => $functionData) {
         $functionStore->register($name, $functionData);
     }
     $constantStore = $executor->getConstantStore();
     foreach ($this->getConstants() as $name => $value) {
         $constantStore->register($name, Engine\Zval::factory($value));
     }
     $classStore = $executor->getClassStore();
     foreach ($this->getClasses() as $ce) {
         $classStore->register($ce);
     }
 }
Esempio n. 5
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     self::$instanceNumber++;
     $className = $this->op1->toString();
     $classEntry = $data->executor->getClassStore()->get($className);
     $instance = $classEntry->instantiate($data, array());
     $instance->setInstanceNumber(self::$instanceNumber);
     $constructor = $classEntry->getConstructor();
     if ($constructor) {
         $data->executor->executorGlobals->call = new Engine\FunctionCall($data->executor, $constructor, $instance);
     }
     $this->result->setValue(Zval::factory($instance));
     if (!$constructor) {
         $data->jump($this->noConstructorJumpOffset);
     } else {
         $data->nextOp();
     }
 }
Esempio n. 6
0
 protected function setValue($value)
 {
     $zval = Zval::factory($value);
     if ($this->property) {
         $this->op1->getValue()->setProperty($this->property->toString(), $zval);
     } else {
         if ($this->dim) {
             $array =& $this->op1->getArray();
             $key = $this->dim->toString();
             if (isset($array[$key])) {
                 $array[$key]->setValue($zval);
             } else {
                 $array[$key] = Zval::ptrFactory($zval);
             }
         } else {
             $this->op1->setValue($zval);
         }
     }
     if ($this->result) {
         $this->result->setValue($zval);
     }
 }
Esempio n. 7
0
 protected function makeZvalFromNode(\PHPParser_Node $node)
 {
     if ($node instanceof \PHPParser_Node_Scalar_LNumber || $node instanceof \PHPParser_Node_Scalar_DNumber || $node instanceof \PHPParser_Node_Scalar_String) {
         return Zval::factory($node->value);
     } elseif ($node instanceof \PHPParser_Node_Expr_Array) {
         $array = array();
         foreach ($node->items as $item) {
             if ($item->byRef) {
                 return null;
             }
             $array[$this->makeZvalFromNode($item->key)] = $this->makeZvalFromNode($item->value);
         }
         return $array;
     } elseif ($node instanceof \PHPParser_Node_Scalar_FileConst) {
         /* TODO */
         return null;
     } else {
         return null;
     }
 }