VM produces objects.
This commit is contained in:
parent
0320c0c73b
commit
04a4f35400
6 changed files with 43 additions and 23 deletions
|
|
@ -38,14 +38,16 @@ proc annotateType*(n: PNode, t: PType) =
|
|||
# Note: x can be unequal to t and we need to be careful to use 't'
|
||||
# to not to skip tyGenericInst
|
||||
case n.kind
|
||||
of nkObjConstr:
|
||||
n.typ = t
|
||||
for i in 1 .. <n.len:
|
||||
let field = x.n.ithField(i - 1)
|
||||
if field.isNil: globalError n.info, "invalid field at index " & $i
|
||||
else:
|
||||
internalAssert(n.sons[i].kind == nkExprColonExpr)
|
||||
annotateType(n.sons[i].sons[1], field.typ)
|
||||
of nkPar:
|
||||
if x.kind == tyObject:
|
||||
n.typ = t
|
||||
for i in 0 .. <n.len:
|
||||
let field = x.n.ithField(i)
|
||||
if field.isNil: globalError n.info, "invalid field at index " & $i
|
||||
else: annotateType(n.sons[i], field.typ)
|
||||
elif x.kind == tyTuple:
|
||||
if x.kind == tyTuple:
|
||||
n.typ = t
|
||||
for i in 0 .. <n.len:
|
||||
if i >= x.len: globalError n.info, "invalid field at index " & $i
|
||||
|
|
@ -53,7 +55,7 @@ proc annotateType*(n: PNode, t: PType) =
|
|||
elif x.kind == tyProc and x.callConv == ccClosure:
|
||||
n.typ = t
|
||||
else:
|
||||
globalError(n.info, "() must have an object or tuple type")
|
||||
globalError(n.info, "() must have a tuple type")
|
||||
of nkBracket:
|
||||
if x.kind in {tyArrayConstr, tyArray, tySequence, tyOpenArray}:
|
||||
n.typ = t
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue