Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

desugar more types of for-loops #10

Merged
merged 30 commits into from
Oct 18, 2018
Merged

desugar more types of for-loops #10

merged 30 commits into from
Oct 18, 2018

Conversation

hofstee
Copy link
Collaborator

@hofstee hofstee commented Oct 5, 2018

  • for x in range(1,10,1)
  • for x in range(len(A))
  • for x in X

@coveralls
Copy link

coveralls commented Oct 5, 2018

Pull Request Test Coverage Report for Build 264

  • 416 of 494 (84.21%) changed or added relevant lines in 10 files are covered.
  • 124 unchanged lines in 8 files lost coverage.
  • Overall coverage decreased (-3.1%) to 69.381%

Changes Missing Coverage Covered Lines Changed/Added Lines %
silica/cfg/control_flow_graph.py 20 21 95.24%
silica/memory.py 1 2 50.0%
silica/cfg/types.py 4 8 50.0%
silica/cfg/ssa.py 226 233 97.0%
silica/width.py 1 14 7.14%
silica/verilog.py 59 84 70.24%
silica/transformations/desugar_for_loops.py 63 90 70.0%
Files with Coverage Reduction New Missed Lines %
silica/width.py 1 49.41%
silica/analysis.py 2 85.71%
silica/cfg/types.py 2 90.14%
silica/visitors/collect_loads.py 8 42.86%
silica/compile.py 12 78.11%
silica/verilog.py 16 76.0%
silica/cfg/ssa.py 41 81.82%
silica/cfg/control_flow_graph.py 42 63.12%
Totals Coverage Status
Change from base Build 237: -3.1%
Covered Lines: 1525
Relevant Lines: 2198

💛 - Coveralls

@hofstee hofstee requested a review from leonardt October 5, 2018 20:09
@hofstee
Copy link
Collaborator Author

hofstee commented Oct 5, 2018

Actually, don't merge this yet.

Copy link
Owner

@leonardt leonardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me in its current state, let me know when you think it's ready for another review/merge

tree, list_lens = propagate_types(tree)
tree, loopvars = desugar_for_loops(tree, list_lens)

ast_utils.print_ast(tree)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's take this out before we merge. More generally it would be good to set up some logging infrastructure so we could have these print outs hidden under a DEBUG level. I'll put that on the todo list.

return "<MemoryType: {}, {}>".format(self.height, self.width)

def __repr__(self):
return "<MemoryType: {}, {}>".format(self.height, self.width)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just have __str__ call __repr__ since right now they're the same. In fact, I think if you only define __repr__, __str__ will default to calling __repr__

ast.Assign([ast.Name(index, ast.Store())], start),
ast.While(ast.BinOp(ast.Name(index, ast.Load()), ast.Lt(), stop),
[ast.Assign([ast.Name(node.target.id, ast.Store())],
ast.Subscript(node.iter, ast.Index(ast.Name(index, ast.Load()))))] +
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like travis is unhappy about this Subscript constructor call. Are you using Python 3.6? The AST has had some changes in Python 3, so that could explain the discrepancy if you're not seeing the issue locally. Subscript expects value, slice, ctx (see https://greentreesnakes.readthedocs.io/en/latest/nodes.html#Subscript), so I think this is missing a ctx. I think in this case it would be an ast.Load(), since we're loading the subscripted value and storing into the loop var

@hofstee hofstee merged commit 82d6d01 into master Oct 18, 2018
@hofstee hofstee deleted the desugar branch October 18, 2018 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants