From 8c2b1bd5bd85667a2ea24ec3aa85cbdd97f9ea1c Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 17 Jul 2022 23:09:00 -0700 Subject: 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 --- source/20-codegen-compiler/CodegenDecl.hpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'source/20-codegen-compiler/CodegenDecl.hpp') 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 #include // 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 memberFunctions; std::vector 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 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; -- cgit v1.2.3-70-g09d2