Exemple #1
0
        protected override bool TypeChecking(List <Error> errors, SymbolTable symbolTable)
        {
            TypeExpression thenType     = ThenInstruction.ReturnType;
            TypeExpression expectedType = ExpectedType();

            if (thenType.IsEquivalent(expectedType))
            {
                ReturnType = (expectedType.PrimitiveType is BuiltInType) ? expectedType.PrimitiveType : expectedType;
                return(true);
            }
            string message = string.Format("Could not convert type : '{0}' to '{1}'. {2}", thenType, expectedType, TypeMessage);

            errors.Add(new Error(message, ThenInstruction.Line, ThenInstruction.CharPositionInLine));
            ReturnType = TypeExpression.ErrorType;
            return(false);
        }