Example #1
0
        public IComparable /*?*/ GetValue(InterpretationContext context)
        {
            if (!field.IsStatic)
            {
                // TO DO: Implement instance field maps
                Map <LabeledInstance, IComparable /*?*/> result = Map <LabeledInstance, IComparable /*?*/> .EmptyMap;

                Symbol sort = AbstractValue.TypeSort(field.DeclaringType);
                foreach (LabeledInstance instance in context.InstancePoolValues(sort))
                {
                    object obj = field.GetValue(instance);
                    if (obj == null)
                    {
                        result = result.Add(instance, null);
                    }
                    else
                    {
                        IComparable comparable = obj as IComparable;
                        if ((object)comparable == null)
                        {
                            throw new ArgumentException(MessageStrings.LocalizedFormat(MessageStrings.RuntimeTypeError, typeof(IComparable).ToString(), obj.GetType().ToString()));
                        }
                        result = result.Add(instance, comparable);
                    }
                }
                return(result);
            }
            else
            {
                object obj = field.GetValue(null);
                if (obj == null)
                {
                    return(null);
                }

                IComparable comparable = obj as IComparable;
                if ((object)comparable == null)
                {
                    throw new ArgumentException(MessageStrings.LocalizedFormat(MessageStrings.RuntimeTypeError, typeof(IComparable).ToString(), obj.GetType().ToString()));
                }
                return(comparable);
            }
        }