mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-07 07:28:44 +00:00
binary operator expression repalced with function call expression
This commit is contained in:
parent
5192ffe5f3
commit
94805c8662
15 changed files with 165 additions and 269 deletions
|
|
@ -315,32 +315,35 @@ void ExecuteVisitor::Visit(LoopControlExpression& node) {
|
|||
|
||||
// Operators
|
||||
|
||||
void ExecuteVisitor::Visit(BinaryOperatorExpression* node) {
|
||||
context_manager_.EnterContext();
|
||||
|
||||
auto maybe_function_definition = namespace_visitor_.GetGlobalInfo()->GetFunctionInfo(node->function_id_).definition;
|
||||
|
||||
if (maybe_function_definition.has_value()) {
|
||||
Visitor::Visit(node->left_expression);
|
||||
// TODO: custom argument value types, references, etc.
|
||||
current_value_ = context_manager_.ToModifiedValue(current_value_, utils::ValueType::Const);
|
||||
context_manager_.DefineVariable(
|
||||
node->is_method_ ? utils::ClassInternalVarName : maybe_function_definition.value().argument_names[0],
|
||||
current_value_);
|
||||
|
||||
Visitor::Visit(node->left_expression);
|
||||
// TODO: custom argument value types, references, etc.
|
||||
current_value_ = context_manager_.ToModifiedValue(current_value_, utils::ValueType::Const);
|
||||
context_manager_.DefineVariable(maybe_function_definition.value().argument_names[node->is_method_ ? 0 : 1], current_value_);
|
||||
|
||||
Visit(maybe_function_definition.value().node);
|
||||
} else {
|
||||
// TODO: builtin operators, etc. (imports?)
|
||||
error_handling::HandleRuntimeError("Binary operator definition not found", node->base);
|
||||
}
|
||||
|
||||
context_manager_.ExitContext();
|
||||
}
|
||||
// TODO: function call expression used instead
|
||||
/////////////////////////////////////////////////
|
||||
// void ExecuteVisitor::Visit(BinaryOperatorExpression* node) {
|
||||
// context_manager_.EnterContext();
|
||||
//
|
||||
// auto maybe_function_definition = namespace_visitor_.GetGlobalInfo()->GetFunctionInfo(node->function_id_).definition;
|
||||
//
|
||||
// if (maybe_function_definition.has_value()) {
|
||||
// Visitor::Visit(node->left_expression);
|
||||
// // TODO: custom argument value types, references, etc.
|
||||
// current_value_ = context_manager_.ToModifiedValue(current_value_, utils::ValueType::Const);
|
||||
// context_manager_.DefineVariable(
|
||||
// node->is_method_ ? utils::ClassInternalVarName : maybe_function_definition.value().argument_names[0],
|
||||
// current_value_);
|
||||
//
|
||||
// Visitor::Visit(node->left_expression);
|
||||
// // TODO: custom argument value types, references, etc.
|
||||
// current_value_ = context_manager_.ToModifiedValue(current_value_, utils::ValueType::Const);
|
||||
// context_manager_.DefineVariable(maybe_function_definition.value().argument_names[node->is_method_ ? 0 : 1], current_value_);
|
||||
//
|
||||
// Visit(maybe_function_definition.value().node);
|
||||
// } else {
|
||||
// // TODO: builtin operators, etc. (imports?)
|
||||
// error_handling::HandleRuntimeError("Binary operator definition not found", node->base);
|
||||
// }
|
||||
//
|
||||
// context_manager_.ExitContext();
|
||||
// }
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
void ExecuteVisitor::Visit(ReferenceExpression* node) {
|
||||
// TODO: check, that there is no references to "Tmp"??
|
||||
|
|
@ -371,6 +374,8 @@ void ExecuteVisitor::Visit(AccessExpression* node) {
|
|||
|
||||
// Other Expressions
|
||||
|
||||
// TODO: typeclass methods
|
||||
// TODO: binary operator expression
|
||||
void ExecuteVisitor::Visit(FunctionCallExpression* node) {
|
||||
context_manager_.EnterContext();
|
||||
if (node->prefix.has_value()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue