mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +01:00
script: Remove dead code in xpath implementation (#39454)
Testing: Verified by the fact that the code still compiles, and existing web platform tests of course Part of https://github.com/servo/servo/issues/34527 Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
ac8895c3ae
commit
dd8e4f231c
5 changed files with 0 additions and 281 deletions
|
@ -234,130 +234,6 @@ pub(crate) enum CoreFunction {
|
|||
Lang(Box<Expr>),
|
||||
}
|
||||
|
||||
impl CoreFunction {
|
||||
pub(crate) fn name(&self) -> &'static str {
|
||||
match self {
|
||||
CoreFunction::Last => "last",
|
||||
CoreFunction::Position => "position",
|
||||
CoreFunction::Count(_) => "count",
|
||||
CoreFunction::Id(_) => "id",
|
||||
CoreFunction::LocalName(_) => "local-name",
|
||||
CoreFunction::NamespaceUri(_) => "namespace-uri",
|
||||
CoreFunction::Name(_) => "name",
|
||||
CoreFunction::String(_) => "string",
|
||||
CoreFunction::Concat(_) => "concat",
|
||||
CoreFunction::StartsWith(_, _) => "starts-with",
|
||||
CoreFunction::Contains(_, _) => "contains",
|
||||
CoreFunction::SubstringBefore(_, _) => "substring-before",
|
||||
CoreFunction::SubstringAfter(_, _) => "substring-after",
|
||||
CoreFunction::Substring(_, _, _) => "substring",
|
||||
CoreFunction::StringLength(_) => "string-length",
|
||||
CoreFunction::NormalizeSpace(_) => "normalize-space",
|
||||
CoreFunction::Translate(_, _, _) => "translate",
|
||||
CoreFunction::Number(_) => "number",
|
||||
CoreFunction::Sum(_) => "sum",
|
||||
CoreFunction::Floor(_) => "floor",
|
||||
CoreFunction::Ceiling(_) => "ceiling",
|
||||
CoreFunction::Round(_) => "round",
|
||||
CoreFunction::Boolean(_) => "boolean",
|
||||
CoreFunction::Not(_) => "not",
|
||||
CoreFunction::True => "true",
|
||||
CoreFunction::False => "false",
|
||||
CoreFunction::Lang(_) => "lang",
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn min_args(&self) -> usize {
|
||||
match self {
|
||||
// No args
|
||||
CoreFunction::Last |
|
||||
CoreFunction::Position |
|
||||
CoreFunction::True |
|
||||
CoreFunction::False => 0,
|
||||
|
||||
// Optional single arg
|
||||
CoreFunction::LocalName(_) |
|
||||
CoreFunction::NamespaceUri(_) |
|
||||
CoreFunction::Name(_) |
|
||||
CoreFunction::String(_) |
|
||||
CoreFunction::StringLength(_) |
|
||||
CoreFunction::NormalizeSpace(_) |
|
||||
CoreFunction::Number(_) => 0,
|
||||
|
||||
// Required single arg
|
||||
CoreFunction::Count(_) |
|
||||
CoreFunction::Id(_) |
|
||||
CoreFunction::Sum(_) |
|
||||
CoreFunction::Floor(_) |
|
||||
CoreFunction::Ceiling(_) |
|
||||
CoreFunction::Round(_) |
|
||||
CoreFunction::Boolean(_) |
|
||||
CoreFunction::Not(_) |
|
||||
CoreFunction::Lang(_) => 1,
|
||||
|
||||
// Required two args
|
||||
CoreFunction::StartsWith(_, _) |
|
||||
CoreFunction::Contains(_, _) |
|
||||
CoreFunction::SubstringBefore(_, _) |
|
||||
CoreFunction::SubstringAfter(_, _) => 2,
|
||||
|
||||
// Special cases
|
||||
CoreFunction::Concat(_) => 2, // Minimum 2 args
|
||||
CoreFunction::Substring(_, _, _) => 2, // 2 or 3 args
|
||||
CoreFunction::Translate(_, _, _) => 3, // Exactly 3 args
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn max_args(&self) -> Option<usize> {
|
||||
match self {
|
||||
// No args
|
||||
CoreFunction::Last |
|
||||
CoreFunction::Position |
|
||||
CoreFunction::True |
|
||||
CoreFunction::False => Some(0),
|
||||
|
||||
// Optional single arg (0 or 1)
|
||||
CoreFunction::LocalName(_) |
|
||||
CoreFunction::NamespaceUri(_) |
|
||||
CoreFunction::Name(_) |
|
||||
CoreFunction::String(_) |
|
||||
CoreFunction::StringLength(_) |
|
||||
CoreFunction::NormalizeSpace(_) |
|
||||
CoreFunction::Number(_) => Some(1),
|
||||
|
||||
// Exactly one arg
|
||||
CoreFunction::Count(_) |
|
||||
CoreFunction::Id(_) |
|
||||
CoreFunction::Sum(_) |
|
||||
CoreFunction::Floor(_) |
|
||||
CoreFunction::Ceiling(_) |
|
||||
CoreFunction::Round(_) |
|
||||
CoreFunction::Boolean(_) |
|
||||
CoreFunction::Not(_) |
|
||||
CoreFunction::Lang(_) => Some(1),
|
||||
|
||||
// Exactly two args
|
||||
CoreFunction::StartsWith(_, _) |
|
||||
CoreFunction::Contains(_, _) |
|
||||
CoreFunction::SubstringBefore(_, _) |
|
||||
CoreFunction::SubstringAfter(_, _) => Some(2),
|
||||
|
||||
// Special cases
|
||||
CoreFunction::Concat(_) => None, // Unlimited args
|
||||
CoreFunction::Substring(_, _, _) => Some(3), // 2 or 3 args
|
||||
CoreFunction::Translate(_, _, _) => Some(3), // Exactly 3 args
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the number of arguments is valid for this function
|
||||
pub(crate) fn is_valid_arity(&self, num_args: usize) -> bool {
|
||||
let min = self.min_args();
|
||||
let max = self.max_args();
|
||||
|
||||
num_args >= min && max.is_none_or(|max| num_args <= max)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(crate) struct OwnedParserError {
|
||||
input: String,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue