blob: a0909c1ac3d03fc60864f9e8fe6416d64031d8bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
/*
* 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);
interpreter->run(interpreter->global_object(), *program);
}
return 0;
}
|