Skip to content

Commit

Permalink
remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
johnynek committed Dec 7, 2024
1 parent 9a623d5 commit 3c80cb2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 160 deletions.
94 changes: 0 additions & 94 deletions core/src/main/scala/org/bykn/bosatsu/codegen/clang/ClangGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -715,100 +715,6 @@ object ClangGen {
} yield Code.declareInt(offsetIdent, Some(0)) +: res
}

def searchList(
locMut: LocalAnonMut,
initVL: Code.ValueLike,
checkVL: Code.ValueLike,
optLeft: Option[LocalAnonMut]
): T[Code.ValueLike] = {
import Code.Expression

val emptyList: Expression =
Code.Ident("alloc_enum0")(Code.IntLiteral(0))

def isNonEmptyList(expr: Expression): Expression =
Code.Ident("get_variant")(expr) =:= Code.IntLiteral(1)

def headList(expr: Expression): Expression =
Code.Ident("get_enum_index")(expr, Code.IntLiteral(0))

def tailList(expr: Expression): Expression =
Code.Ident("get_enum_index")(expr, Code.IntLiteral(1))

def consList(head: Expression, tail: Expression): Expression =
Code.Ident("alloc_enum2")(Code.IntLiteral(1), head, tail)
/*
* here is the implementation from MatchlessToValue
*
Dynamic { (scope: Scope) =>
var res = false
var currentList = initF(scope)
var leftList = VList.VNil
while (currentList ne null) {
currentList match {
case [email protected](head, tail) =>
scope.updateMut(mutV, nonempty)
scope.updateMut(left, leftList)
res = checkF(scope)
if (res) { currentList = null }
else {
currentList = tail
leftList = VList.Cons(head, leftList)
}
case _ =>
currentList = null
// we don't match empty lists
}
}
res
}
*/
for {
currentList <- getAnon(locMut.ident)
optLeft <- optLeft.traverse(lm => getAnon(lm.ident))
res <- newLocalName("result")
tmpList <- newLocalName("tmp_list")
declTmpList <- Code.ValueLike.declareVar(Code.TypeIdent.BValue, tmpList, initVL)(newLocalName)
/*
top <- currentTop
_ = println(s"""in $top: searchList(
$locMut: LocalAnonMut,
$initVL: Code.ValueLike,
$checkVL: Code.ValueLike,
$optLeft: Option[LocalAnonMut]
)""")
*/
} yield
(Code
.Statements(
Code.DeclareVar(Nil, Code.TypeIdent.Bool, res, Some(Code.FalseLit)),
declTmpList
)
.maybeCombine(
optLeft.map(_ := emptyList),
) +
// we don't match empty lists, so if currentList reaches Empty we are done
Code.While(
isNonEmptyList(tmpList),
Code.block(
currentList := tmpList,
res := checkVL,
Code.ifThenElse(res,
{ tmpList := emptyList },
{
(tmpList := tailList(tmpList))
.maybeCombine(
optLeft.map { left =>
left := consList(headList(currentList), left)
}
)
}
)
)
)
) :+ res
}

def boxFn(ident: Code.Ident, arity: Int): Code.Expression =
Code.Ident(s"alloc_boxed_pure_fn$arity")(ident)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1585,72 +1585,6 @@ object PythonGen {
} yield (offsetIdent := 0).withValue(res)
}

def searchList(
locMut: LocalAnonMut,
initVL: ValueLike,
checkVL: ValueLike,
optLeft: Option[LocalAnonMut]
): Env[ValueLike] =
/*
* here is the implementation from MatchlessToValue
*
Dynamic { (scope: Scope) =>
var res = false
var currentList = initF(scope)
var leftList = VList.VNil
while (currentList ne null) {
currentList match {
case [email protected](head, tail) =>
scope.updateMut(mutV, nonempty)
scope.updateMut(left, leftList)
res = checkF(scope)
if (res) { currentList = null }
else {
currentList = tail
leftList = VList.Cons(head, leftList)
}
case _ =>
currentList = null
// we don't match empty lists
}
}
res
}
*/
(
Env.nameForAnon(locMut.ident),
optLeft.traverse(lm => Env.nameForAnon(lm.ident)),
Env.newAssignableVar,
Env.newAssignableVar
)
.mapN { (currentList, optLeft, res, tmpList) =>
Code
.block(
res := Code.Const.False,
tmpList := initVL,
optLeft.fold(Code.pass)(_ := emptyList),
// we don't match empty lists, so if currentList reaches Empty we are done
Code.While(
isNonEmpty(tmpList),
Code.block(
currentList := tmpList,
res := checkVL,
Code.ifElseS(
res,
tmpList := emptyList,
Code.block(
tmpList := tailList(tmpList),
optLeft.fold(Code.pass) { left =>
left := consList(headList(currentList), left)
}
)
)
)
)
)
.withValue(res)
}

// if expr is a Lambda handle it
def topFn(
name: Code.Ident,
Expand Down

0 comments on commit 3c80cb2

Please sign in to comment.