[Feat] 详细区分左值(LvObject)与右值(RvObject -> ObjectPtr)

[Impl] 重构evaluator.cpp + hpp 全部
[Feat] 增加对于IndexExpr的解析
[Fix][Impl] 现在点运算符不由BinaryExpr负责,增加MemberExpr,单独实现解析
[Impl] 项目目录全部翻修, src/目录下单独文件夹放置每一个模块
This commit is contained in:
2025-12-24 17:51:49 +08:00
parent 3227230aa2
commit fc35368d85
70 changed files with 1558 additions and 1233 deletions

View File

@@ -0,0 +1,45 @@
#pragma once
#include <Ast/astBase.hpp>
#include <Ast/functionParameters.hpp>
#include <Value/value.hpp>
namespace Fig::Ast
{
/*
func greet(greeting, name:String, age:Int, split:String=":") -> Null
{
io.println("{}, {}{}{}", greeting, name, split, age);
}
`greeting`, `name`, `age` -> positional parameters
`split` -> default parameter
*/
class FunctionDefSt final : public StatementAst // for definition
{
public:
FString name;
FunctionParameters paras;
bool isPublic;
FString retType;
BlockStatement body;
FunctionDefSt() :
retType(ValueType::Null.name)
{
type = AstType::FunctionDefSt;
}
FunctionDefSt(FString _name, FunctionParameters _paras, bool _isPublic, FString _retType, BlockStatement _body)
{
type = AstType::FunctionDefSt;
name = std::move(_name);
paras = std::move(_paras);
isPublic = _isPublic;
retType = std::move(_retType);
body = std::move(_body);
}
};
using FunctionDef = std::shared_ptr<FunctionDefSt>;
}; // namespace Fig