mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:48:11 +00:00
js: Add --use-test262-global option
Add --use-test262-global option to expose the test262 global object instead of normal script object.
This commit is contained in:
parent
080b4e5e27
commit
2cd4f135f0
1 changed files with 9 additions and 1 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include <LibJS/Bytecode/Generator.h>
|
#include <LibJS/Bytecode/Generator.h>
|
||||||
#include <LibJS/Bytecode/Interpreter.h>
|
#include <LibJS/Bytecode/Interpreter.h>
|
||||||
#include <LibJS/Console.h>
|
#include <LibJS/Console.h>
|
||||||
|
#include <LibJS/Contrib/Test262/GlobalObject.h>
|
||||||
#include <LibJS/Interpreter.h>
|
#include <LibJS/Interpreter.h>
|
||||||
#include <LibJS/Parser.h>
|
#include <LibJS/Parser.h>
|
||||||
#include <LibJS/Print.h>
|
#include <LibJS/Print.h>
|
||||||
|
@ -599,6 +600,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
bool gc_on_every_allocation = false;
|
bool gc_on_every_allocation = false;
|
||||||
bool disable_syntax_highlight = false;
|
bool disable_syntax_highlight = false;
|
||||||
bool disable_debug_printing = false;
|
bool disable_debug_printing = false;
|
||||||
|
bool use_test262_global = false;
|
||||||
StringView evaluate_script;
|
StringView evaluate_script;
|
||||||
Vector<StringView> script_paths;
|
Vector<StringView> script_paths;
|
||||||
|
|
||||||
|
@ -616,6 +618,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
args_parser.add_option(disable_syntax_highlight, "Disable live syntax highlighting", "no-syntax-highlight", 's');
|
args_parser.add_option(disable_syntax_highlight, "Disable live syntax highlighting", "no-syntax-highlight", 's');
|
||||||
args_parser.add_option(disable_debug_printing, "Disable debug output", "disable-debug-output", {});
|
args_parser.add_option(disable_debug_printing, "Disable debug output", "disable-debug-output", {});
|
||||||
args_parser.add_option(evaluate_script, "Evaluate argument as a script", "evaluate", 'c', "script");
|
args_parser.add_option(evaluate_script, "Evaluate argument as a script", "evaluate", 'c', "script");
|
||||||
|
args_parser.add_option(use_test262_global, "Use test262 global ($262)", "use-test262-global", {});
|
||||||
args_parser.add_positional_argument(script_paths, "Path to script files", "scripts", Core::ArgsParser::Required::No);
|
args_parser.add_positional_argument(script_paths, "Path to script files", "scripts", Core::ArgsParser::Required::No);
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
|
@ -863,7 +866,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
TRY(repl(*interpreter));
|
TRY(repl(*interpreter));
|
||||||
s_editor->save_history(s_history_path.to_deprecated_string());
|
s_editor->save_history(s_history_path.to_deprecated_string());
|
||||||
} else {
|
} else {
|
||||||
interpreter = JS::Interpreter::create<ScriptObject>(*g_vm);
|
if (use_test262_global) {
|
||||||
|
interpreter = JS::Interpreter::create<JS::Test262::GlobalObject>(*g_vm);
|
||||||
|
} else {
|
||||||
|
interpreter = JS::Interpreter::create<ScriptObject>(*g_vm);
|
||||||
|
}
|
||||||
|
|
||||||
auto& console_object = *interpreter->realm().intrinsics().console_object();
|
auto& console_object = *interpreter->realm().intrinsics().console_object();
|
||||||
ReplConsoleClient console_client(console_object.console());
|
ReplConsoleClient console_client(console_object.console());
|
||||||
console_object.console().set_client(console_client);
|
console_object.console().set_client(console_client);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue