|
|
@ -215,23 +215,38 @@ class Functions |
|
|
|
* @param NodeFunction $function |
|
|
|
* @return ?Node |
|
|
|
*/ |
|
|
|
/* |
|
|
|
* TODO: Reimplement |
|
|
|
public function f_expr(Node $node, NodeFunction $function): ?Node |
|
|
|
{ |
|
|
|
if (!($function instanceof NodeFunctionValue)) |
|
|
|
{ |
|
|
|
throw new \Exception('!if requires scalar argument'); |
|
|
|
throw new \Exception('!expr requires scalar argument'); |
|
|
|
} |
|
|
|
|
|
|
|
$parser = new \App\Cfnpp\Expression\Parser(); |
|
|
|
$expression = $parser->parse($function->getValue()); |
|
|
|
$result = $expression->evaluate($this->options->getVariables()); |
|
|
|
$expression = new \App\Cfnpp\Expression\Expression($function->getValue(), $this->options); |
|
|
|
|
|
|
|
$result = Node::fromPhp($result); |
|
|
|
$result->setName($node->hasName() ? $node->getName() : null); |
|
|
|
if ($expression->isComplete()) |
|
|
|
{ |
|
|
|
// If we computed a final value/set of values, we can just insert those |
|
|
|
// directly. |
|
|
|
if ($expression->count() == 1) |
|
|
|
{ |
|
|
|
$solution_node = Node::fromPhp($expression->getValue()); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
$solution_node = Node::fromPhp($expression->toArray()); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// Otherwise let's convert it to cfn intrinsics |
|
|
|
$solution_node = Node::fromPhp($expression->toCloudformation()); |
|
|
|
} |
|
|
|
|
|
|
|
return $result; |
|
|
|
if ($node->hasName()) |
|
|
|
{ |
|
|
|
$solution_node->setName($node->getName()); |
|
|
|
} |
|
|
|
return $solution_node; |
|
|
|
} |
|
|
|
*/ |
|
|
|
} |
|
|
|