| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 // The infrastructure used for (localized) message reporting in V8. | 5 // The infrastructure used for (localized) message reporting in V8. |
| 6 // | 6 // |
| 7 // Note: there's a big unresolved issue about ownership of the data | 7 // Note: there's a big unresolved issue about ownership of the data |
| 8 // structures used by this framework. | 8 // structures used by this framework. |
| 9 | 9 |
| 10 #ifndef V8_MESSAGES_H_ | 10 #ifndef V8_MESSAGES_H_ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 int end_pos() const { return end_pos_; } | 35 int end_pos() const { return end_pos_; } |
| 36 Handle<JSFunction> function() const { return function_; } | 36 Handle<JSFunction> function() const { return function_; } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 Handle<Script> script_; | 39 Handle<Script> script_; |
| 40 int start_pos_; | 40 int start_pos_; |
| 41 int end_pos_; | 41 int end_pos_; |
| 42 Handle<JSFunction> function_; | 42 Handle<JSFunction> function_; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 |
| 46 class CallSite { |
| 47 public: |
| 48 CallSite(Isolate* isolate, Handle<JSObject> call_site_obj); |
| 49 |
| 50 Handle<Object> GetFileName(); |
| 51 Handle<Object> GetFunctionName(); |
| 52 Handle<Object> GetScriptNameOrSourceUrl(); |
| 53 Handle<Object> GetMethodName(); |
| 54 Handle<Object> GetTypeName(); |
| 55 Handle<Object> GetEvalOrigin(); |
| 56 // Return 1-based line number, including line offset. |
| 57 int GetLineNumber(); |
| 58 // Return 1-based column number, including column offset if first line. |
| 59 int GetColumnNumber(); |
| 60 bool IsNative(); |
| 61 bool IsToplevel(); |
| 62 bool IsEval(); |
| 63 bool IsConstructor(); |
| 64 |
| 65 bool IsJavaScript() { return !fun_.is_null(); } |
| 66 bool IsWasm() { return !wasm_obj_.is_null(); } |
| 67 |
| 68 int wasm_func_index() const { return wasm_func_index_; } |
| 69 |
| 70 private: |
| 71 Isolate* isolate_; |
| 72 Handle<Object> receiver_; |
| 73 Handle<JSFunction> fun_; |
| 74 int32_t pos_ = -1; |
| 75 Handle<JSObject> wasm_obj_; |
| 76 uint32_t wasm_func_index_ = static_cast<uint32_t>(-1); |
| 77 }; |
| 78 |
| 45 // Determines how stack trace collection skips frames. | 79 // Determines how stack trace collection skips frames. |
| 46 enum FrameSkipMode { | 80 enum FrameSkipMode { |
| 47 // Unconditionally skips the first frame. Used e.g. when the Error constructor | 81 // Unconditionally skips the first frame. Used e.g. when the Error constructor |
| 48 // is called, in which case the first frame is always a BUILTIN_EXIT frame. | 82 // is called, in which case the first frame is always a BUILTIN_EXIT frame. |
| 49 SKIP_FIRST, | 83 SKIP_FIRST, |
| 50 // Skip all frames until a specified caller function is seen. | 84 // Skip all frames until a specified caller function is seen. |
| 51 SKIP_UNTIL_SEEN, | 85 SKIP_UNTIL_SEEN, |
| 52 SKIP_NONE, | 86 SKIP_NONE, |
| 53 }; | 87 }; |
| 54 | 88 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 66 Handle<Object> arg0, Handle<Object> arg1, Handle<Object> arg2, | 100 Handle<Object> arg0, Handle<Object> arg1, Handle<Object> arg2, |
| 67 FrameSkipMode mode); | 101 FrameSkipMode mode); |
| 68 | 102 |
| 69 // Formats a textual stack trace from the given structured stack trace. | 103 // Formats a textual stack trace from the given structured stack trace. |
| 70 // Note that this can call arbitrary JS code through Error.prepareStackTrace. | 104 // Note that this can call arbitrary JS code through Error.prepareStackTrace. |
| 71 static MaybeHandle<Object> FormatStackTrace(Isolate* isolate, | 105 static MaybeHandle<Object> FormatStackTrace(Isolate* isolate, |
| 72 Handle<JSObject> error, | 106 Handle<JSObject> error, |
| 73 Handle<Object> stack_trace); | 107 Handle<Object> stack_trace); |
| 74 }; | 108 }; |
| 75 | 109 |
| 110 class CallSiteUtils : public AllStatic { |
| 111 public: |
| 112 static MaybeHandle<Object> Construct(Isolate* isolate, |
| 113 Handle<Object> receiver, |
| 114 Handle<Object> fun, Handle<Object> pos, |
| 115 Handle<Object> strict_mode); |
| 116 |
| 117 static MaybeHandle<String> ToString(Isolate* isolate, Handle<Object> recv); |
| 118 }; |
| 119 |
| 76 #define MESSAGE_TEMPLATES(T) \ | 120 #define MESSAGE_TEMPLATES(T) \ |
| 77 /* Error */ \ | 121 /* Error */ \ |
| 78 T(None, "") \ | 122 T(None, "") \ |
| 79 T(CyclicProto, "Cyclic __proto__ value") \ | 123 T(CyclicProto, "Cyclic __proto__ value") \ |
| 80 T(Debugger, "Debugger: %") \ | 124 T(Debugger, "Debugger: %") \ |
| 81 T(DebuggerLoading, "Error loading debugger") \ | 125 T(DebuggerLoading, "Error loading debugger") \ |
| 82 T(DefaultOptionsMissing, "Internal % error. Default options are missing.") \ | 126 T(DefaultOptionsMissing, "Internal % error. Default options are missing.") \ |
| 83 T(UncaughtException, "Uncaught %") \ | 127 T(UncaughtException, "Uncaught %") \ |
| 84 T(Unsupported, "Not supported") \ | 128 T(Unsupported, "Not supported") \ |
| 85 T(WrongServiceType, "Internal error, wrong service type: %") \ | 129 T(WrongServiceType, "Internal error, wrong service type: %") \ |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 static Handle<String> GetMessage(Isolate* isolate, Handle<Object> data); | 580 static Handle<String> GetMessage(Isolate* isolate, Handle<Object> data); |
| 537 static std::unique_ptr<char[]> GetLocalizedMessage(Isolate* isolate, | 581 static std::unique_ptr<char[]> GetLocalizedMessage(Isolate* isolate, |
| 538 Handle<Object> data); | 582 Handle<Object> data); |
| 539 }; | 583 }; |
| 540 | 584 |
| 541 | 585 |
| 542 } // namespace internal | 586 } // namespace internal |
| 543 } // namespace v8 | 587 } // namespace v8 |
| 544 | 588 |
| 545 #endif // V8_MESSAGES_H_ | 589 #endif // V8_MESSAGES_H_ |
| OLD | NEW |