diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-09-21 11:19:00 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-09-21 11:19:09 +0200 |
commit | b04ef2973d5384e27197643303b1ea1c325d04f5 (patch) | |
tree | dac160d944b122a9765d566d3fcef4cd4c604331 /compiler/pragmas.nim | |
parent | be82d115764819bf9da799630948676ef6cde42a (diff) | |
download | Nim-b04ef2973d5384e27197643303b1ea1c325d04f5.tar.gz |
cleanup importjs implementation
Diffstat (limited to 'compiler/pragmas.nim')
-rw-r--r-- | compiler/pragmas.nim | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 56f5ea126..f8f6a1a23 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -805,20 +805,13 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, 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) + localError(c.config, it.info, "`importjs` pragma requires the JavaScript target") + let name = getOptionalStr(c, it, "$1") 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) + if sym.kind in skProcKinds and {'(', '#', '@'} notin name: + localError(c.config, n.info, "`importjs` for routines requires a pattern") + setExternName(c, sym, name, it.info) of wImportObjC: processImportObjC(c, sym, getOptionalStr(c, it, "$1"), it.info) of wAlign: |