Implement more bitwise operation for parser bitfields

These will be used in the parser.

Maybe this type should be a struct with boolean fields. The current way has
the upside that the usage is exactly the same as in C++.
This commit is contained in:
Johannes Altmanninger 2023-03-04 03:38:16 +01:00
parent 5dbffa8b6d
commit 2c331e9c69
2 changed files with 12 additions and 1 deletions

View file

@ -6,7 +6,7 @@ use crate::wchar::{wstr, WString, L};
use crate::wchar_ffi::{wcharz, WCharFromFFI, WCharToFFI};
use crate::wutil::{sprintf, wgettext_fmt};
use cxx::{CxxWString, UniquePtr};
use std::ops::{BitAnd, BitOrAssign};
use std::ops::{BitAnd, BitOr, BitOrAssign};
use widestring_suffix::widestrs;
pub type SourceOffset = u32;
@ -39,6 +39,12 @@ impl BitAnd for ParseTreeFlags {
(self.0 & rhs.0) != 0
}
}
impl BitOr for ParseTreeFlags {
type Output = ParseTreeFlags;
fn bitor(self, rhs: Self) -> Self::Output {
Self(self.0 | rhs.0)
}
}
impl BitOrAssign for ParseTreeFlags {
fn bitor_assign(&mut self, rhs: Self) {
self.0 |= rhs.0

View file

@ -180,6 +180,11 @@ impl BitOr for TokFlags {
Self(self.0 | rhs.0)
}
}
impl BitOrAssign for TokFlags {
fn bitor_assign(&mut self, rhs: Self) {
self.0 |= rhs.0
}
}
/// Flag telling the tokenizer to accept incomplete parameters, i.e. parameters with mismatching
/// parenthesis, etc. This is useful for tab-completion.