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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
- `PUSH_RETURN_ADDRESS` instruction now replaces the VM auto push of IP/PP
- remove the stack swapping by pushing arguments in the reverse order by which they are loaded
- wasm export: we can now run ArkScript code on the web!
- `GET_CURRENT_PAGE_ADDRESS` instruction to push the current page address to the stack
- `CALL_CURRENT_PAGE` super instruction, calling the current page with a given number of arguments (avoid loading a page address on the stack, then popping it to perform the call)

### Changed
- instructions are on 4 bytes: 1 byte for the instruction, 1 byte of padding, 2 bytes for an immediate argument
Expand Down Expand Up @@ -141,6 +143,7 @@
- `io:removeFiles` is now `io:removeFile` and works on a single file/path
- renamed almost all builtins to prefix them with `builtin__`, to have them proxied in the standard library (to be able to import and scope them properly)
- new super instruction `CALL_BUILTIN_WITHOUT_RETURN_ADDRESS` to optimize the proxied builtins, skipping the return address deletion
- the VM no longer store a reference to the current function being called in the newly created scope

### Removed
- removed unused `NodeType::Closure`
Expand Down
25 changes: 23 additions & 2 deletions include/Ark/Compiler/AST/Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ namespace Ark::internal
*/
[[nodiscard]] bool isStringLike() const noexcept;

/**
* @brief Check if the node is a function
* @return true if the node is a function declaration
* @return false
*/
[[nodiscard]] bool isFunction() const noexcept;

/**
* @brief Copy a node to the current one, while keeping the filename and position in the file
*
Expand Down Expand Up @@ -174,6 +181,19 @@ namespace Ark::internal
*/
void setAltSyntax(bool toggle);

/**
* @brief Set the m_is_anonymous_function flag on the node
* @param anonymous true to mark the node as an anonymous function
*/
void setFunctionKind(bool anonymous);

/**
* @brief Check if a node is an anonymous function
* @return true if the node is of an anonymous function
* @return false
*/
[[nodiscard]] bool isAnonymousFunction() const noexcept;

/**
* @brief Check if a node is alt syntax
* @return bool
Expand Down Expand Up @@ -236,8 +256,9 @@ namespace Ark::internal
std::size_t m_line = 0, m_col = 0;
std::string m_filename;
std::string m_comment;
std::string m_after_comment; ///< Comment after node
bool m_alt_syntax = false; ///< Used to tell if a node uses the alternative syntax (if available), eg (begin) / {}, (list) / []
std::string m_after_comment; ///< Comment after node
bool m_alt_syntax = false; ///< Used to tell if a node uses the alternative syntax (if available), eg (begin) / {}, (list) / []
bool m_is_anonymous_function = true; ///< Function nodes are marked as anonymous/non-anonymous by the ASTLowerer, to enable some optimisations
};

const Node& getTrueNode();
Expand Down
Loading
Loading