commit
1d08c22f73
29
.github/workflows/benchmark.yml
vendored
Normal file
29
.github/workflows/benchmark.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
name: Benchmark
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
benchmark:
|
||||
name: Run Rust benchmark
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: rustup toolchain update nightly && rustup default nightly
|
||||
- name: Run benchmark
|
||||
run: cargo +nightly bench | tee output.txt
|
||||
- name: Store benchmark result
|
||||
uses: rhysd/github-action-benchmark@v1
|
||||
with:
|
||||
name: Rust Benchmark
|
||||
tool: 'cargo'
|
||||
output-file-path: output.txt
|
||||
# Use personal access token instead of GITHUB_TOKEN due to https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false
|
||||
github-token: ${{ secrets.RHAI }}
|
||||
auto-push: true
|
||||
# Show alert with commit comment on detecting possible performance regression
|
||||
alert-threshold: '200%'
|
||||
comment-on-alert: true
|
||||
fail-on-alert: true
|
||||
alert-comment-cc-users: '@schungx'
|
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -3,8 +3,8 @@ name: Build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
- v1.3-fixes
|
||||
pull_request: {}
|
||||
|
||||
jobs:
|
||||
|
@ -8,6 +8,13 @@ Bug fixes
|
||||
---------
|
||||
|
||||
* Variables introduced inside `try` blocks are now properly cleaned up upon an exception.
|
||||
* Off-by-one error in character positions after a comment line is now fixed.
|
||||
|
||||
Enhancements
|
||||
------------
|
||||
|
||||
* `rhai-repl` tool has a few more commands, such as `strict` to turn on/off _Strict Variables Mode_ and `optimize` to turn on/off script optimization.
|
||||
* Default features for dependencies (such as `ahash/std` and `num-traits/std`) are no longer required.
|
||||
|
||||
|
||||
Version 1.4.1
|
||||
|
@ -26,7 +26,7 @@ rhai_codegen = { version = "1.2", path = "codegen", default-features = false }
|
||||
serde_bytes = "0.11"
|
||||
|
||||
[features]
|
||||
default = ["ahash/std", "num-traits/std"]
|
||||
default = []
|
||||
unchecked = [] # unchecked arithmetic
|
||||
sync = [] # restrict to only types that implement Send + Sync
|
||||
no_position = [] # do not track position in the parser
|
||||
|
@ -14,7 +14,7 @@ static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
||||
#[cfg(all(windows, target_env = "msvc"))]
|
||||
#[link(name = "msvcrt")]
|
||||
#[link(name = "libcmt")]
|
||||
extern {}
|
||||
extern "C" {}
|
||||
|
||||
use rhai::{Engine, INT};
|
||||
|
||||
@ -39,11 +39,17 @@ extern "C" fn rust_begin_panic(_: &core::panic::PanicInfo) -> ! {
|
||||
core::intrinsics::abort();
|
||||
}
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
extern "C" fn eh_personality() {}
|
||||
#[no_mangle]
|
||||
extern "C" fn _rust_eh_personality() {}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn rust_eh_personality() {}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn rust_eh_register_frames() {}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn rust_eh_unregister_frames() {}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn _Unwind_Resume() {}
|
||||
|
@ -21,7 +21,7 @@ use std::{
|
||||
use std::str::FromStr;
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
use num_traits::Float;
|
||||
use num_traits::float::FloatCore as Float;
|
||||
|
||||
/// _(internals)_ A binary expression.
|
||||
/// Exported under the `internals` feature only.
|
||||
@ -646,15 +646,14 @@ impl Expr {
|
||||
| Self::Variable(_, pos, _)
|
||||
| Self::Stack(_, pos)
|
||||
| Self::FnCall(_, pos)
|
||||
| Self::Index(_, _, pos)
|
||||
| Self::Custom(_, pos)
|
||||
| Self::InterpolatedString(_, pos) => *pos,
|
||||
|
||||
Self::Property(x) => (x.2).1,
|
||||
Self::Stmt(x) => x.position(),
|
||||
|
||||
Self::And(x, _) | Self::Or(x, _) | Self::Dot(x, _, _) | Self::Index(x, _, _) => {
|
||||
x.lhs.position()
|
||||
}
|
||||
Self::And(x, _) | Self::Or(x, _) | Self::Dot(x, _, _) => x.lhs.position(),
|
||||
}
|
||||
}
|
||||
/// Override the [position][Position] of the expression.
|
||||
|
@ -47,6 +47,8 @@ fn print_help() {
|
||||
println!("quit, exit => quit");
|
||||
println!("scope => print all variables in the scope");
|
||||
println!("strict => toggle on/off Strict Variables Mode");
|
||||
#[cfg(not(feature = "no_optimize"))]
|
||||
println!("optimize => toggle on/off script optimization");
|
||||
#[cfg(feature = "metadata")]
|
||||
println!("functions => print all functions defined");
|
||||
#[cfg(feature = "metadata")]
|
||||
@ -85,7 +87,9 @@ fn main() {
|
||||
let title = format!("Rhai REPL tool (version {})", env!("CARGO_PKG_VERSION"));
|
||||
println!("{}", title);
|
||||
println!("{0:=<1$}", "", title.len());
|
||||
print_help();
|
||||
|
||||
#[cfg(not(feature = "no_optimize"))]
|
||||
let mut optimize_level = rhai::OptimizationLevel::Simple;
|
||||
|
||||
// Initialize scripting engine
|
||||
let mut engine = Engine::new();
|
||||
@ -196,6 +200,8 @@ fn main() {
|
||||
let mut ast_u = AST::empty();
|
||||
let mut ast = AST::empty();
|
||||
|
||||
print_help();
|
||||
|
||||
'main_loop: loop {
|
||||
print!("rhai-repl> ");
|
||||
stdout().flush().expect("couldn't flush stdout");
|
||||
@ -247,6 +253,18 @@ fn main() {
|
||||
println!("Strict Variables Mode turned ON.");
|
||||
continue;
|
||||
}
|
||||
#[cfg(not(feature = "no_optimize"))]
|
||||
"optimize" if optimize_level == rhai::OptimizationLevel::Simple => {
|
||||
optimize_level = rhai::OptimizationLevel::None;
|
||||
println!("Script optimization turned OFF.");
|
||||
continue;
|
||||
}
|
||||
#[cfg(not(feature = "no_optimize"))]
|
||||
"optimize" => {
|
||||
optimize_level = rhai::OptimizationLevel::Simple;
|
||||
println!("Script optimization turned ON.");
|
||||
continue;
|
||||
}
|
||||
"scope" => {
|
||||
print_scope(&scope);
|
||||
continue;
|
||||
@ -296,7 +314,7 @@ fn main() {
|
||||
|
||||
#[cfg(not(feature = "no_optimize"))]
|
||||
{
|
||||
ast = engine.optimize_ast(&scope, r, rhai::OptimizationLevel::Simple);
|
||||
ast = engine.optimize_ast(&scope, r, optimize_level);
|
||||
}
|
||||
|
||||
#[cfg(feature = "no_optimize")]
|
||||
|
@ -1592,11 +1592,11 @@ fn get_next_token_inner(
|
||||
// `\r - start from next line
|
||||
Some('\r') => {
|
||||
eat_next(stream, pos);
|
||||
pos.new_line();
|
||||
// `\r\n
|
||||
if let Some('\n') = stream.peek_next() {
|
||||
eat_next(stream, pos);
|
||||
}
|
||||
pos.new_line();
|
||||
}
|
||||
// `\n - start from next line
|
||||
Some('\n') => {
|
||||
@ -1762,11 +1762,11 @@ fn get_next_token_inner(
|
||||
|
||||
while let Some(c) = stream.get_next() {
|
||||
if c == '\r' {
|
||||
pos.new_line();
|
||||
// \r\n
|
||||
if let Some('\n') = stream.peek_next() {
|
||||
eat_next(stream, pos);
|
||||
}
|
||||
pos.new_line();
|
||||
break;
|
||||
}
|
||||
if c == '\n' {
|
||||
|
Loading…
Reference in New Issue
Block a user