本文整理汇总了C#中DataDictionary.Interpreter.ExplanationPart类的典型用法代码示例。如果您正苦于以下问题:C# ExplanationPart类的具体用法?C# ExplanationPart怎么用?C# ExplanationPart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExplanationPart类属于DataDictionary.Interpreter命名空间,在下文中一共展示了ExplanationPart类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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);
retVal = Surface.createSurface(GetValue(context, explain), xParam, yParam);
if (retVal == null)
{
throw new Exception("Cannot create surface for " + ToString());
}
retVal.XParameter = xParam;
retVal.YParameter = yParam;
return retVal;
}
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:24,代码来源:DerefExpression.cs
示例17: 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 = Called;
if (retVal == null)
{
AddError("Cannot evaluate call to " + ToString());
}
return retVal;
}
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:17,代码来源:DerefExpression.cs
示例18: createGraph
/// <summary>
/// Creates the graph associated to this expression, when the given parameter ranges over the X axis
/// </summary>
/// <param name="context">The interpretation context</param>
/// <param name="parameter">The parameters of *the enclosing function* for which the graph should be created</param>
/// <param name="explain"></param>
/// <returns></returns>
public override Graph createGraph(InterpretationContext context, Parameter parameter, ExplanationPart explain)
{
Graph retVal = base.createGraph(context, parameter, explain);
retVal = Graph.createGraph(GetValue(context, explain), parameter, explain);
if (retVal == null)
{
throw new Exception("Cannot create graph for " + ToString());
}
return retVal;
}
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:20,代码来源:DerefExpression.cs
示例19: GetChanges
/// <summary>
/// Creates a list of changes to be applied on the system
/// </summary>
/// <param name="context">The context on which the changes should be computed</param>
/// <param name="changes">The list of changes to be updated</param>
/// <param name="explanation">The explanatino to fill, if any</param>
/// <param name="apply">Indicates that the changes should be applied immediately</param>
/// <param name="runner"></param>
/// <returns>The list to fill with the changes</returns>
public virtual void GetChanges(InterpretationContext context, ChangeList changes, ExplanationPart explanation,
bool apply, Runner runner)
{
if (!DeActivated)
{
long start = Environment.TickCount;
try
{
if (Statement != null)
{
Statement.GetChanges(context, changes, explanation, apply, runner);
}
else
{
AddError("Invalid actions statement");
}
}
catch (Exception e)
{
AddException(e);
}
long stop = Environment.TickCount;
long span = (stop - start);
if (RuleCondition != null && RuleCondition.EnclosingRule != null)
{
// Rule execution execution time (as opposed to guard evaluation)
RuleCondition.EnclosingRule.ExecutionTimeInMilli += span;
RuleCondition.EnclosingRule.ExecutionCount += 1;
}
}
}
开发者ID:GautierBerck,项目名称:ERTMSFormalSpecs,代码行数:43,代码来源:Action.cs
示例20: Evaluate
/// <summary>
/// Provides the value of the function
/// </summary>
/// <param name="context"></param>
/// <param name="actuals"></param>
/// <param name="explain"></param>
/// <returns>The value for the function application</returns>
public virtual IValue Evaluate(InterpretationContext context, Dictionary<Actual, IValue> actuals,
ExplanationPart explain)
{
IValue retVal = null;
bool useCache = EFSSystem.CacheFunctions;
ExplainedValue explainedValue = null;
// Only use the cached value when the EFSSystem indicates that caches should be used
// This condition has been added to handle the fact that the user changes the status
// of EFSSystem.CacheFunctions within a test session
if (useCache)
{
if (_cachedResult == null)
{
_cachedResult = new CurryCache(this);
}
explainedValue = _cachedResult.GetValue(actuals);
}
if (explainedValue == null)
{
int token = context.LocalScope.PushContext();
AssignParameters(context, actuals);
if (Cases.Count > 0)
{
bool preConditionSatisfied = false;
// Statically defined function
foreach (Case aCase in Cases)
{
// Evaluate the function
ExplanationPart subExplanation = ExplanationPart.CreateSubExplanation(explain, aCase);
preConditionSatisfied = aCase.EvaluatePreConditions(context, subExplanation);
ExplanationPart.SetNamable(subExplanation,
preConditionSatisfied ? EFSSystem.BoolType.True : EFSSystem.BoolType.False);
if (preConditionSatisfied)
{
retVal = aCase.Expression.GetValue(context, subExplanation);
break;
}
}
if (!preConditionSatisfied)
{
ExplanationPart.CreateSubExplanation(explain, "Partial function called outside its domain");
AddError("Partial function called outside its domain");
}
}
else if (Surface != null && FormalParameters.Count == 2)
{
double x = 0.0;
double y = 0.0;
Parameter formal1 = (Parameter) FormalParameters[0];
Parameter formal2 = (Parameter) FormalParameters[1];
foreach (KeyValuePair<Actual, IValue> pair in actuals)
{
if (pair.Key.Parameter == formal1)
{
x = GetDoubleValue(pair.Value);
}
if (pair.Key.Parameter == formal2)
{
y = GetDoubleValue(pair.Value);
}
}
retVal = new DoubleValue(EFSSystem.DoubleType, Surface.Val(x, y));
}
else if (Graph != null && FormalParameters.Count < 2)
{
if (FormalParameters.Count == 0)
{
retVal = new DoubleValue(EFSSystem.DoubleType, Graph.Evaluate(0));
}
else if (FormalParameters.Count == 1)
{
double x = 0.0;
Parameter formal = (Parameter) FormalParameters[0];
foreach (KeyValuePair<Actual, IValue> pair in actuals)
{
if (pair.Key.Parameter == formal)
{
x = GetDoubleValue(pair.Value);
}
}
retVal = new DoubleValue(EFSSystem.DoubleType, Graph.Evaluate(x));
}
}
context.LocalScope.PopContext(token);
ExplanationPart.SetNamable(explain, retVal);
if (useCache)
//.........这里部分代码省略.........
开发者ID:nikiforovandrey,项目名称:ERTMSFormalSpecs,代码行数:101,代码来源:Function.cs
注:本文中的DataDictionary.Interpreter.ExplanationPart类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论