better handling of packages, still incomplete
This commit is contained in:
parent
d4263b1012
commit
c55f5b34ee
4 changed files with 63 additions and 14 deletions
|
|
@ -209,21 +209,52 @@ proc getGeneratedPath: string =
|
||||||
result = if nimcacheDir.len > 0: nimcacheDir else: gProjectPath.shortenDir /
|
result = if nimcacheDir.len > 0: nimcacheDir else: gProjectPath.shortenDir /
|
||||||
genSubDir
|
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 =
|
proc getPackageName*(path: string): string =
|
||||||
var q = 1
|
var parents = 0
|
||||||
var b = 0
|
block packageSearch:
|
||||||
if path[len(path)-1] in {DirSep, AltSep}: q = 2
|
for d in myParentDirs(path):
|
||||||
for i in countdown(len(path)-q, 0):
|
if packageCache.hasKey(d):
|
||||||
if path[i] in {DirSep, AltSep}:
|
#echo "from cache ", d, " |", packageCache[d], "|", path.splitFile.name
|
||||||
if b == 0: b = i
|
return packageCache[d]
|
||||||
else:
|
inc parents
|
||||||
let x = path.substr(i+1, b-1)
|
for file in walkFiles(d / "*.babel"):
|
||||||
case x.normalize
|
result = file.splitFile.name
|
||||||
of "lib", "src", "source", "package", "pckg", "library", "private":
|
break packageSearch
|
||||||
b = i
|
# 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:
|
else:
|
||||||
return x.replace('.', '_')
|
let x = path.substr(i+1, b-1)
|
||||||
result = ""
|
case x.normalize
|
||||||
|
of "lib", "src", "source", "package", "pckg", "library", "private":
|
||||||
|
b = i
|
||||||
|
else:
|
||||||
|
return x.replace('.', '_')
|
||||||
|
result = ""
|
||||||
|
|
||||||
proc withPackageName*(path: string): string =
|
proc withPackageName*(path: string): string =
|
||||||
let x = path.getPackageName
|
let x = path.getPackageName
|
||||||
|
|
|
||||||
6
lib/packages/docutils/docutils.babel
Normal file
6
lib/packages/docutils/docutils.babel
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
[Package]
|
||||||
|
name = "docutils"
|
||||||
|
version = "0.9.0"
|
||||||
|
author = "Andreas Rumpf"
|
||||||
|
description = "Nimrod's reStructuredText processor."
|
||||||
|
license = "MIT"
|
||||||
6
lib/stdlib.babel
Normal file
6
lib/stdlib.babel
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
[Package]
|
||||||
|
name = "stdlib"
|
||||||
|
version = "0.9.0"
|
||||||
|
author = "Dominik Picheta"
|
||||||
|
description = "Nimrod's standard library."
|
||||||
|
license = "MIT"
|
||||||
8
todo.txt
8
todo.txt
|
|
@ -1,6 +1,11 @@
|
||||||
version 0.9.4
|
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
|
- fix GC issues
|
||||||
- test and fix showoff
|
- test and fix showoff
|
||||||
|
|
||||||
|
|
@ -21,8 +26,9 @@ Bugs
|
||||||
version 0.9.x
|
version 0.9.x
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
- memory manager: add a measure of fragmentation
|
||||||
- implement 'union' and 'bits' pragmas
|
- implement 'union' and 'bits' pragmas
|
||||||
- fix closures
|
- fix closures/lambdalifting
|
||||||
- ensure (ref T)(a, b) works as a type conversion and type constructor
|
- ensure (ref T)(a, b) works as a type conversion and type constructor
|
||||||
- optimize 'genericReset'; 'newException' leads to code bloat
|
- optimize 'genericReset'; 'newException' leads to code bloat
|
||||||
- stack-less GC
|
- stack-less GC
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue