2023-05-07 20:21:19 +03:00
|
|
|
// for clangd
|
|
|
|
|
#include "../include/execute_visitor.hpp"
|
2023-05-09 14:55:04 +03:00
|
|
|
#include <cwchar>
|
|
|
|
|
#include <optional>
|
|
|
|
|
#include <variant>
|
2023-05-07 20:21:19 +03:00
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
|
|
namespace interpreter {
|
|
|
|
|
|
|
|
|
|
// Sources -----------------
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(SourceFile* node) { // never used ??
|
2023-05-07 20:21:19 +03:00
|
|
|
for (auto& statement : node->statements) {
|
|
|
|
|
Visitor::Visit(statement);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Namespaces, partitions -----------------
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(NamespaceSources* node) { // never used ??
|
2023-05-07 20:21:19 +03:00
|
|
|
for (auto& statement : node->statements) {
|
|
|
|
|
Visitor::Visit(statement);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(Namespace* node) { // never used ??
|
|
|
|
|
// Visit(&node->type);
|
2023-05-07 20:21:19 +03:00
|
|
|
Visit(&node->scope);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Definitions -----------------
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(ImportStatement* node) {} // no value
|
|
|
|
|
void ExecuteVisitor::Visit(AliasDefinitionStatement* node) {} // no value
|
2023-05-07 20:21:19 +03:00
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(VariableDefinitionStatement* node) {
|
|
|
|
|
Visitor::Visit(node->name);
|
|
|
|
|
Visitor::Visit(node->value);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(FunctionDeclaration* node) {} // no value
|
2023-05-07 20:21:19 +03:00
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(FunctionDefinitionStatement* node) {
|
2023-05-09 14:55:04 +03:00
|
|
|
// Visit(node->definition.get());
|
2023-05-07 20:21:19 +03:00
|
|
|
Visitor::Visit(node->value);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(TypeDefinitionStatement* node) {} // no value
|
|
|
|
|
void ExecuteVisitor::Visit(AbstractTypeDefinitionStatement* node) {} // no value
|
2023-05-07 20:21:19 +03:00
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(TypeclassDefinitionStatement* node) {} // no value
|
2023-05-07 20:21:19 +03:00
|
|
|
|
2023-05-08 20:34:36 +03:00
|
|
|
void ExecuteVisitor::Visit(PartitionStatement* node) {
|
2023-05-07 22:58:15 +03:00
|
|
|
Visitor::Visit(node->value);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-07 20:21:19 +03:00
|
|
|
// Flow control -----------------
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(TypeConstructorPatternParameter* node) {
|
|
|
|
|
if (node->name.has_value()) {
|
2023-05-09 14:55:04 +03:00
|
|
|
// Visit(&node->name.value());
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
Visitor::Visit(node->value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(TypeConstructorPattern* node) {
|
|
|
|
|
Visit(node->constructor.get());
|
|
|
|
|
for (auto& parameter : node->parameters) {
|
|
|
|
|
Visit(¶meter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(MatchCase* node) {
|
|
|
|
|
Visitor::Visit(node->value);
|
|
|
|
|
if (node->condition.has_value()) {
|
|
|
|
|
Visitor::Visit(node->condition.value());
|
|
|
|
|
}
|
|
|
|
|
if (node->statement.has_value()) {
|
|
|
|
|
Visitor::Visit(node->statement.value());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(Match* node) {
|
|
|
|
|
Visitor::Visit(node->value);
|
|
|
|
|
for (auto& match_case : node->matches) {
|
|
|
|
|
Visit(&match_case);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(Condition* node) {
|
|
|
|
|
for (size_t i = 0; i < node->conditions.size(); ++i) {
|
|
|
|
|
Visitor::Visit(node->conditions[i]);
|
|
|
|
|
Visitor::Visit(node->statements[i]);
|
|
|
|
|
}
|
|
|
|
|
if (node->statements.size() > node->conditions.size()) {
|
|
|
|
|
Visitor::Visit(node->statements[node->conditions.size()]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(DoWhileLoop* node) {
|
2023-05-09 14:55:04 +03:00
|
|
|
std::vector<utils::IdType> result;
|
|
|
|
|
do {
|
|
|
|
|
Visitor::Visit(node->statement);
|
|
|
|
|
if (active_loop_control_expression_.has_value()) {
|
|
|
|
|
if (active_loop_control_expression_.value() == LoopControlExpression::Break) {
|
|
|
|
|
active_loop_control_expression_ = std::nullopt;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
active_loop_control_expression_ = std::nullopt;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
result.push_back(current_value_);
|
|
|
|
|
} while(HandleCondition(node->condition, node->base));
|
|
|
|
|
|
|
|
|
|
current_value_ = context_manager_.AddValue<info::value::ArrayValue>(
|
|
|
|
|
info::value::ArrayValue(result, false),
|
|
|
|
|
utils::ValueType::Tmp);
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(WhileLoop* node) {
|
2023-05-09 14:55:04 +03:00
|
|
|
std::vector<utils::IdType> result;
|
|
|
|
|
while(HandleCondition(node->condition, node->base)) {
|
|
|
|
|
Visitor::Visit(node->statement);
|
|
|
|
|
if (active_loop_control_expression_.has_value()) {
|
|
|
|
|
if (active_loop_control_expression_.value() == LoopControlExpression::Break) {
|
|
|
|
|
active_loop_control_expression_ = std::nullopt;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
active_loop_control_expression_ = std::nullopt;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
result.push_back(current_value_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
current_value_ = context_manager_.AddValue<info::value::ArrayValue>(
|
|
|
|
|
info::value::ArrayValue(result, false),
|
|
|
|
|
utils::ValueType::Tmp);
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
void ExecuteVisitor::Visit(ForLoop* node) {
|
2023-05-09 14:55:04 +03:00
|
|
|
std::vector<utils::IdType> result;
|
|
|
|
|
|
|
|
|
|
// TODO: extend on different interval types (not only array)
|
2023-05-07 20:21:19 +03:00
|
|
|
Visitor::Visit(node->interval);
|
2023-05-09 14:55:04 +03:00
|
|
|
info::value::ArrayValue* interval = ExtractValue<info::value::ArrayValue>(current_value_, node->base);
|
|
|
|
|
|
|
|
|
|
for (auto& value : interval->elements) {
|
|
|
|
|
current_value_ = value;
|
|
|
|
|
Visitor::Visit(node->variable);
|
|
|
|
|
|
|
|
|
|
Visitor::Visit(node->statement);
|
|
|
|
|
if (active_loop_control_expression_.has_value()) {
|
|
|
|
|
if (active_loop_control_expression_.value() == LoopControlExpression::Break) {
|
|
|
|
|
active_loop_control_expression_ = std::nullopt;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
active_loop_control_expression_ = std::nullopt;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
result.push_back(current_value_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
current_value_ = context_manager_.AddValue<info::value::ArrayValue>(
|
|
|
|
|
info::value::ArrayValue(result, false),
|
|
|
|
|
utils::ValueType::Tmp);
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(LoopLoop* node) {
|
2023-05-09 14:55:04 +03:00
|
|
|
std::vector<utils::IdType> result;
|
|
|
|
|
while(true) {
|
|
|
|
|
Visitor::Visit(node->statement);
|
|
|
|
|
if (active_loop_control_expression_.has_value()) {
|
|
|
|
|
if (active_loop_control_expression_.value() == LoopControlExpression::Break) {
|
|
|
|
|
active_loop_control_expression_ = std::nullopt;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
active_loop_control_expression_ = std::nullopt;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
result.push_back(current_value_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
current_value_ = context_manager_.AddValue<info::value::ArrayValue>(
|
|
|
|
|
info::value::ArrayValue(result, false),
|
|
|
|
|
utils::ValueType::Tmp);
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Statements, expressions, blocks, etc. -----------------
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(Block* node) {
|
|
|
|
|
for (auto& statement : node->statements) {
|
2023-05-09 14:55:04 +03:00
|
|
|
return_value_ = std::nullopt;
|
2023-05-07 20:21:19 +03:00
|
|
|
Visitor::Visit(statement);
|
2023-05-09 14:55:04 +03:00
|
|
|
if (return_value_.has_value()) {
|
|
|
|
|
current_value_ = return_value_.value();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
2023-05-09 14:55:04 +03:00
|
|
|
current_value_ = context_manager_.AddValue<info::value::InternalValue>(
|
|
|
|
|
info::value::InternalValue(info::value::Unit()),
|
|
|
|
|
utils::ValueType::Tmp);
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(ScopedStatement* node) {
|
|
|
|
|
Visitor::Visit(node->statement);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(LoopControlExpression& node) {
|
|
|
|
|
active_loop_control_expression_ = node;
|
|
|
|
|
|
|
|
|
|
current_value_ = context_manager_.AddValue(info::value::InternalValue(info::value::Unit()),
|
|
|
|
|
utils::ValueType::Tmp); // ??
|
|
|
|
|
}
|
2023-05-07 20:21:19 +03:00
|
|
|
|
|
|
|
|
// Operators
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(BinaryOperatorExpression* node) {
|
|
|
|
|
Visitor::Visit(node->left_expression);
|
|
|
|
|
Visitor::Visit(&node->operator_name);
|
|
|
|
|
Visitor::Visit(node->right_expression);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(UnaryOperatorExpression* node) {
|
2023-05-09 14:55:04 +03:00
|
|
|
// Visit(&node->operator_name);
|
2023-05-07 20:21:19 +03:00
|
|
|
Visitor::Visit(node->expression);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(ReferenceExpression* node) {
|
2023-05-09 14:55:04 +03:00
|
|
|
// TODO: check, that therie is no references to "Tmp"
|
2023-05-07 20:21:19 +03:00
|
|
|
Visit(node->expression.get());
|
2023-05-09 14:55:04 +03:00
|
|
|
|
|
|
|
|
utils::ValueType value_type = context_manager_.GetValueType(current_value_);
|
|
|
|
|
|
|
|
|
|
current_value_ = context_manager_.AddValue(
|
|
|
|
|
info::value::ReferenceToValue(node->references, current_value_),
|
|
|
|
|
value_type);
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(AccessExpression* node) {
|
2023-05-09 14:55:04 +03:00
|
|
|
// TODO: extend to other types
|
2023-05-07 20:21:19 +03:00
|
|
|
Visit(node->name.get());
|
2023-05-09 14:55:04 +03:00
|
|
|
info::value::ArrayValue* array_value = ExtractValue<info::value::ArrayValue>(current_value_, node->base);
|
|
|
|
|
utils::ValueType value_type = context_manager_.GetValueType(current_value_);
|
|
|
|
|
|
2023-05-07 20:21:19 +03:00
|
|
|
Visitor::Visit(node->id);
|
2023-05-09 14:55:04 +03:00
|
|
|
long long index = *ExtractInternalValue<long long>(current_value_, node->base); // TODO: size_t
|
|
|
|
|
|
|
|
|
|
if (index < 0 || index >= array_value->elements.size()) {
|
|
|
|
|
error_handling::HandleRuntimeError("Access index out of range", node->base);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
current_value_ = context_manager_.ToModifiedValue(array_value->elements[index], value_type); // needed ??
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Other Expressions
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(FunctionCallExpression* node) {
|
|
|
|
|
if (node->prefix.has_value()) {
|
|
|
|
|
if (std::holds_alternative<std::unique_ptr<SubExpressionToken>>(node->prefix.value())) {
|
|
|
|
|
Visitor::Visit(*std::get<std::unique_ptr<SubExpressionToken>>(node->prefix.value()));
|
|
|
|
|
} else if (std::holds_alternative<std::unique_ptr<TypeExpression>>(node->prefix.value())) {
|
|
|
|
|
Visit(std::get<std::unique_ptr<TypeExpression>>(node->prefix.value()).get());
|
|
|
|
|
} else {
|
|
|
|
|
// error
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
// Visit(&node->name);
|
2023-05-07 20:21:19 +03:00
|
|
|
|
|
|
|
|
for (auto& parameter : node->parameters) {
|
|
|
|
|
Visit(parameter.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto& argument : node->arguments) {
|
|
|
|
|
Visitor::Visit(argument);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(TupleExpression* node) {
|
2023-05-09 14:55:04 +03:00
|
|
|
std::vector<std::pair<std::optional<std::string>, utils::IdType>> fields;
|
|
|
|
|
fields.reserve(node->expressions.size());
|
2023-05-07 20:21:19 +03:00
|
|
|
for (auto& expression : node->expressions) {
|
|
|
|
|
Visitor::Visit(expression);
|
2023-05-09 14:55:04 +03:00
|
|
|
fields.push_back({std::nullopt, current_value_});
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
2023-05-09 14:55:04 +03:00
|
|
|
|
|
|
|
|
current_value_ = context_manager_.AddValue<info::value::TupleValue>(info::value::TupleValue(std::move(fields)),
|
|
|
|
|
utils::ValueType::Tmp);
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
// TODO
|
|
|
|
|
void ExecuteVisitor::Visit(VariantExpression* node) { // ??
|
2023-05-07 20:21:19 +03:00
|
|
|
for (auto& expression : node->expressions) {
|
|
|
|
|
Visitor::Visit(expression);
|
2023-05-09 14:55:04 +03:00
|
|
|
info::value::OptionalValue* expression_value = ExtractValue<info::value::OptionalValue>(current_value_, node->base);
|
|
|
|
|
if (expression_value->value.has_value()) {
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(ReturnExpression* node) {
|
|
|
|
|
Visitor::Visit(node->expression);
|
2023-05-09 14:55:04 +03:00
|
|
|
return_value_ = current_value_;
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(TypeConstructorParameter* node) {
|
|
|
|
|
if (node->name.has_value()) {
|
2023-05-09 14:55:04 +03:00
|
|
|
// Visit(&node->name.value());
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
Visitor::Visit(node->value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(TypeConstructor* node) {
|
|
|
|
|
Visit(node->constructor.get());
|
|
|
|
|
for (auto& parameter : node->parameters) {
|
|
|
|
|
Visit(¶meter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
// TODO
|
2023-05-07 20:21:19 +03:00
|
|
|
void ExecuteVisitor::Visit(LambdaFunction* node) {
|
2023-05-09 14:55:04 +03:00
|
|
|
error_handling::HandleInternalError("Lambda function are not implemented yet",
|
|
|
|
|
"ExecuteVisitor.LambdaFunction");
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(ArrayExpression* node) {
|
|
|
|
|
for (auto& element : node->elements) {
|
|
|
|
|
Visitor::Visit(element);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Name
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(NameExpression* node) {
|
|
|
|
|
for (auto& name : node->names) {
|
2023-05-09 14:55:04 +03:00
|
|
|
// Visit(&name);
|
2023-05-07 20:21:19 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(TupleName* node) {
|
|
|
|
|
for (auto& name : node->names) {
|
|
|
|
|
Visitor::Visit(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(VariantName* node) {
|
|
|
|
|
for (auto& name : node->names) {
|
|
|
|
|
Visitor::Visit(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(AnnotatedName* node) {
|
2023-05-09 14:55:04 +03:00
|
|
|
// Visit(&node->name);
|
2023-05-07 20:21:19 +03:00
|
|
|
if (node->type.has_value()) {
|
|
|
|
|
Visitor::Visit(node->type.value());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Type, typeclass, etc. -----------------
|
|
|
|
|
|
|
|
|
|
// Type
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(FunctionType* node) {} // no value
|
|
|
|
|
void ExecuteVisitor::Visit(TupleType* node) {} // no value
|
|
|
|
|
void ExecuteVisitor::Visit(VariantType* node) {} // no value
|
|
|
|
|
void ExecuteVisitor::Visit(TypeExpression* node) {} // no value
|
|
|
|
|
void ExecuteVisitor::Visit(ExtendedScopedAnyType* node) {} // no value
|
2023-05-07 20:21:19 +03:00
|
|
|
|
|
|
|
|
// Typeclass
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(ParametrizedTypeclass* node) {} // no value
|
2023-05-07 20:21:19 +03:00
|
|
|
|
|
|
|
|
// Typeclass & Type -----------------
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(ParametrizedType* node) {} // no value
|
2023-05-07 20:21:19 +03:00
|
|
|
|
|
|
|
|
// Identifiers, constants, etc. -----------------
|
|
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
// void ExecuteVisitor::Visit(ExtendedName* node) {}
|
2023-05-07 20:21:19 +03:00
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
// void ExecuteVisitor::Visit(std::string* node) {} // std::string
|
2023-05-07 20:21:19 +03:00
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(FloatNumberLiteral* node) {
|
|
|
|
|
current_value_ = context_manager_.AddValue<info::value::InternalValue>(
|
|
|
|
|
info::value::InternalValue(node->value),
|
|
|
|
|
utils::ValueType::Tmp);
|
|
|
|
|
}
|
2023-05-07 20:21:19 +03:00
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(NumberLiteral* node) {
|
|
|
|
|
current_value_ = context_manager_.AddValue<info::value::InternalValue>(
|
|
|
|
|
info::value::InternalValue(node->value),
|
|
|
|
|
utils::ValueType::Tmp);
|
|
|
|
|
}
|
2023-05-07 20:21:19 +03:00
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(StringLiteral* node) {
|
|
|
|
|
current_value_ = context_manager_.AddValue<info::value::InternalValue>(
|
|
|
|
|
info::value::InternalValue(node->value),
|
|
|
|
|
utils::ValueType::Tmp);
|
|
|
|
|
}
|
2023-05-07 20:21:19 +03:00
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(CharLiteral* node) {
|
|
|
|
|
current_value_ = context_manager_.AddValue<info::value::InternalValue>(
|
|
|
|
|
info::value::InternalValue(node->value),
|
|
|
|
|
utils::ValueType::Tmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteVisitor::Visit(UnitLiteral* node) {
|
|
|
|
|
current_value_ = context_manager_.AddValue<info::value::InternalValue>(
|
|
|
|
|
info::value::InternalValue(info::value::Unit()),
|
|
|
|
|
utils::ValueType::Tmp);
|
|
|
|
|
}
|
2023-05-07 20:21:19 +03:00
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
void ExecuteVisitor::Visit(BoolLiteral* node) {
|
|
|
|
|
current_value_ = context_manager_.AddValue<info::value::InternalValue>(
|
|
|
|
|
info::value::InternalValue(node->value),
|
|
|
|
|
utils::ValueType::Tmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
2023-05-07 20:21:19 +03:00
|
|
|
|
2023-05-09 14:55:04 +03:00
|
|
|
bool ExecuteVisitor::HandleCondition(Expression& node, const BaseNode& base_node) {
|
|
|
|
|
Visitor::Visit(node);
|
|
|
|
|
return *ExtractInternalValue<bool>(current_value_, base_node);
|
|
|
|
|
}
|
2023-05-08 20:34:36 +03:00
|
|
|
|
2023-05-07 20:21:19 +03:00
|
|
|
} // namespace interpreter
|
|
|
|
|
|