Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
typon
typon-compiler
Commits
1e3fcd78
Commit
1e3fcd78
authored
Nov 03, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move function parameters emission to separate method
parent
0e3c66da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
typon/trans/transpiler/phases/emit_cpp/block.py
typon/trans/transpiler/phases/emit_cpp/block.py
+14
-11
No files found.
typon/trans/transpiler/phases/emit_cpp/block.py
View file @
1e3fcd78
...
...
@@ -68,6 +68,19 @@ class BlockVisitor(NodeVisitor):
yield
f"
{
name
}
;"
yield
from
child_visitor
.
visit
(
child
)
def
visit_func_params
(
self
,
args
:
Iterable
[
tuple
[
str
,
BaseType
,
Optional
[
ast
.
expr
]]],
emission
:
FunctionEmissionKind
)
->
Iterable
[
str
]:
for
i
,
(
arg
,
argty
,
default
)
in
enumerate
(
args
):
if
i
!=
0
:
yield
", "
if
emission
==
FunctionEmissionKind
.
METHOD
and
i
==
0
:
yield
"Self"
else
:
yield
from
self
.
visit
(
argty
)
yield
arg
if
emission
in
{
FunctionEmissionKind
.
DECLARATION
,
FunctionEmissionKind
.
LAMBDA
,
FunctionEmissionKind
.
METHOD
}
and
default
:
yield
" = "
yield
from
self
.
expr
().
visit
(
default
)
def
visit_func_new
(
self
,
node
:
ast
.
FunctionDef
,
emission
:
FunctionEmissionKind
,
skip_first_arg
:
bool
=
False
)
->
Iterable
[
str
]:
if
emission
==
FunctionEmissionKind
.
LAMBDA
:
yield
"[&]"
...
...
@@ -83,17 +96,7 @@ class BlockVisitor(NodeVisitor):
args_iter
=
zip
(
node
.
args
.
args
,
node
.
type
.
parameters
,
padded_defaults
)
if
skip_first_arg
:
next
(
args_iter
)
for
i
,
(
arg
,
argty
,
default
)
in
enumerate
(
args_iter
):
if
i
!=
0
:
yield
", "
if
emission
==
FunctionEmissionKind
.
METHOD
and
i
==
0
:
yield
"Self"
else
:
yield
from
self
.
visit
(
argty
)
yield
arg
.
arg
if
emission
in
{
FunctionEmissionKind
.
DECLARATION
,
FunctionEmissionKind
.
LAMBDA
,
FunctionEmissionKind
.
METHOD
}
and
default
:
yield
" = "
yield
from
self
.
expr
().
visit
(
default
)
yield
from
self
.
visit_func_params
(((
arg
.
arg
,
argty
,
default
)
for
arg
,
argty
,
default
in
args_iter
),
emission
)
yield
")"
if
emission
==
FunctionEmissionKind
.
METHOD
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment