Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tom Niget
typon
Commits
3ddf3249
Commit
3ddf3249
authored
Jun 12, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow passing type objects around
parent
173e8636
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
trans/tests/a_a_usertype.py
trans/tests/a_a_usertype.py
+2
-1
trans/transpiler/phases/emit_cpp/__init__.py
trans/transpiler/phases/emit_cpp/__init__.py
+4
-1
No files found.
trans/tests/a_a_usertype.py
View file @
3ddf3249
...
...
@@ -4,7 +4,7 @@ class Person:
name
:
str
age
:
int
def
__init__
(
self
,
name
:
str
,
age
:
int
):
def
__init__
(
self
,
name
,
age
):
self
.
name
=
name
self
.
age
=
age
...
...
@@ -15,6 +15,7 @@ def creer():
return
Person
(
"jean"
,
123
)
if
__name__
==
"__main__"
:
y
=
Person
x
=
creer
()
print
(
x
.
name
)
print
(
x
.
age
)
...
...
trans/transpiler/phases/emit_cpp/__init__.py
View file @
3ddf3249
...
...
@@ -6,7 +6,8 @@ from typing import Iterable
from
transpiler.phases.emit_cpp.consts
import
MAPPINGS
from
transpiler.phases.typing
import
TypeVariable
from
transpiler.phases.typing.types
import
BaseType
,
TY_INT
,
TY_BOOL
,
TY_NONE
,
Promise
,
PromiseKind
,
TY_STR
,
UserType
from
transpiler.phases.typing.types
import
BaseType
,
TY_INT
,
TY_BOOL
,
TY_NONE
,
Promise
,
PromiseKind
,
TY_STR
,
UserType
,
\
TypeType
from
transpiler.utils
import
UnsupportedNodeError
class
UniversalVisitor
:
...
...
@@ -59,6 +60,8 @@ class NodeVisitor(UniversalVisitor):
yield
"std::string"
elif
isinstance
(
node
,
UserType
):
yield
f"std::shared_ptr<decltype(
{
node
.
name
}
)::type>"
elif
isinstance
(
node
,
TypeType
):
yield
"auto"
# TODO
elif
isinstance
(
node
,
Promise
):
yield
"typon::"
if
node
.
kind
==
PromiseKind
.
TASK
:
...
...
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