mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
chore: Harden RVM implementation (#537)
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
d626f75421
commit
740db8a0f5
+10
-15
@@ -1,10 +1,5 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
#![allow(
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::pattern_type_mismatch
|
||||
)]
|
||||
|
||||
use crate::rvm::instructions::{ComprehensionMode, LoopMode};
|
||||
use crate::value::Value;
|
||||
@@ -49,18 +44,18 @@ pub enum IterationState {
|
||||
}
|
||||
|
||||
impl IterationState {
|
||||
pub(super) fn advance(&mut self) {
|
||||
match self {
|
||||
IterationState::Array { index, .. } => {
|
||||
*index += 1;
|
||||
pub(super) const fn advance(&mut self) {
|
||||
match *self {
|
||||
Self::Array { ref mut index, .. } => {
|
||||
*index = index.saturating_add(1);
|
||||
}
|
||||
IterationState::Object {
|
||||
first_iteration, ..
|
||||
} => {
|
||||
*first_iteration = false;
|
||||
Self::Object {
|
||||
ref mut first_iteration,
|
||||
..
|
||||
}
|
||||
IterationState::Set {
|
||||
first_iteration, ..
|
||||
| Self::Set {
|
||||
ref mut first_iteration,
|
||||
..
|
||||
} => {
|
||||
*first_iteration = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user