diff options
Diffstat (limited to 'lib/core')
-rwxr-xr-x | lib/core/macros.nim | 12 | ||||
-rwxr-xr-x | lib/core/typeinfo.nim | 13 |
2 files changed, 18 insertions, 7 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 966a21a1b..bf7510a92 100755 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -45,8 +45,16 @@ type nnkConstDef, nnkTypeDef, nnkYieldStmt, nnkTryStmt, nnkFinally, nnkRaiseStmt, nnkReturnStmt, nnkBreakStmt, nnkContinueStmt, nnkBlockStmt, nnkStaticStmt, - nnkDiscardStmt, nnkStmtList, nnkImportStmt, nnkFromStmt, - nnkIncludeStmt, nnkBindStmt, nnkMixinStmt, + nnkDiscardStmt, nnkStmtList, + + nnkImportStmt, + nnkImportExceptStmt, + nnkExportStmt, + nnkExportExceptStmt, + nnkFromStmt, + nnkIncludeStmt, + + nnkBindStmt, nnkMixinStmt, nnkCommentStmt, nnkStmtListExpr, nnkBlockExpr, nnkStmtListType, nnkBlockType, nnkTypeOfExpr, nnkObjectTy, nnkTupleTy, nnkRecList, nnkRecCase, nnkRecWhen, diff --git a/lib/core/typeinfo.nim b/lib/core/typeinfo.nim index 26a14f444..eb2a0c9e5 100755 --- a/lib/core/typeinfo.nim +++ b/lib/core/typeinfo.nim @@ -1,7 +1,7 @@ # # # Nimrod's Runtime Library -# (c) Copyright 2012 Dominik Picheta, Andreas Rumpf +# (c) Copyright 2013 Dominik Picheta, Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -139,12 +139,15 @@ proc invokeNewSeq*(x: TAny, len: int) = var z = newSeq(x.rawType, len) genericShallowAssign(x.value, addr(z), x.rawType) -proc extendSeq*(x: TAny, elems = 1) = - ## performs ``setLen(x, x.len+elems)``. `x` needs to represent a ``seq``. +proc extendSeq*(x: TAny) = + ## performs ``setLen(x, x.len+1)``. `x` needs to represent a ``seq``. assert x.rawType.kind == tySequence var y = cast[ptr PGenSeq](x.value)[] - var z = incrSeq(y, x.rawType.base.size * elems) - genericShallowAssign(x.value, addr(z), x.rawType) + var z = incrSeq(y, x.rawType.base.size) + # 'incrSeq' already freed the memory for us and copied over the RC! + # So we simply copy the raw pointer into 'x.value': + cast[ppointer](x.value)[] = z + #genericShallowAssign(x.value, addr(z), x.rawType) proc setObjectRuntimeType*(x: TAny) = ## this needs to be called to set `x`'s runtime object type field. |