| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
| 6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
| 7 | 7 |
| 8 #include <iosfwd> | 8 #include <iosfwd> |
| 9 | 9 |
| 10 #include "src/assert-scope.h" | 10 #include "src/assert-scope.h" |
| (...skipping 6400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6411 // this through. Encoded in the 'flags' field. | 6411 // this through. Encoded in the 'flags' field. |
| 6412 inline v8::ScriptOriginOptions origin_options(); | 6412 inline v8::ScriptOriginOptions origin_options(); |
| 6413 inline void set_origin_options(ScriptOriginOptions origin_options); | 6413 inline void set_origin_options(ScriptOriginOptions origin_options); |
| 6414 | 6414 |
| 6415 DECLARE_CAST(Script) | 6415 DECLARE_CAST(Script) |
| 6416 | 6416 |
| 6417 // If script source is an external string, check that the underlying | 6417 // If script source is an external string, check that the underlying |
| 6418 // resource is accessible. Otherwise, always return true. | 6418 // resource is accessible. Otherwise, always return true. |
| 6419 inline bool HasValidSource(); | 6419 inline bool HasValidSource(); |
| 6420 | 6420 |
| 6421 // Convert code offset into column number. |
| 6422 static int GetColumnNumber(Handle<Script> script, int code_offset); |
| 6423 |
| 6424 // Convert code offset into (zero-based) line number. |
| 6425 // The non-handlified version does not allocate, but may be much slower. |
| 6426 static int GetLineNumber(Handle<Script> script, int code_offset); |
| 6427 int GetLineNumber(int code_pos); |
| 6428 |
| 6421 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); | 6429 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); |
| 6422 | 6430 |
| 6423 // Set eval origin for stack trace formatting. | 6431 // Set eval origin for stack trace formatting. |
| 6424 static void SetEvalOrigin(Handle<Script> script, | 6432 static void SetEvalOrigin(Handle<Script> script, |
| 6425 Handle<SharedFunctionInfo> outer, | 6433 Handle<SharedFunctionInfo> outer, |
| 6426 int eval_position); | 6434 int eval_position); |
| 6427 // Retrieve source position from where eval was called. | 6435 // Retrieve source position from where eval was called. |
| 6428 int GetEvalPosition(); | 6436 int GetEvalPosition(); |
| 6429 | 6437 |
| 6430 // Init line_ends array with source code positions of line ends. | 6438 // Init line_ends array with source code positions of line ends. |
| 6431 static void InitLineEnds(Handle<Script> script); | 6439 static void InitLineEnds(Handle<Script> script); |
| 6432 | 6440 |
| 6433 // Convert code offset into column number. | |
| 6434 static int GetColumnNumber(Handle<Script> script, int code_offset); | |
| 6435 | |
| 6436 // Convert code offset into (zero-based) line number. | |
| 6437 // The non-handlified version does not allocate, but may be much slower. | |
| 6438 static int GetLineNumber(Handle<Script> script, int code_offset); | |
| 6439 int GetLineNumber(int code_pos); | |
| 6440 | |
| 6441 // Carries information about a source position. | |
| 6442 struct PositionInfo { | |
| 6443 PositionInfo() : line(-1), column(-1), line_start(-1), line_end(-1) {} | |
| 6444 | |
| 6445 int line; // Zero-based line number. | |
| 6446 int column; // Zero-based column number. | |
| 6447 int line_start; // Position of first character in line. | |
| 6448 int line_end; // Position of last (non-linebreak) character in line. | |
| 6449 }; | |
| 6450 | |
| 6451 // Specifies whether to add offsets to position infos. | |
| 6452 enum OffsetFlag { NO_OFFSET = 0, WITH_OFFSET = 1 }; | |
| 6453 | |
| 6454 // Retrieves information about the given position, optionally with an offset. | |
| 6455 // Returns false on failure, and otherwise writes into the given info object | |
| 6456 // on success. | |
| 6457 bool GetPositionInfo(int position, PositionInfo* info, | |
| 6458 OffsetFlag offset_flag); | |
| 6459 | |
| 6460 // Get the JS object wrapping the given script; create it if none exists. | 6441 // Get the JS object wrapping the given script; create it if none exists. |
| 6461 static Handle<JSObject> GetWrapper(Handle<Script> script); | 6442 static Handle<JSObject> GetWrapper(Handle<Script> script); |
| 6462 | 6443 |
| 6463 // Look through the list of existing shared function infos to find one | 6444 // Look through the list of existing shared function infos to find one |
| 6464 // that matches the function literal. Return empty handle if not found. | 6445 // that matches the function literal. Return empty handle if not found. |
| 6465 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun); | 6446 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun); |
| 6466 | 6447 |
| 6467 // Iterate over all script objects on the heap. | 6448 // Iterate over all script objects on the heap. |
| 6468 class Iterator { | 6449 class Iterator { |
| 6469 public: | 6450 public: |
| (...skipping 4298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10768 } | 10749 } |
| 10769 return value; | 10750 return value; |
| 10770 } | 10751 } |
| 10771 }; | 10752 }; |
| 10772 | 10753 |
| 10773 | 10754 |
| 10774 } // NOLINT, false-positive due to second-order macros. | 10755 } // NOLINT, false-positive due to second-order macros. |
| 10775 } // NOLINT, false-positive due to second-order macros. | 10756 } // NOLINT, false-positive due to second-order macros. |
| 10776 | 10757 |
| 10777 #endif // V8_OBJECTS_H_ | 10758 #endif // V8_OBJECTS_H_ |
| OLD | NEW |