Exemple #1
0
        public TypeChecker(SymbolTableManager symbolTableManager)
        {
            _exprTypeVisitor = new ExprTypeVisitor(symbolTableManager);

            _symTableManager = symbolTableManager;
            _programAST      = symbolTableManager.ProgramAST;
        }
Exemple #2
0
        public TypeInferer(SymbolTableManager symTableManager)
        {
            _symTableManager         = symTableManager;
            _identifiersToBeInferred = symTableManager.IdentifiersToBeInferred;

            Func <IdentifierInfo, TypeAST> GetVariableTypeFunc = (IdentifierInfo identInfo) =>
            {
                var identToBeInfered = _identifiersToBeInferred.Find(x => x.identInfo == identInfo);

                if (identToBeInfered == null)
                {
                    throw new Exception("Undeclared identifier " + identInfo);
                }

                return(_typeVisitor.GetAstNodeType(identToBeInfered.file, identInfo.scopeId, identInfo.position, identToBeInfered.expr, identInfo.isConstant));
            };

            _typeVisitor = new ExprTypeVisitor(symTableManager, GetVariableTypeFunc);
        }