summary refs log tree commit diff stats
path: root/tests/generics/mdotlookup.nim
diff options
context:
space:
mode:
authorDean Thompson <deansherthompson@gmail.com>2019-01-21 16:40:04 -0500
committerGitHub <noreply@github.com>2019-01-21 16:40:04 -0500
commita6de0274ee768d135bab280d2b2700a0bb475300 (patch)
tree176b91e837ab7d2217713665c16fc28163017960 /tests/generics/mdotlookup.nim
parent5b39c7aca91c1d20eb81425cf8f3854876aed475 (diff)
parentee89ba6bdb664fe4972f2917499cff1afdac0bab (diff)
downloadNim-a6de0274ee768d135bab280d2b2700a0bb475300.tar.gz
Merge pull request #1 from nim-lang/devel
Getting the latest from nim-lang
Diffstat (limited to 'tests/generics/mdotlookup.nim')
0 files changed, 0 insertions, 0 deletions
itle='Blame the previous revision' href='/ahoang/Nim/blame/rod/ccgutils.nim?h=devel&id=6850fb73c1b9ae8d3f56a61ee37922c3cb3788d6'>^
d61f326f3 ^
70ea45cdb ^
8d734244b ^


70ea45cdb ^
8d734244b ^
2df9b442c ^
8d734244b ^



a4e2b0c15 ^
8d734244b ^
a4e2b0c15 ^
8d734244b ^


d61f326f3 ^
92b8fac94 ^
8d734244b ^





d61f326f3 ^
8d734244b ^
d61f326f3 ^
92b8fac94 ^
8d734244b ^





e25474154 ^
479212995 ^
e25474154 ^
0f0dfd637 ^


669a56449 ^
0f0dfd637 ^
e25474154 ^
a568c6102 ^
e65c296bc ^
fab69661a ^








a568c6102 ^

848676cec ^
a568c6102 ^
848676cec ^


e213b120a ^
848676cec ^


fab69661a ^

















a568c6102 ^
fab69661a ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

 
                            
                                         






                                                             
      
                                                               
                          


                                                       
                
                         


                                     
                         
                                            
               



                                                           
                                                          
                                                      
                                          


                                      
                                    
                        





                           
       
                 
                                    
                              





                               
 
                                                
 


                                                
                     
                  
 
                                    
                                   








                                

                   
                                    
                    


                                                                       
                                                          


                      

















                             
         



                                         
#
#
#           The Nim Compiler
#        (c) Copyright 2012 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

# This module declares some helpers for the C code generator.

import
  ast, astalgo, ropes, hashes, strutils, types, msgs, wordrecg,
  platform, trees, options

proc getPragmaStmt*(n: PNode, w: TSpecialWord): PNode =
  case n.kind
  of nkStmtList:
    for i in 0 ..< n.len:
      result = getPragmaStmt(n[i], w)
      if result != nil: break
  of nkPragma:
    for i in 0 ..< n.len:
      if whichPragma(n[i]) == w: return n[i]
  else: discard

proc stmtsContainPragma*(n: PNode, w: TSpecialWord): bool =
  result = getPragmaStmt(n, w) != nil

proc hashString*(conf: ConfigRef; s: string): BiggestInt =
  # has to be the same algorithm as system.hashString!
  if CPU[conf.target.targetCPU].bit == 64:
    # we have to use the same bitwidth
    # as the target CPU
    var b = 0'i64
    for i in countup(0, len(s) - 1):
      b = b +% ord(s[i])
      b = b +% `shl`(b, 10)
      b = b xor `shr`(b, 6)
    b = b +% `shl`(b, 3)
    b = b xor `shr`(b, 11)
    b = b +% `shl`(b, 15)
    result = b
  else:
    var a = 0'i32
    for i in countup(0, len(s) - 1):
      a = a +% ord(s[i]).int32
      a = a +% `shl`(a, 10'i32)
      a = a xor `shr`(a, 6'i32)
    a = a +% `shl`(a, 3'i32)
    a = a xor `shr`(a, 11'i32)
    a = a +% `shl`(a, 15'i32)
    result = a

template getUniqueType*(key: PType): PType = key

proc makeSingleLineCString*(s: string): string =
  result = "\""
  for c in items(s):
    c.toCChar(result)
  result.add('\"')

proc mangle*(name: string): string =
  result = newStringOfCap(name.len)
  var start = 0
  if name[0] in Digits:
    result.add("X" & name[0])
    start = 1
  var requiresUnderscore = false
  template special(x) =
    result.add x
    requiresUnderscore = true
  for i in start..(name.len-1):
    let c = name[i]
    case c
    of 'a'..'z', '0'..'9', 'A'..'Z':
      add(result, c)
    of '_':
      # we generate names like 'foo_9' for scope disambiguations and so
      # disallow this here:
      if i > 0 and i < name.len-1 and name[i+1] in Digits:
        discard
      else:
        add(result, c)
    of '$': special "dollar"
    of '%': special "percent"
    of '&': special "amp"
    of '^': special "roof"
    of '!': special "emark"
    of '?': special "qmark"
    of '*': special "star"
    of '+': special "plus"
    of '-': special "minus"
    of '/': special "slash"
    of '=': special "eq"
    of '<': special "lt"
    of '>': special "gt"
    of '~': special "tilde"
    of ':': special "colon"
    of '.': special "dot"
    of '@': special "at"
    of '|': special "bar"
    else:
      add(result, "X" & toHex(ord(c), 2))
      requiresUnderscore = true
  if requiresUnderscore:
    result.add "_"