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
Stephen Chung
936dc01e39
Pass level to var resolver.
2022-02-04 22:16:12 +08:00
Stephen Chung
6c1c8bc538
Improve position display.
2022-02-04 12:04:33 +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
e0ed713bb6
Fix builds.
2022-02-02 14:57:30 +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
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
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
Stephen Chung
66af69aaff
Refactor and add state to debugger.
2022-01-28 18:59:18 +08:00
Stephen Chung
e476929597
Remove Box on callback traits.
2022-01-27 23:55:32 +08:00
Stephen Chung
3c2ac7f0c5
Add ability for debugger to throw errors.
2022-01-27 16:58:11 +08:00
Stephen Chung
3cec9751bf
Remove call stack under no_function.
2022-01-27 16:58:11 +08:00
Stephen Chung
40aaab60c3
Refine debugger.
2022-01-27 16:58:11 +08:00
Stephen Chung
fc87dec128
Add debugging interface.
2022-01-27 16:58:11 +08:00
Stephen Chung
fb0b071fe0
Add lifetimes to GlobalRuntimeState and EvalState for future needs.
2022-01-22 17:48:07 +08:00
Stephen Chung
f92894e337
Rename GlobalRuntimeStatemodules -> imports.
2022-01-20 08:17:34 +08:00
Stephen Chung
86fc2f7bf1
Refine types display.
2022-01-17 21:51:04 +08:00
Stephen Chung
00b189d0c6
Replace Cow<str> in Scope with SmartString.
2022-01-15 11:26:43 +08:00
Stephen Chung
a8ec984b0f
Fix unsafe violation in for loop.
2022-01-15 10:18:16 +08:00
Stephen Chung
37dbc68bf5
Use target_family for wasm.
2022-01-12 08:12:28 +08:00
Stephen Chung
f399e8a905
Evaluate function call args more efficiently.
2022-01-08 18:40:19 +08:00
Stephen Chung
a267ac5e54
Split Engine into eval folder.
2022-01-07 11:43:47 +08:00
Stephen Chung
c75d51ae88
Reduce unnecessary data size checking.
2022-01-06 22:10:16 +08:00
Stephen Chung
bc6bf6c6ba
Change expect("exists") to unwrap().
2022-01-06 11:07:52 +08:00
Stephen Chung
328f6910b6
Refactor wasm feature gates.
2022-01-04 22:16:20 +08:00
Stephen Chung
d99953c101
Fixup AsRef<str> vs &str.
2022-01-04 15:22:48 +08:00
Stephen Chung
1d1e473ac4
Minor refactor.
2022-01-03 23:16:47 +08:00
Stephen Chung
29f1328087
Simplify Dynamic::from for better inlining.
2022-01-02 20:47:03 +08:00
Stephen Chung
809feaf58d
Add doc comments.
2022-01-02 15:14:55 +08:00
Stephen Chung
d60ed5a502
Reduce size of Variant trait.
2022-01-01 19:54:46 +08:00
Stephen Chung
a6ddb64596
Fix builds.
2022-01-01 17:38:32 +08:00
Stephen Chung
135b1f54c2
Remove Option from source and use empty string as no source.
2022-01-01 17:20:00 +08:00
Stephen Chung
ce93f56813
Rename parameters.
2021-12-31 17:49:19 +08:00
Stephen Chung
be4ae6e763
Add rewind_scope to eval_stmt.
2021-12-30 08:57:23 +08:00
Stephen Chung
4bd482352e
Fix eval call.
2021-12-28 23:00:31 +08:00
Stephen Chung
cbaf095c7a
Merge restore_state and rewind_scope.
2021-12-28 17:50:49 +08:00
Stephen Chung
5b667a69b7
Reverse EvalStateData.
2021-12-28 12:19:20 +08:00
Stephen Chung
280010c427
Fix builds.
2021-12-28 12:00:01 +08:00
Stephen Chung
807240e249
Rename Imports to GlobalRuntimeState.
2021-12-28 11:42:52 +08:00
Stephen Chung
9deddc679c
Use Box<str>.
2021-12-27 23:15:25 +08:00
Stephen Chung
a78488d935
Rename Imports to GlobalRuntimeState.
2021-12-27 23:03:30 +08:00
Stephen Chung
757eacfdde
No need for types with Into::into.
2021-12-27 16:59:05 +08:00
Stephen Chung
f443e4d9f6
Fix formatting.
2021-12-27 13:30:44 +08:00
Stephen Chung
dfb3378b28
Expand function call arguments inline storage.
2021-12-27 12:27:44 +08:00
Stephen Chung
05d4c81e7a
Use type alias for error.
2021-12-27 12:27:31 +08:00
Stephen Chung
e7ca3f41dd
Fix formatting.
2021-12-27 11:43:11 +08:00
Stephen Chung
01c35808cb
Use type alias
2021-12-25 23:49:14 +08:00
Stephen Chung
5c31ec7f78
Fix array bug.
2021-12-22 22:22:20 +08:00
Stephen Chung
3751b6d018
Build in array/blob concat functions.
2021-12-22 19:59:48 +08:00
Stephen Chung
d7960dfe80
Short circuit no_function.
2021-12-21 13:03:39 +08:00
Stephen Chung
b4756b4575
Move CallableFunction to own file.
2021-12-20 22:13:00 +08:00
Stephen Chung
0ae4d14a62
Move BLOB concat and push to builtin.
2021-12-18 15:37:20 +08:00
Stephen Chung
9cf8360616
Move blob functions to builtin.
2021-12-18 14:58:02 +08:00
Stephen Chung
2b79a65454
Move range contains into builtin.
2021-12-18 14:50:37 +08:00
Stephen Chung
fc84600b22
Add NativeCallContext::call_fn
2021-12-18 12:29:04 +08:00
Stephen Chung
dc6896fbe2
Add OpAssignment::new_from_token.
2021-12-17 16:55:24 +08:00
Stephen Chung
42638db0fb
Move Engine default limits.
2021-12-17 16:15:30 +08:00
Stephen Chung
c7ec27acc7
Split AST into separate files.
2021-12-17 16:07:13 +08:00
Stephen Chung
59a9ff0b0f
Fix range precedences and add comparison operators.
2021-12-15 14:18:03 +08:00
Stephen Chung
ef14079c61
Add ranges.
2021-12-15 12:06:17 +08:00
Stephen Chung
780c36e675
Simplify if let.
2021-12-12 12:33:22 +08:00
Stephen Chung
2a7a648429
Reduce feature gates.
2021-12-06 20:52:47 +08:00
Stephen Chung
206b5051eb
Clarify non-zero hashes.
2021-12-06 10:34:13 +08:00
Stephen Chung
54f78c5cd9
Use zero for no hash.
2021-12-05 17:05:19 +08:00
Stephen Chung
d36e2d22d1
Minor refactor.
2021-12-02 12:49:46 +08:00
Stephen Chung
4b4b7a753b
Add low-level warnings.
2021-11-29 13:12:47 +08:00
Stephen Chung
c5f2b0a253
Fix builds.
2021-11-29 10:17:04 +08:00
Stephen Chung
95dc2ad502
Remove fields and parameters under no_function.
2021-11-29 09:43:35 +08:00
Stephen Chung
9fa4d60336
Minor code and docs refactor.
2021-11-28 22:57:28 +08:00
Stephen Chung
c5317d7706
Deprecate NativeCallContext::new
2021-11-28 12:41:33 +08:00
Stephen Chung
d88e17d177
Move more &str to AsRef<str>
2021-11-28 12:41:20 +08:00
Stephen Chung
9c4ed44ab8
Fix builds.
2021-11-27 23:29:32 +08:00
Stephen Chung
4fc088a0f1
Fix feature builds.
2021-11-27 23:20:05 +08:00
Stephen Chung
e918e61e95
Use AsRef<str> for more flexible API.
2021-11-27 23:04:45 +08:00
Stephen Chung
d56585c877
Remove no_smartstring feature.
2021-11-27 14:24:36 +08:00
Stephen Chung
abe6b4a29b
Use more const functions.
2021-11-27 14:24:06 +08:00
Stephen Chung
280b5b405e
Make some new functions const.
2021-11-25 17:09:00 +08:00
Stephen Chung
90200e607c
Fix doc comment links.
2021-11-20 21:29:36 +08:00
Stephen Chung
e961ae23fd
Eliminate script hashes under no_function.
2021-11-16 13:42:46 +08:00
Stephen Chung
b178d7c367
Fix no_function builds.
2021-11-16 13:42:22 +08:00
Stephen Chung
c2c30f7711
Use fold.
2021-11-16 13:15:43 +08:00
Stephen Chung
2fffe31b59
Level up exports.
2021-11-16 12:26:37 +08:00
Stephen Chung
98707912e0
Convert for loop to iterator.
2021-11-15 14:30:00 +08:00
Stephen Chung
de906053ed
Deprecate call_fn_dynamic into call_fn_raw.
2021-11-15 11:13:00 +08:00
Stephen Chung
615c3acad6
Use actual outer scope for function-bang calls.
2021-11-14 22:48:57 +08:00
Stephen Chung
64b889fb95
Restructure code base.
2021-11-13 22:36:23 +08:00