回档之后的重写。部分问题修复。添加了什么我也忘了

This commit is contained in:
2026-02-01 15:52:28 +08:00
parent 61bffdc743
commit aea716ced2
50 changed files with 3676 additions and 2997 deletions

View File

@@ -0,0 +1,31 @@
#include <Evaluator/Value/LvObject.hpp>
#include <Evaluator/evaluator.hpp>
#include <Evaluator/evaluator_error.hpp>
namespace Fig
{
RvObject Evaluator::evalUnary(Ast::UnaryExpr un, ContextPtr ctx)
{
using Ast::Operator;
Operator op = un->op;
Ast::Expression exp = un->exp;
ObjectPtr value = eval(exp, ctx);
switch (op)
{
case Operator::Not: {
return std::make_shared<Object>(!(*value));
}
case Operator::Subtract: {
return std::make_shared<Object>(-(*value));
}
case Operator::BitNot: {
return std::make_shared<Object>(bit_not((*value)));
}
default: {
throw EvaluatorError(u8"UnsupportedOpError",
std::format("Unsupported op '{}' for unary expression", magic_enum::enum_name(op)),
un);
}
}
}
};