MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / test_bytecode_match

Method test_bytecode_match

bytecode/bytecode_base.cpp:1779–1988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1777}
1778
1779Error GDScriptDecomp::test_bytecode_match(const Vector<uint8_t> &p_buffer1, const Vector<uint8_t> &p_buffer2, bool ignore_lines_cols, bool is_printing_verbose) {
1780 int64_t discontinuity = -1;
1781 if (p_buffer1 == p_buffer2) {
1782 return OK;
1783 }
1784 ScriptState state1;
1785 Error error = get_script_state(p_buffer1, state1);
1786 ERR_FAIL_COND_V_MSG(error, error, "Error reading first bytecode");
1787 ScriptState state2;
1788 error = get_script_state(p_buffer2, state2);
1789 ERR_FAIL_COND_V_MSG(error, error, "Error reading second bytecode");
1790 Error err = OK;
1791#define REPORT_DIFF(x) \
1792 err = ERR_BUG; \
1793 error_message += x + "\n"; \
1794 // WARN_PRINT(x)
1795
1796#ifdef DEBUG_ENABLED
1797#define bl_print(...) print_line(__VA_ARGS__)
1798#else
1799#define bl_print(...) print_verbose(__VA_ARGS__)
1800#endif
1801
1802 if (state1.bytecode_version != state2.bytecode_version) {
1803 REPORT_DIFF("Bytecode version mismatch: " + itos(state1.bytecode_version) + " != " + itos(state2.bytecode_version));
1804 return ERR_BUG;
1805 }
1806 if (state1.bytecode_version < GDSCRIPT_2_0_VERSION) {
1807 discontinuity = continuity_tester(p_buffer1, p_buffer2, "Bytecode");
1808 } else {
1809 auto decompressed_size1 = decode_uint32(&p_buffer1[8]);
1810 auto decompressed_size2 = decode_uint32(&p_buffer2[8]);
1811 if (decompressed_size1 != 0 && decompressed_size2 != 0) {
1812 if (decompressed_size1 != decompressed_size2) {
1813 REPORT_DIFF("Decompressed size mismatch: " + itos(decompressed_size1) + " != " + itos(decompressed_size2));
1814 }
1815 Vector<uint8_t> contents1;
1816 Vector<uint8_t> contents2;
1817 decompress_buf(p_buffer1, contents1);
1818 decompress_buf(p_buffer2, contents2);
1819 discontinuity = continuity_tester(contents1, contents2, "Decompressed Bytecode");
1820 } else {
1821 if (decompressed_size1 != decompressed_size2) {
1822 discontinuity = 0;
1823 }
1824 }
1825 }
1826 if (discontinuity == -1) {
1827 return OK;
1828 }
1829
1830 // Ref<GDScriptDecomp> decomp = create_decomp_for_commit(get_bytecode_rev());
1831 error_message = "";
1832 discontinuity = continuity_tester(state1.identifiers, state2.identifiers, "Identifiers");
1833 if (discontinuity != -1) {
1834 REPORT_DIFF("Discontinuity in identifier at index " + itos(discontinuity));
1835 if (discontinuity < state1.identifiers.size() && discontinuity < state2.identifiers.size()) {
1836 REPORT_DIFF("Different identifiers: " + state1.identifiers[discontinuity] + " != " + state2.identifiers[discontinuity]);

Callers 4

unzip_and_copy_addonMethod · 0.80
test_exportMethod · 0.80
test_script_binaryFunction · 0.80
test_bytecode.hFile · 0.80

Calls 5

continuity_testerFunction · 0.85
decompress_bufFunction · 0.85
push_backMethod · 0.80
sizeMethod · 0.45
get_token_lineMethod · 0.45

Tested by

no test coverage detected