public function filter(\Closure $c) { $filtered = $this->expression->filter($c); if ($this->codeChunks !== null) { foreach ($this->codeChunks->getCodeChunks() as $codeChunk) { $filtered = array_merge($filtered, $codeChunk->filter($c)); } } return $filtered; }
/** * @param TES5FragmentType $fragmentType * @param string $fragmentName * @param TES5GlobalScope $globalScope * @param TES4CodeChunks $chunks * @return TES5FunctionCodeBlock */ public function createFragment(TES5FragmentType $fragmentType, $fragmentName, TES5GlobalScope $globalScope, TES5MultipleScriptsScope $multipleScriptsScope, TES4CodeChunks $chunks) { $fragmentLocalScope = $this->fragmentLocalScopeFactory->createFromFragmentType($fragmentType); $function = new TES5FunctionCodeBlock($fragmentName, new TES5VoidType(), $fragmentLocalScope, $this->codeScopeFactory->createCodeScope($this->fragmentLocalScopeFactory->createRecursiveScope($fragmentLocalScope))); foreach ($chunks->getCodeChunks() as $codeChunk) { $codeChunks = $this->codeChunkFactory->createCodeChunk($codeChunk, $function->getCodeScope(), $globalScope, $multipleScriptsScope); if ($codeChunks !== null) { foreach ($codeChunks as $newCodeChunk) { $function->addChunk($newCodeChunk); } } } return $function; }