diff options
author | cooldome <ariabushenko@bk.ru> | 2018-06-26 23:33:34 +0100 |
---|---|---|
committer | cooldome <ariabushenko@bk.ru> | 2018-06-26 23:33:34 +0100 |
commit | 34170db96308c367357ece15404815727bce223a (patch) | |
tree | 0461d115e39feff0b5ea855fb56f9882ce1eba2c /compiler/pluginsupport.nim | |
parent | 0b709fb916923b0d5e9eab06fc8766e46e63d955 (diff) | |
parent | 19ea3a70d2d6d404235e0f5250d6b681d56903a5 (diff) | |
download | Nim-34170db96308c367357ece15404815727bce223a.tar.gz |
Merge branch 'devel' into Fixes-7845
Diffstat (limited to 'compiler/pluginsupport.nim')
-rw-r--r-- | compiler/pluginsupport.nim | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/compiler/pluginsupport.nim b/compiler/pluginsupport.nim index f67942c97..a44436f11 100644 --- a/compiler/pluginsupport.nim +++ b/compiler/pluginsupport.nim @@ -8,40 +8,26 @@ # ## Plugin support for the Nim compiler. Right now plugins -## need to be built with the compiler only: plugins using +## need to be built with the compiler only: plugins using ## DLLs or the FFI will not work. import ast, semdata, idents type Transformation* = proc (c: PContext; n: PNode): PNode {.nimcall.} - Plugin = ref object - fn, module, package: PIdent + Plugin* = tuple + package, module, fn: string t: Transformation - next: Plugin -proc pluginMatches(p: Plugin; s: PSym): bool = - if s.name.id != p.fn.id: +proc pluginMatches*(ic: IdentCache; p: Plugin; s: PSym): bool = + if s.name.id != ic.getIdent(p.fn).id: return false let module = s.skipGenericOwner if module == nil or module.kind != skModule or - module.name.id != p.module.id: + module.name.id != ic.getIdent(p.module).id: return false let package = module.owner if package == nil or package.kind != skPackage or - package.name.id != p.package.id: + package.name.id != ic.getIdent(p.package).id: return false return true - -var head: Plugin - -proc getPlugin*(fn: PSym): Transformation = - var it = head - while it != nil: - if pluginMatches(it, fn): return it.t - it = it.next - -proc registerPlugin*(package, module, fn: string; t: Transformation) = - let oldHead = head - head = Plugin(fn: getIdent(fn), module: getIdent(module), - package: getIdent(package), t: t, next: oldHead) |