needed to defer loading of local conventions to avoid circular dependency issue
776557
def label_maker(self):
        
        if (not hasattr(graphBase, '_label_maker') or
            graphBase._label_maker.local_conventions != graphBase.local_conventions):
            graphBase._label_maker = LabelMaker(graphBase.local_conventions)

        return graphBase._label_maker
405748
function create(module, timeout, dependencyStack) {
      dependencyStack = dependencyStack.slice(0);
      if (module.name != null) dependencyStack.push(module.name);

      /* Already in cache? Why even bother? */
      if (cache[module.name]) return cache[module.name];

      /* Create an expiring Deferred, shortening the timeout */
      if (timeout < 50) timeout = 50;
      var deferred = new Deferred(timeout, "Timeout waiting for module '" + module.name + "'");

      /* ... and *IMMEDIATELY* cache the promise */
      if (module.name && (! module.$$dynamic)) {
        cache[module.name] = deferred.promise;
      }

      /* Calculate the module's direct dependencies */
      resolveDependencies(module).then(function(dependencies) {
        var parameters = [];

        /* Prepare parameters, either from cache or new creations */
        for (var i in dependencies) {
          var dependency = dependencies[i];

          /* Check for circular dependencies */
          var circularIndex = dependencyStack.indexOf(dependency.name);
          if (circularIndex >= 0) {
            var circularDependencies = dependencyStack.slice(circularIndex);
            throw new CircularDependencyError(circularDependencies);
          }

          if (cache[dependency.name]) {
            parameters.push(cache[dependency.name]);
          } else {
            parameters.push(create(dependency, timeout - 5, dependencyStack));
          }
        }

        /* When all parameters have been resolved... */
        return Promise.all(parameters).then(function(parameters) {
          return module.constructor.apply(module, parameters);
        });
      })

      /* Cache and resolve, or reject */
      .then(function(created) {
        if (module.name && (! module.$$dynamic)) cache[module.name] = created;
        deferred.resolve(created);
      }, function(failure) {
        deferred.reject(new InjectionError(module.name, failure));
      });

      /* Return the deferred promise */
      return deferred.promise;

    }
757858
function modPreDefine(id, dependencies, factory) {
        // 将模块存入容器
        //
        // 模块内部信息包括
        // -----------------------------------
        // id: module id
        // depsDec: 模块定义时声明的依赖
        // deps: 模块依赖，默认为['require', 'exports', 'module']
        // factory: 初始化函数或对象
        // factoryDeps: 初始化函数的参数依赖
        // exports: 模块的实际暴露对象（AMD定义）
        // config: 用于获取模块配置信息的函数（AMD定义）
        // state: 模块当前状态
        // require: local require函数
        // depMs: 实际依赖的模块集合，数组形式
        // depMkv: 实际依赖的模块集合，表形式，便于查找
        // depRs: 实际依赖的资源集合
        // ------------------------------------
        if (!modModules[id]) {
            modModules[id] = {
                id         : id,
                depsDec    : dependencies,
                deps       : dependencies || ['require', 'exports', 'module'],
                factoryDeps: [],
                factory    : factory,
                exports    : {},
                config     : moduleConfigGetter,
                state      : MODULE_PRE_DEFINED,
                require    : createLocalRequire(id),
                depMs      : [],
                depMkv     : {},
                depRs      : [],
                hang       : 0
            };
        }
    }
852860
def circular_references(self) -> Set[str]:
        
        rval = set()
        for k in self.grammarelts.keys():
            if k in self.dependency_closure(k):
                rval.add(k)
        return rval
900706
function resolveTransitiveDependencies(module, hash) {
    if (!(module instanceof Module)) {
      return Promise.reject("Unable to resolve module of type " + typeof(module));
    }

    var promises = [];
    for (var i in module.dependencies) {
      (function(dependencyName) {

        /* Ignore already resolved dependencies */
        if (hash[dependencyName]) return;

        /* Get a module or a promise to it and put it in the hash NOW! */
        var dependency = hash[dependencyName] = moduleOrPromise(dependencyName);

        /* Transitively resolve the dependency */
        promises.push(Promise.resolve(dependency).then(function(dependency) {
          hash[dependencyName] = dependency;
          return resolveTransitiveDependencies(dependency, hash);
        }));

      })(module.dependencies[i]);
    }

    return Promise.all(promises).then(function() {
      return hash;
    });
  }
667990
function makeLocalContext (store, namespace, path) {
  const noNamespace = namespace === ''

  const local = {
    dispatch: noNamespace ? store.dispatch : (_type, _payload, _options) => {
      const args = unifyObjectStyle(_type, _payload, _options)
      const { payload, options } = args
      let { type } = args

      if (!options || !options.root) {
        type = namespace + type
        if (process.env.NODE_ENV !== 'production' && !store._actions[type]) {
          console.error(`[vuex] unknown local action type: ${args.type}, global type: ${type}`)
          return
        }
      }

      return store.dispatch(type, payload)
    },

    commit: noNamespace ? store.commit : (_type, _payload, _options) => {
      const args = unifyObjectStyle(_type, _payload, _options)
      const { payload, options } = args
      let { type } = args

      if (!options || !options.root) {
        type = namespace + type
        if (process.env.NODE_ENV !== 'production' && !store._mutations[type]) {
          console.error(`[vuex] unknown local mutation type: ${args.type}, global type: ${type}`)
          return
        }
      }

      store.commit(type, payload, options)
    }
  }

  // getters and state object must be gotten lazily
  // because they will be changed by vm update
  Object.defineProperties(local, {
    getters: {
      get: noNamespace
        ? () => store.getters
        : () => makeLocalGetters(store, namespace)
    },
    state: {
      get: () => getNestedState(store.state, path)
    }
  })

  return local
}
486188
public void init(Object workingMemoryContext,
                     Object context,
                     Tuple tuple,
                     Declaration[] declarations,
                     WorkingMemory workingMemory) throws Exception {
        Object[] localVars = new Object[initUnit.getOtherIdentifiers().length];
        
        MVELAccumulatorFactoryContext factoryContext = (MVELAccumulatorFactoryContext)workingMemoryContext;
        VariableResolverFactory factory = factoryContext.getInitFactory();
        initUnit.updateFactory( null, tuple, localVars, (InternalWorkingMemory) workingMemory, workingMemory.getGlobalResolver(), factory );

        InternalKnowledgePackage pkg = workingMemory.getKnowledgeBase().getPackage( "MAIN" );
        if ( pkg != null ) {
            MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData( "mvel" );
            factory.setNextFactory( data.getFunctionFactory() );
        }

        MVELSafeHelper.getEvaluator().executeExpression( this.init,
                                null,
                                factory );
        
        
        DroolsVarFactory df = ( DroolsVarFactory ) factory.getNextFactory();
        if ( localVars.length > 0 ) {
            for ( int i = 0; i < df.getOtherVarsLength(); i++ ) {
                localVars[i] = factory.getIndexedVariableResolver( df.getOtherVarsPos() + i ).getValue();
            }
        }
        
        ((MVELAccumulatorContext) context).setVariables( localVars );
    }
1253172
function (callback) {

    var self = this;

    var warnings = null;

    async.series([
      // load domain files...
      function (callback) {
        debug('load denormalizer files..');
        self.structureLoader(self.options.denormalizerPath, function (err, tree, warns) {
          if (err) {
            return callback(err);
          }
          warnings = warns;
          self.tree = attachLookupFunctions(tree);
          callback(null);
        });
      },

      // prepare infrastructure...
      function (callback) {
        debug('prepare infrastructure...');
        async.parallel([

          // prepare repository...
          function (callback) {
            debug('prepare repository...');

            self.repository.on('connect', function () {
              self.emit('connect');
            });

            self.repository.on('disconnect', function () {
              self.emit('disconnect');
            });

            self.repository.connect(callback);
          },

          // prepare revisionGuard...
          function (callback) {
            debug('prepare revisionGuard...');

            self.revisionGuardStore.on('connect', function () {
              self.emit('connect');
            });

            self.revisionGuardStore.on('disconnect', function () {
              self.emit('disconnect');
            });

            self.revisionGuardStore.connect(callback);
          }
        ], callback);
      },

      // inject all needed dependencies...
      function (callback) {
        debug('inject all needed dependencies...');

        self.revisionGuard = new RevisionGuard(self.revisionGuardStore, self.options.revisionGuard);
        self.revisionGuard.onEventMissing(function (info, evt) {
          self.onEventMissingHandle(info, evt);
        });

        self.eventDispatcher = new EventDispatcher(self.tree, self.definitions.event);
        self.tree.defineOptions(self.options)
          .defineEvent(self.definitions.event)
          .defineNotification(self.definitions.notification)
          .idGenerator(self.getNewId)
          .useRepository(self.repository);

        self.revisionGuard.defineEvent(self.definitions.event);

        self.replayHandler = new ReplayHandler(self.eventDispatcher, self.revisionGuardStore, self.definitions.event, self.options);

        callback(null);
      }
    ], function (err) {
      if (err) {
        debug(err);
      }
      if (callback) { callback(err, warnings); }
    });
  }
1064145
function local_require(submod) {
			// Resolve local module symbol
			if(submod.slice(0, 1) === ".") {
				submod = path.join(path.dirname(sym.path), submod);

				// Outside bundle
				if(submod.slice(0, 2) === "..") {
					throw null; // Will be catched by the try{} in require
				}
			}
			
			// Try given name, if fails, add ".js" and try again
			var submod_sym;
			try {
				submod_sym = __nld.resolve(submod);
			} catch(e) {
				submod_sym = __nld.resolve(submod + ".js");
			}
			
			// Detect cycles
			function find_cycle_root(leaf) {
				if(leaf.id === submod_sym) {
					return leaf;
				} else if(leaf.parent) {
					return find_cycle_root(leaf.parent);
				} else {
					return false;
				}
			}
			
			var cycle_root = find_cycle_root(module);
			if(cycle_root) {
				return cycle_root.exports;
			}
			
			return __nld(submod_sym, undefined, module);
		}
291191
function convertLater(context, waiting, fn) {
	utils.forEach(waiting, function(p){
		var packageName = p.packageName;
		var requestedVersion = p.requestedVersion;

		var conv = context.deferredConversions;
		var pkg = conv[packageName];
		if(!pkg) pkg = conv[packageName] = {};
		var vers = pkg[requestedVersion];
		if(!vers) vers = pkg[requestedVersion] = [];
		vers.push(fn);
	});
}
910691
function(config, protoFactory, originalModule) {

		this.config = config;
		this.protoFactory = protoFactory;
		this.originalModule = originalModule || module;

		//defines if circular dependencies should throw an error or be gracefully handled
		this.allowCircular = this.config.allowCircular || false;
		this.modules = [];

		if(define.amd && typeof requirejs !== "undefined") {
			this._loader = require;
		} else if(define.amd && typeof curl !== "undefined") {
			this._loader = curl;
		} else {
			this._loader = this._commonRequire;
		}
	}
795712
function onLocalModuleBinding(ident, ast, acc) {
  traverse(ast, {
    CallExpression({ node: callExpression }) {
      // left must be a member expression
      if (t.isMemberExpression(callExpression.callee) === false) {
        return;
      }

      const memberExpression = callExpression.callee;

      /**
       * Search for `makeX().then(...)`
       */
      if (
        t.isCallExpression(memberExpression.object) &&
        memberExpression.object.callee.name === ident.name &&
        memberExpression.property.name === "then"
      ) {
        const [thenFnBody] = callExpression.arguments;

        if (typeof thenFnBody === "undefined") {
          return;
        }

        onInstanceThenFn(thenFnBody, acc);
      }
    }
  });
}
203520
function init (func) {
    func = ensureFunc(func);
    cache = undefined;
    deps = parseDepsFromFunc(func);
  }
495301
private void initializeQueue() {
        this.queue.clear();
        for (Map.Entry<String, NodeT> entry: nodeTable.entrySet()) {
            if (!entry.getValue().hasDependencies()) {
                this.queue.add(entry.getKey());
            }
        }
        if (queue.isEmpty()) {
            throw new IllegalStateException("Detected circular dependency");
        }
    }
403237
async function buildDirectDependentTree() {
  const dependents = new Map();

  for (const packageName of await _list()) {
    dependents.set(packageName, new Set());
  }

  for (const packageName of await _list()) {
    for (const dep of tree.get(packageName)) {
      dependents.get(dep).add(packageName);
    }
  }

  return dependents;
}
1190150
function(next) {
            core.allowPackages.forEach(function(pkg) {
                try {
                    var mod = path.dirname(require.resolve(pkg)).replace(/\/lib$/, "");
                    core.packages[pkg] = { path: mod };
                    if (lib.statSync(mod + "/etc").isDirectory()) {
                        core.packages[pkg].etc = 1;
                        var cfg = lib.readFileSync(mod + "/etc/config");
                        if (cfg) {
                            config = cfg + "\n" + config;
                            core.packages[pkg].config = 1;
                            core.parseConfig(cfg, 1);
                        }
                    }
                    ["modules","locales","views","web"].forEach(function(x) {
                        if (lib.statSync(mod + "/" + x).isDirectory()) {
                            core.path[x].unshift(mod + "/" + x);
                            core.packages[pkg][x] = 1;
                        }
                    });
                    logger.debug("init:", "npm package:", pkg, core.packages[pkg]);
                } catch(e) {
                    logger.error("init:", "npm package:", pkg, e);
                }
            });
            next();
        }
288606
private final void checkInvariants() throws Error {

        if (_lineBreak == null) {
            throw new Error("_lineBreak == null");
        } else if (_lineBreak == LineBreak.NONE && _indentation.length() > 0) {
            throw new Error("_lineBreak == LineBreak.NONE && _indentation = \"" + _indentation + "\".");
        } else if (_elementStack == null) {
            throw new Error("_elementStack (" + _elementStack + " == null");
        } else if (_elementStackSize < 0) {
            throw new Error("_elementStackSize (" + _elementStackSize + ") < 0");
        }
    }