WIP : better AST::debug_str()

Now its more contexually rich to the ast type, however I need to hookup tokens from parsing to the AST. There needs to be a way for the debug string to lookup the token and provide the contexual line.
Can either pass it ( TokArray* toks ) from the parser on failure (or `CodeFile`)..
Technically there is more than enough room for another Token* ptr. I could add another and specifiers would still have at minimum 14 slots before needing to extended to next specs.
**************... yeah
This commit is contained in:
Edward R. Gonzalez 2023-09-11 23:22:53 -04:00
parent 9495fc2985
commit 4b48b96a79
22 changed files with 635 additions and 158 deletions

View File

@ -6,7 +6,6 @@ The library API is a composition of code element constructors.
These build up a code AST to then serialize with a file builder. These build up a code AST to then serialize with a file builder.
This code base attempts follow the [handmade philosophy](https://handmade.network/manifesto). This code base attempts follow the [handmade philosophy](https://handmade.network/manifesto).
Its not meant to be a black box metaprogramming utility, it should be easy to intergrate into a user's project domain. Its not meant to be a black box metaprogramming utility, it should be easy to intergrate into a user's project domain.
## Notes ## Notes

View File

@ -2,7 +2,7 @@
The library features a naive parser tailored for only what the library needs to construct the supported syntax of C++ into its AST. The library features a naive parser tailored for only what the library needs to construct the supported syntax of C++ into its AST.
This parser does not, and should not do the compiler's job. By only supporting this minimal set of features, the parser is kept (so far) around 5000 loc. This parser does not, and should not do the compiler's job. By only supporting this minimal set of features, the parser is kept (so far) around 5500 loc. I hope to keep it under 10k loc worst case.
You can think of this parser of a frontend parser vs a semantic parser. Its intuitively similar to WYSIWYG. What you precerive as the syntax from the user-side before the compiler gets a hold of it, is what you get. You can think of this parser of a frontend parser vs a semantic parser. Its intuitively similar to WYSIWYG. What you precerive as the syntax from the user-side before the compiler gets a hold of it, is what you get.

View File

@ -8,21 +8,22 @@
<ShowEmptyFolders>true</ShowEmptyFolders> <ShowEmptyFolders>true</ShowEmptyFolders>
<IsVirtual>false</IsVirtual> <IsVirtual>false</IsVirtual>
<IsFolder>false</IsFolder> <IsFolder>false</IsFolder>
<BuildCommand>powershell ./scripts/test.gen_run.ps1</BuildCommand> <BuildCommand>pwsh ./scripts/build.ps1 msvc debug bootstrap</BuildCommand>
<RebuildCommand></RebuildCommand> <RebuildCommand></RebuildCommand>
<BuildFileCommand></BuildFileCommand> <BuildFileCommand></BuildFileCommand>
<CleanCommand>powershell ./scripts/clean.ps1</CleanCommand> <CleanCommand>psh ./scripts/clean.ps1</CleanCommand>
<BuildWorkingDirectory></BuildWorkingDirectory> <BuildWorkingDirectory></BuildWorkingDirectory>
<CancelBuild></CancelBuild> <CancelBuild></CancelBuild>
<RunCommand>./test/gen/build/gencpp.exe</RunCommand> <RunCommand>./test/gen/build/gencpp.exe</RunCommand>
<RunCommandWorkingDirectory></RunCommandWorkingDirectory> <RunCommandWorkingDirectory></RunCommandWorkingDirectory>
<DebugCommand>powershell ./scripts/build.ps1</DebugCommand> <DebugCommand>pwsh ./scripts/build.ps1</DebugCommand>
<ExePathCommand>./test/gen/build/gencpp.exe</ExePathCommand> <ExePathCommand>./test/gen/build/gencpp.exe</ExePathCommand>
<DebugSln>gencpp.sln</DebugSln> <DebugSln></DebugSln>
<UseVisualStudioEnvBat>false</UseVisualStudioEnvBat> <UseVisualStudioEnvBat>false</UseVisualStudioEnvBat>
<Configurations> <Configurations>
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Configuration>bootstrap debug</Configuration>
</Configurations> </Configurations>
<Platforms> <Platforms>
<Platform>x64</Platform> <Platform>x64</Platform>
@ -41,6 +42,7 @@
<Defines> <Defines>
<Define>GEN_TIME</Define> <Define>GEN_TIME</Define>
<Define>GEN_SYSTEM_WINDOWS</Define> <Define>GEN_SYSTEM_WINDOWS</Define>
<Define>GEN_INTELLISENSE_DIRECTIVES</Define>
</Defines> </Defines>
<ConfigProperties> <ConfigProperties>
<ConfigAndPlatform> <ConfigAndPlatform>
@ -48,10 +50,19 @@
<Defines></Defines> <Defines></Defines>
<ForceIncludes></ForceIncludes> <ForceIncludes></ForceIncludes>
</ConfigAndPlatform> </ConfigAndPlatform>
<ConfigAndPlatform>
<Name>bootstrap debug:x64</Name>
<Defines></Defines>
<ForceIncludes></ForceIncludes>
</ConfigAndPlatform>
<Config> <Config>
<Name>Debug</Name> <Name>Debug</Name>
<Defines></Defines> <Defines></Defines>
</Config> </Config>
<Config>
<Name>bootstrap debug</Name>
<Defines></Defines>
</Config>
<Platform> <Platform>
<Name>x64</Name> <Name>x64</Name>
<Defines></Defines> <Defines></Defines>

View File

@ -7,20 +7,37 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gencpp", "gencpp.vcxproj",
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 bootstrap debug|x64 = bootstrap debug|x64
Debug|x86 = Debug|x86 bootstrap debug|x86 = bootstrap debug|x86
Release|x64 = Release|x64 bootstrap release|x64 = bootstrap release|x64
Release|x86 = Release|x86 bootstrap release|x86 = bootstrap release|x86
singleheader debug|x64 = singleheader debug|x64
singleheader debug|x86 = singleheader debug|x86
singleheader release|x64 = singleheader release|x64
singleheader release|x86 = singleheader release|x86
test debug|x64 = test debug|x64
test debug|x86 = test debug|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Debug|x64.ActiveCfg = Debug|x64 {53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x64.ActiveCfg = bootstrap release|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Debug|x64.Build.0 = Debug|x64 {53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x64.Build.0 = bootstrap release|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Debug|x86.ActiveCfg = Debug|Win32 {53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x86.ActiveCfg = bootstrap debug|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Debug|x86.Build.0 = Debug|Win32 {53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap debug|x86.Build.0 = bootstrap debug|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Release|x64.ActiveCfg = Release|x64 {53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap release|x64.ActiveCfg = bootstrap release|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Release|x64.Build.0 = Release|x64 {53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap release|x86.ActiveCfg = bootstrap release|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Release|x86.ActiveCfg = Release|Win32 {53AF600D-C09C-4F39-83E0-E022AA9479F2}.bootstrap release|x86.Build.0 = bootstrap release|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.Release|x86.Build.0 = Release|Win32 {53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x64.ActiveCfg = singleheader debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x64.Build.0 = singleheader debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x86.ActiveCfg = singleheader debug|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader debug|x86.Build.0 = singleheader debug|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x64.ActiveCfg = bootstrap debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x64.Build.0 = bootstrap debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x86.ActiveCfg = singleheader release|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.singleheader release|x86.Build.0 = singleheader release|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x64.ActiveCfg = test debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x64.Build.0 = test debug|x64
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x86.ActiveCfg = test debug|Win32
{53AF600D-C09C-4F39-83E0-E022AA9479F2}.test debug|x86.Build.0 = test debug|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -1,20 +1,44 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="bootstrap debug|Win32">
<Configuration>Debug</Configuration> <Configuration>bootstrap debug</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32"> <ProjectConfiguration Include="bootstrap debug|x64">
<Configuration>Release</Configuration> <Configuration>bootstrap debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release|x64"> <ProjectConfiguration Include="bootstrap release|Win32">
<Configuration>Release</Configuration> <Configuration>bootstrap release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="bootstrap release|x64">
<Configuration>bootstrap release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="singleheader debug|Win32">
<Configuration>singleheader debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="singleheader debug|x64">
<Configuration>singleheader debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="singleheader release|Win32">
<Configuration>singleheader release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="singleheader release|x64">
<Configuration>singleheader release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="test debug|Win32">
<Configuration>test debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="test debug|x64">
<Configuration>test debug</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
@ -25,24 +49,54 @@
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType> <ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType> <ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType> <ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@ -50,48 +104,132 @@
</ImportGroup> </ImportGroup>
<ImportGroup Label="Shared"> <ImportGroup Label="Shared">
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='test debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|Win32'">
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine> <NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine> <NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine> <NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> <NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|Win32'">
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine> <NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine> <NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine> <NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> <NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|Win32'">
<NMakeBuildCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1"</NMakeBuildCommandLine> <NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1"</NMakeReBuildCommandLine> <NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
<NMakeCleanCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine> <NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>GEN_TIME;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> <NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)thirdparty;$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(ProjectDir)test;$(SourcePath)</SourcePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|Win32'">
<NMakeBuildCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1"</NMakeBuildCommandLine> <NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1"</NMakeReBuildCommandLine> <NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
<NMakeCleanCommandLine>powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine> <NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>GEN_TIME;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> <NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)thirdparty;$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(ProjectDir)test;$(SourcePath)</SourcePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|Win32'">
<NMakeBuildCommandLine>./scripts/build.ps1</NMakeBuildCommandLine>
<NMakeCleanCommandLine>./scripts/clean.ps1</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>./scripts/build.ps1</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'">
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc debug bootstrap</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>
</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'">
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc debug test</NMakeBuildCommandLine>
<NMakeReBuildCommandLine />
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'">
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc debug singleheader</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>
</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'">
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc release singleheader</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>
</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'">
<NMakeBuildCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\build.ps1" msvc release bootstrap</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>
</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>pwsh.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)scripts\clean.ps1"</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_INTELLISENSE_DIRECTIVES;GEN_TIME;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<IncludePath>$(ProjectDir)project;$(ProjectDir)test;$(IncludePath)</IncludePath>
<SourcePath>$(ProjectDir)project;$(SourcePath)</SourcePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'">
<ClCompile>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'">
<ClCompile>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'">
<ClCompile>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'">
<ClCompile>
<LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'">
<ClCompile> <ClCompile>
<LanguageStandard_C>stdc11</LanguageStandard_C> <LanguageStandard_C>stdc11</LanguageStandard_C>
</ClCompile> </ClCompile>
@ -105,6 +243,7 @@
<None Include="project\enums\ESpecifier.csv" /> <None Include="project\enums\ESpecifier.csv" />
<None Include="project\enums\ETokType.csv" /> <None Include="project\enums\ETokType.csv" />
<None Include="Readme.md" /> <None Include="Readme.md" />
<None Include="scripts\.clang-format" />
<None Include="scripts\build.ci.ps1" /> <None Include="scripts\build.ci.ps1" />
<None Include="scripts\build.ps1" /> <None Include="scripts\build.ps1" />
<None Include="scripts\clean.ps1" /> <None Include="scripts\clean.ps1" />
@ -124,6 +263,10 @@
<ClInclude Include="project\auxillary\scanner.hpp" /> <ClInclude Include="project\auxillary\scanner.hpp" />
<ClInclude Include="project\components\ast.hpp" /> <ClInclude Include="project\components\ast.hpp" />
<ClInclude Include="project\components\ast_types.hpp" /> <ClInclude Include="project\components\ast_types.hpp" />
<ClInclude Include="project\components\gen\ast_inlines.hpp" />
<ClInclude Include="project\components\gen\ecode.hpp" />
<ClInclude Include="project\components\gen\eoperator.hpp" />
<ClInclude Include="project\components\gen\especifier.hpp" />
<ClInclude Include="project\components\header_end.hpp" /> <ClInclude Include="project\components\header_end.hpp" />
<ClInclude Include="project\components\header_start.hpp" /> <ClInclude Include="project\components\header_start.hpp" />
<ClInclude Include="project\components\inlines.hpp" /> <ClInclude Include="project\components\inlines.hpp" />
@ -153,6 +296,7 @@
<ClInclude Include="project\helpers\push_ignores.inline.hpp" /> <ClInclude Include="project\helpers\push_ignores.inline.hpp" />
<ClInclude Include="project\helpers\undef.macros.hpp" /> <ClInclude Include="project\helpers\undef.macros.hpp" />
<ClInclude Include="singleheader\components\header_start.hpp" /> <ClInclude Include="singleheader\components\header_start.hpp" />
<ClInclude Include="test\CURSED_TYPEDEF.h" />
<ClInclude Include="test\DummyInclude.hpp" /> <ClInclude Include="test\DummyInclude.hpp" />
<ClInclude Include="test\Parsed\Buffer.Parsed.hpp" /> <ClInclude Include="test\Parsed\Buffer.Parsed.hpp" />
<ClInclude Include="test\Parsed\HashTable.Parsed.hpp" /> <ClInclude Include="test\Parsed\HashTable.Parsed.hpp" />
@ -174,6 +318,7 @@
<ClCompile Include="project\bootstrap.cpp" /> <ClCompile Include="project\bootstrap.cpp" />
<ClCompile Include="project\components\ast.cpp" /> <ClCompile Include="project\components\ast.cpp" />
<ClCompile Include="project\components\ast_case_macros.cpp" /> <ClCompile Include="project\components\ast_case_macros.cpp" />
<ClCompile Include="project\components\gen\etoktype.cpp" />
<ClCompile Include="project\components\interface.cpp" /> <ClCompile Include="project\components\interface.cpp" />
<ClCompile Include="project\components\interface.parsing.cpp" /> <ClCompile Include="project\components\interface.parsing.cpp" />
<ClCompile Include="project\components\interface.untyped.cpp" /> <ClCompile Include="project\components\interface.untyped.cpp" />

View File

@ -129,6 +129,9 @@
<ClCompile Include="project\components\interface.untyped.cpp"> <ClCompile Include="project\components\interface.untyped.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="project\components\gen\etoktype.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="project\gen.hpp"> <ClInclude Include="project\gen.hpp">
@ -275,6 +278,21 @@
<ClInclude Include="singleheader\components\header_start.hpp"> <ClInclude Include="singleheader\components\header_start.hpp">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="project\components\gen\ast_inlines.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="project\components\gen\ecode.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="project\components\gen\eoperator.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="project\components\gen\especifier.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="test\CURSED_TYPEDEF.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include=".editorconfig" /> <None Include=".editorconfig" />
@ -297,6 +315,7 @@
<None Include="scripts\helpers\target_arch.psm1" /> <None Include="scripts\helpers\target_arch.psm1" />
<None Include="scripts\package_release.ps1" /> <None Include="scripts\package_release.ps1" />
<None Include="scripts\refactor.ps1" /> <None Include="scripts\refactor.ps1" />
<None Include="scripts\.clang-format" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Natvis Include=".vscode\gencpp.natvis" /> <Natvis Include=".vscode\gencpp.natvis" />

View File

@ -3,14 +3,29 @@
<PropertyGroup> <PropertyGroup>
<ShowAllFiles>true</ShowAllFiles> <ShowAllFiles>true</ShowAllFiles>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap debug|x64'">
<LocalDebuggerAttach>false</LocalDebuggerAttach> <LocalDebuggerAttach>false</LocalDebuggerAttach>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommand>C:\projects\gencpp\test\gen\build\gencpp.exe</LocalDebuggerCommand> <LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='test debug|x64'">
<LocalDebuggerAttach>false</LocalDebuggerAttach> <LocalDebuggerAttach>false</LocalDebuggerAttach>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommand>C:\projects\gencpp\test\gen\build\gencpp.exe</LocalDebuggerCommand> <LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader debug|x64'">
<LocalDebuggerAttach>false</LocalDebuggerAttach>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='singleheader release|x64'">
<LocalDebuggerAttach>false</LocalDebuggerAttach>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='bootstrap release|x64'">
<LocalDebuggerAttach>false</LocalDebuggerAttach>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommand>$(ProjectDir)project\build\bootstrap.exe</LocalDebuggerCommand>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -120,45 +120,40 @@ Code scan_file( char const* path )
} }
#if 0 #if 0
struct Policy struct CodeFile
{ {
// Nothing for now. using namespace Parser;
String FilePath;
TokArray Tokens;
Array<ParseFailure> ParseFailures;
Code CodeRoot;
}; };
struct SymbolInfo namespace Parser
{ {
StringCached File; struct ParseFailure
char const* Marker;
Code Signature;
};
struct Scanner
{
struct RequestEntry
{ {
SymbolInfo Info; String Reason;
Code Node;
}; };
}
struct Receipt CodeFile scan_file( char const* path )
{ {
StringCached File; using namespace Parser;
Code Defintion;
bool Result;
};
AllocatorInfo MemAlloc; CodeFile
result = {};
result.FilePath = String::make( GlobalAllocator, path );
static void set_allocator( AllocatorInfo allocator ); Code code = scan_file( path );
result.CodeRoot = code;
Array<FileInfo> Files; ParseContext context = parser_get_last_context();
String Buffer; result.Tokens = context.Tokens;
Array<RequestEntry> Requests; result.ParseFailures = context.Failures;
void add_files( s32 num, char const** files ); return result;
}
void add( SymbolInfo signature, Policy policy );
bool process_requests( Array<Receipt> out_receipts );
};
#endif #endif

View File

@ -148,6 +148,7 @@ int gen_main()
CodeBody gen_component_header = def_global_body( args( CodeBody gen_component_header = def_global_body( args(
def_preprocess_cond( PreprocessCond_IfDef, txt("GEN_INTELLISENSE_DIRECTIVES") ), def_preprocess_cond( PreprocessCond_IfDef, txt("GEN_INTELLISENSE_DIRECTIVES") ),
pragma_once, pragma_once,
def_include(txt("types.hpp")),
preprocess_endif, preprocess_endif,
fmt_newline, fmt_newline,
untyped_str( to_str(generation_notice) ) untyped_str( to_str(generation_notice) )

View File

@ -6,32 +6,276 @@
Code Code::Global; Code Code::Global;
Code Code::Invalid; Code Code::Invalid;
// This serializes all the data-members in a "debug" format, where each member is printed with its associated value.
char const* AST::debug_str() char const* AST::debug_str()
{ {
String result = String::make_reserve( GlobalAllocator, kilobytes(1) );
#if 1
if ( Parent ) if ( Parent )
result.append_fmt( "\n\tParent : %S %S", Parent->type_str(), Name ? Name : "" );
else
result.append_fmt( "\n\tParent : %S", "Null" );
result.append_fmt( "\n\tName : %S", Name ? Name : "Null" );
result.append_fmt( "\n\tType : %S", type_str() );
result.append_fmt( "\n\tModule Flags : %S", to_str( ModuleFlags ) );
result.append_fmt( "\n\tToken : %d", Token );
switch ( Type )
{ {
String using namespace ECode;
result = String::make_reserve( GlobalAllocator, kilobytes(1) );
result.append_fmt(
"\n\tType : %s"
"\n\tParent : %s %s"
"\n\tName : %s"
, type_str()
, Parent->type_str()
, Parent->Name, Name ? Name : ""
);
return result; case Invalid:
case NewLine:
case Access_Private:
case Access_Protected:
case Access_Public:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
break;
case Untyped:
case Execution:
case Comment:
case PlatformAttributes:
case Preprocess_Define:
case Preprocess_Include:
case Preprocess_Pragma:
case Preprocess_If:
case Preprocess_ElIf:
case Preprocess_Else:
case Preprocess_IfDef:
case Preprocess_IfNotDef:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tContent: %S", Content );
break;
case Class:
case Struct:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmd : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
result.append_fmt( "\n\tParentAccess: %s", ParentType ? to_str( ParentAccess ) : "No Parent" );
result.append_fmt( "\n\tParentType : %s", ParentType ? ParentType->type_str() : "Null" );
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
break;
case Constructor:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
result.append_fmt( "\n\tInitializerList: %S", InitializerList ? InitializerList->to_string() : "Null" );
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
break;
case Destructor:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
break;
case Enum:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
result.append_fmt( "\n\tUnderlying Type : %S", UnderlyingType ? UnderlyingType->to_string() : "Null" );
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
break;
case Extern_Linkage:
case Namespace:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tBody: %S", Body ? Body->debug_str() : "Null" );
break;
case Friend:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tDeclaration: %S", Declaration ? Declaration->to_string() : "Null" );
break;
case Function:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
result.append_fmt( "\n\tReturnType: %S", ReturnType ? ReturnType->to_string() : "Null" );
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
break;
case Module:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
break;
case Operator:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
result.append_fmt( "\n\tReturnType: %S", ReturnType ? ReturnType->to_string() : "Null" );
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
result.append_fmt( "\n\tOp : %S", to_str( Op ) );
break;
case Operator_Cast:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
result.append_fmt( "\n\tValueType : %S", ValueType ? ValueType->to_string() : "Null" );
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
break;
case Parameters:
result.append_fmt( "\n\tNumEntries: %d", NumEntries );
result.append_fmt( "\n\tLast : %S", Last->Name );
result.append_fmt( "\n\tNext : %S", Next->Name );
result.append_fmt( "\n\tValueType : %S", ValueType ? ValueType->to_string() : "Null" );
result.append_fmt( "\n\tValue : %S", Value ? Value->to_string() : "Null" );
break;
case Specifiers:
{
result.append_fmt( "\n\tNumEntries: %d", NumEntries );
result.append( "\n\tArrSpecs: " );
s32 idx = 0;
s32 left = NumEntries;
while ( left-- )
{
StrC spec = ESpecifier::to_str( ArrSpecs[idx] );
result.append_fmt( "%.*s, ", spec.Len, spec.Ptr );
idx++;
}
result.append_fmt( "\n\tNextSpecs: %S", NextSpecs ? NextSpecs->debug_str() : "Null" );
}
break;
case Template:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
result.append_fmt( "\n\tDeclaration: %S", Declaration ? Declaration->to_string() : "Null" );
break;
case Typedef:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tUnderlyingType: %S", UnderlyingType ? UnderlyingType->to_string() : "Null" );
break;
case Typename:
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
result.append_fmt( "\n\tReturnType : %S", ReturnType ? ReturnType->to_string() : "Null" );
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
result.append_fmt( "\n\tArrExpr : %S", ArrExpr ? ArrExpr->to_string() : "Null" );
break;
case Union:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
break;
case Using:
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
result.append_fmt( "\n\tUnderlyingType: %S", UnderlyingType ? UnderlyingType->to_string() : "Null" );
break;
case Variable:
if ( Parent && Parent->Type == Variable )
{
// Its a NextVar
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
result.append_fmt( "\n\tValue : %S", Value ? Value->to_string() : "Null" );
result.append_fmt( "\n\tBitfieldSize: %S", BitfieldSize ? BitfieldSize->to_string() : "Null" );
result.append_fmt( "\n\tNextVar : %S", NextVar ? NextVar->debug_str() : "Null" );
break;
}
if ( Prev )
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name );
if ( Next )
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name );
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
result.append_fmt( "\n\tValueType : %S", ValueType ? ValueType->to_string() : "Null" );
result.append_fmt( "\n\tBitfieldSize: %S", BitfieldSize ? BitfieldSize->to_string() : "Null" );
result.append_fmt( "\n\tValue : %S", Value ? Value->to_string() : "Null" );
result.append_fmt( "\n\tNextVar : %S", NextVar ? NextVar->debug_str() : "Null" );
break;
} }
#endif
String
result = String::make_reserve( GlobalAllocator, kilobytes(1) );
result.append_fmt(
"\n\tType : %s"
"\n\tName : %s"
, type_str()
, Name ? Name : ""
);
return result; return result;
} }
@ -61,7 +305,11 @@ String AST::to_string()
using namespace ECode; using namespace ECode;
case Invalid: case Invalid:
#ifdef GEN_DONT_ALLOW_INVALID_CODE
log_failure("Attempted to serialize invalid code! - %S", Parent ? Parent->debug_str() : Name ); log_failure("Attempted to serialize invalid code! - %S", Parent ? Parent->debug_str() : Name );
#else
result.append_fmt( "Invalid Code!" );
#endif
break; break;
case NewLine: case NewLine:
@ -71,6 +319,7 @@ String AST::to_string()
case Untyped: case Untyped:
case Execution: case Execution:
case Comment: case Comment:
case PlatformAttributes:
result.append( Content ); result.append( Content );
break; break;
@ -80,9 +329,6 @@ String AST::to_string()
result.append( Name ); result.append( Name );
break; break;
case PlatformAttributes:
result.append( Content );
case Class: case Class:
{ {
if ( bitfield_is_equal( u32, ModuleFlags, ModuleFlag::Export )) if ( bitfield_is_equal( u32, ModuleFlags, ModuleFlag::Export ))

View File

@ -41,10 +41,10 @@ struct CodeBody;
// These are to offer ease of use and optionally strong type safety for the AST. // These are to offer ease of use and optionally strong type safety for the AST.
struct CodeAttributes; struct CodeAttributes;
struct CodeComment; struct CodeComment;
struct CodeConstructor;
struct CodeDestructor;
struct CodeClass; struct CodeClass;
struct CodeConstructor;
struct CodeDefine; struct CodeDefine;
struct CodeDestructor;
struct CodeEnum; struct CodeEnum;
struct CodeExec; struct CodeExec;
struct CodeExtern; struct CodeExtern;
@ -217,14 +217,14 @@ struct AST
uw ArrSpecs_Cap = uw ArrSpecs_Cap =
( (
AST_POD_Size AST_POD_Size
- sizeof(AST*) * 3 - sizeof(AST*) * 4
- sizeof(StringCached) - sizeof(StringCached)
- sizeof(CodeT) - sizeof(CodeT)
- sizeof(ModuleFlag) - sizeof(ModuleFlag)
- sizeof(u32) - sizeof(u32)
- sizeof(s32) - sizeof(s32)
) )
/ sizeof(SpecifierT) - 1; // -1 for 4 extra bytes / sizeof(SpecifierT); // -1 for 4 extra bytes
union { union {
struct struct
@ -255,7 +255,10 @@ struct AST
}; };
}; };
StringCached Content; // Attributes, Comment, Execution, Include StringCached Content; // Attributes, Comment, Execution, Include
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers struct {
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
AST* NextSpecs; // Specifiers
};
}; };
union { union {
AST* Prev; AST* Prev;
@ -310,8 +313,11 @@ struct AST_POD
AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature. AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature.
}; };
}; };
StringCached Content; // Attributes, Comment, Execution, Include StringCached Content; // Attributes, Comment, Execution, Include
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers struct {
SpecifierT ArrSpecs[AST::ArrSpecs_Cap]; // Specifiers
AST* NextSpecs; // Specifiers
};
}; };
union { union {
AST* Prev; AST* Prev;

View File

@ -12,7 +12,7 @@
struct AST_Body struct AST_Body
{ {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
Code Front; Code Front;
Code Back; Code Back;
Code Parent; Code Parent;
@ -27,7 +27,7 @@ static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Filtered is not the
struct AST_Attributes struct AST_Attributes
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -43,7 +43,7 @@ static_assert( sizeof(AST_Attributes) == sizeof(AST), "ERROR: AST_Attributes is
struct AST_Comment struct AST_Comment
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -59,7 +59,7 @@ static_assert( sizeof(AST_Comment) == sizeof(AST), "ERROR: AST_Comment is not th
struct AST_Class struct AST_Class
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; // Only supported by forward declarations CodeComment InlineCmt; // Only supported by forward declarations
@ -71,7 +71,7 @@ struct AST_Class
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
}; };
}; };
CodeType Last; CodeType Prev;
CodeType Next; CodeType Next;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
@ -85,7 +85,7 @@ static_assert( sizeof(AST_Class) == sizeof(AST), "ERROR: AST_Class is not the sa
struct AST_Constructor struct AST_Constructor
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; // Only supported by forward declarations CodeComment InlineCmt; // Only supported by forward declarations
@ -110,7 +110,7 @@ static_assert( sizeof(AST_Constructor) == sizeof(AST), "ERROR: AST_Constructor i
struct AST_Define struct AST_Define
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -126,7 +126,7 @@ static_assert( sizeof(AST_Define) == sizeof(AST), "ERROR: AST_Define is not the
struct AST_Destructor struct AST_Destructor
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -150,7 +150,7 @@ static_assert( sizeof(AST_Destructor) == sizeof(AST), "ERROR: AST_Destructor is
struct AST_Enum struct AST_Enum
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -176,7 +176,7 @@ static_assert( sizeof(AST_Enum) == sizeof(AST), "ERROR: AST_Enum is not the same
struct AST_Exec struct AST_Exec
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -192,7 +192,7 @@ static_assert( sizeof(AST_Exec) == sizeof(AST), "ERROR: AST_Exec is not the same
struct AST_Extern struct AST_Extern
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ];
@ -213,7 +213,7 @@ static_assert( sizeof(AST_Extern) == sizeof(AST), "ERROR: AST_Extern is not the
struct AST_Include struct AST_Include
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -229,7 +229,7 @@ static_assert( sizeof(AST_Include) == sizeof(AST), "ERROR: AST_Include is not th
struct AST_Friend struct AST_Friend
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -251,7 +251,7 @@ static_assert( sizeof(AST_Friend) == sizeof(AST), "ERROR: AST_Friend is not the
struct AST_Fn struct AST_Fn
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -276,7 +276,7 @@ static_assert( sizeof(AST_Fn) == sizeof(AST), "ERROR: AST_Fn is not the same siz
struct AST_Module struct AST_Module
{ {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
Code Prev; Code Prev;
Code Next; Code Next;
Code Parent; Code Parent;
@ -291,7 +291,7 @@ static_assert( sizeof(AST_Module) == sizeof(AST), "ERROR: AST_Module is not the
struct AST_NS struct AST_NS
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct { struct {
char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 5 ];
CodeBody Body; CodeBody Body;
@ -312,7 +312,7 @@ static_assert( sizeof(AST_NS) == sizeof(AST), "ERROR: AST_NS is not the same siz
struct AST_Operator struct AST_Operator
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -338,7 +338,7 @@ static_assert( sizeof(AST_Operator) == sizeof(AST), "ERROR: AST_Operator is not
struct AST_OpCast struct AST_OpCast
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -363,7 +363,7 @@ static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the
struct AST_Param struct AST_Param
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) * 3 ];
@ -387,7 +387,7 @@ static_assert( sizeof(AST_Param) == sizeof(AST), "ERROR: AST_Param is not the sa
struct AST_Pragma struct AST_Pragma
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -403,7 +403,7 @@ static_assert( sizeof(AST_Pragma) == sizeof(AST), "ERROR: AST_Pragma is not the
struct AST_PreprocessCond struct AST_PreprocessCond
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
StringCached Content; StringCached Content;
}; };
Code Prev; Code Prev;
@ -419,6 +419,7 @@ static_assert( sizeof(AST_PreprocessCond) == sizeof(AST), "ERROR: AST_Preprocess
struct AST_Specifiers struct AST_Specifiers
{ {
SpecifierT ArrSpecs[ AST::ArrSpecs_Cap ]; SpecifierT ArrSpecs[ AST::ArrSpecs_Cap ];
CodeSpecifiers NextSpecs;
Code Prev; Code Prev;
Code Next; Code Next;
Code Parent; Code Parent;
@ -433,7 +434,7 @@ struct AST_Specifiers
struct AST_Struct struct AST_Struct
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -445,7 +446,7 @@ struct AST_Struct
char _PAD_PROPERTIES_2_[ sizeof(AST*) ]; char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
}; };
}; };
CodeType Last; CodeType Prev;
CodeType Next; CodeType Next;
Code Parent; Code Parent;
StringCached Name; StringCached Name;
@ -459,7 +460,7 @@ static_assert( sizeof(AST_Struct) == sizeof(AST), "ERROR: AST_Struct is not the
struct AST_Template struct AST_Template
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ]; char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
@ -482,7 +483,7 @@ static_assert( sizeof(AST_Template) == sizeof(AST), "ERROR: AST_Template is not
struct AST_Type struct AST_Type
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_INLINE_CMT_[ sizeof(AST*) ]; char _PAD_INLINE_CMT_[ sizeof(AST*) ];
@ -508,7 +509,7 @@ static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same
struct AST_Typedef struct AST_Typedef
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -531,7 +532,7 @@ static_assert( sizeof(AST_Typedef) == sizeof(AST), "ERROR: AST_Typedef is not th
struct AST_Union struct AST_Union
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
char _PAD_INLINE_CMT_[ sizeof(AST*) ]; char _PAD_INLINE_CMT_[ sizeof(AST*) ];
@ -555,7 +556,7 @@ static_assert( sizeof(AST_Union) == sizeof(AST), "ERROR: AST_Union is not the sa
struct AST_Using struct AST_Using
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;
@ -579,7 +580,7 @@ static_assert( sizeof(AST_Using) == sizeof(AST), "ERROR: AST_Using is not the sa
struct AST_Var struct AST_Var
{ {
union { union {
char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap ]; char _PAD_[ sizeof(SpecifierT) * AST::ArrSpecs_Cap + sizeof(AST*) ];
struct struct
{ {
CodeComment InlineCmt; CodeComment InlineCmt;

View File

@ -1,5 +1,6 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "types.hpp"
#endif #endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)

View File

@ -1,5 +1,6 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "types.hpp"
#endif #endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)

View File

@ -1,5 +1,6 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "types.hpp"
#endif #endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)

View File

@ -1,5 +1,6 @@
#ifdef GEN_INTELLISENSE_DIRECTIVES #ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once #pragma once
#include "types.hpp"
#endif #endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)

View File

@ -86,6 +86,7 @@ extern CodeSpecifiers spec_internal_linkage;
extern CodeSpecifiers spec_local_persist; extern CodeSpecifiers spec_local_persist;
extern CodeSpecifiers spec_mutable; extern CodeSpecifiers spec_mutable;
extern CodeSpecifiers spec_neverinline; extern CodeSpecifiers spec_neverinline;
extern CodeSpecifiers spec_noexcept;
extern CodeSpecifiers spec_override; extern CodeSpecifiers spec_override;
extern CodeSpecifiers spec_ptr; extern CodeSpecifiers spec_ptr;
extern CodeSpecifiers spec_pure; extern CodeSpecifiers spec_pure;

View File

@ -203,6 +203,7 @@ void define_constants()
def_constant_spec( local_persist, ESpecifier::Local_Persist ); def_constant_spec( local_persist, ESpecifier::Local_Persist );
def_constant_spec( mutable, ESpecifier::Mutable ); def_constant_spec( mutable, ESpecifier::Mutable );
def_constant_spec( neverinline, ESpecifier::NeverInline ); def_constant_spec( neverinline, ESpecifier::NeverInline );
def_constant_spec( noexcept, ESpecifier::NoExceptions );
def_constant_spec( override, ESpecifier::Override ); def_constant_spec( override, ESpecifier::Override );
def_constant_spec( ptr, ESpecifier::Ptr ); def_constant_spec( ptr, ESpecifier::Ptr );
def_constant_spec( pure, ESpecifier::Pure ) def_constant_spec( pure, ESpecifier::Pure )

View File

@ -5050,8 +5050,9 @@ CodeType parse_type( bool* typedef_is_function )
using namespace ECode; using namespace ECode;
CodeType CodeType
result = (CodeType) make_code(); result = (CodeType) make_code();
result->Type = Typename; result->Type = Typename;
result->Token = Context.Scope->Start;
// Need to wait until were using the new parsing method to do this. // Need to wait until were using the new parsing method to do this.
String name_stripped = strip_formatting( name, strip_formatting_dont_preserve_newlines ); String name_stripped = strip_formatting( name, strip_formatting_dont_preserve_newlines );

View File

@ -861,8 +861,8 @@ CodeInclude def_include( StrC path, bool foreign )
} }
StrC content = foreign ? StrC content = foreign ?
to_str( str_fmt_buf( "<%.*s>\n", path.Len, path.Ptr )) to_str( str_fmt_buf( "<%.*s>", path.Len, path.Ptr ))
: to_str( str_fmt_buf( "\"%.*s\"\n", path.Len, path.Ptr )); : to_str( str_fmt_buf( "\"%.*s\"", path.Len, path.Ptr ));
Code Code
result = make_code(); result = make_code();

View File

@ -58,6 +58,7 @@ global CodeSpecifiers spec_inline;
global CodeSpecifiers spec_internal_linkage; global CodeSpecifiers spec_internal_linkage;
global CodeSpecifiers spec_local_persist; global CodeSpecifiers spec_local_persist;
global CodeSpecifiers spec_mutable; global CodeSpecifiers spec_mutable;
global CodeSpecifiers spec_noexcept;
global CodeSpecifiers spec_neverinline; global CodeSpecifiers spec_neverinline;
global CodeSpecifiers spec_override; global CodeSpecifiers spec_override;
global CodeSpecifiers spec_ptr; global CodeSpecifiers spec_ptr;

View File

@ -56,12 +56,26 @@ enum class ModuleFlag : u32
None = 0, None = 0,
Export = bit(0), Export = bit(0),
Import = bit(1), Import = bit(1),
// Private = bit(2),
Num_ModuleFlags, Num_ModuleFlags,
Invalid, Invalid,
}; };
StrC to_str( ModuleFlag flag )
{
local_persist
StrC lookup[ (u32)ModuleFlag::Num_ModuleFlags ] = {
{ sizeof("__none__"), "__none__" },
{ sizeof("export"), "export" },
{ sizeof("import"), "import" },
};
if ( flag > ModuleFlag::Import )
return { sizeof("invalid"), "invalid" };
return lookup[ (u32)flag ];
}
ModuleFlag operator|( ModuleFlag A, ModuleFlag B) ModuleFlag operator|( ModuleFlag A, ModuleFlag B)
{ {
return (ModuleFlag)( (u32)A | (u32)B ); return (ModuleFlag)( (u32)A | (u32)B );