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
4ff63464
Commit
4ff63464
authored
Jun 12, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow passing type objects around
parent
db55dac1
Changes
2
Show 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 @
4ff63464
...
@@ -4,7 +4,7 @@ class Person:
...
@@ -4,7 +4,7 @@ class Person:
name
:
str
name
:
str
age
:
int
age
:
int
def
__init__
(
self
,
name
:
str
,
age
:
int
):
def
__init__
(
self
,
name
,
age
):
self
.
name
=
name
self
.
name
=
name
self
.
age
=
age
self
.
age
=
age
...
@@ -15,6 +15,7 @@ def creer():
...
@@ -15,6 +15,7 @@ def creer():
return
Person
(
"jean"
,
123
)
return
Person
(
"jean"
,
123
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
y
=
Person
x
=
creer
()
x
=
creer
()
print
(
x
.
name
)
print
(
x
.
name
)
print
(
x
.
age
)
print
(
x
.
age
)
...
...
trans/transpiler/phases/emit_cpp/__init__.py
View file @
4ff63464
...
@@ -6,7 +6,8 @@ from typing import Iterable
...
@@ -6,7 +6,8 @@ from typing import Iterable
from
transpiler.phases.emit_cpp.consts
import
MAPPINGS
from
transpiler.phases.emit_cpp.consts
import
MAPPINGS
from
transpiler.phases.typing
import
TypeVariable
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
from
transpiler.utils
import
UnsupportedNodeError
class
UniversalVisitor
:
class
UniversalVisitor
:
...
@@ -59,6 +60,8 @@ class NodeVisitor(UniversalVisitor):
...
@@ -59,6 +60,8 @@ class NodeVisitor(UniversalVisitor):
yield
"std::string"
yield
"std::string"
elif
isinstance
(
node
,
UserType
):
elif
isinstance
(
node
,
UserType
):
yield
f"std::shared_ptr<decltype(
{
node
.
name
}
)::type>"
yield
f"std::shared_ptr<decltype(
{
node
.
name
}
)::type>"
elif
isinstance
(
node
,
TypeType
):
yield
"auto"
# TODO
elif
isinstance
(
node
,
Promise
):
elif
isinstance
(
node
,
Promise
):
yield
"typon::"
yield
"typon::"
if
node
.
kind
==
PromiseKind
.
TASK
:
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