From 03ffc344e129e38638a698fa0e83bb6c7b634913 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Sun, 20 Apr 2014 12:23:54 +0200 Subject: [PATCH 01/14] Version switch displays options used during `koch boot` --- compiler/commands.nim | 22 ++++++++++++++++++++++ compiler/options.nim | 2 +- lib/system/excpt.nim | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/compiler/commands.nim b/compiler/commands.nim index 8339219edb..366019c190 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -50,11 +50,33 @@ proc writeAdvancedUsage(pass: TCmdLinePass) = CPU[platform.hostCPU].name]) & AdvancedUsage) 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) = if pass == passCmd1: msgWriteln(`%`(HelpMessage, [VersionAsString, platform.OS[platform.hostOS].name, CPU[platform.hostCPU].name])) + msgWriteln("active boot switches:" & usedRelease & usedAvoidTimeMachine & + usedTinyC & usedGnuReadline & usedNativeStacktrace & usedNoCaas & + usedFFI & usedBoehm & usedMarkAndSweep & usedGenerational & usedNoGC) quit(0) var diff --git a/compiler/options.nim b/compiler/options.nim index f053546669..02719cacce 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -16,7 +16,7 @@ const hasFFI* = defined(useFFI) newScopeForIf* = true 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 # (improves code efficiency a lot!) diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index 612a9e729f..e11a30e9b2 100644 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -71,7 +71,7 @@ proc popCurrentException {.compilerRtl, inl.} = # some platforms have native support for stack traces: const - nativeStackTraceSupported = (defined(macosx) or defined(linux)) and + nativeStackTraceSupported* = (defined(macosx) or defined(linux)) and not nimrodStackTrace hasSomeStackTrace = nimrodStackTrace or defined(nativeStackTrace) and nativeStackTraceSupported From a822d0bf0196f2c77f9032a5455c5102f673acad Mon Sep 17 00:00:00 2001 From: EXetoC Date: Sun, 20 Apr 2014 18:10:57 +0200 Subject: [PATCH 02/14] Add spawn test. Hangs most of the time on linux x64 at least. --- tests/system/tsysspawn.nim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/system/tsysspawn.nim diff --git a/tests/system/tsysspawn.nim b/tests/system/tsysspawn.nim new file mode 100644 index 0000000000..0388918aa8 --- /dev/null +++ b/tests/system/tsysspawn.nim @@ -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 From bc79f40281accea987b23b47778782f7684de38c Mon Sep 17 00:00:00 2001 From: Simon Hafner Date: Mon, 21 Apr 2014 13:20:17 -0500 Subject: [PATCH 03/14] changed pointer to array in sqlite callback --- lib/wrappers/sqlite3.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/wrappers/sqlite3.nim b/lib/wrappers/sqlite3.nim index 586f763ae2..7b7f0874e6 100644 --- a/lib/wrappers/sqlite3.nim +++ b/lib/wrappers/sqlite3.nim @@ -106,15 +106,15 @@ type Pstmt* = ptr Tstmt Tvalue{.pure, final.} = object Pvalue* = ptr Tvalue - PPValue* = ptr Pvalue + PValueArg* = array[0..127, Pvalue] Tcallback* = proc (para1: pointer, para2: int32, para3, para4: cstringArray): int32{.cdecl.} Tbind_destructor_func* = proc (para1: pointer){.cdecl.} Tcreate_function_step_func* = proc (para1: Pcontext, para2: int32, - para3: PPValue){.cdecl.} + para3: PValueArg){.cdecl.} Tcreate_function_func_func* = proc (para1: Pcontext, para2: int32, - para3: PPValue){.cdecl.} + para3: PValueArg){.cdecl.} Tcreate_function_final_func* = proc (para1: Pcontext){.cdecl.} Tresult_func* = proc (para1: pointer){.cdecl.} Tcreate_collation_func* = proc (para1: pointer, para2: int32, para3: pointer, From 9ea55bf8875cd357e4164a27e358f61532ad1521 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Tue, 22 Apr 2014 00:36:46 +0100 Subject: [PATCH 04/14] Website updates. --- web/download.txt | 103 ++++++++++++++++++++++++++++++++++++++++++++++- web/news.txt | 14 ++++--- web/ticker.txt | 4 +- 3 files changed, 112 insertions(+), 9 deletions(-) diff --git a/web/download.txt b/web/download.txt index a306e516c8..0de31e8ce8 100644 --- a/web/download.txt +++ b/web/download.txt @@ -1,7 +1,103 @@ +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 `_. GCC is recommended on Linux +and clang on Mac OS X. + +Installers +---------- + +Installers will be available soon. + + + +Archives +-------- + +Windows +~~~~~~~ + +The "full" version includes a full mingw distribution which includes a C +compiler. The "slim" version lacks this. + +* Full (i386, 32bit): ``_ + + .. raw:: html +

+ SHA256: 8ee18faaa3a3d5df482c7abd6aa7ea87a350d7328b80ce1e2d486b59a7a93956 +

+ +* Slim (i386, 32bit): ``_ + + .. raw:: html +

+ SHA256: 7024fb8ad8f98c0bd4949ae36ed11b52b4e401754bbd62a11199d6dc8628d857 +

+ +* Full (amd64, 64bit): ``_ + + .. raw:: html +

+ SHA256: cb33cacc1a84fec771323d24cb6d9795f4803882466a9f417b424990aa49e18a +

+ +* Slim (amd64, 64bit): ``_ + + .. raw:: html +

+ SHA256: fcf877e4bd1ebfa214749af6e4811cd8539af19f1d7b23017e4bd7f6cbfb3eba +

+ +Linux +~~~~~ + +* Linux (i386, 32bit): ``_ + + .. raw:: html +

+ SHA256: 79DD337A77AC4313A75F2C5EED8252F00BBBDEB1E0C3504660D4A52EA63DBA92 +

+* Linux (amd64, 64bit): ``_ + + .. raw:: html +

+ SHA256: 6F6CB3C727BA8059B7605C02942AE7910C20C2A3DC6A8A600D90D50FE61F0D8C +

+* Linux (ppc64, 64bit): ``_ + + .. raw:: html +

+ SHA256: 5DAC2D9F7F545929E04540E6E2594C68FC3126A3B2F7B1FA7DBA5E295B4A7D31 +

+ +Mac OS X +~~~~~~~~ + +* Mac OS X (amd64, 64bit): ``_ + + .. raw:: html +

+ SHA256: E6F3A8E434DF3E89686F043954C6DFC09ABEBC0FC09D3B9A6B35C2B3102F7C3C +

+ +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 `_. + +Source +====== + Starting with 0.9.4 we now advise people to build directly from the github `master `_ branch:: - git clone git://github.com/Araq/Nimrod.git + git clone -b master git://github.com/Araq/Nimrod.git cd Nimrod git clone --depth 1 git://github.com/nimrod-code/csources cd csources && sh build.sh @@ -9,4 +105,7 @@ github `master `_ branch:: bin/nimrod c koch ./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. + diff --git a/web/news.txt b/web/news.txt index fa1c532e8f..4c41a0a76a 100644 --- a/web/news.txt +++ b/web/news.txt @@ -9,13 +9,15 @@ News 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 -considered beta quality! Lots of new features have been implemented but most -do not fullfill our quality standards.** +considered beta quality! Lots of new features have been implemented but +unfortunately some do not fullfill our quality standards yet.** -This release can be downloaded from `github `_. -Prebuilt binaries will be available soon. +Prebuilt binaries and instructions for building from source are available +on the `download page `_. -This release includes about 1300 changes in total including various bug +This release includes about +`1400 changes `_ +in total including various bug fixes, new languages features and standard library additions and improvements. 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 @@ -79,6 +81,8 @@ syntax: var s = @[1, 2, 3, 4, 5] echo(s.map((x: int) => x * 5)) +A list of changes follows, for a comprehensive list of changes take a look +`here `_. Library Additions ----------------- diff --git a/web/ticker.txt b/web/ticker.txt index 691a14575f..f06b005727 100644 --- a/web/ticker.txt +++ b/web/ticker.txt @@ -1,4 +1,4 @@ - +

Apr 21, 2014

Nimrod version 0.9.4 has been released!

@@ -46,4 +46,4 @@

Mar 14, 2010

Nimrod version 0.8.8 has been released!

-
\ No newline at end of file + From 15bd91a5dadc0d1e0eceb6ea8ebb5a8f144abafe Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Tue, 22 Apr 2014 00:28:57 +0200 Subject: [PATCH 05/14] Adds example of custom object types used as table key. --- lib/pure/collections/tables.nim | 68 +++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim index cd28f9af08..33e558aee2 100644 --- a/lib/pure/collections/tables.nim +++ b/lib/pure/collections/tables.nim @@ -10,6 +10,47 @@ ## The ``tables`` module implements an efficient hash table that is ## 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 `_ +## 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 ## that ``=`` performs a copy of the hash table. @@ -526,3 +567,30 @@ proc sort*[A](t: var TCountTable[A]) = if j < h: 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 From 71e1c8d642edb8aed5d6525fd564444141fd747f Mon Sep 17 00:00:00 2001 From: Araq Date: Tue, 22 Apr 2014 21:36:54 +0200 Subject: [PATCH 06/14] website updates --- tools/website.tmpl | 2 +- web/index.txt | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/website.tmpl b/tools/website.tmpl index bd68bdb062..1d62427362 100644 --- a/tools/website.tmpl +++ b/tools/website.tmpl @@ -71,7 +71,7 @@