Exemplo n.º 1
0
        protected BoundVariable(IBoundType type)
        {
            if (type == null)
                throw new ArgumentNullException("type");

            Type = type;
        }
Exemplo n.º 2
0
        public BoundMagicType(BoundMagicVariableType magicType, IBoundType type)
        {
            if (type == null)
                throw new ArgumentNullException("type");

            MagicType = magicType;
            Type = type;
        }
Exemplo n.º 3
0
            public void MarkWrite(IBoundType type, BoundValueType valueType)
            {
                var internalType = (BoundType)type;

                if (type.Type == BoundValueType.Unset)
                    internalType.Type = valueType;
                else if (type.Type != valueType)
                    internalType.Type = BoundValueType.Unknown;
            }
Exemplo n.º 4
0
        public BoundClosureField(BoundClosure closure, IBoundType type)
            : base(type)
        {
            if (closure == null)
                throw new ArgumentNullException("closure");

            Closure = closure;
            Builder = closure.Builder.CreateClosureFieldBuilder(this);
        }
Exemplo n.º 5
0
        public BoundClosureField AddField(IBoundType type)
        {
            if (type == null)
                throw new ArgumentNullException("type");

            var field = new BoundClosureField(this, type);

            _fields.Add(field);

            return field;
        }
Exemplo n.º 6
0
            private Speculations GetSpeculations(IBoundType boundType)
            {
                if (_speculations == null)
                    _speculations = new Dictionary<IBoundType, Speculations>();

                Speculations speculations;
                if (!_speculations.TryGetValue(boundType, out speculations))
                {
                    speculations = new Speculations();
                    _speculations.Add(boundType, speculations);
                }

                return speculations;
            }
Exemplo n.º 7
0
            public void SpeculateType(IBoundType target, IBoundType source)
            {
                if (
                    (target.Kind != BoundTypeKind.Local && target.Kind != BoundTypeKind.Temporary) ||
                    (source.Kind != BoundTypeKind.Local && source.Kind != BoundTypeKind.Temporary)
                )
                    return;

                var sourceSpeculations = GetSpeculations(source);
                var targetSpeculations = GetSpeculations(target);

                if (sourceSpeculations.Definite)
                {
                    targetSpeculations.Definite = true;
                    targetSpeculations.Type = sourceSpeculations.Type;
                }
                else
                {
                    targetSpeculations.ArrayCount += sourceSpeculations.ArrayCount;
                    targetSpeculations.ObjectCount += sourceSpeculations.ObjectCount;
                }
            }
 public ObjectEmitter(CodeGenerator generator, IBoundType type)
     : base(generator, type)
 {
 }
Exemplo n.º 9
0
 public BoundTemporary(int index, IBoundType type)
     : base(type)
 {
     Index = index;
 }
 protected UnspeculatedEmitter(CodeGenerator generator, IBoundType type)
     : base(generator, type)
 {
 }
 public UnknownEmitter(CodeGenerator generator, IBoundType type)
     : base(generator, type)
 {
 }
 public SpeculatedDictionaryUnknownEmitter(CodeGenerator generator, IBoundType type)
     : base(generator, type)
 {
 }
 public SpeculatedArrayObjectEmitter(CodeGenerator generator, IBoundType type)
     : base(generator, type)
 {
 }
Exemplo n.º 14
0
            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();
                    }
                }
            }
 protected ValueEmitter(CodeGenerator generator, IBoundType type)
 {
     Generator = generator;
     Type = type;
 }
Exemplo n.º 16
0
 public BoundGlobal(bool isDeclared, IBoundType type)
     : base(isDeclared, type)
 {
 }
 protected LocalEmitter(CodeGenerator generator, IBoundType type)
     : base(generator, type)
 {
 }
Exemplo n.º 18
0
            private LocalEmitter CreateEmitter(IBoundType type)
            {
                switch (type.SpeculatedType)
                {
                    case SpeculatedType.Array:
                        Debug.Assert(type.Type == BoundValueType.Object || type.Type == BoundValueType.Unknown);

                        if (type.Type == BoundValueType.Object)
                            return new SpeculatedArrayObjectEmitter(Generator, type);
                        return new SpeculatedArrayUnknownEmitter(Generator, type);

                    case SpeculatedType.Object:
                        Debug.Assert(type.Type == BoundValueType.Object || type.Type == BoundValueType.Unknown);

                        if (type.Type == BoundValueType.Object)
                            return new SpeculatedDictionaryObjectEmitter(Generator, type);
                        return new SpeculatedDictionaryUnknownEmitter(Generator, type);

                    default:
                        if (type.Type == BoundValueType.Object)
                            return new ObjectEmitter(Generator, type);
                        return new UnknownEmitter(Generator, type);
                }
            }
Exemplo n.º 19
0
 protected BoundLocalBase(bool isDeclared, IBoundType type)
     : base(type)
 {
     IsDeclared = isDeclared;
 }