Example #1
0
        public override void Bind(IntermediateBuilder context)
        {
            _op1.Bind(context);
            _op2.Bind(context);

            CodeType wideType = _op1.Type.GetWiderType(_op2.Type);



            if (wideType is UserType)
            {
                var user     = UserType.ToUserType(wideType);
                var overload = user.GetOperatorOverload(Op, context);

                if (overload != null)
                {
                    _overload = new InterCall(overload, new CodeValue[] { _op1, _op2 }, true);
                    _overload.SetOwner(Owner);
                    _overload.Bind(context);
                    return;
                }
            }

            if (_op1.Type != wideType)
            {
                _op1 = new ConvertedValue(_op1, wideType, Owner); _op1.Bind(context);
            }

            if (_op2.Type != wideType)
            {
                _op2 = new ConvertedValue(_op2, wideType, Owner); _op2.Bind(context);
            }
        }
        public override void Bind(IntermediateBuilder context)
        {
            if (_type != null)
            {
                return;
            }
            base.Bind(context);

            _owner.Bind(context);
            _param.Bind(context);

            _valType = _param.Type;
            _type    = GenericType.NewGenericType(UserType.ToUserType(context.ResolveType(new BasicTypeName("System.Collections.Generic.IEnumerator`1"))), new CodeType[] { _valType });
            CodeType ownerType = GenericType.NewGenericType(UserType.ToUserType(context.ResolveType(new BasicTypeName("System.Collections.Generic.IEnumerable`1"))), new CodeType[] { _valType });

            _call = new InterCall("GetEnumerator", new CodeValue[0], true, _owner)
            {
                ThisPointerTypeOverride = ownerType
            };
            _call.Bind(context);
        }