1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:47:45 +00:00

LibJS: Add all the Error subclasses

This patch adds instance, constructor and prototype classes for:

    - EvalError
    - InternalError
    - RangeError
    - ReferenceError
    - SyntaxError
    - TypeError
    - URIError

Enumerator macros are used to reduce the amount of typing. :^)
This commit is contained in:
Andreas Kling 2020-04-10 12:42:33 +02:00
parent df7b617ba1
commit 58ab76269c
11 changed files with 157 additions and 7 deletions

View file

@ -139,12 +139,18 @@ public:
Object* string_prototype() { return m_string_prototype; }
Object* object_prototype() { return m_object_prototype; }
Object* array_prototype() { return m_array_prototype; }
Object* error_prototype() { return m_error_prototype; }
Object* date_prototype() { return m_date_prototype; }
Object* function_prototype() { return m_function_prototype; }
Object* number_prototype() { return m_number_prototype; }
Object* boolean_prototype() { return m_boolean_prototype; }
Object* error_prototype() { return m_error_prototype; }
#define __JS_ENUMERATE_ERROR_SUBCLASS(TitleCase, snake_case) \
Object* snake_case##_prototype() { return m_##snake_case##_prototype; }
JS_ENUMERATE_ERROR_SUBCLASSES
#undef __JS_ENUMERATE_ERROR_SUBCLASS
Exception* exception() { return m_exception; }
void clear_exception() { m_exception = nullptr; }
@ -178,12 +184,18 @@ private:
Object* m_string_prototype { nullptr };
Object* m_object_prototype { nullptr };
Object* m_array_prototype { nullptr };
Object* m_error_prototype { nullptr };
Object* m_date_prototype { nullptr };
Object* m_function_prototype { nullptr };
Object* m_number_prototype { nullptr };
Object* m_boolean_prototype { nullptr };
Object* m_error_prototype { nullptr };
#define __JS_ENUMERATE_ERROR_SUBCLASS(TitleCase, snake_case) \
Object* m_##snake_case##_prototype;
JS_ENUMERATE_ERROR_SUBCLASSES
#undef __JS_ENUMERATE_ERROR_SUBCLASS
Exception* m_exception { nullptr };
ScopeType m_unwind_until { ScopeType::None };