Debian Codegraph @

js/src/gdb/tests/test-jsval.cpp

raw
1 #include "gdb-tests.h"
2
3 #include "js/GlobalObject.h"
4 #include "js/String.h"
5 #include "js/Symbol.h"
6 #include "vm/BigIntType.h"
7
8 FRAGMENT(jsval, simple) {
9 using namespace JS;
10
11 RootedValue fortytwo(cx, Int32Value(42));
12 RootedValue fortytwoD(cx, DoubleValue(42));
13 RootedValue negone(cx, Int32Value(-1));
14 RootedValue undefined(cx, UndefinedValue());
15 RootedValue null(cx, NullValue());
16 RootedValue js_true(cx, BooleanValue(true));
17 RootedValue js_false(cx, BooleanValue(false));
18 RootedValue elements_hole(cx, js::MagicValue(JS_ELEMENTS_HOLE));
19
20 RootedValue empty_string(cx);
21 empty_string.setString(JS_NewStringCopyZ(cx, ""));
22 RootedString hello(cx, JS_NewStringCopyZ(cx, "Hello!"));
23 RootedValue friendly_string(cx, StringValue(hello));
24 RootedValue symbol(cx, SymbolValue(GetSymbolFor(cx, hello)));
25 RootedValue bi(cx, BigIntValue(BigInt::zero(cx)));
26
27 RootedValue global(cx);
28 global.setObject(*CurrentGlobalOrNull(cx));
29
30 // Some interesting value that floating-point won't munge.
31 RootedValue onehundredthirtysevenonehundredtwentyeighths(
32 cx, DoubleValue(137.0 / 128.0));
33
34 breakpoint();
35
36 use(fortytwo);
37 use(fortytwoD);
38 use(negone);
39 use(undefined);
40 use(js_true);
41 use(js_false);
42 use(null);
43 use(elements_hole);
44 use(empty_string);
45 use(friendly_string);
46 use(symbol);
47 use(bi);
48 use(global);
49 }