Ejemplo n.º 1
0
 public function compile(Compiler $compiler, OperatorNode $node)
 {
     $data = $node->getChild(OperatorNode::OPERAND_LEFT);
     $filter = $node->getChild(OperatorNode::OPERAND_RIGHT);
     if ($filter instanceof FunctionNode) {
         $arguments = $filter->getArguments();
         array_unshift($arguments, $data);
         $filter->setArguments($arguments);
     } elseif ($filter instanceof IdentifierNode && !$filter instanceof VariableNode) {
         $filter = new FunctionNode($filter->getData('name'), [$data]);
     } else {
         throw new ParseException('Invalid filter node.');
     }
     $filter->compile($compiler);
 }
Ejemplo n.º 2
0
 public function createMethodCallNode($object, $function, array $arguments = [])
 {
     $functionNode = new FunctionNode($function, $arguments);
     $functionNode->setObject($object);
     return $functionNode;
 }
Ejemplo n.º 3
0
 private function isFunctionNodeSafe(FunctionNode $node)
 {
     if ($this->functionLevel++ === 0) {
         if ($node->getObject()) {
             return false;
         }
         return $this->isFunctionSafe($node);
     }
     return true;
 }
Ejemplo n.º 4
0
 private function parseIdentifier($identifier)
 {
     if ($this->stream->nextTokenIf(Token::PUNCTUATION, '(')) {
         //function call
         $node = new FunctionNode($identifier, $this->parseArgumentList());
         $lastOperator = $this->operatorStack->top();
         if ($lastOperator instanceof PropertyAccessOperator) {
             $this->operatorStack->pop();
             $node->setObject($this->operandStack->pop());
         }
     } else {
         $node = new IdentifierNode($identifier);
     }
     $this->operandStack->push($node);
 }