Commit 8c105262 authored by frmdstryr's avatar frmdstryr Committed by Sven Brauch
Browse files

Fix UnaryOp checking wrong object..

parent 8a8a1551
......@@ -745,6 +745,23 @@ QString UnaryOperationAst::dump() const {
QString r;
r.append("Unary(");
dumpNode(r, "value=", operand);
r.append(", op=");
switch(type) {
case Ast::UnaryOperatorInvert:
r.append("Invert()");
break;
case Ast::UnaryOperatorNot:
r.append("Not()");
break;
case Ast::UnaryOperatorAdd:
r.append("UAdd()");
break;
case Ast::UnaryOperatorSub:
r.append("USub()");
break;
default:
r.append("Invalid");
}
r.append(")");
return r;
}
......
......@@ -370,13 +370,13 @@ Ast* AstTransformer::visitExprNode(PyObject* node, Ast* parent)
UnaryOperationAst* v = new UnaryOperationAst(parent);
{
PyObjectRef op = getattr<PyObjectRef>(node, "op");
if (PyObject_IsInstance(node, grammar.ast_Invert))
v->type = Ast::UnaryOperatorInvalid;
else if (PyObject_IsInstance(node, grammar.ast_Not))
if (PyObject_IsInstance(op, grammar.ast_Invert))
v->type = Ast::UnaryOperatorInvert;
else if (PyObject_IsInstance(op, grammar.ast_Not))
v->type = Ast::UnaryOperatorNot;
else if (PyObject_IsInstance(node, grammar.ast_UAdd))
else if (PyObject_IsInstance(op, grammar.ast_UAdd))
v->type = Ast::UnaryOperatorAdd;
else if (PyObject_IsInstance(node, grammar.ast_USub))
else if (PyObject_IsInstance(op, grammar.ast_USub))
v->type = Ast::UnaryOperatorSub;
else
v->type = Ast::UnaryOperatorInvalid;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment