forked from PuqiAR/Fig-TreeWalker
[Feat] 支持运算符重载!详见文档或 Library/lang/lang.fig中的定义。通过 impl Operation for xxx实现重载
[Impl] 函数参数指定现在也接受一个 exp,逐渐改动其他中...
This commit is contained in:
@@ -7,22 +7,15 @@
|
||||
#include <Evaluator/Value/value.hpp>
|
||||
#include <Core/runtimeTime.hpp>
|
||||
|
||||
|
||||
#include <unordered_map>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Fig
|
||||
{
|
||||
namespace Builtins
|
||||
{
|
||||
|
||||
inline static const TypeInfo &getErrorInterfaceTypeInfo()
|
||||
{
|
||||
static const TypeInfo ErrorInterfaceTypeInfo(u8"Error", true);
|
||||
return ErrorInterfaceTypeInfo;
|
||||
}
|
||||
/*
|
||||
// error's interface like:
|
||||
interface Error
|
||||
@@ -33,15 +26,33 @@ namespace Fig
|
||||
}
|
||||
*/
|
||||
|
||||
inline static const TypeInfo &getErrorInterfaceTypeInfo()
|
||||
{
|
||||
static const TypeInfo ErrorInterfaceTypeInfo(u8"Error", true);
|
||||
return ErrorInterfaceTypeInfo;
|
||||
}
|
||||
|
||||
/*
|
||||
interface Operation
|
||||
{
|
||||
add(..., ...) -> ...;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
inline static const TypeInfo &getOperationInterfaceTypeInfo()
|
||||
{
|
||||
static const TypeInfo OperationInterfaceTypeInfo(u8"Operation", true);
|
||||
return OperationInterfaceTypeInfo;
|
||||
}
|
||||
|
||||
const std::unordered_map<FString, ObjectPtr> &getBuiltinValues();
|
||||
|
||||
using BuiltinFunction = std::function<ObjectPtr(const std::vector<ObjectPtr> &)>;
|
||||
|
||||
|
||||
const std::unordered_map<FString, int> &getBuiltinFunctionArgCounts();
|
||||
const std::unordered_map<FString, BuiltinFunction> &getBuiltinFunctions();
|
||||
|
||||
|
||||
inline bool isBuiltinFunction(const FString &name)
|
||||
{
|
||||
return getBuiltinFunctions().find(name) != getBuiltinFunctions().end();
|
||||
|
||||
Reference in New Issue
Block a user