GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
gd::ExpressionCodeGenerator Class Reference

Generate code for a parsed expression. More...

#include <ExpressionCodeGenerator.h>

Inherits gd::ExpressionParser2NodeWorker.

Public Member Functions

 ExpressionCodeGenerator (const gd::String &rootType_, const gd::String &rootObjectName_, EventsCodeGenerator &codeGenerator_, EventsCodeGenerationContext &context_)
 
const gd::StringGetOutput ()
 

Static Public Member Functions

static gd::String GenerateExpressionCode (EventsCodeGenerator &codeGenerator, EventsCodeGenerationContext &context, const gd::String &type, const gd::Expression &expression, const gd::String &objectName="", const gd::String &extraInfo="")
 

Protected Member Functions

void OnVisitSubExpressionNode (SubExpressionNode &node) override
 
void OnVisitOperatorNode (OperatorNode &node) override
 
void OnVisitUnaryOperatorNode (UnaryOperatorNode &node) override
 
void OnVisitNumberNode (NumberNode &node) override
 
void OnVisitTextNode (TextNode &node) override
 
void OnVisitVariableNode (VariableNode &node) override
 
void OnVisitVariableAccessorNode (VariableAccessorNode &node) override
 
void OnVisitVariableBracketAccessorNode (VariableBracketAccessorNode &node) override
 
void OnVisitIdentifierNode (IdentifierNode &node) override
 
void OnVisitObjectFunctionNameNode (ObjectFunctionNameNode &node) override
 
void OnVisitFunctionCallNode (FunctionCallNode &node) override
 
void OnVisitEmptyNode (EmptyNode &node) override
 

Detailed Description

Generate code for a parsed expression.

Almost all code generation is dedicated to the gd::EventsCodeGenerator, so that it can be adapted to the target.

See also
gd::ExpressionParser2

Member Function Documentation

◆ GenerateExpressionCode()

gd::String gd::ExpressionCodeGenerator::GenerateExpressionCode ( EventsCodeGenerator codeGenerator,
EventsCodeGenerationContext context,
const gd::String type,
const gd::Expression expression,
const gd::String objectName = "",
const gd::String extraInfo = "" 
)
static

Helper to generate the code for an expression. If expression is invalid, a default generated value is returned (0 for number expression, empty string for strings).

Parameters
codeGeneratorThe code generator to use to output code.
contextThe context of the code generation.
typeThe type of the expression (see gd::ExpressionParser2).
expressionThe expression to parse and generate code for.
objectThe object the expression refers too (only for "objectvar" type).
See also
see gd::ExpressionParser2

The documentation for this class was generated from the following files: