mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2026-01-25 13:07:13 +00:00
part of execute_visitor, minor fixes, function & operator fixes
This commit is contained in:
parent
d31979166e
commit
78de51f6f2
6 changed files with 345 additions and 247 deletions
|
|
@ -7,6 +7,8 @@
|
|||
#include "global_info.hpp"
|
||||
#include "interpreter_tree.hpp"
|
||||
#include "type_info_contexts.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "values.hpp"
|
||||
#include "visitor.hpp"
|
||||
#include "error_handling.hpp"
|
||||
|
||||
|
|
@ -54,9 +56,9 @@ private:
|
|||
|
||||
// Definition parts
|
||||
|
||||
void Visit(FunctionDefinition* node) override;
|
||||
void Visit(TypeDefinition* node) override;
|
||||
void Visit(AnyAnnotatedType* node) override;
|
||||
// // void Visit(FunctionDefinition* node) override;
|
||||
// // void Visit(TypeDefinition* node) override;
|
||||
// // void Visit(AnyAnnotatedType* node) override;
|
||||
|
||||
// Flow control -----------------
|
||||
|
||||
|
|
@ -99,7 +101,7 @@ private:
|
|||
|
||||
// Name
|
||||
|
||||
void Visit(PartitionName* node) override;
|
||||
// // void Visit(PartitionName* node) override;
|
||||
void Visit(NameExpression* node) override;
|
||||
void Visit(TupleName* node) override;
|
||||
void Visit(VariantName* node) override;
|
||||
|
|
@ -126,9 +128,9 @@ private:
|
|||
|
||||
// Identifiers, constants, etc. -----------------
|
||||
|
||||
void Visit(ExtendedName* node) override;
|
||||
// // void Visit(ExtendedName* node) override;
|
||||
|
||||
void Visit(std::string* node) override; // std::string
|
||||
// // void Visit(std::string* node) override; // std::string
|
||||
|
||||
void Visit(FloatNumberLiteral* node) override;
|
||||
void Visit(NumberLiteral* node) override;
|
||||
|
|
@ -137,10 +139,34 @@ private:
|
|||
void Visit(UnitLiteral* node) override;
|
||||
void Visit(BoolLiteral* node) override;
|
||||
|
||||
bool HandleCondition(Expression& condition, const BaseNode& base_node);
|
||||
|
||||
template<typename T>
|
||||
T* ExtractValue(utils::IdType value, const BaseNode& base_node) {
|
||||
std::optional<T*> maybe_value_info = context_manager_.GetValue<T>(value);
|
||||
if (!maybe_value_info.has_value()) {
|
||||
error_handling::HandleRuntimeError("Value has value class that is different from exprected one", base_node);
|
||||
}
|
||||
return maybe_value_info.value();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* ExtractInternalValue(utils::IdType value, const BaseNode& base_node) {
|
||||
info::value::InternalValue* value_info = ExtractValue<info::value::InternalValue>(value, base_node);
|
||||
std::optional<T*> maybe_internal_value_info = value_info->GetValue<T>();
|
||||
if (!maybe_internal_value_info.has_value()) {
|
||||
error_handling::HandleRuntimeError("Value has internal value class that is different from exprected one", base_node);
|
||||
}
|
||||
return maybe_internal_value_info.value();
|
||||
}
|
||||
private:
|
||||
info::GlobalInfo::NamespaceVisitor namespace_visitor_;
|
||||
info::TypeInfoContextManager& type_info_context_manager_;
|
||||
info::ContextManager& context_manager_;
|
||||
|
||||
utils::IdType current_value_;
|
||||
std::optional<LoopControlExpression> active_loop_control_expression_;
|
||||
std::optional<utils::IdType> return_value_; // TODO: work outside block ??
|
||||
};
|
||||
|
||||
} // namespace interpreter
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue