#[allow(unused_imports)]
use crate::aver_generated::domain::ast::*;
#[allow(unused_imports)]
use crate::*;
#[inline(always)]
pub fn annotateFastFns(
mut fns: aver_rt::AverList<FnDef>,
mut fnMap: aver_rt::AverMap<AverStr, i64>,
mut acc: aver_rt::AverList<FnDef>,
) -> aver_rt::AverList<FnDef> {
loop {
crate::cancel_checkpoint();
return aver_list_match!(fns, [] => acc.reverse(), [f, rest] => { {
let __tmp1 = fnMap.clone();
let __tmp2 = aver_rt::AverList::prepend(annotateFastFn(&f, &fnMap), &acc);
fns = rest;
fnMap = __tmp1;
acc = __tmp2;
continue;
} });
}
}
pub fn annotateFastFn(fd: &FnDef, fnMap: &aver_rt::AverMap<AverStr, i64>) -> FnDef {
crate::cancel_checkpoint();
let selfId = fnMap.get(&fd.name).cloned().unwrap_or((-1i64));
FnDef {
name: fd.name.clone(),
params: fd.params.clone(),
body: fd.body.clone(),
slotCount: fd.slotCount,
slotMap: fd.slotMap.clone(),
fastPath: classifyFastPath(&fd.body),
tailLoop: classifyTailLoop(selfId, fd.body.clone()),
}
}
#[inline(always)]
pub fn classifyTailLoop(mut selfId: i64, mut body: aver_rt::AverList<Stmt>) -> bool {
loop {
crate::cancel_checkpoint();
return aver_list_match!(body, [] => false, [stmt, rest] => { { let __list_subject = rest.clone(); if __list_subject.is_empty() { stmtNeedsTailLoop(selfId, &stmt) } else { {
body = rest;
continue;
} } } });
}
}
pub fn stmtNeedsTailLoop(selfId: i64, stmt: &Stmt) -> bool {
crate::cancel_checkpoint();
match stmt.clone() {
Stmt::StmtExpr(expr) => exprNeedsTailLoop(selfId, expr),
_ => false,
}
}
pub fn exprNeedsTailLoop(mut selfId: i64, mut expr: Expr) -> bool {
loop {
crate::cancel_checkpoint();
return match expr {
Expr::ExprCallDirect(fnId, _) => (fnId == selfId),
Expr::ExprBoolBranch(_, thenExpr, elseExpr) => {
let thenExpr = (*thenExpr).clone();
let elseExpr = (*elseExpr).clone();
if exprNeedsTailLoop(selfId, thenExpr) {
true
} else {
{
expr = elseExpr;
continue;
}
}
}
Expr::ExprMatch(_, arms) => armsNeedTailLoop(selfId, arms),
_ => false,
};
}
}
#[inline(always)]
pub fn armsNeedTailLoop(mut selfId: i64, mut arms: aver_rt::AverList<MatchArm>) -> bool {
loop {
crate::cancel_checkpoint();
return aver_list_match!(arms, [] => false, [arm, rest] => { if exprNeedsTailLoop(selfId, arm.body.clone()) { true } else { {
arms = rest;
continue;
} } });
}
}
pub fn classifyFastPath(body: &aver_rt::AverList<Stmt>) -> FnFastPath {
crate::cancel_checkpoint();
{
let __list_subject = body.clone();
if let Some((stmt, rest)) = aver_rt::list_uncons_cloned(&__list_subject) {
if (rest == aver_rt::AverList::empty()) {
classifyFastStmt(&stmt)
} else {
FnFastPath::FastNone.clone()
}
} else {
FnFastPath::FastNone.clone()
}
}
}
pub fn classifyFastStmt(stmt: &Stmt) -> FnFastPath {
crate::cancel_checkpoint();
match stmt.clone() {
Stmt::StmtExpr(expr) => classifyFastExpr(&expr),
_ => FnFastPath::FastNone.clone(),
}
}
#[inline(always)]
pub fn classifyFastExpr(expr: &Expr) -> FnFastPath {
crate::cancel_checkpoint();
match classifyFastLeafExpr(expr) {
Some(leaf) => FnFastPath::FastLeaf(leaf),
None => match expr.clone() {
Expr::ExprCallDirect(fnId, args) => classifyFastForwardCall(fnId, &args),
Expr::ExprMatch(scrutinee, arms) => {
let scrutinee = (*scrutinee).clone();
classifyFastMatch(&scrutinee, &arms)
}
_ => FnFastPath::FastSingleExpr.clone(),
},
}
}
pub fn classifyFastLeafExpr(expr: &Expr) -> Option<FastLeaf> {
crate::cancel_checkpoint();
match expr.clone() {
Expr::ExprInt(n) => Some(FastLeaf::LeafConstInt(n)),
Expr::ExprFloat(f) => Some(FastLeaf::LeafConstFloat(f)),
Expr::ExprStr(s) => Some(FastLeaf::LeafConstStr(s)),
Expr::ExprBool(b) => Some(FastLeaf::LeafConstBool(b)),
Expr::ExprSlot(slot) => Some(FastLeaf::LeafSlot(slot)),
Expr::ExprFieldAccess(obj, field) => {
let obj = (*obj).clone();
classifyFastFieldAccess(&obj, field)
}
Expr::ExprCallBuiltin(name, args) => classifyFastBuiltinLeaf(name, &args),
Expr::ExprAdd(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastBinopSlots(&BinOp::OpAdd, &a, &b)
}
Expr::ExprSub(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastBinopSlots(&BinOp::OpSub, &a, &b)
}
_ => classifyFastLeafExprTail(expr),
}
}
pub fn classifyFastLeafExprTail(expr: &Expr) -> Option<FastLeaf> {
crate::cancel_checkpoint();
match expr.clone() {
Expr::ExprMul(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastBinopSlots(&BinOp::OpMul, &a, &b)
}
Expr::ExprDiv(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastBinopSlots(&BinOp::OpDiv, &a, &b)
}
Expr::ExprEq(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastCmpSlots(&CmpOp::CmpEq, &a, &b)
}
Expr::ExprNeq(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastCmpSlots(&CmpOp::CmpNeq, &a, &b)
}
Expr::ExprLt(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastCmpSlots(&CmpOp::CmpLt, &a, &b)
}
Expr::ExprGt(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastCmpSlots(&CmpOp::CmpGt, &a, &b)
}
Expr::ExprLte(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastCmpSlots(&CmpOp::CmpLte, &a, &b)
}
Expr::ExprGte(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastCmpSlots(&CmpOp::CmpGte, &a, &b)
}
_ => None,
}
}
pub fn classifyFastFieldAccess(obj: &Expr, field: AverStr) -> Option<FastLeaf> {
crate::cancel_checkpoint();
match obj.clone() {
Expr::ExprSlot(slot) => Some(FastLeaf::LeafFieldAccess(slot, field)),
_ => None,
}
}
pub fn classifyFastBinopSlots(op: &BinOp, a: &Expr, b: &Expr) -> Option<FastLeaf> {
crate::cancel_checkpoint();
match a.clone() {
Expr::ExprSlot(sa) => match b.clone() {
Expr::ExprSlot(sb) => Some(FastLeaf::LeafBinopSlots(op.clone(), sa, sb)),
_ => None,
},
_ => None,
}
}
pub fn classifyFastCmpSlots(op: &CmpOp, a: &Expr, b: &Expr) -> Option<FastLeaf> {
crate::cancel_checkpoint();
match a.clone() {
Expr::ExprSlot(sa) => match b.clone() {
Expr::ExprSlot(sb) => Some(FastLeaf::LeafCmpSlots(op.clone(), sa, sb)),
_ => None,
},
_ => None,
}
}
#[inline(always)]
pub fn classifyFastBuiltinLeaf(name: AverStr, args: &aver_rt::AverList<Expr>) -> Option<FastLeaf> {
crate::cancel_checkpoint();
{
let __dispatch_subject = name;
if &*__dispatch_subject == "Vector.new" {
classifyFastVectorNew(args)
} else {
if &*__dispatch_subject == "Vector.len" {
classifyFastVectorLen(args)
} else {
if &*__dispatch_subject == "Option.withDefault" {
classifyFastOptionWithDefault(args)
} else {
if &*__dispatch_subject == "Map.get" {
classifyFastMapGet(args)
} else {
if &*__dispatch_subject == "Map.set" {
classifyFastMapSet(args)
} else {
if &*__dispatch_subject == "Map.has" {
classifyFastMapHas(args)
} else {
if &*__dispatch_subject == "Map.remove" {
classifyFastMapRemove(args)
} else {
None
}
}
}
}
}
}
}
}
}
pub fn classifyFastMapGet(args: &aver_rt::AverList<Expr>) -> Option<FastLeaf> {
crate::cancel_checkpoint();
{
let __list_subject = args.clone();
if let Some((mapExpr, rest)) = aver_rt::list_uncons_cloned(&__list_subject) {
{
let __list_subject = rest;
if let Some((keyExpr, ignored)) = aver_rt::list_uncons_cloned(&__list_subject) {
classifyFastMapGetArgs(&mapExpr, &keyExpr)
} else {
None
}
}
} else {
None
}
}
}
pub fn classifyFastMapGetArgs(mapExpr: &Expr, keyExpr: &Expr) -> Option<FastLeaf> {
crate::cancel_checkpoint();
match mapExpr.clone() {
Expr::ExprSlot(mapSlot) => match keyExpr.clone() {
Expr::ExprSlot(keySlot) => Some(FastLeaf::LeafMapGet(mapSlot, keySlot)),
_ => None,
},
_ => None,
}
}
pub fn classifyFastMapSet(args: &aver_rt::AverList<Expr>) -> Option<FastLeaf> {
crate::cancel_checkpoint();
{
let __list_subject = args.clone();
if let Some((mapExpr, rest)) = aver_rt::list_uncons_cloned(&__list_subject) {
{
let __list_subject = rest;
if let Some((keyExpr, rest2)) = aver_rt::list_uncons_cloned(&__list_subject) {
{
let __list_subject = rest2;
if let Some((valueExpr, ignored)) =
aver_rt::list_uncons_cloned(&__list_subject)
{
classifyFastMapSetArgs(&mapExpr, &keyExpr, &valueExpr)
} else {
None
}
}
} else {
None
}
}
} else {
None
}
}
}
pub fn classifyFastMapSetArgs(
mapExpr: &Expr,
keyExpr: &Expr,
valueExpr: &Expr,
) -> Option<FastLeaf> {
crate::cancel_checkpoint();
match mapExpr.clone() {
Expr::ExprSlot(mapSlot) => match keyExpr.clone() {
Expr::ExprSlot(keySlot) => match valueExpr.clone() {
Expr::ExprSlot(valueSlot) => {
Some(FastLeaf::LeafMapSet(mapSlot, keySlot, valueSlot))
}
_ => None,
},
_ => None,
},
_ => None,
}
}
pub fn classifyFastMapHas(args: &aver_rt::AverList<Expr>) -> Option<FastLeaf> {
crate::cancel_checkpoint();
{
let __list_subject = args.clone();
if let Some((mapExpr, rest)) = aver_rt::list_uncons_cloned(&__list_subject) {
{
let __list_subject = rest;
if let Some((keyExpr, ignored)) = aver_rt::list_uncons_cloned(&__list_subject) {
classifyFastMapHasArgs(&mapExpr, &keyExpr)
} else {
None
}
}
} else {
None
}
}
}
pub fn classifyFastMapHasArgs(mapExpr: &Expr, keyExpr: &Expr) -> Option<FastLeaf> {
crate::cancel_checkpoint();
match mapExpr.clone() {
Expr::ExprSlot(mapSlot) => match keyExpr.clone() {
Expr::ExprSlot(keySlot) => Some(FastLeaf::LeafMapHas(mapSlot, keySlot)),
_ => None,
},
_ => None,
}
}
pub fn classifyFastMapRemove(args: &aver_rt::AverList<Expr>) -> Option<FastLeaf> {
crate::cancel_checkpoint();
{
let __list_subject = args.clone();
if let Some((mapExpr, rest)) = aver_rt::list_uncons_cloned(&__list_subject) {
{
let __list_subject = rest;
if let Some((keyExpr, ignored)) = aver_rt::list_uncons_cloned(&__list_subject) {
classifyFastMapRemoveArgs(&mapExpr, &keyExpr)
} else {
None
}
}
} else {
None
}
}
}
pub fn classifyFastMapRemoveArgs(mapExpr: &Expr, keyExpr: &Expr) -> Option<FastLeaf> {
crate::cancel_checkpoint();
match mapExpr.clone() {
Expr::ExprSlot(mapSlot) => match keyExpr.clone() {
Expr::ExprSlot(keySlot) => Some(FastLeaf::LeafMapRemove(mapSlot, keySlot)),
_ => None,
},
_ => None,
}
}
pub fn classifyFastVectorLen(args: &aver_rt::AverList<Expr>) -> Option<FastLeaf> {
crate::cancel_checkpoint();
{
let __list_subject = args.clone();
if let Some((vecExpr, ignored)) = aver_rt::list_uncons_cloned(&__list_subject) {
match vecExpr {
Expr::ExprSlot(slot) => Some(FastLeaf::LeafVectorLen(slot)),
_ => None,
}
} else {
None
}
}
}
pub fn classifyFastVectorNew(args: &aver_rt::AverList<Expr>) -> Option<FastLeaf> {
crate::cancel_checkpoint();
{
let __list_subject = args.clone();
if let Some((sizeExpr, rest)) = aver_rt::list_uncons_cloned(&__list_subject) {
{
let __list_subject = rest;
if let Some((fillExpr, ignored)) = aver_rt::list_uncons_cloned(&__list_subject) {
classifyFastVectorNewArgs(&sizeExpr, &fillExpr)
} else {
None
}
}
} else {
None
}
}
}
pub fn classifyFastVectorNewArgs(sizeExpr: &Expr, fillExpr: &Expr) -> Option<FastLeaf> {
crate::cancel_checkpoint();
match sizeExpr.clone() {
Expr::ExprSlot(sizeSlot) => match fillExpr.clone() {
Expr::ExprInt(fill) => Some(FastLeaf::LeafVectorNew(sizeSlot, fill)),
_ => None,
},
_ => None,
}
}
pub fn classifyFastOptionWithDefault(args: &aver_rt::AverList<Expr>) -> Option<FastLeaf> {
crate::cancel_checkpoint();
{
let __list_subject = args.clone();
if let Some((optionExpr, rest)) = aver_rt::list_uncons_cloned(&__list_subject) {
{
let __list_subject = rest;
if let Some((defaultExpr, ignored)) = aver_rt::list_uncons_cloned(&__list_subject) {
classifyFastOptionWithDefaultArgs(&optionExpr, &defaultExpr)
} else {
None
}
}
} else {
None
}
}
}
pub fn classifyFastOptionWithDefaultArgs(
optionExpr: &Expr,
defaultExpr: &Expr,
) -> Option<FastLeaf> {
crate::cancel_checkpoint();
match optionExpr.clone() {
Expr::ExprCallBuiltin(name, innerArgs) => {
if (name == AverStr::from("Vector.get")) {
classifyFastVectorGet(&innerArgs, defaultExpr)
} else {
None
}
}
_ => None,
}
}
pub fn classifyFastVectorGet(
args: &aver_rt::AverList<Expr>,
defaultExpr: &Expr,
) -> Option<FastLeaf> {
crate::cancel_checkpoint();
{
let __list_subject = args.clone();
if let Some((vecExpr, rest)) = aver_rt::list_uncons_cloned(&__list_subject) {
{
let __list_subject = rest;
if let Some((idxExpr, ignored)) = aver_rt::list_uncons_cloned(&__list_subject) {
classifyFastVectorGetArgs(&vecExpr, &idxExpr, defaultExpr)
} else {
None
}
}
} else {
None
}
}
}
pub fn classifyFastVectorGetArgs(
vecExpr: &Expr,
idxExpr: &Expr,
defaultExpr: &Expr,
) -> Option<FastLeaf> {
crate::cancel_checkpoint();
match vecExpr.clone() {
Expr::ExprSlot(vecSlot) => match idxExpr.clone() {
Expr::ExprSlot(idxSlot) => match defaultExpr.clone() {
Expr::ExprInt(defaultValue) => {
Some(FastLeaf::LeafVectorGetOrInt(vecSlot, idxSlot, defaultValue))
}
_ => None,
},
_ => None,
},
_ => None,
}
}
#[inline(always)]
pub fn classifyFastMatch(scrutinee: &Expr, arms: &aver_rt::AverList<MatchArm>) -> FnFastPath {
crate::cancel_checkpoint();
match classifyBoolArms(arms) {
Some(pair) => {
let (thenLeaf, elseLeaf) = pair;
classifyFastMatchScrutinee(scrutinee, &thenLeaf, &elseLeaf)
}
None => classifyFastListMatch(scrutinee, arms),
}
}
pub fn classifyFastListMatch(scrutinee: &Expr, arms: &aver_rt::AverList<MatchArm>) -> FnFastPath {
crate::cancel_checkpoint();
match scrutinee.clone() {
Expr::ExprSlot(slot) => classifyFastListArms(slot, arms),
_ => FnFastPath::FastSingleExpr.clone(),
}
}
pub fn classifyFastListArms(slot: i64, arms: &aver_rt::AverList<MatchArm>) -> FnFastPath {
crate::cancel_checkpoint();
{
let __list_subject = arms.clone();
if let Some((arm1, rest)) = aver_rt::list_uncons_cloned(&__list_subject) {
{
let __list_subject = rest;
if let Some((arm2, tail)) = aver_rt::list_uncons_cloned(&__list_subject) {
if (tail == aver_rt::AverList::empty()) {
classifyFastListArmPair(slot, &arm1, &arm2)
} else {
FnFastPath::FastSingleExpr.clone()
}
} else {
FnFastPath::FastSingleExpr.clone()
}
}
} else {
FnFastPath::FastSingleExpr.clone()
}
}
}
#[inline(always)]
pub fn classifyFastListArmPair(slot: i64, arm1: &MatchArm, arm2: &MatchArm) -> FnFastPath {
crate::cancel_checkpoint();
let leaf1 = classifyFastLeafExpr(&arm1.body);
let leaf2 = classifyFastLeafExpr(&arm2.body);
match leaf1 {
Some(v1) => match leaf2 {
Some(v2) => classifyFastListPatterns(
slot,
&arm1.pattern,
&arm1.bindingSlots,
&v1,
&arm2.pattern,
&arm2.bindingSlots,
&v2,
),
None => FnFastPath::FastSingleExpr.clone(),
},
None => FnFastPath::FastSingleExpr.clone(),
}
}
pub fn classifyFastListPatterns(
slot: i64,
p1: &Pattern,
bindingSlots1: &aver_rt::AverMap<AverStr, i64>,
leaf1: &FastLeaf,
p2: &Pattern,
bindingSlots2: &aver_rt::AverMap<AverStr, i64>,
leaf2: &FastLeaf,
) -> FnFastPath {
crate::cancel_checkpoint();
match p1.clone() {
Pattern::PatEmpty => classifyFastListOther(slot, leaf1, p2, bindingSlots2, leaf2),
Pattern::PatCons(head, tail) => {
classifyFastListConsFirst(slot, head, tail, bindingSlots1, leaf1, p2, leaf2)
}
_ => FnFastPath::FastSingleExpr.clone(),
}
}
pub fn classifyFastListOther(
slot: i64,
emptyLeaf: &FastLeaf,
other: &Pattern,
bindingSlots: &aver_rt::AverMap<AverStr, i64>,
otherLeaf: &FastLeaf,
) -> FnFastPath {
crate::cancel_checkpoint();
match other.clone() {
Pattern::PatCons(head, tail) => {
classifyFastListCons(slot, emptyLeaf, head, tail, bindingSlots, otherLeaf)
}
_ => FnFastPath::FastSingleExpr.clone(),
}
}
pub fn classifyFastListConsFirst(
slot: i64,
head: AverStr,
tail: AverStr,
bindingSlots: &aver_rt::AverMap<AverStr, i64>,
consLeaf: &FastLeaf,
other: &Pattern,
otherLeaf: &FastLeaf,
) -> FnFastPath {
crate::cancel_checkpoint();
match other {
Pattern::PatEmpty => {
classifyFastListCons(slot, otherLeaf, head, tail, bindingSlots, consLeaf)
}
_ => FnFastPath::FastSingleExpr.clone(),
}
}
#[inline(always)]
pub fn classifyFastListCons(
slot: i64,
emptyLeaf: &FastLeaf,
head: AverStr,
tail: AverStr,
bindingSlots: &aver_rt::AverMap<AverStr, i64>,
consLeaf: &FastLeaf,
) -> FnFastPath {
crate::cancel_checkpoint();
match bindingSlots.get(&head).cloned() {
Some(headSlot) => match bindingSlots.get(&tail).cloned() {
Some(tailSlot) => FnFastPath::FastListSlotBranch(
slot,
emptyLeaf.clone(),
headSlot,
tailSlot,
consLeaf.clone(),
),
None => FnFastPath::FastSingleExpr.clone(),
},
None => FnFastPath::FastSingleExpr.clone(),
}
}
#[inline(always)]
pub fn classifyFastForwardCall(fnId: i64, args: &aver_rt::AverList<Expr>) -> FnFastPath {
crate::cancel_checkpoint();
match classifyFastForwardSlots(args.clone(), aver_rt::AverList::empty()) {
Some(slotArgs) => FnFastPath::FastForwardCall(fnId, slotArgs),
None => FnFastPath::FastSingleExpr.clone(),
}
}
#[inline(always)]
pub fn classifyFastForwardSlots(
mut args: aver_rt::AverList<Expr>,
mut acc: aver_rt::AverList<i64>,
) -> Option<aver_rt::AverList<i64>> {
loop {
crate::cancel_checkpoint();
return aver_list_match!(args, [] => Some(acc.reverse()), [arg, rest] => { match arg {
Expr::ExprSlot(slot) => {
let __tmp1 = aver_rt::AverList::prepend(slot, &acc);
args = rest;
acc = __tmp1;
continue;
},
_ => None
} });
}
}
pub fn classifyBoolArms(arms: &aver_rt::AverList<MatchArm>) -> Option<(FastLeaf, FastLeaf)> {
crate::cancel_checkpoint();
{
let __list_subject = arms.clone();
if let Some((arm1, rest)) = aver_rt::list_uncons_cloned(&__list_subject) {
{
let __list_subject = rest;
if let Some((arm2, tail)) = aver_rt::list_uncons_cloned(&__list_subject) {
if (tail == aver_rt::AverList::empty()) {
classifyBoolArmPair(&arm1, &arm2)
} else {
None
}
} else {
None
}
}
} else {
None
}
}
}
#[inline(always)]
pub fn classifyBoolArmPair(arm1: &MatchArm, arm2: &MatchArm) -> Option<(FastLeaf, FastLeaf)> {
crate::cancel_checkpoint();
let leaf1 = classifyFastLeafExpr(&arm1.body);
let leaf2 = classifyFastLeafExpr(&arm2.body);
match leaf1 {
Some(v1) => match leaf2 {
Some(v2) => classifyBoolArmPatterns(&arm1.pattern, &v1, &arm2.pattern, &v2),
None => None,
},
None => None,
}
}
pub fn classifyBoolArmPatterns(
p1: &Pattern,
leaf1: &FastLeaf,
p2: &Pattern,
leaf2: &FastLeaf,
) -> Option<(FastLeaf, FastLeaf)> {
crate::cancel_checkpoint();
match p1.clone() {
Pattern::PatBool(b1) => classifyBoolArmPatternsInner(b1, leaf1, p2, leaf2),
_ => None,
}
}
pub fn classifyBoolArmPatternsInner(
b1: bool,
leaf1: &FastLeaf,
p2: &Pattern,
leaf2: &FastLeaf,
) -> Option<(FastLeaf, FastLeaf)> {
crate::cancel_checkpoint();
match p2.clone() {
Pattern::PatBool(b2) => classifyBoolArmPatternsPair(b1, leaf1, b2, leaf2),
_ => None,
}
}
pub fn classifyBoolArmPatternsPair(
b1: bool,
leaf1: &FastLeaf,
b2: bool,
leaf2: &FastLeaf,
) -> Option<(FastLeaf, FastLeaf)> {
crate::cancel_checkpoint();
match (b1, b2) {
(true, false) => Some((leaf1.clone(), leaf2.clone())),
(false, true) => Some((leaf2.clone(), leaf1.clone())),
_ => None,
}
}
pub fn classifyFastMatchScrutinee(
scrutinee: &Expr,
thenLeaf: &FastLeaf,
elseLeaf: &FastLeaf,
) -> FnFastPath {
crate::cancel_checkpoint();
match scrutinee.clone() {
Expr::ExprSlot(slot) => {
FnFastPath::FastBoolSlotBranch(slot, thenLeaf.clone(), elseLeaf.clone())
}
Expr::ExprEq(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastEqScrutinee(&a, &b, thenLeaf, elseLeaf)
}
Expr::ExprLt(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastLtScrutinee(&a, &b, thenLeaf, elseLeaf)
}
Expr::ExprGt(a, b) => {
let a = (*a).clone();
let b = (*b).clone();
classifyFastLtScrutinee(&b, &a, thenLeaf, elseLeaf)
}
_ => FnFastPath::FastSingleExpr.clone(),
}
}
pub fn classifyFastEqScrutinee(
a: &Expr,
b: &Expr,
thenLeaf: &FastLeaf,
elseLeaf: &FastLeaf,
) -> FnFastPath {
crate::cancel_checkpoint();
match a.clone() {
Expr::ExprSlot(slot) => classifyFastEqOther(slot, b, thenLeaf, elseLeaf),
_ => match b.clone() {
Expr::ExprSlot(slot) => classifyFastEqOther(slot, a, thenLeaf, elseLeaf),
_ => FnFastPath::FastSingleExpr.clone(),
},
}
}
pub fn classifyFastEqOther(
slot: i64,
other: &Expr,
thenLeaf: &FastLeaf,
elseLeaf: &FastLeaf,
) -> FnFastPath {
crate::cancel_checkpoint();
match other.clone() {
Expr::ExprInt(n) => {
FnFastPath::FastEqIntBranch(slot, n, thenLeaf.clone(), elseLeaf.clone())
}
Expr::ExprStr(s) => {
FnFastPath::FastEqStringBranch(slot, s, thenLeaf.clone(), elseLeaf.clone())
}
_ => FnFastPath::FastSingleExpr.clone(),
}
}
pub fn classifyFastLtScrutinee(
a: &Expr,
b: &Expr,
thenLeaf: &FastLeaf,
elseLeaf: &FastLeaf,
) -> FnFastPath {
crate::cancel_checkpoint();
match a.clone() {
Expr::ExprSlot(lhs) => match b.clone() {
Expr::ExprSlot(rhs) => {
FnFastPath::FastLtIntSlotsBranch(lhs, rhs, thenLeaf.clone(), elseLeaf.clone())
}
_ => FnFastPath::FastSingleExpr.clone(),
},
_ => FnFastPath::FastSingleExpr.clone(),
}
}