aboutsummaryrefslogtreecommitdiff
path: root/source/20-codegen-compiler/CodegenDecl.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-07-17 23:09:00 -0700
committerrtk0c <[email protected]>2022-07-17 23:09:00 -0700
commit8c2b1bd5bd85667a2ea24ec3aa85cbdd97f9ea1c (patch)
tree80b12277b667747aa4f18ebcc3931c2ea618cb1e /source/20-codegen-compiler/CodegenDecl.hpp
parentc6e57dc94e532442ffa0bd57a16206217adbca92 (diff)
Changeset: 85 Work on codegen (a big blob of changes about various things, giving up on writing a clear commit message)
- stuff along the lines of cleaning up store process - remove completed TODOs - move code generation out of parser loop - ^^^ also introduce some weird bugs of DeclXxx::name field disappearing -- maybe fixed, maybe didn't, can't reliably reproduce - add infra to mangle (not included in codegen yet, also not tested) - convert SourceFile storage map to node map, ensuring pointer stability (was broken before) - buildsystem asan and UBsan applying to all targest
Diffstat (limited to 'source/20-codegen-compiler/CodegenDecl.hpp')
-rw-r--r--source/20-codegen-compiler/CodegenDecl.hpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/source/20-codegen-compiler/CodegenDecl.hpp b/source/20-codegen-compiler/CodegenDecl.hpp
index d99f79c..eacd254 100644
--- a/source/20-codegen-compiler/CodegenDecl.hpp
+++ b/source/20-codegen-compiler/CodegenDecl.hpp
@@ -1,12 +1,18 @@
#pragma once
+#include "CodegenOutput.hpp"
+
#include <string>
#include <vector>
// TODO replace std::string name with std::string_view into the token storage?
struct SourceFile {
- std::string_view filename; // View into storage map key
+ std::string filename;
+ CodegenOutput preHeaderOutput;
+ CodegenOutput postHeaderOutput;
+ CodegenOutput postSourceOutput;
+ CodegenOutput tuOutput; // "tu" = Translation Unit, produces a separately compiled .cpp file
bool header = false;
/// Whether this file is being reprocessed in this invocation of codegen.exe or not.
bool reprocessing = false;
@@ -27,6 +33,8 @@ struct DeclMemberVariable {
std::string type;
std::string getterName;
std::string setterName;
+ bool isGetterGenerated = false;
+ bool isSetterGenerated = false;
};
struct DeclMemberFunction {
DeclStruct* containerStruct = nullptr;
@@ -43,11 +51,14 @@ struct DeclStruct {
std::vector<DeclMemberFunction> memberFunctions;
std::vector<DeclMemberFunction> generatedFunctions;
std::string name;
+ mutable std::string mangledName;
std::string_view fullname;
// Scanned generation options
bool generating : 1 = false;
bool generatingInheritanceHiearchy : 1 = false;
+
+ const std::string& GetMangledName() const;
};
enum EnumUnderlyingType {
@@ -85,6 +96,7 @@ struct DeclEnum {
SourceFile* sourceFile = nullptr;
DeclNamespace* container = nullptr;
std::string name;
+ mutable std::string mangledName;
std::string_view fullname;
std::vector<DeclEnumElement> elements;
EnumUnderlyingType underlyingType;
@@ -101,6 +113,10 @@ struct DeclEnum {
// NOTE: see GenerateForEnum() for the exact heuristics
bool generateExcludeUseHeuristics : 1 = false;
+ const std::string& GetName() const { return name; }
+ std::string_view GetFullName() const { return fullname; }
+ const std::string& GetMangledName() const;
+
std::string_view GetUnderlyingTypeName() const;
EnumValuePattern CalcPattern() const;