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
c8d6c8db
Commit
c8d6c8db
authored
Jul 07, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add float type and dict type alias
parent
4d9e52e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
2 deletions
+7
-2
trans/transpiler/phases/emit_cpp/__init__.py
trans/transpiler/phases/emit_cpp/__init__.py
+3
-1
trans/transpiler/phases/typing/__init__.py
trans/transpiler/phases/typing/__init__.py
+3
-1
trans/transpiler/phases/typing/types.py
trans/transpiler/phases/typing/types.py
+1
-0
No files found.
trans/transpiler/phases/emit_cpp/__init__.py
View file @
c8d6c8db
...
...
@@ -8,7 +8,7 @@ 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
,
\
TypeType
,
TypeOperator
TypeType
,
TypeOperator
,
TY_FLOAT
from
transpiler.utils
import
UnsupportedNodeError
class
UniversalVisitor
:
...
...
@@ -53,6 +53,8 @@ class NodeVisitor(UniversalVisitor):
node
=
node
.
resolve
()
if
node
is
TY_INT
:
yield
"int"
elif
node
is
TY_FLOAT
:
yield
"double"
elif
node
is
TY_BOOL
:
yield
"bool"
elif
node
is
TY_NONE
:
...
...
trans/transpiler/phases/typing/__init__.py
View file @
c8d6c8db
...
...
@@ -5,7 +5,7 @@ from transpiler.phases.typing.scope import VarKind, VarDecl, ScopeKind, Scope
from
transpiler.phases.typing.stdlib
import
PRELUDE
,
StdlibVisitor
from
transpiler.phases.typing.types
import
TY_TYPE
,
TY_INT
,
TY_STR
,
TY_BOOL
,
TY_COMPLEX
,
TY_NONE
,
FunctionType
,
\
TypeVariable
,
CppType
,
PyList
,
TypeType
,
Forked
,
Task
,
Future
,
PyIterator
,
TupleType
,
TypeOperator
,
BaseType
,
\
ModuleType
,
TY_BYTES
ModuleType
,
TY_BYTES
,
TY_FLOAT
,
PyDict
PRELUDE
.
vars
.
update
({
# "int": VarDecl(VarKind.LOCAL, TY_TYPE, TY_INT),
...
...
@@ -18,6 +18,7 @@ PRELUDE.vars.update({
# "CppType": VarDecl(VarKind.LOCAL, TY_TYPE, CppType),
# "list": VarDecl(VarKind.LOCAL, TY_TYPE, PyList),
"int"
:
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
TY_INT
)),
"float"
:
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
TY_FLOAT
)),
"str"
:
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
TY_STR
)),
"bytes"
:
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
TY_BYTES
)),
"bool"
:
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
TY_BOOL
)),
...
...
@@ -27,6 +28,7 @@ PRELUDE.vars.update({
"TypeVar"
:
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
TypeVariable
)),
"CppType"
:
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
CppType
)),
"list"
:
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
PyList
)),
"dict"
:
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
PyDict
)),
"Forked"
:
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
Forked
)),
"Task"
:
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
Task
)),
"Future"
:
VarDecl
(
VarKind
.
LOCAL
,
TypeType
(
Future
)),
...
...
trans/transpiler/phases/typing/types.py
View file @
c8d6c8db
...
...
@@ -305,6 +305,7 @@ class TypeType(TypeOperator):
TY_TYPE
=
TypeOperator
.
make_type
(
"type"
)
TY_INT
=
TypeOperator
.
make_type
(
"int"
)
TY_FLOAT
=
TypeOperator
.
make_type
(
"float"
)
TY_STR
=
TypeOperator
.
make_type
(
"str"
)
TY_BYTES
=
TypeOperator
.
make_type
(
"bytes"
)
TY_BOOL
=
TypeOperator
.
make_type
(
"bool"
)
...
...
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