Parses linux drm trace events.
@constructor
19409
function DrmParser(importer) {
    Parser.call(this, importer);

    importer.registerEventHandler('drm_vblank_event',
        DrmParser.prototype.vblankEvent.bind(this));
  }
300646
Node parseInputs() {
    boolean devMode = options.devMode != DevMode.OFF;

    // If old roots exist (we are parsing a second time), detach each of the
    // individual file parse trees.
    externsRoot.detachChildren();
    jsRoot.detachChildren();

    Tracer tracer = newTracer(PassNames.PARSE_INPUTS);
    beforePass(PassNames.PARSE_INPUTS);

    try {
      // Parse externs sources.
      if (options.numParallelThreads > 1) {
        new PrebuildAst(this, options.numParallelThreads).prebuild(externs);
      }
      for (CompilerInput input : externs) {
        Node n = checkNotNull(input.getAstRoot(this));
        if (hasErrors()) {
          return null;
        }
        externsRoot.addChildToBack(n);
      }

      if (options.transformAMDToCJSModules) {
        processAMDModules(moduleGraph.getAllInputs());
      }

      if (options.getLanguageIn().toFeatureSet().has(FeatureSet.Feature.MODULES)
          || options.processCommonJSModules) {

        ModuleResolverFactory moduleResolverFactory = null;

        switch (options.getModuleResolutionMode()) {
          case BROWSER:
            moduleResolverFactory = BrowserModuleResolver.FACTORY;
            break;
          case NODE:
            // processJsonInputs requires a module loader to already be defined
            // so we redefine it afterwards with the package.json inputs
            moduleResolverFactory =
                new NodeModuleResolver.Factory(processJsonInputs(moduleGraph.getAllInputs()));
            break;
          case WEBPACK:
            moduleResolverFactory = new WebpackModuleResolver.Factory(inputPathByWebpackId);
            break;
          case BROWSER_WITH_TRANSFORMED_PREFIXES:
            moduleResolverFactory =
                new BrowserWithTransformedPrefixesModuleResolver.Factory(
                    options.getBrowserResolverPrefixReplacements());
            break;
        }

        this.moduleLoader =
            new ModuleLoader(
                null,
                options.moduleRoots,
                moduleGraph.getAllInputs(),
                moduleResolverFactory,
                ModuleLoader.PathResolver.RELATIVE,
                options.getPathEscaper());
      } else {
        // Use an empty module loader if we're not actually dealing with modules.
        this.moduleLoader = ModuleLoader.EMPTY;
      }

      if (options.getDependencyOptions().needsManagement()) {
        findModulesFromEntryPoints(
            options.getLanguageIn().toFeatureSet().has(Feature.MODULES),
            options.processCommonJSModules);
      } else if (options.needsTranspilationFrom(FeatureSet.ES6_MODULES)
          || options.processCommonJSModules) {
        if (options.getLanguageIn().toFeatureSet().has(Feature.MODULES)) {
          parsePotentialModules(moduleGraph.getAllInputs());
        }

        // Build a map of module identifiers for any input which provides no namespace.
        // These files could be imported modules which have no exports, but do have side effects.
        Map<String, CompilerInput> inputModuleIdentifiers = new HashMap<>();
        for (CompilerInput input : moduleGraph.getAllInputs()) {
          if (input.getKnownProvides().isEmpty()) {
            ModuleLoader.ModulePath modPath =
                moduleLoader.resolve(input.getSourceFile().getOriginalPath());
            inputModuleIdentifiers.put(modPath.toModuleName(), input);
          }
        }

        // Find out if any input attempted to import a module that had no exports.
        // In this case we must force module rewriting to occur on the imported file
        Map<String, CompilerInput> inputsToRewrite = new HashMap<>();
        for (CompilerInput input : moduleGraph.getAllInputs()) {
          for (String require : input.getKnownRequiredSymbols()) {
            if (inputModuleIdentifiers.containsKey(require)
                && !inputsToRewrite.containsKey(require)) {
              inputsToRewrite.put(require, inputModuleIdentifiers.get(require));
            }
          }
        }

        for (CompilerInput input : inputsToRewrite.values()) {
          input.setJsModuleType(CompilerInput.ModuleType.IMPORTED_SCRIPT);
        }
      }

      if (this.moduleLoader != null) {
        this.moduleLoader.setErrorHandler(this);
      }

      orderInputs();

      // If in IDE mode, we ignore the error and keep going.
      if (hasErrors()) {
        return null;
      }

      // Build the AST.
      if (options.numParallelThreads > 1) {
        new PrebuildAst(this, options.numParallelThreads).prebuild(moduleGraph.getAllInputs());
      }

      for (CompilerInput input : moduleGraph.getAllInputs()) {
        Node n = checkNotNull(input.getAstRoot(this));
        if (devMode) {
          runValidityCheck();
          if (hasErrors()) {
            return null;
          }
        }

        // TODO(johnlenz): we shouldn't need to check both isExternExportsEnabled and
        // externExportsPath.
        if (options.sourceMapOutputPath != null
            || options.isExternExportsEnabled()
            || options.externExportsPath != null
            || !options.replaceStringsFunctionDescriptions.isEmpty()) {

          // Annotate the nodes in the tree with information from the
          // input file. This information is used to construct the SourceMap.
          SourceInformationAnnotator sia =
              new SourceInformationAnnotator(
                  input.getName(), options.devMode != DevMode.OFF);
          NodeTraversal.traverse(this, n, sia);
        }

        if (NodeUtil.isFromTypeSummary(n)) {
          input.setIsExtern();
          externsRoot.addChildToBack(n);
        } else {
          jsRoot.addChildToBack(n);
        }
      }

      if (hasErrors()) {
        return null;
      }
      return externAndJsRoot;
    } finally {
      afterPass(PassNames.PARSE_INPUTS);
      stopTracer(tracer, PassNames.PARSE_INPUTS);
    }
  }
284574
function _osxPs() {
  const fieldsInfo = _.map({user: 'user', pid: 'pid', ppid: 'ppid', cmd: 'comm', full_cmd: 'command'}, (value, key) => {
    return {name: key, specifier: value};
  });

  // Parsing OS X version of ps seems very complicated, you cannot specify a separator
  // but specifying a header is possible. So we will specify a well known header pattern and
  // read each column size to be able to parse the rest
  const spacerLength = 100;
  const spacer = '_'.repeat(spacerLength);
  const specifiersArg = _.map(fieldsInfo, e => `${e.specifier}=${spacer}`).join(',');

  let firstLine = true;
  const sizes = [];
  return _ps(['wwaxo', specifiersArg], line => {
    // Use the first line (the header) to calculate all columns length
    if (firstLine) {
      const re = new RegExp(`(${spacer} *)`, 'g');
      let match = null;
      /* eslint-disable no-cond-assign */
      while ((match = re.exec(line)) !== null) {
        const field = match[1];
        sizes.push(field.length);
      }
      /* eslint-enable no-cond-assign */
      if (sizes.length !== fieldsInfo.length) throw new Error('Cannot parse ps output');
      firstLine = false;
      return null;
    }

    const process = {};
    let startIdx = 0;
    // Split the line using the column sizes
    _.each(sizes, (size, index) => {
      const value = line.slice(startIdx, startIdx + size).trim();
      startIdx += size;
      const key = fieldsInfo[index].name;
      process[key] = value;
    });
    return process;
  });
}
965153
function parseEvent(event) {
  var eventParts = event.match(/^((?:start|end|update)Element|text):?(.*)/);
  if (eventParts === null) {
    return null;
  }
  var eventType = eventParts[1];
  var selector = normalizeSelector(eventParts[2]);
  return {
    selector: selector,
    type: eventType,
    name: (eventParts[2]) ? eventType + ': ' + selector.normalized
                          : eventType
  };
}
552770
function get(data) {
    var parser = this
      , matches = [];

    //
    // Another npm oddity, it allows licenses to be specified in to different
    // properties. Because why the fuck not?
    //
    ['license', 'licenses'].forEach(function each(key) {
      if ('string' === typeof data[key]) {
        return matches.push(data[key]);
      }

      if (Array.isArray(data[key])) {
        return Array.prototype.push.apply(
          matches,
          data[key].map(function map(item) {
            return parser.license(item);
          }).filter(Boolean)
        );
      }

      if ('object' === typeof data[key] && parser.license(data[key])) {
        return Array.prototype.push.apply(
          matches,
          [parser.license(data[key])]
        );
      }
    });

    if (matches.length) return matches;
  }
225424
function parse_EncryptionInfo(blob) {
	var vers = parse_CRYPTOVersion(blob);
	switch(vers.Minor) {
		case 0x02: return [vers.Minor, parse_EncInfoStd(blob, vers)];
		case 0x03: return [vers.Minor, parse_EncInfoExt(blob, vers)];
		case 0x04: return [vers.Minor, parse_EncInfoAgl(blob, vers)];
	}
	throw new Error("ECMA-376 Encrypted file unrecognized Version: " + vers.Minor);
}
954497
function Detect(config) {
	var events = [];
	var api = {};
	var sysPackages = [];
	var numSysCmds = config.sysCmds.length;
	var numTests = 0;	// test counter

	// require detectionizr module(s)
	config.use.forEach(r, api);

	process.on("exit", function cleanup() {
		events.forEach(function(e,i,all) {
			all[i] = null;	// explicitly de-reference
		})
		events.splice(0, events.length);	// empty array
	});

	// public api
	api.require = r;
	api.detect = function(tests) {
		numTests = tests.length;
  		tests.forEach(detect, api);
  		return api;
	}
	api.on = function(event, fn, scope) {
		events.push([event, fn, scope]);
		return api;
	}
	api.overwrite = function(event, fn, scope) {
		events.forEach(function(e,i,all) {
			if(event === e)
				all.splice(i,1);
		});
		return api.on(event, fn, scope);
	}

	api.on("detect", function() {
		if(numTests === 1)
			events.forEach(function(event) {
				if(event[0] === "finally")
					event[1].call(event[2], api);
			});
	});

	return api;

	function detect(package) {
		//console.log(test);
		if(!r(package)) {
			if(api.child_process) {
				sysPackages.push([package, 0]);
				config.sysCmds.forEach(function(cmd) {
					sysProcess(package, cmd);
				});
			} else {
				console.warn("Weird butt nodejs distro - can not test non NPM packages.");
			}
		} else {
			numTests--;	// reduce test counter
			events.forEach(function(event) {
				if(event[0] === "detect")
					event[1].call(event[2], package, true);
			});
		}
	}

	function sysProcess(package, cmd) {
		var proc = api.child_process.spawn(cmd[0], cmd[1] ? [cmd[1], package] : [package]);
		proc.stdout.setEncoding("utf8");
		proc.stdout.on("data", sysHandler);
//		proc.stderr.on("data", sysHandler);
		proc.stdout.on('end', sysCounter);

		function sysHandler(input) {
			//console.log(input);
			if(input.length > 0) api[package] = true;
		}

		function sysCounter() {
			sysPackages.some(function find(syspackage) {
				if( syspackage[0] === package ) {
					syspackage[1]++;
//console.dir(sysPackages)
//console.log("%s has been tested %d times out of %d", package, syspackage[1], numSysCmds);
					if( numSysCmds === syspackage[1] ) {
						events.forEach(function(event) {
							if(event[0] === "detect")
								event[1].call(event[2], package, api[package]);
						});
						numTests--;	// reduce test counter
						return true;	// stop loop
					}
				}
			});
		}
	}

	function r(package) {
		try {
			api[package] = require(package);
		} catch(err) {
			//console.warn(err.toString());
			api[package] = false;
		} finally {
			return api[package];
		}
	}
}
633815
function readDotEnsimeValue(from, key) {
  var r = new RegExp("\\s*:" + key + " \"([^\"]*)\"\\s*$", "m");
  var m = from.match(r);
  if (m) return m[1];
  else return undefined;
}
1102476
function normalizeEvents(events)
{
  // start with converting falsy events into catch-all placeholder
  events = events || entryPoint;

  if (!Array.isArray(events))
  {
    events = [events];
  }

  // return shallow copy
  return events.concat();
}
710833
function parseExpr(source) {
    if (!source) {
        return;
    }

    if (typeof source === 'object' && source.type) {
        return source;
    }

    var expr = readTertiaryExpr(new Walker(source));
    expr.raw = source;
    return expr;
}
964139
function KernelFuncParser(importer) {
    LinuxPerfParser.call(this, importer);

    importer.registerEventHandler('graph_ent',
        KernelFuncParser.prototype.traceKernelFuncEnterEvent.
            bind(this));
    importer.registerEventHandler('graph_ret',
        KernelFuncParser.prototype.traceKernelFuncReturnEvent.
            bind(this));

    this.model_ = importer.model_;
    this.ppids_ = {};
  }
827519
function parse(dist) {
  return Object.keys(dist).map((id) => {
    let pid;

    if (id.slice(2, 6) === '0000') {
      pid = '';
    } else if (id.slice(4, 6) === '00') {
      pid = `${id.slice(0, 2)}0000`;
    } else {
      pid = `${id.slice(0, 4)}00`;
    }

    return { id, pid, name: dist[id] };
  });
}
248403
function parseTrack(cursor) {
    var chunk, events = [],
        result, runningStatus = null;

    chunk = parseChunk('MTrk', cursor);

    while (!chunk.eof()) {
        result = parseEvent(chunk, runningStatus);
        runningStatus = result.runningStatus;

        events.push(result.event);
    }

    return new Track(events);
}
108936
def ParseDownloadsRow(
      self, parser_mediator, query, row, **unused_kwargs):
    
    query_hash = hash(query)

    event_data = FirefoxDownloadEventData()
    event_data.full_path = self._GetRowValue(query_hash, row, 'target')
    event_data.mime_type = self._GetRowValue(query_hash, row, 'mimeType')
    event_data.name = self._GetRowValue(query_hash, row, 'name')
    event_data.offset = self._GetRowValue(query_hash, row, 'id')
    event_data.query = query
    event_data.received_bytes = self._GetRowValue(query_hash, row, 'currBytes')
    event_data.referrer = self._GetRowValue(query_hash, row, 'referrer')
    event_data.temporary_location = self._GetRowValue(
        query_hash, row, 'tempPath')
    event_data.total_bytes = self._GetRowValue(query_hash, row, 'maxBytes')
    event_data.url = self._GetRowValue(query_hash, row, 'source')

    timestamp = self._GetRowValue(query_hash, row, 'startTime')
    if timestamp:
      date_time = dfdatetime_posix_time.PosixTimeInMicroseconds(
          timestamp=timestamp)
      event = time_events.DateTimeValuesEvent(
          date_time, definitions.TIME_DESCRIPTION_START)
      parser_mediator.ProduceEventWithEventData(event, event_data)

    timestamp = self._GetRowValue(query_hash, row, 'endTime')
    if timestamp:
      date_time = dfdatetime_posix_time.PosixTimeInMicroseconds(
          timestamp=timestamp)
      event = time_events.DateTimeValuesEvent(
          date_time, definitions.TIME_DESCRIPTION_END)
      parser_mediator.ProduceEventWithEventData(event, event_data)
577442
function parse(fileString, callback) {
	try {
		return callback(null, Yaml.safeLoad(fileString));
	} catch (err) {
		return callback(err);
	}
}
949823
function readAllSecure(user, options) {
    // jscs:disable
    // jshint -W040
    const self = this;
    // jshint +W040
    // jscs:enable
    const shield = self.constructor.shield;
    const action = 'read';
    const rules = shield.getApplicableRules(action);
    return shield._fetchAll.call(self, options)
        .then(function runShieldRules(collection) {
            // TODO: investigate what happens if fetch returns nothing (err?)
            return collection.mapThen((mdl) => applyRules(rules, mdl, user))
                .then(function resolveResult() {
                    return collection;
                });
        });
}
1108768
function ParseFormat(md) {
    var formats = md.formats;
    if (!formats) {
      return null;
    }
    // Bail if we already parsed the format definitions.
    if (!(Array.isArray(formats[0])))
      return;
    for (var n = 0; n < formats.length; ++n) {
      formats[n] = ParseArray(formats[n],
                              FORMAT_ENCODING,
                              {});
    }
  }