コード例 #1
0
ファイル: RuleBuilder.cs プロジェクト: gaybro8777/ironruby
        public Expression MakeTestForTypes(Type[] types, int index)
        {
            Expression test = MakeTypeTest(types[index], index);

            if (index < types.Length - 1)
            {
                Expression nextTests = MakeTestForTypes(types, index + 1);
                if (ConstantCheck.Check(test, true))
                {
                    return(nextTests);
                }
                else if (ConstantCheck.Check(nextTests, true))
                {
                    return(test);
                }
                else
                {
                    return(Ast.AndAlso(test, nextTests));
                }
            }
            else
            {
                return(test);
            }
        }
コード例 #2
0
ファイル: TypeUtils.cs プロジェクト: stantoxt/dlr
        internal static bool CanAssign(Type to, Expression from) {
            if (CanAssign(to, from.Type)) return true;

            if (to.IsValueType() && 
                to.IsGenericType() && 
                to.GetGenericTypeDefinition() == typeof(Nullable<>) && 
                ConstantCheck.Check(from, null)) {
                return true;
            }

            return false;
        }