ArkScript
A small, fast, functional and scripting language for video games
Ark::internal Namespace Reference

Namespaces

namespace  Builtins
 
namespace  IR
 
namespace  Language
 

Classes

class  BaseParser
 
struct  CharPred
 
class  Closure
 Closure management. More...
 
class  Compiler
 The ArkScript bytecode compiler. More...
 
class  ConditionalExecutor
 Handles Conditional macros. More...
 
struct  Declaration
 
struct  EntityWithOffset
 
struct  ExecutionContext
 
struct  FilePosition
 Describe a position in a given file ; handled by the BaseParser. More...
 
class  FunctionExecutor
 Handles function macros. More...
 
class  Future
 
struct  Import
 
class  ImportSolver
 
class  IRCompiler
 
class  IROptimizer
 
struct  IsAlnum
 
struct  IsAlpha
 
struct  IsChar
 
struct  IsDigit
 
struct  IsEither
 
struct  IsHex
 
struct  IsInlineSpace
 
struct  IsNot
 
struct  IsSpace
 
struct  IsSymbol
 
class  Logger
 
class  MacroExecutor
 A class that applies macros in a Node. More...
 
class  MacroProcessor
 The class handling the macros definitions and calls, given an AST. More...
 
class  MacroScope
 
class  NameResolutionPass
 
struct  Namespace
 
class  NamespaceScope
 
class  Node
 A node of an Abstract Syntax Tree for ArkScript. More...
 
class  Optimizer
 The ArkScript AST optimizer. More...
 
struct  Package
 
class  Parser
 
class  Pass
 An interface to describe compiler passes. More...
 
class  Scope
 A class to handle the VM scope more efficiently. More...
 
class  ScopeResolver
 
class  SharedLibrary
 Handling a shared library as an ArkScript plugin. More...
 
class  StaticScope
 
class  SymbolExecutor
 Handles Symbol macros. More...
 
struct  type_uid
 
struct  type_uid_impl
 
class  utf8_char_t
 
struct  ValTableElem
 A Compiler Value class helper to handle multiple types. More...
 
struct  Word
 

Typedefs

using PageAddr_t = uint16_t
 

Enumerations

enum class  NodeType {
  Symbol , Capture , Keyword , String ,
  Number , List , Spread , Field ,
  Macro , Namespace , Unused
}
 The different node types available. More...
 
enum class  Keyword {
  Fun , Let , Mut , Set ,
  If , While , Begin , Import ,
  Del
}
 The different keywords available. More...
 
enum  Instruction : uint8_t {
  NOP = 0x00 , SYM_TABLE_START = 0x01 , VAL_TABLE_START = 0x02 , NUMBER_TYPE = 0x01 ,
  STRING_TYPE = 0x02 , FUNC_TYPE = 0x03 , CODE_SEGMENT_START = 0x03 , LOAD_SYMBOL = 0x01 ,
  LOAD_CONST = 0x02 , POP_JUMP_IF_TRUE = 0x03 , STORE = 0x04 , SET_VAL = 0x05 ,
  POP_JUMP_IF_FALSE = 0x06 , JUMP = 0x07 , RET = 0x08 , HALT = 0x09 ,
  CALL = 0x0a , CAPTURE = 0x0b , BUILTIN = 0x0c , DEL = 0x0d ,
  MAKE_CLOSURE = 0x0e , GET_FIELD = 0x0f , PLUGIN = 0x10 , LIST = 0x11 ,
  APPEND = 0x12 , CONCAT = 0x13 , APPEND_IN_PLACE = 0x14 , CONCAT_IN_PLACE = 0x15 ,
  POP_LIST = 0x16 , POP_LIST_IN_PLACE = 0x17 , SET_AT_INDEX = 0x18 , SET_AT_2_INDEX = 0x19 ,
  POP = 0x1a , DUP = 0x1b , CREATE_SCOPE = 0x1c , POP_SCOPE = 0x1d ,
  FIRST_OPERATOR = 0x1e , ADD = 0x1e , SUB = 0x1f , MUL = 0x20 ,
  DIV = 0x21 , GT = 0x22 , LT = 0x23 , LE = 0x24 ,
  GE = 0x25 , NEQ = 0x26 , EQ = 0x27 , LEN = 0x28 ,
  EMPTY = 0x29 , TAIL = 0x2a , HEAD = 0x2b , ISNIL = 0x2c ,
  ASSERT = 0x2d , TO_NUM = 0x2e , TO_STR = 0x2f , AT = 0x30 ,
  AT_AT = 0x31 , MOD = 0x32 , TYPE = 0x33 , HASFIELD = 0x34 ,
  NOT = 0x35 , LOAD_CONST_LOAD_CONST = 0x36 , LOAD_CONST_STORE = 0x37 , LOAD_CONST_SET_VAL = 0x38 ,
  STORE_FROM = 0x39 , SET_VAL_FROM = 0x3a , INCREMENT = 0x3b , DECREMENT = 0x3c ,
  STORE_TAIL = 0x3d , STORE_HEAD = 0x3e , SET_VAL_TAIL = 0x3f , SET_VAL_HEAD = 0x40 ,
  CALL_BUILTIN = 0x41
}
 The different bytecodes are stored here. More...
 
enum class  ValTableElemType { Number , String , PageAddr }
 Enumeration to keep track of the type of a Compiler Value. More...
 
enum class  ErrorKind {
  VM , Module , Scope , Type ,
  Index , Arity , DivisionByZero
}
 

Functions

bool operator== (const Namespace &A, const Namespace &B)
 
bool operator< (const Namespace &, const Namespace &)
 
const NodegetTrueNode ()
 
const NodegetFalseNode ()
 
const NodegetNilNode ()
 
const NodegetListNode ()
 
std::string typeToString (const Node &node) noexcept
 
bool operator< (const Closure &A, const Closure &B)
 
long countOpenEnclosures (const std::string &line, char open, char close)
 Count the open enclosure and its counterpart: (), {}, [].
 
void trimWhitespace (std::string &line)
 Remove whitespaces at the start and end of a string.
 
replxx::Replxx::completions_t hookCompletion (const std::vector< std::string > &words, const std::string &context, int &length)
 
void hookColor (const std::vector< std::pair< std::string, replxx::Replxx::Color > > &words_colors, const std::string &context, replxx::Replxx::colors_t &colors)
 
replxx::Replxx::hints_t hookHint (const std::vector< std::string > &words, const std::string &context, int &length, replxx::Replxx::Color &color)
 
bool operator== (const Node &A, const Node &B)
 
bool operator< (const Node &A, const Node &B)
 
std::optional< std::filesystem::path > testExtensions (const std::filesystem::path &folder, const std::string &package_path)
 
bool operator== (const Scope &A, const Scope &B)
 
bool operator== (const Closure &A, const Closure &B)
 
std::size_t codepointLength (const std::string &str)
 
std::size_t contextLen (const std::string &prefix)
 

Variables

Ark::internal::IsSpace IsSpace
 
Ark::internal::IsInlineSpace IsInlineSpace
 
Ark::internal::IsDigit IsDigit
 
Ark::internal::IsHex IsHex
 
Ark::internal::IsAlpha IsAlpha
 
Ark::internal::IsAlnum IsAlnum
 
Ark::internal::IsSymbol IsSymbol
 
const IsChar IsMinus ('-')
 
constexpr std::array< std::string_view, 11 > nodeTypes
 Node types as string, in the same order as the enum NodeType.
 
constexpr std::array< std::string_view, 9 > keywords
 List of available keywords in ArkScript.
 
constexpr std::array InstructionNames
 
constexpr std::array< std::string_view, 7 > errorKinds
 
constexpr std::array colors
 

Typedef Documentation

◆ PageAddr_t

using Ark::internal::PageAddr_t = uint16_t

Definition at line 30 of file Closure.hpp.

Enumeration Type Documentation

◆ ErrorKind

enum class Ark::internal::ErrorKind
strong
Enumerator
VM 
Module 
Scope 
Type 
Index 
Arity 
DivisionByZero 

Definition at line 9 of file ErrorKind.hpp.

◆ Instruction

The different bytecodes are stored here.

Adding an operator
It must be referenced as well under include/Ark/Compiler/Common.hpp, in the operators table. The order of the operators below FIRST_OPERATOR must be the same as the one in the operators table from the aforementioned file.
Enumerator
NOP 
SYM_TABLE_START 
VAL_TABLE_START 
NUMBER_TYPE 
STRING_TYPE 
FUNC_TYPE 
CODE_SEGMENT_START 
LOAD_SYMBOL 
LOAD_CONST 
POP_JUMP_IF_TRUE 
STORE 
SET_VAL 
POP_JUMP_IF_FALSE 
JUMP 
RET 
HALT 
CALL 
CAPTURE 
BUILTIN 
DEL 
MAKE_CLOSURE 
GET_FIELD 
PLUGIN 
LIST 
APPEND 
CONCAT 
APPEND_IN_PLACE 
CONCAT_IN_PLACE 
POP_LIST 
POP_LIST_IN_PLACE 
SET_AT_INDEX 
SET_AT_2_INDEX 
POP 
DUP 
CREATE_SCOPE 
POP_SCOPE 
FIRST_OPERATOR 
ADD 
SUB 
MUL 
DIV 
GT 
LT 
LE 
GE 
NEQ 
EQ 
LEN 
EMPTY 
TAIL 
HEAD 
ISNIL 
ASSERT 
TO_NUM 
TO_STR 
AT 
AT_AT 
MOD 
TYPE 
HASFIELD 
NOT 
LOAD_CONST_LOAD_CONST 
LOAD_CONST_STORE 
LOAD_CONST_SET_VAL 
STORE_FROM 
SET_VAL_FROM 
INCREMENT 
DECREMENT 
STORE_TAIL 
STORE_HEAD 
SET_VAL_TAIL 
SET_VAL_HEAD 
CALL_BUILTIN 

Definition at line 27 of file Instructions.hpp.

◆ Keyword

enum class Ark::internal::Keyword
strong

The different keywords available.

Enumerator
Fun 
Let 
Mut 
Set 
If 
While 
Begin 
Import 
Del 

Definition at line 59 of file Common.hpp.

◆ NodeType

enum class Ark::internal::NodeType
strong

The different node types available.

Enumerator
Symbol 
Capture 
Keyword 
String 
Number 
List 
Spread 
Field 
Macro 
Namespace 
Unused 

Definition at line 28 of file Common.hpp.

◆ ValTableElemType

Enumeration to keep track of the type of a Compiler Value.

Enumerator
Number 
String 
PageAddr 

Definition at line 26 of file ValTableElem.hpp.

Function Documentation

◆ codepointLength()

std::size_t Ark::internal::codepointLength ( const std::string & str)

Definition at line 23 of file Utils.cpp.

Referenced by hookColor(), hookCompletion(), and hookHint().

◆ contextLen()

std::size_t Ark::internal::contextLen ( const std::string & prefix)

Definition at line 31 of file Utils.cpp.

Referenced by hookCompletion(), and hookHint().

◆ countOpenEnclosures()

long Ark::internal::countOpenEnclosures ( const std::string & line,
char open,
char close )

Count the open enclosure and its counterpart: (), {}, [].

Parameters
linedata to operate on
openthe open char: (, { or [
closethe closing char: ), } or ]
Returns
positive if there are more open enclosures than closed. 0 when both are equal, negative otherwise

Definition at line 8 of file Utils.cpp.

◆ getFalseNode()

const Node & Ark::internal::getFalseNode ( )

Definition at line 314 of file Node.cpp.

References Symbol.

Referenced by Ark::internal::MacroProcessor::evaluate().

◆ getListNode()

const Node & Ark::internal::getListNode ( )

◆ getNilNode()

const Node & Ark::internal::getNilNode ( )

◆ getTrueNode()

const Node & Ark::internal::getTrueNode ( )

Definition at line 308 of file Node.cpp.

References Symbol.

Referenced by Ark::internal::MacroProcessor::evaluate().

◆ hookColor()

void Ark::internal::hookColor ( const std::vector< std::pair< std::string, replxx::Replxx::Color > > & words_colors,
const std::string & context,
replxx::Replxx::colors_t & colors )

Definition at line 73 of file Utils.cpp.

References codepointLength(), and colors.

◆ hookCompletion()

replxx::Replxx::completions_t Ark::internal::hookCompletion ( const std::vector< std::string > & words,
const std::string & context,
int & length )

Definition at line 49 of file Utils.cpp.

References codepointLength(), and contextLen().

◆ hookHint()

replxx::Replxx::hints_t Ark::internal::hookHint ( const std::vector< std::string > & words,
const std::string & context,
int & length,
replxx::Replxx::Color & color )

Definition at line 98 of file Utils.cpp.

References codepointLength(), and contextLen().

◆ operator<() [1/3]

bool Ark::internal::operator< ( const Closure & A,
const Closure & B )
inlinenoexcept

Definition at line 89 of file Closure.hpp.

◆ operator<() [2/3]

bool Ark::internal::operator< ( const Namespace & ,
const Namespace &  )
inline

Definition at line 27 of file Namespace.hpp.

◆ operator<() [3/3]

bool Ark::internal::operator< ( const Node & A,
const Node & B )

Definition at line 342 of file Node.cpp.

◆ operator==() [1/4]

bool Ark::internal::operator== ( const Closure & A,
const Closure & B )
noexcept

Definition at line 45 of file Closure.cpp.

◆ operator==() [2/4]

bool Ark::internal::operator== ( const Namespace & A,
const Namespace & B )
inline

◆ operator==() [3/4]

bool Ark::internal::operator== ( const Node & A,
const Node & B )

Definition at line 332 of file Node.cpp.

◆ operator==() [4/4]

bool Ark::internal::operator== ( const Scope & A,
const Scope & B )
noexcept

Definition at line 84 of file Scope.cpp.

◆ testExtensions()

std::optional< std::filesystem::path > Ark::internal::testExtensions ( const std::filesystem::path & folder,
const std::string & package_path )

Definition at line 183 of file ImportSolver.cpp.

Referenced by Ark::internal::ImportSolver::findFile().

◆ trimWhitespace()

void Ark::internal::trimWhitespace ( std::string & line)

Remove whitespaces at the start and end of a string.

Parameters
linestring modified in place

Definition at line 13 of file Utils.cpp.

◆ typeToString()

std::string Ark::internal::typeToString ( const Node & node)
inlinenoexcept

Variable Documentation

◆ colors

std::array Ark::internal::colors
constexpr
Initial value:
= {
fmt::color::beige,
fmt::color::chartreuse,
fmt::color::coral,
fmt::color::cornflower_blue,
fmt::color::khaki,
fmt::color::dark_olive_green,
fmt::color::dark_orange,
fmt::color::dark_salmon,
fmt::color::fire_brick,
fmt::color::forest_green,
fmt::color::honey_dew,
fmt::color::medium_orchid,
fmt::color::medium_turquoise,
fmt::color::peru,
fmt::color::sea_green,
fmt::color::tomato,
fmt::color::wheat,
fmt::color::sea_shell
}

Definition at line 8 of file Logger.cpp.

Referenced by hookColor(), and Ark::internal::Logger::Logger().

◆ errorKinds

std::array<std::string_view, 7> Ark::internal::errorKinds
constexpr
Initial value:
= {
"VMError",
"ModuleError",
"ScopeError",
"TypeError",
"IndexError",
"ArityError",
"DivisionByZero"
}

Definition at line 20 of file ErrorKind.hpp.

Referenced by Ark::VM::throwVMError().

◆ InstructionNames

std::array Ark::internal::InstructionNames
constexpr

◆ IsAlnum

Ark::internal::IsAlnum Ark::internal::IsAlnum

◆ IsAlpha

Ark::internal::IsAlpha Ark::internal::IsAlpha

◆ IsDigit

Ark::internal::IsDigit Ark::internal::IsDigit

◆ IsHex

Ark::internal::IsHex Ark::internal::IsHex

◆ IsInlineSpace

Ark::internal::IsInlineSpace Ark::internal::IsInlineSpace

◆ IsMinus

const IsChar Ark::internal::IsMinus('-') ( '-' )

◆ IsSpace

Ark::internal::IsSpace Ark::internal::IsSpace

◆ IsSymbol

Ark::internal::IsSymbol Ark::internal::IsSymbol

◆ keywords

std::array<std::string_view, 9> Ark::internal::keywords
constexpr
Initial value:
= {
"fun",
"let",
"mut",
"set",
"if",
"while",
"begin",
"import",
"del"
}

List of available keywords in ArkScript.

Definition at line 73 of file Common.hpp.

Referenced by Formatter::format(), Formatter::formatVariable(), and Ark::internal::Node::repr().

◆ nodeTypes

std::array<std::string_view, 11> Ark::internal::nodeTypes
constexpr
Initial value:
= {
"Symbol",
"Capture",
"Keyword",
"String",
"Number",
"List",
"Spread",
"Field",
"Macro",
"Namespace",
"Unused"
}

Node types as string, in the same order as the enum NodeType.

Definition at line 44 of file Common.hpp.

Referenced by JsonCompiler::_compile(), Ark::internal::Parser::letMutSet(), and typeToString().