commit
0531658c00
7 changed files with 33 additions and 30 deletions
|
|
@ -3,7 +3,7 @@ set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
if [ ! -e csources/.git ]; then
|
if [ ! -e csources/.git ]; then
|
||||||
git clone --depth 1 git://github.com/nim-lang/csources.git csources
|
git clone --depth 1 https://github.com/nim-lang/csources.git csources
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "csources"
|
cd "csources"
|
||||||
|
|
|
||||||
|
|
@ -674,17 +674,18 @@ variable number of arguments:
|
||||||
|
|
||||||
macro debug(n: varargs[expr]): stmt =
|
macro debug(n: varargs[expr]): stmt =
|
||||||
# `n` is a Nim AST that contains a list of expressions;
|
# `n` is a Nim AST that contains a list of expressions;
|
||||||
# this macro returns a list of statements:
|
# this macro returns a list of statements (n is passed for proper line
|
||||||
|
# information):
|
||||||
result = newNimNode(nnkStmtList, n)
|
result = newNimNode(nnkStmtList, n)
|
||||||
# iterate over any argument that is passed to this macro:
|
# iterate over any argument that is passed to this macro:
|
||||||
for i in 0..n.len-1:
|
for x in n:
|
||||||
# add a call to the statement list that writes the expression;
|
# add a call to the statement list that writes the expression;
|
||||||
# `toStrLit` converts an AST to its string representation:
|
# `toStrLit` converts an AST to its string representation:
|
||||||
result.add(newCall("write", newIdentNode("stdout"), toStrLit(n[i])))
|
result.add(newCall("write", newIdentNode("stdout"), toStrLit(x)))
|
||||||
# add a call to the statement list that writes ": "
|
# add a call to the statement list that writes ": "
|
||||||
result.add(newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
|
result.add(newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
|
||||||
# add a call to the statement list that writes the expressions value:
|
# add a call to the statement list that writes the expressions value:
|
||||||
result.add(newCall("writeLine", newIdentNode("stdout"), n[i]))
|
result.add(newCall("writeLine", newIdentNode("stdout"), x))
|
||||||
|
|
||||||
var
|
var
|
||||||
a: array[0..10, int]
|
a: array[0..10, int]
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ proc sort*[T](a: var openArray[T],
|
||||||
## sort(myStrArray, system.cmp)
|
## sort(myStrArray, system.cmp)
|
||||||
##
|
##
|
||||||
## You can inline adhoc comparison procs with the `do notation
|
## You can inline adhoc comparison procs with the `do notation
|
||||||
## <manual.html#do-notation>`_. Example:
|
## <manual.html#procedures-do-notation>`_. Example:
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -1047,7 +1047,7 @@ proc copyDir*(source, dest: string) {.rtl, extern: "nos$1",
|
||||||
|
|
||||||
proc createSymlink*(src, dest: string) =
|
proc createSymlink*(src, dest: string) =
|
||||||
## Create a symbolic link at `dest` which points to the item specified
|
## Create a symbolic link at `dest` which points to the item specified
|
||||||
## by `src`. On most operating systems, will fail if a lonk
|
## by `src`. On most operating systems, will fail if a link already exists.
|
||||||
##
|
##
|
||||||
## **Warning**:
|
## **Warning**:
|
||||||
## Some OS's (such as Microsoft Windows) restrict the creation
|
## Some OS's (such as Microsoft Windows) restrict the creation
|
||||||
|
|
@ -1070,8 +1070,8 @@ proc createHardlink*(src, dest: string) =
|
||||||
## Create a hard link at `dest` which points to the item specified
|
## Create a hard link at `dest` which points to the item specified
|
||||||
## by `src`.
|
## by `src`.
|
||||||
##
|
##
|
||||||
## **Warning**: Most OS's restrict the creation of hard links to
|
## **Warning**: Some OS's restrict the creation of hard links to
|
||||||
## root users (administrators) .
|
## root users (administrators).
|
||||||
when defined(Windows):
|
when defined(Windows):
|
||||||
when useWinUnicode:
|
when useWinUnicode:
|
||||||
var wSrc = newWideCString(src)
|
var wSrc = newWideCString(src)
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,7 @@ proc high*[T](x: T): T {.magic: "High", noSideEffect.}
|
||||||
## var arr = [1,2,3,4,5,6,7]
|
## var arr = [1,2,3,4,5,6,7]
|
||||||
## high(arr) #=> 6
|
## high(arr) #=> 6
|
||||||
## high(2) #=> 9223372036854775807
|
## high(2) #=> 9223372036854775807
|
||||||
|
## high(int) #=> 9223372036854775807
|
||||||
|
|
||||||
proc low*[T](x: T): T {.magic: "Low", noSideEffect.}
|
proc low*[T](x: T): T {.magic: "Low", noSideEffect.}
|
||||||
## returns the lowest possible index of an array, a sequence, a string or
|
## returns the lowest possible index of an array, a sequence, a string or
|
||||||
|
|
@ -236,6 +237,7 @@ proc low*[T](x: T): T {.magic: "Low", noSideEffect.}
|
||||||
## var arr = [1,2,3,4,5,6,7]
|
## var arr = [1,2,3,4,5,6,7]
|
||||||
## low(arr) #=> 0
|
## low(arr) #=> 0
|
||||||
## low(2) #=> -9223372036854775808
|
## low(2) #=> -9223372036854775808
|
||||||
|
## low(int) #=> -9223372036854775808
|
||||||
|
|
||||||
type
|
type
|
||||||
range*{.magic: "Range".}[T] ## Generic type to construct range types.
|
range*{.magic: "Range".}[T] ## Generic type to construct range types.
|
||||||
|
|
@ -603,7 +605,7 @@ proc `<`*[T](x: Ordinal[T]): T {.magic: "UnaryLt", noSideEffect.}
|
||||||
## unary ``<`` that can be used for nice looking excluding ranges:
|
## unary ``<`` that can be used for nice looking excluding ranges:
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## for i in 0 .. <10: echo i
|
## for i in 0 .. <10: echo i #=> 0 1 2 3 4 5 6 7 8 9
|
||||||
##
|
##
|
||||||
## Semantically this is the same as ``pred``.
|
## Semantically this is the same as ``pred``.
|
||||||
|
|
||||||
|
|
@ -889,8 +891,8 @@ proc `shl` *(x, y: int64): int64 {.magic: "ShlI", noSideEffect.}
|
||||||
## computes the `shift left` operation of `x` and `y`.
|
## computes the `shift left` operation of `x` and `y`.
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
## 1'i32 shl 4 == 0x0000_0010
|
## 1'i32 shl 4 == 0x0000_0010
|
||||||
## 1'i64 shl 4 == 0x0000_0000_0000_0010
|
## 1'i64 shl 4 == 0x0000_0000_0000_0010
|
||||||
|
|
||||||
proc `and` *(x, y: int): int {.magic: "BitandI", noSideEffect.}
|
proc `and` *(x, y: int): int {.magic: "BitandI", noSideEffect.}
|
||||||
proc `and` *(x, y: int8): int8 {.magic: "BitandI", noSideEffect.}
|
proc `and` *(x, y: int8): int8 {.magic: "BitandI", noSideEffect.}
|
||||||
|
|
@ -1313,20 +1315,20 @@ when defined(boehmgc):
|
||||||
|
|
||||||
when taintMode:
|
when taintMode:
|
||||||
type TaintedString* = distinct string ## a distinct string type that
|
type TaintedString* = distinct string ## a distinct string type that
|
||||||
## is `tainted`:idx:. It is an alias for
|
## is `tainted`:idx:, see `taint mode
|
||||||
|
## <manual.html#taint-mode>`_ for
|
||||||
|
## details. It is an alias for
|
||||||
## ``string`` if the taint mode is not
|
## ``string`` if the taint mode is not
|
||||||
## turned on. Use the ``-d:taintMode``
|
## turned on.
|
||||||
## command line switch to turn the taint
|
|
||||||
## mode on.
|
|
||||||
|
|
||||||
proc len*(s: TaintedString): int {.borrow.}
|
proc len*(s: TaintedString): int {.borrow.}
|
||||||
else:
|
else:
|
||||||
type TaintedString* = string ## a distinct string type that
|
type TaintedString* = string ## a distinct string type that
|
||||||
## is `tainted`:idx:. It is an alias for
|
## is `tainted`:idx:, see `taint mode
|
||||||
|
## <manual.html#taint-mode>`_ for
|
||||||
|
## details. It is an alias for
|
||||||
## ``string`` if the taint mode is not
|
## ``string`` if the taint mode is not
|
||||||
## turned on. Use the ``-d:taintMode``
|
## turned on.
|
||||||
## command line switch to turn the taint
|
|
||||||
## mode on.
|
|
||||||
|
|
||||||
when defined(profiler):
|
when defined(profiler):
|
||||||
proc nimProfile() {.compilerProc, noinline.}
|
proc nimProfile() {.compilerProc, noinline.}
|
||||||
|
|
@ -1410,7 +1412,7 @@ proc del*[T](x: var seq[T], i: Natural) {.noSideEffect.} =
|
||||||
## This is an O(1) operation.
|
## This is an O(1) operation.
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## var i = @[1,2,3,4,5]
|
## var i = @[1, 2, 3, 4, 5]
|
||||||
## i.del(2) #=> @[1, 2, 5, 4]
|
## i.del(2) #=> @[1, 2, 5, 4]
|
||||||
let xl = x.len - 1
|
let xl = x.len - 1
|
||||||
shallowCopy(x[i], x[xl])
|
shallowCopy(x[i], x[xl])
|
||||||
|
|
@ -1421,7 +1423,7 @@ proc delete*[T](x: var seq[T], i: Natural) {.noSideEffect.} =
|
||||||
## This is an O(n) operation.
|
## This is an O(n) operation.
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## var i = @[1,2,3,4,5]
|
## var i = @[1, 2, 3, 4, 5]
|
||||||
## i.delete(2) #=> @[1, 2, 4, 5]
|
## i.delete(2) #=> @[1, 2, 4, 5]
|
||||||
template defaultImpl =
|
template defaultImpl =
|
||||||
let xl = x.len
|
let xl = x.len
|
||||||
|
|
@ -1440,8 +1442,8 @@ proc insert*[T](x: var seq[T], item: T, i = 0.Natural) {.noSideEffect.} =
|
||||||
## inserts `item` into `x` at position `i`.
|
## inserts `item` into `x` at position `i`.
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## var i = @[1,2,3,4,5]
|
## var i = @[1, 2, 3, 4, 5]
|
||||||
## i.insert(2,4) #=> @[1, 2, 3, 4, 2, 5]
|
## i.insert(2, 4) #=> @[1, 2, 3, 4, 2, 5]
|
||||||
template defaultImpl =
|
template defaultImpl =
|
||||||
let xl = x.len
|
let xl = x.len
|
||||||
setLen(x, xl+1)
|
setLen(x, xl+1)
|
||||||
|
|
@ -1465,8 +1467,8 @@ proc repr*[T](x: T): string {.magic: "Repr", noSideEffect.}
|
||||||
## debugging tool.
|
## debugging tool.
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## var s: seq[string] = @["test2","test2"]
|
## var s: seq[string] = @["test2", "test2"]
|
||||||
## var i = @[1,2,3,4,5]
|
## var i = @[1, 2, 3, 4, 5]
|
||||||
## repr(s) #=> 0x1055eb050[0x1055ec050"test2", 0x1055ec078"test2"]
|
## repr(s) #=> 0x1055eb050[0x1055ec050"test2", 0x1055ec078"test2"]
|
||||||
## repr(i) #=> 0x1055ed050[1, 2, 3, 4, 5]
|
## repr(i) #=> 0x1055ed050[1, 2, 3, 4, 5]
|
||||||
|
|
||||||
|
|
@ -2792,7 +2794,7 @@ when not defined(JS): #and not defined(nimscript):
|
||||||
|
|
||||||
proc writeLine*[Ty](f: File, x: varargs[Ty, `$`]) {.inline,
|
proc writeLine*[Ty](f: File, x: varargs[Ty, `$`]) {.inline,
|
||||||
tags: [WriteIOEffect], benign.}
|
tags: [WriteIOEffect], benign.}
|
||||||
## writes the values `x` to `f` and then writes "\n".
|
## writes the values `x` to `f` and then writes "\\n".
|
||||||
## May throw an IO exception.
|
## May throw an IO exception.
|
||||||
|
|
||||||
proc getFileSize*(f: File): int64 {.tags: [ReadIOEffect], benign.}
|
proc getFileSize*(f: File): int64 {.tags: [ReadIOEffect], benign.}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ Just a dumb little game
|
||||||
|
|
||||||
### How to build?
|
### How to build?
|
||||||
|
|
||||||
* `git clone --recursive git://github.com/fowlmouth/keineSchweine.git somedir`
|
* `git clone --recursive https://github.com/fowlmouth/keineSchweine.git somedir`
|
||||||
* `cd somedir`
|
* `cd somedir`
|
||||||
* `nim c -r nakefile test` or `nim c -r keineschweine && ./keineschweine`
|
* `nim c -r nakefile test` or `nim c -r keineschweine && ./keineschweine`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,9 @@ directory where you would like the download to take place.
|
||||||
The following commands can be used to download the current development branch
|
The following commands can be used to download the current development branch
|
||||||
and then to build it::
|
and then to build it::
|
||||||
|
|
||||||
git clone git://github.com/nim-lang/Nim.git
|
git clone https://github.com/nim-lang/Nim.git
|
||||||
cd Nim
|
cd Nim
|
||||||
git clone --depth 1 git://github.com/nim-lang/csources
|
git clone --depth 1 https://github.com/nim-lang/csources
|
||||||
cd csources && sh build.sh
|
cd csources && sh build.sh
|
||||||
cd ..
|
cd ..
|
||||||
bin/nim c koch
|
bin/nim c koch
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue