diff options
-rw-r--r-- | compiler/ast.nim | 1 | ||||
-rw-r--r-- | compiler/cgen.nim | 4 | ||||
-rw-r--r-- | compiler/modules.nim | 9 | ||||
-rw-r--r-- | compiler/options.nim | 49 | ||||
-rw-r--r-- | lib/packages/docutils/docutils.babel | 6 | ||||
-rw-r--r-- | lib/pure/os.nim | 3 | ||||
-rw-r--r-- | lib/pure/sockets2.nim | 11 | ||||
-rw-r--r-- | lib/stdlib.babel | 6 | ||||
-rw-r--r-- | todo.txt | 7 |
9 files changed, 74 insertions, 22 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index bd8bdb30b..61b8ca795 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -481,6 +481,7 @@ type skStub, # symbol is a stub and not yet loaded from the ROD # file (it is loaded on demand, which may # mean: never) + skPackage # symbol is a package (used for canonicalization) TSymKinds* = set[TSymKind] const diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 8da753d04..c3a28527e 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1044,8 +1044,10 @@ proc genMainProc(m: BModule) = appcg(m, m.s[cfsProcs], otherMain, []) proc getSomeInitName(m: PSym, suffix: string): PRope = + assert m.kind == skModule + assert m.owner.kind == skPackage if {sfSystemModule, sfMainModule} * m.flags == {}: - result = m.info.toFullPath.getPackageName.mangle.toRope + result = m.owner.name.s.mangle.toRope result.app m.name.s result.app suffix diff --git a/compiler/modules.nim b/compiler/modules.nim index 6a1491682..fb1940741 100644 --- a/compiler/modules.nim +++ b/compiler/modules.nim @@ -1,7 +1,7 @@ # # # The Nimrod Compiler -# (c) Copyright 2013 Andreas Rumpf +# (c) Copyright 2014 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -20,7 +20,7 @@ type TModuleInMemory* = object compiledAt*: float crc*: TCrc32 - deps*: seq[int32] ## XXX: slurped files are not currently tracked + deps*: seq[int32] ## XXX: slurped files are currently not tracked needsRecompile*: TNeedRecompile crcStatus*: TCrcStatus @@ -83,7 +83,7 @@ proc resetAllModules* = for i in 0..gCompiledModules.high: if gCompiledModules[i] != nil: resetModule(i.int32) - + resetPackageCache() # for m in cgenModules(): echo "CGEN MODULE FOUND" proc checkDepMem(fileIdx: int32): TNeedRecompile = @@ -120,8 +120,9 @@ proc newModule(fileIdx: int32): PSym = if not isNimrodIdentifier(result.name.s): rawMessage(errInvalidModuleName, result.name.s) - result.owner = result # a module belongs to itself result.info = newLineInfo(fileIdx, 1, 1) + result.owner = newSym(skPackage, getIdent(getPackageName(filename)), nil, + result.info) result.position = fileIdx growCache gMemCacheData, fileIdx diff --git a/compiler/options.nim b/compiler/options.nim index 4f642e626..102ebc386 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -209,21 +209,42 @@ proc getGeneratedPath: string = result = if nimcacheDir.len > 0: nimcacheDir else: gProjectPath.shortenDir / genSubDir +template newPackageCache(): expr = + newStringTable(when FileSystemCaseSensitive: + modeCaseInsensitive + else: + modeCaseSensitive) + +var packageCache = newPackageCache() + +proc resetPackageCache*() = packageCache = newPackageCache() + +iterator myParentDirs(p: string): string = + # XXX os's parentDirs is stupid (multiple yields) and triggers an old bug... + var current = p + while true: + current = current.parentDir + if current.len == 0: break + yield current + proc getPackageName*(path: string): string = - var q = 1 - var b = 0 - if path[len(path)-1] in {DirSep, AltSep}: q = 2 - for i in countdown(len(path)-q, 0): - if path[i] in {DirSep, AltSep}: - if b == 0: b = i - else: - let x = path.substr(i+1, b-1) - case x.normalize - of "lib", "src", "source", "package", "pckg", "library", "private": - b = i - else: - return x.replace('.', '_') - result = "" + var parents = 0 + block packageSearch: + for d in myParentDirs(path): + if packageCache.hasKey(d): + #echo "from cache ", d, " |", packageCache[d], "|", path.splitFile.name + return packageCache[d] + inc parents + for file in walkFiles(d / "*.babel"): + result = file.splitFile.name + break packageSearch + # we also store if we didn't find anything: + if result.isNil: result = "" + for d in myParentDirs(path): + #echo "set cache ", d, " |", result, "|", parents + packageCache[d] = result + dec parents + if parents <= 0: break proc withPackageName*(path: string): string = let x = path.getPackageName diff --git a/lib/packages/docutils/docutils.babel b/lib/packages/docutils/docutils.babel new file mode 100644 index 000000000..1ed86ca05 --- /dev/null +++ b/lib/packages/docutils/docutils.babel @@ -0,0 +1,6 @@ +[Package] +name = "docutils" +version = "0.9.0" +author = "Andreas Rumpf" +description = "Nimrod's reStructuredText processor." +license = "MIT" diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 89bb92f9a..bfecc569a 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1192,7 +1192,8 @@ iterator walkFiles*(pattern: string): string {.tags: [FReadDir].} = res = findFirstFile(pattern, f) if res != -1: while true: - if not skipFindData(f): + if not skipFindData(f) and + (f.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) == 0'i32: yield splitFile(pattern).dir / extractFilename(getFilename(f)) if findNextFile(res, f) == 0'i32: break findClose(res) diff --git a/lib/pure/sockets2.nim b/lib/pure/sockets2.nim index 031217b90..3542a0694 100644 --- a/lib/pure/sockets2.nim +++ b/lib/pure/sockets2.nim @@ -17,7 +17,6 @@ when hostos == "solaris": when defined(Windows): import winlean - export ioctlsocket else: import posix export fcntl, F_GETFL, O_NONBLOCK, F_SETFL @@ -66,6 +65,16 @@ type when defined(windows): let osInvalidSocket* = winlean.INVALID_SOCKET + + const + IOCPARM_MASK* = 127 + IOC_IN* = int(-2147483648) + FIONBIO* = IOC_IN.int32 or ((sizeof(int32) and IOCPARM_MASK) shl 16) or + (102 shl 8) or 126 + + proc ioctlsocket*(s: TSocketHandle, cmd: clong, + argptr: ptr clong): cint {. + stdcall, importc: "ioctlsocket", dynlib: "ws2_32.dll".} else: let osInvalidSocket* = posix.INVALID_SOCKET diff --git a/lib/stdlib.babel b/lib/stdlib.babel new file mode 100644 index 000000000..f22598aba --- /dev/null +++ b/lib/stdlib.babel @@ -0,0 +1,6 @@ +[Package] +name = "stdlib" +version = "0.9.0" +author = "Dominik Picheta" +description = "Nimrod's standard library." +license = "MIT" diff --git a/todo.txt b/todo.txt index 4bee45516..974e18360 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,10 @@ version 0.9.4 ============= +- fix gensym capture bug +- vm + - at least try to get the basic type zoo ops right + - optimize opcAsgnStr - fix GC issues - test and fix showoff @@ -21,8 +25,9 @@ Bugs version 0.9.x ============= +- memory manager: add a measure of fragmentation - implement 'union' and 'bits' pragmas -- fix closures +- fix closures/lambdalifting - ensure (ref T)(a, b) works as a type conversion and type constructor - optimize 'genericReset'; 'newException' leads to code bloat - stack-less GC |