MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / preVisitGlobalLet

Method preVisitGlobalLet

src/ast/ast_lint.cpp:542–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 6

needAvoidNullPtrFunction · 0.85
isConstMethod · 0.80
errorMethod · 0.45
isNoHeapTypeMethod · 0.45
describeMethod · 0.45
getSizeOf64Method · 0.45

Tested by

no test coverage detected