forked from Xeeynamo/sonic-hybrid-rsdk
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
459 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
sonic3air-main/Oxygen/lemonscript/source/lemon/translator/SourceCodeWriter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Part of the Oxygen Engine / Sonic 3 A.I.R. software distribution. | ||
* Copyright (C) 2017-2024 by Eukaryot | ||
* | ||
* Published under the GNU GPLv3 open source software license, see license.txt | ||
* or https://www.gnu.org/licenses/gpl-3.0.en.html | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "lemon/program/DataType.h" | ||
|
||
|
||
namespace lemon | ||
{ | ||
class Function; | ||
|
||
class SourceCodeWriter | ||
{ | ||
public: | ||
inline SourceCodeWriter(String& output) : mOutput(output) {} | ||
|
||
inline void increaseIndentation() { ++mIndentation; } | ||
inline void decreaseIndentation() { --mIndentation; } | ||
|
||
void writeLine(const String& line); | ||
void writeEmptyLine(); | ||
|
||
void beginBlock(const char* lineContent = "{"); | ||
void endBlock(const char* lineContent = "}"); | ||
|
||
protected: | ||
String& mOutput; | ||
int mIndentation = 0; | ||
}; | ||
|
||
|
||
class CppWriter : public SourceCodeWriter | ||
{ | ||
public: | ||
inline CppWriter(String& output) : SourceCodeWriter(output) {} | ||
|
||
void writeFunctionHeader(const Function& function); | ||
|
||
public: | ||
static void addDataType(String& line, const DataTypeDefinition* dataType); | ||
static void addIdentifier(String& line, std::string_view identifier); | ||
}; | ||
|
||
} |
Oops, something went wrong.