当前位置: 首页>>代码示例>>C#>>正文


C# Interpreter.ExplanationPart类代码示例

本文整理汇总了C#中DataDictionary.Interpreter.ExplanationPart的典型用法代码示例。如果您正苦于以下问题:C# ExplanationPart类的具体用法?C# ExplanationPart怎么用?C# ExplanationPart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExplanationPart类属于DataDictionary.Interpreter命名空间,在下文中一共展示了ExplanationPart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertInListChange

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="context"></param>
 /// <param name="statement"></param>
 /// <param name="variable"></param>
 /// <param name="explanation"></param>
 public InsertInListChange(InterpretationContext context, InsertStatement statement, IVariable variable, ExplanationPart explanation)
     : base(variable, null, null)
 {
     Context = context;
     Statement = statement;
     Explanation = explanation;
 }
开发者ID:ERTMSSolutions,项目名称:ERTMSFormalSpecs,代码行数:14,代码来源:InsertInListChange.cs

示例2: Evaluate

        /// <summary>
        ///     Provides the value of the function
        /// </summary>
        /// <param name="context"></param>
        /// <param name="actuals">the actual parameters values</param>
        /// <param name="explain"></param>
        /// <returns>The value for the function application</returns>
        public override IValue Evaluate(InterpretationContext context, Dictionary<Actual, IValue> actuals,
            ExplanationPart explain)
        {
            IValue retVal = null;

            int token = context.LocalScope.PushContext();
            AssignParameters(context, actuals);

            ListValue value = context.FindOnStack(Collection) as ListValue;
            if (value != null)
            {
                Collection collectionType = value.Type as Collection;
                if (collectionType != null && collectionType.Type != null)
                {
                    Type elementType = collectionType.Type;

                    if (value.Val.Count >= collectionType.getMaxSize())
                    {
                        AddError("Cannot allocate element in list : list full");
                    }
                    else
                    {
                        retVal = elementType.DefaultValue;
                        value.Val.Add(retVal);
                    }
                }
            }
            context.LocalScope.PopContext(token);

            return retVal;
        }
开发者ID:GautierBerck,项目名称:ERTMSFormalSpecs,代码行数:38,代码来源:Allocate.cs

示例3: SetExplanation

        /// <summary>
        ///     Sets the explanation for this explain box
        /// </summary>
        /// <param name="explanation"></param>
        public void SetExplanation(ExplanationPart explanation)
        {
            Explanation = explanation;

            explainTreeView.Nodes.Clear();
            if (explanation != null)
            {
                ExplainTreeNode node = new ExplainTreeNode(explanation);
                node.UpdateText();
                InnerSetExplanation(explanation, node, 0);
                explainTreeView.Nodes.Add(node);
            }
        }
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:17,代码来源:ExplainBox.cs

示例4: Evaluate

        /// <summary>
        ///     Provides the value of the function
        /// </summary>
        /// <param name="context"></param>
        /// <param name="actuals">the actual parameters values</param>
        /// <param name="explain"></param>
        /// <returns>The value for the function application</returns>
        public override IValue Evaluate(InterpretationContext context, Dictionary<Actual, IValue> actuals,
            ExplanationPart explain)
        {
            IValue retVal = EFSSystem.BoolType.False;

            int token = context.LocalScope.PushContext();
            AssignParameters(context, actuals);

            if (context.FindOnStack(Element).Value != EFSSystem.EmptyValue)
            {
                retVal = EFSSystem.BoolType.True;
            }

            context.LocalScope.PopContext(token);

            return retVal;
        }
开发者ID:nikiforovandrey,项目名称:ERTMSFormalSpecs,代码行数:24,代码来源:Available.cs

示例5: Evaluate

        /// <summary>
        ///     Provides the value of the function
        /// </summary>
        /// <param name="context"></param>
        /// <param name="actuals">the actual parameters values</param>
        /// <param name="explain"></param>
        /// <returns>The value for the function application</returns>
        public override IValue Evaluate(InterpretationContext context, Dictionary<Actual, IValue> actuals,
            ExplanationPart explain)
        {
            IValue retVal = null;

            int token = context.LocalScope.PushContext();
            AssignParameters(context, actuals);

            DoubleValue value = context.findOnStack(Value).Value as DoubleValue;
            if (value != null)
            {
                int res = (int) Math.Round(value.Val);
                retVal = new IntValue(ReturnType, res);
            }

            context.LocalScope.PopContext(token);

            return retVal;
        }
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:26,代码来源:DoubleToInteger.cs

示例6: Evaluate

        /// <summary>
        ///     Provides the value of the function
        /// </summary>
        /// <param name="context"></param>
        /// <param name="actuals">the actual parameters values</param>
        /// <param name="explain"></param>
        /// <returns>The value for the function application</returns>
        public override IValue Evaluate(InterpretationContext context, Dictionary<Actual, IValue> actuals,
            ExplanationPart explain)
        {
            IValue retVal = null;

            int token = context.LocalScope.PushContext();
            AssignParameters(context, actuals);
            BoolValue val = context.findOnStack(Value).Value as BoolValue;
            if (val != null)
            {
                if (val.Val)
                {
                    retVal = EFSSystem.BoolType.False;
                }
                else
                {
                    retVal = EFSSystem.BoolType.True;
                }
            }
            context.LocalScope.PopContext(token);

            return retVal;
        }
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:30,代码来源:Not.cs

示例7: Evaluate

        /// <summary>
        ///     Provides the value of the function
        /// </summary>
        /// <param name="context"></param>
        /// <param name="actuals">the actual parameters values</param>
        /// <param name="explain"></param>
        /// <returns>The value for the function application</returns>
        public override IValue Evaluate(InterpretationContext context, Dictionary<Actual, IValue> actuals,
            ExplanationPart explain)
        {
            IValue retVal = null;

            int token = context.LocalScope.PushContext();
            AssignParameters(context, actuals);

            ListValue value = context.FindOnStack(Collection) as ListValue;
            if (value != null)
            {
                Collection collectionType = value.Type as Collection;
                if (collectionType != null && collectionType.Type != null)
                {
                    Type elementType = collectionType.Type;

                    int i = 0;
                    while (i < value.Val.Count && value.Val[i] != EFSSystem.EmptyValue)
                    {
                        i += 1;
                    }

                    if (i < value.Val.Count)
                    {
                        retVal = elementType.DefaultValue;
                        value.Val[i] = retVal;
                    }
                    else
                    {
                        AddError("Cannot allocate element in list : list full");
                    }
                }
            }
            context.LocalScope.PopContext(token);

            return retVal;
        }
开发者ID:nikiforovandrey,项目名称:ERTMSFormalSpecs,代码行数:44,代码来源:Allocate.cs

示例8: AddSubExplanation

 /// <summary>
 ///     Adds a sub explanation for the explain provided as parameter
 /// </summary>
 /// <param name="explain"></param>
 /// <param name="subExplain"></param>
 public static void AddSubExplanation(ExplanationPart explain, ExplanationPart subExplain)
 {
     if (explain != null)
     {
         explain.SubExplanations.Add(subExplain);
     }
 }
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:12,代码来源:ExplanationPart.cs

示例9: CreateNamedSubExplanation

        /// <summary>
        ///     Creates a sub explanation for the explain provided as parameter
        /// </summary>
        /// <param name="explain"></param>
        /// <param name="message"></param>
        /// <param name="leftPart"></param>
        /// <returns></returns>
        public static ExplanationPart CreateNamedSubExplanation(ExplanationPart explain, string message, object leftPart)
        {
            ExplanationPart retVal = null;

            if (explain != null)
            {
                retVal = new ExplanationPart(explain.Element, message);
                retVal.LeftPart = leftPart;
                explain.SubExplanations.Add(retVal);
            }

            return retVal;
        }
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:20,代码来源:ExplanationPart.cs

示例10: GetCalled

        /// <summary>
        ///     Provides the callable that is called by this expression
        /// </summary>
        /// <param name="context"></param>
        /// <param name="explain"></param>
        /// <returns></returns>
        public override ICallable GetCalled(InterpretationContext context, ExplanationPart explain)
        {
            ICallable retVal = null;

            if (Term != null)
            {
                retVal = Term.GetCalled(context, explain);
            }
            else if (Expression != null)
            {
                retVal = Expression.GetCalled(context, explain);
            }

            // TODO : Investigate why this
            if (retVal == null)
            {
                retVal = GetValue(context, explain) as ICallable;
            }

            return retVal;
        }
开发者ID:GautierBerck,项目名称:ERTMSFormalSpecs,代码行数:27,代码来源:UnaryExpression.cs

示例11: GetValue

        /// <summary>
        ///     Provides the value associated to this Expression
        /// </summary>
        /// <param name="context">The context on which the value must be found</param>
        /// <param name="explain">The explanation to fill, if any</param>
        /// <returns></returns>
        protected internal override IValue GetValue(InterpretationContext context, ExplanationPart explain)
        {
            IValue retVal = null;

            if (Term != null)
            {
                retVal = Term.GetValue(context, explain);
            }
            else
            {
                if (Not.Equals(UnaryOp))
                {
                    BoolValue b = Expression.GetValue(context, explain) as BoolValue;
                    if (b != null)
                    {
                        if (b.Val)
                        {
                            retVal = EfsSystem.Instance.BoolType.False;
                        }
                        else
                        {
                            retVal = EfsSystem.Instance.BoolType.True;
                        }
                    }
                    else
                    {
                        AddError("Expression " + Expression + " does not evaluate to boolean");
                    }
                }
                else if (Minus.Equals(UnaryOp))
                {
                    IValue val = Expression.GetValue(context, explain);
                    IntValue intValue = val as IntValue;
                    if (intValue != null)
                    {
                        retVal = new IntValue(intValue.Type, -intValue.Val);
                    }
                    else
                    {
                        DoubleValue doubleValue = val as DoubleValue;
                        if (doubleValue != null)
                        {
                            retVal = new DoubleValue(doubleValue.Type, -doubleValue.Val);
                        }
                    }

                    if (retVal == null)
                    {
                        AddError("Cannot negate value for " + Expression);
                    }
                }
                else
                {
                    retVal = Expression.GetValue(context, explain);
                }
            }

            return retVal;
        }
开发者ID:GautierBerck,项目名称:ERTMSFormalSpecs,代码行数:65,代码来源:UnaryExpression.cs

示例12: CreateSurfaceForParameters

        /// <summary>
        ///     Provides the surface of this function if it has been statically defined
        /// </summary>
        /// <param name="context">the context used to create the graph</param>
        /// <param name="xParameter">The parameter used for the X axis</param>
        /// <param name="yParameter">The parameter used for the Y axis</param>
        /// <param name="explain"></param>
        /// <returns></returns>
        public virtual Surface CreateSurfaceForParameters(InterpretationContext context, Parameter xParameter,
            Parameter yParameter, ExplanationPart explain)
        {
            Surface retVal = Surface;

            if (retVal == null)
            {
                if (xParameter != null)
                {
                    if (yParameter != null)
                    {
                        if (Cases.Count > 0)
                        {
                            retVal = new Surface(xParameter, yParameter);

                            foreach (Case cas in Cases)
                            {
                                if (PreconditionSatisfied(context, cas, xParameter, yParameter, explain))
                                {
                                    Surface surface = cas.Expression.CreateSurface(context, xParameter, yParameter,
                                        explain);
                                    if (surface != null)
                                    {
                                        Parameter parameter = null;
                                        surface = ReduceSurface(context, cas, surface, out parameter, explain);

                                        if (parameter == null || parameter == surface.XParameter)
                                        {
                                            retVal.MergeX(surface);
                                        }
                                        else
                                        {
                                            retVal = Surface.MergeY(retVal, surface);
                                        }
                                    }
                                    else
                                    {
                                        AddError("Cannot create surface for expression " + cas.ExpressionText);
                                        retVal = null;
                                        break;
                                    }
                                }
                            }
                        }
                        else if (Graph != null)
                        {
                            // The function is defined by a graph
                            // Extend it to a surface
                            // TODO: Check the right parameter
                            retVal = Graph.ToSurfaceX();
                            retVal.XParameter = xParameter;
                            retVal.YParameter = yParameter;
                        }
                        else
                        {
                            AddError("cannot create surface for function " + Name + " with given parameters");
                        }
                    }
                    else
                    {
                        // Function with 1 parameter that ranges over the Xaxis
                        retVal = new Surface(xParameter, yParameter);
                        Graph graph = CreateGraphForParameter(context, xParameter, explain);
                        foreach (Graph.Segment segment in graph.Segments)
                        {
                            Graph newGraph = Graph.createGraph(segment.Expression.V0);
                            Surface.Segment newSegment = new Surface.Segment(segment.Start, segment.End, newGraph);
                            retVal.AddSegment(newSegment);
                        }
                    }
                }
                else if (yParameter != null)
                {
                    // Function with 1 parameter that ranges over the Yaxis
                    retVal = new Surface(xParameter, yParameter);
                    Graph graph = CreateGraphForParameter(context, yParameter, explain);
                    Surface.Segment segment = new Surface.Segment(0, double.MaxValue, graph);
                    retVal.AddSegment(segment);
                }
                else
                {
                    AddError("Invalid parameters for surface creation");
                }
            }

            if (retVal != null)
            {
                retVal.XParameter = xParameter;
                retVal.YParameter = yParameter;
            }

            return retVal;
//.........这里部分代码省略.........
开发者ID:nikiforovandrey,项目名称:ERTMSFormalSpecs,代码行数:101,代码来源:Function.cs

示例13: CreateSurface

        /// <summary>
        ///     Provides the surface of this function if it has been statically defined
        /// </summary>
        /// <param name="context">the context used to create the surface</param>
        /// <param name="xParam">The X axis of this surface</param>
        /// <param name="yParam">The Y axis of this surface</param>
        /// <param name="explain"></param>
        /// <returns>The surface which corresponds to this expression</returns>
        public override Surface CreateSurface(InterpretationContext context, Parameter xParam, Parameter yParam,
            ExplanationPart explain)
        {
            Surface retVal = base.CreateSurface(context, xParam, yParam, explain);

            if (Term != null)
            {
                retVal = Surface.createSurface(xParam, yParam, GetValue(context, explain), explain);
            }
            else if (Expression != null)
            {
                if (UnaryOp == null)
                {
                    retVal = Expression.CreateSurface(context, xParam, yParam, explain);
                }
                else
                {
                    if (UnaryOp == Minus)
                    {
                        retVal = Expression.CreateSurface(context, xParam, yParam, explain);
                        retVal.Negate();
                    }
                    else
                    {
                        AddError("Cannot create surface with unary op " + UnaryOp);
                    }
                }
            }
            retVal.XParameter = xParam;
            retVal.YParameter = yParam;

            return retVal;
        }
开发者ID:GautierBerck,项目名称:ERTMSFormalSpecs,代码行数:41,代码来源:UnaryExpression.cs

示例14: Evaluate

        /// <summary>
        ///     Provides the value of the function
        /// </summary>
        /// <param name="context"></param>
        /// <param name="actuals">the actual parameters values</param>
        /// <param name="explain"></param>
        /// <returns>The value for the function application</returns>
        public override IValue Evaluate(InterpretationContext context, Dictionary<Actual, IValue> actuals,
            ExplanationPart explain)
        {
            IValue retVal = null;

            int token = context.LocalScope.PushContext();
            AssignParameters(context, actuals);

            StructureValue startDate = context.findOnStack(StartDate).Value as StructureValue;
            if (startDate != null)
            {
                int year = GetIntValue(startDate, "Year");
                int month = GetIntValue(startDate, "Month");
                int day = GetIntValue(startDate, "Day");
                int hour = GetIntValue(startDate, "Hour");
                int minute = GetIntValue(startDate, "Minute");
                int second = GetIntValue(startDate, "Second");
                int tts = GetIntValue(startDate, "TTS");

                DoubleValue addedTime = context.findOnStack(Increment).Value as DoubleValue;
                if (addedTime != null)
                {
                    DateTime start = new DateTime(year, month, day, hour, minute, second, tts);
                    DateTime currentTime = start.AddSeconds((double) addedTime.Val);

                    retVal = GetEFSDate(currentTime, startDate.Type as Structure);
                }
            }

            context.LocalScope.PopContext(token);

            return retVal;
        }
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:40,代码来源:AddToDate.cs

示例15: CreateSubExplanation

        /// <summary>
        ///     Creates a sub explanation for the explain provided as parameter
        /// </summary>
        /// <param name="explain"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ExplanationPart CreateSubExplanation(ExplanationPart explain, string name)
        {
            ExplanationPart retVal = null;

            if (explain != null)
            {
                retVal = new ExplanationPart(explain.Element, name);
                explain.SubExplanations.Add(retVal);
            }

            return retVal;
        }
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:18,代码来源:ExplanationPart.cs


注:本文中的DataDictionary.Interpreter.ExplanationPart类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。