Beispiel #1
0
        /// <summary>
        /// Add a class to this Scope.  If the class already exists,
        /// throw an exception.
        /// </summary>
        /// <param name="nsName">name space name</param>
        /// <param name="name">class name</param>
        /// <returns>a descriptor for this class in another module</returns>
        public virtual ClassRef AddClass(string nsName, string name)
        {
            Contract.Requires(nsName != null);
            Contract.Requires(name != null);
            ClassRef aClass = GetClass(nsName, name);

            if (aClass != null)
            {
                if ((aClass is SystemClass) && (!((SystemClass)aClass).added))
                {
                    ((SystemClass)aClass).added = true;
                }
                else
                {
                    throw new DescriptorException("Class " + aClass.NameString());
                }
            }
            else
            {
                aClass = new ClassRef(this, nsName, name);
                classes.Add(aClass);
            }
            // FIXME Contract.Ensures(aClass != null);
            return(aClass);
        }
Beispiel #2
0
 internal override string NameString()
 {
     if (parent == null)
     {
         return(Name);
     }
     return(parent.NameString() + "+" + Name);
 }
Beispiel #3
0
        /// <summary>
        /// Add a class to this Scope.  If this class already exists, throw
        /// an exception
        /// </summary>
        /// <param name="newClass">The class to be added</param>
        public void AddClass(ClassRef newClass)
        {
            Contract.Requires(newClass != null);
            ClassRef aClass = (ClassRef)GetClass(newClass.NameSpace, newClass.Name, true);

            if (aClass != null)
            {
                throw new DescriptorException("Class " + newClass.NameString());
            }
            if (Diag.DiagOn)
            {
                Console.WriteLine("Adding class " + newClass.Name + " to ResolutionScope " + name);
            }
            classes.Add(newClass);
            // Change Refs to Defs here
            newClass.SetScope(this);
        }
Beispiel #4
0
 /// <summary>
 /// Add a class to this Scope.  If this class already exists, throw
 /// an exception
 /// </summary>
 /// <param name="newClass">The class to be added</param>
 public void AddClass(ClassRef newClass)
 {
     Contract.Requires(newClass != null);
     ClassRef aClass = (ClassRef)GetClass(newClass.NameSpace, newClass.Name, true);
     if (aClass != null)
         throw new DescriptorException("Class " + newClass.NameString());
     if (Diag.DiagOn) Console.WriteLine("Adding class " + newClass.Name + " to ResolutionScope " + name);
     classes.Add(newClass);
     // Change Refs to Defs here
     newClass.SetScope(this);
 }