diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-09 21:58:27 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-09 21:58:27 +0100 |
commit | 70a3e738f532a1aa92cec5e9283dedfb768b4846 (patch) | |
tree | da4f74b63a6798a810721308d02e7b4655960404 | |
parent | 0d6be2cac2547d9e28f65ba3812322aedc3c5439 (diff) | |
download | serenity-70a3e738f532a1aa92cec5e9283dedfb768b4846.zip |
js: Make it a little easier to add new AST builder functions
-rw-r--r-- | Userland/js.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/Userland/js.cpp b/Userland/js.cpp index 64ae49abfa..3017ae30b2 100644 --- a/Userland/js.cpp +++ b/Userland/js.cpp @@ -31,14 +31,14 @@ #include <LibJS/Value.h> #include <stdio.h> -//static void build_program_1(JS::Program&); -//static void build_program_2(JS::Program&); -static void build_program_3(JS::Program&); +#define PROGRAM 2 + +static void build_program(JS::Program&); int main() { auto program = make<JS::Program>(); - build_program_3(*program); + build_program(*program); program->dump(0); @@ -53,8 +53,8 @@ int main() return 0; } -#if 0 -void build_program_1(JS::Program& program) +#if PROGRAM == 1 +void build_program(JS::Program& program) { // function foo() { return (1 + 2) + 3; } // foo(); @@ -72,10 +72,8 @@ void build_program_1(JS::Program& program) program.append<JS::FunctionDeclaration>("foo", move(block)); program.append<JS::CallExpression>("foo"); } -#endif - -#if 0 -void build_program_2(JS::Program& program) +#elif PROGRAM == 2 +void build_program(JS::Program& program) { // c = 1; // function foo() { @@ -109,9 +107,8 @@ void build_program_2(JS::Program& program) program.append<JS::FunctionDeclaration>("foo", move(block)); program.append<JS::CallExpression>("foo"); } -#endif - -void build_program_3(JS::Program& program) +#elif PROGRAM == 3 +void build_program(JS::Program& program) { // function foo() { // var x = {}; @@ -128,3 +125,4 @@ void build_program_3(JS::Program& program) program.append<JS::FunctionDeclaration>("foo", move(block)); program.append<JS::CallExpression>("foo"); } +#endif |