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
d8891f7d
Commit
d8891f7d
authored
Jul 07, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add field to store whether type is reference
parent
bbff8ada
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
trans/transpiler/phases/emit_cpp/expr.py
trans/transpiler/phases/emit_cpp/expr.py
+1
-1
trans/transpiler/phases/typing/types.py
trans/transpiler/phases/typing/types.py
+3
-1
No files found.
trans/transpiler/phases/emit_cpp/expr.py
View file @
d8891f7d
...
@@ -176,7 +176,7 @@ class ExpressionVisitor(NodeVisitor):
...
@@ -176,7 +176,7 @@ class ExpressionVisitor(NodeVisitor):
def
visit_Attribute
(
self
,
node
:
ast
.
Attribute
)
->
Iterable
[
str
]:
def
visit_Attribute
(
self
,
node
:
ast
.
Attribute
)
->
Iterable
[
str
]:
yield
from
self
.
prec
(
"."
).
visit
(
node
.
value
)
yield
from
self
.
prec
(
"."
).
visit
(
node
.
value
)
if
isinstance
(
node
.
value
.
type
,
UserType
)
:
if
node
.
value
.
type
.
resolve
().
is_reference
:
yield
"->"
yield
"->"
else
:
else
:
yield
"."
yield
"."
...
...
trans/transpiler/phases/typing/types.py
View file @
d8891f7d
...
@@ -18,6 +18,7 @@ class BaseType(ABC):
...
@@ -18,6 +18,7 @@ class BaseType(ABC):
parents
:
List
[
"BaseType"
]
=
field
(
default_factory
=
list
,
init
=
False
)
parents
:
List
[
"BaseType"
]
=
field
(
default_factory
=
list
,
init
=
False
)
typevars
:
List
[
"TypeVariable"
]
=
field
(
default_factory
=
list
,
init
=
False
)
typevars
:
List
[
"TypeVariable"
]
=
field
(
default_factory
=
list
,
init
=
False
)
def
get_parents
(
self
)
->
List
[
"BaseType"
]:
def
get_parents
(
self
)
->
List
[
"BaseType"
]:
return
self
.
parents
return
self
.
parents
...
@@ -124,6 +125,7 @@ class TypeOperator(BaseType, ABC):
...
@@ -124,6 +125,7 @@ class TypeOperator(BaseType, ABC):
is_protocol
:
bool
=
False
is_protocol
:
bool
=
False
is_protocol_gen
:
ClassVar
[
bool
]
=
False
is_protocol_gen
:
ClassVar
[
bool
]
=
False
match_cache
:
set
[
"TypeOperator"
]
=
field
(
default_factory
=
set
,
init
=
False
)
match_cache
:
set
[
"TypeOperator"
]
=
field
(
default_factory
=
set
,
init
=
False
)
is_reference
:
bool
=
False
@
staticmethod
@
staticmethod
def
make_type
(
name
:
str
):
def
make_type
(
name
:
str
):
...
@@ -421,7 +423,7 @@ class Future(Promise):
...
@@ -421,7 +423,7 @@ class Future(Promise):
class
UserType
(
TypeOperator
):
class
UserType
(
TypeOperator
):
def
__init__
(
self
,
name
:
str
):
def
__init__
(
self
,
name
:
str
):
super
().
__init__
([],
name
=
name
)
super
().
__init__
([],
name
=
name
,
is_reference
=
True
)
def
unify_internal
(
self
,
other
:
"BaseType"
):
def
unify_internal
(
self
,
other
:
"BaseType"
):
if
type
(
self
)
!=
type
(
other
):
if
type
(
self
)
!=
type
(
other
):
...
...
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