From 4b7655fd10d81ea50d0af41152df07ec21b05232 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 19 Mar 2014 02:52:48 +0200 Subject: reference implementation of a vector swizzle library This also provides the initial steps towards support for type class "filtered" type inference fixes an "ordinal type expected" ICE, related to the use of static params --- compiler/semdata.nim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'compiler/semdata.nim') diff --git a/compiler/semdata.nim b/compiler/semdata.nim index 088b93fae..5ec66b51c 100644 --- a/compiler/semdata.nim +++ b/compiler/semdata.nim @@ -251,6 +251,27 @@ proc makeNotType*(c: PContext, t1: PType): PType = propagateToOwner(result, t1) result.flags.incl(t1.flags * {tfHasStatic}) +proc nMinusOne*(n: PNode): PNode = + result = newNode(nkCall, n.info, @[ + newSymNode(getSysMagic("<", mUnaryLt)), + n]) + +# Remember to fix the procs below this one when you make changes! +proc makeRangeWithStaticExpr*(c: PContext, n: PNode): PType = + let intType = getSysType tyInt + result = newTypeS(tyRange, c) + result.sons = @[intType] + result.n = newNode(nkRange, n.info, @[ + newIntTypeNode(nkIntLit, 0, intType), + makeStaticExpr(c, n.nMinusOne)]) + +template rangeHasStaticIf*(t: PType): bool = + # this accepts the ranges's node + t.n[1].kind == nkStaticExpr + +template getStaticTypeFromRange*(t: PType): PType = + t.n[1][0][1].typ + proc newTypeS(kind: TTypeKind, c: PContext): PType = result = newType(kind, getCurrOwner()) -- cgit 1.4.1-2-gfad0