Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:

install-arkscript:
runs-on: ${{ matrix.os }}
name: Install ArkScript on ${{ matrix.os }}
name: "Install ArkScript on ${{ matrix.os }} (static: ${{ matrix.static }})"
needs: [ check ]

strategy:
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ endif ()
# Create the different (optional) targets
#####################################################

if (ARK_BUILD_MODULES)
if (ARK_BUILD_MODULES AND NOT ARK_STATIC)
get_directory_property(old_dir_compile_options COMPILE_OPTIONS)
add_compile_options(-w)
add_subdirectory(${ark_SOURCE_DIR}/lib/modules)
Expand Down Expand Up @@ -358,8 +358,8 @@ if (ARK_BUILD_EXE)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif ()

if (ARK_SANITIZERS)
message(STATUS "Enabling address sanitizer and undefined behavior sanitizer")
if (ARK_SANITIZERS AND NOT ARK_STATIC)
message(STATUS "Enabling ASAN and UBSAN")
add_address_sanitizer()
add_undefined_sanitizer()
endif ()
2 changes: 1 addition & 1 deletion include/Ark/Compiler/AST/Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ namespace Ark::internal
* @param node
* @return std::string a string corresponding to the node type
*/
inline std::string typeToString(const Node& node) noexcept
ARK_ALWAYS_INLINE inline std::string typeToString(const Node& node) noexcept
{
if (node.nodeType() == NodeType::Symbol)
{
Expand Down
18 changes: 9 additions & 9 deletions include/Ark/Compiler/IntermediateRepresentation/Entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,25 @@ namespace Ark::internal::IR

[[nodiscard]] Word bytecode() const;

[[nodiscard]] inline label_t label() const { return m_label; }
[[nodiscard]] label_t label() const { return m_label; }

[[nodiscard]] inline Kind kind() const { return m_kind; }
[[nodiscard]] Kind kind() const { return m_kind; }

[[nodiscard]] inline Instruction inst() const { return m_inst; }
[[nodiscard]] Instruction inst() const { return m_inst; }

[[nodiscard]] inline uint16_t primaryArg() const { return m_primary_arg; }
[[nodiscard]] uint16_t primaryArg() const { return m_primary_arg; }

[[nodiscard]] inline uint16_t secondaryArg() const { return m_secondary_arg; }
[[nodiscard]] uint16_t secondaryArg() const { return m_secondary_arg; }

[[nodiscard]] inline uint16_t tertiaryArg() const { return m_tertiary_arg; }
[[nodiscard]] uint16_t tertiaryArg() const { return m_tertiary_arg; }

void setSourceLocation(const std::string& filename, std::size_t line);

[[nodiscard]] inline bool hasValidSourceLocation() const { return !m_source_file.empty(); }
[[nodiscard]] bool hasValidSourceLocation() const { return !m_source_file.empty(); }

[[nodiscard]] inline const std::string& filename() const { return m_source_file; }
[[nodiscard]] const std::string& filename() const { return m_source_file; }

[[nodiscard]] inline std::size_t sourceLine() const { return m_source_line; }
[[nodiscard]] std::size_t sourceLine() const { return m_source_line; }

private:
Kind m_kind;
Expand Down
2 changes: 1 addition & 1 deletion include/Ark/State.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ namespace Ark
* @param ip instruction pointer
* @return uint8_t instruction
*/
[[nodiscard]] inline constexpr uint8_t inst(const std::size_t pp, const std::size_t ip) const noexcept
[[nodiscard]] ARK_ALWAYS_INLINE constexpr uint8_t inst(const std::size_t pp, const std::size_t ip) const noexcept
{
return m_code[pp * m_max_page_size + ip];
}
Expand Down
10 changes: 9 additions & 1 deletion include/Ark/Utils/Platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
# define ARK_OS_LINUX
#endif

#if defined(__GNUC__) || defined(__clang__)
# define ARK_ALWAYS_INLINE __attribute__((always_inline))
#elif defined(_MSC_VER) && !defined(__clang__)
# define ARK_ALWAYS_INLINE __forceinline
#else
# define ARK_ALWAYS_INLINE
#endif

#ifndef ARK_STATIC
# ifdef ARK_OS_WINDOWS
// Windows compilers need specific (and different) keywords for export and import
Expand All @@ -36,7 +44,7 @@
// the same keyword is used for both importing and exporting
# define ARK_API __attribute__((__visibility__("default")))
# else
// GCC < 4 has no mechanism to explicitely hide symbols, everything's exported
// GCC < 4 has no mechanism to explicitly hide symbols, everything's exported
# define ARK_API
# endif
# endif
Expand Down
4 changes: 2 additions & 2 deletions include/Ark/VM/Debugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ namespace Ark::internal

void registerInstruction(uint32_t word) noexcept;

[[nodiscard]] inline bool isRunning() const noexcept
[[nodiscard]] ARK_ALWAYS_INLINE bool isRunning() const noexcept
{
return m_running;
}

[[nodiscard]] inline bool shouldQuitVM() const noexcept
[[nodiscard]] ARK_ALWAYS_INLINE bool shouldQuitVM() const noexcept
{
return m_quit_vm;
}
Expand Down
12 changes: 6 additions & 6 deletions include/Ark/VM/Helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Ark::helper
{
using namespace internal;

inline Value tail(Value* a)
inline ARK_ALWAYS_INLINE Value tail(Value* a)
{
if (a->valueType() == ValueType::List)
{
Expand Down Expand Up @@ -49,7 +49,7 @@ namespace Ark::helper
{ *a });
}

inline Value head(Value* a)
inline ARK_ALWAYS_INLINE Value head(Value* a)
{
if (a->valueType() == ValueType::List)
{
Expand All @@ -71,7 +71,7 @@ namespace Ark::helper
{ *a });
}

inline Value at(Value& container, Value& index, VM& vm)
inline ARK_ALWAYS_INLINE Value at(Value& container, Value& index, VM& vm)
{
if (index.valueType() != ValueType::Number)
throw types::TypeCheckingError(
Expand Down Expand Up @@ -110,7 +110,7 @@ namespace Ark::helper
{ container, index });
}

inline Value atAt(const Value* x, const Value* y, Value& list)
inline ARK_ALWAYS_INLINE Value atAt(const Value* x, const Value* y, Value& list)
{
if (y->valueType() != ValueType::Number || x->valueType() != ValueType::Number ||
list.valueType() != ValueType::List)
Expand Down Expand Up @@ -148,7 +148,7 @@ namespace Ark::helper
return Value(std::string(1, list.list()[static_cast<std::size_t>(idx_y)].stringRef()[static_cast<std::size_t>(idx_x)]));
}

inline double doMath(double a, double b, const Instruction op)
inline ARK_ALWAYS_INLINE double doMath(double a, double b, const Instruction op)
{
if (op == ADD)
a += b;
Expand All @@ -166,7 +166,7 @@ namespace Ark::helper
return a;
}

inline std::string mathInstToStr(const Instruction op)
inline ARK_ALWAYS_INLINE std::string mathInstToStr(const Instruction op)
{
if (op == ADD)
return "+";
Expand Down
35 changes: 28 additions & 7 deletions include/Ark/VM/ScopeView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,33 @@ namespace Ark::internal
* @param id The symbol id of the variable
* @param val The value linked to the symbol
*/
void pushBack(uint16_t id, Value&& val) noexcept;
ARK_ALWAYS_INLINE void pushBack(uint16_t id, Value&& val) noexcept
{
if (id < m_min_id)
m_min_id = id;
if (id > m_max_id)
m_max_id = id;

m_storage[m_start + m_size] = std::make_pair(id, std::move(val));
++m_size;
}

/**
* @brief Put a value in the scope
*
* @param id The symbol id of the variable
* @param val The value linked to the symbol
*/
void pushBack(uint16_t id, const Value& val) noexcept;
ARK_ALWAYS_INLINE void pushBack(uint16_t id, const Value& val) noexcept
{
if (id < m_min_id)
m_min_id = id;
if (id > m_max_id)
m_max_id = id;

m_storage[m_start + m_size] = std::make_pair(id, val);
++m_size;
}

/**
* @brief Insert one or more pairs at the beginning of the scope
Expand All @@ -72,7 +90,10 @@ namespace Ark::internal
* @return true On success
* @return false Otherwise
*/
[[nodiscard]] bool maybeHas(uint16_t id) const noexcept;
[[nodiscard]] ARK_ALWAYS_INLINE bool maybeHas(const uint16_t id) const noexcept
{
return m_min_id <= id && id <= m_max_id;
}

/**
* @brief Get a value from its symbol id
Expand Down Expand Up @@ -103,7 +124,7 @@ namespace Ark::internal
*
* @return const pair_t&
*/
[[nodiscard]] inline const pair_t& atPos(const std::size_t i) const noexcept
[[nodiscard]] ARK_ALWAYS_INLINE const pair_t& atPos(const std::size_t i) const noexcept
{
return m_storage[m_start + i];
}
Expand All @@ -113,7 +134,7 @@ namespace Ark::internal
*
* @return const pair_t&
*/
[[nodiscard]] inline pair_t& atPosReverse(const std::size_t i) noexcept
[[nodiscard]] ARK_ALWAYS_INLINE pair_t& atPosReverse(const std::size_t i) noexcept
{
return m_storage[m_start + m_size - 1 - i];
}
Expand All @@ -128,7 +149,7 @@ namespace Ark::internal
*
* @return const std::size_t
*/
[[nodiscard]] inline std::size_t size() const noexcept
[[nodiscard]] ARK_ALWAYS_INLINE std::size_t size() const noexcept
{
return m_size;
}
Expand All @@ -138,7 +159,7 @@ namespace Ark::internal
*
* @return std::size_t
*/
[[nodiscard]] inline std::size_t storageEnd() const noexcept
[[nodiscard]] ARK_ALWAYS_INLINE std::size_t storageEnd() const noexcept
{
return m_start + m_size;
}
Expand Down
Loading
Loading