function parseGTWP($ast, $name, $header) { // Push LibraryManager so we can undo this waypoint's definitions. ob_start(); LibraryManager::Push(); /*************** PROCESS AST ***************/ $attMap = ast_get($ast, NodeKey::ATT_MAP); $payload = ast_get($ast, NodeKey::PAYLOAD); $passthrough = parseQueryToAttributeSet(ast_get($ast, NodeKey::PASSTHROUGH)); $queries = []; // Info to return $res = new GenerationInfo(); foreach ($payload as $query => $qInfo) { $gtSpec = parseGT(ast_get($qInfo, NodeKey::TYPE)); $exprs = parseNamedExpressionList(ast_get($qInfo, NodeKey::ARGS)); $output = parseAttributeList(ast_get($qInfo, NodeKey::VALUE)); $cargs = parseJsonAst(ast_get($qInfo, NodeKey::CARGS)); $sargs = parseStateList(ast_get($qInfo, NodeKey::SARGS), $query); // Set of attributes to be copied to the output for each tuple $pass = $passthrough[$query]; $reqStates = []; foreach ($sargs as $val) { $reqStates[$val->name()] = $val->type(); } $gt = $gtSpec->apply($exprs, extractTypes($output), $reqStates); correlateAttributes($output, $gt->output()); $info = ['gt' => $gt, 'expressions' => $exprs, 'output' => $output, 'cargs' => $cargs, 'states' => $sargs, 'pass' => $pass]; $queries[$query] = $info; $res->addJob($query, $name); $res->absorbInfoList($exprs); $res->absorbAttrList($pass); $res->absorbAttrList($output); $res->absorbStateList($sargs); $res->absorbInfo($gt); } /*************** END PROCESS AST ***************/ // Get this waypoint's headers $myHeaders = $header . PHP_EOL . ob_get_clean(); // Only one file at the moment $filename = $name . '.cc'; $res->addFile($filename, $name); _startFile($filename); GTGenerate($name, $queries, $attMap); _endFile($filename, $myHeaders); // Pop LibraryManager again to get rid of this waypoint's declarations LibraryManager::Pop(); return $res; }