Fix UINT -> UNSIGNED_INT.
This commit is contained in:
parent
25f54c0ea5
commit
96764c0d2d
@ -859,7 +859,8 @@ impl Engine {
|
||||
(
|
||||
start as u8,
|
||||
// 2^bits - 1
|
||||
(((2 as crate::UINT).pow((end - start) as u32) - 1) as crate::INT)
|
||||
(((2 as crate::UNSIGNED_INT).pow((end - start) as u32) - 1)
|
||||
as crate::INT)
|
||||
<< start,
|
||||
)
|
||||
}
|
||||
@ -883,7 +884,8 @@ impl Engine {
|
||||
(
|
||||
start as u8,
|
||||
// 2^bits - 1
|
||||
(((2 as crate::UINT).pow((end - start + 1) as u32) - 1) as crate::INT)
|
||||
(((2 as crate::UNSIGNED_INT).pow((end - start + 1) as u32) - 1)
|
||||
as crate::INT)
|
||||
<< start,
|
||||
)
|
||||
}
|
||||
|
@ -112,7 +112,8 @@ pub type INT = i32;
|
||||
/// If the `only_i32` feature is enabled, this will be [`u32`] instead.
|
||||
#[cfg(not(feature = "only_i32"))]
|
||||
#[allow(non_camel_case_types)]
|
||||
type UINT = u64;
|
||||
type UNSIGNED_INT = u64;
|
||||
|
||||
/// The unsigned system integer base type.
|
||||
/// It is defined as [`u32`] since the `only_i32` feature is used.
|
||||
///
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
use crate::eval::calc_index;
|
||||
use crate::plugin::*;
|
||||
use crate::{def_package, ExclusiveRange, InclusiveRange, Position, RhaiResultOf, ERR, INT, UINT};
|
||||
use crate::{
|
||||
def_package, ExclusiveRange, InclusiveRange, Position, RhaiResultOf, ERR, INT, UNSIGNED_INT,
|
||||
};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
|
||||
@ -75,7 +77,7 @@ mod bit_field_functions {
|
||||
}
|
||||
|
||||
// 2^bits - 1
|
||||
let mask = ((2 as UINT).pow(bits as u32) - 1) as crate::INT;
|
||||
let mask = ((2 as UNSIGNED_INT).pow(bits as u32) - 1) as crate::INT;
|
||||
|
||||
Ok(((value & (mask << bit)) >> bit) & mask)
|
||||
}
|
||||
@ -121,7 +123,7 @@ mod bit_field_functions {
|
||||
}
|
||||
|
||||
// 2^bits - 1
|
||||
let mask = ((2 as UINT).pow(bits as u32) - 1) as crate::INT;
|
||||
let mask = ((2 as UNSIGNED_INT).pow(bits as u32) - 1) as crate::INT;
|
||||
|
||||
*value &= !(mask << bit);
|
||||
*value |= (new_value & mask) << bit;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use crate::plugin::*;
|
||||
use crate::{def_package, Position, RhaiResultOf, ERR, INT, UINT};
|
||||
use crate::{def_package, Position, RhaiResultOf, ERR, INT, UNSIGNED_INT};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
|
||||
@ -118,7 +118,7 @@ mod int_functions {
|
||||
.into());
|
||||
}
|
||||
|
||||
UINT::from_str_radix(string.trim(), radix as u32)
|
||||
UNSIGNED_INT::from_str_radix(string.trim(), radix as u32)
|
||||
.map(|v| v as INT)
|
||||
.map_err(|err| {
|
||||
ERR::ErrorArithmetic(
|
||||
|
@ -5,7 +5,7 @@ use crate::engine::{
|
||||
KEYWORD_FN_PTR_CURRY, KEYWORD_IS_DEF_VAR, KEYWORD_PRINT, KEYWORD_THIS, KEYWORD_TYPE_OF,
|
||||
};
|
||||
use crate::func::native::OnParseTokenCallback;
|
||||
use crate::{Engine, LexError, StaticVec, INT, UINT};
|
||||
use crate::{Engine, LexError, StaticVec, INT, UNSIGNED_INT};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
use std::{
|
||||
@ -1530,7 +1530,7 @@ fn get_next_token_inner(
|
||||
.filter(|&&c| c != NUMBER_SEPARATOR)
|
||||
.collect();
|
||||
|
||||
UINT::from_str_radix(&out, radix)
|
||||
UNSIGNED_INT::from_str_radix(&out, radix)
|
||||
.map(|v| v as INT)
|
||||
.map(Token::IntegerConstant)
|
||||
.unwrap_or_else(|_| {
|
||||
|
Loading…
Reference in New Issue
Block a user