Inheritance: NestedSemanticOperation
        public override Object Perform(Object obj)
        {
            int selectedCaseIndex = -1;
            int state             = (Int32)semanticOperationHandler.GetOperationState(this, "state", INIT);

            if (state == INIT)
            {
                state = INTER;

                if (cases != null)
                {
                    for (int i = 0; i < cases.Count; ++i)
                    {
                        if (semanticOperationHandler.CheckConditionsIfAny(cases[i]))
                        {
                            semanticOperationHandler.SetOperationState(this, "select", i);
                            break;
                        }
                    }
                }
            }

            if (selectedCaseIndex >= 0)
            {
                IfSemanticOperation      aCase = cases[selectedCaseIndex];
                List <SemanticOperation> nestedSemanticActions = aCase.NestedSemanticActionList;
                foreach (SemanticOperation nestedSemanticAction in nestedSemanticActions)
                {
                    semanticOperationHandler.HandleSemanticOperation(nestedSemanticAction, documentParser,
                                                                     sessionScope);
                }
            }
            else
            {
                if (otherwise != null)
                {
                    List <SemanticOperation> otherwiseActions = otherwise.NestedSemanticActionList;
                    foreach (SemanticOperation action in otherwiseActions)
                    {
                        semanticOperationHandler.HandleSemanticOperation(action, documentParser, sessionScope);
                    }
                }
            }

            return(null);
        }
示例#2
0
        public void HandleIf(IfSemanticOperation operation, DocumentParser parser, SemanticsGlobalScope infoCollector)
        {
            // conditions have been checked in handleSemanticAction()

            try
            {
                SetOperationState(operation, "state", SemanticOperation.INTER);
                List <SemanticOperation> nestedSemanticActions = operation.NestedSemanticActionList;
                foreach (SemanticOperation nestedSemanticAction in nestedSemanticActions)
                {
                    HandleSemanticOperation(nestedSemanticAction, parser, infoCollector);
                }
            }
            catch (Exception e)
            {
                throw new IfOperationException(e, operation, semanticOperationVariableMap);
            }
        }