code: function (unloadedMods, errorList, stack, cache, ret) {
              var i, m, mod, modStatus,
                  stackDepth,
                  self = this;
  
              if ('@DEBUG@') {
                  stack = stack || [];
              }
              ret = ret || [];
              // 提高性能，不用每个模块都再次全部依赖计算
              // 做个缓存，每个模块对应的待动态加载模块
              cache = cache || {};
  
              for (i = 0; i < unloadedMods.length; i++) {
                  mod = unloadedMods[i];
                  m = mod.name;
  
                  if (cache[m]) {
                      continue;
                  }
  
                  if ('@DEBUG@') {
                      stackDepth = stack.length;
                  }
  
                  modStatus = mod.status;
                  if (modStatus === ERROR) {
                      errorList.push(mod);
                      cache[m] = 1;
                      continue;
                  }
                  if (modStatus > LOADED) {
                      cache[m] = 1;
                      continue;
                  } else if (modStatus !== LOADED && !mod.contains(self)) {
                      if (modStatus !== LOADING) {
                          mod.status = LOADING;
                          ret.push(mod);
                      }
                      mod.add(self);
                      self.wait(mod);
                  }
  
                  if ('@DEBUG@') {
                      // do not use indexOf, poor performance in ie8
                      if (stack[m]) {
                          S.log('find cyclic dependency between mods: ' + stack, 'warn');
                          cache[m] = 1;
                          continue;
                      } else {
                          stack[m] = 1;
                          stack.push(m);
                      }
                  }
  
                  self.calculate(mod.getNormalizedRequiredModules(), errorList, stack, cache, ret);
                  cache[m] = 1;
                  if ('@DEBUG@') {
                      for (var si = stackDepth; si < stack.length; si++) {
                          stack[stack[si]] = 0;
                      }
                      stack.length = stackDepth;
                  }
              }
  
              return ret;
          }
docs: calculate dependency