diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2018-01-03 12:16:33 +0100 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2018-01-03 12:16:33 +0100 |
commit | 32ac20b7d941df693cc757a7fc75a225d11c7ee5 (patch) | |
tree | f82ffe744a16a74766bdaf4b0868703e8e702ba2 /canonicalize | |
parent | 1ee2b0252602b6176ee02db5c4a77fb2daac0a0f (diff) |
canonicalize: don’t rename imports
Diffstat (limited to 'canonicalize')
-rw-r--r-- | canonicalize/__init__.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/canonicalize/__init__.py b/canonicalize/__init__.py index 481b6e2..8b3fda0 100644 --- a/canonicalize/__init__.py +++ b/canonicalize/__init__.py @@ -4,7 +4,7 @@ import uuid from .transformations import * from .display import printFunction -from .astTools import deepcopy +from .astTools import deepcopy, getAllImportStatements def giveIds(a, idCounter=0): if isinstance(a, ast.AST): @@ -27,10 +27,7 @@ def giveIds(a, idCounter=0): setattr(a, field, child) giveIds(child, idCounter) -def getCanonicalForm(tree, problem_name=None, given_names=None, argTypes=None, imports=None): - if imports == None: - imports = [] - +def getCanonicalForm(tree, problem_name=None, given_names=None, argTypes=None): transformations = [ constantFolding, @@ -53,6 +50,8 @@ def getCanonicalForm(tree, problem_name=None, given_names=None, argTypes=None, i deadCodeRemoval ] + imports = getAllImportStatements(tree) + varmap = {} tree = propogateMetadata(tree, {'foo': ['int', 'int']}, varmap, [0]) @@ -71,7 +70,7 @@ def canonicalize(code): tree = ast.parse(code) giveIds(tree) - new_tree = getCanonicalForm(tree, problem_name='foo', given_names=['foo']) + new_tree = getCanonicalForm(tree, given_names=['bmi']) new_code = printFunction(new_tree) return new_code |