Created
November 27, 2013 21:29
-
-
Save mflamer/7683587 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc enumConstructor(c: PContext, head: PNode): PNode = | |
var sym = lookUp(c, head.sons[0]) | |
var val = lookUp(c, head.sons[1]) | |
result = newNodeI(nkInfix, head.info) | |
result.addSon(newIdentNode(getIdent("or"), head.info)) | |
result.addSon(newIntNode(nkIntLit, sym.position)) | |
var x = newNodeIT(nkCast, head.info, getSysType(tyInt)) | |
x.addSon(newNodeIT(nkType, head.info, getSysType(tyInt))) | |
var y = newNodeIT(nkAddr, head.info, x.typ) | |
y.addSon(newSymNode(val, head.info)) | |
x.addSon(y) | |
result.addSon(x) | |
result = semExpr(c, result) | |
result.typ = sym.typ | |
result.typ.newSons(1) | |
result.typ.sons[0] = sym.ast.sym.typ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As of now this proc assumes the x in Just(x) is a sym we can take the addr of.