Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/ImplementEnumFunc.cpp

    racb33f15 rc92bdcc  
    22#include "AST/Pass.hpp"
    33#include "AST/TranslationUnit.hpp"
    4 #include "CodeGen/OperatorTable.h"  // for isCtorDtor, isCtorDtorAssign
    5 #include "InitTweak/InitTweak.h"    // for isAssignment, isCopyConstructor
     4#include "CodeGen/OperatorTable.hpp"  // for isCtorDtor, isCtorDtorAssign
     5#include "InitTweak/InitTweak.hpp"    // for isAssignment, isCopyConstructor
    66namespace Validate {
    77
     
    7272                ast::DeclWithType* decl = declPtr.get_and_mutate();
    7373                decl->attributes.push_back(new ast::Attribute("unused"));
     74        }
     75
     76        ast::ObjectDecl* dstParam() const {
     77                return new ast::ObjectDecl(getLocation(), "_dst",
     78                                           new ast::ReferenceType(new ast::EnumAttrType(
     79                                               ast::deepCopy(instType))));
     80        }
     81
     82        ast::ObjectDecl* srcParam() const {
     83                return new ast::ObjectDecl(
     84                        getLocation(), "_src",
     85                        new ast::EnumAttrType(ast::deepCopy(instType)));
    7486        }
    7587
     
    317329}
    318330
     331inline ast::EnumAttrType * getPosnType( const ast::EnumDecl * decl ) {
     332        return new ast::EnumAttrType(new ast::EnumInstType(decl), ast::EnumAttribute::Posn);
     333}
     334
    319335ast::ObjectDecl* EnumAttrFuncGenerator::genAttrArrayProto(
    320336        const ast::EnumAttribute attr, const CodeLocation& location,
     
    344360                        func->location,
    345361                        new ast::VariableExpr( func->location, func->params.front() ),
    346                         new ast::BasicType( ast::BasicKind::UnsignedInt ),
    347                         ast::GeneratedFlag::ExplicitCast
    348                 )});
     362                        new ast::EnumAttrType( new ast::EnumInstType(decl),
     363                                ast::EnumAttribute::Posn))});
    349364        func->stmts = new ast::CompoundStmt(
    350365                func->location, {new ast::ReturnStmt(func->location, untyped)});
     
    355370                func->location,
    356371                new ast::VariableExpr(func->location, func->params.front()),
    357                 new ast::BasicType( ast::BasicKind::UnsignedInt ),
    358                         ast::GeneratedFlag::ExplicitCast);
     372                new ast::EnumAttrType(new ast::EnumInstType(decl),
     373                                                          ast::EnumAttribute::Posn));
    359374        func->stmts = new ast::CompoundStmt(
    360375                func->location, {new ast::ReturnStmt(func->location, castExpr)});
Note: See TracChangeset for help on using the changeset viewer.