NodeBase CreateLogicalNode(LogicalExpression exp)
		{
			NodeBase node = null;

			if (exp.HasUnary())
			{
				node = new LogicalNode(m_Container);		
				((LogicalNode)node).m_LogicalType = LogicalOperatorType.NOT;			
				node.AddChild(CreateLogicalNode(exp.GetUnary().GetLogicalExpression()));
			}
			else if (exp.HasRelational())
			{
				node = new RelationalNode(m_Container);
				RelationalOperator op = exp.GetRelational().GetRelationalOperator();
				if (op.HasEquals())
					((RelationalNode)node).m_RelationType = RelationType.EQUAL;
				else if (op.HasGreaterThan())
					((RelationalNode)node).m_RelationType = RelationType.GREATERTHAN;
				else if (op.HasGreaterThanOrEquals())
					((RelationalNode)node).m_RelationType = RelationType.GREATERTHANOREQUAL;
				else if (op.HasLessThan())
					((RelationalNode)node).m_RelationType = RelationType.LESSTHAN;
				else if (op.HasLessThanOrEquals())
					((RelationalNode)node).m_RelationType = RelationType.LESSTHANOREQUAL;
				else if (op.HasNotEquals())
					((RelationalNode)node).m_RelationType = RelationType.NOTEQUAL;
				
				node.AddChild(CreateArithmeticNode(exp.GetRelational().GetLHSArithmeticExpression()));
				node.AddChild(CreateArithmeticNode(exp.GetRelational().GetRHSArithmeticExpression()));
			}
			else if (exp.HasLogical())
			{
				node = new LogicalNode(m_Container);
				
				if (exp.GetLogical().GetLogicalOperator().HasAnd())
					((LogicalNode)node).m_LogicalType = LogicalOperatorType.AND;
				else
					((LogicalNode)node).m_LogicalType = LogicalOperatorType.OR;
				
				node.AddChild(CreateLogicalNode(exp.GetLogical().GetLHSLogicalExpression()));
				node.AddChild(CreateLogicalNode(exp.GetLogical().GetRHSLogicalExpression()));
			}
			else if (exp.HasValue())
			{
				if (exp.GetValue().HasConstant())
				{
					node = new ConstantNode(m_Container);
					((ConstantNode)node).m_ConstantValue = exp.GetValue().GetConstant().GetBoolean().Value;
					((ConstantNode)node).m_ConstantType = VariableType.BOOLEAN;
				}
				else
				{
					node = new VariableNode(m_Container);
					
					((VariableNode)node).m_VariableName = exp.GetValue().GetVariable().GetName().Value;
					((VariableNode)node).m_VariableType = VariableType.BOOLEAN;
				}
			}
			
			return node;
		}
Example #2
0
        NodeBase CreateLogicalNode(LogicalExpression exp)
        {
            NodeBase node = null;

            if (exp.HasUnary())
            {
                node = new LogicalNode(m_Container);
                ((LogicalNode)node).m_LogicalType = LogicalOperatorType.NOT;
                node.AddChild(CreateLogicalNode(exp.GetUnary().GetLogicalExpression()));
            }
            else if (exp.HasRelational())
            {
                node = new RelationalNode(m_Container);
                RelationalOperator op = exp.GetRelational().GetRelationalOperator();
                if (op.HasEquals())
                {
                    ((RelationalNode)node).m_RelationType = RelationType.EQUAL;
                }
                else if (op.HasGreaterThan())
                {
                    ((RelationalNode)node).m_RelationType = RelationType.GREATERTHAN;
                }
                else if (op.HasGreaterThanOrEquals())
                {
                    ((RelationalNode)node).m_RelationType = RelationType.GREATERTHANOREQUAL;
                }
                else if (op.HasLessThan())
                {
                    ((RelationalNode)node).m_RelationType = RelationType.LESSTHAN;
                }
                else if (op.HasLessThanOrEquals())
                {
                    ((RelationalNode)node).m_RelationType = RelationType.LESSTHANOREQUAL;
                }
                else if (op.HasNotEquals())
                {
                    ((RelationalNode)node).m_RelationType = RelationType.NOTEQUAL;
                }

                node.AddChild(CreateArithmeticNode(exp.GetRelational().GetLHSArithmeticExpression()));
                node.AddChild(CreateArithmeticNode(exp.GetRelational().GetRHSArithmeticExpression()));
            }
            else if (exp.HasLogical())
            {
                node = new LogicalNode(m_Container);

                if (exp.GetLogical().GetLogicalOperator().HasAnd())
                {
                    ((LogicalNode)node).m_LogicalType = LogicalOperatorType.AND;
                }
                else
                {
                    ((LogicalNode)node).m_LogicalType = LogicalOperatorType.OR;
                }

                node.AddChild(CreateLogicalNode(exp.GetLogical().GetLHSLogicalExpression()));
                node.AddChild(CreateLogicalNode(exp.GetLogical().GetRHSLogicalExpression()));
            }
            else if (exp.HasValue())
            {
                if (exp.GetValue().HasConstant())
                {
                    node = new ConstantNode(m_Container);
                    ((ConstantNode)node).m_ConstantValue = exp.GetValue().GetConstant().GetBoolean().Value;
                    ((ConstantNode)node).m_ConstantType  = VariableType.BOOLEAN;
                }
                else
                {
                    node = new VariableNode(m_Container);

                    ((VariableNode)node).m_VariableName = exp.GetValue().GetVariable().GetName().Value;
                    ((VariableNode)node).m_VariableType = VariableType.BOOLEAN;
                }
            }

            return(node);
        }