@futpib/parser 1.0.2 → 1.0.3

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.
Files changed (284) hide show
  1. package/.github/copilot-instructions.md +149 -0
  2. package/.github/workflows/copilot-setup-steps.yml +18 -0
  3. package/.github/workflows/main.yml +29 -8
  4. package/.yarn/releases/yarn-4.9.4.cjs +942 -0
  5. package/.yarnrc.yml +1 -1
  6. package/build/allSettledStream.js +1 -1
  7. package/build/allSettledStream.test.js +2 -2
  8. package/build/androidPackageParser.d.ts +1 -1
  9. package/build/androidPackageParser.js +5 -3
  10. package/build/androidPackageParser.test.js +7 -7
  11. package/build/androidPackageUnparser.d.ts +2 -2
  12. package/build/androidPackageUnparser.js +18 -14
  13. package/build/androidPackageUnparser.test.js +7 -7
  14. package/build/arbitrarilySlicedAsyncInterator.js +2 -1
  15. package/build/arbitraryDalvikBytecode.d.ts +4 -0
  16. package/build/arbitraryDalvikBytecode.js +640 -0
  17. package/build/arbitraryDalvikExecutable.d.ts +3 -0
  18. package/build/arbitraryDalvikExecutable.js +282 -0
  19. package/build/arbitraryDosDateTime.js +1 -0
  20. package/build/arbitraryZipStream.js +1 -1
  21. package/build/arrayParser.js +2 -2
  22. package/build/arrayUnparser.d.ts +1 -1
  23. package/build/backsmali.d.ts +3 -1
  24. package/build/backsmali.js +31 -3
  25. package/build/customInvariant.d.ts +2 -1
  26. package/build/customInvariant.js +4 -6
  27. package/build/dalvikBytecodeParser/formatParsers.d.ts +76 -2
  28. package/build/dalvikBytecodeParser/formatParsers.js +146 -11
  29. package/build/dalvikBytecodeParser/formatSizes.d.ts +34 -0
  30. package/build/dalvikBytecodeParser/formatSizes.js +34 -0
  31. package/build/dalvikBytecodeParser/operationFormats.d.ts +225 -0
  32. package/build/dalvikBytecodeParser/operationFormats.js +225 -0
  33. package/build/dalvikBytecodeParser.d.ts +1105 -5
  34. package/build/dalvikBytecodeParser.js +658 -205
  35. package/build/dalvikBytecodeUnparser/formatUnparsers.d.ts +152 -0
  36. package/build/dalvikBytecodeUnparser/formatUnparsers.js +225 -0
  37. package/build/dalvikBytecodeUnparser.d.ts +3 -0
  38. package/build/dalvikBytecodeUnparser.js +642 -0
  39. package/build/dalvikBytecodeUnparser.test.d.ts +1 -0
  40. package/build/dalvikBytecodeUnparser.test.js +25 -0
  41. package/build/dalvikExecutable.d.ts +65 -8
  42. package/build/dalvikExecutable.js +36 -0
  43. package/build/dalvikExecutableParser/stringSyntaxParser.d.ts +1 -1
  44. package/build/dalvikExecutableParser/stringSyntaxParser.js +17 -17
  45. package/build/dalvikExecutableParser/typeParsers.d.ts +2 -1
  46. package/build/dalvikExecutableParser/typeParsers.js +16 -11
  47. package/build/dalvikExecutableParser/typedNumbers.d.ts +85 -69
  48. package/build/dalvikExecutableParser/typedNumbers.js +0 -1
  49. package/build/dalvikExecutableParser.d.ts +2 -2
  50. package/build/dalvikExecutableParser.js +655 -337
  51. package/build/dalvikExecutableParser.test.js +24 -22
  52. package/build/dalvikExecutableParserAgainstSmaliParser.test.js +223 -246
  53. package/build/dalvikExecutableUnparser/annotationUnparsers.d.ts +14 -0
  54. package/build/dalvikExecutableUnparser/annotationUnparsers.js +97 -0
  55. package/build/dalvikExecutableUnparser/poolBuilders.d.ts +49 -0
  56. package/build/dalvikExecutableUnparser/poolBuilders.js +140 -0
  57. package/build/dalvikExecutableUnparser/poolScanners.d.ts +4 -0
  58. package/build/dalvikExecutableUnparser/poolScanners.js +220 -0
  59. package/build/dalvikExecutableUnparser/sectionUnparsers.d.ts +25 -0
  60. package/build/dalvikExecutableUnparser/sectionUnparsers.js +581 -0
  61. package/build/dalvikExecutableUnparser/utils.d.ts +10 -0
  62. package/build/dalvikExecutableUnparser/utils.js +108 -0
  63. package/build/dalvikExecutableUnparser.d.ts +4 -0
  64. package/build/dalvikExecutableUnparser.js +406 -0
  65. package/build/dalvikExecutableUnparser.test.d.ts +1 -0
  66. package/build/dalvikExecutableUnparser.test.js +31 -0
  67. package/build/debugLogInputParser.js +1 -1
  68. package/build/disjunctionParser.d.ts +2 -2
  69. package/build/disjunctionParser.js +2 -2
  70. package/build/elementTerminatedArrayParser.d.ts +2 -2
  71. package/build/elementTerminatedArrayParser.js +1 -1
  72. package/build/elementTerminatedArrayParser.test.js +5 -5
  73. package/build/elementTerminatedSequenceArrayParser.d.ts +2 -2
  74. package/build/elementTerminatedSequenceArrayParser.js +1 -1
  75. package/build/elementTerminatedSequenceArrayParser.test.js +2 -2
  76. package/build/elementTerminatedSequenceParser.d.ts +2 -2
  77. package/build/elementTerminatedSequenceParser.js +1 -1
  78. package/build/elementTerminatedSequenceParser.test.js +2 -2
  79. package/build/endOfInputParser.d.ts +1 -1
  80. package/build/exactElementSwitchParser.d.ts +3 -0
  81. package/build/exactElementSwitchParser.js +22 -0
  82. package/build/fetchCid.js +2 -6
  83. package/build/fetchCid.test.d.ts +1 -0
  84. package/build/fetchCid.test.js +16 -0
  85. package/build/fixedLengthSequenceParser.test.js +2 -2
  86. package/build/hasExecutable.js +2 -2
  87. package/build/highResolutionTimer.js +1 -1
  88. package/build/inputReader.d.ts +1 -1
  89. package/build/inputReader.test.js +33 -45
  90. package/build/javaKeyStoreParser.test.js +6 -6
  91. package/build/jsonParser.js +8 -8
  92. package/build/lazyMessageError.d.ts +48 -0
  93. package/build/lazyMessageError.js +53 -0
  94. package/build/lazyMessageError.test.d.ts +1 -0
  95. package/build/lazyMessageError.test.js +15 -0
  96. package/build/leb128Parser.d.ts +1 -1
  97. package/build/leb128Parser.js +10 -10
  98. package/build/leb128Parser.test.js +7 -7
  99. package/build/negativeLookaheadParser.js +2 -2
  100. package/build/negativeLookaheadParser.test.js +4 -4
  101. package/build/noStackCaptureOverheadError.d.ts +4 -0
  102. package/build/noStackCaptureOverheadError.js +9 -0
  103. package/build/noStackCaptureOverheadError.test.d.ts +1 -0
  104. package/build/noStackCaptureOverheadError.test.js +15 -0
  105. package/build/nonEmptyArrayParser.js +2 -2
  106. package/build/nonEmptyArrayParser.test.js +2 -1
  107. package/build/optionalParser.js +2 -2
  108. package/build/parser.d.ts +2 -1
  109. package/build/parser.js +23 -8
  110. package/build/parser.test.js +78 -29
  111. package/build/parserConsumedSequenceParser.d.ts +1 -1
  112. package/build/parserConsumedSequenceParser.js +2 -2
  113. package/build/parserContext.d.ts +8 -6
  114. package/build/parserContext.js +60 -33
  115. package/build/parserContext.test.js +7 -3
  116. package/build/parserError.d.ts +603 -44
  117. package/build/parserError.js +98 -53
  118. package/build/parserImplementationInvariant.d.ts +1 -1
  119. package/build/parserImplementationInvariant.js +2 -2
  120. package/build/parserInputCompanion.js +2 -2
  121. package/build/promiseCompose.js +1 -2
  122. package/build/separatedArrayParser.js +2 -2
  123. package/build/separatedNonEmptyArrayParser.d.ts +2 -0
  124. package/build/separatedNonEmptyArrayParser.js +40 -0
  125. package/build/separatedNonEmptyArrayParser.test.d.ts +1 -0
  126. package/build/separatedNonEmptyArrayParser.test.js +66 -0
  127. package/build/sequenceBuffer.js +1 -1
  128. package/build/sequenceTerminatedSequenceParser.d.ts +2 -2
  129. package/build/sequenceTerminatedSequenceParser.js +3 -3
  130. package/build/sequenceTerminatedSequenceParser.test.js +1 -1
  131. package/build/sequenceUnparser.d.ts +1 -1
  132. package/build/skipToParser.d.ts +1 -1
  133. package/build/skipToParser.js +2 -2
  134. package/build/sliceBoundedParser.test.js +4 -9
  135. package/build/smali.d.ts +1 -1
  136. package/build/smali.js +6 -2
  137. package/build/smaliParser.d.ts +62 -6
  138. package/build/smaliParser.js +1721 -296
  139. package/build/smaliParser.test.js +338 -43
  140. package/build/stringFromAsyncIterable.d.ts +1 -0
  141. package/build/stringFromAsyncIterable.js +7 -0
  142. package/build/terminatedArrayParser.js +4 -4
  143. package/build/terminatedArrayParser.test.js +7 -7
  144. package/build/toAsyncIterator.js +4 -4
  145. package/build/unionParser.d.ts +1 -1
  146. package/build/unionParser.js +2 -2
  147. package/build/unionParser.test.js +3 -3
  148. package/build/unparser.d.ts +3 -3
  149. package/build/unparser.js +6 -4
  150. package/build/unparser.test.js +7 -19
  151. package/build/unparserContext.d.ts +2 -2
  152. package/build/unparserContext.js +2 -3
  153. package/build/unparserError.d.ts +2 -1
  154. package/build/unparserError.js +2 -1
  155. package/build/unparserImplementationInvariant.d.ts +1 -1
  156. package/build/unparserOutputCompanion.d.ts +1 -1
  157. package/build/unparserOutputCompanion.js +1 -1
  158. package/build/zipParser.js +1 -1
  159. package/build/zipUnparser.d.ts +3 -3
  160. package/build/zipUnparser.js +9 -19
  161. package/build/zipUnparser.test.js +1 -1
  162. package/package.json +19 -26
  163. package/src/allSettledStream.test.ts +2 -2
  164. package/src/allSettledStream.ts +3 -3
  165. package/src/androidPackageParser.test.ts +17 -19
  166. package/src/androidPackageParser.ts +129 -171
  167. package/src/androidPackageUnparser.test.ts +19 -21
  168. package/src/androidPackageUnparser.ts +23 -17
  169. package/src/arbitrarilySlicedAsyncInterable.ts +1 -1
  170. package/src/arbitrarilySlicedAsyncInterator.ts +4 -4
  171. package/src/arbitraryDalvikBytecode.ts +992 -0
  172. package/src/arbitraryDalvikExecutable.ts +434 -0
  173. package/src/arbitraryDosDateTime.ts +1 -0
  174. package/src/arbitraryZipStream.ts +1 -1
  175. package/src/arrayParser.ts +2 -2
  176. package/src/arrayUnparser.ts +2 -2
  177. package/src/backsmali.ts +48 -4
  178. package/src/bsonParser.test.ts +12 -14
  179. package/src/customInvariant.ts +8 -12
  180. package/src/dalvikBytecodeParser/formatParsers.ts +376 -17
  181. package/src/dalvikBytecodeParser/formatSizes.ts +35 -0
  182. package/src/dalvikBytecodeParser/operationFormats.ts +226 -0
  183. package/src/dalvikBytecodeParser.ts +1042 -243
  184. package/src/dalvikBytecodeUnparser/formatUnparsers.ts +442 -0
  185. package/src/dalvikBytecodeUnparser.test.ts +44 -0
  186. package/src/dalvikBytecodeUnparser.ts +758 -0
  187. package/src/dalvikExecutable.ts +110 -48
  188. package/src/dalvikExecutableParser/stringSyntaxParser.ts +33 -33
  189. package/src/dalvikExecutableParser/typeParsers.ts +23 -14
  190. package/src/dalvikExecutableParser/typedNumbers.ts +19 -19
  191. package/src/dalvikExecutableParser.test.ts +60 -60
  192. package/src/dalvikExecutableParser.test.ts.md +6 -6
  193. package/src/dalvikExecutableParser.test.ts.snap +0 -0
  194. package/src/dalvikExecutableParser.ts +911 -434
  195. package/src/dalvikExecutableParserAgainstSmaliParser.test.ts +256 -239
  196. package/src/dalvikExecutableUnparser/annotationUnparsers.ts +135 -0
  197. package/src/dalvikExecutableUnparser/poolBuilders.ts +189 -0
  198. package/src/dalvikExecutableUnparser/poolScanners.ts +297 -0
  199. package/src/dalvikExecutableUnparser/sectionUnparsers.ts +683 -0
  200. package/src/dalvikExecutableUnparser/utils.ts +149 -0
  201. package/src/dalvikExecutableUnparser.test.ts +57 -0
  202. package/src/dalvikExecutableUnparser.ts +581 -0
  203. package/src/debugLogInputParser.ts +1 -1
  204. package/src/disjunctionParser.ts +5 -5
  205. package/src/elementTerminatedArrayParser.test.ts +8 -8
  206. package/src/elementTerminatedArrayParser.ts +2 -2
  207. package/src/elementTerminatedSequenceArrayParser.test.ts +4 -6
  208. package/src/elementTerminatedSequenceArrayParser.ts +2 -2
  209. package/src/elementTerminatedSequenceParser.test.ts +4 -6
  210. package/src/elementTerminatedSequenceParser.ts +2 -2
  211. package/src/endOfInputParser.ts +1 -1
  212. package/src/exactElementSwitchParser.ts +41 -0
  213. package/src/fetchCid.test.ts +20 -0
  214. package/src/fetchCid.ts +3 -7
  215. package/src/fixedLengthSequenceParser.test.ts +10 -12
  216. package/src/hasExecutable.ts +2 -2
  217. package/src/highResolutionTimer.ts +1 -1
  218. package/src/inputReader.test.ts +39 -52
  219. package/src/inputReader.ts +2 -4
  220. package/src/inputReaderState.ts +1 -1
  221. package/src/inspect.ts +1 -1
  222. package/src/javaKeyStoreParser.test.ts +12 -14
  223. package/src/javaKeyStoreParser.ts +2 -6
  224. package/src/jsonParser.test.ts +2 -4
  225. package/src/jsonParser.ts +34 -38
  226. package/src/lazyMessageError.test.ts +21 -0
  227. package/src/lazyMessageError.ts +88 -0
  228. package/src/leb128Parser.test.ts +25 -23
  229. package/src/leb128Parser.ts +19 -19
  230. package/src/negativeLookaheadParser.test.ts +7 -11
  231. package/src/negativeLookaheadParser.ts +2 -2
  232. package/src/noStackCaptureOverheadError.test.ts +17 -0
  233. package/src/noStackCaptureOverheadError.ts +12 -0
  234. package/src/nonEmptyArrayParser.test.ts +3 -2
  235. package/src/nonEmptyArrayParser.ts +2 -2
  236. package/src/optionalParser.ts +2 -2
  237. package/src/parser.test.ts +96 -43
  238. package/src/parser.test.ts.md +13 -6
  239. package/src/parser.test.ts.snap +0 -0
  240. package/src/parser.ts +35 -12
  241. package/src/parserAccessorParser.ts +1 -1
  242. package/src/parserConsumedSequenceParser.ts +3 -3
  243. package/src/parserContext.test.ts +7 -3
  244. package/src/parserContext.ts +82 -48
  245. package/src/parserError.ts +143 -63
  246. package/src/parserImplementationInvariant.ts +3 -3
  247. package/src/parserInputCompanion.ts +2 -2
  248. package/src/promiseCompose.ts +2 -2
  249. package/src/separatedArrayParser.ts +3 -3
  250. package/src/separatedNonEmptyArrayParser.test.ts +117 -0
  251. package/src/separatedNonEmptyArrayParser.ts +61 -0
  252. package/src/sequenceBuffer.test.ts +9 -9
  253. package/src/sequenceBuffer.ts +4 -4
  254. package/src/sequenceTerminatedSequenceParser.test.ts +3 -5
  255. package/src/sequenceTerminatedSequenceParser.ts +4 -4
  256. package/src/sequenceUnparser.ts +2 -2
  257. package/src/skipToParser.ts +2 -2
  258. package/src/sliceBoundedParser.test.ts +4 -12
  259. package/src/sliceBoundedParser.ts +2 -2
  260. package/src/smali.ts +8 -3
  261. package/src/smaliParser.test.ts +377 -66
  262. package/src/smaliParser.test.ts.md +1635 -48
  263. package/src/smaliParser.test.ts.snap +0 -0
  264. package/src/smaliParser.ts +2751 -569
  265. package/src/stringFromAsyncIterable.ts +9 -0
  266. package/src/terminatedArrayParser.test.ts +11 -11
  267. package/src/terminatedArrayParser.ts +5 -7
  268. package/src/toAsyncIterator.ts +8 -8
  269. package/src/uint8Array.ts +2 -3
  270. package/src/unionParser.test.ts +22 -23
  271. package/src/unionParser.ts +6 -8
  272. package/src/unparser.test.ts +18 -34
  273. package/src/unparser.ts +13 -9
  274. package/src/unparserContext.ts +9 -13
  275. package/src/unparserError.ts +2 -1
  276. package/src/unparserImplementationInvariant.ts +1 -1
  277. package/src/unparserOutputCompanion.ts +1 -1
  278. package/src/zip.ts +2 -6
  279. package/src/zipParser.ts +10 -18
  280. package/src/zipUnparser.test.ts +1 -1
  281. package/src/zipUnparser.ts +52 -64
  282. package/tsconfig.json +7 -1
  283. package/xo.config.ts +15 -0
  284. package/.yarn/releases/yarn-4.5.3.cjs +0 -934
@@ -3,13 +3,9 @@ import { runParser } from './parser.js';
3
3
  import { uint8ArrayParserInputCompanion } from './parserInputCompanion.js';
4
4
  import { dalvikExecutableParser, dalvikExecutableWithRawInstructionsParser } from './dalvikExecutableParser.js';
5
5
  import { fetchCid } from './fetchCid.js';
6
- for (const [dexCid, shouldSnapshot] of [
7
- ['bafkreibb4gsprc3fvmnyqx6obswvm7e7wngnfj64gz65ey72r7xgyzymt4', true],
8
- ['bafybeiebe27ylo53trgitu6fqfbmba43c4ivxj3nt4kumsilkucpbdxtqq', false],
9
- ['bafybeibbupm7uzhuq4pa674rb2amxsenbdaoijigmaf4onaodaql4mh7yy', false],
10
- ['bafybeicb3qajmwy6li7hche2nkucvytaxcyxhwhphmi73tgydjzmyoqoda', false],
11
- ]) {
12
- test.serial('dex (with instructions as bytes) ' + dexCid, async (t) => {
6
+ const dexWithRawInstructionsMacro = test.macro({
7
+ title: (providedTitle, dexCid) => providedTitle ?? `dex (with instructions as bytes) ${dexCid}`,
8
+ async exec(t, dexCid, shouldSnapshot) {
13
9
  const dexStream = await fetchCid(dexCid);
14
10
  const actual = await runParser(dalvikExecutableWithRawInstructionsParser, dexStream, uint8ArrayParserInputCompanion, {
15
11
  errorJoinMode: 'all',
@@ -18,11 +14,15 @@ for (const [dexCid, shouldSnapshot] of [
18
14
  t.snapshot(actual);
19
15
  }
20
16
  else {
21
- //console.dir(actual, { depth: null });
17
+ // Console.dir(actual, { depth: null });
22
18
  t.pass();
23
19
  }
24
- });
25
- }
20
+ },
21
+ });
22
+ test.serial(dexWithRawInstructionsMacro, 'bafkreibb4gsprc3fvmnyqx6obswvm7e7wngnfj64gz65ey72r7xgyzymt4', true);
23
+ test.serial(dexWithRawInstructionsMacro, 'bafybeiebe27ylo53trgitu6fqfbmba43c4ivxj3nt4kumsilkucpbdxtqq', false);
24
+ test.serial(dexWithRawInstructionsMacro, 'bafybeibbupm7uzhuq4pa674rb2amxsenbdaoijigmaf4onaodaql4mh7yy', false);
25
+ test.serial(dexWithRawInstructionsMacro, 'bafybeicb3qajmwy6li7hche2nkucvytaxcyxhwhphmi73tgydjzmyoqoda', false);
26
26
  function objectWalk(object, f, initialPath = []) {
27
27
  f(initialPath, object);
28
28
  if (!object
@@ -40,31 +40,33 @@ function objectWalk(object, f, initialPath = []) {
40
40
  }
41
41
  }
42
42
  }
43
- for (const [dexCid, shouldSnapshot] of [
44
- ['bafkreibb4gsprc3fvmnyqx6obswvm7e7wngnfj64gz65ey72r7xgyzymt4', true],
45
- // [ 'bafybeiebe27ylo53trgitu6fqfbmba43c4ivxj3nt4kumsilkucpbdxtqq', false ],
46
- // [ 'bafybeibbupm7uzhuq4pa674rb2amxsenbdaoijigmaf4onaodaql4mh7yy', false ],
47
- // [ 'bafybeicb3qajmwy6li7hche2nkucvytaxcyxhwhphmi73tgydjzmyoqoda', false ],
48
- ]) {
49
- test.serial('dex (with parsed instructions) ' + dexCid, async (t) => {
43
+ const dexWithParsedInstructionsMacro = test.macro({
44
+ title: (providedTitle, dexCid) => providedTitle ?? `dex (with parsed instructions) ${dexCid}`,
45
+ async exec(t, dexCid, shouldSnapshot) {
50
46
  const dexStream = await fetchCid(dexCid);
47
+ debugger;
51
48
  const actual = await runParser(dalvikExecutableParser, dexStream, uint8ArrayParserInputCompanion, {
52
49
  errorJoinMode: 'all',
53
50
  });
54
- objectWalk(actual, (path) => {
51
+ debugger;
52
+ objectWalk(actual, path => {
55
53
  const key = path.at(-1);
56
54
  if (typeof key !== 'string') {
57
55
  return;
58
56
  }
59
- t.false(key.endsWith('Offset'), 'All offsets should be resolved: ' + path.join('.'));
57
+ t.false(key.endsWith('Offset') && key !== 'branchOffset', 'All offsets should be resolved: ' + path.join('.'));
60
58
  t.false(key.endsWith('Index'), 'All indexes should be resolved: ' + path.join('.'));
61
59
  });
62
60
  if (shouldSnapshot) {
63
61
  t.snapshot(actual);
64
62
  }
65
63
  else {
66
- //console.dir(actual, { depth: null });
64
+ // Console.dir(actual, { depth: null });
67
65
  t.pass();
68
66
  }
69
- });
70
- }
67
+ },
68
+ });
69
+ test.serial.only(dexWithParsedInstructionsMacro, 'bafkreibb4gsprc3fvmnyqx6obswvm7e7wngnfj64gz65ey72r7xgyzymt4', true);
70
+ test.serial.skip(dexWithParsedInstructionsMacro, 'bafybeiebe27ylo53trgitu6fqfbmba43c4ivxj3nt4kumsilkucpbdxtqq', false);
71
+ test.serial.skip(dexWithParsedInstructionsMacro, 'bafybeibbupm7uzhuq4pa674rb2amxsenbdaoijigmaf4onaodaql4mh7yy', false);
72
+ test.serial.skip(dexWithParsedInstructionsMacro, 'bafybeicb3qajmwy6li7hche2nkucvytaxcyxhwhphmi73tgydjzmyoqoda', false);
@@ -4,7 +4,7 @@ import { stringParserInputCompanion, uint8ArrayParserInputCompanion } from './pa
4
4
  import { dalvikExecutableParser } from './dalvikExecutableParser.js';
5
5
  import { fetchCid } from './fetchCid.js';
6
6
  import { hasExecutable } from './hasExecutable.js';
7
- import { baksmaliClass } from './backsmali.js';
7
+ import { backsmaliSmaliIsolateClass, baksmaliClass, baksmaliListClasses } from './backsmali.js';
8
8
  import { smaliParser } from './smaliParser.js';
9
9
  import { smaliClass } from './smali.js';
10
10
  const hasBaksmaliPromise = hasExecutable('baksmali');
@@ -26,253 +26,235 @@ function objectWalk(object, f, initialPath = []) {
26
26
  }
27
27
  }
28
28
  }
29
- for (const [dexCid, smaliFilePaths] of [
30
- [
31
- 'bafkreibb4gsprc3fvmnyqx6obswvm7e7wngnfj64gz65ey72r7xgyzymt4',
32
- [
33
- 'pl/czak/minimal/MainActivity',
34
- ],
35
- ],
36
- // [
37
- // 'bafybeiebe27ylo53trgitu6fqfbmba43c4ivxj3nt4kumsilkucpbdxtqq',
38
- // [
39
- // 'd/m',
40
- // ],
41
- // ],
42
- // [ 'bafybeiebe27ylo53trgitu6fqfbmba43c4ivxj3nt4kumsilkucpbdxtqq' ],
43
- // [
44
- // 'bafybeibbupm7uzhuq4pa674rb2amxsenbdaoijigmaf4onaodaql4mh7yy',
45
- // [
46
- // 'com/journeyapps/barcodescanner/CaptureActivity',
47
- // ],
48
- // ],
49
- // [ 'bafybeicb3qajmwy6li7hche2nkucvytaxcyxhwhphmi73tgydjzmyoqoda' ],
50
- ]) {
51
- for (const smaliFilePath of smaliFilePaths) {
52
- test.serial('parse(dex) against parse(smali(dex))' + dexCid + ' ' + smaliFilePath, async (t) => {
53
- const hasBaksmali = await hasBaksmaliPromise;
54
- if (!hasBaksmali) {
55
- t.pass('skipping test because baksmali is not available');
56
- return;
29
+ function normalizeSmaliFilePath(smaliFilePath) {
30
+ if (typeof smaliFilePath === 'string') {
31
+ return {
32
+ smaliFilePath,
33
+ isolate: false,
34
+ };
35
+ }
36
+ return {
37
+ smaliFilePath: smaliFilePath.smaliFilePath,
38
+ isolate: smaliFilePath.isolate ?? false,
39
+ };
40
+ }
41
+ function normalizeClassDefinition(classDefinition) {
42
+ objectWalk(classDefinition, (_path, value) => {
43
+ if (value
44
+ && typeof value === 'object'
45
+ && 'debugInfo' in value) {
46
+ value.debugInfo = undefined;
47
+ }
48
+ });
49
+ }
50
+ const parseDexAgainstSmaliMacro = test.macro({
51
+ title(providedTitle, dexCid, smaliFilePathInput) {
52
+ const { smaliFilePath, isolate } = normalizeSmaliFilePath(smaliFilePathInput);
53
+ return providedTitle ?? `parse(dex) against parse(smali(dex)) ${dexCid} ${smaliFilePath}${isolate ? ' isolated' : ''}`;
54
+ },
55
+ async exec(t, dexCid, smaliFilePathInput) {
56
+ const { smaliFilePath, isolate } = normalizeSmaliFilePath(smaliFilePathInput);
57
+ const hasBaksmali = await hasBaksmaliPromise;
58
+ if (!hasBaksmali) {
59
+ t.pass('skipping test because baksmali is not available');
60
+ return;
61
+ }
62
+ const dexStream = await fetchCid(dexCid);
63
+ const smali_ = await baksmaliClass(dexStream, smaliFilePath);
64
+ const smali = (smali_
65
+ .replaceAll(/^\s+# getter for:.*$/gm, '')
66
+ .replaceAll(/^\s+# setter for:.*$/gm, '')
67
+ .replaceAll(/^\s+# invokes:.*$/gm, '')
68
+ .replaceAll(/\n{3,}/g, '\n\n'));
69
+ // Console.log(smali);
70
+ const classDefinitionFromSmali = await runParser(smaliParser, smali, stringParserInputCompanion, {
71
+ errorJoinMode: 'all',
72
+ });
73
+ let dexStream2 = await fetchCid(dexCid);
74
+ if (isolate) {
75
+ dexStream2 = await backsmaliSmaliIsolateClass(dexStream2, smaliFilePath);
76
+ }
77
+ const executableFromDex = await runParser(dalvikExecutableParser, dexStream2, uint8ArrayParserInputCompanion, {
78
+ errorJoinMode: 'all',
79
+ });
80
+ const classDefinitionFromDex = executableFromDex.classDefinitions.find(classDefinition => classDefinition.class === classDefinitionFromSmali.class);
81
+ // Normalize both DEX and Smali by removing debug info
82
+ normalizeClassDefinition(classDefinitionFromDex);
83
+ normalizeClassDefinition(classDefinitionFromSmali);
84
+ // Console.dir({
85
+ // classDefinitionFromSmali,
86
+ // classDefinitionFromDex,
87
+ // }, {
88
+ // depth: null,
89
+ // });
90
+ t.deepEqual(classDefinitionFromDex, classDefinitionFromSmali);
91
+ },
92
+ });
93
+ const parseAllClassesInDexAgainstSmaliMacro = test.macro({
94
+ title(providedTitle, dexCid, options) {
95
+ return providedTitle ?? `parse all classes from dex ${dexCid} against smali${options?.skipUntilClassPath ? ` (skip until ${options.skipUntilClassPath})` : ''}`;
96
+ },
97
+ async exec(t, dexCid, options) {
98
+ const hasBaksmali = await hasBaksmaliPromise;
99
+ if (!hasBaksmali) {
100
+ t.pass('skipping test because baksmali is not available');
101
+ return;
102
+ }
103
+ const dexStream = await fetchCid(dexCid);
104
+ const classes = ((await baksmaliListClasses(dexStream))
105
+ .map(smaliFilePath => ({ smaliFilePath, sort: Math.random() }))
106
+ .sort((a, b) => a.sort - b.sort)
107
+ .map(({ smaliFilePath }) => smaliFilePath));
108
+ const failures = [];
109
+ let shouldProcess = options?.skipUntilClassPath === undefined;
110
+ let processedCount = 0;
111
+ for (const smaliFilePath of classes) {
112
+ if (options?.skipUntilClassPath && smaliFilePath === options.skipUntilClassPath) {
113
+ shouldProcess = true;
57
114
  }
58
- const dexStream = await fetchCid(dexCid);
59
- const smali = await baksmaliClass(dexStream, smaliFilePath);
60
- const classDefinitionFromSmali = await runParser(smaliParser, smali, stringParserInputCompanion, {
61
- errorJoinMode: 'all',
62
- });
63
- const dexStream2 = await fetchCid(dexCid);
64
- const executableFromDex = await runParser(dalvikExecutableParser, dexStream2, uint8ArrayParserInputCompanion, {
65
- errorJoinMode: 'all',
115
+ if (!shouldProcess) {
116
+ continue;
117
+ }
118
+ processedCount++;
119
+ const result = await t.try(parseDexAgainstSmaliMacro, dexCid, {
120
+ smaliFilePath,
121
+ isolate: true,
66
122
  });
67
- const classDefinitionFromDex = executableFromDex.classDefinitions.find(classDefinition => classDefinition.class === classDefinitionFromSmali.class);
68
- // console.log(smali);
69
- // console.dir({
70
- // classDefinitionFromDex,
71
- // classDefinitionFromSmali,
72
- // }, {
73
- // depth: null,
74
- // });
75
- objectWalk(classDefinitionFromDex, (_path, value) => {
76
- if (value
77
- && typeof value === 'object'
78
- && 'debugInfo' in value) {
79
- value.debugInfo = undefined;
123
+ if (result.passed) {
124
+ result.commit();
125
+ console.log(`ok ${processedCount}/${classes.length}`, smaliFilePath);
126
+ continue;
127
+ }
128
+ function consoleLogFailure(failure) {
129
+ const [error] = failure.errors;
130
+ console.log(error.formattedDetails.at(0).formatted ?? error);
131
+ }
132
+ console.log(smaliFilePath);
133
+ consoleLogFailure(result);
134
+ failures.push(result);
135
+ if (failures.length >= (options?.maxFailures ?? 1)) {
136
+ for (const failure of failures) {
137
+ consoleLogFailure(failure);
80
138
  }
81
- });
82
- t.deepEqual(classDefinitionFromDex, classDefinitionFromSmali);
83
- });
139
+ for (const failure of failures) {
140
+ failure.commit();
141
+ }
142
+ }
143
+ }
144
+ for (const failure of failures) {
145
+ failure.commit();
146
+ }
147
+ t.pass('completed all classes');
148
+ },
149
+ });
150
+ const testCasesByCid = {
151
+ bafybeicb3qajmwy6li7hche2nkucvytaxcyxhwhphmi73tgydjzmyoqoda: [
152
+ { smaliFilePath: 'androidx/activity/ComponentActivity$1', isolate: true },
153
+ { smaliFilePath: 'androidx/activity/R$id', isolate: true },
154
+ { smaliFilePath: 'androidx/activity/ComponentActivity$NonConfigurationInstances', isolate: true },
155
+ { smaliFilePath: 'androidx/appcompat/R$styleable', isolate: true },
156
+ { smaliFilePath: 'androidx/core/content/FileProvider', isolate: true },
157
+ { smaliFilePath: 'androidx/core/view/KeyEventDispatcher', isolate: true },
158
+ { smaliFilePath: 'com/google/android/exoplayer2/audio/Sonic', isolate: true },
159
+ { smaliFilePath: 'com/google/android/exoplayer2/ext/opus/OpusDecoder', isolate: true },
160
+ { smaliFilePath: 'com/google/android/exoplayer2/extractor/ts/H262Reader', isolate: true },
161
+ { smaliFilePath: 'com/google/android/gms/internal/common/zzg', isolate: true },
162
+ { smaliFilePath: 'com/google/android/gms/internal/mlkit_vision_label/zzcm', isolate: true },
163
+ { smaliFilePath: 'com/google/android/play/core/integrity/model/StandardIntegrityErrorCode', isolate: true },
164
+ { smaliFilePath: 'com/google/common/math/IntMath', isolate: true },
165
+ { smaliFilePath: 'com/google/gson/internal/bind/CollectionTypeAdapterFactory', isolate: true },
166
+ ],
167
+ bafkreibb4gsprc3fvmnyqx6obswvm7e7wngnfj64gz65ey72r7xgyzymt4: [
168
+ 'pl/czak/minimal/MainActivity',
169
+ 'pl/czak/minimal/R',
170
+ ],
171
+ bafybeibbupm7uzhuq4pa674rb2amxsenbdaoijigmaf4onaodaql4mh7yy: [
172
+ { smaliFilePath: 'com/journeyapps/barcodescanner/CaptureActivity', isolate: true },
173
+ { smaliFilePath: '_COROUTINE/ArtificialStackFrames', isolate: true },
174
+ { smaliFilePath: 'androidx/appcompat/widget/AppCompatTextHelper', isolate: true },
175
+ { smaliFilePath: '_COROUTINE/CoroutineDebuggingKt', isolate: true },
176
+ { smaliFilePath: 'androidx/compose/ui/text/android/style/LineHeightSpan', isolate: true },
177
+ { smaliFilePath: 'androidx/compose/ui/layout/LayoutIdElement', isolate: true },
178
+ { smaliFilePath: 'androidx/compose/ui/text/EmojiSupportMatch', isolate: true },
179
+ { smaliFilePath: 'androidx/compose/ui/focus/FocusTransactionsKt', isolate: true },
180
+ { smaliFilePath: 'androidx/compose/animation/core/SpringSimulationKt', isolate: true },
181
+ { smaliFilePath: 'androidx/constraintlayout/core/widgets/ConstraintWidget', isolate: true },
182
+ { smaliFilePath: 'ch/qos/logback/core/CoreConstants', isolate: true },
183
+ { smaliFilePath: 'ch/qos/logback/classic/spi/ClassPackagingData', isolate: true },
184
+ { smaliFilePath: 'kotlin/coroutines/jvm/internal/DebugMetadata', isolate: true },
185
+ ],
186
+ bafybeiebe27ylo53trgitu6fqfbmba43c4ivxj3nt4kumsilkucpbdxtqq: [
187
+ { smaliFilePath: 'androidx/viewpager2/adapter/FragmentStateAdapter$5', isolate: true },
188
+ { smaliFilePath: 'androidx/lifecycle/b0', isolate: true },
189
+ { smaliFilePath: 'androidx/activity/b', isolate: true },
190
+ { smaliFilePath: 'androidx/activity/result/a$a', isolate: true },
191
+ { smaliFilePath: 'androidx/annotation/Keep', isolate: true },
192
+ { smaliFilePath: 'androidx/activity/result/e', isolate: true },
193
+ { smaliFilePath: 'androidx/appcompat/widget/ActionBarContextView$a', isolate: true },
194
+ { smaliFilePath: 'androidx/appcompat/widget/b0', isolate: true },
195
+ { smaliFilePath: 'androidx/appcompat/widget/b1', isolate: true },
196
+ { smaliFilePath: 'androidx/appcompat/widget/e', isolate: true },
197
+ { smaliFilePath: 'androidx/appcompat/widget/m0', isolate: true },
198
+ { smaliFilePath: 'androidx/appcompat/widget/r1', isolate: true },
199
+ { smaliFilePath: 'androidx/recyclerview/widget/RecyclerView$a0', isolate: true },
200
+ { smaliFilePath: 'androidx/constraintlayout/widget/ConstraintLayout$a', isolate: true },
201
+ { smaliFilePath: 'l4/a', isolate: true },
202
+ { smaliFilePath: 'n4/o', isolate: true },
203
+ { smaliFilePath: 'o6/f', isolate: true },
204
+ { smaliFilePath: 'a', isolate: true },
205
+ { smaliFilePath: 'a/b', isolate: true },
206
+ { smaliFilePath: 'f/b', isolate: true },
207
+ { smaliFilePath: 'h1/j', isolate: true },
208
+ { smaliFilePath: 'android/app/AppComponentFactory', isolate: true },
209
+ { smaliFilePath: 'android/app/job/JobInfo$TriggerContentUri', isolate: true },
210
+ { smaliFilePath: 'android/graphics/BlendModeColorFilter', isolate: true },
211
+ { smaliFilePath: 'android/graphics/fonts/Font$Builder', isolate: true },
212
+ { smaliFilePath: 'android/os/LocaleList', isolate: true },
213
+ { smaliFilePath: 'a0/i', isolate: true },
214
+ { smaliFilePath: 'a0/l', isolate: true },
215
+ { smaliFilePath: 'a0/n', isolate: true },
216
+ { smaliFilePath: 'a0/p', isolate: true },
217
+ { smaliFilePath: 'a0/v', isolate: true },
218
+ { smaliFilePath: 'a0/v$a', isolate: true },
219
+ { smaliFilePath: 'a3/a', isolate: true },
220
+ { smaliFilePath: 'a3/b', isolate: true },
221
+ { smaliFilePath: 'a3/d', isolate: true },
222
+ { smaliFilePath: 'a4/b', isolate: true },
223
+ { smaliFilePath: 'b4/v', isolate: true },
224
+ { smaliFilePath: 'd6/a', isolate: true },
225
+ { smaliFilePath: 'q2/d$a', isolate: true },
226
+ { smaliFilePath: 'y4/t1', isolate: true },
227
+ { smaliFilePath: 'com/google/android/material/textfield/b', isolate: true },
228
+ { smaliFilePath: 'm/g', isolate: true },
229
+ ],
230
+ };
231
+ for (const [dexCid, smaliFilePaths] of Object.entries(testCasesByCid)) {
232
+ for (const smaliFilePath of smaliFilePaths) {
233
+ test.serial(parseDexAgainstSmaliMacro, dexCid, smaliFilePath);
84
234
  }
85
235
  }
236
+ for (const dexCid of Object.keys(testCasesByCid)) {
237
+ test.serial.skip(parseAllClassesInDexAgainstSmaliMacro, dexCid);
238
+ }
86
239
  const smali = `
87
- .class public Lcom/journeyapps/barcodescanner/CaptureActivity;
88
- .super Landroid/app/Activity;
89
- .source "CaptureActivity.java"
90
-
91
-
92
- # instance fields
93
- .field private barcodeScannerView:Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
94
-
95
- .field private capture:Lcom/journeyapps/barcodescanner/CaptureManager;
96
-
240
+ .class public final La0/l;
241
+ .super Ljava/lang/Object;
242
+ .source "SourceFile"
97
243
 
98
244
  # direct methods
99
- .method public constructor <init>()V
100
- .registers 1
101
-
102
- .line 13
103
- invoke-direct {p0}, Landroid/app/Activity;-><init>()V
245
+ .method public static final a(Lh1/p;ZJ)F
246
+ .registers 6
104
247
 
105
- return-void
106
- .end method
107
-
108
-
109
- # virtual methods
110
- .method protected initializeContent()Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
111
- .registers 2
112
-
113
- sget v0, Lcom/google/zxing/client/android/R$layout;->zxing_capture:I
114
-
115
- .line 34
116
- invoke-virtual {p0, v0}, Landroid/app/Activity;->setContentView(I)V
117
-
118
- sget v0, Lcom/google/zxing/client/android/R$id;->zxing_barcode_scanner:I
119
-
120
- .line 35
121
- invoke-virtual {p0, v0}, Landroid/app/Activity;->findViewById(I)Landroid/view/View;
122
-
123
- move-result-object v0
124
-
125
- check-cast v0, Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
126
-
127
- return-object v0
128
- .end method
129
-
130
- .method protected onCreate(Landroid/os/Bundle;)V
131
- .registers 4
132
-
133
- .line 19
134
- invoke-super {p0, p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V
135
-
136
- .line 21
137
- invoke-virtual {p0}, Lcom/journeyapps/barcodescanner/CaptureActivity;->initializeContent()Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
138
-
139
- move-result-object v0
140
-
141
- iput-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->barcodeScannerView:Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
142
-
143
- .line 23
144
- new-instance v0, Lcom/journeyapps/barcodescanner/CaptureManager;
145
-
146
- iget-object v1, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->barcodeScannerView:Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
147
-
148
- invoke-direct {v0, p0, v1}, Lcom/journeyapps/barcodescanner/CaptureManager;-><init>(Landroid/app/Activity;Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;)V
149
-
150
- iput-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
151
-
152
- .line 24
153
- invoke-virtual {p0}, Landroid/app/Activity;->getIntent()Landroid/content/Intent;
154
-
155
- move-result-object v1
156
-
157
- invoke-virtual {v0, v1, p1}, Lcom/journeyapps/barcodescanner/CaptureManager;->initializeFromIntent(Landroid/content/Intent;Landroid/os/Bundle;)V
158
-
159
- iget-object p1, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
160
-
161
- .line 25
162
- invoke-virtual {p1}, Lcom/journeyapps/barcodescanner/CaptureManager;->decode()V
163
-
164
- return-void
165
- .end method
166
-
167
- .method protected onDestroy()V
168
- .registers 2
169
-
170
- .line 52
171
- invoke-super {p0}, Landroid/app/Activity;->onDestroy()V
172
-
173
- iget-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
174
-
175
- .line 53
176
- invoke-virtual {v0}, Lcom/journeyapps/barcodescanner/CaptureManager;->onDestroy()V
177
-
178
- return-void
179
- .end method
180
-
181
- .method public onKeyDown(ILandroid/view/KeyEvent;)Z
182
- .registers 4
183
-
184
- iget-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->barcodeScannerView:Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
185
-
186
- .line 69
187
- invoke-virtual {v0, p1, p2}, Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;->onKeyDown(ILandroid/view/KeyEvent;)Z
188
-
189
- move-result v0
190
-
191
- if-nez v0, :cond_11
192
-
193
- invoke-super {p0, p1, p2}, Landroid/app/Activity;->onKeyDown(ILandroid/view/KeyEvent;)Z
194
-
195
- move-result p1
196
-
197
- if-eqz p1, :cond_f
198
-
199
- goto :goto_11
200
-
201
- :cond_f
202
- const/4 p1, 0x0
203
-
204
- goto :goto_12
205
-
206
- :cond_11
207
- :goto_11
208
- const/4 p1, 0x1
209
-
210
- :goto_12
211
- return p1
212
- .end method
213
-
214
- .method protected onPause()V
215
- .registers 2
216
-
217
- .line 46
218
- invoke-super {p0}, Landroid/app/Activity;->onPause()V
219
-
220
- iget-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
221
-
222
- .line 47
223
- invoke-virtual {v0}, Lcom/journeyapps/barcodescanner/CaptureManager;->onPause()V
224
-
225
- return-void
226
- .end method
227
-
228
- .method public onRequestPermissionsResult(I[Ljava/lang/String;[I)V
229
- .registers 5
230
-
231
- iget-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
232
-
233
- .line 64
234
- invoke-virtual {v0, p1, p2, p3}, Lcom/journeyapps/barcodescanner/CaptureManager;->onRequestPermissionsResult(I[Ljava/lang/String;[I)V
235
-
236
- return-void
237
- .end method
238
-
239
- .method protected onResume()V
240
- .registers 2
241
-
242
- .line 40
243
- invoke-super {p0}, Landroid/app/Activity;->onResume()V
244
-
245
- iget-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
246
-
247
- .line 41
248
- invoke-virtual {v0}, Lcom/journeyapps/barcodescanner/CaptureManager;->onResume()V
249
-
250
- return-void
251
- .end method
252
-
253
- .method protected onSaveInstanceState(Landroid/os/Bundle;)V
254
- .registers 3
255
-
256
- .line 58
257
- invoke-super {p0, p1}, Landroid/app/Activity;->onSaveInstanceState(Landroid/os/Bundle;)V
258
-
259
- iget-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
260
-
261
- .line 59
262
- invoke-virtual {v0, p1}, Lcom/journeyapps/barcodescanner/CaptureManager;->onSaveInstanceState(Landroid/os/Bundle;)V
263
-
264
- return-void
248
+ return v0
265
249
  .end method
266
250
  `;
267
- test.serial.skip('parse(dex(smali)) againts parse(smali)', async (t) => {
251
+ test.serial('parse(dex(smali)) againts parse(smali)', async (t) => {
268
252
  const hasSmali = await hasSmaliPromise;
269
253
  if (!hasSmali) {
270
254
  t.pass('skipping test because smali is not available');
271
255
  return;
272
256
  }
273
- const dexBuffer = await smaliClass(async function* () {
274
- yield smali;
275
- }());
257
+ const dexBuffer = await smaliClass(smali);
276
258
  const classDefinitionFromSmali = await runParser(smaliParser, smali, stringParserInputCompanion, {
277
259
  errorJoinMode: 'all',
278
260
  });
@@ -280,19 +262,14 @@ test.serial.skip('parse(dex(smali)) againts parse(smali)', async (t) => {
280
262
  errorJoinMode: 'all',
281
263
  });
282
264
  const classDefinitionFromDex = executableFromDex.classDefinitions.find(classDefinition => classDefinition.class === classDefinitionFromSmali.class);
283
- // console.log(smali);
284
- console.dir({
285
- classDefinitionFromDex,
286
- classDefinitionFromSmali,
287
- }, {
288
- depth: null,
289
- });
290
- objectWalk(classDefinitionFromDex, (_path, value) => {
291
- if (value
292
- && typeof value === 'object'
293
- && 'debugInfo' in value) {
294
- value.debugInfo = undefined;
295
- }
296
- });
265
+ // Normalize both DEX and Smali by removing debug info
266
+ normalizeClassDefinition(classDefinitionFromDex);
267
+ normalizeClassDefinition(classDefinitionFromSmali);
268
+ // Console.dir({
269
+ // classDefinitionFromDex,
270
+ // classDefinitionFromSmali,
271
+ // }, {
272
+ // depth: null,
273
+ // });
297
274
  t.deepEqual(classDefinitionFromDex, classDefinitionFromSmali);
298
275
  });
@@ -0,0 +1,14 @@
1
+ import { type Unparser } from '../unparser.js';
2
+ import { type DalvikExecutableAnnotation, type DalvikExecutableClassAnnotations, type DalvikExecutableEncodedValue, type DalvikExecutableField, type DalvikExecutableMethod } from '../dalvikExecutable.js';
3
+ import { WriteLater } from '../unparserContext.js';
4
+ export declare function createAnnotationUnparsers(getStringIndex: (str: string | undefined) => number, getTypeIndex: (typeDescriptor: string | undefined) => number, getFieldIndex: (field: DalvikExecutableField) => number, getMethodIndex: (method: DalvikExecutableMethod) => number, encodedValueUnparser: Unparser<DalvikExecutableEncodedValue, Uint8Array>): {
5
+ annotationItemUnparser: Unparser<DalvikExecutableAnnotation, Uint8Array<ArrayBufferLike>>;
6
+ annotationSetItemUnparser: (annotationItemOffsetWriteLaters: Array<WriteLater<Uint8Array, number>>) => Unparser<DalvikExecutableAnnotation[], Uint8Array>;
7
+ annotationSetRefListUnparser: (annotationSetOffsetWriteLaters: Array<WriteLater<Uint8Array, number> | null>) => Unparser<DalvikExecutableAnnotation[][], Uint8Array>;
8
+ annotationsDirectoryItemUnparser: (annotationOffsetWriteLaters: {
9
+ classAnnotationsOffsetWriteLater?: WriteLater<Uint8Array, number>;
10
+ fieldAnnotationsOffsetWriteLaters?: Array<WriteLater<Uint8Array, number> | null>;
11
+ methodAnnotationsOffsetWriteLaters?: Array<WriteLater<Uint8Array, number>>;
12
+ parameterAnnotationsOffsetWriteLaters?: Array<WriteLater<Uint8Array, number>>;
13
+ }) => Unparser<DalvikExecutableClassAnnotations, Uint8Array>;
14
+ };