Add ConstFn::File

This commit is contained in:
Tad Hardesty 2019-06-29 17:59:17 -07:00
parent 6b401ef5ef
commit cb31916ca0
2 changed files with 5 additions and 0 deletions

View file

@ -122,6 +122,7 @@ impl<'o> AssumptionSet<'o> {
ConstFn::Newlist => AssumptionSet::from_valid_instance(objtree.expect("/list")),
ConstFn::Sound => AssumptionSet::from_valid_instance(objtree.expect("/sound")),
ConstFn::Filter => AssumptionSet::default(),
ConstFn::File => AssumptionSet::default(),
},
Constant::New { type_, args: _ } => {
if let Some(pop) = type_.as_ref() {

View file

@ -78,6 +78,8 @@ pub enum ConstFn {
Sound,
/// The `filter()` type constructor.
Filter,
/// The `file()` annotator (marks a string as `isfile`).
File,
}
/// A constant-evaluation error (usually type mismatch).
@ -334,6 +336,7 @@ impl fmt::Display for ConstFn {
ConstFn::Newlist => "newlist",
ConstFn::Sound => "sound",
ConstFn::Filter => "filter",
ConstFn::File => "file",
})
}
}
@ -700,6 +703,7 @@ impl<'a> ConstantFolder<'a> {
"newlist" => Constant::Call(ConstFn::Newlist, self.arguments(args)?),
"icon" => Constant::Call(ConstFn::Icon, self.arguments(args)?),
"sound" => Constant::Call(ConstFn::Sound, self.arguments(args)?),
"file" => Constant::Call(ConstFn::File, self.arguments(args)?),
// constant-evaluatable functions
"rgb" => {
use std::fmt::Write;