/** Add a variable occurency to tree */ Group * insertGroup(Group * g_root, char * tag, char * name, int line) { int cmp; #ifdef DEBUG printf("Got %s, %s at %d\n", tag, name, line); #endif if (g_root == NULL) { g_root = newGroup(tag); g_root->var = insertVariable(g_root->var, name, line); } else if ((cmp = strcmp(tag, g_root->tag)) == 0) { g_root->total_count++; g_root->var = insertVariable(g_root->var, name, line); } else if (cmp > 0) g_root->right = insertGroup(g_root->right, tag, name, line); else g_root->left = insertGroup(g_root->left, tag, name, line); return g_root; }
/** Add a variable occurency to variable group */ Variable * insertVariable(Variable * v_root, char * name, int line) { int cmp; Line * nl; if (v_root == NULL) { v_root = newVariable(name); v_root->last_line = newLine(line); } else if ((cmp = strcmp(name, v_root->name)) == 0) { v_root->count++; if (line == v_root->last_line->number) v_root->last_line->count++; else { nl = newLine(line); nl->prev = v_root->last_line; v_root->last_line = nl; } } else if (cmp > 0) v_root->right = insertVariable(v_root->right, name, line); else v_root->left = insertVariable(v_root->left, name, line); return v_root; }
void Number_RulePlusPlus::unifyVariables(NFunction function){ QList<NTerm> body = function->getBody(); int size = body.size(); for(int i=0; i<size; ++i){ NTerm term = body[i]; NVariable variable = term.staticCast<Number_Variable>(); if(variable){ NVariable newVariable = insertVariable(variable); body[i] = newVariable.dynamicCast<Number_Term>(); continue; } NConstant constant = term.staticCast<Number_Constant>(); if(constant){ continue; } NFunction subFunction = term.staticCast<Number_Function>(); if(subFunction){ unifyVariables(subFunction); continue; } Q_ASSERT(false); } }
bool extendVarValue (struct node *head, char *set_resetName, char *getVarValue, char *extendWith, int extendingPosition) { char finalValue[100], extendTemp[100]; // create a node to track the place struct node *place; place = head; // find the value that is needed to extend with while(TRUE){ if (place == NULL) { return FALSE; } else if (strcmp(place->name,getVarValue) != 0 && place->next == NULL) { return FALSE; } else if (strcmp(place->name,getVarValue) == 0) { strcpy(finalValue, place->value); break; } else { place = place->next; } } // create the new variable value if (extendingPosition == varValueInFront) { strcat(finalValue, extendWith); } else {//(extendingPosition == varValueInBack) strcpy(finalValue, (strcat(extendWith, finalValue))); } // Insert it into the list (insert OR replace) extendWith = finalValue; insertVariable(head, set_resetName, extendWith, VARIABLE); return TRUE; }
void CodeEditorDialog::insertVariable(QAction *action) { insertVariable(action->text()); }
void CodeLineEdit::insertVariable(QAction *action) { insertVariable(action->text()); }