diff options
author | Zahary Karadjov <zahary@gmail.com> | 2014-03-19 02:52:48 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2014-03-20 01:16:50 +0200 |
commit | 4b7655fd10d81ea50d0af41152df07ec21b05232 (patch) | |
tree | a437c41d515806717de7737d065098a91e13a3b7 /compiler/semdata.nim | |
parent | a66d059accc9db4c376fdb1220ee2c5ca8daf311 (diff) | |
download | Nim-4b7655fd10d81ea50d0af41152df07ec21b05232.tar.gz |
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
Diffstat (limited to 'compiler/semdata.nim')
-rw-r--r-- | compiler/semdata.nim | 21 |
1 files changed, 21 insertions, 0 deletions
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()) |