summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/ErrorInstance.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/runtime/ErrorInstance.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/JavaScriptCore/runtime/ErrorInstance.h')
-rw-r--r--Source/JavaScriptCore/runtime/ErrorInstance.h72
1 files changed, 40 insertions, 32 deletions
diff --git a/Source/JavaScriptCore/runtime/ErrorInstance.h b/Source/JavaScriptCore/runtime/ErrorInstance.h
index 91dd7ef0a..732b79a42 100644
--- a/Source/JavaScriptCore/runtime/ErrorInstance.h
+++ b/Source/JavaScriptCore/runtime/ErrorInstance.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2016 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,50 +18,58 @@
*
*/
-#ifndef ErrorInstance_h
-#define ErrorInstance_h
+#pragma once
-#include "Interpreter.h"
#include "JSObject.h"
+#include "RuntimeType.h"
#include "SourceProvider.h"
namespace JSC {
- class ErrorInstance : public JSNonFinalObject {
- public:
- typedef JSNonFinalObject Base;
+class ErrorInstance : public JSNonFinalObject {
+public:
+ typedef JSNonFinalObject Base;
- DECLARE_INFO;
+ enum SourceTextWhereErrorOccurred { FoundExactSource, FoundApproximateSource };
+ typedef String (*SourceAppender) (const String& originalMessage, const String& sourceText, RuntimeType, SourceTextWhereErrorOccurred);
- static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
- {
- return Structure::create(vm, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), info());
- }
+ DECLARE_EXPORT_INFO;
- static ErrorInstance* create(VM& vm, Structure* structure, const String& message, Vector<StackFrame> stackTrace = Vector<StackFrame>())
- {
- ErrorInstance* instance = new (NotNull, allocateCell<ErrorInstance>(vm.heap)) ErrorInstance(vm, structure);
- instance->finishCreation(vm, message, stackTrace);
- return instance;
- }
+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+ {
+ return Structure::create(vm, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), info());
+ }
- static ErrorInstance* create(ExecState* exec, Structure* structure, JSValue message, Vector<StackFrame> stackTrace = Vector<StackFrame>())
- {
- return create(exec->vm(), structure, message.isUndefined() ? String() : message.toString(exec)->value(exec), stackTrace);
- }
+ static ErrorInstance* create(ExecState* exec, VM& vm, Structure* structure, const String& message, SourceAppender appender = nullptr, RuntimeType type = TypeNothing, bool useCurrentFrame = true)
+ {
+ ErrorInstance* instance = new (NotNull, allocateCell<ErrorInstance>(vm.heap)) ErrorInstance(vm, structure);
+ instance->m_sourceAppender = appender;
+ instance->m_runtimeTypeForCause = type;
+ instance->finishCreation(exec, vm, message, useCurrentFrame);
+ return instance;
+ }
- bool appendSourceToMessage() { return m_appendSourceToMessage; }
- void setAppendSourceToMessage() { m_appendSourceToMessage = true; }
- void clearAppendSourceToMessage() { m_appendSourceToMessage = false; }
+ static ErrorInstance* create(ExecState*, Structure*, JSValue message, SourceAppender = nullptr, RuntimeType = TypeNothing, bool useCurrentFrame = true);
- protected:
- explicit ErrorInstance(VM&, Structure*);
+ static void addErrorInfo(ExecState*, VM&, JSObject*, bool = true);
- void finishCreation(VM&, const String&, Vector<StackFrame> = Vector<StackFrame>());
+ bool hasSourceAppender() const { return !!m_sourceAppender; }
+ SourceAppender sourceAppender() const { return m_sourceAppender; }
+ void setSourceAppender(SourceAppender appender) { m_sourceAppender = appender; }
+ void clearSourceAppender() { m_sourceAppender = nullptr; }
+ void setRuntimeTypeForCause(RuntimeType type) { m_runtimeTypeForCause = type; }
+ RuntimeType runtimeTypeForCause() const { return m_runtimeTypeForCause; }
+ void clearRuntimeTypeForCause() { m_runtimeTypeForCause = TypeNothing; }
- bool m_appendSourceToMessage;
- };
+ JS_EXPORT_PRIVATE String sanitizedToString(ExecState*);
-} // namespace JSC
+protected:
+ explicit ErrorInstance(VM&, Structure*);
+
+ void finishCreation(ExecState*, VM&, const String&, bool useCurrentFrame = true);
-#endif // ErrorInstance_h
+ SourceAppender m_sourceAppender { nullptr };
+ RuntimeType m_runtimeTypeForCause { TypeNothing };
+};
+
+} // namespace JSC