MinitScript
0.9.31 PRE-BETA
|
MinitScript transpiler. More...
#include <minitscript/minitscript/Transpiler.h>
Static Public Member Functions | |
static void | transpile (MinitScript *minitScript, const string &transpilationFileName, const vector< string > &minitScriptExtensionFileNames) |
Transpile MinitScript script instance. More... | |
static void | untranspile (const string &scriptFileName, const string &transpilationFileName) |
Untranspile. More... | |
static const string | createSourceCode (MinitScript *minitScript) |
Create source code for whole script. More... | |
Static Private Member Functions | |
static const string | getScriptTypeReadableName (MinitScript::Script::Type type) |
Get script type name. More... | |
static const string | getScriptTypeEnumIdentifier (MinitScript::Script::Type type) |
Get script type enum identifier. More... | |
static const string | createMethodName (MinitScript *minitScript, int scriptIdx) |
Create method name. More... | |
static const string | createShortMethodName (MinitScript *minitScript, int scriptIdx) |
Create short method name. More... | |
static const string | escapeString (const string &str) |
Escape string variable. More... | |
static bool | variableHasStatement (const string &variableStatement) |
Check if variable has access statement. More... | |
static const string | createVariableName (const string &variableStatement) |
Create variable name. More... | |
static const string | createGlobalVariableName (const string &variableStatement) |
Create global variable name. More... | |
static const string | createLocalVariableName (const string &variableStatement) |
Create local variable name. More... | |
static const unordered_set< string > | getAllClassesMethodNames (MinitScript *minitScript) |
Get all classes method names. More... | |
static const vector< string > | getAllClassesMethodNamesSorted (MinitScript *minitScript) |
Get all classes method names sorted. More... | |
static const unordered_map< string, vector< string > > | getClassesMethodNames (MinitScript *minitScript) |
Get method names per classes. More... | |
static void | determineVariables (MinitScript *minitScript, unordered_set< string > &globalVariables, vector< unordered_set< string >> &localVariables) |
Determine variables. More... | |
static void | determineVariables (int scriptIdx, const MinitScript::SyntaxTreeNode &syntaxTreeNode, unordered_set< string > &globalVariables, vector< unordered_set< string >> &localVariables) |
Determine variables within syntax tree. More... | |
static void | gatherMethodCode (const vector< string > &minitScriptExtensionsCode, const string &className, int registerLine, unordered_map< string, vector< string >> &methodCodeMap) |
Gather method code. More... | |
static void | generateVariableAccess (MinitScript *minitScript, string &generatedCode, int scriptConditionIdx, int scriptIdx, const string &variableName, const string &indent, bool getMethodArgumentVariable, bool getVariable, bool getVariableReference, bool setVariable, bool setVariableReference, bool setConstant, const string &returnValueStatement="returnValue = ", const string &statementEnd=";\n", int getArgumentIdx=0, int setArgumentIdx=1) |
Generate variable access. More... | |
static void | generateArrayAccessMethods (MinitScript *minitScript, string &generatedDefinitions, const string &minitScriptClassName, int scriptConditionIdx, int scriptIdx, const string &methodName, const MinitScript::SyntaxTreeNode &syntaxTree, const MinitScript::Statement &statement, const unordered_map< string, vector< string >> &methodCodeMap, const unordered_set< string > &allMethods, bool condition, const vector< int > &argumentIndices={}, int depth=0) |
Generate array access methods. More... | |
static void | generateEvaluateMemberAccessArrays (MinitScript *minitScript, vector< string > &generatedDeclarations, vector< string > &generatedDefinitions) |
Generate evaluate member access arrays. More... | |
static void | generateArrayMapSetVariable (MinitScript *minitScript, int scriptConditionIdx, int scriptIdx, const MinitScript::Variable &variable, const unordered_map< string, vector< string >> &methodCodeMap, const unordered_set< string > &allMethods, const string &methodName, bool condition, const string &minitScriptClassName, string &generatedDefinitions, int depth=0, int initializerDepth=0, const string &postStatement=string()) |
Generate array/map/set variable. More... | |
static void | generateArrayMapSetInitializer (MinitScript *minitScript, string &generatedDefinitions, int scriptConditionIdx, int scriptIdx, const string &minitScriptClassName, const string &methodName, const MinitScript::SyntaxTreeNode &syntaxTree, const MinitScript::Statement &statement, const unordered_map< string, vector< string >> &methodCodeMap, const unordered_set< string > &allMethods, bool condition, const vector< int > &argumentIndices={}, int depth=0) |
Generate array/map/set variable. More... | |
static bool | transpileStatement (MinitScript *minitScript, string &generatedCode, const MinitScript::SyntaxTreeNode &syntaxTree, const MinitScript::Statement &statement, int scriptConditionIdx, int scriptIdx, int &statementIdx, const unordered_map< string, vector< string >> &methodCodeMap, const unordered_set< string > &allMethods, bool &scriptStateChanged, bool &scriptStopped, vector< string > &enabledNamedConditions, int depth=0, const vector< int > &argumentIndices={}, const string &returnValue=string(), const string &injectCode=string(), int additionalIndent=0) |
Transpile statement. More... | |
static bool | transpile (MinitScript *minitScript, const string &className, string &generatedCode, int scriptIdx, const unordered_map< string, vector< string >> &methodCodeMap, const unordered_set< string > &allMethods) |
Transpile a script statement. More... | |
static bool | transpileCondition (MinitScript *minitScript, string &generatedCode, int scriptIdx, const unordered_map< string, vector< string >> &methodCodeMap, const unordered_set< string > &allMethods, const string &returnValue, const string &injectCode, int depth=0) |
Transpile a condition. More... | |
static const string | createSourceCode (const MinitScript::SyntaxTreeNode &syntaxTreeNode) |
Create source code for given syntax tree node. More... | |
static const string | createSourceCode (MinitScript::Script::Type scriptType, const string &condition, const vector< MinitScript::Script::Argument > &functionArguments, const string &name, const MinitScript::SyntaxTreeNode &conditionSyntaxTree, const vector< MinitScript::SyntaxTreeNode > &syntaxTree) |
Create source code for given syntax tree. More... | |
MinitScript transpiler.
Definition at line 28 of file Transpiler.h.
|
static |
Transpile MinitScript script instance.
minitScript | MinitScript script instance |
transpilationFileName | transpilation file name |
minitScriptExtensionFileNames | MinitScript extension file names |
Definition at line 45 of file Transpiler.cpp.
|
static |
Untranspile.
scriptFileName | script file name |
transpilationFileName | transpilation file name |
Definition at line 798 of file Transpiler.cpp.
|
static |
Create source code for whole script.
minitScript | MinitScript instance |
Definition at line 2985 of file Transpiler.cpp.
|
inlinestaticprivate |
Get script type name.
type | script type |
Definition at line 58 of file Transpiler.h.
|
inlinestaticprivate |
Get script type enum identifier.
type | script type |
Definition at line 75 of file Transpiler.h.
|
inlinestaticprivate |
Create method name.
scriptIdx | script index |
Definition at line 92 of file Transpiler.h.
|
inlinestaticprivate |
Create short method name.
scriptIdx | script index |
Definition at line 120 of file Transpiler.h.
|
inlinestaticprivate |
Escape string variable.
str | string |
Definition at line 137 of file Transpiler.h.
|
inlinestaticprivate |
Check if variable has access statement.
variableStatement | variable statement |
Definition at line 180 of file Transpiler.h.
|
inlinestaticprivate |
Create variable name.
variableStatement | variable statement |
Definition at line 195 of file Transpiler.h.
|
inlinestaticprivate |
Create global variable name.
variableStatement | variable statement |
Definition at line 211 of file Transpiler.h.
|
inlinestaticprivate |
Create local variable name.
variableStatement | variable statement |
Definition at line 230 of file Transpiler.h.
|
staticprivate |
Get all classes method names.
minitScript | MinitScript instance |
Definition at line 912 of file Transpiler.cpp.
|
staticprivate |
Get all classes method names sorted.
minitScript | MinitScript instance |
Definition at line 934 of file Transpiler.cpp.
|
staticprivate |
Get method names per classes.
minitScript | MinitScript instance |
Definition at line 944 of file Transpiler.cpp.
|
staticprivate |
Determine variables.
minitScript | MinitScript script instance |
globalVariables | global variables |
localVariables | local variables per script index |
Definition at line 967 of file Transpiler.cpp.
|
staticprivate |
Determine variables within syntax tree.
scriptIdx | script index |
syntaxTreeNode | syntax tree node |
globalVariables | global variables |
localVariables | local variables per script index |
Definition at line 1012 of file Transpiler.cpp.
|
staticprivate |
Gather method code.
minitScriptExtensionsCode | MinitScript extensions code |
className | class name |
register | line register line |
methodCodeMap | method code map |
Definition at line 1081 of file Transpiler.cpp.
|
staticprivate |
Generate variable access.
minitScript | MinitScript instance |
generatedCode | generated code |
scriptConditionIdx | script condition index |
scriptIdx | script index |
variableName | variable name |
accessName | access name |
indent | indent |
getMethodArgumentVariable | get method argument variable |
getVariable | issue get variable access |
getVariableReference | issue get variable reference access |
setVariable | set variable |
setVariableReference | set variable reference |
setConstant | set constant |
returnValue | return value |
statementEnd | statement end |
getArgumentIdx | get argument index |
setArgumentIdx | set argument index |
Definition at line 1228 of file Transpiler.cpp.
|
staticprivate |
Generate array access methods.
minitScript | MinitScript instance |
generatedDefinitions | generated definitions |
minitScriptClassName | MinitScript class name |
scriptConditionIdx | script condition index |
scriptIdx | script index |
methodName | method name |
syntaxTree | syntax tree |
statement | statement |
methodCodeMap | method code map |
allMethods | all methods |
condition | condition |
argumentIndices | argument indices stack |
depth | depth |
Definition at line 1432 of file Transpiler.cpp.
|
staticprivate |
Generate evaluate member access arrays.
minitScript | MinitScript instance |
generatedDeclarations | generated declarations |
generatedDefinitions | generated definitions |
Definition at line 1681 of file Transpiler.cpp.
|
staticprivate |
Generate array/map/set variable.
minitScript | MinitScript instance |
scriptConditionIdx | script condition index |
scriptIdx | script index |
variable | variable |
methodCodeMap | method code map |
allMethods | all methods |
methodName | method name |
condition | condition |
minitScriptClassName | MinitScript class name |
generatedDefinitions | generated definitions |
depth | depth |
initializerDepth | initializer depth |
postStatement | post statement |
Definition at line 1724 of file Transpiler.cpp.
|
staticprivate |
Generate array/map/set variable.
minitScript | MinitScript instance |
generatedDefinitions | generated definitions |
scriptConditionIdx | script condition index |
scriptIdx | script index |
minitScriptClassName | MinitScript class name |
methodName | method name |
syntaxTree | syntax tree |
statement | statement |
methodCodeMap | method code map |
allMethods | all methods |
condition | condition |
argumentIndices | argument indices |
depth | depth |
Definition at line 1947 of file Transpiler.cpp.
|
staticprivate |
Transpile statement.
minitScript | MinitScript instance |
generatedCode | generated code |
syntaxTree | syntax tree |
statement | script statement |
scriptConditionIdx | script condition index |
scriptIdx | script index |
statementIdx | statement index |
methodCodeMap | method code map |
allMethods | all methods |
scriptStateChanged | script could have state changed |
scriptStopped | script could have been stopped |
enabledNamedConditions | enabled named conditions |
depth | depth |
argumentIndices | argument indices |
returnValue | return value |
injectCode | code to additionally inject |
additionalIndent | additional indent |
Definition at line 2065 of file Transpiler.cpp.
|
staticprivate |
Transpile a script statement.
minitScript | MinitScript instance |
className | MinitScript class name |
generatedCode | generated code |
scriptIdx | script index |
methodCodeMap | method code map |
allMethods | all methods |
Definition at line 2705 of file Transpiler.cpp.
|
staticprivate |
Transpile a condition.
minitScript | MinitScript instance |
generatedCode | generated code |
scriptIdx | script index |
methodCodeMap | method code map |
allMethods | all methods |
returnValue | return value |
injectCode | inject code |
Definition at line 2809 of file Transpiler.cpp.
|
staticprivate |
Create source code for given syntax tree node.
syntaxTreeNode | syntax tree node |
Definition at line 2853 of file Transpiler.cpp.
|
staticprivate |
Create source code for given syntax tree.
scriptType | script type |
condition | condition |
functionArguments | function arguments |
name | name of named conditions |
conditionSyntaxTree | condition syntax tree |
syntaxTree | syntax tree |
Definition at line 2907 of file Transpiler.cpp.