openarray/varargs split; breaks bootstrapping
This commit is contained in:
parent
1215193010
commit
0171566c98
29 changed files with 228 additions and 175 deletions
|
|
@ -7,8 +7,6 @@ SET LINK_FLAGS=
|
||||||
|
|
||||||
REM call the compiler:
|
REM call the compiler:
|
||||||
|
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\nim__dat.c -o build\1_1\nim__dat.o
|
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_1\nim__dat.c -o build\1_1\nim__dat.o
|
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\system.c -o build\1_1\system.o
|
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\system.c -o build\1_1\system.o
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_1\system.c -o build\1_1\system.o
|
%CC% %COMP_FLAGS% -Ibuild -c build\1_1\system.c -o build\1_1\system.o
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\nimrod.c -o build\1_1\nimrod.o
|
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\nimrod.c -o build\1_1\nimrod.o
|
||||||
|
|
@ -141,8 +139,6 @@ ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\semtypinst.c -o build\1_1\semtypinst
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_1\semtypinst.c -o build\1_1\semtypinst.o
|
%CC% %COMP_FLAGS% -Ibuild -c build\1_1\semtypinst.c -o build\1_1\semtypinst.o
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\sigmatch.c -o build\1_1\sigmatch.o
|
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\sigmatch.c -o build\1_1\sigmatch.o
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_1\sigmatch.c -o build\1_1\sigmatch.o
|
%CC% %COMP_FLAGS% -Ibuild -c build\1_1\sigmatch.c -o build\1_1\sigmatch.o
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\suggest.c -o build\1_1\suggest.o
|
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_1\suggest.c -o build\1_1\suggest.o
|
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\aliases.c -o build\1_1\aliases.o
|
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\aliases.c -o build\1_1\aliases.o
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_1\aliases.c -o build\1_1\aliases.o
|
%CC% %COMP_FLAGS% -Ibuild -c build\1_1\aliases.c -o build\1_1\aliases.o
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\docgen.c -o build\1_1\docgen.o
|
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\docgen.c -o build\1_1\docgen.o
|
||||||
|
|
@ -174,8 +170,8 @@ ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\docgen2.c -o build\1_1\docgen2.o
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\parseopt.c -o build\1_1\parseopt.o
|
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_1\parseopt.c -o build\1_1\parseopt.o
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_1\parseopt.c -o build\1_1\parseopt.o
|
%CC% %COMP_FLAGS% -Ibuild -c build\1_1\parseopt.c -o build\1_1\parseopt.o
|
||||||
|
|
||||||
ECHO %LINKER% %LINK_FLAGS% -o bin\nimrod.exe build\1_1\nim__dat.o build\1_1\system.o build\1_1\nimrod.o build\1_1\times.o build\1_1\strutils.o build\1_1\parseutils.o build\1_1\winlean.o build\1_1\commands.o build\1_1\os.o build\1_1\msgs.o build\1_1\options.o build\1_1\lists.o build\1_1\strtabs.o build\1_1\hashes.o build\1_1\tables.o build\1_1\math.o build\1_1\nversion.o build\1_1\condsyms.o build\1_1\ast.o build\1_1\crc.o build\1_1\ropes.o build\1_1\platform.o build\1_1\idents.o build\1_1\intsets.o build\1_1\idgen.o build\1_1\astalgo.o build\1_1\rodutils.o build\1_1\extccomp.o build\1_1\osproc.o build\1_1\streams.o build\1_1\wordrecg.o build\1_1\lexer.o build\1_1\lexbase.o build\1_1\llstream.o build\1_1\nimconf.o build\1_1\main.o build\1_1\syntaxes.o build\1_1\parser.o build\1_1\pbraces.o build\1_1\filters.o build\1_1\renderer.o build\1_1\filter_tmpl.o build\1_1\rodread.o build\1_1\types.o build\1_1\trees.o build\1_1\memfiles.o build\1_1\rodwrite.o build\1_1\passes.o build\1_1\magicsys.o build\1_1\nimsets.o build\1_1\bitsets.o build\1_1\semthreads.o build\1_1\importer.o build\1_1\lookups.o build\1_1\semdata.o build\1_1\treetab.o build\1_1\evals.o build\1_1\semfold.o build\1_1\saturate.o build\1_1\transf.o build\1_1\cgmeth.o build\1_1\lambdalifting.o build\1_1\sem.o build\1_1\procfind.o build\1_1\pragmas.o build\1_1\semtypinst.o build\1_1\sigmatch.o build\1_1\suggest.o build\1_1\aliases.o build\1_1\docgen.o build\1_1\rstast.o build\1_1\rst.o build\1_1\rstgen.o build\1_1\highlite.o build\1_1\cgen.o build\1_1\ccgutils.o build\1_1\cgendata.o build\1_1\ccgmerge.o build\1_1\ecmasgen.o build\1_1\passaux.o build\1_1\depends.o build\1_1\docgen2.o build\1_1\parseopt.o
|
ECHO %LINKER% %LINK_FLAGS% -o bin\nimrod.exe build\1_1\system.o build\1_1\nimrod.o build\1_1\times.o build\1_1\strutils.o build\1_1\parseutils.o build\1_1\winlean.o build\1_1\commands.o build\1_1\os.o build\1_1\msgs.o build\1_1\options.o build\1_1\lists.o build\1_1\strtabs.o build\1_1\hashes.o build\1_1\tables.o build\1_1\math.o build\1_1\nversion.o build\1_1\condsyms.o build\1_1\ast.o build\1_1\crc.o build\1_1\ropes.o build\1_1\platform.o build\1_1\idents.o build\1_1\intsets.o build\1_1\idgen.o build\1_1\astalgo.o build\1_1\rodutils.o build\1_1\extccomp.o build\1_1\osproc.o build\1_1\streams.o build\1_1\wordrecg.o build\1_1\lexer.o build\1_1\lexbase.o build\1_1\llstream.o build\1_1\nimconf.o build\1_1\main.o build\1_1\syntaxes.o build\1_1\parser.o build\1_1\pbraces.o build\1_1\filters.o build\1_1\renderer.o build\1_1\filter_tmpl.o build\1_1\rodread.o build\1_1\types.o build\1_1\trees.o build\1_1\memfiles.o build\1_1\rodwrite.o build\1_1\passes.o build\1_1\magicsys.o build\1_1\nimsets.o build\1_1\bitsets.o build\1_1\semthreads.o build\1_1\importer.o build\1_1\lookups.o build\1_1\semdata.o build\1_1\treetab.o build\1_1\evals.o build\1_1\semfold.o build\1_1\saturate.o build\1_1\transf.o build\1_1\cgmeth.o build\1_1\lambdalifting.o build\1_1\sem.o build\1_1\procfind.o build\1_1\pragmas.o build\1_1\semtypinst.o build\1_1\sigmatch.o build\1_1\aliases.o build\1_1\docgen.o build\1_1\rstast.o build\1_1\rst.o build\1_1\rstgen.o build\1_1\highlite.o build\1_1\cgen.o build\1_1\ccgutils.o build\1_1\cgendata.o build\1_1\ccgmerge.o build\1_1\ecmasgen.o build\1_1\passaux.o build\1_1\depends.o build\1_1\docgen2.o build\1_1\parseopt.o
|
||||||
%LINKER% %LINK_FLAGS% -o bin\nimrod.exe build\1_1\nim__dat.o build\1_1\system.o build\1_1\nimrod.o build\1_1\times.o build\1_1\strutils.o build\1_1\parseutils.o build\1_1\winlean.o build\1_1\commands.o build\1_1\os.o build\1_1\msgs.o build\1_1\options.o build\1_1\lists.o build\1_1\strtabs.o build\1_1\hashes.o build\1_1\tables.o build\1_1\math.o build\1_1\nversion.o build\1_1\condsyms.o build\1_1\ast.o build\1_1\crc.o build\1_1\ropes.o build\1_1\platform.o build\1_1\idents.o build\1_1\intsets.o build\1_1\idgen.o build\1_1\astalgo.o build\1_1\rodutils.o build\1_1\extccomp.o build\1_1\osproc.o build\1_1\streams.o build\1_1\wordrecg.o build\1_1\lexer.o build\1_1\lexbase.o build\1_1\llstream.o build\1_1\nimconf.o build\1_1\main.o build\1_1\syntaxes.o build\1_1\parser.o build\1_1\pbraces.o build\1_1\filters.o build\1_1\renderer.o build\1_1\filter_tmpl.o build\1_1\rodread.o build\1_1\types.o build\1_1\trees.o build\1_1\memfiles.o build\1_1\rodwrite.o build\1_1\passes.o build\1_1\magicsys.o build\1_1\nimsets.o build\1_1\bitsets.o build\1_1\semthreads.o build\1_1\importer.o build\1_1\lookups.o build\1_1\semdata.o build\1_1\treetab.o build\1_1\evals.o build\1_1\semfold.o build\1_1\saturate.o build\1_1\transf.o build\1_1\cgmeth.o build\1_1\lambdalifting.o build\1_1\sem.o build\1_1\procfind.o build\1_1\pragmas.o build\1_1\semtypinst.o build\1_1\sigmatch.o build\1_1\suggest.o build\1_1\aliases.o build\1_1\docgen.o build\1_1\rstast.o build\1_1\rst.o build\1_1\rstgen.o build\1_1\highlite.o build\1_1\cgen.o build\1_1\ccgutils.o build\1_1\cgendata.o build\1_1\ccgmerge.o build\1_1\ecmasgen.o build\1_1\passaux.o build\1_1\depends.o build\1_1\docgen2.o build\1_1\parseopt.o
|
%LINKER% %LINK_FLAGS% -o bin\nimrod.exe build\1_1\system.o build\1_1\nimrod.o build\1_1\times.o build\1_1\strutils.o build\1_1\parseutils.o build\1_1\winlean.o build\1_1\commands.o build\1_1\os.o build\1_1\msgs.o build\1_1\options.o build\1_1\lists.o build\1_1\strtabs.o build\1_1\hashes.o build\1_1\tables.o build\1_1\math.o build\1_1\nversion.o build\1_1\condsyms.o build\1_1\ast.o build\1_1\crc.o build\1_1\ropes.o build\1_1\platform.o build\1_1\idents.o build\1_1\intsets.o build\1_1\idgen.o build\1_1\astalgo.o build\1_1\rodutils.o build\1_1\extccomp.o build\1_1\osproc.o build\1_1\streams.o build\1_1\wordrecg.o build\1_1\lexer.o build\1_1\lexbase.o build\1_1\llstream.o build\1_1\nimconf.o build\1_1\main.o build\1_1\syntaxes.o build\1_1\parser.o build\1_1\pbraces.o build\1_1\filters.o build\1_1\renderer.o build\1_1\filter_tmpl.o build\1_1\rodread.o build\1_1\types.o build\1_1\trees.o build\1_1\memfiles.o build\1_1\rodwrite.o build\1_1\passes.o build\1_1\magicsys.o build\1_1\nimsets.o build\1_1\bitsets.o build\1_1\semthreads.o build\1_1\importer.o build\1_1\lookups.o build\1_1\semdata.o build\1_1\treetab.o build\1_1\evals.o build\1_1\semfold.o build\1_1\saturate.o build\1_1\transf.o build\1_1\cgmeth.o build\1_1\lambdalifting.o build\1_1\sem.o build\1_1\procfind.o build\1_1\pragmas.o build\1_1\semtypinst.o build\1_1\sigmatch.o build\1_1\aliases.o build\1_1\docgen.o build\1_1\rstast.o build\1_1\rst.o build\1_1\rstgen.o build\1_1\highlite.o build\1_1\cgen.o build\1_1\ccgutils.o build\1_1\cgendata.o build\1_1\ccgmerge.o build\1_1\ecmasgen.o build\1_1\passaux.o build\1_1\depends.o build\1_1\docgen2.o build\1_1\parseopt.o
|
||||||
|
|
||||||
|
|
||||||
ECHO SUCCESS
|
ECHO SUCCESS
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@ SET LINK_FLAGS=
|
||||||
|
|
||||||
REM call the compiler:
|
REM call the compiler:
|
||||||
|
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\nim__dat.c -o build\1_2\nim__dat.o
|
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_2\nim__dat.c -o build\1_2\nim__dat.o
|
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\system.c -o build\1_2\system.o
|
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\system.c -o build\1_2\system.o
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_2\system.c -o build\1_2\system.o
|
%CC% %COMP_FLAGS% -Ibuild -c build\1_2\system.c -o build\1_2\system.o
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\nimrod.c -o build\1_2\nimrod.o
|
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\nimrod.c -o build\1_2\nimrod.o
|
||||||
|
|
@ -141,8 +139,6 @@ ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\semtypinst.c -o build\1_2\semtypinst
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_2\semtypinst.c -o build\1_2\semtypinst.o
|
%CC% %COMP_FLAGS% -Ibuild -c build\1_2\semtypinst.c -o build\1_2\semtypinst.o
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\sigmatch.c -o build\1_2\sigmatch.o
|
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\sigmatch.c -o build\1_2\sigmatch.o
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_2\sigmatch.c -o build\1_2\sigmatch.o
|
%CC% %COMP_FLAGS% -Ibuild -c build\1_2\sigmatch.c -o build\1_2\sigmatch.o
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\suggest.c -o build\1_2\suggest.o
|
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_2\suggest.c -o build\1_2\suggest.o
|
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\aliases.c -o build\1_2\aliases.o
|
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\aliases.c -o build\1_2\aliases.o
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_2\aliases.c -o build\1_2\aliases.o
|
%CC% %COMP_FLAGS% -Ibuild -c build\1_2\aliases.c -o build\1_2\aliases.o
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\docgen.c -o build\1_2\docgen.o
|
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\docgen.c -o build\1_2\docgen.o
|
||||||
|
|
@ -174,8 +170,8 @@ ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\docgen2.c -o build\1_2\docgen2.o
|
||||||
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\parseopt.c -o build\1_2\parseopt.o
|
ECHO %CC% %COMP_FLAGS% -Ibuild -c build\1_2\parseopt.c -o build\1_2\parseopt.o
|
||||||
%CC% %COMP_FLAGS% -Ibuild -c build\1_2\parseopt.c -o build\1_2\parseopt.o
|
%CC% %COMP_FLAGS% -Ibuild -c build\1_2\parseopt.c -o build\1_2\parseopt.o
|
||||||
|
|
||||||
ECHO %LINKER% %LINK_FLAGS% -o bin\nimrod.exe build\1_2\nim__dat.o build\1_2\system.o build\1_2\nimrod.o build\1_2\times.o build\1_2\strutils.o build\1_2\parseutils.o build\1_2\winlean.o build\1_2\commands.o build\1_2\os.o build\1_2\msgs.o build\1_2\options.o build\1_2\lists.o build\1_2\strtabs.o build\1_2\hashes.o build\1_2\tables.o build\1_2\math.o build\1_2\nversion.o build\1_2\condsyms.o build\1_2\ast.o build\1_2\crc.o build\1_2\ropes.o build\1_2\platform.o build\1_2\idents.o build\1_2\intsets.o build\1_2\idgen.o build\1_2\astalgo.o build\1_2\rodutils.o build\1_2\extccomp.o build\1_2\osproc.o build\1_2\streams.o build\1_2\wordrecg.o build\1_2\lexer.o build\1_2\lexbase.o build\1_2\llstream.o build\1_2\nimconf.o build\1_2\main.o build\1_2\syntaxes.o build\1_2\parser.o build\1_2\pbraces.o build\1_2\filters.o build\1_2\renderer.o build\1_2\filter_tmpl.o build\1_2\rodread.o build\1_2\types.o build\1_2\trees.o build\1_2\memfiles.o build\1_2\rodwrite.o build\1_2\passes.o build\1_2\magicsys.o build\1_2\nimsets.o build\1_2\bitsets.o build\1_2\semthreads.o build\1_2\importer.o build\1_2\lookups.o build\1_2\semdata.o build\1_2\treetab.o build\1_2\evals.o build\1_2\semfold.o build\1_2\saturate.o build\1_2\transf.o build\1_2\cgmeth.o build\1_2\lambdalifting.o build\1_2\sem.o build\1_2\procfind.o build\1_2\pragmas.o build\1_2\semtypinst.o build\1_2\sigmatch.o build\1_2\suggest.o build\1_2\aliases.o build\1_2\docgen.o build\1_2\rstast.o build\1_2\rst.o build\1_2\rstgen.o build\1_2\highlite.o build\1_2\cgen.o build\1_2\ccgutils.o build\1_2\cgendata.o build\1_2\ccgmerge.o build\1_2\ecmasgen.o build\1_2\passaux.o build\1_2\depends.o build\1_2\docgen2.o build\1_2\parseopt.o
|
ECHO %LINKER% %LINK_FLAGS% -o bin\nimrod.exe build\1_2\system.o build\1_2\nimrod.o build\1_2\times.o build\1_2\strutils.o build\1_2\parseutils.o build\1_2\winlean.o build\1_2\commands.o build\1_2\os.o build\1_2\msgs.o build\1_2\options.o build\1_2\lists.o build\1_2\strtabs.o build\1_2\hashes.o build\1_2\tables.o build\1_2\math.o build\1_2\nversion.o build\1_2\condsyms.o build\1_2\ast.o build\1_2\crc.o build\1_2\ropes.o build\1_2\platform.o build\1_2\idents.o build\1_2\intsets.o build\1_2\idgen.o build\1_2\astalgo.o build\1_2\rodutils.o build\1_2\extccomp.o build\1_2\osproc.o build\1_2\streams.o build\1_2\wordrecg.o build\1_2\lexer.o build\1_2\lexbase.o build\1_2\llstream.o build\1_2\nimconf.o build\1_2\main.o build\1_2\syntaxes.o build\1_2\parser.o build\1_2\pbraces.o build\1_2\filters.o build\1_2\renderer.o build\1_2\filter_tmpl.o build\1_2\rodread.o build\1_2\types.o build\1_2\trees.o build\1_2\memfiles.o build\1_2\rodwrite.o build\1_2\passes.o build\1_2\magicsys.o build\1_2\nimsets.o build\1_2\bitsets.o build\1_2\semthreads.o build\1_2\importer.o build\1_2\lookups.o build\1_2\semdata.o build\1_2\treetab.o build\1_2\evals.o build\1_2\semfold.o build\1_2\saturate.o build\1_2\transf.o build\1_2\cgmeth.o build\1_2\lambdalifting.o build\1_2\sem.o build\1_2\procfind.o build\1_2\pragmas.o build\1_2\semtypinst.o build\1_2\sigmatch.o build\1_2\aliases.o build\1_2\docgen.o build\1_2\rstast.o build\1_2\rst.o build\1_2\rstgen.o build\1_2\highlite.o build\1_2\cgen.o build\1_2\ccgutils.o build\1_2\cgendata.o build\1_2\ccgmerge.o build\1_2\ecmasgen.o build\1_2\passaux.o build\1_2\depends.o build\1_2\docgen2.o build\1_2\parseopt.o
|
||||||
%LINKER% %LINK_FLAGS% -o bin\nimrod.exe build\1_2\nim__dat.o build\1_2\system.o build\1_2\nimrod.o build\1_2\times.o build\1_2\strutils.o build\1_2\parseutils.o build\1_2\winlean.o build\1_2\commands.o build\1_2\os.o build\1_2\msgs.o build\1_2\options.o build\1_2\lists.o build\1_2\strtabs.o build\1_2\hashes.o build\1_2\tables.o build\1_2\math.o build\1_2\nversion.o build\1_2\condsyms.o build\1_2\ast.o build\1_2\crc.o build\1_2\ropes.o build\1_2\platform.o build\1_2\idents.o build\1_2\intsets.o build\1_2\idgen.o build\1_2\astalgo.o build\1_2\rodutils.o build\1_2\extccomp.o build\1_2\osproc.o build\1_2\streams.o build\1_2\wordrecg.o build\1_2\lexer.o build\1_2\lexbase.o build\1_2\llstream.o build\1_2\nimconf.o build\1_2\main.o build\1_2\syntaxes.o build\1_2\parser.o build\1_2\pbraces.o build\1_2\filters.o build\1_2\renderer.o build\1_2\filter_tmpl.o build\1_2\rodread.o build\1_2\types.o build\1_2\trees.o build\1_2\memfiles.o build\1_2\rodwrite.o build\1_2\passes.o build\1_2\magicsys.o build\1_2\nimsets.o build\1_2\bitsets.o build\1_2\semthreads.o build\1_2\importer.o build\1_2\lookups.o build\1_2\semdata.o build\1_2\treetab.o build\1_2\evals.o build\1_2\semfold.o build\1_2\saturate.o build\1_2\transf.o build\1_2\cgmeth.o build\1_2\lambdalifting.o build\1_2\sem.o build\1_2\procfind.o build\1_2\pragmas.o build\1_2\semtypinst.o build\1_2\sigmatch.o build\1_2\suggest.o build\1_2\aliases.o build\1_2\docgen.o build\1_2\rstast.o build\1_2\rst.o build\1_2\rstgen.o build\1_2\highlite.o build\1_2\cgen.o build\1_2\ccgutils.o build\1_2\cgendata.o build\1_2\ccgmerge.o build\1_2\ecmasgen.o build\1_2\passaux.o build\1_2\depends.o build\1_2\docgen2.o build\1_2\parseopt.o
|
%LINKER% %LINK_FLAGS% -o bin\nimrod.exe build\1_2\system.o build\1_2\nimrod.o build\1_2\times.o build\1_2\strutils.o build\1_2\parseutils.o build\1_2\winlean.o build\1_2\commands.o build\1_2\os.o build\1_2\msgs.o build\1_2\options.o build\1_2\lists.o build\1_2\strtabs.o build\1_2\hashes.o build\1_2\tables.o build\1_2\math.o build\1_2\nversion.o build\1_2\condsyms.o build\1_2\ast.o build\1_2\crc.o build\1_2\ropes.o build\1_2\platform.o build\1_2\idents.o build\1_2\intsets.o build\1_2\idgen.o build\1_2\astalgo.o build\1_2\rodutils.o build\1_2\extccomp.o build\1_2\osproc.o build\1_2\streams.o build\1_2\wordrecg.o build\1_2\lexer.o build\1_2\lexbase.o build\1_2\llstream.o build\1_2\nimconf.o build\1_2\main.o build\1_2\syntaxes.o build\1_2\parser.o build\1_2\pbraces.o build\1_2\filters.o build\1_2\renderer.o build\1_2\filter_tmpl.o build\1_2\rodread.o build\1_2\types.o build\1_2\trees.o build\1_2\memfiles.o build\1_2\rodwrite.o build\1_2\passes.o build\1_2\magicsys.o build\1_2\nimsets.o build\1_2\bitsets.o build\1_2\semthreads.o build\1_2\importer.o build\1_2\lookups.o build\1_2\semdata.o build\1_2\treetab.o build\1_2\evals.o build\1_2\semfold.o build\1_2\saturate.o build\1_2\transf.o build\1_2\cgmeth.o build\1_2\lambdalifting.o build\1_2\sem.o build\1_2\procfind.o build\1_2\pragmas.o build\1_2\semtypinst.o build\1_2\sigmatch.o build\1_2\aliases.o build\1_2\docgen.o build\1_2\rstast.o build\1_2\rst.o build\1_2\rstgen.o build\1_2\highlite.o build\1_2\cgen.o build\1_2\ccgutils.o build\1_2\cgendata.o build\1_2\ccgmerge.o build\1_2\ecmasgen.o build\1_2\passaux.o build\1_2\depends.o build\1_2\docgen2.o build\1_2\parseopt.o
|
||||||
|
|
||||||
|
|
||||||
ECHO SUCCESS
|
ECHO SUCCESS
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ proc loadInto(p: BProc, le, ri: PNode, a: var TLoc) {.inline.} =
|
||||||
expr(p, ri, a)
|
expr(p, ri, a)
|
||||||
|
|
||||||
proc startBlock(p: BProc, start: TFormatStr = "{$n",
|
proc startBlock(p: BProc, start: TFormatStr = "{$n",
|
||||||
args: openarray[PRope]): int {.discardable.} =
|
args: varargs[PRope]): int {.discardable.} =
|
||||||
lineCg(p, cpsStmts, start, args)
|
lineCg(p, cpsStmts, start, args)
|
||||||
inc(p.labels)
|
inc(p.labels)
|
||||||
result = len(p.blocks)
|
result = len(p.blocks)
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ proc getTypeName(typ: PType): PRope =
|
||||||
else:
|
else:
|
||||||
if typ.loc.r == nil:
|
if typ.loc.r == nil:
|
||||||
typ.loc.r = if gCmd != cmdCompileToLLVM: con(typ.typeName, typ.id.toRope)
|
typ.loc.r = if gCmd != cmdCompileToLLVM: con(typ.typeName, typ.id.toRope)
|
||||||
else: con("%".toRope, typ.typeName, typ.id.toRope)
|
else: con(["%".toRope, typ.typeName, typ.id.toRope])
|
||||||
result = typ.loc.r
|
result = typ.loc.r
|
||||||
if result == nil: InternalError("getTypeName: " & $typ.kind)
|
if result == nil: InternalError("getTypeName: " & $typ.kind)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,12 @@ proc cgenPass*(): TPass
|
||||||
var
|
var
|
||||||
generatedHeader: BModule
|
generatedHeader: BModule
|
||||||
|
|
||||||
proc ropeff(cformat, llvmformat: string, args: openarray[PRope]): PRope =
|
proc ropeff(cformat, llvmformat: string, args: varargs[PRope]): PRope =
|
||||||
if gCmd == cmdCompileToLLVM: result = ropef(llvmformat, args)
|
if gCmd == cmdCompileToLLVM: result = ropef(llvmformat, args)
|
||||||
else: result = ropef(cformat, args)
|
else: result = ropef(cformat, args)
|
||||||
|
|
||||||
proc appff(dest: var PRope, cformat, llvmformat: string,
|
proc appff(dest: var PRope, cformat, llvmformat: string,
|
||||||
args: openarray[PRope]) =
|
args: varargs[PRope]) =
|
||||||
if gCmd == cmdCompileToLLVM: appf(dest, llvmformat, args)
|
if gCmd == cmdCompileToLLVM: appf(dest, llvmformat, args)
|
||||||
else: appf(dest, cformat, args)
|
else: appf(dest, cformat, args)
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ proc useHeader(m: BModule, sym: PSym) =
|
||||||
|
|
||||||
proc cgsym(m: BModule, name: string): PRope
|
proc cgsym(m: BModule, name: string): PRope
|
||||||
|
|
||||||
proc ropecg(m: BModule, frmt: TFormatStr, args: openarray[PRope]): PRope =
|
proc ropecg(m: BModule, frmt: TFormatStr, args: varargs[PRope]): PRope =
|
||||||
var i = 0
|
var i = 0
|
||||||
var length = len(frmt)
|
var length = len(frmt)
|
||||||
result = nil
|
result = nil
|
||||||
|
|
@ -145,15 +145,15 @@ proc ropecg(m: BModule, frmt: TFormatStr, args: openarray[PRope]): PRope =
|
||||||
app(result, substr(frmt, start, i - 1))
|
app(result, substr(frmt, start, i - 1))
|
||||||
|
|
||||||
proc appcg(m: BModule, c: var PRope, frmt: TFormatStr,
|
proc appcg(m: BModule, c: var PRope, frmt: TFormatStr,
|
||||||
args: openarray[PRope]) =
|
args: varargs[PRope]) =
|
||||||
app(c, ropecg(m, frmt, args))
|
app(c, ropecg(m, frmt, args))
|
||||||
|
|
||||||
proc appcg(m: BModule, s: TCFileSection, frmt: TFormatStr,
|
proc appcg(m: BModule, s: TCFileSection, frmt: TFormatStr,
|
||||||
args: openarray[PRope]) =
|
args: varargs[PRope]) =
|
||||||
app(m.s[s], ropecg(m, frmt, args))
|
app(m.s[s], ropecg(m, frmt, args))
|
||||||
|
|
||||||
proc appcg(p: BProc, s: TCProcSection, frmt: TFormatStr,
|
proc appcg(p: BProc, s: TCProcSection, frmt: TFormatStr,
|
||||||
args: openarray[PRope]) =
|
args: varargs[PRope]) =
|
||||||
app(p.s(s), ropecg(p.module, frmt, args))
|
app(p.s(s), ropecg(p.module, frmt, args))
|
||||||
|
|
||||||
var indent = "\t".toRope
|
var indent = "\t".toRope
|
||||||
|
|
@ -168,19 +168,19 @@ proc line(p: BProc, s: TCProcSection, r: string) =
|
||||||
app(p.s(s), indentLine(p, r.toRope))
|
app(p.s(s), indentLine(p, r.toRope))
|
||||||
|
|
||||||
proc lineF(p: BProc, s: TCProcSection, frmt: TFormatStr,
|
proc lineF(p: BProc, s: TCProcSection, frmt: TFormatStr,
|
||||||
args: openarray[PRope]) =
|
args: varargs[PRope]) =
|
||||||
app(p.s(s), indentLine(p, ropef(frmt, args)))
|
app(p.s(s), indentLine(p, ropef(frmt, args)))
|
||||||
|
|
||||||
proc lineCg(p: BProc, s: TCProcSection, frmt: TFormatStr,
|
proc lineCg(p: BProc, s: TCProcSection, frmt: TFormatStr,
|
||||||
args: openarray[PRope]) =
|
args: varargs[PRope]) =
|
||||||
app(p.s(s), indentLine(p, ropecg(p.module, frmt, args)))
|
app(p.s(s), indentLine(p, ropecg(p.module, frmt, args)))
|
||||||
|
|
||||||
proc appLineCg(p: BProc, r: var PRope, frmt: TFormatStr,
|
proc appLineCg(p: BProc, r: var PRope, frmt: TFormatStr,
|
||||||
args: openarray[PRope]) =
|
args: varargs[PRope]) =
|
||||||
app(r, indentLine(p, ropecg(p.module, frmt, args)))
|
app(r, indentLine(p, ropecg(p.module, frmt, args)))
|
||||||
|
|
||||||
proc lineFF(p: BProc, s: TCProcSection, cformat, llvmformat: string,
|
proc lineFF(p: BProc, s: TCProcSection, cformat, llvmformat: string,
|
||||||
args: openarray[PRope]) =
|
args: varargs[PRope]) =
|
||||||
if gCmd == cmdCompileToLLVM: lineF(p, s, llvmformat, args)
|
if gCmd == cmdCompileToLLVM: lineF(p, s, llvmformat, args)
|
||||||
else: lineF(p, s, cformat, args)
|
else: lineF(p, s, cformat, args)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -479,7 +479,7 @@ proc getLinkOptions: string =
|
||||||
for linkedLib in items(cLinkedLibs):
|
for linkedLib in items(cLinkedLibs):
|
||||||
result.add(cc[ccompiler].linkLibCmd % linkedLib.quoteIfContainsWhite)
|
result.add(cc[ccompiler].linkLibCmd % linkedLib.quoteIfContainsWhite)
|
||||||
for libDir in items(cLibs):
|
for libDir in items(cLibs):
|
||||||
result.add cc[ccompiler].linkDirCmd, libDir.quoteIfContainsWhite
|
result.add([cc[ccompiler].linkDirCmd, libDir.quoteIfContainsWhite])
|
||||||
|
|
||||||
proc needsExeExt(): bool {.inline.} =
|
proc needsExeExt(): bool {.inline.} =
|
||||||
result = (optGenScript in gGlobalOptions and targetOS == osWindows) or
|
result = (optGenScript in gGlobalOptions and targetOS == osWindows) or
|
||||||
|
|
@ -502,7 +502,7 @@ proc getCompileCFileCmd*(cfilename: string, isExternal = false): string =
|
||||||
includeCmd = cc[c].includeCmd & quoteIfContainsWhite(libpath)
|
includeCmd = cc[c].includeCmd & quoteIfContainsWhite(libpath)
|
||||||
|
|
||||||
for includeDir in items(cIncludes):
|
for includeDir in items(cIncludes):
|
||||||
includeCmd.add cc[c].includeCmd, includeDir.quoteIfContainsWhite
|
includeCmd.add([cc[c].includeCmd, includeDir.quoteIfContainsWhite])
|
||||||
|
|
||||||
compilePattern = JoinPath(ccompilerpath, exe)
|
compilePattern = JoinPath(ccompilerpath, exe)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ type
|
||||||
proc con*(a, b: PRope): PRope
|
proc con*(a, b: PRope): PRope
|
||||||
proc con*(a: PRope, b: string): PRope
|
proc con*(a: PRope, b: string): PRope
|
||||||
proc con*(a: string, b: PRope): PRope
|
proc con*(a: string, b: PRope): PRope
|
||||||
proc con*(a: openarray[PRope]): PRope
|
proc con*(a: varargs[PRope]): PRope
|
||||||
proc app*(a: var PRope, b: PRope)
|
proc app*(a: var PRope, b: PRope)
|
||||||
proc app*(a: var PRope, b: string)
|
proc app*(a: var PRope, b: string)
|
||||||
proc prepend*(a: var PRope, b: PRope)
|
proc prepend*(a: var PRope, b: PRope)
|
||||||
|
|
@ -84,8 +84,8 @@ proc toRope*(i: BiggestInt): PRope
|
||||||
proc ropeLen*(a: PRope): int
|
proc ropeLen*(a: PRope): int
|
||||||
proc writeRopeIfNotEqual*(r: PRope, filename: string): bool
|
proc writeRopeIfNotEqual*(r: PRope, filename: string): bool
|
||||||
proc ropeToStr*(p: PRope): string
|
proc ropeToStr*(p: PRope): string
|
||||||
proc ropef*(frmt: TFormatStr, args: openarray[PRope]): PRope
|
proc ropef*(frmt: TFormatStr, args: varargs[PRope]): PRope
|
||||||
proc appf*(c: var PRope, frmt: TFormatStr, args: openarray[PRope])
|
proc appf*(c: var PRope, frmt: TFormatStr, args: varargs[PRope])
|
||||||
proc RopeEqualsFile*(r: PRope, f: string): bool
|
proc RopeEqualsFile*(r: PRope, f: string): bool
|
||||||
# returns true if the rope r is the same as the contents of file f
|
# returns true if the rope r is the same as the contents of file f
|
||||||
proc RopeInvariant*(r: PRope): bool
|
proc RopeInvariant*(r: PRope): bool
|
||||||
|
|
@ -183,7 +183,7 @@ proc con(a, b: PRope): PRope =
|
||||||
proc con(a: PRope, b: string): PRope = result = con(a, toRope(b))
|
proc con(a: PRope, b: string): PRope = result = con(a, toRope(b))
|
||||||
proc con(a: string, b: PRope): PRope = result = con(toRope(a), b)
|
proc con(a: string, b: PRope): PRope = result = con(toRope(a), b)
|
||||||
|
|
||||||
proc con(a: openarray[PRope]): PRope =
|
proc con(a: varargs[PRope]): PRope =
|
||||||
for i in countup(0, high(a)): result = con(result, a[i])
|
for i in countup(0, high(a)): result = con(result, a[i])
|
||||||
|
|
||||||
proc toRope(i: BiggestInt): PRope = result = toRope($i)
|
proc toRope(i: BiggestInt): PRope = result = toRope($i)
|
||||||
|
|
@ -212,7 +212,7 @@ proc WriteRope*(head: PRope, filename: string, useWarning = false) =
|
||||||
rawMessage(if useWarning: warnCannotOpenFile else: errCannotOpenFile,
|
rawMessage(if useWarning: warnCannotOpenFile else: errCannotOpenFile,
|
||||||
filename)
|
filename)
|
||||||
|
|
||||||
proc ropef(frmt: TFormatStr, args: openarray[PRope]): PRope =
|
proc ropef(frmt: TFormatStr, args: varargs[PRope]): PRope =
|
||||||
var i = 0
|
var i = 0
|
||||||
var length = len(frmt)
|
var length = len(frmt)
|
||||||
result = nil
|
result = nil
|
||||||
|
|
@ -254,7 +254,7 @@ proc ropef(frmt: TFormatStr, args: openarray[PRope]): PRope =
|
||||||
app(result, substr(frmt, start, i - 1))
|
app(result, substr(frmt, start, i - 1))
|
||||||
assert(RopeInvariant(result))
|
assert(RopeInvariant(result))
|
||||||
|
|
||||||
proc appf(c: var PRope, frmt: TFormatStr, args: openarray[PRope]) =
|
proc appf(c: var PRope, frmt: TFormatStr, args: varargs[PRope]) =
|
||||||
app(c, ropef(frmt, args))
|
app(c, ropef(frmt, args))
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
|
||||||
|
|
@ -388,9 +388,9 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||||
elif f.sons[0].kind in GenericTypes:
|
elif f.sons[0].kind in GenericTypes:
|
||||||
result = minRel(result, typeRel(c, f.sons[0], a.sons[0]))
|
result = minRel(result, typeRel(c, f.sons[0], a.sons[0]))
|
||||||
else: nil
|
else: nil
|
||||||
of tyOpenArray:
|
of tyOpenArray, tyVarargs:
|
||||||
case a.Kind
|
case a.Kind
|
||||||
of tyOpenArray:
|
of tyOpenArray, tyVarargs:
|
||||||
result = typeRel(c, base(f), base(a))
|
result = typeRel(c, base(f), base(a))
|
||||||
if result < isGeneric: result = isNone
|
if result < isGeneric: result = isNone
|
||||||
of tyArrayConstr:
|
of tyArrayConstr:
|
||||||
|
|
@ -409,10 +409,6 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||||
elif typeRel(c, base(f), a.sons[0]) >= isGeneric:
|
elif typeRel(c, base(f), a.sons[0]) >= isGeneric:
|
||||||
result = isConvertible
|
result = isConvertible
|
||||||
else: nil
|
else: nil
|
||||||
of tyVarargs:
|
|
||||||
if a.Kind == tyVarargs:
|
|
||||||
result = typeRel(c, base(f), base(a))
|
|
||||||
if result < isGeneric: result = isNone
|
|
||||||
of tySequence:
|
of tySequence:
|
||||||
case a.Kind
|
case a.Kind
|
||||||
of tyNil:
|
of tyNil:
|
||||||
|
|
@ -611,10 +607,13 @@ proc localConvMatch(c: PContext, m: var TCandidate, f, a: PType,
|
||||||
result = c.semOverloadedCall(c, call, call, RoutineKinds)
|
result = c.semOverloadedCall(c, call, call, RoutineKinds)
|
||||||
if result != nil:
|
if result != nil:
|
||||||
# resulting type must be consistent with the other arguments:
|
# resulting type must be consistent with the other arguments:
|
||||||
var r = typeRel(m, f, result.typ)
|
var r = typeRel(m, f.sons[0], result.typ)
|
||||||
if r < isGeneric: return nil
|
if r < isGeneric: return nil
|
||||||
if result.kind == nkCall: result.kind = nkHiddenCallConv
|
if result.kind == nkCall: result.kind = nkHiddenCallConv
|
||||||
inc(m.convMatches)
|
inc(m.convMatches)
|
||||||
|
if r == isGeneric:
|
||||||
|
result.typ = getInstantiatedType(c, arg, m, base(f))
|
||||||
|
m.baseTypeMatch = true
|
||||||
|
|
||||||
proc ParamTypesMatchAux(c: PContext, m: var TCandidate, f, a: PType,
|
proc ParamTypesMatchAux(c: PContext, m: var TCandidate, f, a: PType,
|
||||||
arg, argOrig: PNode): PNode =
|
arg, argOrig: PNode): PNode =
|
||||||
|
|
@ -686,14 +685,18 @@ proc ParamTypesMatchAux(c: PContext, m: var TCandidate, f, a: PType,
|
||||||
m.proxyMatch = true
|
m.proxyMatch = true
|
||||||
return copyTree(arg)
|
return copyTree(arg)
|
||||||
result = userConvMatch(c, m, f, a, arg)
|
result = userConvMatch(c, m, f, a, arg)
|
||||||
# check for a base type match, which supports openarray[T] without []
|
# check for a base type match, which supports varargs[T] without []
|
||||||
# constructor in a call:
|
# constructor in a call:
|
||||||
if result == nil and f.kind == tyOpenArray:
|
if result == nil and f.kind == tyVarargs:
|
||||||
|
if f.n != nil:
|
||||||
|
result = localConvMatch(c, m, f, a, arg)
|
||||||
|
else:
|
||||||
r = typeRel(m, base(f), a)
|
r = typeRel(m, base(f), a)
|
||||||
if r >= isGeneric:
|
if r >= isGeneric:
|
||||||
inc(m.convMatches)
|
inc(m.convMatches)
|
||||||
result = copyTree(arg)
|
result = copyTree(arg)
|
||||||
if r == isGeneric: result.typ = getInstantiatedType(c, arg, m, base(f))
|
if r == isGeneric:
|
||||||
|
result.typ = getInstantiatedType(c, arg, m, base(f))
|
||||||
m.baseTypeMatch = true
|
m.baseTypeMatch = true
|
||||||
else:
|
else:
|
||||||
result = userConvMatch(c, m, base(f), a, arg)
|
result = userConvMatch(c, m, base(f), a, arg)
|
||||||
|
|
@ -874,7 +877,7 @@ proc matches*(c: PContext, n, nOrig: PNode, m: var TCandidate) =
|
||||||
var formal = m.callee.n.sons[f].sym
|
var formal = m.callee.n.sons[f].sym
|
||||||
if not ContainsOrIncl(marker, formal.position):
|
if not ContainsOrIncl(marker, formal.position):
|
||||||
if formal.ast == nil:
|
if formal.ast == nil:
|
||||||
if formal.typ.kind == tyOpenArray:
|
if formal.typ.kind == tyVarargs:
|
||||||
var container = newNodeI(nkBracket, n.info)
|
var container = newNodeI(nkBracket, n.info)
|
||||||
addSon(m.call, implicitConv(nkHiddenStdConv, formal.typ,
|
addSon(m.call, implicitConv(nkHiddenStdConv, formal.typ,
|
||||||
container, m, c))
|
container, m, c))
|
||||||
|
|
|
||||||
|
|
@ -89,17 +89,17 @@ proc substituteLog*(frmt: string): string =
|
||||||
|
|
||||||
|
|
||||||
method log*(L: ref TLogger, level: TLevel,
|
method log*(L: ref TLogger, level: TLevel,
|
||||||
frmt: string, args: openArray[string]) =
|
frmt: string, args: varargs[string, `$`]) =
|
||||||
## override this method in custom loggers. Default implementation does
|
## override this method in custom loggers. Default implementation does
|
||||||
## nothing.
|
## nothing.
|
||||||
nil
|
nil
|
||||||
|
|
||||||
method log*(L: ref TConsoleLogger, level: TLevel,
|
method log*(L: ref TConsoleLogger, level: TLevel,
|
||||||
frmt: string, args: openArray[string]) =
|
frmt: string, args: varargs[string, `$`]) =
|
||||||
Writeln(stdout, LevelNames[level], " ", substituteLog(L.fmtStr), frmt % args)
|
Writeln(stdout, LevelNames[level], " ", substituteLog(L.fmtStr), frmt % args)
|
||||||
|
|
||||||
method log*(L: ref TFileLogger, level: TLevel,
|
method log*(L: ref TFileLogger, level: TLevel,
|
||||||
frmt: string, args: openArray[string]) =
|
frmt: string, args: varargs[string, `$`]) =
|
||||||
Writeln(L.f, LevelNames[level], " ", substituteLog(L.fmtStr), frmt % args)
|
Writeln(L.f, LevelNames[level], " ", substituteLog(L.fmtStr), frmt % args)
|
||||||
|
|
||||||
proc defaultFilename*(): string =
|
proc defaultFilename*(): string =
|
||||||
|
|
@ -150,7 +150,7 @@ proc newRollingFileLogger*(filename = defaultFilename(),
|
||||||
|
|
||||||
|
|
||||||
method log*(L: ref TRollingFileLogger, level: TLevel,
|
method log*(L: ref TRollingFileLogger, level: TLevel,
|
||||||
frmt: string, args: openArray[string]) =
|
frmt: string, args: varargs[string, `$`]) =
|
||||||
# TODO
|
# TODO
|
||||||
# if more than maxlines, then set cursor to zero
|
# if more than maxlines, then set cursor to zero
|
||||||
|
|
||||||
|
|
@ -162,12 +162,12 @@ var
|
||||||
level* = lvlAll ## global log filter
|
level* = lvlAll ## global log filter
|
||||||
handlers*: seq[ref TLogger] = @[] ## handlers with their own log levels
|
handlers*: seq[ref TLogger] = @[] ## handlers with their own log levels
|
||||||
|
|
||||||
proc logLoop(level: TLevel, frmt: string, args: openarray[string]) =
|
proc logLoop(level: TLevel, frmt: string, args: varargs[string, `$`]) =
|
||||||
for logger in items(handlers):
|
for logger in items(handlers):
|
||||||
if level >= logger.levelThreshold:
|
if level >= logger.levelThreshold:
|
||||||
log(logger, level, frmt, args)
|
log(logger, level, frmt, args)
|
||||||
|
|
||||||
template log*(level: TLevel, frmt: string, args: openarray[string]) =
|
template log*(level: TLevel, frmt: string, args: varargs[string, `$`]) =
|
||||||
## logs a message of the given level
|
## logs a message of the given level
|
||||||
bind logLoop
|
bind logLoop
|
||||||
bind `%`
|
bind `%`
|
||||||
|
|
@ -176,23 +176,23 @@ template log*(level: TLevel, frmt: string, args: openarray[string]) =
|
||||||
if level >= logging.Level:
|
if level >= logging.Level:
|
||||||
logLoop(level, frmt, args)
|
logLoop(level, frmt, args)
|
||||||
|
|
||||||
template debug*(frmt: string, args: openarray[string]) =
|
template debug*(frmt: string, args: varargs[string, `$`]) =
|
||||||
## logs a debug message
|
## logs a debug message
|
||||||
log(lvlDebug, frmt, args)
|
log(lvlDebug, frmt, args)
|
||||||
|
|
||||||
template info*(frmt: string, args: openarray[string]) =
|
template info*(frmt: string, args: varargs[string, `$`]) =
|
||||||
## logs an info message
|
## logs an info message
|
||||||
log(lvlInfo, frmt, args)
|
log(lvlInfo, frmt, args)
|
||||||
|
|
||||||
template warn*(frmt: string, args: openarray[string]) =
|
template warn*(frmt: string, args: varargs[string, `$`]) =
|
||||||
## logs a warning message
|
## logs a warning message
|
||||||
log(lvlWarn, frmt, args)
|
log(lvlWarn, frmt, args)
|
||||||
|
|
||||||
template error*(frmt: string, args: openarray[string]) =
|
template error*(frmt: string, args: varargs[string, `$`]) =
|
||||||
## logs an error message
|
## logs an error message
|
||||||
log(lvlError, frmt, args)
|
log(lvlError, frmt, args)
|
||||||
|
|
||||||
template fatal*(frmt: string, args: openarray[string]) =
|
template fatal*(frmt: string, args: varargs[string, `$`]) =
|
||||||
## logs a fatal error message
|
## logs a fatal error message
|
||||||
log(lvlFatal, frmt, args)
|
log(lvlFatal, frmt, args)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -891,12 +891,18 @@ Arrays are always bounds checked (at compile-time or at runtime). These
|
||||||
checks can be disabled via pragmas or invoking the compiler with the
|
checks can be disabled via pragmas or invoking the compiler with the
|
||||||
``--boundChecks:off`` command line switch.
|
``--boundChecks:off`` command line switch.
|
||||||
|
|
||||||
An open array is also a means to implement passing a variable number of
|
The current implementation does not support nested open arrays.
|
||||||
arguments to a procedure. The compiler converts the list of arguments
|
|
||||||
to an array automatically:
|
|
||||||
|
Varargs
|
||||||
|
~~~~~~~
|
||||||
|
|
||||||
|
A `varargs`:idx: parameter is an openarray parameter that additionally
|
||||||
|
allows to pass a variable number of arguments to a procedure. The compiler
|
||||||
|
converts the list of arguments to an array implicitely:
|
||||||
|
|
||||||
.. code-block:: nimrod
|
.. code-block:: nimrod
|
||||||
proc myWriteln(f: TFile, a: openarray[string]) =
|
proc myWriteln(f: TFile, a: varargs[string]) =
|
||||||
for s in items(a):
|
for s in items(a):
|
||||||
write(f, s)
|
write(f, s)
|
||||||
write(f, "\n")
|
write(f, "\n")
|
||||||
|
|
@ -905,9 +911,23 @@ to an array automatically:
|
||||||
# is transformed by the compiler to:
|
# is transformed by the compiler to:
|
||||||
myWriteln(stdout, ["abc", "def", "xyz"])
|
myWriteln(stdout, ["abc", "def", "xyz"])
|
||||||
|
|
||||||
This transformation is only done if the openarray parameter is the
|
This transformation is only done if the varargs parameter is the
|
||||||
last parameter in the procedure header. The current implementation does not
|
last parameter in the procedure header. It is also possible to perform
|
||||||
support nested open arrays.
|
type conversions in this context:
|
||||||
|
|
||||||
|
.. code-block:: nimrod
|
||||||
|
proc myWriteln(f: TFile, a: varargs[string, `$`]) =
|
||||||
|
for s in items(a):
|
||||||
|
write(f, s)
|
||||||
|
write(f, "\n")
|
||||||
|
|
||||||
|
myWriteln(stdout, 123, "abc", 4.0)
|
||||||
|
# is transformed by the compiler to:
|
||||||
|
myWriteln(stdout, [$123, $"def", $4.0])
|
||||||
|
|
||||||
|
In this example ``$`` is applied to any argument that is passed to the
|
||||||
|
parameter ``a``. (Note that ``$`` applied to strings is a nop.)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Tuples and object types
|
Tuples and object types
|
||||||
|
|
@ -2336,8 +2356,7 @@ Var parameters
|
||||||
The type of a parameter may be prefixed with the ``var`` keyword:
|
The type of a parameter may be prefixed with the ``var`` keyword:
|
||||||
|
|
||||||
.. code-block:: nimrod
|
.. code-block:: nimrod
|
||||||
proc divmod(a, b: int,
|
proc divmod(a, b: int; res, remainder: var int) =
|
||||||
res, remainder: var int) =
|
|
||||||
res = a div b
|
res = a div b
|
||||||
remainder = a mod b
|
remainder = a mod b
|
||||||
|
|
||||||
|
|
@ -2355,8 +2374,7 @@ an l-value. Var parameters are implemented as hidden pointers. The
|
||||||
above example is equivalent to:
|
above example is equivalent to:
|
||||||
|
|
||||||
.. code-block:: nimrod
|
.. code-block:: nimrod
|
||||||
proc divmod(a, b: int,
|
proc divmod(a, b: int; res, remainder: ptr int) =
|
||||||
res, remainder: ptr int) =
|
|
||||||
res[] = a div b
|
res[] = a div b
|
||||||
remainder[] = a mod b
|
remainder[] = a mod b
|
||||||
|
|
||||||
|
|
|
||||||
27
doc/tut1.txt
27
doc/tut1.txt
|
|
@ -1131,12 +1131,17 @@ an openarray parameter, the index type does not matter.
|
||||||
The openarray type cannot be nested: multidimensional openarrays are not
|
The openarray type cannot be nested: multidimensional openarrays are not
|
||||||
supported because this is seldom needed and cannot be done efficiently.
|
supported because this is seldom needed and cannot be done efficiently.
|
||||||
|
|
||||||
An openarray is also a means to implement passing a variable number of
|
|
||||||
|
Varargs
|
||||||
|
-------
|
||||||
|
|
||||||
|
A ``varargs`` parameter is like an openarray parameter. However, it is
|
||||||
|
also a means to implement passing a variable number of
|
||||||
arguments to a procedure. The compiler converts the list of arguments
|
arguments to a procedure. The compiler converts the list of arguments
|
||||||
to an array automatically:
|
to an array automatically:
|
||||||
|
|
||||||
.. code-block:: nimrod
|
.. code-block:: nimrod
|
||||||
proc myWriteln(f: TFile, a: openarray[string]) =
|
proc myWriteln(f: TFile, a: varargs[string]) =
|
||||||
for s in items(a):
|
for s in items(a):
|
||||||
write(f, s)
|
write(f, s)
|
||||||
write(f, "\n")
|
write(f, "\n")
|
||||||
|
|
@ -1145,8 +1150,22 @@ to an array automatically:
|
||||||
# is transformed by the compiler to:
|
# is transformed by the compiler to:
|
||||||
myWriteln(stdout, ["abc", "def", "xyz"])
|
myWriteln(stdout, ["abc", "def", "xyz"])
|
||||||
|
|
||||||
This transformation is only done if the openarray parameter is the
|
This transformation is only done if the varargs parameter is the
|
||||||
last parameter in the procedure header.
|
last parameter in the procedure header. It is also possible to perform
|
||||||
|
type conversions in this context:
|
||||||
|
|
||||||
|
.. code-block:: nimrod
|
||||||
|
proc myWriteln(f: TFile, a: varargs[string, `$`]) =
|
||||||
|
for s in items(a):
|
||||||
|
write(f, s)
|
||||||
|
write(f, "\n")
|
||||||
|
|
||||||
|
myWriteln(stdout, 123, "abc", 4.0)
|
||||||
|
# is transformed by the compiler to:
|
||||||
|
myWriteln(stdout, [$123, $"def", $4.0])
|
||||||
|
|
||||||
|
In this example ``$`` is applied to any argument that is passed to the
|
||||||
|
parameter ``a``. Note that ``$`` applied to strings is a nop.
|
||||||
|
|
||||||
|
|
||||||
Tuples
|
Tuples
|
||||||
|
|
|
||||||
|
|
@ -195,10 +195,6 @@ if [ $# -eq 1 ] ; then
|
||||||
cp doc/tut2.txt $docdir/tut2.txt
|
cp doc/tut2.txt $docdir/tut2.txt
|
||||||
chmod 644 $docdir/tut2.txt
|
chmod 644 $docdir/tut2.txt
|
||||||
fi
|
fi
|
||||||
if [ -f doc/manual.html ]; then
|
|
||||||
cp doc/manual.html $docdir/manual.html
|
|
||||||
chmod 644 $docdir/manual.html
|
|
||||||
fi
|
|
||||||
if [ -f doc/nimrodc.html ]; then
|
if [ -f doc/nimrodc.html ]; then
|
||||||
cp doc/nimrodc.html $docdir/nimrodc.html
|
cp doc/nimrodc.html $docdir/nimrodc.html
|
||||||
chmod 644 $docdir/nimrodc.html
|
chmod 644 $docdir/nimrodc.html
|
||||||
|
|
@ -313,6 +309,8 @@ if [ $# -eq 1 ] ; then
|
||||||
chmod 644 $libdir/core/macros.nim
|
chmod 644 $libdir/core/macros.nim
|
||||||
cp lib/core/typeinfo.nim $libdir/core/typeinfo.nim
|
cp lib/core/typeinfo.nim $libdir/core/typeinfo.nim
|
||||||
chmod 644 $libdir/core/typeinfo.nim
|
chmod 644 $libdir/core/typeinfo.nim
|
||||||
|
cp lib/core/unsigned.nim $libdir/core/unsigned.nim
|
||||||
|
chmod 644 $libdir/core/unsigned.nim
|
||||||
cp lib/pure/actors.nim $libdir/pure/actors.nim
|
cp lib/pure/actors.nim $libdir/pure/actors.nim
|
||||||
chmod 644 $libdir/pure/actors.nim
|
chmod 644 $libdir/pure/actors.nim
|
||||||
cp lib/pure/algorithm.nim $libdir/pure/algorithm.nim
|
cp lib/pure/algorithm.nim $libdir/pure/algorithm.nim
|
||||||
|
|
@ -497,6 +495,8 @@ if [ $# -eq 1 ] ; then
|
||||||
chmod 644 $libdir/wrappers/openssl.nim
|
chmod 644 $libdir/wrappers/openssl.nim
|
||||||
cp lib/wrappers/pcre.nim $libdir/wrappers/pcre.nim
|
cp lib/wrappers/pcre.nim $libdir/wrappers/pcre.nim
|
||||||
chmod 644 $libdir/wrappers/pcre.nim
|
chmod 644 $libdir/wrappers/pcre.nim
|
||||||
|
cp lib/wrappers/pdcurses.nim $libdir/wrappers/pdcurses.nim
|
||||||
|
chmod 644 $libdir/wrappers/pdcurses.nim
|
||||||
cp lib/wrappers/postgres.nim $libdir/wrappers/postgres.nim
|
cp lib/wrappers/postgres.nim $libdir/wrappers/postgres.nim
|
||||||
chmod 644 $libdir/wrappers/postgres.nim
|
chmod 644 $libdir/wrappers/postgres.nim
|
||||||
cp lib/wrappers/python.nim $libdir/wrappers/python.nim
|
cp lib/wrappers/python.nim $libdir/wrappers/python.nim
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ proc len*(n: PNimrodNode): int {.magic: "NLen".}
|
||||||
proc add*(father, child: PNimrodNode) {.magic: "NAdd".}
|
proc add*(father, child: PNimrodNode) {.magic: "NAdd".}
|
||||||
## adds the `child` to the `father` node
|
## adds the `child` to the `father` node
|
||||||
|
|
||||||
proc add*(father: PNimrodNode, children: openArray[PNimrodNode]) {.
|
proc add*(father: PNimrodNode, children: varargs[PNimrodNode]) {.
|
||||||
magic: "NAddMultiple".}
|
magic: "NAddMultiple".}
|
||||||
## adds each child of `children` to the `father` node
|
## adds each child of `children` to the `father` node
|
||||||
|
|
||||||
|
|
@ -251,7 +251,7 @@ proc expectLen*(n: PNimrodNode, len: int) {.compileTime.} =
|
||||||
if n.len != len: error("macro expects a node with " & $len & " children")
|
if n.len != len: error("macro expects a node with " & $len & " children")
|
||||||
|
|
||||||
proc newCall*(theProc: TNimrodIdent,
|
proc newCall*(theProc: TNimrodIdent,
|
||||||
args: openArray[PNimrodNode]): PNimrodNode {.compileTime.} =
|
args: varargs[PNimrodNode]): PNimrodNode {.compileTime.} =
|
||||||
## produces a new call node. `theProc` is the proc that is called with
|
## produces a new call node. `theProc` is the proc that is called with
|
||||||
## the arguments ``args[0..]``.
|
## the arguments ``args[0..]``.
|
||||||
result = newNimNode(nnkCall)
|
result = newNimNode(nnkCall)
|
||||||
|
|
@ -259,7 +259,7 @@ proc newCall*(theProc: TNimrodIdent,
|
||||||
result.add(args)
|
result.add(args)
|
||||||
|
|
||||||
proc newCall*(theProc: string,
|
proc newCall*(theProc: string,
|
||||||
args: openArray[PNimrodNode]): PNimrodNode {.compileTime.} =
|
args: varargs[PNimrodNode]): PNimrodNode {.compileTime.} =
|
||||||
## produces a new call node. `theProc` is the proc that is called with
|
## produces a new call node. `theProc` is the proc that is called with
|
||||||
## the arguments ``args[0..]``.
|
## the arguments ``args[0..]``.
|
||||||
result = newNimNode(nnkCall)
|
result = newNimNode(nnkCall)
|
||||||
|
|
|
||||||
|
|
@ -165,13 +165,13 @@ iterator find*(db: var TDbConn, namespace: string,
|
||||||
yield bson(cursor[])[]
|
yield bson(cursor[])[]
|
||||||
destroy(cursor[])
|
destroy(cursor[])
|
||||||
|
|
||||||
proc setupFieldnames(fields: openArray[string]): TBSon =
|
proc setupFieldnames(fields: varargs[string]): TBSon =
|
||||||
init(result)
|
init(result)
|
||||||
for x in fields: add(result, x, 1'i32)
|
for x in fields: add(result, x, 1'i32)
|
||||||
finish(result)
|
finish(result)
|
||||||
|
|
||||||
iterator find*(db: var TDbConn, namespace: string,
|
iterator find*(db: var TDbConn, namespace: string,
|
||||||
query: var TBSon, fields: openArray[string]): var TBSon =
|
query: var TBSon, fields: varargs[string]): var TBSon =
|
||||||
## yields the `fields` of any document that suffices `query`. If `fields`
|
## yields the `fields` of any document that suffices `query`. If `fields`
|
||||||
## is ``[]`` the whole document is yielded.
|
## is ``[]`` the whole document is yielded.
|
||||||
var f = setupFieldnames(fields)
|
var f = setupFieldnames(fields)
|
||||||
|
|
@ -188,7 +188,7 @@ proc setupQuery(query: string): TBSon =
|
||||||
finish(result)
|
finish(result)
|
||||||
|
|
||||||
iterator find*(db: var TDbConn, namespace: string,
|
iterator find*(db: var TDbConn, namespace: string,
|
||||||
query: string, fields: openArray[string]): var TBSon =
|
query: string, fields: varargs[string]): var TBSon =
|
||||||
## yields the `fields` of any document that suffices `query`. If `fields`
|
## yields the `fields` of any document that suffices `query`. If `fields`
|
||||||
## is ``[]`` the whole document is yielded.
|
## is ``[]`` the whole document is yielded.
|
||||||
var f = setupFieldnames(fields)
|
var f = setupFieldnames(fields)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ proc dbError*(msg: string) {.noreturn.} =
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
when false:
|
when false:
|
||||||
proc dbQueryOpt*(db: TDbConn, query: string, args: openarray[string]) =
|
proc dbQueryOpt*(db: TDbConn, query: string, args: varargs[string]) =
|
||||||
var stmt = mysql_stmt_init(db)
|
var stmt = mysql_stmt_init(db)
|
||||||
if stmt == nil: dbError(db)
|
if stmt == nil: dbError(db)
|
||||||
if mysql_stmt_prepare(stmt, query, len(query)) != 0:
|
if mysql_stmt_prepare(stmt, query, len(query)) != 0:
|
||||||
|
|
@ -50,7 +50,7 @@ proc dbQuote(s: string): string =
|
||||||
else: add(result, c)
|
else: add(result, c)
|
||||||
add(result, '\'')
|
add(result, '\'')
|
||||||
|
|
||||||
proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
|
proc dbFormat(formatstr: TSqlQuery, args: varargs[string]): string =
|
||||||
result = ""
|
result = ""
|
||||||
var a = 0
|
var a = 0
|
||||||
for c in items(string(formatstr)):
|
for c in items(string(formatstr)):
|
||||||
|
|
@ -60,12 +60,12 @@ proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
|
||||||
else:
|
else:
|
||||||
add(result, c)
|
add(result, c)
|
||||||
|
|
||||||
proc TryExec*(db: TDbConn, query: TSqlQuery, args: openarray[string]): bool =
|
proc TryExec*(db: TDbConn, query: TSqlQuery, args: varargs[string]): bool =
|
||||||
## tries to execute the query and returns true if successful, false otherwise.
|
## tries to execute the query and returns true if successful, false otherwise.
|
||||||
var q = dbFormat(query, args)
|
var q = dbFormat(query, args)
|
||||||
return mysql.RealQuery(db, q, q.len) == 0'i32
|
return mysql.RealQuery(db, q, q.len) == 0'i32
|
||||||
|
|
||||||
proc Exec*(db: TDbConn, query: TSqlQuery, args: openarray[string]) =
|
proc Exec*(db: TDbConn, query: TSqlQuery, args: varargs[string]) =
|
||||||
## executes the query and raises EDB if not successful.
|
## executes the query and raises EDB if not successful.
|
||||||
var q = dbFormat(query, args)
|
var q = dbFormat(query, args)
|
||||||
if mysql.RealQuery(db, q, q.len) != 0'i32: dbError(db)
|
if mysql.RealQuery(db, q, q.len) != 0'i32: dbError(db)
|
||||||
|
|
@ -80,7 +80,7 @@ proc properFreeResult(sqlres: mysql.PRES, row: cstringArray) =
|
||||||
mysql.FreeResult(sqlres)
|
mysql.FreeResult(sqlres)
|
||||||
|
|
||||||
iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): TRow =
|
args: varargs[string]): TRow =
|
||||||
## executes the query and iterates over the result dataset. This is very
|
## executes the query and iterates over the result dataset. This is very
|
||||||
## fast, but potenially dangerous: If the for-loop-body executes another
|
## fast, but potenially dangerous: If the for-loop-body executes another
|
||||||
## query, the results can be undefined. For MySQL this is the case!.
|
## query, the results can be undefined. For MySQL this is the case!.
|
||||||
|
|
@ -100,7 +100,7 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
||||||
properFreeResult(sqlres, row)
|
properFreeResult(sqlres, row)
|
||||||
|
|
||||||
proc getRow*(db: TDbConn, query: TSqlQuery,
|
proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): TRow =
|
args: varargs[string]): TRow =
|
||||||
## retrieves a single row.
|
## retrieves a single row.
|
||||||
Exec(db, query, args)
|
Exec(db, query, args)
|
||||||
var sqlres = mysql.UseResult(db)
|
var sqlres = mysql.UseResult(db)
|
||||||
|
|
@ -115,7 +115,7 @@ proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||||
properFreeResult(sqlres, row)
|
properFreeResult(sqlres, row)
|
||||||
|
|
||||||
proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): seq[TRow] =
|
args: varargs[string]): seq[TRow] =
|
||||||
## executes the query and returns the whole result dataset.
|
## executes the query and returns the whole result dataset.
|
||||||
result = @[]
|
result = @[]
|
||||||
Exec(db, query, args)
|
Exec(db, query, args)
|
||||||
|
|
@ -134,12 +134,12 @@ proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
||||||
mysql.FreeResult(sqlres)
|
mysql.FreeResult(sqlres)
|
||||||
|
|
||||||
iterator Rows*(db: TDbConn, query: TSqlQuery,
|
iterator Rows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): TRow =
|
args: varargs[string]): TRow =
|
||||||
## same as `FastRows`, but slower and safe.
|
## same as `FastRows`, but slower and safe.
|
||||||
for r in items(GetAllRows(db, query, args)): yield r
|
for r in items(GetAllRows(db, query, args)): yield r
|
||||||
|
|
||||||
proc GetValue*(db: TDbConn, query: TSqlQuery,
|
proc GetValue*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): string =
|
args: varargs[string]): string =
|
||||||
## executes the query and returns the result dataset's the first column
|
## executes the query and returns the result dataset's the first column
|
||||||
## of the first row. Returns "" if the dataset contains no rows. This uses
|
## of the first row. Returns "" if the dataset contains no rows. This uses
|
||||||
## `FastRows`, so it inherits its fragile behaviour.
|
## `FastRows`, so it inherits its fragile behaviour.
|
||||||
|
|
@ -149,7 +149,7 @@ proc GetValue*(db: TDbConn, query: TSqlQuery,
|
||||||
break
|
break
|
||||||
|
|
||||||
proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): int64 =
|
args: varargs[string]): int64 =
|
||||||
## executes the query (typically "INSERT") and returns the
|
## executes the query (typically "INSERT") and returns the
|
||||||
## generated ID for the row or -1 in case of an error.
|
## generated ID for the row or -1 in case of an error.
|
||||||
var q = dbFormat(query, args)
|
var q = dbFormat(query, args)
|
||||||
|
|
@ -158,14 +158,14 @@ proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
else:
|
else:
|
||||||
result = mysql.InsertId(db)
|
result = mysql.InsertId(db)
|
||||||
|
|
||||||
proc InsertID*(db: TDbConn, query: TSqlQuery, args: openArray[string]): int64 =
|
proc InsertID*(db: TDbConn, query: TSqlQuery, args: varargs[string]): int64 =
|
||||||
## executes the query (typically "INSERT") and returns the
|
## executes the query (typically "INSERT") and returns the
|
||||||
## generated ID for the row.
|
## generated ID for the row.
|
||||||
result = TryInsertID(db, query, args)
|
result = TryInsertID(db, query, args)
|
||||||
if result < 0: dbError(db)
|
if result < 0: dbError(db)
|
||||||
|
|
||||||
proc ExecAffectedRows*(db: TDbConn, query: TSqlQuery,
|
proc ExecAffectedRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openArray[string]): int64 =
|
args: varargs[string]): int64 =
|
||||||
## runs the query (typically "UPDATE") and returns the
|
## runs the query (typically "UPDATE") and returns the
|
||||||
## number of affected rows
|
## number of affected rows
|
||||||
Exec(db, query, args)
|
Exec(db, query, args)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ proc dbQuote(s: string): string =
|
||||||
else: add(result, c)
|
else: add(result, c)
|
||||||
add(result, '\'')
|
add(result, '\'')
|
||||||
|
|
||||||
proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
|
proc dbFormat(formatstr: TSqlQuery, args: varargs[string]): string =
|
||||||
result = ""
|
result = ""
|
||||||
var a = 0
|
var a = 0
|
||||||
for c in items(string(formatstr)):
|
for c in items(string(formatstr)):
|
||||||
|
|
@ -60,14 +60,14 @@ proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
|
||||||
add(result, c)
|
add(result, c)
|
||||||
|
|
||||||
proc TryExec*(db: TDbConn, query: TSqlQuery,
|
proc TryExec*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): bool =
|
args: varargs[string]): bool =
|
||||||
## tries to execute the query and returns true if successful, false otherwise.
|
## tries to execute the query and returns true if successful, false otherwise.
|
||||||
var q = dbFormat(query, args)
|
var q = dbFormat(query, args)
|
||||||
var res = PQExec(db, q)
|
var res = PQExec(db, q)
|
||||||
result = PQresultStatus(res) == PGRES_COMMAND_OK
|
result = PQresultStatus(res) == PGRES_COMMAND_OK
|
||||||
PQclear(res)
|
PQclear(res)
|
||||||
|
|
||||||
proc Exec*(db: TDbConn, query: TSqlQuery, args: openarray[string]) =
|
proc Exec*(db: TDbConn, query: TSqlQuery, args: varargs[string]) =
|
||||||
## executes the query and raises EDB if not successful.
|
## executes the query and raises EDB if not successful.
|
||||||
var q = dbFormat(query, args)
|
var q = dbFormat(query, args)
|
||||||
var res = PQExec(db, q)
|
var res = PQExec(db, q)
|
||||||
|
|
@ -79,7 +79,7 @@ proc newRow(L: int): TRow =
|
||||||
for i in 0..L-1: result[i] = ""
|
for i in 0..L-1: result[i] = ""
|
||||||
|
|
||||||
proc setupQuery(db: TDbConn, query: TSqlQuery,
|
proc setupQuery(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): PPGresult =
|
args: varargs[string]): PPGresult =
|
||||||
var q = dbFormat(query, args)
|
var q = dbFormat(query, args)
|
||||||
result = PQExec(db, q)
|
result = PQExec(db, q)
|
||||||
if PQresultStatus(result) != PGRES_TUPLES_OK: dbError(db)
|
if PQresultStatus(result) != PGRES_TUPLES_OK: dbError(db)
|
||||||
|
|
@ -91,7 +91,7 @@ proc setRow(res: PPGresult, r: var TRow, line, cols: int32) =
|
||||||
add(r[col], x)
|
add(r[col], x)
|
||||||
|
|
||||||
iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): TRow =
|
args: varargs[string]): TRow =
|
||||||
## executes the query and iterates over the result dataset. This is very
|
## executes the query and iterates over the result dataset. This is very
|
||||||
## fast, but potenially dangerous: If the for-loop-body executes another
|
## fast, but potenially dangerous: If the for-loop-body executes another
|
||||||
## query, the results can be undefined. For Postgres it is safe though.
|
## query, the results can be undefined. For Postgres it is safe though.
|
||||||
|
|
@ -104,7 +104,7 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
||||||
PQclear(res)
|
PQclear(res)
|
||||||
|
|
||||||
proc getRow*(db: TDbConn, query: TSqlQuery,
|
proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): TRow =
|
args: varargs[string]): TRow =
|
||||||
## retrieves a single row.
|
## retrieves a single row.
|
||||||
var res = setupQuery(db, query, args)
|
var res = setupQuery(db, query, args)
|
||||||
var L = PQnfields(res)
|
var L = PQnfields(res)
|
||||||
|
|
@ -113,26 +113,26 @@ proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||||
PQclear(res)
|
PQclear(res)
|
||||||
|
|
||||||
proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): seq[TRow] =
|
args: varargs[string]): seq[TRow] =
|
||||||
## executes the query and returns the whole result dataset.
|
## executes the query and returns the whole result dataset.
|
||||||
result = @[]
|
result = @[]
|
||||||
for r in FastRows(db, query, args):
|
for r in FastRows(db, query, args):
|
||||||
result.add(r)
|
result.add(r)
|
||||||
|
|
||||||
iterator Rows*(db: TDbConn, query: TSqlQuery,
|
iterator Rows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): TRow =
|
args: varargs[string]): TRow =
|
||||||
## same as `FastRows`, but slower and safe.
|
## same as `FastRows`, but slower and safe.
|
||||||
for r in items(GetAllRows(db, query, args)): yield r
|
for r in items(GetAllRows(db, query, args)): yield r
|
||||||
|
|
||||||
proc GetValue*(db: TDbConn, query: TSqlQuery,
|
proc GetValue*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): string =
|
args: varargs[string]): string =
|
||||||
## executes the query and returns the result dataset's the first column
|
## executes the query and returns the result dataset's the first column
|
||||||
## of the first row. Returns "" if the dataset contains no rows.
|
## of the first row. Returns "" if the dataset contains no rows.
|
||||||
var x = PQgetvalue(setupQuery(db, query, args), 0, 0)
|
var x = PQgetvalue(setupQuery(db, query, args), 0, 0)
|
||||||
result = if isNil(x): "" else: $x
|
result = if isNil(x): "" else: $x
|
||||||
|
|
||||||
proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): int64 =
|
args: varargs[string]): int64 =
|
||||||
## executes the query (typically "INSERT") and returns the
|
## executes the query (typically "INSERT") and returns the
|
||||||
## generated ID for the row or -1 in case of an error. For Postgre this adds
|
## generated ID for the row or -1 in case of an error. For Postgre this adds
|
||||||
## ``RETURNING id`` to the query, so it only works if your primary key is
|
## ``RETURNING id`` to the query, so it only works if your primary key is
|
||||||
|
|
@ -144,7 +144,7 @@ proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
result = -1
|
result = -1
|
||||||
|
|
||||||
proc InsertID*(db: TDbConn, query: TSqlQuery,
|
proc InsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openArray[string]): int64 =
|
args: varargs[string]): int64 =
|
||||||
## executes the query (typically "INSERT") and returns the
|
## executes the query (typically "INSERT") and returns the
|
||||||
## generated ID for the row. For Postgre this adds
|
## generated ID for the row. For Postgre this adds
|
||||||
## ``RETURNING id`` to the query, so it only works if your primary key is
|
## ``RETURNING id`` to the query, so it only works if your primary key is
|
||||||
|
|
@ -153,7 +153,7 @@ proc InsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
if result < 0: dbError(db)
|
if result < 0: dbError(db)
|
||||||
|
|
||||||
proc ExecAffectedRows*(db: TDbConn, query: TSqlQuery,
|
proc ExecAffectedRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openArray[string]): int64 =
|
args: varargs[string]): int64 =
|
||||||
## executes the query (typically "UPDATE") and returns the
|
## executes the query (typically "UPDATE") and returns the
|
||||||
## number of affected rows.
|
## number of affected rows.
|
||||||
var q = dbFormat(query, args)
|
var q = dbFormat(query, args)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ proc dbQuote(s: string): string =
|
||||||
else: add(result, c)
|
else: add(result, c)
|
||||||
add(result, '\'')
|
add(result, '\'')
|
||||||
|
|
||||||
proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
|
proc dbFormat(formatstr: TSqlQuery, args: varargs[string]): string =
|
||||||
result = ""
|
result = ""
|
||||||
var a = 0
|
var a = 0
|
||||||
for c in items(string(formatstr)):
|
for c in items(string(formatstr)):
|
||||||
|
|
@ -60,7 +60,7 @@ proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
|
||||||
add(result, c)
|
add(result, c)
|
||||||
|
|
||||||
proc TryExec*(db: TDbConn, query: TSqlQuery,
|
proc TryExec*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): bool =
|
args: varargs[string]): bool =
|
||||||
## tries to execute the query and returns true if successful, false otherwise.
|
## tries to execute the query and returns true if successful, false otherwise.
|
||||||
var q = dbFormat(query, args)
|
var q = dbFormat(query, args)
|
||||||
var stmt: sqlite3.PStmt
|
var stmt: sqlite3.PStmt
|
||||||
|
|
@ -68,7 +68,7 @@ proc TryExec*(db: TDbConn, query: TSqlQuery,
|
||||||
if step(stmt) == SQLITE_DONE:
|
if step(stmt) == SQLITE_DONE:
|
||||||
result = finalize(stmt) == SQLITE_OK
|
result = finalize(stmt) == SQLITE_OK
|
||||||
|
|
||||||
proc Exec*(db: TDbConn, query: TSqlQuery, args: openarray[string]) =
|
proc Exec*(db: TDbConn, query: TSqlQuery, args: varargs[string]) =
|
||||||
## executes the query and raises EDB if not successful.
|
## executes the query and raises EDB if not successful.
|
||||||
if not TryExec(db, query, args): dbError(db)
|
if not TryExec(db, query, args): dbError(db)
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ proc newRow(L: int): TRow =
|
||||||
for i in 0..L-1: result[i] = ""
|
for i in 0..L-1: result[i] = ""
|
||||||
|
|
||||||
proc setupQuery(db: TDbConn, query: TSqlQuery,
|
proc setupQuery(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): PStmt =
|
args: varargs[string]): PStmt =
|
||||||
var q = dbFormat(query, args)
|
var q = dbFormat(query, args)
|
||||||
if prepare_v2(db, q, q.len.cint, result, nil) != SQLITE_OK: dbError(db)
|
if prepare_v2(db, q, q.len.cint, result, nil) != SQLITE_OK: dbError(db)
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ proc setRow(stmt: PStmt, r: var TRow, cols: cint) =
|
||||||
if not isNil(x): add(r[col], x)
|
if not isNil(x): add(r[col], x)
|
||||||
|
|
||||||
iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): TRow =
|
args: varargs[string]): TRow =
|
||||||
## executes the query and iterates over the result dataset. This is very
|
## executes the query and iterates over the result dataset. This is very
|
||||||
## fast, but potenially dangerous: If the for-loop-body executes another
|
## fast, but potenially dangerous: If the for-loop-body executes another
|
||||||
## query, the results can be undefined. For Sqlite it is safe though.
|
## query, the results can be undefined. For Sqlite it is safe though.
|
||||||
|
|
@ -102,7 +102,7 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
||||||
if finalize(stmt) != SQLITE_OK: dbError(db)
|
if finalize(stmt) != SQLITE_OK: dbError(db)
|
||||||
|
|
||||||
proc getRow*(db: TDbConn, query: TSqlQuery,
|
proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): TRow =
|
args: varargs[string]): TRow =
|
||||||
## retrieves a single row.
|
## retrieves a single row.
|
||||||
var stmt = setupQuery(db, query, args)
|
var stmt = setupQuery(db, query, args)
|
||||||
var L = (columnCount(stmt))
|
var L = (columnCount(stmt))
|
||||||
|
|
@ -112,19 +112,19 @@ proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||||
if finalize(stmt) != SQLITE_OK: dbError(db)
|
if finalize(stmt) != SQLITE_OK: dbError(db)
|
||||||
|
|
||||||
proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): seq[TRow] =
|
args: varargs[string]): seq[TRow] =
|
||||||
## executes the query and returns the whole result dataset.
|
## executes the query and returns the whole result dataset.
|
||||||
result = @[]
|
result = @[]
|
||||||
for r in FastRows(db, query, args):
|
for r in FastRows(db, query, args):
|
||||||
result.add(r)
|
result.add(r)
|
||||||
|
|
||||||
iterator Rows*(db: TDbConn, query: TSqlQuery,
|
iterator Rows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): TRow =
|
args: varargs[string]): TRow =
|
||||||
## same as `FastRows`, but slower and safe.
|
## same as `FastRows`, but slower and safe.
|
||||||
for r in FastRows(db, query, args): yield r
|
for r in FastRows(db, query, args): yield r
|
||||||
|
|
||||||
proc GetValue*(db: TDbConn, query: TSqlQuery,
|
proc GetValue*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): string =
|
args: varargs[string]): string =
|
||||||
## executes the query and returns the result dataset's the first column
|
## executes the query and returns the result dataset's the first column
|
||||||
## of the first row. Returns "" if the dataset contains no rows.
|
## of the first row. Returns "" if the dataset contains no rows.
|
||||||
var stmt = setupQuery(db, query, args)
|
var stmt = setupQuery(db, query, args)
|
||||||
|
|
@ -136,7 +136,7 @@ proc GetValue*(db: TDbConn, query: TSqlQuery,
|
||||||
result = ""
|
result = ""
|
||||||
|
|
||||||
proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): int64 =
|
args: varargs[string]): int64 =
|
||||||
## executes the query (typically "INSERT") and returns the
|
## executes the query (typically "INSERT") and returns the
|
||||||
## generated ID for the row or -1 in case of an error.
|
## generated ID for the row or -1 in case of an error.
|
||||||
if tryExec(db, query, args):
|
if tryExec(db, query, args):
|
||||||
|
|
@ -145,7 +145,7 @@ proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
result = -1
|
result = -1
|
||||||
|
|
||||||
proc InsertID*(db: TDbConn, query: TSqlQuery,
|
proc InsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openArray[string]): int64 =
|
args: varargs[string]): int64 =
|
||||||
## executes the query (typically "INSERT") and returns the
|
## executes the query (typically "INSERT") and returns the
|
||||||
## generated ID for the row. For Postgre this adds
|
## generated ID for the row. For Postgre this adds
|
||||||
## ``RETURNING id`` to the query, so it only works if your primary key is
|
## ``RETURNING id`` to the query, so it only works if your primary key is
|
||||||
|
|
@ -154,7 +154,7 @@ proc InsertID*(db: TDbConn, query: TSqlQuery,
|
||||||
if result < 0: dbError(db)
|
if result < 0: dbError(db)
|
||||||
|
|
||||||
proc ExecAffectedRows*(db: TDbConn, query: TSqlQuery,
|
proc ExecAffectedRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openArray[string]): int64 =
|
args: varargs[string]): int64 =
|
||||||
## executes the query (typically "UPDATE") and returns the
|
## executes the query (typically "UPDATE") and returns the
|
||||||
## number of affected rows.
|
## number of affected rows.
|
||||||
Exec(db, query, args)
|
Exec(db, query, args)
|
||||||
|
|
|
||||||
|
|
@ -161,17 +161,6 @@ proc assign*(dest: var TIntSet, src: TIntSet) =
|
||||||
|
|
||||||
it = it.next
|
it = it.next
|
||||||
|
|
||||||
template dollarImpl(): stmt =
|
|
||||||
result = "{"
|
|
||||||
for key in items(s):
|
|
||||||
if result.len > 1: result.add(", ")
|
|
||||||
result.add($key)
|
|
||||||
result.add("}")
|
|
||||||
|
|
||||||
proc `$`*(s: TIntSet): string =
|
|
||||||
## The `$` operator for int sets.
|
|
||||||
dollarImpl()
|
|
||||||
|
|
||||||
iterator items*(s: TIntSet): int {.inline.} =
|
iterator items*(s: TIntSet): int {.inline.} =
|
||||||
## iterates over any included element of `s`.
|
## iterates over any included element of `s`.
|
||||||
var r = s.head
|
var r = s.head
|
||||||
|
|
@ -190,6 +179,17 @@ iterator items*(s: TIntSet): int {.inline.} =
|
||||||
inc(i)
|
inc(i)
|
||||||
r = r.next
|
r = r.next
|
||||||
|
|
||||||
|
template dollarImpl(): stmt =
|
||||||
|
result = "{"
|
||||||
|
for key in items(s):
|
||||||
|
if result.len > 1: result.add(", ")
|
||||||
|
result.add($key)
|
||||||
|
result.add("}")
|
||||||
|
|
||||||
|
proc `$`*(s: TIntSet): string =
|
||||||
|
## The `$` operator for int sets.
|
||||||
|
dollarImpl()
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
var x = initIntSet()
|
var x = initIntSet()
|
||||||
x.incl(1)
|
x.incl(1)
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ proc assertReply(received: TaintedString, expected: string) =
|
||||||
"Expected reply '$1' got: $2" % [
|
"Expected reply '$1' got: $2" % [
|
||||||
expected, received.string])
|
expected, received.string])
|
||||||
|
|
||||||
proc assertReply(received: TaintedString, expected: openarray[string]) =
|
proc assertReply(received: TaintedString, expected: varargs[string]) =
|
||||||
for i in items(expected):
|
for i in items(expected):
|
||||||
if received.string.startsWith(i): return
|
if received.string.startsWith(i): return
|
||||||
raise newException(EInvalidReply,
|
raise newException(EInvalidReply,
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ template multipleOp(k: TPegKind, localOpt: expr) =
|
||||||
if result.len == 1:
|
if result.len == 1:
|
||||||
result = result.sons[0]
|
result = result.sons[0]
|
||||||
|
|
||||||
proc `/`*(a: openArray[TPeg]): TPeg {.
|
proc `/`*(a: varargs[TPeg]): TPeg {.
|
||||||
nosideEffect, rtl, extern: "npegsOrderedChoice".} =
|
nosideEffect, rtl, extern: "npegsOrderedChoice".} =
|
||||||
## constructs an ordered choice with the PEGs in `a`
|
## constructs an ordered choice with the PEGs in `a`
|
||||||
multipleOp(pkOrderedChoice, addChoice)
|
multipleOp(pkOrderedChoice, addChoice)
|
||||||
|
|
@ -166,7 +166,7 @@ proc addSequence(dest: var TPeg, elem: TPeg) =
|
||||||
else: add(dest, elem)
|
else: add(dest, elem)
|
||||||
else: add(dest, elem)
|
else: add(dest, elem)
|
||||||
|
|
||||||
proc sequence*(a: openArray[TPeg]): TPeg {.
|
proc sequence*(a: varargs[TPeg]): TPeg {.
|
||||||
nosideEffect, rtl, extern: "npegs$1".} =
|
nosideEffect, rtl, extern: "npegs$1".} =
|
||||||
## constructs a sequence with all the PEGs from `a`
|
## constructs a sequence with all the PEGs from `a`
|
||||||
multipleOp(pkSequence, addSequence)
|
multipleOp(pkSequence, addSequence)
|
||||||
|
|
@ -939,7 +939,7 @@ proc replace*(s: string, sub: TPeg, by = ""): string {.
|
||||||
inc(i, x)
|
inc(i, x)
|
||||||
add(result, substr(s, i))
|
add(result, substr(s, i))
|
||||||
|
|
||||||
proc parallelReplace*(s: string, subs: openArray[
|
proc parallelReplace*(s: string, subs: varargs[
|
||||||
tuple[pattern: TPeg, repl: string]]): string {.
|
tuple[pattern: TPeg, repl: string]]): string {.
|
||||||
nosideEffect, rtl, extern: "npegs$1".} =
|
nosideEffect, rtl, extern: "npegs$1".} =
|
||||||
## Returns a modified copy of `s` with the substitutions in `subs`
|
## Returns a modified copy of `s` with the substitutions in `subs`
|
||||||
|
|
@ -964,7 +964,7 @@ proc parallelReplace*(s: string, subs: openArray[
|
||||||
add(result, substr(s, i))
|
add(result, substr(s, i))
|
||||||
|
|
||||||
proc transformFile*(infile, outfile: string,
|
proc transformFile*(infile, outfile: string,
|
||||||
subs: openArray[tuple[pattern: TPeg, repl: string]]) {.
|
subs: varargs[tuple[pattern: TPeg, repl: string]]) {.
|
||||||
rtl, extern: "npegs$1".} =
|
rtl, extern: "npegs$1".} =
|
||||||
## reads in the file `infile`, performs a parallel replacement (calls
|
## reads in the file `infile`, performs a parallel replacement (calls
|
||||||
## `parallelReplace`) and writes back to `outfile`. Raises ``EIO`` if an
|
## `parallelReplace`) and writes back to `outfile`. Raises ``EIO`` if an
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ proc newStringTable*(mode: TStringTableMode): PStringTable {.
|
||||||
result.counter = 0
|
result.counter = 0
|
||||||
newSeq(result.data, startSize)
|
newSeq(result.data, startSize)
|
||||||
|
|
||||||
proc newStringTable*(keyValuePairs: openarray[string],
|
proc newStringTable*(keyValuePairs: varargs[string],
|
||||||
mode: TStringTableMode): PStringTable {.
|
mode: TStringTableMode): PStringTable {.
|
||||||
rtl, extern: "nst$1WithPairs".} =
|
rtl, extern: "nst$1WithPairs".} =
|
||||||
## creates a new string table with given key value pairs.
|
## creates a new string table with given key value pairs.
|
||||||
|
|
@ -164,7 +164,7 @@ proc newStringTable*(keyValuePairs: openarray[string],
|
||||||
result[keyValuePairs[i]] = keyValuePairs[i + 1]
|
result[keyValuePairs[i]] = keyValuePairs[i + 1]
|
||||||
inc(i, 2)
|
inc(i, 2)
|
||||||
|
|
||||||
proc newStringTable*(keyValuePairs: openarray[tuple[key, val: string]],
|
proc newStringTable*(keyValuePairs: varargs[tuple[key, val: string]],
|
||||||
mode: TStringTableMode = modeCaseSensitive): PStringTable {.
|
mode: TStringTableMode = modeCaseSensitive): PStringTable {.
|
||||||
rtl, extern: "nst$1WithTableConstr".} =
|
rtl, extern: "nst$1WithTableConstr".} =
|
||||||
## creates a new string table with given key value pairs.
|
## creates a new string table with given key value pairs.
|
||||||
|
|
|
||||||
|
|
@ -1113,6 +1113,13 @@ proc `%` *(formatstr, a: string): string {.noSideEffect,
|
||||||
result = newStringOfCap(formatstr.len + a.len)
|
result = newStringOfCap(formatstr.len + a.len)
|
||||||
addf(result, formatstr, [a])
|
addf(result, formatstr, [a])
|
||||||
|
|
||||||
|
proc format*(formatstr: string, a: varargs[string, `$`]): string {.noSideEffect,
|
||||||
|
rtl, extern: "nsuFormatVarargs".} =
|
||||||
|
## This is the same as ``formatstr % a`` except that it supports
|
||||||
|
## auto stringification.
|
||||||
|
result = newStringOfCap(formatstr.len + a.len)
|
||||||
|
addf(result, formatstr, a)
|
||||||
|
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
|
|
|
||||||
|
|
@ -141,13 +141,14 @@ proc low*[T](x: T): T {.magic: "Low", noSideEffect.}
|
||||||
## semantic rule, `x` may also be a type identifier.
|
## semantic rule, `x` may also be a type identifier.
|
||||||
|
|
||||||
type
|
type
|
||||||
range*{.magic: "Range".} [T] ## Generic type to construct range types.
|
range*{.magic: "Range".}[T] ## Generic type to construct range types.
|
||||||
array*{.magic: "Array".}[I, T] ## Generic type to construct
|
array*{.magic: "Array".}[I, T] ## Generic type to construct
|
||||||
## fixed-length arrays.
|
## fixed-length arrays.
|
||||||
openarray*{.magic: "OpenArray".}[T] ## Generic type to construct open arrays.
|
openarray*{.magic: "OpenArray".}[T] ## Generic type to construct open arrays.
|
||||||
## Open arrays are implemented as a
|
## Open arrays are implemented as a
|
||||||
## pointer to the array data and a
|
## pointer to the array data and a
|
||||||
## length field.
|
## length field.
|
||||||
|
varargs*{.magic: "Varargs".}[T] ## Generic type to construct a varargs type.
|
||||||
seq*{.magic: "Seq".}[T] ## Generic type to construct sequences.
|
seq*{.magic: "Seq".}[T] ## Generic type to construct sequences.
|
||||||
set*{.magic: "Set".}[T] ## Generic type to construct bit sets.
|
set*{.magic: "Set".}[T] ## Generic type to construct bit sets.
|
||||||
|
|
||||||
|
|
@ -347,7 +348,8 @@ proc newSeq*[T](s: var seq[T], len: int) {.magic: "NewSeq", noSideEffect.}
|
||||||
## This is equivalent to ``s = @[]; setlen(s, len)``, but more
|
## This is equivalent to ``s = @[]; setlen(s, len)``, but more
|
||||||
## efficient since no reallocation is needed.
|
## efficient since no reallocation is needed.
|
||||||
|
|
||||||
proc len*[T: openArray](x: T): int {.magic: "LengthOpenArray", noSideEffect.}
|
proc len*[TOpenArray: openArray|varargs](x: TOpenArray): int {.
|
||||||
|
magic: "LengthOpenArray", noSideEffect.}
|
||||||
proc len*(x: string): int {.magic: "LengthStr", noSideEffect.}
|
proc len*(x: string): int {.magic: "LengthStr", noSideEffect.}
|
||||||
proc len*(x: cstring): int {.magic: "LengthStr", noSideEffect.}
|
proc len*(x: cstring): int {.magic: "LengthStr", noSideEffect.}
|
||||||
proc len*[I, T](x: array[I, T]): int {.magic: "LengthArray", noSideEffect.}
|
proc len*[I, T](x: array[I, T]): int {.magic: "LengthArray", noSideEffect.}
|
||||||
|
|
@ -1238,8 +1240,8 @@ proc min*(x, y: int32): int32 {.magic: "MinI", noSideEffect.}
|
||||||
proc min*(x, y: int64): int64 {.magic: "MinI64", noSideEffect.}
|
proc min*(x, y: int64): int64 {.magic: "MinI64", noSideEffect.}
|
||||||
## The minimum value of two integers.
|
## The minimum value of two integers.
|
||||||
|
|
||||||
proc min*[T](x: openarray[T]): T =
|
proc min*[T](x: varargs[T]): T =
|
||||||
## The minimum value of an openarray.
|
## The minimum value of `x`.
|
||||||
result = x[0]
|
result = x[0]
|
||||||
for i in 1..high(x): result = min(result, x[i])
|
for i in 1..high(x): result = min(result, x[i])
|
||||||
|
|
||||||
|
|
@ -1250,8 +1252,8 @@ proc max*(x, y: int32): int32 {.magic: "MaxI", noSideEffect.}
|
||||||
proc max*(x, y: int64): int64 {.magic: "MaxI64", noSideEffect.}
|
proc max*(x, y: int64): int64 {.magic: "MaxI64", noSideEffect.}
|
||||||
## The maximum value of two integers.
|
## The maximum value of two integers.
|
||||||
|
|
||||||
proc max*[T](x: openarray[T]): T =
|
proc max*[T](x: varargs[T]): T =
|
||||||
## The maximum value of an openarray.
|
## The maximum value of `x`.
|
||||||
result = x[0]
|
result = x[0]
|
||||||
for i in 1..high(x): result = max(result, x[i])
|
for i in 1..high(x): result = max(result, x[i])
|
||||||
|
|
||||||
|
|
@ -1642,7 +1644,7 @@ else:
|
||||||
|
|
||||||
proc add*(x: var cstring, y: cstring) {.magic: "AppendStrStr".}
|
proc add*(x: var cstring, y: cstring) {.magic: "AppendStrStr".}
|
||||||
|
|
||||||
proc echo*[Ty](x: openarray[Ty]) {.magic: "Echo", noSideEffect.}
|
proc echo*[T](x: varargs[T, `$`]) {.magic: "Echo", noSideEffect.}
|
||||||
## special built-in that takes a variable number of arguments. Each argument
|
## special built-in that takes a variable number of arguments. Each argument
|
||||||
## is converted to a string via ``$``, so it works for user-defined
|
## is converted to a string via ``$``, so it works for user-defined
|
||||||
## types that have an overloaded ``$`` operator.
|
## types that have an overloaded ``$`` operator.
|
||||||
|
|
@ -1812,7 +1814,7 @@ when not defined(EcmaScript) and not defined(NimrodVM):
|
||||||
proc write*(f: TFile, b: Bool)
|
proc write*(f: TFile, b: Bool)
|
||||||
proc write*(f: TFile, c: char)
|
proc write*(f: TFile, c: char)
|
||||||
proc write*(f: TFile, c: cstring)
|
proc write*(f: TFile, c: cstring)
|
||||||
proc write*(f: TFile, a: openArray[string])
|
proc write*(f: TFile, a: varargs[string, `$`])
|
||||||
## Writes a value to the file `f`. May throw an IO exception.
|
## Writes a value to the file `f`. May throw an IO exception.
|
||||||
|
|
||||||
proc readLine*(f: TFile): TaintedString
|
proc readLine*(f: TFile): TaintedString
|
||||||
|
|
@ -1831,7 +1833,7 @@ when not defined(EcmaScript) and not defined(NimrodVM):
|
||||||
## writes a value `x` to `f` and then writes "\n".
|
## writes a value `x` to `f` and then writes "\n".
|
||||||
## May throw an IO exception.
|
## May throw an IO exception.
|
||||||
|
|
||||||
proc writeln*[Ty](f: TFile, x: openArray[Ty]) {.inline.}
|
proc writeln*[Ty](f: TFile, x: varargs[Ty, `$`]) {.inline.}
|
||||||
## writes a value `x` to `f` and then writes "\n".
|
## writes a value `x` to `f` and then writes "\n".
|
||||||
## May throw an IO exception.
|
## May throw an IO exception.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ proc write(f: TFile, r: float) = fprintf(f, "%g", r)
|
||||||
proc write(f: TFile, r: biggestFloat) = fprintf(f, "%g", r)
|
proc write(f: TFile, r: biggestFloat) = fprintf(f, "%g", r)
|
||||||
|
|
||||||
proc write(f: TFile, c: Char) = putc(c, f)
|
proc write(f: TFile, c: Char) = putc(c, f)
|
||||||
proc write(f: TFile, a: openArray[string]) =
|
proc write(f: TFile, a: varargs[string, `$`]) =
|
||||||
for x in items(a): write(f, x)
|
for x in items(a): write(f, x)
|
||||||
|
|
||||||
proc readAllBuffer(file: TFile): string =
|
proc readAllBuffer(file: TFile): string =
|
||||||
|
|
@ -150,7 +150,7 @@ proc writeln[Ty](f: TFile, x: Ty) =
|
||||||
write(f, x)
|
write(f, x)
|
||||||
write(f, "\n")
|
write(f, "\n")
|
||||||
|
|
||||||
proc writeln[Ty](f: TFile, x: openArray[Ty]) =
|
proc writeln[Ty](f: TFile, x: varargs[Ty, `$`]) =
|
||||||
for i in items(x): write(f, i)
|
for i in items(x): write(f, i)
|
||||||
write(f, "\n")
|
write(f, "\n")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,12 +138,12 @@ proc disp(target: TOutputTarget, xml, tex: string): string =
|
||||||
else: result = tex
|
else: result = tex
|
||||||
|
|
||||||
proc dispF(target: TOutputTarget, xml, tex: string,
|
proc dispF(target: TOutputTarget, xml, tex: string,
|
||||||
args: openArray[string]): string =
|
args: varargs[string]): string =
|
||||||
if target != outLatex: result = xml % args
|
if target != outLatex: result = xml % args
|
||||||
else: result = tex % args
|
else: result = tex % args
|
||||||
|
|
||||||
proc dispA(target: TOutputTarget, dest: var string,
|
proc dispA(target: TOutputTarget, dest: var string,
|
||||||
xml, tex: string, args: openarray[string]) =
|
xml, tex: string, args: varargs[string]) =
|
||||||
if target != outLatex: addf(dest, xml, args)
|
if target != outLatex: addf(dest, xml, args)
|
||||||
else: addf(dest, tex, args)
|
else: addf(dest, tex, args)
|
||||||
|
|
||||||
|
|
@ -241,12 +241,12 @@ proc mergeIndexes*(dir: string): string =
|
||||||
var i = 0
|
var i = 0
|
||||||
while i < L:
|
while i < L:
|
||||||
result.addf("<dt><span>$1</span></dt><ul class=\"simple\"><dd>\n",
|
result.addf("<dt><span>$1</span></dt><ul class=\"simple\"><dd>\n",
|
||||||
a[i].keyword)
|
[a[i].keyword])
|
||||||
var j = i
|
var j = i
|
||||||
while j < L and a[i].keyword == a[j].keyword:
|
while j < L and a[i].keyword == a[j].keyword:
|
||||||
result.addf(
|
result.addf(
|
||||||
"<li><a class=\"reference external\" href=\"$1\">$1</a></li>\n",
|
"<li><a class=\"reference external\" href=\"$1\">$1</a></li>\n",
|
||||||
a[j].link)
|
[a[j].link])
|
||||||
inc j
|
inc j
|
||||||
result.add("</ul></dd>\n")
|
result.add("</ul></dd>\n")
|
||||||
i = j
|
i = j
|
||||||
|
|
@ -352,7 +352,7 @@ proc renderCodeBlock(d: PDoc, n: PRstNode, result: var string) =
|
||||||
else:
|
else:
|
||||||
lang = getSourceLanguage(langstr)
|
lang = getSourceLanguage(langstr)
|
||||||
|
|
||||||
dispA(d.target, result, "<pre>", "\\begin{rstpre}\n")
|
dispA(d.target, result, "<pre>", "\\begin{rstpre}\n", [])
|
||||||
if lang == langNone:
|
if lang == langNone:
|
||||||
d.msgHandler(d.filename, 1, 0, mwUnsupportedLanguage, langstr)
|
d.msgHandler(d.filename, 1, 0, mwUnsupportedLanguage, langstr)
|
||||||
result.add(m.text)
|
result.add(m.text)
|
||||||
|
|
|
||||||
11
tests/reject/tnocontains.nim
Normal file
11
tests/reject/tnocontains.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
discard """
|
||||||
|
file: "tnocontains.nim"
|
||||||
|
line: 10
|
||||||
|
errormsg: "type mismatch: got (string, string)"
|
||||||
|
"""
|
||||||
|
|
||||||
|
# shouldn't compile since it doesn't do what you think it does without
|
||||||
|
# importing strutils:
|
||||||
|
|
||||||
|
let x = "abc" in "abcdef"
|
||||||
|
echo x
|
||||||
|
|
@ -161,7 +161,7 @@ template multipleOp(k: TPegKind, localOpt: expr) =
|
||||||
if result.len == 1:
|
if result.len == 1:
|
||||||
result = result.sons[0]
|
result = result.sons[0]
|
||||||
|
|
||||||
proc `/`*(a: openArray[TPeg]): TPeg {.
|
proc `/`*(a: varargs[TPeg]): TPeg {.
|
||||||
rtl, extern: "npegsOrderedChoice".} =
|
rtl, extern: "npegsOrderedChoice".} =
|
||||||
## constructs an ordered choice with the PEGs in `a`
|
## constructs an ordered choice with the PEGs in `a`
|
||||||
multipleOp(pkOrderedChoice, addChoice)
|
multipleOp(pkOrderedChoice, addChoice)
|
||||||
|
|
@ -178,7 +178,7 @@ proc addSequence(dest: var TPeg, elem: TPeg) =
|
||||||
else: add(dest, elem)
|
else: add(dest, elem)
|
||||||
else: add(dest, elem)
|
else: add(dest, elem)
|
||||||
|
|
||||||
proc sequence*(a: openArray[TPeg]): TPeg {.
|
proc sequence*(a: varargs[TPeg]): TPeg {.
|
||||||
rtl, extern: "npegs$1".} =
|
rtl, extern: "npegs$1".} =
|
||||||
## constructs a sequence with all the PEGs from `a`
|
## constructs a sequence with all the PEGs from `a`
|
||||||
multipleOp(pkSequence, addSequence)
|
multipleOp(pkSequence, addSequence)
|
||||||
|
|
@ -935,7 +935,7 @@ proc replace*(s: string, sub: TPeg, by = ""): string {.
|
||||||
inc(i, x)
|
inc(i, x)
|
||||||
add(result, substr(s, i))
|
add(result, substr(s, i))
|
||||||
|
|
||||||
proc parallelReplace*(s: string, subs: openArray[
|
proc parallelReplace*(s: string, subs: varargs[
|
||||||
tuple[pattern: TPeg, repl: string]]): string {.
|
tuple[pattern: TPeg, repl: string]]): string {.
|
||||||
rtl, extern: "npegs$1".} =
|
rtl, extern: "npegs$1".} =
|
||||||
## Returns a modified copy of `s` with the substitutions in `subs`
|
## Returns a modified copy of `s` with the substitutions in `subs`
|
||||||
|
|
@ -957,7 +957,7 @@ proc parallelReplace*(s: string, subs: openArray[
|
||||||
add(result, substr(s, i))
|
add(result, substr(s, i))
|
||||||
|
|
||||||
proc transformFile*(infile, outfile: string,
|
proc transformFile*(infile, outfile: string,
|
||||||
subs: openArray[tuple[pattern: TPeg, repl: string]]) {.
|
subs: varargs[tuple[pattern: TPeg, repl: string]]) {.
|
||||||
rtl, extern: "npegs$1".} =
|
rtl, extern: "npegs$1".} =
|
||||||
## reads in the file `infile`, performs a parallel replacement (calls
|
## reads in the file `infile`, performs a parallel replacement (calls
|
||||||
## `parallelReplace`) and writes back to `outfile`. Calls ``quit`` if an
|
## `parallelReplace`) and writes back to `outfile`. Calls ``quit`` if an
|
||||||
|
|
|
||||||
2
todo.txt
2
todo.txt
|
|
@ -4,7 +4,7 @@ version 0.9.0
|
||||||
- implement "closure tuple consists of a single 'ref'" optimization
|
- implement "closure tuple consists of a single 'ref'" optimization
|
||||||
- implement for loop transformation for first class iterators
|
- implement for loop transformation for first class iterators
|
||||||
|
|
||||||
- implicit deref for parameter matching; implement ``varargs[T, `$`]``
|
- implicit deref for parameter matching
|
||||||
- ``final`` should be the default for objects
|
- ``final`` should be the default for objects
|
||||||
- ``bycopy`` pragma for imported C types
|
- ``bycopy`` pragma for imported C types
|
||||||
- optimize genericAssign in the code generator
|
- optimize genericAssign in the code generator
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ Changes affecting backwards compatibility
|
||||||
for procs it remains ``nimcall`` (which is compatible to ``closure``).
|
for procs it remains ``nimcall`` (which is compatible to ``closure``).
|
||||||
Activate the warning ``ImplicitClosure`` to make the compiler list the
|
Activate the warning ``ImplicitClosure`` to make the compiler list the
|
||||||
occurances of proc types which are affected.
|
occurances of proc types which are affected.
|
||||||
|
- The Nimrod type system now distinguishes ``openarray`` from ``varargs``.
|
||||||
|
|
||||||
|
|
||||||
Compiler Additions
|
Compiler Additions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue