コード例 #1
0
        public void AddType(Structure type)
        {
            // Find the previous group.
            ScopeMember oldMember = FindMember(type.GetName());

            if (oldMember != null)
            {
                if (!oldMember.IsTypeGroup())
                {
                    throw new ModuleException("expected type group.");
                }

                // Find the previous definition.
                TypeGroup oldGroup = (TypeGroup)oldMember;
                if (oldGroup.Find(type.GetGenericPrototype()) != null)
                {
                    throw new ModuleException("matching type already exists.");
                }

                // Add the type into the group.
                oldGroup.Insert(type);
            }
            else
            {
                // Create a new type group.
                TypeGroup newGroup = new TypeGroup(type.GetName(), this);
                newGroup.Insert(type);
                AddMember(newGroup);
            }
        }
コード例 #2
0
        public virtual Structure FindType(string name, GenericPrototype prototype)
        {
            // Find the member.
            ScopeMember member = FindMember(name);

            if (member == null)
            {
                return(null);
            }

            // Use the matching type in the type group.
            if (member.IsTypeGroup())
            {
                TypeGroup group = (TypeGroup)member;
                return(group.Find(prototype));
            }
            else if (!member.IsClass() && !member.IsInterface() && !member.IsStructure())
            {
                throw new ModuleException("found no structural type " + member.GetFullName());
            }

            // Cast the member.
            return((Structure)member);
        }