| 540 | } |
| 541 | } |
| 542 | virtual void preVisitGlobalLet ( const VariablePtr & var ) override { |
| 543 | Visitor::preVisitGlobalLet(var); |
| 544 | if ( checkNoGlobalVariables && !var->generated ) { |
| 545 | if ( checkNoGlobalVariablesAtAll ) { |
| 546 | program->error("variable '" + var->name + "' is disabled via option no_global_variables_at_all", "", "", |
| 547 | var->at, CompilationError::cant_global ); |
| 548 | } else if ( !var->type->isConst() ) { |
| 549 | program->error("variable '" + var->name + "' is not a constant, which is disabled via option no_global_variables", "", "", |
| 550 | var->at, CompilationError::cant_global ); |
| 551 | } |
| 552 | } |
| 553 | if ( checkNoGlobalHeap ) { |
| 554 | if ( !var->type->isNoHeapType() ) { // note: this is too dangerous to allow even with generated |
| 555 | program->error("variable '" + var->name + "' uses heap, which is disabled via option no_global_heap", "", "", |
| 556 | var->at, CompilationError::cant_global ); |
| 557 | } |
| 558 | } |
| 559 | if ( !var->init ) { |
| 560 | if ( needAvoidNullPtr(var->type,true) ) { |
| 561 | program->error("global variable of type '" + var->type->describe() + "' needs to be initialized to avoid null pointer", "", "", |
| 562 | var->at, CompilationError::missing_global); |
| 563 | } |
| 564 | } else { |
| 565 | if ( needAvoidNullPtr(var->type,false) && var->init->rtti_isNullPtr() ) { |
| 566 | program->error("global variable of type '" + var->type->describe() + "' can't be initialized with null", "", "", |
| 567 | var->init->at, CompilationError::cant_global); |
| 568 | } |
| 569 | } |
| 570 | if ( var->type->getSizeOf64()>0x7fffffff ) { |
| 571 | program->error("global variable '" + var->name + "' is too big", "", "", |
| 572 | var->at,CompilationError::exceeds_global); |
| 573 | } |
| 574 | } |
| 575 | virtual void preVisitGlobalLetInit ( const VariablePtr & var, Expression * that ) override { |
| 576 | Visitor::preVisitGlobalLetInit(var,that); |
| 577 | globalVar = var; |
nothing calls this directly
no test coverage detected