Add initial typechecker for AST #2
@ -89,7 +89,7 @@ exampleMethodCallAndAssignmentFail = Block [
|
|||||||
LocalVariableDeclaration (VariableDeclaration "Person" "bob" (Just (StatementExpressionExpression (ConstructorCall "Person" [IntegerLiteral 30])))),
|
LocalVariableDeclaration (VariableDeclaration "Person" "bob" (Just (StatementExpressionExpression (ConstructorCall "Person" [IntegerLiteral 30])))),
|
||||||
LocalVariableDeclaration (VariableDeclaration "int" "age" (Just (StatementExpressionExpression (MethodCall (Reference "bob") "getAge" [])))),
|
LocalVariableDeclaration (VariableDeclaration "int" "age" (Just (StatementExpressionExpression (MethodCall (Reference "bob") "getAge" [])))),
|
||||||
StatementExpressionStatement (MethodCall (Reference "bob") "setAge" [IntegerLiteral 30]),
|
StatementExpressionStatement (MethodCall (Reference "bob") "setAge" [IntegerLiteral 30]),
|
||||||
StatementExpressionStatement (Assignment (Reference "age") (Reference "age"))
|
StatementExpressionStatement (Assignment (Reference "a") (Reference "age"))
|
||||||
]
|
]
|
||||||
|
|
||||||
exampleNameResolutionAssignment :: Statement
|
exampleNameResolutionAssignment :: Statement
|
||||||
|
@ -295,12 +295,6 @@ unifyReturnTypes dt1 dt2
|
|||||||
| dt1 == dt2 = dt1
|
| dt1 == dt2 = dt1
|
||||||
| otherwise = "Object"
|
| otherwise = "Object"
|
||||||
|
|
||||||
lookupType :: Identifier -> [(Identifier, DataType)] -> Maybe DataType
|
|
||||||
lookupType id symtab =
|
|
||||||
case lookup id symtab of
|
|
||||||
Just t -> Just t
|
|
||||||
Nothing -> Nothing
|
|
||||||
|
|
||||||
resolveResultType :: DataType -> DataType -> DataType
|
resolveResultType :: DataType -> DataType -> DataType
|
||||||
resolveResultType "char" "char" = "char"
|
resolveResultType "char" "char" = "char"
|
||||||
resolveResultType "int" "int" = "int"
|
resolveResultType "int" "int" = "int"
|
||||||
|
Loading…
Reference in New Issue
Block a user