コード例 #1
0
        //Формирует тип данных к которому сводятся оба типа, useParam - использовать при сравнении ParentParam
        public CalcType Add(CalcType type, bool useParam = false)
        {
            CalcType ct;

            if (LessOrEquals(type))
            {
                ct = type.Clone();
            }
            else if (type.LessOrEquals(this))
            {
                ct = Clone();
            }
            else if (ClassType == ClassType.Single && type.ClassType == ClassType.Single && IndexType == type.IndexType)
            {
                var dt = DataType.Add(type.DataType);
                if (dt == DataType.Error)
                {
                    return(new CalcType(ClassType.Error));
                }
                return(new CalcType(dt, IndexType));
            }
            else
            {
                ct = new CalcType(ClassType.Max);
            }
            ct.ParentParams      = !useParam ? null : type.ParentParams;
            ct.ArrayParentParams = !useParam ? null : type.ArrayParentParams;
            if (ClassType != ClassType.Undef)
            {
                ct.Text   = null;
                ct.Signal = null;
                ct.InputSignals.Clear();
            }
            return(ct);
        }
コード例 #2
0
        //Копия себя
        public CalcType Clone()
        {
            CalcType ct;

            switch (ClassType)
            {
            case ClassType.Single:
                ct = new CalcType(DataType, Text)
                {
                    IndexType = IndexType
                };
                break;

            case ClassType.Var:
                ct = new CalcType(Var);
                break;

            default:
                ct = new CalcType(ClassType);
                break;
            }
            ct.InputSignals      = InputSignals;
            ct.ParentParams      = ParentParams;
            ct.ArrayParentParams = ArrayParentParams;
            return(ct);
        }
コード例 #3
0
 //Возвращает тип данных, получаемый из текущего взятием индекса массива типа ind
 public CalcType GetIndex(CalcType ind)
 {
     if (ind.ClassType != ClassType.Single || !ind.DataType.LessOrEquals(IndexType))
     {
         return(new CalcType(ClassType.Max));
     }
     if (ind.DataType == DataType.Value)
     {
         return(this);
     }
     if (ClassType == ClassType.Single)
     {
         return new CalcType(DataType)
                {
                    ArrayParentParams = ParentParams
                }
     }
     ;
     return(new CalcType(ClassType.Max));
 }
コード例 #4
0
 //Сравнивает два типа данных без учета ParentParam
 public bool Equals(CalcType type)
 {
     if (ClassType != type.ClassType)
     {
         return(false);
     }
     if (IndexType != type.IndexType)
     {
         return(false);
     }
     if (ClassType == ClassType.Single)
     {
         if (DataType != type.DataType)
         {
             return(false);
         }
         if (Text != null && type.Text == null)
         {
             return(false);
         }
         if (Text == null && type.Text != null)
         {
             return(false);
         }
         bool e = true;
         foreach (var sig in type.InputSignals.Dic)
         {
             e &= InputSignals.Get(sig.Key, DataType.Error) == sig.Value;
         }
         foreach (var sig in InputSignals.Dic)
         {
             e &= type.InputSignals.Get(sig.Key, DataType.Error) == sig.Value;
         }
         return(e);
     }
     return(true);
 }
コード例 #5
0
 //Возвращает тип данных, получаемый из текущего добавление индексированности по типу ind
 public CalcType AddIndex(CalcType ind)
 {
     if (ind.ClassType != ClassType.Single || !ind.DataType.LessOrEquals(DataType.String))
     {
         return(new CalcType(ClassType.Max));
     }
     if (ind.DataType == DataType.Value)
     {
         return(this);
     }
     if (IndexType != DataType.Value)
     {
         return(new CalcType(ClassType.Max));
     }
     if (ClassType == ClassType.Single)
     {
         var idt = ind.DataType.LessOrEquals(DataType.Integer) ? DataType.Integer : DataType.String;
         return(new CalcType(DataType, idt)
         {
             ArrayParentParams = ParentParams, ParentParams = null
         });
     }
     return(new CalcType(ClassType.Max));
 }
コード例 #6
0
 public FunParam(CalcType calcType, string d = null)
 {
     CalcType = calcType;
     Default  = d;
 }
コード例 #7
0
 public ExprLexeme(Lexeme lexeme, CalcType type, ExprType exprType)
 {
     Lexeme        = lexeme;
     ExprType      = exprType;
     CalcTypeConst = type;
 }
コード例 #8
0
 //True - если данное значение подходит под заданный CommonType, useParam - использовать при сравнении ParentParam
 public bool LessOrEquals(CalcType type, bool useParam = false)
 {
     if (useParam && type.ParentParam != null)
     {
         foreach (var par in ParentParams)
         {
             if (par == type.ParentParam)
             {
                 return(true);
             }
         }
     }
     if (ClassType == ClassType.Calc)
     {
         return(ParentParam.CalcType.LessOrEquals(type));
     }
     if (ClassType == ClassType.Undef)
     {
         return(true);
     }
     if (type.ClassType == ClassType.Undef && ClassType == ClassType.Error)
     {
         return(false);
     }
     if (ClassType == ClassType.Error)
     {
         return(true);
     }
     if (type.ClassType == ClassType.Max)
     {
         return(true);
     }
     if (ClassType != type.ClassType)
     {
         return(false);
     }
     if (IndexType != type.IndexType)
     {
         return(false);
     }
     if (Equals(type))
     {
         return(true);
     }
     if (ClassType == ClassType.Single)
     {
         if (!DataType.LessOrEquals(type.DataType))
         {
             return(false);
         }
         if (Text == null && type.Text != null)
         {
             return(false);
         }
         if (type.InputSignals.Count > 0)
         {
             bool e = true;
             if (Signal != null)
             {
                 foreach (var sig in type.InputSignals.Dic)
                 {
                     e &= Signal.ObjectSignal.Signals.ContainsKey(sig.Key) && Signal.ObjectSignal.Signals[sig.Key].DataType.LessOrEquals(sig.Value);
                 }
             }
             else
             {
                 foreach (var sig in type.InputSignals.Dic)
                 {
                     e &= InputSignals[sig.Key].LessOrEquals(sig.Value);
                 }
             }
             return(e);
         }
         return(true);
     }
     return(false);
 }