summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/lexer.nim2
-rw-r--r--lib/pure/os.nim22
-rw-r--r--lib/pure/osproc.nim22
-rw-r--r--lib/pure/sockets.nim66
-rw-r--r--lib/system.nim7
5 files changed, 60 insertions, 59 deletions
diff --git a/compiler/lexer.nim b/compiler/lexer.nim
index bcc02da9e..abc491bfe 100644
--- a/compiler/lexer.nim
+++ b/compiler/lexer.nim
@@ -431,7 +431,7 @@ proc getNumber(L: var TLexer): TToken =
         lexMessage(L, errNumberOutOfRange, result.literal)
   except ValueError:
     lexMessage(L, errInvalidNumber, result.literal)
-  except OverflowError, EOutOfRange:
+  except OverflowError, RangeError:
     lexMessage(L, errNumberOutOfRange, result.literal)
   L.bufpos = endpos
 
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index d8a0f910a..483044d0a 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -951,7 +951,7 @@ proc setFilePermissions*(filename: string, permissions: set[TFilePermission]) {.
     if res2 == - 1'i32: osError(osLastError())
 
 proc copyFile*(source, dest: string) {.rtl, extern: "nos$1",
-  tags: [ReadIOEffect, FWriteIO].} =
+  tags: [ReadIOEffect, WriteIOEffect].} =
   ## Copies a file from `source` to `dest`.
   ##
   ## If this fails, `EOS` is raised. On the Windows platform this proc will
@@ -972,7 +972,7 @@ proc copyFile*(source, dest: string) {.rtl, extern: "nos$1",
   else:
     # generic version of copyFile which works for any platform:
     const bufSize = 8000 # better for memory manager
-    var d, s: TFile
+    var d, s: File
     if not open(s, source): osError(osLastError())
     if not open(d, dest, fmWrite):
       close(s)
@@ -993,7 +993,7 @@ proc copyFile*(source, dest: string) {.rtl, extern: "nos$1",
     close(d)
 
 proc moveFile*(source, dest: string) {.rtl, extern: "nos$1",
-  tags: [ReadIOEffect, FWriteIO].} =
+  tags: [ReadIOEffect, WriteIOEffect].} =
   ## Moves a file from `source` to `dest`. If this fails, `EOS` is raised.
   if c_rename(source, dest) != 0'i32:
     raise newException(OSError, $strerror(errno))
@@ -1031,7 +1031,7 @@ proc removeFile*(file: string) {.rtl, extern: "nos$1", tags: [FWriteDir].} =
           osError(osLastError())
   else:
     if c_remove(file) != 0'i32 and errno != ENOENT:
-      raise newException(EOS, $strerror(errno))
+      raise newException(OSError, $strerror(errno))
 
 proc execShellCmd*(command: string): int {.rtl, extern: "nos$1",
   tags: [ExecIOEffect].} =
@@ -1364,7 +1364,7 @@ proc createDir*(dir: string) {.rtl, extern: "nos$1", tags: [FWriteDir].} =
   rawCreateDir(dir)
 
 proc copyDir*(source, dest: string) {.rtl, extern: "nos$1",
-  tags: [WriteIOEffect, FReadIO].} =
+  tags: [WriteIOEffect, ReadIOEffect].} =
   ## Copies a directory from `source` to `dest`.
   ##
   ## If this fails, `EOS` is raised. On the Windows platform this proc will
@@ -1537,7 +1537,7 @@ proc copyFileWithPermissions*(source, dest: string,
 
 proc copyDirWithPermissions*(source, dest: string,
     ignorePermissionErrors = true) {.rtl, extern: "nos$1",
-    tags: [WriteIOEffect, FReadIO].} =
+    tags: [WriteIOEffect, ReadIOEffect].} =
   ## Copies a directory from `source` to `dest` preserving file permissions.
   ##
   ## If this fails, `EOS` is raised. This is a wrapper proc around `copyDir()
@@ -1674,12 +1674,12 @@ elif not defined(createNimRtl):
     cmdCount {.importc: "cmdCount".}: cint
     cmdLine {.importc: "cmdLine".}: cstringArray
 
-  proc paramStr*(i: int): TaintedString {.tags: [FReadIO].} =
+  proc paramStr*(i: int): TaintedString {.tags: [ReadIOEffect].} =
     # Docstring in nimdoc block.
     if i < cmdCount and i >= 0: return TaintedString($cmdLine[i])
-    raise newException(EInvalidIndex, "invalid index")
+    raise newException(IndexError, "invalid index")
 
-  proc paramCount*(): int {.tags: [FReadIO].} =
+  proc paramCount*(): int {.tags: [ReadIOEffect].} =
     # Docstring in nimdoc block.
     result = cmdCount-1
 
@@ -1820,7 +1820,7 @@ proc getFileSize*(file: string): BiggestInt {.rtl, extern: "nos$1",
     result = rdFileSize(a)
     findClose(resA)
   else:
-    var f: TFile
+    var f: File
     if open(f, file):
       result = getFileSize(f)
       close(f)
@@ -1867,7 +1867,7 @@ when defined(Windows):
 else:
   type
     DeviceId* = TDev
-    FileId* = TIno
+    FileId* = Tino
 
 type
   FileInfo* = object
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index 37b36e7cc..d5ca2f5a5 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -30,7 +30,7 @@ type
       inHandle, outHandle, errHandle: FileHandle
       id: THandle
     else:
-      inHandle, outHandle, errHandle: TFileHandle
+      inHandle, outHandle, errHandle: FileHandle
       inStream, outStream, errStream: PStream
       id: TPid
     exitCode: cint
@@ -109,7 +109,7 @@ proc execProcess*(command: string,
                                                   poUsePath,
                                                   poEvalCommand}): TaintedString {.
                                                   rtl, extern: "nosp$1",
-                                                  tags: [ExecIOEffect, FReadIO].}
+                                                  tags: [ExecIOEffect, ReadIOEffect].}
   ## A convenience procedure that executes ``command`` with ``startProcess``
   ## and returns its output as a string.
   ## WARNING: this function uses poEvalCommand by default for backward compatibility.
@@ -233,7 +233,7 @@ proc countProcessors*(): int {.rtl, extern: "nosp$1".} =
 proc execProcesses*(cmds: openArray[string],
                     options = {poStdErrToStdOut, poParentStreams},
                     n = countProcessors()): int {.rtl, extern: "nosp$1",
-                    tags: [ExecIOEffect, FTime, FReadEnv]} =
+                    tags: [ExecIOEffect, TimeEffect, FReadEnv]} =
   ## executes the commands `cmds` in parallel. Creates `n` processes
   ## that execute in parallel. The highest return value of all processes
   ## is returned.
@@ -584,12 +584,12 @@ elif not defined(useNimRtl):
 
   when not defined(useFork):
     proc startProcessAuxSpawn(data: TStartProcessData): TPid {.
-      tags: [FExecIO, FReadEnv], gcsafe.}
+      tags: [ExecIOEffect, FReadEnv], gcsafe.}
   proc startProcessAuxFork(data: TStartProcessData): TPid {.
-    tags: [FExecIO, FReadEnv], gcsafe.}
+    tags: [ExecIOEffect, FReadEnv], gcsafe.}
   {.push stacktrace: off, profiler: off.}
   proc startProcessAfterFork(data: ptr TStartProcessData) {.
-    tags: [FExecIO, FReadEnv], cdecl, gcsafe.}
+    tags: [ExecIOEffect, FReadEnv], cdecl, gcsafe.}
   {.pop.}
 
   proc startProcess(command: string,
@@ -850,9 +850,9 @@ elif not defined(useNimRtl):
     if p.exitCode == -3: result = -1
     else: result = p.exitCode.int shr 8
 
-  proc createStream(stream: var PStream, handle: var TFileHandle,
-                    fileMode: TFileMode) =
-    var f: TFile
+  proc createStream(stream: var PStream, handle: var FileHandle,
+                    fileMode: FileMode) =
+    var f: File
     if not open(f, handle, fileMode): osError(osLastError())
     stream = newFileStream(f)
 
@@ -897,7 +897,7 @@ elif not defined(useNimRtl):
     setLen(s, L)
 
   proc select(readfds: var seq[PProcess], timeout = 500): int =
-    var tv: TTimeVal
+    var tv: Ttimeval
     tv.tv_sec = 0
     tv.tv_usec = timeout * 1000
 
@@ -916,7 +916,7 @@ elif not defined(useNimRtl):
 proc execCmdEx*(command: string, options: set[TProcessOption] = {
                 poStdErrToStdOut, poUsePath}): tuple[
                 output: TaintedString,
-                exitCode: int] {.tags: [ExecIOEffect, FReadIO], gcsafe.} =
+                exitCode: int] {.tags: [ExecIOEffect, ReadIOEffect], gcsafe.} =
   ## a convenience proc that runs the `command`, grabs all its output and
   ## exit code and returns both.
   var p = startCmd(command, options)
diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim
index 68c5ec6ae..b0cc67c70 100644
--- a/lib/pure/sockets.nim
+++ b/lib/pure/sockets.nim
@@ -131,7 +131,7 @@ type
   TReadLineResult* = enum ## result for readLineAsync
     ReadFullLine, ReadPartialLine, ReadDisconnected, ReadNone
 
-  ETimeout* = object of ESynch
+  ETimeout* = object of Exception
 
 let
   invalidSocket*: TSocket = nil ## invalid socket
@@ -439,16 +439,16 @@ proc bindAddr*(socket: TSocket, port = TPort(0), address = "") {.
     name.sin_port = sockets.htons(int16(port))
     name.sin_addr.s_addr = sockets.htonl(INADDR_ANY)
     if bindSocket(socket.fd, cast[ptr TSockAddr](addr(name)),
-                  sizeof(name).TSockLen) < 0'i32:
+                  sizeof(name).TSocklen) < 0'i32:
       osError(osLastError())
   else:
-    var hints: TAddrInfo
-    var aiList: ptr TAddrInfo = nil
+    var hints: Taddrinfo
+    var aiList: ptr Taddrinfo = nil
     hints.ai_family = toInt(AF_INET)
     hints.ai_socktype = toInt(SOCK_STREAM)
     hints.ai_protocol = toInt(IPPROTO_TCP)
     gaiNim(address, port, hints, aiList)
-    if bindSocket(socket.fd, aiList.ai_addr, aiList.ai_addrlen.TSockLen) < 0'i32:
+    if bindSocket(socket.fd, aiList.ai_addr, aiList.ai_addrlen.TSocklen) < 0'i32:
       osError(osLastError())
   
 proc getSockName*(socket: TSocket): TPort = 
@@ -460,7 +460,7 @@ proc getSockName*(socket: TSocket): TPort =
     name.sin_family = posix.AF_INET
   #name.sin_port = htons(cint16(port))
   #name.sin_addr.s_addr = htonl(INADDR_ANY)
-  var namelen = sizeof(name).TSockLen
+  var namelen = sizeof(name).TSocklen
   if getsockname(socket.fd, cast[ptr TSockAddr](addr(name)),
                  addr(namelen)) == -1'i32:
     osError(osLastError())
@@ -470,7 +470,7 @@ template acceptAddrPlain(noClientRet, successRet: expr,
                          sslImplementation: stmt): stmt {.immediate.} =
   assert(client != nil)
   var sockAddress: Tsockaddr_in
-  var addrLen = sizeof(sockAddress).TSockLen
+  var addrLen = sizeof(sockAddress).TSocklen
   var sock = accept(server.fd, cast[ptr TSockAddr](addr(sockAddress)),
                     addr(addrLen))
   
@@ -685,7 +685,7 @@ proc getHostByAddr*(ip: string): Thostent {.tags: [ReadIOEffect].} =
     var s = posix.gethostbyaddr(addr(myaddr), sizeof(myaddr).TSocklen, 
                                 cint(posix.AF_INET))
     if s == nil:
-      raise newException(EOS, $hstrerror(h_errno))
+      raise newException(OSError, $hstrerror(h_errno))
   
   result.name = $s.h_name
   result.aliases = cstringArrayToSeq(s.h_aliases)
@@ -697,7 +697,7 @@ proc getHostByAddr*(ip: string): Thostent {.tags: [ReadIOEffect].} =
     elif s.h_addrtype == posix.AF_INET6:
       result.addrtype = AF_INET6
     else:
-      raise newException(EOS, "unknown h_addrtype")
+      raise newException(OSError, "unknown h_addrtype")
   result.addrList = cstringArrayToSeq(s.h_addr_list)
   result.length = int(s.h_length)
 
@@ -718,7 +718,7 @@ proc getHostByName*(name: string): Thostent {.tags: [ReadIOEffect].} =
     elif s.h_addrtype == posix.AF_INET6:
       result.addrtype = AF_INET6
     else:
-      raise newException(EOS, "unknown h_addrtype")
+      raise newException(OSError, "unknown h_addrtype")
   result.addrList = cstringArrayToSeq(s.h_addr_list)
   result.length = int(s.h_length)
 
@@ -726,7 +726,7 @@ proc getSockOptInt*(socket: TSocket, level, optname: int): int {.
   tags: [ReadIOEffect].} = 
   ## getsockopt for integer options.
   var res: cint
-  var size = sizeof(res).TSockLen
+  var size = sizeof(res).TSocklen
   if getsockopt(socket.fd, cint(level), cint(optname), 
                 addr(res), addr(size)) < 0'i32:
     osError(osLastError())
@@ -737,7 +737,7 @@ proc setSockOptInt*(socket: TSocket, level, optname, optval: int) {.
   ## setsockopt for integer options.
   var value = cint(optval)
   if setsockopt(socket.fd, cint(level), cint(optname), addr(value),  
-                sizeof(value).TSockLen) < 0'i32:
+                sizeof(value).TSocklen) < 0'i32:
     osError(osLastError())
 
 proc toCInt(opt: TSOBool): cint =
@@ -754,7 +754,7 @@ proc getSockOpt*(socket: TSocket, opt: TSOBool, level = SOL_SOCKET): bool {.
   tags: [ReadIOEffect].} =
   ## Retrieves option ``opt`` as a boolean value.
   var res: cint
-  var size = sizeof(res).TSockLen
+  var size = sizeof(res).TSocklen
   if getsockopt(socket.fd, cint(level), toCInt(opt), 
                 addr(res), addr(size)) < 0'i32:
     osError(osLastError())
@@ -765,7 +765,7 @@ proc setSockOpt*(socket: TSocket, opt: TSOBool, value: bool, level = SOL_SOCKET)
   ## Sets option ``opt`` to a boolean value specified by ``value``.
   var valuei = cint(if value: 1 else: 0)
   if setsockopt(socket.fd, cint(level), toCInt(opt), addr(valuei),  
-                sizeof(valuei).TSockLen) < 0'i32:
+                sizeof(valuei).TSocklen) < 0'i32:
     osError(osLastError())
 
 proc connect*(socket: TSocket, address: string, port = TPort(0), 
@@ -776,8 +776,8 @@ proc connect*(socket: TSocket, address: string, port = TPort(0),
   ## not do it.
   ##
   ## If ``socket`` is an SSL socket a handshake will be automatically performed.
-  var hints: TAddrInfo
-  var aiList: ptr TAddrInfo = nil
+  var hints: Taddrinfo
+  var aiList: ptr Taddrinfo = nil
   hints.ai_family = toInt(af)
   hints.ai_socktype = toInt(SOCK_STREAM)
   hints.ai_protocol = toInt(IPPROTO_TCP)
@@ -787,7 +787,7 @@ proc connect*(socket: TSocket, address: string, port = TPort(0),
   var lastError: TOSErrorCode
   var it = aiList
   while it != nil:
-    if connect(socket.fd, it.ai_addr, it.ai_addrlen.TSockLen) == 0'i32:
+    if connect(socket.fd, it.ai_addr, it.ai_addrlen.TSocklen) == 0'i32:
       success = true
       break
     else: lastError = osLastError()
@@ -839,8 +839,8 @@ proc connectAsync*(socket: TSocket, name: string, port = TPort(0),
   ##
   ## **Note**: For SSL sockets, the ``handshake`` procedure must be called
   ## whenever the socket successfully connects to a server.
-  var hints: TAddrInfo
-  var aiList: ptr TAddrInfo = nil
+  var hints: Taddrinfo
+  var aiList: ptr Taddrinfo = nil
   hints.ai_family = toInt(af)
   hints.ai_socktype = toInt(SOCK_STREAM)
   hints.ai_protocol = toInt(IPPROTO_TCP)
@@ -850,7 +850,7 @@ proc connectAsync*(socket: TSocket, name: string, port = TPort(0),
   var lastError: TOSErrorCode
   var it = aiList
   while it != nil:
-    var ret = connect(socket.fd, it.ai_addr, it.ai_addrlen.TSockLen)
+    var ret = connect(socket.fd, it.ai_addr, it.ai_addrlen.TSocklen)
     if ret == 0'i32:
       success = true
       break
@@ -915,7 +915,7 @@ when defined(ssl):
     else:
       SSLError("Socket is not an SSL socket.")
 
-proc timeValFromMilliseconds(timeout = 500): TTimeval =
+proc timeValFromMilliseconds(timeout = 500): Ttimeval =
   if timeout != -1:
     var seconds = timeout div 1000
     result.tv_sec = seconds.int32
@@ -975,7 +975,7 @@ proc select*(readfds, writefds, exceptfds: var seq[TSocket],
   if buffersFilled > 0:
     return buffersFilled
 
-  var tv {.noInit.}: TTimeval = timeValFromMilliseconds(timeout)
+  var tv {.noInit.}: Ttimeval = timeValFromMilliseconds(timeout)
   
   var rd, wr, ex: TFdSet
   var m = 0
@@ -998,7 +998,7 @@ proc select*(readfds, writefds: var seq[TSocket],
   let buffersFilled = checkBuffer(readfds)
   if buffersFilled > 0:
     return buffersFilled
-  var tv {.noInit.}: TTimeval = timeValFromMilliseconds(timeout)
+  var tv {.noInit.}: Ttimeval = timeValFromMilliseconds(timeout)
   
   var rd, wr: TFdSet
   var m = 0
@@ -1022,7 +1022,7 @@ proc selectWrite*(writefds: var seq[TSocket],
   ##
   ## ``timeout`` is specified in miliseconds and ``-1`` can be specified for
   ## an unlimited time.
-  var tv {.noInit.}: TTimeval = timeValFromMilliseconds(timeout)
+  var tv {.noInit.}: Ttimeval = timeValFromMilliseconds(timeout)
   
   var wr: TFdSet
   var m = 0
@@ -1040,7 +1040,7 @@ proc select*(readfds: var seq[TSocket], timeout = 500): int =
   let buffersFilled = checkBuffer(readfds)
   if buffersFilled > 0:
     return buffersFilled
-  var tv {.noInit.}: TTimeval = timeValFromMilliseconds(timeout)
+  var tv {.noInit.}: Ttimeval = timeValFromMilliseconds(timeout)
   
   var rd: TFdSet
   var m = 0
@@ -1153,7 +1153,7 @@ proc waitFor(socket: TSocket, waited: var float, timeout, size: int,
     waited += (epochTime() - startTime)
 
 proc recv*(socket: TSocket, data: pointer, size: int, timeout: int): int {.
-  tags: [ReadIOEffect, FTime].} =
+  tags: [ReadIOEffect, TimeEffect].} =
   ## overload with a ``timeout`` parameter in miliseconds.
   var waited = 0.0 # number of seconds already waited  
   
@@ -1224,7 +1224,7 @@ proc peekChar(socket: TSocket, c: var char): int {.tags: [ReadIOEffect].} =
     result = recv(socket.fd, addr(c), 1, MSG_PEEK)
 
 proc recvLine*(socket: TSocket, line: var TaintedString, timeout = -1): bool {.
-  tags: [ReadIOEffect, FTime], deprecated.} =
+  tags: [ReadIOEffect, TimeEffect], deprecated.} =
   ## Receive a line of data from ``socket``.
   ##
   ## If a full line is received ``\r\L`` is not
@@ -1271,7 +1271,7 @@ proc recvLine*(socket: TSocket, line: var TaintedString, timeout = -1): bool {.
     add(line.string, c)
 
 proc readLine*(socket: TSocket, line: var TaintedString, timeout = -1) {.
-  tags: [ReadIOEffect, FTime].} =
+  tags: [ReadIOEffect, TimeEffect].} =
   ## Reads a line of data from ``socket``.
   ##
   ## If a full line is read ``\r\L`` is not
@@ -1493,7 +1493,7 @@ proc recvFrom*(socket: TSocket, data: var string, length: int,
   # TODO: Buffered sockets
   data.setLen(length)
   var sockAddress: Tsockaddr_in
-  var addrLen = sizeof(sockAddress).TSockLen
+  var addrLen = sizeof(sockAddress).TSocklen
   result = recvfrom(socket.fd, cstring(data), length.cint, flags.cint,
                     cast[ptr TSockAddr](addr(sockAddress)), addr(addrLen))
 
@@ -1627,8 +1627,8 @@ proc sendTo*(socket: TSocket, address: string, port: TPort, data: pointer,
   ## this function will try each IP of that hostname.
   ##
   ## **Note:** This proc is not available for SSL sockets.
-  var hints: TAddrInfo
-  var aiList: ptr TAddrInfo = nil
+  var hints: Taddrinfo
+  var aiList: ptr Taddrinfo = nil
   hints.ai_family = toInt(af)
   hints.ai_socktype = toInt(SOCK_STREAM)
   hints.ai_protocol = toInt(IPPROTO_TCP)
@@ -1639,7 +1639,7 @@ proc sendTo*(socket: TSocket, address: string, port: TPort, data: pointer,
   var it = aiList
   while it != nil:
     result = sendto(socket.fd, data, size.cint, flags.cint, it.ai_addr,
-                    it.ai_addrlen.TSockLen)
+                    it.ai_addrlen.TSocklen)
     if result != -1'i32:
       success = true
       break
@@ -1685,7 +1685,7 @@ discard """ proc setReuseAddr*(s: TSocket) =
     OSError(OSLastError()) """
 
 proc connect*(socket: TSocket, address: string, port = TPort(0), timeout: int,
-             af: TDomain = AF_INET) {.tags: [ReadIOEffect, FWriteIO].} =
+             af: TDomain = AF_INET) {.tags: [ReadIOEffect, WriteIOEffect].} =
   ## Connects to server as specified by ``address`` on port specified by ``port``.
   ##
   ## The ``timeout`` paremeter specifies the time in miliseconds to allow for
diff --git a/lib/system.nim b/lib/system.nim
index 73b470052..ad1cbd423 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -384,11 +384,11 @@ type
     ##
     ## This happens for calculations whose results are too large to fit in the
     ## provided bits.  See the full `exception hierarchy`_.
-  AccessViolationError* {.compilerproc.} = object of Exception ## \
+  AccessViolationError* = object of Exception ## \
     ## Raised for invalid memory access errors
     ##
     ## See the full `exception hierarchy`_.
-  AssertionError* {.compilerproc.} = object of Exception ## \
+  AssertionError* = object of Exception ## \
     ## Raised when assertion is proved wrong.
     ##
     ## Usually the result of using the `assert() template <#assert>`_.  See the
@@ -496,7 +496,8 @@ type
   EFloatingPoint: FloatingPointError,
   EFloatInvalidOp: FloatInvalidOpError,
   EFloatDivByZero: FloatDivByZeroError,
-  EFloatOverflow: FloatOverflowError
+  EFloatOverflow: FloatOverflowError,
+  ESynch: Exception
 ].}
 
 proc sizeof*[T](x: T): Natural {.magic: "SizeOf", noSideEffect.}