@futpib/parser 1.0.3 → 1.0.6
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.
- package/.claude/settings.local.json +24 -0
- package/.github/workflows/main.yml +1 -0
- package/build/androidPackageParser.js +30 -32
- package/build/arbitraryDalvikBytecode.d.ts +3 -3
- package/build/arbitraryDalvikBytecode.js +33 -27
- package/build/arbitraryDalvikExecutable.js +55 -17
- package/build/arbitraryJava.d.ts +31 -0
- package/build/arbitraryJava.js +532 -0
- package/build/arbitraryJavaScript.d.ts +3 -0
- package/build/arbitraryJavaScript.js +263 -0
- package/build/arbitraryJavascript.d.ts +3 -0
- package/build/arbitraryJavascript.js +263 -0
- package/build/arbitraryZig.d.ts +3 -0
- package/build/arbitraryZig.js +240 -0
- package/build/arbitraryZipStream.d.ts +1 -1
- package/build/arrayParser.js +72 -13
- package/build/backsmali.d.ts +4 -3
- package/build/backsmali.js +26 -6
- package/build/bash.d.ts +89 -0
- package/build/bash.js +1 -0
- package/build/bashParser.d.ts +6 -0
- package/build/bashParser.js +335 -0
- package/build/bashParser.test.d.ts +1 -0
- package/build/bashParser.test.js +343 -0
- package/build/bashParserEdgeCases.test.d.ts +1 -0
- package/build/bashParserEdgeCases.test.js +117 -0
- package/build/dalvikBytecodeParser/addressConversion.d.ts +110 -0
- package/build/dalvikBytecodeParser/addressConversion.js +334 -0
- package/build/dalvikBytecodeParser/formatParsers.d.ts +7 -6
- package/build/dalvikBytecodeParser/formatParsers.js +13 -14
- package/build/dalvikBytecodeParser.d.ts +60 -31
- package/build/dalvikBytecodeParser.js +92 -35
- package/build/dalvikBytecodeParser.test-d.d.ts +1 -0
- package/build/dalvikBytecodeParser.test-d.js +268 -0
- package/build/dalvikBytecodeUnparser/formatUnparsers.d.ts +9 -8
- package/build/dalvikBytecodeUnparser/formatUnparsers.js +13 -12
- package/build/dalvikBytecodeUnparser.d.ts +2 -2
- package/build/dalvikBytecodeUnparser.js +23 -23
- package/build/dalvikBytecodeUnparser.test.js +7 -7
- package/build/dalvikExecutable.d.ts +3 -3
- package/build/dalvikExecutable.test-d.d.ts +1 -0
- package/build/dalvikExecutable.test-d.js +59 -0
- package/build/dalvikExecutableParser/typedNumbers.d.ts +18 -0
- package/build/dalvikExecutableParser/typedNumbers.js +3 -0
- package/build/dalvikExecutableParser.d.ts +2 -1
- package/build/dalvikExecutableParser.js +96 -77
- package/build/dalvikExecutableParser.test.js +24 -3
- package/build/dalvikExecutableParserAgainstSmaliParser.test.js +3 -0
- package/build/dalvikExecutableUnparser/poolScanners.d.ts +2 -2
- package/build/dalvikExecutableUnparser/sectionUnparsers.d.ts +3 -3
- package/build/dalvikExecutableUnparser/sectionUnparsers.js +26 -11
- package/build/dalvikExecutableUnparser.d.ts +2 -2
- package/build/dalvikExecutableUnparser.test.js +2 -1
- package/build/disjunctionParser.d.ts +5 -3
- package/build/disjunctionParser.js +79 -17
- package/build/disjunctionParser.test-d.d.ts +1 -0
- package/build/disjunctionParser.test-d.js +72 -0
- package/build/elementSwitchParser.d.ts +4 -0
- package/build/{exactElementSwitchParser.js → elementSwitchParser.js} +3 -4
- package/build/elementSwitchParser.test-d.d.ts +1 -0
- package/build/elementSwitchParser.test-d.js +44 -0
- package/build/exactSequenceParser.d.ts +4 -2
- package/build/exactSequenceParser.test-d.d.ts +1 -0
- package/build/exactSequenceParser.test-d.js +36 -0
- package/build/fetchCid.js +2 -66
- package/build/index.d.ts +25 -2
- package/build/index.js +23 -1
- package/build/index.test.js +16 -1
- package/build/inputReader.d.ts +10 -0
- package/build/inputReader.js +36 -0
- package/build/java.d.ts +502 -0
- package/build/java.js +2 -0
- package/build/javaKeyStoreParser.js +14 -17
- package/build/javaParser.d.ts +51 -0
- package/build/javaParser.js +1538 -0
- package/build/javaParser.test.d.ts +1 -0
- package/build/javaParser.test.js +1287 -0
- package/build/javaScript.d.ts +35 -0
- package/build/javaScript.js +1 -0
- package/build/javaScriptParser.d.ts +9 -0
- package/build/javaScriptParser.js +34 -0
- package/build/javaScriptUnparser.d.ts +3 -0
- package/build/javaScriptUnparser.js +4 -0
- package/build/javaScriptUnparser.test.d.ts +1 -0
- package/build/javaScriptUnparser.test.js +24 -0
- package/build/javaUnparser.d.ts +2 -0
- package/build/javaUnparser.js +519 -0
- package/build/javaUnparser.test.d.ts +1 -0
- package/build/javaUnparser.test.js +24 -0
- package/build/javascript.d.ts +35 -0
- package/build/javascript.js +1 -0
- package/build/javascriptParser.d.ts +9 -0
- package/build/javascriptParser.js +34 -0
- package/build/javascriptUnparser.d.ts +3 -0
- package/build/javascriptUnparser.js +4 -0
- package/build/javascriptUnparser.test.d.ts +1 -0
- package/build/javascriptUnparser.test.js +24 -0
- package/build/jsonParser.js +2 -12
- package/build/lazyMessageError.d.ts +3 -0
- package/build/lookaheadParser.js +60 -3
- package/build/negativeLookaheadParser.js +70 -11
- package/build/nonEmptyArrayParser.js +72 -13
- package/build/objectParser.d.ts +12 -0
- package/build/objectParser.js +31 -0
- package/build/objectParser.test-d.d.ts +1 -0
- package/build/objectParser.test-d.js +112 -0
- package/build/objectParser.test.d.ts +1 -0
- package/build/objectParser.test.js +55 -0
- package/build/optionalParser.js +69 -10
- package/build/parser.d.ts +4 -0
- package/build/parser.js +3 -1
- package/build/parser.test.js +114 -1
- package/build/parserConsumedSequenceParser.js +66 -7
- package/build/parserContext.d.ts +6 -0
- package/build/parserContext.js +20 -11
- package/build/parserError.d.ts +119 -27
- package/build/parserError.js +16 -8
- package/build/regexpParser.d.ts +2 -0
- package/build/regexpParser.js +101 -0
- package/build/regexpParser.test.d.ts +1 -0
- package/build/regexpParser.test.js +114 -0
- package/build/regularExpression.d.ts +63 -0
- package/build/regularExpression.js +1 -0
- package/build/regularExpressionParser.d.ts +3 -0
- package/build/regularExpressionParser.js +600 -0
- package/build/regularExpressionParser.test.d.ts +1 -0
- package/build/regularExpressionParser.test.js +89 -0
- package/build/separatedArrayParser.js +73 -14
- package/build/separatedNonEmptyArrayParser.js +73 -14
- package/build/sliceBoundedParser.js +62 -5
- package/build/smaliParser.d.ts +7 -7
- package/build/smaliParser.js +185 -268
- package/build/smaliParser.test.js +58 -0
- package/build/stringEscapes.d.ts +5 -0
- package/build/stringEscapes.js +244 -0
- package/build/symbolicExpression.d.ts +29 -0
- package/build/symbolicExpression.js +1 -0
- package/build/symbolicExpressionParser.d.ts +4 -0
- package/build/symbolicExpressionParser.js +123 -0
- package/build/symbolicExpressionParser.test.d.ts +1 -0
- package/build/symbolicExpressionParser.test.js +289 -0
- package/build/terminatedArrayParser.js +113 -38
- package/build/terminatedArrayParser.test.js +4 -2
- package/build/tupleParser.d.ts +7 -15
- package/build/tupleParser.js +1 -0
- package/build/unionParser.d.ts +5 -3
- package/build/unionParser.js +7 -2
- package/build/unionParser.test-d.d.ts +1 -0
- package/build/unionParser.test-d.js +72 -0
- package/build/unionParser.test.js +10 -11
- package/build/zig.d.ts +280 -0
- package/build/zig.js +2 -0
- package/build/zigParser.d.ts +3 -0
- package/build/zigParser.js +1119 -0
- package/build/zigParser.test.d.ts +1 -0
- package/build/zigParser.test.js +1590 -0
- package/build/zigUnparser.d.ts +2 -0
- package/build/zigUnparser.js +460 -0
- package/build/zigUnparser.test.d.ts +1 -0
- package/build/zigUnparser.test.js +24 -0
- package/build/zipParser.js +19 -32
- package/build/zipUnparser.js +19 -7
- package/build/zipUnparser.test.js +1 -1
- package/node_modules-@types/s-expression/index.d.ts +5 -0
- package/package.json +25 -6
- package/src/androidPackageParser.ts +33 -60
- package/src/arbitraryDalvikBytecode.ts +39 -31
- package/src/arbitraryDalvikExecutable.ts +65 -20
- package/src/arbitraryJava.ts +804 -0
- package/src/arbitraryJavaScript.ts +410 -0
- package/src/arbitraryZig.ts +380 -0
- package/src/arrayParser.ts +1 -3
- package/src/backsmali.ts +35 -4
- package/src/bash.ts +127 -0
- package/src/bashParser.test.ts +590 -0
- package/src/bashParser.ts +498 -0
- package/src/dalvikBytecodeParser/addressConversion.ts +496 -0
- package/src/dalvikBytecodeParser/formatParsers.ts +19 -29
- package/src/dalvikBytecodeParser.test-d.ts +310 -0
- package/src/dalvikBytecodeParser.ts +194 -69
- package/src/dalvikBytecodeUnparser/formatUnparsers.ts +27 -26
- package/src/dalvikBytecodeUnparser.test.ts +7 -7
- package/src/dalvikBytecodeUnparser.ts +31 -30
- package/src/dalvikExecutable.test-d.ts +132 -0
- package/src/dalvikExecutable.ts +3 -3
- package/src/dalvikExecutableParser/typedNumbers.ts +11 -0
- package/src/dalvikExecutableParser.test.ts +37 -3
- package/src/dalvikExecutableParser.test.ts.md +163 -2
- package/src/dalvikExecutableParser.test.ts.snap +0 -0
- package/src/dalvikExecutableParser.ts +121 -139
- package/src/dalvikExecutableParserAgainstSmaliParser.test.ts +4 -0
- package/src/dalvikExecutableUnparser/poolScanners.ts +6 -6
- package/src/dalvikExecutableUnparser/sectionUnparsers.ts +38 -14
- package/src/dalvikExecutableUnparser.test.ts +3 -2
- package/src/dalvikExecutableUnparser.ts +4 -4
- package/src/disjunctionParser.test-d.ts +105 -0
- package/src/disjunctionParser.ts +18 -15
- package/src/elementSwitchParser.test-d.ts +74 -0
- package/src/elementSwitchParser.ts +51 -0
- package/src/exactSequenceParser.test-d.ts +43 -0
- package/src/exactSequenceParser.ts +13 -8
- package/src/fetchCid.ts +2 -76
- package/src/index.test.ts +22 -1
- package/src/index.ts +119 -2
- package/src/inputReader.ts +53 -0
- package/src/java.ts +708 -0
- package/src/javaKeyStoreParser.ts +18 -32
- package/src/javaParser.test.ts +1592 -0
- package/src/javaParser.ts +2640 -0
- package/src/javaScript.ts +36 -0
- package/src/javaScriptParser.ts +57 -0
- package/src/javaScriptUnparser.test.ts +37 -0
- package/src/javaScriptUnparser.ts +7 -0
- package/src/javaUnparser.test.ts +37 -0
- package/src/javaUnparser.ts +640 -0
- package/src/jsonParser.ts +6 -27
- package/src/lookaheadParser.ts +2 -6
- package/src/negativeLookaheadParser.ts +1 -3
- package/src/nonEmptyArrayParser.ts +1 -3
- package/src/objectParser.test-d.ts +152 -0
- package/src/objectParser.test.ts +71 -0
- package/src/objectParser.ts +69 -0
- package/src/optionalParser.ts +1 -3
- package/src/parser.test.ts +151 -4
- package/src/parser.ts +11 -1
- package/src/parserConsumedSequenceParser.ts +2 -4
- package/src/parserContext.ts +26 -11
- package/src/parserError.ts +17 -3
- package/src/regexpParser.test.ts +264 -0
- package/src/regexpParser.ts +126 -0
- package/src/regularExpression.ts +24 -0
- package/src/regularExpressionParser.test.ts +102 -0
- package/src/regularExpressionParser.ts +920 -0
- package/src/separatedArrayParser.ts +1 -3
- package/src/separatedNonEmptyArrayParser.ts +1 -3
- package/src/sliceBoundedParser.test.ts +2 -2
- package/src/sliceBoundedParser.ts +15 -19
- package/src/smaliParser.test.ts +64 -0
- package/src/smaliParser.test.ts.md +12 -12
- package/src/smaliParser.test.ts.snap +0 -0
- package/src/smaliParser.ts +246 -534
- package/src/stringEscapes.ts +253 -0
- package/src/symbolicExpression.ts +17 -0
- package/src/symbolicExpressionParser.test.ts +466 -0
- package/src/symbolicExpressionParser.ts +190 -0
- package/src/terminatedArrayParser.test.ts +9 -6
- package/src/terminatedArrayParser.ts +25 -29
- package/src/tupleParser.ts +21 -18
- package/src/unionParser.test-d.ts +105 -0
- package/src/unionParser.test.ts +18 -17
- package/src/unionParser.ts +28 -16
- package/src/zig.ts +411 -0
- package/src/zigParser.test.ts +1693 -0
- package/src/zigParser.ts +1745 -0
- package/src/zigUnparser.test.ts +37 -0
- package/src/zigUnparser.ts +615 -0
- package/src/zipParser.ts +20 -56
- package/src/zipUnparser.test.ts +1 -1
- package/src/zipUnparser.ts +22 -7
- package/tsconfig.json +2 -2
- package/build/exactElementSwitchParser.d.ts +0 -3
- package/src/exactElementSwitchParser.ts +0 -41
|
@@ -31,10 +31,11 @@ import {
|
|
|
31
31
|
} from './dalvikExecutableParser/typeParsers.js';
|
|
32
32
|
import { type DalvikExecutableField, type DalvikExecutableMethod } from './dalvikExecutable.js';
|
|
33
33
|
import {
|
|
34
|
-
type
|
|
34
|
+
type CodeUnit, isoCodeUnit,
|
|
35
|
+
type IndexIntoCallSiteIds, type IndexIntoFieldIds, type IndexIntoMethodIds, type IndexIntoPrototypeIds, type IndexIntoStringIds, type IndexIntoTypeIds, isoIndexIntoCallSiteIds, isoIndexIntoFieldIds, isoIndexIntoMethodIds, isoIndexIntoPrototypeIds, isoIndexIntoStringIds, isoIndexIntoTypeIds,
|
|
35
36
|
} from './dalvikExecutableParser/typedNumbers.js';
|
|
36
37
|
import { createExactElementParser } from './exactElementParser.js';
|
|
37
|
-
import { createElementSwitchParser } from './
|
|
38
|
+
import { createElementSwitchParser } from './elementSwitchParser.js';
|
|
38
39
|
import { type Parser, setParserName } from './parser.js';
|
|
39
40
|
import { promiseCompose } from './promiseCompose.js';
|
|
40
41
|
import { createSliceBoundedParser } from './sliceBoundedParser.js';
|
|
@@ -43,6 +44,7 @@ import { parserCreatorCompose } from './parserCreatorCompose.js';
|
|
|
43
44
|
import { createQuantifierParser } from './quantifierParser.js';
|
|
44
45
|
import { createDebugLogInputParser } from './debugLogInputParser.js';
|
|
45
46
|
import { createNegativeLookaheadParser } from './negativeLookaheadParser.js';
|
|
47
|
+
import { createObjectParser } from './objectParser.js';
|
|
46
48
|
import { createTupleParser } from './tupleParser.js';
|
|
47
49
|
|
|
48
50
|
// https://source.android.com/docs/core/runtime/dalvik-bytecode
|
|
@@ -69,12 +71,10 @@ type DalvikBytecodeOperationNoOperation = {
|
|
|
69
71
|
operation: 'nop';
|
|
70
72
|
};
|
|
71
73
|
|
|
72
|
-
const dalvikBytecodeOperationNoOperationParser: Parser<DalvikBytecodeOperationNoOperation, Uint8Array> =
|
|
73
|
-
createExactUshortParser(0x00_00), // nop is 2 bytes: 0x00 0x00
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}),
|
|
77
|
-
);
|
|
74
|
+
const dalvikBytecodeOperationNoOperationParser: Parser<DalvikBytecodeOperationNoOperation, Uint8Array> = createObjectParser({
|
|
75
|
+
_opcode: createExactUshortParser(0x00_00), // nop is 2 bytes: 0x00 0x00
|
|
76
|
+
operation: 'nop' as const,
|
|
77
|
+
});
|
|
78
78
|
|
|
79
79
|
setParserName(dalvikBytecodeOperationNoOperationParser, 'dalvikBytecodeOperationNoOperationParser');
|
|
80
80
|
|
|
@@ -253,9 +253,60 @@ const dalvikBytecodeOperationInvokePolymorphicRangeParser: Parser<DalvikBytecode
|
|
|
253
253
|
|
|
254
254
|
setParserName(dalvikBytecodeOperationInvokePolymorphicRangeParser, 'dalvikBytecodeOperationInvokePolymorphicRangeParser');
|
|
255
255
|
|
|
256
|
+
// Invoke-custom and invoke-custom/range (Android 8.0+)
|
|
257
|
+
type DalvikBytecodeOperationInvokeCustom = {
|
|
258
|
+
operation: 'invoke-custom';
|
|
259
|
+
callSiteIndex: IndexIntoCallSiteIds;
|
|
260
|
+
registers: number[];
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const dalvikBytecodeOperationInvokeCustomParser: Parser<DalvikBytecodeOperationInvokeCustom, Uint8Array> = promiseCompose(
|
|
264
|
+
createTupleParser([
|
|
265
|
+
createExactElementParser(0xFC),
|
|
266
|
+
createDalvikBytecodeFormat35cParser({
|
|
267
|
+
isoIndex: isoIndexIntoCallSiteIds,
|
|
268
|
+
}),
|
|
269
|
+
]),
|
|
270
|
+
([
|
|
271
|
+
_opcode,
|
|
272
|
+
{ index, registers },
|
|
273
|
+
]) => ({
|
|
274
|
+
operation: 'invoke-custom',
|
|
275
|
+
callSiteIndex: index,
|
|
276
|
+
registers,
|
|
277
|
+
}),
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
setParserName(dalvikBytecodeOperationInvokeCustomParser, 'dalvikBytecodeOperationInvokeCustomParser');
|
|
281
|
+
|
|
282
|
+
type DalvikBytecodeOperationInvokeCustomRange = {
|
|
283
|
+
operation: 'invoke-custom/range';
|
|
284
|
+
callSiteIndex: IndexIntoCallSiteIds;
|
|
285
|
+
registers: number[];
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const dalvikBytecodeOperationInvokeCustomRangeParser: Parser<DalvikBytecodeOperationInvokeCustomRange, Uint8Array> = promiseCompose(
|
|
289
|
+
createTupleParser([
|
|
290
|
+
createExactElementParser(0xFD),
|
|
291
|
+
createDalvikBytecodeFormat3rcParser({
|
|
292
|
+
isoIndex: isoIndexIntoCallSiteIds,
|
|
293
|
+
}),
|
|
294
|
+
]),
|
|
295
|
+
([
|
|
296
|
+
_opcode,
|
|
297
|
+
{ index, registers },
|
|
298
|
+
]) => ({
|
|
299
|
+
operation: 'invoke-custom/range',
|
|
300
|
+
callSiteIndex: index,
|
|
301
|
+
registers,
|
|
302
|
+
}),
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
setParserName(dalvikBytecodeOperationInvokeCustomRangeParser, 'dalvikBytecodeOperationInvokeCustomRangeParser');
|
|
306
|
+
|
|
256
307
|
type DalvikBytecodeOperationGoto = {
|
|
257
308
|
operation: 'goto';
|
|
258
|
-
|
|
309
|
+
branchOffsetCodeUnit: CodeUnit;
|
|
259
310
|
};
|
|
260
311
|
|
|
261
312
|
const dalvikBytecodeOperationGotoParser: Parser<DalvikBytecodeOperationGoto, Uint8Array> = promiseCompose(
|
|
@@ -263,15 +314,15 @@ const dalvikBytecodeOperationGotoParser: Parser<DalvikBytecodeOperationGoto, Uin
|
|
|
263
314
|
createExactElementParser(0x28),
|
|
264
315
|
dalvikBytecodeFormat10tParser,
|
|
265
316
|
]),
|
|
266
|
-
([ _opcode, {
|
|
317
|
+
([ _opcode, { branchOffsetCodeUnit } ]) => ({
|
|
267
318
|
operation: 'goto',
|
|
268
|
-
|
|
319
|
+
branchOffsetCodeUnit,
|
|
269
320
|
}),
|
|
270
321
|
);
|
|
271
322
|
|
|
272
323
|
type DalvikBytecodeOperationGoto16 = {
|
|
273
324
|
operation: 'goto/16';
|
|
274
|
-
|
|
325
|
+
branchOffsetCodeUnit: CodeUnit;
|
|
275
326
|
};
|
|
276
327
|
|
|
277
328
|
const dalvikBytecodeOperationGoto16Parser: Parser<DalvikBytecodeOperationGoto16, Uint8Array> = promiseCompose(
|
|
@@ -279,15 +330,15 @@ const dalvikBytecodeOperationGoto16Parser: Parser<DalvikBytecodeOperationGoto16,
|
|
|
279
330
|
createExactElementParser(0x29),
|
|
280
331
|
dalvikBytecodeFormat20tParser,
|
|
281
332
|
]),
|
|
282
|
-
([ _opcode, {
|
|
333
|
+
([ _opcode, { branchOffsetCodeUnit } ]) => ({
|
|
283
334
|
operation: 'goto/16',
|
|
284
|
-
|
|
335
|
+
branchOffsetCodeUnit,
|
|
285
336
|
}),
|
|
286
337
|
);
|
|
287
338
|
|
|
288
339
|
type DalvikBytecodeOperationGoto32 = {
|
|
289
340
|
operation: 'goto/32';
|
|
290
|
-
|
|
341
|
+
branchOffsetCodeUnit: CodeUnit;
|
|
291
342
|
};
|
|
292
343
|
|
|
293
344
|
const dalvikBytecodeOperationGoto32Parser: Parser<DalvikBytecodeOperationGoto32, Uint8Array> = promiseCompose(
|
|
@@ -295,15 +346,15 @@ const dalvikBytecodeOperationGoto32Parser: Parser<DalvikBytecodeOperationGoto32,
|
|
|
295
346
|
createExactElementParser(0x2A),
|
|
296
347
|
dalvikBytecodeFormat30tParser,
|
|
297
348
|
]),
|
|
298
|
-
([ _opcode, {
|
|
349
|
+
([ _opcode, { branchOffsetCodeUnit } ]) => ({
|
|
299
350
|
operation: 'goto/32',
|
|
300
|
-
|
|
351
|
+
branchOffsetCodeUnit,
|
|
301
352
|
}),
|
|
302
353
|
);
|
|
303
354
|
|
|
304
355
|
type DalvikBytecodeOperationPackedSwitch = {
|
|
305
356
|
operation: 'packed-switch';
|
|
306
|
-
|
|
357
|
+
branchOffsetCodeUnit: CodeUnit;
|
|
307
358
|
registers: number[];
|
|
308
359
|
};
|
|
309
360
|
|
|
@@ -312,9 +363,9 @@ const dalvikBytecodeOperationPackedSwitchParser: Parser<DalvikBytecodeOperationP
|
|
|
312
363
|
createExactElementParser(0x2B),
|
|
313
364
|
dalvikBytecodeFormat31tParser,
|
|
314
365
|
]),
|
|
315
|
-
([ _opcode, {
|
|
366
|
+
([ _opcode, { branchOffsetCodeUnit, registers } ]) => ({
|
|
316
367
|
operation: 'packed-switch',
|
|
317
|
-
|
|
368
|
+
branchOffsetCodeUnit,
|
|
318
369
|
registers,
|
|
319
370
|
}),
|
|
320
371
|
);
|
|
@@ -324,7 +375,7 @@ setParserName(dalvikBytecodeOperationPackedSwitchParser, 'dalvikBytecodeOperatio
|
|
|
324
375
|
type DalvikBytecodeOperationPackedSwitchPayload = {
|
|
325
376
|
operation: 'packed-switch-payload';
|
|
326
377
|
value: number;
|
|
327
|
-
|
|
378
|
+
branchOffsetsCodeUnit: CodeUnit[];
|
|
328
379
|
};
|
|
329
380
|
|
|
330
381
|
const dalvikBytecodeOperationPackedSwitchPayloadParser: Parser<DalvikBytecodeOperationPackedSwitchPayload, Uint8Array> = parserCreatorCompose(
|
|
@@ -347,7 +398,7 @@ const dalvikBytecodeOperationPackedSwitchPayloadParser: Parser<DalvikBytecodeOpe
|
|
|
347
398
|
branchOffsets => ({
|
|
348
399
|
operation: 'packed-switch-payload' as const,
|
|
349
400
|
value,
|
|
350
|
-
branchOffsets,
|
|
401
|
+
branchOffsetsCodeUnit: branchOffsets.map(isoCodeUnit.wrap),
|
|
351
402
|
}),
|
|
352
403
|
),
|
|
353
404
|
)();
|
|
@@ -356,7 +407,7 @@ setParserName(dalvikBytecodeOperationPackedSwitchPayloadParser, 'dalvikBytecodeO
|
|
|
356
407
|
|
|
357
408
|
type DalvikBytecodeOperationSparseSwitch = {
|
|
358
409
|
operation: 'sparse-switch';
|
|
359
|
-
|
|
410
|
+
branchOffsetCodeUnit: CodeUnit;
|
|
360
411
|
registers: number[];
|
|
361
412
|
};
|
|
362
413
|
|
|
@@ -365,9 +416,9 @@ const dalvikBytecodeOperationSparseSwitchParser: Parser<DalvikBytecodeOperationS
|
|
|
365
416
|
createExactElementParser(0x2C),
|
|
366
417
|
dalvikBytecodeFormat31tParser,
|
|
367
418
|
]),
|
|
368
|
-
([ _opcode, {
|
|
419
|
+
([ _opcode, { branchOffsetCodeUnit, registers } ]) => ({
|
|
369
420
|
operation: 'sparse-switch',
|
|
370
|
-
|
|
421
|
+
branchOffsetCodeUnit,
|
|
371
422
|
registers,
|
|
372
423
|
}),
|
|
373
424
|
);
|
|
@@ -377,7 +428,7 @@ setParserName(dalvikBytecodeOperationSparseSwitchParser, 'dalvikBytecodeOperatio
|
|
|
377
428
|
type DalvikBytecodeOperationSparseSwitchPayload = {
|
|
378
429
|
operation: 'sparse-switch-payload';
|
|
379
430
|
keys: number[];
|
|
380
|
-
|
|
431
|
+
branchOffsetsCodeUnit: CodeUnit[];
|
|
381
432
|
};
|
|
382
433
|
|
|
383
434
|
const dalvikBytecodeOperationSparseSwitchPayloadParser: Parser<DalvikBytecodeOperationSparseSwitchPayload, Uint8Array> = parserCreatorCompose(
|
|
@@ -404,7 +455,7 @@ const dalvikBytecodeOperationSparseSwitchPayloadParser: Parser<DalvikBytecodeOpe
|
|
|
404
455
|
([ keys, branchOffsets ]) => ({
|
|
405
456
|
operation: 'sparse-switch-payload' as const,
|
|
406
457
|
keys,
|
|
407
|
-
branchOffsets,
|
|
458
|
+
branchOffsetsCodeUnit: branchOffsets.map(isoCodeUnit.wrap),
|
|
408
459
|
}),
|
|
409
460
|
),
|
|
410
461
|
)();
|
|
@@ -1293,6 +1344,10 @@ const dalvikBytecodeOperationDivideFloatParser = createDalvikBytecodeOperationBi
|
|
|
1293
1344
|
|
|
1294
1345
|
type DalvikBytecodeOperationDivideFloat = Awaited<ReturnType<typeof dalvikBytecodeOperationDivideFloatParser>>;
|
|
1295
1346
|
|
|
1347
|
+
const dalvikBytecodeOperationRemainderFloatParser = createDalvikBytecodeOperationBinaryOperation('rem-float', 0xAA);
|
|
1348
|
+
|
|
1349
|
+
type DalvikBytecodeOperationRemainderFloat = Awaited<ReturnType<typeof dalvikBytecodeOperationRemainderFloatParser>>;
|
|
1350
|
+
|
|
1296
1351
|
const dalvikBytecodeOperationAddDoubleParser = createDalvikBytecodeOperationBinaryOperation('add-double', 0xAB);
|
|
1297
1352
|
|
|
1298
1353
|
type DalvikBytecodeOperationAddDouble = Awaited<ReturnType<typeof dalvikBytecodeOperationAddDoubleParser>>;
|
|
@@ -1340,6 +1395,7 @@ type DalvikBytecodeOperationBinaryOperation =
|
|
|
1340
1395
|
| DalvikBytecodeOperationSubtractFloat
|
|
1341
1396
|
| DalvikBytecodeOperationMultiplyFloat
|
|
1342
1397
|
| DalvikBytecodeOperationDivideFloat
|
|
1398
|
+
| DalvikBytecodeOperationRemainderFloat
|
|
1343
1399
|
| DalvikBytecodeOperationAddDouble
|
|
1344
1400
|
| DalvikBytecodeOperationSubtractDouble
|
|
1345
1401
|
| DalvikBytecodeOperationMultiplyDouble
|
|
@@ -1374,6 +1430,7 @@ const dalvikBytecodeOperationBinaryOperationParser: Parser<DalvikBytecodeOperati
|
|
|
1374
1430
|
dalvikBytecodeOperationSubtractFloatParser,
|
|
1375
1431
|
dalvikBytecodeOperationMultiplyFloatParser,
|
|
1376
1432
|
dalvikBytecodeOperationDivideFloatParser,
|
|
1433
|
+
dalvikBytecodeOperationRemainderFloatParser,
|
|
1377
1434
|
dalvikBytecodeOperationAddDoubleParser,
|
|
1378
1435
|
dalvikBytecodeOperationSubtractDoubleParser,
|
|
1379
1436
|
dalvikBytecodeOperationMultiplyDoubleParser,
|
|
@@ -1535,16 +1592,16 @@ setParserName(dalvikBytecodeOperationUnaryOperationParser, 'dalvikBytecodeOperat
|
|
|
1535
1592
|
const createDalvikBytecodeOperationIfTestCommutative = <T extends string>(operation: T, opcode: number): Parser<{
|
|
1536
1593
|
operation: T;
|
|
1537
1594
|
registers: number[];
|
|
1538
|
-
|
|
1595
|
+
branchOffsetCodeUnit: CodeUnit;
|
|
1539
1596
|
}, Uint8Array> => promiseCompose(
|
|
1540
1597
|
createTupleParser([
|
|
1541
1598
|
createExactElementParser(opcode),
|
|
1542
1599
|
createDalvikBytecodeFormat22tParser(),
|
|
1543
1600
|
]),
|
|
1544
|
-
([ _opcode, { registers,
|
|
1601
|
+
([ _opcode, { registers, branchOffsetCodeUnit } ]) => ({
|
|
1545
1602
|
operation,
|
|
1546
1603
|
registers: registers.sort((a, b) => a - b),
|
|
1547
|
-
|
|
1604
|
+
branchOffsetCodeUnit,
|
|
1548
1605
|
}),
|
|
1549
1606
|
);
|
|
1550
1607
|
|
|
@@ -1552,16 +1609,16 @@ const createDalvikBytecodeOperationIfTestCommutative = <T extends string>(operat
|
|
|
1552
1609
|
const createDalvikBytecodeOperationIfTest = <T extends string>(operation: T, opcode: number): Parser<{
|
|
1553
1610
|
operation: T;
|
|
1554
1611
|
registers: number[];
|
|
1555
|
-
|
|
1612
|
+
branchOffsetCodeUnit: CodeUnit;
|
|
1556
1613
|
}, Uint8Array> => promiseCompose(
|
|
1557
1614
|
createTupleParser([
|
|
1558
1615
|
createExactElementParser(opcode),
|
|
1559
1616
|
createDalvikBytecodeFormat22tParser(),
|
|
1560
1617
|
]),
|
|
1561
|
-
([ _opcode, { registers,
|
|
1618
|
+
([ _opcode, { registers, branchOffsetCodeUnit } ]) => ({
|
|
1562
1619
|
operation,
|
|
1563
1620
|
registers: registers.reverse(),
|
|
1564
|
-
|
|
1621
|
+
branchOffsetCodeUnit,
|
|
1565
1622
|
}),
|
|
1566
1623
|
);
|
|
1567
1624
|
|
|
@@ -1612,16 +1669,16 @@ setParserName(dalvikBytecodeOperationIfTestParser, 'dalvikBytecodeOperationIfTes
|
|
|
1612
1669
|
const createDalvikBytecodeOperationIfTestZero = <T extends string>(operation: T, opcode: number): Parser<{
|
|
1613
1670
|
operation: T;
|
|
1614
1671
|
registers: number[];
|
|
1615
|
-
|
|
1672
|
+
branchOffsetCodeUnit: CodeUnit;
|
|
1616
1673
|
}, Uint8Array> => promiseCompose(
|
|
1617
1674
|
createTupleParser([
|
|
1618
1675
|
createExactElementParser(opcode),
|
|
1619
1676
|
createDalvikBytecodeFormat21tParser(),
|
|
1620
1677
|
]),
|
|
1621
|
-
([ _opcode, { registers,
|
|
1678
|
+
([ _opcode, { registers, branchOffsetCodeUnit } ]) => ({
|
|
1622
1679
|
operation,
|
|
1623
1680
|
registers,
|
|
1624
|
-
|
|
1681
|
+
branchOffsetCodeUnit,
|
|
1625
1682
|
}),
|
|
1626
1683
|
);
|
|
1627
1684
|
|
|
@@ -1735,6 +1792,28 @@ const dalvikBytecodeOperationConstMethodHandleParser: Parser<DalvikBytecodeOpera
|
|
|
1735
1792
|
|
|
1736
1793
|
setParserName(dalvikBytecodeOperationConstMethodHandleParser, 'dalvikBytecodeOperationConstMethodHandleParser');
|
|
1737
1794
|
|
|
1795
|
+
type DalvikBytecodeOperationConstMethodType = {
|
|
1796
|
+
operation: 'const-method-type';
|
|
1797
|
+
protoIndex: IndexIntoPrototypeIds;
|
|
1798
|
+
registers: number[];
|
|
1799
|
+
};
|
|
1800
|
+
|
|
1801
|
+
const dalvikBytecodeOperationConstMethodTypeParser: Parser<DalvikBytecodeOperationConstMethodType, Uint8Array> = promiseCompose(
|
|
1802
|
+
createTupleParser([
|
|
1803
|
+
createExactElementParser(0xFF),
|
|
1804
|
+
createDalvikBytecodeFormat21cParser({
|
|
1805
|
+
isoIndex: isoIndexIntoPrototypeIds,
|
|
1806
|
+
}),
|
|
1807
|
+
]),
|
|
1808
|
+
([ _opcode, { index, registers } ]) => ({
|
|
1809
|
+
operation: 'const-method-type',
|
|
1810
|
+
protoIndex: index,
|
|
1811
|
+
registers,
|
|
1812
|
+
}),
|
|
1813
|
+
);
|
|
1814
|
+
|
|
1815
|
+
setParserName(dalvikBytecodeOperationConstMethodTypeParser, 'dalvikBytecodeOperationConstMethodTypeParser');
|
|
1816
|
+
|
|
1738
1817
|
type DalvikBytecodeOperationNewInstance = {
|
|
1739
1818
|
operation: 'new-instance';
|
|
1740
1819
|
typeIndex: IndexIntoTypeIds;
|
|
@@ -1825,7 +1904,7 @@ setParserName(dalvikBytecodeOperationFilledNewArrayRangeParser, 'dalvikBytecodeO
|
|
|
1825
1904
|
|
|
1826
1905
|
type DalvikBytecodeOperationFillArrayData = {
|
|
1827
1906
|
operation: 'fill-array-data';
|
|
1828
|
-
|
|
1907
|
+
branchOffsetCodeUnit: CodeUnit;
|
|
1829
1908
|
registers: number[];
|
|
1830
1909
|
};
|
|
1831
1910
|
|
|
@@ -1834,9 +1913,9 @@ const dalvikBytecodeOperationFillArrayDataParser: Parser<DalvikBytecodeOperation
|
|
|
1834
1913
|
createExactElementParser(0x26),
|
|
1835
1914
|
dalvikBytecodeFormat31tParser,
|
|
1836
1915
|
]),
|
|
1837
|
-
([ _opcode, {
|
|
1916
|
+
([ _opcode, { branchOffsetCodeUnit, registers } ]) => ({
|
|
1838
1917
|
operation: 'fill-array-data',
|
|
1839
|
-
|
|
1918
|
+
branchOffsetCodeUnit,
|
|
1840
1919
|
registers,
|
|
1841
1920
|
}),
|
|
1842
1921
|
);
|
|
@@ -1945,15 +2024,11 @@ type DalvikBytecodeOperationReturnVoid = {
|
|
|
1945
2024
|
operation: 'return-void';
|
|
1946
2025
|
};
|
|
1947
2026
|
|
|
1948
|
-
const dalvikBytecodeOperationReturnVoidParser: Parser<DalvikBytecodeOperationReturnVoid, Uint8Array> =
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
() => ({
|
|
1954
|
-
operation: 'return-void',
|
|
1955
|
-
}),
|
|
1956
|
-
);
|
|
2027
|
+
const dalvikBytecodeOperationReturnVoidParser: Parser<DalvikBytecodeOperationReturnVoid, Uint8Array> = createObjectParser({
|
|
2028
|
+
_opcode: createExactElementParser(0x0E),
|
|
2029
|
+
_format: dalvikBytecodeFormat10xParser,
|
|
2030
|
+
operation: 'return-void' as const,
|
|
2031
|
+
});
|
|
1957
2032
|
|
|
1958
2033
|
setParserName(dalvikBytecodeOperationReturnVoidParser, 'dalvikBytecodeOperationReturnVoidParser');
|
|
1959
2034
|
|
|
@@ -2123,6 +2198,42 @@ const dalvikBytecodeOperationMoveWide16Parser: Parser<DalvikBytecodeOperationMov
|
|
|
2123
2198
|
|
|
2124
2199
|
setParserName(dalvikBytecodeOperationMoveWide16Parser, 'dalvikBytecodeOperationMoveWide16Parser');
|
|
2125
2200
|
|
|
2201
|
+
type DalvikBytecodeOperationMove16 = {
|
|
2202
|
+
operation: 'move/16';
|
|
2203
|
+
registers: number[];
|
|
2204
|
+
};
|
|
2205
|
+
|
|
2206
|
+
const dalvikBytecodeOperationMove16Parser: Parser<DalvikBytecodeOperationMove16, Uint8Array> = promiseCompose(
|
|
2207
|
+
createTupleParser([
|
|
2208
|
+
createExactElementParser(0x03),
|
|
2209
|
+
dalvikBytecodeFormat32xParser,
|
|
2210
|
+
]),
|
|
2211
|
+
([ _opcode, { registers } ]) => ({
|
|
2212
|
+
operation: 'move/16',
|
|
2213
|
+
registers,
|
|
2214
|
+
}),
|
|
2215
|
+
);
|
|
2216
|
+
|
|
2217
|
+
setParserName(dalvikBytecodeOperationMove16Parser, 'dalvikBytecodeOperationMove16Parser');
|
|
2218
|
+
|
|
2219
|
+
type DalvikBytecodeOperationMoveObject16 = {
|
|
2220
|
+
operation: 'move-object/16';
|
|
2221
|
+
registers: number[];
|
|
2222
|
+
};
|
|
2223
|
+
|
|
2224
|
+
const dalvikBytecodeOperationMoveObject16Parser: Parser<DalvikBytecodeOperationMoveObject16, Uint8Array> = promiseCompose(
|
|
2225
|
+
createTupleParser([
|
|
2226
|
+
createExactElementParser(0x09),
|
|
2227
|
+
dalvikBytecodeFormat32xParser,
|
|
2228
|
+
]),
|
|
2229
|
+
([ _opcode, { registers } ]) => ({
|
|
2230
|
+
operation: 'move-object/16',
|
|
2231
|
+
registers,
|
|
2232
|
+
}),
|
|
2233
|
+
);
|
|
2234
|
+
|
|
2235
|
+
setParserName(dalvikBytecodeOperationMoveObject16Parser, 'dalvikBytecodeOperationMoveObject16Parser');
|
|
2236
|
+
|
|
2126
2237
|
const createDalvikBytecodeOperationReturn1Parser = createDalvikBytecodeMoveResult1Parser;
|
|
2127
2238
|
|
|
2128
2239
|
const dalvikBytecodeOperationReturnParser = createDalvikBytecodeOperationReturn1Parser('return', 0x0F);
|
|
@@ -2384,7 +2495,7 @@ const dalvikBytecodeOperationCompareParser: Parser<DalvikBytecodeOperationCompar
|
|
|
2384
2495
|
|
|
2385
2496
|
setParserName(dalvikBytecodeOperationCompareParser, 'dalvikBytecodeOperationCompareParser');
|
|
2386
2497
|
|
|
2387
|
-
export type
|
|
2498
|
+
export type RawDalvikBytecodeOperation =
|
|
2388
2499
|
| DalvikBytecodeOperationNoOperation
|
|
2389
2500
|
|
|
2390
2501
|
| DalvikBytecodeOperationIfTest
|
|
@@ -2414,14 +2525,18 @@ export type DalvikBytecodeOperation =
|
|
|
2414
2525
|
| DalvikBytecodeOperationMoveWide
|
|
2415
2526
|
| DalvikBytecodeOperationMoveObject
|
|
2416
2527
|
| DalvikBytecodeOperationMoveFrom16
|
|
2528
|
+
| DalvikBytecodeOperationMove16
|
|
2417
2529
|
| DalvikBytecodeOperationMoveWideFrom16
|
|
2418
2530
|
| DalvikBytecodeOperationMoveObjectFrom16
|
|
2419
2531
|
| DalvikBytecodeOperationMoveWide16
|
|
2532
|
+
| DalvikBytecodeOperationMoveObject16
|
|
2420
2533
|
|
|
2421
2534
|
| DalvikBytecodeOperationInvoke
|
|
2422
2535
|
| DalvikBytecodeOperationInvokeRange
|
|
2423
2536
|
| DalvikBytecodeOperationInvokePolymorphic
|
|
2424
2537
|
| DalvikBytecodeOperationInvokePolymorphicRange
|
|
2538
|
+
| DalvikBytecodeOperationInvokeCustom
|
|
2539
|
+
| DalvikBytecodeOperationInvokeCustomRange
|
|
2425
2540
|
|
|
2426
2541
|
| DalvikBytecodeOperationNewInstance
|
|
2427
2542
|
|
|
@@ -2446,6 +2561,7 @@ export type DalvikBytecodeOperation =
|
|
|
2446
2561
|
| DalvikBytecodeOperationConstString
|
|
2447
2562
|
| DalvikBytecodeOperationConstStringJumbo
|
|
2448
2563
|
| DalvikBytecodeOperationConstMethodHandle
|
|
2564
|
+
| DalvikBytecodeOperationConstMethodType
|
|
2449
2565
|
| DalvikBytecodeOperationConstClass
|
|
2450
2566
|
|
|
2451
2567
|
| DalvikBytecodeOperationMonitorEnter
|
|
@@ -2457,8 +2573,8 @@ export type DalvikBytecodeOperation =
|
|
|
2457
2573
|
|
|
2458
2574
|
| DalvikBytecodeOperationReturnVoid
|
|
2459
2575
|
| DalvikBytecodeOperationReturn1;
|
|
2460
|
-
export const
|
|
2461
|
-
getRegisters(operation:
|
|
2576
|
+
export const rawDalvikBytecodeOperationCompanion = {
|
|
2577
|
+
getRegisters(operation: RawDalvikBytecodeOperation): number[] {
|
|
2462
2578
|
if (operation && typeof operation === 'object' && 'registers' in operation) {
|
|
2463
2579
|
return operation.registers;
|
|
2464
2580
|
}
|
|
@@ -2487,6 +2603,10 @@ const dalvikBytecodeOperationOpcodeMap = new Map<number, Parser<unknown, Uint8Ar
|
|
|
2487
2603
|
[ 0xFA, dalvikBytecodeOperationInvokePolymorphicParser ],
|
|
2488
2604
|
[ 0xFB, dalvikBytecodeOperationInvokePolymorphicRangeParser ],
|
|
2489
2605
|
|
|
2606
|
+
// Invoke custom operations
|
|
2607
|
+
[ 0xFC, dalvikBytecodeOperationInvokeCustomParser ],
|
|
2608
|
+
[ 0xFD, dalvikBytecodeOperationInvokeCustomRangeParser ],
|
|
2609
|
+
|
|
2490
2610
|
// New instance/array operations
|
|
2491
2611
|
[ 0x22, dalvikBytecodeOperationNewInstanceParser ],
|
|
2492
2612
|
[ 0x23, dalvikBytecodeOperationNewArrayParser ],
|
|
@@ -2549,6 +2669,7 @@ const dalvikBytecodeOperationOpcodeMap = new Map<number, Parser<unknown, Uint8Ar
|
|
|
2549
2669
|
[ 0x1A, dalvikBytecodeOperationConstStringParser ],
|
|
2550
2670
|
[ 0x1B, dalvikBytecodeOperationConstStringJumboParser ],
|
|
2551
2671
|
[ 0xFE, dalvikBytecodeOperationConstMethodHandleParser ],
|
|
2672
|
+
[ 0xFF, dalvikBytecodeOperationConstMethodTypeParser ],
|
|
2552
2673
|
[ 0x1C, dalvikBytecodeOperationConstClassParser ],
|
|
2553
2674
|
|
|
2554
2675
|
// Monitor operations
|
|
@@ -2585,6 +2706,8 @@ const dalvikBytecodeOperationOpcodeMap = new Map<number, Parser<unknown, Uint8Ar
|
|
|
2585
2706
|
[ 0x05, dalvikBytecodeOperationMoveWideFrom16Parser ],
|
|
2586
2707
|
[ 0x08, dalvikBytecodeOperationMoveObjectFrom16Parser ],
|
|
2587
2708
|
[ 0x06, dalvikBytecodeOperationMoveWide16Parser ],
|
|
2709
|
+
[ 0x03, dalvikBytecodeOperationMove16Parser ],
|
|
2710
|
+
[ 0x09, dalvikBytecodeOperationMoveObject16Parser ],
|
|
2588
2711
|
|
|
2589
2712
|
// Const value operations
|
|
2590
2713
|
[ 0x12, dalvikBytecodeOperationConst4Parser ],
|
|
@@ -2646,7 +2769,7 @@ const dalvikBytecodeOperationOpcodeMap = new Map<number, Parser<unknown, Uint8Ar
|
|
|
2646
2769
|
[ 0xA7, dalvikBytecodeOperationSubtractFloatParser ],
|
|
2647
2770
|
[ 0xA8, dalvikBytecodeOperationMultiplyFloatParser ],
|
|
2648
2771
|
[ 0xA9, dalvikBytecodeOperationDivideFloatParser ],
|
|
2649
|
-
|
|
2772
|
+
[ 0xAA, dalvikBytecodeOperationRemainderFloatParser ],
|
|
2650
2773
|
[ 0xAB, dalvikBytecodeOperationAddDoubleParser ],
|
|
2651
2774
|
[ 0xAC, dalvikBytecodeOperationSubtractDoubleParser ],
|
|
2652
2775
|
[ 0xAD, dalvikBytecodeOperationMultiplyDoubleParser ],
|
|
@@ -2773,7 +2896,7 @@ const dalvikBytecodeOperationOpcodeMap = new Map<number, Parser<unknown, Uint8Ar
|
|
|
2773
2896
|
]);
|
|
2774
2897
|
|
|
2775
2898
|
// Fallback parser for multi-byte opcodes (nop and payload instructions)
|
|
2776
|
-
const dalvikBytecodeOperationMultiByteParser: Parser<
|
|
2899
|
+
const dalvikBytecodeOperationMultiByteParser: Parser<RawDalvikBytecodeOperation, Uint8Array> = createDisjunctionParser([
|
|
2777
2900
|
dalvikBytecodeOperationNoOperationParser,
|
|
2778
2901
|
dalvikBytecodeOperationPackedSwitchPayloadParser,
|
|
2779
2902
|
dalvikBytecodeOperationSparseSwitchPayloadParser,
|
|
@@ -2782,11 +2905,11 @@ const dalvikBytecodeOperationMultiByteParser: Parser<DalvikBytecodeOperation, Ui
|
|
|
2782
2905
|
|
|
2783
2906
|
setParserName(dalvikBytecodeOperationMultiByteParser, 'dalvikBytecodeOperationMultiByteParser');
|
|
2784
2907
|
|
|
2785
|
-
const dalvikBytecodeOperationParser: Parser<
|
|
2908
|
+
const dalvikBytecodeOperationParser: Parser<RawDalvikBytecodeOperation | undefined, Uint8Array> = promiseCompose(
|
|
2786
2909
|
createTupleParser([
|
|
2787
2910
|
() => {},
|
|
2788
2911
|
// CreateDebugLogInputParser(),
|
|
2789
|
-
createElementSwitchParser
|
|
2912
|
+
createElementSwitchParser(
|
|
2790
2913
|
dalvikBytecodeOperationOpcodeMap,
|
|
2791
2914
|
dalvikBytecodeOperationMultiByteParser,
|
|
2792
2915
|
),
|
|
@@ -2796,21 +2919,21 @@ const dalvikBytecodeOperationParser: Parser<DalvikBytecodeOperation | undefined,
|
|
|
2796
2919
|
operation,
|
|
2797
2920
|
]) =>
|
|
2798
2921
|
// Console.log(operation);
|
|
2799
|
-
operation,
|
|
2922
|
+
operation as RawDalvikBytecodeOperation | undefined,
|
|
2800
2923
|
);
|
|
2801
2924
|
|
|
2802
2925
|
setParserName(dalvikBytecodeOperationParser, 'dalvikBytecodeOperationParser');
|
|
2803
2926
|
|
|
2804
|
-
export type
|
|
2927
|
+
export type RawDalvikBytecode = RawDalvikBytecodeOperation[];
|
|
2805
2928
|
|
|
2806
|
-
const
|
|
2929
|
+
const rawDalvikBytecodeParser: Parser<RawDalvikBytecode, Uint8Array> = promiseCompose(
|
|
2807
2930
|
createArrayParser(dalvikBytecodeOperationParser),
|
|
2808
|
-
operations => operations.filter((operation): operation is
|
|
2931
|
+
operations => operations.filter((operation): operation is RawDalvikBytecodeOperation => operation !== undefined),
|
|
2809
2932
|
);
|
|
2810
2933
|
|
|
2811
|
-
export const
|
|
2934
|
+
export const createRawDalvikBytecodeParser = (size: number): Parser<RawDalvikBytecode, Uint8Array> => createSliceBoundedParser(rawDalvikBytecodeParser, size, true);
|
|
2812
2935
|
|
|
2813
|
-
type
|
|
2936
|
+
export type IndexResolvedOperation<T> = T extends { stringIndex: IndexIntoStringIds }
|
|
2814
2937
|
? Omit<T, 'stringIndex'> & { string: string }
|
|
2815
2938
|
: T extends { typeIndex: IndexIntoTypeIds }
|
|
2816
2939
|
? Omit<T, 'typeIndex'> & { type: string }
|
|
@@ -2820,26 +2943,28 @@ type ResolvedDalvikBytecodeOperation<T extends DalvikBytecodeOperation> = T exte
|
|
|
2820
2943
|
? Omit<T, 'fieldIndex'> & { field: DalvikExecutableField }
|
|
2821
2944
|
: T;
|
|
2822
2945
|
|
|
2823
|
-
|
|
2946
|
+
type IndexResolvedRawDalvikBytecodeOperation<T extends RawDalvikBytecodeOperation> = IndexResolvedOperation<T>;
|
|
2947
|
+
|
|
2948
|
+
export type RawDalvikBytecodeOperationResolvers = {
|
|
2824
2949
|
resolveIndexIntoStringIds: (index: IndexIntoStringIds) => string;
|
|
2825
2950
|
resolveIndexIntoTypeIds: (index: IndexIntoTypeIds) => string;
|
|
2826
2951
|
resolveIndexIntoMethodIds: (index: IndexIntoMethodIds) => DalvikExecutableMethod;
|
|
2827
2952
|
resolveIndexIntoFieldIds: (index: IndexIntoFieldIds) => DalvikExecutableField;
|
|
2828
2953
|
};
|
|
2829
2954
|
|
|
2830
|
-
export function
|
|
2955
|
+
export function resolveRawDalvikBytecodeOperationIndices<T extends RawDalvikBytecodeOperation>(operation: T, {
|
|
2831
2956
|
resolveIndexIntoStringIds,
|
|
2832
2957
|
resolveIndexIntoTypeIds,
|
|
2833
2958
|
resolveIndexIntoMethodIds,
|
|
2834
2959
|
resolveIndexIntoFieldIds,
|
|
2835
|
-
}:
|
|
2960
|
+
}: RawDalvikBytecodeOperationResolvers): IndexResolvedRawDalvikBytecodeOperation<T> {
|
|
2836
2961
|
if (operation && typeof operation === 'object' && 'stringIndex' in operation) {
|
|
2837
2962
|
const { stringIndex, ...rest } = operation;
|
|
2838
2963
|
|
|
2839
2964
|
return {
|
|
2840
2965
|
...rest,
|
|
2841
2966
|
string: resolveIndexIntoStringIds(stringIndex),
|
|
2842
|
-
} as
|
|
2967
|
+
} as IndexResolvedRawDalvikBytecodeOperation<T>;
|
|
2843
2968
|
}
|
|
2844
2969
|
|
|
2845
2970
|
if (operation && typeof operation === 'object' && 'typeIndex' in operation) {
|
|
@@ -2848,7 +2973,7 @@ export function resolveDalvikBytecodeOperation<T extends DalvikBytecodeOperation
|
|
|
2848
2973
|
return {
|
|
2849
2974
|
...rest,
|
|
2850
2975
|
type: resolveIndexIntoTypeIds(typeIndex),
|
|
2851
|
-
} as
|
|
2976
|
+
} as IndexResolvedRawDalvikBytecodeOperation<T>;
|
|
2852
2977
|
}
|
|
2853
2978
|
|
|
2854
2979
|
if (operation && typeof operation === 'object' && 'methodIndex' in operation) {
|
|
@@ -2857,7 +2982,7 @@ export function resolveDalvikBytecodeOperation<T extends DalvikBytecodeOperation
|
|
|
2857
2982
|
return {
|
|
2858
2983
|
...rest,
|
|
2859
2984
|
method: resolveIndexIntoMethodIds(methodIndex),
|
|
2860
|
-
} as
|
|
2985
|
+
} as IndexResolvedRawDalvikBytecodeOperation<T>;
|
|
2861
2986
|
}
|
|
2862
2987
|
|
|
2863
2988
|
if (operation && typeof operation === 'object' && 'fieldIndex' in operation) {
|
|
@@ -2866,8 +2991,8 @@ export function resolveDalvikBytecodeOperation<T extends DalvikBytecodeOperation
|
|
|
2866
2991
|
return {
|
|
2867
2992
|
...rest,
|
|
2868
2993
|
field: resolveIndexIntoFieldIds(fieldIndex),
|
|
2869
|
-
} as
|
|
2994
|
+
} as IndexResolvedRawDalvikBytecodeOperation<T>;
|
|
2870
2995
|
}
|
|
2871
2996
|
|
|
2872
|
-
return operation as
|
|
2997
|
+
return operation as IndexResolvedRawDalvikBytecodeOperation<T>;
|
|
2873
2998
|
}
|