From 0009d7b139880d0d7a08c5d51af94cebbb337bd3 Mon Sep 17 00:00:00 2001 From: Keerthan Jaic Date: Sun, 1 Feb 2015 20:36:08 -0500 Subject: [PATCH] Remove deprecated _unparse module delete module, disable test it is not used anywhere --- myhdl/_unparse.py | 172 ------------------------------------ myhdl/test/core/test_all.py | 4 +- 2 files changed, 2 insertions(+), 174 deletions(-) delete mode 100644 myhdl/_unparse.py diff --git a/myhdl/_unparse.py b/myhdl/_unparse.py deleted file mode 100644 index f4e3eb64..00000000 --- a/myhdl/_unparse.py +++ /dev/null @@ -1,172 +0,0 @@ -# This file is part of the myhdl library, a Python package for using -# Python as a Hardware Description Language. -# -# Copyright (C) 2003-2008 Jan Decaluwe -# -# The myhdl library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of the -# License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -""" unparse module - -""" -from __future__ import absolute_import - - -import compiler -from myhdl._compat import StringIO - -def _unparse(ast): - v = _UnparseVisitor() - compiler.walk(ast, v) - return v.buf.getvalue() - -class _UnparseVisitor(object): - - def __init__(self): - self.buf = StringIO() - - def write(self, arg): - self.buf.write(arg) - - def unaryOp(self, node, op): - self.write("(") - self.write("%s" % op) - self.visit(node.expr) - self.write(")") - - def binaryOp(self, node, op): - self.write("(") - self.visit(node.left) - self.write(" %s " % op) - self.visit(node.right) - self.write(")") - - def multiOp(self, node, op): - self.write("(") - self.visit(node.nodes[0]) - for node in node.nodes[1:]: - self.write(" %s " % op) - self.visit(node) - self.write(")") - - def visitAdd(self, node): - self.binaryOp(node, '+') - - def visitAnd(self, node): - self.multiOp(node, ' and ') - - def visitBitand(self, node): - self.multiOp(node, '&') - - def visitBitor(self, node): - self.multiOp(node, '|') - - def visitBitxor(self, node): - self.multiOp(node, '^') - - def visitCallFunc(self, node): - self.visit(node.node) - self.write('(') - comma = '' - for arg in node.args: - self.write(comma); comma=',' - self.visit(arg) - if node.star_args: - self.write(comma); comma=',' - self.write('*') - self.visit(node.star_args) - if node.dstar_args: - self.write(comma); comma=',' - self.write('**') - self.visit(node.dstar_args) - self.write(')') - - def visitCompare(self, node): - self.write("(") - self.visit(node.expr) - for comp in node.ops: - op, expr = comp - self.write(" %s " % op) - self.visit(expr) - self.write(")") - - def visitConst(self, node): - self.write(str(node.value)) - - def visitGetattr(self, node): - self.visit(node.expr) - self.write('.') - self.write(node.attrname) - - def visitFloorDiv(self, node): - self.binaryOp(node, '//') - - def visitInvert(self, node): - self.unaryOp(node, '~') - - def visitKeyword(self, node): - self.write(node.name) - self.write('=') - self.visit(node.expr) - - def visitLeftShift(self, node): - self.binaryOp(node, '<<') - - def visitName(self, node): - self.write(node.name) - - def visitMod(self, node): - self.binaryOp(node, '%') - - def visitMul(self, node): - self.binaryOp(node, '*') - - def visitNot(self, node): - self.unaryOp(node, 'not ') - - def visitOr(self, node): - self.multiOp(node, ' or ') - - def visitPower(self, node): - self.binaryOp(node, '**') - - def visitRightShift(self, node): - self.binaryOp(node, '>>') - - def visitSlice(self, node): - self.visit(node.expr) - self.write('[') - if node.lower is not None: - self.visit(node.lower) - self.write(':') - if node.upper is not None: - self.visit(node.upper) - self.write(']') - - def visitSub(self, node): - self.binaryOp(node, '-') - - def visitSubscript(self, node): - self.visit(node.expr) - self.write("[") - if len(node.subs) > 1: - raise NotImplementedError - self.visit(node.subs[0]) - self.write("]") - - def visitUnaryAdd(self, node, *args): - self.unaryOp(node, '+') - - def visitUnarySub(self, node, *args): - self.unaryOp(node, '-') diff --git a/myhdl/test/core/test_all.py b/myhdl/test/core/test_all.py index 6eca864c..56acc97c 100644 --- a/myhdl/test/core/test_all.py +++ b/myhdl/test/core/test_all.py @@ -23,12 +23,12 @@ from __future__ import absolute_import import test_Simulation, test_Signal, test_intbv, test_Cosimulation, test_misc, \ test_always_comb, test_bin, test_traceSignals, test_enum, test_concat, \ - test_unparse, test_inferWaiter, test_always, test_instance, test_signed, \ + test_inferWaiter, test_always, test_instance, test_signed, \ test_modbv modules = (test_Simulation, test_Signal, test_intbv, test_misc, test_always_comb, test_bin, test_traceSignals, test_enum, test_concat, - test_unparse, test_inferWaiter, test_always, test_instance, test_signed, + test_inferWaiter, test_always, test_instance, test_signed, test_modbv )