-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
0 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|