protected override void ResetRuntimeData() { if (m_program != null) { RecyclableObject.Recycle(m_program); m_program = null; } }
public void Reset() { m_constant = FixPoint.Zero; if (m_program != null) { RecyclableObject.Recycle(m_program); m_program = null; } }
public void CopyFrom(Formula rhs) { m_constant = rhs.m_constant; if (rhs.m_program != null) { m_program = RecyclableObject.Create <ExpressionProgram>(); m_program.CopyFrom(rhs.m_program); } }
protected override void OnActionUpdate(FixPoint delta_time) { if (m_program == null) { m_program = RecyclableObject.Create <ExpressionProgram>(); m_program.Compile(m_context_value_expression); } FixPoint context_value = m_program.Evaluate(this); m_context.SetData(m_context_key, context_value); }
public void CopyFrom(ExpressionProgram rhs) { m_error_occurred = rhs.m_error_occurred; RecycleVariable(); for (int i = 0; i < rhs.m_variables.Count; ++i) { ExpressionVariable variable = RecyclableObject.Create <ExpressionVariable>(); variable.CopyFrom(rhs.m_variables[i]); m_variables.Add(variable); } m_instructions.Clear(); for (int i = 0; i < rhs.m_instructions.Count; ++i) { m_instructions.Add(rhs.m_instructions[i]); } }
protected override bool IsSatisfy() { if (m_program == null) { m_program = RecyclableObject.Create <ExpressionProgram>(); m_program.Compile(m_expression); } FixPoint result = m_program.Evaluate(this); if (result != FixPoint.Zero) { return(true); } else { return(false); } }
void InitializeSyncModelTest() { string expression = "(2 > 3) ? (2 + 5) : (1 + 2)"; Combat.ExpressionProgram program = new Combat.ExpressionProgram(); program.Compile(expression); FixPoint result = program.Evaluate(null); LogWrapper.LogError(expression, ", EVALUATES ", result); if (m_combat_tester != null) { return; } //m_sync_tester = new Combat.SyncTester(this); //m_sync_tester.Init(); m_combat_tester = new Combat.CombatTester(); m_combat_tester.Initialize(); }
public bool Compile(string formula_string) { ExpressionProgram program = RecyclableObject.Create <ExpressionProgram>(); if (!program.Compile(formula_string)) { return(false); } if (program.IsConstant()) { m_constant = program.Evaluate(null); m_program = null; RecyclableObject.Recycle(program); } else { m_program = program; } return(true); }