backburn 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/Makefile +50 -0
- data/README.md +520 -0
- data/docs/cli-and-outputs.md +226 -0
- data/docs/technical-spec.md +656 -0
- data/exe/backburn +8 -0
- data/ext/backburn/extconf.rb +31 -0
- data/ext/backburn/prism/COMMIT +1 -0
- data/ext/backburn/prism/LICENSE.md +7 -0
- data/ext/backburn/prism/Makefile +213 -0
- data/ext/backburn/prism/include/prism/arena.h +45 -0
- data/ext/backburn/prism/include/prism/arena.hpp +42 -0
- data/ext/backburn/prism/include/prism/ast.h +10395 -0
- data/ext/backburn/prism/include/prism/ast.hpp +641 -0
- data/ext/backburn/prism/include/prism/buffer.h +60 -0
- data/ext/backburn/prism/include/prism/buffer.hpp +55 -0
- data/ext/backburn/prism/include/prism/comments.h +72 -0
- data/ext/backburn/prism/include/prism/compiler/accel.h +26 -0
- data/ext/backburn/prism/include/prism/compiler/align.h +36 -0
- data/ext/backburn/prism/include/prism/compiler/assume.h +25 -0
- data/ext/backburn/prism/include/prism/compiler/branch.h +26 -0
- data/ext/backburn/prism/include/prism/compiler/bswap.h +46 -0
- data/ext/backburn/prism/include/prism/compiler/cplusplus.hpp +16 -0
- data/ext/backburn/prism/include/prism/compiler/endianness.h +34 -0
- data/ext/backburn/prism/include/prism/compiler/exceptions.hpp +17 -0
- data/ext/backburn/prism/include/prism/compiler/exported.h +24 -0
- data/ext/backburn/prism/include/prism/compiler/fallthrough.h +22 -0
- data/ext/backburn/prism/include/prism/compiler/filesystem.h +32 -0
- data/ext/backburn/prism/include/prism/compiler/flex_array.h +19 -0
- data/ext/backburn/prism/include/prism/compiler/force_inline.h +21 -0
- data/ext/backburn/prism/include/prism/compiler/format.h +27 -0
- data/ext/backburn/prism/include/prism/compiler/inline.h +17 -0
- data/ext/backburn/prism/include/prism/compiler/lifetimebound.hpp +25 -0
- data/ext/backburn/prism/include/prism/compiler/nodiscard.h +22 -0
- data/ext/backburn/prism/include/prism/compiler/nonnull.h +18 -0
- data/ext/backburn/prism/include/prism/compiler/noreturn.h +24 -0
- data/ext/backburn/prism/include/prism/compiler/stack.h +60 -0
- data/ext/backburn/prism/include/prism/compiler/unused.h +18 -0
- data/ext/backburn/prism/include/prism/constant_pool.h +112 -0
- data/ext/backburn/prism/include/prism/diagnostic.h +121 -0
- data/ext/backburn/prism/include/prism/errors_format.h +63 -0
- data/ext/backburn/prism/include/prism/excludes.h +29 -0
- data/ext/backburn/prism/include/prism/integer.h +79 -0
- data/ext/backburn/prism/include/prism/internal/allocator.h +68 -0
- data/ext/backburn/prism/include/prism/internal/allocator_debug.h +88 -0
- data/ext/backburn/prism/include/prism/internal/arena.h +223 -0
- data/ext/backburn/prism/include/prism/internal/assert.h +14 -0
- data/ext/backburn/prism/include/prism/internal/bignum.h +239 -0
- data/ext/backburn/prism/include/prism/internal/bit.h +66 -0
- data/ext/backburn/prism/include/prism/internal/buffer.h +104 -0
- data/ext/backburn/prism/include/prism/internal/char.h +145 -0
- data/ext/backburn/prism/include/prism/internal/comments.h +54 -0
- data/ext/backburn/prism/include/prism/internal/constant_pool.h +155 -0
- data/ext/backburn/prism/include/prism/internal/diagnostic.h +392 -0
- data/ext/backburn/prism/include/prism/internal/double.h +19 -0
- data/ext/backburn/prism/include/prism/internal/encoding.h +326 -0
- data/ext/backburn/prism/include/prism/internal/integer.h +66 -0
- data/ext/backburn/prism/include/prism/internal/isinf.h +16 -0
- data/ext/backburn/prism/include/prism/internal/line_offset_list.h +50 -0
- data/ext/backburn/prism/include/prism/internal/list.h +62 -0
- data/ext/backburn/prism/include/prism/internal/magic_comments.h +23 -0
- data/ext/backburn/prism/include/prism/internal/memchr.h +15 -0
- data/ext/backburn/prism/include/prism/internal/node.h +197 -0
- data/ext/backburn/prism/include/prism/internal/oom.h +16 -0
- data/ext/backburn/prism/include/prism/internal/options.h +248 -0
- data/ext/backburn/prism/include/prism/internal/parser.h +1170 -0
- data/ext/backburn/prism/include/prism/internal/regexp.h +70 -0
- data/ext/backburn/prism/include/prism/internal/serialize.h +39 -0
- data/ext/backburn/prism/include/prism/internal/source.h +72 -0
- data/ext/backburn/prism/include/prism/internal/static_literals.h +60 -0
- data/ext/backburn/prism/include/prism/internal/stringy.h +37 -0
- data/ext/backburn/prism/include/prism/internal/strncasecmp.h +18 -0
- data/ext/backburn/prism/include/prism/internal/strpbrk.h +61 -0
- data/ext/backburn/prism/include/prism/internal/tokens.h +11 -0
- data/ext/backburn/prism/include/prism/internal/xxh3.h +16 -0
- data/ext/backburn/prism/include/prism/json.h +40 -0
- data/ext/backburn/prism/include/prism/line_offset_list.h +69 -0
- data/ext/backburn/prism/include/prism/magic_comments.h +53 -0
- data/ext/backburn/prism/include/prism/node.h +139 -0
- data/ext/backburn/prism/include/prism/node.hpp +272 -0
- data/ext/backburn/prism/include/prism/node_type.hpp +38 -0
- data/ext/backburn/prism/include/prism/options.h +393 -0
- data/ext/backburn/prism/include/prism/options.hpp +43 -0
- data/ext/backburn/prism/include/prism/parser.h +433 -0
- data/ext/backburn/prism/include/prism/parser.hpp +274 -0
- data/ext/backburn/prism/include/prism/prettyprint.h +39 -0
- data/ext/backburn/prism/include/prism/serialize.h +123 -0
- data/ext/backburn/prism/include/prism/source.h +163 -0
- data/ext/backburn/prism/include/prism/stream.h +36 -0
- data/ext/backburn/prism/include/prism/string_query.h +97 -0
- data/ext/backburn/prism/include/prism/stringy.h +61 -0
- data/ext/backburn/prism/include/prism/stringy.hpp +31 -0
- data/ext/backburn/prism/include/prism/version.h +46 -0
- data/ext/backburn/prism/include/prism.h +123 -0
- data/ext/backburn/prism/include/prism.hpp +24 -0
- data/ext/backburn/prism/src/arena.c +200 -0
- data/ext/backburn/prism/src/bignum.c +399 -0
- data/ext/backburn/prism/src/buffer.c +405 -0
- data/ext/backburn/prism/src/char.c +289 -0
- data/ext/backburn/prism/src/comments.c +455 -0
- data/ext/backburn/prism/src/constant_pool.c +410 -0
- data/ext/backburn/prism/src/diagnostic.c +918 -0
- data/ext/backburn/prism/src/double.c +394 -0
- data/ext/backburn/prism/src/encoding.c +1701 -0
- data/ext/backburn/prism/src/errors_format.c +650 -0
- data/ext/backburn/prism/src/integer.c +675 -0
- data/ext/backburn/prism/src/json.c +5745 -0
- data/ext/backburn/prism/src/line_offset_list.c +99 -0
- data/ext/backburn/prism/src/list.c +24 -0
- data/ext/backburn/prism/src/memchr.c +37 -0
- data/ext/backburn/prism/src/node.c +4464 -0
- data/ext/backburn/prism/src/options.c +475 -0
- data/ext/backburn/prism/src/parser.c +371 -0
- data/ext/backburn/prism/src/prettyprint.c +9038 -0
- data/ext/backburn/prism/src/prism.c +23615 -0
- data/ext/backburn/prism/src/regexp.c +3833 -0
- data/ext/backburn/prism/src/serialize.c +2656 -0
- data/ext/backburn/prism/src/source.c +525 -0
- data/ext/backburn/prism/src/static_literals.c +562 -0
- data/ext/backburn/prism/src/string_query.c +195 -0
- data/ext/backburn/prism/src/stringy.c +77 -0
- data/ext/backburn/prism/src/strncasecmp.c +37 -0
- data/ext/backburn/prism/src/strpbrk.c +465 -0
- data/ext/backburn/prism/src/tokens.c +724 -0
- data/ext/backburn/prism/src/xxh3.c +292 -0
- data/lib/backburn/version.rb +7 -0
- data/presets/devise.roots +11 -0
- data/presets/fast-mcp.roots +5 -0
- data/presets/graphql.roots +6 -0
- data/presets/phlex.roots +7 -0
- data/presets/pundit.roots +3 -0
- data/presets/rails-framework.roots +10 -0
- data/presets/rails.roots +83 -0
- data/presets/sidekiq.roots +4 -0
- data/presets/thor.roots +3 -0
- data/rails.roots +99 -0
- data/scripts/embed-presets.sh +13 -0
- data/scripts/version-h.sh +7 -0
- data/src/analysis/analysis.c +95 -0
- data/src/analysis/analysis.h +24 -0
- data/src/analysis/batches.c +127 -0
- data/src/analysis/batches.h +17 -0
- data/src/analysis/graph.c +238 -0
- data/src/analysis/graph.h +34 -0
- data/src/analysis/mark.c +300 -0
- data/src/analysis/mark.h +21 -0
- data/src/analysis/roots.c +229 -0
- data/src/analysis/roots.h +29 -0
- data/src/cli/cli.c +237 -0
- data/src/cli/cli.h +9 -0
- data/src/cli/config.c +112 -0
- data/src/cli/config.h +14 -0
- data/src/cli/options.c +17 -0
- data/src/cli/options.h +35 -0
- data/src/commands/commands.h +11 -0
- data/src/commands/explain.c +255 -0
- data/src/commands/gemfile.c +126 -0
- data/src/commands/gemfile.h +27 -0
- data/src/commands/gems.c +408 -0
- data/src/commands/init.c +92 -0
- data/src/commands/roots.c +82 -0
- data/src/commands/scan.c +91 -0
- data/src/core/intern.c +94 -0
- data/src/core/intern.h +40 -0
- data/src/core/json.c +17 -0
- data/src/core/json.h +9 -0
- data/src/core/model.c +25 -0
- data/src/core/model.h +85 -0
- data/src/core/util.c +116 -0
- data/src/core/util.h +48 -0
- data/src/index/erb.c +40 -0
- data/src/index/erb.h +9 -0
- data/src/index/haml.c +334 -0
- data/src/index/haml.h +10 -0
- data/src/index/indexer.c +702 -0
- data/src/index/indexer.h +19 -0
- data/src/index/walk.c +144 -0
- data/src/index/walk.h +14 -0
- data/src/main.c +81 -0
- data/src/output/baseline.c +101 -0
- data/src/output/baseline.h +15 -0
- data/src/output/report.c +440 -0
- data/src/output/report.h +28 -0
- metadata +231 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An implementation of the XXH3 hash function.
|
|
3
|
+
*
|
|
4
|
+
* The reason some of these names do not look quite like the style of the rest
|
|
5
|
+
* of the code in Prism is that this was adapted straight from the XXH3
|
|
6
|
+
* specification here:
|
|
7
|
+
*
|
|
8
|
+
* https://github.com/Cyan4973/xxHash/blob/release/doc/xxhash_spec.md
|
|
9
|
+
*
|
|
10
|
+
* To better understand this code it is recommended to read the XXH3
|
|
11
|
+
* specification linked above, where you should be able to follow along with
|
|
12
|
+
* this implementation more easily. Note this only implements the XXH3_64
|
|
13
|
+
* variant with the default secret and a seed of 0. Additionally it does not
|
|
14
|
+
* include a lot of the various CPU-specific optimizations that exist in the
|
|
15
|
+
* reference implementation.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include "prism/internal/xxh3.h"
|
|
19
|
+
|
|
20
|
+
#include "prism/compiler/accel.h"
|
|
21
|
+
#include "prism/compiler/bswap.h"
|
|
22
|
+
#include "prism/compiler/endianness.h"
|
|
23
|
+
|
|
24
|
+
#include <string.h>
|
|
25
|
+
|
|
26
|
+
#if defined(PRISM_HAS_NEON) && defined(PRISM_LITTLE_ENDIAN_COMPTIME)
|
|
27
|
+
#include <arm_neon.h>
|
|
28
|
+
#define XXH3_NEON
|
|
29
|
+
#elif defined(PRISM_HAS_SSE2)
|
|
30
|
+
#include <emmintrin.h>
|
|
31
|
+
#define XXH3_SSE2
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
#if defined(__SIZEOF_INT128__)
|
|
35
|
+
static uint64_t
|
|
36
|
+
XXH3_mul128_fold64(uint64_t lhs, uint64_t rhs) {
|
|
37
|
+
__uint128_t x = (__uint128_t) lhs * (__uint128_t) rhs;
|
|
38
|
+
return ((uint64_t) (x & 0xFFFFFFFFFFFFFFFFULL)) ^ ((uint64_t) (x >> 64));
|
|
39
|
+
}
|
|
40
|
+
#else
|
|
41
|
+
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64))
|
|
42
|
+
#include <intrin.h>
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
static uint64_t
|
|
46
|
+
XXH3_mul128_fold64(uint64_t lhs, uint64_t rhs) {
|
|
47
|
+
uint64_t lo, hi;
|
|
48
|
+
#if defined(_MSC_VER) && defined(_M_X64)
|
|
49
|
+
lo = _umul128(lhs, rhs, &hi);
|
|
50
|
+
#elif defined(_MSC_VER) && defined(_M_ARM64)
|
|
51
|
+
hi = __umulh(lhs, rhs);
|
|
52
|
+
lo = lhs * rhs;
|
|
53
|
+
#else
|
|
54
|
+
uint64_t lo_lo = (lhs & 0xFFFFFFFF) * (rhs & 0xFFFFFFFF);
|
|
55
|
+
uint64_t hi_lo = (lhs >> 32) * (rhs & 0xFFFFFFFF);
|
|
56
|
+
uint64_t lo_hi = (lhs & 0xFFFFFFFF) * (rhs >> 32);
|
|
57
|
+
uint64_t hi_hi = (lhs >> 32) * (rhs >> 32);
|
|
58
|
+
|
|
59
|
+
uint64_t cross = (lo_lo >> 32) + (hi_lo & 0xFFFFFFFF) + lo_hi;
|
|
60
|
+
hi = hi_hi + (hi_lo >> 32) + (cross >> 32);
|
|
61
|
+
lo = (cross << 32) | (lo_lo & 0xFFFFFFFF);
|
|
62
|
+
#endif
|
|
63
|
+
return lo ^ hi;
|
|
64
|
+
}
|
|
65
|
+
#endif
|
|
66
|
+
|
|
67
|
+
static uint32_t
|
|
68
|
+
read32(const void* ptr) {
|
|
69
|
+
uint32_t val;
|
|
70
|
+
memcpy(&val, ptr, sizeof(val));
|
|
71
|
+
if (!PRISM_LITTLE_ENDIAN_RUNTIME) {
|
|
72
|
+
val = pm_bswap32(val);
|
|
73
|
+
}
|
|
74
|
+
return val;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static uint64_t
|
|
78
|
+
read64(const void* ptr) {
|
|
79
|
+
uint64_t val;
|
|
80
|
+
memcpy(&val, ptr, sizeof(val));
|
|
81
|
+
if (!PRISM_LITTLE_ENDIAN_RUNTIME) {
|
|
82
|
+
val = pm_bswap64(val);
|
|
83
|
+
}
|
|
84
|
+
return val;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static const uint64_t PRIME32_1 = 0x9E3779B1U;
|
|
88
|
+
static const uint64_t PRIME32_2 = 0x85EBCA77U;
|
|
89
|
+
static const uint64_t PRIME32_3 = 0xC2B2AE3DU;
|
|
90
|
+
static const uint64_t PRIME64_1 = 0x9E3779B185EBCA87ULL;
|
|
91
|
+
static const uint64_t PRIME64_2 = 0xC2B2AE3D27D4EB4FULL;
|
|
92
|
+
static const uint64_t PRIME64_3 = 0x165667B19E3779F9ULL;
|
|
93
|
+
static const uint64_t PRIME64_4 = 0x85EBCA77C2B2AE63ULL;
|
|
94
|
+
static const uint64_t PRIME64_5 = 0x27D4EB2F165667C5ULL;
|
|
95
|
+
static const uint64_t PRIME_MX1 = 0x165667919E3779F9ULL;
|
|
96
|
+
static const uint64_t PRIME_MX2 = 0x9FB21C651E98DF25ULL;
|
|
97
|
+
|
|
98
|
+
static const uint8_t secret[192] = {
|
|
99
|
+
0xb8, 0xfe, 0x6c, 0x39, 0x23, 0xa4, 0x4b, 0xbe, 0x7c, 0x01, 0x81, 0x2c, 0xf7, 0x21, 0xad, 0x1c,
|
|
100
|
+
0xde, 0xd4, 0x6d, 0xe9, 0x83, 0x90, 0x97, 0xdb, 0x72, 0x40, 0xa4, 0xa4, 0xb7, 0xb3, 0x67, 0x1f,
|
|
101
|
+
0xcb, 0x79, 0xe6, 0x4e, 0xcc, 0xc0, 0xe5, 0x78, 0x82, 0x5a, 0xd0, 0x7d, 0xcc, 0xff, 0x72, 0x21,
|
|
102
|
+
0xb8, 0x08, 0x46, 0x74, 0xf7, 0x43, 0x24, 0x8e, 0xe0, 0x35, 0x90, 0xe6, 0x81, 0x3a, 0x26, 0x4c,
|
|
103
|
+
0x3c, 0x28, 0x52, 0xbb, 0x91, 0xc3, 0x00, 0xcb, 0x88, 0xd0, 0x65, 0x8b, 0x1b, 0x53, 0x2e, 0xa3,
|
|
104
|
+
0x71, 0x64, 0x48, 0x97, 0xa2, 0x0d, 0xf9, 0x4e, 0x38, 0x19, 0xef, 0x46, 0xa9, 0xde, 0xac, 0xd8,
|
|
105
|
+
0xa8, 0xfa, 0x76, 0x3f, 0xe3, 0x9c, 0x34, 0x3f, 0xf9, 0xdc, 0xbb, 0xc7, 0xc7, 0x0b, 0x4f, 0x1d,
|
|
106
|
+
0x8a, 0x51, 0xe0, 0x4b, 0xcd, 0xb4, 0x59, 0x31, 0xc8, 0x9f, 0x7e, 0xc9, 0xd9, 0x78, 0x73, 0x64,
|
|
107
|
+
0xea, 0xc5, 0xac, 0x83, 0x34, 0xd3, 0xeb, 0xc3, 0xc5, 0x81, 0xa0, 0xff, 0xfa, 0x13, 0x63, 0xeb,
|
|
108
|
+
0x17, 0x0d, 0xdd, 0x51, 0xb7, 0xf0, 0xda, 0x49, 0xd3, 0x16, 0x55, 0x26, 0x29, 0xd4, 0x68, 0x9e,
|
|
109
|
+
0x2b, 0x16, 0xbe, 0x58, 0x7d, 0x47, 0xa1, 0xfc, 0x8f, 0xf8, 0xb8, 0xd1, 0x7a, 0xd0, 0x31, 0xce,
|
|
110
|
+
0x45, 0xcb, 0x3a, 0x8f, 0x95, 0x16, 0x04, 0x28, 0xaf, 0xd7, 0xfb, 0xca, 0xbb, 0x4b, 0x40, 0x7e,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
static uint64_t
|
|
114
|
+
avalanche(uint64_t x) {
|
|
115
|
+
x ^= (x >> 37);
|
|
116
|
+
x *= PRIME_MX1;
|
|
117
|
+
x ^= (x >> 32);
|
|
118
|
+
return x;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static uint64_t
|
|
122
|
+
avalanche_XXH64(uint64_t x) {
|
|
123
|
+
x ^= (x >> 33);
|
|
124
|
+
x *= PRIME64_2;
|
|
125
|
+
x ^= (x >> 29);
|
|
126
|
+
x *= PRIME64_3;
|
|
127
|
+
x ^= (x >> 32);
|
|
128
|
+
return x;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
static uint64_t
|
|
132
|
+
XXH3_64_empty(void) {
|
|
133
|
+
return avalanche_XXH64(read64(secret + 56) ^ read64(secret + 64));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static uint64_t
|
|
137
|
+
XXH3_64_1to3(const uint8_t *input, size_t length) {
|
|
138
|
+
uint32_t combined = (uint32_t) input[length - 1] | ((uint32_t) length << 8) | ((uint32_t) input[0] << 16) | ((uint32_t) input[length >> 1] << 24);
|
|
139
|
+
return avalanche_XXH64((uint64_t) (read32(secret) ^ read32(secret + 4)) ^ (uint64_t) combined);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
static uint64_t
|
|
143
|
+
XXH3_64_4to8(const uint8_t *input, size_t length) {
|
|
144
|
+
#define rot(x_, r_) (((x_) << (r_)) | ((x_) >> (64 - (r_))))
|
|
145
|
+
|
|
146
|
+
uint64_t combined = (uint64_t) read32(input + length - 4) | ((uint64_t) read32(input) << 32);
|
|
147
|
+
uint64_t value = (read64(secret + 8) ^ read64(secret + 16)) ^ combined;
|
|
148
|
+
value ^= rot(value, 49) ^ rot(value, 24);
|
|
149
|
+
value *= PRIME_MX2;
|
|
150
|
+
value ^= ((value >> 35) + length);
|
|
151
|
+
value *= PRIME_MX2;
|
|
152
|
+
value ^= (value >> 28);
|
|
153
|
+
return value;
|
|
154
|
+
|
|
155
|
+
#undef rot
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
static uint64_t
|
|
159
|
+
XXH3_64_9to16(const uint8_t *input, size_t length) {
|
|
160
|
+
uint64_t lo = (read64(secret + 24) ^ read64(secret + 32)) ^ read64(input);
|
|
161
|
+
uint64_t hi = (read64(secret + 40) ^ read64(secret + 48)) ^ read64(input + length - 8);
|
|
162
|
+
return avalanche(length + pm_bswap64(lo) + hi + XXH3_mul128_fold64(lo, hi));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
static uint64_t
|
|
166
|
+
XXH3_64_17to240(const uint8_t *input, size_t length) {
|
|
167
|
+
#define mix(data_, offset_) XXH3_mul128_fold64(read64((data_)) ^ read64(secret + (offset_)), read64((data_) + 8) ^ read64(secret + (offset_) + 8))
|
|
168
|
+
|
|
169
|
+
uint64_t acc = length * PRIME64_1;
|
|
170
|
+
|
|
171
|
+
if (length <= 128) {
|
|
172
|
+
size_t idx = (length - 1) / 32;
|
|
173
|
+
do {
|
|
174
|
+
acc += mix(input + idx * 16, idx * 32) + mix(input + length - idx * 16 - 16, idx * 32 + 16);
|
|
175
|
+
} while (idx--);
|
|
176
|
+
} else {
|
|
177
|
+
for (size_t idx = 0; idx < 8; idx++) {
|
|
178
|
+
acc += mix(input + idx * 16, idx * 16);
|
|
179
|
+
}
|
|
180
|
+
acc = avalanche(acc);
|
|
181
|
+
for (size_t idx = 8; idx < length >> 4; idx++) {
|
|
182
|
+
acc += mix(input + idx * 16, (idx - 8) * 16 + 3);
|
|
183
|
+
}
|
|
184
|
+
acc += mix(input + length - 16, 119);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return avalanche(acc);
|
|
188
|
+
|
|
189
|
+
#undef mix
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
static void
|
|
193
|
+
accumulate(uint64_t acc[8], const uint8_t *stripe, size_t secret_offset) {
|
|
194
|
+
#if defined(XXH3_NEON)
|
|
195
|
+
for (int idx = 0; idx < 8; idx += 2) {
|
|
196
|
+
uint64x2_t data = vreinterpretq_u64_u8(vld1q_u8(stripe + 8 * idx));
|
|
197
|
+
uint64x2_t value = veorq_u64(data, vreinterpretq_u64_u8(vld1q_u8(secret + secret_offset + 8 * idx)));
|
|
198
|
+
uint64x2_t product = vmull_u32(vmovn_u64(value), vshrn_n_u64(value, 32));
|
|
199
|
+
vst1q_u64(acc + idx, vaddq_u64(vld1q_u64(acc + idx), vaddq_u64(vextq_u64(data, data, 1), product)));
|
|
200
|
+
}
|
|
201
|
+
#elif defined(XXH3_SSE2)
|
|
202
|
+
for (int idx = 0; idx < 8; idx += 2) {
|
|
203
|
+
__m128i data = _mm_loadu_si128((const __m128i *) (stripe + 8 * idx));
|
|
204
|
+
__m128i value = _mm_xor_si128(data, _mm_loadu_si128((const __m128i *) (secret + secret_offset + 8 * idx)));
|
|
205
|
+
__m128i product = _mm_mul_epu32(value, _mm_shuffle_epi32(value, _MM_SHUFFLE(0, 3, 0, 1)));
|
|
206
|
+
_mm_storeu_si128((__m128i *) (acc + idx), _mm_add_epi64(_mm_loadu_si128((const __m128i *) (acc + idx)), _mm_add_epi64(_mm_shuffle_epi32(data, _MM_SHUFFLE(1, 0, 3, 2)), product)));
|
|
207
|
+
}
|
|
208
|
+
#else
|
|
209
|
+
for (int idx = 0; idx < 8; idx++) {
|
|
210
|
+
uint64_t data = read64(stripe + 8 * idx);
|
|
211
|
+
uint64_t value = data ^ read64(secret + secret_offset + 8 * idx);
|
|
212
|
+
acc[idx ^ 1] = acc[idx ^ 1] + data;
|
|
213
|
+
acc[idx] += (value & 0xFFFFFFFF) * (value >> 32);
|
|
214
|
+
}
|
|
215
|
+
#endif
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
static uint64_t
|
|
219
|
+
XXH3_64_large(const uint8_t *input, size_t length) {
|
|
220
|
+
const size_t secret_length = sizeof(secret);
|
|
221
|
+
const size_t stripes_per_block = (secret_length - 64) / 8;
|
|
222
|
+
const size_t block_size = 64 * stripes_per_block;
|
|
223
|
+
const size_t block_count = (length - 1) / block_size;
|
|
224
|
+
const size_t last_offset = block_count * block_size;
|
|
225
|
+
|
|
226
|
+
uint64_t acc[8] = {
|
|
227
|
+
PRIME32_3, PRIME64_1, PRIME64_2, PRIME64_3,
|
|
228
|
+
PRIME64_4, PRIME32_2, PRIME64_5, PRIME32_1
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
for (size_t block_idx = 0; block_idx < block_count; block_idx++) {
|
|
232
|
+
const uint8_t *block = input + block_idx * block_size;
|
|
233
|
+
|
|
234
|
+
for (size_t stripe_idx = 0; stripe_idx < stripes_per_block; stripe_idx++) {
|
|
235
|
+
accumulate(acc, block + stripe_idx * 64, stripe_idx * 8);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
#if defined(XXH3_NEON)
|
|
239
|
+
const uint32x2_t prime = vdup_n_u32((uint32_t) PRIME32_1);
|
|
240
|
+
for (size_t idx = 0; idx < 8; idx += 2) {
|
|
241
|
+
uint64x2_t value = vld1q_u64(acc + idx);
|
|
242
|
+
value = veorq_u64(value, vshrq_n_u64(value, 47));
|
|
243
|
+
value = veorq_u64(value, vreinterpretq_u64_u8(vld1q_u8(secret + secret_length - 64 + idx * 8)));
|
|
244
|
+
vst1q_u64(acc + idx, vaddq_u64(vmull_u32(vmovn_u64(value), prime), vshlq_n_u64(vmull_u32(vshrn_n_u64(value, 32), prime), 32)));
|
|
245
|
+
}
|
|
246
|
+
#elif defined(XXH3_SSE2)
|
|
247
|
+
const __m128i prime = _mm_set1_epi32((int) (uint32_t) PRIME32_1);
|
|
248
|
+
for (size_t idx = 0; idx < 8; idx += 2) {
|
|
249
|
+
__m128i value = _mm_loadu_si128((const __m128i *) (acc + idx));
|
|
250
|
+
value = _mm_xor_si128(value, _mm_srli_epi64(value, 47));
|
|
251
|
+
value = _mm_xor_si128(value, _mm_loadu_si128((const __m128i *) (secret + secret_length - 64 + idx * 8)));
|
|
252
|
+
_mm_storeu_si128((__m128i *) (acc + idx), _mm_add_epi64(_mm_mul_epu32(value, prime), _mm_slli_epi64(_mm_mul_epu32(_mm_shuffle_epi32(value, _MM_SHUFFLE(0, 3, 0, 1)), prime), 32)));
|
|
253
|
+
}
|
|
254
|
+
#else
|
|
255
|
+
for (size_t idx = 0; idx < 8; idx++) {
|
|
256
|
+
acc[idx] ^= (acc[idx] >> 47);
|
|
257
|
+
acc[idx] ^= read64(secret + secret_length - 64 + idx * 8);
|
|
258
|
+
acc[idx] *= PRIME32_1;
|
|
259
|
+
}
|
|
260
|
+
#endif
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
for (size_t stripe_idx = 0; stripe_idx < (length - last_offset - 1) / 64; stripe_idx++) {
|
|
264
|
+
accumulate(acc, input + last_offset + stripe_idx * 64, stripe_idx * 8);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
accumulate(acc, input + length - 64, secret_length - 71);
|
|
268
|
+
|
|
269
|
+
uint64_t result = (uint64_t) length * PRIME64_1;
|
|
270
|
+
for (size_t idx = 0; idx < 4; idx++) {
|
|
271
|
+
result += XXH3_mul128_fold64(acc[idx * 2] ^ read64(secret + 11 + 16 * idx), acc[idx * 2 + 1] ^ read64(secret + 11 + 16 * idx + 8));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return avalanche(result);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
uint64_t
|
|
278
|
+
pm_xxh3(const uint8_t *input, size_t length) {
|
|
279
|
+
if (length == 0) {
|
|
280
|
+
return XXH3_64_empty();
|
|
281
|
+
} else if (length <= 3) {
|
|
282
|
+
return XXH3_64_1to3(input, length);
|
|
283
|
+
} else if (length <= 8) {
|
|
284
|
+
return XXH3_64_4to8(input, length);
|
|
285
|
+
} else if (length <= 16) {
|
|
286
|
+
return XXH3_64_9to16(input, length);
|
|
287
|
+
} else if (length <= 240) {
|
|
288
|
+
return XXH3_64_17to240(input, length);
|
|
289
|
+
} else {
|
|
290
|
+
return XXH3_64_large(input, length);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Preset `devise`: Devise calls these hooks on your controllers, often protected or private ones.
|
|
2
|
+
< Devise::*Controller
|
|
3
|
+
< DeviseController
|
|
4
|
+
*Controller#after_sign_in_path_for
|
|
5
|
+
*Controller#after_sign_out_path_for
|
|
6
|
+
*Controller#after_sign_up_path_for
|
|
7
|
+
*Controller#after_inactive_sign_up_path_for
|
|
8
|
+
*Controller#after_update_path_for
|
|
9
|
+
*Controller#after_confirmation_path_for
|
|
10
|
+
*Controller#after_resetting_password_path_for
|
|
11
|
+
*Controller#configure_permitted_parameters
|
data/presets/phlex.roots
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Entry points of the Rails framework itself, layered on --public-api.
|
|
2
|
+
# Generators and commands are looked up by name (`rails generate model`, `rails server`),
|
|
3
|
+
# and Thor runs every public method of a generator in order.
|
|
4
|
+
< Rails::Generators::Base
|
|
5
|
+
< Rails::Command::Base
|
|
6
|
+
< Thor::Group
|
|
7
|
+
< Thor
|
|
8
|
+
# Bug-report templates and app templates are run as scripts.
|
|
9
|
+
path:guides/*
|
|
10
|
+
path:*/templates/*
|
data/presets/rails.roots
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Preset `rails`: entry points Rails and its common companions call by convention.
|
|
2
|
+
|
|
3
|
+
# --- Rails core
|
|
4
|
+
public < ActionController::Base
|
|
5
|
+
public < ActionController::API
|
|
6
|
+
public *Controller#*
|
|
7
|
+
public < ActionMailer::Base
|
|
8
|
+
< ActiveJob::Base
|
|
9
|
+
< ActiveRecord::Migration
|
|
10
|
+
< ActiveModel::*Validator
|
|
11
|
+
< Rails::Application
|
|
12
|
+
< Rails::Engine
|
|
13
|
+
*Helper
|
|
14
|
+
*Controller
|
|
15
|
+
*Job
|
|
16
|
+
*Mailer
|
|
17
|
+
path:db/migrate/*
|
|
18
|
+
path:db/seeds.rb
|
|
19
|
+
path:config/*
|
|
20
|
+
path:lib/tasks/*
|
|
21
|
+
path:*/db/migrate/*
|
|
22
|
+
path:*/config/*
|
|
23
|
+
path:*/lib/tasks/*
|
|
24
|
+
path:*.rake
|
|
25
|
+
|
|
26
|
+
# --- errors are raised by class name, rescued by class name; their methods are hooks
|
|
27
|
+
< StandardError
|
|
28
|
+
< *Error
|
|
29
|
+
< Exception
|
|
30
|
+
|
|
31
|
+
# --- admin (Avo) and maintenance tasks
|
|
32
|
+
< Avo::*
|
|
33
|
+
public < MaintenanceTasks::Task
|
|
34
|
+
|
|
35
|
+
# --- tests are roots for what they define (helpers, setup)
|
|
36
|
+
path:test/*
|
|
37
|
+
path:spec/*
|
|
38
|
+
|
|
39
|
+
# --- hooks Rails and common gems call by name
|
|
40
|
+
*.table_name_prefix
|
|
41
|
+
*#to_xml
|
|
42
|
+
*#as_json
|
|
43
|
+
*#serializable_hash
|
|
44
|
+
*.matches?
|
|
45
|
+
*#matches?
|
|
46
|
+
*#pundit_user
|
|
47
|
+
*#append_info_to_payload
|
|
48
|
+
*#search_data
|
|
49
|
+
< ActiveModel::Type::*
|
|
50
|
+
< ActiveRecord::Type::*
|
|
51
|
+
< RuboCop::Cop::*
|
|
52
|
+
|
|
53
|
+
# --- scripts are run by hand
|
|
54
|
+
path:script/*
|
|
55
|
+
path:bin/*
|
|
56
|
+
|
|
57
|
+
# --- Ruby's own protocols: IO-like and conversion objects are called by the standard library
|
|
58
|
+
*#readpartial
|
|
59
|
+
*#read
|
|
60
|
+
*#write
|
|
61
|
+
*#to_str
|
|
62
|
+
*#to_ary
|
|
63
|
+
*#to_proc
|
|
64
|
+
*#coerce
|
|
65
|
+
*#respond_to_missing?
|
|
66
|
+
|
|
67
|
+
# --- Action Cable
|
|
68
|
+
public < ActionCable::Channel::Base
|
|
69
|
+
< ActionCable::Connection::Base
|
|
70
|
+
|
|
71
|
+
# --- ActiveModel class-level hooks
|
|
72
|
+
*.human_attribute_name
|
|
73
|
+
*.model_name
|
|
74
|
+
|
|
75
|
+
# --- Action Mailbox: Rails names ApplicationMailbox and routes to its subclasses
|
|
76
|
+
< ActionMailbox::Base
|
|
77
|
+
|
|
78
|
+
# --- protocols Rails calls on your objects: `render item`, table-name prefixes on namespace modules
|
|
79
|
+
*#to_partial_path
|
|
80
|
+
*.to_partial_path
|
|
81
|
+
*#table_name_prefix
|
|
82
|
+
*.table_name_suffix
|
|
83
|
+
*#table_name_suffix
|
data/presets/thor.roots
ADDED
data/rails.roots
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Entry points the framework calls by convention. This file is the tool's only Rails knowledge.
|
|
2
|
+
#
|
|
3
|
+
# Pattern matches a qualified name: Class#instance_method, Class.class_method, Namespace::Class
|
|
4
|
+
# public Pattern only public methods
|
|
5
|
+
# < Superclass every class that inherits (directly or not) from Superclass, and all its methods
|
|
6
|
+
# public < Superclass ... and only its public methods
|
|
7
|
+
# path:glob everything defined in matching files
|
|
8
|
+
|
|
9
|
+
# --- Rails core
|
|
10
|
+
public < ActionController::Base
|
|
11
|
+
public < ActionController::API
|
|
12
|
+
public *Controller#*
|
|
13
|
+
public < ActionMailer::Base
|
|
14
|
+
< ActiveJob::Base
|
|
15
|
+
< ActiveRecord::Migration
|
|
16
|
+
< ActiveModel::*Validator
|
|
17
|
+
< Rails::Application
|
|
18
|
+
< Rails::Engine
|
|
19
|
+
*Helper
|
|
20
|
+
*Controller
|
|
21
|
+
*Job
|
|
22
|
+
*Mailer
|
|
23
|
+
path:db/migrate/*
|
|
24
|
+
path:db/seeds.rb
|
|
25
|
+
path:config/*
|
|
26
|
+
path:lib/tasks/*
|
|
27
|
+
|
|
28
|
+
# --- errors are raised by class name, rescued by class name; their methods are hooks
|
|
29
|
+
< StandardError
|
|
30
|
+
< *Error
|
|
31
|
+
< Exception
|
|
32
|
+
|
|
33
|
+
# --- view components (Phlex, ViewComponent)
|
|
34
|
+
< Phlex::*
|
|
35
|
+
< ViewComponent::Base
|
|
36
|
+
*Component#view_template
|
|
37
|
+
*Component#call
|
|
38
|
+
*Component#before_template
|
|
39
|
+
*Component#render?
|
|
40
|
+
|
|
41
|
+
# --- authorization (Pundit)
|
|
42
|
+
public < *ApplicationPolicy
|
|
43
|
+
public < *ApplicationPolicy::Scope
|
|
44
|
+
|
|
45
|
+
# --- admin (Avo) and maintenance tasks
|
|
46
|
+
< Avo::*
|
|
47
|
+
public < MaintenanceTasks::Task
|
|
48
|
+
|
|
49
|
+
# --- tests are roots for what they define (helpers, setup)
|
|
50
|
+
path:test/*
|
|
51
|
+
path:spec/*
|
|
52
|
+
|
|
53
|
+
# --- hooks Rails and common gems call by name
|
|
54
|
+
*.table_name_prefix
|
|
55
|
+
*#to_xml
|
|
56
|
+
*#as_json
|
|
57
|
+
*#serializable_hash
|
|
58
|
+
*.matches?
|
|
59
|
+
*#matches?
|
|
60
|
+
*#pundit_user
|
|
61
|
+
*#append_info_to_payload
|
|
62
|
+
*#search_data
|
|
63
|
+
< ActiveModel::Type::*
|
|
64
|
+
< ActiveRecord::Type::*
|
|
65
|
+
< RuboCop::Cop::*
|
|
66
|
+
|
|
67
|
+
# --- background workers marked by a mixin rather than a superclass
|
|
68
|
+
< Shoryuken::Worker
|
|
69
|
+
< Sidekiq::Job
|
|
70
|
+
< Sidekiq::Worker
|
|
71
|
+
|
|
72
|
+
# --- scripts are run by hand
|
|
73
|
+
path:script/*
|
|
74
|
+
path:bin/*
|
|
75
|
+
|
|
76
|
+
# --- Ruby's own protocols: IO-like and conversion objects are called by the standard library
|
|
77
|
+
*#readpartial
|
|
78
|
+
*#read
|
|
79
|
+
*#write
|
|
80
|
+
*#to_str
|
|
81
|
+
*#to_ary
|
|
82
|
+
*#to_proc
|
|
83
|
+
*#coerce
|
|
84
|
+
*#respond_to_missing?
|
|
85
|
+
|
|
86
|
+
# --- Action Cable
|
|
87
|
+
public < ActionCable::Channel::Base
|
|
88
|
+
< ActionCable::Connection::Base
|
|
89
|
+
|
|
90
|
+
# --- GraphQL-ruby: the schema calls types, mutations, resolvers and scalars by convention
|
|
91
|
+
public < GraphQL::Schema
|
|
92
|
+
public < GraphQL::Schema::*
|
|
93
|
+
< GraphQL::Dataloader::Source
|
|
94
|
+
*.resolve_type
|
|
95
|
+
*#resolve_type
|
|
96
|
+
|
|
97
|
+
# --- ActiveModel class-level hooks
|
|
98
|
+
*.human_attribute_name
|
|
99
|
+
*.model_name
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Compiles presets/*.roots into presets.h so a single backburn binary works anywhere.
|
|
3
|
+
set -e
|
|
4
|
+
echo "/* Generated by scripts/embed-presets.sh from the presets directory. Do not edit. */"
|
|
5
|
+
echo "static const struct { const char *name; const char *text; } PRESETS[] = {"
|
|
6
|
+
for f in "$@"; do
|
|
7
|
+
name=$(basename "$f" .roots)
|
|
8
|
+
printf ' {"%s",\n' "$name"
|
|
9
|
+
awk '{ gsub(/\\/, "\\\\"); gsub(/"/, "\\\""); printf " \"%s\\n\"\n", $0 }' "$f"
|
|
10
|
+
printf ' },\n'
|
|
11
|
+
done
|
|
12
|
+
echo " {0, 0}"
|
|
13
|
+
echo "};"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Generates version.h from lib/backburn/version.rb, the only version source.
|
|
3
|
+
set -e
|
|
4
|
+
version=$(sed -n 's/^ *VERSION *= *"\([^"]*\)".*/\1/p' "$1")
|
|
5
|
+
test -n "$version" || { echo "version-h.sh: no VERSION in $1" >&2; exit 1; }
|
|
6
|
+
echo "/* Generated by scripts/version-h.sh from $1. Do not edit. */"
|
|
7
|
+
echo "#define BACKBURN_VERSION \"$version\""
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* The analysis pipeline, definition ordering, and stable ids. */
|
|
2
|
+
|
|
3
|
+
#include "analysis/analysis.h"
|
|
4
|
+
#include "core/intern.h"
|
|
5
|
+
#include "core/model.h"
|
|
6
|
+
#include "cli/options.h"
|
|
7
|
+
#include "index/walk.h"
|
|
8
|
+
#include "analysis/graph.h"
|
|
9
|
+
#include "analysis/roots.h"
|
|
10
|
+
#include "analysis/mark.h"
|
|
11
|
+
#include "analysis/batches.h"
|
|
12
|
+
|
|
13
|
+
uint32_t *FILE_RANK; /* files sorted by path */
|
|
14
|
+
|
|
15
|
+
int def_loc_cmp(uint32_t a, uint32_t b) {
|
|
16
|
+
const def_t *x = &D.a[a], *y = &D.a[b];
|
|
17
|
+
if (x->file != y->file) return FILE_RANK[x->file] < FILE_RANK[y->file] ? -1 : 1;
|
|
18
|
+
if (x->line != y->line) return x->line < y->line ? -1 : 1;
|
|
19
|
+
return a < b ? -1 : a > b;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
int def_loc_qcmp(const void *a, const void *b) { return def_loc_cmp(*(const uint32_t *) a, *(const uint32_t *) b); }
|
|
23
|
+
|
|
24
|
+
char *ROOT_ABS;
|
|
25
|
+
|
|
26
|
+
double ELAPSED_MS;
|
|
27
|
+
|
|
28
|
+
size_t NREFS;
|
|
29
|
+
|
|
30
|
+
static int file_rank_cmp(const void *a, const void *b) {
|
|
31
|
+
return strcmp(FILES.a[*(const uint32_t *) a], FILES.a[*(const uint32_t *) b]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
void analyse(void) {
|
|
35
|
+
double t0 = now_ms();
|
|
36
|
+
index_tree(O.root);
|
|
37
|
+
place_singleton_defs();
|
|
38
|
+
build_name_indexes();
|
|
39
|
+
expand_patterns();
|
|
40
|
+
NREFS = 0;
|
|
41
|
+
for (size_t i = 0; i < D.n; i++) {
|
|
42
|
+
dedupe_refs(&D.a[i]);
|
|
43
|
+
NREFS += D.a[i].refs.n;
|
|
44
|
+
}
|
|
45
|
+
index_classes();
|
|
46
|
+
resolve_mixins();
|
|
47
|
+
prepare_roots();
|
|
48
|
+
mark();
|
|
49
|
+
mark_namespaces();
|
|
50
|
+
mark_uncertain();
|
|
51
|
+
classify();
|
|
52
|
+
uint32_t *order = xcalloc(FILES.n + 1, sizeof *order);
|
|
53
|
+
for (uint32_t f = 0; f < FILES.n; f++) order[f] = f;
|
|
54
|
+
qsort(order, FILES.n, sizeof *order, file_rank_cmp);
|
|
55
|
+
FILE_RANK = xcalloc(FILES.n + 1, sizeof *FILE_RANK);
|
|
56
|
+
for (uint32_t r = 0; r < FILES.n; r++) FILE_RANK[order[r]] = r;
|
|
57
|
+
free(order);
|
|
58
|
+
build_batches();
|
|
59
|
+
ELAPSED_MS = now_ms() - t0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static uint8_t *ID_MULTI; /* per def: its (kind word, qual) is defined in several files */
|
|
63
|
+
|
|
64
|
+
void compute_ids(void) {
|
|
65
|
+
ID_MULTI = xcalloc(D.n + 1, 1);
|
|
66
|
+
int32_t *first[4];
|
|
67
|
+
for (int k = 0; k < 4; k++) {
|
|
68
|
+
first[k] = xcalloc(NN + 1, sizeof *first[k]);
|
|
69
|
+
for (uint32_t j = 0; j <= NN; j++) first[k][j] = -1;
|
|
70
|
+
}
|
|
71
|
+
uint8_t *multi[4];
|
|
72
|
+
for (int k = 0; k < 4; k++) multi[k] = xcalloc(NN + 1, 1);
|
|
73
|
+
for (size_t i = 1; i < D.n; i++) {
|
|
74
|
+
const def_t *d = &D.a[i];
|
|
75
|
+
int k = is_meth(d->kind) ? 0 : d->kind == K_CLASS ? 1 : d->kind == K_MODULE ? 2 : 3;
|
|
76
|
+
if (first[k][d->qual] < 0) first[k][d->qual] = (int32_t) d->file;
|
|
77
|
+
else if ((uint32_t) first[k][d->qual] != d->file) multi[k][d->qual] = 1;
|
|
78
|
+
}
|
|
79
|
+
for (size_t i = 1; i < D.n; i++) {
|
|
80
|
+
const def_t *d = &D.a[i];
|
|
81
|
+
int k = is_meth(d->kind) ? 0 : d->kind == K_CLASS ? 1 : d->kind == K_MODULE ? 2 : 3;
|
|
82
|
+
ID_MULTI[i] = multi[k][d->qual];
|
|
83
|
+
}
|
|
84
|
+
for (int k = 0; k < 4; k++) free(first[k]), free(multi[k]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void def_id(sbuf *b, uint32_t i) {
|
|
88
|
+
const def_t *d = &D.a[i];
|
|
89
|
+
if (d->kind == K_LOAD) {
|
|
90
|
+
sb_puts(b, "load:<load time>");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
sb_printf(b, "%s:%s", kind_word(d->kind), S(d->qual));
|
|
94
|
+
if (ID_MULTI && ID_MULTI[i]) sb_printf(b, "@%s", FILES.a[d->file]);
|
|
95
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* The analysis pipeline, definition ordering, and stable ids. */
|
|
2
|
+
#ifndef BACKBURN_ANALYSIS_ANALYSIS_H
|
|
3
|
+
#define BACKBURN_ANALYSIS_ANALYSIS_H
|
|
4
|
+
|
|
5
|
+
#include "core/util.h"
|
|
6
|
+
|
|
7
|
+
extern char *ROOT_ABS;
|
|
8
|
+
extern double ELAPSED_MS;
|
|
9
|
+
extern size_t NREFS;
|
|
10
|
+
extern uint32_t *FILE_RANK; /* file index -> rank by path */
|
|
11
|
+
|
|
12
|
+
/* Walk and index, build name indexes, expand name patterns, index classes,
|
|
13
|
+
* resolve mixins, mark, mark namespaces, mark what computed sends on
|
|
14
|
+
* self may call (uncertain), classify, build batches. */
|
|
15
|
+
void analyse(void);
|
|
16
|
+
|
|
17
|
+
int def_loc_cmp(uint32_t a, uint32_t b); /* by file path, then line */
|
|
18
|
+
int def_loc_qcmp(const void *a, const void *b);
|
|
19
|
+
|
|
20
|
+
/* Stable ids: kind:QualifiedName, plus @path when one name lives in two files. */
|
|
21
|
+
void compute_ids(void);
|
|
22
|
+
void def_id(sbuf *b, uint32_t i);
|
|
23
|
+
|
|
24
|
+
#endif
|