Example #1
0
 public static bool HasVODefaultParameter(this ParameterSymbol param)
 {
     if ((object)param != null)
     {
         var attrs = param.GetAttributes();
         foreach (var attr in attrs)
         {
             var atype = attr.AttributeClass;
             if (atype.IsOurAttribute(OurTypeNames.DefaultParameterAttribute))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #2
0
        public static TypeSymbol GetActualType(this ParameterSymbol parameter)
        {
            var type = parameter.Type;

            if (type.SpecialType == SpecialType.System_IntPtr)
            {
                var attrs = parameter.GetAttributes();
                foreach (var attr in attrs)
                {
                    var atype = attr.AttributeClass;
                    if (atype.IsOurAttribute(OurTypeNames.ActualTypeAttribute))
                    {
                        object t = attr.CommonConstructorArguments[0].DecodeValue <object>(SpecialType.None);
                        if (t is TypeSymbol)
                        {
                            type = (TypeSymbol)t;
                            break;
                        }
                    }
                }
            }
            return(type);
        }
Example #3
0
 public override ImmutableArray <CSharpAttributeData> GetAttributes()
 {
     return(_underlyingParameter.GetAttributes());
 }
Example #4
0
        public static ConstantValue GetVODefaultParameter(this ParameterSymbol param)
        {
            if ((object)param != null)
            {
                var attrs = param.GetAttributes();
                foreach (var attr in attrs)
                {
                    var atype = attr.AttributeClass;
                    if (atype.IsOurAttribute(OurTypeNames.DefaultParameterAttribute))
                    {
                        int desc = attr.CommonConstructorArguments[1].DecodeValue <int>(SpecialType.System_Int32);

                        var arg = attr.CommonConstructorArguments[0];
                        switch (desc)
                        {
                        case 0:
                            // normal .Net Object
                            // return value  or null
                            if (arg.Type != null && arg.Value != null)
                            {
                                if (arg.Type.SpecialType == SpecialType.None)
                                {
                                    // Enum type? can be casted to Int32
                                    return(ConstantValue.Create(arg.Value, SpecialType.System_Int32));
                                }
                                else
                                {
                                    return(ConstantValue.Create(arg.Value, arg.Type.SpecialType));
                                }
                            }
                            else
                            {
                                return(ConstantValue.Null);
                            }

                        case 1:
                            // NIL
                            return(ConstantValue.Null);

                        case 2:
                            // Date, value should be long of ticks. Return DateTime
                            DateTime dt = new DateTime((long)arg.Value);
                            return(ConstantValue.Create(dt));

                        case 3:
                            // Symbol, value should be a string literal or null
                            if (arg.Value == null)
                            {
                                return(ConstantValue.Null);
                            }
                            else
                            {
                                return(ConstantValue.Create((string)arg.Value));
                            }

                        case 4:
                            // Psz, value should be a string or null
                            if (arg.Value == null)
                            {
                                return(ConstantValue.Null);
                            }
                            else
                            {
                                return(ConstantValue.Create((string)arg.Value));
                            }

                        case 5:
                            // IntPtr, return value as IntPtr
                            if (arg.Value == null)
                            {
                                return(ConstantValue.Null);
                            }
                            else
                            {
                                int    i = arg.DecodeValue <int>(SpecialType.System_Int32);
                                IntPtr p = new IntPtr(i);
                                return(ConstantValue.Create(p));
                            }

                        default:
                            return(ConstantValue.Null);
                        }
                    }
                }
            }
            return(ConstantValue.Bad);
        }