Changes in / [ffec1bf:def751f]
- Files:
-
- 10 edited
-
src/CodeGen/CodeGenerator.cc (modified) (1 diff)
-
src/Parser/ExpressionNode.cc (modified) (1 diff)
-
src/Parser/ParseNode.h (modified) (1 diff)
-
src/ResolvExpr/CandidateFinder.cpp (modified) (1 diff)
-
src/ResolvExpr/ConversionCost.cc (modified) (1 diff)
-
src/ResolvExpr/Unify.cc (modified) (2 diffs)
-
src/SynTree/Expression.h (modified) (1 diff)
-
src/SynTree/SynTree.h (modified) (1 diff)
-
src/Validate/Autogen.cpp (modified) (1 diff)
-
tests/enum_tests/structEnum.cfa (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rffec1bf rdef751f 289 289 if ( obj->get_init() ) { 290 290 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(); 292 292 } else { 293 293 output << ++last_val; -
src/Parser/ExpressionNode.cc
rffec1bf rdef751f 509 509 } // build_varref 510 510 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 511 517 DimensionExpr * build_dimensionref( const string * name ) { 512 518 DimensionExpr * expr = new DimensionExpr( *name ); -
src/Parser/ParseNode.h
rffec1bf rdef751f 183 183 184 184 NameExpr * build_varref( const std::string * name ); 185 QualifiedNameExpr * build_qualified_expr( const DeclarationNode * decl_node, const NameExpr * name ); 185 186 DimensionExpr * build_dimensionref( const std::string * name ); 186 187 -
src/ResolvExpr/CandidateFinder.cpp
rffec1bf rdef751f 897 897 } 898 898 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 int907 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; // 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 // } 910 910 else funcFinder.otypeKeys.insert(Mangle::mangle(argType, Mangle::NoGenericParams | Mangle::Type)); 911 911 } -
src/ResolvExpr/ConversionCost.cc
rffec1bf rdef751f 695 695 if ( const ast::Type * baseType = baseEnum->base ) { 696 696 cost = costCalc( baseType, dst, srcIsLvalue, symtab, env ); 697 // cost = Cost::safe; 697 698 } else { 698 699 (void)enumInstType; -
src/ResolvExpr/Unify.cc
rffec1bf rdef751f 165 165 ast::Type * newFirst = shallowCopy( first ); 166 166 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 167 181 newFirst ->qualifiers = {}; 168 182 newSecond->qualifiers = {}; … … 988 1002 if ( isTuple && isTuple2 ) { 989 1003 ++it; ++jt; // skip ttype parameters before break 990 } else if ( isTuple ) { 1004 } else if ( isTuple ) { 991 1005 // bundle remaining params into tuple 992 1006 pty2 = tupleFromExprs( param2, jt, params2.end(), pty->qualifiers ); -
src/SynTree/Expression.h
rffec1bf rdef751f 163 163 }; 164 164 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 165 195 /// VariableExpr represents an expression that simply refers to the value of a named variable. 166 196 /// Does not take ownership of var. -
src/SynTree/SynTree.h
rffec1bf rdef751f 103 103 class DefaultArgExpr; 104 104 class GenericExpr; 105 class QualifiedNameExpr; 105 106 106 107 class Type; -
src/Validate/Autogen.cpp
rffec1bf rdef751f 235 235 // Must visit children (enum constants) to add them to the symbol table. 236 236 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 // } 237 244 238 245 ast::EnumInstType enumInst( enumDecl->name ); -
tests/enum_tests/structEnum.cfa
rffec1bf rdef751f 2 2 3 3 struct Point { 4 int x;5 char y;4 int x; 5 char y; 6 6 }; 7 7 8 8 enum(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 } 17 17 }; 18 19 PointEnum foo(PointEnum in) { 20 return in; 21 } 18 22 19 23 // The only valid usage 20 24 struct Point apple = first; 21 25 // Failed due to Qualified name is currently unimplemented. 22 //struct Point banana = PointEnum.first;26 struct Point banana = PointEnum.first; 23 27 24 28 int main() { 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; 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; 30 39 }
Note:
See TracChangeset
for help on using the changeset viewer.