implement primop (filter)
This commit is contained in:
+230
-1
@@ -88,7 +88,6 @@ define_builtins! {
|
||||
("__mapAttrs", MapAttrs, 2),
|
||||
("__match", Match, 2),
|
||||
("__mul", Mul, 2),
|
||||
("null", Null, 0), // constant, not a function
|
||||
("__parseDrvName", ParseDrvName, 1),
|
||||
("__partition", Partition, 2),
|
||||
("__path", Path, 1),
|
||||
@@ -123,3 +122,233 @@ define_builtins! {
|
||||
("__warn", Warn, 2),
|
||||
("__zipAttrsWith", ZipAttrsWith, 2),
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, TryFromPrimitive)]
|
||||
pub enum PrimOpPhase {
|
||||
Abort,
|
||||
Add,
|
||||
AddErrorContext,
|
||||
All,
|
||||
Any,
|
||||
AppendContext,
|
||||
AttrNames,
|
||||
AttrValues,
|
||||
BaseNameOf,
|
||||
BitAnd,
|
||||
BitOr,
|
||||
BitXor,
|
||||
Break,
|
||||
CatAttrs,
|
||||
Ceil,
|
||||
CompareVersions,
|
||||
ConcatLists,
|
||||
ConcatMap,
|
||||
ConcatStringsSep,
|
||||
ConvertHash,
|
||||
DeepSeq,
|
||||
Derivation,
|
||||
DerivationStrict,
|
||||
DirOf,
|
||||
Div,
|
||||
Elem,
|
||||
ElemAt,
|
||||
FetchGit,
|
||||
FetchMercurial,
|
||||
FetchTarball,
|
||||
FetchTree,
|
||||
FetchUrl,
|
||||
|
||||
FilterForceList,
|
||||
FilterCallPred,
|
||||
FilterCheck,
|
||||
|
||||
FilterSource,
|
||||
FindFile,
|
||||
Floor,
|
||||
FoldlStrict,
|
||||
FromJSON,
|
||||
FromTOML,
|
||||
FunctionArgs,
|
||||
GenList,
|
||||
GenericClosure,
|
||||
GetAttr,
|
||||
GetContext,
|
||||
GetEnv,
|
||||
GroupBy,
|
||||
HasAttr,
|
||||
HasContext,
|
||||
HashFile,
|
||||
HashString,
|
||||
Head,
|
||||
Import,
|
||||
IntersectAttrs,
|
||||
IsAttrs,
|
||||
IsBool,
|
||||
IsFloat,
|
||||
IsFunction,
|
||||
IsInt,
|
||||
IsList,
|
||||
IsNull,
|
||||
IsPath,
|
||||
IsString,
|
||||
Length,
|
||||
LessThan,
|
||||
ListToAttrs,
|
||||
Map,
|
||||
MapAttrs,
|
||||
Match,
|
||||
Mul,
|
||||
ParseDrvName,
|
||||
Partition,
|
||||
Path,
|
||||
PathExists,
|
||||
Placeholder,
|
||||
ReadDir,
|
||||
ReadFile,
|
||||
ReadFileType,
|
||||
RemoveAttrs,
|
||||
ReplaceStrings,
|
||||
ScopedImport,
|
||||
Seq,
|
||||
Sort,
|
||||
Split,
|
||||
SplitVersion,
|
||||
StorePath,
|
||||
StringLength,
|
||||
Sub,
|
||||
Substring,
|
||||
Tail,
|
||||
Throw,
|
||||
ToFile,
|
||||
ToJSON,
|
||||
ToPath,
|
||||
ToString,
|
||||
ToXML,
|
||||
Trace,
|
||||
TryEval,
|
||||
TypeOf,
|
||||
UnsafeDiscardStringContext,
|
||||
UnsafeGetAttrPos,
|
||||
Warn,
|
||||
ZipAttrsWith,
|
||||
|
||||
Illegal,
|
||||
}
|
||||
|
||||
impl BuiltinId {
|
||||
#[inline(always)]
|
||||
pub fn entry_phase(self) -> PrimOpPhase {
|
||||
use BuiltinId::*;
|
||||
match self {
|
||||
Abort => PrimOpPhase::Abort,
|
||||
Add => PrimOpPhase::Add,
|
||||
AddErrorContext => PrimOpPhase::AddErrorContext,
|
||||
All => PrimOpPhase::All,
|
||||
Any => PrimOpPhase::Any,
|
||||
AppendContext => PrimOpPhase::AppendContext,
|
||||
AttrNames => PrimOpPhase::AttrNames,
|
||||
AttrValues => PrimOpPhase::AttrValues,
|
||||
BaseNameOf => PrimOpPhase::BaseNameOf,
|
||||
BitAnd => PrimOpPhase::BitAnd,
|
||||
BitOr => PrimOpPhase::BitOr,
|
||||
BitXor => PrimOpPhase::BitXor,
|
||||
Break => PrimOpPhase::Break,
|
||||
CatAttrs => PrimOpPhase::CatAttrs,
|
||||
Ceil => PrimOpPhase::Ceil,
|
||||
CompareVersions => PrimOpPhase::CompareVersions,
|
||||
ConcatLists => PrimOpPhase::ConcatLists,
|
||||
ConcatMap => PrimOpPhase::ConcatMap,
|
||||
ConcatStringsSep => PrimOpPhase::ConcatStringsSep,
|
||||
ConvertHash => PrimOpPhase::ConvertHash,
|
||||
DeepSeq => PrimOpPhase::DeepSeq,
|
||||
Derivation => PrimOpPhase::Derivation,
|
||||
DerivationStrict => PrimOpPhase::DerivationStrict,
|
||||
DirOf => PrimOpPhase::DirOf,
|
||||
Div => PrimOpPhase::Div,
|
||||
Elem => PrimOpPhase::Elem,
|
||||
ElemAt => PrimOpPhase::ElemAt,
|
||||
FetchGit => PrimOpPhase::FetchGit,
|
||||
FetchMercurial => PrimOpPhase::FetchMercurial,
|
||||
FetchTarball => PrimOpPhase::FetchTarball,
|
||||
FetchTree => PrimOpPhase::FetchTree,
|
||||
FetchUrl => PrimOpPhase::FetchUrl,
|
||||
Filter => PrimOpPhase::FilterForceList,
|
||||
FilterSource => PrimOpPhase::FilterSource,
|
||||
FindFile => PrimOpPhase::FindFile,
|
||||
Floor => PrimOpPhase::Floor,
|
||||
FoldlStrict => PrimOpPhase::FoldlStrict,
|
||||
FromJSON => PrimOpPhase::FromJSON,
|
||||
FromTOML => PrimOpPhase::FromTOML,
|
||||
FunctionArgs => PrimOpPhase::FunctionArgs,
|
||||
GenList => PrimOpPhase::GenList,
|
||||
GenericClosure => PrimOpPhase::GenericClosure,
|
||||
GetAttr => PrimOpPhase::GetAttr,
|
||||
GetContext => PrimOpPhase::GetContext,
|
||||
GetEnv => PrimOpPhase::GetEnv,
|
||||
GroupBy => PrimOpPhase::GroupBy,
|
||||
HasAttr => PrimOpPhase::HasAttr,
|
||||
HasContext => PrimOpPhase::HasContext,
|
||||
HashFile => PrimOpPhase::HashFile,
|
||||
HashString => PrimOpPhase::HashString,
|
||||
Head => PrimOpPhase::Head,
|
||||
Import => PrimOpPhase::Import,
|
||||
IntersectAttrs => PrimOpPhase::IntersectAttrs,
|
||||
IsAttrs => PrimOpPhase::IsAttrs,
|
||||
IsBool => PrimOpPhase::IsBool,
|
||||
IsFloat => PrimOpPhase::IsFloat,
|
||||
IsFunction => PrimOpPhase::IsFunction,
|
||||
IsInt => PrimOpPhase::IsInt,
|
||||
IsList => PrimOpPhase::IsList,
|
||||
IsNull => PrimOpPhase::IsNull,
|
||||
IsPath => PrimOpPhase::IsPath,
|
||||
IsString => PrimOpPhase::IsString,
|
||||
Length => PrimOpPhase::Length,
|
||||
LessThan => PrimOpPhase::LessThan,
|
||||
ListToAttrs => PrimOpPhase::ListToAttrs,
|
||||
Map => PrimOpPhase::Map,
|
||||
MapAttrs => PrimOpPhase::MapAttrs,
|
||||
Match => PrimOpPhase::Match,
|
||||
Mul => PrimOpPhase::Mul,
|
||||
ParseDrvName => PrimOpPhase::ParseDrvName,
|
||||
Partition => PrimOpPhase::Partition,
|
||||
Path => PrimOpPhase::Path,
|
||||
PathExists => PrimOpPhase::PathExists,
|
||||
Placeholder => PrimOpPhase::Placeholder,
|
||||
ReadDir => PrimOpPhase::ReadDir,
|
||||
ReadFile => PrimOpPhase::ReadFile,
|
||||
ReadFileType => PrimOpPhase::ReadFileType,
|
||||
RemoveAttrs => PrimOpPhase::RemoveAttrs,
|
||||
ReplaceStrings => PrimOpPhase::ReplaceStrings,
|
||||
ScopedImport => PrimOpPhase::ScopedImport,
|
||||
Seq => PrimOpPhase::Seq,
|
||||
Sort => PrimOpPhase::Sort,
|
||||
Split => PrimOpPhase::Split,
|
||||
SplitVersion => PrimOpPhase::SplitVersion,
|
||||
StorePath => PrimOpPhase::StorePath,
|
||||
StringLength => PrimOpPhase::StringLength,
|
||||
Sub => PrimOpPhase::Sub,
|
||||
Substring => PrimOpPhase::Substring,
|
||||
Tail => PrimOpPhase::Tail,
|
||||
Throw => PrimOpPhase::Throw,
|
||||
ToFile => PrimOpPhase::ToFile,
|
||||
ToJSON => PrimOpPhase::ToJSON,
|
||||
ToPath => PrimOpPhase::ToPath,
|
||||
ToString => PrimOpPhase::ToString,
|
||||
ToXML => PrimOpPhase::ToXML,
|
||||
Trace => PrimOpPhase::Trace,
|
||||
TryEval => PrimOpPhase::TryEval,
|
||||
TypeOf => PrimOpPhase::TypeOf,
|
||||
UnsafeDiscardStringContext => PrimOpPhase::UnsafeDiscardStringContext,
|
||||
UnsafeGetAttrPos => PrimOpPhase::UnsafeGetAttrPos,
|
||||
Warn => PrimOpPhase::Warn,
|
||||
ZipAttrsWith => PrimOpPhase::ZipAttrsWith,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PrimOpPhase {
|
||||
pub fn ip(self) -> u32 {
|
||||
self as u32 * 2
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user