Skip to content

Bite API

David Khristepher Santos edited this page Apr 14, 2022 · 2 revisions

BiteCompiler

The BiteCompiler is responsible for taking code and compiling it into a BiteProgram that gets executed on the BiteVM.

Compile

BiteProgram Compile( IEnumerable < string > modules )

Compiles a set of modules and returns a BiteProgram.

BiteProgram Compile( IReadOnlyCollection < Module > modules )

Compiles a set of modules encapsulated in a Module class and returns a BiteProgram. This allows you to set the Name and Imports of a module in a way you can control in your code.

CompileStatements

BiteProgram CompileStatements( string statements, SymbolTable symbolTable = null )

Compiles a statement or set of statements into a default module named "MainModule" and returns a BiteProgram. Pass in the SymbolTable of a previous BiteProgram to retain the symbol information.

This is used in the REPL for example, to compile new statements into a program that get executed an existing BiteVM.

CompileExpression

BiteProgram CompileExpression( string expression )

Compiles a single expression into a default module named "MainModule" and returns a BiteProgram.

This is currently only used for unit testing.

BiteProgram

A BiteProgram contains compiled bytecode.

Run

BiteResult Run( Dictionary <string, object> externalObjects = null )

A convenience method that creates a BiteVM, executes the BiteProgram and returns the status of execution and last value on the stack (if any) in a BiteResult.

BiteResult Run( CancellationToken cancellationToken, Dictionary < string, object > externalObjects = null )

A convenience method that creates a BiteVM, executes the BiteProgram and returns the status of execution and last value on the stack (if any) in a BiteResult.

RunAsync

Task < BiteResult > RunAsync( CancellationToken cancellationToken, Dictionary < string, object > externalObjects = null )

BiteVm

void InitVm()
BiteVmInterpretResult Interpret( BiteProgram context )
void RegisterExternalGlobalObject( string varName, object data )
void RegisterCallable( string linkId, IBiteVmCallable callable )
void ResetVm()

Module

IBiteVmCallable