mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:47:45 +00:00
js: Add another little test AST to exercise marking of locals
This commit is contained in:
parent
363c40e3f3
commit
ad401ca098
1 changed files with 24 additions and 9 deletions
|
@ -32,12 +32,13 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
//static void build_program_1(JS::Program&);
|
//static void build_program_1(JS::Program&);
|
||||||
static void build_program_2(JS::Program&);
|
//static void build_program_2(JS::Program&);
|
||||||
|
static void build_program_3(JS::Program&);
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
auto program = make<JS::Program>();
|
auto program = make<JS::Program>();
|
||||||
build_program_2(*program);
|
build_program_3(*program);
|
||||||
|
|
||||||
program->dump(0);
|
program->dump(0);
|
||||||
|
|
||||||
|
@ -47,13 +48,7 @@ int main()
|
||||||
|
|
||||||
printf("%s\n", result.to_string().characters());
|
printf("%s\n", result.to_string().characters());
|
||||||
|
|
||||||
interpreter.heap().allocate<JS::Object>();
|
dbg() << "Collecting garbage on exit...";
|
||||||
|
|
||||||
dbg() << "Collecting garbage...";
|
|
||||||
interpreter.heap().collect_garbage();
|
|
||||||
|
|
||||||
interpreter.global_object().put("foo", JS::Value(123));
|
|
||||||
dbg() << "Collecting garbage after overwriting global_object.foo...";
|
|
||||||
interpreter.heap().collect_garbage();
|
interpreter.heap().collect_garbage();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +74,7 @@ void build_program_1(JS::Program& program)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
void build_program_2(JS::Program& program)
|
void build_program_2(JS::Program& program)
|
||||||
{
|
{
|
||||||
// c = 1;
|
// c = 1;
|
||||||
|
@ -113,3 +109,22 @@ void build_program_2(JS::Program& program)
|
||||||
program.append<JS::FunctionDeclaration>("foo", move(block));
|
program.append<JS::FunctionDeclaration>("foo", move(block));
|
||||||
program.append<JS::CallExpression>("foo");
|
program.append<JS::CallExpression>("foo");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void build_program_3(JS::Program& program)
|
||||||
|
{
|
||||||
|
// function foo() {
|
||||||
|
// var x = {};
|
||||||
|
// $gc();
|
||||||
|
// }
|
||||||
|
// foo();
|
||||||
|
|
||||||
|
auto block = make<JS::BlockStatement>();
|
||||||
|
block->append<JS::VariableDeclaration>(
|
||||||
|
make<JS::Identifier>("x"),
|
||||||
|
make<JS::ObjectExpression>());
|
||||||
|
block->append<JS::CallExpression>("$gc");
|
||||||
|
|
||||||
|
program.append<JS::FunctionDeclaration>("foo", move(block));
|
||||||
|
program.append<JS::CallExpression>("foo");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue