Changes in / [3cd5fdd:99d4584]
- Location:
- src
- Files:
-
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r3cd5fdd r99d4584 749 749 break; 750 750 case ast::ConstantExpr::String: 751 rslt = new ConstantExpr{Constant{ 752 get<Type>().accept1( node->result ), 753 node->rep, 754 (long long unsigned int)0 755 }}; 751 rslt = new ConstantExpr{Constant::from_string( node->rep )}; 756 752 break; 757 753 } … … 2154 2150 GET_ACCEPT_1(result, Type), 2155 2151 old->constant.get_value(), 2156 (unsigned long long) old->intValue(), 2157 ast::ConstantExpr::Kind::Integer 2152 (unsigned long long) old->intValue() 2158 2153 ); 2159 2154 } else if (isFloatlikeConstantType(old->result)) { … … 2165 2160 ); 2166 2161 } else if (isStringlikeConstantType(old->result)) { 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 2162 rslt = ast::ConstantExpr::from_string( 2163 old->location, 2164 old->constant.get_value() 2173 2165 ); 2174 2166 } -
src/AST/Node.cpp
r3cd5fdd r99d4584 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); }39 36 40 37 template< typename node_t, enum ast::Node::ref_type ref_t > -
src/AST/Node.hpp
r3cd5fdd r99d4584 46 46 }; 47 47 48 bool unique() const { return strong_count == 1; }49 50 48 private: 51 49 /// Make a copy of this node; should be overridden in subclass with more precise return type … … 58 56 mutable size_t strong_count = 0; 59 57 mutable size_t weak_count = 0; 60 mutable bool was_ever_strong = false;61 58 62 59 void increment(ref_type ref) const { 63 60 switch (ref) { 64 case ref_type::strong: strong_count++; was_ever_strong = true;break;61 case ref_type::strong: strong_count++; break; 65 62 case ref_type::weak : weak_count ++; break; 66 63 } … … 179 176 } 180 177 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; }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; } 186 183 187 184 /// wrapper for convenient access to dynamic_cast 188 185 template<typename o_node_t> 189 const o_node_t * as() const { _check();return dynamic_cast<const o_node_t *>(node); }186 const o_node_t * as() const { return dynamic_cast<const o_node_t *>(node); } 190 187 191 188 /// wrapper for convenient access to strict_dynamic_cast … … 211 208 void _inc( const node_t * other ); 212 209 void _dec( const node_t * other ); 213 void _check() const;214 210 215 211 protected: -
src/ResolvExpr/Resolver.cc
r3cd5fdd r99d4584 29 29 #include "typeops.h" // for extractResultType 30 30 #include "Unify.h" // for unify 31 #include "AST/Chain.hpp"32 31 #include "AST/Decl.hpp" 33 32 #include "AST/Init.hpp" … … 411 410 412 411 void Resolver_old::previsit( ObjectDecl * objectDecl ) { 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 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 417 416 // retained, so the type on the first analysis is preserved and used for selecting the RHS. 418 417 GuardValue( currentObject ); … … 451 450 452 451 void Resolver_old::postvisit( FunctionDecl * functionDecl ) { 453 // default value expressions have an environment which shouldn't be there and trips up 452 // default value expressions have an environment which shouldn't be there and trips up 454 453 // later passes. 455 454 // xxx - it might be necessary to somehow keep the information from this environment, but I … … 1119 1118 } 1120 1119 1121 class Resolver_new final 1122 : public ast::WithSymbolTable, public ast::WithGuards, 1123 public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting, 1120 class Resolver_new final 1121 : public ast::WithSymbolTable, public ast::WithGuards, 1122 public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting, 1124 1123 public ast::WithStmtsToAdd<> { 1125 1124 1126 1125 ast::ptr< ast::Type > functionReturn = nullptr; 1127 1126 // ast::CurrentObject currentObject = nullptr; 1128 1127 bool inEnumDecl = false; 1129 1128 1130 public: 1129 public: 1131 1130 Resolver_new() = default; 1132 1131 Resolver_new( const ast::SymbolTable & syms ) { symtab = syms; } … … 1171 1170 1172 1171 const ast::FunctionDecl * Resolver_new::postvisit( const ast::FunctionDecl * functionDecl ) { 1173 // default value expressions have an environment which shouldn't be there and trips up 1172 // default value expressions have an environment which shouldn't be there and trips up 1174 1173 // later passes. 1175 1174 ast::ptr< ast::FunctionDecl > ret = functionDecl; 1176 1175 for ( unsigned i = 0; i < functionDecl->type->params.size(); ++i ) { 1177 1176 const ast::ptr<ast::DeclWithType> & d = functionDecl->type->params[i]; 1178 1177 1179 1178 if ( const ast::ObjectDecl * obj = d.as< ast::ObjectDecl >() ) { 1180 1179 if ( const ast::SingleInit * init = obj->init.as< ast::SingleInit >() ) { 1181 1180 if ( init->value->env == nullptr ) continue; 1182 1181 // clone initializer minus the initializer environment 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 ); 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; 1191 1187 } 1192 1188 } -
src/SynTree/BaseSyntaxNode.h
r3cd5fdd r99d4584 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 // } 43 46 }; 44 47 -
src/SynTree/DeclReplacer.cc
r3cd5fdd r99d4584 30 30 bool debug; 31 31 public: 32 size_t replaced;33 34 public:35 32 DeclReplacer( const DeclMap & declMap, const TypeMap & typeMap, bool debug = false ); 36 33 … … 48 45 bool debug; 49 46 public: 50 size_t replaced;51 52 public:53 47 ExprDeclReplacer( const ExprMap & exprMap, bool debug = false ); 54 48 … … 58 52 } 59 53 60 size_treplace( BaseSyntaxNode * node, const DeclMap & declMap, const TypeMap & typeMap, bool debug ) {54 void replace( BaseSyntaxNode * node, const DeclMap & declMap, const TypeMap & typeMap, bool debug ) { 61 55 PassVisitor<DeclReplacer> replacer( declMap, typeMap, debug ); 62 56 maybeAccept( node, replacer ); 63 return replacer.pass.replaced;64 57 } 65 58 66 size_treplace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug ) {59 void replace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug ) { 67 60 TypeMap typeMap; 68 re turn replace( node, declMap, typeMap, debug );61 replace( node, declMap, typeMap, debug ); 69 62 } 70 63 71 size_treplace( BaseSyntaxNode * node, const TypeMap & typeMap, bool debug ) {64 void replace( BaseSyntaxNode * node, const TypeMap & typeMap, bool debug ) { 72 65 DeclMap declMap; 73 re turn replace( node, declMap, typeMap, debug );66 replace( node, declMap, typeMap, debug ); 74 67 } 75 68 76 size_treplace( BaseSyntaxNode *& node, const ExprMap & exprMap, bool debug ) {69 void replace( BaseSyntaxNode *& node, const ExprMap & exprMap, bool debug ) { 77 70 PassVisitor<ExprDeclReplacer> replacer( exprMap, debug ); 78 71 node = maybeMutate( node, replacer ); 79 return replacer.pass.replaced;80 72 } 81 73 82 74 namespace { 83 DeclReplacer::DeclReplacer( const DeclMap & declMap, const TypeMap & typeMap, bool debug ) : declMap( declMap ), typeMap( typeMap ) , debug( debug ) , replaced( 0 ){}75 DeclReplacer::DeclReplacer( const DeclMap & declMap, const TypeMap & typeMap, bool debug ) : declMap( declMap ), typeMap( typeMap ) , debug( debug ) {} 84 76 85 77 // replace variable with new node from decl map … … 87 79 // 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) 88 80 if ( declMap.count( varExpr->var ) ) { 89 replaced++;90 81 auto replacement = declMap.at( varExpr->var ); 91 82 if ( debug ) { … … 98 89 void DeclReplacer::previsit( TypeInstType * inst ) { 99 90 if ( typeMap.count( inst->baseType ) ) { 100 replaced++;101 91 auto replacement = typeMap.at( inst->baseType ); 102 92 if ( debug ) { … … 107 97 } 108 98 109 ExprDeclReplacer::ExprDeclReplacer( const ExprMap & exprMap, bool debug ) : exprMap( exprMap ), debug( debug ) , replaced( 0 ){}99 ExprDeclReplacer::ExprDeclReplacer( const ExprMap & exprMap, bool debug ) : exprMap( exprMap ), debug( debug ) {} 110 100 111 101 Expression * ExprDeclReplacer::postmutate( VariableExpr * varExpr ) { 112 102 if ( exprMap.count( varExpr->var ) ) { 113 replaced++;114 103 Expression * replacement = exprMap.at( varExpr->var )->clone(); 115 104 if ( debug ) { -
src/SynTree/DeclReplacer.h
r3cd5fdd r99d4584 28 28 typedef std::map< DeclarationWithType *, Expression * > ExprMap; 29 29 30 size_treplace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug = false );31 size_treplace( BaseSyntaxNode * node, const TypeMap & typeMap, bool debug = false );32 size_treplace( BaseSyntaxNode * node, const DeclMap & declMap, const TypeMap & typeMap, bool debug = false );30 void replace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug = false ); 31 void replace( BaseSyntaxNode * node, const TypeMap & typeMap, bool debug = false ); 32 void replace( BaseSyntaxNode * node, const DeclMap & declMap, const TypeMap & typeMap, bool debug = false ); 33 33 34 size_treplace( BaseSyntaxNode *& node, const ExprMap & exprMap, bool debug = false);34 void 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
r3cd5fdd r99d4584 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 5 13:48:41201913 // Update Count : 60012 // Last Modified On : Fri May 3 16:10:52 2019 13 // Update Count : 599 14 14 // 15 15 … … 406 406 407 407 408 static const char optstring[] = ":hlLmNn pP:S:twW:D:F:";408 static const char optstring[] = ":hlLmNn:pP:S:twW:D:F:"; 409 409 410 410 enum { PreludeDir = 128 };
Note:
See TracChangeset
for help on using the changeset viewer.