Commit 8c58c8d9 authored by Tom Niget's avatar Tom Niget

Add helper class for displaying synthesized annotations in unparsed code

parent f23605f5
......@@ -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.types import BaseType, TypeVariable, FunctionType, \
Promise, TY_NONE, PromiseKind, TupleType, UserType, TypeType, ModuleType
from transpiler.phases.utils import PlainBlock
from transpiler.phases.utils import PlainBlock, AnnotationName
@dataclass
......@@ -141,7 +141,7 @@ class ScoperBlockVisitor(ScoperVisitor):
def annotate_arg(self, arg: ast.arg) -> BaseType:
if arg.annotation is None:
res = TypeVariable()
arg.annotation = ast.Name(id=str(res), ctx=ast.Load())
arg.annotation = AnnotationName(res)
return res
else:
return self.visit_annotation(arg.annotation)
......
......@@ -31,3 +31,14 @@ class NodeVisitorSeq:
@dataclass
class PlainBlock(ast.stmt):
body: list[ast.stmt]
@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
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