示例#1
0
文件: Type.java 项目: nypgit/alto
 public static final Type For(Component.Type addr) {
   if (null != Instance)
     try {
       Reference ref = new Reference(Component.Type.Tools.For(addr));
       Type type = Instance.dereference(ref);
       if (null != type) {
         String name = type.getName();
         if (null == name) throw new alto.sys.Error.Bug();
       }
       return type;
     } catch (java.io.IOException exc) {
       return null;
     }
   else throw new alto.sys.Error.State.Init("alto.io.Tools not initialized");
 }
示例#2
0
文件: Type.java 项目: nypgit/alto
    /** Boostrap and validate type and rtype instances in the file cache. */
    public Tools init() {
      /*
       * Install
       */
      alto.lang.Type[] types = this.bootstrap();
      /*
       * Validate
       */
      alto.lang.Type test;

      for (alto.lang.Type type : types) {

        String name = type.getName();
        test = Type.Tools.For(name);
        if (type != test && (!type.equals(test))) throw new alto.sys.Error.Bug(name + '@' + type);

        String fext = type.getFext();
        test = Type.Tools.Of(fext);
        if (type != test && (!type.equals(test))) throw new alto.sys.Error.Bug(fext + '@' + type);
      }
      return this;
    }
示例#3
0
文件: Type.java 项目: nypgit/alto
 /** @return First best (practical) matching type */
 public Type best(Type compareto) {
   Type[] list = this.list;
   if (null == list) return null;
   else {
     int count = list.length;
     if (1 == count) return list[0];
     else {
       Type best = null;
       for (int cc = 0; cc < count; cc++) {
         Type test = list[cc];
         if (test.equals(compareto) || compareto.equals(test)) {
           if (null == best) best = test;
           else if (test.getQ() > best.getQ()) // (in-order preference when eq(q))
           best = test;
           else if (test.isPractical() && best.isNotPractical()) best = test;
         }
       }
       if (best.isPractical()) return best;
       else return null;
     }
   }
 }