Browse Source

Bugfix: Fix processing order for functions -- deepest nodes first

master
Adam Pippin 3 years ago
parent
commit
6f90b5d222
  1. 25
      app/Cfnpp/Compiler.php

25
app/Cfnpp/Compiler.php

@ -123,15 +123,6 @@ class Compiler implements \App\Engine\ICompile
$this->pass_2($document, $options);
return $this->document;
// Process each passed document
/*
foreach ($documents as $next_document)
{
$this->runMergeFunctions($document, $next_document);
$this->merge($document, $next_document);
$this->runFunctions($document);
}
*/
}
/**
@ -302,14 +293,12 @@ class Compiler implements \App\Engine\ICompile
{
$variables[] = $node->getValue();
}
/*
// TODO: Reimplement
elseif ($node instanceof NodeFunctionValue &&
$node->getName() == 'expr')
{
$expression = new \App\Cfnpp\Expression\Expression($node->getValue());
$variables = array_merge($variables, $expression->getReferencedVariables());
}*/
}
}
return $variables;
@ -454,6 +443,12 @@ class Compiler implements \App\Engine\ICompile
*/
protected function runFunctions(Node $node): void
{
$children = $node->getChildren();
foreach ($children as $child)
{
$this->runFunctions($child);
}
if ($node->isFunctionParent() && isset($this->functions[$node[0]->getName()]))
{
$function_node = $node[0];
@ -471,12 +466,6 @@ class Compiler implements \App\Engine\ICompile
return;
}
}
$children = $node->getChildren();
foreach ($children as $child)
{
$this->runFunctions($child);
}
}
/**

Loading…
Cancel
Save