summaryrefslogtreecommitdiff
path: root/src/eval/value.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-06-26 18:07:05 +0200
committerLaurenz <laurmaedje@gmail.com>2021-06-26 18:07:05 +0200
commit422b8e640f00977177a5a7250a3c56009eed10c4 (patch)
treeb1a21718e9511d776a6de47b713e3308bb1baaad /src/eval/value.rs
parentd53c933e4d56e6c0484d81814779ddb1597ee032 (diff)
With expressions
Diffstat (limited to 'src/eval/value.rs')
-rw-r--r--src/eval/value.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/eval/value.rs b/src/eval/value.rs
index e8ecffa2..28c7d588 100644
--- a/src/eval/value.rs
+++ b/src/eval/value.rs
@@ -274,7 +274,7 @@ impl Debug for FuncValue {
pub struct FuncArgs {
/// The span of the whole argument list.
pub span: Span,
- /// The arguments.
+ /// The positional arguments.
pub items: Vec<FuncArg>,
}
@@ -346,7 +346,7 @@ impl FuncArgs {
let index = self
.items
.iter()
- .position(|arg| arg.name.as_ref().map(|s| s.v.as_str()) == Some(name))?;
+ .position(|arg| arg.name.as_ref().map_or(false, |other| name == other))?;
let value = self.items.remove(index).value;
let span = value.span;
@@ -373,7 +373,7 @@ impl FuncArgs {
pub fn finish(self, ctx: &mut EvalContext) {
for arg in &self.items {
if arg.value.v != Value::Error {
- ctx.diag(error!(arg.span(), "unexpected argument"));
+ ctx.diag(error!(arg.span, "unexpected argument"));
}
}
}
@@ -382,22 +382,14 @@ impl FuncArgs {
/// An argument to a function call: `12` or `draw: false`.
#[derive(Debug, Clone, PartialEq)]
pub struct FuncArg {
+ /// The span of the whole argument.
+ pub span: Span,
/// The name of the argument (`None` for positional arguments).
- pub name: Option<Spanned<String>>,
+ pub name: Option<String>,
/// The value of the argument.
pub value: Spanned<Value>,
}
-impl FuncArg {
- /// The source code location.
- pub fn span(&self) -> Span {
- match &self.name {
- Some(name) => name.span.join(self.value.span),
- None => self.value.span,
- }
- }
-}
-
/// A wrapper around a dynamic value.
pub struct AnyValue(Box<dyn Bounds>);