5 #ifndef V8_OBJECTS_SCRIPT_H_ 6 #define V8_OBJECTS_SCRIPT_H_ 8 #include "src/objects.h" 9 #include "src/objects/fixed-array.h" 12 #include "src/objects/object-macros.h" 30 enum CompilationType { COMPILATION_TYPE_HOST = 0, COMPILATION_TYPE_EVAL = 1 };
33 enum CompilationState {
34 COMPILATION_STATE_INITIAL = 0,
35 COMPILATION_STATE_COMPILED = 1
39 DECL_ACCESSORS(source,
Object)
42 DECL_ACCESSORS(name,
Object)
45 DECL_INT_ACCESSORS(
id)
48 DECL_INT_ACCESSORS(line_offset)
52 DECL_INT_ACCESSORS(column_offset)
55 DECL_ACCESSORS(context_data,
Object)
58 DECL_INT_ACCESSORS(
type)
61 DECL_ACCESSORS(line_ends,
Object)
63 DECL_ACCESSORS(eval_from_shared_or_wrapped_arguments,
Object)
73 inline bool is_wrapped()
const;
77 inline bool has_eval_from_shared()
const;
82 DECL_INT_ACCESSORS(eval_from_position)
89 DECL_INT_ACCESSORS(flags)
92 DECL_ACCESSORS(source_url,
Object)
95 DECL_ACCESSORS(source_mapping_url,
Object)
99 DECL_ACCESSORS(wasm_module_object,
Object)
102 DECL_ACCESSORS2(host_defined_options,
FixedArray)
106 inline CompilationType compilation_type();
107 inline void set_compilation_type(CompilationType
type);
111 inline CompilationState compilation_state();
112 inline void set_compilation_state(CompilationState state);
124 inline bool HasValidSource();
126 Object* GetNameOrSourceURL();
129 int GetEvalPosition();
132 bool ContainsAsmModule();
139 PositionInfo() : line(-1), column(-1), line_start(-1), line_end(-1) {}
148 enum OffsetFlag { NO_OFFSET = 0, WITH_OFFSET = 1 };
158 PositionInfo* info, OffsetFlag offset_flag);
159 bool GetPositionInfo(
int position, PositionInfo* info,
160 OffsetFlag offset_flag)
const;
162 bool IsUserJavaScript();
165 static int GetColumnNumber(
Handle<Script> script,
int code_offset);
166 int GetColumnNumber(
int code_pos)
const;
168 int GetLineNumber(
int code_pos)
const;
190 static const int kSourceOffset = HeapObject::kHeaderSize;
191 static const int kNameOffset = kSourceOffset + kPointerSize;
192 static const int kLineOffsetOffset = kNameOffset + kPointerSize;
193 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize;
194 static const int kContextOffset = kColumnOffsetOffset + kPointerSize;
195 static const int kTypeOffset = kContextOffset + kPointerSize;
196 static const int kLineEndsOffset = kTypeOffset + kPointerSize;
197 static const int kIdOffset = kLineEndsOffset + kPointerSize;
198 static const int kEvalFromSharedOrWrappedArgumentsOffset =
199 kIdOffset + kPointerSize;
200 static const int kEvalFromPositionOffset =
201 kEvalFromSharedOrWrappedArgumentsOffset + kPointerSize;
202 static const int kSharedFunctionInfosOffset =
203 kEvalFromPositionOffset + kPointerSize;
204 static const int kFlagsOffset = kSharedFunctionInfosOffset + kPointerSize;
205 static const int kSourceUrlOffset = kFlagsOffset + kPointerSize;
206 static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize;
207 static const int kHostDefinedOptionsOffset =
208 kSourceMappingUrlOffset + kPointerSize;
209 static const int kSize = kHostDefinedOptionsOffset + kPointerSize;
213 static const int kCompilationTypeBit = 0;
214 static const int kCompilationStateBit = 1;
215 static const int kOriginOptionsShift = 2;
216 static const int kOriginOptionsSize = 4;
217 static const int kOriginOptionsMask = ((1 << kOriginOptionsSize) - 1)
218 << kOriginOptionsShift;
220 DISALLOW_IMPLICIT_CONSTRUCTORS(
Script);
226 #include "src/objects/object-macros-undef.h" 228 #endif // V8_OBJECTS_SCRIPT_H_