/**
* Pre-compiles the method making compilation pass data (static inference, local-context-pass) available to other methods
*
* @param CompilationContext $compilationContext
* @return null
* @throws CompilerException
*/
public function preCompile(CompilationContext $compilationContext)
{
$localContext = null;
$typeInference = null;
$callGathererPass = null;
if (is_object($this->statements)) {
$compilationContext->currentMethod = $this;
/**
* This pass checks for zval variables than can be potentially
* used without allocating memory and track it
* these variables are stored in the stack
*/
if ($compilationContext->config->get('local-context-pass', 'optimizations')) {
$localContext = new LocalContextPass();
$localContext->pass($this->statements);
}
/**
* This pass tries to infer types for dynamic variables
* replacing them by low level variables
*/
if ($compilationContext->config->get('static-type-inference', 'optimizations')) {
$typeInference = new StaticTypeInference();
$typeInference->pass($this->statements);
if ($compilationContext->config->get('static-type-inference-second-pass', 'optimizations')) {
$typeInference->reduce();
$typeInference->pass($this->statements);
}
}
/**
* This pass counts how many times a specific
*/
if ($compilationContext->config->get('call-gatherer-pass', 'optimizations')) {
$callGathererPass = new CallGathererPass($compilationContext);
$callGathererPass->pass($this->statements);
}
}
$this->localContext = $localContext;
$this->typeInference = $typeInference;
$this->callGathererPass = $callGathererPass;
}