1515#include < FPG/MSG.h>
1616
1717Abstract_interpretation_visitor::Abstract_interpretation_visitor ( Abstract_value* initial_value )
18- : expression_value( NULL ), initial_value( initial_value )
18+ : expression_value( nullptr ), initial_value( initial_value )
1919{}
2020
2121void
5252Abstract_interpretation_visitor::visit ( AST::UnaryExpression* uexp ) {
5353 MSG ( " " )
5454 analyze ( uexp->e );
55- // expression_value = NULL ;
55+ // expression_value = nullptr ;
5656}
5757
5858void
@@ -65,8 +65,8 @@ Abstract_interpretation_visitor::visit( AST::BinaryExpression* bexp) {
6565 expression_value = new_abstract_value ();
6666 return ;
6767 }
68- assert ( value1 != NULL );
69- assert ( value2 != NULL );
68+ assert ( value1 != nullptr );
69+ assert ( value2 != nullptr );
7070 switch ( bexp->kind ) {
7171 case AST::BinaryExpression::ADD:
7272 expression_value = value1->add ( value2, bexp );
119119Abstract_interpretation_visitor::visit ( AST::AssignmentExpression* aexp ) {
120120 // expression_value is passed upwards unchanged
121121 AST::IdentifierExpression *id_expr = dynamic_cast < AST::IdentifierExpression* >( aexp->e1 );
122- if ( id_expr != NULL ) {
122+ if ( id_expr != nullptr ) {
123123 Variable *var = id_expr->var ;
124124 Abstract_value *val = analyze ( aexp->e2 );
125125 if ( is_float (var->type ) ) {
@@ -160,7 +160,7 @@ Abstract_interpretation_visitor::visit( AST::FunctionCall* funcall ) {
160160 // for non-external functions:
161161 if ( !funcall->fun_type ->is_extern ) {
162162 AST::FunctionDefinition *fun_def = funcall->called_function ;
163- assert ( fun_def != NULL );
163+ assert ( fun_def != nullptr );
164164 // now it's safe to create the new environment:
165165 value_env_stack.push ( Value_environment () );
166166 std::vector< Abstract_value * >::iterator abs_arg_iter = abstract_arguments.begin ();
@@ -176,7 +176,7 @@ Abstract_interpretation_visitor::visit( AST::FunctionCall* funcall ) {
176176 ++abs_arg_iter;
177177 }
178178 }
179- return_values.push ( NULL );
179+ return_values.push ( nullptr );
180180 analyze ( fun_def->body );
181181#if 0
182182 // NOTE: this is an ugly hack! in particular, if there was an assignment to one of the
@@ -201,7 +201,7 @@ Abstract_interpretation_visitor::visit( AST::FunctionCall* funcall ) {
201201 expression_value = return_values.top ();
202202 return_values.pop ();
203203 if ( funcall->fun_type ->getReturnType () != type_void ) {
204- assert ( expression_value != NULL );
204+ assert ( expression_value != nullptr );
205205 MSG ( " return value=" << expression_value )
206206 }
207207 } else
@@ -227,13 +227,13 @@ Abstract_interpretation_visitor::visit( AST::UnaryFunction* uf ) {
227227void
228228Abstract_interpretation_visitor::visit ( AST::EmptyStatement* ) {
229229 // an emptystatement does not depend on anything
230- assert ( expression_value == NULL );
230+ assert ( expression_value == nullptr );
231231}
232232
233233void
234234Abstract_interpretation_visitor::visit ( AST::ExpressionStatement* expr_stmt ) {
235235 analyze ( expr_stmt->e );
236- expression_value = NULL ;
236+ expression_value = nullptr ;
237237}
238238
239239void
@@ -275,7 +275,7 @@ Abstract_interpretation_visitor::visit( AST::Return* ret) {
275275 if ( ret->e ) {
276276 analyze (ret->e );
277277 assert ( return_values.size () > 0 );
278- if ( return_values.top () == NULL ) {
278+ if ( return_values.top () == nullptr ) {
279279 MSG ( " setting retval=" << expression_value )
280280 return_values.top () = expression_value;
281281 } else if ( is_float ( ret->e ->getType () ) && return_values.top () != expression_value ) {
@@ -284,7 +284,7 @@ Abstract_interpretation_visitor::visit( AST::Return* ret) {
284284 MSG ( " result: " << return_values.top () )
285285 }
286286 }
287- expression_value = NULL ;
287+ expression_value = nullptr ;
288288}
289289
290290void
@@ -293,7 +293,7 @@ Abstract_interpretation_visitor::visit( AST::StatementList* slist ) {
293293 AST::Statement *stmt = *it;
294294 analyze (stmt);
295295 // statements have no expression value
296- assert ( expression_value == NULL );
296+ assert ( expression_value == nullptr );
297297 }
298298}
299299
306306Abstract_interpretation_visitor::visit ( AST::FunctionDefinition* fundef ) {
307307 MSG ( fundef->type ->id )
308308 value_env_stack.push ( Value_environment () );
309- return_values.push ( NULL );
309+ return_values.push ( nullptr );
310310 FunctionType::ParameterList::iterator it;
311311 for ( it = fundef->type ->parameters .begin (); it != fundef->type ->parameters .end (); ++it ) {
312312 Variable *var = *it;
@@ -327,7 +327,7 @@ Abstract_interpretation_visitor::visit( AST::FunctionDefinition* fundef ) {
327327 // toplevel return values are ignored, they are most probably of integer type anyway.
328328 return_values.pop ();
329329 assert ( return_values.size () == 0 );
330- assert ( expression_value == NULL );
330+ assert ( expression_value == nullptr );
331331}
332332
333333void
@@ -349,7 +349,7 @@ Abstract_interpretation_visitor::get_analysis_result( AST::Expression *e ) {
349349 }*/
350350 assert ( analysis_result.find (e) != analysis_result.end () );
351351 Abstract_value *val = analysis_result[ e ];
352- assert ( val != NULL );
352+ assert ( val != nullptr );
353353 return val;
354354 } else if ( is_int (e->getType ()) )
355355 return new_abstract_value ();
@@ -360,8 +360,8 @@ Abstract_interpretation_visitor::get_analysis_result( AST::Expression *e ) {
360360
361361void
362362Abstract_interpretation_visitor::update ( AST::Expression *old_e, AST::Expression *new_e ) {
363- assert ( old_e != NULL );
364- assert ( new_e != NULL );
363+ assert ( old_e != nullptr );
364+ assert ( new_e != nullptr );
365365 if ( is_float (old_e->getType ()) ) {
366366 assert ( is_float (new_e->getType ()) );
367367 // old_e->dump(0);
@@ -419,18 +419,18 @@ Abstract_interpretation_visitor::is_defined_in_env( Variable* var ) {
419419
420420Abstract_value*
421421Abstract_interpretation_visitor::analyze ( AST::Node* n ) {
422- expression_value = NULL ;
422+ expression_value = nullptr ;
423423 // std::cout << "xxxxxx analyze " << (unsigned int)n << std::endl;
424424 if ( !is_bound ( n->getType () ) ) {
425425 // std::cout << "xxxxxx accept " << (unsigned int)n << std::endl;
426426 n->accept ( this );
427- if ( is_float (n->getType ()) && expression_value != NULL ) {
427+ if ( is_float (n->getType ()) && expression_value != nullptr ) {
428428 AST::Expression *e = dynamic_cast <AST::Expression*>(n);
429429 assert ( e );
430430 // std::cout << "xxxxxx create " << (unsigned int)e << std::endl;
431431 analysis_result[ e ] = expression_value;
432432 }
433433 }
434- return expression_value != NULL ? expression_value
434+ return expression_value != nullptr ? expression_value
435435 : new_abstract_value ();
436436}
0 commit comments