diff options
author | Araq <rumpf_a@web.de> | 2010-08-28 22:33:07 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2010-08-28 22:33:07 +0200 |
commit | 47886978c79a3246295114a853a9cd945d368708 (patch) | |
tree | f006dc90bb9c8c166214ca751af3739b89a73621 /rod | |
parent | b2075302b10b88047ea16007895bff4e46a2fa9c (diff) | |
download | Nim-47886978c79a3246295114a853a9cd945d368708.tar.gz |
tiny C support; cosmetic improvements for the docs
Diffstat (limited to 'rod')
-rwxr-xr-x | rod/ccgexprs.nim | 2 | ||||
-rwxr-xr-x | rod/commands.nim | 8 | ||||
-rwxr-xr-x | rod/crc.nim | 8 | ||||
-rwxr-xr-x | rod/extccomp.nim | 8 | ||||
-rwxr-xr-x | rod/options.nim | 2 | ||||
-rwxr-xr-x | rod/rst.nim | 11 | ||||
-rwxr-xr-x | rod/semstmts.nim | 2 | ||||
-rwxr-xr-x | rod/semtypes.nim | 2 | ||||
-rwxr-xr-x | rod/tccgen.nim | 8 |
9 files changed, 35 insertions, 16 deletions
diff --git a/rod/ccgexprs.nim b/rod/ccgexprs.nim index 7ea90eec8..6169c970c 100755 --- a/rod/ccgexprs.nim +++ b/rod/ccgexprs.nim @@ -243,7 +243,7 @@ proc genAssignment(p: BProc, dest, src: TLoc, flags: TAssignmentFlags) = # passed to an open array? if needsComplexAssignment(dest.t): appcg(p, cpsStmts, # XXX: is this correct for arrays? - "genericAssignOpenArray((void*)$1, (void*)$2, $1Len0, $3);$n", + "#genericAssignOpenArray((void*)$1, (void*)$2, $1Len0, $3);$n", [addrLoc(dest), addrLoc(src), genTypeInfo(p.module, dest.t)]) else: appcg(p, cpsStmts, diff --git a/rod/commands.nim b/rod/commands.nim index f67a8e765..706332447 100755 --- a/rod/commands.nim +++ b/rod/commands.nim @@ -31,12 +31,11 @@ const const Usage = """ -Usage:: +Usage: nimrod command [options] inputfile [arguments] -Command:: +Command: compile, c compile project with default code generator (C) compileToC, cc compile project with C code generator - run compile the project in memory and run it doc generate the documentation for inputfile rst2html converts a reStructuredText file to HTML rst2tex converts a reStructuredText file to TeX @@ -70,7 +69,8 @@ Options: """ AdvancedUsage = """ -Advanced commands:: +Advanced commands: + run run the project (with Tiny C backend; buggy!) pretty pretty print the inputfile genDepend generate a DOT file containing the module dependency graph diff --git a/rod/crc.nim b/rod/crc.nim index b397d5382..be1aee16b 100755 --- a/rod/crc.nim +++ b/rod/crc.nim @@ -17,8 +17,8 @@ const InitCrc32* = TCrc32(- 1) InitAdler32* = int32(1) -proc updateCrc32*(val: int8, crc: TCrc32): TCrc32 -proc updateCrc32*(val: Char, crc: TCrc32): TCrc32 +proc updateCrc32*(val: int8, crc: TCrc32): TCrc32 {.inline.} +proc updateCrc32*(val: Char, crc: TCrc32): TCrc32 {.inline.} proc crcFromBuf*(buf: Pointer, length: int): TCrc32 proc strCrc32*(s: string): TCrc32 proc crcFromFile*(filename: string): TCrc32 @@ -85,6 +85,10 @@ proc strCrc32(s: string): TCrc32 = result = InitCrc32 for i in countup(0, len(s) + 0 - 1): result = updateCrc32(s[i], result) +proc `><`*(c: TCrc32, s: string): TCrc32 = + result = c + for i in 0..len(s)-1: result = updateCrc32(s[i], result) + type TByteArray = array[0..10000000, int8] PByteArray = ref TByteArray diff --git a/rod/extccomp.nim b/rod/extccomp.nim index d7b429339..ce8e71547 100755 --- a/rod/extccomp.nim +++ b/rod/extccomp.nim @@ -299,9 +299,15 @@ proc toObjFile(filenameWithoutExt: string): string = proc addFileToCompile(filename: string) = appendStr(toCompile, filename) +proc footprint(filename: string): TCrc32 = + result = crcFromFile(filename) >< + platform.OS[targetOS].name >< + platform.CPU[targetCPU].name >< + extccomp.CC[extccomp.ccompiler].name + proc externalFileChanged(filename: string): bool = var crcFile = toGeneratedFile(filename, "crc") - var currentCrc = int(crcFromFile(filename)) + var currentCrc = int(footprint(filename)) var f: TFile if open(f, crcFile, fmRead): var line = f.readLine() diff --git a/rod/options.nim b/rod/options.nim index 28b58f40a..3742cad9d 100755 --- a/rod/options.nim +++ b/rod/options.nim @@ -11,7 +11,7 @@ import os, lists, strutils, nstrtabs const - hasTinyCBackend* = false + hasTinyCBackend* = defined(tinyc) type # please make sure we have under 32 options # (improves code efficiency a lot!) diff --git a/rod/rst.nim b/rod/rst.nim index 5c675f563..207640b2c 100755 --- a/rod/rst.nim +++ b/rod/rst.nim @@ -948,6 +948,10 @@ proc isDefList(p: TRstParser): bool = (p.tok[j].kind in {tkWord, tkOther, tkPunct}) and (p.tok[j - 2].symbol != "::") +proc isOptionList(p: TRstParser): bool = + result = match(p, p.idx, "-w") or match(p, p.idx, "--w") or + match(p, p.idx, "/w") or match(p, p.idx, "//w") + proc whichSection(p: TRstParser): TRstNodeKind = case p.tok[p.idx].kind of tkAdornment: @@ -977,8 +981,7 @@ proc whichSection(p: TRstParser): TRstNodeKind = rstMessage(p, errGridTableNotImplemented) elif isDefList(p): result = rnDefList - elif match(p, p.idx, "-w") or match(p, p.idx, "--w") or - match(p, p.idx, "/w"): + elif isOptionList(p): result = rnOptionList else: result = rnParagraph @@ -1176,11 +1179,11 @@ proc parseBulletList(p: var TRstParser): PRstNode = proc parseOptionList(p: var TRstParser): PRstNode = result = newRstNode(rnOptionList) while true: - if match(p, p.idx, "-w") or match(p, p.idx, "--w") or - match(p, p.idx, "/w"): + if isOptionList(p): var a = newRstNode(rnOptionGroup) var b = newRstNode(rnDescription) var c = newRstNode(rnOptionListItem) + if match(p, p.idx, "//w"): inc(p.idx) while not (p.tok[p.idx].kind in {tkIndent, tkEof}): if (p.tok[p.idx].kind == tkWhite) and (len(p.tok[p.idx].symbol) > 1): inc(p.idx) diff --git a/rod/semstmts.nim b/rod/semstmts.nim index cadecad40..b449c995a 100755 --- a/rod/semstmts.nim +++ b/rod/semstmts.nim @@ -671,6 +671,8 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, if n.sons[genericParamsPos] == nil: # we have a list of implicit type parameters: n.sons[genericParamsPos] = gp + # check for semantics again: + semParamList(c, n.sons[ParamsPos], nil, s) addParams(c, s.typ.n) else: s.typ = newTypeS(tyProc, c) diff --git a/rod/semtypes.nim b/rod/semtypes.nim index f5fae4811..8083227fd 100755 --- a/rod/semtypes.nim +++ b/rod/semtypes.nim @@ -454,6 +454,8 @@ proc addTypeVarsOfGenericBody(c: PContext, t: PType, genericParams: PNode, #if not IntSetContainsOrIncl(cl, t.sons[i].sym.ident.id): var s = copySym(t.sons[i].sym) s.position = sonsLen(genericParams) + if s.typ == nil or s.typ.kind != tyGenericParam: + InternalError("addTypeVarsOfGenericBody 2") addDecl(c, s) addSon(genericParams, newSymNode(s)) addSon(result, t.sons[i]) diff --git a/rod/tccgen.nim b/rod/tccgen.nim index 3e3c311a4..0a588fda0 100755 --- a/rod/tccgen.nim +++ b/rod/tccgen.nim @@ -28,9 +28,11 @@ proc addFile(filename: string) = rawMessage(errCannotOpenFile, filename) proc setupEnvironment = - #defineSymbol(gTinyC, "__x86_64__", nil) - #defineSymbol(gTinyC, "__linux__", nil) - #defineSymbol(gTinyC, "__linux", nil) + when defined(amd64): + defineSymbol(gTinyC, "__x86_64__", nil) + when defined(linux): + defineSymbol(gTinyC, "__linux__", nil) + defineSymbol(gTinyC, "__linux", nil) var nimrodDir = getPrefixDir() addIncludePath(gTinyC, libpath) |