Perform lambda lifting for compile-time stuff when targeting JS. Enable unittest test.
This commit is contained in:
parent
ccb9ae2d52
commit
c55f5dfca2
3 changed files with 10 additions and 10 deletions
|
|
@ -946,7 +946,11 @@ proc transformOuterProc(o: POuterContext, n: PNode; it: TIter): PNode =
|
||||||
proc liftLambdas*(fn: PSym, body: PNode): PNode =
|
proc liftLambdas*(fn: PSym, body: PNode): PNode =
|
||||||
# XXX gCmd == cmdCompileToJS does not suffice! The compiletime stuff needs
|
# XXX gCmd == cmdCompileToJS does not suffice! The compiletime stuff needs
|
||||||
# the transformation even when compiling to JS ...
|
# the transformation even when compiling to JS ...
|
||||||
if body.kind == nkEmpty or gCmd == cmdCompileToJS or
|
|
||||||
|
# However we can do lifting for the stuff which is *only* compiletime.
|
||||||
|
let isCompileTime = sfCompileTime in fn.flags or fn.kind == skMacro
|
||||||
|
|
||||||
|
if body.kind == nkEmpty or (gCmd == cmdCompileToJS and not isCompileTime) or
|
||||||
fn.skipGenericOwner.kind != skModule:
|
fn.skipGenericOwner.kind != skModule:
|
||||||
# ignore forward declaration:
|
# ignore forward declaration:
|
||||||
result = body
|
result = body
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,9 @@ template test*(name: expr, body: stmt): stmt {.immediate, dirty.} =
|
||||||
body
|
body
|
||||||
|
|
||||||
except:
|
except:
|
||||||
checkpoint("Unhandled exception: " & getCurrentExceptionMsg())
|
when not defined(js):
|
||||||
echo getCurrentException().getStackTrace()
|
checkpoint("Unhandled exception: " & getCurrentExceptionMsg())
|
||||||
|
echo getCurrentException().getStackTrace()
|
||||||
fail()
|
fail()
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
@ -114,9 +115,7 @@ proc checkpoint*(msg: string) =
|
||||||
template fail* =
|
template fail* =
|
||||||
bind checkpoints
|
bind checkpoints
|
||||||
for msg in items(checkpoints):
|
for msg in items(checkpoints):
|
||||||
# this used to be 'echo' which now breaks due to a bug. XXX will revisit
|
echo msg
|
||||||
# this issue later.
|
|
||||||
stdout.writeln msg
|
|
||||||
|
|
||||||
when not defined(ECMAScript):
|
when not defined(ECMAScript):
|
||||||
if abortOnError: quit(1)
|
if abortOnError: quit(1)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
disabled: "true"
|
output: '''[OK] >:)'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Unittest uses lambdalifting at compile-time which we disable for the JS
|
|
||||||
# codegen! So this cannot and will not work for quite some time.
|
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
suite "Bacon":
|
suite "Bacon":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue