private string displayValueFor(ValuePoint valuePoint, IComparison <TableFormula> comparison) { var formulaOwnerName = _displayNameProvider.DisplayNameFor(comparison.CommonAncestor); var tableFormula = comparison.Object1.DowncastTo <TableFormula>(); return(Captions.Comparisons.ValuePointAt(tableFormula.Name, formulaOwnerName, tableFormula.XDisplayValueFor(valuePoint.X))); }
public Area GetArea(ValuePoint a) { int x = (int)(a.x / unitSize); int y = (int)(a.y / unitSize); return(areas[x, y]); }
public void CmdAddPoint(ValuePoint p) { int index = UnityEngine.Random.Range(1, 3); GameObject obj = Tools.LoadGameObject("Point/Pt" + index); obj.transform.localPosition = new Vector3(p.x, 0, p.y); points.Add(p.id, obj); }
public ValuePointDTO(IParameter parameter, TableFormula tableFormula, ValuePoint point) { _parameter = parameter; _tableFormula = tableFormula; X = convertToDisplayUnit(tableFormula.XDimension, tableFormula.XDisplayUnit, point.X); Y = convertToDisplayUnit(tableFormula.Dimension, tableFormula.YDisplayUnit, point.Y); Rules.AddRange(AllRules.All()); }
protected override void Context() { base.Context(); _p1 = new ValuePoint(1, 10); _p2 = new ValuePoint(2, 20); sut.AddPoint(_p1); sut.AddPoint(_p2); }
protected override void Context() { base.Context(); _tableFormula = new TableFormula(); _newValuePointPresenter = A.Fake <INewValuePointPresenter>(); A.CallTo(() => _applicationController.Start <INewValuePointPresenter>()).Returns(_newValuePointPresenter); _valuePoint = new ValuePoint(0, 0); A.CallTo(() => _newValuePointPresenter.GetNewValuePoint()).Returns(_valuePoint); sut.Edit(_tableFormula); }
protected override void Context() { base.Context(); _p1 = new ValuePoint(1, 2); _p2 = new ValuePoint(3, 4); _tableFormula.AddPoint(_p1); _tableFormula.AddPoint(_p2); _editedFormula.AddPoint(_p1); _editedFormula.AddPoint(_p2); }
/// <summary> /// Visits a ConditionalExPoint point and propagates the taint /// </summary> /// <param name="p">point to visit</param> public override void VisitValue(ValuePoint p) { _currentPoint = p; if (p is ConditionalExPoint) { var pEx = p as ConditionalExPoint; var possibleValues = pEx.Condition.Value.ReadMemory(Output).PossibleValues; if (pEx.TrueAssume.Assumed && pEx.FalseAssume.Assumed) { var truevarID = getVariableIdentifier(pEx.TrueOperand.Value); var falsevarID = getVariableIdentifier(pEx.FalseOperand.Value); List <Value> trueValues = new List <Value>(pEx.TrueOperand.Value.ReadMemory(pEx.TrueOperand.OutSnapshot).PossibleValues); List <Value> falseValues = new List <Value>(pEx.FalseOperand.Value.ReadMemory(pEx.FalseOperand.OutSnapshot).PossibleValues); //merge taint info from both branches List <ValueInfo> values = new List <ValueInfo>(); values.Add(new ValueInfo(trueValues, truevarID)); values.Add(new ValueInfo(falseValues, falsevarID)); bool nullValue = hasPossibleNullValue(pEx.TrueOperand) || hasPossibleNullValue(pEx.FalseOperand); TaintInfo outputTaint = mergeTaint(values, nullValue); pEx.SetValueContent(new MemoryEntry(Output.CreateInfo(outputTaint))); } else if (pEx.TrueAssume.Assumed) { var truevarID = getVariableIdentifier(pEx.TrueOperand.Value); List <Value> trueValues = new List <Value>(pEx.TrueOperand.Value.ReadMemory(Output).PossibleValues); //only true value is used List <ValueInfo> values = new List <ValueInfo>(); values.Add(new ValueInfo(trueValues, truevarID)); bool nullValue = hasPossibleNullValue(pEx.TrueOperand); TaintInfo outputTaint = mergeTaint(values, nullValue); pEx.SetValueContent(new MemoryEntry(Output.CreateInfo(outputTaint))); } else { var falsevarID = getVariableIdentifier(pEx.FalseOperand.Value); List <Value> falseValues = new List <Value>(pEx.FalseOperand.Value.ReadMemory(Output).PossibleValues); //only false value is used List <ValueInfo> values = new List <ValueInfo>(); values.Add(new ValueInfo(falseValues, falsevarID)); bool nullValue = hasPossibleNullValue(pEx.FalseOperand); TaintInfo outputTaint = mergeTaint(values, nullValue); pEx.SetValueContent(new MemoryEntry(Output.CreateInfo(outputTaint))); } } }
protected override void Context() { _context = A.Fake <IMoBiContext>(); _tableFormula = new TableFormula(); _tableFormula.Dimension = A.Fake <IDimension>(); _tableFormula.XDimension = A.Fake <IDimension>(); _valuePoint = new ValuePoint(1, 2); _buildingBlock = A.Fake <IBuildingBlock>(); sut = new AddValuePointCommand(_tableFormula, _valuePoint, _buildingBlock); }
public override void VisitClassConstUse(ClassConstUse x) { ValuePoint thisObj = null; if (x.ClassName.QualifiedName.Name.Value == "") { thisObj = CreateRValue(x.TypeRef); } Result(new ClassConstPoint(x, thisObj)); }
/// <summary> /// Gets the complete taint information /// </summary> /// <param name="lValue">value point to get the taint for</param> /// <returns>the taint information of given value point</returns> private TaintInfo getTaint(ValuePoint lValue) { var varID = getVariableIdentifier(lValue.Value); List <Value> info = new List <Value>(lValue.Value.ReadMemory(lValue.OutSnapshot).PossibleValues); List <ValueInfo> values = new List <ValueInfo>(); values.Add(new ValueInfo(info, varID)); return(mergeTaint(values, hasPossibleNullValue(lValue))); }
protected SetValuePointCommand(TableFormula tableFormula, ValuePoint valuePoint, double newBaseValue, IBuildingBlock buildingBlock) : base(buildingBlock) { _valuePoint = valuePoint; _tableFormula = tableFormula; _tableFormulaId = _tableFormula.Id; _newBaseValue = newBaseValue; CommandType = AppConstants.Commands.EditCommand; ObjectType = ObjectTypes.ValuePoint; }
private bool addOperandValues(List <ValueInfo> values, ValuePoint operand, bool nullValue) { if (operand.Value != null) { var operandID = getVariableIdentifier(operand.Value); var vals = operand.Value.ReadMemory(operand.OutSnapshot).PossibleValues; List <Value> operandValues = new List <Value>(vals); values.Add(new ValueInfo(operandValues, operandID)); nullValue |= hasPossibleNullValue(operand); } return(nullValue); }
internal static void LocalVariable() { Point reference1 = new Point(1, 2); Point reference2 = reference1; // Copy. reference2 = new Point(3, 4); // reference1 is not impacted. ValuePoint value1 = new ValuePoint(5, 6); ValuePoint value2 = value1; // Copy. value2 = new ValuePoint(7, 8); // value1 is not impacted. }
protected override void Context() { base.Context(); _valuePoint = new ValuePoint(10, 20); _xDisplayUnit = A.Fake <Unit>(); _YDisplayUnit = A.Fake <Unit>(); _tableFormula = A.Fake <TableFormula>(); _tableFormula.XDisplayUnit = _xDisplayUnit; _tableFormula.YDisplayUnit = _YDisplayUnit; _newDisplayValue = 12; }
public void RandomPoint(int i, int j) { maxPTId++; float x = Game.inst.rand(unitSize) + i * unitSize; float y = Game.inst.rand(unitSize) + j * unitSize; ValuePoint p = new ValuePoint(maxPTId, x, y); areas[i, j].points.Add(maxPTId, p); Game.inst.points.Add(maxPTId, p); Game.inst.BoardCast(x, y, "AddPoint", p); }
protected override void Context() { base.Context(); _tableFormula = new TableFormula(); _tableFormula.AddPoint(0, 0); _valuePoint = new ValuePoint(1, 1); _tableFormula.AddPoint(_valuePoint); sut.Edit(_tableFormula); _removedPointDTO = new DTOValuePoint(A.Fake <TableFormulaBuilderDTO>()) { ValuePoint = _valuePoint }; }
public void AddValuePoint() { using (var getValuePointPresenter = _applicationController.Start<INewValuePointPresenter>()) { getValuePointPresenter.Dimension = _formula.Dimension; ValuePoint newValuePoint = getValuePointPresenter.GetNewValuePoint(); if (newValuePoint != null) { AddCommand(_moBiFormulaTask.AddValuePoint(_formula, newValuePoint, BuildingBlock)); } } }
public void DelPoint(int id) { ValuePoint a = Game.inst.points[id]; Area area = GetArea(a); if (area != null) { area.points.Remove(id); } Game.inst.points.Remove(id); Game.inst.BoardCast(a.x, a.y, "DelPoint", id); }
public override void VisitNewEx(NewEx x) { var arguments = CreateArguments(x.CallSignature); ValuePoint name = null; if (!(x.ClassNameRef is DirectTypeRef)) { name = CreateRValue(x.ClassNameRef); } Result(new NewExPoint(x, name, arguments)); }
public override void VisitInstanceOfEx(InstanceOfEx x) { var expression = CreateRValue(x.Expression); ValuePoint name = null; if (!(x.ClassNameRef is DirectTypeRef)) { name = CreateRValue(x.ClassNameRef); } Result(new InstanceOfExPoint(x, expression, name)); }
public override void VisitIndirectStMtdCall(IndirectStMtdCall x) { var arguments = CreateArguments(x.CallSignature); var name = CreateRValue(x.MethodNameVar); ValuePoint thisObj = null; if (x.ClassName.QualifiedName.Name.Value == "") { thisObj = CreateRValue(x.PublicTypeRef); } Result(new IndirectStaticMethodCallPoint(x, thisObj, name, arguments)); }
/// <summary> /// 比较两个点的时间区间 /// </summary> /// <param name="p_objValue1"></param> /// <param name="p_objValue2"></param> /// <returns></returns> private static int s_intCompare(ValuePoint p_objValue1, ValuePoint p_objValue2) { int intResult = 0; if (p_objValue1.TimePeriod < p_objValue2.TimePeriod) { intResult = -1; } else if (p_objValue1.TimePeriod > p_objValue2.TimePeriod) { intResult = 1; } return(intResult); }
protected override void Context() { base.Context(); _input = new TableFormula(); _p1 = new ValuePoint(0, 0); _p2 = new ValuePoint(1, 1); _p3 = new ValuePoint(2, 2); _input.UseDerivedValues = false; _input.AddPoint(_p1); _input.AddPoint(_p2); _input.AddPoint(_p3); }
protected override void Context() { _context = A.Fake <IMoBiContext>(); _newValue = 10; _tableFormulaId = "FormulaId"; _valuePoint = new ValuePoint(1, 11); _tableFormula = new TableFormula { Id = _tableFormulaId, Dimension = DomainHelperForSpecs.AmountDimension, XDimension = DomainHelperForSpecs.TimeDimension }; _tableFormula.AddPoint(_valuePoint); _tableFormula.AddPoint(2, 22); _buildingBlock = A.Fake <IBuildingBlock>(); }
public ValuePoint[] GetAllPointInfo() { ValuePoint[] ret = new ValuePoint[points.Count]; int n = 0; foreach (var a in points) { ret[n] = a.Value; n++; } return(ret); }
protected override void Context() { base.Context(); _valuePointDTO = new DTOValuePoint(A.Fake <TableFormulaBuilderDTO>()); var valuePoint = new ValuePoint(0, 0) { RestartSolver = false }; _valuePointDTO.ValuePoint = valuePoint; _valuePointDTO.RestartSolver = false; _tableFormula = new TableFormula(); sut.Edit(_tableFormula); }
public DTOValuePoint MapFrom(ValuePoint input) { var dto = new DTOValuePoint(_tableFormulaDTO) { X = new ValuePointParameterDTO { Value = input.X, Dimension = _xDimension, DisplayUnit = _xDisplayUnit }, Y = new ValuePointParameterDTO { Value = input.Y, Dimension = _yDimension, DisplayUnit = _yDisplayUnit }, RestartSolver = input.RestartSolver, ValuePoint = input }; return(dto); }
protected override void Context() { base.Context(); _tableFormulaExport = new TableFormulaExport { Id = 1 }; _p1 = new ValuePoint(0, 0); _p2 = new ValuePoint(1, 1) { RestartSolver = true }; _p3 = new ValuePoint(2, 2); _tableFormulaExport.AddPoint(_p1); _tableFormulaExport.AddPoint(_p2); _tableFormulaExport.AddPoint(_p3); _tableFormulaExport.UseDerivedValues = false; }
protected override void Context() { _buildingBlock = A.Fake <IBuildingBlock>(); _tableFormula = new TableFormula() { Dimension = DomainHelperForSpecs.AmountDimension, XDimension = DomainHelperForSpecs.TimeDimension }; _valuePoint = new ValuePoint(1.0, 1.0) { RestartSolver = false }; _newRestartSolverValue = true; _tableFormula.AddPoint(_valuePoint); _context = A.Fake <IMoBiContext>(); A.CallTo(() => _context.Get <TableFormula>(_tableFormula.Id)).Returns(_tableFormula); sut = new SetRestartSolverInValuePointCommand(_tableFormula, _valuePoint, _newRestartSolverValue, _buildingBlock); }