Commit 3ddf3249 authored by Tom Niget's avatar Tom Niget

Allow passing type objects around

parent 173e8636
...@@ -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)
......
...@@ -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:
......
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