the big renamefest: first steps

This commit is contained in:
Araq
2014-08-22 23:54:26 +02:00
parent 014b79617e
commit dbf9117c56
56 changed files with 529 additions and 508 deletions

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this
@@ -31,10 +31,10 @@ type
state: TTokenClass
TSourceLanguage* = enum
langNone, langNimrod, langCpp, langCsharp, langC, langJava
langNone, langNim, langCpp, langCsharp, langC, langJava
const
sourceLanguageToStr*: array[TSourceLanguage, string] = ["none", "Nimrod",
sourceLanguageToStr*: array[TSourceLanguage, string] = ["none", "Nim",
"C++", "C#", "C", "Java"]
tokenClassToStr*: array[TTokenClass, string] = ["Eof", "None", "Whitespace",
"DecNumber", "BinNumber", "HexNumber", "OctNumber", "FloatNumber",
@@ -46,7 +46,7 @@ const
# The following list comes from doc/keywords.txt, make sure it is
# synchronized with this array by running the module itself as a test case.
nimrodKeywords = ["addr", "and", "as", "asm", "atomic", "bind", "block",
nimKeywords = ["addr", "and", "as", "asm", "atomic", "bind", "block",
"break", "case", "cast", "const", "continue", "converter", "discard",
"distinct", "div", "do", "elif", "else", "end", "enum", "except", "export",
"finally", "for", "from", "generic", "if", "import", "in", "include",
@@ -79,7 +79,7 @@ proc deinitGeneralTokenizer*(g: var TGeneralTokenizer) =
discard
proc nimGetKeyword(id: string): TTokenClass =
for k in nimrodKeywords:
for k in nimKeywords:
if cmpIgnoreStyle(id, k) == 0: return gtKeyword
result = gtIdentifier
when false:
@@ -542,7 +542,7 @@ proc javaNextToken(g: var TGeneralTokenizer) =
proc getNextToken*(g: var TGeneralTokenizer, lang: TSourceLanguage) =
case lang
of langNone: assert false
of langNimrod: nimNextToken(g)
of langNim: nimNextToken(g)
of langCpp: cppNextToken(g)
of langCsharp: csharpNextToken(g)
of langC: cNextToken(g)
@@ -557,7 +557,7 @@ when isMainModule:
keywords = input.split()
break
doAssert(not keywords.isNil, "Couldn't read any keywords.txt file!")
doAssert keywords.len == nimrodKeywords.len, "No matching lengths"
doAssert keywords.len == nimKeywords.len, "No matching lengths"
for i in 0..keywords.len-1:
#echo keywords[i], " == ", nimrodKeywords[i]
doAssert keywords[i] == nimrodKeywords[i], "Unexpected keyword"
#echo keywords[i], " == ", nimKeywords[i]
doAssert keywords[i] == nimKeywords[i], "Unexpected keyword"

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this
@@ -103,7 +103,7 @@ proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget,
##
## Example:
##
## .. code-block:: nimrod
## .. code-block:: nim
##
## import packages/docutils/rstgen
##
@@ -231,7 +231,7 @@ proc renderRstToOut*(d: var TRstGenerator, n: PRstNode, result: var string)
## ``initRstGenerator`` and parse a rst file with ``rstParse`` from the
## `packages/docutils/rst module <rst.html>`_. Example:
##
## .. code-block:: nimrod
## .. code-block:: nim
##
## # ...configure gen and rst vars...
## var generatedHTML = ""
@@ -597,7 +597,7 @@ proc mergeIndexes*(dir: string): string =
## Merges all index files in `dir` and returns the generated index as HTML.
##
## This proc will first scan `dir` for index files with the ``.idx``
## extension previously created by commands like ``nimrod doc|rst2html``
## extension previously created by commands like ``nim doc|rst2html``
## which use the ``--index:on`` switch. These index files are the result of
## calls to `setIndexTerm() <#setIndexTerm>`_ and `writeIndexFile()
## <#writeIndexFile>`_, so they are simple tab separated files.
@@ -768,7 +768,7 @@ proc renderCodeBlock(d: PDoc, n: PRstNode, result: var string) =
var langstr = strip(getArgument(n))
var lang: TSourceLanguage
if langstr == "":
lang = langNimrod # default language
lang = langNim # default language
else:
lang = getSourceLanguage(langstr)
@@ -1123,7 +1123,7 @@ proc rstToHtml*(s: string, options: TRstParseOptions,
## work. For an explanation of the ``config`` parameter see the
## ``initRstGenerator`` proc. Example:
##
## .. code-block:: nimrod
## .. code-block:: nim
## import packages/docutils/rstgen, strtabs
##
## echo rstToHtml("*Hello* **world**!", {},

View File

@@ -2015,7 +2015,7 @@ template accumulateResult*(iter: expr) =
for x in iter: add(result, x)
# we have to compute this here before turning it off in except.nim anyway ...
const nimrodStackTrace = compileOption("stacktrace")
const NimStackTrace = compileOption("stacktrace")
{.push checks: off.}
# obviously we cannot generate checking operations here :-)

View File

@@ -1,13 +1,13 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
# Low level allocator for Nimrod. Has been designed to support the GC.
# Low level allocator for Nim. Has been designed to support the GC.
# TODO:
# - eliminate "used" field
# - make searching for block O(1)

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2013 Andreas Rumpf
#
# See the file "copying.txt", included in this
@@ -8,7 +8,7 @@
#
# This include file contains headers of Ansi C procs
# and definitions of Ansi C types in Nimrod syntax
# and definitions of Ansi C types in Nim syntax
# All symbols are prefixed with 'c_' to avoid ambiguities
{.push hints:off}

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,13 +1,13 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2014 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
# Atomic operations for Nimrod.
# Atomic operations for Nim.
{.push stackTrace:off.}
const someGcc = defined(gcc) or defined(llvm_gcc) or defined(clang)
@@ -159,6 +159,7 @@ when someGcc and hasThreadSupport:
elif defined(vcc) and hasThreadSupport:
proc addAndFetch*(p: ptr int, val: int): int {.
importc: "NimXadd", nodecl.}
proc fence*() {.importc: "_ReadWriteBarrier", header: "<intrin.h>".}
else:
proc addAndFetch*(p: ptr int, val: int): int {.inline.} =

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2013 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2014 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2013 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2013 Andreas Rumpf
#
# See the file "copying.txt", included in this
@@ -293,7 +293,7 @@ proc checkWatchpoints =
Watchpoints[i].oldValue = newHash
proc endb(line: int, file: cstring) {.compilerproc, noinline.} =
# This proc is called before every Nimrod code line!
# This proc is called before every Nim code line!
if framePtr == nil: return
if dbgWatchpointHook != nil: checkWatchpoints()
framePtr.line = line # this is done here for smaller code size!

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2014 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2013 Andreas Rumpf
#
# See the file "copying.txt", included in this
@@ -11,7 +11,7 @@
# with the application. Mostly we do not use dynamic memory here as that
# would interfere with the GC and trigger ON/OFF errors if the
# user program corrupts memory. Unfortunately, for dispaying
# variables we use the ``system.repr()`` proc which uses Nimrod
# variables we use the ``system.repr()`` proc which uses Nim
# strings and thus allocates memory from the heap. Pity, but
# I do not want to implement ``repr()`` twice.

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2014 Andreas Rumpf
#
# See the file "copying.txt", included in this
@@ -68,8 +68,8 @@ proc popCurrentException {.compilerRtl, inl.} =
# some platforms have native support for stack traces:
const
nativeStackTraceSupported* = (defined(macosx) or defined(linux)) and
not nimrodStackTrace
hasSomeStackTrace = nimrodStackTrace or
not NimStackTrace
hasSomeStackTrace = NimStackTrace or
defined(nativeStackTrace) and nativeStackTraceSupported
when defined(nativeStacktrace) and nativeStackTraceSupported:
@@ -177,7 +177,7 @@ proc auxWriteStackTrace(f: PFrame, s: var string) =
when hasSomeStackTrace:
proc rawWriteStackTrace(s: var string) =
when nimrodStackTrace:
when NimStackTrace:
if framePtr == nil:
add(s, "No stack traceback available\n")
else:
@@ -318,7 +318,7 @@ when not defined(noSignalHandler):
GC_disable()
var buf = newStringOfCap(2000)
rawWriteStackTrace(buf)
processSignal(sig, buf.add) # nice hu? currying a la nimrod :-)
processSignal(sig, buf.add) # nice hu? currying a la Nim :-)
showErrorMessage(buf)
GC_enable()
else:

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2013 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,13 +1,13 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2014 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
# A simple mark&sweep garbage collector for Nimrod. Define the
# A simple mark&sweep garbage collector for Nim. Define the
# symbol ``gcUseBitvectors`` to generate a variant of this GC.
{.push profiler:off.}

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2014 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this
@@ -103,7 +103,7 @@ proc raiseException(e: ref E_Base, ename: cstring) {.
if excHandler != nil:
excHandler.exc = e
else:
when nimrodStackTrace:
when NimStackTrace:
var buf = rawWriteStackTrace()
else:
var buf = ""

View File

@@ -1,14 +1,14 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2013 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
# Nimrod high-level memory manager: It supports Boehm's GC, no GC and the
# native Nimrod GC. The native Nimrod GC is the default.
# Nim high-level memory manager: It supports Boehm's GC, no GC and the
# native Nim GC. The native Nim GC is the default.
#{.push checks:on, assertions:on.}
{.push checks:off.}
@@ -259,7 +259,7 @@ elif defined(nogc) and defined(useMalloc):
elif defined(nogc):
# Even though we don't want the GC, we cannot simply use C's memory manager
# because Nimrod's runtime wants ``realloc`` to zero out the additional
# because Nim's runtime wants ``realloc`` to zero out the additional
# space which C's ``realloc`` does not. And we cannot get the old size of an
# object, because C does not support this operation... Even though every
# possible implementation has to have a way to determine the object's size.

View File

@@ -1,13 +1,13 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
# This file implements the Nimrod profiler. The profiler needs support by the
# This file implements the Nim profiler. The profiler needs support by the
# code generator. The idea is to inject the instruction stream
# with 'nimProfile()' calls. These calls are injected at every loop end
# (except perhaps loops that have no side-effects). At every Nth call a

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,13 +1,13 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2014 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
## Implements Nimrod's 'spawn'.
## Implements Nim's 'spawn'.
when not declared(NimString):
{.error: "You must not import this module explicitly".}

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this
@@ -119,7 +119,7 @@ proc addChar(s: NimString, c: char): NimString =
inc(result.len)
# These routines should be used like following:
# <Nimrod code>
# <Nim code>
# s &= "Hello " & name & ", how do you feel?"
#
# <generated C code>
@@ -130,7 +130,7 @@ proc addChar(s: NimString, c: char): NimString =
# appendString(s, strLit3);
# }
#
# <Nimrod code>
# <Nim code>
# s = "Hello " & name & ", how do you feel?"
#
# <generated C code>
@@ -143,7 +143,7 @@ proc addChar(s: NimString, c: char): NimString =
# s = tmp0;
# }
#
# <Nimrod code>
# <Nim code>
# s = ""
#
# <generated C code>

View File

@@ -1,17 +1,17 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
## Thread support for Nimrod. **Note**: This is part of the system module.
## Thread support for Nim. **Note**: This is part of the system module.
## Do not import it directly. To activate thread support you need to compile
## with the ``--threads:on`` command line switch.
##
## Nimrod's memory model for threads is quite different from other common
## Nim's memory model for threads is quite different from other common
## programming languages (C, Pascal): Each thread has its own
## (garbage collected) heap and sharing of memory is restricted. This helps
## to prevent race conditions and improves efficiency. See `the manual for
@@ -19,7 +19,7 @@
##
## Example:
##
## .. code-block:: nimrod
## .. code-block:: Nim
##
## import locks
##
@@ -245,14 +245,14 @@ when not defined(useNimRtl):
# the GC can examine the stacks?
proc stopTheWord() = discard
# We jump through some hops here to ensure that Nimrod thread procs can have
# the Nimrod calling convention. This is needed because thread procs are
# We jump through some hops here to ensure that Nim thread procs can have
# the Nim calling convention. This is needed because thread procs are
# ``stdcall`` on Windows and ``noconv`` on UNIX. Alternative would be to just
# use ``stdcall`` since it is mapped to ``noconv`` on UNIX anyway.
type
TThread* {.pure, final.}[TArg] =
object of TGcThread ## Nimrod thread. A thread is a heavy object (~14K)
object of TGcThread ## Nim thread. A thread is a heavy object (~14K)
## that **must not** be part of a message! Use
## a ``TThreadId`` for that.
when TArg is void:

View File

@@ -1,6 +1,6 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this

View File

@@ -1,13 +1,13 @@
#
#
# Nimrod's Runtime Library
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
# Nimrod support for C/C++'s `wide strings`:idx:. This is part of the system
# Nim support for C/C++'s `wide strings`:idx:. This is part of the system
# module! Do not import it directly!
when not declared(NimString):