summary refs log tree commit diff stats
path: root/compiler/semgnrc.nim
Commit message (Expand)AuthorAgeFilesLines
...
* updated the compiler to use the new symbol namesAraq2014-08-281-4/+4
* Nimrod renamed to NimAraq2014-08-281-1/+1
* the big renamefest: first stepsAraq2014-08-221-2/+2
* fixes latest regressionAraq2014-07-111-1/+1
* fixes #1011Araq2014-07-091-3/+34
* Renamed considerAccents to considerQuotedIdentClay Sweetser2014-05-261-2/+2
* Renamed 'considerAcc' to 'considerAccents' for clarityClay Sweetser2014-05-241-2/+2
* compiler prepared for the new comment handlingAraq2014-04-301-0/+1
* propagate semExpr flags in macro/template expansionZahary Karadjov2014-04-061-4/+4
* fixes wrong commitAraq2014-03-221-2/+0
* fixes #1006Araq2014-03-221-0/+2
* split the inline and closure iterators into different symbol kinds for easier...Zahary Karadjov2014-03-061-2/+2
* fixes 'newSeq[T]' instantiation bugAraq2014-02-091-7/+4
* it's the year 2014Araq2014-01-191-3/+3
* introduce tyFromExpr; fixes #618Zahary Karadjov2014-01-041-7/+0
* case consistency part 4Araq2013-12-271-9/+9
* case consistency part 1Araq2013-12-271-1/+1
* fixes #531Araq2013-07-241-1/+1
* Merge branch 'master' of github.com:Araq/NimrodAraq2013-05-141-16/+16
|\
| * get rid of the SymTab* procs in astalgoZahary Karadjov2013-05-121-2/+2
| * switch to a linked list of scopesZahary Karadjov2013-05-111-14/+14
* | todo.txt changesAraq2013-05-111-5/+0
|/
* Removes executable bit for text files.Grzegorz Adam Hankiewicz2013-03-161-0/+0
* bugfix: 'indexOf' for tuple fields worksAraq2013-03-111-5/+0
* fixes for the new overloading resolutionAraq2013-03-031-5/+10
* bugfix: threads should work again; fixes #220Araq2012-10-121-4/+5
* allow 'mixin' in genericsAraq2012-10-121-50/+69
* syntax compatibility between do blocks and stmt blocksZahary Karadjov2012-10-041-11/+2
* the `is` operator now works with type classes and type variablesZahary Karadjov2012-10-031-10/+10
* bugfix: allow tuple constructors in generic codeZahary Karadjov2012-10-031-0/+3
* fixes #194Araq2012-09-201-1/+8
* bugfix: 'defined/compiles' open an implicit mixin scope in genericsAraq2012-09-181-3/+6
* made tests green againAraq2012-09-181-5/+12
* stricter symbol lookup in genericsAraq2012-09-171-8/+10
* first steps for overloading support of passing blocks; bugfix: test results o...Araq2012-09-111-6/+29
* parameter passing works the same for macros and templates; use callsite magic...Araq2012-08-281-2/+2
* distinguish properly between nkOpen and nkClosedSymChoiceAraq2012-08-261-6/+7
* next steps to hygienic templatesAraq2012-08-201-1/+1
* first steps to make templates hygienicAraq2012-08-201-11/+11
* bugfix: bind context for genericsAraq2012-07-241-3/+3
* added system.||; lacks runtime supportAraq2012-05-231-1/+1
* experimental support for preserving local variable names in the generated codeZahary Karadjov2012-04-131-0/+2
* `do' keyword in the grammar for lambda blocksZahary Karadjov2012-02-101-2/+2
* bugfix: removed newSons legacyAraq2012-01-071-1/+2
* year 2012 for most copyright headersAraq2012-01-021-1/+1
* bugfix: preliminary symbol declaration in first pass of genericsAraq2011-12-301-9/+11
* implemented 'let' statementAraq2011-11-291-1/+1
* small bugfixes to make more tests greenAraq2011-11-021-2/+4
* lazy loading of body ast implementedAraq2011-10-301-2/+3
* 'bind' as a declarative statementAraq2011-10-101-37/+46
"sd">## Descriptor is available for read Write, ## Descriptor is available for write Timer, ## Timer descriptor is completed Signal, ## Signal is raised Process, ## Process is finished Vnode, ## BSD specific file change happens User, ## User event is raised Error, ## Error happens while waiting, for descriptor VnodeWrite, ## NOTE_WRITE (BSD specific, write to file occurred) VnodeDelete, ## NOTE_DELETE (BSD specific, unlink of file occurred) VnodeExtend, ## NOTE_EXTEND (BSD specific, file extended) VnodeAttrib, ## NOTE_ATTRIB (BSD specific, file attributes changed) VnodeLink, ## NOTE_LINK (BSD specific, file link count changed) VnodeRename, ## NOTE_RENAME (BSD specific, file renamed) VnodeRevoke ## NOTE_REVOKE (BSD specific, file revoke occurred) ReadyKey*[T] = object ## An object which holds result for descriptor fd* : int ## file/socket descriptor events*: set[Event] ## set of events data*: T ## application-defined data SelectEvent* = object ## An object which holds user defined event proc newSelector*[T](): Selector[T] = ## Creates a new selector proc close*[T](s: Selector[T]) = ## Closes selector proc registerHandle*[T](s: Selector[T], fd: SocketHandle, events: set[Event], data: T) = ## Registers file/socket descriptor ``fd`` to selector ``s`` ## with events set in ``events``. The ``data`` is application-defined ## data, which to be passed when event happens. proc updateHandle*[T](s: Selector[T], fd: SocketHandle, events: set[Event]) = ## Update file/socket descriptor ``fd``, registered in selector ## ``s`` with new events set ``event``. proc registerTimer*[T](s: Selector[T], timeout: int, oneshot: bool, data: T): int {.discardable.} = ## Registers timer notification with ``timeout`` in milliseconds ## to selector ``s``. ## If ``oneshot`` is ``true`` timer will be notified only once. ## Set ``oneshot`` to ``false`` if your want periodic notifications. ## The ``data`` is application-defined data, which to be passed, when ## time limit expired. proc registerSignal*[T](s: Selector[T], signal: int, data: T): int {.discardable.} = ## Registers Unix signal notification with ``signal`` to selector ## ``s``. The ``data`` is application-defined data, which to be ## passed, when signal raises. ## ## This function is not supported for ``Windows``. proc registerProcess*[T](s: Selector[T], pid: int, data: T): int {.discardable.} = ## Registers process id (pid) notification when process has ## exited to selector ``s``. ## The ``data`` is application-defined data, which to be passed, when ## process with ``pid`` has exited. proc registerEvent*[T](s: Selector[T], ev: SelectEvent, data: T) = ## Registers selector event ``ev`` to selector ``s``. ## ``data`` application-defined data, which to be passed, when ## ``ev`` happens. proc registerVnode*[T](s: Selector[T], fd: cint, events: set[Event], data: T) = ## Registers selector BSD/MacOSX specific vnode events for file ## descriptor ``fd`` and events ``events``. ## ``data`` application-defined data, which to be passed, when ## vnode event happens. ## ## This function is supported only by BSD and MacOSX. proc newSelectEvent*(): SelectEvent = ## Creates new event ``SelectEvent``. proc setEvent*(ev: SelectEvent) = ## Trigger event ``ev``. proc close*(ev: SelectEvent) = ## Closes selector event ``ev``. proc unregister*[T](s: Selector[T], ev: SelectEvent) = ## Unregisters event ``ev`` from selector ``s``. proc unregister*[T](s: Selector[T], fd: int|SocketHandle|cint) = ## Unregisters file/socket descriptor ``fd`` from selector ``s``. proc flush*[T](s: Selector[T]) = ## Flushes all changes was made to kernel pool/queue. ## This function is useful only for BSD and MacOS, because ## kqueue supports bulk changes to be made. ## On Linux/Windows and other Posix compatible operation systems, ## ``flush`` is alias for `discard`. proc selectInto*[T](s: Selector[T], timeout: int, results: var openarray[ReadyKey[T]]): int = ## Process call waiting for events registered in selector ``s``. ## The ``timeout`` argument specifies the minimum number of milliseconds ## the function will be blocked, if no events are not ready. Specifying a ## timeout of ``-1`` causes function to block indefinitely. ## All available events will be stored in ``results`` array. ## ## Function returns number of triggered events. proc select*[T](s: Selector[T], timeout: int): seq[ReadyKey[T]] = ## Process call waiting for events registered in selector ``s``. ## The ``timeout`` argument specifies the minimum number of milliseconds ## the function will be blocked, if no events are not ready. Specifying a ## timeout of -1 causes function to block indefinitely. ## ## Function returns sequence of triggered events. template isEmpty*[T](s: Selector[T]): bool = ## Returns ``true``, if there no registered events or descriptors ## in selector. template withData*[T](s: Selector[T], fd: SocketHandle, value, body: untyped) = ## retrieves the application-data assigned with descriptor ``fd`` ## to ``value``. This ``value`` can be modified in the scope of ## the ``withData`` call. ## ## .. code-block:: nim ## ## s.withData(fd, value) do: ## # block is executed only if ``fd`` registered in selector ``s`` ## value.uid = 1000 ## template withData*[T](s: Selector[T], fd: SocketHandle, value, body1, body2: untyped) = ## retrieves the application-data assigned with descriptor ``fd`` ## to ``value``. This ``value`` can be modified in the scope of ## the ``withData`` call. ## ## .. code-block:: nim ## ## s.withData(fd, value) do: ## # block is executed only if ``fd`` registered in selector ``s``. ## value.uid = 1000 ## do: ## # block is executed if ``fd`` not registered in selector ``s``. ## raise ## else: when hasThreadSupport: import locks type SharedArray {.unchecked.}[T] = array[0..100, T] proc allocSharedArray[T](nsize: int): ptr SharedArray[T] = result = cast[ptr SharedArray[T]](allocShared0(sizeof(T) * nsize)) proc deallocSharedArray[T](sa: ptr SharedArray[T]) = deallocShared(cast[pointer](sa)) type Event* {.pure.} = enum Read, Write, Timer, Signal, Process, Vnode, User, Error, Oneshot, VnodeWrite, VnodeDelete, VnodeExtend, VnodeAttrib, VnodeLink, VnodeRename, VnodeRevoke ReadyKey*[T] = object fd* : int events*: set[Event] data*: T SelectorKey[T] = object ident: int events: set[Event] param: int key: ReadyKey[T] when not defined(windows): import posix proc setNonBlocking(fd: cint) {.inline.} = var x = fcntl(fd, F_GETFL, 0) if x == -1: raiseOSError(osLastError()) else: var mode = x or O_NONBLOCK if fcntl(fd, F_SETFL, mode) == -1: raiseOSError(osLastError()) template setKey(s, pident, pkeyfd, pevents, pparam, pdata) = var skey = addr(s.fds[pident]) skey.ident = pident skey.events = pevents skey.param = pparam skey.key.fd = pkeyfd skey.key.data = pdata when supportedPlatform: template blockSignals(newmask: var Sigset, oldmask: var Sigset) = when hasThreadSupport: if posix.pthread_sigmask(SIG_BLOCK, newmask, oldmask) == -1: raiseOSError(osLastError()) else: if posix.sigprocmask(SIG_BLOCK, newmask, oldmask) == -1: raiseOSError(osLastError()) template unblockSignals(newmask: var Sigset, oldmask: var Sigset) = when hasThreadSupport: if posix.pthread_sigmask(SIG_UNBLOCK, newmask, oldmask) == -1: raiseOSError(osLastError()) else: if posix.sigprocmask(SIG_UNBLOCK, newmask, oldmask) == -1: raiseOSError(osLastError()) when defined(linux): include ioselects/ioselectors_epoll elif bsdPlatform: include ioselects/ioselectors_kqueue elif defined(windows): include ioselects/ioselectors_select elif defined(solaris): include ioselects/ioselectors_poll # need to replace it with event ports else: include ioselects/ioselectors_poll