예제 #1
0
파일: CLike.cs 프로젝트: codyn-net/rawc
        private string EventNodeStateVariable(Cdn.EventLogicalNode node,
                                              EventNodeState.StateType type,
                                              Context context)
        {
            var st = d_program.StateTable[EventNodeState.Key(node, type)];

            return(String.Format("{0}[{1}]", context.This(d_program.StateTable), st.AliasOrIndex));
        }
예제 #2
0
파일: CLike.cs 프로젝트: codyn-net/rawc
        private string EventConditionHolds(Cdn.Event ev,
                                           Cdn.EventLogicalNode node,
                                           EventNodeState.StateType type,
                                           Context context)
        {
            var st = EventNodeStateVariable(node, type, context);

            switch (node.CompareType)
            {
            case Cdn.MathFunctionType.Less:
            case Cdn.MathFunctionType.Greater:
                return(String.Format("{0} > 0",
                                     st));

            case Cdn.MathFunctionType.LessOrEqual:
            case Cdn.MathFunctionType.GreaterOrEqual:
            case Cdn.MathFunctionType.And:
            case Cdn.MathFunctionType.Or:
                return(String.Format("{0} >= 0",
                                     st));

            case Cdn.MathFunctionType.Equal:
                if (ev.Approximation != Double.MaxValue)
                {
                    var approx = context.TranslateNumber(ev.Approximation);

                    return(String.Format("{0}({1}) <= {2}",
                                         context.MathFunction(MathFunctionType.Abs, 1),
                                         st,
                                         approx));
                }
                else
                {
                    return("1");
                }

            default:
                return("0");
            }
        }