* @return Cons
   */
  public static Cons listModules(boolean kbOnlyP) {
    if (kbOnlyP) {
      { Cons value000 = Stella.NIL;

        { Module m = null;
          Iterator iter000 = Stella.allModules();
          Cons collect000 = null;

          while (iter000.nextP()) {
            m = ((Module)(iter000.value));
            if ((!((BooleanWrapper)(KeyValueList.dynamicSlotValue(m.dynamicSlots, Stella.SYM_STELLA_CODE_ONLYp, Stella.FALSE_WRAPPER))).wrapperValue) &&
                (!((BooleanWrapper)(KeyValueList.dynamicSlotValue(m.dynamicSlots, Stella.SYM_STELLA_NAMESPACEp, Stella.FALSE_WRAPPER))).wrapperValue)) {
              if (collect000 == null) {
                {
                  collect000 = Cons.cons(m, Stella.NIL);
                  if (value000 == Stella.NIL) {
                    value000 = collect000;
                  }
                  else {
                    Cons.addConsToEndOfConsList(value000, collect000);
                  }
                }
              }
              else {
                {
                  collect000.rest = Cons.cons(m, Stella.NIL);
                  collect000 = collect000.rest;
                }
              }
            }
          }
        }
        { Cons value001 = value000;

          return (value001);
        }
      }
    }
    else {
      { Cons value002 = Stella.NIL;

        { Module m = null;
          Iterator iter001 = Stella.allModules();
          Cons collect001 = null;

          while (iter001.nextP()) {
            m = ((Module)(iter001.value));
            if (collect001 == null) {
              {
                collect001 = Cons.cons(m, Stella.NIL);
                if (value002 == Stella.NIL) {
                  value002 = collect001;
                }
                else {
                  Cons.addConsToEndOfConsList(value002, collect001);
                }
              }
            }
            else {
              {
                collect001.rest = Cons.cons(m, Stella.NIL);
                collect001 = collect001.rest;
              }
            }
          }
        }
        { Cons value003 = value002;

          return (value003);
        }
      }
    }
  }