Merge branch 'devel' of https://github.com/Araq/Nimrod into devel

This commit is contained in:
Araq 2014-04-25 19:55:06 +02:00
commit 0049a2a388
19 changed files with 326 additions and 586 deletions

564
.gitignore vendored
View file

@ -1,36 +1,27 @@
*
!**/
!*.*
nimcache/
*.o *.o
!/icons/*.o
*.exe *.exe
*.so *.so
*.dylib
*.zip *.zip
*.iss *.iss
nimcache
lib/nimcache mapping.txt
tools/nimcache tags
tools/nimweb install.sh
tests/nimcache deinstall.sh
tests/accept/run/nimcache
tests/accept/compile/nimcache
tests/reject/nimcache
compiler/nimcache
compiler/c2nim/nimcache
compiler/pas2nim/nimcache
misc
doc/*.html doc/*.html
doc/*.pdf doc/*.pdf
doc/*.idx doc/*.idx
/web/upload /web/upload
koch build/*
compiler/nimrod* bin/*
build/[0-9]_[0-9]
bin/nimrod
examples/cross_calculator/nimrod_commandline/nimcalculator
examples/cross_todo/nimrod_backend/*.html
examples/cross_todo/nimrod_backend/backend
examples/cross_todo/nimrod_backend/testbackend
examples/cross_todo/nimrod_backend/todo.sqlite3
examples/cross_todo/nimrod_commandline/nimtodo
install.sh
deinstall.sh
# iOS specific wildcards. # iOS specific wildcards.
*.mode1v3 *.mode1v3
@ -42,534 +33,11 @@ deinstall.sh
project.xcworkspace/ project.xcworkspace/
xcuserdata/ xcuserdata/
# iOS specific absolute paths
examples/cross_calculator/ios/resources/ui/*.m
examples/cross_calculator/ios/tags
# Android specific absolute paths.
examples/cross_calculator/android/bin/
examples/cross_calculator/android/gen/
examples/cross_calculator/android/jni/backend-jni.h
examples/cross_calculator/android/libs/
examples/cross_calculator/android/local.properties
examples/cross_calculator/android/obj/
examples/cross_calculator/android/tags
# Generated files. # Generated files.
/compile.json /compile.json
/compiler/c2nim/c2nim
/compiler/nimrod.dot /compiler/nimrod.dot
/compiler/pas2nim/pas2nim
/compiler/service
/examples/allany
/examples/cairoex
/examples/cgiex
/examples/cgi/cgi_stacktrace
/examples/cgi/example
/examples/curlex
/examples/debugging
/examples/docstrings
/examples/filterex
/examples/fizzbuzz
/examples/gtk/ex1
/examples/gtk/ex2
/examples/gtk/ex3
/examples/gtk/ex4
/examples/gtk/ex5
/examples/gtk/ex6
/examples/gtk/ex7
/examples/gtk/ex8
/examples/gtk/ex9
/examples/hallo
/examples/htmlrefs
/examples/htmltitle
/examples/httpserver2
/examples/iupex1
/examples/keyval
/examples/keyval2
/examples/luaex
/examples/maximum
/examples/parsecfgex
/examples/pythonex
/examples/sdlex
/examples/statcsv
/examples/talk/dsl
/examples/talk/formatoptimizer
/examples/talk/hoisting
/examples/talk/lazyeval
/examples/talk/quasiquote
/examples/talk/tags
/examples/tclex
/examples/transff
/examples/tunit
/examples/wingui
/examples/x11ex
/lib/libnimrtl.dylib
/lib/libserver.dylib
/lib/packages/docutils/highlite
/lib/pure/actors
/lib/pure/algorithm
/lib/pure/asyncio
/lib/pure/base64
/lib/pure/basic2d
/lib/pure/basic3d
/lib/pure/browsers
/lib/pure/cgi
/lib/pure/collections/sequtils
/lib/pure/collections/tables
/lib/pure/colors
/lib/pure/complex
/lib/pure/cookies
/lib/pure/dynlib
/lib/pure/encodings
/lib/pure/endians
/lib/pure/events
/lib/pure/fsmonitor
/lib/pure/ftpclient
/lib/pure/gentabs
/lib/pure/hashes
/lib/pure/htmlgen
/lib/pure/htmlparser
/lib/pure/httpclient
/lib/pure/httpserver
/lib/pure/irc
/lib/pure/json
/lib/pure/lexbase
/lib/pure/lib/
/lib/pure/marshal
/lib/pure/matchers
/lib/pure/math
/lib/pure/md5
/lib/pure/memfiles
/lib/pure/mersenne
/lib/pure/mimetypes
/lib/pure/nimprof
/lib/pure/numeric
/lib/pure/oids
/lib/pure/os
/lib/pure/osproc
/lib/pure/parsecfg
/lib/pure/parsecsv
/lib/pure/parseopt
/lib/pure/parseopt2
/lib/pure/parsesql
/lib/pure/parseurl
/lib/pure/parseutils
/lib/pure/parsexml
/lib/pure/pegs
/lib/pure/poly
/lib/pure/redis
/lib/pure/romans
/lib/pure/ropes
/lib/pure/scgi
/lib/pure/smtp
/lib/pure/sockets
/lib/pure/streams
/lib/pure/strtabs
/lib/pure/strutils
/lib/pure/subexes
/lib/pure/terminal
/lib/pure/times
/lib/pure/typetraits
/lib/pure/unicode
/lib/pure/unittest
/lib/pure/uri
/lib/pure/xmldom
/lib/pure/xmldomparser
/lib/pure/xmlparser
/lib/pure/xmltree
/lib/system/sysio
/lib/weird
/lib/wrappers/gtk/gtk2
/reject.json /reject.json
/run.json /run.json
/testresults.html /testresults.html
/testresults.json /testresults.json
/tests/caas/absurd_nesting testament.db
/tests/caas/completion_dot_syntax_main
/tests/caasdriver
/tests/caas/forward_declarations
/tests/caas/idetools_api
/tests/caas/imported
/tests/caas/issue_416_template_shift
/tests/caas/issue_452_export_shift
/tests/caas/issue_477_dynamic_dispatch
/tests/caas/its_full_of_procs
/tests/caas/main
/tests/caas/SymbolProcRun.*/
/tests/ccg/tmissingbracket
/tests/compile/talias
/tests/compile/tambsym2
/tests/compile/tarrindx
/tests/compile/tassign
/tests/compile/tbindoverload
/tests/compile/tcan_alias_generic
/tests/compile/tcan_alias_specialised_generic
/tests/compile/tcan_inherit_generic
/tests/compile/tcan_specialise_generic
/tests/compile/tccgen1
/tests/compile/tclosure4
/tests/compile/tclosurebug2
/tests/compile/tcmdline
/tests/compile/tcodegenbug1
/tests/compile/tcolonisproc
/tests/compile/tcolors
/tests/compile/tcommontype
/tests/compile/tcompiles
/tests/compile/tcomputedgoto
/tests/compile/tconsteval
/tests/compile/tconstraints
/tests/compile/tconvcolors
/tests/compile/tcputime
/tests/compile/tdefaultprocparam
/tests/compile/tdictdestruct
/tests/compile/tdiscardable
/tests/compile/tdllvar
/tests/compile/tdumpast
/tests/compile/tdumpast2
/tests/compile/techo
/tests/compile/teffects1
/tests/compile/temptyecho
/tests/compile/tendian
/tests/compile/tenum
/tests/compile/tenum2
/tests/compile/tenum3
/tests/compile/teval1
/tests/compile/texport
/tests/compile/tfib
/tests/compile/tforwardgeneric
/tests/compile/tforwty
/tests/compile/tforwty2
/tests/compile/tgeneric
/tests/compile/tgeneric2
/tests/compile/tgeneric3
/tests/compile/tgeneric4
/tests/compile/tgenericmatcher
/tests/compile/tgenericmatcher2
/tests/compile/tgenericprocvar
/tests/compile/tgenericprop
/tests/compile/tgenericrefs
/tests/compile/tgenerictmpl
/tests/compile/tgenericvariant
/tests/compile/tgensymgeneric
/tests/compile/tgetstartmilsecs
/tests/compile/tglobalforvar
/tests/compile/thallo
/tests/compile/theaproots
/tests/compile/thexrange
/tests/compile/thygienictempl
/tests/compile/tident
/tests/compile/timplicititems
/tests/compile/timplictderef
/tests/compile/tinheritref
/tests/compile/tio
/tests/compile/tircbot
/tests/compile/titer
/tests/compile/titer2
/tests/compile/titer_no_tuple_unpack
/tests/compile/titerovl
/tests/compile/tlastmod
/tests/compile/tlinearscanend
/tests/compile/tloops
/tests/compile/tmacro1
/tests/compile/tmacro2
/tests/compile/tmacroaspragma
/tests/compile/tmacrostmt
/tests/compile/tmandelbrot
/tests/compile/tmarshal
/tests/compile/tmath
/tests/compile/tmatrix1
/tests/compile/tmatrix2
/tests/compile/tmongo
/tests/compile/tnamedparamanonproc
/tests/compile/tnamedparams
/tests/compile/tnestedproc
/tests/compile/tnew
/tests/compile/tnewsets
/tests/compile/tnewuns
/tests/compile/tnoargopenarray
/tests/compile/tnoforward
/tests/compile/tobjconstr2
/tests/compile/tobjcov
/tests/compile/tobject2
/tests/compile/tobject3
/tests/compile/tobjects
/tests/compile/toop
/tests/compile/toptions
/tests/compile/tos
/tests/compile/toverprc
/tests/compile/tparedef
/tests/compile/tparscfg
/tests/compile/tparsefloat
/tests/compile/tparsopt
/tests/compile/tposix
/tests/compile/tprep
/tests/compile/tprocvars
/tests/compile/tpush
/tests/compile/tquicksort
/tests/compile/tquit
/tests/compile/tradix
/tests/compile/treadln
/tests/compile/treadx
/tests/compile/trecmod
/tests/compile/trecmod2
/tests/compile/trectuple
/tests/compile/trectuples
/tests/compile/tredef
/tests/compile/trepr
/tests/compile/tsecondarrayproperty
/tests/compile/tseq2
/tests/compile/tseqcon2
/tests/compile/tshadow_magic_type
/tests/compile/tsizeof
/tests/compile/tslurp
/tests/compile/tsockets
/tests/compile/tsortcall
/tests/compile/tspecialised_is_equivalent
/tests/compile/tstrace
/tests/compile/tstrdesc
/tests/compile/tstrdist
/tests/compile/tstreams
/tests/compile/tstrset
/tests/compile/tstrtabs
/tests/compile/ttableconstr
/tests/compile/ttempl
/tests/compile/ttempl3
/tests/compile/ttempl4
/tests/compile/ttempl5
/tests/compile/ttemplreturntype
/tests/compile/tthread_generic
/tests/compile/ttime
/tests/compile/ttuple1
/tests/compile/ttypeclasses
/tests/compile/ttypeconverter1
/tests/compile/tuserpragma
/tests/compile/tvoid
/tests/compile/twalker
/tests/compile/typalias
/tests/dll/client
/tests/gc/closureleak
/tests/gc/cycleleak
/tests/gc/gcbench
/tests/gc/gcleak
/tests/gc/gcleak2
/tests/gc/gcleak3
/tests/gc/gctest
/tests/gc/weakrefs
/tests/manyloc/argument_parser/ex_wget
/tests/manyloc/nake/nakefile
/tests/manyloc/packages/noconflicts
/tests/manyloc/standalone/barebone
/tests/patterns/targlist
/tests/patterns/tcse
/tests/patterns/thoist
/tests/patterns/tmatrix
/tests/patterns/tnoalias
/tests/patterns/tnoendlessrec
/tests/patterns/tor
/tests/patterns/tpartial
/tests/patterns/tstar
/tests/patterns/tstmtlist
/tests/reject/t99bott
/tests/reject/tcheckedfield1
/tests/reject/tdeprecated
/tests/reject/tdisallowif
/tests/reject/tuninit1
/tests/rodfiles/aconv
/tests/rodfiles/bconv
/tests/rodfiles/bmethods
/tests/rodfiles/bmethods2
/tests/rodfiles/deada
/tests/rodfiles/deada2
/tests/rodfiles/hallo
/tests/rodfiles/hallo2
/tests/rodfiles/tgeneric1
/tests/rodfiles/tgeneric2
/tests/run/tack
/tests/run/tactiontable
/tests/run/tambsym2
/tests/run/tambsys
/tests/run/tanontuples
/tests/run/tarray
/tests/run/tarray2
/tests/run/tarray3
/tests/run/tarraycons
/tests/run/tassert
/tests/run/tastoverload1
/tests/run/tasynciossl
/tests/run/tasyncudp
/tests/run/tbind1
/tests/run/tbind3
/tests/run/tbintre2
/tests/run/tbintree
/tests/run/tborrow
/tests/run/tbug499771
/tests/run/tbug511622
/tests/run/tcase_setconstr
/tests/run/tcasestm
/tests/run/tcgbug
/tests/run/tclosure2
/tests/run/tclosure3
/tests/run/tcnstseq
/tests/run/tcnstseq2
/tests/run/tcnstseq3
/tests/run/tconcat
/tests/run/tconstr2
/tests/run/tcontinue
/tests/run/tcontinuexc
/tests/run/tcopy
/tests/run/tcountup
/tests/run/tcritbits
/tests/run/tcurrncy
/tests/run/tdestructor
/tests/run/tdrdobbs_examples
/tests/run/temit
/tests/run/tenumhole
/tests/run/tenumitems
/tests/run/teventemitter
/tests/run/tevents
/tests/run/texceptions
/tests/run/texcpt1
/tests/run/texcsub
/tests/run/texplicitgeneric1
/tests/run/tfieldindex
/tests/run/tfielditerator
/tests/run/tfielditerator2
/tests/run/tfilter
/tests/run/tfinally
/tests/run/tfinally2
/tests/run/tfinally3
/tests/run/tfinalobj
/tests/run/tfloat1
/tests/run/tfloat2
/tests/run/tfloat3
/tests/run/tformat
/tests/run/tfriends
/tests/run/tgenericassign
/tests/run/tgenericassigntuples
/tests/run/tgenericconverter
/tests/run/tgenericprocvar
/tests/run/tgenerics1
/tests/run/tgensym
/tests/run/tglobal
/tests/run/thashes
/tests/run/thexlit
/tests/run/thintoff
/tests/run/tidgen
/tests/run/tindent1
/tests/run/tinit
/tests/run/tinterf
/tests/run/tints
/tests/run/tisopr
/tests/run/titer3
/tests/run/titer5
/tests/run/titer6
/tests/run/titer7
/tests/run/titer8
/tests/run/titer9
/tests/run/titerslice
/tests/run/titervaropenarray
/tests/run/tkoeniglookup
/tests/run/tlet
/tests/run/tlists
/tests/run/tlocals
/tests/run/tlowhigh
/tests/run/tmacro2
/tests/run/tmacro3
/tests/run/tmacro4
/tests/run/tmacros1
/tests/run/tmath
/tests/run/tmatrix
/tests/run/tmemoization
/tests/run/tmethods1
/tests/run/tmixin
/tests/run/tmoditer
/tests/run/tmultim1
/tests/run/tmultim2
/tests/run/tmultim3
/tests/run/tmultim4
/tests/run/tmultim6
/tests/run/tnamedenumfields
/tests/run/tnestif
/tests/run/tnestprc
/tests/run/tnewderef
/tests/run/tnodeadlocks
/tests/run/tobjasgn
/tests/run/tobjconstr
/tests/run/tobject
/tests/run/tofopr
/tests/run/tonraise
/tests/run/toop1
/tests/run/topenarrayrepr
/tests/run/topenlen
/tests/run/toprprec
/tests/run/toverflw
/tests/run/toverflw2
/tests/run/toverl2
/tests/run/toverl3
/tests/run/toverwr
/tests/run/tovfint
/tests/run/tpatterns
/tests/run/tpegs
/tests/run/tpos
/tests/run/tprecedence
/tests/run/tprintf
/tests/run/tprocvar
/tests/run/tquotewords
/tests/run/tregex
/tests/run/treguse
/tests/run/trepr
/tests/run/treraise
/tests/run/tromans
/tests/run/tseqcon
/tests/run/tseqtuple
/tests/run/tsequtils
/tests/run/tsets
/tests/run/tsets2
/tests/run/tsidee2
/tests/run/tsidee3
/tests/run/tsimmeth
/tests/run/tsimplesort
/tests/run/tslices
/tests/run/tsortdev
/tests/run/tsplit
/tests/run/tstempl
/tests/run/tstmtexprs
/tests/run/tstrange
/tests/run/tstringinterp
/tests/run/tstrlits
/tests/run/tstrutil
/tests/run/tsubrange
/tests/run/tsubrange2
/tests/run/ttables
/tests/run/ttables2
/tests/run/ttoseq
/tests/run/ttypedesc1
/tests/run/tunhandledexc
/tests/run/tunidecode
/tests/run/tunittests
/tests/run/tuserassert
/tests/run/tvarargs_vs_generic
/tests/run/tvardecl
/tests/run/tvariantasgn
/tests/run/tvariantstack
/tests/run/tvarious1
/tests/run/tvarnums
/tests/run/tvarres1
/tests/run/tvarres2
/tests/run/tvartup
/tests/run/tvtable
/tests/run/twrongexc
/tests/run/txmlgen
/tests/run/txmltree
/tests/run/tzeroarray
/tests/system/helpers/readall_echo
/tests/system/io
/tests/system/params
/tests/tester
/tests/threads/tactors
/tests/threads/tactors2
/tests/threads/tthreadanalysis2
/tests/threads/tthreadanalysis3
/tests/threads/tthreadheapviolation1
/tools/nimgrep

View file

@ -50,11 +50,33 @@ proc writeAdvancedUsage(pass: TCmdLinePass) =
CPU[platform.hostCPU].name]) & AdvancedUsage) CPU[platform.hostCPU].name]) & AdvancedUsage)
quit(0) quit(0)
template bootSwitch(name, expr, userString: expr): expr =
# Helper to build boot constants, for debugging you can 'echo' the else part.
const name = if expr: " " & userString else: ""
bootSwitch(usedAvoidTimeMachine, noTimeMachine, "-d:avoidTimeMachine")
bootSwitch(usedRelease, defined(release), "-d:release")
bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc")
bootSwitch(usedGnuReadline, defined(useGnuReadline), "-d:useGnuReadline")
bootSwitch(usedNativeStacktrace,
defined(nativeStackTrace) and nativeStackTraceSupported,
"-d:nativeStackTrace")
bootSwitch(usedNoCaas, defined(noCaas), "-d:noCaas")
bootSwitch(usedFFI, hasFFI, "-d:useFFI")
bootSwitch(usedBoehm, defined(boehmgc), "--gc:boehm")
bootSwitch(usedMarkAndSweep, defined(gcmarkandsweep), "--gc:markAndSweep")
bootSwitch(usedGenerational, defined(gcgenerational), "--gc:generational")
bootSwitch(usedNoGC, defined(nogc), "--gc:none")
proc writeVersionInfo(pass: TCmdLinePass) = proc writeVersionInfo(pass: TCmdLinePass) =
if pass == passCmd1: if pass == passCmd1:
msgWriteln(`%`(HelpMessage, [VersionAsString, msgWriteln(`%`(HelpMessage, [VersionAsString,
platform.OS[platform.hostOS].name, platform.OS[platform.hostOS].name,
CPU[platform.hostCPU].name])) CPU[platform.hostCPU].name]))
msgWriteln("active boot switches:" & usedRelease & usedAvoidTimeMachine &
usedTinyC & usedGnuReadline & usedNativeStacktrace & usedNoCaas &
usedFFI & usedBoehm & usedMarkAndSweep & usedGenerational & usedNoGC)
quit(0) quit(0)
var var

View file

@ -12,10 +12,9 @@
const const
MaxSetElements* = 1 shl 16 # (2^16) to support unicode character sets? MaxSetElements* = 1 shl 16 # (2^16) to support unicode character sets?
defaultAsmMarkerSymbol* = '!'
VersionMajor* = 0 VersionMajor* = 0
VersionMinor* = 9 VersionMinor* = 9
VersionPatch* = 4 VersionPatch* = 5
VersionAsString* = $VersionMajor & "." & $VersionMinor & "." & $VersionPatch VersionAsString* = $VersionMajor & "." & $VersionMinor & "." & $VersionPatch
RodFileVersion* = "1215" # modify this if the rod-format changes! RodFileVersion* = "1215" # modify this if the rod-format changes!

View file

@ -16,7 +16,7 @@ const
hasFFI* = defined(useFFI) hasFFI* = defined(useFFI)
newScopeForIf* = true newScopeForIf* = true
useCaas* = not defined(noCaas) useCaas* = not defined(noCaas)
noTimeMachine = defined(avoidTimeMachine) and defined(macosx) noTimeMachine* = defined(avoidTimeMachine) and defined(macosx)
type # please make sure we have under 32 options type # please make sure we have under 32 options
# (improves code efficiency a lot!) # (improves code efficiency a lot!)

View file

@ -5688,7 +5688,7 @@ Spawn
Nimrod has a builtin thread pool that can be used for CPU intensive tasks. For Nimrod has a builtin thread pool that can be used for CPU intensive tasks. For
IO intensive tasks the upcoming ``async`` and ``await`` features should be IO intensive tasks the upcoming ``async`` and ``await`` features should be
used. `spawn`:idx: is used to pass a task to the thread pool: used instead. `spawn`:idx: is used to pass a task to the thread pool:
.. code-block:: nimrod .. code-block:: nimrod
proc processLine(line: string) = proc processLine(line: string) =

12
examples/cross_calculator/.gitignore vendored Normal file
View file

@ -0,0 +1,12 @@
# Android specific absolute paths.
android/bin/
android/gen/
android/jni/backend-jni.h
android/libs/
android/local.properties
android/obj/
android/tags
# iOS specific absolute paths
ios/resources/ui/*.m
ios/tags

View file

@ -299,7 +299,7 @@ of cmdArgument:
of "boot": boot(op.cmdLineRest) of "boot": boot(op.cmdLineRest)
of "clean": clean(op.cmdLineRest) of "clean": clean(op.cmdLineRest)
of "web": web(op.cmdLineRest) of "web": web(op.cmdLineRest)
of "csource": csource(op.cmdLineRest) of "csource", "csources": csource(op.cmdLineRest)
of "zip": zip(op.cmdLineRest) of "zip": zip(op.cmdLineRest)
of "inno": inno(op.cmdLineRest) of "inno": inno(op.cmdLineRest)
of "install": install(op.cmdLineRest) of "install": install(op.cmdLineRest)

View file

@ -10,6 +10,47 @@
## The ``tables`` module implements an efficient hash table that is ## The ``tables`` module implements an efficient hash table that is
## a mapping from keys to values. ## a mapping from keys to values.
## ##
## If you are using simple standard types like ``int`` or ``string`` for the
## keys of the table you won't have any problems, but as soon as you try to use
## a more complex object as a key you will be greeted by a strange compiler
## error::
##
## Error: type mismatch: got (Person)
## but expected one of:
## hashes.hash(x: openarray[A]): THash
## hashes.hash(x: int): THash
## hashes.hash(x: float): THash
## …
##
## What is happening here is that the types used for table keys require to have
## a ``hash()`` proc which will convert them to a `THash <hashes.html#THash>`_
## value, and the compiler is listing all the hash functions it knows. After
## you add such a proc for your custom type everything will work. See this
## example:
##
## .. code-block:: nimrod
## type
## Person = object
## firstName, lastName: string
##
## proc hash(x: Person): THash =
## ## Piggyback on the already available string hash proc.
## ##
## ## Without this proc nothing works!
## result = hash(x.firstName & x.lastName)
##
## var
## salaries = initTable[Person, int]()
## p1, p2: Person
##
## p1.firstName = "Jon"
## p1.lastName = "Ross"
## salaries[p1] = 30_000
##
## p2.firstName = "소진"
## p2.lastName = "박"
## salaries[p2] = 45_000
##
## **Note:** The data types declared here have *value semantics*: This means ## **Note:** The data types declared here have *value semantics*: This means
## that ``=`` performs a copy of the hash table. ## that ``=`` performs a copy of the hash table.
@ -526,3 +567,30 @@ proc sort*[A](t: var TCountTable[A]) =
if j < h: break if j < h: break
if h == 1: break if h == 1: break
when isMainModule:
type
Person = object
firstName, lastName: string
proc hash(x: Person): THash =
## Piggyback on the already available string hash proc.
##
## Without this proc nothing works!
result = hash(x.firstName & x.lastName)
var
salaries = initTable[Person, int]()
p1, p2: Person
p1.firstName = "Jon"
p1.lastName = "Ross"
salaries[p1] = 30_000
p2.firstName = "소진"
p2.lastName = "박"
salaries[p2] = 45_000
var
s2 = initOrderedTable[Person, int]()
s3 = initCountTable[Person]()
s2[p1] = 30_000
s2[p2] = 45_000
s3[p1] = 30_000
s3[p2] = 45_000

View file

@ -1,7 +1,7 @@
# #
# #
# Nimrod's Runtime Library # Nimrod's Runtime Library
# (c) Copyright 2012 Andreas Rumpf # (c) Copyright 2014 Andreas Rumpf
# #
# See the file "copying.txt", included in this # See the file "copying.txt", included in this
# distribution, for details about the copyright. # distribution, for details about the copyright.
@ -1612,6 +1612,20 @@ when defined(linux) or defined(solaris) or defined(bsd) or defined(aix):
len = readlink(procPath, result, len) len = readlink(procPath, result, len)
setLen(result, len) setLen(result, len)
when not (defined(windows) or defined(macosx)):
proc getApplHeuristic(): string =
when defined(paramStr):
result = string(paramStr(0))
# POSIX guaranties that this contains the executable
# as it has been executed by the calling process
if len(result) > 0 and result[0] != DirSep: # not an absolute path?
# iterate over any path in the $PATH environment variable
for p in split(string(getEnv("PATH")), {PathSep}):
var x = joinPath(p, result)
if existsFile(x): return x
else:
result = ""
when defined(macosx): when defined(macosx):
type type
cuint32* {.importc: "unsigned int", nodecl.} = int cuint32* {.importc: "unsigned int", nodecl.} = int
@ -1648,10 +1662,13 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [FReadIO].} =
setlen(result, int(len)) setlen(result, int(len))
elif defined(linux) or defined(aix): elif defined(linux) or defined(aix):
result = getApplAux("/proc/self/exe") result = getApplAux("/proc/self/exe")
if result.len == 0: result = getApplHeuristic()
elif defined(solaris): elif defined(solaris):
result = getApplAux("/proc/" & $getpid() & "/path/a.out") result = getApplAux("/proc/" & $getpid() & "/path/a.out")
if result.len == 0: result = getApplHeuristic()
elif defined(freebsd): elif defined(freebsd):
result = getApplAux("/proc/" & $getpid() & "/file") result = getApplAux("/proc/" & $getpid() & "/file")
if result.len == 0: result = getApplHeuristic()
elif defined(macosx): elif defined(macosx):
var size: cuint32 var size: cuint32
getExecPath1(nil, size) getExecPath1(nil, size)
@ -1663,15 +1680,7 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [FReadIO].} =
else: else:
# little heuristic that may work on other POSIX-like systems: # little heuristic that may work on other POSIX-like systems:
result = string(getEnv("_")) result = string(getEnv("_"))
if len(result) == 0: if result.len == 0: result = getApplHeuristic()
result = string(paramStr(0))
# POSIX guaranties that this contains the executable
# as it has been executed by the calling process
if len(result) > 0 and result[0] != DirSep: # not an absolute path?
# iterate over any path in the $PATH environment variable
for p in split(string(getEnv("PATH")), {PathSep}):
var x = joinPath(p, result)
if existsFile(x): return x
proc getApplicationFilename*(): string {.rtl, extern: "nos$1", deprecated.} = proc getApplicationFilename*(): string {.rtl, extern: "nos$1", deprecated.} =
## Returns the filename of the application's executable. ## Returns the filename of the application's executable.

View file

@ -234,6 +234,11 @@ template `>` * (x, y: expr): expr {.immediate.} =
## "is greater" operator. This is the same as ``y < x``. ## "is greater" operator. This is the same as ``y < x``.
y < x y < x
const
appType* {.magic: "AppType"}: string = ""
## a string that describes the application type. Possible values:
## "console", "gui", "lib".
include "system/inclrtl" include "system/inclrtl"
const NoFakeVars* = defined(NimrodVM) ## true if the backend doesn't support \ const NoFakeVars* = defined(NimrodVM) ## true if the backend doesn't support \
@ -940,10 +945,6 @@ const
## a string that describes the host CPU. Possible values: ## a string that describes the host CPU. Possible values:
## "i386", "alpha", "powerpc", "sparc", "amd64", "mips", "arm". ## "i386", "alpha", "powerpc", "sparc", "amd64", "mips", "arm".
appType* {.magic: "AppType"}: string = ""
## a string that describes the application type. Possible values:
## "console", "gui", "lib".
seqShallowFlag = low(int) seqShallowFlag = low(int)
proc compileOption*(option: string): bool {. proc compileOption*(option: string): bool {.

View file

@ -77,7 +77,7 @@ proc popCurrentException {.compilerRtl, inl.} =
# some platforms have native support for stack traces: # some platforms have native support for stack traces:
const const
nativeStackTraceSupported = (defined(macosx) or defined(linux)) and nativeStackTraceSupported* = (defined(macosx) or defined(linux)) and
not nimrodStackTrace not nimrodStackTrace
hasSomeStackTrace = nimrodStackTrace or hasSomeStackTrace = nimrodStackTrace or
defined(nativeStackTrace) and nativeStackTraceSupported defined(nativeStackTrace) and nativeStackTraceSupported

View file

@ -1,7 +1,7 @@
# #
# #
# Nimrod's Runtime Library # Nimrod's Runtime Library
# (c) Copyright 2013 Andreas Rumpf # (c) Copyright 2014 Andreas Rumpf
# #
# See the file "copying.txt", included in this # See the file "copying.txt", included in this
# distribution, for details about the copyright. # distribution, for details about the copyright.

View file

@ -106,15 +106,15 @@ type
Pstmt* = ptr Tstmt Pstmt* = ptr Tstmt
Tvalue{.pure, final.} = object Tvalue{.pure, final.} = object
Pvalue* = ptr Tvalue Pvalue* = ptr Tvalue
PPValue* = ptr Pvalue PValueArg* = array[0..127, Pvalue]
Tcallback* = proc (para1: pointer, para2: int32, para3, Tcallback* = proc (para1: pointer, para2: int32, para3,
para4: cstringArray): int32{.cdecl.} para4: cstringArray): int32{.cdecl.}
Tbind_destructor_func* = proc (para1: pointer){.cdecl.} Tbind_destructor_func* = proc (para1: pointer){.cdecl.}
Tcreate_function_step_func* = proc (para1: Pcontext, para2: int32, Tcreate_function_step_func* = proc (para1: Pcontext, para2: int32,
para3: PPValue){.cdecl.} para3: PValueArg){.cdecl.}
Tcreate_function_func_func* = proc (para1: Pcontext, para2: int32, Tcreate_function_func_func* = proc (para1: Pcontext, para2: int32,
para3: PPValue){.cdecl.} para3: PValueArg){.cdecl.}
Tcreate_function_final_func* = proc (para1: Pcontext){.cdecl.} Tcreate_function_final_func* = proc (para1: Pcontext){.cdecl.}
Tresult_func* = proc (para1: pointer){.cdecl.} Tresult_func* = proc (para1: pointer){.cdecl.}
Tcreate_collation_func* = proc (para1: pointer, para2: int32, para3: pointer, Tcreate_collation_func* = proc (para1: pointer, para2: int32, para3: pointer,

View file

@ -0,0 +1,29 @@
discard """
output: '''4
8'''
cmd: "nimrod $target --threads:on $options $file"
"""
var
x, y = 0
proc p1 =
for i in 0 .. 1_000_000:
discard
inc x
proc p2 =
for i in 0 .. 1_000_000:
discard
inc y, 2
for i in 0.. 3:
spawn(p1())
spawn(p2())
sync()
echo x
echo y

View file

@ -71,7 +71,7 @@
</div> </div>
<!-- site_foot --> <!-- site_foot -->
<div id="site_foot"> <div id="site_foot">
<div id="legal">Copyright &copy; 2013 - Andreas Rumpf &amp; Contributors - All rights reserved - <a href="http://reign-studios.com/philipwitte/">Design by Philip Witte</a></div> <div id="legal">Copyright &copy; 2014 - Andreas Rumpf &amp; Contributors - All rights reserved - <a href="http://reign-studios.com/philipwitte/">Design by Philip Witte</a></div>
</div> </div>
</div> </div>
<script> <script>

View file

@ -1,7 +1,130 @@
You can download the latest version of the Nimrod compiler here. You can
use the binaries provided or build from source.
Binaries
========
All installers and archives contain the html documentation and tools
(nimgrep, c2nim and babel).
**Note:** The Nimrod compiler requires a C compiler to compile software. On
Windows we recommend that you use
`Mingw-w64 <http://mingw-w64.sourceforge.net/>`_. GCC is recommended on Linux
and clang on Mac OS X.
Installers
----------
The "full" version includes a full mingw distribution which includes a C
compiler. The "slim" version lacks this.
* Full (i386, 32bit): `<download/nimrod_0.9.4_windows_i386_full.exe>`_
.. raw:: html
<p style="font-size: 8pt; margin-top: 0;">
SHA256: dca7c63d0c1861d2d7c51b2e7a29fa98371750a10ab282d5df9de22a07719c24
</p>
* Slim (i386, 32bit): `<download/nimrod_0.9.4_windows_i386_slim.exe>`_
.. raw:: html
<p style="font-size: 8pt; margin-top: 0;">
SHA256: c0fcd1201bd20fad1e14b9d2cc2529494057068de1dd01f871cf129f088a8242
</p>
* Full (amd64, 64bit): `<download/nimrod_0.9.4_windows_amd64_full.exe>`_
.. raw:: html
<p style="font-size: 8pt; margin-top: 0;">
SHA256: af9d478c2f3361e0f238fcb07fa8e7ae5821938c0f9063c6670e925c9ae9d16e
</p>
* Slim (amd64, 64bit): `<download/nimrod_0.9.4_windows_amd64_slim.exe>`_
.. raw:: html
<p style="font-size: 8pt; margin-top: 0;">
SHA256: 90c380721a46be2b9b8d5437187f701940aefc2e1fb9722dbc543f5c5a3bb85e
</p>
Archives
--------
Windows
~~~~~~~
The "full" version includes a full mingw distribution which includes a C
compiler. The "slim" version lacks this.
* Full (i386, 32bit): `<download/nimrod_0.9.4_windows_i386_full.zip>`_
.. raw:: html
<p style="font-size: 8pt; margin-top: 0;">
SHA256: 8ee18faaa3a3d5df482c7abd6aa7ea87a350d7328b80ce1e2d486b59a7a93956
</p>
* Slim (i386, 32bit): `<download/nimrod_0.9.4_windows_i386_slim.zip>`_
.. raw:: html
<p style="font-size: 8pt; margin-top: 0;">
SHA256: 7024fb8ad8f98c0bd4949ae36ed11b52b4e401754bbd62a11199d6dc8628d857
</p>
* Full (amd64, 64bit): `<download/nimrod_0.9.4_windows_amd64_full.zip>`_
.. raw:: html
<p style="font-size: 8pt; margin-top: 0;">
SHA256: cb33cacc1a84fec771323d24cb6d9795f4803882466a9f417b424990aa49e18a
</p>
* Slim (amd64, 64bit): `<download/nimrod_0.9.4_windows_amd64_slim.zip>`_
.. raw:: html
<p style="font-size: 8pt; margin-top: 0;">
SHA256: fcf877e4bd1ebfa214749af6e4811cd8539af19f1d7b23017e4bd7f6cbfb3eba
</p>
Linux
~~~~~
* Linux (i386, 32bit): `<download/nimrod_0.9.4_linux_i386.tar.gz>`_
.. raw:: html
<p style="font-size: 8pt; margin-top: 0;">
SHA256: 79DD337A77AC4313A75F2C5EED8252F00BBBDEB1E0C3504660D4A52EA63DBA92
</p>
* Linux (amd64, 64bit): `<download/nimrod_0.9.4_linux_amd64.tar.gz>`_
.. raw:: html
<p style="font-size: 8pt; margin-top: 0;">
SHA256: 6F6CB3C727BA8059B7605C02942AE7910C20C2A3DC6A8A600D90D50FE61F0D8C
</p>
* Linux (ppc64, 64bit): `<download/nimrod_0.9.4_linux_ppc64.tar.gz>`_
.. raw:: html
<p style="font-size: 8pt; margin-top: 0;">
SHA256: 5DAC2D9F7F545929E04540E6E2594C68FC3126A3B2F7B1FA7DBA5E295B4A7D31
</p>
Mac OS X
~~~~~~~~
* Mac OS X (amd64, 64bit): `<download/nimrod_0.9.4_macosx_amd64.zip>`_
.. raw:: html
<p style="font-size: 8pt; margin-top: 0;">
SHA256: E6F3A8E434DF3E89686F043954C6DFC09ABEBC0FC09D3B9A6B35C2B3102F7C3C
</p>
If a binary for your platform is not available then you must build from source.
Bleeding edge binaries are available from the `Nimrod build farm <http://build.nimrod-lang.org/>`_.
Source
======
Starting with 0.9.4 we now advise people to build directly from the Starting with 0.9.4 we now advise people to build directly from the
github `master <https://github.com/Araq/Nimrod#compiling>`_ branch:: github `master <https://github.com/Araq/Nimrod#compiling>`_ branch::
git clone git://github.com/Araq/Nimrod.git git clone -b master git://github.com/Araq/Nimrod.git
cd Nimrod cd Nimrod
git clone --depth 1 git://github.com/nimrod-code/csources git clone --depth 1 git://github.com/nimrod-code/csources
cd csources && sh build.sh cd csources && sh build.sh
@ -9,4 +132,7 @@ github `master <https://github.com/Araq/Nimrod#compiling>`_ branch::
bin/nimrod c koch bin/nimrod c koch
./koch boot -d:release ./koch boot -d:release
Prebuilt binaries will be available soon. The ``master`` branch always contains the latest stable version of the compiler.
If you want bleeding edge then switch to the ``devel`` branch and follow
the same instructions outlined above.

View file

@ -90,7 +90,9 @@ Nimrod plays nice with others
interfacing.** interfacing.**
* There are lots of bindings: for example, bindings to GTK2, the Windows API, * There are lots of bindings: for example, bindings to GTK2, the Windows API,
the POSIX API, OpenGL, SDL, Cairo, Python, Lua, TCL, X11, libzip, PCRE, the POSIX API, OpenGL, SDL, Cairo, Python, Lua, TCL, X11, libzip, PCRE,
libcurl, mySQL and SQLite are included in the standard distribution. libcurl, mySQL and SQLite are included in the standard distribution or
can easily be obtained via the
`Babel package manager <https://github.com/nimrod-code/babel>`_.
* A C to Nimrod conversion utility: New bindings to C libraries are easily * A C to Nimrod conversion utility: New bindings to C libraries are easily
generated by ``c2nim``. generated by ``c2nim``.
@ -98,6 +100,6 @@ Nimrod plays nice with others
Roadmap to 1.0 Roadmap to 1.0
============== ==============
Version 0.9.x Please have a look at
* the symbol binding rules for templates will change this `wiki page <https://github.com/Araq/Nimrod/wiki/Feature-Matrix>`_ for
* a shared memory garbage collected heap will be provided an up-to-date overview.

View file

@ -9,13 +9,15 @@ News
The Nimrod development community is proud to announce the release of version The Nimrod development community is proud to announce the release of version
0.9.4 of the Nimrod compiler and tools. **Note: This release has to be 0.9.4 of the Nimrod compiler and tools. **Note: This release has to be
considered beta quality! Lots of new features have been implemented but most considered beta quality! Lots of new features have been implemented but
do not fullfill our quality standards.** unfortunately some do not fullfill our quality standards yet.**
This release can be downloaded from `github <https://github.com/Araq/Nimrod>`_. Prebuilt binaries and instructions for building from source are available
Prebuilt binaries will be available soon. on the `download page <download.html>`_.
This release includes about 1300 changes in total including various bug This release includes about
`1400 changes <https://github.com/Araq/Nimrod/compare/v0.9.2...v0.9.4>`_
in total including various bug
fixes, new languages features and standard library additions and improvements. fixes, new languages features and standard library additions and improvements.
This release brings with it support for user-defined type classes, a brand This release brings with it support for user-defined type classes, a brand
new VM for executing Nimrod code at compile-time and new symbol binding new VM for executing Nimrod code at compile-time and new symbol binding
@ -79,6 +81,8 @@ syntax:
var s = @[1, 2, 3, 4, 5] var s = @[1, 2, 3, 4, 5]
echo(s.map((x: int) => x * 5)) echo(s.map((x: int) => x * 5))
A list of changes follows, for a comprehensive list of changes take a look
`here <https://github.com/Araq/Nimrod/compare/v0.9.2...v0.9.4>`_.
Library Additions Library Additions
----------------- -----------------

View file

@ -1,4 +1,4 @@
<a class="news" href="news.html#Z2014-XX-XX-version-0-9-4-released"> <a class="news" href="news.html#Z2014-04-21-version-0-9-4-released">
<h3>Apr 21, 2014</h3> <h3>Apr 21, 2014</h3>
<p>Nimrod version 0.9.4 has been released!</p> <p>Nimrod version 0.9.4 has been released!</p>
</a> </a>
@ -46,4 +46,4 @@
<a class="news" href="news.html#Z2010-03-14-version-0-8-8-released"> <a class="news" href="news.html#Z2010-03-14-version-0-8-8-released">
<h3>Mar 14, 2010</h3> <h3>Mar 14, 2010</h3>
<p>Nimrod version 0.8.8 has been released!</p> <p>Nimrod version 0.8.8 has been released!</p>
</a> </a>