<commit_before>(function(functionNames, operationTypes) {
  var global = Function("return this")();
  if (global.__didInitializeDataFlowTracking) {
    return;
  }
  global.__didInitializeDataFlowTracking = true;

  var argTrackingInfo = null;
  global[functionNames.makeCall] = function _makeCall(
    fn,
    object,
    objectKey,
    args
  ) {
    // console.log({fn, object, objectKey, args})
    if (fn) {
      // not called as part of a member expresison
      object = this;
    } else if (typeof object !== "undefined") {
      fn = object[objectKey];
    } else {
      debugger;
      throw Error("Can't find which function to call");
    }
    argTrackingInfo = args.map(arg => ({
      type: operationTypes.functionArgument,
      argValues: [ret],
      argTrackingValues: [arg[1]],
      fnToString: fn.toString(),
      resVal: [arg[0]]
    }));
    var argValues = args.map(arg => arg[0]);
    var ret = fn.apply(object, argValues);

    // debugger;
    lastOpValueResult = ret;
    lastOpTrackingResult = {
      type: operationTypes.functionReturnValue,
      argValues,
      argTrackingValues: [lastOpTrackingResult],
      resVal: ret,
      fnToString: [fn.toString()]
    };

    argTrackingInfo = null;

    return ret;
  };

  global[
    functionNames.getFunctionArgTrackingInfo
  ] = function getArgTrackingInfo(index) {
    if (!argTrackingInfo) {
      console.log("no arg tracking info...");
      return { info: "none" };
    }
    return argTrackingInfo[index];
  };

  global.getTrackingAndNormalValue = function(value) {
    return {
      normal: value,
      tracking: argTrackingInfo[0]
    };
  };

  const objTrackingMap = new Map();
  function trackObjectPropertyAssignment(obj, propName, trackingValue) {
    // console.log("setting to", obj, propName, trackingValue);
    var objectPropertyTrackingInfo = objTrackingMap.get(obj);
    if (!objectPropertyTrackingInfo) {
      objectPropertyTrackingInfo = {};
      objTrackingMap.set(obj, objectPropertyTrackingInfo);
    }
    objectPropertyTrackingInfo[propName] = trackingValue;
  }
  function getObjectPropertyTrackingValue(obj, propName) {
    var objectPropertyTrackingInfo = objTrackingMap.get(obj);
    if (!objectPropertyTrackingInfo) {
      return null;
    }
    return objectPropertyTrackingInfo[propName];
  }

  var lastOpValueResult = null;
  var lastOpTrackingResult = null;
  global[functionNames.doOperation] = function op(opName, ...args) {
    // console.log(opName, JSON.stringify(args, null, 4));
    var value, trackingValue;
    var argValues = args.map(arg => arg[0]);
    var argTrackingValues = args.map(arg => arg[1]);
    var extraTrackingValues = [];
    var ret;
    if (opName === "stringLiteral") {
      ret = argValues[0];
    } else if (opName === "identifier") {
      ret = argValues[0];
    } else if (opName === "returnStatement") {
      ret = argValues[0];
    } else if (opName === "evaluateAssignment") {
      ret = argValues[0];
    } else if (opName === operationTypes.binaryExpression) {
      var [operation, left, right] = argValues;
      if (operation === "+") {
        ret = left + right;
      } else {
        throw Error("unknown bine exp operation");<commit_msg>Make function call just another operation<commit_after>(function(functionNames, operationTypes) {
  var global = Function("return this")();
  if (global.__didInitializeDataFlowTracking) {
    return;
  }
  global.__didInitializeDataFlowTracking = true;

  var argTrackingInfo = null;
  global[functionNames.makeCall] = function _makeCall(
    fn,
    object,
    objectKey,
    args
  ) {
    return global[functionNames.doOperation](
      operationTypes.functionReturnValue,
      [fn, null],
      [object, null],
      [objectKey, null],
      ...args
    );
  };

  global[
    functionNames.getFunctionArgTrackingInfo
  ] = function getArgTrackingInfo(index) {
    if (!argTrackingInfo) {
      console.log("no arg tracking info...");
      return { info: "none" };
    }
    return argTrackingInfo[index];
  };

  global.getTrackingAndNormalValue = function(value) {
    return {
      normal: value,
      tracking: argTrackingInfo[0]
    };
  };

  const objTrackingMap = new Map();
  function trackObjectPropertyAssignment(obj, propName, trackingValue) {
    // console.log("setting to", obj, propName, trackingValue);
    var objectPropertyTrackingInfo = objTrackingMap.get(obj);
    if (!objectPropertyTrackingInfo) {
      objectPropertyTrackingInfo = {};
      objTrackingMap.set(obj, objectPropertyTrackingInfo);
    }
    objectPropertyTrackingInfo[propName] = trackingValue;
  }
  function getObjectPropertyTrackingValue(obj, propName) {
    var objectPropertyTrackingInfo = objTrackingMap.get(obj);
    if (!objectPropertyTrackingInfo) {
      return null;
    }
    return objectPropertyTrackingInfo[propName];
  }

  var lastOpValueResult = null;
  var lastOpTrackingResult = null;
  global[functionNames.doOperation] = function op(opName, ...args) {
    var value, trackingValue;
    var argValues = args.map(arg => arg[0]);
    var argTrackingValues = args.map(arg => arg[1]);
    var extraTrackingValues = [];
    var ret;
    if (opName === operationTypes.functionReturnValue) {
      var [__, ___, ____, ...fnArgs] = args;
      var [fn, object, objectKey] = argValues;
      if (fn) {
        // not called as part of a member expresison
        object = this;
      } else if (typeof object !== "undefined") {
        fn = object[objectKey];
      } else {
        throw Error("Can't find which function to call");
      }
      argTrackingInfo = fnArgs.map(arg => ({
        type: operationTypes.functionArgument,
        argValues: [ret],
        argTrackingValues: [arg[1]],
        fnToString: fn.toString(),
        resVal: [arg[0]]
      }));
      var fnArgValues = fnArgs.map(arg => arg[0]);
      ret = fn.apply(object, fnArgValues);
      argTrackingInfo = null;

      // TODO: I don't think this is what this should be...
      // I should not need a special case!
      lastOpTrackingResult = {
        type: operationTypes.functionReturnValue,
        argValues: fnArgValues,
        argTrackingValues: [lastOpTrackingResult],
        resVal: ret,
        fnToString: [fn.toString()]
      };

      lastOpValueResult = ret;

      return ret;
    } else if (opName === "stringLiteral") {
      ret = argValues[0];
    } else if (opName === "identifier") {
      ret = argValues[0];
    } else if (opName === "returnStatement") {
      ret = argValues[0];
    } else if (opName === "evaluateAssignment") {
      ret = argValues[0];
    } else if (opName === operationTypes.binaryExpression) {
      var [operation, left, right] = argValues;
      if (operation === "+") {
        ret = left + right;
      } else {
        throw Error("unknown bine exp operation");
{'fraction_non_alphanumeric': 0.12254470829668719, 'fraction_numerical': 0.0030782761653474055, 'mean_word_length': 2.9807467911318555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4622990', 'n_tokens_mistral': 2042, 'n_tokens_neox': 2030, 'n_words': 471}