almost every pragma is allowed in a 'push' pragma
This commit is contained in:
parent
1dfc57c5ff
commit
022ff2e86e
7 changed files with 259 additions and 231 deletions
|
|
@ -259,6 +259,7 @@ proc MainCommand =
|
||||||
gCmd = cmdDoc
|
gCmd = cmdDoc
|
||||||
LoadConfigs(DocConfig)
|
LoadConfigs(DocConfig)
|
||||||
wantMainModule()
|
wantMainModule()
|
||||||
|
DefineSymbol("nimdoc")
|
||||||
CommandDoc2()
|
CommandDoc2()
|
||||||
of "rst2html":
|
of "rst2html":
|
||||||
gCmd = cmdRst2html
|
gCmd = cmdRst2html
|
||||||
|
|
|
||||||
|
|
@ -262,10 +262,10 @@ proc processNote(c: PContext, n: PNode) =
|
||||||
else:
|
else:
|
||||||
invalidPragma(n)
|
invalidPragma(n)
|
||||||
|
|
||||||
proc processOption(c: PContext, n: PNode) =
|
proc processOption(c: PContext, n: PNode): bool =
|
||||||
if n.kind != nkExprColonExpr: invalidPragma(n)
|
if n.kind != nkExprColonExpr: result = true
|
||||||
elif n.sons[0].kind == nkBracketExpr: processNote(c, n)
|
elif n.sons[0].kind == nkBracketExpr: processNote(c, n)
|
||||||
elif n.sons[0].kind != nkIdent: invalidPragma(n)
|
elif n.sons[0].kind != nkIdent: result = true
|
||||||
else:
|
else:
|
||||||
var sw = whichKeyword(n.sons[0].ident)
|
var sw = whichKeyword(n.sons[0].ident)
|
||||||
case sw
|
case sw
|
||||||
|
|
@ -307,9 +307,11 @@ proc processOption(c: PContext, n: PNode) =
|
||||||
else: LocalError(n.info, errNoneSpeedOrSizeExpected)
|
else: LocalError(n.info, errNoneSpeedOrSizeExpected)
|
||||||
of wImplicitStatic: OnOff(c, n, {optImplicitStatic})
|
of wImplicitStatic: OnOff(c, n, {optImplicitStatic})
|
||||||
of wPatterns: OnOff(c, n, {optPatterns})
|
of wPatterns: OnOff(c, n, {optPatterns})
|
||||||
else: LocalError(n.info, errOptionExpected)
|
else: result = true
|
||||||
|
|
||||||
proc processPush(c: PContext, n: PNode, start: int) =
|
proc processPush(c: PContext, n: PNode, start: int) =
|
||||||
|
if n.sons[start-1].kind == nkExprColonExpr:
|
||||||
|
LocalError(n.info, errGenerated, "':' after 'push' not supported")
|
||||||
var x = newOptionEntry()
|
var x = newOptionEntry()
|
||||||
var y = POptionEntry(c.optionStack.tail)
|
var y = POptionEntry(c.optionStack.tail)
|
||||||
x.options = gOptions
|
x.options = gOptions
|
||||||
|
|
@ -318,15 +320,18 @@ proc processPush(c: PContext, n: PNode, start: int) =
|
||||||
x.notes = gNotes
|
x.notes = gNotes
|
||||||
append(c.optionStack, x)
|
append(c.optionStack, x)
|
||||||
for i in countup(start, sonsLen(n) - 1):
|
for i in countup(start, sonsLen(n) - 1):
|
||||||
processOption(c, n.sons[i])
|
if processOption(c, n.sons[i]):
|
||||||
#liMessage(n.info, warnUser, ropeToStr(optionsToStr(gOptions)));
|
# simply store it somehwere:
|
||||||
|
if x.otherPragmas.isNil:
|
||||||
|
x.otherPragmas = newNodeI(nkPragma, n.info)
|
||||||
|
x.otherPragmas.add n.sons[i]
|
||||||
|
#LocalError(n.info, errOptionExpected)
|
||||||
|
|
||||||
proc processPop(c: PContext, n: PNode) =
|
proc processPop(c: PContext, n: PNode) =
|
||||||
if c.optionStack.counter <= 1:
|
if c.optionStack.counter <= 1:
|
||||||
LocalError(n.info, errAtPopWithoutPush)
|
LocalError(n.info, errAtPopWithoutPush)
|
||||||
else:
|
else:
|
||||||
gOptions = POptionEntry(c.optionStack.tail).options
|
gOptions = POptionEntry(c.optionStack.tail).options
|
||||||
#liMessage(n.info, warnUser, ropeToStr(optionsToStr(gOptions)));
|
|
||||||
gNotes = POptionEntry(c.optionStack.tail).notes
|
gNotes = POptionEntry(c.optionStack.tail).notes
|
||||||
remove(c.optionStack, c.optionStack.tail)
|
remove(c.optionStack, c.optionStack.tail)
|
||||||
|
|
||||||
|
|
@ -481,9 +486,8 @@ proc pragmaRaisesOrTags(c: PContext, n: PNode) =
|
||||||
else:
|
else:
|
||||||
invalidPragma(n)
|
invalidPragma(n)
|
||||||
|
|
||||||
proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int,
|
||||||
if n == nil: return
|
validPragmas: TSpecialWords): bool =
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
|
||||||
var it = n.sons[i]
|
var it = n.sons[i]
|
||||||
var key = if it.kind == nkExprColonExpr: it.sons[0] else: it
|
var key = if it.kind == nkExprColonExpr: it.sons[0] else: it
|
||||||
if key.kind == nkIdent:
|
if key.kind == nkIdent:
|
||||||
|
|
@ -646,11 +650,11 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
||||||
of wWatchpoint: PragmaWatchpoint(c, it)
|
of wWatchpoint: PragmaWatchpoint(c, it)
|
||||||
of wPush:
|
of wPush:
|
||||||
processPush(c, n, i + 1)
|
processPush(c, n, i + 1)
|
||||||
break
|
result = true
|
||||||
of wPop: processPop(c, it)
|
of wPop: processPop(c, it)
|
||||||
of wPragma:
|
of wPragma:
|
||||||
processPragma(c, n, i)
|
processPragma(c, n, i)
|
||||||
break
|
result = true
|
||||||
of wDiscardable:
|
of wDiscardable:
|
||||||
noVal(it)
|
noVal(it)
|
||||||
if sym != nil: incl(sym.flags, sfDiscardable)
|
if sym != nil: incl(sym.flags, sfDiscardable)
|
||||||
|
|
@ -666,7 +670,9 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
||||||
wCallConv,
|
wCallConv,
|
||||||
wDebugger, wProfiler, wFloatChecks, wNanChecks, wInfChecks,
|
wDebugger, wProfiler, wFloatChecks, wNanChecks, wInfChecks,
|
||||||
wPatterns:
|
wPatterns:
|
||||||
processOption(c, it) # calling conventions (boring...):
|
if processOption(c, it):
|
||||||
|
# calling conventions (boring...):
|
||||||
|
LocalError(it.info, errOptionExpected)
|
||||||
of firstCallConv..lastCallConv:
|
of firstCallConv..lastCallConv:
|
||||||
assert(sym != nil)
|
assert(sym != nil)
|
||||||
if sym.typ == nil: invalidPragma(it)
|
if sym.typ == nil: invalidPragma(it)
|
||||||
|
|
@ -684,7 +690,7 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
||||||
of wByRef:
|
of wByRef:
|
||||||
noVal(it)
|
noVal(it)
|
||||||
if sym == nil or sym.typ == nil:
|
if sym == nil or sym.typ == nil:
|
||||||
processOption(c, it)
|
if processOption(c, it): LocalError(it.info, errOptionExpected)
|
||||||
else:
|
else:
|
||||||
incl(sym.typ.flags, tfByRef)
|
incl(sym.typ.flags, tfByRef)
|
||||||
of wByCopy:
|
of wByCopy:
|
||||||
|
|
@ -701,7 +707,19 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
||||||
else: invalidPragma(it)
|
else: invalidPragma(it)
|
||||||
else: invalidPragma(it)
|
else: invalidPragma(it)
|
||||||
else: processNote(c, it)
|
else: processNote(c, it)
|
||||||
|
|
||||||
|
proc implictPragmas*(c: PContext, sym: PSym, n: PNode,
|
||||||
|
validPragmas: TSpecialWords) =
|
||||||
if sym != nil and sym.kind != skModule:
|
if sym != nil and sym.kind != skModule:
|
||||||
|
var it = POptionEntry(c.optionstack.head)
|
||||||
|
while it != nil:
|
||||||
|
let o = it.otherPragmas
|
||||||
|
if not o.isNil:
|
||||||
|
for i in countup(0, sonsLen(o) - 1):
|
||||||
|
if singlePragma(c, sym, o, i, validPragmas):
|
||||||
|
InternalError(n.info, "implicitPragmas")
|
||||||
|
it = it.next.POptionEntry
|
||||||
|
|
||||||
if lfExportLib in sym.loc.flags and sfExportc notin sym.flags:
|
if lfExportLib in sym.loc.flags and sfExportc notin sym.flags:
|
||||||
LocalError(n.info, errDynlibRequiresExportc)
|
LocalError(n.info, errDynlibRequiresExportc)
|
||||||
var lib = POptionEntry(c.optionstack.tail).dynlib
|
var lib = POptionEntry(c.optionstack.tail).dynlib
|
||||||
|
|
@ -711,3 +729,8 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
||||||
addToLib(lib, sym)
|
addToLib(lib, sym)
|
||||||
if sym.loc.r == nil: sym.loc.r = toRope(sym.name.s)
|
if sym.loc.r == nil: sym.loc.r = toRope(sym.name.s)
|
||||||
|
|
||||||
|
proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
||||||
|
if n == nil: return
|
||||||
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
|
if singlePragma(c, sym, n, i, validPragmas): break
|
||||||
|
implictPragmas(c, sym, n, validPragmas)
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ type
|
||||||
defaultCC*: TCallingConvention
|
defaultCC*: TCallingConvention
|
||||||
dynlib*: PLib
|
dynlib*: PLib
|
||||||
Notes*: TNoteKinds
|
Notes*: TNoteKinds
|
||||||
|
otherPragmas*: PNode # every pragma can be pushed
|
||||||
|
|
||||||
POptionEntry* = ref TOptionEntry
|
POptionEntry* = ref TOptionEntry
|
||||||
PProcCon* = ref TProcCon
|
PProcCon* = ref TProcCon
|
||||||
|
|
|
||||||
|
|
@ -758,6 +758,8 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
||||||
addInterfaceDeclAt(c, s, c.tab.tos - 2)
|
addInterfaceDeclAt(c, s, c.tab.tos - 2)
|
||||||
if n.sons[pragmasPos].kind != nkEmpty:
|
if n.sons[pragmasPos].kind != nkEmpty:
|
||||||
pragma(c, s, n.sons[pragmasPos], validPragmas)
|
pragma(c, s, n.sons[pragmasPos], validPragmas)
|
||||||
|
else:
|
||||||
|
implictPragmas(c, s, n, validPragmas)
|
||||||
else:
|
else:
|
||||||
if n.sons[pragmasPos].kind != nkEmpty:
|
if n.sons[pragmasPos].kind != nkEmpty:
|
||||||
LocalError(n.sons[pragmasPos].info, errPragmaOnlyInHeaderOfProc)
|
LocalError(n.sons[pragmasPos].info, errPragmaOnlyInHeaderOfProc)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nimrod's Runtime Library
|
||||||
# (c) Copyright 2010 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
## Declaration of the Document Object Model for the ECMAScript backend.
|
## Declaration of the Document Object Model for the ECMAScript backend.
|
||||||
|
|
||||||
when not defined(ecmascript):
|
when not defined(ecmascript) and not defined(Nimdoc):
|
||||||
{.error: "This module only works on the ECMAScript platform".}
|
{.error: "This module only works on the ECMAScript platform".}
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ Compiler Additions
|
||||||
Use the new ``--project`` switch to enable this behaviour.
|
Use the new ``--project`` switch to enable this behaviour.
|
||||||
- The compiler can now warn about shadowed local variables. However, this needs
|
- The compiler can now warn about shadowed local variables. However, this needs
|
||||||
to be turned on explicitly via ``--warning[ShadowIdent]:on``.
|
to be turned on explicitly via ``--warning[ShadowIdent]:on``.
|
||||||
|
- The compiler now supports almost every pragma in a ``push`` pragma.
|
||||||
|
|
||||||
|
|
||||||
Language Additions
|
Language Additions
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ pdf: "manual;lib;tut1;tut2;nimrodc;c2nim;niminst;gc"
|
||||||
srcdoc2: "system.nim;impure/graphics;wrappers/sdl"
|
srcdoc2: "system.nim;impure/graphics;wrappers/sdl"
|
||||||
srcdoc2: "core/macros;pure/marshal;core/typeinfo;core/unsigned"
|
srcdoc2: "core/macros;pure/marshal;core/typeinfo;core/unsigned"
|
||||||
srcdoc2: "impure/re;pure/sockets"
|
srcdoc2: "impure/re;pure/sockets"
|
||||||
srcdoc: "system/threads.nim;system/channels.nim"
|
srcdoc: "system/threads.nim;system/channels.nim;ecmas/dom"
|
||||||
srcdoc2: "pure/os;pure/strutils;pure/math;pure/matchers;pure/algorithm"
|
srcdoc2: "pure/os;pure/strutils;pure/math;pure/matchers;pure/algorithm"
|
||||||
srcdoc2: "pure/complex;pure/times;pure/osproc;pure/pegs;pure/dynlib"
|
srcdoc2: "pure/complex;pure/times;pure/osproc;pure/pegs;pure/dynlib"
|
||||||
srcdoc2: "pure/parseopt;pure/hashes;pure/strtabs;pure/lexbase"
|
srcdoc2: "pure/parseopt;pure/hashes;pure/strtabs;pure/lexbase"
|
||||||
|
|
@ -43,7 +43,7 @@ srcdoc2: "pure/json;pure/base64;pure/scgi;pure/redis;impure/graphics"
|
||||||
srcdoc2: "impure/rdstdin;wrappers/zmq;wrappers/sphinx"
|
srcdoc2: "impure/rdstdin;wrappers/zmq;wrappers/sphinx"
|
||||||
srcdoc2: "pure/collections/tables;pure/collections/sets;pure/collections/lists"
|
srcdoc2: "pure/collections/tables;pure/collections/sets;pure/collections/lists"
|
||||||
srcdoc2: "pure/collections/intsets;pure/collections/queues;pure/encodings"
|
srcdoc2: "pure/collections/intsets;pure/collections/queues;pure/encodings"
|
||||||
srcdoc2: "pure/events;pure/collections/sequtils;pure/irc;ecmas/dom;pure/cookies"
|
srcdoc2: "pure/events;pure/collections/sequtils;pure/irc;pure/cookies"
|
||||||
srcdoc2: "pure/ftpclient;pure/memfiles;pure/subexes;pure/collections/critbits"
|
srcdoc2: "pure/ftpclient;pure/memfiles;pure/subexes;pure/collections/critbits"
|
||||||
srcdoc2: "pure/asyncio;pure/actors;core/locks;pure/oids;pure/endians;pure/uri"
|
srcdoc2: "pure/asyncio;pure/actors;core/locks;pure/oids;pure/endians;pure/uri"
|
||||||
srcdoc2: "pure/nimprof"
|
srcdoc2: "pure/nimprof"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue