added iterToProc plugin

This commit is contained in:
Araq
2015-11-29 14:58:06 +01:00
parent 6361f6b76d
commit 5de900b456
3 changed files with 27 additions and 7 deletions

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
## Plugin support for the Nim compiler. Right now there are no plugins and they
## Plugin support for the Nim compiler. Right now they
## need to be build with the compiler, no DLL support.
import ast, semdata, idents
@@ -20,13 +20,16 @@ type
next: Plugin
proc pluginMatches(p: Plugin; s: PSym): bool =
if s.name.id != p.fn.id: return false
let module = s.owner
if s.name.id != p.fn.id:
return false
let module = s.owner.skipGenericOwner
if module == nil or module.kind != skModule or
module.name.id != p.module.id: return false
module.name.id != p.module.id:
return false
let package = module.owner
if package == nil or package.kind != skPackage or
package.name.id != p.package.id: return false
package.name.id != p.package.id:
return false
return true
var head: Plugin

View File

@@ -10,4 +10,4 @@
## Include file that imports all plugins that are active.
import
locals.locals
locals.locals, itersgen

View File

@@ -1780,7 +1780,24 @@ proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
result = setMs(n, s)
result.sons[1] = semExpr(c, n.sons[1])
result.typ = n[1].typ
else: result = semDirectOp(c, n, flags)
of mPlugin:
# semDirectOp with conditional 'afterCallActions':
let nOrig = n.copyTree
#semLazyOpAux(c, n)
result = semOverloadedCallAnalyseEffects(c, n, nOrig, flags)
if result == nil:
result = errorNode(c, n)
else:
let callee = result.sons[0].sym
if callee.magic == mNone:
semFinishOperands(c, result)
activate(c, result)
fixAbstractType(c, result)
analyseIfAddressTakenInCall(c, result)
if callee.magic != mNone:
result = magicsAfterOverloadResolution(c, result, flags)
else:
result = semDirectOp(c, n, flags)
proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
# If semCheck is set to false, ``when`` will return the verbatim AST of