(&mut self)
| 82 | } |
| 83 | |
| 84 | fn init_stdlib(&mut self) { |
| 85 | self.arena.mutate_root(|_mc, state| { |
| 86 | let ctx = state.get_context(); |
| 87 | |
| 88 | state.builtin_methods.init(ctx); |
| 89 | state.globals.insert( |
| 90 | ctx.intern(b"ValidationError!"), |
| 91 | Value::Class(builtins::create_validation_error(ctx)), |
| 92 | ); |
| 93 | |
| 94 | // Initialize standard library modules |
| 95 | state.module_manager.register_native_module( |
| 96 | ctx.intern(b"std.auth.jwt"), |
| 97 | stdlib::create_jwt_module(ctx), |
| 98 | ); |
| 99 | state |
| 100 | .module_manager |
| 101 | .register_native_module(ctx.intern(b"std.env"), stdlib::create_env_module(ctx)); |
| 102 | state |
| 103 | .module_manager |
| 104 | .register_native_module(ctx.intern(b"std.math"), stdlib::create_math_module(ctx)); |
| 105 | state |
| 106 | .module_manager |
| 107 | .register_native_module(ctx.intern(b"std.http"), stdlib::create_http_module(ctx)); |
| 108 | state |
| 109 | .module_manager |
| 110 | .register_native_module(ctx.intern(b"std.io"), stdlib::create_io_module(ctx)); |
| 111 | state |
| 112 | .module_manager |
| 113 | .register_native_module(ctx.intern(b"std.time"), stdlib::create_time_module(ctx)); |
| 114 | state.module_manager.register_native_module( |
| 115 | ctx.intern(b"std.random"), |
| 116 | stdlib::create_random_module(ctx), |
| 117 | ); |
| 118 | state |
| 119 | .module_manager |
| 120 | .register_native_module(ctx.intern(b"std.serde"), stdlib::create_serde_module(ctx)); |
| 121 | state |
| 122 | .module_manager |
| 123 | .register_native_module(ctx.intern(b"std.db.pg"), stdlib::create_pg_module(ctx)); |
| 124 | state.module_manager.register_native_module( |
| 125 | ctx.intern(b"std.db.sqlite"), |
| 126 | stdlib::create_sqlite_module(ctx), |
| 127 | ); |
| 128 | state.module_manager.register_native_module( |
| 129 | ctx.intern(b"std.db.redis"), |
| 130 | stdlib::create_redis_module(ctx), |
| 131 | ); |
| 132 | }); |
| 133 | } |
| 134 | |
| 135 | pub fn compile(&mut self, source: &'static str) -> Result<(), VmError> { |
| 136 | self.arena.mutate_root(|_mc, state| { |
no test coverage detected