Changeset 85855b0 for src/AST/Decl.cpp


Ignore:
Timestamp:
Jun 10, 2024, 2:43:13 AM (5 weeks ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
42cdd07d
Parents:
d68de59
Message:
  1. Implement enum cast; 2. Change valueE so that opague enum returns quasi_void; 3. change enum hiding interpretation and pass visiting scheme
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.cpp

    rd68de59 r85855b0  
    170170
    171171const std::string EnumDecl::getUnmangeldArrayName( const ast::EnumAttribute attr ) const {
    172                 switch( attr ) {
    173                         case ast::EnumAttribute::Value: return "values_" + name ;
    174                         case ast::EnumAttribute::Label: return "labels_" + name;
    175                         default: /* Posn does not generate array */
    176                                 return "";
     172        switch( attr ) {
     173                case ast::EnumAttribute::Value: return "values_" + name ;
     174                case ast::EnumAttribute::Label: return "labels_" + name;
     175                default: /* Posn does not generate array */
     176                        return "";
     177        }
     178}
     179
     180unsigned EnumDecl::calChildOffset(const std::string & target) const{
     181        unsigned offset = 0;
     182        for (auto childEnum: inlinedDecl) {
     183                auto childDecl = childEnum->base;
     184                if (childDecl->name == target) {
     185                        return offset;
    177186                }
    178         }
     187                offset += childDecl->members.size();
     188        }
     189    std::cerr << "Cannot find the target enum" << std::endl;
     190        return 0;
     191}
     192
     193unsigned EnumDecl::calChildOffset(const ast::EnumInstType * target) const{
     194        return calChildOffset(target->base->name);
     195}
     196
     197bool EnumDecl::isSubTypeOf(const ast::EnumDecl * other) const {
     198        if (name == other->name) return true;
     199        for (auto inlined: other->inlinedDecl) {
     200                if (isSubTypeOf(inlined->base)) return true;
     201        }
     202        return false;
     203}
    179204
    180205}
Note: See TracChangeset for help on using the changeset viewer.