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
8c58c8d9
Commit
8c58c8d9
authored
Aug 10, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper class for displaying synthesized annotations in unparsed code
parent
f23605f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
trans/transpiler/phases/typing/block.py
trans/transpiler/phases/typing/block.py
+2
-2
trans/transpiler/phases/utils.py
trans/transpiler/phases/utils.py
+12
-1
No files found.
trans/transpiler/phases/typing/block.py
View file @
8c58c8d9
...
@@ -11,7 +11,7 @@ from transpiler.phases.typing.class_ import ScoperClassVisitor
...
@@ -11,7 +11,7 @@ from transpiler.phases.typing.class_ import ScoperClassVisitor
from
transpiler.phases.typing.scope
import
VarDecl
,
VarKind
,
ScopeKind
,
Scope
from
transpiler.phases.typing.scope
import
VarDecl
,
VarKind
,
ScopeKind
,
Scope
from
transpiler.phases.typing.types
import
BaseType
,
TypeVariable
,
FunctionType
,
\
from
transpiler.phases.typing.types
import
BaseType
,
TypeVariable
,
FunctionType
,
\
Promise
,
TY_NONE
,
PromiseKind
,
TupleType
,
UserType
,
TypeType
,
ModuleType
Promise
,
TY_NONE
,
PromiseKind
,
TupleType
,
UserType
,
TypeType
,
ModuleType
from
transpiler.phases.utils
import
PlainBlock
from
transpiler.phases.utils
import
PlainBlock
,
AnnotationName
@
dataclass
@
dataclass
...
@@ -141,7 +141,7 @@ class ScoperBlockVisitor(ScoperVisitor):
...
@@ -141,7 +141,7 @@ class ScoperBlockVisitor(ScoperVisitor):
def
annotate_arg
(
self
,
arg
:
ast
.
arg
)
->
BaseType
:
def
annotate_arg
(
self
,
arg
:
ast
.
arg
)
->
BaseType
:
if
arg
.
annotation
is
None
:
if
arg
.
annotation
is
None
:
res
=
TypeVariable
()
res
=
TypeVariable
()
arg
.
annotation
=
ast
.
Name
(
id
=
str
(
res
),
ctx
=
ast
.
Load
()
)
arg
.
annotation
=
AnnotationName
(
res
)
return
res
return
res
else
:
else
:
return
self
.
visit_annotation
(
arg
.
annotation
)
return
self
.
visit_annotation
(
arg
.
annotation
)
...
...
trans/transpiler/phases/utils.py
View file @
8c58c8d9
...
@@ -30,4 +30,15 @@ class NodeVisitorSeq:
...
@@ -30,4 +30,15 @@ class NodeVisitorSeq:
@
dataclass
@
dataclass
class
PlainBlock
(
ast
.
stmt
):
class
PlainBlock
(
ast
.
stmt
):
body
:
list
[
ast
.
stmt
]
body
:
list
[
ast
.
stmt
]
\ No newline at end of file
@
dataclass
class
AnnotationName
:
inner
:
"transpiler.phases.typing.types.BaseType"
@
property
def
id
(
self
):
return
str
(
self
.
inner
)
AnnotationName
.
__name__
=
"Name"
\ No newline at end of file
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