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