示例#1
0
 /**
  * Adds a source loader
  *
  * @param   lang.IClassLoader
  */
 public function addSourceLoader(\lang\IClassLoader $l)
 {
     $this->sourcepath[$l->hashCode()] = $l;
 }
示例#2
0
 /**
  * Unregister a class loader as a delegate
  *
  * @param   lang.IClassLoader l
  * @return  bool TRUE if the delegate was unregistered
  */
 public static function removeLoader(IClassLoader $l)
 {
     $id = $l->instanceId();
     if (isset(self::$delegates[$id])) {
         unset(self::$delegates[$id]);
         if (isset(self::$modules[$id])) {
             if (Module::$INCOMPLETE !== self::$modules[$id]) {
                 Module::remove(self::$modules[$id]);
             }
             unset(self::$modules[$id]);
         }
         return true;
     }
     return false;
 }
示例#3
0
 /**
  * Returns the XPClass object associated with the class with the given 
  * string name. Uses the default classloader if none is specified.
  *
  * @param   string name - e.g. "Exception", "io.File" or "lang.XPClass"
  * @param   lang.IClassLoader classloader default NULL
  * @return  lang.XPClass class object
  * @throws  lang.ClassNotFoundException when there is no such class
  */
 public static function forName($name, IClassLoader $classloader = null) : self
 {
     $p = strpos($name, '\\');
     if (false === $p) {
         // No backslashes, using dotted form
         $resolved = strtr($name, '.', '\\');
     } else {
         // Name literal
         $resolved = 0 === $p ? substr($name, 1) : $name;
         $name = strtr($resolved, '\\', '.');
     }
     if (class_exists($resolved, false) || interface_exists($resolved, false) || trait_exists($resolved, false)) {
         return new self($resolved);
     } else {
         if (null === $classloader) {
             return ClassLoader::getDefault()->loadClass($name);
         } else {
             return $classloader->loadClass($name);
         }
     }
 }