Skip to content

Commit

Permalink
Minor Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-pino committed Feb 26, 2021
1 parent 51d7e38 commit d1c603f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/semantics/autotype_inferencer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import semantics.visitor as visitor
from parsing.ast import AttrDeclarationNode, ClassDeclarationNode, ProgramNode
from semantics.tools import Context, Scope

class AutotypeInferencer:
def __init__(self, context:Context) -> None:
self.context = context
self.current_type = None
self.errors = []

@visitor.when(ProgramNode)
def visit(self, node:ProgramNode, scope:Scope):
for declaration in node.declarations:
self.visit(declaration, scope.next_child())

scope.reset()

@visitor.when(ClassDeclarationNode)
def visit(self, node, scope):
self.current_type = self.context.get_type(node.id, unpacked=True)
for feature in node.features:
self.visit(feature, scope)

@visitor.when(AttrDeclarationNode)
def visit(self, node, scope):

self.visit(node.expr, scope)
node_expr = node.expr.inferenced_type

0 comments on commit d1c603f

Please sign in to comment.