mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 23:57:25 +00:00
Instead of making it a void function, checking for an exception, and then receiving the relevant result via VM::last_value(), we can consolidate all of this by using completions. This allows us to remove more uses of VM::exception(), and all uses of VM::last_value().
28 lines
788 B
C++
28 lines
788 B
C++
/*
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/StringView.h>
|
|
#include <LibJS/Interpreter.h>
|
|
#include <LibJS/Lexer.h>
|
|
#include <LibJS/Parser.h>
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
|
{
|
|
auto js = StringView(static_cast<const unsigned char*>(data), size);
|
|
auto lexer = JS::Lexer(js);
|
|
auto parser = JS::Parser(lexer);
|
|
auto program = parser.parse_program();
|
|
if (!parser.has_errors()) {
|
|
auto vm = JS::VM::create();
|
|
auto interpreter = JS::Interpreter::create<JS::GlobalObject>(*vm);
|
|
(void)interpreter->run(interpreter->global_object(), *program);
|
|
}
|
|
return 0;
|
|
}
|