Skip to content

Commit e1661cc

Browse files
committed
Merge pull request #82 from afernandez90/develop
Extending support of C++11 lambda expression code generation
2 parents 54b6bc1 + 17be610 commit e1661cc

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/common/Functions.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,10 @@ trait CGenFunctions extends CGenEffect with BaseGenFunctions {
346346
val IR: FunctionsExp
347347
import IR._
348348

349-
// Nested functions are not allowed in standard C.
350-
// TODO: Either emit the function other place or use C++11 (or only gcc)
351-
/*
349+
// Case for functions with a single argument (therefore, not tupled)
352350
override def emitNode(sym: Sym[Any], rhs: Def[Any]) = rhs match {
353351
case e@Lambda(fun, x, y) =>
354-
stream.println(remap(y.tp)+" "+quote(sym)+"("+remap(x.tp)+" "+quote(x)+") {")
352+
stream.println("auto "+quote(sym)+" = [&]("+remap(x.tp)+" "+quote(x)+") {")
355353
emitBlock(y)
356354
val z = getBlockResult(y)
357355
if (remap(z.tp) != "void")
@@ -361,7 +359,7 @@ trait CGenFunctions extends CGenEffect with BaseGenFunctions {
361359
emitValDef(sym, quote(fun) + "(" + quote(arg) + ")")
362360
case _ => super.emitNode(sym, rhs)
363361
}
364-
*/
362+
365363
}
366364

367365
trait CGenTupledFunctions extends CGenFunctions with GenericGenUnboxedTupleAccess {

0 commit comments

Comments
 (0)