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
0b516646
Commit
0b516646
authored
Aug 10, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add type checking for default values and emit them in C++
parent
a98a3941
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
trans/transpiler/phases/emit_cpp/block.py
trans/transpiler/phases/emit_cpp/block.py
+6
-2
trans/transpiler/phases/typing/block.py
trans/transpiler/phases/typing/block.py
+3
-1
No files found.
trans/transpiler/phases/emit_cpp/block.py
View file @
0b516646
...
@@ -61,14 +61,18 @@ class BlockVisitor(NodeVisitor):
...
@@ -61,14 +61,18 @@ class BlockVisitor(NodeVisitor):
yield
f"
{
node
.
name
}
_inner::"
yield
f"
{
node
.
name
}
_inner::"
yield
"operator()"
yield
"operator()"
yield
"("
yield
"("
args_iter
=
zip
(
node
.
args
.
args
,
node
.
type
.
parameters
)
padded_defaults
=
[
None
]
*
node
.
type
.
optional_at
+
node
.
args
.
defaults
args_iter
=
zip
(
node
.
args
.
args
,
node
.
type
.
parameters
,
padded_defaults
)
if
skip_first_arg
:
if
skip_first_arg
:
next
(
args_iter
)
next
(
args_iter
)
for
i
,
(
arg
,
argty
)
in
enumerate
(
args_iter
):
for
i
,
(
arg
,
argty
,
default
)
in
enumerate
(
args_iter
):
if
i
!=
0
:
if
i
!=
0
:
yield
", "
yield
", "
yield
from
self
.
visit
(
argty
)
yield
from
self
.
visit
(
argty
)
yield
arg
.
arg
yield
arg
.
arg
if
emission
==
FunctionEmissionKind
.
DECLARATION
and
default
:
yield
" = "
yield
from
self
.
expr
().
visit
(
default
)
yield
")"
yield
")"
inner_scope
=
node
.
inner_scope
inner_scope
=
node
.
inner_scope
...
...
trans/transpiler/phases/typing/block.py
View file @
0b516646
...
@@ -156,7 +156,9 @@ class ScoperBlockVisitor(ScoperVisitor):
...
@@ -156,7 +156,9 @@ class ScoperBlockVisitor(ScoperVisitor):
scope
.
function
=
scope
scope
.
function
=
scope
node
.
inner_scope
=
scope
node
.
inner_scope
=
scope
node
.
type
=
ftype
node
.
type
=
ftype
ftype
.
optional_at
=
1
+
len
(
node
.
args
.
args
)
-
len
(
node
.
args
.
defaults
)
ftype
.
optional_at
=
len
(
node
.
args
.
args
)
-
len
(
node
.
args
.
defaults
)
for
ty
,
default
in
zip
(
argtypes
[
ftype
.
optional_at
:],
node
.
args
.
defaults
):
self
.
expr
().
visit
(
default
).
unify
(
ty
)
for
arg
,
ty
in
zip
(
node
.
args
.
args
,
argtypes
):
for
arg
,
ty
in
zip
(
node
.
args
.
args
,
argtypes
):
scope
.
vars
[
arg
.
arg
]
=
VarDecl
(
VarKind
.
LOCAL
,
ty
)
scope
.
vars
[
arg
.
arg
]
=
VarDecl
(
VarKind
.
LOCAL
,
ty
)
self
.
fdecls
.
append
((
node
,
rtype
.
return_type
))
self
.
fdecls
.
append
((
node
,
rtype
.
return_type
))
...
...
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