- Timestamp:
- Oct 27, 2022, 11:43:10 AM (3 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 0026d67
- Parents:
- a167c70c
- Location:
- src/AST
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Type.cpp
ra167c70c r63d1ebe 147 147 // --- TypeInstType 148 148 149 bool TypeInstType::operator==( const TypeInstType & other ) const { 150 return base == other.base 151 && formal_usage == other.formal_usage 152 && expr_id == other.expr_id; 153 } 154 149 155 TypeInstType::TypeInstType( const TypeDecl * b, 150 156 CV::Qualifiers q, std::vector<ptr<Attribute>> && as ) … … 157 163 158 164 bool TypeInstType::isComplete() const { return base->sized; } 165 166 std::string TypeInstType::TypeEnvKey::typeString() const { 167 return std::string("_") + std::to_string(formal_usage) 168 + "_" + std::to_string(expr_id) + "_" + base->name; 169 } 170 171 bool TypeInstType::TypeEnvKey::operator==( 172 const TypeInstType::TypeEnvKey & other ) const { 173 return base == other.base 174 && formal_usage == other.formal_usage 175 && expr_id == other.expr_id; 176 } 177 178 bool TypeInstType::TypeEnvKey::operator<( 179 const TypeInstType::TypeEnvKey & other ) const { 180 // TypeEnvKey ordering is an arbitrary total ordering. 181 // It doesn't mean anything but allows for a sorting. 182 if ( base < other.base ) { 183 return true; 184 } else if ( other.base < base ) { 185 return false; 186 } else if ( formal_usage < other.formal_usage ) { 187 return true; 188 } else if ( other.formal_usage < formal_usage ) { 189 return false; 190 } else { 191 return expr_id < other.expr_id; 192 } 193 } 159 194 160 195 // --- TupleType -
src/AST/Type.hpp
ra167c70c r63d1ebe 408 408 409 409 TypeEnvKey() = default; 410 TypeEnvKey(const TypeDecl * base, int formal_usage = 0, int expr_id = 0): base(base), formal_usage(formal_usage), expr_id(expr_id) {} 411 TypeEnvKey(const TypeInstType & inst): base(inst.base), formal_usage(inst.formal_usage), expr_id(inst.expr_id) {} 412 std::string typeString() const { return std::string("_") + std::to_string(formal_usage) + "_" + std::to_string(expr_id) + "_" + base->name; } 413 bool operator==(const TypeEnvKey & other) const { return base == other.base && formal_usage == other.formal_usage && expr_id == other.expr_id; } 410 TypeEnvKey(const TypeDecl * base, int formal_usage = 0, int expr_id = 0) 411 : base(base), formal_usage(formal_usage), expr_id(expr_id) {} 412 TypeEnvKey(const TypeInstType & inst) 413 : base(inst.base), formal_usage(inst.formal_usage), expr_id(inst.expr_id) {} 414 std::string typeString() const; 415 bool operator==(const TypeEnvKey & other) const; 416 bool operator<(const TypeEnvKey & other) const; 414 417 }; 415 418 416 bool operator==(const TypeInstType & other) const { return base == other.base && formal_usage == other.formal_usage && expr_id == other.expr_id; }419 bool operator==(const TypeInstType & other) const; 417 420 418 421 TypeInstType(
Note:
See TracChangeset
for help on using the changeset viewer.