def _preprocess(self, source_lines, global_defines):
    # All defines in global + #defined in file
    file_defines = set(global_defines)

    # A stack of #ifdef scopes - for a given line to be included all must be
    # set to true
    inclusion_scopes = [True]

    target_lines = []
    for line in source_lines:
      line_included = all(inclusion_scopes)

      if line[0] == '#':
        line_included = False
        if line.startswith('#ifdef '):
          value = line[7:].strip()
          inclusion_scopes.append(value in file_defines)
        elif line.startswith('#else'):
          inclusion_scopes[-1] = not inclusion_scopes[-1]
        elif line.startswith('#endif'):
          inclusion_scopes.pop()
        elif line.startswith('#define '):
          value = line[8:].strip()
          file_defines.add(value)
        elif line.startswith('#undef '):
          value = line[7:].strip()
          file_defines.remove(value)

      if line_included:
        target_lines.append(line)

    return '\n'.join(target_lines)
dataset/ETHPy150Open google/anvil-build/anvil/rules/preprocessor_rules.py/_PreprocessFilesTask._preprocess/original