compiler prepared for the new comment handling

This commit is contained in:
Araq 2014-04-30 00:53:44 +02:00
commit bd705a517f
8 changed files with 17 additions and 4 deletions

View file

@ -593,6 +593,7 @@ proc genStringCase(p: BProc, t: PNode, d: var TLoc) =
else: else:
# else statement: nothing to do yet # else statement: nothing to do yet
# but we reserved a label, which we use later # but we reserved a label, which we use later
discard
linefmt(p, cpsStmts, "switch (#hashString($1) & $2) {$n", linefmt(p, cpsStmts, "switch (#hashString($1) & $2) {$n",
rdLoc(a), toRope(bitMask)) rdLoc(a), toRope(bitMask))
for j in countup(0, high(branches)): for j in countup(0, high(branches)):

View file

@ -69,6 +69,7 @@ proc commandCompileToC =
# echo "BEFORE CHECK DEP" # echo "BEFORE CHECK DEP"
# discard checkDepMem(gProjectMainIdx) # discard checkDepMem(gProjectMainIdx)
# echo "CHECK DEP COMPLETE" # echo "CHECK DEP COMPLETE"
discard
compileProject() compileProject()
cgenWriteModules() cgenWriteModules()

View file

@ -116,7 +116,7 @@ type
warnSmallLshouldNotBeUsed, warnUnknownMagic, warnRedefinitionOfLabel, warnSmallLshouldNotBeUsed, warnUnknownMagic, warnRedefinitionOfLabel,
warnUnknownSubstitutionX, warnLanguageXNotSupported, warnCommentXIgnored, warnUnknownSubstitutionX, warnLanguageXNotSupported, warnCommentXIgnored,
warnNilStatement, warnAnalysisLoophole, warnNilStatement, warnAnalysisLoophole,
warnDifferentHeaps, warnWriteToForeignHeap, warnImplicitClosure, warnDifferentHeaps, warnWriteToForeignHeap, warnUnsafeCode,
warnEachIdentIsTuple, warnShadowIdent, warnEachIdentIsTuple, warnShadowIdent,
warnProveInit, warnProveField, warnProveIndex, warnGcUnsafe, warnGcUnsafe2, warnProveInit, warnProveField, warnProveIndex, warnGcUnsafe, warnGcUnsafe2,
warnUninit, warnGcMem, warnUser, warnUninit, warnGcMem, warnUser,
@ -380,7 +380,7 @@ const
warnAnalysisLoophole: "thread analysis incomplete due to unknown call '$1' [AnalysisLoophole]", warnAnalysisLoophole: "thread analysis incomplete due to unknown call '$1' [AnalysisLoophole]",
warnDifferentHeaps: "possible inconsistency of thread local heaps [DifferentHeaps]", warnDifferentHeaps: "possible inconsistency of thread local heaps [DifferentHeaps]",
warnWriteToForeignHeap: "write to foreign heap [WriteToForeignHeap]", warnWriteToForeignHeap: "write to foreign heap [WriteToForeignHeap]",
warnImplicitClosure: "implicit closure convention: '$1' [ImplicitClosure]", warnUnsafeCode: "unsafe code: '$1' [UnsafeCode]",
warnEachIdentIsTuple: "each identifier is a tuple [EachIdentIsTuple]", warnEachIdentIsTuple: "each identifier is a tuple [EachIdentIsTuple]",
warnShadowIdent: "shadowed identifier: '$1' [ShadowIdent]", warnShadowIdent: "shadowed identifier: '$1' [ShadowIdent]",
warnProveInit: "Cannot prove that '$1' is initialized. This will become a compile time error in the future. [ProveInit]", warnProveInit: "Cannot prove that '$1' is initialized. This will become a compile time error in the future. [ProveInit]",
@ -416,7 +416,7 @@ const
"RedefinitionOfLabel", "UnknownSubstitutionX", "LanguageXNotSupported", "RedefinitionOfLabel", "UnknownSubstitutionX", "LanguageXNotSupported",
"CommentXIgnored", "NilStmt", "CommentXIgnored", "NilStmt",
"AnalysisLoophole", "DifferentHeaps", "WriteToForeignHeap", "AnalysisLoophole", "DifferentHeaps", "WriteToForeignHeap",
"ImplicitClosure", "EachIdentIsTuple", "ShadowIdent", "UnsafeCode", "EachIdentIsTuple", "ShadowIdent",
"ProveInit", "ProveField", "ProveIndex", "GcUnsafe", "GcUnsafe2", "Uninit", "ProveInit", "ProveField", "ProveIndex", "GcUnsafe", "GcUnsafe2", "Uninit",
"GcMem", "User"] "GcMem", "User"]

View file

@ -166,6 +166,7 @@ proc checkConvertible(c: PContext, castDest, src: PType): TConvStatus =
elif (skipTypes(castDest, abstractVarRange).kind in IntegralTypes) and elif (skipTypes(castDest, abstractVarRange).kind in IntegralTypes) and
(skipTypes(src, abstractVarRange-{tyTypeDesc}).kind in IntegralTypes): (skipTypes(src, abstractVarRange-{tyTypeDesc}).kind in IntegralTypes):
# accept conversion between integral types # accept conversion between integral types
discard
else: else:
# we use d, s here to speed up that operation a bit: # we use d, s here to speed up that operation a bit:
case cmpTypes(c, d, s) case cmpTypes(c, d, s)
@ -2060,6 +2061,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
of nkClosedSymChoice, nkOpenSymChoice: of nkClosedSymChoice, nkOpenSymChoice:
# handling of sym choices is context dependent # handling of sym choices is context dependent
# the node is left intact for now # the node is left intact for now
discard
of nkStaticExpr: of nkStaticExpr:
result = semStaticExpr(c, n) result = semStaticExpr(c, n)
of nkAsgn: result = semAsgn(c, n) of nkAsgn: result = semAsgn(c, n)

View file

@ -141,6 +141,7 @@ proc semGenericStmt(c: PContext, n: PNode,
# symbol lookup ... # symbol lookup ...
of skUnknown, skParam: of skUnknown, skParam:
# Leave it as an identifier. # Leave it as an identifier.
discard
of skProc, skMethod, skIterators, skConverter: of skProc, skMethod, skIterators, skConverter:
result.sons[0] = symChoice(c, n.sons[0], s, scOption) result.sons[0] = symChoice(c, n.sons[0], s, scOption)
first = 1 first = 1

View file

@ -1,7 +1,7 @@
# #
# #
# The Nimrod Compiler # The Nimrod Compiler
# (c) Copyright 2013 Andreas Rumpf # (c) Copyright 2014 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.
@ -485,6 +485,11 @@ proc isTrue(n: PNode): bool =
proc paramType(op: PType, i: int): PType = proc paramType(op: PType, i: int): PType =
if op != nil and i < op.len: result = op.sons[i] if op != nil and i < op.len: result = op.sons[i]
proc cstringCheck(tracked: PEffects; n: PNode) =
if n.sons[0].typ.kind == tyCString and (let a = skipConv(n[1]);
a.typ.kind == tyString and a.kind notin {nkStrLit..nkTripleStrLit}):
message(n.info, warnUnsafeCode, renderTree(n))
proc track(tracked: PEffects, n: PNode) = proc track(tracked: PEffects, n: PNode) =
case n.kind case n.kind
of nkSym: of nkSym:
@ -541,6 +546,7 @@ proc track(tracked: PEffects, n: PNode) =
track(tracked, n.sons[0]) track(tracked, n.sons[0])
addAsgnFact(tracked.guards, n.sons[0], n.sons[1]) addAsgnFact(tracked.guards, n.sons[0], n.sons[1])
notNilCheck(tracked, n.sons[1], n.sons[0].typ) notNilCheck(tracked, n.sons[1], n.sons[0].typ)
when false: cstringCheck(tracked, n)
of nkVarSection: of nkVarSection:
for child in n: for child in n:
let last = lastSon(child) let last = lastSon(child)

View file

@ -385,6 +385,7 @@ proc semIdentWithPragma(c: PContext, kind: TSymKind, n: PNode,
case kind case kind
of skType: of skType:
# process pragmas later, because result.typ has not been set yet # process pragmas later, because result.typ has not been set yet
discard
of skField: pragma(c, result, n.sons[1], fieldPragmas) of skField: pragma(c, result, n.sons[1], fieldPragmas)
of skVar: pragma(c, result, n.sons[1], varPragmas) of skVar: pragma(c, result, n.sons[1], varPragmas)
of skLet: pragma(c, result, n.sons[1], letPragmas) of skLet: pragma(c, result, n.sons[1], letPragmas)

View file

@ -11,6 +11,7 @@ version 0.9.6
- built-in 'getImpl' - built-in 'getImpl'
- type API for macros; make 'spawn' a macro - type API for macros; make 'spawn' a macro
- markAndSweepGC should expose an API for fibers - markAndSweepGC should expose an API for fibers
- prevent 'alloc(TypeWithGCedMemory)'
Bugs Bugs