Changeset 3cd5fdd
- Timestamp:
- Jun 5, 2019, 6:07:41 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- c6a1e8a, d3b2c32a, dd857bb
- Parents:
- 99d4584 (diff), 8568319 (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. - git-author:
- Aaron Moss <a3moss@…> (06/05/19 18:02:23)
- git-committer:
- Aaron Moss <a3moss@…> (06/05/19 18:07:41)
- Location:
- src
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r99d4584 r3cd5fdd 749 749 break; 750 750 case ast::ConstantExpr::String: 751 rslt = new ConstantExpr{Constant::from_string( node->rep )}; 751 rslt = new ConstantExpr{Constant{ 752 get<Type>().accept1( node->result ), 753 node->rep, 754 (long long unsigned int)0 755 }}; 752 756 break; 753 757 } … … 2150 2154 GET_ACCEPT_1(result, Type), 2151 2155 old->constant.get_value(), 2152 (unsigned long long) old->intValue() 2156 (unsigned long long) old->intValue(), 2157 ast::ConstantExpr::Kind::Integer 2153 2158 ); 2154 2159 } else if (isFloatlikeConstantType(old->result)) { … … 2160 2165 ); 2161 2166 } else if (isStringlikeConstantType(old->result)) { 2162 rslt = ast::ConstantExpr::from_string( 2163 old->location, 2164 old->constant.get_value() 2167 rslt = new ast::ConstantExpr( 2168 old->location, 2169 GET_ACCEPT_1(result, Type), 2170 old->constant.get_value(), 2171 0, 2172 ast::ConstantExpr::Kind::String 2165 2173 ); 2166 2174 } -
src/AST/Node.cpp
r99d4584 r3cd5fdd 34 34 template< typename node_t, enum ast::Node::ref_type ref_t > 35 35 void ast::ptr_base<node_t, ref_t>::_dec( const node_t * node ) { node->decrement(ref_t); } 36 37 template< typename node_t, enum ast::Node::ref_type ref_t > 38 void ast::ptr_base<node_t, ref_t>::_check() const { if(node) assert(node->was_ever_strong == false || node->strong_count > 0); } 36 39 37 40 template< typename node_t, enum ast::Node::ref_type ref_t > -
src/AST/Node.hpp
r99d4584 r3cd5fdd 46 46 }; 47 47 48 bool unique() const { return strong_count == 1; } 49 48 50 private: 49 51 /// Make a copy of this node; should be overridden in subclass with more precise return type … … 56 58 mutable size_t strong_count = 0; 57 59 mutable size_t weak_count = 0; 60 mutable bool was_ever_strong = false; 58 61 59 62 void increment(ref_type ref) const { 60 63 switch (ref) { 61 case ref_type::strong: strong_count++; break;64 case ref_type::strong: strong_count++; was_ever_strong = true; break; 62 65 case ref_type::weak : weak_count ++; break; 63 66 } … … 176 179 } 177 180 178 const node_t * get() const { return node; }179 const node_t * operator->() const { return node; }180 const node_t & operator* () const { return *node; }181 explicit operator bool() const { return node; }182 operator const node_t * () const { return node; }181 const node_t * get() const { _check(); return node; } 182 const node_t * operator->() const { _check(); return node; } 183 const node_t & operator* () const { _check(); return *node; } 184 explicit operator bool() const { _check(); return node; } 185 operator const node_t * () const { _check(); return node; } 183 186 184 187 /// wrapper for convenient access to dynamic_cast 185 188 template<typename o_node_t> 186 const o_node_t * as() const { return dynamic_cast<const o_node_t *>(node); }189 const o_node_t * as() const { _check(); return dynamic_cast<const o_node_t *>(node); } 187 190 188 191 /// wrapper for convenient access to strict_dynamic_cast … … 208 211 void _inc( const node_t * other ); 209 212 void _dec( const node_t * other ); 213 void _check() const; 210 214 211 215 protected: -
src/ResolvExpr/Resolver.cc
r99d4584 r3cd5fdd 29 29 #include "typeops.h" // for extractResultType 30 30 #include "Unify.h" // for unify 31 #include "AST/Chain.hpp" 31 32 #include "AST/Decl.hpp" 32 33 #include "AST/Init.hpp" … … 410 411 411 412 void Resolver_old::previsit( ObjectDecl * objectDecl ) { 412 // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that 413 // class-variable initContext is changed multiple time because the LHS is analysed twice. 414 // The second analysis changes initContext because of a function type can contain object 415 // declarations in the return and parameter types. So each value of initContext is 413 // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that 414 // class-variable initContext is changed multiple time because the LHS is analysed twice. 415 // The second analysis changes initContext because of a function type can contain object 416 // declarations in the return and parameter types. So each value of initContext is 416 417 // retained, so the type on the first analysis is preserved and used for selecting the RHS. 417 418 GuardValue( currentObject ); … … 450 451 451 452 void Resolver_old::postvisit( FunctionDecl * functionDecl ) { 452 // default value expressions have an environment which shouldn't be there and trips up 453 // default value expressions have an environment which shouldn't be there and trips up 453 454 // later passes. 454 455 // xxx - it might be necessary to somehow keep the information from this environment, but I … … 1118 1119 } 1119 1120 1120 class Resolver_new final 1121 : public ast::WithSymbolTable, public ast::WithGuards, 1122 public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting, 1121 class Resolver_new final 1122 : public ast::WithSymbolTable, public ast::WithGuards, 1123 public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting, 1123 1124 public ast::WithStmtsToAdd<> { 1124 1125 1125 1126 ast::ptr< ast::Type > functionReturn = nullptr; 1126 1127 // ast::CurrentObject currentObject = nullptr; 1127 1128 bool inEnumDecl = false; 1128 1129 1129 public: 1130 public: 1130 1131 Resolver_new() = default; 1131 1132 Resolver_new( const ast::SymbolTable & syms ) { symtab = syms; } … … 1170 1171 1171 1172 const ast::FunctionDecl * Resolver_new::postvisit( const ast::FunctionDecl * functionDecl ) { 1172 // default value expressions have an environment which shouldn't be there and trips up 1173 // default value expressions have an environment which shouldn't be there and trips up 1173 1174 // later passes. 1174 1175 ast::ptr< ast::FunctionDecl > ret = functionDecl; 1175 1176 for ( unsigned i = 0; i < functionDecl->type->params.size(); ++i ) { 1176 1177 const ast::ptr<ast::DeclWithType> & d = functionDecl->type->params[i]; 1177 1178 1178 1179 if ( const ast::ObjectDecl * obj = d.as< ast::ObjectDecl >() ) { 1179 1180 if ( const ast::SingleInit * init = obj->init.as< ast::SingleInit >() ) { 1180 1181 if ( init->value->env == nullptr ) continue; 1181 1182 // clone initializer minus the initializer environment 1182 strict_dynamic_cast< ast::SingleInit * >( 1183 strict_dynamic_cast< ast::ObjectDecl * >( 1184 ret.get_and_mutate()->type.get_and_mutate()->params[i].get_and_mutate() 1185 )->init.get_and_mutate() 1186 )->value.get_and_mutate()->env = nullptr; 1183 ast::chain_mutate( ret ) 1184 ( &ast::FunctionDecl::type ) 1185 ( &ast::FunctionType::params )[i] 1186 ( &ast::ObjectDecl::init ) 1187 ( &ast::SingleInit::value )->env = nullptr; 1188 1189 assert( functionDecl != ret.get() || functionDecl->unique() ); 1190 assert( ! ret->type->params[i].strict_as< ast::ObjectDecl >()->init.strict_as< ast::SingleInit >()->value->env ); 1187 1191 } 1188 1192 } -
src/SynTree/BaseSyntaxNode.h
r99d4584 r3cd5fdd 41 41 /// * Expressions should not finish with a newline, since the expression's parent has better information. 42 42 virtual void print( std::ostream & os, Indenter indent = {} ) const = 0; 43 // void print( std::ostream & os, unsigned int indent ) {44 // print( os, Indenter{ indent });45 // }46 43 }; 47 44 -
src/SynTree/DeclReplacer.cc
r99d4584 r3cd5fdd 30 30 bool debug; 31 31 public: 32 size_t replaced; 33 34 public: 32 35 DeclReplacer( const DeclMap & declMap, const TypeMap & typeMap, bool debug = false ); 33 36 … … 45 48 bool debug; 46 49 public: 50 size_t replaced; 51 52 public: 47 53 ExprDeclReplacer( const ExprMap & exprMap, bool debug = false ); 48 54 … … 52 58 } 53 59 54 voidreplace( BaseSyntaxNode * node, const DeclMap & declMap, const TypeMap & typeMap, bool debug ) {60 size_t replace( BaseSyntaxNode * node, const DeclMap & declMap, const TypeMap & typeMap, bool debug ) { 55 61 PassVisitor<DeclReplacer> replacer( declMap, typeMap, debug ); 56 62 maybeAccept( node, replacer ); 63 return replacer.pass.replaced; 57 64 } 58 65 59 voidreplace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug ) {66 size_t replace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug ) { 60 67 TypeMap typeMap; 61 re place( node, declMap, typeMap, debug );68 return replace( node, declMap, typeMap, debug ); 62 69 } 63 70 64 voidreplace( BaseSyntaxNode * node, const TypeMap & typeMap, bool debug ) {71 size_t replace( BaseSyntaxNode * node, const TypeMap & typeMap, bool debug ) { 65 72 DeclMap declMap; 66 re place( node, declMap, typeMap, debug );73 return replace( node, declMap, typeMap, debug ); 67 74 } 68 75 69 voidreplace( BaseSyntaxNode *& node, const ExprMap & exprMap, bool debug ) {76 size_t replace( BaseSyntaxNode *& node, const ExprMap & exprMap, bool debug ) { 70 77 PassVisitor<ExprDeclReplacer> replacer( exprMap, debug ); 71 78 node = maybeMutate( node, replacer ); 79 return replacer.pass.replaced; 72 80 } 73 81 74 82 namespace { 75 DeclReplacer::DeclReplacer( const DeclMap & declMap, const TypeMap & typeMap, bool debug ) : declMap( declMap ), typeMap( typeMap ) , debug( debug ) {}83 DeclReplacer::DeclReplacer( const DeclMap & declMap, const TypeMap & typeMap, bool debug ) : declMap( declMap ), typeMap( typeMap ) , debug( debug ), replaced( 0 ) {} 76 84 77 85 // replace variable with new node from decl map … … 79 87 // xxx - assertions and parameters aren't accounted for in this... (i.e. they aren't inserted into the map when it's made, only DeclStmts are) 80 88 if ( declMap.count( varExpr->var ) ) { 89 replaced++; 81 90 auto replacement = declMap.at( varExpr->var ); 82 91 if ( debug ) { … … 89 98 void DeclReplacer::previsit( TypeInstType * inst ) { 90 99 if ( typeMap.count( inst->baseType ) ) { 100 replaced++; 91 101 auto replacement = typeMap.at( inst->baseType ); 92 102 if ( debug ) { … … 97 107 } 98 108 99 ExprDeclReplacer::ExprDeclReplacer( const ExprMap & exprMap, bool debug ) : exprMap( exprMap ), debug( debug ) {}109 ExprDeclReplacer::ExprDeclReplacer( const ExprMap & exprMap, bool debug ) : exprMap( exprMap ), debug( debug ), replaced( 0 ) {} 100 110 101 111 Expression * ExprDeclReplacer::postmutate( VariableExpr * varExpr ) { 102 112 if ( exprMap.count( varExpr->var ) ) { 113 replaced++; 103 114 Expression * replacement = exprMap.at( varExpr->var )->clone(); 104 115 if ( debug ) { -
src/SynTree/DeclReplacer.h
r99d4584 r3cd5fdd 28 28 typedef std::map< DeclarationWithType *, Expression * > ExprMap; 29 29 30 voidreplace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug = false );31 voidreplace( BaseSyntaxNode * node, const TypeMap & typeMap, bool debug = false );32 voidreplace( BaseSyntaxNode * node, const DeclMap & declMap, const TypeMap & typeMap, bool debug = false );30 size_t replace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug = false ); 31 size_t replace( BaseSyntaxNode * node, const TypeMap & typeMap, bool debug = false ); 32 size_t replace( BaseSyntaxNode * node, const DeclMap & declMap, const TypeMap & typeMap, bool debug = false ); 33 33 34 voidreplace( BaseSyntaxNode *& node, const ExprMap & exprMap, bool debug = false);34 size_t replace( BaseSyntaxNode *& node, const ExprMap & exprMap, bool debug = false); 35 35 template<typename T> 36 36 void replace( T *& node, const ExprMap & exprMap, bool debug = false ) { -
src/main.cc
r99d4584 r3cd5fdd 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri May 3 16:10:52201913 // Update Count : 59912 // Last Modified On : Wed Jun 5 13:48:41 2019 13 // Update Count : 600 14 14 // 15 15 … … 406 406 407 407 408 static const char optstring[] = ":hlLmNn :pP:S:twW:D:F:";408 static const char optstring[] = ":hlLmNnpP:S:twW:D:F:"; 409 409 410 410 enum { PreludeDir = 128 };
Note: See TracChangeset
for help on using the changeset viewer.