Beispiel #1
0
        internal RegisteredType GetRegisteredType(TypeDesc type)
        {
            RegisteredType existingRegistration;

            if (_registeredTypes.TryGetValue(type, out existingRegistration))
            {
                return(existingRegistration);
            }

            RegisteredType registration = new RegisteredType()
            {
                Type = type
            };

            _registeredTypes.Add(type, registration);

            // Register all base types too
            var baseType = type.BaseType;

            if (baseType != null)
            {
                GetRegisteredType(baseType);
            }

            return(registration);
        }
Beispiel #2
0
        public void AddVirtualSlot(MethodDesc method)
        {
            RegisteredType reg = GetRegisteredType(method.OwningType);

            if (reg.VirtualSlots == null)
            {
                reg.VirtualSlots = new List <MethodDesc>();
            }

            for (int i = 0; i < reg.VirtualSlots.Count; i++)
            {
                if (reg.VirtualSlots[i] == method)
                {
                    return;
                }
            }

            reg.VirtualSlots.Add(method);
        }
Beispiel #3
0
        public void AddType(TypeDesc type)
        {
            RegisteredType reg = GetRegisteredType(type);

            if (reg.IncludedInCompilation)
            {
                return;
            }
            reg.IncludedInCompilation = true;

            TypeDesc baseType = type.BaseType;

            if (baseType != null)
            {
                AddType(baseType);
            }
            if (type.IsArray)
            {
                AddType(((ArrayType)type).ElementType);
            }
        }
Beispiel #4
0
        public void AddMethod(MethodDesc method)
        {
            RegisteredMethod reg = GetRegisteredMethod(method);

            if (reg.IncludedInCompilation)
            {
                return;
            }
            reg.IncludedInCompilation = true;

            RegisteredType regType = GetRegisteredType(method.OwningType);

            if (regType.Methods == null)
            {
                regType.Methods = new List <RegisteredMethod>();
            }
            regType.Methods.Add(reg);

            if (_methodsThatNeedsCompilation == null)
            {
                _methodsThatNeedsCompilation = new List <MethodDesc>();
            }
            _methodsThatNeedsCompilation.Add(method);

            if (_options.IsCppCodeGen)
            {
                // Precreate name to ensure that all types referenced by signatures are present
                GetRegisteredType(method.OwningType);
                var signature = method.Signature;
                GetRegisteredType(signature.ReturnType);
                for (int i = 0; i < signature.Length; i++)
                {
                    GetRegisteredType(signature[i]);
                }
            }
        }