def makeAssignExpr(node): if nodeType(node) == 'Assignment' and nodeType(node.lvalue) == 'ID': return c_ast.BinaryOp( '|', node, c_ast.BinaryOp( '==', makeAssignLog(node.coord, node.lvalue.name), c_ast.Constant('int', '0'), node.coord), node.coord) elif nodeType(node) == 'UnaryOp' and nodeType(node.expr) == 'ID': if node.op == 'p++': return c_ast.BinaryOp( '|', node, c_ast.BinaryOp( '==', makePostIncAssignLog(node.coord, node.expr.name), c_ast.Constant('int', '0'), node.coord), node.coord) elif node.op == 'p--': return c_ast.BinaryOp( '|', node, c_ast.BinaryOp( '==', makePostDecAssignLog(node.coord, node.expr.name), c_ast.Constant('int', '0'), node.coord), node.coord) elif node.op == '++' or node.op == '--': return c_ast.BinaryOp( '|', node, c_ast.BinaryOp( '==', makeAssignLog(node.coord, node.expr.name), c_ast.Constant('int', '0'), node.coord), node.coord) return node
def assignNode(node): if node == None: return None elif nodeType(node) == 'ArrayDecl': return assignArrayDecl(node) elif nodeType(node) == 'ArrayRef': return assignArrayRef(node) elif nodeType(node) == 'Assignment': return assignAssignment(node) elif nodeType(node) == 'BinaryOp': return assignBinaryOp(node) elif nodeType(node) == 'Break': return assignBreak(node) elif nodeType(node) == 'Case': return assignCase(node) elif nodeType(node) == 'Cast': return assignCast(node) elif nodeType(node) == 'Compound': return assignCompound(node) elif nodeType(node) == 'CompoundLiteral': return assignCompoundLiteral(node) elif nodeType(node) == 'Constant': return assignConstant(node) elif nodeType(node) == 'Continue': return assignContinue(node) elif nodeType(node) == 'Decl': return assignDecl(node) elif nodeType(node) == 'DeclList': return assignDeclList(node) elif nodeType(node) == 'Default': return assignDefault(node) elif nodeType(node) == 'DoWhile': return assignDoWhile(node) elif nodeType(node) == 'EllipsisParam': return assignEllipsisParam(node) elif nodeType(node) == 'EmptyStatement': return assignEmptyStatement(node) elif nodeType(node) == 'Enum': return assignEnum(node) elif nodeType(node) == 'Enumerator': return assignEnumerator(node) elif nodeType(node) == 'EnumeratorList': return assignEnumeratorList(node) elif nodeType(node) == 'ExprList': return assignExprList(node) elif nodeType(node) == 'FileAST': return assignFileAST(node) elif nodeType(node) == 'For': return assignFor(node) elif nodeType(node) == 'FuncCall': return assignFuncCall(node) elif nodeType(node) == 'FuncDecl': return assignFuncDecl(node) elif nodeType(node) == 'FuncDef': return assignFuncDef(node) elif nodeType(node) == 'Goto': return assignGoto(node) elif nodeType(node) == 'ID': return assignID(node) elif nodeType(node) == 'IdentifierType': return assignIdentifierType(node) elif nodeType(node) == 'If': return assignIf(node) elif nodeType(node) == 'Label': return assignLabel(node) elif nodeType(node) == 'NamedInitializer': return assignNamedInitializer(node) elif nodeType(node) == 'ParamList': return assignParamList(node) elif nodeType(node) == 'PtrDecl': return assignPtrDecl(node) elif nodeType(node) == 'Return': return assignReturn(node) elif nodeType(node) == 'Struct': return assignStruct(node) elif nodeType(node) == 'StructRef': return assignStructRef(node) elif nodeType(node) == 'Switch': return assignSwitch(node) elif nodeType(node) == 'TernaryOp': return assignTernaryOp(node) elif nodeType(node) == 'TypeDecl': return assignTypeDecl(node) elif nodeType(node) == 'Typedef': return assignTypedef(node) elif nodeType(node) == 'Typename': return assignTypename(node) elif nodeType(node) == 'UnaryOp': return assignUnaryOp(node) elif nodeType(node) == 'Union': return assignUnion(node) elif nodeType(node) == 'While': return assignWhile(node) else: print('===================================================================================') print('bad type' + nodeType) print('===================================================================================') return node