Ejemplo n.º 1
0
        public List <long> Evaluate(CDRelationshipPool RelationshipSpace, EXEScope Scope)
        {
            List <long>        Result        = null;
            EXEReferenceHandle StartVariable = Scope.FindReferenceHandleByName(this.StartingVariable);

            if (StartVariable != null && this.RelationshipSpecification.Any())
            {
                List <long> CurrentIds = StartVariable.GetReferencedIds();
                if (CurrentIds == null)
                {
                    return(null);
                }

                String CurrentClass = StartVariable.ClassName;
                foreach (EXERelationshipLink RelationshipLink in this.RelationshipSpecification)
                {
                    if (CurrentIds == null || !CurrentIds.Any())
                    {
                        break;
                    }
                    CurrentIds   = RelationshipLink.RetrieveIds(CurrentIds, CurrentClass, RelationshipSpace);
                    CurrentClass = RelationshipLink.ClassName;
                }
                Result = CurrentIds;
            }
            return(Result);
        }
Ejemplo n.º 2
0
        public bool VerifyReferences(EXEScope Scope, CDClassPool ExecutionSpace)
        {
            bool Result = false;
            EXEExpressionEvaluator      Evaluator       = new EXEExpressionEvaluator();
            EXEEvaluatorHandleOperators HandleEvaluator = new EXEEvaluatorHandleOperators();
            EXEReferenceEvaluator       AccessEvaluator = new EXEReferenceEvaluator();

            // If we just calculate with ints, reals, bools, strings
            if (Evaluator.IsSimpleOperator(this.Operation))
            {
                foreach (EXEASTNode Operand in this.Operands)
                {
                    if (!Operand.VerifyReferences(Scope, ExecutionSpace))
                    {
                        return(false);
                    }
                }
                Result = true;
            }
            // If we have handle operators
            else if (HandleEvaluator.IsHandleOperator(this.Operation))
            {
                if (this.Operands.Count() == 1 && Scope.FindReferenceHandleByName(((EXEASTNodeLeaf)this.Operands[0]).GetNodeValue()) != null)
                {
                    Result = true;
                }
            }
            // If we have access operator - we either access attribute or have decimal number. There are always 2 operands
            else if (".".Equals(this.Operation) && this.Operands.Count == 2)
            {
                if (EXETypes.IntegerTypeName.Equals(EXETypes.DetermineVariableType("", this.Operands[0].GetNodeValue())) &&
                    EXETypes.IntegerTypeName.Equals(EXETypes.DetermineVariableType("", this.Operands[1].GetNodeValue()))
                    )
                {
                    Result = true;
                }
                else if (EXETypes.ReferenceTypeName.Equals(EXETypes.DetermineVariableType("", this.Operands[0].GetNodeValue())) &&
                         EXETypes.ReferenceTypeName.Equals(EXETypes.DetermineVariableType("", this.Operands[1].GetNodeValue()))
                         )
                {
                    EXEReferencingVariable Variable = Scope.FindReferencingVariableByName(this.Operands[0].GetNodeValue());
                    if (Variable == null)
                    {
                        return(false);
                    }
                    CDClass Class = ExecutionSpace.getClassByName(Variable.ClassName);
                    if (Class == null)
                    {
                        return(false);
                    }
                    CDAttribute Attribute = Class.GetAttributeByName(this.Operands[1].GetNodeValue());
                    if (Attribute == null)
                    {
                        return(false);
                    }
                    CDClassInstance Instance = Variable.RetrieveReferencedClassInstance(ExecutionSpace);
                    if (Instance == null)
                    {
                        return(false);
                    }
                    Result = true;
                }
            }
            return(Result);
        }