summary refs log tree commit diff stats
path: root/compiler/lowerings.nim
Commit message (Expand)AuthorAgeFilesLines
* type refactoring: part 2 (#23059)Andreas Rumpf2023-12-131-5/+5
* Types: Refactorings; step 1 (#23055)Andreas Rumpf2023-12-121-3/+3
* IC: progress and refactorings (#22961)Andreas Rumpf2023-11-201-2/+2
* round out tuple unpacking assignment, support underscores (#22537)metagn2023-08-241-19/+0
* fixes #22419; async/closure environment does not align local variables (#22425)ringabout2023-08-091-0/+3
* fixes #22268; fixes `move` codegen (#22288)ringabout2023-07-191-11/+2
* make `move` use `=wasMoved` internally (#22032)ringabout2023-06-091-2/+11
* cheap fix for #10853 + better tuple subscript error message (#21767)metagn2023-05-021-1/+1
* refactoring in preparation for better, simpler name mangling that wor… (#21...Andreas Rumpf2023-04-241-8/+7
* warn on set types bigger than max size, default to 0..255 for int literals (#...metagn2023-04-171-1/+2
* Fixed noinit pragma for closure variables (#20101)Yuriy Glukhov2022-07-281-1/+2
* Fix bug in freshVarForClosureIter. Fixes #18474 (#19675) [backport]flywind2022-04-041-1/+2
* mitigates #19364 [backport]; we make this bug more unlikely to appear by prod...Andreas Rumpf2022-03-261-6/+12
* move assertions out of system (#19599)flywind2022-03-231-0/+3
* big steps torwards an efficient, simple IC implementation (#16543)Andreas Rumpf2021-01-021-9/+9
* fix #15463 (#15831)flywind2020-11-051-0/+1
* explicit ID generation for easier IC (#15559)Andreas Rumpf2020-10-251-29/+32
* fixes #15076 (#15329)Andreas Rumpf2020-09-151-1/+1
* Expand hoisted default params in sem (#15270)Clyybber2020-09-051-11/+0
* init checks and 'out' parameters (#14521)Andreas Rumpf2020-06-231-1/+1
* Step2: fixes #13781, fixes #13805 (#13897)cooldome2020-04-161-0/+7
* fixes #13708 (#13711)cooldome2020-03-211-2/+2
* fixes #13368 (#13397)cooldome2020-02-141-2/+3
* make case-object transitions explicit, make unknownLineInfo a const, replace ...Jasper Jenkins2020-01-171-1/+1
* Sink to MemMove optimization in injectdestructors (#13002)cooldome2020-01-021-2/+8
* fixes #12989 (#12992)cooldome2019-12-311-1/+0
* Revert "fixes #12989"Andrii Riabushenko2019-12-311-0/+1
* fixes #12989Andrii Riabushenko2019-12-311-1/+0
* ARC: fixes cycle detection and move the .cursor attribute into closures (#12872)Andreas Rumpf2019-12-111-0/+1
* Cosmetic compiler cleanup (#12718)Clyybber2019-11-281-76/+76
* ARC: ported the GC tests over to --gc:arcAraq2019-11-261-0/+1
* Revert "ARC: another critical bugfix; temporary tuples we introduce for tuple...narimiran2019-11-241-1/+0
* ARC: another critical bugfix; temporary tuples we introduce for tuple unpacka...Araq2019-11-221-0/+1
* more arc improvements (#12690)Andreas Rumpf2019-11-201-0/+8
* Small ast.nim cleanup (#12156)Clyybber2019-09-091-5/+5
* Support iterators returning lent T (#11938)cooldome2019-08-311-2/+2
* int128 on firstOrd, lastOrd and lengthOrd (#11701)Arne Döring2019-08-071-2/+2
* [refactoring] remove unused imports in the compiler and in some stdlib modulesAraq2019-07-181-1/+0
* [refactoring] moves transformation for 'spawn' into its own spawn.nim impleme...Araq2019-07-141-428/+15
* fixes #7057Andreas Rumpf2019-07-061-1/+1
* [bugfix] owned closures (#11544)Andreas Rumpf2019-06-201-0/+3
* fixes #11215Araq2019-05-121-2/+2
* rename tyExpr/tyStmt to tyUntyped/tyTyped (#11227)Arne Döring2019-05-111-2/+2
* Replace countup(x, y-1) with x ..< yClyybber2019-05-071-2/+2
* added lowerings.evalOnceAraq2019-04-091-0/+16
* more destructor based changes (#10885)Andreas Rumpf2019-03-231-1/+1
* added lowerings.genLen helper procAndreas Rumpf2019-03-141-0/+9
* Tuple unpacking now works for `for` vars (#10152)Neelesh Chandola2019-02-231-6/+14
* Destructors: more moves for tuples (#9808)cooldome2018-11-271-1/+1
* Change the order of compilation passes, transformation is made lazy at code g...cooldome2018-10-181-0/+2
"n">n.info) result.add(tupl) result.add(newIntNode(nkIntLit, c.tupleIndex)) else: result = newNodeI(nkDotExpr, n.info) result.add(tupl) result.add(newSymNode(c.field, n.info)) break else: if n.kind == nkContinueStmt: localError(n.info, errGenerated, "'continue' not supported in a 'fields' loop") result = copyNode(n) newSons(result, sonsLen(n)) for i in countup(0, sonsLen(n)-1): result.sons[i] = instFieldLoopBody(c, n.sons[i], forLoop) type TFieldsCtx = object c: PContext m: TMagic proc semForObjectFields(c: TFieldsCtx, typ, forLoop, father: PNode) = case typ.kind of nkSym: var fc: TFieldInstCtx # either 'tup[i]' or 'field' is valid fc.field = typ.sym fc.replaceByFieldName = c.m == mFieldPairs openScope(c.c) inc c.c.inUnrolledContext let body = instFieldLoopBody(fc, lastSon(forLoop), forLoop) father.add(semStmt(c.c, body)) dec c.c.inUnrolledContext closeScope(c.c) of nkNilLit: discard of nkRecCase: let L = forLoop.len let call = forLoop.sons[L-2] if call.len > 2: localError(forLoop.info, errGenerated, "parallel 'fields' iterator does not work for 'case' objects") return # iterate over the selector: semForObjectFields(c, typ[0], forLoop, father) # we need to generate a case statement: var caseStmt = newNodeI(nkCaseStmt, forLoop.info) # generate selector: var access = newNodeI(nkDotExpr, forLoop.info, 2) access.sons[0] = call.sons[1] access.sons[1] = newSymNode(typ.sons[0].sym, forLoop.info) caseStmt.add(semExprWithType(c.c, access)) # copy the branches over, but replace the fields with the for loop body: for i in 1 .. <typ.len: var branch = copyTree(typ[i]) let L = branch.len branch.sons[L-1] = newNodeI(nkStmtList, forLoop.info) semForObjectFields(c, typ[i].lastSon, forLoop, branch[L-1]) caseStmt.add(branch) father.add(caseStmt) of nkRecList: for t in items(typ): semForObjectFields(c, t, forLoop, father) else: illFormedAstLocal(typ) proc semForFields(c: PContext, n: PNode, m: TMagic): PNode = # so that 'break' etc. work as expected, we produce # a 'while true: stmt; break' loop ... result = newNodeI(nkWhileStmt, n.info, 2) var trueSymbol = strTableGet(magicsys.systemModule.tab, getIdent"true") if trueSymbol == nil: localError(n.info, errSystemNeeds, "true") trueSymbol = newSym(skUnknown, getIdent"true", getCurrOwner(), n.info) trueSymbol.typ = getSysType(tyBool) result.sons[0] = newSymNode(trueSymbol, n.info) var stmts = newNodeI(nkStmtList, n.info) result.sons[1] = stmts var length = sonsLen(n) var call = n.sons[length-2] if length-2 != sonsLen(call)-1 + ord(m==mFieldPairs): localError(n.info, errWrongNumberOfVariables) return result var tupleTypeA = skipTypes(call.sons[1].typ, abstractVar-{tyTypeDesc}) if tupleTypeA.kind notin {tyTuple, tyObject}: localError(n.info, errGenerated, "no object or tuple type") return result for i in 1..call.len-1: var tupleTypeB = skipTypes(call.sons[i].typ, abstractVar-{tyTypeDesc}) if not sameType(tupleTypeA, tupleTypeB): typeMismatch(call.sons[i], tupleTypeA, tupleTypeB) inc(c.p.nestedLoopCounter) if tupleTypeA.kind == tyTuple: var loopBody = n.sons[length-1] for i in 0..sonsLen(tupleTypeA)-1: openScope(c) var fc: TFieldInstCtx fc.tupleType = tupleTypeA fc.tupleIndex = i fc.replaceByFieldName = m == mFieldPairs var body = instFieldLoopBody(fc, loopBody, n) inc c.inUnrolledContext stmts.add(semStmt(c, body)) dec c.inUnrolledContext closeScope(c) else: var fc: TFieldsCtx fc.m = m fc.c = c var t = tupleTypeA while t.kind == tyObject: semForObjectFields(fc, t.n, n, stmts) if t.sons[0] == nil: break t = skipTypes(t.sons[0], abstractPtrs) dec(c.p.nestedLoopCounter) # for TR macros this 'while true: ...; break' loop is pretty bad, so # we avoid it now if we can: if containsNode(stmts, {nkBreakStmt}): var b = newNodeI(nkBreakStmt, n.info) b.add(ast.emptyNode) stmts.add(b) else: result = stmts