diff options
author | Araq <rumpf_a@web.de> | 2014-03-02 15:41:53 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-03-02 15:41:53 +0100 |
commit | c55f5b34ee4d3c44c21b17c93e8d38dd867fb9cc (patch) | |
tree | cdebb4a733cb89cfb8f2cdd986fb000e74ae8e8a | |
parent | d4263b1012f50e7d468e53d07d592b39983f026a (diff) | |
download | Nim-c55f5b34ee4d3c44c21b17c93e8d38dd867fb9cc.tar.gz |
better handling of packages, still incomplete
-rw-r--r-- | compiler/options.nim | 57 | ||||
-rw-r--r-- | lib/packages/docutils/docutils.babel | 6 | ||||
-rw-r--r-- | lib/stdlib.babel | 6 | ||||
-rw-r--r-- | todo.txt | 8 |
4 files changed, 63 insertions, 14 deletions
diff --git a/compiler/options.nim b/compiler/options.nim index 4f642e626..69d41c562 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -209,21 +209,52 @@ proc getGeneratedPath: string = result = if nimcacheDir.len > 0: nimcacheDir else: gProjectPath.shortenDir / genSubDir +var packageCache = newStringTable(when FileSystemCaseSensitive: + modeCaseInsensitive + else: + modeCaseSensitive) + +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 + 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 + when false: + 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: - return x.replace('.', '_') - result = "" + 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 = "" 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/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..5cbe2fe8b 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,11 @@ version 0.9.4 ============= +- fix gensym capture bug +- make the compiler aware of packages +- vm + - at least try to get the basic type zoo ops right + - optimize opcAsgnStr - fix GC issues - test and fix showoff @@ -21,8 +26,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 |