本文整理汇总了C#中Interpreter.findOnStack方法的典型用法代码示例。如果您正苦于以下问题:C# Interpreter.findOnStack方法的具体用法?C# Interpreter.findOnStack怎么用?C# Interpreter.findOnStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interpreter
的用法示例。
在下文中一共展示了Interpreter.findOnStack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Evaluate
/// <summary>
/// Provides the value of the function
/// </summary>
/// <param name="instance">the instance on which the function is evaluated</param>
/// <param name="actuals">the actual parameters values</param>
/// <param name="localScope">the values of local variables</param>
/// <returns>The value for the function application</returns>
public override Values.IValue Evaluate(Interpreter.InterpretationContext context, Dictionary<Variables.Actual, Values.IValue> actuals)
{
Values.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;
}
示例2: createGraph
public override Graph createGraph(Interpreter.InterpretationContext context, Parameter parameter)
{
Graph retVal = null;
Variables.IVariable variable = context.findOnStack(Value);
if (variable != null)
{
retVal = Graph.createGraph(Functions.Function.getDoubleValue(variable.Value), parameter);
}
else
{
AddError("Cannot find variable " + Value + " on the stack");
}
return retVal;
}
示例3: Evaluate
/// <summary>
/// Provides the value of the function
/// </summary>
/// <param name="instance">the instance on which the function is evaluated</param>
/// <param name="actuals">the actual parameters values</param>
/// <param name="localScope">the values of local variables</param>
/// <returns>The value for the function application</returns>
public override Values.IValue Evaluate(Interpreter.InterpretationContext context, Dictionary<Variables.Actual, Values.IValue> actuals)
{
Values.IValue retVal = null;
int token = context.LocalScope.PushContext();
AssignParameters(context, actuals);
Values.BoolValue val = context.findOnStack(Value).Value as Values.BoolValue;
if (val != null)
{
if (val.Val)
{
retVal = EFSSystem.BoolType.False;
}
else
{
retVal = EFSSystem.BoolType.True;
}
}
context.LocalScope.PopContext(token);
return retVal;
}
示例4: Evaluate
/// <summary>
/// Provides the value of the function
/// </summary>
/// <param name="instance">the instance on which the function is evaluated</param>
/// <param name="actuals">the actual parameters values</param>
/// <param name="localScope">the values of local variables</param>
/// <returns>The value for the function application</returns>
public override Values.IValue Evaluate(Interpreter.InterpretationContext context, Dictionary<Variables.Actual, Values.IValue> actuals)
{
Values.IValue retVal = null;
int token = context.LocalScope.PushContext();
AssignParameters(context, actuals);
Values.ListValue value = context.findOnStack(Collection) as Values.ListValue;
if (value != null)
{
Types.Collection collectionType = value.Type as Types.Collection;
if (collectionType != null && collectionType.Type != null)
{
Types.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;
}
示例5: createGraph
/// <summary>
/// Provides the graph of this function if it has been statically defined
/// </summary>
/// <param name="context">the context used to create the graph</param>
/// <returns></returns>
public override Graph createGraph(Interpreter.InterpretationContext context, Parameter parameter)
{
Graph retVal = null;
Graph graph = null;
Function function = context.findOnStack(Function).Value as Function;
if (function != null)
{
int token = context.LocalScope.PushContext();
Parameter p = (Parameter)function.FormalParameters[0];
context.LocalScope.setGraphParameter(p);
graph = createGraphForValue(context, function, p);
context.LocalScope.PopContext(token);
}
if (graph != null)
{
Function increment = context.findOnStack(Increment).Value as Function;
retVal = graph.AddIncrement(context, increment);
}
else
{
Log.Error("Cannot create graph for " + Function.ToString());
}
return retVal;
}
示例6: createGraph
/// <summary>
/// Provides the graph of this function if it has been statically defined
/// </summary>
/// <param name="context">the context used to create the graph</param>
/// <returns></returns>
public override Graph createGraph(Interpreter.InterpretationContext context, Parameter parameter)
{
Graph retVal = null;
Values.IValue firstValue = context.findOnStack(First).Value;
Values.IValue secondValue = context.findOnStack(Second).Value;
Graph firstGraph = createGraphForValue(context, firstValue, parameter);
if (firstGraph != null)
{
Graph secondGraph = createGraphForValue(context, secondValue, parameter);
if (secondGraph != null)
{
retVal = firstGraph.Max(secondGraph);
}
else
{
Log.Error("Cannot create graph for " + Second.ToString());
}
}
else
{
Log.Error("Cannot create graph for " + First.ToString());
}
return retVal;
}
示例7: createGraph
/// <summary>
/// Provides the graph of this function if it has been statically defined
/// </summary>
/// <param name="context">the context used to create the graph</param>
/// <returns></returns>
public override Graph createGraph(Interpreter.InterpretationContext context, Parameter parameter)
{
Graph retVal = null;
Graph MRSPGraph = null;
Function speedRestriction = context.findOnStack(SpeedRestrictions).Value as Function;
if (speedRestriction != null)
{
Parameter p = (Parameter)speedRestriction.FormalParameters[0];
int token = context.LocalScope.PushContext();
context.LocalScope.setGraphParameter(p);
MRSPGraph = createGraphForValue(context, context.findOnStack(SpeedRestrictions).Value, p);
context.LocalScope.PopContext(token);
}
if (MRSPGraph != null)
{
Function deceleratorFactor = context.findOnStack(DecelerationFactor).Value as Function;
if (deceleratorFactor != null)
{
Surface DecelerationSurface = deceleratorFactor.createSurface(context);
if (DecelerationSurface != null)
{
FlatSpeedDistanceCurve MRSPCurve = MRSPGraph.FlatSpeedDistanceCurve(MRSPGraph.ExpectedEndX());
AccelerationSpeedDistanceSurface accelerationSurface = DecelerationSurface.createAccelerationSpeedDistanceSurface(double.MaxValue, double.MaxValue);
QuadraticSpeedDistanceCurve BrakingCurve = null;
try
{
BrakingCurve = EtcsBrakingCurveBuilder.Build_A_Safe_Backward(accelerationSurface, MRSPCurve);
}
catch (System.Exception e)
{
retVal = new Graph();
retVal.addSegment(new Graph.Segment(0, double.MaxValue, new Graph.Segment.Curve(0, 0, 0)));
}
if (BrakingCurve != null)
{
retVal = new Graph();
// TODO : Remove the distinction between linear curves and quadratic curves
bool isLinear = true;
for (int i = 0; i < BrakingCurve.SegmentCount; i++)
{
QuadraticCurveSegment segment = BrakingCurve[i];
if (segment.A.ToUnits() != 0.0 || segment.V0.ToUnits() != 0.0)
{
isLinear = false;
break;
}
}
for (int i = 0; i < BrakingCurve.SegmentCount; i++)
{
QuadraticCurveSegment segment = BrakingCurve[i];
Graph.Segment newSegment;
if (isLinear)
{
newSegment = new Graph.Segment(
segment.X.X0.ToUnits(),
segment.X.X1.ToUnits(),
new Graph.Segment.Curve(0.0, segment.V0.ToSubUnits(SiSpeed_SubUnits.KiloMeter_per_Hour), 0.0));
}
else
{
newSegment = new Graph.Segment(
segment.X.X0.ToUnits(),
segment.X.X1.ToUnits(),
new Graph.Segment.Curve(
segment.A.ToSubUnits(SiAcceleration_SubUnits.Meter_per_SecondSquare),
segment.V0.ToSubUnits(SiSpeed_SubUnits.KiloMeter_per_Hour),
segment.D0.ToSubUnits(SiDistance_SubUnits.Meter)
)
);
}
retVal.addSegment(newSegment);
}
}
}
else
{
Log.Error("Cannot create surface for " + DecelerationFactor.ToString());
}
}
else
{
Log.Error("Cannot evaluate " + DecelerationFactor.ToString() + " as a function");
}
}
else
{
Log.Error("Cannot create graph for " + SpeedRestrictions.ToString());
}
//.........这里部分代码省略.........
示例8: Evaluate
/// <summary>
/// Provides the value of the function
/// </summary>
/// <param name="instance">the instance on which the function is evaluated</param>
/// <param name="actuals">the actual parameters values</param>
/// <param name="localScope">the values of local variables</param>
/// <returns>The value for the function application</returns>
public override Values.IValue Evaluate(Interpreter.InterpretationContext context, Dictionary<Variables.Actual, Values.IValue> actuals)
{
Values.IValue retVal = null;
int token = context.LocalScope.PushContext();
AssignParameters(context, actuals);
Functions.Function function = context.findOnStack(Function).Value as Functions.Function;
if (function != null)
{
double speed = Functions.Function.getDoubleValue(context.findOnStack(Speed).Value);
Parameter parameter = (Parameter)function.FormalParameters[0];
int token2 = context.LocalScope.PushContext();
context.LocalScope.setGraphParameter(parameter);
Graph graph = function.createGraph(context, (Parameter)function.FormalParameters[0]);
context.LocalScope.PopContext(token2);
retVal = new Values.DoubleValue(EFSSystem.DoubleType, graph.SolutionX(speed));
}
else
{
Log.Error("Cannot get function for " + Function.ToString());
}
context.LocalScope.PopContext(token);
return retVal;
}
示例9: createGraph
/// <summary>
/// Provides the graph of this function if it has been statically defined
/// </summary>
/// <param name="context">the context used to create the graph</param>
/// <returns></returns>
public override Graph createGraph(Interpreter.InterpretationContext context, Parameter parameter)
{
Graph retVal = null;
Graph graph = createGraphForValue(context, context.findOnStack(Function).Value, parameter);
if (graph != null)
{
double speed = Functions.Function.getDoubleValue(context.findOnStack(Speed).Value);
retVal = Graph.createGraph(graph.SolutionX(speed));
}
else
{
Log.Error("Cannot create graph for " + Function.ToString());
}
return retVal;
}
示例10: Evaluate
/// <summary>
/// Provides the value of the function
/// </summary>
/// <param name="instance">the instance on which the function is evaluated</param>
/// <param name="actuals">the actual parameters values</param>
/// <param name="localScope">the values of local variables</param>
/// <returns>The value for the function application</returns>
public override Values.IValue Evaluate(Interpreter.InterpretationContext context, Dictionary<Variables.Actual, Values.IValue> actuals)
{
Values.IValue retVal = null;
AssignParameters(context, actuals);
Graph graph = createGraphForValue(context, context.findOnStack(FunctionA).Value);
if (graph != null)
{
foreach (Graph.Segment segment in graph.Segments)
{
if (segment.Expression.a == 0.0)
{
double speed = segment.Expression.v0;
Function function = context.findOnStack(FunctionB).Value as Function;
if (function.FormalParameters.Count > 0)
{
Parameter functionParameter = function.FormalParameters[0] as Parameter;
Variables.Actual actual = functionParameter.createActual();
actual.Value = new Values.DoubleValue(EFSSystem.DoubleType, speed);
Dictionary<Variables.Actual, Values.IValue> values = new Dictionary<Variables.Actual, Values.IValue>();
values[actual] = new Values.DoubleValue(EFSSystem.DoubleType, speed);
Values.IValue solution = function.Evaluate(context, values);
double doubleValue = getDoubleValue(solution);
if (doubleValue >= segment.Start && doubleValue <= segment.End)
{
retVal = new Values.DoubleValue(EFSSystem.DoubleType, doubleValue);
break;
}
}
else
{
Log.Error("The FunctionB doesn't have any parameter");
break;
}
}
else
{
Log.Error("The FunctionA is not a step function");
break;
}
}
}
else
{
Log.Error("Cannot create graph for " + FunctionA.ToString());
}
if (retVal == null)
{
Log.Error("Cannot compute the intersection of " + FunctionA.ToString() + " and " + FunctionB.ToString());
}
return retVal;
}
示例11: Evaluate
/// <summary>
/// Provides the value of the function
/// </summary>
/// <param name="instance">the instance on which the function is evaluated</param>
/// <param name="actuals">the actual parameters values</param>
/// <returns>The value for the function application</returns>
public override Values.IValue Evaluate(Interpreter.InterpretationContext context, Dictionary<Variables.Actual, Values.IValue> actuals)
{
Values.IValue retVal = null;
int token = context.LocalScope.PushContext();
AssignParameters(context, actuals);
Types.Collection collectionType = (Types.Collection)EFSSystem.findType(OverallNameSpaceFinder.INSTANCE.findByName(EFSSystem.Dictionaries[0], "Kernel.SpeedAndDistanceMonitoring.TargetSupervision"), "Kernel.SpeedAndDistanceMonitoring.TargetSupervision.Targets");
Values.ListValue collection = new Values.ListValue(collectionType, new List<Values.IValue>());
// compute targets from the MRSP
Function function1 = context.findOnStack(Targets1).Value as Functions.Function;
if (function1 != null && !function1.Name.Equals("EMPTY"))
{
Graph graph1 = createGraphForValue(context, function1);
ComputeTargets(graph1.Function, collection);
}
// compute targets from the MA
Function function2 = context.findOnStack(Targets2).Value as Functions.Function;
if (function2 != null && !function2.Name.Equals("EMPTY"))
{
Graph graph2 = createGraphForValue(context, function2);
ComputeTargets(graph2.Function, collection);
}
// compute targets from the SR
Function function3 = context.findOnStack(Targets3).Value as Functions.Function;
if (function3 != null && !function3.Name.Equals("EMPTY"))
{
Graph graph3 = createGraphForValue(context, function3);
ComputeTargets(graph3.Function, collection);
}
context.LocalScope.PopContext(token);
retVal = collection;
return retVal;
}
示例12: 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>
/// <returns></returns>
public override Surface createSurface(Interpreter.InterpretationContext context)
{
Surface retVal = null;
Values.IValue firstValue = context.findOnStack(First).Value;
Values.IValue secondValue = context.findOnStack(Second).Value;
Surface firstSurface = createSurfaceForValue(context, firstValue);
if (firstSurface != null)
{
Surface secondSurface = createSurfaceForValue(context, secondValue);
if (secondSurface != null)
{
retVal = firstSurface.Min(secondSurface);
}
else
{
Log.Error("Cannot create surface for " + Second.ToString());
}
}
else
{
Log.Error("Cannot create surface for " + First.ToString());
}
return retVal;
}
示例13: Evaluate
/// <summary>
/// Provides the value of the function
/// </summary>
/// <param name="instance">the instance on which the function is evaluated</param>
/// <param name="actuals">the actual parameters values</param>
/// <returns>The value for the function application</returns>
public override Values.IValue Evaluate(Interpreter.InterpretationContext context, Dictionary<Variables.Actual, Values.IValue> actuals)
{
Values.IValue retVal = null;
int token = context.LocalScope.PushContext();
AssignParameters(context, actuals);
Values.DoubleValue value = context.findOnStack(Value).Value as Values.DoubleValue;
Values.DoubleValue multiple = context.findOnStack(Multiple).Value as Values.DoubleValue;
if (value != null && multiple != null)
{
double res = Math.Floor(value.Val);
while (res > 0 && res % multiple.Val != 0)
{
res--;
}
retVal = new Values.DoubleValue(ReturnType, res);
}
context.LocalScope.PopContext(token);
return retVal;
}
示例14: ExpressionBasedOnPlaceHolder
/// <summary>
/// Indicates whether the expression is based on a placeholder value, ommiting the parameter provided
/// </summary>
/// <param name="context">The current interpretation context</param>
/// <param name="expression">The expression to evaluate</param>
/// <returns></returns>
private bool ExpressionBasedOnPlaceHolder(Interpreter.InterpretationContext context, Interpreter.BinaryExpression expression)
{
bool retVal = false;
if (expression != null)
{
foreach (Types.ITypedElement element in expression.GetRightSides())
{
Parameter parameter = element as Parameter;
if (parameter != null)
{
Variables.IVariable variable = context.findOnStack(parameter);
if (variable != null)
{
Values.PlaceHolder placeHolder = variable.Value as Values.PlaceHolder;
if (placeHolder != null)
{
retVal = true;
break;
}
}
}
}
}
return retVal;
}
示例15: 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>
/// <returns></returns>
public override Surface createSurface(Interpreter.InterpretationContext context)
{
Surface retVal = null;
Surface defaultSurface = createSurfaceForValue(context, context.findOnStack(DefaultFunction).Value);
if (defaultSurface != null)
{
Surface overrideSurface = createSurfaceForValue(context, context.findOnStack(OverrideFunction).Value);
if (overrideSurface != null)
{
retVal = defaultSurface.Override(overrideSurface);
}
else
{
Log.Error("Cannot create graph for OVERRIDE argument");
}
}
else
{
Log.Error("Cannot create graph for DEFAULT argument");
}
return retVal;
}