first steps to explicit channels for thread communication; added mainThreadId
This commit is contained in:
parent
fe5df368c1
commit
42e6130b2c
16 changed files with 155 additions and 71 deletions
|
|
@ -267,7 +267,7 @@ proc GetNumber(L: var TLexer): TToken =
|
|||
inc(L.bufpos)
|
||||
matchUnderscoreChars(L, result, {'0'..'9'})
|
||||
endpos = L.bufpos
|
||||
if L.buf[endpos] == '\'':
|
||||
if L.buf[endpos] == '\'':
|
||||
#matchUnderscoreChars(L, result, ['''', 'f', 'F', 'i', 'I', '0'..'9']);
|
||||
inc(endpos)
|
||||
L.bufpos = pos # restore position
|
||||
|
|
@ -281,7 +281,7 @@ proc GetNumber(L: var TLexer): TToken =
|
|||
result.tokType = tkFloat32Lit
|
||||
inc(endpos, 2)
|
||||
else:
|
||||
lexMessage(L, errInvalidNumber, result.literal)
|
||||
lexMessage(L, errInvalidNumber, result.literal & "'f" & L.buf[endpos])
|
||||
of 'i', 'I':
|
||||
inc(endpos)
|
||||
if (L.buf[endpos] == '6') and (L.buf[endpos + 1] == '4'):
|
||||
|
|
@ -297,9 +297,9 @@ proc GetNumber(L: var TLexer): TToken =
|
|||
result.tokType = tkInt8Lit
|
||||
inc(endpos)
|
||||
else:
|
||||
lexMessage(L, errInvalidNumber, result.literal)
|
||||
else: lexMessage(L, errInvalidNumber, result.literal)
|
||||
else:
|
||||
lexMessage(L, errInvalidNumber, result.literal & "'i" & L.buf[endpos])
|
||||
else: lexMessage(L, errInvalidNumber, result.literal & "'" & L.buf[endpos])
|
||||
else:
|
||||
L.bufpos = pos # restore position
|
||||
try:
|
||||
if (L.buf[pos] == '0') and
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@ const
|
|||
defaultAsmMarkerSymbol* = '!'
|
||||
VersionMajor* = 0
|
||||
VersionMinor* = 8
|
||||
VersionPatch* = 12
|
||||
VersionPatch* = 13
|
||||
VersionAsString* = $VersionMajor & "." & $VersionMinor & "." & $VersionPatch
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,13 @@ proc explicitGenericInstError(n: PNode): PNode =
|
|||
LocalError(n.info, errCannotInstantiateX, renderTree(n))
|
||||
result = n
|
||||
|
||||
proc explicitGenericSym(c: PContext, n: PNode, s: PSym): PNode =
|
||||
var x: TCandidate
|
||||
initCandidate(x, s, n)
|
||||
var newInst = generateInstance(c, s, x.bindings, n.info)
|
||||
markUsed(n, s)
|
||||
result = newSymNode(newInst, n.info)
|
||||
|
||||
proc explicitGenericInstantiation(c: PContext, n: PNode, s: PSym): PNode =
|
||||
assert n.kind == nkBracketExpr
|
||||
for i in 1..sonsLen(n)-1:
|
||||
|
|
@ -94,27 +101,30 @@ proc explicitGenericInstantiation(c: PContext, n: PNode, s: PSym): PNode =
|
|||
# number of generic type parameters:
|
||||
if safeLen(s.ast.sons[genericParamsPos]) != n.len-1:
|
||||
return explicitGenericInstError(n)
|
||||
result = explicitGenericSym(c, n, s)
|
||||
elif a.kind == nkSymChoice:
|
||||
# choose the generic proc with the proper number of type parameters.
|
||||
# XXX I think this could be improved by reusing sigmatch.ParamTypesMatch.
|
||||
# It's good enough for now.
|
||||
var candidateCount = 0
|
||||
result = newNodeI(nkSymChoice, n.info)
|
||||
for i in countup(0, len(a)-1):
|
||||
var candidate = a.sons[i].sym
|
||||
if candidate.kind in {skProc, skMethod, skConverter, skIterator}:
|
||||
# if suffices that the candidate has the proper number of generic
|
||||
# type parameters:
|
||||
if safeLen(candidate.ast.sons[genericParamsPos]) == n.len-1:
|
||||
s = candidate
|
||||
inc(candidateCount)
|
||||
if candidateCount != 1: return explicitGenericInstError(n)
|
||||
result.add(explicitGenericSym(c, n, candidate))
|
||||
# get rid of nkSymChoice if not ambigious:
|
||||
if result.len == 1: result = result[0]
|
||||
# candidateCount != 1: return explicitGenericInstError(n)
|
||||
else:
|
||||
assert false
|
||||
|
||||
var x: TCandidate
|
||||
initCandidate(x, s, n)
|
||||
var newInst = generateInstance(c, s, x.bindings, n.info)
|
||||
|
||||
markUsed(n, s)
|
||||
result = newSymNode(newInst, n.info)
|
||||
when false:
|
||||
var x: TCandidate
|
||||
initCandidate(x, s, n)
|
||||
var newInst = generateInstance(c, s, x.bindings, n.info)
|
||||
|
||||
markUsed(n, s)
|
||||
result = newSymNode(newInst, n.info)
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ proc instantiateGenericParamList(c: PContext, n: PNode, pt: TIdTable) =
|
|||
if t == nil:
|
||||
LocalError(a.info, errCannotInstantiateX, s.name.s)
|
||||
break
|
||||
if (t.kind == tyGenericParam):
|
||||
if t.kind == tyGenericParam:
|
||||
InternalError(a.info, "instantiateGenericParamList: " & q.name.s)
|
||||
s.typ = t
|
||||
addDecl(c, s)
|
||||
|
|
|
|||
|
|
@ -152,42 +152,32 @@ proc semCase(c: PContext, n: PNode): PNode =
|
|||
closeScope(c.tab)
|
||||
|
||||
proc SemReturn(c: PContext, n: PNode): PNode =
|
||||
var
|
||||
restype: PType
|
||||
a: PNode # temporary assignment for code generator
|
||||
result = n
|
||||
checkSonsLen(n, 1)
|
||||
if not (c.p.owner.kind in {skConverter, skMethod, skProc, skMacro}):
|
||||
if c.p.owner.kind notin {skConverter, skMethod, skProc, skMacro}:
|
||||
globalError(n.info, errXNotAllowedHere, "\'return\'")
|
||||
if n.sons[0].kind != nkEmpty:
|
||||
n.sons[0] = SemExprWithType(c, n.sons[0]) # check for type compatibility:
|
||||
restype = c.p.owner.typ.sons[0]
|
||||
if restype != nil:
|
||||
a = newNodeI(nkAsgn, n.sons[0].info)
|
||||
n.sons[0] = fitNode(c, restype, n.sons[0])
|
||||
# optimize away ``return result``, because it would be transformed
|
||||
# to ``result = result; return``:
|
||||
if (n.sons[0].kind == nkSym) and (sfResult in n.sons[0].sym.flags):
|
||||
n.sons[0] = ast.emptyNode
|
||||
else:
|
||||
if (c.p.resultSym == nil): InternalError(n.info, "semReturn")
|
||||
addSon(a, semExprWithType(c, newSymNode(c.p.resultSym)))
|
||||
addSon(a, n.sons[0])
|
||||
n.sons[0] = a
|
||||
else:
|
||||
localError(n.info, errCannotReturnExpr)
|
||||
if n.sons[0].kind != nkEmpty:
|
||||
# transform ``return expr`` to ``result = expr; return``
|
||||
if c.p.resultSym == nil: InternalError(n.info, "semReturn")
|
||||
var a = newNodeI(nkAsgn, n.sons[0].info)
|
||||
addSon(a, newSymNode(c.p.resultSym))
|
||||
addSon(a, n.sons[0])
|
||||
n.sons[0] = semAsgn(c, a)
|
||||
# optimize away ``result = result``:
|
||||
if n[0][1].kind == nkSym and sfResult in n[0][1].sym.flags:
|
||||
n.sons[0] = ast.emptyNode
|
||||
|
||||
proc SemYield(c: PContext, n: PNode): PNode =
|
||||
result = n
|
||||
checkSonsLen(n, 1)
|
||||
if (c.p.owner == nil) or (c.p.owner.kind != skIterator):
|
||||
if c.p.owner == nil or c.p.owner.kind != skIterator:
|
||||
GlobalError(n.info, errYieldNotAllowedHere)
|
||||
if n.sons[0].kind != nkEmpty:
|
||||
if n.sons[0].kind != nkEmpty:
|
||||
n.sons[0] = SemExprWithType(c, n.sons[0]) # check for type compatibility:
|
||||
var restype = c.p.owner.typ.sons[0]
|
||||
if restype != nil:
|
||||
n.sons[0] = fitNode(c, restype, n.sons[0])
|
||||
if (n.sons[0].typ == nil): InternalError(n.info, "semYield")
|
||||
if n.sons[0].typ == nil: InternalError(n.info, "semYield")
|
||||
else:
|
||||
localError(n.info, errCannotReturnExpr)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue