import ast import compiler def process(node): if len(node.nodes) < 2: print "and must have at least two parameters" #first term dest = ast.nextPRegister() ast.outputInBlock("%s = %s" % ( dest, ast.evaluate(node.nodes[0]) ) ) #remaining terms operand = ast.nextPRegister() for x in node.nodes[1:]: ast.outputInBlock("%s = %s" % ( operand, ast.evaluate(x) ) ) ast.outputInBlock("band %s, %s, %s" % ( dest, dest, operand ) ) return dest