summary refs log tree commit diff stats
path: root/lib/pure/hashes.nim
Commit message (Expand)AuthorAgeFilesLines
* rename nimEnableHashRef [backport] (#18941)flywind2021-10-041-5/+13
* fixes #18220 (#18227)Andreas Rumpf2021-06-101-1/+1
* hashes for refs should be an opt-in feature (#18098)Miran2021-05-301-1/+1
* fix #17911 rawProc for cpp (#17912)Timothee Cour2021-05-011-6/+12
* fix #17905: hash(closure) was not being tested (#17906)Timothee Cour2021-04-301-12/+20
* add -d:nimLegacyNoHashRef for a transition period which avoids defining hash(...Timothee Cour2021-04-271-17/+22
* std/hashes: hash(ref|ptr|pointer) + other improvements (#17731)Timothee Cour2021-04-161-23/+49
* hashes: Made the runnableExample easier to understand (#17689)Andreas Rumpf2021-04-091-1/+1
* hashes: support object default hash (#17175)Timothee Cour2021-02-261-17/+13
* add example of hashing an object by all of its fields with `fields` (#16643)dawidkotlin2021-02-191-0/+14
* JS: make hash float support IE/Safari (#16872)flywind2021-02-011-5/+10
* refactor hash in JS backend (#16863)flywind2021-01-301-29/+31
* Improve documentation for the hashes module (#16720)konsumlamm2021-01-151-51/+73
* fix #16061 (#16551)flywind2021-01-021-4/+10
* fix #16542 (#16549)flywind2021-01-021-2/+21
* move tests to testament (#16101)flywind2020-11-241-43/+0
* Alternate to https://github.com/nim-lang/Nim/pull/15915 (#15937)c-blake2020-11-131-2/+7
* Fix #14394 (#14395)Clyybber2020-05-181-1/+1
* move since from inclrtl to std/private/since (#14188)hlaaftana2020-05-021-1/+1
* bug fix (#14149) [backport:1.2]cooldome2020-04-281-1/+4
* fixes #12834 (#14017)Andreas Rumpf2020-04-191-3/+3
* added a .since annotation to hashIdentityAndreas Rumpf2020-04-151-2/+4
* Add `hashWangYi1` (#13823)c-blake2020-04-151-2/+71
* fix #12508, unaligned access on sparc64 (#13594)Miran2020-03-091-1/+1
* cleanup Ordinal (#13501)Timothee Cour2020-02-271-1/+1
* [backport] pseudorandom probing for hash collision (#13418)Timothee Cour2020-02-191-28/+4
* style fix: change 'JS' to 'js' to make it consistent (#13168)Miran2020-01-161-2/+2
* fixes #11764, faster hashing of (u)int (#12407)Miran2019-10-151-6/+9
* [backport] run nimpretty on hashesnarimiran2019-09-301-4/+4
* hashes: implement murmur3 (#12022)Miran2019-09-011-47/+149
* 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-4/+0
* styleCheck: make the compiler and large parts of the stdlib compatible with -...Araq2019-07-101-1/+1
* [bugfix] hashes: fix regression for nested containers (#11426)Miran2019-06-081-6/+6
* right shift is now by default sign preserving (#11322)Arne Döring2019-05-291-7/+12
* hashes: quickfix one testnarimiran2019-05-271-1/+1
* fix spelling [ci skip] (#11307)Andy Davidoff2019-05-221-1/+1
* faster hashing (#11203)Miran2019-05-211-41/+94
* hashes: fix inconsistent tests, fixes #10771narimiran2019-03-031-4/+3
* improved documentation for several modules (#10752)Miran2019-03-011-40/+91
* remove deprecated stuff from the stdlib; introduce better deprecation warningsAraq2018-05-051-1/+0
* fixes #5969Araq2017-06-091-3/+8
* remove en-dash from the languageAndreas Rumpf2017-04-021-5/+1
* added hash for uints (#5435)Fabian Keller2017-02-261-0/+8
* Add hash proc for cstrings (#5386)Ruslan Mustakov2017-02-131-0/+10
* added hash procs for handling portions of strings/arrays/seqs.JamesP2015-10-071-4/+70
* Added commaapense2015-07-061-1/+1
* THash -> Hash correctionapense2015-07-061-1/+1
* added hash function for ordinal typesFabian Keller2015-07-031-0/+4
* lib/pure/e-o - Dropped 'T' from typespdw2015-06-041-30/+31
vious revision' href='/akkartik/mu/blame/070display.cc?h=main&id=7199af30e8fdcdc0848a2e2b90014b98f97998b3'>^
dc1323e9 ^

5f128523 ^






dc1323e9 ^

10a3b8cc ^
dc1323e9 ^





10a3b8cc ^
64ac91c5 ^

10a3b8cc ^
0e120d81 ^


64ac91c5 ^
10a3b8cc ^
dc1323e9 ^

5f128523 ^


12d73ee8 ^








0487a30e ^


12d73ee8 ^








ac0e9db5 ^
827898fc ^
ac0e9db5 ^
827898fc ^
5f128523 ^

12d73ee8 ^


0012c703 ^





dc1323e9 ^
ac0e9db5 ^
dc1323e9 ^




0012c703 ^








dc1323e9 ^




0012c703 ^








dc1323e9 ^
ac0e9db5 ^
dc1323e9 ^




0012c703 ^








dc1323e9 ^




0012c703 ^


9fae6657 ^





















12d73ee8 ^


f08a13e1 ^
54d48b25 ^
f08a13e1 ^
54d48b25 ^
f08a13e1 ^
e02d7e98 ^
bbff2a35 ^


0e120d81 ^



0487a30e ^
0e120d81 ^
bbff2a35 ^








e02d7e98 ^
bbff2a35 ^
0487a30e ^

f8c0ef3e ^
0487a30e ^
f8c0ef3e ^
af336c44 ^


0487a30e ^
bbff2a35 ^
0487a30e ^


54d48b25 ^

5f128523 ^


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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
                                                      
 



                                      

                       
                       
                                                  
 
                                             
                  
                                        
                                                       
                                                                     
                                                
                         

                                   



                                             
                  
                                        
                                                       
                                                
                         
                
                                             


        


                        
                                             




                                                

                                   








                                                               

                                                          
                                                            


                                             








                                                                         
                                  


                                          
                                            


                                                                                

                                 






                                                 

                             
                                                                             





                                                 
                       

                                      
                                    


                                              
   
                                                                  

                                 


                                               








                                                                         


                                           








                                                                 
                                    
                                        
                                    
                                           

                                             


        





                                                                           
                    
                                          




                                               








                                                                       




                                               








                                                                             
                   
                                         




                                               








                                                                           




                                               


        





















                                                 


                                             
                           
                                        
                                                                         
                                                
                                  
                 


                                       



                                                                
                     
                                   








                                                                 
                 
                                                  

                              
                                       
                                   
                                              


                                                                  
                 
   


                                   

        


                           
//: Take charge of the text-mode display and keyboard.

// uncomment to debug console programs
:(before "End Globals")
//? ofstream LOG("log.txt");

//:: Display management

:(before "End Globals")
long long int Display_row = 0, Display_column = 0;

:(before "End Primitive Recipe Declarations")
SWITCH_TO_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["switch-to-display"] = SWITCH_TO_DISPLAY;
//? cerr << "switch-to-display: " << SWITCH_TO_DISPLAY << '\n'; //? 1
:(before "End Primitive Recipe Implementations")
case SWITCH_TO_DISPLAY: {
  tb_init();
  Display_row = Display_column = 0;
  break;
}

:(before "End Primitive Recipe Declarations")
RETURN_TO_CONSOLE,
:(before "End Primitive Recipe Numbers")
Recipe_number["return-to-console"] = RETURN_TO_CONSOLE;
:(before "End Primitive Recipe Implementations")
case RETURN_TO_CONSOLE: {
  tb_shutdown();
//?   Trace_stream->dump_layer = "all"; //? 1
  break;
}

:(before "End Teardown")
tb_shutdown();

:(before "End Primitive Recipe Declarations")
CLEAR_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["clear-display"] = CLEAR_DISPLAY;
:(before "End Primitive Recipe Implementations")
case CLEAR_DISPLAY: {
  tb_clear();
  Display_row = Display_column = 0;
  break;
}

:(before "End Primitive Recipe Declarations")
CLEAR_LINE_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["clear-line-on-display"] = CLEAR_LINE_ON_DISPLAY;
:(before "End Primitive Recipe Implementations")
case CLEAR_LINE_ON_DISPLAY: {
  long long int width = tb_width();
  for (long long int x = Display_column; x < width; ++x) {
    tb_change_cell(x, Display_row, ' ', TB_WHITE, TB_BLACK);
  }
  tb_set_cursor(Display_column, Display_row);
  tb_present();
  break;
}

:(before "End Primitive Recipe Declarations")
PRINT_CHARACTER_TO_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["print-character-to-display"] = PRINT_CHARACTER_TO_DISPLAY;
:(before "End Primitive Recipe Implementations")
case PRINT_CHARACTER_TO_DISPLAY: {
  int h=tb_height(), w=tb_width();
  long long int height = (h >= 0) ? h : 0;
  long long int width = (w >= 0) ? w : 0;
  assert(scalar(ingredients.at(0)));
  long long int c = ingredients.at(0).at(0);
//?   tb_shutdown(); //? 1
//?   cerr << "AAA " << c << ' ' << (int)'\n' << ' ' << (int)'\r' << '\n'; //? 1
//?   exit(1); //? 1
  if (c == '\n' || c == '\r') {
    if (Display_row < height-1) {
      Display_column = 0;
      ++Display_row;
      tb_set_cursor(Display_column, Display_row);
      tb_present();
    }
    break;
  }
  if (c == '\b') {
    if (Display_column > 0) {
      tb_change_cell(Display_column-1, Display_row, ' ', TB_WHITE, TB_BLACK);
      --Display_column;
      tb_set_cursor(Display_column, Display_row);
      tb_present();
    }
    break;
  }
  int color = TB_BLACK;
  if (SIZE(ingredients) > 1) {
    assert(scalar(ingredients.at(1)));
    color = ingredients.at(1).at(0);
//?     tb_shutdown(); //? 1
//?     cerr << "AAA " << color << '\n'; //? 1
//?     exit(1); //? 1
  }
  tb_change_cell(Display_column, Display_row, c, color, TB_BLACK);
  if (Display_column < width-1) {
    ++Display_column;
    tb_set_cursor(Display_column, Display_row);
  }
  tb_present();
  break;
}

:(before "End Primitive Recipe Declarations")
CURSOR_POSITION_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["cursor-position-on-display"] = CURSOR_POSITION_ON_DISPLAY;
:(before "End Primitive Recipe Implementations")
case CURSOR_POSITION_ON_DISPLAY: {
  products.resize(2);
  products.at(0).push_back(Display_row);
  products.at(1).push_back(Display_column);
  break;
}

:(before "End Primitive Recipe Declarations")
MOVE_CURSOR_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["move-cursor-on-display"] = MOVE_CURSOR_ON_DISPLAY;
:(before "End Primitive Recipe Implementations")
case MOVE_CURSOR_ON_DISPLAY: {
  assert(scalar(ingredients.at(0)));
  Display_row = ingredients.at(0).at(0);
  assert(scalar(ingredients.at(1)));
  Display_column = ingredients.at(1).at(0);
  tb_set_cursor(Display_column, Display_row);
  tb_present();
  break;
}

:(before "End Primitive Recipe Declarations")
MOVE_CURSOR_DOWN_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["move-cursor-down-on-display"] = MOVE_CURSOR_DOWN_ON_DISPLAY;
:(before "End Primitive Recipe Implementations")
case MOVE_CURSOR_DOWN_ON_DISPLAY: {
  int h=tb_height();
  long long int height = (h >= 0) ? h : 0;
  if (Display_row < height-1) {
    Display_row++;
    tb_set_cursor(Display_column, Display_row);
    tb_present();
  }
  break;
}

:(before "End Primitive Recipe Declarations")
MOVE_CURSOR_UP_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["move-cursor-up-on-display"] = MOVE_CURSOR_UP_ON_DISPLAY;
:(before "End Primitive Recipe Implementations")
case MOVE_CURSOR_UP_ON_DISPLAY: {
  if (Display_row > 0) {
    Display_row--;
    tb_set_cursor(Display_column, Display_row);
    tb_present();
  }
  break;
}

:(before "End Primitive Recipe Declarations")
MOVE_CURSOR_RIGHT_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["move-cursor-right-on-display"] = MOVE_CURSOR_RIGHT_ON_DISPLAY;
:(before "End Primitive Recipe Implementations")
case MOVE_CURSOR_RIGHT_ON_DISPLAY: {
  int w=tb_width();
  long long int width = (w >= 0) ? w : 0;
  if (Display_column < width-1) {
    Display_column++;
    tb_set_cursor(Display_column, Display_row);
    tb_present();
  }
  break;
}

:(before "End Primitive Recipe Declarations")
MOVE_CURSOR_LEFT_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["move-cursor-left-on-display"] = MOVE_CURSOR_LEFT_ON_DISPLAY;
:(before "End Primitive Recipe Implementations")
case MOVE_CURSOR_LEFT_ON_DISPLAY: {
  if (Display_column > 0) {
    Display_column--;
    tb_set_cursor(Display_column, Display_row);
    tb_present();
  }
  break;
}

:(before "End Primitive Recipe Declarations")
DISPLAY_WIDTH,
:(before "End Primitive Recipe Numbers")
Recipe_number["display-width"] = DISPLAY_WIDTH;
:(before "End Primitive Recipe Implementations")
case DISPLAY_WIDTH: {
  products.resize(1);
  products.at(0).push_back(tb_width());
  break;
}

:(before "End Primitive Recipe Declarations")
DISPLAY_HEIGHT,
:(before "End Primitive Recipe Numbers")
Recipe_number["display-height"] = DISPLAY_HEIGHT;
:(before "End Primitive Recipe Implementations")
case DISPLAY_HEIGHT: {
  products.resize(1);
  products.at(0).push_back(tb_height());
  break;
}

//:: Keyboard management

:(before "End Primitive Recipe Declarations")
WAIT_FOR_KEY_FROM_KEYBOARD,
:(before "End Primitive Recipe Numbers")
Recipe_number["wait-for-key-from-keyboard"] = WAIT_FOR_KEY_FROM_KEYBOARD;
:(before "End Primitive Recipe Implementations")
case WAIT_FOR_KEY_FROM_KEYBOARD: {
  tb_event event;
  do {
    tb_poll_event(&event);
  } while (event.type != TB_EVENT_KEY);
  long long int result = event.key ? event.key : event.ch;
  if (result == TB_KEY_CTRL_C) tb_shutdown(), exit(1);
  if (result == TB_KEY_BACKSPACE2) result = TB_KEY_BACKSPACE;
  if (result == TB_KEY_CARRIAGE_RETURN) result = TB_KEY_NEWLINE;
  products.resize(1);
  products.at(0).push_back(result);
  break;
}

:(before "End Primitive Recipe Declarations")
READ_KEY_FROM_KEYBOARD,
:(before "End Primitive Recipe Numbers")
Recipe_number["read-key-from-keyboard"] = READ_KEY_FROM_KEYBOARD;
:(before "End Primitive Recipe Implementations")
case READ_KEY_FROM_KEYBOARD: {
  tb_event event;
  int event_type = tb_peek_event(&event, 5/*ms*/);
  long long int result = 0;
  long long int found = false;
//?   cerr << event_type << '\n'; //? 1
  if (event_type == TB_EVENT_KEY) {
    result = event.key ? event.key : event.ch;
    if (result == TB_KEY_CTRL_C) tb_shutdown(), exit(1);
    if (result == TB_KEY_BACKSPACE2) result = TB_KEY_BACKSPACE;
    if (result == TB_KEY_CARRIAGE_RETURN) result = TB_KEY_NEWLINE;
    found = true;
  }
  products.resize(2);
  products.at(0).push_back(result);
  products.at(1).push_back(found);
  break;
}

:(before "End Includes")
#include"termbox/termbox.h"