2020-08-10 00:42:37 -07:00
|
|
|
#include "CompilerWorkspace.h"
|
|
|
|
|
|
2021-02-25 16:53:22 +01:00
|
|
|
#include "bscript/compiler/ast/ModuleFunctionDeclaration.h"
|
|
|
|
|
#include "bscript/compiler/ast/Program.h"
|
|
|
|
|
#include "bscript/compiler/ast/TopLevelStatements.h"
|
|
|
|
|
#include "bscript/compiler/analyzer/Constants.h"
|
|
|
|
|
#include "bscript/compiler/ast/ConstDeclaration.h"
|
|
|
|
|
#include "bscript/compiler/ast/UserFunction.h"
|
|
|
|
|
#include "bscript/compiler/file/SourceFileIdentifier.h"
|
2020-08-10 00:42:37 -07:00
|
|
|
|
2020-08-10 03:20:29 -07:00
|
|
|
namespace Pol::Bscript::Compiler
|
2020-08-10 00:42:37 -07:00
|
|
|
{
|
2020-09-01 00:54:24 -07:00
|
|
|
CompilerWorkspace::CompilerWorkspace( Report& report ) : constants( report ) {}
|
2020-08-10 00:42:37 -07:00
|
|
|
|
|
|
|
|
CompilerWorkspace::~CompilerWorkspace() = default;
|
|
|
|
|
|
2020-09-01 00:54:24 -07:00
|
|
|
/*
|
|
|
|
|
* This method is the main argument for making this class into an ast/Node.
|
|
|
|
|
* However, it has only one caller: the Optimizer.
|
|
|
|
|
* Other classes visit parts of the tree or do things in between visiting parts.
|
|
|
|
|
*/
|
|
|
|
|
void CompilerWorkspace::accept( NodeVisitor& visitor )
|
|
|
|
|
{
|
|
|
|
|
for ( auto& constant : const_declarations )
|
|
|
|
|
{
|
|
|
|
|
constant->accept( visitor );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( auto& module_function : module_function_declarations )
|
|
|
|
|
{
|
|
|
|
|
module_function->accept( visitor );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
top_level_statements->accept( visitor );
|
|
|
|
|
|
|
|
|
|
if ( program )
|
|
|
|
|
{
|
|
|
|
|
program->accept( visitor );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( auto& user_function : user_functions )
|
|
|
|
|
{
|
|
|
|
|
user_function->accept( visitor );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-10 03:20:29 -07:00
|
|
|
} // namespace Pol::Bscript::Compiler
|