mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-07 20:34:21 +00:00
implemented write access to s[i] for macros
This commit is contained in:
@@ -355,25 +355,40 @@ proc evalFieldAccess(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode =
|
||||
result = emptyNode
|
||||
|
||||
proc evalAsgn(c: PEvalContext, n: PNode): PNode =
|
||||
result = evalAux(c, n.sons[0], {efLValue})
|
||||
if isSpecial(result): return
|
||||
var x = result
|
||||
result = evalAux(c, n.sons[1], {})
|
||||
if isSpecial(result): return
|
||||
myreset(x)
|
||||
x.kind = result.kind
|
||||
x.typ = result.typ
|
||||
case x.kind
|
||||
of nkCharLit..nkInt64Lit:
|
||||
x.intVal = result.intVal
|
||||
of nkFloatLit..nkFloat64Lit:
|
||||
x.floatVal = result.floatVal
|
||||
of nkStrLit..nkTripleStrLit:
|
||||
x.strVal = result.strVal
|
||||
else:
|
||||
if not (x.kind in {nkEmpty..nkNilLit}):
|
||||
discardSons(x)
|
||||
for i in countup(0, sonsLen(result) - 1): addSon(x, result.sons[i])
|
||||
var a = n.sons[0]
|
||||
if a.kind == nkBracketExpr and a.sons[0].typ.kind in {tyString, tyCString}:
|
||||
result = evalAux(c, a.sons[0], {efLValue})
|
||||
if isSpecial(result): return
|
||||
var x = result
|
||||
result = evalAux(c, a.sons[1], {})
|
||||
if isSpecial(result): return
|
||||
var idx = getOrdValue(result)
|
||||
|
||||
result = evalAux(c, n.sons[1], {})
|
||||
if isSpecial(result): return
|
||||
if result.kind != nkCharLit: InternalError(n.info, "no character")
|
||||
|
||||
if (idx >= 0) and (idx < len(x.strVal)):
|
||||
x.strVal[int(idx)] = chr(int(result.intVal))
|
||||
else:
|
||||
stackTrace(c, n, errIndexOutOfBounds)
|
||||
else:
|
||||
result = evalAux(c, n.sons[0], {efLValue})
|
||||
if isSpecial(result): return
|
||||
var x = result
|
||||
result = evalAux(c, n.sons[1], {})
|
||||
if isSpecial(result): return
|
||||
myreset(x)
|
||||
x.kind = result.kind
|
||||
x.typ = result.typ
|
||||
case x.kind
|
||||
of nkCharLit..nkInt64Lit: x.intVal = result.intVal
|
||||
of nkFloatLit..nkFloat64Lit: x.floatVal = result.floatVal
|
||||
of nkStrLit..nkTripleStrLit: x.strVal = result.strVal
|
||||
else:
|
||||
if not (x.kind in {nkEmpty..nkNilLit}):
|
||||
discardSons(x)
|
||||
for i in countup(0, sonsLen(result) - 1): addSon(x, result.sons[i])
|
||||
result = emptyNode
|
||||
assert result.kind == nkEmpty
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ proc merge[T](a, b: var openArray[T], lo, m, hi: int,
|
||||
cmp: proc (x, y: T): int, order: TSortOrder) =
|
||||
template `<-` (a, b: expr) =
|
||||
when onlySafeCode:
|
||||
a = b
|
||||
shallowCopy(a, b)
|
||||
else:
|
||||
copyMem(addr(a), addr(b), sizeof(T))
|
||||
# optimization: If max(left) <= min(right) there is nothing to do!
|
||||
@@ -54,7 +54,7 @@ proc merge[T](a, b: var openArray[T], lo, m, hi: int,
|
||||
when onlySafeCode:
|
||||
var bb = 0
|
||||
while j <= m:
|
||||
b[bb] = a[j]
|
||||
b[bb] <- a[j]
|
||||
inc(bb)
|
||||
inc(j)
|
||||
else:
|
||||
@@ -74,7 +74,7 @@ proc merge[T](a, b: var openArray[T], lo, m, hi: int,
|
||||
# copy rest of b:
|
||||
when onlySafeCode:
|
||||
while k < j:
|
||||
a[k] = b[i]
|
||||
a[k] <- b[i]
|
||||
inc(k)
|
||||
inc(i)
|
||||
else:
|
||||
|
||||
@@ -475,9 +475,9 @@ elif not defined(useNimRtl):
|
||||
result.exitCode = -3 # for ``waitForExit``
|
||||
if pipe(p_stdin) != 0'i32 or pipe(p_stdout) != 0'i32 or
|
||||
pipe(p_stderr) != 0'i32:
|
||||
OSError("failed to create a pipe")
|
||||
OSError()
|
||||
var Pid = fork()
|
||||
if Pid < 0: OSError("failed to fork process")
|
||||
if Pid < 0: OSError()
|
||||
|
||||
if pid == 0:
|
||||
## child process:
|
||||
|
||||
13
todo.txt
13
todo.txt
@@ -1,6 +1,5 @@
|
||||
High priority (version 0.8.12)
|
||||
==============================
|
||||
* implement write access to ``s[i]`` for macros
|
||||
* implement message passing built-ins
|
||||
* add --deadlock_prevention:on|off switch? timeout for locks?
|
||||
* built-in serialization
|
||||
@@ -20,6 +19,18 @@ version 0.9.0
|
||||
- fix overloading resolution
|
||||
- make ^ available as operator
|
||||
- implement closures; implement proper coroutines
|
||||
- rethink comment syntax; people want::
|
||||
|
||||
type
|
||||
TConfig* = object
|
||||
limit*: int
|
||||
outFile*: string
|
||||
# Regex patterns to ignore. TLogEntry field -> regex pattern
|
||||
# If this matches, the request will NOT be shown.
|
||||
ignoreRe*: TTable[string, string]
|
||||
|
||||
I think a good compromise is to define positions for the docgen in the
|
||||
grammar and ignore other comments everywhere.
|
||||
|
||||
Bugs
|
||||
----
|
||||
|
||||
Reference in New Issue
Block a user