6
6
#include < argon/vm/runtime.h>
7
7
#include < argon/vm/version.h>
8
8
9
+ #include < argon/vm/datatype/boolean.h>
9
10
#include < argon/vm/datatype/integer.h>
10
11
#include < argon/vm/datatype/tuple.h>
11
12
@@ -17,6 +18,70 @@ Tuple *ParseCMDArgs(int argc, char **argv);
17
18
18
19
// EOL
19
20
21
+ bool ExposeConfig (Module *self) {
22
+ #define PUT_BOOL (name, field ) \
23
+ if (!DictInsert (ret, #name, (ArObject *) (field ? True : False))) { \
24
+ Release (ret); \
25
+ return false ; }
26
+
27
+ #define PUT_INT (name, field ) \
28
+ if ((tmp = (ArObject *) IntNew (field)) == nullptr ) { \
29
+ Release (ret); \
30
+ return false ; } \
31
+ \
32
+ if (!DictInsert (ret, #name, tmp)) { \
33
+ Release (tmp); \
34
+ Release (ret); \
35
+ return false ; } \
36
+ \
37
+ Release (tmp);
38
+
39
+ #define PUT_STR (name, field ) \
40
+ if ((tmp = (ArObject *) StringNew (field)) == nullptr ) { \
41
+ Release (ret); \
42
+ return false ; } \
43
+ \
44
+ if (!DictInsert (ret, #name, tmp)) { \
45
+ Release (tmp); \
46
+ Release (ret); \
47
+ return false ; } \
48
+ \
49
+ Release (tmp);
50
+
51
+ auto *conf = argon::vm::GetFiber ()->context ->global_config ;
52
+
53
+ auto *ret = DictNew ();
54
+ if (ret == nullptr )
55
+ return false ;
56
+
57
+ ArObject *tmp;
58
+
59
+ PUT_BOOL (interactive, conf->interactive )
60
+ PUT_BOOL (nogc, conf->nogc )
61
+ PUT_BOOL (quiet, conf->quiet )
62
+ PUT_BOOL (stack_trace, conf->stack_trace )
63
+ PUT_BOOL (unbuffered, conf->unbuffered )
64
+
65
+ PUT_INT (max_vc, conf->max_vc )
66
+ PUT_INT (max_ost, conf->max_ost )
67
+ PUT_INT (fiber_ss, conf->fiber_ss )
68
+ PUT_INT (fiber_pool, conf->fiber_pool )
69
+ PUT_INT (optim_lvl, conf->optim_lvl )
70
+
71
+ if (!ModuleAddObject (self, " config" , (ArObject *) ret, MODULE_ATTRIBUTE_DEFAULT)) {
72
+ Release (ret);
73
+
74
+ return false ;
75
+ }
76
+
77
+ Release (ret);
78
+
79
+ return true ;
80
+ #undef PUT_BOOL
81
+ #undef PUT_INT
82
+ #undef PUT_STR
83
+ }
84
+
20
85
bool SetAbout (Module *self) {
21
86
#define ADD_INFO (macro, key ) \
22
87
if ((tmp = (ArObject*) StringNew (macro)) == nullptr ) \
@@ -114,6 +179,9 @@ bool SetOsName(Module *self) {
114
179
}
115
180
116
181
bool RuntimeInit (Module *self) {
182
+ if (!ExposeConfig (self))
183
+ return false ;
184
+
117
185
if (!SetAbout (self))
118
186
return false ;
119
187
0 commit comments