/*- *--------------------------------------------------------------------- * ParseDoOp -- * Apply the parsed operator to the given target node. Used in a * Array_Find call by ParseDoDependency once all targets have * been found and their operator parsed. If the previous and new * operators are incompatible, a major error is taken. * * Side Effects: * The type field of the node is altered to reflect any new bits in * the op. *--------------------------------------------------------------------- */ static int ParseDoOp(GNode **gnp, unsigned int op) { GNode *gn = *gnp; /* * If the dependency mask of the operator and the node don't match and * the node has actually had an operator applied to it before, and the * operator actually has some dependency information in it, complain. */ if (((op & OP_OPMASK) != (gn->type & OP_OPMASK)) && !OP_NOP(gn->type) && !OP_NOP(op)) { Parse_Error(PARSE_FATAL, "Inconsistent dependency operator for target %s\n" "\t(was %s%s, now %s%s)", gn->name, gn->name, operator_string(gn->type), gn->name, operator_string(op)); return 0; } if (op == OP_DOUBLEDEP && ((gn->type & OP_OPMASK) == OP_DOUBLEDEP)) { /* If the node was the object of a :: operator, we need to * create a new instance of it for the children and commands on * this dependency line. The new instance is placed on the * 'cohorts' list of the initial one (note the initial one is * not on its own cohorts list) and the new instance is linked * to all parents of the initial instance. */ GNode *cohort; LstNode ln; cohort = Targ_NewGN(gn->name); /* Duplicate links to parents so graph traversal is simple. * Perhaps some type bits should be duplicated? * * Make the cohort invisible as well to avoid duplicating it * into other variables. True, parents of this target won't * tend to do anything with their local variables, but better * safe than sorry. */ for (ln = Lst_First(&gn->parents); ln != NULL; ln = Lst_Adv(ln)) ParseLinkSrc((GNode *)Lst_Datum(ln), cohort); cohort->type = OP_DOUBLEDEP|OP_INVISIBLE; Lst_AtEnd(&gn->cohorts, cohort); /* Replace the node in the targets list with the new copy */ *gnp = cohort; gn = cohort; } /* We don't want to nuke any previous flags (whatever they were) so we * just OR the new operator into the old. */ gn->type |= op; return 1; }
void ast_expression_bin::print(void) const { subexpressions[0]->print(); printf("%s ", operator_string(oper)); subexpressions[1]->print(); }
const char *ir_expression::operator_string() { return operator_string(this->operation); }