Changeset - 149b39c6603f
[Not reviewed]
0 2 0
MH - 3 years ago 2022-02-25 11:59:37
contact@maxhenger.nl
Disable type deduplication for now
2 files changed with 14 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/protocol/parser/type_table.rs
Show inline comments
 
@@ -36,6 +36,8 @@
 
 * layout.
 
 */
 

	
 
// Programmer note: deduplication of types is currently disabled, see the
 
// @Deduplication key. Tests might fail when it is re-enabled.
 
use std::collections::HashMap;
 
use std::hash::{Hash, Hasher};
 

	
 
@@ -452,10 +454,10 @@ impl MonoSearchKey {
 
impl Hash for MonoSearchKey {
 
    fn hash<H: Hasher>(&self, state: &mut H) {
 
        for index in 0..self.parts.len() {
 
            let (flags, part) = self.parts[index];
 
            if flags & Self::KEY_IN_USE != 0 {
 
                part.hash(state);
 
            }
 
            let (_flags, part) = self.parts[index];
 
            // if flags & Self::KEY_IN_USE != 0 { @Deduplication
 
            part.hash(state);
 
            // }
 
        }
 
    }
 
}
 
@@ -469,8 +471,8 @@ impl PartialEq for MonoSearchKey {
 
            // Retrieve part and flags
 
            let (self_bits, _) = self.parts[self_index];
 
            let (other_bits, _) = other.parts[other_index];
 
            let self_in_use = (self_bits & Self::KEY_IN_USE) != 0;
 
            let other_in_use = (other_bits & Self::KEY_IN_USE) != 0;
 
            let self_in_use = true; // (self_bits & Self::KEY_IN_USE) != 0; @Deduplication
 
            let other_in_use = true; // (other_bits & Self::KEY_IN_USE) != 0; @Deduplication
 

	
 
            // Determine ending indices
 
            let self_end_index = self.find_end_index(self_index);
 
@@ -2178,7 +2180,7 @@ impl TypeTable {
 
            },
 
            // Builtin types with a single nested type
 
            CTP::Array | CTP::Slice | CTP::Input | CTP::Output | CTP::Pointer => {
 
                debug_assert_eq!(type_parts.len(), 2);
 
                debug_assert_eq!(type_parts[0].num_embedded(), 1);
 
                search_key.set(type_parts, &POLY_VARS_IN_USE[..1])
 
            },
 
            // User-defined types
src/protocol/tests/parser_monomorphs.rs
Show inline comments
 
@@ -57,7 +57,7 @@ fn test_enum_monomorphs() {
 

	
 
    // Note for reader: because the enum doesn't actually use the polymorphic
 
    // variable, we expect to have 1 monomorph: the type only has to be laid
 
    // out once.
 
    // out once. @Deduplication
 
    Tester::new_single_source_expect_ok(
 
        "single polymorph",
 
        "
 
@@ -71,8 +71,10 @@ fn test_enum_monomorphs() {
 
        }
 
        "
 
    ).for_enum("Answer", |e| { e
 
        .assert_num_monomorphs(1)
 
        .assert_has_monomorph("Answer<s8>");
 
        .assert_num_monomorphs(3)
 
        .assert_has_monomorph("Answer<s8>")
 
        .assert_has_monomorph("Answer<s32>")
 
        .assert_has_monomorph("Answer<Answer<Answer<s64>>>");
 
    });
 
}
 

	
0 comments (0 inline, 0 general)