Merge branch 'newtempl' of github.com:Araq/Nimrod
This commit is contained in:
commit
61b3048323
3 changed files with 66 additions and 48 deletions
|
|
@ -72,11 +72,6 @@ proc semGenericStmtSymbol(c: PContext, n: PNode, s: PSym): PNode =
|
||||||
else:
|
else:
|
||||||
result = n
|
result = n
|
||||||
else: result = newSymNode(s, n.info)
|
else: result = newSymNode(s, n.info)
|
||||||
|
|
||||||
proc semMixinStmt(c: PContext, n: PNode, toMixin: var TIntSet): PNode =
|
|
||||||
for i in 0 .. < n.len:
|
|
||||||
toMixin.incl(considerAcc(n.sons[i]).id)
|
|
||||||
result = newNodeI(nkNilLit, n.info)
|
|
||||||
|
|
||||||
proc Lookup(c: PContext, n: PNode, flags: TSemGenericFlags,
|
proc Lookup(c: PContext, n: PNode, flags: TSemGenericFlags,
|
||||||
ctx: var TIntSet): PNode =
|
ctx: var TIntSet): PNode =
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# The Nimrod Compiler
|
# The Nimrod Compiler
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2013 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
@ -89,7 +89,12 @@ proc semBindStmt(c: PContext, n: PNode, toBind: var TIntSet): PNode =
|
||||||
for x in items(sc): toBind.incl(x.sym.id)
|
for x in items(sc): toBind.incl(x.sym.id)
|
||||||
else:
|
else:
|
||||||
illFormedAst(a)
|
illFormedAst(a)
|
||||||
result = newNodeI(nkNilLit, n.info)
|
result = newNodeI(nkEmpty, n.info)
|
||||||
|
|
||||||
|
proc semMixinStmt(c: PContext, n: PNode, toMixin: var TIntSet): PNode =
|
||||||
|
for i in 0 .. < n.len:
|
||||||
|
toMixin.incl(considerAcc(n.sons[i]).id)
|
||||||
|
result = newNodeI(nkEmpty, n.info)
|
||||||
|
|
||||||
proc replaceIdentBySym(n: var PNode, s: PNode) =
|
proc replaceIdentBySym(n: var PNode, s: PNode) =
|
||||||
case n.kind
|
case n.kind
|
||||||
|
|
@ -101,7 +106,7 @@ proc replaceIdentBySym(n: var PNode, s: PNode) =
|
||||||
type
|
type
|
||||||
TemplCtx {.pure, final.} = object
|
TemplCtx {.pure, final.} = object
|
||||||
c: PContext
|
c: PContext
|
||||||
toBind: TIntSet
|
toBind, toMixin: TIntSet
|
||||||
owner: PSym
|
owner: PSym
|
||||||
|
|
||||||
proc getIdentNode(c: var TemplCtx, n: PNode): PNode =
|
proc getIdentNode(c: var TemplCtx, n: PNode): PNode =
|
||||||
|
|
@ -192,6 +197,8 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
result = semTemplBody(c, n.sons[0])
|
result = semTemplBody(c, n.sons[0])
|
||||||
of nkBindStmt:
|
of nkBindStmt:
|
||||||
result = semBindStmt(c.c, n, c.toBind)
|
result = semBindStmt(c.c, n, c.toBind)
|
||||||
|
of nkMixinStmt:
|
||||||
|
result = semMixinStmt(c.c, n, c.toMixin)
|
||||||
of nkEmpty, nkSym..nkNilLit:
|
of nkEmpty, nkSym..nkNilLit:
|
||||||
nil
|
nil
|
||||||
of nkIfStmt:
|
of nkIfStmt:
|
||||||
|
|
@ -395,6 +402,7 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
|
||||||
n.sons[patternPos] = semPattern(c, n.sons[patternPos])
|
n.sons[patternPos] = semPattern(c, n.sons[patternPos])
|
||||||
var ctx: TemplCtx
|
var ctx: TemplCtx
|
||||||
ctx.toBind = initIntSet()
|
ctx.toBind = initIntSet()
|
||||||
|
ctx.toMixin = initIntSet()
|
||||||
ctx.c = c
|
ctx.c = c
|
||||||
ctx.owner = s
|
ctx.owner = s
|
||||||
if sfDirty in s.flags:
|
if sfDirty in s.flags:
|
||||||
|
|
@ -416,6 +424,8 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
|
||||||
addInterfaceOverloadableSymAt(c, s, curScope)
|
addInterfaceOverloadableSymAt(c, s, curScope)
|
||||||
else:
|
else:
|
||||||
SymTabReplace(c.tab.stack[curScope], proto, s)
|
SymTabReplace(c.tab.stack[curScope], proto, s)
|
||||||
|
# XXX this seems wrong: We need to check for proto before and overwrite
|
||||||
|
# proto.ast ...
|
||||||
if n.sons[patternPos].kind != nkEmpty:
|
if n.sons[patternPos].kind != nkEmpty:
|
||||||
c.patterns.add(s)
|
c.patterns.add(s)
|
||||||
|
|
||||||
|
|
@ -536,6 +546,7 @@ proc semPattern(c: PContext, n: PNode): PNode =
|
||||||
openScope(c.tab)
|
openScope(c.tab)
|
||||||
var ctx: TemplCtx
|
var ctx: TemplCtx
|
||||||
ctx.toBind = initIntSet()
|
ctx.toBind = initIntSet()
|
||||||
|
ctx.toMixin = initIntSet()
|
||||||
ctx.c = c
|
ctx.c = c
|
||||||
ctx.owner = getCurrOwner()
|
ctx.owner = getCurrOwner()
|
||||||
result = flattenStmts(semPatternBody(ctx, n))
|
result = flattenStmts(semPatternBody(ctx, n))
|
||||||
|
|
|
||||||
92
todo.txt
92
todo.txt
|
|
@ -1,12 +1,14 @@
|
||||||
version 0.9.2
|
version 0.9.2
|
||||||
=============
|
=============
|
||||||
|
|
||||||
- FFI:
|
- make 'bind' default for templates and introduce 'mixin';
|
||||||
* test libffi on windows
|
special rule for ``[]=``
|
||||||
* test: times.format with the FFI
|
- ``=`` should be overloadable; requires specialization for ``=``; general
|
||||||
- acyclic vs prunable; introduce GC hints
|
lift mechanism in the compiler is already implemented for 'fields'
|
||||||
- CGEN: ``restrict`` pragma + backend support; computed goto support
|
- mocking support with ``tyProxy`` that does: fallback for ``.`` operator
|
||||||
- document NimMain and check whether it works for threading
|
- overloading of ``.``? Special case ``.=``?
|
||||||
|
- built-in 'getImpl'
|
||||||
|
|
||||||
|
|
||||||
Bugs
|
Bugs
|
||||||
====
|
====
|
||||||
|
|
@ -28,18 +30,15 @@ version 0.9.4
|
||||||
=============
|
=============
|
||||||
|
|
||||||
- macros as type pragmas
|
- macros as type pragmas
|
||||||
- provide tool/API to track leaks/object counts
|
- implement full 'not nil' checking; range[1..3] needs the same mechanism
|
||||||
- hybrid GC
|
|
||||||
- use big blocks in the allocator
|
|
||||||
- implement full 'not nil' checking
|
|
||||||
- make 'bind' default for templates and introduce 'mixin';
|
|
||||||
special rule for ``[]=``
|
|
||||||
- implicit deref for parameter matching
|
- implicit deref for parameter matching
|
||||||
- ``=`` should be overloadable; requires specialization for ``=``; general
|
|
||||||
lift mechanism in the compiler is already implemented for 'fields'
|
|
||||||
- lazy overloading resolution:
|
- lazy overloading resolution:
|
||||||
* get rid of ``expr[typ]``, use perhaps ``static[typ]`` instead
|
* get rid of ``expr[typ]``, use perhaps ``static[typ]`` instead
|
||||||
* special case ``tyStmt``
|
* special case ``tyStmt``
|
||||||
|
- FFI:
|
||||||
|
* test libffi on windows
|
||||||
|
* test: times.format with the FFI
|
||||||
|
- document NimMain and check whether it works for threading
|
||||||
|
|
||||||
|
|
||||||
version 0.9.X
|
version 0.9.X
|
||||||
|
|
@ -48,8 +47,6 @@ version 0.9.X
|
||||||
- test&finish first class iterators:
|
- test&finish first class iterators:
|
||||||
* nested iterators
|
* nested iterators
|
||||||
- implement the missing features wrt inheritance
|
- implement the missing features wrt inheritance
|
||||||
- object pooling support for *hard* realtime systems
|
|
||||||
- improve the compiler as a service
|
|
||||||
- better support for macros that rewrite procs
|
- better support for macros that rewrite procs
|
||||||
- macros need access to types and symbols (partially implemented)
|
- macros need access to types and symbols (partially implemented)
|
||||||
- perhaps: change comment handling in the AST
|
- perhaps: change comment handling in the AST
|
||||||
|
|
@ -62,8 +59,8 @@ version 0.9.X
|
||||||
templates that would work too: T([.ref int])
|
templates that would work too: T([.ref int])
|
||||||
|
|
||||||
|
|
||||||
Concurrency
|
Concurrency/Effect system
|
||||||
-----------
|
=========================
|
||||||
|
|
||||||
- shared memory heap: ``shared ref`` etc. The only hard part in the GC is to
|
- shared memory heap: ``shared ref`` etc. The only hard part in the GC is to
|
||||||
"stop the world". However, it may be worthwhile to generate explicit
|
"stop the world". However, it may be worthwhile to generate explicit
|
||||||
|
|
@ -83,21 +80,51 @@ Concurrency
|
||||||
version 0.9.XX
|
version 0.9.XX
|
||||||
==============
|
==============
|
||||||
|
|
||||||
- object branch transitions can't work with the current 'reset'; add a 'reset'
|
|
||||||
with an additional parameter --> simple:
|
|
||||||
provide a 'reset(x, TObj(k: nkValue))' instead? why bother? '=' does the
|
|
||||||
same.
|
|
||||||
- document nimdoc properly finally
|
- document nimdoc properly finally
|
||||||
- make 'clamp' a magic for the range stuff
|
- make 'clamp' a magic for the range stuff
|
||||||
- better type syntax for functions and tuples: tuple(int, int); (int,int)->int
|
- better type syntax for functions and tuples: tuple(int, int); (int,int)->int
|
||||||
|
|
||||||
|
|
||||||
|
Memory safety
|
||||||
|
=============
|
||||||
|
|
||||||
|
- object branch transitions from low(selector) are unsafe! ---> Needs a
|
||||||
|
deprecation path
|
||||||
|
- object branch transitions can't work with the current 'reset'; add a 'reset'
|
||||||
|
with an additional parameter --> simple:
|
||||||
|
provide a 'reset(x, TObj(k: nkValue))' instead? why bother? '=' does the
|
||||||
|
same.
|
||||||
|
- returning 'var T' is unsafe and needs some static analysis
|
||||||
|
|
||||||
|
|
||||||
|
GC
|
||||||
|
==
|
||||||
|
|
||||||
|
- precise stack marking; embrace C++ code generation for that
|
||||||
|
- marker procs for Boehm GC
|
||||||
|
- hybrid GC
|
||||||
|
- GC: implement simple generational GC
|
||||||
|
* first version: mark black in write barrier
|
||||||
|
* second version: introduce fake roots instead of marking black
|
||||||
|
* third version: find some clever heuristic which is preferable
|
||||||
|
- acyclic vs prunable; introduce GC hints
|
||||||
|
- use big blocks in the allocator
|
||||||
|
- object pooling support for *hard* realtime systems
|
||||||
|
- provide tool/API to track leaks/object counts
|
||||||
|
- resizing of strings/sequences could take into account the memory that
|
||||||
|
is allocated
|
||||||
|
|
||||||
|
|
||||||
|
CGEN
|
||||||
|
====
|
||||||
|
- codegen should use "NIM_CAST" macro and respect aliasing rules for GCC
|
||||||
|
- ``restrict`` pragma + backend support; computed goto support
|
||||||
|
- 'const' objects including case objects
|
||||||
|
|
||||||
|
|
||||||
Not essential for 1.0.0
|
Not essential for 1.0.0
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
- 'const' objects including case objects
|
|
||||||
- mocking support with ``tyProxy`` that does: fallback for ``.`` operator
|
|
||||||
- overloading of ``.``? Special case ``.=``?
|
|
||||||
- allow implicit forward declarations of procs via a pragma (so that the
|
- allow implicit forward declarations of procs via a pragma (so that the
|
||||||
wrappers can deactivate it): better solution: introduce the notion of a
|
wrappers can deactivate it): better solution: introduce the notion of a
|
||||||
'proc section' that is similar to a type section.
|
'proc section' that is similar to a type section.
|
||||||
|
|
@ -108,28 +135,13 @@ Not essential for 1.0.0
|
||||||
- ``with proc `+`(x, y: T): T`` for generic code
|
- ``with proc `+`(x, y: T): T`` for generic code
|
||||||
- new feature: ``distinct T with operations``
|
- new feature: ``distinct T with operations``
|
||||||
- arglist as a type (iterator chaining); variable length type lists for generics
|
- arglist as a type (iterator chaining); variable length type lists for generics
|
||||||
- resizing of strings/sequences could take into account the memory that
|
|
||||||
is allocated
|
|
||||||
- codegen should use "NIM_CAST" macro and respect aliasing rules for GCC
|
|
||||||
- implement marker procs for message passing
|
- implement marker procs for message passing
|
||||||
- activate more thread tests
|
- activate more thread tests
|
||||||
- implement closures that support nesting of *procs* > 1
|
- implement closures that support nesting of *procs* > 1
|
||||||
- GC: implement simple generational GC
|
|
||||||
* first version: mark black in write barrier
|
|
||||||
* second version: introduce fake roots instead of marking black
|
|
||||||
* third version: find some clever heuristic which is preferable
|
|
||||||
- object constructors: static check for fields if discriminator is known at
|
- object constructors: static check for fields if discriminator is known at
|
||||||
compile time
|
compile time
|
||||||
|
|
||||||
|
|
||||||
GC
|
|
||||||
==
|
|
||||||
|
|
||||||
- precise stack marking; embrace C++ code generation for that
|
|
||||||
- marker procs for Boehm GC
|
|
||||||
- implement 'mixed' GC mode
|
|
||||||
|
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue