Sen API
Sen Libraries
Loading...
Searching...
No Matches
vm.h File Reference
#include "sen/core/base/numbers.h"
#include "sen/core/base/result.h"
#include "sen/core/base/span.h"
#include "sen/core/base/static_vector.h"
#include "sen/core/lang/stl_statement.h"
#include <cstdint>
#include <functional>
#include <stack>
#include <string>
#include <variant>
#include <vector>

Go to the source code of this file.

Classes

struct  sen::lang::VariantAccessError
 Represents a variant that could not be accessed. More...
class  sen::lang::Chunk
 A chunk of byte code. It holds code and constants needed by the code. Constants are accessed by index. More...
class  sen::lang::VM
 Virtual machine for executing Sen byte code. More...
struct  sen::lang::VM::CompileError
 Compilation failure report. More...
struct  sen::lang::VM::RuntimeError
 Runtime error report. More...

Namespaces

namespace  sen
namespace  sen::lang

Typedefs

using sen::lang::Value
 A value that can be in the stack.
using sen::lang::ValueGetter = std::function<Value()>
 Gets a value from some source.
using sen::lang::Environment = Span<ValueGetter>
 The environment is an indexed list of value getter functions.

Enumerations

enum  sen::lang::OpCode : uint8_t {
  sen::lang::opReturn = 0 , sen::lang::opConstant = 1 , sen::lang::opNegate = 2 , sen::lang::opAdd = 3 ,
  sen::lang::opSub = 4 , sen::lang::opMul = 5 , sen::lang::opDiv = 6 , sen::lang::opEqual = 7 ,
  sen::lang::opNotEqual = 8 , sen::lang::opGreaterThan = 9 , sen::lang::opGreaterOrEqualThan = 10 , sen::lang::opLowerThan = 11 ,
  sen::lang::opLowerOrEqualThan = 12 , sen::lang::opAnd = 13 , sen::lang::opOr = 14 , sen::lang::opJumpIfTrue = 15 ,
  sen::lang::opJumpIfFalse = 16 , sen::lang::opFetchVariable = 17 , sen::lang::opBetween = 18
}
 Instructions that can be executed by the virtual machine. More...

Functions

template<typename T>
sen::lang::extract (const Value &value)
 Get T out of the value variant.
template<typename T>
bool sen::lang::holds (const Value &value) noexcept
 True if the variant holds T.

Variables

constexpr std::size_t sen::lang::stackMax = 256U

Class Documentation

◆ sen::lang::VM::CompileError

struct sen::lang::VM::CompileError

Compilation failure report.

Class Members
string what

◆ sen::lang::VM::RuntimeError

struct sen::lang::VM::RuntimeError

Runtime error report.

Class Members
string what