Browse Source

Add !var to use value of variable as value

master
Adam Pippin 3 years ago
parent
commit
6ce8dec215
  1. 16
      app/Engine/CfnppFunctions.php

16
app/Engine/CfnppFunctions.php

@ -6,6 +6,7 @@ namespace App\Engine;
use App\Dom\Document;
use App\Dom\Node;
use App\Dom\NodeValue;
use App\Dom\NodeFunction;
use App\Dom\NodeFunctionValue;
@ -30,6 +31,8 @@ class CfnppFunctions
public function __construct(Cfnpp $compiler, CfnppOptions $options)
{
$this->compiler = $compiler;
$this->options = $options;
}
/**
@ -92,4 +95,17 @@ class CfnppFunctions
{
return null;
}
/**
* Get the value of a variable.
*
* @param Node $node
* @param NodeFunction $function
* @return ?Node
*/
public function f_var(Node $node, NodeFunction $function): ?Node
{
$value = $this->options->getVariable($function->getValue());
return new NodeValue(null, $node->hasName() ? $node->getName() : null, $value);
}
}

Loading…
Cancel
Save