2021-09-02 18:21:37 +00:00
|
|
|
use super::Expression;
|
|
|
|
use crate::{DeclId, Span};
|
2021-09-02 08:25:22 +00:00
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct Call {
|
|
|
|
/// identifier of the declaration to call
|
|
|
|
pub decl_id: DeclId,
|
|
|
|
pub head: Span,
|
|
|
|
pub positional: Vec<Expression>,
|
|
|
|
pub named: Vec<(String, Option<Expression>)>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Call {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Call {
|
|
|
|
pub fn new() -> Call {
|
|
|
|
Self {
|
|
|
|
decl_id: 0,
|
|
|
|
head: Span::unknown(),
|
|
|
|
positional: vec![],
|
|
|
|
named: vec![],
|
|
|
|
}
|
|
|
|
}
|
2021-09-11 21:26:35 +00:00
|
|
|
|
|
|
|
pub fn has_flag(&self, flag_name: &str) -> bool {
|
|
|
|
for name in &self.named {
|
|
|
|
if flag_name == name.0 {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
false
|
|
|
|
}
|
2021-10-01 21:53:13 +00:00
|
|
|
|
|
|
|
pub fn get_flag_expr(&self, flag_name: &str) -> Option<Expression> {
|
|
|
|
for name in &self.named {
|
|
|
|
if flag_name == name.0 {
|
|
|
|
return name.1.clone();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
None
|
|
|
|
}
|
2021-09-02 08:25:22 +00:00
|
|
|
}
|