Ejemplo n.º 1
0
 public override void GuardTypeSafety()
 {
     if (Nested == null || Nested.ReturnType == null)
     {
         return;
     }
     if (Nested.ReturnType != typeof(bool))
     {
         throw ConvertException.StaticTypeSafety(typeof(bool), Nested.ReturnType, Nested.ToString());
     }
     Nested.GuardTypeSafety();
 }
Ejemplo n.º 2
0
 public override void GuardTypeSafety()
 {
     if (Lhs == null || Rhs == null || Lhs.ReturnType == null || Rhs.ReturnType == null)
     {
         return;
     }
     if (Lhs.ReturnType != Rhs.ReturnType)
     {
         throw ConvertException.StaticTypeSafety(Lhs.ReturnType, Rhs.ReturnType, Rhs.ToString());
     }
     Lhs.GuardTypeSafety();
     Rhs.GuardTypeSafety();
 }
Ejemplo n.º 3
0
 public override void GuardTypeSafety()
 {
     if (Lhs == null || Lhs.ReturnType == null)
     {
         return;
     }
     if (Lhs.ReturnType != typeof(string))
     {
         throw ConvertException.StaticTypeSafety(typeof(bool), Lhs.ReturnType, Lhs.ToString());
     }
     Lhs.GuardTypeSafety();
     if (Rhs == null || Rhs.ReturnType == null)
     {
         return;
     }
     Rhs.GuardTypeSafety();
 }
 public override void GuardTypeSafety()
 {
     if (Condition?.ReturnType == null)
     {
         return;
     }
     if (Then?.ReturnType == null)
     {
         return;
     }
     if (Else?.ReturnType == null)
     {
         return;
     }
     if (Condition.ReturnType != typeof(bool))
     {
         throw ConvertException.StaticTypeSafety(typeof(bool), Condition.ReturnType, Condition.ToString());
     }
     //            if (Rhs.ReturnType != typeof(bool)) throw ConvertException.StaticTypeSafety(typeof(bool), Rhs.ReturnType, Rhs.ToString());
     //            Lhs.GuardTypeSafety();
     //            Rhs.GuardTypeSafety();
 }
Ejemplo n.º 5
0
 public override void GuardTypeSafety()
 {
     if (_function.IsParamsFunctions())
     {
         for (int i = 0; i < _nested.Nodes.Count; i++)
         {
             var        argumentType = i < _function.Arguments.Length?_function.Arguments[i].Type:_function.Arguments.Last().Type;
             Expression node         = _nested.Nodes[i];
             if (node == null || node.ReturnType == null ||
                 typeof(object).Equals(argumentType))
             {
                 continue;
             }
             if (_function.Arguments[i].Type.IsInterface)
             {
                 if (!node.ReturnType.GetInterfaces().Contains(argumentType))
                 {
                     throw ConvertException.StaticTypeSafety(argumentType, node.ReturnType,
                                                             node.ToString());
                 }
             }
             else
             {
                 if (node.ReturnType != _function.Arguments[i].Type)
                 {
                     throw ConvertException.StaticTypeSafety(argumentType, node.ReturnType,
                                                             node.ToString());
                 }
             }
             node.GuardTypeSafety();
         }
     }
     else
     {
         for (int i = 0; i < _function.Arguments.Length; i++)
         {
             Expression node = _nested.Nodes[i];
             if (node == null || node.ReturnType == null ||
                 typeof(object).Equals(_function.Arguments[i].Type))
             {
                 continue;
             }
             if (_function.Arguments[i].Type.IsInterface)
             {
                 if (!node.ReturnType.GetInterfaces().Contains(_function.Arguments[i].Type))
                 {
                     throw ConvertException.StaticTypeSafety(_function.Arguments[i].Type, node.ReturnType,
                                                             node.ToString());
                 }
             }
             else if ((_function.Arguments[i].Type != typeof(object) && !node.ReturnType.IsArray && !_function.Arguments[i].Type.IsArray) ||
                      (_function.Arguments[i].Type != typeof(object[]) && node.ReturnType.IsArray && _function.Arguments[i].Type.IsArray)
                      )
             {
                 if (node.ReturnType != _function.Arguments[i].Type)
                 {
                     throw ConvertException.StaticTypeSafety(_function.Arguments[i].Type, node.ReturnType,
                                                             node.ToString());
                 }
             }
             node.GuardTypeSafety();
         }
     }
 }