Changes in / [def751f:ffec1bf]


Ignore:
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rdef751f rffec1bf  
    289289                                        if ( obj->get_init() ) {
    290290                                                obj->get_init()->accept( *visitor );
    291                                                 // last_val = ((ConstantExpr *)(((SingleInit *)(obj->init))->value))->constant.get_ival();
     291                                                last_val = ((ConstantExpr *)(((SingleInit *)(obj->init))->value))->constant.get_ival();
    292292                                        } else {
    293293                                                output << ++last_val;
  • src/Parser/ExpressionNode.cc

    rdef751f rffec1bf  
    509509} // build_varref
    510510
    511 QualifiedNameExpr * build_qualified_expr( const DeclarationNode * decl_node, const NameExpr * name ) {
    512         Type * targetType = maybeMoveBuildType( decl_node );
    513         return new QualifiedNameExpr( targetType, name->name );
    514         return nullptr;
    515 }
    516 
    517511DimensionExpr * build_dimensionref( const string * name ) {
    518512        DimensionExpr * expr = new DimensionExpr( *name );
  • src/Parser/ParseNode.h

    rdef751f rffec1bf  
    183183
    184184NameExpr * build_varref( const std::string * name );
    185 QualifiedNameExpr * build_qualified_expr( const DeclarationNode * decl_node, const NameExpr * name );
    186185DimensionExpr * build_dimensionref( const std::string * name );
    187186
  • src/ResolvExpr/CandidateFinder.cpp

    rdef751f rffec1bf  
    897897                                                }
    898898
    899                                                 if (argType.as<ast::PointerType>()) funcFinder.otypeKeys.insert(Mangle::Encoding::pointer);                                             
    900                                                 // else if (const ast::EnumInstType * enumInst = argType.as<ast::EnumInstType>()) {
    901                                                 //      const ast::EnumDecl * enumDecl = enumInst->base; // Here
    902                                                 //      if ( const ast::Type* enumType = enumDecl->base ) {
    903                                                 //              // instance of enum (T) is a instance of type (T)
    904                                                 //              funcFinder.otypeKeys.insert(Mangle::mangle(enumType, Mangle::NoGenericParams | Mangle::Type));
    905                                                 //      } else {
    906                                                 //              // instance of an untyped enum is techically int
    907                                                 //              funcFinder.otypeKeys.insert(Mangle::mangle(enumDecl, Mangle::NoGenericParams | Mangle::Type));
    908                                                 //      }
    909                                                 // }
     899                                                if (argType.as<ast::PointerType>()) funcFinder.otypeKeys.insert(Mangle::Encoding::pointer);
     900                                                else if (const ast::EnumInstType * enumInst = argType.as<ast::EnumInstType>()) {
     901                                                        const ast::EnumDecl * enumDecl = enumInst->base;
     902                                                        if ( const ast::Type* enumType = enumDecl->base ) {
     903                                                                // instance of enum (T) is a instance of type (T)
     904                                                                funcFinder.otypeKeys.insert(Mangle::mangle(enumType, Mangle::NoGenericParams | Mangle::Type));
     905                                                        } else {
     906                                                                // instance of an untyped enum is techically int
     907                                                                funcFinder.otypeKeys.insert(Mangle::mangle(enumDecl, Mangle::NoGenericParams | Mangle::Type));
     908                                                        }
     909                                                }
    910910                                                else funcFinder.otypeKeys.insert(Mangle::mangle(argType, Mangle::NoGenericParams | Mangle::Type));
    911911                                        }
  • src/ResolvExpr/ConversionCost.cc

    rdef751f rffec1bf  
    695695        if ( const ast::Type * baseType = baseEnum->base ) {
    696696                cost = costCalc( baseType, dst, srcIsLvalue, symtab, env );
    697                 // cost = Cost::safe;
    698697        } else {
    699698                (void)enumInstType;
  • src/ResolvExpr/Unify.cc

    rdef751f rffec1bf  
    165165                ast::Type * newFirst  = shallowCopy( first  );
    166166                ast::Type * newSecond = shallowCopy( second );
    167                 if ( auto temp = dynamic_cast<const ast::EnumInstType *>(first) ) {
    168                         if ( !dynamic_cast< const ast::EnumInstType * >( second ) ) {
    169                                 const ast::EnumDecl * baseEnum = dynamic_cast<const ast::EnumDecl *>(temp->base.get());
    170                                 if ( auto t = baseEnum->base.get() ) {
    171                                         newFirst = ast::shallowCopy( t );
    172                                 }
    173                         }
    174                 } else if ( auto temp = dynamic_cast<const ast::EnumInstType *>(second) ) {
    175                         const ast::EnumDecl * baseEnum = dynamic_cast<const ast::EnumDecl *>(temp->base.get());
    176                         if ( auto t = baseEnum->base.get() ) {
    177                                 newSecond = ast::shallowCopy( t );
    178                         }
    179                 }
    180 
    181167                newFirst ->qualifiers = {};
    182168                newSecond->qualifiers = {};
     
    1002988                                if ( isTuple && isTuple2 ) {
    1003989                                        ++it; ++jt;  // skip ttype parameters before break
    1004                                 } else if ( isTuple ) { 
     990                                } else if ( isTuple ) {
    1005991                                        // bundle remaining params into tuple
    1006992                                        pty2 = tupleFromExprs( param2, jt, params2.end(), pty->qualifiers );
  • src/SynTree/Expression.h

    rdef751f rffec1bf  
    163163};
    164164
    165 // [Qualifier].name; Qualifier is the type_name from the parser
    166 class QualifiedNameExpr : public Expression {
    167   public:
    168         Type * type; // Convert to [parent] QualifiedNameExpr
    169         std::string name; // Convert from NameExpr
    170 
    171         QualifiedNameExpr( Type * type, std::string name):
    172                 Expression(), type(type), name(name) {
    173                 std::cout << "Making QualifiedNameExpr" << std::endl;
    174                 print( std::cout );
    175         }
    176         QualifiedNameExpr( const QualifiedNameExpr & other): Expression(other), type(other.type), name(other.name) {
    177 
    178         }
    179         virtual ~QualifiedNameExpr() {
    180                 delete type;
    181         }
    182 
    183         virtual QualifiedNameExpr * clone() const override {
    184                 return new QualifiedNameExpr( * this );
    185         }
    186         virtual void accept( Visitor & v ) override { (void)v; }
    187         virtual void accept( Visitor & v ) const override { (void)v; }
    188         virtual Expression * acceptMutator( Mutator & m ) override { (void) m;return nullptr; }
    189         virtual void print( std::ostream & os, Indenter indent = {} ) const override {
    190                 type->print( os, indent );
    191                 std::cout << name << std::endl;
    192         }
    193 };
    194 
    195165/// VariableExpr represents an expression that simply refers to the value of a named variable.
    196166/// Does not take ownership of var.
  • src/SynTree/SynTree.h

    rdef751f rffec1bf  
    103103class DefaultArgExpr;
    104104class GenericExpr;
    105 class QualifiedNameExpr;
    106105
    107106class Type;
  • src/Validate/Autogen.cpp

    rdef751f rffec1bf  
    235235        // Must visit children (enum constants) to add them to the symbol table.
    236236        if ( !enumDecl->body ) return;
    237 
    238         // if ( auto enumBaseType = enumDecl->base ) {
    239         //      if ( auto enumBaseTypeAsStructInst = dynamic_cast<const ast::StructInstType *>(enumBaseType.get()) ) {
    240         //              const ast::StructDecl * structDecl = enumBaseTypeAsStructInst->base.get();
    241         //              this->previsit( structDecl );
    242         //      }
    243         // }
    244237
    245238        ast::EnumInstType enumInst( enumDecl->name );
  • tests/enum_tests/structEnum.cfa

    rdef751f rffec1bf  
    22
    33struct Point {
    4      int x;
    5      char y;
     4    int x;
     5    char y;
    66};
    77
    88enum(Point) PointEnum {
    9      first={
    10          100,
    11          'c'
    12      },
    13      second={
    14          200,
    15          'a'
    16      }
     9    first={
     10        100,
     11        'c'
     12    },
     13    second={
     14        200,
     15        'a'
     16    }
    1717};
    18 
    19 PointEnum foo(PointEnum in) {
    20      return in;
    21 }
    2218
    2319// The only valid usage
    2420struct Point apple = first;
    2521// Failed due to Qualified name is currently unimplemented.
    26 struct Point banana = PointEnum.first;
     22// struct Point banana = PointEnum.first;
    2723
    2824int main() {
    29      PointEnum vals = second;
    30      PointEnum val2;
    31      // P1
    32      val2 = vals;
    33 
    34      printf("%d %c\n", apple.x, apple.y);
    35      // Failed; enumInstType is now not a real type and not instantiated.
    36      // Not sure if we want that
    37      // printf("%d %c\n", second.x, second.y);
    38      return 0;
     25    printf("%d %c\n", apple.x, apple.y);
     26    // Failed; enumInstType is now not a real type and not instantiated.
     27    // Not sure if we want that
     28    // printf("%d %c\n", second.x, second.y);
     29    return 0;
    3930}
Note: See TracChangeset for help on using the changeset viewer.