GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 (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::String &expression, const gd::String &objectName="")

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 OnVisitFunctionNode (FunctionNode &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

Member Function Documentation

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

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).

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: