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
|
||||
LoadConfigs(DocConfig)
|
||||
wantMainModule()
|
||||
DefineSymbol("nimdoc")
|
||||
CommandDoc2()
|
||||
of "rst2html":
|
||||
gCmd = cmdRst2html
|
||||
|
|
|
|||
|
|
@ -262,10 +262,10 @@ proc processNote(c: PContext, n: PNode) =
|
|||
else:
|
||||
invalidPragma(n)
|
||||
|
||||
proc processOption(c: PContext, n: PNode) =
|
||||
if n.kind != nkExprColonExpr: invalidPragma(n)
|
||||
proc processOption(c: PContext, n: PNode): bool =
|
||||
if n.kind != nkExprColonExpr: result = true
|
||||
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:
|
||||
var sw = whichKeyword(n.sons[0].ident)
|
||||
case sw
|
||||
|
|
@ -307,9 +307,11 @@ proc processOption(c: PContext, n: PNode) =
|
|||
else: LocalError(n.info, errNoneSpeedOrSizeExpected)
|
||||
of wImplicitStatic: OnOff(c, n, {optImplicitStatic})
|
||||
of wPatterns: OnOff(c, n, {optPatterns})
|
||||
else: LocalError(n.info, errOptionExpected)
|
||||
else: result = true
|
||||
|
||||
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 y = POptionEntry(c.optionStack.tail)
|
||||
x.options = gOptions
|
||||
|
|
@ -318,15 +320,18 @@ proc processPush(c: PContext, n: PNode, start: int) =
|
|||
x.notes = gNotes
|
||||
append(c.optionStack, x)
|
||||
for i in countup(start, sonsLen(n) - 1):
|
||||
processOption(c, n.sons[i])
|
||||
#liMessage(n.info, warnUser, ropeToStr(optionsToStr(gOptions)));
|
||||
if processOption(c, n.sons[i]):
|
||||
# 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) =
|
||||
if c.optionStack.counter <= 1:
|
||||
LocalError(n.info, errAtPopWithoutPush)
|
||||
else:
|
||||
gOptions = POptionEntry(c.optionStack.tail).options
|
||||
#liMessage(n.info, warnUser, ropeToStr(optionsToStr(gOptions)));
|
||||
gNotes = POptionEntry(c.optionStack.tail).notes
|
||||
remove(c.optionStack, c.optionStack.tail)
|
||||
|
||||
|
|
@ -481,9 +486,8 @@ proc pragmaRaisesOrTags(c: PContext, n: PNode) =
|
|||
else:
|
||||
invalidPragma(n)
|
||||
|
||||
proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
||||
if n == nil: return
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int,
|
||||
validPragmas: TSpecialWords): bool =
|
||||
var it = n.sons[i]
|
||||
var key = if it.kind == nkExprColonExpr: it.sons[0] else: it
|
||||
if key.kind == nkIdent:
|
||||
|
|
@ -646,11 +650,11 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
|||
of wWatchpoint: PragmaWatchpoint(c, it)
|
||||
of wPush:
|
||||
processPush(c, n, i + 1)
|
||||
break
|
||||
result = true
|
||||
of wPop: processPop(c, it)
|
||||
of wPragma:
|
||||
processPragma(c, n, i)
|
||||
break
|
||||
result = true
|
||||
of wDiscardable:
|
||||
noVal(it)
|
||||
if sym != nil: incl(sym.flags, sfDiscardable)
|
||||
|
|
@ -666,7 +670,9 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
|||
wCallConv,
|
||||
wDebugger, wProfiler, wFloatChecks, wNanChecks, wInfChecks,
|
||||
wPatterns:
|
||||
processOption(c, it) # calling conventions (boring...):
|
||||
if processOption(c, it):
|
||||
# calling conventions (boring...):
|
||||
LocalError(it.info, errOptionExpected)
|
||||
of firstCallConv..lastCallConv:
|
||||
assert(sym != nil)
|
||||
if sym.typ == nil: invalidPragma(it)
|
||||
|
|
@ -684,7 +690,7 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
|||
of wByRef:
|
||||
noVal(it)
|
||||
if sym == nil or sym.typ == nil:
|
||||
processOption(c, it)
|
||||
if processOption(c, it): LocalError(it.info, errOptionExpected)
|
||||
else:
|
||||
incl(sym.typ.flags, tfByRef)
|
||||
of wByCopy:
|
||||
|
|
@ -701,7 +707,19 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
|||
else: invalidPragma(it)
|
||||
else: invalidPragma(it)
|
||||
else: processNote(c, it)
|
||||
|
||||
proc implictPragmas*(c: PContext, sym: PSym, n: PNode,
|
||||
validPragmas: TSpecialWords) =
|
||||
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:
|
||||
LocalError(n.info, errDynlibRequiresExportc)
|
||||
var lib = POptionEntry(c.optionstack.tail).dynlib
|
||||
|
|
@ -711,3 +729,8 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
|
|||
addToLib(lib, sym)
|
||||
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
|
||||
dynlib*: PLib
|
||||
Notes*: TNoteKinds
|
||||
otherPragmas*: PNode # every pragma can be pushed
|
||||
|
||||
POptionEntry* = ref TOptionEntry
|
||||
PProcCon* = ref TProcCon
|
||||
|
|
|
|||
|
|
@ -758,6 +758,8 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
|||
addInterfaceDeclAt(c, s, c.tab.tos - 2)
|
||||
if n.sons[pragmasPos].kind != nkEmpty:
|
||||
pragma(c, s, n.sons[pragmasPos], validPragmas)
|
||||
else:
|
||||
implictPragmas(c, s, n, validPragmas)
|
||||
else:
|
||||
if n.sons[pragmasPos].kind != nkEmpty:
|
||||
LocalError(n.sons[pragmasPos].info, errPragmaOnlyInHeaderOfProc)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
# (c) Copyright 2012 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
## 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".}
|
||||
|
||||
type
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ Compiler Additions
|
|||
Use the new ``--project`` switch to enable this behaviour.
|
||||
- The compiler can now warn about shadowed local variables. However, this needs
|
||||
to be turned on explicitly via ``--warning[ShadowIdent]:on``.
|
||||
- The compiler now supports almost every pragma in a ``push`` pragma.
|
||||
|
||||
|
||||
Language Additions
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pdf: "manual;lib;tut1;tut2;nimrodc;c2nim;niminst;gc"
|
|||
srcdoc2: "system.nim;impure/graphics;wrappers/sdl"
|
||||
srcdoc2: "core/macros;pure/marshal;core/typeinfo;core/unsigned"
|
||||
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/complex;pure/times;pure/osproc;pure/pegs;pure/dynlib"
|
||||
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: "pure/collections/tables;pure/collections/sets;pure/collections/lists"
|
||||
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/asyncio;pure/actors;core/locks;pure/oids;pure/endians;pure/uri"
|
||||
srcdoc2: "pure/nimprof"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue