Support basic parsing function statements.
This commit is contained in:
9
src/CoreData/AccessModifier.hpp
Normal file
9
src/CoreData/AccessModifier.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef MALACHSCRIPT_ACCESSMODIFIER_HPP
|
||||
#define MALACHSCRIPT_ACCESSMODIFIER_HPP
|
||||
|
||||
#include <cstdint>
|
||||
namespace MalachScript {
|
||||
enum class AccessModifier : uint8_t { Public, Private, Protected };
|
||||
}
|
||||
|
||||
#endif // MALACHSCRIPT_ACCESSMODIFIER_HPP
|
||||
25
src/CoreData/FuncAttr.hpp
Normal file
25
src/CoreData/FuncAttr.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef MALACHSCRIPT_FUNCATTR_HPP
|
||||
#define MALACHSCRIPT_FUNCATTR_HPP
|
||||
|
||||
#include <cstdint>
|
||||
namespace MalachScript {
|
||||
enum class FuncAttr : uint8_t {
|
||||
None = 0,
|
||||
Override = 1 << 1,
|
||||
Final = 1 << 2,
|
||||
Explicit = 1 << 3,
|
||||
Property = 1 << 4,
|
||||
};
|
||||
|
||||
class FuncAttrHelpers {
|
||||
public:
|
||||
constexpr inline static bool Contains(FuncAttr set, FuncAttr flag) {
|
||||
return (static_cast<uint8_t>(set) & static_cast<uint8_t>(flag)) != 0;
|
||||
}
|
||||
constexpr inline static FuncAttr Set(FuncAttr set, FuncAttr flag){
|
||||
return static_cast<FuncAttr>(static_cast<uint8_t>(set) | static_cast<uint8_t>(flag));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // MALACHSCRIPT_FUNCATTR_HPP
|
||||
@@ -36,13 +36,15 @@ namespace MalachScript {
|
||||
0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
||||
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D};
|
||||
|
||||
static std::u8string empty;
|
||||
|
||||
class Identifier {
|
||||
std::u8string_view _str;
|
||||
uint32_t _hash;
|
||||
|
||||
public:
|
||||
Identifier() : _hash(0) {}
|
||||
consteval Identifier(const char8_t* c) : _str(c), _hash(Hash(c)) {}
|
||||
Identifier() : _str(empty), _hash(0) {}
|
||||
constexpr Identifier(const char8_t* c) : _str(c), _hash(Hash(c)) {}
|
||||
Identifier(const std::u8string_view& c) : _str(c), _hash(Hash(c)) {}
|
||||
Identifier(const std::u8string_view& c, uint32_t hash) : _str(c), _hash(hash) {}
|
||||
|
||||
@@ -59,6 +61,19 @@ namespace MalachScript {
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
class ScopedIdentifier {
|
||||
std::vector<Identifier> _scope;
|
||||
Identifier _identifier;
|
||||
|
||||
public:
|
||||
ScopedIdentifier() {}
|
||||
|
||||
inline std::vector<Identifier>& GetScope() noexcept { return _scope; }
|
||||
inline const std::vector<Identifier>& GetScope() const noexcept { return _scope; }
|
||||
inline Identifier& GetIdentifier() noexcept { return _identifier; }
|
||||
inline const Identifier& GetIdentifier() const noexcept { return _identifier; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // MALACHSCRIPT_IDENTIFIER_HPP
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace MalachScript {
|
||||
static constinit Identifier _doubleName = u8"double";
|
||||
static constinit Identifier _boolName = u8"bool";
|
||||
|
||||
static constinit Identifier _autoName = u8"auto";
|
||||
|
||||
class PrimitiveTypes {
|
||||
public:
|
||||
constexpr static const Identifier& VoidName() noexcept { return _voidName; }
|
||||
@@ -36,6 +38,7 @@ namespace MalachScript {
|
||||
constexpr static const Identifier& FloatName() noexcept { return _floatName; }
|
||||
constexpr static const Identifier& DoubleName() noexcept { return _doubleName; }
|
||||
constexpr static const Identifier& BoolName() noexcept { return _boolName; }
|
||||
constexpr static const Identifier& AutoName() noexcept { return _autoName; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
15
src/CoreData/TypeMod.hpp
Normal file
15
src/CoreData/TypeMod.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef MALACHSCRIPT_TYPEMOD_HPP
|
||||
#define MALACHSCRIPT_TYPEMOD_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace MalachScript{
|
||||
enum class TypeMod : uint8_t {
|
||||
None = 0,
|
||||
RefIn = 1,
|
||||
RefOut = 2,
|
||||
RefInOut = 3,
|
||||
};
|
||||
}
|
||||
|
||||
#endif // MALACHSCRIPT_TYPEMOD_HPP
|
||||
Reference in New Issue
Block a user