public void SpeculateType(IBoundType boundType, SpeculatedType type, bool definite)
            {
                if (
                    boundType.Kind != BoundTypeKind.Local &&
                    boundType.Kind != BoundTypeKind.Temporary &&
                    boundType.Kind != BoundTypeKind.Magic
                )
                    return;

                var speculations = GetSpeculations(boundType);

                if (definite)
                {
                    Debug.Assert(speculations.Type == type || speculations.Type == SpeculatedType.Unknown);

                    speculations.Type = type;
                    speculations.Definite = true;
                }
                else
                {
                    switch (type)
                    {
                        case SpeculatedType.Array: speculations.ArrayCount++; break;
                        case SpeculatedType.Object: speculations.ObjectCount++; break;
                        default: throw new InvalidOperationException();
                    }
                }
            }
示例#2
0
                public void SpeculateType(IBoundReadable target, SpeculatedType type, bool definite)
                {
                    var targetType = ResolveType(target);

                    if (targetType != null)
                    {
                    #if TRACE_SPECULATION
                        Trace.WriteLine("Speculating " + target + " to " + type + " definite " + definite);
                    #endif
                        _marker.SpeculateType(targetType, type, definite);
                    }
                }