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

[mypyc] Improve docstrings and comments + some minor refactoring #9861

Merged
merged 8 commits into from
Dec 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mypyc/analysis/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ def visit_branch(self, op: Branch) -> GenAndKill:
return non_trivial_sources(op), set()

def visit_return(self, op: Return) -> GenAndKill:
if not isinstance(op.reg, Integer):
return {op.reg}, set()
if not isinstance(op.value, Integer):
return {op.value}, set()
else:
return set(), set()

Expand Down
12 changes: 6 additions & 6 deletions mypyc/codegen/emitfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ def visit_branch(self, op: Branch) -> None:

cond = ''
if op.op == Branch.BOOL:
expr_result = self.reg(op.left) # right isn't used
expr_result = self.reg(op.value)
cond = '{}{}'.format(neg, expr_result)
elif op.op == Branch.IS_ERROR:
typ = op.left.type
typ = op.value.type
compare = '!=' if op.negated else '=='
if isinstance(typ, RTuple):
# TODO: What about empty tuple?
cond = self.emitter.tuple_undefined_check_cond(typ,
self.reg(op.left),
self.reg(op.value),
self.c_error_value,
compare)
else:
cond = '{} {} {}'.format(self.reg(op.left),
cond = '{} {} {}'.format(self.reg(op.value),
compare,
self.c_error_value(typ))
else:
Expand All @@ -141,8 +141,8 @@ def visit_branch(self, op: Branch) -> None:
)

def visit_return(self, op: Return) -> None:
regstr = self.reg(op.reg)
self.emit_line('return %s;' % regstr)
value_str = self.reg(op.value)
self.emit_line('return %s;' % value_str)

def visit_tuple_set(self, op: TupleSet) -> None:
dest = self.reg(op)
Expand Down
5 changes: 4 additions & 1 deletion mypyc/ir/func_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class RuntimeArg:
"""Representation of a function argument in IR.
"""Description of a function argument in IR.

Argument kind is one of ARG_* constants defined in mypy.nodes.
"""
Expand Down Expand Up @@ -156,8 +156,11 @@ def __init__(self,
blocks: List[BasicBlock],
line: int = -1,
traceback_name: Optional[str] = None) -> None:
# Declaration of the function, including the signature
self.decl = decl
# Registers for all the arguments to the function
self.arg_regs = arg_regs
# Body of the function
self.blocks = blocks
self.line = line
# The name that should be displayed for tracebacks that
Expand Down
Loading