示例#1
0
文件: IssetOp.php 项目: asgrim/PHPPHP
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $varName = $this->op1->getName();
     $ret = isset($data->symbolTable[$varName]) && !$data->symbolTable[$varName]->isNull();
     $this->result->setValue($ret);
     $data->nextOp();
 }
示例#2
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $this->op1->separateIfNotRef();
     if (!$this->op1->isArray()) {
         if ($this->op1->isNull()) {
             $this->op1->setValue(array());
         } else {
             throw new \RuntimeException('Cannot use a scalar value as an array');
         }
     }
     $array =& $this->op1->getArray();
     if ($this->dim) {
         $key = $this->dim->toString();
         if (isset($array[$key])) {
             $array[$key]->forceValue($this->op2->getZval());
         } else {
             $array[$key] = Zval::ptrFactory($this->op2->getZval());
         }
     } else {
         $array[] = Zval::ptrFactory($this->op2->getZval());
     }
     if ($this->result) {
         $this->result->setValue($this->op2->getZval());
     }
     $data->nextOp();
 }
示例#3
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $command = $this->op1->getValue();
     $result = `{$command}`;
     $this->result->setValue($result);
     $data->nextOp();
 }
示例#4
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $name = $this->op1->toString();
     $functionData = $this->op2;
     $data->executor->getFunctionStore()->register($name, $functionData);
     $data->nextOp();
 }
示例#5
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $consts = $data->executor->getConstantStore();
     $value = $consts->get($this->op1->toString());
     $this->result->setValue($value);
     $data->nextOp();
 }
示例#6
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $key = $this->op2->getValue();
     if ($this->op1->isArray()) {
         $array =& $this->op1->getArray();
         if (!isset($array[$key])) {
             if ($this->write) {
                 $array[$key] = Zval::ptrFactory();
                 $this->result->setValue($array[$key]);
             } else {
                 $this->result->setValue(Zval::ptrFactory());
             }
         } else {
             $this->result->setValue($array[$key]);
         }
     } elseif ($this->op1->isString()) {
         $value = $this->op1->getValue();
         if (isset($value[$key])) {
             $this->result->setValue($value[$key]);
         } else {
             $this->result->setValue('');
         }
     } elseif ($this->write && $this->op1->isNull()) {
         $value = Zval::ptrFactory();
         $this->op1->setValue(array($key => $value));
         $this->result->setValue($value);
     } else {
         throw new \RuntimeException('Cannot use a scalar value as an array');
     }
     if ($this->write) {
         $this->result->getZval()->makeRef();
     }
     $data->nextOp();
 }
示例#7
0
文件: PreInc.php 项目: asgrim/PHPPHP
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $val = $this->op1->getValue();
     $this->op1->setValue(++$val);
     $this->result->setValue($this->op1);
     $data->nextOp();
 }
示例#8
0
文件: PostDec.php 项目: asgrim/PHPPHP
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $ret = $this->op1->getZval();
     $this->result->setValue($ret);
     $val = $this->op1->getValue();
     $this->op1->setValue(--$val);
     $data->nextOp();
 }
示例#9
0
文件: JumpIf.php 项目: asgrim/PHPPHP
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     if ($this->op1->toBool()) {
         $data->jump($this->op2);
         return;
     }
     $data->nextOp();
 }
示例#10
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     if ($this->op2) {
         $this->op2->setValue($this->op1->getIterator()->key());
     }
     $this->result->setValue($this->op1->getIterator()->current());
     $data->nextOp();
 }
示例#11
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $varName = $this->op1->toString();
     if (!isset($data->executor->executorGlobals->symbolTable[$varName])) {
         $data->executor->executorGlobals->symbolTable[$varName] = Zval::ptrFactory();
     }
     $data->symbolTable[$varName] = $data->executor->executorGlobals->symbolTable[$varName];
     $data->nextOp();
 }
示例#12
0
文件: Mod.php 项目: asgrim/PHPPHP
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     if (0 == $this->op2->getValue()) {
         $this->result->setValue(false);
     } else {
         $this->result->setValue($this->op1->getValue() % $this->op2->getValue());
     }
     $data->nextOp();
 }
示例#13
0
文件: Iterate.php 项目: asgrim/PHPPHP
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $this->result->setIterator($this->op1->getIterator());
     if (!$this->result->getIterator()->valid()) {
         $data->jump($this->op2);
     } else {
         $data->nextOp();
     }
 }
示例#14
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $value = $this->getValue();
     if (0 == $value) {
         $this->setValue(false);
     } else {
         $this->setValue($value / $this->op2->getValue());
     }
     $data->nextOp();
 }
示例#15
0
文件: EvalOp.php 项目: asgrim/PHPPHP
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $fileName = $data->opArray->getFileName() . '(' . $this->lineno . ") : eval()'d code";
     $code = $this->op1->toString();
     $opCodes = $data->executor->compile('<?php ' . $code, $fileName);
     $return = $data->executor->execute($opCodes, $data->symbolTable);
     if ($return) {
         $this->result->setValue($return);
     }
     $data->nextOp();
 }
示例#16
0
文件: EmptyOp.php 项目: asgrim/PHPPHP
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     if ($this->op1->isVariable()) {
         $varName = $this->op1->getName();
         if (!isset($data->symbolTable[$varName])) {
             $this->result->setValue(true);
             $data->nextOp();
             return;
         }
     }
     $this->result->setValue(!$this->op1->getValue());
     $data->nextOp();
 }
示例#17
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $key = $this->op1->toString();
     $array = $this->result->toArray();
     $var = Zval::ptrFactory($this->op2->getZval())->separateIfRef();
     if ($key) {
         $array[$key] = $var;
     } else {
         $array[] = $var;
     }
     $this->result->setValue($array);
     $data->nextOp();
 }
示例#18
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $varName = $this->op1->toString();
     $var = $data->fetchVariable($varName);
     if (!$this->value) {
         $var->makeRef();
         $this->value = $var;
         if ($this->op2) {
             $var->setValue($this->op2);
         }
     }
     $var->assignZval($this->value);
     $data->nextOp();
 }
示例#19
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $functionCall = $data->executor->executorGlobals->call;
     $args = array();
     $stack = $data->executor->getStack();
     for ($i = $stack->count() - 1; $i >= 0; $i--) {
         $args[] = $stack->pop();
     }
     $args = array_reverse($args);
     if (!$this->result) {
         $this->result = Zval::ptrFactory();
     }
     $functionCall->execute($args, $this->result);
     $data->executor->executorGlobals->call = null;
     $data->nextOp();
 }
示例#20
0
文件: Recv.php 项目: asgrim/PHPPHP
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $args = $data->arguments;
     $n = $this->op1->toLong();
     $param = $data->function->getParam($n);
     if ($param) {
         $var = $data->fetchVariable($param->name);
         if ($param->isRef) {
             $var->assignZval($args[$n]->getZval());
             $var->addRef();
         } else {
             $var->setValue($args[$n]);
         }
     }
     $data->nextOp();
 }
示例#21
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     if ($this->op1->isString()) {
         $ce = $data->executor->getClassStore()->get($this->op1->getValue());
     } else {
         if ($this->op1->isObject()) {
             $ce = $this->op1->getValue()->getClassEntry();
         } else {
             throw new \RuntimeException('Class name must be a valid object or a string');
         }
     }
     $consts = $ce->getConstantStore();
     $value = $consts->get($this->op2->toString());
     $this->result->setValue($value);
     $data->nextOp();
 }
示例#22
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $ci = $this->op1;
     $funcName = $this->op2->toString();
     if ($ci) {
         if ($ci->isObject()) {
             $ci = $ci->getValue();
             $functionData = $ci->getClassEntry()->getMethodStore()->get($funcName);
         } else {
             throw new \RuntimeException(sprintf('Call to a member function %s() on a non-object', $funcName));
         }
     } else {
         $functionData = $data->executor->getFunctionStore()->get($funcName);
     }
     $data->executor->executorGlobals->call = new Engine\FunctionCall($data->executor, $functionData, $ci);
     $data->nextOp();
 }
示例#23
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $className = $this->op1;
     $funcName = $this->op2->toString();
     if ($className->isString()) {
         $ce = $data->executor->getClassStore()->get($className->getValue());
     } else {
         if ($className->isObject()) {
             $ce = $className->getValue()->getClassEntry();
         } else {
             throw new \RuntimeException('Class name must be a valid object or a string');
         }
     }
     $functionData = $ce->getMethodStore()->get($funcName);
     $data->executor->executorGlobals->call = new Engine\FunctionCall($data->executor, $functionData, null, $ce);
     $data->nextOp();
 }
示例#24
0
文件: Send.php 项目: asgrim/PHPPHP
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $ptr = null;
     if ($data->executor->executorGlobals->call->getFunction()->isArgByRef($this->op2->getValue())) {
         if ($this->op1->isVariable() || $this->op1->isRef() || $this->op1->isObject()) {
             $op = $this->op1->getPtr();
             $op->makeRef();
             $op->addRef();
             $ptr = Zval::ptrFactory($op->getZval());
         } else {
             throw new \RuntimeException("Can't pass parameter {" . $this->op2->getValue() . "} by reference");
         }
     } else {
         $ptr = Zval::ptrFactory($this->op1->getValue());
     }
     $data->executor->getStack()->push($ptr);
     $data->nextOp();
 }
示例#25
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $fileName = $this->op2->toString();
     if (substr($fileName, 0, 1) !== '/') {
         $fileName = $data->executor->executorGlobals->cwd . '/' . $fileName;
     }
     $fileName = realpath($fileName);
     if (!is_file($fileName)) {
         throw new \RuntimeException('Including bad file!');
     }
     switch ($this->op1->getValue()) {
         case IncludeNode::TYPE_INCLUDE_ONCE:
         case IncludeNode::TYPE_REQUIRE_ONCE:
             if ($data->executor->hasFile($fileName)) {
                 break;
             }
         case IncludeNode::TYPE_INCLUDE:
         case IncludeNode::TYPE_REQUIRE:
             $opCodes = $data->executor->compileFile($fileName);
             $data->executor->execute($opCodes);
     }
     $data->nextOp();
 }
示例#26
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $this->op2->makeRef();
     $zval = $this->op2->getZval();
     if ($this->property) {
         $this->op1->getValue()->setProperty($this->property->toString(), $zval);
     } else {
         if ($this->dim) {
             $array =& $this->op1->getArray();
             $key = $this->property->toString();
             if (isset($array[$key])) {
                 $array[$key]->forceValue($zval);
             } else {
                 $array[$key] = Zval::ptrFactory($zval);
             }
         } else {
             $this->op1->forceValue($zval);
         }
     }
     if ($this->result) {
         $this->result->setValue($zval);
     }
     $data->nextOp();
 }
示例#27
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $data->jump($this->op1->continueOp);
 }
示例#28
0
文件: Smaller.php 项目: asgrim/PHPPHP
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $this->result->setValue($this->op1->getValue() < $this->op2->getValue());
     $data->nextOp();
 }
示例#29
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $ce = $this->op1;
     $data->executor->getClassStore()->register($ce);
     $data->nextOp();
 }
示例#30
0
 public function execute(\PHPPHP\Engine\ExecuteData $data)
 {
     $this->result->setValue(!$this->op1->isEqualTo($this->op2));
     $data->nextOp();
 }