Skip to content

Commit

Permalink
Merge branch 'devel' of git://github.com/nim-lang/Nim into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
slangmgh committed Feb 20, 2019
2 parents ab283b4 + 6a5c747 commit 470f4fe
Show file tree
Hide file tree
Showing 196 changed files with 9,265 additions and 6,069 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
sudo: false
language: c

dist: trusty
dist: xenial

matrix:
fast_finish: true

include:
- os: linux
env: NIM_COMPILE_TO_CPP=false
Expand Down Expand Up @@ -45,10 +47,12 @@ before_script:
- set +e # prevents breaking after_failure

script:
- set -e
- echo "travis_fold:start:nim_c_koch"
- nim c koch
- echo "travis_fold:end:nim_c_koch"
- ./koch runCI
- set +e

before_deploy:
# Make https://nim-lang.github.io/Nim work the same as https://nim-lang.github.io/Nim/overview.html
Expand Down
39 changes: 21 additions & 18 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
version: '{build}'

environment:
MINGW_DIR: mingw64
MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z/download
MINGW_ARCHIVE: x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z
OPENBLAS_URL: https://sourceforge.net/projects/openblas/files/v0.3.5/OpenBLAS%200.3.5%20version.zip/download
OPENBLAS_ARCHIVE: OpenBLAS-0.3.5.zip
SQLITE_URL: http://www.sqlite.org/2017/sqlite-dll-win64-x64-3160200.zip
SQLITE_ARCHIVE: sqlite-dll-win64-x64-3160200.zip
platform: x64

matrix:
- NIM_TEST_PACKAGES: true
- NIM_TEST_PACKAGES: false

cache:
- x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z
- sqlite-dll-win64-x64-3160200.zip
# - i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z
- '%MINGW_ARCHIVE%'
- '%SQLITE_ARCHIVE%'
- '%OPENBLAS_ARCHIVE%'

matrix:
#allow_failures:
# - NIM_TEST_PACKAGES: true
fast_finish: true

environment:
matrix:
- MINGW_DIR: mingw64
MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z/download
MINGW_ARCHIVE: x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z
SQLITE_URL: http://www.sqlite.org/2017/sqlite-dll-win64-x64-3160200.zip
SQLITE_ARCHIVE: sqlite-dll-win64-x64-3160200.zip
platform: x64
# - MINGW_DIR: mingw32
# MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/dwarf/i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z/download
# MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z
# SQLITE_URL: http://www.sqlite.org/2017/sqlite-dll-win32-x86-3160200.zip
# SQLITE_ARCHIVE: sqlite-dll-win32-x86-3160200.zip
# platform: x86

install:
- ps: Install-Product node 8 # node 8 or later is required to test js async stuff
- MKDIR %CD%\DIST
Expand All @@ -32,6 +33,8 @@ install:
- 7z x -y "%SQLITE_ARCHIVE%" -o"%CD%\DIST"> nul
- IF not exist "%MINGW_ARCHIVE%" appveyor DownloadFile "%MINGW_URL%" -FileName "%MINGW_ARCHIVE%"
- 7z x -y "%MINGW_ARCHIVE%" -o"%CD%\DIST"> nul
- IF not exist "%OPENBLAS_ARCHIVE%" appveyor DownloadFile "%OPENBLAS_URL%" -FileName "%OPENBLAS_ARCHIVE%"
- 7z x -y "%OPENBLAS_ARCHIVE%" -o"%CD%\DIST"> nul
- SET PATH=%CD%\DIST\%MINGW_DIR%\BIN;%CD%\BIN;%PATH%
- IF "%PLATFORM%" == "x64" ( copy C:\OpenSSL-Win64\libeay32.dll %CD%\BIN\libeay64.dll & copy C:\OpenSSL-Win64\libeay32.dll %CD%\BIN\libeay32.dll & copy C:\OpenSSL-Win64\libssl32.dll %CD%\BIN\libssl64.dll & copy C:\OpenSSL-Win64\libssl32.dll %CD%\BIN\libssl32.dll )
ELSE ( copy C:\OpenSSL-Win32\libeay32.dll %CD%\BIN\libeay32.dll & copy C:\OpenSSL-Win32\libssl32.dll %CD%\BIN\libssl32.dll )
Expand Down
3 changes: 3 additions & 0 deletions bin/nim-gdb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Exit if anything fails
set -e

which nim > /dev/null || (echo "nim not in PATH"; exit 1)
which gdb > /dev/null || (echo "gdb not in PATH"; exit 1)

# Find out where the pretty printer Python module is
NIM_SYSROOT=$(dirname $(dirname $(readlink -e $(which nim))))
GDB_PYTHON_MODULE_PATH="$NIM_SYSROOT/tools/nim-gdb.py"
Expand Down
1 change: 0 additions & 1 deletion build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ build_nim_csources(){
[ -f $nim_csources ] || echo_run build_nim_csources

# Note: if fails, may need to `cd csources && git pull`
# see D20190115T162028
echo_run bin/nim c --skipUserCfg --skipParentCfg koch

echo_run ./koch boot -d:release
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ proc enumToString*(enums: openArray[enum]): string =

- Added `xmltree.toXmlAttributes`.

- Added ``std/sums`` module for fast summation functions.

- Added `Rusage`, `getrusage`, `wait4` to posix interface.



### Library changes

Expand Down
12 changes: 9 additions & 3 deletions compiler/ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ type
# language; for interfacing with Objective C
sfDiscardable, # returned value may be discarded implicitly
sfOverriden, # proc is overriden
sfCallSideLineinfo# A flag for template symbols to tell the
# compiler it should use line information from
# the calling side of the macro, not from the
# implementation.
sfGenSym # symbol is 'gensym'ed; do not add to symbol table

TSymFlags* = set[TSymFlag]
Expand Down Expand Up @@ -655,7 +659,7 @@ type
mEqIdent, mEqNimrodNode, mSameNodeType, mGetImpl, mNGenSym,
mNHint, mNWarning, mNError,
mInstantiationInfo, mGetTypeInfo,
mNimvm, mIntDefine, mStrDefine, mRunnableExamples,
mNimvm, mIntDefine, mStrDefine, mBoolDefine, mRunnableExamples,
mException, mBuiltinType, mSymOwner, mUncheckedArray, mGetImplTransf,
mSymIsInstantiationOf

Expand Down Expand Up @@ -1265,7 +1269,10 @@ proc `$`*(x: TLockLevel): string =
else: result = $int16(x)

proc `$`*(s: PSym): string =
result = s.name.s & "@" & $s.id
if s != nil:
result = s.name.s & "@" & $s.id
else:
result = "<nil>"

proc newType*(kind: TTypeKind, owner: PSym): PType =
new(result)
Expand Down Expand Up @@ -1352,7 +1359,6 @@ proc copySym*(s: PSym): PSym =
result = newSym(s.kind, s.name, s.owner, s.info, s.options)
#result.ast = nil # BUGFIX; was: s.ast which made problems
result.typ = s.typ
result.id = getID()
when debugIds: registerId(result)
result.flags = s.flags
result.magic = s.magic
Expand Down
121 changes: 63 additions & 58 deletions compiler/astalgo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,6 @@ proc symToYamlAux(conf: ConfigRef; n: PSym, marker: var IntSet,
proc typeToYamlAux(conf: ConfigRef; n: PType, marker: var IntSet,
indent, maxRecDepth: int): Rope

proc ropeConstr(indent: int, c: openArray[Rope]): Rope =
# array of (name, value) pairs
var istr = rspaces(indent + 2)
result = rope("{")
var i = 0
while i <= high(c):
if i > 0: add(result, ",")
addf(result, "$N$1\"$2\": $3", [istr, c[i], c[i + 1]])
inc(i, 2)
addf(result, "$N$1}", [rspaces(indent)])

proc symToYamlAux(conf: ConfigRef; n: PSym, marker: var IntSet, indent: int,
maxRecDepth: int): Rope =
if n == nil:
Expand All @@ -257,51 +246,60 @@ proc symToYamlAux(conf: ConfigRef; n: PSym, marker: var IntSet, indent: int,
result = "\"$1\"" % [rope(n.name.s)]
else:
var ast = treeToYamlAux(conf, n.ast, marker, indent + 2, maxRecDepth - 1)
result = ropeConstr(indent, [rope("kind"),
makeYamlString($n.kind),
rope("name"), makeYamlString(n.name.s),
#rope("typ"), typeToYamlAux(conf, n.typ, marker,
# indent + 2, maxRecDepth - 1),
rope("info"), lineInfoToStr(conf, n.info),
rope("flags"), flagsToStr(n.flags),
rope("magic"), makeYamlString($n.magic),
rope("ast"), ast, rope("options"),
flagsToStr(n.options), rope("position"),
rope(n.position),
rope("k"), makeYamlString($n.loc.k),
rope("storage"), makeYamlString($n.loc.storage),
rope("flags"), makeYamlString($n.loc.flags),
rope("r"), n.loc.r,
rope("lode"), treeToYamlAux(conf, n.loc.lode, marker, indent + 2, maxRecDepth - 1)
])
let istr = rspaces(indent + 2)
result = rope("{")
addf(result, "$N$1\"kind\": $2", [istr, makeYamlString($n.kind)])
addf(result, "$N$1\"name\": $2", [istr, makeYamlString(n.name.s)])
addf(result, "$N$1\"typ\": $2", [istr, typeToYamlAux(conf, n.typ, marker, indent + 2, maxRecDepth - 1)])
if conf != nil:
# if we don't pass the config, we probably don't care about the line info
addf(result, "$N$1\"info\": $2", [istr, lineInfoToStr(conf, n.info)])
if card(n.flags) > 0:
addf(result, "$N$1\"flags\": $2", [istr, flagsToStr(n.flags)])
addf(result, "$N$1\"magic\": $2", [istr, makeYamlString($n.magic)])
addf(result, "$N$1\"ast\": $2", [istr, ast])
addf(result, "$N$1\"options\": $2", [istr, flagsToStr(n.options)])
addf(result, "$N$1\"position\": $2", [istr, rope(n.position)])
addf(result, "$N$1\"k\": $2", [istr, makeYamlString($n.loc.k)])
addf(result, "$N$1\"storage\": $2", [istr, makeYamlString($n.loc.storage)])
if card(n.loc.flags) > 0:
addf(result, "$N$1\"flags\": $2", [istr, makeYamlString($n.loc.flags)])
addf(result, "$N$1\"r\": $2", [istr, n.loc.r])
addf(result, "$N$1\"lode\": $2", [istr, treeToYamlAux(conf, n.loc.lode, marker, indent + 2, maxRecDepth - 1)])
addf(result, "$N$1}", [rspaces(indent)])

proc typeToYamlAux(conf: ConfigRef; n: PType, marker: var IntSet, indent: int,
maxRecDepth: int): Rope =
var sonsRope: Rope
if n == nil:
result = rope("null")
sonsRope = rope("null")
elif containsOrIncl(marker, n.id):
result = "\"$1 @$2\"" % [rope($n.kind), rope(
sonsRope = "\"$1 @$2\"" % [rope($n.kind), rope(
strutils.toHex(cast[ByteAddress](n), sizeof(n) * 2))]
else:
if sonsLen(n) > 0:
result = rope("[")
sonsRope = rope("[")
for i in countup(0, sonsLen(n) - 1):
if i > 0: add(result, ",")
addf(result, "$N$1$2", [rspaces(indent + 4), typeToYamlAux(conf, n.sons[i],
if i > 0: add(sonsRope, ",")
addf(sonsRope, "$N$1$2", [rspaces(indent + 4), typeToYamlAux(conf, n.sons[i],
marker, indent + 4, maxRecDepth - 1)])
addf(result, "$N$1]", [rspaces(indent + 2)])
addf(sonsRope, "$N$1]", [rspaces(indent + 2)])
else:
result = rope("null")
result = ropeConstr(indent, [rope("kind"),
makeYamlString($n.kind),
rope("sym"), symToYamlAux(conf, n.sym, marker,
indent + 2, maxRecDepth - 1), rope("n"), treeToYamlAux(conf, n.n, marker,
indent + 2, maxRecDepth - 1), rope("flags"), flagsToStr(n.flags),
rope("callconv"),
makeYamlString(CallingConvToStr[n.callConv]),
rope("size"), rope(n.size),
rope("align"), rope(n.align),
rope("sons"), result])
sonsRope = rope("null")

let istr = rspaces(indent + 2)
result = rope("{")
addf(result, "$N$1\"kind\": $2", [istr, makeYamlString($n.kind)])
addf(result, "$N$1\"sym\": $2", [istr, symToYamlAux(conf, n.sym, marker, indent + 2, maxRecDepth - 1)])
addf(result, "$N$1\"n\": $2", [istr, treeToYamlAux(conf, n.n, marker, indent + 2, maxRecDepth - 1)])
if card(n.flags) > 0:
addf(result, "$N$1\"flags\": $2", [istr, flagsToStr(n.flags)])
addf(result, "$N$1\"callconv\": $2", [istr, makeYamlString(CallingConvToStr[n.callConv])])
addf(result, "$N$1\"size\": $2", [istr, rope(n.size)])
addf(result, "$N$1\"align\": $2", [istr, rope(n.align)])
addf(result, "$N$1\"sons\": $2", [istr, sonsRope])

proc treeToYamlAux(conf: ConfigRef; n: PNode, marker: var IntSet, indent: int,
maxRecDepth: int): Rope =
Expand All @@ -311,7 +309,8 @@ proc treeToYamlAux(conf: ConfigRef; n: PNode, marker: var IntSet, indent: int,
var istr = rspaces(indent + 2)
result = "{$N$1\"kind\": $2" % [istr, makeYamlString($n.kind)]
if maxRecDepth != 0:
addf(result, ",$N$1\"info\": $2", [istr, lineInfoToStr(conf, n.info)])
if conf != nil:
addf(result, ",$N$1\"info\": $2", [istr, lineInfoToStr(conf, n.info)])
case n.kind
of nkCharLit..nkInt64Lit:
addf(result, ",$N$1\"intVal\": $2", [istr, rope(n.intVal)])
Expand Down Expand Up @@ -362,8 +361,8 @@ proc debugType(conf: ConfigRef; n: PType, maxRecDepth=100): Rope =
add(result, " ")
add(result, n.sym.name.s)
if n.kind in IntegralTypes and n.n != nil:
add(result, ", node: ")
add(result, debugTree(conf, n.n, 2, maxRecDepth-1, renderType=true))
add(result, ", n: ")
add(result, debugTree(conf, n.n, 2, maxRecDepth-1, renderType=false))
if (n.kind != tyString) and (sonsLen(n) > 0) and maxRecDepth != 0:
add(result, "(")
for i in countup(0, sonsLen(n) - 1):
Expand All @@ -373,7 +372,7 @@ proc debugType(conf: ConfigRef; n: PType, maxRecDepth=100): Rope =
else:
add(result, debugType(conf, n.sons[i], maxRecDepth-1))
if n.kind == tyObject and n.n != nil:
add(result, ", node: ")
add(result, ", n: ")
add(result, debugTree(conf, n.n, 2, maxRecDepth-1, renderType=true))
add(result, ")")

Expand All @@ -387,9 +386,11 @@ proc debugTree(conf: ConfigRef; n: PNode, indent: int, maxRecDepth: int;
[istr, makeYamlString($n.kind)]
when defined(useNodeIds):
addf(result, ",$N$1\"id\": $2", [istr, rope(n.id)])
addf(result, ",$N$1\"info\": $2", [istr, lineInfoToStr(conf, n.info)])
if conf != nil:
addf(result, ",$N$1\"info\": $2", [istr, lineInfoToStr(conf, n.info)])
if maxRecDepth != 0:
addf(result, ",$N$1\"flags\": $2", [istr, rope($n.flags)])
if card(n.flags) > 0:
addf(result, ",$N$1\"flags\": $2", [istr, rope($n.flags)])
case n.kind
of nkCharLit..nkUInt64Lit:
addf(result, ",$N$1\"intVal\": $2", [istr, rope(n.intVal)])
Expand All @@ -400,15 +401,19 @@ proc debugTree(conf: ConfigRef; n: PNode, indent: int, maxRecDepth: int;
addf(result, ",$N$1\"strVal\": $2", [istr, makeYamlString(n.strVal)])
of nkSym:
let s = n.sym
addf(result, ",$N$1\"sym\": $2_$3 k: $4 storage: $5 flags: $6 r: $7",
[istr, rope(s.name.s), rope(s.id),
rope($s.loc.k),
rope($s.loc.storage),
rope($s.loc.flags),
s.loc.r
])
# [istr, symToYaml(conf, n.sym, indent, maxRecDepth),
# rope(n.sym.id)])
var symStr = ""
symStr.add "\"kind\": "
symStr.add $s.kind
symStr.add ", \"name\": "
symStr.add s.name.s
symStr.add ", \"id\": "
symStr.add s.id
if s.kind in {skField, skEnumField, skParam}:
symStr.add ", \"position\": "
symStr.add s.position
addf(result, ",$N$1\"sym\": {$2}", [
istr, rope(symStr)])

if renderType and n.sym.typ != nil:
addf(result, ",$N$1\"typ\": $2", [istr, debugType(conf, n.sym.typ, 2)])
of nkIdent:
Expand Down
13 changes: 9 additions & 4 deletions compiler/ccgexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ proc binaryStmtAddr(p: BProc, e: PNode, d: var TLoc, frmt: string) =
if d.k != locNone: internalError(p.config, e.info, "binaryStmtAddr")
initLocExpr(p, e.sons[1], a)
initLocExpr(p, e.sons[2], b)
lineCg(p, cpsStmts, frmt, addrLoc(p.config, a), rdLoc(b))
lineCg(p, cpsStmts, frmt, byRefLoc(p, a), rdLoc(b))

proc unaryStmt(p: BProc, e: PNode, d: var TLoc, frmt: string) =
var a: TLoc
Expand Down Expand Up @@ -1028,7 +1028,7 @@ proc gcUsage(conf: ConfigRef; n: PNode) =

proc strLoc(p: BProc; d: TLoc): Rope =
if p.config.selectedGc == gcDestructors:
result = addrLoc(p.config, d)
result = byRefLoc(p, d)
else:
result = rdLoc(d)

Expand Down Expand Up @@ -1110,7 +1110,7 @@ proc genStrAppend(p: BProc, e: PNode, d: var TLoc) =
strLoc(p, dest), rdLoc(a)))
if p.config.selectedGC == gcDestructors:
linefmt(p, cpsStmts, "#prepareAdd($1, $2$3);$n",
addrLoc(p.config, dest), lens, rope(L))
byRefLoc(p, dest), lens, rope(L))
else:
initLoc(call, locCall, e, OnHeap)
call.r = ropecg(p.module, "#resizeString($1, $2$3)", [rdLoc(dest), lens, rope(L)])
Expand All @@ -1123,7 +1123,7 @@ proc genSeqElemAppend(p: BProc, e: PNode, d: var TLoc) =
# seq = (typeof seq) incrSeq(&seq->Sup, sizeof(x));
# seq->data[seq->len-1] = x;
let seqAppendPattern = if not p.module.compileToCpp:
"($2) #incrSeqV3(&($1)->Sup, $3)"
"($2) #incrSeqV3((TGenericSeq*)($1), $3)"
else:
"($2) #incrSeqV3($1, $3)"
var a, b, dest, tmpL, call: TLoc
Expand Down Expand Up @@ -1997,6 +1997,11 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
of mSizeOf:
let t = e.sons[1].typ.skipTypes({tyTypeDesc})
putIntoDest(p, d, e, "((NI)sizeof($1))" % [getTypeDesc(p.module, t)])
of mAlignOf:
let t = e.sons[1].typ.skipTypes({tyTypeDesc})
if not p.module.compileToCpp:
p.module.includeHeader("<stdalign.h>")
putIntoDest(p, d, e, "((NI)alignof($1))" % [getTypeDesc(p.module, t)])
of mChr: genSomeCast(p, e, d)
of mOrd: genOrd(p, e, d)
of mLengthArray, mHigh, mLengthStr, mLengthSeq, mLengthOpenArray:
Expand Down
Loading

1 comment on commit 470f4fe

@slangmgh
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge branch 'devel'

Please sign in to comment.