Skip to content

Commit

Permalink
MiniScript: Transpilation: some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasdr committed Oct 22, 2023
1 parent cec892b commit e43fa19
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/tdme/tools/cli/miniscripttranspiler-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ static void createArrayAccessMethods(MiniScript* miniScript, string& generatedDe

static void generateMiniScriptEvaluateMemberAccessArrays(MiniScript* miniScript, vector<string>& declarations, vector<string>& definitions) {
auto scriptMethods = miniScript->getMethods();
auto allMethods = MiniScriptTranspiler::getAllMethodNames(miniScript);
auto allMethods = MiniScriptTranspiler::getAllMethodNamesSorted(miniScript);
auto methodsByClasses = MiniScriptTranspiler::getAllClassesMethodNames(miniScript);
declarations.push_back("// evaluate member access constants");
declarations.push_back("static constexpr int EVALUATEMEMBERACCESSARRAYIDX_NONE { -1 };");
Expand Down
8 changes: 7 additions & 1 deletion src/tdme/utilities/MiniScriptTranspiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using tdme::math::Vector4;
using tdme::utilities::Console;
using tdme::utilities::StringTools;

const vector<string> MiniScriptTranspiler::getAllMethodNames(MiniScript* miniScript) {
const unordered_set<string> MiniScriptTranspiler::getAllMethodNames(MiniScript* miniScript) {
unordered_set<string> allMethods;
for (auto scriptMethod: miniScript->getMethods()) {
string className;
Expand All @@ -58,6 +58,12 @@ const vector<string> MiniScriptTranspiler::getAllMethodNames(MiniScript* miniScr
allMethods.insert(method);
}
//
return allMethods;
}

const vector<string> MiniScriptTranspiler::getAllMethodNamesSorted(MiniScript* miniScript) {
auto allMethods = getAllMethodNames(miniScript);
//
vector<string> result;
for (auto method: allMethods) result.push_back(method);
sort(result.begin(), result.end());
Expand Down
11 changes: 9 additions & 2 deletions src/tdme/utilities/MiniScriptTranspiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@ class tdme::utilities::MiniScriptTranspiler {
* @param miniScript MiniScript instance
* @return all method names
*/
static const vector<string> getAllMethodNames(MiniScript* miniScript);
static const unordered_set<string> getAllMethodNames(MiniScript* miniScript);

/**
* Get all method names
* Get all method names sorted
* @param miniScript MiniScript instance
* @return all method names sorted
*/
static const vector<string> getAllMethodNamesSorted(MiniScript* miniScript);

/**
* Get all method names by class name
* @param miniScript MiniScript instance
* @return all method names
*/
Expand Down

0 comments on commit e43fa19

Please sign in to comment.