コード例 #1
0
        private static ConstantValue XsDefaultValue(ParameterSymbol parameter, CSharpCompilation compilation)
        {
            TypeSymbol parameterType        = parameter.Type;
            var        defaultConstantValue = parameter.GetVODefaultParameter();

            if (defaultConstantValue == null)
            {
                return(null);
            }
            if (parameterType is NamedTypeSymbol &&
                ((NamedTypeSymbol)parameterType).ConstructedFrom == compilation.PszType())
            {
                if (defaultConstantValue.StringValue != null)
                {
                    // ToDo
                    // when the parameter is of type PSZ and there was a literal default string
                    // then Vulcan generates a special literal array in the calling code.
                    // For example Foo(s := "abcë" AS PSZ) becomes a
                    // Foo([DefaultParameterValue("abc\x00eb", 0)] __Psz s)
                    //
                    // and in the calling code the default parameter is stored as a field of the <Module> class
                    //
                    // .field assembly static valuetype $ArrayType$5 䌤㘲␵$PSZ$_15_1 = ((61 62 63 EB 00))
                    //
                    // and a type is declared for the array size of 5 bytes. This type is declared in the global namespace:
                    //
                    // [StructLayout(LayoutKind.Explicit, Size=5, Pack=1)]
                    //    public struct $ArrayType$5
                    //    {
                    //    }
                    //
                    // The call to the function becomes
                    // Foo((__Psz) &䌤㘲␵$PSZ$_15_1);
                    // Nikos can you implement something like this ?
                    //
                    defaultConstantValue = ConstantValue.Null;
                }
            }
            return(defaultConstantValue);
        }
コード例 #2
0
 static internal bool IsValidVOUsualType(this TypeSymbol type, CSharpCompilation compilation)
 {
     switch (type.SpecialType)
     {
     case SpecialType.System_Int32:
     case SpecialType.System_Int64:
     case SpecialType.System_Boolean:
     case SpecialType.System_String:
     case SpecialType.System_IntPtr:
     case SpecialType.System_Decimal:
     case SpecialType.System_DateTime:
     case SpecialType.System_Object:
         return(true);
     }
     if (type == compilation.ArrayType())
     {
         return(true);
     }
     if (type == compilation.CodeBlockType())
     {
         return(true);
     }
     if (type == compilation.DateType())
     {
         return(true);
     }
     if (type == compilation.FloatType())
     {
         return(true);
     }
     if (type == compilation.SymbolType())
     {
         return(true);
     }
     if (type == compilation.PszType())
     {
         return(true);
     }
     return(false);
 }