Changeset d191e24
- Timestamp:
- Oct 19, 2022, 5:29:12 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- bc899d6
- Parents:
- 82ff4ed1 (diff), 058ece2 (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. - Files:
-
- 2 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/containers/array.hfa
r82ff4ed1 rd191e24 27 27 // - Given bug of Trac #247, CFA gives sizeof expressions type unsigned long int, when it 28 28 // should give them type size_t. 29 // 29 // 30 30 // gcc -m32 cfa -m32 given bug gcc -m64 31 31 // ptrdiff_t int int long int … … 39 39 } 40 40 41 static inline const Timmed & ?[?]( const arpk(N, S, Timmed, Tbase) & a, int i ) { 42 assert( i < N ); 43 return (Timmed &) a.strides[i]; 44 } 45 41 46 static inline Timmed & ?[?]( arpk(N, S, Timmed, Tbase) & a, unsigned int i ) { 47 assert( i < N ); 48 return (Timmed &) a.strides[i]; 49 } 50 51 static inline const Timmed & ?[?]( const arpk(N, S, Timmed, Tbase) & a, unsigned int i ) { 42 52 assert( i < N ); 43 53 return (Timmed &) a.strides[i]; … … 49 59 } 50 60 61 static inline const Timmed & ?[?]( const arpk(N, S, Timmed, Tbase) & a, long int i ) { 62 assert( i < N ); 63 return (Timmed &) a.strides[i]; 64 } 65 51 66 static inline Timmed & ?[?]( arpk(N, S, Timmed, Tbase) & a, unsigned long int i ) { 67 assert( i < N ); 68 return (Timmed &) a.strides[i]; 69 } 70 71 static inline const Timmed & ?[?]( const arpk(N, S, Timmed, Tbase) & a, unsigned long int i ) { 52 72 assert( i < N ); 53 73 return (Timmed &) a.strides[i]; … … 83 103 // Make a FOREACH macro 84 104 #define FE_0(WHAT) 85 #define FE_1(WHAT, X) WHAT(X) 105 #define FE_1(WHAT, X) WHAT(X) 86 106 #define FE_2(WHAT, X, ...) WHAT(X)FE_1(WHAT, __VA_ARGS__) 87 107 #define FE_3(WHAT, X, ...) WHAT(X)FE_2(WHAT, __VA_ARGS__) … … 90 110 //... repeat as needed 91 111 92 #define GET_MACRO(_0,_1,_2,_3,_4,_5,NAME,...) NAME 112 #define GET_MACRO(_0,_1,_2,_3,_4,_5,NAME,...) NAME 93 113 #define FOR_EACH(action,...) \ 94 114 GET_MACRO(_0,__VA_ARGS__,FE_5,FE_4,FE_3,FE_2,FE_1,FE_0)(action,__VA_ARGS__) … … 115 135 } 116 136 117 #else 137 #else 118 138 119 139 // Workaround form. Listing all possibilities up to 4 dims. … … 155 175 156 176 // Wrapper 157 struct all_t {} all;177 extern struct all_t {} all; 158 178 forall( [N], S & | sized(S), Te &, result &, Tbase & | { tag(result) enq_( tag(Tbase), tag(N), tag(S), tag(Te) ); } ) 159 179 static inline result & ?[?]( arpk(N, S, Te, Tbase) & this, all_t ) { -
libcfa/src/device/cpu.cfa
r82ff4ed1 rd191e24 359 359 int idxs = count_cache_indexes(); 360 360 361 // Do we actually have a cache? 362 if(idxs == 0) { 363 // if not just fake the data structure, it makes things easier. 364 cpu_info.hthrd_count = cpus_c; 365 cpu_info.llc_count = 0; 366 struct cpu_map_entry_t * entries = alloc(cpu_info.hthrd_count); 367 for(i; cpu_info.hthrd_count) { 368 entries[i].self = i; 369 entries[i].start = 0; 370 entries[i].count = cpu_info.hthrd_count; 371 entries[i].cache = 0; 372 } 373 cpu_info.llc_map = entries; 374 return; 375 } 376 361 377 // Count actual cache levels 362 378 unsigned cache_levels = 0; 363 379 unsigned llc = 0; 364 if (idxs != 0) { 365 unsigned char prev = -1u; 366 void first(unsigned idx, unsigned char level, const char * map, size_t len) { 367 /* paranoid */ verifyf(level < prev, "Index %u of cpu 0 has cache levels out of order: %u then %u", idx, (unsigned)prev, (unsigned)level); 368 llc = max(llc, level); 369 prev = level; 370 cache_levels++; 371 } 372 foreach_cacheidx(0, idxs, first); 373 } 380 381 unsigned char prev = -1u; 382 void first(unsigned idx, unsigned char level, const char * map, size_t len) { 383 /* paranoid */ verifyf(level < prev, "Index %u of cpu 0 has cache levels out of order: %u then %u", idx, (unsigned)prev, (unsigned)level); 384 llc = max(llc, level); 385 prev = level; 386 cache_levels++; 387 } 388 foreach_cacheidx(0, idxs, first); 374 389 375 390 // Read in raw data -
libcfa/src/parseargs.cfa
r82ff4ed1 rd191e24 50 50 extern char ** cfa_args_envp __attribute__((weak)); 51 51 52 static void usage(char * cmd, cfa_option options[], size_t opt_count, const char * usage, FILE * out) __attribute__ ((noreturn)); 52 forall([N]) 53 static void usage(char * cmd, const array( cfa_option, N ) & options, const char * usage, FILE * out) __attribute__ ((noreturn)); 53 54 //----------------------------------------------------------------------------- 54 55 // checking 55 static void check_args(cfa_option options[], size_t opt_count) { 56 for(i; opt_count) { 57 for(j; opt_count) { 56 forall([N]) 57 static void check_args( const array( cfa_option, N ) & options ) { 58 for(i; N) { 59 for(j; N) { 58 60 if(i == j) continue; 59 61 … … 70 72 //----------------------------------------------------------------------------- 71 73 // Parsing args 72 void parse_args( cfa_option options[], size_t opt_count, const char * usage, char ** & left ) { 73 if( 0p != &cfa_args_argc ) { 74 parse_args(cfa_args_argc, cfa_args_argv, options, opt_count, usage, left ); 75 } 76 else { 77 char * temp = ""; 78 parse_args(0, &temp, options, opt_count, usage, left ); 79 } 80 } 81 82 void parse_args( 83 int argc, 84 char * argv[], 85 cfa_option options[], 86 size_t opt_count, 87 const char * usage, 88 char ** & left 89 ) { 90 check_args(options, opt_count); 91 92 int maxv = 'h'; 93 char optstring[(opt_count * 3) + 2] = { '\0' }; 94 { 95 int idx = 0; 96 for(i; opt_count) { 97 if (options[i].short_name) { 98 maxv = max(options[i].short_name, maxv); 99 optstring[idx] = options[i].short_name; 100 idx++; 101 if( ((intptr_t)options[i].parse) != ((intptr_t)parse_settrue) 102 && ((intptr_t)options[i].parse) != ((intptr_t)parse_setfalse) ) { 103 optstring[idx] = ':'; 74 forall([opt_count]) { 75 void parse_args( const array( cfa_option, opt_count ) & options, const char * usage, char ** & left ) { 76 if( 0p != &cfa_args_argc ) { 77 parse_args(cfa_args_argc, cfa_args_argv, options, usage, left ); 78 } 79 else { 80 char * temp = ""; 81 parse_args(0, &temp, options, usage, left ); 82 } 83 } 84 85 void parse_args( 86 int argc, 87 char * argv[], 88 const array( cfa_option, opt_count ) & options, 89 const char * usage, 90 char ** & left 91 ) { 92 check_args(options); 93 94 int maxv = 'h'; 95 char optstring[(opt_count * 3) + 2] = { '\0' }; 96 { 97 int idx = 0; 98 for(i; opt_count) { 99 if (options[i].short_name) { 100 maxv = max(options[i].short_name, maxv); 101 optstring[idx] = options[i].short_name; 102 idx++; 103 if( ((intptr_t)options[i].parse) != ((intptr_t)parse_settrue) 104 && ((intptr_t)options[i].parse) != ((intptr_t)parse_setfalse) ) { 105 optstring[idx] = ':'; 106 idx++; 107 } 108 } 109 } 110 optstring[idx+0] = 'h'; 111 optstring[idx+1] = '\0'; 112 } 113 114 struct option optarr[opt_count + 2]; 115 { 116 int idx = 0; 117 for(i; opt_count) { 118 if(options[i].long_name) { 119 // we don't have the mutable keyword here, which is really what we would want 120 int & val_ref = (int &)(const int &)options[i].val; 121 val_ref = (options[i].short_name != '\0') ? ((int)options[i].short_name) : ++maxv; 122 123 optarr[idx].name = options[i].long_name; 124 optarr[idx].flag = 0p; 125 optarr[idx].val = options[i].val; 126 if( ((intptr_t)options[i].parse) == ((intptr_t)parse_settrue) 127 || ((intptr_t)options[i].parse) == ((intptr_t)parse_setfalse) ) { 128 optarr[idx].has_arg = no_argument; 129 } else { 130 optarr[idx].has_arg = required_argument; 131 } 104 132 idx++; 105 133 } 106 134 } 107 } 108 optstring[idx+0] = 'h'; 109 optstring[idx+1] = '\0'; 110 } 111 112 struct option optarr[opt_count + 2]; 113 { 114 int idx = 0; 115 for(i; opt_count) { 116 if(options[i].long_name) { 117 options[i].val = (options[i].short_name != '\0') ? ((int)options[i].short_name) : ++maxv; 118 optarr[idx].name = options[i].long_name; 119 optarr[idx].flag = 0p; 120 optarr[idx].val = options[i].val; 121 if( ((intptr_t)options[i].parse) == ((intptr_t)parse_settrue) 122 || ((intptr_t)options[i].parse) == ((intptr_t)parse_setfalse) ) { 123 optarr[idx].has_arg = no_argument; 124 } else { 125 optarr[idx].has_arg = required_argument; 126 } 127 idx++; 135 optarr[idx+0].[name, has_arg, flag, val] = ["help", no_argument, 0, 'h']; 136 optarr[idx+1].[name, has_arg, flag, val] = [0, no_argument, 0, 0]; 137 } 138 139 FILE * out = stderr; 140 NEXT_ARG: 141 for() { 142 int idx = 0; 143 int opt = getopt_long(argc, argv, optstring, optarr, &idx); 144 switch(opt) { 145 case -1: 146 if(&left != 0p) left = argv + optind; 147 return; 148 case 'h': 149 out = stdout; 150 case '?': 151 usage(argv[0], options, usage, out); 152 default: 153 for(i; opt_count) { 154 if(opt == options[i].val) { 155 const char * arg = optarg ? optarg : ""; 156 if( arg[0] == '=' ) { arg++; } 157 // work around for some weird bug 158 void * variable = options[i].variable; 159 bool (*parse_func)(const char *, void * ) = options[i].parse; 160 bool success = parse_func( arg, variable ); 161 if(success) continue NEXT_ARG; 162 163 fprintf(out, "Argument '%s' for option %c could not be parsed\n\n", arg, (char)opt); 164 usage(argv[0], options, usage, out); 165 } 166 } 167 abort("Internal parse arg error\n"); 128 168 } 129 } 130 optarr[idx+0].[name, has_arg, flag, val] = ["help", no_argument, 0, 'h']; 131 optarr[idx+1].[name, has_arg, flag, val] = [0, no_argument, 0, 0]; 132 } 133 134 FILE * out = stderr; 135 NEXT_ARG: 136 for() { 137 int idx = 0; 138 int opt = getopt_long(argc, argv, optstring, optarr, &idx); 139 switch(opt) { 140 case -1: 141 if(&left != 0p) left = argv + optind; 142 return; 143 case 'h': 144 out = stdout; 145 case '?': 146 usage(argv[0], options, opt_count, usage, out); 147 default: 148 for(i; opt_count) { 149 if(opt == options[i].val) { 150 const char * arg = optarg ? optarg : ""; 151 if( arg[0] == '=' ) { arg++; } 152 bool success = options[i].parse( arg, options[i].variable ); 153 if(success) continue NEXT_ARG; 154 155 fprintf(out, "Argument '%s' for option %c could not be parsed\n\n", arg, (char)opt); 156 usage(argv[0], options, opt_count, usage, out); 157 } 158 } 159 abort("Internal parse arg error\n"); 160 } 161 169 170 } 162 171 } 163 172 } … … 222 231 223 232 void print_args_usage(cfa_option options[], size_t opt_count, const char * usage, bool error) __attribute__ ((noreturn)) { 224 usage(cfa_args_argv[0], options, opt_count, usage, error ? stderr : stdout); 233 const array( cfa_option, opt_count ) & arr = (const array( cfa_option, opt_count ) &) *options; 234 usage(cfa_args_argv[0], arr, usage, error ? stderr : stdout); 225 235 } 226 236 227 237 void print_args_usage(int , char * argv[], cfa_option options[], size_t opt_count, const char * usage, bool error) __attribute__ ((noreturn)) { 228 usage(argv[0], options, opt_count, usage, error ? stderr : stdout); 229 } 230 231 static void usage(char * cmd, cfa_option options[], size_t opt_count, const char * help, FILE * out) __attribute__((noreturn)) { 238 const array( cfa_option, opt_count ) & arr = (const array( cfa_option, opt_count ) &) *options; 239 usage(argv[0], arr, usage, error ? stderr : stdout); 240 } 241 242 forall( [N] ) { 243 void print_args_usage( const array(cfa_option, N ) & options, const char * usage, bool error) { 244 usage(cfa_args_argv[0], options, usage, error ? stderr : stdout); 245 } 246 247 void print_args_usage(int argc, char * argv[], const array( cfa_option, N ) & options, const char * usage, bool error) { 248 usage(argv[0], options, usage, error ? stderr : stdout); 249 } 250 } 251 252 forall([N]) 253 static void usage(char * cmd, const array( cfa_option, N ) & options, const char * help, FILE * out) __attribute__((noreturn)) { 232 254 int width = 0; 233 255 { 234 for(i; opt_count) {256 for(i; N) { 235 257 if(options[i].long_name) { 236 258 int w = strlen(options[i].long_name); … … 251 273 fprintf(out, "Usage:\n %s %s\n", cmd, help); 252 274 253 for(i; opt_count) {275 for(i; N) { 254 276 printopt(out, width, max_width, options[i].short_name, options[i].long_name, options[i].help); 255 277 } -
libcfa/src/parseargs.hfa
r82ff4ed1 rd191e24 16 16 #pragma once 17 17 18 #include <array.hfa> 19 18 20 struct cfa_option { 19 20 21 22 23 24 21 int val; // reserved 22 char short_name; 23 const char * long_name; 24 const char * help; 25 void * variable; 26 bool (*parse)(const char *, void * ); 25 27 }; 26 28 … … 31 33 forall(T & | { bool parse(const char *, T & ); }) 32 34 static inline void ?{}( cfa_option & this, char short_name, const char * long_name, const char * help, T & variable ) { 33 34 35 36 37 38 35 this.val = 0; 36 this.short_name = short_name; 37 this.long_name = long_name; 38 this.help = help; 39 this.variable = (void*)&variable; 40 this.parse = (bool (*)(const char *, void * ))parse; 39 41 } 40 42 41 43 forall(T &) 42 44 static inline void ?{}( cfa_option & this, char short_name, const char * long_name, const char * help, T & variable, bool (*parse)(const char *, T & )) { 43 44 45 46 47 48 45 this.val = 0; 46 this.short_name = short_name; 47 this.long_name = long_name; 48 this.help = help; 49 this.variable = (void*)&variable; 50 this.parse = (bool (*)(const char *, void * ))parse; 49 51 } 50 52 … … 52 54 void parse_args( int argc, char * argv[], cfa_option options[], size_t opt_count, const char * usage, char ** & left ); 53 55 56 forall( [N] ) { 57 void parse_args( const array( cfa_option, N ) & options, const char * usage, char ** & left ); 58 void parse_args( int argc, char * argv[], const array( cfa_option, N ) & options, const char * usage, char ** & left ); 59 } 60 54 61 void print_args_usage(cfa_option options[], size_t opt_count, const char * usage, bool error) __attribute__ ((noreturn)); 55 62 void print_args_usage(int argc, char * argv[], cfa_option options[], size_t opt_count, const char * usage, bool error) __attribute__ ((noreturn)); 63 64 forall( [N] ) { 65 void print_args_usage( const array(cfa_option, N ) & options, const char * usage, bool error) __attribute__ ((noreturn)); 66 void print_args_usage(int argc, char * argv[], const array( cfa_option, N ) & options, const char * usage, bool error) __attribute__ ((noreturn)); 67 } 56 68 57 69 bool parse_yesno (const char *, bool & ); -
src/AST/Convert.cpp
r82ff4ed1 rd191e24 310 310 node->name, 311 311 get<Attribute>().acceptL( node->attributes ), 312 false, // Temporary312 node->isTyped, 313 313 LinkageSpec::Spec( node->linkage.val ), 314 314 get<Type>().accept1(node->base) 315 315 ); 316 return aggregatePostamble( decl, node ); // Node info, including members, processed in aggregatePostamble316 return aggregatePostamble( decl, node ); 317 317 } 318 318 … … 737 737 node->name 738 738 ); 739 temp->var = get<DeclarationWithType>().accept1(node->var);740 739 auto expr = visitBaseExpr( node, 741 740 temp … … 1615 1614 { old->get_funcSpec().val } 1616 1615 ); 1616 decl->enumInLine = old->enumInLine; 1617 1617 cache.emplace(old, decl); 1618 1618 assert(cache.find( old ) != cache.end()); … … 2281 2281 } 2282 2282 2283 /// xxx - type_decl should be DeclWithType in the final design2284 /// type_decl is set to EnumDecl as a temporary fix2285 2283 virtual void visit( const QualifiedNameExpr * old ) override final { 2286 2284 this->node = visitBaseExpr( old, … … 2288 2286 old->location, 2289 2287 GET_ACCEPT_1(type_decl, Decl), 2290 GET_ACCEPT_1(var, DeclWithType),2291 2288 old->name 2292 2289 ) -
src/AST/Decl.hpp
r82ff4ed1 rd191e24 105 105 ptr<Init> init; 106 106 ptr<Expr> bitfieldWidth; 107 bool enumInLine = false; // enum inline is not a real object declaration. 108 // It is a place holder for a set of enum value (ObjectDecl) 109 bool importValue = false; // if the value copied from somewhere else 107 110 108 111 ObjectDecl( const CodeLocation & loc, const std::string & name, const Type * type, … … 312 315 class EnumDecl final : public AggregateDecl { 313 316 public: 314 bool isTyped; 315 ptr<Type> base; 317 bool isTyped; // isTyped indicated if the enum has a declaration like: 318 // enum (type_optional) Name {...} 319 ptr<Type> base; // if isTyped == true && base.get() == nullptr, it is a "void" type enum 316 320 317 321 EnumDecl( const CodeLocation& loc, const std::string& name, bool isTyped = false, -
src/AST/Expr.hpp
r82ff4ed1 rd191e24 257 257 public: 258 258 ptr<Decl> type_decl; 259 ptr<DeclWithType> var;260 259 std::string name; 261 260 262 QualifiedNameExpr( const CodeLocation & loc, const Decl * d, const DeclWithType * r, conststd::string & n )263 : Expr( loc ), type_decl( d ), var(r),name( n ) {}261 QualifiedNameExpr( const CodeLocation & loc, const Decl * d, const std::string & n ) 262 : Expr( loc ), type_decl( d ), name( n ) {} 264 263 265 264 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } -
src/AST/Pass.impl.hpp
r82ff4ed1 rd191e24 1205 1205 if ( __visit_children() ) { 1206 1206 guard_symtab guard { *this }; 1207 maybe_accept( node, &QualifiedNameExpr::var );1208 1207 maybe_accept( node, &QualifiedNameExpr::type_decl ); 1209 1208 } -
src/CodeGen/CodeGenerator.cc
r82ff4ed1 rd191e24 912 912 } 913 913 output << ")"; 914 }915 916 // QualifiedNameExpr should not reach to CodeGen.917 // FixQualifiedName Convert QualifiedNameExpr to VariableExpr918 void CodeGenerator::postvisit( QualifiedNameExpr * expr ) {919 output << "/* label */" << mangleName(expr->var);920 914 } 921 915 -
src/CodeGen/CodeGenerator.h
r82ff4ed1 rd191e24 103 103 void postvisit( DefaultArgExpr * ); 104 104 void postvisit( GenericExpr * ); 105 void postvisit( QualifiedNameExpr *);106 105 107 106 //*** Statements -
src/Common/PassVisitor.impl.h
r82ff4ed1 rd191e24 1934 1934 indexerScopedAccept( node->result, *this ); 1935 1935 maybeAccept_impl( node->type_decl, *this ); 1936 maybeAccept_impl( node->var, *this );1937 1936 1938 1937 VISIT_END( node ); … … 1945 1944 indexerScopedAccept( node->result, *this ); 1946 1945 maybeAccept_impl( node->type_decl, *this ); 1947 maybeAccept_impl( node->var, *this );1948 1946 1949 1947 VISIT_END( node ); … … 1957 1955 indexerScopedMutate( node->result, *this ); 1958 1956 maybeMutate_impl( node->type_decl, *this ); 1959 maybeAccept_impl( node->var, *this );1960 1957 1961 1958 MUTATE_END( Expression, node ); -
src/Parser/DeclarationNode.cc
r82ff4ed1 rd191e24 297 297 } // if 298 298 } // DeclarationNode::newEnumValueGeneric 299 300 DeclarationNode * DeclarationNode::newEnumInLine( const string name ) { 301 DeclarationNode * newnode = newName( new std::string(name) ); 302 newnode->enumInLine = true; 303 return newnode; 304 } 299 305 300 306 DeclarationNode * DeclarationNode::newFromTypedef( const string * name ) { -
src/Parser/ExpressionNode.cc
r82ff4ed1 rd191e24 523 523 auto enumInst = new EnumInstType( Type::Qualifiers(), e ); 524 524 auto obj = new ObjectDecl( name->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, enumInst, nullptr ); 525 ret->set_var( obj );526 525 } 527 526 return ret; -
src/Parser/ParseNode.h
r82ff4ed1 rd191e24 240 240 static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant ); 241 241 static DeclarationNode * newEnumValueGeneric( const std::string * name, InitializerNode * init ); 242 static DeclarationNode * newEnumInLine( const std::string name ); 242 243 static DeclarationNode * newName( const std::string * ); 243 244 static DeclarationNode * newFromTypeGen( const std::string *, ExpressionNode * params ); … … 339 340 340 341 bool inLine = false; 342 bool enumInLine = false; 341 343 Type::FuncSpecifiers funcSpecs; 342 344 Type::StorageClasses storageClasses; -
src/Parser/TypeData.cc
r82ff4ed1 rd191e24 924 924 list< Declaration * >::iterator members = ret->get_members().begin(); 925 925 for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) { 926 if ( cur->enumInLine ) { 927 // Tell the compiler this is a inline value placeholder 928 ObjectDecl * member = dynamic_cast< ObjectDecl* >(* members); 929 member->enumInLine = true; 930 } 926 931 if ( ret->isTyped && !ret->base && cur->has_enumeratorValue() ) { 927 932 SemanticError( td->location, "Enumerator of enum(void) cannot have an explicit initializer value." ); -
src/Parser/parser.yy
r82ff4ed1 rd191e24 2605 2605 { $$ = DeclarationNode::newEnumValueGeneric( $1, $2 ); } 2606 2606 | INLINE type_name 2607 { $$ = DeclarationNode::newEnum ValueGeneric( new string("inline"), nullptr); }2607 { $$ = DeclarationNode::newEnumInLine( *$2->type->symbolic.name ); } 2608 2608 | enumerator_list ',' identifier_or_type_name enumerator_value_opt 2609 2609 { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( $3, $4 ) ); } -
src/ResolvExpr/CandidateFinder.cpp
r82ff4ed1 rd191e24 862 862 } 863 863 } 864 }865 866 void postvisit( const ast::QualifiedNameExpr * qualifiedNameExpr ) {867 auto mangleName = Mangle::mangle(qualifiedNameExpr->var);868 addCandidate( qualifiedNameExpr, tenv );869 864 } 870 865 -
src/SymTab/Mangler.cc
r82ff4ed1 rd191e24 65 65 void postvisit( const QualifiedType * qualType ); 66 66 67 void postvisit( const QualifiedNameExpr * qualNameExpr );68 69 67 std::string get_mangleName() { return mangleName; } 70 68 private: … … 307 305 mangleName += Encoding::qualifiedTypeEnd; 308 306 } 309 }310 311 void Mangler_old::postvisit( const QualifiedNameExpr * qual ) {312 maybeAccept( qual->var, *visitor );313 307 } 314 308 … … 423 417 void postvisit( const ast::OneType * oneType ); 424 418 void postvisit( const ast::QualifiedType * qualType ); 425 void postvisit( const ast::QualifiedNameExpr * qualNameExpr );426 419 427 420 std::string get_mangleName() { return mangleName; } … … 652 645 mangleName += Encoding::qualifiedTypeEnd; 653 646 } 654 }655 void Mangler_new::postvisit( const ast::QualifiedNameExpr * qual ) {656 maybeAccept( qual->var.get(), *visitor );657 647 } 658 648 -
src/SymTab/Validate.cc
r82ff4ed1 rd191e24 858 858 declsToAddBefore.push_back( new UnionDecl( aggDecl->name, noAttributes, tyDecl->linkage ) ); 859 859 } else if ( EnumInstType * enumInst = dynamic_cast< EnumInstType * >( designatorType ) ) { 860 // declsToAddBefore.push_back( new EnumDecl( enumDecl->name, noAttributes, tyDecl->linkage, enumDecl->baseEnum->base ) );861 860 if ( enumInst->baseEnum ) { 862 861 const EnumDecl * enumDecl = enumInst->baseEnum; -
src/SymTab/ValidateType.cc
r82ff4ed1 rd191e24 81 81 void previsit( QualifiedType * qualType ); 82 82 void postvisit( QualifiedType * qualType ); 83 84 83 void postvisit( QualifiedNameExpr * qualExpr ); 85 84 86 85 void postvisit( EnumDecl * enumDecl ); 87 86 void postvisit( StructDecl * structDecl ); -
src/SynTree/AddressExpr.cc
r82ff4ed1 rd191e24 50 50 set_result( addrType( refType->base ) ); 51 51 } else { 52 if(!arg->result->location.isSet()) arg->result->location = arg->location; 52 53 SemanticError( arg->result, "Attempt to take address of non-lvalue expression: " ); 53 54 } // if -
src/SynTree/Declaration.h
r82ff4ed1 rd191e24 121 121 Initializer * init; 122 122 Expression * bitfieldWidth; 123 bool enumInLine = false; 123 124 124 125 ObjectDecl( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression * bitfieldWidth, Type * type, Initializer * init, -
src/SynTree/Expression.h
r82ff4ed1 rd191e24 168 168 Declaration * type_decl; 169 169 std::string name; 170 DeclarationWithType * var;171 170 172 171 QualifiedNameExpr( Declaration * decl, std::string name): Expression(), type_decl(decl), name(name) {} 173 QualifiedNameExpr( const QualifiedNameExpr & other): Expression(other), type_decl(other.type_decl), name(other.name), var(other.var) {} 174 DeclarationWithType * get_var() const { return var; } 175 void set_var( DeclarationWithType * newValue ) { var = newValue; } 172 QualifiedNameExpr( const QualifiedNameExpr & other): Expression(other), type_decl(other.type_decl), name(other.name) {} 176 173 177 174 virtual ~QualifiedNameExpr() { 178 delete var;179 175 delete type_decl; 180 176 } -
src/Validate/FixQualifiedTypes.cpp
r82ff4ed1 rd191e24 102 102 } 103 103 104 105 auto var = new ast::ObjectDecl( t->var->location, t->name, 106 new ast::EnumInstType(enumDecl, ast::CV::Const), nullptr, {}, ast::Linkage::Cforall ); 107 var->scopeLevel = 1; // 1 for now; should copy the scopeLevel of the enumValue 104 auto var = new ast::ObjectDecl( t->location, t->name, 105 new ast::EnumInstType(enumDecl, ast::CV::Const), nullptr, {}, ast::Linkage::Cforall ); 108 106 var->mangleName = Mangle::mangle( var ); 109 107 return new ast::VariableExpr( t->location, var ); 110 // return ret;111 108 } 112 109 -
src/Validate/LinkReferenceToTypes.cpp
r82ff4ed1 rd191e24 44 44 void postvisit( ast::UnionDecl const * decl ); 45 45 ast::TraitDecl const * postvisit( ast::TraitDecl const * decl ); 46 ast::QualifiedNameExpr const * previsit( ast::QualifiedNameExpr const * decl);47 46 48 47 private: … … 203 202 } 204 203 204 // The following section 205 auto mut = ast::mutate( decl ); 206 std::vector<ast::ptr<ast::Decl>> buffer; 207 for ( auto it = decl->members.begin(); it != decl->members.end(); ++it) { 208 auto member = (*it).as<ast::ObjectDecl>(); 209 if ( member->enumInLine ) { 210 auto targetEnum = symtab.lookupEnum( member->name ); 211 if ( targetEnum ) { 212 for ( auto singleMamber : targetEnum->members ) { 213 auto tm = singleMamber.as<ast::ObjectDecl>(); 214 auto t = new ast::ObjectDecl( 215 member->location, // use the "inline" location 216 tm->name, 217 new ast::EnumInstType( decl, ast::CV::Const ), 218 // Construct a new EnumInstType as the type 219 tm->init, 220 tm->storage, 221 tm->linkage, 222 tm->bitfieldWidth, 223 {}, // enum member doesn't have attribute 224 tm->funcSpec 225 ); 226 t->importValue = true; 227 buffer.push_back(t); 228 } 229 } 230 } else { 231 auto search_it = std::find_if( buffer.begin(), buffer.end(), [member](ast::ptr<ast::Decl> cur) { 232 auto curAsObjDecl = cur.as<ast::ObjectDecl>(); 233 return (curAsObjDecl->importValue) && (curAsObjDecl->name == member->name); 234 }); 235 if ( search_it != buffer.end() ) { 236 buffer.erase( search_it ); // Found an import enum value that has the same name 237 // override the imported value 238 } 239 buffer.push_back( *it ); 240 } 241 } 242 mut->members = buffer; 243 decl = mut; 244 205 245 ForwardEnumsType::iterator fwds = forwardEnums.find( decl->name ); 206 246 if ( fwds != forwardEnums.end() ) { … … 284 324 } 285 325 286 ast::QualifiedNameExpr const * LinkTypesCore::previsit( ast::QualifiedNameExpr const * decl ) {287 // Try to lookup type288 if ( auto objDecl = decl->type_decl.as<ast::ObjectDecl>() ) {289 if ( auto inst = objDecl->type.as<ast::TypeInstType>()) {290 if ( auto enumDecl = symtab.lookupEnum ( inst->name ) ) {291 auto mut = ast::mutate( decl );292 mut->type_decl = enumDecl;293 auto enumInst = new ast::EnumInstType( enumDecl );294 enumInst->name = decl->name;295 // Adding result; addCandidate() use result296 mut->result = enumInst;297 decl = mut;298 }299 }300 } else if ( auto enumDecl = decl->type_decl.as<ast::EnumDecl>() ) {301 auto mut = ast::mutate( decl );302 auto enumInst = new ast::EnumInstType( enumDecl );303 enumInst->name = decl->name;304 // Adding result; addCandidate() use result305 mut->result = enumInst;306 decl = mut;307 }308 // ast::EnumDecl const * decl = symtab.lookupEnum( type->name );309 // // It's not a semantic error if the enum is not found, just an implicit forward declaration.310 // if ( decl ) {311 // // Just linking in the node.312 // auto mut = ast::mutate( type );313 // mut->base = const_cast<ast::EnumDecl *>( decl );314 // type = mut;315 // }316 return decl;317 }318 319 326 } // namespace 320 327 -
tests/configs/parsebools.cfa
r82ff4ed1 rd191e24 15 15 // 16 16 17 #include <fstream.hfa> 17 18 #include <parseargs.hfa> 18 #include <fstream.hfa>19 19 20 20 #include "../meta/fork+exec.hfa" … … 30 30 bool sf = true; 31 31 32 cfa_option options[] = { 33 {'e', "yesno", "test yes/no", YN, parse_yesno}, 34 {'y', "YN", "test yes/no", Yn, parse_yesno}, 35 {'n', "yn", "test yes/no", yn, parse_yesno}, 36 {'t', "truefalse", "test true/false", tf, parse_truefalse}, 37 {'s', "settrue", "test set true", st, parse_settrue}, 38 {'u', "setfalse", "test set false", sf, parse_setfalse}, 39 }; 40 int options_cnt = sizeof(options) / sizeof(cfa_option); 32 array( cfa_option, 6 ) options; 33 options[0] = (cfa_option){'e', "yesno", "test yes/no", YN, parse_yesno}; 34 options[1] = (cfa_option){'y', "YN", "test yes/no", Yn, parse_yesno}; 35 options[2] = (cfa_option){'n', "yn", "test yes/no", yn, parse_yesno}; 36 options[3] = (cfa_option){'t', "truefalse", "test true/false", tf, parse_truefalse}; 37 options[4] = (cfa_option){'s', "settrue", "test set true", st, parse_settrue}; 38 options[5] = (cfa_option){'u', "setfalse", "test set false", sf, parse_setfalse}; 41 39 42 40 char **left; 43 parse_args( options, options_cnt,"[OPTIONS]...\ntesting bool parameters", left);41 parse_args( options, "[OPTIONS]...\ntesting bool parameters", left); 44 42 45 43 sout | "yes/no :" | YN; -
tests/configs/parsenums.cfa
r82ff4ed1 rd191e24 15 15 // 16 16 17 #include <fstream.hfa> 17 18 #include <parseargs.hfa> 18 #include <fstream.hfa>19 19 20 20 #include "../meta/fork+exec.hfa" … … 42 42 43 43 44 cfa_option options[] = { 45 { 'i', "int", "test int", i }, 46 { 'u', "unsigned", "test unsigned", u }, 47 { 'l', "unsignedlong", "test unsigned long", ul }, 48 { 'L', "unsignedlonglong", "test unsigned long long", ull }, 49 { 'd', "double", "test double", d }, 50 }; 51 int options_cnt = sizeof(options) / sizeof(cfa_option); 44 array( cfa_option, 5 ) options; 45 options[0] = (cfa_option){ 'i', "int", "test int", i }; 46 options[1] = (cfa_option){ 'u', "unsigned", "test unsigned", u }; 47 options[2] = (cfa_option){ 'l', "unsignedlong", "test unsigned long", ul }; 48 options[3] = (cfa_option){ 'L', "unsignedlonglong", "test unsigned long long", ull }; 49 options[4] = (cfa_option){ 'd', "double", "test double", d }; 52 50 53 51 char **left; 54 parse_args( options, options_cnt,"[OPTIONS]...\ntesting bool parameters", left);52 parse_args( options, "[OPTIONS]...\ntesting bool parameters", left); 55 53 56 54 sout | "int :" | i; -
tests/configs/usage.cfa
r82ff4ed1 rd191e24 15 15 // 16 16 17 #include <fstream.hfa> 17 18 #include <parseargs.hfa> 18 #include <fstream.hfa>19 19 20 20 #include "../meta/fork+exec.hfa" … … 25 25 sout | "No args, no errors"; 26 26 if(pid_t child = strict_fork(); child == 0) { 27 cfa_option opts[0];28 print_args_usage(1, fake_argv, opts, 0,"Test usage", false);27 array( cfa_option, 0 ) opts; 28 print_args_usage(1, fake_argv, opts, "Test usage", false); 29 29 } 30 30 else { … … 35 35 sout | "No args, with errors"; 36 36 if(pid_t child = strict_fork(); child == 0) { 37 cfa_option opts[0];38 print_args_usage(1, fake_argv, opts, 0,"Test usage", true);37 array( cfa_option, 0 ) opts; 38 print_args_usage(1, fake_argv, opts, "Test usage", true); 39 39 } 40 40 else { … … 46 46 if(pid_t child = strict_fork(); child == 0) { 47 47 int a, b, c; 48 cfa_option opts[] = { 49 {'a', "", "First arg", a }, 50 {'b', "", "Second arg", b }, 51 {'c', "", "Third arg", c }, 52 }; 53 print_args_usage(1, fake_argv, opts, 3, "Test usage", false); 48 array( cfa_option, 3 ) opts; 49 opts[0] = (cfa_option){'a', "", "First arg", a }; 50 opts[1] = (cfa_option){'b', "", "Second arg", b }; 51 opts[2] = (cfa_option){'c', "", "Third arg", c }; 52 print_args_usage(1, fake_argv, opts, "Test usage", false); 54 53 } 55 54 else { … … 61 60 if(pid_t child = strict_fork(); child == 0) { 62 61 int a, b, c; 63 cfa_option opts[] = { 64 {'\0', "AA", "First arg", a }, 65 {'\0', "BB", "Second arg", b }, 66 {'\0', "CC", "Third arg", c }, 67 }; 68 print_args_usage(1, fake_argv, opts, 3, "Test usage", false); 62 array( cfa_option, 3 ) opts; 63 opts[0] = (cfa_option){'\0', "AA", "First arg", a }; 64 opts[1] = (cfa_option){'\0', "BB", "Second arg", b }; 65 opts[2] = (cfa_option){'\0', "CC", "Third arg", c }; 66 print_args_usage(1, fake_argv, opts, "Test usage", false); 69 67 } 70 68 else { … … 76 74 if(pid_t child = strict_fork(); child == 0) { 77 75 int a, b, c; 78 cfa_option opts[] = { 79 {'a', "", "First arg", a }, 80 {'b', "BBBB", "Second arg", b }, 81 {'\0', "CC", "Third arg", c }, 82 }; 83 print_args_usage(1, fake_argv, opts, 3, "Test usage", false); 76 array( cfa_option, 3 ) opts; 77 opts[0] = (cfa_option){'a', "", "First arg", a }; 78 opts[1] = (cfa_option){'b', "BBBB", "Second arg", b }; 79 opts[2] = (cfa_option){'\0', "CC", "Third arg", c }; 80 print_args_usage(1, fake_argv, opts, "Test usage", false); 84 81 } 85 82 else { … … 91 88 if(pid_t child = strict_fork(); child == 0) { 92 89 int a, b, c; 93 cfa_option opts[] = { 94 {'a', "", "First arg", a }, 95 {'b', "BBBB", "", b }, 96 {'\0', "CC", "Third arg", c }, 97 }; 98 print_args_usage(1, fake_argv, opts, 3, "Test usage", false); 90 array( cfa_option, 3 ) opts; 91 opts[0] = (cfa_option){'a', "", "First arg", a }; 92 opts[1] = (cfa_option){'b', "BBBB", "", b }; 93 opts[2] = (cfa_option){'\0', "CC", "Third arg", c }; 94 print_args_usage(1, fake_argv, opts, "Test usage", false); 99 95 } 100 96 else { … … 106 102 if(pid_t child = strict_fork(); child == 0) { 107 103 int a, b, c; 108 cfa_option opts[] = { 109 {'a', "", "First arg\nThe description has multiple lines,\n...for some reason", a }, 110 {'b', "BBBB", "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", b }, 111 {'\0', "CC", "Third arg", c }, 112 }; 113 print_args_usage(1, fake_argv, opts, 3, "Test usage", false); 104 array( cfa_option, 3 ) opts; 105 opts[0] = (cfa_option){'a', "", "First arg\nThe description has multiple lines,\n...for some reason", a }; 106 opts[1] = (cfa_option){'b', "BBBB", "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", b }; 107 opts[2] = (cfa_option){'\0', "CC", "Third arg", c }; 108 print_args_usage(1, fake_argv, opts, "Test usage", false); 114 109 } 115 110 else { -
tests/device/cpu.cfa
r82ff4ed1 rd191e24 117 117 unsigned find_idx() { 118 118 int idxs = count_cache_indexes(); 119 if( 0 == idxs ) return 0; 119 120 120 121 unsigned found_level = 0; … … 179 180 unsigned idx = find_idx(); 180 181 // For all procs check mapping is consistent 181 for(cpu_me; cpu_info.hthrd_count) {182 if( idx > 0 ) for(cpu_me; cpu_info.hthrd_count) { 182 183 char buf_me[32]; 183 184 size_t len_me = read_cpuidxinfo_into(cpu_me, idx, "shared_cpu_list", buf_me, 32);
Note:
See TracChangeset
for help on using the changeset viewer.