mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
working parallel implementation
This commit is contained in:
parent
b8a2db793f
commit
434ccbbf68
2 changed files with 194 additions and 194 deletions
|
@ -107,6 +107,118 @@ pub enum LowLevel {
|
|||
ExpectTrue,
|
||||
}
|
||||
|
||||
macro_rules! first_order {
|
||||
() => {
|
||||
StrConcat
|
||||
| StrJoinWith
|
||||
| StrIsEmpty
|
||||
| StrStartsWith
|
||||
| StrStartsWithCodePt
|
||||
| StrEndsWith
|
||||
| StrSplit
|
||||
| StrCountGraphemes
|
||||
| StrFromInt
|
||||
| StrFromUtf8
|
||||
| StrFromUtf8Range
|
||||
| StrToUtf8
|
||||
| StrRepeat
|
||||
| StrFromFloat
|
||||
| ListLen
|
||||
| ListGetUnsafe
|
||||
| ListSet
|
||||
| ListDrop
|
||||
| ListDropAt
|
||||
| ListSingle
|
||||
| ListRepeat
|
||||
| ListReverse
|
||||
| ListConcat
|
||||
| ListContains
|
||||
| ListAppend
|
||||
| ListPrepend
|
||||
| ListJoin
|
||||
| ListRange
|
||||
| ListSwap
|
||||
| DictSize
|
||||
| DictEmpty
|
||||
| DictInsert
|
||||
| DictRemove
|
||||
| DictContains
|
||||
| DictGetUnsafe
|
||||
| DictKeys
|
||||
| DictValues
|
||||
| DictUnion
|
||||
| DictIntersection
|
||||
| DictDifference
|
||||
| SetFromList
|
||||
| NumAdd
|
||||
| NumAddWrap
|
||||
| NumAddChecked
|
||||
| NumSub
|
||||
| NumSubWrap
|
||||
| NumSubChecked
|
||||
| NumMul
|
||||
| NumMulWrap
|
||||
| NumMulChecked
|
||||
| NumGt
|
||||
| NumGte
|
||||
| NumLt
|
||||
| NumLte
|
||||
| NumCompare
|
||||
| NumDivUnchecked
|
||||
| NumRemUnchecked
|
||||
| NumIsMultipleOf
|
||||
| NumAbs
|
||||
| NumNeg
|
||||
| NumSin
|
||||
| NumCos
|
||||
| NumSqrtUnchecked
|
||||
| NumLogUnchecked
|
||||
| NumRound
|
||||
| NumToFloat
|
||||
| NumPow
|
||||
| NumCeiling
|
||||
| NumPowInt
|
||||
| NumFloor
|
||||
| NumIsFinite
|
||||
| NumAtan
|
||||
| NumAcos
|
||||
| NumAsin
|
||||
| NumBitwiseAnd
|
||||
| NumBitwiseXor
|
||||
| NumBitwiseOr
|
||||
| NumShiftLeftBy
|
||||
| NumShiftRightBy
|
||||
| NumBytesToU16
|
||||
| NumBytesToU32
|
||||
| NumShiftRightZfBy
|
||||
| NumIntCast
|
||||
| Eq
|
||||
| NotEq
|
||||
| And
|
||||
| Or
|
||||
| Not
|
||||
| Hash
|
||||
| ExpectTrue
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! higher_order {
|
||||
() => {
|
||||
ListMap
|
||||
| ListMap2
|
||||
| ListMap3
|
||||
| ListMapWithIndex
|
||||
| ListKeepIf
|
||||
| ListWalk
|
||||
| ListWalkUntil
|
||||
| ListWalkBackwards
|
||||
| ListKeepOks
|
||||
| ListKeepErrs
|
||||
| ListSortWith
|
||||
| DictWalk
|
||||
};
|
||||
}
|
||||
|
||||
impl LowLevel {
|
||||
/// is one of the arguments always a function?
|
||||
/// An example is List.map.
|
||||
|
@ -114,25 +226,28 @@ impl LowLevel {
|
|||
use LowLevel::*;
|
||||
|
||||
match self {
|
||||
StrConcat | StrJoinWith | StrIsEmpty | StrStartsWith | StrStartsWithCodePt
|
||||
| StrEndsWith | StrSplit | StrCountGraphemes | StrFromInt | StrFromUtf8
|
||||
| StrFromUtf8Range | StrToUtf8 | StrRepeat | StrFromFloat | ListLen | ListGetUnsafe
|
||||
| ListSet | ListDrop | ListDropAt | ListSingle | ListRepeat | ListReverse
|
||||
| ListConcat | ListContains | ListAppend | ListPrepend | ListJoin | ListRange
|
||||
| ListSwap | DictSize | DictEmpty | DictInsert | DictRemove | DictContains
|
||||
| DictGetUnsafe | DictKeys | DictValues | DictUnion | DictIntersection
|
||||
| DictDifference | SetFromList | NumAdd | NumAddWrap | NumAddChecked | NumSub
|
||||
| NumSubWrap | NumSubChecked | NumMul | NumMulWrap | NumMulChecked | NumGt | NumGte
|
||||
| NumLt | NumLte | NumCompare | NumDivUnchecked | NumRemUnchecked | NumIsMultipleOf
|
||||
| NumAbs | NumNeg | NumSin | NumCos | NumSqrtUnchecked | NumLogUnchecked | NumRound
|
||||
| NumToFloat | NumPow | NumCeiling | NumPowInt | NumFloor | NumIsFinite | NumAtan
|
||||
| NumAcos | NumAsin | NumBitwiseAnd | NumBitwiseXor | NumBitwiseOr | NumShiftLeftBy
|
||||
| NumShiftRightBy | NumBytesToU16 | NumBytesToU32 | NumShiftRightZfBy | NumIntCast
|
||||
| Eq | NotEq | And | Or | Not | Hash | ExpectTrue => false,
|
||||
first_order!() => false,
|
||||
higher_order!() => true,
|
||||
}
|
||||
}
|
||||
|
||||
ListMap | ListMap2 | ListMap3 | ListMapWithIndex | ListKeepIf | ListWalk
|
||||
| ListWalkUntil | ListWalkBackwards | ListKeepOks | ListKeepErrs | ListSortWith
|
||||
| DictWalk => true,
|
||||
pub fn function_argument_position(&self) -> usize {
|
||||
use LowLevel::*;
|
||||
|
||||
match self {
|
||||
first_order!() => unreachable!(),
|
||||
ListMap => 1,
|
||||
ListMap2 => 2,
|
||||
ListMap3 => 3,
|
||||
ListMapWithIndex => 1,
|
||||
ListKeepIf => 1,
|
||||
ListWalk => 2,
|
||||
ListWalkUntil => 2,
|
||||
ListWalkBackwards => 2,
|
||||
ListKeepOks => 1,
|
||||
ListKeepErrs => 1,
|
||||
ListSortWith => 1,
|
||||
DictWalk => 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue