Author: Elliot Levin (elliotlevin@hotmail.com)
Inheritance: extends TraversalExpression
 protected final function visitOffsetGet(O\Expression $expression)
 {
     $requestId = $this->getId('offset-get');
     $indexId = $this->getId('offset-get-index');
     if ($expression instanceof O\MethodCallExpression) {
         $this->interpretation->interpretOffsetGet($requestId, $indexId, $this->getArgumentValueAt(0, $expression));
     } elseif ($expression instanceof O\IndexExpression) {
         $this->interpretation->interpretOffsetGet($requestId, $indexId, $this->getValue($expression->getIndex()));
     } else {
         throw new PinqException('Cannot interpret offset get request: invalid expression type, expecting %s, %s given', O\MethodCallExpression::getType() . ' or ' . O\IndexExpression::getType(), $expression->getType());
     }
     $this->interpretSourceAsScope($expression);
 }
示例#2
0
 public function visitIndex(O\IndexExpression $expression)
 {
     $this->walk($expression->getValue());
     $this->walk($expression->getIndex());
     $this->addTypeOperation($expression, $this->analysis[$expression->getValue()]->getIndex($expression));
 }
 protected function visitIndex(O\IndexExpression $expression)
 {
     $valueExpression = $expression->getValue();
     if (!$valueExpression instanceof O\VariableExpression || !$valueExpression->getName() instanceof O\ValueExpression) {
         throw new PinqDemoSqlException('Variable indexer is not supported');
     }
     $index = $expression->getIndex()->getValue();
     $this->sql .= $this->query->tableName . '.' . $index;
 }
 protected final function visitOffsetSet(O\Expression $expression)
 {
     if ($expression instanceof O\MethodCallExpression) {
         $index = $this->getArgumentValueAt(0, $expression);
         $value = $this->getArgumentValueAt(1, $expression);
         $sourceExpression = $expression;
     } elseif ($expression instanceof O\AssignmentExpression) {
         $sourceExpression = $expression->getAssignTo();
         if ($sourceExpression instanceof O\IndexExpression) {
             $index = $this->getValue($sourceExpression->getIndex());
             $value = $this->getValue($expression->getAssignmentValue());
         } else {
             throw new PinqException('Cannot interpret set index operation: invalid source expression type, expecting %s, %s given', O\IndexExpression::getType(), $expression->getType());
         }
     } else {
         throw new PinqException('Cannot interpret set index operation: invalid expression type, expecting %s, %s given', O\MethodCallExpression::getType() . ' or ' . O\AssignmentExpression::getType(), $expression->getType());
     }
     $this->interpretation->interpretOffsetSet($this->getId('offset-set'), $this->getId('set-index'), $index, $this->getId('set-value'), $value);
     $this->interpretSourceAsScope($sourceExpression);
 }