Commit Graph

111 Commits

Author SHA1 Message Date
Arne Döring
77a0f3768b adopt tests 2018-11-08 22:28:29 +01:00
jcosborn
fc740c54ec fixes #9600 (#9601) 2018-11-07 08:40:00 +01:00
PMunch
e9ed4dccb6 Quote do now works with result in block (#7343)
* Fix result not being able to use in quote do

This fixes the annoying issue of not be able to use result inside a
quote do block. It works by a simple trick. The quote do mechanic is
based on dynamically creating a template and immediately calling it with
the arguments found within the quote do block. Since this is called in
the scope of the macro the result variable is shadowed. This trick works
by changing all occurences of result (which shouldn't cause any issues
as result isn't used for anything else for the same reason) to another
name and then passing in an IdentNode with result as a named parameter
with that name.

Note that currently this just replaces it with a fixed named variable
"res" which should be changed to a non-colliding, dynamically created
name.

* Fix hard coded parameter "res" to anonymous symbol

This fixes the hard coded parameter "res" to be an anonymous symbol
instead so it won't collide with other parts of the argument list.

* Add test case for result in quote do block

A simple test case based on GitHub issue #7323 on how you can't put
result in a quote do block. This test verifies that it actually works
correctly now.

* Add test for explicit capturing of result

* Rebased against devel
2018-10-31 22:14:29 +01:00
jcosborn
69c0a9c6fb getTypeImpl now returns pragmas for object types (#9538) 2018-10-30 06:41:12 +01:00
Miran
1b17c9f693 More descriptive names of test files (#9531)
* change generic `tissues` name to more specific
* change `tvarious` to more specific names
2018-10-29 17:07:27 +01:00
cooldome
eaca5be9d6 Change the order of compilation passes, transformation is made lazy at code gen (#8489)
* Ast no transformation
* Add getImplNoTransform to the macros module
* progress on delaying transf
* Fix methods tranformation
* Fix lazy lambdalifting
* fix create thread wrapper
* transform for lambda lifting
* improve getImplTransformed
* Fix destructor tests
* try to fix nimprof for linux
2018-10-18 20:21:25 +02:00
Arne Döring
48697dc5bb added test case for or operator 2018-10-18 15:39:22 +02:00
Miran
a30ba8cc37 merge macros tests (#9367) 2018-10-14 17:08:42 +02:00
xzfc
8fc7cecfa2 compiler: show name of instantiating context in error traces (#6763) (#9207) 2018-10-11 09:34:56 +02:00
LemonBoy
0ead36dae6 Unchecked arrays now have their own type (#9267) 2018-10-10 21:03:18 +02:00
LemonBoy
32d5b80938 Fix macro expansion in expandMacros (#8998)
* Fix macro expansion in expandMacros

Running a semanticized node trough the semantic pass was a bad idea.

Fixes #7723

* Simpler smaller implementation
2018-10-09 23:24:54 +02:00
LemonBoy
33458894da Fix overload resolution for pragmas evaluation (#8902)
Fixes #6448
Fixes #4384
2018-10-09 19:58:23 +02:00
LemonBoy
8a1055adce Fix range type construction in the VM (#9205)
The `range[X,Y]` representation is wrong, we use `range[X .. Y]`
instead.

Fixes #9194
2018-10-09 15:51:49 +02:00
Andreas Rumpf
de02f5fa0a add tcollect test for the new for-loops as expressions feature 2018-09-11 19:14:31 +02:00
cooldome
c033ff990a Renderer bug fixes (#8804)
Fixes #8763: render bug: pure enums not handled correctly
Fixes #8762: render bug: binary operators called with quotes rendered incorrectly
FIxes #8761: render bug: inversion of operator priorities
2018-09-07 01:52:42 +02:00
cooldome
e63c66b810 Add sym owner to macros (#8253) 2018-09-03 13:25:59 +02:00
LemonBoy
b74faf354e Do not materialize empty varargs[untyped] arrays (#8715)
When an empty nkArgList `varargs[untyped]` is passed around it is now
reused for efficiency sake and to prevent the introduction of a spurious
element: before this commit we'd pass the caller a
nkArgList[nkHiddenStdConv[nkBracket]] node instead of just an empty
nkArgList.

Fixes #8706
2018-08-31 12:16:46 +02:00
LemonBoy
5cd152bfda Allow hint and warning to specify its loc info (#8771)
Let's bring those to feature-parity with `error`.
2018-08-28 22:59:28 +02:00
cooldome
d5e1d102df fixes 8754 (#8755)
* fixes 8754

* improve test
2018-08-24 09:57:38 +02:00
Andreas Rumpf
da41fc1801 put the new for loop macros under an experimental switch named 'forLoopMacros' 2018-08-15 17:45:57 +02:00
andri lim
6e3d1dced5 fixes #5617, 'copyLineInfo' addition (#8523) 2018-08-05 23:38:21 +02:00
andri lim
78c0ac5407 fixes #7827, bindSym enhancement (#8499)
* bindSym power up, working prototype

* update bindSym doc

* add bindSym test

* fix some typo

* fix bindSym doc

* get rid of specialops field from vm

* add experimental: dynamicBindSym
2018-08-02 12:56:44 +02:00
cooldome
ec02940185 Render bug: if expression with statement list expression as condition (#8375)
* Fixes #8348
2018-07-21 13:01:47 +02:00
cooldome
a651809411 Fixes #8343, Fixes #8344 (#8347) 2018-07-18 14:54:44 +02:00
Andreas Rumpf
0cbfd67522 make typesafeprintf test green 2018-07-17 20:33:42 +02:00
cooldome
231a83a6b1 Fixes #8287 (#8288) 2018-07-12 11:03:08 +02:00
Andreas Rumpf
c7298561c1 system.nim: remove deprecated symbols 2018-06-28 07:42:46 +02:00
LemonBoy
52fc16d5d2 Return an error symbol as macro output if needed (#8116)
Return an error symbol if the macro output has no type and a typedesc
is expected.

Fixes #7454
2018-06-27 21:43:07 +02:00
Arne Döring
51fdb071cb fix #5930 2018-06-13 12:18:21 +02:00
Andreas Rumpf
61e1897922 make tests green again 2018-06-11 01:23:14 +02:00
Zahary Karadjov
2b8bf8fc4a A motivating example for the new bindSym behavior.
The example is a proof-of-concept logging library, allowing you to define
lexically-scoped environments where certain logging attributes are applied
automatically to all logging statements.

fixes tmacro1 (use of `bindSym` inside static blocks)
2018-05-07 09:37:49 +02:00
Zahary Karadjov
bdcb729597 Better support for treating templates and macros as symbols.
This allows you to pass a template or a macro to another macro
which can then inspect the implementation of the former template/macro
using `getImpl`.

Since templates can be freely redefined, this allows you to treat
their symbols as compile-time variables that have lexical scope.
A motivating PoC example for a logging library taking advantage of
this will be provided in the next commit.

Implementation details:

* The name of a template or a macro will be consider a symbol if
  the template/macro requires parameters

* For parameterless templates/macros, you can use `bindSym`, which
  was extended to also work outside of compile-time procs.
2018-05-07 09:37:49 +02:00
Arne Döring
9d4fd1f1bb eqIdent new returns false on non identifier types (#7629) 2018-04-17 01:23:38 +02:00
Arne Döring
ed5b7cbac0 move eqIdent to vm.nim (#7585)
* Strutils comment changes.

* fix typo
2018-04-15 23:38:43 +02:00
Andreas Rumpf
c08efb4c51 implements first version of for-loop macros 2018-04-15 01:07:28 +02:00
Arne Döring
6baca58693 Get symbol kind (#7491) 2018-04-11 16:48:01 +02:00
PMunch
a9f21cffdf Add CommentStmt to astGenRepr (#7313)
* Added codeRepr and dumpCode to the macros module.

This allows those writing macros to write examples, get the code to generate the AST for that example, and then modify that code to be dynamic with the macro function.
2018-03-16 15:57:40 +01:00
Andreas Rumpf
6a2b57b4aa fixes #7093 2018-01-18 11:40:18 +01:00
jcosborn
96a5062b8c modify getTypeImpl to reduce result to final implementation (#6891)
* added test case for getTypeImpl
* modify getTypeImpl to reduce result to final implementation
2017-12-09 13:07:37 +01:00
jcosborn
35d7a99b6a fix getTypeInst for tyGenericInst (#6868) 2017-12-04 17:37:25 +01:00
Araq
14468e2336 make tests green again 2017-11-23 14:37:53 +01:00
Andreas Rumpf
68c7da227f make tests green again 2017-10-01 07:46:13 +02:00
Andreas Rumpf
ddc131cf07 the parser finally parses 'echo {1,2}' as it should 2017-09-30 21:35:30 +02:00
BigEpsilon
6f6e6fe4eb Fix #6295 (#6296) 2017-08-30 14:44:11 +02:00
Yuriy Glukhov
8481e9ff14 Fixed NimTypeKind enum, added missing values. (#6157) 2017-07-30 11:10:07 +02:00
PMunch
e00953cbc0 Added codeRepr and dumpCode to the macros module. (#5778) 2017-07-26 00:37:37 +02:00
Arne Döring
000b8afd26 Remove expr/stmt (#5857) 2017-07-25 09:28:23 +02:00
Arne Döring
52cab78ae5 newLit emty seq fix (#6091)
* the type of the empty seq is still the correct type
* updated test
2017-07-13 17:07:33 +02:00
Andreas Rumpf
2ad9a16e0a fixes anon procs created by macros 2017-07-11 18:07:34 +02:00
Arne Döring
eb8e267ff6 improved comment satement support in macros (#5904) 2017-06-02 01:22:21 +02:00