summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-10-14 12:03:18 +0200
committerAraq <rumpf_a@web.de>2012-10-14 12:03:18 +0200
commitb800b77a1a9c746248488bec0ca40adffe565344 (patch)
tree02bb250b819af3978401a0c890dadc4f0e0e7073
parent6fd4b8350d4d5a1a9c45cc633151762945fa1e73 (diff)
parent4ef96a7435b9565e2c971eb2c93464dba223a34f (diff)
downloadNim-b800b77a1a9c746248488bec0ca40adffe565344.tar.gz
Merge branch 'master' of github.com:Araq/Nimrod
-rwxr-xr-xcompiler/ast.nim5
-rwxr-xr-xcompiler/semtypinst.nim4
-rwxr-xr-xcompiler/sigmatch.nim17
-rwxr-xr-xcompiler/transf.nim2
-rwxr-xr-xcompiler/types.nim6
-rw-r--r--lib/wrappers/opengl/opengl.nim120
6 files changed, 85 insertions, 69 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 340a14888..83bd360f2 100755
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -287,6 +287,11 @@ type
     tyGenericInvokation, # ``T[a, b]`` for types to invoke
     tyGenericBody,       # ``T[a, b, body]`` last parameter is the body
     tyGenericInst,       # ``T[a, b, realInstance]`` instantiated generic type
+                         # realInstance will be a concrete type like tyObject
+                         # unless this is an instance of a generic alias type.
+                         # then realInstance will be the tyGenericInst of the
+                         # completely (recursively) resolved alias.
+                         
     tyGenericParam,      # ``a`` in the above patterns
     tyDistinct,
     tyEnum,
diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim
index d51e24c89..e12640945 100755
--- a/compiler/semtypinst.nim
+++ b/compiler/semtypinst.nim
@@ -171,6 +171,10 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType =
     result.flags = result.flags + newbody.flags
     newbody.callConv = body.callConv
     newbody.n = ReplaceTypeVarsN(cl, lastSon(body).n)
+    # This type may be a generic alias and we want to resolve it here.
+    # One step is enough, because the recursive nature of
+    # handleGenericInvokation will handle the alias-to-alias-to-alias case
+    if newbody.isGenericAlias: newbody = newbody.skipGenericAlias
     rawAddSon(result, newbody)
     checkPartialConstructedType(cl.info, newbody)
   else:
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 8968e4e03..f1920a255 100755
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -476,22 +476,23 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
     let ff = lastSon(f)
     if ff != nil: result = typeRel(c, ff, a)
   of tyGenericInvokation:
+    var x = a.skipGenericAlias
     assert(f.sons[0].kind == tyGenericBody)
-    if a.kind == tyGenericInvokation: 
+    if x.kind == tyGenericInvokation:
       #InternalError("typeRel: tyGenericInvokation -> tyGenericInvokation")
       # simply no match for now:
       nil
-    elif a.kind == tyGenericInst and 
-          (f.sons[0].containerID == a.sons[0].containerID) and
-          (sonsLen(a) - 1 == sonsLen(f)): 
-      assert(a.sons[0].kind == tyGenericBody)
+    elif x.kind == tyGenericInst and 
+          (f.sons[0].containerID == x.sons[0].containerID) and
+          (sonsLen(x) - 1 == sonsLen(f)): 
+      assert(x.sons[0].kind == tyGenericBody)
       for i in countup(1, sonsLen(f) - 1): 
-        if a.sons[i].kind == tyGenericParam: 
+        if x.sons[i].kind == tyGenericParam: 
           InternalError("wrong instantiated type!")
-        elif typeRel(c, f.sons[i], a.sons[i]) <= isSubtype: return 
+        elif typeRel(c, f.sons[i], x.sons[i]) <= isSubtype: return 
       result = isGeneric
     else:
-      result = typeRel(c, f.sons[0], a)
+      result = typeRel(c, f.sons[0], x)
       if result != isNone:
         # we steal the generic parameters from the tyGenericBody:
         for i in countup(1, sonsLen(f) - 1):
diff --git a/compiler/transf.nim b/compiler/transf.nim
index 170f8ff0f..d1ee76cf1 100755
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -603,7 +603,7 @@ proc transform(c: PTransf, n: PNode): PTransNode =
     dec c.inLoop
   of nkCaseStmt: result = transformCase(c, n)
   of nkContinueStmt:
-    result = PTransNode(newNode(nkBreakStmt))
+    result = PTransNode(newNodeI(nkBreakStmt, n.info))
     var labl = c.contSyms[c.contSyms.high]
     add(result, PTransNode(newSymNode(labl)))
   of nkBreakStmt: result = transformBreak(c, n)
diff --git a/compiler/types.nim b/compiler/types.nim
index e02d93233..90fffff40 100755
--- a/compiler/types.nim
+++ b/compiler/types.nim
@@ -905,6 +905,12 @@ proc matchType*(a: PType, pattern: openArray[tuple[k:TTypeKind, i:int]],
     a = a.sons[i]
   result = a.kind == last
 
+proc isGenericAlias*(t: PType): bool =
+  return t.kind == tyGenericInst and t.lastSon.kind == tyGenericInst
+
+proc skipGenericAlias*(t: PType): PType =
+  return if t.isGenericAlias: t.lastSon else: t
+
 proc matchTypeClass*(bindings: var TIdTable, typeClass, t: PType): bool =
   for i in countup(0, typeClass.sonsLen - 1):
     let req = typeClass.sons[i]
diff --git a/lib/wrappers/opengl/opengl.nim b/lib/wrappers/opengl/opengl.nim
index fab8183f5..a61159016 100644
--- a/lib/wrappers/opengl/opengl.nim
+++ b/lib/wrappers/opengl/opengl.nim
@@ -8,13 +8,13 @@
 #

 

 ## This module is a wrapper around `opengl`:idx:. If you define the symbol

-## ``useGlew`` this wrapper does not use Nimrod's ``dynlib`` mechanism, 
-## but `glew`:idx: instead. However, this shouldn't be necessary anymore; even
-## extension loading for the different operating systems is handled here.
-##
-## You need to call ``loadExtensions`` after a rendering context has been
+## ``useGlew`` this wrapper does not use Nimrod's ``dynlib`` mechanism, 

+## but `glew`:idx: instead. However, this shouldn't be necessary anymore; even

+## extension loading for the different operating systems is handled here.

+##

+## You need to call ``loadExtensions`` after a rendering context has been

 ## created to load any extension proc that your code uses.

-
+

 when defined(linux):

   import X, XLib, XUtil

 elif defined(windows):

@@ -39,58 +39,58 @@ when defined(useGlew):
   {.pragma: wgl, header: "<GL/wglew.h>".}

   {.pragma: glu, dynlib: gludll.}

 else:

-  # quite complex ... thanks to extension support for various platforms:
-  import dynlib
-  
-  let oglHandle = LoadLib(ogldll)
-  if isNil(oglHandle): quit("could not load: " & ogldll)
-  
-  when defined(windows):
-    var wglGetProcAddress = cast[proc (s: cstring): pointer {.stdcall.}](
-      symAddr(oglHandle, "wglGetProcAddress"))
-  elif defined(linux):
-    var glXGetProcAddress = cast[proc (s: cstring): pointer {.cdecl.}](
-      symAddr(oglHandle, "glXGetProcAddress"))
-    var glXGetProcAddressARB = cast[proc (s: cstring): pointer {.cdecl.}](
-      symAddr(oglHandle, "glXGetProcAddressARB"))
-
-  proc glGetProc(h: TLibHandle; procName: cstring): pointer =
-    when defined(windows):
-      result = symAddr(h, procname)
-      if result != nil: return
-      if not isNil(wglGetProcAddress): result = wglGetProcAddress(ProcName)
-    elif defined(linux):
-      if not isNil(glXGetProcAddress): result = glXGetProcAddress(ProcName)
-      if result != nil: return 
-      if not isNil(glXGetProcAddressARB): 
-        result = glXGetProcAddressARB(ProcName)
-        if result != nil: return
-      result = symAddr(h, procname)
-    else:
-      result = symAddr(h, procName)
-    if result == nil: raiseInvalidLibrary(procName)
-
-  var gluHandle: TLibHandle
-  
-  proc gluGetProc(procname: cstring): pointer =
-    if gluHandle == nil:
-      gluHandle = LoadLib(gludll)
-      if gluHandle == nil: quit("could not load: " & gludll)
-    result = glGetProc(gluHandle, procname)
-  
-  # undocumented 'dynlib' feature: the string literal is replaced by
-  # the imported proc name:
-  {.pragma: ogl, dynlib: glGetProc(oglHandle, "").}

+  # quite complex ... thanks to extension support for various platforms:

+  import dynlib

+  

+  let oglHandle = LoadLib(ogldll)

+  if isNil(oglHandle): quit("could not load: " & ogldll)

+  

+  when defined(windows):

+    var wglGetProcAddress = cast[proc (s: cstring): pointer {.stdcall.}](

+      symAddr(oglHandle, "wglGetProcAddress"))

+  elif defined(linux):

+    var glXGetProcAddress = cast[proc (s: cstring): pointer {.cdecl.}](

+      symAddr(oglHandle, "glXGetProcAddress"))

+    var glXGetProcAddressARB = cast[proc (s: cstring): pointer {.cdecl.}](

+      symAddr(oglHandle, "glXGetProcAddressARB"))

+

+  proc glGetProc(h: TLibHandle; procName: cstring): pointer =

+    when defined(windows):

+      result = symAddr(h, procname)

+      if result != nil: return

+      if not isNil(wglGetProcAddress): result = wglGetProcAddress(ProcName)

+    elif defined(linux):

+      if not isNil(glXGetProcAddress): result = glXGetProcAddress(ProcName)

+      if result != nil: return 

+      if not isNil(glXGetProcAddressARB): 

+        result = glXGetProcAddressARB(ProcName)

+        if result != nil: return

+      result = symAddr(h, procname)

+    else:

+      result = symAddr(h, procName)

+    if result == nil: raiseInvalidLibrary(procName)

+

+  var gluHandle: TLibHandle

+  

+  proc gluGetProc(procname: cstring): pointer =

+    if gluHandle == nil:

+      gluHandle = LoadLib(gludll)

+      if gluHandle == nil: quit("could not load: " & gludll)

+    result = glGetProc(gluHandle, procname)

+  

+  # undocumented 'dynlib' feature: the string literal is replaced by

+  # the imported proc name:

+  {.pragma: ogl, dynlib: glGetProc(oglHandle, "0").}

   {.pragma: oglx, dynlib: glGetProc(oglHandle, "0").}

-  {.pragma: wgl, dynlib: glGetProc(oglHandle, "").}

-  {.pragma: glu, dynlib: gluGetProc("").}
-  
-  proc nimLoadProcs0() {.importc.}
-  
-  template loadExtensions*() =
-    ## call this after your rendering context has been setup if you use
-    ## extensions.
-    bind nimLoadProcs0
+  {.pragma: wgl, dynlib: glGetProc(oglHandle, "0").}

+  {.pragma: glu, dynlib: gluGetProc("").}

+  

+  proc nimLoadProcs0() {.importc.}

+  

+  template loadExtensions*() =

+    ## call this after your rendering context has been setup if you use

+    ## extensions.

+    bind nimLoadProcs0

     nimLoadProcs0()

 

 #==============================================================================

@@ -9104,7 +9104,7 @@ proc glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN*(rc: GLuint,
 proc glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN*(rc: PGLuint, 

     tc: PGLfloat, c: PGLfloat, n: PGLfloat, v: PGLfloat){.stdcall, importc, ogl.}

   # window support functions

-when defined(windows): 
+when defined(windows): 

   when not defined(wglGetProcAddress):

     proc wglGetProcAddress*(ProcName: cstring): Pointer{.stdcall, importc, wgl.}

   proc wglCopyContext*(p1: HGLRC, p2: HGLRC, p3: int): BOOL{.stdcall, importc, wgl.}

@@ -9446,11 +9446,11 @@ when defined(LINUX):
       stdcall, importc, oglx.}

   proc glXGetSelectedEvent*(dpy: PDisplay, draw: GLXDrawable, 

                             event_mask: PGLuint){.stdcall, importc, oglx.}

-    # GLX_VERSION_1_4
+    # GLX_VERSION_1_4

   when not defined(glXGetProcAddress):

     proc glXGetProcAddress*(name: cstring): pointer{.stdcall, importc, oglx.}

     # GLX_ARB_get_proc_address

-  when not defined(glXGetProcAddressARB):
+  when not defined(glXGetProcAddressARB):

     proc glXGetProcAddressARB*(name: cstring): pointer{.stdcall, importc, oglx.}

     # GLX_ARB_create_context

   proc glXCreateContextAttribsARB*(dpy: PDisplay, config: GLXFBConfig, 

a@gmail.com> 2013-06-30 18:59:38 +0300 initial support of autojoin for MUC' href='/danisanti/profani-tty/commit/src/xmpp/stanza.h?id=2837c4054f0c46f9cbbd0f09571e7d91501f2253'>2837c405 ^
48f9f3b3 ^
167ee28e ^
48f9f3b3 ^
78beccee ^
475dfebd ^
eb5cb7b2 ^
bc2784da ^
5e5590b0 ^

e263e00a ^





508bfeb2 ^












5bb3fab1 ^
2837c405 ^
c8a6bdb3 ^
48f9f3b3 ^
c8a6bdb3 ^
48f9f3b3 ^
bc2784da ^
c8a6bdb3 ^
bc2784da ^
c8a6bdb3 ^




78beccee ^
57c75644 ^
c8a6bdb3 ^
bc2784da ^
c8a6bdb3 ^

bc2784da ^

c8a6bdb3 ^
bc2784da ^

c8a6bdb3 ^
bc2784da ^
c8a6bdb3 ^
bc2784da ^

c8a6bdb3 ^


bc2784da ^
c8a6bdb3 ^

26d160ca ^
c8a6bdb3 ^



81020e6d ^
bc2784da ^

c8a6bdb3 ^





























bc2784da ^

c8a6bdb3 ^




1cea320a ^
c8a6bdb3 ^


1cd2d6c7 ^
c8a6bdb3 ^

8d2e0656 ^
c8a6bdb3 ^


d300e8e7 ^
c8a6bdb3 ^
292ae567 ^
c8a6bdb3 ^
d12534c5 ^



77674beb ^

d12534c5 ^
508bfeb2 ^



c8a6bdb3 ^
e263e00a ^

bc2784da ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306