Esempio n. 1
0
        /// <summary>
        /// A private helper method to check the type of an IExpressionNode.
        /// </summary>
        /// <returns>An IProperty of the operation's type.</returns>
        /// <param name="node">Node.</param>
        private IProperty VisitOperationNode(IExpressionNode node)
        {
            // evaluate the IExpressionNode's expressions
            IProperty evaluationType = getEvaluation(node.GetExpressions());

            // check that the operation is legit for this type
            if (SemanticAnalysisConstants.LEGIT_OPERATIONS.ContainsKey(evaluationType.GetTokenType()) &&
                SemanticAnalysisConstants.LEGIT_OPERATIONS [evaluationType.GetTokenType()].ContainsKey(node.Operation))
            {
                // if it's a logical operation, never mind the original type, the evaluation type is boolean
                if (SemanticAnalysisConstants.LOGICAL_OPERATIONS.ContainsKey(node.Operation))
                {
                    return(new BooleanProperty(SemanticAnalysisConstants.DEFAULT_BOOL_VALUE));
                }
                return(evaluationType);
            }
            return(new ErrorProperty());
        }