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

Method RemoveUnusedSymbols

src/ast/ast_export.cpp:118–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116 }
117 }
118 void RemoveUnusedSymbols ( Module & mod ) {
119 auto functions = das::move(mod.functions);
120 auto globals = das::move(mod.globals);
121 mod.functionsByName.clear();
122 // mod.globals.clear();
123 for ( auto & fn : functions.each() ) {
124 if ( fn->used ) {
125 if ( !mod.addFunction(fn, true) ) {
126 program->error("internal error, failed to add function " + fn->name,"","", fn->at, CompilationError::internal_function );
127 }
128 }
129 }
130 for ( auto & var : globals.each() ) {
131 if ( var->used ) {
132 if ( !mod.addVariable(var, true) ) {
133 program->error("internal error, failed to add variable " + var->name,"","", var->at, CompilationError::internal_variable );
134 }
135 }
136 }
137 }
138 protected:
139 ProgramPtr program;
140 FunctionPtr func = nullptr;

Callers 1

removeUnusedSymbolsMethod · 0.80

Calls 4

clearMethod · 0.45
addFunctionMethod · 0.45
errorMethod · 0.45
addVariableMethod · 0.45

Tested by

no test coverage detected