Commit c8d6c8db authored by Tom Niget's avatar Tom Niget

Add float type and dict type alias

parent 4d9e52e8
......@@ -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:
......
......@@ -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)),
......
......@@ -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")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment