Esempio n. 1
0
 public virtual void Bind(IntermediateBuilder context)
 {
     if (Type == null)
     {
         Type = context.ResolveType(TypeName);
     }
 }
Esempio n. 2
0
 public void Bind(IntermediateBuilder builder)
 {
     BaseType = builder.ResolveType(BaseTypeName);
     if (Constructors.Count == 0)
     {
         Constructors.Add(new InterConstructor(this));
     }
 }
Esempio n. 3
0
        public override void Bind(IntermediateBuilder context)
        {
            base.Bind(context);

            if (_typeName == TypeName.Unknown)
            {
                return;
            }
            _type = context.ResolveType(_typeName);
        }
        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);
        }
Esempio n. 5
0
        public override void Bind(IntermediateBuilder context)
        {
            _owner?.Bind(context);
            if (_owningTypeName != TypeName.Unknown)
            {
                _owningType = UserType.ToUserType(context.ResolveType(_owningTypeName));
            }

            if (Field != null)
            {
                Type = Field.Type; return;
            }

            UserType type = (_owningType != null ? _owningType : _owner.Type) as UserType;

            if (_owningType == null)
            {
                _owningType = type;
            }

            IFieldWrapper matchField = null;

            var t = type;

            while (matchField == null && t != CodeType.Object)
            {
                foreach (var f in t.GetFields(context))
                {
                    if (f.Name == ID)
                    {
                        matchField = f; break;
                    }
                }
                if (matchField == null)
                {
                    t = t.GetBaseType();
                }
            }

            _owningType = t;

            //Debug.Assert(matchField != null);

            if (matchField == null)
            {
                return;
            }

            Type  = matchField.Type;
            Field = matchField;
        }
Esempio n. 6
0
        public override void Bind(IntermediateBuilder context)
        {
            if (Type == null)
            {
                Type = context.ResolveType(_convertName);
            }

            Original.Bind(context);
            var method = Type.GetConversionMethod(context, Original);

            if (method == null)
            {
                return;
            }
            _convertCall = new InterCall(method, true, Original);
            _convertCall.SetOwner(_owner);
            _convertCall.Bind(context);
        }
Esempio n. 7
0
        public override void Bind(IntermediateBuilder context)
        {
            foreach (var p in _parameters)
            {
                p.Bind(context);
            }

            _type = context.ResolveType(_typeName);

            _constructor = context.FindMostApplicableConstructor(_type as UserType, _parameters);


            for (int i = 0; i < _parameters.Length; i++)
            {
                if (_parameters[i].Type.CanAssignTo(_constructor.Arguments[i]) == AssignType.CanAssign)
                {
                    continue;
                }

                _parameters[i] = new ConvertedValue(_parameters[i], _constructor.Arguments[i], Owner);
                _parameters[i].Bind(context);
            }
        }
Esempio n. 8
0
        public override void Bind(IntermediateBuilder context)
        {
            if (_method == null)
            {
                foreach (var p in _parameters)
                {
                    p.Bind(context);
                }

                _thisPtr?.Bind(context);

                if (_resolver != null)
                {
                    _resolver.SetOwner(Owner);
                    _resolver.Bind(context);
                    _staticCall = _resolver.IsStatic;
                    if (!_staticCall)
                    {
                        _thisPtr = _resolver.GetReferencedFieldOrProperty();
                    }
                }

                CodeType type;
                if (_staticCall)
                {
                    type = _resolver.Type;
                }
                else if (_thisPtr == null)
                {
                    if (!_baseAccess)
                    {
                        type = new InterUserType(Owner.Owner);
                    }
                    else
                    {
                        type = UserType.ToUserType(Owner.Owner.BaseType);
                    }
                }
                else
                {
                    if (!_baseAccess)
                    {
                        type = _thisPtr.Type;
                    }
                    else
                    {
                        type = UserType.ToUserType(_thisPtr.Type).GetBaseType();
                    }
                }

                CodeType searchType;

                if (ThisPointerTypeOverride != null)
                {
                    searchType = ThisPointerTypeOverride;
                }
                else if (ThisPointerTypeNameOverride != TypeName.Unknown)
                {
                    searchType = context.ResolveType(ThisPointerTypeNameOverride);
                }
                else
                {
                    searchType = type;
                }

                _method = context.FindClosestFunction(_targetName, searchType, _parameters);
            }

            _return = _method.ReturnType;

            for (int i = 0; i < _parameters.Length; i++)
            {
                if (_parameters[i].Type.CanAssignTo(_method.Arguments[i].StoredType) == AssignType.CanAssign)
                {
                    continue;
                }

                _parameters[i] = new ConvertedValue(_parameters[i], _method.Arguments[i].StoredType, Owner);
                _parameters[i].Bind(context);
            }

            _valueType = _thisPtr != null &&
                         ((_thisPtr.Type is UserType &&
                           (_thisPtr.Type as UserType).ValueType) ||
                          _thisPtr.IsSymbol() && _thisPtr.Type is BasicType);

            if (_thisPtr == null)
            {
                return;
            }
            if (_thisPtr.Type is UserType && (_thisPtr.Type as UserType).ValueType)
            {
                _valueType = true;
            }
            if (_method.IsInstance && !_thisPtr.IsSymbol() && _thisPtr.Type is BasicType)
            {
                if (_thisPtr.ToSymbol() == null)
                {
                    _valueType = true;
                    LocalSymbol l = new LocalSymbol("locl" + Owner.Locals.Count, _thisPtr.Type, Owner.Locals.Count);
                    Owner.Locals.Add(l);
                    _symbolConversion = new InterCopy(l, _thisPtr);
                    _symbolConversion.SetOwner(Owner);
                    _symbolConversion.Bind(context);
                    _thisPtr = l;
                }
                else
                {
                    _thisPtr = _thisPtr.ToSymbol();
                }
            }
        }
Esempio n. 9
0
        public override void Bind(IntermediateBuilder context)
        {
            base.Bind(context);

            if (_rank == null)
            {
                foreach (var e in _entries)
                {
                    e.Bind(context);
                }
                _rank = new CodeValue(BasicType.Int32, _entries.Length);
            }

            _rank.Bind(context);



            _typeof = _type == TypeName.Unknown ? new ArrayType(_entries[0].Type) : (ArrayType)context.ResolveType(_type);
        }
Esempio n. 10
0
 public void Bind(IntermediateBuilder builder)
 {
     Type = builder.ResolveType(_typeName);
     Symbol.Bind(builder);
 }