- Timestamp:
- May 6, 2016, 4:28:50 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- ec79847
- Parents:
- 99ee64d (diff), 03e5d14 (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. - Location:
- src
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r99ee64d r9e2c1f0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Apr 27 11:59:36201612 // Last Modified On : Fri May 06 16:01:00 2016 13 13 // Update Count : 255 14 14 // … … 76 76 //*** Declarations 77 77 void CodeGenerator::visit( FunctionDecl *functionDecl ) { 78 // generalize this 79 FunctionDecl::Attribute attr = functionDecl->get_attribute(); 80 switch ( attr.type ) { 81 case FunctionDecl::Attribute::Constructor: 82 output << "__attribute__ ((constructor"; 83 if ( attr.priority != FunctionDecl::Attribute::Default ) { 84 output << "(" << attr.priority << ")"; 85 } 86 output << ")) "; 87 break; 88 case FunctionDecl::Attribute::Destructor: 89 output << "__attribute__ ((destructor"; 90 if ( attr.priority != FunctionDecl::Attribute::Default ) { 91 output << "(" << attr.priority << ")"; 92 } 93 output << ")) "; 94 break; 95 default: 96 break; 97 } 78 98 handleStorageClass( functionDecl ); 79 99 if ( functionDecl->get_isInline() ) { -
src/InitTweak/GenInit.cc
r99ee64d r9e2c1f0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Apr 28 12:26:47201612 // Last Modified On : Fri May 06 16:11:15 2016 13 13 // Update Count : 166 14 14 // … … 129 129 } 130 130 131 bool tryConstruct( ObjectDecl * objDecl ) { 132 // xxx - handle designations 133 return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) && 134 (objDecl->get_init() == NULL || 135 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() )); 136 } 131 137 namespace { 132 bool tryConstruct( ObjectDecl * objDecl ) {133 // xxx - handle designations134 return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) &&135 (objDecl->get_init() == NULL ||136 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() ));137 }138 138 139 139 Expression * makeCtorDtorExpr( std::string name, ObjectDecl * objDecl, std::list< Expression * > args ) { … … 209 209 objDecl->set_init( new ConstructorInit( ctorStmt, dtorStmt, objDecl->get_init() ) ); 210 210 } 211 } else {212 // xxx - find a way to construct/destruct globals213 // hack: implicit "static" initialization routine for each struct type? or something similar?214 // --ties into module system215 // this can be done by mangling main and replacing it with our own main which calls each216 // module initialization routine in some decided order (order given in link command?)217 // and finally calls mangled main218 211 } 219 212 } -
src/InitTweak/GenInit.h
r99ee64d r9e2c1f0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Apr 28 12:22:09201612 // Last Modified On : Fri May 06 16:18:22 2016 13 13 // Update Count : 3 14 14 // … … 27 27 /// Adds return value temporaries and wraps Initializers in ConstructorInit nodes 28 28 void genInit( std::list< Declaration * > & translationUnit ); 29 /// True if the resolver should try to construct objDecl 30 bool tryConstruct( ObjectDecl * objDecl ); 29 31 } // namespace 30 32 31 #endif // GENPOLY_POLYMUTATOR_H33 #endif // INITTWEAK_GENINIT_H 32 34 33 35 // Local Variables: // -
src/InitTweak/module.mk
r99ee64d r9e2c1f0 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 12 ## Last Modified By : Rob Schluntz 13 ## Last Modified On : Thu Apr 28 12:23:17 201613 ## Last Modified On : Fri May 06 15:59:27 2016 14 14 ## Update Count : 3 15 15 ############################################################################### 16 16 17 17 SRC += InitTweak/GenInit.cc \ 18 InitTweak/FixInit.cc 18 InitTweak/FixInit.cc \ 19 InitTweak/FixGlobalInit.cc 20 -
src/Makefile.in
r99ee64d r9e2c1f0 125 125 InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT) \ 126 126 InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT) \ 127 InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT) \ 127 128 Parser/driver_cfa_cpp-parser.$(OBJEXT) \ 128 129 Parser/driver_cfa_cpp-lex.$(OBJEXT) \ … … 348 349 GenPoly/CopyParams.cc GenPoly/FindFunction.cc \ 349 350 GenPoly/DeclMutator.cc InitTweak/GenInit.cc \ 350 InitTweak/FixInit.cc Parser/parser.yy Parser/lex.ll\351 Parser/ TypedefTable.cc Parser/ParseNode.cc \352 Parser/ DeclarationNode.cc Parser/ExpressionNode.cc \353 Parser/ StatementNode.cc Parser/InitializerNode.cc \354 Parser/ TypeData.cc Parser/LinkageSpec.cc \355 Parser/ parseutility.cc Parser/Parser.cc \351 InitTweak/FixInit.cc InitTweak/FixGlobalInit.cc \ 352 Parser/parser.yy Parser/lex.ll Parser/TypedefTable.cc \ 353 Parser/ParseNode.cc Parser/DeclarationNode.cc \ 354 Parser/ExpressionNode.cc Parser/StatementNode.cc \ 355 Parser/InitializerNode.cc Parser/TypeData.cc \ 356 Parser/LinkageSpec.cc Parser/parseutility.cc Parser/Parser.cc \ 356 357 ResolvExpr/AlternativeFinder.cc ResolvExpr/Alternative.cc \ 357 358 ResolvExpr/Unify.cc ResolvExpr/PtrsAssignable.cc \ … … 569 570 InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT): InitTweak/$(am__dirstamp) \ 570 571 InitTweak/$(DEPDIR)/$(am__dirstamp) 572 InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT): \ 573 InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp) 571 574 Parser/parser.h: Parser/parser.cc 572 575 @if test ! -f $@; then rm -f Parser/parser.cc; else :; fi … … 800 803 -rm -f GenPoly/driver_cfa_cpp-ScrubTyVars.$(OBJEXT) 801 804 -rm -f GenPoly/driver_cfa_cpp-Specialize.$(OBJEXT) 805 -rm -f InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT) 802 806 -rm -f InitTweak/driver_cfa_cpp-FixInit.$(OBJEXT) 803 807 -rm -f InitTweak/driver_cfa_cpp-GenInit.$(OBJEXT) … … 907 911 @AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-ScrubTyVars.Po@am__quote@ 908 912 @AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-Specialize.Po@am__quote@ 913 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po@am__quote@ 909 914 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-FixInit.Po@am__quote@ 910 915 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-GenInit.Po@am__quote@ … … 1406 1411 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixInit.obj `if test -f 'InitTweak/FixInit.cc'; then $(CYGPATH_W) 'InitTweak/FixInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixInit.cc'; fi` 1407 1412 1413 InitTweak/driver_cfa_cpp-FixGlobalInit.o: InitTweak/FixGlobalInit.cc 1414 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixGlobalInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.o `test -f 'InitTweak/FixGlobalInit.cc' || echo '$(srcdir)/'`InitTweak/FixGlobalInit.cc 1415 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po 1416 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/FixGlobalInit.cc' object='InitTweak/driver_cfa_cpp-FixGlobalInit.o' libtool=no @AMDEPBACKSLASH@ 1417 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1418 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.o `test -f 'InitTweak/FixGlobalInit.cc' || echo '$(srcdir)/'`InitTweak/FixGlobalInit.cc 1419 1420 InitTweak/driver_cfa_cpp-FixGlobalInit.obj: InitTweak/FixGlobalInit.cc 1421 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixGlobalInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.obj `if test -f 'InitTweak/FixGlobalInit.cc'; then $(CYGPATH_W) 'InitTweak/FixGlobalInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixGlobalInit.cc'; fi` 1422 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po 1423 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/FixGlobalInit.cc' object='InitTweak/driver_cfa_cpp-FixGlobalInit.obj' libtool=no @AMDEPBACKSLASH@ 1424 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1425 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.obj `if test -f 'InitTweak/FixGlobalInit.cc'; then $(CYGPATH_W) 'InitTweak/FixGlobalInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixGlobalInit.cc'; fi` 1426 1408 1427 Parser/driver_cfa_cpp-parser.o: Parser/parser.cc 1409 1428 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/driver_cfa_cpp-parser.o -MD -MP -MF Parser/$(DEPDIR)/driver_cfa_cpp-parser.Tpo -c -o Parser/driver_cfa_cpp-parser.o `test -f 'Parser/parser.cc' || echo '$(srcdir)/'`Parser/parser.cc -
src/SynTree/Declaration.h
r99ee64d r9e2c1f0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Mon Apr 11 16:55:12 201613 // Update Count : 3 612 // Last Modified On : Fri May 06 16:26:12 2016 13 // Update Count : 33 14 14 // 15 15 … … 115 115 typedef DeclarationWithType Parent; 116 116 public: 117 FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn ); 117 // temporary - merge this into general GCC attributes 118 struct Attribute { 119 enum Type { 120 NoAttribute, Constructor, Destructor, 121 } type; 122 enum Priority { 123 // priorities 0-100 are reserved by gcc, so it's okay to use 100 an exceptional case 124 Default = 100, High, 125 } priority; 126 Attribute(Type t = NoAttribute, Priority p = Default) : type(t), priority(p) {}; 127 }; 128 129 FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute = Attribute() ); 118 130 FunctionDecl( const FunctionDecl &other ); 119 131 virtual ~FunctionDecl(); … … 128 140 std::list< std::string >& get_oldIdents() { return oldIdents; } 129 141 std::list< Declaration* >& get_oldDecls() { return oldDecls; } 142 Attribute get_attribute() const { return attribute; } 143 void set_attribute( Attribute newValue ) { attribute = newValue; } 130 144 131 145 virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); } … … 139 153 std::list< std::string > oldIdents; 140 154 std::list< Declaration* > oldDecls; 155 Attribute attribute; 141 156 }; 142 157 -
src/SynTree/FunctionDecl.cc
r99ee64d r9e2c1f0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue May 03 15:37:43201612 // Last Modified On : Fri May 06 15:59:48 2016 13 13 // Update Count : 19 14 14 // … … 21 21 #include "Common/utility.h" 22 22 23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn )24 : Parent( name, sc, linkage ), type( type ), statements( statements ) {23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute ) 24 : Parent( name, sc, linkage ), type( type ), statements( statements ), attribute( attribute ) { 25 25 set_isInline( isInline ); 26 26 set_isNoreturn( isNoreturn ); … … 32 32 33 33 FunctionDecl::FunctionDecl( const FunctionDecl &other ) 34 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {34 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), attribute( other.attribute ) { 35 35 } 36 36 … … 65 65 os << "_Noreturn "; 66 66 } // if 67 switch ( attribute.type ) { 68 case Attribute::Constructor: 69 os << "Global Constructor "; 70 break; 71 case Attribute::Destructor: 72 os << "Global Destructor "; 73 break; 74 default: 75 break; 76 } 77 if ( attribute.priority != Attribute::Default ) { 78 os << "with priority " << attribute.priority << " "; 79 } 67 80 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 68 81 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; … … 105 118 os << "_Noreturn "; 106 119 } // if 120 switch ( attribute.type ) { 121 case Attribute::Constructor: 122 os << " Global Constructor "; 123 break; 124 case Attribute::Destructor: 125 os << " Global Destructor "; 126 break; 127 default: 128 break; 129 } 130 if ( attribute.priority != Attribute::Default ) { 131 os << "with priority " << attribute.priority << " "; 132 } 107 133 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 108 134 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; -
src/driver/cc1.cc
r99ee64d r9e2c1f0 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 25 16:05:15201613 // Update Count : 5612 // Last Modified On : Thu May 5 16:04:30 2016 13 // Update Count : 77 14 14 // 15 15 … … 108 108 const char *args[argc + 100]; // leave space for 100 additional cpp command line values 109 109 int nargs = 1; // number of arguments in args list; 0 => command name 110 const char * uargs[20]; // leave space for 20 additional cfa-cpp command line values111 int n uargs = 1; // 0 => command name110 const char *cargs[20]; // leave space for 20 additional cfa-cpp command line values 111 int ncargs = 1; // 0 => command name 112 112 113 113 signal( SIGINT, sigTermHandler ); 114 114 signal( SIGTERM, sigTermHandler ); 115 116 #ifdef __DEBUG_H__ 117 cerr << "Stage1" << endl; 118 #endif // __DEBUG_H__ 115 119 116 120 // process all the arguments … … 153 157 CFA_flag = true; 154 158 } else if ( prefix( arg, D__CFA_FLAGPREFIX__ ) ) { 155 uargs[nuargs] = ( *new string( arg.substr( D__CFA_FLAGPREFIX__.size() ) ) ).c_str();156 n uargs += 1;159 cargs[ncargs] = ( *new string( arg.substr( D__CFA_FLAGPREFIX__.size() ) ) ).c_str(); 160 ncargs += 1; 157 161 } else if ( arg == "-D" && prefix( argv[i + 1], D__CFA_FLAGPREFIX__.substr(2) ) ) { 158 uargs[nuargs] = ( *new string( string( argv[i + 1] ).substr( D__CFA_FLAGPREFIX__.size() - 2 ) ) ).c_str();159 n uargs += 1;162 cargs[ncargs] = ( *new string( string( argv[i + 1] ).substr( D__CFA_FLAGPREFIX__.size() - 2 ) ) ).c_str(); 163 ncargs += 1; 160 164 i += 1; // and the argument 161 165 } else if ( prefix( arg, D__GCC_BPREFIX__ ) ) { … … 317 321 318 322 if ( fork() == 0 ) { // child runs CFA 319 uargs[0] = ( *new string( bprefix + "/cfa-cpp" ) ).c_str(); 320 321 uargs[nuargs] = tmpname; 322 nuargs += 1; 323 cargs[0] = ( *new string( bprefix + "/cfa-cpp" ) ).c_str(); 324 325 // Source file-name used to generate routine names containing global initializations for TU. 326 cargs[ncargs] = ( *new string( "-F" ) ).c_str(); 327 ncargs += 1; 328 cargs[ncargs] = ( *new string( string( cpp_in ) ) ).c_str(); 329 ncargs += 1; 330 331 cargs[ncargs] = tmpname; 332 ncargs += 1; 323 333 if ( o_name != NULL ) { 324 uargs[nuargs] = o_name;325 n uargs += 1;334 cargs[ncargs] = o_name; 335 ncargs += 1; 326 336 } else if ( ! CFA_flag ) { // run cfa-cpp ? 327 uargs[nuargs] = cpp_out;328 n uargs += 1;337 cargs[ncargs] = cpp_out; 338 ncargs += 1; 329 339 } // if 330 uargs[nuargs] = NULL; // terminate argument list331 332 #ifdef __DEBUG_H__ 333 cerr << "cfa-cpp n uargs: " << o_name << " " << CFA_flag << " " << nuargs << endl;334 for ( i = 0; uargs[i] != NULL; i += 1 ) {335 cerr << uargs[i] << " ";340 cargs[ncargs] = NULL; // terminate argument list 341 342 #ifdef __DEBUG_H__ 343 cerr << "cfa-cpp ncargs: " << o_name << " " << CFA_flag << " " << ncargs << endl; 344 for ( i = 0; cargs[i] != NULL; i += 1 ) { 345 cerr << cargs[i] << " "; 336 346 } // for 337 347 cerr << endl; 338 348 #endif // __DEBUG_H__ 339 349 340 execvp( uargs[0], (char * const *)uargs ); // should not return350 execvp( cargs[0], (char * const *)cargs ); // should not return 341 351 perror( "CFA Translator error: cpp level, execvp" ); 342 352 exit( EXIT_FAILURE ); … … 370 380 const char *args[argc + 100]; // leave space for 100 additional cfa command line values 371 381 int nargs = 1; // number of arguments in args list; 0 => command name 382 383 #ifdef __DEBUG_H__ 384 cerr << "Stage2" << endl; 385 #endif // __DEBUG_H__ 372 386 373 387 // process all the arguments … … 467 481 468 482 if ( arg == "-E" ) { 469 #ifdef __DEBUG_H__470 cerr << "Stage1" << endl;471 #endif // __DEBUG_H__472 483 Stage1( argc, argv ); 473 484 } else if ( arg == "-fpreprocessed" ) { 474 #ifdef __DEBUG_H__475 cerr << "Stage2" << endl;476 #endif // __DEBUG_H__477 485 Stage2( argc, argv ); 478 486 } else { -
src/examples/abstype.c
r99ee64d r9e2c1f0 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 27 18:10:01 201513 // Update Count : 412 // Last Modified On : Wed Apr 6 22:16:08 2016 13 // Update Count : 8 14 14 // 15 15 16 type T | { T x( T ); };16 otype T | { T x( T ); }; 17 17 18 18 T y( T t ) { … … 21 21 } 22 22 23 forall( type T) lvalue T*?( T* );24 int ?++( int * );25 int ?=?( int *, int );26 forall( dtype DT) DT* ?=?( DT **, DT* );23 forall( otype T ) lvalue T *?( T* ); 24 int ?++( int * ); 25 int ?=?( int *, int ); 26 forall( dtype DT ) DT * ?=?( DT **, DT* ); 27 27 28 type U = int*;28 otype U = int *; 29 29 30 30 U x( U u ) { -
src/examples/alloc.c
r99ee64d r9e2c1f0 11 11 // Created On : Wed Feb 3 07:56:22 2016 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Wed Feb 17 11:43:23201614 // Update Count : 4013 // Last Modified On : Fri Mar 11 17:42:08 2016 14 // Update Count : 59 15 15 // 16 16 17 forall( otype T ) T * malloc( char fill ); 18 forall( dtype T ) T *?=?( T **, void * ); 19 void *malloc( unsigned long int ); 20 #if 0 17 21 #include <fstream> 18 22 #include <stdlib> … … 25 29 int * bar( int * p, int c ) { return p; } 26 30 int * baz( int * p, int c ) { return p; } 31 #endif 27 32 28 33 int main( void ) { 34 #if 0 29 35 size_t size = 10; 30 36 int * p; 31 37 struct S { int x; double y; } * s; 38 #endif 32 39 40 #if 0 33 41 p = malloc( sizeof(*p) ); // C malloc, type unsafe 34 42 printf( "here1\n" ); … … 37 45 printf( "here2\n" ); 38 46 free( p ); 39 p = malloc( (char)'\0' ); // CFA malloc, type safe 47 #endif 48 // int * p; 49 // p = malloc( (char)'\0' ); // CFA malloc, type safe 50 (int *)malloc( (char)'\0' ); // CFA malloc, type safe 51 (void *)malloc( (char)'\0' ); // CFA malloc, type safe 52 #if 0 40 53 printf( "here3\n" ); 41 54 p = malloc( p, 1000 ); // CFA remalloc, type safe … … 60 73 printf( "here9\n" ); 61 74 free( p ); 62 #if 0 75 63 76 float * fp = malloc() + 1; 64 77 fprintf( stderr, "%p %p\n", fp, fp - 1 ); -
src/examples/includes.c
r99ee64d r9e2c1f0 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 23:28:02 201613 // Update Count : 3 2812 // Last Modified On : Wed Apr 13 22:30:02 2016 13 // Update Count : 370 14 14 // 15 15 … … 24 24 #if 1 25 25 #define _GNU_SOURCE 26 #include <aio.h>27 #include <a.out.h>28 #include <aliases.h>29 #include <alloca.h>30 #include <ansidecl.h>31 #include <ar.h>32 #include <argp.h>26 //#include <aio.h> 27 //#include <a.out.h> 28 //#include <aliases.h> 29 //#include <alloca.h> 30 //#include <ansidecl.h> 31 //#include <ar.h> 32 //#include <argp.h> 33 33 #include <argz.h> 34 #include <assert.h>34 //#include <assert.h> 35 35 #include <bfd.h> 36 #if 0 36 37 #include <bfdlink.h> 37 38 #include <byteswap.h> … … 56 57 #include <err.h> 57 58 #include <errno.h> 58 #if 059 59 #include <error.h> 60 #endif61 60 #include <eti.h> 62 61 #include <evdns.h> 63 62 #include <event.h> 64 63 #include <evhttp.h> 64 #endif 65 65 #if 0 66 66 #include <evrpc.h> … … 129 129 130 130 //#define _GNU_SOURCE 131 #include <error.h> 131 #include <bfd.h> 132 //#include <error.h> 132 133 133 134 #endif // 0 -
src/main.cc
r99ee64d r9e2c1f0 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Apr 29 12:02:21201613 // Update Count : 20 012 // Last Modified On : Fri May 06 15:59:09 2016 13 // Update Count : 203 14 14 // 15 15 … … 42 42 #include "InitTweak/GenInit.h" 43 43 #include "InitTweak/FixInit.h" 44 #include "InitTweak/FixGlobalInit.h" 44 45 //#include "Explain/GenProlog.h" 45 46 //#include "Try/Visit.h" … … 102 103 std::ostream *output = &std::cout; 103 104 int long_index; 104 std::list< Declaration* > translationUnit; 105 std::list< Declaration * > translationUnit; 106 const char *filename = NULL; 105 107 106 108 opterr = 0; // prevent getopt from printing error messages 107 109 108 110 int c; 109 while ( (c = getopt_long( argc, argv, "abBcef FglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {111 while ( (c = getopt_long( argc, argv, "abBcefglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) { 110 112 switch ( c ) { 111 113 case Ast: … … 174 176 break; 175 177 case 'D': // ignore -Dxxx 178 break; 179 case 'F': // source file-name without suffix 180 filename = optarg; 176 181 break; 177 182 case '?': … … 188 193 input = fopen( argv[ optind ], "r" ); 189 194 if ( ! input ) { 190 std::cout << "Error: can't open " << argv[ optind] << std::endl;195 std::cout << "Error: can't open " << argv[ optind ] << std::endl; 191 196 exit( 1 ); 192 197 } // if 198 // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to) 199 if ( filename == NULL ) filename = argv[ optind ]; 200 // prelude filename comes in differently 201 if ( libcfap ) filename = "prelude.cf"; 193 202 optind += 1; 194 203 } else { … … 263 272 OPTPRINT( "fixNames" ) 264 273 CodeGen::fixNames( translationUnit ); 274 OPTPRINT( "fixGlobalInit" ); 275 InitTweak::fixGlobalInit( translationUnit, filename, libcfap || treep ); 265 276 OPTPRINT( "tweakInit" ) 266 277 InitTweak::genInit( translationUnit );
Note:
See TracChangeset
for help on using the changeset viewer.