Commit Graph

202 Commits

Author SHA1 Message Date
Reimer Behrends
f664c576c2 Fix code generation issues with TNimType.
This is an alternative attempt to fix issue #2841 in a way that does not
rely on non-standard C compiler behavior.

The underlying problem is that the typeinfo module includes
system/hti.nim, but system/hti.nim is also included by system.nim. The
result is that the compiler at any given point has two instances of
TNimType with the same external name and will generate code either for
one or both of them. Code generation for the second version is normally
suppressed by using {.importc.}, but that results in a missing type
declaration for modules that only use the second version. This happens
for modules that import typeinfo, because the the second component of
typeinfo.Any has type PNimType = ptr TNimType, which generates a
"TNimType *" struct member.

The previous solution was to have a typedef for TNimType in nimbase.h;
however, this results in duplicate typedefs (specifically, but not only
for the code generated for typeinfo.nim). Duplicate typedefs with the
same type name are allowed in C++ and C11, but are explicitly forbidden
in C89 and C99. Modern versions of gcc and clang accept them anyway, but
this is not standard-compliant and may break for other C compilers or
older versions of gcc and clang.

This patch attempts to fix the issue by making the second component of
typeinfo.Nim a pointer instead of a PNimType and casting back and forth
as needed. Thus, the second version of TNimType occurs only within the
code for typeinfo.nim, where it can be safely omitted.
2015-12-15 13:33:38 +01:00
Araq
ba6d0eb4db fixes #3541 2015-11-18 16:07:20 +01:00
Adam Strzelecki
144dc8f8ad Move deprecated modules into lib/deprecated/
This gives clear indication what modules are now deprecated and reduce clutter
in non-deprecated module directories.
2015-09-30 12:26:25 +02:00
Araq
0cc662d8b8 fixes bootstrapping 2015-08-21 12:18:04 +02:00
Araq
695e2e970e implemented macros.getImpl 2015-08-21 02:34:34 +02:00
Dominik Picheta
b9c1dd0072 Fixed macros.nim not compiling.
Iterator aliases are not possible.
2015-08-03 18:42:02 +01:00
Dominik Picheta
303bc45745 Added documentation to macros.items. 2015-08-03 17:05:14 +01:00
Dominik Picheta
04dc46b1aa Merge branch 'macro-items' of https://github.com/transfuturist/Nim into transfuturist-macro-items 2015-08-03 17:03:57 +01:00
Araq
8913e82f45 removed macros.high as it never worked outside of macros.nim 2015-07-28 02:54:21 +02:00
Araq
8594faa543 fixes #2841 2015-07-22 17:08:21 +02:00
Andreas Rumpf
fc9dc6c828 Merge pull request #2272 from def-/unsigned
Move unsigned int operations to system module
2015-07-11 13:28:20 +02:00
Araq
83842ff4ed Nimrod -> Nim rename 2015-07-08 11:49:33 +02:00
Araq
b9ccd06013 fixes bootstrapping problem 2015-07-04 18:24:57 +02:00
transfuturist
558360e6fd Update macros.nim 2015-07-03 13:48:13 -07:00
Adam Strzelecki
1a0417fbe0 macros: Introduce sameType(a, b) for node types
Previously introduced node comparison `==` was working somehow wrong on nodes
returned from getType(a), comparing just ids of the symbols.

Recently introduced `==` change 47dce26886
started comparing symbol nodes pointer-wise, thus strictly. Since getType(a)
always creates new symbol pointing to the type, comparing two such nodes using
`==` always returns false, even they point to the same type.

That is why we need a new sameType macro to be able to tell if these nodes
point to the same type.
2015-07-03 11:11:10 +02:00
Araq
60ac5e3e76 fixes #3046 2015-07-03 10:55:50 +02:00
Araq
6b3abdba0f made macros.$ a bit smarter; but really this one needs to die 2015-07-03 01:57:01 +02:00
def
2353fe343a Update deprecation notice about unsigned module 2015-07-02 12:26:04 +02:00
def
ec97195d8f Add unsigned exports for backwards-compatibility 2015-07-01 18:59:08 +02:00
def
11a908fd40 Move unsigned int operations to system module
This should lead to less confusion because uint numbers and literals
seem to work, but operators are just missing.
2015-07-01 18:57:54 +02:00
Araq
28de800d61 Merge branch 'more_concurrency' into devel
Conflicts:
	doc/tut1.txt
	lib/core/locks.nim
	lib/pure/collections/tables.nim
	lib/pure/selectors.nim
2015-06-30 12:50:24 +02:00
transfuturist
a31c36e98f Undeprecate children 2015-06-20 12:21:16 -07:00
Stefan Talpalaru
b487d4e425 conditional TGenericSeq extension 2015-06-16 15:15:17 +02:00
Stefan Talpalaru
bdac85f2cf Merge branch 'devel' into gogc 2015-06-15 08:44:02 +02:00
Andreas Rumpf
bbb1bdb4a9 Merge pull request #2643 from grncdr/TAny-and-inheritance
Resolve base type fields in `[](TAny, string)`
2015-06-07 10:56:29 +02:00
pdw
6ca3504dfb lib/core - Dropped 'T' from types 2015-06-04 13:17:08 +02:00
Stefan Talpalaru
50e96ad939 the Go GC - initial implementation 2015-05-31 19:07:44 +02:00
Araq
543ec37975 get rid of deprecated effects 2015-05-28 12:51:18 +02:00
transfuturist
bc2aaea853 Change check for NimNode items to node kind 2015-05-17 15:05:26 -07:00
Adam Strzelecki
1d47617d1b Macros: Introduce getType(t: typedesc): NimNode
Since typedesc are exception in macros and they are not implicitly converted to
NimNode on macro call, we need some means to perform such conversion on demand.

Fortunately it is as simple as declaring new magic "NGetType" proc with
typedesc parameter.

NOTE: Keeping actual macro exceptional behavior for typedesc is important,
since it allows passing typedesc macro parameter to other procs or macros
expecting type parameter. If typedesc parameter was implicitly converted, then
we would lost this ability.
2015-05-17 15:28:41 +02:00
transfuturist
3d80fcb8c6 Add value check for NimNode items 2015-05-16 17:50:01 -07:00
transfuturist
7500eed0cf Better solution: deprecation 2015-05-16 17:26:47 -07:00
transfuturist
939c0a6bb8 NimNode needs an items iterator to be used nicely in for statements 2015-05-16 10:52:44 -07:00
Araq
75ccdebd1e get rid of deprecated effects 2015-05-13 12:19:08 +02:00
Stephen Sugden
7fb5932b9b Resolve base type fields in [](TAny, string) 2015-05-03 00:16:22 +02:00
Araq
43eae0c113 macros: added bool literal support 2015-04-20 20:40:10 +02:00
Araq
2b4e233510 Merge branch 'devel' of https://github.com/Araq/Nim into devel 2015-04-20 11:44:54 +02:00
Araq
dc3a0bc009 added macros.newTree proc (why didn't we do this earlier?) 2015-04-20 11:34:18 +02:00
fowlmouth
f8917e8ad3 add ntys up to ntyNot 2015-03-28 03:19:48 -05:00
Araq
a541be8935 prepare for upcoming parsing change of unary operators 2015-03-22 09:31:15 +01:00
def
fd4e629905 Rename PNimrodNode to NimNode 2015-03-17 17:50:32 +01:00
Max Zerzouri
9c126282b2 interpret tuple as a class and tuple[] as the empty tuple
When the indentation syntax is allowed it is always interpreted as a
tuple:

type
  Unit = tuple
2015-03-06 12:20:15 +13:00
Chris Heller
0553758ebd Clone the implementation of cmpIgnoreStyle into macros.nim from typeinfo.nim so that we get rid of any imports in the core modules 2015-03-03 09:29:38 -08:00
Chris Heller
b54dfbce16 Remove use of .format() from macros.nim to avoid importing into core. There is still a remaining import of cmpIgnoreStyle from strutils that needs to be removed as well 2015-03-03 09:22:54 -08:00
Chris Heller
df7e388e0c Make macros.nim expectKind error message with a single TNimrodNodeKind consistent with error message shown with a set of TNimrodNodeKind by displaying the actual node kind (as well as the expected) 2015-03-02 17:02:43 -08:00
Araq
24ae0c387f some love for the testsuite; fixed regressions 2015-03-01 21:41:21 +01:00
Araq
3bfcfeb0cf don't use stdout for nimsuggest server mode 2015-02-27 16:44:55 +01:00
Araq
975f33b01d disable deprecated warnings for macros module 2015-02-25 21:14:21 +01:00
Araq
752052e903 implements a type API for macros 2015-02-24 00:13:28 +01:00
Araq
1e6aef62ba macros.PNimrodNode is now NimNode 2015-02-24 00:13:27 +01:00