Commit Graph

139 Commits

Author SHA1 Message Date
Stephen Chung
9813f657bb Use ImmutableString for AST. 2022-08-13 18:40:14 +08:00
Stephen Chung
cba394d73c Revise strings interning. 2022-08-12 16:34:57 +08:00
Stephen Chung
be448dfe4d Use identifiers in format! 2022-08-11 19:01:23 +08:00
Stephen Chung
255af006ee Fix doc comments. 2022-08-10 12:48:37 +08:00
Stephen Chung
2f948a784c Clean up more clippy. 2022-07-27 18:04:59 +08:00
Stephen Chung
39dee556c4 Clean up clippy. 2022-07-27 16:04:24 +08:00
Stephen Chung
753e527cbb Fix BLOB and string operations. 2022-07-20 21:17:21 +08:00
quake
299777f1c9 chore: clippy fix needless_borrow 2022-07-20 21:16:35 +09:00
Stephen Chung
b6528bd51d Reduce usage of as_ref and as_mut. 2022-07-05 16:26:38 +08:00
Stephen Chung
7068775f19 Use locked_read. 2022-06-26 14:10:09 +08:00
Stephen Chung
84b8e1ed87 Detect whether dynamic functions exist to save checking. 2022-06-24 11:30:54 +08:00
Stephen Chung
b592ac1599 Export locked_read. 2022-06-17 23:36:09 +08:00
Stephen Chung
b9cbeb65d6 Use Option instead of once/empty. 2022-06-11 16:01:15 +08:00
Stephen Chung
e5f6b28abd Fix warnings. 2022-06-08 17:06:49 +08:00
Stephen Chung
bbaad8dfcb Speed up method calls. 2022-06-08 16:34:56 +08:00
Stephen Chung
8501d9d33f Improve speed on common dot/index expressions. 2022-06-07 20:38:05 +08:00
Stephen Chung
6ebe002b18 Check for missing docs. 2022-06-05 18:17:44 +08:00
Stephen Chung
8f73796110 Fix builds. 2022-05-19 21:49:19 +08:00
Stephen Chung
857ae7a64a Comments update. 2022-05-19 14:41:48 +08:00
Stephen Chung
4194e2c048 Refine data structures. 2022-05-07 15:54:44 +08:00
Stephen Chung
c69f98c2c4 Add custom state. 2022-05-02 00:03:45 +08:00
Stephen Chung
2889ca0988 Add Start/End to DebuggerEvent. 2022-04-26 16:36:24 +08:00
Stephen Chung
f9ee0c29be Fix builds. 2022-04-18 23:24:08 +08:00
Stephen Chung
daf73d5341 Make caches optional for EvalContext. 2022-04-16 23:32:14 +08:00
Stephen Chung
855cb76246 Rename EvalState to Caches. 2022-04-16 16:36:53 +08:00
Stephen Chung
7788e1058a Merge use. 2022-04-13 10:35:10 +08:00
Stephen Chung
63359f3f81 Unused parameters naming. 2022-04-11 16:29:16 +08:00
Stephen Chung
42f977862f Add Dynamic parameters to qualified function calls. 2022-04-08 16:42:53 +08:00
Stephen Chung
99118fe2c3 Minor refactors. 2022-03-20 21:58:43 +08:00
Stephen Chung
dc8c4ed8f4 Improve string functions. 2022-03-17 17:00:48 +08:00
Stephen Chung
63716759be Fix typo. 2022-03-14 11:28:52 +08:00
Stephen Chung
672cda63ab Simplify formatting. 2022-03-14 08:50:17 +08:00
Stephen Chung
a704d26986 Fixup ArgBackup. 2022-03-14 08:26:27 +08:00
Stephen Chung
8bda8c64df Refine data structures 2022-03-05 17:57:23 +08:00
Stephen Chung
e06c2b2abb Remove constants in function call expressions. 2022-03-05 12:06:47 +08:00
Stephen Chung
0e9a16e437 Add checks for is_empty. 2022-03-03 13:02:57 +08:00
Stephen Chung
83755bf936 Refine doc comments. 2022-03-01 15:34:15 +08:00
Stephen Chung
73f10b8adc Minor housekeeping. 2022-02-24 10:36:20 +08:00
Stephen Chung
fa8e2e638b Fix bug. 2022-02-23 15:43:27 +08:00
Stephen Chung
fb9964e1a3 Revise on_def_var API. 2022-02-15 10:56:05 +08:00
Stephen Chung
5bb6ce835f Run var def filter during parsing. 2022-02-13 18:46:25 +08:00
Stephen Chung
664e3d31e5 BLOB's and strings. 2022-02-12 23:39:07 +08:00
Stephen Chung
8cf6f424a5 Use turbofish notation. 2022-02-08 21:28:15 +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
becbfa8930 Fix errors. 2022-02-06 23:02:59 +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
be9356727f Add variable definition filter. 2022-02-04 22:59:41 +08:00