Implement codegenDecl for js (#6851)

This commit is contained in:
Alexander Ivanov 2017-12-01 16:42:10 +02:00 • committed by Andreas Rumpf
commit 1699d7c2a4
3 changed files with 54 additions and 11 deletions

View file

@ -0,0 +1,11 @@
discard """
output: '''
-1
8
'''
ccodecheck: "'console.log(-1); function fac_' \\d+ '(n_' \\d+ ')'"
"""
proc fac(n: int): int {.codegenDecl: "console.log(-1); function $2($3)".} =
return n
echo fac(8)

View file

@ -0,0 +1,10 @@
discard """
output: '''
-1
2
'''
ccodecheck: "'console.log(-1); var v_' \\d+ ' = [2]'"
"""
var v {.codegenDecl: "console.log(-1); var $2".} = 2
echo v