Merge branch 'devel' of gh:/Araq/Nimrod into devel
This commit is contained in:
commit
f13a836972
11 changed files with 128 additions and 34 deletions
|
|
@ -1025,7 +1025,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): PNode =
|
||||||
regs[ra].sons[0].flags.incl nfIsRef
|
regs[ra].sons[0].flags.incl nfIsRef
|
||||||
of opcNCopyNimNode:
|
of opcNCopyNimNode:
|
||||||
decodeB(nkMetaNode)
|
decodeB(nkMetaNode)
|
||||||
setMeta(regs[ra], copyNode(regs[rb]))
|
setMeta(regs[ra], copyNode(regs[rb].skipMeta))
|
||||||
of opcNCopyNimTree:
|
of opcNCopyNimTree:
|
||||||
decodeB(nkMetaNode)
|
decodeB(nkMetaNode)
|
||||||
setMeta(regs[ra], copyTree(regs[rb]))
|
setMeta(regs[ra], copyTree(regs[rb]))
|
||||||
|
|
|
||||||
|
|
@ -321,9 +321,18 @@ proc genAndOr(c: PCtx; n: PNode; opc: TOpcode; dest: var TDest) =
|
||||||
c.gen(n.sons[2], dest)
|
c.gen(n.sons[2], dest)
|
||||||
c.patch(L1)
|
c.patch(L1)
|
||||||
|
|
||||||
|
proc nilLiteral(n: PNode): PNode =
|
||||||
|
if n.kind == nkNilLit and n.typ.sym != nil and
|
||||||
|
n.typ.sym.magic == mPNimrodNode:
|
||||||
|
let nilo = newNodeIT(nkNilLit, n.info, n.typ)
|
||||||
|
result = newNodeIT(nkMetaNode, n.info, n.typ)
|
||||||
|
result.add nilo
|
||||||
|
else:
|
||||||
|
result = n
|
||||||
|
|
||||||
proc rawGenLiteral(c: PCtx; n: PNode): int =
|
proc rawGenLiteral(c: PCtx; n: PNode): int =
|
||||||
result = c.constants.len
|
result = c.constants.len
|
||||||
c.constants.add n
|
c.constants.add n.nilLiteral
|
||||||
internalAssert result < 0x7fff
|
internalAssert result < 0x7fff
|
||||||
|
|
||||||
proc sameConstant*(a, b: PNode): bool =
|
proc sameConstant*(a, b: PNode): bool =
|
||||||
|
|
@ -907,17 +916,20 @@ proc requiresCopy(n: PNode): bool =
|
||||||
proc unneededIndirection(n: PNode): bool =
|
proc unneededIndirection(n: PNode): bool =
|
||||||
n.typ.skipTypes(abstractInst-{tyTypeDesc}).kind == tyRef
|
n.typ.skipTypes(abstractInst-{tyTypeDesc}).kind == tyRef
|
||||||
|
|
||||||
proc skipDeref(n: PNode): PNode =
|
|
||||||
if n.kind in {nkDerefExpr, nkHiddenDeref} and unneededIndirection(n.sons[0]):
|
|
||||||
result = n.sons[0]
|
|
||||||
else:
|
|
||||||
result = n
|
|
||||||
|
|
||||||
proc genAddrDeref(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode;
|
proc genAddrDeref(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode;
|
||||||
flags: TGenFlags) =
|
flags: TGenFlags) =
|
||||||
# a nop for certain types
|
# a nop for certain types
|
||||||
let flags = if opc == opcAddr: flags+{gfAddrOf} else: flags
|
let flags = if opc == opcAddr: flags+{gfAddrOf} else: flags
|
||||||
if unneededIndirection(n.sons[0]):
|
# consider:
|
||||||
|
# proc foo(f: var ref int) =
|
||||||
|
# f = new(int)
|
||||||
|
# proc blah() =
|
||||||
|
# var x: ref int
|
||||||
|
# foo x
|
||||||
|
#
|
||||||
|
# The type of 'f' is 'var ref int' and of 'x' is 'ref int'. Hence for
|
||||||
|
# nkAddr we must not use 'unneededIndirection', but for deref we use it.
|
||||||
|
if opc != opcAddr and unneededIndirection(n.sons[0]):
|
||||||
gen(c, n.sons[0], dest, flags)
|
gen(c, n.sons[0], dest, flags)
|
||||||
else:
|
else:
|
||||||
let tmp = c.genx(n.sons[0], flags)
|
let tmp = c.genx(n.sons[0], flags)
|
||||||
|
|
@ -1109,7 +1121,12 @@ proc getNullValue(typ: PType, info: TLineInfo): PNode =
|
||||||
result = newNodeIT(nkFloatLit, info, t)
|
result = newNodeIT(nkFloatLit, info, t)
|
||||||
of tyVar, tyPointer, tyPtr, tyCString, tySequence, tyString, tyExpr,
|
of tyVar, tyPointer, tyPtr, tyCString, tySequence, tyString, tyExpr,
|
||||||
tyStmt, tyTypeDesc, tyStatic, tyRef:
|
tyStmt, tyTypeDesc, tyStatic, tyRef:
|
||||||
result = newNodeIT(nkNilLit, info, t)
|
if t.sym != nil and t.sym.magic == mPNimrodNode:
|
||||||
|
let nilo = newNodeIT(nkNilLit, info, t)
|
||||||
|
result = newNodeIT(nkMetaNode, info, t)
|
||||||
|
result.add nilo
|
||||||
|
else:
|
||||||
|
result = newNodeIT(nkNilLit, info, t)
|
||||||
of tyProc:
|
of tyProc:
|
||||||
if t.callConv != ccClosure:
|
if t.callConv != ccClosure:
|
||||||
result = newNodeIT(nkNilLit, info, t)
|
result = newNodeIT(nkNilLit, info, t)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
type
|
type
|
||||||
TLibHandle* = pointer ## a handle to a dynamically loaded library
|
TLibHandle* = pointer ## a handle to a dynamically loaded library
|
||||||
|
|
||||||
proc loadLib*(path: string): TLibHandle
|
proc loadLib*(path: string, global_symbols=false): TLibHandle
|
||||||
## loads a library from `path`. Returns nil if the library could not
|
## loads a library from `path`. Returns nil if the library could not
|
||||||
## be loaded.
|
## be loaded.
|
||||||
|
|
||||||
|
|
@ -53,6 +53,7 @@ when defined(posix):
|
||||||
#
|
#
|
||||||
var
|
var
|
||||||
RTLD_NOW {.importc: "RTLD_NOW", header: "<dlfcn.h>".}: int
|
RTLD_NOW {.importc: "RTLD_NOW", header: "<dlfcn.h>".}: int
|
||||||
|
RTLD_GLOBAL {.importc: "RTLD_GLOBAL", header: "<dlfcn.h>".}: int
|
||||||
|
|
||||||
proc dlclose(lib: TLibHandle) {.importc, header: "<dlfcn.h>".}
|
proc dlclose(lib: TLibHandle) {.importc, header: "<dlfcn.h>".}
|
||||||
proc dlopen(path: CString, mode: int): TLibHandle {.
|
proc dlopen(path: CString, mode: int): TLibHandle {.
|
||||||
|
|
@ -60,7 +61,10 @@ when defined(posix):
|
||||||
proc dlsym(lib: TLibHandle, name: cstring): pointer {.
|
proc dlsym(lib: TLibHandle, name: cstring): pointer {.
|
||||||
importc, header: "<dlfcn.h>".}
|
importc, header: "<dlfcn.h>".}
|
||||||
|
|
||||||
proc loadLib(path: string): TLibHandle = return dlopen(path, RTLD_NOW)
|
proc loadLib(path: string, global_symbols=false): TLibHandle =
|
||||||
|
var flags = RTLD_NOW
|
||||||
|
if global_symbols: flags = flags or RTLD_GLOBAL
|
||||||
|
return dlopen(path, flags)
|
||||||
proc loadLib(): TLibHandle = return dlopen(nil, RTLD_NOW)
|
proc loadLib(): TLibHandle = return dlopen(nil, RTLD_NOW)
|
||||||
proc unloadLib(lib: TLibHandle) = dlclose(lib)
|
proc unloadLib(lib: TLibHandle) = dlclose(lib)
|
||||||
proc symAddr(lib: TLibHandle, name: cstring): pointer =
|
proc symAddr(lib: TLibHandle, name: cstring): pointer =
|
||||||
|
|
@ -81,7 +85,7 @@ elif defined(windows) or defined(dos):
|
||||||
proc getProcAddress(lib: THINSTANCE, name: cstring): pointer {.
|
proc getProcAddress(lib: THINSTANCE, name: cstring): pointer {.
|
||||||
importc: "GetProcAddress", header: "<windows.h>", stdcall.}
|
importc: "GetProcAddress", header: "<windows.h>", stdcall.}
|
||||||
|
|
||||||
proc loadLib(path: string): TLibHandle =
|
proc loadLib(path: string, global_symbols=false): TLibHandle =
|
||||||
result = cast[TLibHandle](winLoadLibrary(path))
|
result = cast[TLibHandle](winLoadLibrary(path))
|
||||||
proc loadLib(): TLibHandle =
|
proc loadLib(): TLibHandle =
|
||||||
result = cast[TLibHandle](winLoadLibrary(nil))
|
result = cast[TLibHandle](winLoadLibrary(nil))
|
||||||
|
|
|
||||||
19
tests/macros/tvarnimnode.nim
Normal file
19
tests/macros/tvarnimnode.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
discard """
|
||||||
|
output: 10
|
||||||
|
"""
|
||||||
|
|
||||||
|
#bug #926
|
||||||
|
|
||||||
|
import macros
|
||||||
|
|
||||||
|
proc test(f: var PNimrodNode) {.compileTime.} =
|
||||||
|
f = newNimNode(nnkStmtList)
|
||||||
|
f.add newCall(newIdentNode("echo"), newLit(10))
|
||||||
|
|
||||||
|
macro blah(prc: stmt): stmt =
|
||||||
|
result = prc
|
||||||
|
|
||||||
|
test(result)
|
||||||
|
|
||||||
|
proc test() {.blah.} =
|
||||||
|
echo 5
|
||||||
|
|
@ -178,14 +178,14 @@ template new_parsed_parameter*(tkind: Tparam_kind, expr): Tparsed_parameter =
|
||||||
## #parsed_param3 = new_parsed_parameter(PK_INT, "231")
|
## #parsed_param3 = new_parsed_parameter(PK_INT, "231")
|
||||||
var result {.gensym.}: Tparsed_parameter
|
var result {.gensym.}: Tparsed_parameter
|
||||||
result.kind = tkind
|
result.kind = tkind
|
||||||
when tkind == PK_EMPTY: nil
|
when tkind == PK_EMPTY: discard
|
||||||
elif tkind == PK_INT: result.int_val = expr
|
elif tkind == PK_INT: result.int_val = expr
|
||||||
elif tkind == PK_BIGGEST_INT: result.big_int_val = expr
|
elif tkind == PK_BIGGEST_INT: result.big_int_val = expr
|
||||||
elif tkind == PK_FLOAT: result.float_val = expr
|
elif tkind == PK_FLOAT: result.float_val = expr
|
||||||
elif tkind == PK_BIGGEST_FLOAT: result.big_float_val = expr
|
elif tkind == PK_BIGGEST_FLOAT: result.big_float_val = expr
|
||||||
elif tkind == PK_STRING: result.str_val = expr
|
elif tkind == PK_STRING: result.str_val = expr
|
||||||
elif tkind == PK_BOOL: result.bool_val = expr
|
elif tkind == PK_BOOL: result.bool_val = expr
|
||||||
elif tkind == PK_HELP: nil
|
elif tkind == PK_HELP: discard
|
||||||
else: {.error: "unknown kind".}
|
else: {.error: "unknown kind".}
|
||||||
result
|
result
|
||||||
|
|
||||||
|
|
|
||||||
4
todo.txt
4
todo.txt
|
|
@ -1,8 +1,10 @@
|
||||||
version 0.9.4
|
version 0.9.4
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
- fix macros\tstringinterp.nim:
|
||||||
|
- problem: needs another level of indirection for 'seq'
|
||||||
|
- problem: deref is not correct
|
||||||
- fix GC issues
|
- fix GC issues
|
||||||
- fix macros\tstringinterp.nim
|
|
||||||
- test and fix showoff
|
- test and fix showoff
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,5 +74,15 @@
|
||||||
<div id="legal">Copyright © 2013 - Andreas Rumpf & Contributors - All rights reserved - <a href="http://reign-studios.com/philipwitte/">Design by Philip Witte</a></div>
|
<div id="legal">Copyright © 2013 - Andreas Rumpf & Contributors - All rights reserved - <a href="http://reign-studios.com/philipwitte/">Design by Philip Witte</a></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||||
|
|
||||||
|
ga('create', 'UA-48159761-1', 'nimrod-lang.org');
|
||||||
|
ga('send', 'pageview');
|
||||||
|
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ html, body {
|
||||||
|
|
||||||
#page { position:relative; float:left; padding:20px 30px 50px 50px; width:620px; color:#343739; }
|
#page { position:relative; float:left; padding:20px 30px 50px 50px; width:620px; color:#343739; }
|
||||||
|
|
||||||
#page h1 { margin-top:40px; }
|
#page h1 { margin-top:40px; line-height: 28px; }
|
||||||
#page h2 { margin-top:40px; }
|
#page h2 { margin-top:40px; }
|
||||||
|
|
||||||
#page p { text-align:justify; }
|
#page p { text-align:justify; }
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,55 @@
|
||||||
Discuss Nimrod in our `forum <http://forum.nimrod-code.org/>`_.
|
Forum
|
||||||
|
=====
|
||||||
|
|
||||||
Visit our project page at GitHub: http://github.com/Araq/Nimrod.
|
The `Nimrod forum <http://forum.nimrod-code.org/>`_ is the place where most
|
||||||
|
discussions related to the language happen. It not only includes discussions
|
||||||
|
relating to the design of Nimrod but also allows for beginners to ask questions
|
||||||
|
relating to Nimrod.
|
||||||
|
|
||||||
Wiki: http://github.com/Araq/Nimrod/wiki.
|
IRC
|
||||||
|
====
|
||||||
|
|
||||||
Bug reports: http://github.com/Araq/Nimrod/issues.
|
Many Nimrod developers are a part of the
|
||||||
|
`#nimrod IRC channel <http://webchat.freenode.net/?channels=nimrod>`_ on
|
||||||
|
Freenode. That is the place where the rest of the discussion relating to Nimrod
|
||||||
|
occurs. Be sure to join us there if you wish to discuss Nimrod in real-time.
|
||||||
|
IRC is the perfect place for people just starting to learn Nimrod and we
|
||||||
|
welcome any questions that you may have!
|
||||||
|
|
||||||
For quickest feedback, join our IRC channel: irc://irc.freenode.net/nimrod
|
You may also be interested in reading the
|
||||||
(logs at `<http://build.nimrod-code.org/irclogs/>`_).
|
`IRC logs <http://build.nimrod-code.org/irclogs/>`_ which are an archive of all
|
||||||
|
of the previous discussions that took place in the IRC channel.
|
||||||
|
|
||||||
Check out our Twitter account for latest news and announcements: `@nimrodlang <http://twitter.com/nimrodlang>`_.
|
Github
|
||||||
|
======
|
||||||
|
|
||||||
|
Nimrod's `source code <http://github.com/Araq/Nimrod>`_ is hosted on Github.
|
||||||
|
Together with the `wiki <http://github.com/Araq/Nimrod/wiki>`_ and
|
||||||
|
`issue tracker <http://github.com/Araq/Nimrod/issues>`_.
|
||||||
|
|
||||||
|
Github also hosts other projects relating to Nimrod. These projects are a part
|
||||||
|
of the `nimrod-code organisation <http://github.com/nimrod-code>`_.
|
||||||
|
This includes the `Babel package manager <http://github.com/nimrod-code/babel>`_
|
||||||
|
and its `package repository <http://github.com/nimrod-code/packages>`_.
|
||||||
|
|
||||||
|
Twitter
|
||||||
|
=======
|
||||||
|
|
||||||
|
Follow us `@nimrodlang <http://twitter.com/nimrodlang>`_ for latest news about
|
||||||
|
Nimrod.
|
||||||
|
|
||||||
|
Reddit
|
||||||
|
======
|
||||||
|
|
||||||
|
Subscribe to `/r/nimrod <http://reddit.com/r/nimrod>`_ for latest news about
|
||||||
|
Nimrod.
|
||||||
|
|
||||||
|
StackOverflow
|
||||||
|
=============
|
||||||
|
|
||||||
|
When asking a question relating to Nimrod, be sure to use the
|
||||||
|
`Nimrod <http://stackoverflow.com/questions/tagged/nimrod>`_ tag in your
|
||||||
|
question.
|
||||||
|
|
||||||
How to help
|
How to help
|
||||||
===========
|
===========
|
||||||
|
|
@ -26,7 +66,9 @@ can't find anything you fancy doing, you can always ask for inspiration on IRC
|
||||||
Donations
|
Donations
|
||||||
---------
|
---------
|
||||||
|
|
||||||
If you love what we do and are feeling generous then you can always donate:
|
If you love what we do and are feeling generous then you can always donate.
|
||||||
|
Contributions of any quantity are greatly appreciated and will contribute to
|
||||||
|
making Nimrod even better!
|
||||||
|
|
||||||
Gittip
|
Gittip
|
||||||
``````
|
``````
|
||||||
|
|
|
||||||
|
|
@ -86,15 +86,15 @@ News
|
||||||
to activate.
|
to activate.
|
||||||
|
|
||||||
|
|
||||||
2014-02-11 Nimrod Featured in Dr. Dobb's
|
2014-02-11 Nimrod Featured in Dr. Dobb's Journal
|
||||||
========================================
|
================================================
|
||||||
|
|
||||||
Nimrod has been `featured<http://www.drdobbs.com/open-source/nimrod-a-new-systems-programming-languag/240165321>`_
|
Nimrod has been `featured<http://www.drdobbs.com/open-source/nimrod-a-new-systems-programming-languag/240165321>`_
|
||||||
as the cover story in the February 2014 issue of Dr. Dobb's Journal.
|
as the cover story in the February 2014 issue of Dr. Dobb's Journal.
|
||||||
|
|
||||||
|
|
||||||
2014-01-15 Nimrod Talk is Online
|
2014-01-15 Andreas Rumpf's talk on Nimrod at Strange Loop 2013 is now online
|
||||||
================================
|
============================================================================
|
||||||
|
|
||||||
Andreas Rumpf presented *Nimrod: A New Approach to Metaprogramming* at
|
Andreas Rumpf presented *Nimrod: A New Approach to Metaprogramming* at
|
||||||
`Strange Loop 2013<https://thestrangeloop.com/sessions/nimrod-a-new-approach-to-meta-programming>`_.
|
`Strange Loop 2013<https://thestrangeloop.com/sessions/nimrod-a-new-approach-to-meta-programming>`_.
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
<a class="news" href="news.html#Z2014-02-11-nimrod-featured-in-dr-dobb-s">
|
<a class="news" href="news.html#Z2014-02-11-nimrod-featured-in-dr-dobb-s-journal">
|
||||||
<h3>Feb 11, 2014</h3>
|
<h3>Feb 11, 2014</h3>
|
||||||
<p>Nimrod in Dr. Dobb's.</p>
|
<p>Nimrod featured in Dr. Dobb's Journal</p>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="news" href="news.html#Z2014-01-15-nimrod-talk-is-online">
|
<a class="news" href="news.html#Z2014-01-15-andreas-rumpf-s-talk-on-nimrod-at-strange-loop-2013-is-now-online">
|
||||||
<h3>Jan 15, 2014</h3>
|
<h3>Jan 15, 2014</h3>
|
||||||
<p>Nimrod video is online.</p>
|
<p>Andreas Rumpf's talk on Nimrod at Strange Loop 2013 is now online.</p>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="news" href="news.html#new-website-design">
|
<a class="news" href="news.html#Z2013-05-20-new-website-design">
|
||||||
<h3>May 20, 2013</h3>
|
<h3>May 20, 2013</h3>
|
||||||
<p>New website design!</p>
|
<p>New website design!</p>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue