Bicameral Engine
GPU-resident engine for a magic-research open-world game
Loading...
Searching...
No Matches
bicameral::script Namespace Reference

Namespaces

namespace  anonymous_namespace{luau_package.cpp}
namespace  anonymous_namespace{luau_sandbox.cpp}
namespace  anonymous_namespace{luau_type_check.cpp}
namespace  anonymous_namespace{reaction_hot_reload.cpp}
namespace  anonymous_namespace{reaction_package.cpp}
namespace  anonymous_namespace{reaction_table_loader.cpp}
namespace  anonymous_namespace{script_value.cpp}

Classes

struct  PackageSource
struct  PackageLoadOptions
struct  PackageRejection
struct  TableOverride
struct  TableEntry
struct  PackageSetResult
struct  SandboxLimits
struct  ScriptError
struct  ModuleFile
struct  RunOptions
struct  RunResult
class  LuauSandbox
struct  TypeDiagnostic
class  LuauTypeChecker
struct  HotReloadResult
class  ReactionTableHotReload
struct  DecimalNumber
struct  ReactionTableSource
struct  LoadedReactionTable
struct  ScriptValue
struct  ScriptField

Typedefs

using HostFunction = int (*)(lua_State* state)
using ModuleResolver = std::function<std::expected<ModuleFile, std::string>(std::string_view name)>

Enumerations

enum class  MergeMode : uint8_t { AddOnly , OverrideMarked , Override }
enum class  ScriptErrorKind : uint8_t {
  Compile , Runtime , SafepointLimit , Memory ,
  Usage
}
enum class  HotReloadState : uint8_t { Unchanged , Waiting , Reloaded , Failed }

Functions

bool IsValidPackageName (std::string_view name)
std::expected< std::string, std::string > PackageModulePath (std::string_view name)
std::expected< PackageSource, std::string > ReadPackageFolder (const fs::path &folder)
std::expected< std::vector< PackageSource >, std::string > ReadPackageRoot (const fs::path &root)
std::expected< PackageSetResult, std::string > LoadPackages (LuauSandbox &sandbox, std::span< const PackageSource > packages, const PackageLoadOptions &options)
std::string TableBytes (const PackageSetResult &result)
uint64_t TableVersion (const PackageSetResult &result)
std::string FormatDiagnostic (const TypeDiagnostic &diagnostic)
std::string SummarizeDiagnostics (const std::vector< TypeDiagnostic > &diagnostics, size_t maxShown)
fs::path DefaultTypeDefinitionsPath ()
std::expected< std::unique_ptr< LuauTypeChecker >, std::string > CreateTypeCheckerFromFile (const fs::path &definitionsFile)
uint64_t DirectoryFingerprint (const fs::path &root)
std::expected< void, std::string > CheckHotReloadCompatible (const sim::BakedReactionTable &current, const sim::BakedReactionTable &next)
std::expected< DecimalNumber, std::string > ParseDecimal (std::string_view text)
std::expected< ReactionTableDefinition, std::string > ReadReactionTableDefinition (const PackageSetResult &packages)
fs::path DefaultPackageRoot ()
std::expected< LoadedReactionTable, std::string > LoadReactionTable (const ReactionTableSource &source)
bool KeyLess (const ScriptValue &left, const ScriptValue &right)
void AppendCanonicalString (std::string_view text, std::string &out)
void AppendCanonicalBytes (const ScriptValue &value, std::string &out)
uint64_t HashBytes (std::string_view bytes)
std::string ToDebugText (const ScriptValue &value)

Variables

constexpr int64_t PACKAGE_FORMAT_VERSION = 1
constexpr std::string_view MANIFEST_TYPE_NAME = "PackageManifest"
constexpr std::string_view ENTRY_TYPE_NAME = "PackageEntry"
constexpr std::string_view REACTION_ELEMENTS_CATEGORY = "elements"
constexpr std::string_view REACTION_SPECIES_CATEGORY = "species"
constexpr std::string_view REACTION_RULES_CATEGORY = "reactions"
constexpr std::string_view DEFAULT_BASE_PACKAGE = "combustion_test"

Typedef Documentation

◆ HostFunction

using bicameral::script::HostFunction = int (*)(lua_State* state)

Definition at line 31 of file luau_sandbox.h.

◆ ModuleResolver

using bicameral::script::ModuleResolver = std::function<std::expected<ModuleFile, std::string>(std::string_view name)>

Definition at line 66 of file luau_sandbox.h.

Enumeration Type Documentation

◆ HotReloadState

enum class bicameral::script::HotReloadState : uint8_t
strong
Enumerator
Unchanged 
Waiting 
Reloaded 
Failed 

Definition at line 32 of file reaction_hot_reload.h.

◆ MergeMode

enum class bicameral::script::MergeMode : uint8_t
strong
Enumerator
AddOnly 
OverrideMarked 
Override 

Definition at line 40 of file luau_package.h.

◆ ScriptErrorKind

enum class bicameral::script::ScriptErrorKind : uint8_t
strong
Enumerator
Compile 
Runtime 
SafepointLimit 
Memory 
Usage 

Definition at line 46 of file luau_sandbox.h.

Function Documentation

◆ AppendCanonicalBytes()

void bicameral::script::AppendCanonicalBytes ( const ScriptValue & value,
std::string & out )

Definition at line 89 of file script_value.cpp.

References AppendCanonicalBytes(), AppendCanonicalString(), bicameral::script::ScriptValue::Boolean, bicameral::script::ScriptValue::boolean, bicameral::script::ScriptValue::fields, bicameral::script::ScriptField::key, bicameral::script::ScriptValue::kind, bicameral::script::ScriptValue::Nil, bicameral::script::ScriptValue::Number, bicameral::script::ScriptValue::number, bicameral::script::ScriptValue::String, bicameral::script::ScriptValue::Table, bicameral::script::ScriptValue::text, and bicameral::script::ScriptField::value.

Referenced by AppendCanonicalBytes(), and TableBytes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AppendCanonicalString()

void bicameral::script::AppendCanonicalString ( std::string_view text,
std::string & out )

Definition at line 84 of file script_value.cpp.

Referenced by AppendCanonicalBytes(), and TableBytes().

Here is the caller graph for this function:

◆ CheckHotReloadCompatible()

std::expected< void, std::string > bicameral::script::CheckHotReloadCompatible ( const sim::BakedReactionTable & current,
const sim::BakedReactionTable & next )
nodiscard

Definition at line 92 of file reaction_hot_reload.cpp.

References bicameral::sim::BakedReactionTable::elementNames, bicameral::sim::BakedReactionTable::speciesElements, and bicameral::sim::BakedReactionTable::speciesNames.

Referenced by bicameral::script::ReactionTableHotReload::Reload().

Here is the caller graph for this function:

◆ CreateTypeCheckerFromFile()

std::expected< std::unique_ptr< LuauTypeChecker >, std::string > bicameral::script::CreateTypeCheckerFromFile ( const fs::path & definitionsFile)
nodiscard

Definition at line 555 of file luau_type_check.cpp.

References bicameral::script::LuauTypeChecker::Create().

Referenced by bicameral::script::anonymous_namespace{reaction_table_loader.cpp}::LoadPackageSet().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefaultPackageRoot()

fs::path bicameral::script::DefaultPackageRoot ( )
nodiscard

Definition at line 61 of file reaction_table_loader.cpp.

References bicameral::ExecutableDirectory().

Referenced by bicameral::script::ReactionTableHotReload::Fingerprint(), and LoadReactionTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefaultTypeDefinitionsPath()

fs::path bicameral::script::DefaultTypeDefinitionsPath ( )
nodiscard

Definition at line 551 of file luau_type_check.cpp.

References bicameral::ExecutableDirectory().

Referenced by bicameral::script::ReactionTableHotReload::Fingerprint(), and bicameral::script::anonymous_namespace{reaction_table_loader.cpp}::LoadPackageSet().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DirectoryFingerprint()

uint64_t bicameral::script::DirectoryFingerprint ( const fs::path & root)
nodiscard

Definition at line 62 of file reaction_hot_reload.cpp.

Referenced by bicameral::script::ReactionTableHotReload::Fingerprint().

Here is the caller graph for this function:

◆ FormatDiagnostic()

std::string bicameral::script::FormatDiagnostic ( const TypeDiagnostic & diagnostic)
nodiscard

Definition at line 530 of file luau_type_check.cpp.

References bicameral::script::TypeDiagnostic::column, bicameral::script::TypeDiagnostic::file, bicameral::script::TypeDiagnostic::kind, bicameral::script::TypeDiagnostic::line, and bicameral::script::TypeDiagnostic::message.

Referenced by SummarizeDiagnostics().

Here is the caller graph for this function:

◆ HashBytes()

uint64_t bicameral::script::HashBytes ( std::string_view bytes)
nodiscard

Definition at line 107 of file script_value.cpp.

Referenced by TableVersion().

Here is the caller graph for this function:

◆ IsValidPackageName()

bool bicameral::script::IsValidPackageName ( std::string_view name)
nodiscard

Definition at line 361 of file luau_package.cpp.

Referenced by LoadPackages(), bicameral::script::anonymous_namespace{luau_package.cpp}::ModulePath(), bicameral::script::anonymous_namespace{luau_package.cpp}::ReadContribution(), and bicameral::script::anonymous_namespace{luau_package.cpp}::ReadNameList().

Here is the caller graph for this function:

◆ KeyLess()

bool bicameral::script::KeyLess ( const ScriptValue & left,
const ScriptValue & right )
nodiscard

Definition at line 73 of file script_value.cpp.

References bicameral::script::ScriptValue::kind, bicameral::script::ScriptValue::Number, bicameral::script::ScriptValue::number, and bicameral::script::ScriptValue::text.

Referenced by bicameral::script::ScriptValue::MakeTable().

Here is the caller graph for this function:

◆ LoadPackages()

std::expected< PackageSetResult, std::string > bicameral::script::LoadPackages ( LuauSandbox & sandbox,
std::span< const PackageSource > packages,
const PackageLoadOptions & options )
nodiscard

Definition at line 433 of file luau_package.cpp.

References bicameral::script::LuauTypeChecker::CheckManifest(), bicameral::script::LuauSandbox::IsSealed(), IsValidPackageName(), bicameral::script::PackageSetResult::loadOrder, bicameral::script::PackageSetResult::rejected, and bicameral::script::PackageLoadOptions::typeChecker.

Referenced by bicameral::script::anonymous_namespace{reaction_table_loader.cpp}::LoadPackageSet().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadReactionTable()

std::expected< LoadedReactionTable, std::string > bicameral::script::LoadReactionTable ( const ReactionTableSource & source)
nodiscard

Definition at line 65 of file reaction_table_loader.cpp.

References bicameral::sim::BakeReactionTable(), bicameral::script::ReactionTableSource::basePackage, DefaultPackageRoot(), bicameral::script::ReactionTableSource::packageRoot, ReadPackageRoot(), ReadReactionTableDefinition(), and TableVersion().

Referenced by bicameral::frame::anonymous_namespace{frame_loop.cpp}::LoadWorldReactionTable(), and bicameral::script::ReactionTableHotReload::Reload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PackageModulePath()

std::expected< std::string, std::string > bicameral::script::PackageModulePath ( std::string_view name)
nodiscard

Definition at line 373 of file luau_package.cpp.

Referenced by bicameral::script::LuauTypeChecker::CheckPackage(), and bicameral::script::anonymous_namespace{luau_type_check.cpp}::PackageFileResolver::resolveModule().

Here is the caller graph for this function:

◆ ParseDecimal()

std::expected< DecimalNumber, std::string > bicameral::script::ParseDecimal ( std::string_view text)
nodiscard

Definition at line 383 of file reaction_package.cpp.

Referenced by bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadPreExponential().

Here is the caller graph for this function:

◆ ReadPackageFolder()

std::expected< PackageSource, std::string > bicameral::script::ReadPackageFolder ( const fs::path & folder)
nodiscard

◆ ReadPackageRoot()

std::expected< std::vector< PackageSource >, std::string > bicameral::script::ReadPackageRoot ( const fs::path & root)
nodiscard

Definition at line 405 of file luau_package.cpp.

Referenced by LoadReactionTable().

Here is the caller graph for this function:

◆ ReadReactionTableDefinition()

std::expected< sim::ReactionTableDefinition, std::string > bicameral::script::ReadReactionTableDefinition ( const PackageSetResult & packages)
nodiscard

◆ SummarizeDiagnostics()

std::string bicameral::script::SummarizeDiagnostics ( const std::vector< TypeDiagnostic > & diagnostics,
size_t maxShown )
nodiscard

Definition at line 535 of file luau_type_check.cpp.

References FormatDiagnostic().

Referenced by bicameral::script::anonymous_namespace{luau_package.cpp}::TypeCheckReason().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TableBytes()

std::string bicameral::script::TableBytes ( const PackageSetResult & result)
nodiscard

Definition at line 491 of file luau_package.cpp.

References AppendCanonicalBytes(), AppendCanonicalString(), PACKAGE_FORMAT_VERSION, and bicameral::script::PackageSetResult::tables.

Referenced by TableVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TableVersion()

uint64_t bicameral::script::TableVersion ( const PackageSetResult & result)
nodiscard

Definition at line 508 of file luau_package.cpp.

References HashBytes(), and TableBytes().

Referenced by LoadReactionTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToDebugText()

Variable Documentation

◆ DEFAULT_BASE_PACKAGE

std::string_view bicameral::script::DEFAULT_BASE_PACKAGE = "combustion_test"
constexpr

Definition at line 25 of file reaction_table_loader.h.

◆ ENTRY_TYPE_NAME

std::string_view bicameral::script::ENTRY_TYPE_NAME = "PackageEntry"
constexpr

◆ MANIFEST_TYPE_NAME

std::string_view bicameral::script::MANIFEST_TYPE_NAME = "PackageManifest"
constexpr

◆ PACKAGE_FORMAT_VERSION

int64_t bicameral::script::PACKAGE_FORMAT_VERSION = 1
constexpr

◆ REACTION_ELEMENTS_CATEGORY

std::string_view bicameral::script::REACTION_ELEMENTS_CATEGORY = "elements"
constexpr

Definition at line 33 of file reaction_package.h.

Referenced by ReadReactionTableDefinition().

◆ REACTION_RULES_CATEGORY

std::string_view bicameral::script::REACTION_RULES_CATEGORY = "reactions"
constexpr

Definition at line 35 of file reaction_package.h.

Referenced by ReadReactionTableDefinition().

◆ REACTION_SPECIES_CATEGORY

std::string_view bicameral::script::REACTION_SPECIES_CATEGORY = "species"
constexpr

Definition at line 34 of file reaction_package.h.

Referenced by ReadReactionTableDefinition().