Merge branch 'devel'

This commit is contained in:
Dominik Picheta 2015-05-05 14:14:22 +01:00
commit ac1fbf1469
24 changed files with 339 additions and 181 deletions

View file

@ -964,8 +964,11 @@ proc genEcho(p: BProc, n: PNode) =
var args: Rope = nil
var a: TLoc
for i in countup(0, n.len-1):
initLocExpr(p, n.sons[i], a)
addf(args, ", $1? ($1)->data:\"nil\"", [rdLoc(a)])
if n.sons[i].skipConv.kind == nkNilLit:
add(args, ", \"nil\"")
else:
initLocExpr(p, n.sons[i], a)
addf(args, ", $1? ($1)->data:\"nil\"", [rdLoc(a)])
linefmt(p, cpsStmts, "printf($1$2);$n",
makeCString(repeat("%s", n.len) & tnl), args)

View file

@ -47,7 +47,7 @@ Start: "doc/overview.html"
[Other]
Files: "readme.txt;install.txt;contributors.txt;copying.txt"
Files: "configure;makefile"
Files: "makefile"
Files: "*.ini"
Files: "koch.nim"
@ -70,6 +70,10 @@ Files: "doc/*.nim"
Files: "doc/*.cfg"
Files: "compiler/nimfix/*.nim"
Files: "compiler/nimfix/*.cfg"
Files: "compiler/nimsuggest/*.nim"
Files: "compiler/nimsuggest/*.cfg"
Files: "compiler/plugins/locals/*.nim"
Files: "compiler/plugins/active.nim"
Files: "tools/*.nim"
Files: "tools/*.cfg"
Files: "tools/*.tmpl"
@ -97,13 +101,8 @@ Files: "lib/pure/concurrency/*.cfg"
Files: "lib/impure/*.nim"
Files: "lib/wrappers/*.nim"
Files: "lib/wrappers/cairo/*.nim"
Files: "lib/wrappers/gtk/*.nim"
Files: "lib/wrappers/lua/*.nim"
Files: "lib/wrappers/opengl/*.nim"
Files: "lib/wrappers/readline/*.nim"
Files: "lib/wrappers/sdl/*.nim"
Files: "lib/wrappers/x11/*.nim"
Files: "lib/wrappers/zip/*.nim"
Files: "lib/wrappers/zip/libzip_all.c"
@ -115,8 +114,6 @@ Files: "lib/packages/docutils/*.nim"
[Other]
Files: "examples/*.nim"
Files: "examples/gtk/*.nim"
Files: "examples/0mq/*.nim"
Files: "examples/c++iface/*.nim"
Files: "examples/objciface/*.nim"
Files: "examples/cross_calculator/"
@ -239,7 +236,7 @@ BinPath: r"bin;dist\mingw\bin;dist"
; Section | dir | zipFile | size hint (in KB) | url | exe start menu entry
Download: r"Documentation|doc|docs.zip|13824|http://nim-lang.org/download/docs-${version}.zip|overview.html"
Download: r"C Compiler (MingW)|dist|mingw.zip|82944|http://nim-lang.org/download/${mingw}.zip"
Download: r"Aporia IDE|dist|aporia.zip|97997|http://nim-lang.org/download/aporia-0.3.0.zip|aporia\bin\aporia.exe"
Download: r"Aporia IDE|dist|aporia.zip|97997|http://nim-lang.org/download/aporia-0.3.0.zip|aporia-0.3.0\bin\aporia.exe"
; for now only NSIS supports optional downloads
[UnixBin]

View file

@ -1,7 +1,7 @@
#
#
# The Nim Compiler
# (c) Copyright 2013 Andreas Rumpf
# (c) Copyright 2015 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.

View file

@ -535,7 +535,18 @@ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
result.sons[i] = fitNode(c, typ, result.sons[i])
result.typ.sons[0] = makeRangeType(c, 0, sonsLen(result) - 1, n.info)
template fixAbstractType(c: PContext, n: PNode) =
proc fixAbstractType(c: PContext, n: PNode) =
for i in 1 .. < n.len:
let it = n.sons[i]
# do not get rid of nkHiddenSubConv for OpenArrays, the codegen needs it:
if it.kind == nkHiddenSubConv and
skipTypes(it.typ, abstractVar).kind notin {tyOpenArray, tyVarargs}:
if skipTypes(it.sons[1].typ, abstractVar).kind in
{tyNil, tyArrayConstr, tyTuple, tySet}:
var s = skipTypes(it.typ, abstractVar)
if s.kind != tyExpr:
changeType(it.sons[1], s, check=true)
n.sons[i] = it.sons[1]
when false:
# XXX finally rewrite that crap!
for i in countup(1, sonsLen(n) - 1):
@ -2042,7 +2053,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
of nkEmpty, nkNone, nkCommentStmt:
discard
of nkNilLit:
result.typ = getSysType(tyNil)
if result.typ == nil: result.typ = getSysType(tyNil)
of nkIntLit:
if result.typ == nil: setIntLitType(result)
of nkInt8Lit:

View file

@ -286,10 +286,13 @@ proc evalOp(m: TMagic, n, a, b, c: PNode): PNode =
of mNot: result = newIntNodeT(1 - getInt(a), n)
of mCard: result = newIntNodeT(nimsets.cardSet(a), n)
of mBitnotI, mBitnotI64: result = newIntNodeT(not getInt(a), n)
of mLengthStr, mXLenStr: result = newIntNodeT(len(getStr(a)), n)
of mLengthStr, mXLenStr:
if a.kind == nkNilLit: result = newIntNodeT(0, n)
else: result = newIntNodeT(len(getStr(a)), n)
of mLengthArray: result = newIntNodeT(lengthOrd(a.typ), n)
of mLengthSeq, mLengthOpenArray, mXLenSeq:
result = newIntNodeT(sonsLen(a), n) # BUGFIX
if a.kind == nkNilLit: result = newIntNodeT(0, n)
else: result = newIntNodeT(sonsLen(a), n) # BUGFIX
of mUnaryPlusI, mUnaryPlusF64: result = a # throw `+` away
of mToFloat, mToBiggestFloat:
result = newFloatNodeT(toFloat(int(getInt(a))), n)
@ -545,7 +548,7 @@ proc foldConv*(n, a: PNode; check = false): PNode =
discard
else:
result = a
result.typ = takeType(n.typ, a.typ)
result.typ = n.typ
proc getArrayConstr(m: PSym, n: PNode): PNode =
if n.kind == nkBracket:
@ -652,7 +655,7 @@ proc getConstExpr(m: PSym, n: PNode): PNode =
result = copyNode(n)
of nkIfExpr:
result = getConstIfExpr(m, n)
of nkCall, nkCommand, nkCallStrLit, nkPrefix, nkInfix:
of nkCallKinds:
if n.sons[0].kind != nkSym: return
var s = n.sons[0].sym
if s.kind != skProc: return

View file

@ -716,8 +716,7 @@ proc transform(c: PTransf, n: PNode): PTransNode =
add(result, PTransNode(newSymNode(labl)))
of nkBreakStmt: result = transformBreak(c, n)
of nkWhileStmt: result = transformWhile(c, n)
of nkCall, nkHiddenCallConv, nkCommand, nkInfix, nkPrefix, nkPostfix,
nkCallStrLit:
of nkCallKinds:
result = transformCall(c, n)
of nkAddr, nkHiddenAddr:
result = transformAddrDeref(c, n, nkDerefExpr, nkHiddenDeref)

View file

@ -96,7 +96,7 @@ path="$lib/pure/unidecode"
# Configuration for the GNU C/C++ compiler:
@if windows:
#gcc.path = r"$nimrod\dist\mingw\bin"
#gcc.path = r"$nim\dist\mingw\bin"
@if gcc:
tlsEmulation:on
@end

View file

@ -1451,7 +1451,7 @@ operators perform implicit dereferencing operations for reference types:
type
Node = ref NodeObj
NodeObj = object
le, ri: PNode
le, ri: Node
data: int
var
n: Node

View file

@ -10,7 +10,7 @@
## This module implements a zip archive creator/reader/modifier.
import
streams, libzip, times, os
streams, libzip, times, os, strutils
type
TZipArchive* = object of RootObj ## represents a zip archive
@ -111,19 +111,25 @@ proc addFile*(z: var TZipArchive, dest: string, src: Stream) =
type
TZipFileStream = object of StreamObj
f: PZipFile
atEnd: bool
PZipFileStream* =
ref TZipFileStream ## a reader stream of a file within a zip archive
proc fsClose(s: Stream) = zip_fclose(PZipFileStream(s).f)
proc fsAtEnd(s: Stream): bool = PZipFileStream(s).atEnd
proc fsReadData(s: Stream, buffer: pointer, bufLen: int): int =
result = zip_fread(PZipFileStream(s).f, buffer, bufLen)
if result == 0:
PZipFileStream(s).atEnd = true
proc newZipFileStream(f: PZipFile): PZipFileStream =
new(result)
result.f = f
result.atEnd = false
result.closeImpl = fsClose
result.readDataImpl = fsReadData
result.atEndImpl = fsAtEnd
# other methods are nil!
# ----------------------------------------------------------------------------
@ -158,12 +164,20 @@ proc extractFile*(z: var TZipArchive, srcFile: string, dest: Stream) =
proc extractFile*(z: var TZipArchive, srcFile: string, dest: string) =
## extracts a file from the zip archive `z` to the destination filename.
var file = newFileStream(dest, fmReadWrite)
var file = newFileStream(dest, fmWrite)
extractFile(z, srcFile, file)
file.close()
proc extractAll*(z: var TZipArchive, dest: string) =
## extracts all files from archive `z` to the destination directory.
for file in walkFiles(z):
extractFile(z, file, dest / extractFilename(file))
if file.endsWith("/"):
createDir(dest / file)
else:
extractFile(z, file, dest / file)
when not defined(testing) and isMainModule:
var zip: TZipArchive
if not zip.open("nim-0.11.0.zip"):
raise newException(IOError, "opening zip failed")
zip.extractAll("test")

View file

@ -152,10 +152,12 @@ type
DocumentObj {.importc.} = object of NodeObj
alinkColor*: cstring
bgColor*: cstring
body*: Element
charset*: cstring
cookie*: cstring
defaultCharset*: cstring
fgColor*: cstring
head*: Element
lastModified*: cstring
linkColor*: cstring
referrer*: cstring

View file

@ -819,15 +819,18 @@ proc enlarge[A](t: var CountTable[A]) =
swap(t.data, n)
proc `[]=`*[A](t: var CountTable[A], key: A, val: int) =
## puts a (key, value)-pair into `t`. `val` has to be positive.
## puts a (key, value)-pair into `t`.
assert val > 0
var h = rawGet(t, key)
if h >= 0:
t.data[h].val = val
else:
h = -1 - h
t.data[h].key = key
t.data[h].val = val
if mustRehash(len(t.data), t.counter): enlarge(t)
rawInsert(t, t.data, key, val)
inc(t.counter)
#h = -1 - h
#t.data[h].key = key
#t.data[h].val = val
proc initCountTable*[A](initialSize=64): CountTable[A] =
## creates a new count table that is empty.

View file

@ -1535,7 +1535,7 @@ const
NimMinor*: int = 11
## is the minor number of Nim's version.
NimPatch*: int = 0
NimPatch*: int = 2
## is the patch number of Nim's version.
NimVersion*: string = $NimMajor & "." & $NimMinor & "." & $NimPatch

View file

@ -10,6 +10,8 @@
## This module implements a small wrapper for some needed Win API procedures,
## so that the Nim compiler does not depend on the huge Windows module.
{.deadCodeElim:on.}
const
useWinUnicode* = not defined(useWinAnsi)

View file

@ -0,0 +1,19 @@
discard """
output: "And we get here"
"""
# bug #2625
const s_len = 32
import tables
var substr_counts: CountTable[string] = initCountTable[string]()
var my_string = "Hello, this is sadly broken for strings over 64 characters. Note that it *does* appear to work for short strings."
for i in 0..(my_string.len - s_len):
let s = my_string[i..i+s_len-1]
substr_counts[s] = 1
# substr_counts[s] = substr_counts[s] + 1 # Also breaks, + 2 as well, etc.
# substr_counts.inc(s) # This works
#echo "Iteration ", i
echo "And we get here"

View file

@ -0,0 +1,20 @@
# bug #2641
type MyChar = distinct char
const c:MyChar = MyChar('a')
type MyBool = distinct bool
const b:MyBool = MyBool(true)
type MyBoolSet = distinct set[bool]
const bs:MyBoolSet = MyBoolSet({true})
type MyCharSet= distinct set[char]
const cs:MyCharSet = MyCharSet({'a'})
type MyBoolSeq = distinct seq[bool]
const bseq:MyBoolSeq = MyBoolSeq(@[true, false])
type MyBoolArr = distinct array[3, bool]
const barr:MyBoolArr = MyBoolArr([true, false, true])

View file

@ -0,0 +1,14 @@
# bug #2629
import sequtils, os
template glob_rst(basedir: string = nil): expr =
if baseDir.isNil:
to_seq(walk_files("*.rst"))
else:
to_seq(walk_files(basedir/"*.rst"))
let
rst_files = concat(glob_rst(), glob_rst("docs"))
when isMainModule: echo rst_files

View file

@ -0,0 +1,46 @@
discard """
output: '''it's nil
@[1, 2, 3]'''
"""
template foo(s: string = nil) =
if isNil(s):
echo "it's nil"
else:
echo s
foo
# bug #2632
proc takeTup(x: tuple[s: string;x: seq[int]]) =
discard
takeTup(("foo", @[]))
#proc foobar(): () =
proc f(xs: seq[int]) =
discard
proc g(t: tuple[n:int, xs:seq[int]]) =
discard
when isMainModule:
f(@[]) # OK
g((1,@[1])) # OK
g((0,@[])) # NG
# bug #2630
type T = tuple[a: seq[int], b: int]
var t: T = (@[1,2,3], 7)
proc test(s: seq[int]): T =
echo s
(s, 7)
t = test(t.a)

View file

@ -1,14 +1,14 @@
version 0.10.4
version 0.11.2
==============
version 0.10.6 (RC1?)
=====================
- The remaining bugs of the lambda lifting pass that is responsible to enable
closures and closure iterators need to be fixed.
- ``concept`` needs to be refined, a nice name for the feature is not enough.
- Destructors need to be refined.
- make '--implicitStatic:on' the default; then we can also clean up the
'static[T]' mess in the compiler!
- finish 'parallel' or mark as experimental
- Finish the implementation of the 'parallel' statement.
- Deprecate ``immediate`` for templates and macros
- special case varargs[untyped] and varargs[typed]
- make 'nil' work for 'add':

View file

@ -125,8 +125,8 @@ pre .end { background:url("images/tabEnd.png") no-repeat left bottom; }
opacity 1s ease-in-out; }
#slideshow > div.active { visibility:visible; opacity:1; transition-delay:0s; }
#slideshow > div.init { transition-delay:0s; }
#slideshow-nav { z-index:3; position:absolute; top:110px;; right:-12px; }
#slideshow-nav > div { margin:5px 0; width:23px; height:23px; background:url("images/slideshow-nav.png") no-repeat; }
#slideshow-nav { z-index:3; position:absolute; top:341px; left:18px; }
#slideshow-nav > div { display:inline-block; margin:5px 0; width:23px; height:23px; background:url("images/slideshow-nav.png") no-repeat; }
#slideshow-nav > div:hover { background-image:url("images/slideshow-nav_active.png"); opacity:0.5; }
#slideshow-nav > div.active { background-image:url("images/slideshow-nav_active.png"); opacity:1; }

View file

@ -8,13 +8,13 @@ Nim's Documentation
.. container:: libraries
- | `Standard Library <0.11.0/lib.html>`_
- | `Standard Library <docs/lib.html>`_
| This document describes Nim's standard library.
- | `Language Manual <0.11.0/manual.html>`_
- | `Language Manual <docs/manual.html>`_
| The Nim manual is a draft that will evolve into a proper specification.
- | `Compiler User Guide <0.11.0/nimc.html>`_
- | `Compiler User Guide <docs/nimc.html>`_
| The user guide lists command line arguments, special features of the
compiler, etc.
@ -26,11 +26,11 @@ Nim's Documentation
.. container:: tools
- | `Source Code Filters <0.11.0/filters.html>`_
- | `Source Code Filters <docs/filters.html>`_
| The Nim compiler supports source code filters as a simple yet powerful
builtin templating system.
- | `Tools Documentation <0.11.0/tools.html>`_
- | `Tools Documentation <docs/tools.html>`_
| Description of some tools that come with the standard distribution.
@ -41,11 +41,11 @@ Nim's Documentation
.. container:: internals
- | `Garbage Collector <0.11.0/gc.html>`_
- | `Garbage Collector <docs/gc.html>`_
| Additional documentation about Nim's GC and how to operate it in a
realtime setting.
- | `Internal Documentation <0.11.0/intern.html>`_
- | `Internal Documentation <docs/intern.html>`_
| The internal documentation describes how the compiler is implemented.
Read this if you want to hack the compiler.
@ -53,5 +53,5 @@ Nim's Documentation
Search Options
--------------
`Documentation Index <0.11.0/theindex.html>`_ - The generated
`Documentation Index <docs/theindex.html>`_ - The generated
index. **Index + (Ctrl+F) == Joy**

View file

@ -13,8 +13,8 @@ Binaries
--------
Unfortunately for now we only provide builds for Windows.
* 32 bit: `nim-0.11.0_x32.exe <download/nim-0.11.0_x32.exe>`_
* 64 bit: `nim-0.11.0_x64.exe <download/nim-0.11.0_x64.exe>`_
* 32 bit: `nim-0.11.2_x32.exe <download/nim-0.11.2_x32.exe>`_
* 64 bit: `nim-0.11.2_x64.exe <download/nim-0.11.2_x64.exe>`_
Installation based on generated C code
@ -26,8 +26,8 @@ like systems. Binary packages may be provided later.
Download one of these:
* `nim-0.11.0.zip (28 MB) <download/nim-0.11.0.zip>`_
* `nim-0.11.0.tar.xz (2.6MB) <download/nim-0.11.0.tar.xz>`_
* `nim-0.11.2.zip (28 MB) <download/nim-0.11.2.zip>`_
* `nim-0.11.2.tar.xz (2.6MB) <download/nim-0.11.2.tar.xz>`_
Extract the file and follow these instructions:

View file

@ -8,10 +8,10 @@ Learning Nim
.. container:: tutorials
- | `Tutorial (part I) <0.11.0/tut1.html>`_
- | `Tutorial (part I) <docs/tut1.html>`_
| Learn the basics of Nim's types, variables, procedures, control flow, etc...
- | `Tutorial (part II) <0.11.0/tut2.html>`_
- | `Tutorial (part II) <docs/tut2.html>`_
| Learn Nim's more advanced features such as OOP, generics, macros, etc...
@ -52,5 +52,5 @@ Learning Nim
Documentation
-------------
More examples of Nim code can be found in the `Nim Language Documentation <0.11.0/manual.html>`_.
More examples of Nim code can be found in the `Nim Language Documentation <docs/manual.html>`_.

View file

@ -2,6 +2,31 @@
News
====
..
2015-05-05 Version 0.11.2 released
==================================
Changes affecting backwards compatibility
-----------------------------------------
Language Additions
------------------
Bugfixes
--------
2015-05-04 Version 0.11.2 released
==================================
This is just a bugfix release that fixes the most pressing regressions we
introduced with version 0.11.0. The way types are computed was
changed significantly causing all sort of problems. Sorry for the
inconvenience; we grew overconfident our large test suite would prevent these
things.
2015-04-30 Version 0.11.0 released
==================================

View file

@ -1,6 +1,6 @@
<a class="news" href="news.html#Z2015-04-30-version-0-11-0-released">
<h4>Apr 30, 2015</h4>
<p>Nim version 0.11.0 has been released!</p>
<a class="news" href="news.html#Z2015-05-04-version-0-11-2-released">
<h4>May 4, 2015</h4>
<p>Nim version 0.11.2 has been released!</p>
</a>
<a class="news" href="news.html#Z2014-12-29-version-0-10-2-released">