Changeset 486341f for src/CodeGen
- Timestamp:
- Aug 24, 2016, 1:55:39 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 3906301, 4e2b9710, 60aa49a7, a2a8d2a6
- Parents:
- 0555f4b
- Location:
- src/CodeGen
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r0555f4b r486341f 83 83 } 84 84 85 CodeGenerator::CodeGenerator( std::ostream & os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this) {}85 CodeGenerator::CodeGenerator( std::ostream & os, bool mangle ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ), mangle( mangle ) {} 86 86 87 87 CodeGenerator::CodeGenerator( std::ostream & os, std::string init, int indentation, bool infunp ) … … 95 95 } 96 96 97 string mangleName( DeclarationWithType * decl ) { 97 string CodeGenerator::mangleName( DeclarationWithType * decl ) { 98 if ( ! mangle ) return decl->get_name(); 98 99 if ( decl->get_mangleName() != "" ) { 99 100 // need to incorporate scope level in order to differentiate names for destructors -
src/CodeGen/CodeGenerator.h
r0555f4b r486341f 30 30 static int tabsize; 31 31 32 CodeGenerator( std::ostream &os );32 CodeGenerator( std::ostream &os, bool mangle = true ); 33 33 CodeGenerator( std::ostream &os, std::string, int indent = 0, bool infun = false ); 34 34 CodeGenerator( std::ostream &os, char *, int indent = 0, bool infun = false ); … … 114 114 std::ostream &output; 115 115 LabelPrinter printLabels; 116 bool mangle = true; 116 117 117 118 void printDesignators( std::list< Expression * > & ); … … 119 120 void handleAggregate( AggregateDecl *aggDecl ); 120 121 void handleTypedef( NamedTypeDecl *namedType ); 122 std::string mangleName( DeclarationWithType * decl ); 121 123 }; // CodeGenerator 122 124 -
src/CodeGen/GenType.cc
r0555f4b r486341f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // GenType.cc -- 7 // GenType.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 28 28 class GenType : public Visitor { 29 29 public: 30 GenType( const std::string &typeString );30 GenType( const std::string &typeString, bool mangle = true ); 31 31 std::string get_typeString() const { return typeString; } 32 32 void set_typeString( const std::string &newValue ) { typeString = newValue; } 33 33 34 34 virtual void visit( FunctionType *funcType ); 35 35 virtual void visit( VoidType *voidType ); … … 42 42 virtual void visit( TypeInstType *typeInst ); 43 43 virtual void visit( VarArgsType *varArgsType ); 44 44 45 45 private: 46 46 void handleQualifiers( Type *type ); 47 47 void genArray( const Type::Qualifiers &qualifiers, Type *base, Expression *dimension, bool isVarLen, bool isStatic ); 48 48 49 49 std::string typeString; 50 bool mangle = true; 50 51 }; 51 52 52 std::string genType( Type *type, const std::string &baseString ) {53 GenType gt( baseString );53 std::string genType( Type *type, const std::string &baseString, bool mangle ) { 54 GenType gt( baseString, mangle ); 54 55 type->accept( gt ); 55 56 return gt.get_typeString(); 56 57 } 57 58 58 GenType::GenType( const std::string &typeString ) : typeString( typeString) {}59 GenType::GenType( const std::string &typeString, bool mangle ) : typeString( typeString ), mangle( mangle ) {} 59 60 60 61 void GenType::visit( VoidType *voidType ) { … … 100 101 } // if 101 102 if ( dimension != 0 ) { 102 CodeGenerator cg( os );103 CodeGenerator cg( os, mangle ); 103 104 dimension->accept( cg ); 104 105 } else if ( isVarLen ) { … … 109 110 110 111 typeString = os.str(); 111 112 112 113 base->accept( *this ); 113 114 } … … 142 143 } // if 143 144 } // if 144 145 145 146 /************* parameters ***************/ 146 147 … … 154 155 } // if 155 156 } else { 156 CodeGenerator cg( os );157 CodeGenerator cg( os, mangle ); 157 158 os << "(" ; 158 159 … … 164 165 os << ")"; 165 166 } // if 166 167 167 168 typeString = os.str(); 168 169 -
src/CodeGen/GenType.h
r0555f4b r486341f 21 21 22 22 namespace CodeGen { 23 std::string genType( Type *type, const std::string &baseString );23 std::string genType( Type *type, const std::string &baseString, bool mangle = true ); 24 24 } // namespace CodeGen 25 25
Note: See TracChangeset
for help on using the changeset viewer.