script.tq 2.37 KB
Newer Older
Tobias Tebbi's avatar
Tobias Tebbi committed
1 2 3 4
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7 8 9 10 11 12
type CompilationType extends int32 constexpr 'Script::CompilationType';
type CompilationState extends int32 constexpr 'Script::CompilationState';

bitfield struct ScriptFlags extends uint31 {
  compilation_type: CompilationType: 1 bit;
  compilation_state: CompilationState: 1 bit;
  is_repl_mode: bool: 1 bit;
  origin_options: int32: 4 bit;
13 14
  // Whether an instrumentation breakpoint is set for this script (wasm only).
  break_on_entry: bool: 1 bit;
15 16
}

Tobias Tebbi's avatar
Tobias Tebbi committed
17
extern class Script extends Struct {
18 19 20 21
  // [source]: the script source.
  source: String|Undefined;

  // [name]: the script name.
Tobias Tebbi's avatar
Tobias Tebbi committed
22
  name: Object;
23 24

  // [line_offset]: script line offset in resource from where it was extracted.
Tobias Tebbi's avatar
Tobias Tebbi committed
25
  line_offset: Smi;
26 27 28

  // [column_offset]: script column offset in resource from where it was
  // extracted.
Tobias Tebbi's avatar
Tobias Tebbi committed
29
  column_offset: Smi;
30 31 32 33

  // [context_data]: context data for the context this script was compiled in.
  context_data: Smi|Undefined|Symbol;

Tobias Tebbi's avatar
Tobias Tebbi committed
34
  script_type: Smi;
35 36 37 38 39

  // [line_ends]: FixedArray of line ends positions.
  line_ends: FixedArray|Undefined;

  // [id]: the script id.
Tobias Tebbi's avatar
Tobias Tebbi committed
40
  id: Smi;
41

42 43 44 45 46 47
  // For scripts originating from eval: the SharedFunctionInfo contains the SFI
  // for the script. For scripts wrapped as functions: the FixedArray contains
  // the arguments. For web snapshots: the ObjectHashTable maps function start
  // position to SFI index in shared_function_infos.
  eval_from_shared_or_wrapped_arguments_or_sfi_table: SharedFunctionInfo|
      FixedArray|ObjectHashTable|Undefined;
Tobias Tebbi's avatar
Tobias Tebbi committed
48
  eval_from_position: Smi|Foreign;  // Smi or Managed<wasm::NativeModule>
49 50 51 52 53 54 55 56 57
  shared_function_infos: WeakFixedArray|WeakArrayList;

  // [flags]: Holds an exciting bitfield.
  flags: SmiTagged<ScriptFlags>;

  // [source_url]: sourceURL from magic comment
  source_url: String|Undefined;

  // [source_mapping_url]: sourceMappingURL magic comment
Tobias Tebbi's avatar
Tobias Tebbi committed
58
  source_mapping_url: Object;
59 60 61

  // [host_defined_options]: Options defined by the embedder.
  host_defined_options: FixedArray;
62 63 64 65 66

  // TODO(cbruni, v8:12302): remove once module callback API is updated.
  // Used to make sure we are backwards compatible with node to gaurantee
  // the same lifetime for ScriptOrModule as the Script they originated.
  @if(V8_SCRIPTORMODULE_LEGACY_LIFETIME) script_or_modules: ArrayList;
Tobias Tebbi's avatar
Tobias Tebbi committed
67
}