Changeset 06d75931 for src/AST


Ignore:
Timestamp:
Oct 26, 2024, 8:17:20 AM (14 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
14c31eb
Parents:
3a08cb1 (diff), d031f7f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/AST
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.cpp

    r3a08cb1 r06d75931  
    169169}
    170170
    171 const 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 "";
    177         }
    178 }
    179 
    180 unsigned 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;
    186                 }
    187                 offset += childDecl->members.size();
    188         }
    189     std::cerr << "Cannot find the target enum" << std::endl;
    190         return 0;
    191 }
    192 
    193 unsigned EnumDecl::calChildOffset(const ast::EnumInstType * target) const{
    194         return calChildOffset(target->base->name);
    195 }
    196 
    197 bool 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 }
    204 
    205171bool EnumDecl::isTyped() const { return base; }
    206172
  • src/AST/Decl.hpp

    r3a08cb1 r06d75931  
    302302};
    303303
     304/// Enumeration attribute kind.
    304305enum class EnumAttribute{ Value, Posn, Label };
     306
    305307/// enum declaration `enum Foo { ... };`
    306308class EnumDecl final : public AggregateDecl {
     
    328330        const char * typeString() const override { return aggrString( Enum ); }
    329331
    330         const std::string getUnmangeldArrayName( const EnumAttribute attr ) const;
    331 
    332         unsigned calChildOffset(const std::string & childEnum) const;
    333         unsigned calChildOffset(const ast::EnumInstType * childEnum) const;
    334 
    335         bool isSubTypeOf(const ast::EnumDecl *) const;
    336332        bool isTyped() const;
    337333        bool isOpaque() const;
Note: See TracChangeset for help on using the changeset viewer.