62:824ab7b28e3c | 63:0557babc8675 |
---|---|
41 #ifndef __COMMON_H__ | 41 #ifndef __COMMON_H__ |
42 #define __COMMON_H__ | 42 #define __COMMON_H__ |
43 | 43 |
44 #include <stdio.h> | 44 #include <stdio.h> |
45 #include <stdarg.h> | 45 #include <stdarg.h> |
46 #include <typeinfo> | |
47 #include <stdint.h> | 46 #include <stdint.h> |
48 #include "bots.h" | 47 #include "bots.h" |
49 #include "str.h" | 48 #include "str.h" |
50 | 49 |
51 // Application name and version | 50 // Application name and version |
98 extern int g_CurMode; | 97 extern int g_CurMode; |
99 extern str g_CurState; | 98 extern str g_CurState; |
100 #endif | 99 #endif |
101 | 100 |
102 // Power function | 101 // Power function |
103 template<class T> T pow (T a, int b) { | 102 template<class T> T pow (T a, unsigned int b) { |
104 if (!b) | 103 if (!b) |
105 return 1; | 104 return 1; |
106 | 105 |
107 T r = a; | 106 T r = a; |
108 while (b > 1) { | 107 while (b > 1) { |
109 b--; | 108 b--; |
110 | 109 r = r * a; |
111 // r *= a fails here with large numbers | |
112 r += a * a; | |
113 } | 110 } |
114 | 111 |
115 return r; | 112 return r; |
116 } | 113 } |
117 | 114 |
119 inline bool IsCharWhitespace (char c) { | 116 inline bool IsCharWhitespace (char c) { |
120 return (c <= 32 || c == 127 || c == 255); | 117 return (c <= 32 || c == 127 || c == 255); |
121 } | 118 } |
122 | 119 |
123 // Byte datatype | 120 // Byte datatype |
124 // typedef unsigned long int word; | |
125 typedef int32_t word; | 121 typedef int32_t word; |
126 typedef unsigned char byte; | 122 typedef unsigned char byte; |
127 | 123 |
128 // Keywords | 124 // Keywords |
129 #ifndef __MAIN_CXX__ | 125 #ifndef __MAIN_CXX__ |