Skip to content

Commit

Permalink
Default fields WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Clyybber committed Nov 5, 2019
1 parent 3ba3307 commit 44c0b60
Show file tree
Hide file tree
Showing 6 changed files with 485 additions and 435 deletions.
3 changes: 1 addition & 2 deletions compiler/ccgstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1213,9 +1213,8 @@ proc genCaseObjDiscMapping(p: BProc, e: PNode, t: PType, field: PSym; d: var TLo
expr(p, call, d)

proc asgnFieldDiscriminant(p: BProc, e: PNode) =
var dotExpr = e[0]
var a, tmp: TLoc
var dotExpr = e.sons[0]
if dotExpr.kind == nkCheckedFieldExpr: dotExpr = dotExpr.sons[0]
initLocExpr(p, e.sons[0], a)
getTemp(p, a.t, tmp)
expr(p, e.sons[1], tmp)
Expand Down
18 changes: 12 additions & 6 deletions compiler/parser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ proc parseIdentColonEquals(p: var TParser, flags: TDeclaredIdentFlags): PNode =
optInd(p, result)
addSon(result, parseExpr(p))
else:
addSon(result, newNodeP(nkEmpty, p))
addSon(result, p.emptyNode)

proc parseTuple(p: var TParser, indentAllowed = false): PNode =
#| inlTupleDecl = 'tuple'
Expand Down Expand Up @@ -1899,11 +1899,17 @@ proc parseObjectCase(p: var TParser): PNode =
#| | IND{=} objectBranches)
result = newNodeP(nkRecCase, p)
getTokNoInd(p)
var a = newNodeP(nkIdentDefs, p)
addSon(a, identWithPragma(p))
eat(p, tkColon)
addSon(a, parseTypeDesc(p))
addSon(a, p.emptyNode)
var a = parseIdentColonEquals(p, {withPragma})
# var a = newNodeP(nkIdentDefs, p)
# addSon(a, identWithPragma(p))
# eat(p, tkColon)
# addSon(a, parseTypeDesc(p))
# if p.tok.tokType == tkEquals:
# getTok(p)
# optInd(p, result)
# addSon(a, parseExpr(p))
# else:
# addSon(a, p.emptyNode)
addSon(result, a)
if p.tok.tokType == tkColon: getTok(p)
flexComment(p, result)
Expand Down
Loading

0 comments on commit 44c0b60

Please sign in to comment.