mirror of
https://github.com/nim-lang/Nim.git
synced 2026-09-08 22:47:27 +00:00
openarray/varargs split; breaks bootstrapping
This commit is contained in:
@@ -7,8 +7,6 @@ SET LINK_FLAGS=
|
||||
|
||||
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
|
||||
%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
|
||||
@@ -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
|
||||
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
|
||||
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
|
||||
%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
|
||||
@@ -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
|
||||
%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
|
||||
%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\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
|
||||
|
||||
@@ -7,8 +7,6 @@ SET LINK_FLAGS=
|
||||
|
||||
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
|
||||
%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
|
||||
@@ -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
|
||||
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
|
||||
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
|
||||
%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
|
||||
@@ -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
|
||||
%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
|
||||
%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\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
|
||||
|
||||
@@ -48,7 +48,7 @@ proc loadInto(p: BProc, le, ri: PNode, a: var TLoc) {.inline.} =
|
||||
expr(p, ri, a)
|
||||
|
||||
proc startBlock(p: BProc, start: TFormatStr = "{$n",
|
||||
args: openarray[PRope]): int {.discardable.} =
|
||||
args: varargs[PRope]): int {.discardable.} =
|
||||
lineCg(p, cpsStmts, start, args)
|
||||
inc(p.labels)
|
||||
result = len(p.blocks)
|
||||
|
||||
@@ -153,7 +153,7 @@ proc getTypeName(typ: PType): PRope =
|
||||
else:
|
||||
if typ.loc.r == nil:
|
||||
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
|
||||
if result == nil: InternalError("getTypeName: " & $typ.kind)
|
||||
|
||||
|
||||
@@ -25,12 +25,12 @@ proc cgenPass*(): TPass
|
||||
var
|
||||
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)
|
||||
else: result = ropef(cformat, args)
|
||||
|
||||
proc appff(dest: var PRope, cformat, llvmformat: string,
|
||||
args: openarray[PRope]) =
|
||||
args: varargs[PRope]) =
|
||||
if gCmd == cmdCompileToLLVM: appf(dest, llvmformat, args)
|
||||
else: appf(dest, cformat, args)
|
||||
|
||||
@@ -90,7 +90,7 @@ proc useHeader(m: BModule, sym: PSym) =
|
||||
|
||||
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 length = len(frmt)
|
||||
result = nil
|
||||
@@ -145,15 +145,15 @@ proc ropecg(m: BModule, frmt: TFormatStr, args: openarray[PRope]): PRope =
|
||||
app(result, substr(frmt, start, i - 1))
|
||||
|
||||
proc appcg(m: BModule, c: var PRope, frmt: TFormatStr,
|
||||
args: openarray[PRope]) =
|
||||
args: varargs[PRope]) =
|
||||
app(c, ropecg(m, frmt, args))
|
||||
|
||||
proc appcg(m: BModule, s: TCFileSection, frmt: TFormatStr,
|
||||
args: openarray[PRope]) =
|
||||
args: varargs[PRope]) =
|
||||
app(m.s[s], ropecg(m, frmt, args))
|
||||
|
||||
proc appcg(p: BProc, s: TCProcSection, frmt: TFormatStr,
|
||||
args: openarray[PRope]) =
|
||||
args: varargs[PRope]) =
|
||||
app(p.s(s), ropecg(p.module, frmt, args))
|
||||
|
||||
var indent = "\t".toRope
|
||||
@@ -168,19 +168,19 @@ proc line(p: BProc, s: TCProcSection, r: string) =
|
||||
app(p.s(s), indentLine(p, r.toRope))
|
||||
|
||||
proc lineF(p: BProc, s: TCProcSection, frmt: TFormatStr,
|
||||
args: openarray[PRope]) =
|
||||
args: varargs[PRope]) =
|
||||
app(p.s(s), indentLine(p, ropef(frmt, args)))
|
||||
|
||||
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)))
|
||||
|
||||
proc appLineCg(p: BProc, r: var PRope, frmt: TFormatStr,
|
||||
args: openarray[PRope]) =
|
||||
args: varargs[PRope]) =
|
||||
app(r, indentLine(p, ropecg(p.module, frmt, args)))
|
||||
|
||||
proc lineFF(p: BProc, s: TCProcSection, cformat, llvmformat: string,
|
||||
args: openarray[PRope]) =
|
||||
args: varargs[PRope]) =
|
||||
if gCmd == cmdCompileToLLVM: lineF(p, s, llvmformat, args)
|
||||
else: lineF(p, s, cformat, args)
|
||||
|
||||
|
||||
@@ -479,7 +479,7 @@ proc getLinkOptions: string =
|
||||
for linkedLib in items(cLinkedLibs):
|
||||
result.add(cc[ccompiler].linkLibCmd % linkedLib.quoteIfContainsWhite)
|
||||
for libDir in items(cLibs):
|
||||
result.add cc[ccompiler].linkDirCmd, libDir.quoteIfContainsWhite
|
||||
result.add([cc[ccompiler].linkDirCmd, libDir.quoteIfContainsWhite])
|
||||
|
||||
proc needsExeExt(): bool {.inline.} =
|
||||
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)
|
||||
|
||||
for includeDir in items(cIncludes):
|
||||
includeCmd.add cc[c].includeCmd, includeDir.quoteIfContainsWhite
|
||||
includeCmd.add([cc[c].includeCmd, includeDir.quoteIfContainsWhite])
|
||||
|
||||
compilePattern = JoinPath(ccompilerpath, exe)
|
||||
else:
|
||||
|
||||
@@ -75,7 +75,7 @@ type
|
||||
proc con*(a, b: PRope): PRope
|
||||
proc con*(a: PRope, b: string): 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: string)
|
||||
proc prepend*(a: var PRope, b: PRope)
|
||||
@@ -84,8 +84,8 @@ proc toRope*(i: BiggestInt): PRope
|
||||
proc ropeLen*(a: PRope): int
|
||||
proc writeRopeIfNotEqual*(r: PRope, filename: string): bool
|
||||
proc ropeToStr*(p: PRope): string
|
||||
proc ropef*(frmt: TFormatStr, args: openarray[PRope]): PRope
|
||||
proc appf*(c: var PRope, frmt: TFormatStr, args: openarray[PRope])
|
||||
proc ropef*(frmt: TFormatStr, args: varargs[PRope]): PRope
|
||||
proc appf*(c: var PRope, frmt: TFormatStr, args: varargs[PRope])
|
||||
proc RopeEqualsFile*(r: PRope, f: string): bool
|
||||
# returns true if the rope r is the same as the contents of file f
|
||||
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: 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])
|
||||
|
||||
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,
|
||||
filename)
|
||||
|
||||
proc ropef(frmt: TFormatStr, args: openarray[PRope]): PRope =
|
||||
proc ropef(frmt: TFormatStr, args: varargs[PRope]): PRope =
|
||||
var i = 0
|
||||
var length = len(frmt)
|
||||
result = nil
|
||||
@@ -254,7 +254,7 @@ proc ropef(frmt: TFormatStr, args: openarray[PRope]): PRope =
|
||||
app(result, substr(frmt, start, i - 1))
|
||||
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))
|
||||
|
||||
const
|
||||
|
||||
@@ -388,9 +388,9 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||
elif f.sons[0].kind in GenericTypes:
|
||||
result = minRel(result, typeRel(c, f.sons[0], a.sons[0]))
|
||||
else: nil
|
||||
of tyOpenArray:
|
||||
of tyOpenArray, tyVarargs:
|
||||
case a.Kind
|
||||
of tyOpenArray:
|
||||
of tyOpenArray, tyVarargs:
|
||||
result = typeRel(c, base(f), base(a))
|
||||
if result < isGeneric: result = isNone
|
||||
of tyArrayConstr:
|
||||
@@ -409,10 +409,6 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||
elif typeRel(c, base(f), a.sons[0]) >= isGeneric:
|
||||
result = isConvertible
|
||||
else: nil
|
||||
of tyVarargs:
|
||||
if a.Kind == tyVarargs:
|
||||
result = typeRel(c, base(f), base(a))
|
||||
if result < isGeneric: result = isNone
|
||||
of tySequence:
|
||||
case a.Kind
|
||||
of tyNil:
|
||||
@@ -611,10 +607,13 @@ proc localConvMatch(c: PContext, m: var TCandidate, f, a: PType,
|
||||
result = c.semOverloadedCall(c, call, call, RoutineKinds)
|
||||
if result != nil:
|
||||
# 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 result.kind == nkCall: result.kind = nkHiddenCallConv
|
||||
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,
|
||||
arg, argOrig: PNode): PNode =
|
||||
@@ -686,17 +685,21 @@ proc ParamTypesMatchAux(c: PContext, m: var TCandidate, f, a: PType,
|
||||
m.proxyMatch = true
|
||||
return copyTree(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:
|
||||
if result == nil and f.kind == tyOpenArray:
|
||||
r = typeRel(m, base(f), a)
|
||||
if r >= isGeneric:
|
||||
inc(m.convMatches)
|
||||
result = copyTree(arg)
|
||||
if r == isGeneric: result.typ = getInstantiatedType(c, arg, m, base(f))
|
||||
m.baseTypeMatch = true
|
||||
if result == nil and f.kind == tyVarargs:
|
||||
if f.n != nil:
|
||||
result = localConvMatch(c, m, f, a, arg)
|
||||
else:
|
||||
result = userConvMatch(c, m, base(f), a, arg)
|
||||
r = typeRel(m, base(f), a)
|
||||
if r >= isGeneric:
|
||||
inc(m.convMatches)
|
||||
result = copyTree(arg)
|
||||
if r == isGeneric:
|
||||
result.typ = getInstantiatedType(c, arg, m, base(f))
|
||||
m.baseTypeMatch = true
|
||||
else:
|
||||
result = userConvMatch(c, m, base(f), a, arg)
|
||||
|
||||
proc ParamTypesMatch(c: PContext, m: var TCandidate, f, a: PType,
|
||||
arg, argOrig: PNode): PNode =
|
||||
@@ -777,7 +780,7 @@ proc matchesAux*(c: PContext, n, nOrig: PNode,
|
||||
var container: PNode = nil # constructed container
|
||||
var formal: PSym = nil
|
||||
while a < n.len:
|
||||
if n.sons[a].kind == nkExprEqExpr:
|
||||
if n.sons[a].kind == nkExprEqExpr:
|
||||
# named param
|
||||
# check if m.callee has such a param:
|
||||
if n.sons[a].sons[0].kind != nkIdent:
|
||||
@@ -870,19 +873,19 @@ proc matches*(c: PContext, n, nOrig: PNode, m: var TCandidate) =
|
||||
if m.state == csNoMatch: return
|
||||
# check that every formal parameter got a value:
|
||||
var f = 1
|
||||
while f < sonsLen(m.callee.n):
|
||||
while f < sonsLen(m.callee.n):
|
||||
var formal = m.callee.n.sons[f].sym
|
||||
if not ContainsOrIncl(marker, formal.position):
|
||||
if formal.ast == nil:
|
||||
if formal.typ.kind == tyOpenArray:
|
||||
if formal.ast == nil:
|
||||
if formal.typ.kind == tyVarargs:
|
||||
var container = newNodeI(nkBracket, n.info)
|
||||
addSon(m.call, implicitConv(nkHiddenStdConv, formal.typ,
|
||||
addSon(m.call, implicitConv(nkHiddenStdConv, formal.typ,
|
||||
container, m, c))
|
||||
else:
|
||||
# no default value
|
||||
m.state = csNoMatch
|
||||
break
|
||||
else:
|
||||
else:
|
||||
# use default value:
|
||||
setSon(m.call, formal.position + 1, copyTree(formal.ast))
|
||||
inc(f)
|
||||
|
||||
@@ -89,17 +89,17 @@ proc substituteLog*(frmt: string): string =
|
||||
|
||||
|
||||
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
|
||||
## nothing.
|
||||
nil
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
proc defaultFilename*(): string =
|
||||
@@ -150,7 +150,7 @@ proc newRollingFileLogger*(filename = defaultFilename(),
|
||||
|
||||
|
||||
method log*(L: ref TRollingFileLogger, level: TLevel,
|
||||
frmt: string, args: openArray[string]) =
|
||||
frmt: string, args: varargs[string, `$`]) =
|
||||
# TODO
|
||||
# if more than maxlines, then set cursor to zero
|
||||
|
||||
@@ -162,12 +162,12 @@ var
|
||||
level* = lvlAll ## global log filter
|
||||
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):
|
||||
if level >= logger.levelThreshold:
|
||||
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
|
||||
bind logLoop
|
||||
bind `%`
|
||||
@@ -176,23 +176,23 @@ template log*(level: TLevel, frmt: string, args: openarray[string]) =
|
||||
if level >= logging.Level:
|
||||
logLoop(level, frmt, args)
|
||||
|
||||
template debug*(frmt: string, args: openarray[string]) =
|
||||
template debug*(frmt: string, args: varargs[string, `$`]) =
|
||||
## logs a debug message
|
||||
log(lvlDebug, frmt, args)
|
||||
|
||||
template info*(frmt: string, args: openarray[string]) =
|
||||
template info*(frmt: string, args: varargs[string, `$`]) =
|
||||
## logs an info message
|
||||
log(lvlInfo, frmt, args)
|
||||
|
||||
template warn*(frmt: string, args: openarray[string]) =
|
||||
template warn*(frmt: string, args: varargs[string, `$`]) =
|
||||
## logs a warning message
|
||||
log(lvlWarn, frmt, args)
|
||||
|
||||
template error*(frmt: string, args: openarray[string]) =
|
||||
template error*(frmt: string, args: varargs[string, `$`]) =
|
||||
## logs an error message
|
||||
log(lvlError, frmt, args)
|
||||
|
||||
template fatal*(frmt: string, args: openarray[string]) =
|
||||
template fatal*(frmt: string, args: varargs[string, `$`]) =
|
||||
## logs a fatal error message
|
||||
log(lvlFatal, frmt, args)
|
||||
|
||||
|
||||
@@ -890,24 +890,44 @@ The notation ``x[i]`` can be used to access the i-th element of ``x``.
|
||||
Arrays are always bounds checked (at compile-time or at runtime). These
|
||||
checks can be disabled via pragmas or invoking the compiler with the
|
||||
``--boundChecks:off`` command line switch.
|
||||
|
||||
The current implementation does not support nested open arrays.
|
||||
|
||||
An open array is also a means to implement passing a variable number of
|
||||
arguments to a procedure. The compiler converts the list of arguments
|
||||
to an array automatically:
|
||||
|
||||
.. code-block:: nimrod
|
||||
proc myWriteln(f: TFile, a: openarray[string]) =
|
||||
for s in items(a):
|
||||
write(f, s)
|
||||
write(f, "\n")
|
||||
|
||||
myWriteln(stdout, "abc", "def", "xyz")
|
||||
# is transformed by the compiler to:
|
||||
myWriteln(stdout, ["abc", "def", "xyz"])
|
||||
|
||||
This transformation is only done if the openarray parameter is the
|
||||
last parameter in the procedure header. The current implementation does not
|
||||
support nested open arrays.
|
||||
|
||||
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
|
||||
proc myWriteln(f: TFile, a: varargs[string]) =
|
||||
for s in items(a):
|
||||
write(f, s)
|
||||
write(f, "\n")
|
||||
|
||||
myWriteln(stdout, "abc", "def", "xyz")
|
||||
# is transformed by the compiler to:
|
||||
myWriteln(stdout, ["abc", "def", "xyz"])
|
||||
|
||||
This transformation is only done if the varargs parameter is the
|
||||
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 and object types
|
||||
@@ -2336,8 +2356,7 @@ Var parameters
|
||||
The type of a parameter may be prefixed with the ``var`` keyword:
|
||||
|
||||
.. code-block:: nimrod
|
||||
proc divmod(a, b: int,
|
||||
res, remainder: var int) =
|
||||
proc divmod(a, b: int; res, remainder: var int) =
|
||||
res = a div 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:
|
||||
|
||||
.. code-block:: nimrod
|
||||
proc divmod(a, b: int,
|
||||
res, remainder: ptr int) =
|
||||
proc divmod(a, b: int; res, remainder: ptr int) =
|
||||
res[] = a div 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
|
||||
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
|
||||
to an array automatically:
|
||||
|
||||
.. code-block:: nimrod
|
||||
proc myWriteln(f: TFile, a: openarray[string]) =
|
||||
proc myWriteln(f: TFile, a: varargs[string]) =
|
||||
for s in items(a):
|
||||
write(f, s)
|
||||
write(f, "\n")
|
||||
@@ -1145,8 +1150,22 @@ to an array automatically:
|
||||
# is transformed by the compiler to:
|
||||
myWriteln(stdout, ["abc", "def", "xyz"])
|
||||
|
||||
This transformation is only done if the openarray parameter is the
|
||||
last parameter in the procedure header.
|
||||
This transformation is only done if the varargs parameter is the
|
||||
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
|
||||
|
||||
@@ -195,10 +195,6 @@ if [ $# -eq 1 ] ; then
|
||||
cp doc/tut2.txt $docdir/tut2.txt
|
||||
chmod 644 $docdir/tut2.txt
|
||||
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
|
||||
cp doc/nimrodc.html $docdir/nimrodc.html
|
||||
chmod 644 $docdir/nimrodc.html
|
||||
@@ -313,6 +309,8 @@ if [ $# -eq 1 ] ; then
|
||||
chmod 644 $libdir/core/macros.nim
|
||||
cp lib/core/typeinfo.nim $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
|
||||
chmod 644 $libdir/pure/actors.nim
|
||||
cp lib/pure/algorithm.nim $libdir/pure/algorithm.nim
|
||||
@@ -497,6 +495,8 @@ if [ $# -eq 1 ] ; then
|
||||
chmod 644 $libdir/wrappers/openssl.nim
|
||||
cp lib/wrappers/pcre.nim $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
|
||||
chmod 644 $libdir/wrappers/postgres.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".}
|
||||
## adds the `child` to the `father` node
|
||||
|
||||
proc add*(father: PNimrodNode, children: openArray[PNimrodNode]) {.
|
||||
proc add*(father: PNimrodNode, children: varargs[PNimrodNode]) {.
|
||||
magic: "NAddMultiple".}
|
||||
## 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")
|
||||
|
||||
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
|
||||
## the arguments ``args[0..]``.
|
||||
result = newNimNode(nnkCall)
|
||||
@@ -259,7 +259,7 @@ proc newCall*(theProc: TNimrodIdent,
|
||||
result.add(args)
|
||||
|
||||
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
|
||||
## the arguments ``args[0..]``.
|
||||
result = newNimNode(nnkCall)
|
||||
|
||||
@@ -165,13 +165,13 @@ iterator find*(db: var TDbConn, namespace: string,
|
||||
yield bson(cursor[])[]
|
||||
destroy(cursor[])
|
||||
|
||||
proc setupFieldnames(fields: openArray[string]): TBSon =
|
||||
proc setupFieldnames(fields: varargs[string]): TBSon =
|
||||
init(result)
|
||||
for x in fields: add(result, x, 1'i32)
|
||||
finish(result)
|
||||
|
||||
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`
|
||||
## is ``[]`` the whole document is yielded.
|
||||
var f = setupFieldnames(fields)
|
||||
@@ -188,7 +188,7 @@ proc setupQuery(query: string): TBSon =
|
||||
finish(result)
|
||||
|
||||
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`
|
||||
## is ``[]`` the whole document is yielded.
|
||||
var f = setupFieldnames(fields)
|
||||
|
||||
@@ -34,7 +34,7 @@ proc dbError*(msg: string) {.noreturn.} =
|
||||
raise e
|
||||
|
||||
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)
|
||||
if stmt == nil: dbError(db)
|
||||
if mysql_stmt_prepare(stmt, query, len(query)) != 0:
|
||||
@@ -50,7 +50,7 @@ proc dbQuote(s: string): string =
|
||||
else: add(result, c)
|
||||
add(result, '\'')
|
||||
|
||||
proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
|
||||
proc dbFormat(formatstr: TSqlQuery, args: varargs[string]): string =
|
||||
result = ""
|
||||
var a = 0
|
||||
for c in items(string(formatstr)):
|
||||
@@ -60,12 +60,12 @@ proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
|
||||
else:
|
||||
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.
|
||||
var q = dbFormat(query, args)
|
||||
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.
|
||||
var q = dbFormat(query, args)
|
||||
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)
|
||||
|
||||
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
|
||||
## fast, but potenially dangerous: If the for-loop-body executes another
|
||||
## 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)
|
||||
|
||||
proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||
args: openarray[string]): TRow =
|
||||
args: varargs[string]): TRow =
|
||||
## retrieves a single row.
|
||||
Exec(db, query, args)
|
||||
var sqlres = mysql.UseResult(db)
|
||||
@@ -115,7 +115,7 @@ proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||
properFreeResult(sqlres, row)
|
||||
|
||||
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.
|
||||
result = @[]
|
||||
Exec(db, query, args)
|
||||
@@ -134,12 +134,12 @@ proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
||||
mysql.FreeResult(sqlres)
|
||||
|
||||
iterator Rows*(db: TDbConn, query: TSqlQuery,
|
||||
args: openarray[string]): TRow =
|
||||
args: varargs[string]): TRow =
|
||||
## same as `FastRows`, but slower and safe.
|
||||
for r in items(GetAllRows(db, query, args)): yield r
|
||||
|
||||
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
|
||||
## of the first row. Returns "" if the dataset contains no rows. This uses
|
||||
## `FastRows`, so it inherits its fragile behaviour.
|
||||
@@ -149,7 +149,7 @@ proc GetValue*(db: TDbConn, query: TSqlQuery,
|
||||
break
|
||||
|
||||
proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||
args: openarray[string]): int64 =
|
||||
args: varargs[string]): int64 =
|
||||
## executes the query (typically "INSERT") and returns the
|
||||
## generated ID for the row or -1 in case of an error.
|
||||
var q = dbFormat(query, args)
|
||||
@@ -158,14 +158,14 @@ proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||
else:
|
||||
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
|
||||
## generated ID for the row.
|
||||
result = TryInsertID(db, query, args)
|
||||
if result < 0: dbError(db)
|
||||
|
||||
proc ExecAffectedRows*(db: TDbConn, query: TSqlQuery,
|
||||
args: openArray[string]): int64 =
|
||||
args: varargs[string]): int64 =
|
||||
## runs the query (typically "UPDATE") and returns the
|
||||
## number of affected rows
|
||||
Exec(db, query, args)
|
||||
|
||||
@@ -49,7 +49,7 @@ proc dbQuote(s: string): string =
|
||||
else: add(result, c)
|
||||
add(result, '\'')
|
||||
|
||||
proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
|
||||
proc dbFormat(formatstr: TSqlQuery, args: varargs[string]): string =
|
||||
result = ""
|
||||
var a = 0
|
||||
for c in items(string(formatstr)):
|
||||
@@ -60,14 +60,14 @@ proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
|
||||
add(result, c)
|
||||
|
||||
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.
|
||||
var q = dbFormat(query, args)
|
||||
var res = PQExec(db, q)
|
||||
result = PQresultStatus(res) == PGRES_COMMAND_OK
|
||||
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.
|
||||
var q = dbFormat(query, args)
|
||||
var res = PQExec(db, q)
|
||||
@@ -79,7 +79,7 @@ proc newRow(L: int): TRow =
|
||||
for i in 0..L-1: result[i] = ""
|
||||
|
||||
proc setupQuery(db: TDbConn, query: TSqlQuery,
|
||||
args: openarray[string]): PPGresult =
|
||||
args: varargs[string]): PPGresult =
|
||||
var q = dbFormat(query, args)
|
||||
result = PQExec(db, q)
|
||||
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)
|
||||
|
||||
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
|
||||
## fast, but potenially dangerous: If the for-loop-body executes another
|
||||
## query, the results can be undefined. For Postgres it is safe though.
|
||||
@@ -104,7 +104,7 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
||||
PQclear(res)
|
||||
|
||||
proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||
args: openarray[string]): TRow =
|
||||
args: varargs[string]): TRow =
|
||||
## retrieves a single row.
|
||||
var res = setupQuery(db, query, args)
|
||||
var L = PQnfields(res)
|
||||
@@ -113,26 +113,26 @@ proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||
PQclear(res)
|
||||
|
||||
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.
|
||||
result = @[]
|
||||
for r in FastRows(db, query, args):
|
||||
result.add(r)
|
||||
|
||||
iterator Rows*(db: TDbConn, query: TSqlQuery,
|
||||
args: openarray[string]): TRow =
|
||||
args: varargs[string]): TRow =
|
||||
## same as `FastRows`, but slower and safe.
|
||||
for r in items(GetAllRows(db, query, args)): yield r
|
||||
|
||||
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
|
||||
## of the first row. Returns "" if the dataset contains no rows.
|
||||
var x = PQgetvalue(setupQuery(db, query, args), 0, 0)
|
||||
result = if isNil(x): "" else: $x
|
||||
|
||||
proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||
args: openarray[string]): int64 =
|
||||
args: varargs[string]): int64 =
|
||||
## executes the query (typically "INSERT") and returns the
|
||||
## 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
|
||||
@@ -144,7 +144,7 @@ proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||
result = -1
|
||||
|
||||
proc InsertID*(db: TDbConn, query: TSqlQuery,
|
||||
args: openArray[string]): int64 =
|
||||
args: varargs[string]): int64 =
|
||||
## executes the query (typically "INSERT") and returns the
|
||||
## generated ID for the row. For Postgre this adds
|
||||
## ``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)
|
||||
|
||||
proc ExecAffectedRows*(db: TDbConn, query: TSqlQuery,
|
||||
args: openArray[string]): int64 =
|
||||
args: varargs[string]): int64 =
|
||||
## executes the query (typically "UPDATE") and returns the
|
||||
## number of affected rows.
|
||||
var q = dbFormat(query, args)
|
||||
|
||||
@@ -49,7 +49,7 @@ proc dbQuote(s: string): string =
|
||||
else: add(result, c)
|
||||
add(result, '\'')
|
||||
|
||||
proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
|
||||
proc dbFormat(formatstr: TSqlQuery, args: varargs[string]): string =
|
||||
result = ""
|
||||
var a = 0
|
||||
for c in items(string(formatstr)):
|
||||
@@ -60,7 +60,7 @@ proc dbFormat(formatstr: TSqlQuery, args: openarray[string]): string =
|
||||
add(result, c)
|
||||
|
||||
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.
|
||||
var q = dbFormat(query, args)
|
||||
var stmt: sqlite3.PStmt
|
||||
@@ -68,7 +68,7 @@ proc TryExec*(db: TDbConn, query: TSqlQuery,
|
||||
if step(stmt) == SQLITE_DONE:
|
||||
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.
|
||||
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] = ""
|
||||
|
||||
proc setupQuery(db: TDbConn, query: TSqlQuery,
|
||||
args: openarray[string]): PStmt =
|
||||
args: varargs[string]): PStmt =
|
||||
var q = dbFormat(query, args)
|
||||
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)
|
||||
|
||||
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
|
||||
## fast, but potenially dangerous: If the for-loop-body executes another
|
||||
## 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)
|
||||
|
||||
proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||
args: openarray[string]): TRow =
|
||||
args: varargs[string]): TRow =
|
||||
## retrieves a single row.
|
||||
var stmt = setupQuery(db, query, args)
|
||||
var L = (columnCount(stmt))
|
||||
@@ -112,19 +112,19 @@ proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||
if finalize(stmt) != SQLITE_OK: dbError(db)
|
||||
|
||||
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.
|
||||
result = @[]
|
||||
for r in FastRows(db, query, args):
|
||||
result.add(r)
|
||||
|
||||
iterator Rows*(db: TDbConn, query: TSqlQuery,
|
||||
args: openarray[string]): TRow =
|
||||
args: varargs[string]): TRow =
|
||||
## same as `FastRows`, but slower and safe.
|
||||
for r in FastRows(db, query, args): yield r
|
||||
|
||||
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
|
||||
## of the first row. Returns "" if the dataset contains no rows.
|
||||
var stmt = setupQuery(db, query, args)
|
||||
@@ -136,7 +136,7 @@ proc GetValue*(db: TDbConn, query: TSqlQuery,
|
||||
result = ""
|
||||
|
||||
proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||
args: openarray[string]): int64 =
|
||||
args: varargs[string]): int64 =
|
||||
## executes the query (typically "INSERT") and returns the
|
||||
## generated ID for the row or -1 in case of an error.
|
||||
if tryExec(db, query, args):
|
||||
@@ -145,7 +145,7 @@ proc TryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||
result = -1
|
||||
|
||||
proc InsertID*(db: TDbConn, query: TSqlQuery,
|
||||
args: openArray[string]): int64 =
|
||||
args: varargs[string]): int64 =
|
||||
## executes the query (typically "INSERT") and returns the
|
||||
## generated ID for the row. For Postgre this adds
|
||||
## ``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)
|
||||
|
||||
proc ExecAffectedRows*(db: TDbConn, query: TSqlQuery,
|
||||
args: openArray[string]): int64 =
|
||||
args: varargs[string]): int64 =
|
||||
## executes the query (typically "UPDATE") and returns the
|
||||
## number of affected rows.
|
||||
Exec(db, query, args)
|
||||
|
||||
@@ -161,17 +161,6 @@ proc assign*(dest: var TIntSet, src: TIntSet) =
|
||||
|
||||
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.} =
|
||||
## iterates over any included element of `s`.
|
||||
var r = s.head
|
||||
@@ -190,6 +179,17 @@ iterator items*(s: TIntSet): int {.inline.} =
|
||||
inc(i)
|
||||
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:
|
||||
var x = initIntSet()
|
||||
x.incl(1)
|
||||
|
||||
@@ -108,7 +108,7 @@ proc assertReply(received: TaintedString, expected: string) =
|
||||
"Expected reply '$1' got: $2" % [
|
||||
expected, received.string])
|
||||
|
||||
proc assertReply(received: TaintedString, expected: openarray[string]) =
|
||||
proc assertReply(received: TaintedString, expected: varargs[string]) =
|
||||
for i in items(expected):
|
||||
if received.string.startsWith(i): return
|
||||
raise newException(EInvalidReply,
|
||||
|
||||
@@ -149,7 +149,7 @@ template multipleOp(k: TPegKind, localOpt: expr) =
|
||||
if result.len == 1:
|
||||
result = result.sons[0]
|
||||
|
||||
proc `/`*(a: openArray[TPeg]): TPeg {.
|
||||
proc `/`*(a: varargs[TPeg]): TPeg {.
|
||||
nosideEffect, rtl, extern: "npegsOrderedChoice".} =
|
||||
## constructs an ordered choice with the PEGs in `a`
|
||||
multipleOp(pkOrderedChoice, addChoice)
|
||||
@@ -166,7 +166,7 @@ proc addSequence(dest: var TPeg, elem: TPeg) =
|
||||
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".} =
|
||||
## constructs a sequence with all the PEGs from `a`
|
||||
multipleOp(pkSequence, addSequence)
|
||||
@@ -939,7 +939,7 @@ proc replace*(s: string, sub: TPeg, by = ""): string {.
|
||||
inc(i, x)
|
||||
add(result, substr(s, i))
|
||||
|
||||
proc parallelReplace*(s: string, subs: openArray[
|
||||
proc parallelReplace*(s: string, subs: varargs[
|
||||
tuple[pattern: TPeg, repl: string]]): string {.
|
||||
nosideEffect, rtl, extern: "npegs$1".} =
|
||||
## 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))
|
||||
|
||||
proc transformFile*(infile, outfile: string,
|
||||
subs: openArray[tuple[pattern: TPeg, repl: string]]) {.
|
||||
subs: varargs[tuple[pattern: TPeg, repl: string]]) {.
|
||||
rtl, extern: "npegs$1".} =
|
||||
## reads in the file `infile`, performs a parallel replacement (calls
|
||||
## `parallelReplace`) and writes back to `outfile`. Raises ``EIO`` if an
|
||||
|
||||
@@ -151,7 +151,7 @@ proc newStringTable*(mode: TStringTableMode): PStringTable {.
|
||||
result.counter = 0
|
||||
newSeq(result.data, startSize)
|
||||
|
||||
proc newStringTable*(keyValuePairs: openarray[string],
|
||||
proc newStringTable*(keyValuePairs: varargs[string],
|
||||
mode: TStringTableMode): PStringTable {.
|
||||
rtl, extern: "nst$1WithPairs".} =
|
||||
## 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]
|
||||
inc(i, 2)
|
||||
|
||||
proc newStringTable*(keyValuePairs: openarray[tuple[key, val: string]],
|
||||
proc newStringTable*(keyValuePairs: varargs[tuple[key, val: string]],
|
||||
mode: TStringTableMode = modeCaseSensitive): PStringTable {.
|
||||
rtl, extern: "nst$1WithTableConstr".} =
|
||||
## creates a new string table with given key value pairs.
|
||||
|
||||
@@ -1112,6 +1112,13 @@ proc `%` *(formatstr, a: string): string {.noSideEffect,
|
||||
## This is the same as ``formatstr % [a]``.
|
||||
result = newStringOfCap(formatstr.len + a.len)
|
||||
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.}
|
||||
|
||||
|
||||
@@ -141,13 +141,14 @@ proc low*[T](x: T): T {.magic: "Low", noSideEffect.}
|
||||
## semantic rule, `x` may also be a type identifier.
|
||||
|
||||
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
|
||||
## fixed-length arrays.
|
||||
openarray*{.magic: "OpenArray".}[T] ## Generic type to construct open arrays.
|
||||
## Open arrays are implemented as a
|
||||
## pointer to the array data and a
|
||||
## length field.
|
||||
varargs*{.magic: "Varargs".}[T] ## Generic type to construct a varargs type.
|
||||
seq*{.magic: "Seq".}[T] ## Generic type to construct sequences.
|
||||
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
|
||||
## 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: cstring): int {.magic: "LengthStr", 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.}
|
||||
## The minimum value of two integers.
|
||||
|
||||
proc min*[T](x: openarray[T]): T =
|
||||
## The minimum value of an openarray.
|
||||
proc min*[T](x: varargs[T]): T =
|
||||
## The minimum value of `x`.
|
||||
result = x[0]
|
||||
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.}
|
||||
## The maximum value of two integers.
|
||||
|
||||
proc max*[T](x: openarray[T]): T =
|
||||
## The maximum value of an openarray.
|
||||
proc max*[T](x: varargs[T]): T =
|
||||
## The maximum value of `x`.
|
||||
result = x[0]
|
||||
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 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
|
||||
## is converted to a string via ``$``, so it works for user-defined
|
||||
## 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, c: char)
|
||||
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.
|
||||
|
||||
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".
|
||||
## 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".
|
||||
## 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, 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)
|
||||
|
||||
proc readAllBuffer(file: TFile): string =
|
||||
@@ -150,7 +150,7 @@ proc writeln[Ty](f: TFile, x: Ty) =
|
||||
write(f, x)
|
||||
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)
|
||||
write(f, "\n")
|
||||
|
||||
|
||||
@@ -138,12 +138,12 @@ proc disp(target: TOutputTarget, xml, tex: string): string =
|
||||
else: result = tex
|
||||
|
||||
proc dispF(target: TOutputTarget, xml, tex: string,
|
||||
args: openArray[string]): string =
|
||||
args: varargs[string]): string =
|
||||
if target != outLatex: result = xml % args
|
||||
else: result = tex % args
|
||||
|
||||
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)
|
||||
else: addf(dest, tex, args)
|
||||
|
||||
@@ -241,12 +241,12 @@ proc mergeIndexes*(dir: string): string =
|
||||
var i = 0
|
||||
while i < L:
|
||||
result.addf("<dt><span>$1</span></dt><ul class=\"simple\"><dd>\n",
|
||||
a[i].keyword)
|
||||
[a[i].keyword])
|
||||
var j = i
|
||||
while j < L and a[i].keyword == a[j].keyword:
|
||||
result.addf(
|
||||
"<li><a class=\"reference external\" href=\"$1\">$1</a></li>\n",
|
||||
a[j].link)
|
||||
[a[j].link])
|
||||
inc j
|
||||
result.add("</ul></dd>\n")
|
||||
i = j
|
||||
@@ -352,7 +352,7 @@ proc renderCodeBlock(d: PDoc, n: PRstNode, result: var string) =
|
||||
else:
|
||||
lang = getSourceLanguage(langstr)
|
||||
|
||||
dispA(d.target, result, "<pre>", "\\begin{rstpre}\n")
|
||||
dispA(d.target, result, "<pre>", "\\begin{rstpre}\n", [])
|
||||
if lang == langNone:
|
||||
d.msgHandler(d.filename, 1, 0, mwUnsupportedLanguage, langstr)
|
||||
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:
|
||||
result = result.sons[0]
|
||||
|
||||
proc `/`*(a: openArray[TPeg]): TPeg {.
|
||||
proc `/`*(a: varargs[TPeg]): TPeg {.
|
||||
rtl, extern: "npegsOrderedChoice".} =
|
||||
## constructs an ordered choice with the PEGs in `a`
|
||||
multipleOp(pkOrderedChoice, addChoice)
|
||||
@@ -178,7 +178,7 @@ proc addSequence(dest: var TPeg, elem: TPeg) =
|
||||
else: add(dest, elem)
|
||||
else: add(dest, elem)
|
||||
|
||||
proc sequence*(a: openArray[TPeg]): TPeg {.
|
||||
proc sequence*(a: varargs[TPeg]): TPeg {.
|
||||
rtl, extern: "npegs$1".} =
|
||||
## constructs a sequence with all the PEGs from `a`
|
||||
multipleOp(pkSequence, addSequence)
|
||||
@@ -935,7 +935,7 @@ proc replace*(s: string, sub: TPeg, by = ""): string {.
|
||||
inc(i, x)
|
||||
add(result, substr(s, i))
|
||||
|
||||
proc parallelReplace*(s: string, subs: openArray[
|
||||
proc parallelReplace*(s: string, subs: varargs[
|
||||
tuple[pattern: TPeg, repl: string]]): string {.
|
||||
rtl, extern: "npegs$1".} =
|
||||
## 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))
|
||||
|
||||
proc transformFile*(infile, outfile: string,
|
||||
subs: openArray[tuple[pattern: TPeg, repl: string]]) {.
|
||||
subs: varargs[tuple[pattern: TPeg, repl: string]]) {.
|
||||
rtl, extern: "npegs$1".} =
|
||||
## reads in the file `infile`, performs a parallel replacement (calls
|
||||
## `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 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
|
||||
- ``bycopy`` pragma for imported C types
|
||||
- optimize genericAssign in the code generator
|
||||
|
||||
@@ -103,6 +103,7 @@ Changes affecting backwards compatibility
|
||||
for procs it remains ``nimcall`` (which is compatible to ``closure``).
|
||||
Activate the warning ``ImplicitClosure`` to make the compiler list the
|
||||
occurances of proc types which are affected.
|
||||
- The Nimrod type system now distinguishes ``openarray`` from ``varargs``.
|
||||
|
||||
|
||||
Compiler Additions
|
||||
|
||||
Reference in New Issue
Block a user