diff options
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/locks.nim | 28 | ||||
-rw-r--r-- | lib/core/macros.nim | 28 | ||||
-rw-r--r-- | lib/core/typeinfo.nim | 154 | ||||
-rw-r--r-- | lib/core/unsigned.nim | 2 |
4 files changed, 107 insertions, 105 deletions
diff --git a/lib/core/locks.nim b/lib/core/locks.nim index 894965a85..42a3aec7b 100644 --- a/lib/core/locks.nim +++ b/lib/core/locks.nim @@ -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 module contains Nimrod's support for locks and condition vars. +## This module contains Nim's support for locks and condition vars. ## If the symbol ``preventDeadlocks`` is defined ## (compiled with ``-d:preventDeadlocks``) special logic is added to ## every ``acquire``, ``tryAcquire`` and ``release`` action that ensures at @@ -18,17 +18,19 @@ include "system/syslocks" type - TLock* = TSysLock ## Nimrod lock; whether this is re-entrant + TLock* = TSysLock ## Nim lock; whether this is re-entrant ## or not is unspecified! However, compilation ## in preventDeadlocks-mode guarantees re-entrancy. - TCond* = TSysCond ## Nimrod condition variable + TCond* = TSysCond ## Nim condition variable - FLock* = object of TEffect ## effect that denotes that some lock operation - ## is performed - FAquireLock* = object of FLock ## effect that denotes that some lock is - ## aquired - FReleaseLock* = object of FLock ## effect that denotes that some lock is - ## released + LockEffect* = object of RootEffect ## effect that denotes that some lock operation + ## is performed + AquireEffect* = object of LockEffect ## effect that denotes that some lock is + ## aquired + ReleaseEffect* = object of LockEffect ## effect that denotes that some lock is + ## released +{.deprecated: [FLock: LockEffect, FAquireLock: AquireEffect, + FReleaseLock: ReleaseEffect].} const noDeadlocks = defined(preventDeadlocks) @@ -58,7 +60,7 @@ proc deinitLock*(lock: var TLock) {.inline.} = ## Frees the resources associated with the lock. deinitSys(lock) -proc tryAcquire*(lock: var TLock): bool {.tags: [FAquireLock].} = +proc tryAcquire*(lock: var TLock): bool {.tags: [AquireEffect].} = ## Tries to acquire the given lock. Returns `true` on success. result = tryAcquireSys(lock) when noDeadlocks: @@ -90,7 +92,7 @@ proc tryAcquire*(lock: var TLock): bool {.tags: [FAquireLock].} = inc(locksLen) assert orderedLocks() -proc acquire*(lock: var TLock) {.tags: [FAquireLock].} = +proc acquire*(lock: var TLock) {.tags: [AquireEffect].} = ## Acquires the given lock. when nodeadlocks: var p = addr(lock) @@ -135,7 +137,7 @@ proc acquire*(lock: var TLock) {.tags: [FAquireLock].} = else: acquireSys(lock) -proc release*(lock: var TLock) {.tags: [FReleaseLock].} = +proc release*(lock: var TLock) {.tags: [ReleaseEffect].} = ## Releases the given lock. when nodeadlocks: var p = addr(lock) diff --git a/lib/core/macros.nim b/lib/core/macros.nim index e290cce32..32e74aebf 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -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 @@ -97,7 +97,7 @@ type TNimSymKinds* = set[TNimrodSymKind] type - TNimrodIdent* = object of TObject + TNimrodIdent* = object of RootObj ## represents a Nimrod identifier in the AST TNimrodSymbol {.final.} = object # hidden @@ -261,7 +261,7 @@ proc getAst*(macroOrTemplate: expr): PNimrodNode {.magic: "ExpandToAst", noSideE ## Obtains the AST nodes returned from a macro or template invocation. ## Example: ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## ## macro FooMacro() = ## var ast = getAst(BarTemplate()) @@ -278,7 +278,7 @@ proc quote*(bl: stmt, op = "``"): PNimrodNode {.magic: "QuoteAst", noSideEffect. ## ## Example: ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## ## macro check(ex: expr): stmt = ## # this is a simplified version of the check macro from the @@ -422,7 +422,7 @@ proc lispRepr*(n: PNimrodNode): string {.compileTime.} = add(result, ")") macro dumpTree*(s: stmt): stmt {.immediate.} = echo s.treeRepr - ## Accepts a block of nimrod code and prints the parsed abstract syntax + ## Accepts a block of nim code and prints the parsed abstract syntax ## tree using the `toTree` function. Printing is done *at compile time*. ## ## You can use this as a tool to explore the Nimrod's abstract syntax @@ -430,7 +430,7 @@ macro dumpTree*(s: stmt): stmt {.immediate.} = echo s.treeRepr ## a certain expression/statement. macro dumpLisp*(s: stmt): stmt {.immediate.} = echo s.lispRepr - ## Accepts a block of nimrod code and prints the parsed abstract syntax + ## Accepts a block of nim code and prints the parsed abstract syntax ## tree using the `toLisp` function. Printing is done *at compile time*. ## ## See `dumpTree`. @@ -489,7 +489,7 @@ proc newIdentDefs*(name, kind: PNimrodNode; ## ``let`` or ``var`` blocks may have an empty ``kind`` node if the ## identifier is being assigned a value. Example: ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## ## var varSection = newNimNode(nnkVarSection).add( ## newIdentDefs(ident("a"), ident("string")), @@ -501,7 +501,7 @@ proc newIdentDefs*(name, kind: PNimrodNode; ## If you need to create multiple identifiers you need to use the lower level ## ``newNimNode``: ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## ## result = newNimNode(nnkIdentDefs).add( ## ident("a"), ident("b"), ident("c"), ident("string"), @@ -549,7 +549,7 @@ proc newIfStmt*(branches: varargs[tuple[cond, body: PNimrodNode]]): PNimrodNode {.compiletime.} = ## Constructor for ``if`` statements. ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## ## newIfStmt( ## (Ident, StmtList), @@ -596,7 +596,7 @@ proc `pragma=`*(someProc: PNimrodNode; val: PNimrodNode){.compileTime.}= someProc[4] = val -template badnodekind(k; f): stmt{.immediate.} = +template badNodeKind(k; f): stmt{.immediate.} = assert false, "Invalid node kind $# for macros.`$2`".format(k, f) proc body*(someProc: PNimrodNode): PNimrodNode {.compileTime.} = @@ -608,7 +608,7 @@ proc body*(someProc: PNimrodNode): PNimrodNode {.compileTime.} = of nnkForStmt: return someProc.last else: - badNodeKind someproc.kind, "body" + badNodeKind someProc.kind, "body" proc `body=`*(someProc: PNimrodNode, val: PNimrodNode) {.compileTime.} = case someProc.kind @@ -643,7 +643,7 @@ template findChild*(n: PNimrodNode; cond: expr): PNimrodNode {. immediate, dirty.} = ## Find the first child node matching condition (or nil). ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## var res = findChild(n, it.kind == nnkPostfix and ## it.basename.ident == !"foo") block: @@ -738,11 +738,11 @@ proc addIdentIfAbsent*(dest: PNimrodNode, ident: string) {.compiletime.} = when not defined(booting): template emit*(e: static[string]): stmt = - ## accepts a single string argument and treats it as nimrod code + ## accepts a single string argument and treats it as nim code ## that should be inserted verbatim in the program ## Example: ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## emit("echo " & '"' & "hello world".toUpper & '"') ## macro payload: stmt {.gensym.} = diff --git a/lib/core/typeinfo.nim b/lib/core/typeinfo.nim index 8df1b3dfb..842a944e1 100644 --- a/lib/core/typeinfo.nim +++ b/lib/core/typeinfo.nim @@ -1,6 +1,6 @@ # # -# Nimrod's Runtime Library +# Nim's Runtime Library # (c) Copyright 2013 Dominik Picheta, Andreas Rumpf # # See the file "copying.txt", included in this @@ -50,7 +50,7 @@ type akUInt32 = 43, ## any represents an unsigned int32 akUInt64 = 44, ## any represents an unsigned int64 - TAny* = object {.pure.} ## can represent any nimrod value; NOTE: the wrapped + TAny* = object {.pure.} ## can represent any nim value; NOTE: the wrapped ## value can be modified with its wrapper! This means ## that ``TAny`` keeps a non-traced pointer to its ## wrapped value and **must not** live longer than @@ -68,20 +68,20 @@ type const GenericSeqSize = (2 * sizeof(int)) -proc genericAssign(dest, src: Pointer, mt: PNimType) {.importCompilerProc.} -proc genericShallowAssign(dest, src: Pointer, mt: PNimType) {. +proc genericAssign(dest, src: pointer, mt: PNimType) {.importCompilerProc.} +proc genericShallowAssign(dest, src: pointer, mt: PNimType) {. importCompilerProc.} proc incrSeq(seq: PGenSeq, elemSize: int): PGenSeq {.importCompilerProc.} proc newObj(typ: PNimType, size: int): pointer {.importCompilerProc.} proc newSeq(typ: PNimType, len: int): pointer {.importCompilerProc.} -proc objectInit(dest: Pointer, typ: PNimType) {.importCompilerProc.} +proc objectInit(dest: pointer, typ: PNimType) {.importCompilerProc.} -template `+!!`(a, b: expr): expr = cast[pointer](cast[TAddress](a) + b) +template `+!!`(a, b: expr): expr = cast[pointer](cast[ByteAddress](a) + b) -proc getDiscriminant(aa: Pointer, n: ptr TNimNode): int = +proc getDiscriminant(aa: pointer, n: ptr TNimNode): int = assert(n.kind == nkCase) var d: int - var a = cast[TAddress](aa) + var a = cast[ByteAddress](aa) case n.typ.size of 1: d = ze(cast[ptr int8](a +% n.offset)[]) of 2: d = ze(cast[ptr int16](a +% n.offset)[]) @@ -89,7 +89,7 @@ proc getDiscriminant(aa: Pointer, n: ptr TNimNode): int = else: assert(false) return d -proc selectBranch(aa: Pointer, n: ptr TNimNode): ptr TNimNode = +proc selectBranch(aa: pointer, n: ptr TNimNode): ptr TNimNode = var discr = getDiscriminant(aa, n) if discr <% n.len: result = n.sons[discr] @@ -174,14 +174,14 @@ proc `[]`*(x: TAny, i: int): TAny = of tyArray: var bs = x.rawType.base.size if i >=% x.rawType.size div bs: - raise newException(EInvalidIndex, "index out of bounds") + raise newException(IndexError, "index out of bounds") return newAny(x.value +!! i*bs, x.rawType.base) of tySequence: var s = cast[ppointer](x.value)[] - if s == nil: raise newException(EInvalidValue, "sequence is nil") + if s == nil: raise newException(ValueError, "sequence is nil") var bs = x.rawType.base.size if i >=% cast[PGenSeq](s).len: - raise newException(EInvalidIndex, "index out of bounds") + raise newException(IndexError, "index out of bounds") return newAny(s +!! (GenericSeqSize+i*bs), x.rawType.base) else: assert false @@ -191,15 +191,15 @@ proc `[]=`*(x: TAny, i: int, y: TAny) = of tyArray: var bs = x.rawType.base.size if i >=% x.rawType.size div bs: - raise newException(EInvalidIndex, "index out of bounds") + raise newException(IndexError, "index out of bounds") assert y.rawType == x.rawType.base genericAssign(x.value +!! i*bs, y.value, y.rawType) of tySequence: var s = cast[ppointer](x.value)[] - if s == nil: raise newException(EInvalidValue, "sequence is nil") + if s == nil: raise newException(ValueError, "sequence is nil") var bs = x.rawType.base.size if i >=% cast[PGenSeq](s).len: - raise newException(EInvalidIndex, "index out of bounds") + raise newException(IndexError, "index out of bounds") assert y.rawType == x.rawType.base genericAssign(s +!! (GenericSeqSize+i*bs), y.value, y.rawType) else: assert false @@ -276,7 +276,7 @@ proc cmpIgnoreStyle(a, b: cstring): int {.noSideEffect.} = else: result = c var i = 0 var j = 0 - while True: + while true: while a[i] == '_': inc(i) while b[j] == '_': inc(j) # BUGFIX: typo var aa = toLower(a[i]) @@ -311,12 +311,12 @@ proc `[]=`*(x: TAny, fieldName: string, value: TAny) = when false: if x.rawType.kind == tyObject: t = cast[ptr PNimType](x.value)[] assert x.rawType.kind in {tyTuple, tyObject} - var n = getFieldNode(x.value, t.node, fieldname) + var n = getFieldNode(x.value, t.node, fieldName) if n != nil: assert n.typ == value.rawType genericAssign(x.value +!! n.offset, value.value, value.rawType) else: - raise newException(EInvalidValue, "invalid field name: " & fieldName) + raise newException(ValueError, "invalid field name: " & fieldName) proc `[]`*(x: TAny, fieldName: string): TAny = ## gets a field of `x`; `x` represents an object or a tuple. @@ -325,80 +325,80 @@ proc `[]`*(x: TAny, fieldName: string): TAny = when false: if x.rawType.kind == tyObject: t = cast[ptr PNimType](x.value)[] assert x.rawType.kind in {tyTuple, tyObject} - var n = getFieldNode(x.value, t.node, fieldname) + var n = getFieldNode(x.value, t.node, fieldName) if n != nil: result.value = x.value +!! n.offset result.rawType = n.typ else: - raise newException(EInvalidValue, "invalid field name: " & fieldName) + raise newException(ValueError, "invalid field name: " & fieldName) proc `[]`*(x: TAny): TAny = ## dereference operation for the any `x` that represents a ptr or a ref. - assert x.rawtype.kind in {tyRef, tyPtr} + assert x.rawType.kind in {tyRef, tyPtr} result.value = cast[ppointer](x.value)[] result.rawType = x.rawType.base proc `[]=`*(x, y: TAny) = ## dereference operation for the any `x` that represents a ptr or a ref. - assert x.rawtype.kind in {tyRef, tyPtr} + assert x.rawType.kind in {tyRef, tyPtr} assert y.rawType == x.rawType.base genericAssign(cast[ppointer](x.value)[], y.value, y.rawType) proc getInt*(x: TAny): int = ## retrieve the int value out of `x`. `x` needs to represent an int. - assert skipRange(x.rawtype).kind == tyInt + assert skipRange(x.rawType).kind == tyInt result = cast[ptr int](x.value)[] proc getInt8*(x: TAny): int8 = ## retrieve the int8 value out of `x`. `x` needs to represent an int8. - assert skipRange(x.rawtype).kind == tyInt8 + assert skipRange(x.rawType).kind == tyInt8 result = cast[ptr int8](x.value)[] proc getInt16*(x: TAny): int16 = ## retrieve the int16 value out of `x`. `x` needs to represent an int16. - assert skipRange(x.rawtype).kind == tyInt16 + assert skipRange(x.rawType).kind == tyInt16 result = cast[ptr int16](x.value)[] proc getInt32*(x: TAny): int32 = ## retrieve the int32 value out of `x`. `x` needs to represent an int32. - assert skipRange(x.rawtype).kind == tyInt32 + assert skipRange(x.rawType).kind == tyInt32 result = cast[ptr int32](x.value)[] proc getInt64*(x: TAny): int64 = ## retrieve the int64 value out of `x`. `x` needs to represent an int64. - assert skipRange(x.rawtype).kind == tyInt64 + assert skipRange(x.rawType).kind == tyInt64 result = cast[ptr int64](x.value)[] -proc getBiggestInt*(x: TAny): biggestInt = +proc getBiggestInt*(x: TAny): BiggestInt = ## retrieve the integer value out of `x`. `x` needs to represent ## some integer, a bool, a char, an enum or a small enough bit set. - ## The value might be sign-extended to ``biggestInt``. - var t = skipRange(x.rawtype) + ## The value might be sign-extended to ``BiggestInt``. + var t = skipRange(x.rawType) case t.kind - of tyInt: result = biggestInt(cast[ptr int](x.value)[]) - of tyInt8: result = biggestInt(cast[ptr int8](x.value)[]) - of tyInt16: result = biggestInt(cast[ptr int16](x.value)[]) - of tyInt32: result = biggestInt(cast[ptr int32](x.value)[]) - of tyInt64, tyUInt64: result = biggestInt(cast[ptr int64](x.value)[]) - of tyBool: result = biggestInt(cast[ptr bool](x.value)[]) - of tyChar: result = biggestInt(cast[ptr char](x.value)[]) + of tyInt: result = BiggestInt(cast[ptr int](x.value)[]) + of tyInt8: result = BiggestInt(cast[ptr int8](x.value)[]) + of tyInt16: result = BiggestInt(cast[ptr int16](x.value)[]) + of tyInt32: result = BiggestInt(cast[ptr int32](x.value)[]) + of tyInt64, tyUInt64: result = BiggestInt(cast[ptr int64](x.value)[]) + of tyBool: result = BiggestInt(cast[ptr bool](x.value)[]) + of tyChar: result = BiggestInt(cast[ptr char](x.value)[]) of tyEnum, tySet: case t.size of 1: result = ze64(cast[ptr int8](x.value)[]) of 2: result = ze64(cast[ptr int16](x.value)[]) - of 4: result = biggestInt(cast[ptr int32](x.value)[]) - of 8: result = biggestInt(cast[ptr int64](x.value)[]) + of 4: result = BiggestInt(cast[ptr int32](x.value)[]) + of 8: result = BiggestInt(cast[ptr int64](x.value)[]) else: assert false - of tyUInt: result = biggestInt(cast[ptr uint](x.value)[]) - of tyUInt8: result = biggestInt(cast[ptr uint8](x.value)[]) - of tyUInt16: result = biggestInt(cast[ptr uint16](x.value)[]) - of tyUInt32: result = biggestInt(cast[ptr uint32](x.value)[]) + of tyUInt: result = BiggestInt(cast[ptr uint](x.value)[]) + of tyUInt8: result = BiggestInt(cast[ptr uint8](x.value)[]) + of tyUInt16: result = BiggestInt(cast[ptr uint16](x.value)[]) + of tyUInt32: result = BiggestInt(cast[ptr uint32](x.value)[]) else: assert false -proc setBiggestInt*(x: TAny, y: biggestInt) = +proc setBiggestInt*(x: TAny, y: BiggestInt) = ## sets the integer value of `x`. `x` needs to represent ## some integer, a bool, a char, an enum or a small enough bit set. - var t = skipRange(x.rawtype) + var t = skipRange(x.rawType) case t.kind of tyInt: cast[ptr int](x.value)[] = int(y) of tyInt8: cast[ptr int8](x.value)[] = int8(y) @@ -422,37 +422,37 @@ proc setBiggestInt*(x: TAny, y: biggestInt) = proc getUInt*(x: TAny): uint = ## retrieve the uint value out of `x`, `x` needs to represent an uint. - assert skipRange(x.rawtype).kind == tyUInt + assert skipRange(x.rawType).kind == tyUInt result = cast[ptr uint](x.value)[] proc getUInt8*(x: TAny): uint8 = ## retrieve the uint8 value out of `x`, `x` needs to represent an ## uint8. - assert skipRange(x.rawtype).kind == tyUInt8 + assert skipRange(x.rawType).kind == tyUInt8 result = cast[ptr uint8](x.value)[] proc getUInt16*(x: TAny): uint16 = ## retrieve the uint16 value out of `x`, `x` needs to represent an ## uint16. - assert skipRange(x.rawtype).kind == tyUInt16 + assert skipRange(x.rawType).kind == tyUInt16 result = cast[ptr uint16](x.value)[] proc getUInt32*(x: TAny): uint32 = ## retrieve the uint32 value out of `x`, `x` needs to represent an ## uint32. - assert skipRange(x.rawtype).kind == tyUInt32 + assert skipRange(x.rawType).kind == tyUInt32 result = cast[ptr uint32](x.value)[] proc getUInt64*(x: TAny): uint64 = ## retrieve the uint64 value out of `x`, `x` needs to represent an ## uint64. - assert skipRange(x.rawtype).kind == tyUInt64 + assert skipRange(x.rawType).kind == tyUInt64 result = cast[ptr uint64](x.value)[] proc getBiggestUint*(x: TAny): uint64 = ## retrieve the unsigned integer value out of `x`. `x` needs to ## represent an unsigned integer. - var t = skipRange(x.rawtype) + var t = skipRange(x.rawType) case t.kind of tyUInt: result = uint64(cast[ptr uint](x.value)[]) of tyUInt8: result = uint64(cast[ptr uint8](x.value)[]) @@ -464,7 +464,7 @@ proc getBiggestUint*(x: TAny): uint64 = proc setBiggestUint*(x: TAny; y: uint64) = ## sets the unsigned integer value of `c`. `c` needs to represent an ## unsigned integer. - var t = skipRange(x.rawtype) + var t = skipRange(x.rawType) case t.kind: of tyUInt: cast[ptr uint](x.value)[] = uint(y) of tyUInt8: cast[ptr uint8](x.value)[] = uint8(y) @@ -475,13 +475,13 @@ proc setBiggestUint*(x: TAny; y: uint64) = proc getChar*(x: TAny): char = ## retrieve the char value out of `x`. `x` needs to represent a char. - var t = skipRange(x.rawtype) + var t = skipRange(x.rawType) assert t.kind == tyChar result = cast[ptr char](x.value)[] proc getBool*(x: TAny): bool = ## retrieve the bool value out of `x`. `x` needs to represent a bool. - var t = skipRange(x.rawtype) + var t = skipRange(x.rawType) assert t.kind == tyBool result = cast[ptr bool](x.value)[] @@ -495,7 +495,7 @@ proc getEnumOrdinal*(x: TAny, name: string): int = ## gets the enum field ordinal from `name`. `x` needs to represent an enum ## but is only used to access the type information. In case of an error ## ``low(int)`` is returned. - var typ = skipRange(x.rawtype) + var typ = skipRange(x.rawType) assert typ.kind == tyEnum var n = typ.node var s = n.sons @@ -511,7 +511,7 @@ proc getEnumField*(x: TAny, ordinalValue: int): string = ## gets the enum field name as a string. `x` needs to represent an enum ## but is only used to access the type information. The field name of ## `ordinalValue` is returned. - var typ = skipRange(x.rawtype) + var typ = skipRange(x.rawType) assert typ.kind == tyEnum var e = ordinalValue if ntfEnumHole notin typ.flags: @@ -531,51 +531,51 @@ proc getEnumField*(x: TAny): string = proc getFloat*(x: TAny): float = ## retrieve the float value out of `x`. `x` needs to represent an float. - assert skipRange(x.rawtype).kind == tyFloat + assert skipRange(x.rawType).kind == tyFloat result = cast[ptr float](x.value)[] proc getFloat32*(x: TAny): float32 = ## retrieve the float32 value out of `x`. `x` needs to represent an float32. - assert skipRange(x.rawtype).kind == tyFloat32 + assert skipRange(x.rawType).kind == tyFloat32 result = cast[ptr float32](x.value)[] proc getFloat64*(x: TAny): float64 = ## retrieve the float64 value out of `x`. `x` needs to represent an float64. - assert skipRange(x.rawtype).kind == tyFloat64 + assert skipRange(x.rawType).kind == tyFloat64 result = cast[ptr float64](x.value)[] -proc getBiggestFloat*(x: TAny): biggestFloat = +proc getBiggestFloat*(x: TAny): BiggestFloat = ## retrieve the float value out of `x`. `x` needs to represent - ## some float. The value is extended to ``biggestFloat``. - case skipRange(x.rawtype).kind - of tyFloat: result = biggestFloat(cast[ptr Float](x.value)[]) - of tyFloat32: result = biggestFloat(cast[ptr Float32](x.value)[]) - of tyFloat64: result = biggestFloat(cast[ptr Float64](x.value)[]) + ## some float. The value is extended to ``BiggestFloat``. + case skipRange(x.rawType).kind + of tyFloat: result = BiggestFloat(cast[ptr float](x.value)[]) + of tyFloat32: result = BiggestFloat(cast[ptr float32](x.value)[]) + of tyFloat64: result = BiggestFloat(cast[ptr float64](x.value)[]) else: assert false -proc setBiggestFloat*(x: TAny, y: biggestFloat) = +proc setBiggestFloat*(x: TAny, y: BiggestFloat) = ## sets the float value of `x`. `x` needs to represent ## some float. - case skipRange(x.rawtype).kind - of tyFloat: cast[ptr Float](x.value)[] = y - of tyFloat32: cast[ptr Float32](x.value)[] = y.float32 - of tyFloat64: cast[ptr Float64](x.value)[] = y + case skipRange(x.rawType).kind + of tyFloat: cast[ptr float](x.value)[] = y + of tyFloat32: cast[ptr float32](x.value)[] = y.float32 + of tyFloat64: cast[ptr float64](x.value)[] = y else: assert false proc getString*(x: TAny): string = ## retrieve the string value out of `x`. `x` needs to represent a string. - assert x.rawtype.kind == tyString + assert x.rawType.kind == tyString if not isNil(cast[ptr pointer](x.value)[]): result = cast[ptr string](x.value)[] proc setString*(x: TAny, y: string) = ## sets the string value of `x`. `x` needs to represent a string. - assert x.rawtype.kind == tyString + assert x.rawType.kind == tyString cast[ptr string](x.value)[] = y proc getCString*(x: TAny): cstring = ## retrieve the cstring value out of `x`. `x` needs to represent a cstring. - assert x.rawtype.kind == tyCString + assert x.rawType.kind == tyCString result = cast[ptr cstring](x.value)[] proc assign*(x, y: TAny) = @@ -585,9 +585,9 @@ proc assign*(x, y: TAny) = genericAssign(x.value, y.value, y.rawType) iterator elements*(x: TAny): int = - ## iterates over every element of `x` that represents a Nimrod bitset. + ## iterates over every element of `x` that represents a Nim bitset. assert x.rawType.kind == tySet - var typ = x.rawtype + var typ = x.rawType var p = x.value # "typ.slots.len" field is for sets the "first" field var u: int64 @@ -607,9 +607,9 @@ iterator elements*(x: TAny): int = yield i+typ.node.len proc inclSetElement*(x: TAny, elem: int) = - ## includes an element `elem` in `x`. `x` needs to represent a Nimrod bitset. + ## includes an element `elem` in `x`. `x` needs to represent a Nim bitset. assert x.rawType.kind == tySet - var typ = x.rawtype + var typ = x.rawType var p = x.value # "typ.slots.len" field is for sets the "first" field var e = elem - typ.node.len diff --git a/lib/core/unsigned.nim b/lib/core/unsigned.nim index a3ddd4125..7acdf1439 100644 --- a/lib/core/unsigned.nim +++ b/lib/core/unsigned.nim @@ -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 |