polserver/pol-core/bscript/compiler/model/CompilerWorkspace.cpp
Kevin Eady d7cdcff383 Add classinst.function member; Add is binary operator; Add funcref MTH_NEW (#701)
* Update grammar

* Implement selfIs in BObjectImp

* Add tests

* Update grammar

* Support obj.function as a MemberAccess [1/2]
- AST generation changes

* Support obj.function as a MemberAccess [2/2]
- add funcref index to eprog class table ctor entry
- allow check_mro on non-class inst (skip ctor calls)

* Move address of funcref into funcref table

* Add funcref.new()
- Add class index to funcref table entry
- Add MTH_NEW

* Fix formatting

* Address self-review comments

* Some more tests

* Address self-review comments

* Update grammar

* Remove ObjMember read_only, hidden
No need to special-handle MBR_FUNCTION

* Addres GitHub CI annotations
- '=': conversion from 'size_t' to 'unsigned int', possible loss of data
2024-10-10 18:06:04 +02:00

54 lines
1.4 KiB
C++

#include "CompilerWorkspace.h"
#include "bscript/compiler/analyzer/Constants.h"
#include "bscript/compiler/ast/ClassDeclaration.h"
#include "bscript/compiler/ast/ConstDeclaration.h"
#include "bscript/compiler/ast/ModuleFunctionDeclaration.h"
#include "bscript/compiler/ast/Program.h"
#include "bscript/compiler/ast/TopLevelStatements.h"
#include "bscript/compiler/ast/UserFunction.h"
#include "bscript/compiler/file/SourceFileIdentifier.h"
#include "bscript/compiler/model/FlowControlLabel.h"
namespace Pol::Bscript::Compiler
{
CompilerWorkspace::CompilerWorkspace( Report& report ) : constants( report ) {}
CompilerWorkspace::~CompilerWorkspace() = default;
/*
* 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 );
}
for ( auto& class_decl : class_declarations )
{
class_decl->accept( visitor );
}
}
} // namespace Pol::Bscript::Compiler