JUCE  v5.2.0-514-g49784a029
JUCE API
juce::littlefoot::Compiler Struct Reference

This class compiles littlefoot source code into a littlefoot::Program object which can be executed by a littlefoot::Runner. More...

#include <juce_blocks_basics.h>

Collaboration diagram for juce::littlefoot::Compiler:

Classes

struct  AllocatedObject
 
struct  ArraySubscript
 
struct  Assignment
 
struct  BinaryOperator
 
struct  BlockStatement
 
struct  BreakStatement
 
struct  CodeGenerator
 
struct  CodeLocation
 
struct  ContinueStatement
 
struct  Expression
 
struct  Function
 
struct  FunctionCall
 
struct  Identifier
 
struct  IfStatement
 
struct  LiteralValue
 
struct  LoopStatement
 
struct  ReturnStatement
 
struct  Statement
 
struct  SyntaxTreeBuilder
 
struct  TernaryOp
 
struct  Token
 
struct  TokenIterator
 
struct  UnaryOp
 
struct  Variable
 

Public Member Functions

 Compiler ()=default
 
void addNativeFunctions (const char *const *functionPrototypes)
 Gives the compiler a zero-terminated list of native function prototypes to use when parsing function calls. More...
 
template<typename RunnerType >
void addNativeFunctions (const RunnerType &runner)
 Tells the compiler to use the list of native function prototypes from this littlefoot::Runner object. More...
 
Result compile (const String &sourceCode, uint32 defaultHeapSize)
 Compiles a littlefoot program. More...
 
Program getCompiledProgram () const noexcept
 After a successful compilation, this returns the finished Program. More...
 

Public Attributes

Array< uint8compiledObjectCode
 After a successful call to compile(), this contains the bytecode generated. More...
 

Private Types

using BlockPtr = BlockStatement *
 
using ExpPtr = Expression *
 
using StatementPtr = Statement *
 
using TokenType = const char *
 

Static Private Member Functions

static FunctionID createFunctionID (String name, Type returnType, const Array< Type > &types)
 
static Array< TypegetArgTypesFromFunctionName (const char *nameAndTypes)
 
static String getTokenDescription (TokenType t)
 
static String getTypeName (Type t) noexcept
 
static Type getTypeOfVar (const var &v) noexcept
 
static Type tokenToType (TokenType t) noexcept
 

Private Attributes

Array< NativeFunctionnativeFunctions
 

Detailed Description

This class compiles littlefoot source code into a littlefoot::Program object which can be executed by a littlefoot::Runner.

Member Typedef Documentation

◆ BlockPtr

◆ ExpPtr

◆ StatementPtr

◆ TokenType

using juce::littlefoot::Compiler::TokenType = const char*
private

Constructor & Destructor Documentation

◆ Compiler()

juce::littlefoot::Compiler::Compiler ( )
default

Member Function Documentation

◆ addNativeFunctions() [1/2]

void juce::littlefoot::Compiler::addNativeFunctions ( const char *const *  functionPrototypes)
inline

Gives the compiler a zero-terminated list of native function prototypes to use when parsing function calls.

◆ addNativeFunctions() [2/2]

template<typename RunnerType >
void juce::littlefoot::Compiler::addNativeFunctions ( const RunnerType &  runner)
inline

Tells the compiler to use the list of native function prototypes from this littlefoot::Runner object.

◆ compile()

Result juce::littlefoot::Compiler::compile ( const String sourceCode,
uint32  defaultHeapSize 
)
inline

Compiles a littlefoot program.

If there's an error, this returns it, otherwise the compiled bytecode is placed in the compiledObjectCode member.

◆ createFunctionID()

static FunctionID juce::littlefoot::Compiler::createFunctionID ( String  name,
Type  returnType,
const Array< Type > &  types 
)
inlinestaticprivate

◆ getArgTypesFromFunctionName()

static Array<Type> juce::littlefoot::Compiler::getArgTypesFromFunctionName ( const char *  nameAndTypes)
inlinestaticprivate

◆ getCompiledProgram()

Program juce::littlefoot::Compiler::getCompiledProgram ( ) const
inlinenoexcept

After a successful compilation, this returns the finished Program.

◆ getTokenDescription()

static String juce::littlefoot::Compiler::getTokenDescription ( TokenType  t)
inlinestaticprivate

◆ getTypeName()

static String juce::littlefoot::Compiler::getTypeName ( Type  t)
inlinestaticprivatenoexcept

◆ getTypeOfVar()

static Type juce::littlefoot::Compiler::getTypeOfVar ( const var v)
inlinestaticprivatenoexcept

◆ tokenToType()

static Type juce::littlefoot::Compiler::tokenToType ( TokenType  t)
inlinestaticprivatenoexcept

Member Data Documentation

◆ compiledObjectCode

Array<uint8> juce::littlefoot::Compiler::compiledObjectCode

After a successful call to compile(), this contains the bytecode generated.

A littlefoot::Program object can be created directly from this array.

◆ nativeFunctions

Array<NativeFunction> juce::littlefoot::Compiler::nativeFunctions
private

The documentation for this struct was generated from the following file: