preparations for Nimble NimScript integrations; minor cleanups

This commit is contained in:
Araq
2015-08-18 14:01:40 +02:00
parent 10a7830ba2
commit 9659540b18
7 changed files with 74 additions and 6 deletions

View File

@@ -92,7 +92,6 @@ proc resetAllModulesHard* =
magicsys.resetSysTypes()
# XXX
#gOwners = @[]
#rangeDestructorProc = nil
proc checkDepMem(fileIdx: int32): TNeedRecompile =
template markDirty =

View File

@@ -17,5 +17,4 @@ define:useStdoutAsStdmsg
cs:partial
#define:useNodeIds
symbol:nimfix
#gc:markAndSweep

View File

@@ -25,7 +25,8 @@ proc listDirs(a: VmArgs, filter: set[PathComponent]) =
if kind in filter: result.add path
setResult(a, result)
proc setupVM(module: PSym; scriptName: string): PEvalContext =
proc setupVM*(module: PSym; scriptName: string): PEvalContext =
# For Nimble we need to export 'setupVM'.
result = newCtx(module)
result.mode = emRepl
registerAdditionalOps(result)

View File

@@ -1401,6 +1401,10 @@ proc evalExpr*(c: PCtx, n: PNode): PNode =
assert c.code[start].opcode != opcEof
result = execute(c, start)
proc getGlobalValue*(c: PCtx; s: PSym): PNode =
internalAssert s.kind in {skLet, skVar} and sfGlobal in s.flags
result = c.globals.sons[s.position-1]
include vmops
# for now we share the 'globals' environment. XXX Coming soon: An API for

View File

@@ -50,7 +50,6 @@ path="$lib/js"
path="$lib/pure/unidecode"
@if nimbabel:
babelpath="$home/.babel/pkgs/"
nimblepath="$home/.nimble/pkgs/"
@end

View File

@@ -150,3 +150,30 @@ template task*(name: untyped; description: string; body: untyped): untyped =
elif cmd ==? astToStr(name):
setCommand "nop"
`name Task`()
type
VersionReq* = distinct string ## Describes a version requirement.
template v*(name: string{lit}): VersionReq = VersionReq(name)
template special*(name: string): VersionReq = VersionReq(name)
template `<`*(v: VersionReq): VersionReq = VersionReq("<" & string(v))
template `<=`*(v: VersionReq): VersionReq = VersionReq("<=" & string(v))
template `>`*(v: VersionReq): VersionReq = VersionReq(">" & string(v))
template `>=`*(v: VersionReq): VersionReq = VersionReq(">=" & string(v))
template `&`*(a, b: VersionReq): VersionReq =
VersionReq(string(a) & " & " & string(b))
const
anyVersion* = VersionReq("*")
var
packageName* = ""
version*, author*, description*, license*, srcdir*,
binDir*, backend*: string
skipDirs*, skipFiles*, skipExt*, installDirs*, installFiles*,
installExt*, bin*: seq[string]
requiresData*: seq[(string, VersionReq)]
proc requires*(name: string; v: VersionReq) =
requiresData.add((name, v))

View File

@@ -1,6 +1,9 @@
version 0.11.4
==============
- make tuple unpacking work in a non-var/let context
- built-in 'getImpl'
- document special cased varargs[untyped] and varargs[typed]
- The remaining bugs of the lambda lifting pass that is responsible to enable
@@ -50,14 +53,50 @@ Low priority:
Misc
----
- make tuple unpacking work in a non-var/let context
- built-in 'getImpl'
- prevent 'alloc(TypeWithGCedMemory)'
Bugs
====
- Can lead to wrong C code:
template cd*(dir: string, body: stmt) =
## Sets the current dir to ``dir``, executes ``body`` and restores the
## previous working dir.
let lastDir = getCurrentDir()
setCurrentDir(dir)
try:
body
finally:
setCurrentDir(lastDir)
proc test =
cd dir:
var output = execProcess("git tag")
case meth
of DownloadMethod.git:
output = execProcess("git tag")
of DownloadMethod.hg:
output = execProcess("hg tags")
if output.len > 0:
case meth
of DownloadMethod.git:
result = @[]
for i in output.splitLines():
if i == "": continue
result.add(i)
of DownloadMethod.hg:
result = @[]
for i in output.splitLines():
if i == "": continue
var tag = ""
discard parseUntil(i, tag, ' ')
if tag != "tip":
result.add(tag)
else:
result = @[]
- VM: Pegs do not work at compile-time
- VM: ptr/ref T cannot work in general
- blocks can "export" an identifier but the CCG generates {} for them ...