Commit Graph

3775 Commits

Author SHA1 Message Date
Stephen Chung
ddc66e7fb8 Print this. 2022-02-09 08:11:26 +08:00
Stephen Chung
1b4184ef16 Run debugger with no optimization. 2022-02-09 08:00:05 +08:00
Stephen Chung
3b9dbd5fce Add Span. 2022-02-08 23:01:47 +08:00
Stephen Chung
ea9b6b0e22
Merge pull request #519 from schungx/master
Consolidate most unsafe casts.
2022-02-08 22:53:09 +08:00
Stephen Chung
c64fc6f523 No astu under no_optimize. 2022-02-08 22:30:48 +08:00
Stephen Chung
0cf2cd5cfc Do not trim script lines. 2022-02-08 22:29:38 +08:00
Stephen Chung
5e7db6e105 Use new version of rustyline. 2022-02-08 22:16:12 +08:00
Stephen Chung
8cf6f424a5 Use turbofish notation. 2022-02-08 21:28:15 +08:00
Stephen Chung
83b213b086 Unwrap error when caught. 2022-02-08 19:02:40 +08:00
Stephen Chung
7686ca619a Use .. for (_). 2022-02-08 09:46:14 +08:00
Stephen Chung
97a8fd3d5b Improve reify syntax. 2022-02-08 09:25:53 +08:00
Stephen Chung
f8cee0fe4e Simplify using .. 2022-02-08 09:02:15 +08:00
Stephen Chung
187a20fd8b Refactor OptimizationLevel. 2022-02-07 21:03:39 +08:00
Stephen Chung
556b2393f5 Fix position of function calls. 2022-02-07 16:02:49 +08:00
Stephen Chung
bd9519e96b Remove reify_dynamic. 2022-02-07 12:02:00 +08:00
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
c7888ba1f4
Merge pull request #518 from schungx/master
Add rustyline to rhai-repl and variable definition filter.
2022-02-04 23:21:19 +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
bbca1c472b
Merge pull request #517 from schungx/master
Add debugging interface.
2022-01-30 11:47:17 +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