bool findIO (command_t command, struct graphNode* n, const int which_c) { bool dependent = false; bool subshell = false; if (command->type == SIMPLE_COMMAND) { int k; int j = 0; while(command->u.word[j] != NULL) { for (k = 0; k < output_count; k++) { if (strcmp(outputs[k].word, command->u.word[j]) == 0){ dependent = true; n->before[n->before_index] = outputs[k].t; n->before_index++; } } j++; } if (command->output != NULL) { outputs[output_count].word = command->output; outputs[output_count].t = n; outputs[output_count].which_command = which_c; output_count++; } if (command->input != NULL) { int i; for (i = 0; i < output_count; i++) { if (strcmp(outputs[i].word, command->input) == 0 && outputs[i].which_command != which_c) { dependent = true; n->before[n->before_index] = outputs[i].t; n->before_index ++; } } } return dependent; } if (command->type == SUBSHELL_COMMAND) return findIO(command->u.subshell_command, n, which_c); bool left = findIO(command->u.command[0], n, which_c); bool right = findIO(command->u.command[1], n, which_c); return left || right; }
bool WireManager::selectIO(const QPoint& pos, QString& name) { const EditorView::CircuitViewCollection& circuitViews = m_view->circuitViews(); foreach (ICircuitView * const view, circuitViews) { const QString& res1 = findIO(view->inputs(), pos, Qt::red); if (!res1.isEmpty()) { name = res1; return true; } const QString& res2 = findIO(view->outputs(), pos, Qt::green); if (!res2.isEmpty()) { name = res2; return true; } } return false; }
void build_parallel(command_stream_t stream) { int i = 0; for (; i < stream->num_root; i++) { graphNode* n = malloc(1*sizeof(graphNode)); n->command = stream->root[i]; n->before_index = 0; n->pid = -200; if (findIO(n->command, n, i)) push(&Dependency_front, &Dependency_rear, n); else push(&NoDependency_front, &NoDependency_rear, n); } int j = 0; }