forked from python/mypy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mypyc] Support list of extra constants and str.split (python#9334)
This PR changes the CallC description so that a list of extra constants can be used to a call. With this added functionality, str.split is implemented in new style IR.
- Loading branch information
1 parent
2b704df
commit 05a4cab
Showing
6 changed files
with
90 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[case testStrSplit] | ||
from typing import Optional, List | ||
|
||
def do_split(s: str, sep: Optional[str] = None, max_split: Optional[int] = None) -> List[str]: | ||
if sep is not None: | ||
if max_split is not None: | ||
return s.split(sep, max_split) | ||
else: | ||
return s.split(sep) | ||
return s.split() | ||
[out] | ||
def do_split(s, sep, max_split): | ||
s :: str | ||
sep :: union[str, None] | ||
max_split :: union[int, None] | ||
r0, r1, r2 :: object | ||
r3, r4 :: bool | ||
r5 :: object | ||
r6, r7 :: bool | ||
r8 :: str | ||
r9 :: int | ||
r10 :: list | ||
r11 :: str | ||
r12, r13 :: list | ||
L0: | ||
if is_error(sep) goto L1 else goto L2 | ||
L1: | ||
r0 = box(None, 1) | ||
sep = r0 | ||
L2: | ||
if is_error(max_split) goto L3 else goto L4 | ||
L3: | ||
r1 = box(None, 1) | ||
max_split = r1 | ||
L4: | ||
r2 = box(None, 1) | ||
r3 = sep == r2 | ||
r4 = !r3 | ||
if r4 goto L5 else goto L9 :: bool | ||
L5: | ||
r5 = box(None, 1) | ||
r6 = max_split == r5 | ||
r7 = !r6 | ||
if r7 goto L6 else goto L7 :: bool | ||
L6: | ||
r8 = cast(str, sep) | ||
r9 = unbox(int, max_split) | ||
r10 = CPyStr_Split(s, r8, r9) | ||
return r10 | ||
L7: | ||
r11 = cast(str, sep) | ||
r12 = PyUnicode_Split(s, r11, -1) | ||
return r12 | ||
L8: | ||
L9: | ||
r13 = PyUnicode_Split(s, 0, -1) | ||
return r13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters