def specialFunctions(cv, old, new):
if type(old) == type(new) == list:
log("individualize\tspecialFunctions\tWhy are we comparing lists?: " + str(cv) + ";" + printFunction(old) + ";" + printFunction(new), "bug")
return cv
rev = neg = False
if (hasattr(old, "reversed") and old.reversed and (not hasattr(old, "multCompFixed"))):
rev = True
if (hasattr(old, "negated") and old.negated):
neg = True
if rev and neg:
(old, new) = (negate(undoReverse(old)), negate(undoReverse(new)))
elif rev:
(old, new) = (undoReverse(old), undoReverse(new))
elif neg:
(old, new) = (negate(old), negate(new))
if type(old) == ast.UnaryOp and type(old.op) == ast.Not and \
type(new) == ast.UnaryOp and type(new.op) == ast.Not:
# Just get rid of them
old = old.operand
new = new.operand
if hasattr(old, "num_negated") and old.num_negated:
origNew = deepcopy(new)
(old, new) = (num_negate(old), num_negate(new))
if new == None: # couldn't reverse the new operator
# To get here, we must have a binary operator. Go up a level and negate the right side
cvCopy = cv.deepcopy()
parentSpot = deepcopy(cvCopy.traverseTree(cvCopy.start))
if type(parentSpot) == ast.BinOp:
cvCopy.path = cvCopy.path[1:]
cvCopy.oldSubtree = parentSpot
cvCopy.newSubtree = deepcopy(parentSpot)
cvCopy.newSubtree.op = origNew
cvCopy.newSubtree.right = num_negate(cvCopy.newSubtree.right)
cvCopy = orderedBinOpSpecialFunction(cvCopy) # just in case
return cvCopy
else:
log("individualize\tspecialFunctions\tWhere are we? " + str(type(parentSpot)), "bug")
#if (hasattr(old, "inverted") and old.inverted):
# (old, new) = (invert(old), invert(new))
cv.oldSubtree = old
cv.newSubtree = new
return cv
评论列表
文章目录