diff options
author | Araq <rumpf_a@web.de> | 2011-09-20 00:56:48 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-09-20 00:56:48 +0200 |
commit | fd62116f6eb80d1dd3d6cc745d80629ad32dca1a (patch) | |
tree | ac5cbd102ffa580e322eda22deeef9298babae4a /compiler/seminst.nim | |
parent | dc3ace4f379931f2af4dd4a3cd2a0984a94865af (diff) | |
download | Nim-fd62116f6eb80d1dd3d6cc745d80629ad32dca1a.tar.gz |
bugfixes for generics; new threads implementation still broken
Diffstat (limited to 'compiler/seminst.nim')
-rwxr-xr-x | compiler/seminst.nim | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/seminst.nim b/compiler/seminst.nim index 87f988ed9..d53d33898 100755 --- a/compiler/seminst.nim +++ b/compiler/seminst.nim @@ -29,6 +29,10 @@ proc instantiateGenericParamList(c: PContext, n: PNode, pt: TIdTable, break if t.kind == tyGenericParam: InternalError(a.info, "instantiateGenericParamList: " & q.name.s) + elif t.kind == tyGenericInvokation: + #t = instGenericContainer(c, a, t) + t = generateTypeInstance(c, pt, a, t) + #t = ReplaceTypeVarsT(cl, t) s.typ = t addDecl(c, s) entry.concreteTypes[i] = t @@ -94,6 +98,14 @@ proc fixupInstantiatedSymbols(c: PContext, s: PSym) = closeScope(c.tab) popInfoContext() +proc sideEffectsCheck(c: PContext, s: PSym) = + if {sfNoSideEffect, sfSideEffect} * s.flags == + {sfNoSideEffect, sfSideEffect}: + LocalError(s.info, errXhasSideEffects, s.name.s) + elif sfThread in s.flags and semthreads.needsGlobalAnalysis() and + s.ast.sons[genericParamsPos].kind == nkEmpty: + c.threadEntries.add(s) + proc generateInstance(c: PContext, fn: PSym, pt: TIdTable, info: TLineInfo): PSym = # generates an instantiated proc @@ -133,7 +145,10 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable, var oldPrc = GenericCacheGet(c, entry) if oldPrc == nil: generics.add(entry) + if n.sons[pragmasPos].kind != nkEmpty: + pragma(c, result, n.sons[pragmasPos], allRoutinePragmas) instantiateBody(c, n, result) + sideEffectsCheck(c, result) else: result = oldPrc popInfoContext() |