diff options
author | Arne Döring <arne.doering@gmx.net> | 2019-09-20 20:26:30 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-09-20 20:26:30 +0200 |
commit | 38ab51c44572b78845fa62b0c0a597a46a63ad28 (patch) | |
tree | df3a7ffa585c333fcbe65a3f49c18bbd5d6c5e88 /compiler/pragmas.nim | |
parent | 7bc5bf83345a0ebaef3dca9395f0bc7d285ba61e (diff) | |
download | Nim-38ab51c44572b78845fa62b0c0a597a46a63ad28.tar.gz |
importjs symbol (#12218)
* importjs symbol * importjs warning message, minor warning fixes
Diffstat (limited to 'compiler/pragmas.nim')
-rw-r--r-- | compiler/pragmas.nim | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index e9a89bc44..56f5ea126 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -19,7 +19,7 @@ const LastCallConv* = wNoconv const - declPragmas = {wImportc, wImportObjC, wImportCpp, wExportc, wExportCpp, + declPragmas = {wImportc, wImportObjC, wImportCpp, wImportJs, wExportc, wExportCpp, wExportNims, wExtern, wDeprecated, wNodecl, wError, wUsed} ## common pragmas for declarations, to a good approximation procPragmas* = declPragmas + {FirstCallConv..LastCallConv, @@ -803,6 +803,22 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, else: invalidPragma(c, it) of wImportCpp: processImportCpp(c, sym, getOptionalStr(c, it, "$1"), it.info) + of wImportJs: + if c.config.cmd != cmdCompileToJS: + localError(c.config, it.info, "importjs pragma only supported when compiling to js.") + var strArg: PNode = nil + if it.kind in nkPragmaCallKinds: + strArg = it[1] + if strArg.kind notin {nkStrLit..nkTripleStrLit}: + localError(c.config, it.info, errStringLiteralExpected) + incl(sym.flags, sfImportc) + incl(sym.flags, sfInfixCall) + if strArg == nil: + if sym.kind in skProcKinds: + message(c.config, n.info, warnDeprecated, "procedure import should have an import pattern") + setExternName(c, sym, sym.name.s, it.info) + else: + setExternName(c, sym, strArg.strVal, it.info) of wImportObjC: processImportObjC(c, sym, getOptionalStr(c, it, "$1"), it.info) of wAlign: |