2026-07-25 23:01:18 +02:00
|
|
|
#include "bscript/compiler/model/FunctionLink.h"
|
2020-08-24 01:47:38 -07:00
|
|
|
|
2021-02-25 16:53:22 +01:00
|
|
|
#include "bscript/compiler/ast/ModuleFunctionDeclaration.h"
|
|
|
|
|
#include "bscript/compiler/ast/UserFunction.h"
|
|
|
|
|
#include "bscript/compiler/file/SourceLocation.h"
|
2020-08-24 01:47:38 -07:00
|
|
|
|
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
|
|
|
{
|
2024-08-14 12:56:36 +02:00
|
|
|
FunctionLink::FunctionLink( const SourceLocation& source_location, std::string calling_scope,
|
|
|
|
|
bool require_ctor )
|
2024-08-11 23:01:38 +02:00
|
|
|
: source_location( source_location ),
|
|
|
|
|
calling_scope( std::move( calling_scope ) ),
|
2024-08-14 12:56:36 +02:00
|
|
|
require_ctor( require_ctor ),
|
2024-08-11 23:01:38 +02:00
|
|
|
linked_function( nullptr )
|
2020-08-24 01:47:38 -07:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Function* FunctionLink::function() const
|
|
|
|
|
{
|
|
|
|
|
return linked_function;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ModuleFunctionDeclaration* FunctionLink::module_function_declaration() const
|
|
|
|
|
{
|
|
|
|
|
return dynamic_cast<ModuleFunctionDeclaration*>( linked_function );
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-31 18:46:27 -07:00
|
|
|
UserFunction* FunctionLink::user_function() const
|
|
|
|
|
{
|
|
|
|
|
return dynamic_cast<UserFunction*>( linked_function );
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-24 01:47:38 -07:00
|
|
|
void FunctionLink::link_to( Function* f )
|
|
|
|
|
{
|
|
|
|
|
if ( linked_function )
|
|
|
|
|
source_location.internal_error( "function already linked" );
|
|
|
|
|
linked_function = f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Pol::Bscript::Compiler
|