forked from PuqiAR/Fig-TreeWalker
[Impl] 重构evaluator.cpp + hpp 全部 [Feat] 增加对于IndexExpr的解析 [Fix][Impl] 现在点运算符不由BinaryExpr负责,增加MemberExpr,单独实现解析 [Impl] 项目目录全部翻修, src/目录下单独文件夹放置每一个模块
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
// include/Ast/FunctionCall.hpp
|
|
#pragma once
|
|
|
|
#include <Ast/astBase.hpp>
|
|
#include <Value/value.hpp>
|
|
|
|
namespace Fig::Ast
|
|
{
|
|
struct FunctionArguments
|
|
{
|
|
std::vector<Expression> argv;
|
|
size_t getLength() const { return argv.size(); }
|
|
};
|
|
|
|
struct FunctionCallArgs final
|
|
{
|
|
std::vector<ObjectPtr> argv;
|
|
size_t getLength() const { return argv.size(); }
|
|
};
|
|
|
|
class FunctionCallExpr final : public ExpressionAst
|
|
{
|
|
public:
|
|
Expression callee;
|
|
FunctionArguments arg;
|
|
|
|
FunctionCallExpr()
|
|
{
|
|
type = AstType::FunctionCall;
|
|
}
|
|
|
|
FunctionCallExpr(Expression _callee, FunctionArguments _arg) :
|
|
callee(std::move(_callee)), arg(std::move(_arg))
|
|
{
|
|
type = AstType::FunctionCall;
|
|
}
|
|
|
|
virtual FString toString() override
|
|
{
|
|
FString s = callee->toString();
|
|
s += u8"(";
|
|
for (size_t i = 0; i < arg.argv.size(); ++i)
|
|
{
|
|
s += arg.argv[i]->toString();
|
|
if (i + 1 < arg.argv.size())
|
|
s += u8", ";
|
|
}
|
|
s += u8")";
|
|
return s;
|
|
}
|
|
};
|
|
|
|
using FunctionCall = std::shared_ptr<FunctionCallExpr>;
|
|
}; // namespace Fig
|