Commit Graph

3008 Commits

Author SHA1 Message Date
Stephen Chung
becbfa8930 Fix errors. 2022-02-06 23:02:59 +08:00
Stephen Chung
1ccbda1050 Merge branch 'master' of https://github.com/schungx/rhai 2022-02-06 21:24:55 +08:00
Stephen Chung
c5eafc337a
Merge pull request #64 from neachdainn/reify-sound
Remove unsound casting functions
2022-02-06 21:24:32 +08:00
Stephen Chung
cfbf0397a6 Better position of assignment errors. 2022-02-06 21:24:02 +08:00
Nathan Kent
86d86a85e4 Remove unsound casting functions
The casting functions in `unsafe.rs` were unsound (i.e., they allowed
safe code to cause undefined behavior). While they did appear to be used
in a way that wouldn't cause UB the fact that there exists unsound
functions is unsettling.

This commit removes those functions and replaces it with a macro that
performs the same reification - the difference is that the macro call
will also include the checks which are required to prevent UB. A macro
was chosen instead of a function for two reasons:

1. A macro can keep the same code generation whereas a function would
   require going through an `Option` which has negative impacts on code
   generation (niche values cause poor DCE).
2. There exist other `unsafe` code blocks in the crate and an attempt to
   make Rhai 100% safe is completely out-of-scope for this merge
   request, so we may as well use `unsafe` in the macro.

Regarding (2) above, I may come back at a later date with a 100% safe
`reify` function but only once the other `unsafe` blocks are removed.
For posterity, said function would look something like:

```rust
fn reify<A: Any, C>(value: A) -> Option<C> {
    let mut v = Some(value);
    let v: &mut dyn Any = &mut v;
    v.downcast_mut::<Option<C>>().map(Option::take)
}
```
2022-02-05 16:29:05 -08:00
Stephen Chung
6a740a9fa1 Fix no_module build. 2022-02-04 23:08:09 +08:00
Stephen Chung
40bec9f017 Fix tests. 2022-02-04 23:02:00 +08:00
Stephen Chung
be9356727f Add variable definition filter. 2022-02-04 22:59:41 +08:00
Stephen Chung
936dc01e39 Pass level to var resolver. 2022-02-04 22:16:12 +08:00
Stephen Chung
5aee06674f Fix no-std build. 2022-02-04 16:38:01 +08:00
Stephen Chung
f09abd7ab3 Fix builds. 2022-02-04 13:31:33 +08:00
Stephen Chung
3be27746e0 Add allow_shadowing. 2022-02-04 13:20:47 +08:00
Stephen Chung
6c1c8bc538 Improve position display. 2022-02-04 12:04:33 +08:00
Stephen Chung
345a060672 Fix type name display. 2022-02-03 23:54:53 +08:00
Stephen Chung
419ee45043 Add bin-features to pull in all features for bin tools. 2022-02-03 21:17:47 +08:00
Stephen Chung
9fa6839380 Simplify debugger calls. 2022-02-03 11:56:08 +08:00
Stephen Chung
8322e62c18 Fix function exit trigger and add function enter trigger. 2022-02-02 22:42:33 +08:00
Stephen Chung
db2f1a601c Make call stack available also under no_function. 2022-02-02 15:07:22 +08:00
Stephen Chung
e0ed713bb6 Fix builds. 2022-02-02 14:57:30 +08:00
Stephen Chung
339136901d Benchmark with features turned on. 2022-02-02 14:47:46 +08:00
Stephen Chung
4a80483749 Support call stack and FunctionExit for native functions. 2022-02-02 14:47:35 +08:00
Stephen Chung
7163a7331a Add commands and status to debugging interface. 2022-02-01 22:30:05 +08:00
Stephen Chung
dca0185323 Change on_debugger to register_debugger. 2022-02-01 14:07:06 +08:00
Stephen Chung
389bb9bf66 Add history recall to repl. 2022-01-31 21:02:36 +08:00
Stephen Chung
f1458e79e0 Improve AST debug display. 2022-01-31 13:38:27 +08:00
Stephen Chung
ff06bb98a1 Fix no_module build. 2022-01-30 23:28:02 +08:00
Stephen Chung
7b92a80c32 Fix encapsulated environment in module functions. 2022-01-30 17:27:13 +08:00
Stephen Chung
8fc80ecd10 Fix formatting. 2022-01-30 11:21:45 +08:00
Stephen Chung
06214cf499 Add key bindings to repl. 2022-01-30 09:42:04 +08:00
Stephen Chung
0378c822e1 Use required-features for bin tools. 2022-01-30 09:41:51 +08:00
Stephen Chung
2cfd426aaf Merge branch 'rustyline' of https://github.com/rhaiscript/rhai 2022-01-29 15:59:24 +08:00
Stephen Chung
62ea94999e
Merge pull request #516 from jonathanstrong/add-rustyline-to-repl
poc: adds rustyline to rhai-repl
2022-01-29 15:57:19 +08:00
Stephen Chung
19ef92a3f3 Fix builds. 2022-01-29 13:37:58 +08:00
Stephen Chung
6b02dde848 Gate dead code for no_module. 2022-01-29 11:09:43 +08:00
Jonathan Strong
16f13960f4 poc: adds rustyline to rhai-repl 2022-01-28 20:29:25 -05:00
Stephen Chung
225d9a6546 Update branches list. 2022-01-29 08:51:09 +08:00
Stephen Chung
4ee6657b9d Fix no_function build. 2022-01-28 22:37:59 +08:00
Stephen Chung
cd4335a16f Fix builds. 2022-01-28 22:11:22 +08:00
Stephen Chung
c397a6dcb5 Fix sync build. 2022-01-28 22:07:49 +08:00
Stephen Chung
c93e94c7cd Fix builds. 2022-01-28 21:35:16 +08:00
Stephen Chung
66af69aaff Refactor and add state to debugger. 2022-01-28 18:59:18 +08:00
Stephen Chung
20baae71d4 Factor tuples into structs to aid in understanding. 2022-01-28 10:11:40 +08:00
Stephen Chung
b86dd3f586 Add missing data size check. 2022-01-28 08:28:31 +08:00
Stephen Chung
b9f2fdb635 Rename AST option flags. 2022-01-28 08:28:17 +08:00
Stephen Chung
09d03d07ed Fix sync build. 2022-01-28 08:00:46 +08:00
Stephen Chung
e476929597 Remove Box on callback traits. 2022-01-27 23:55:32 +08:00
Stephen Chung
1d08c22f73
Merge pull request #515 from schungx/master
Fix no-std build.
2022-01-27 17:12:34 +08:00
Stephen Chung
64de20bcd3 Remove warnings. 2022-01-27 16:58:11 +08:00
Stephen Chung
dd937e657d Fix builds. 2022-01-27 16:58:11 +08:00
Stephen Chung
197cdedaf4 Add commands to rhai-dbg. 2022-01-27 16:58:11 +08:00