// Copyright (c) 2019, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library vm.bytecode.options;

/// Collection of options for bytecode generator.
class BytecodeOptions {
  static Map<String, String> commandLineFlags = {
    'annotations': 'Emit Dart annotations',
    'local-var-info': 'Emit debug information about local variables',
    'debugger-stops': 'Emit bytecode instructions for stopping in the debugger',
    'show-bytecode-size-stat': 'Show bytecode size breakdown',
    'source-positions': 'Emit source positions',
    'instance-field-initializers': 'Emit separate instance field initializers',
    'keep-unreachable-code':
        'Do not remove unreachable code (useful if collecting code coverage)',
    'avoid-closure-call-instructions':
        'Do not emit closure call instructions (useful if collecting code '
            'coverage, as closure call instructions are not tracked by code '
            'coverage)',
  };

  bool enableAsserts;
  bool causalAsyncStacks;
  bool emitSourcePositions;
  bool emitSourceFiles;
  bool emitLocalVarInfo;
  bool emitDebuggerStops;
  bool emitAnnotations;
  bool emitInstanceFieldInitializers;
  bool omitAssertSourcePositions;
  bool keepUnreachableCode;
  bool avoidClosureCallInstructions;
  bool showBytecodeSizeStatistics;
  Map<String, String> environmentDefines;

  BytecodeOptions(
      {this.enableAsserts = false,
      this.causalAsyncStacks,
      this.emitSourcePositions = false,
      this.emitSourceFiles = false,
      this.emitLocalVarInfo = false,
      this.emitDebuggerStops = false,
      this.emitAnnotations = false,
      this.emitInstanceFieldInitializers = false,
      this.omitAssertSourcePositions = false,
      this.keepUnreachableCode = false,
      this.avoidClosureCallInstructions = false,
      this.showBytecodeSizeStatistics = false,
      this.environmentDefines = const <String, String>{}}) {
    causalAsyncStacks ??=
        environmentDefines['dart.developer.causal_async_stacks'] == 'true';
  }

  void parseCommandLineFlags(List<String> flags) {
    if (flags == null) {
      return;
    }
    for (String flag in flags) {
      switch (flag) {
        case 'source-positions':
          emitSourcePositions = true;
          break;
        case 'local-var-info':
          emitLocalVarInfo = true;
          break;
        case 'debugger-stops':
          emitDebuggerStops = true;
          break;
        case 'annotations':
          emitAnnotations = true;
          break;
        case 'instance-field-initializers':
          emitInstanceFieldInitializers = true;
          break;
        case 'keep-unreachable-code':
          keepUnreachableCode = true;
          break;
        case 'avoid-closure-call-instructions':
          avoidClosureCallInstructions = true;
          break;
        case 'show-bytecode-size-stat':
          showBytecodeSizeStatistics = true;
          break;
        default:
          throw 'Unexpected bytecode flag $flag';
      }
    }
  }
}
