Skip to content
This repository was archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
[Compiler] Initial implementation for Node\Scalar\Encapsed (refs #280)
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Dec 8, 2016
1 parent 652b11e commit 795841b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Compiler/Scalar.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ protected function factory(Node\Scalar $scalar)

// @todo Review this and implement support
case Node\Scalar\EncapsedStringPart::class:
case Node\Scalar\Encapsed::class:
return new CompiledExpression(CompiledExpression::STRING);
case Node\Scalar\Encapsed::class:
return $this->compileUncapsedString($scalar);

/**
* Fake scalars for testing
Expand Down Expand Up @@ -108,4 +109,17 @@ protected function factory(Node\Scalar $scalar)
throw new RuntimeException('Unknown scalar: ' . get_class($scalar));
}
}

/**
* @param Node\Scalar\Encapsed $scalar
* @return CompiledExpression
*/
protected function compileUncapsedString(Node\Scalar\Encapsed $scalar)
{
foreach ($scalar->parts as $part) {
$this->context->getExpressionCompiler()->compile($part);
}

return new CompiledExpression(CompiledExpression::STRING);
}
}

0 comments on commit 795841b

Please sign in to comment.