2026-07-25 23:01:18 +02:00
|
|
|
#include "bscript/compiler/codegen/CaseDispatchGroupVisitor.h"
|
2020-09-05 20:41:58 -07:00
|
|
|
|
2024-01-20 12:38:25 +08:00
|
|
|
#include "bscript/compiler/ast/BooleanValue.h"
|
2021-02-25 16:53:22 +01:00
|
|
|
#include "bscript/compiler/ast/CaseDispatchDefaultSelector.h"
|
|
|
|
|
#include "bscript/compiler/ast/IntegerValue.h"
|
|
|
|
|
#include "bscript/compiler/ast/StringValue.h"
|
2024-01-20 12:38:25 +08:00
|
|
|
#include "bscript/compiler/ast/UninitializedValue.h"
|
2021-02-25 16:53:22 +01:00
|
|
|
#include "bscript/compiler/codegen/CaseJumpDataBlock.h"
|
|
|
|
|
#include "bscript/compiler/model/FlowControlLabel.h"
|
2020-09-05 20:41:58 -07:00
|
|
|
|
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
|
|
|
{
|
|
|
|
|
CaseDispatchGroupVisitor::CaseDispatchGroupVisitor( CaseJumpDataBlock& data_block,
|
|
|
|
|
FlowControlLabel& group_block_label,
|
|
|
|
|
FlowControlLabel& default_label )
|
|
|
|
|
: data_block( data_block ),
|
|
|
|
|
group_block_label( group_block_label ),
|
|
|
|
|
default_label( default_label )
|
|
|
|
|
{
|
|
|
|
|
}
|
2024-01-20 12:38:25 +08:00
|
|
|
void CaseDispatchGroupVisitor::visit_boolean_value( BooleanValue& boolean_node )
|
|
|
|
|
{
|
|
|
|
|
data_block.on_boolean_value_jump_to( boolean_node.value,
|
|
|
|
|
static_cast<unsigned short>( group_block_label.address() ) );
|
|
|
|
|
}
|
2020-09-05 20:41:58 -07:00
|
|
|
|
|
|
|
|
void CaseDispatchGroupVisitor::visit_case_dispatch_default_selector( CaseDispatchDefaultSelector& )
|
|
|
|
|
{
|
|
|
|
|
default_label = group_block_label;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CaseDispatchGroupVisitor::visit_integer_value( IntegerValue& integer_node )
|
|
|
|
|
{
|
2021-08-28 22:26:15 +02:00
|
|
|
data_block.on_integer_value_jump_to( integer_node.value,
|
|
|
|
|
static_cast<unsigned short>( group_block_label.address() ) );
|
2020-09-05 20:41:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CaseDispatchGroupVisitor::visit_string_value( StringValue& string_node )
|
|
|
|
|
{
|
2021-08-28 22:26:15 +02:00
|
|
|
data_block.on_string_value_jump_to( string_node.value,
|
|
|
|
|
static_cast<unsigned short>( group_block_label.address() ) );
|
2020-09-05 20:41:58 -07:00
|
|
|
}
|
|
|
|
|
|
2024-01-20 12:38:25 +08:00
|
|
|
void CaseDispatchGroupVisitor::visit_uninitialized_value( UninitializedValue& )
|
|
|
|
|
{
|
|
|
|
|
data_block.on_uninitialized_value_jump_to(
|
|
|
|
|
static_cast<unsigned short>( group_block_label.address() ) );
|
|
|
|
|
}
|
2020-09-05 20:41:58 -07:00
|
|
|
} // namespace Pol::Bscript::Compiler
|