serialize method

Object serialize()

Converts this into a JSON-safe object that can be converted back to a Runtime using Runtime.deserialize.

Implementation

Object serialize() {
  if (builtIn.contains(this)) return identifier;

  if (parent != null) {
    return {
      'name': name,
      'defaultCompiler': defaultCompiler.serialize(),
      'supportedCompilers': [
        for (var compiler in supportedCompilers) compiler.serialize(),
      ],
      'identifier': identifier,
      'parent': parent!.serialize()
    };
  }

  return {
    'name': name,
    'defaultCompiler': defaultCompiler.serialize(),
    'supportedCompilers': [
      for (var compiler in supportedCompilers) compiler.serialize(),
    ],
    'identifier': identifier,
    'isDartVM': isDartVM,
    'isBrowser': isBrowser,
    'isBlink': isBlink,
    'isHeadless': isHeadless,
    // TODO(https://github.com/dart-lang/test/issues/2146): Remove this.
    'isJS': isBrowser || this == Runtime.nodeJS,
    // TODO(https://github.com/dart-lang/test/issues/2146): Remove this.
    'isWasm': false,
  };
}