From 4d638a72550cd2b647a74e52b61a74d6ca3b25ce Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 7 Dec 2024 00:21:09 -0500 Subject: [PATCH] borken : lots of stuff changed, explaining in later commit...v --- .vscode/c_cpp_properties.json | 37 +- .vscode/settings.json | 6 +- .vscode/tasks.json | 144 +++ Readme.md | 9 +- gen_c_library/Test.jsonc | 1146 +++++++++++++++++++++ gen_c_library/c_library.cpp | 32 +- gen_singleheader/singleheader.cpp | 2 - project/bootstrap.cpp | 3 +- project/components/ast.cpp | 124 +-- project/components/ast.hpp | 83 +- project/components/code_serialization.cpp | 663 ++++++------ project/components/code_types.hpp | 903 ++++++++-------- project/components/gen/ast_inlines.hpp | 1114 +++++++------------- project/components/gen/ecode.hpp | 204 ++-- project/components/gen/eoperator.hpp | 162 ++- project/components/gen/especifier.hpp | 106 +- project/components/gen/etoktype.cpp | 326 ++---- project/components/inlines.hpp | 164 +-- project/components/interface.cpp | 34 +- project/components/interface.upfront.cpp | 119 ++- project/components/parser.cpp | 39 +- project/dependencies/basic_types.hpp | 6 +- project/dependencies/containers.hpp | 9 +- project/dependencies/debug.cpp | 2 - project/dependencies/debug.hpp | 2 - project/dependencies/filesystem.cpp | 2 - project/dependencies/filesystem.hpp | 41 +- project/dependencies/hashing.cpp | 2 - project/dependencies/hashing.hpp | 2 - project/dependencies/macros.hpp | 61 +- project/dependencies/memory.cpp | 6 +- project/dependencies/memory.hpp | 43 +- project/dependencies/parsing.cpp | 2 - project/dependencies/parsing.hpp | 2 - project/dependencies/platform.hpp | 15 +- project/dependencies/printing.cpp | 2 - project/dependencies/printing.hpp | 6 +- project/dependencies/string_ops.cpp | 2 - project/dependencies/string_ops.hpp | 4 - project/dependencies/strings.cpp | 2 - project/dependencies/strings.hpp | 33 +- project/dependencies/timing.cpp | 2 - project/dependencies/timing.hpp | 4 - project/helpers/helper.hpp | 153 ++- scripts/build.ci.ps1 | 4 +- scripts/helpers/vendor_toolchain.ps1 | 95 +- 46 files changed, 3352 insertions(+), 2570 deletions(-) create mode 100644 .vscode/tasks.json create mode 100644 gen_c_library/Test.jsonc diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 6e9762e..562da8a 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -1,9 +1,9 @@ { "configurations": [ { - "name": "Win32 msvc", + "name": "Bootstrap", "includePath": [ - "${workspaceFolder}/**" + "${workspaceFolder}/project/**" ], "defines": [ "_DEBUG", @@ -15,10 +15,39 @@ "GEN_INTELLISENSE_DIRECTIVES", "INTELLISENSE_DIRECTIVES" ], + "cStandard": "c11", + "cppStandard": "c++17", "windowsSdkVersion": "10.0.19041.0", "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe", "intelliSenseMode": "msvc-x64", - "compileCommands": "${workspaceFolder}/project/build/compile_commands.json" + "compileCommands": "C:\\projects\\gencpp\\.vscode\\tasks.json", + "compilerArgs": [ + "/EHsc-", + "/GR-", + "/Zc:preprocessor", + "/FC" + ] + }, + { + "name": "Win32 msvc c_library", + "includePath": [ + "${workspaceFolder}/gen_c_library/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE", + "GEN_TIME", + "GEN_IMPLEMENTATION", + // "GEN_DONT_USE_NAMESPACE" + "GEN_INTELLISENSE_DIRECTIVES", + "INTELLISENSE_DIRECTIVES" + ], + "cppStandard": "c++17", + "windowsSdkVersion": "10.0.19041.0", + "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe", + "intelliSenseMode": "msvc-x64", + "compileCommands": "C:\\projects\\gencpp\\.vscode\\tasks.json" }, { "name": "Win32 clang", @@ -38,7 +67,7 @@ "windowsSdkVersion": "10.0.19041.0", "compilerPath": "C:/Users/Ed/scoop/apps/llvm/current/bin/clang++.exe", "intelliSenseMode": "windows-clang-x64", - "compileCommands": "${workspaceFolder}/project/build/compile_commands.json" + "compileCommands": ".vscode/tasks.json" } ], "version": 4 diff --git a/.vscode/settings.json b/.vscode/settings.json index c8c081b..fc55c5f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -67,8 +67,10 @@ "C_Cpp.files.exclude": { "**/.vscode": true, "**/.vs": true, - "**/sanity.gen.hpp": true + "**/sanity.gen.hpp": true, + "test/**":true, }, "autoHide.autoHidePanel": false, - "autoHide.autoHideSideBar": false + "autoHide.autoHideSideBar": false, + "dimmer.enabled": true } diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..c54587d --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,144 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build Bootstrap", + "type": "shell", + "command": "C:\\Program Files\\PowerShell\\7\\pwsh.exe", + "args": [ + "-ExecutionPolicy", + "Bypass", + "-File", + "${workspaceFolder}/scripts/build.ci.ps1", + "bootstrap", + "msvc" + ], + "group": "build", + "problemMatcher": { + "owner": "cpp", + "fileLocation": [ + "relative", + "${workspaceFolder}" + ], + "pattern": { + "regexp": "^(.*)\\((\\d+)\\)\\s*:\\s*(warning|error)\\s*(\\w+)\\s*:\\s*(.*)$", + "file": 1, + "line": 2, + "severity": 3, + "code": 4, + "message": 5 + } + }, + "presentation": { + "reveal": "always", + "panel": "shared", + "clear": true + } + }, + { + "label": "Build C Library", + "type": "shell", + "command": "C:\\Program Files\\PowerShell\\7\\pwsh.exe", + "args": [ + "-ExecutionPolicy", + "Bypass", + "-File", + "${workspaceFolder}/scripts/build.ci.ps1", + "c_library", + "msvc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": { + "owner": "cpp", + "fileLocation": [ + "relative", + "${workspaceFolder}" + ], + "pattern": { + "regexp": "^(.*)\\((\\d+)\\)\\s*:\\s*(warning|error)\\s*(\\w+)\\s*:\\s*(.*)$", + "file": 1, + "line": 2, + "severity": 3, + "code": 4, + "message": 5 + } + }, + "presentation": { + "reveal": "always", + "panel": "shared", + "clear": true + } + }, + { + "label": "Build Singleheader (MSVC)", + "type": "shell", + "command": "C:\\Program Files\\PowerShell\\7\\pwsh.exe", + "args": [ + "-ExecutionPolicy", + "Bypass", + "-File", + "${workspaceFolder}/scripts/build.ci.ps1", + "singleheader", + "msvc", + "debug" + ], + "group": "build", + "problemMatcher": { + "owner": "cpp", + "fileLocation": ["relative", "${workspaceFolder}"], + "pattern": [ + { + "regexp": "^(.*)\\((\\d+)\\)\\s*:\\s*(error|warning|info|note)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$", + "file": 1, + "line": 2, + "severity": 3, + "code": 4, + "message": 5 + } + ] + }, + "presentation": { + "reveal": "always", + "panel": "shared", + "clear": true + } + }, + { + "label": "Build Unreal (MSVC)", + "type": "shell", + "command": "C:\\Program Files\\PowerShell\\7\\pwsh.exe", + "args": [ + "-ExecutionPolicy", + "Bypass", + "-File", + "${workspaceFolder}/scripts/build.ci.ps1", + "unreal", + "msvc", + "debug" + ], + "group": "build", + "problemMatcher": { + "owner": "cpp", + "fileLocation": ["relative", "${workspaceFolder}"], + "pattern": [ + { + "regexp": "^(.*)\\((\\d+)\\)\\s*:\\s*(error|warning|info|note)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$", + "file": 1, + "line": 2, + "severity": 3, + "code": 4, + "message": 5 + } + ] + }, + "presentation": { + "reveal": "always", + "panel": "shared", + "clear": true + } + } + ] +} diff --git a/Readme.md b/Readme.md index 20d84fd..61c2a78 100644 --- a/Readme.md +++ b/Readme.md @@ -1,9 +1,9 @@ # gencpp -An attempt at simple staged metaprogramming for c/c++. +An attempt at simple staged metaprogramming for C/C++. -The library API is a composition of code element constructors. -These build up a code AST to then serialize with a file builder. +The library API is a composition of code element constructors, and a non-standards-compliant single-pass C/C++ parser. +These build up a code AST to then serialize with a file builder, or can be traversed for staged-reflection of C/C++ code. 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. @@ -31,7 +31,7 @@ A metaprogram is built to generate files before the main program is built. We'll `gen.cpp` \`s `main()` is defined as `gen_main()` which the user will have to define once for their program. There they will dictate everything that should be generated. -In order to keep the locality of this code within the same files the following pattern may be used (although this pattern isn't required at all): +In order to keep the locality of this code within the same files the following pattern may be used (although this pattern isn't the best to use): Within `program.cpp` : @@ -54,7 +54,6 @@ u32 gen_main() // Regular runtime dependent on the generated code here. #endif - ``` The design uses a constructive builder API for the code to generate. diff --git a/gen_c_library/Test.jsonc b/gen_c_library/Test.jsonc new file mode 100644 index 0000000..1745966 --- /dev/null +++ b/gen_c_library/Test.jsonc @@ -0,0 +1,1146 @@ +{ + "$schema": "vscode://schemas/color-theme", + "type": "light", + "colors": { + "activityBar.background": "#eae1db", + "activityBar.border": "#d8c3b4", + "activityBar.foreground": "#867466", + "activityBar.inactiveForeground": "#c0a693", + "activityBarBadge.background": "#d9aeb0", + "activityBarBadge.foreground": "#ab323a", + "breadcrumb.background": "#f0eae6", + "breadcrumb.focusForeground": "#867466", + "breadcrumb.foreground": "#c0a693", + "button.background": "#ab323a", + "button.foreground": "#fbeeee", + "button.hoverBackground": "#d5404b", + "checkbox.background": "#f4f0ed", + "checkbox.border": "#f4f0ed", + "checkbox.foreground": "#6b5b50", + "descriptionForeground": "#6b5b50", + "dropdown.background": "#f4f0ed", + "dropdown.border": "#f4f0ed", + "dropdown.foreground": "#50443c", + "dropdown.listBackground": "#f4f0ed", + "editor.background": "#cac9c8", + "editor.foreground": "#372f28", + "editor.hoverHighlightBackground": "#eae1db", + "editor.selectionBackground": "#eae1db", + "editor.selectionForeground": "#6b5b50", + "editor.selectionHighlightBackground": "#eae1db", + "editor.wordHighlightBackground": "#eae1db", + "editorCursor.foreground": "#ab323a", + "editorGroup.border": "#eae1db", + "editorGroupHeader.border": "#e1d2c8", + "editorGroupHeader.tabsBackground": "#f4f0ed", + "editorGroupHeader.tabsBorder": "#e1d2c8", + "editorGutter.addedBackground": "#da99ae", + "editorGutter.deletedBackground": "#95acd6", + "editorGutter.modifiedBackground": "#bba1d6", + "editorLineNumber.activeForeground": "#867466", + "editorLineNumber.foreground": "#d8c3b4", + "editorLink.activeForeground": "#526b94", + "editorRuler.foreground": "#eae1db", + "editorSuggestWidget.highlightForeground": "#ab323a", + "editorSuggestWidget.selectedBackground": "#e1d2c8", + "editorWhitespace.foreground": "#eae1db", + "editorWidget.background": "#fbf9f8", + "editorWidget.border": "#00000000", + "editorWidget.foreground": "#6b5b50", + "errorForeground": "#ab323a", + "focusBorder": "#d9aeb0", + "foreground": "#372f28", + "gitDecoration.addedResourceForeground": "#934463", + "gitDecoration.conflictingResourceForeground": "#ab323a", + "gitDecoration.deletedResourceForeground": "#485f84", + "gitDecoration.ignoredResourceForeground": "#c0a693", + "gitDecoration.modifiedResourceForeground": "#764c98", + "gitDecoration.submoduleResourceForeground": "#5e6140", + "gitDecoration.untrackedResourceForeground": "#867466", + "icon.foreground": "#6b5b50", + "list.activeSelectionBackground": "#eae1db", + "list.activeSelectionForeground": "#50443c", + "list.dropBackground": "#f4f0ed", + "list.focusBackground": "#eae1db", + "list.focusForeground": "#50443c", + "list.highlightForeground": "#ab323a", + "list.hoverBackground": "#f4f0ed", + "list.hoverForeground": "#50443c", + "list.inactiveFocusBackground": "#f4f0ed", + "list.inactiveSelectionBackground": "#f4f0ed", + "list.inactiveSelectionForeground": "#50443c", + "minimap.errorHighlight": "#ab323a", + "minimap.findMatchHighlight": "#a8cfc0", + "minimap.selectionHighlight": "#eae1db", + "minimap.warningHighlight": "#ab323a", + "minimapGutter.addedBackground": "#da99ae", + "minimapGutter.deletedBackground": "#95acd6", + "minimapGutter.modifiedBackground": "#bba1d6", + "minimapSlider.activeBackground": "#372f2838", + "minimapSlider.background": "#372f2810", + "minimapSlider.hoverBackground": "#372f2820", + "pickerGroup.border": "#d8c3b4", + "pickerGroup.foreground": "#a38c7c", + "selection.background": "#c0a693", + "settings.modifiedItemIndicator": "#bba1d6", + "sideBar.background": "#f4f0ed", + "sideBar.border": "#eae1db", + "sideBarSectionHeader.background": "#eae1db", + "sideBarSectionHeader.foreground": "#867466", + "statusBar.background": "#eae1db", + "statusBar.border": "#d8c3b4", + "statusBar.debuggingBackground": "#bec8ca", + "statusBar.debuggingBorder": "#b0bbbc", + "statusBar.debuggingForeground": "#5d5046", + "statusBar.foreground": "#867466", + "statusBar.noFolderBackground": "#eae1db", + "statusBar.noFolderBorder": "#d8c3b4", + "statusBar.noFolderForeground": "#867466", + "statusBarItem.hoverBackground": "#e1d2c8", + "tab.activeBackground": "#f0eae6", + "tab.activeBorder": "#50443c", + "tab.activeForeground": "#50443c", + "tab.border": "#00000000", + "tab.inactiveBackground": "#f4f0ed", + "tab.inactiveForeground": "#c0a693", + "terminal.ansiBlack": "#cfb49f", + "terminal.ansiBlue": "#455f87", + "terminal.ansiBrightBlack": "#e1d2c8", + "terminal.ansiBrightBlue": "#5878a9", + "terminal.ansiBrightCyan": "#527e82", + "terminal.ansiBrightGreen": "#677e4d", + "terminal.ansiBrightMagenta": "#9460c0", + "terminal.ansiBrightRed": "#c74f56", + "terminal.ansiBrightWhite": "#372f28", + "terminal.ansiBrightYellow": "#8a744e", + "terminal.ansiCyan": "#406467", + "terminal.ansiGreen": "#51643c", + "terminal.ansiMagenta": "#78499e", + "terminal.ansiRed": "#9f3e43", + "terminal.ansiWhite": "#443932", + "terminal.ansiYellow": "#6e5c3d", + "terminal.background": "#f4f0ed", + "terminal.foreground": "#443932", + "terminal.selectionBackground": "#c0a693", + "terminalCursor.background": "#eae1db", + "terminalCursor.foreground": "#ab323a", + "textBlockQuote.background": "#eae1db", + "textBlockQuote.border": "#c0a693", + "textCodeBlock.background": "#eae1db", + "textLink.activeForeground": "#526b94", + "textLink.foreground": "#3f5374", + "textPreformat.foreground": "#50443c", + "textSeparator.foreground": "#d8c3b4", + "titleBar.activeBackground": "#e1d2c8", + "titleBar.activeForeground": "#867466", + "titleBar.border": "#d8c3b4", + "titleBar.inactiveBackground": "#e1d2c8", + "titleBar.inactiveForeground": "#c0a693", + "widget.shadow": "#372f2810", + "window.activeBorder": "#eae1db", + "window.inactiveBorder": "#eae1db", + //"actionBar.toggledBackground": "#d9aeb033", + //"activityBar.activeBorder": "#867466", + //"activityBar.dropBorder": "#867466", + //"activityBarTop.activeBorder": "#424242", + //"activityBarTop.dropBorder": "#424242", + //"activityBarTop.foreground": "#424242", + //"activityBarTop.inactiveForeground": "#424242bf", + //"activityErrorBadge.background": "#e51400", + //"activityErrorBadge.foreground": "#ffffff", + //"activityWarningBadge.background": "#bf8803", + //"activityWarningBadge.foreground": "#ffffff", + //"badge.background": "#c4c4c4", + //"badge.foreground": "#333333", + //"banner.background": "#b89a85", + //"banner.foreground": "#50443c", + //"banner.iconForeground": "#1a85ff", + //"bookmarks.lineBackground": "#00000000", + //"bookmarks.lineBorder": "#00000000", + //"bookmarks.overviewRuler": "#157efb88", + //"breadcrumb.activeSelectionForeground": "#2c2620", + //"breadcrumbPicker.background": "#fbf9f8", + //"button.secondaryBackground": "#5f6a79", + //"button.secondaryForeground": "#ffffff", + //"button.secondaryHoverBackground": "#4c5561", + //"button.separator": "#fbeeee66", + //"chart.axis": "#00000099", + //"chart.guide": "#00000033", + //"chart.line": "#236b8e", + //"charts.blue": "#1a85ff", + //"charts.foreground": "#372f28", + //"charts.green": "#388a34", + //"charts.lines": "#372f2880", + //"charts.orange": "#a8cfc0", + //"charts.purple": "#652d90", + //"charts.red": "#e51400", + //"charts.yellow": "#bf8803", + //"chat.avatarBackground": "#f2f2f2", + //"chat.avatarForeground": "#372f28", + //"chat.editedFileForeground": "#895503", + //"chat.requestBackground": "#fbf9f89e", + //"chat.requestBorder": "#0000001a", + //"chat.slashCommandBackground": "#d2ecff99", + //"chat.slashCommandForeground": "#306ca2", + //"checkbox.selectBackground": "#fbf9f8", + //"checkbox.selectBorder": "#6b5b50", + //"commandCenter.activeBackground": "#00000014", + //"commandCenter.activeBorder": "#8674664d", + //"commandCenter.activeForeground": "#867466", + //"commandCenter.background": "#0000000d", + //"commandCenter.border": "#86746633", + //"commandCenter.debuggingBackground": "#bec8ca42", + //"commandCenter.foreground": "#867466", + //"commandCenter.inactiveBorder": "#c0a69340", + //"commandCenter.inactiveForeground": "#c0a693", + //"commentsView.resolvedIcon": "#61616180", + //"commentsView.unresolvedIcon": "#d9aeb0", + //"debugConsole.errorForeground": "#ab323a", + //"debugConsole.infoForeground": "#1a85ff", + //"debugConsole.sourceForeground": "#372f28", + //"debugConsole.warningForeground": "#bf8803", + //"debugConsoleInputIcon.foreground": "#372f28", + //"debugExceptionWidget.background": "#f1dfde", + //"debugExceptionWidget.border": "#a31515", + //"debugIcon.breakpointCurrentStackframeForeground": "#be8700", + //"debugIcon.breakpointDisabledForeground": "#848484", + //"debugIcon.breakpointForeground": "#e51400", + //"debugIcon.breakpointStackframeForeground": "#89d185", + //"debugIcon.breakpointUnverifiedForeground": "#848484", + //"debugIcon.continueForeground": "#007acc", + //"debugIcon.disconnectForeground": "#a1260d", + //"debugIcon.pauseForeground": "#007acc", + //"debugIcon.restartForeground": "#388a34", + //"debugIcon.startForeground": "#388a34", + //"debugIcon.stepBackForeground": "#007acc", + //"debugIcon.stepIntoForeground": "#007acc", + //"debugIcon.stepOutForeground": "#007acc", + //"debugIcon.stepOverForeground": "#007acc", + //"debugIcon.stopForeground": "#a1260d", + //"debugTokenExpression.boolean": "#0000ff", + //"debugTokenExpression.error": "#e51400", + //"debugTokenExpression.name": "#9b46b0", + //"debugTokenExpression.number": "#098658", + //"debugTokenExpression.string": "#a31515", + //"debugTokenExpression.type": "#4a90e2", + //"debugTokenExpression.value": "#6c6c6ccc", + //"debugToolBar.background": "#f3f3f3", + //"debugView.exceptionLabelBackground": "#a31515", + //"debugView.exceptionLabelForeground": "#ffffff", + //"debugView.stateLabelBackground": "#88888844", + //"debugView.stateLabelForeground": "#372f28", + //"debugView.valueChangedHighlight": "#569cd6", + //"diffEditor.diagonalFill": "#22222233", + //"diffEditor.insertedLineBackground": "#9bb95533", + //"diffEditor.insertedTextBackground": "#9ccc2c40", + //"diffEditor.move.border": "#8b8b8b9c", + //"diffEditor.moveActive.border": "#ffa500", + //"diffEditor.removedLineBackground": "#ff000033", + //"diffEditor.removedTextBackground": "#ff000033", + //"diffEditor.unchangedCodeBackground": "#b8b8b829", + //"diffEditor.unchangedRegionBackground": "#f4f0ed", + //"diffEditor.unchangedRegionForeground": "#372f28", + //"diffEditor.unchangedRegionShadow": "#737373bf", + //"disabledForeground": "#61616180", + //"editor.compositionBorder": "#000000", + //"editor.findMatchBackground": "#a8ac94", + //"editor.findMatchHighlightBackground": "#ea5c0055", + //"editor.findRangeHighlightBackground": "#b4b4b44d", + //"editor.focusedStackFrameHighlightBackground": "#cee7ce73", + //"editor.foldBackground": "#eae1db4d", + //"editor.foldPlaceholderForeground": "#808080", + //"editor.inactiveSelectionBackground": "#eae1db80", + //"editor.inlineValuesBackground": "#ffc80033", + //"editor.inlineValuesForeground": "#00000080", + //"editor.lineHighlightBorder": "#eeeeee", + //"editor.linkedEditingBackground": "#ff00004d", + //"editor.placeholder.foreground": "#00000077", + //"editor.rangeHighlightBackground": "#fdff0033", + //"editor.snippetFinalTabstopHighlightBorder": "#0a326480", + //"editor.snippetTabstopHighlightBackground": "#0a326433", + //"editor.stackFrameHighlightBackground": "#ffff6673", + //"editor.symbolHighlightBackground": "#ea5c0055", + //"editor.wordHighlightStrongBackground": "#0e639c40", + //"editor.wordHighlightTextBackground": "#eae1db", + //"editorActionList.background": "#fbf9f8", + //"editorActionList.focusBackground": "#eae1db", + //"editorActionList.focusForeground": "#50443c", + //"editorActionList.foreground": "#6b5b50", + //"editorActiveLineNumber.foreground": "#0b216f", + //"editorBracketHighlight.foreground1": "#0431fa", + //"editorBracketHighlight.foreground2": "#319331", + //"editorBracketHighlight.foreground3": "#7b3814", + //"editorBracketHighlight.foreground4": "#00000000", + //"editorBracketHighlight.foreground5": "#00000000", + //"editorBracketHighlight.foreground6": "#00000000", + //"editorBracketHighlight.unexpectedBracket.foreground": "#ff1212cc", + //"editorBracketMatch.background": "#0064001a", + //"editorBracketMatch.border": "#b9b9b9", + //"editorBracketPairGuide.activeBackground1": "#00000000", + //"editorBracketPairGuide.activeBackground2": "#00000000", + //"editorBracketPairGuide.activeBackground3": "#00000000", + //"editorBracketPairGuide.activeBackground4": "#00000000", + //"editorBracketPairGuide.activeBackground5": "#00000000", + //"editorBracketPairGuide.activeBackground6": "#00000000", + //"editorBracketPairGuide.background1": "#00000000", + //"editorBracketPairGuide.background2": "#00000000", + //"editorBracketPairGuide.background3": "#00000000", + //"editorBracketPairGuide.background4": "#00000000", + //"editorBracketPairGuide.background5": "#00000000", + //"editorBracketPairGuide.background6": "#00000000", + //"editorCodeLens.foreground": "#919191", + //"editorCommentsWidget.rangeActiveBackground": "#d9aeb01a", + //"editorCommentsWidget.rangeBackground": "#d9aeb01a", + //"editorCommentsWidget.replyInputBackground": "#f3f3f3", + //"editorCommentsWidget.resolvedBorder": "#61616180", + //"editorCommentsWidget.unresolvedBorder": "#d9aeb0", + //"editorError.foreground": "#e51400", + //"editorGhostText.foreground": "#00000077", + //"editorGroup.dropBackground": "#2677cb2e", + //"editorGroup.dropIntoPromptBackground": "#fbf9f8", + //"editorGroup.dropIntoPromptForeground": "#6b5b50", + //"editorGroupHeader.noTabsBackground": "#fbf9f8", + //"editorGutter.background": "#fbf9f8", + //"editorGutter.commentGlyphForeground": "#372f28", + //"editorGutter.commentRangeForeground": "#ebe4de", + //"editorGutter.commentUnresolvedGlyphForeground": "#372f28", + //"editorGutter.foldingControlForeground": "#6b5b50", + //"editorHint.foreground": "#6c6c6c", + //"editorHoverWidget.background": "#fbf9f8", + //"editorHoverWidget.border": "#00000000", + //"editorHoverWidget.foreground": "#6b5b50", + //"editorHoverWidget.highlightForeground": "#ab323a", + //"editorHoverWidget.statusBarBackground": "#f2ebe8", + //"editorIndentGuide.activeBackground": "#eae1db", + //"editorIndentGuide.activeBackground1": "#eae1db", + //"editorIndentGuide.activeBackground2": "#00000000", + //"editorIndentGuide.activeBackground3": "#00000000", + //"editorIndentGuide.activeBackground4": "#00000000", + //"editorIndentGuide.activeBackground5": "#00000000", + //"editorIndentGuide.activeBackground6": "#00000000", + //"editorIndentGuide.background": "#eae1db", + //"editorIndentGuide.background1": "#eae1db", + //"editorIndentGuide.background2": "#00000000", + //"editorIndentGuide.background3": "#00000000", + //"editorIndentGuide.background4": "#00000000", + //"editorIndentGuide.background5": "#00000000", + //"editorIndentGuide.background6": "#00000000", + //"editorInfo.foreground": "#1a85ff", + //"editorInlayHint.background": "#c4c4c41a", + //"editorInlayHint.foreground": "#969696", + //"editorInlayHint.parameterBackground": "#c4c4c41a", + //"editorInlayHint.parameterForeground": "#969696", + //"editorInlayHint.typeBackground": "#c4c4c41a", + //"editorInlayHint.typeForeground": "#969696", + //"editorLightBulb.foreground": "#ddb100", + //"editorLightBulbAi.foreground": "#ddb100", + //"editorLightBulbAutoFix.foreground": "#007acc", + //"editorMarkerNavigation.background": "#fbf9f8", + //"editorMarkerNavigationError.background": "#e51400", + //"editorMarkerNavigationError.headerBackground": "#e514001a", + //"editorMarkerNavigationInfo.background": "#1a85ff", + //"editorMarkerNavigationInfo.headerBackground": "#1a85ff1a", + //"editorMarkerNavigationWarning.background": "#bf8803", + //"editorMarkerNavigationWarning.headerBackground": "#bf88031a", + //"editorMultiCursor.primary.foreground": "#ab323a", + //"editorMultiCursor.secondary.foreground": "#ab323a", + //"editorOverviewRuler.addedForeground": "#da99ae99", + //"editorOverviewRuler.border": "#7f7f7f4d", + //"editorOverviewRuler.bracketMatchForeground": "#a0a0a0", + //"editorOverviewRuler.commentForeground": "#ebe4de", + //"editorOverviewRuler.commentUnresolvedForeground": "#ebe4de", + //"editorOverviewRuler.commonContentForeground": "#60606066", + //"editorOverviewRuler.currentContentForeground": "#40c8ae80", + //"editorOverviewRuler.deletedForeground": "#95acd699", + //"editorOverviewRuler.errorForeground": "#ff1212b3", + //"editorOverviewRuler.findMatchForeground": "#d186167e", + //"editorOverviewRuler.incomingContentForeground": "#40a6ff80", + //"editorOverviewRuler.infoForeground": "#1a85ff", + //"editorOverviewRuler.inlineChatInserted": "#9ccc2c33", + //"editorOverviewRuler.inlineChatRemoved": "#ff000029", + //"editorOverviewRuler.modifiedForeground": "#bba1d699", + //"editorOverviewRuler.rangeHighlightForeground": "#007acc99", + //"editorOverviewRuler.selectionHighlightForeground": "#a0a0a0cc", + //"editorOverviewRuler.warningForeground": "#bf8803", + //"editorOverviewRuler.wordHighlightForeground": "#a0a0a0cc", + //"editorOverviewRuler.wordHighlightStrongForeground": "#c0a0c0cc", + //"editorOverviewRuler.wordHighlightTextForeground": "#a0a0a0cc", + //"editorPane.background": "#fbf9f8", + //"editorStickyScroll.background": "#fbf9f8", + //"editorStickyScroll.shadow": "#dddddd", + //"editorStickyScrollHover.background": "#f0f0f0", + //"editorSuggestWidget.background": "#fbf9f8", + //"editorSuggestWidget.border": "#00000000", + //"editorSuggestWidget.focusHighlightForeground": "#ab323a", + //"editorSuggestWidget.foreground": "#372f28", + //"editorSuggestWidget.selectedForeground": "#50443c", + //"editorSuggestWidgetStatus.foreground": "#372f2880", + //"editorUnicodeHighlight.border": "#bf8803", + //"editorUnnecessaryCode.opacity": "#00000077", + //"editorWarning.foreground": "#bf8803", + //"editorWatermark.foreground": "#372f28ad", + //"extensionBadge.remoteBackground": "#d9aeb0", + //"extensionBadge.remoteForeground": "#ab323a", + //"extensionButton.background": "#ab323a", + //"extensionButton.foreground": "#fbeeee", + //"extensionButton.hoverBackground": "#d5404b", + //"extensionButton.prominentBackground": "#ab323a", + //"extensionButton.prominentForeground": "#fbeeee", + //"extensionButton.prominentHoverBackground": "#d5404b", + //"extensionButton.separator": "#fbeeee66", + //"extensionIcon.preReleaseForeground": "#1d9271", + //"extensionIcon.sponsorForeground": "#b51e78", + //"extensionIcon.starForeground": "#df6100", + //"extensionIcon.verifiedForeground": "#3f5374", + //"git.blame.editorDecorationForeground": "#919191", + //"gitDecoration.renamedResourceForeground": "#007100", + //"gitDecoration.stageDeletedResourceForeground": "#ad0707", + //"gitDecoration.stageModifiedResourceForeground": "#895503", + //"inlineChat.background": "#fbf9f8", + //"inlineChat.border": "#00000000", + //"inlineChat.foreground": "#6b5b50", + //"inlineChat.shadow": "#372f2810", + //"inlineChatDiff.inserted": "#9ccc2c20", + //"inlineChatDiff.removed": "#ff00001a", + //"inlineChatInput.background": "#ffffff", + //"inlineChatInput.border": "#00000000", + //"inlineChatInput.focusBorder": "#d9aeb0", + //"inlineChatInput.placeholderForeground": "#372f2880", + //"inlineEdit.border": "#cacaca", + //"inlineEdit.indicator.background": "#ab323a", + //"inlineEdit.indicator.border": "#fbeeee66", + //"inlineEdit.indicator.foreground": "#fbeeee", + //"inlineEdit.modifiedBackground": "#9ccc2c1a", + //"inlineEdit.modifiedChangedLineBackground": "#00000000", + //"inlineEdit.modifiedChangedTextBackground": "#9ccc2c40", + //"inlineEdit.originalBackground": "#ff000014", + //"inlineEdit.originalChangedLineBackground": "#00000000", + //"inlineEdit.originalChangedTextBackground": "#ff000033", + //"input.background": "#ffffff", + //"input.foreground": "#372f28", + //"input.placeholderForeground": "#372f2880", + //"inputOption.activeBackground": "#d9aeb033", + //"inputOption.activeBorder": "#007acc", + //"inputOption.activeForeground": "#000000", + //"inputOption.hoverBackground": "#b8b8b850", + //"inputValidation.errorBackground": "#f2dede", + //"inputValidation.errorBorder": "#be1100", + //"inputValidation.infoBackground": "#d6ecf2", + //"inputValidation.infoBorder": "#007acc", + //"inputValidation.warningBackground": "#f6f5d2", + //"inputValidation.warningBorder": "#b89500", + //"interactive.activeCodeBorder": "#007acc", + //"interactive.inactiveCodeBorder": "#f4f0ed", + //"keybindingLabel.background": "#dddddd66", + //"keybindingLabel.border": "#cccccc66", + //"keybindingLabel.bottomBorder": "#bbbbbb66", + //"keybindingLabel.foreground": "#555555", + //"keybindingTable.headerBackground": "#372f280a", + //"keybindingTable.rowsBackground": "#372f280a", + //"list.deemphasizedForeground": "#8e8e90", + //"list.dropBetweenBackground": "#6b5b50", + //"list.errorForeground": "#b01011", + //"list.filterMatchBackground": "#ea5c0055", + //"list.focusHighlightForeground": "#ab323a", + //"list.focusOutline": "#d9aeb0", + //"list.invalidItemForeground": "#b89500", + //"list.warningForeground": "#855f00", + //"listFilterWidget.background": "#fbf9f8", + //"listFilterWidget.noMatchesOutline": "#be1100", + //"listFilterWidget.outline": "#00000000", + //"listFilterWidget.shadow": "#372f2810", + //"menu.background": "#f4f0ed", + //"menu.foreground": "#50443c", + //"menu.selectionBackground": "#eae1db", + //"menu.selectionForeground": "#50443c", + //"menu.separatorBackground": "#d4d4d4", + //"menubar.selectionBackground": "#b8b8b850", + //"menubar.selectionForeground": "#867466", + //"merge.commonContentBackground": "#60606029", + //"merge.commonHeaderBackground": "#60606066", + //"merge.currentContentBackground": "#40c8ae33", + //"merge.currentHeaderBackground": "#40c8ae80", + //"merge.incomingContentBackground": "#40a6ff33", + //"merge.incomingHeaderBackground": "#40a6ff80", + //"mergeEditor.change.background": "#9bb95533", + //"mergeEditor.change.word.background": "#9ccc2c66", + //"mergeEditor.changeBase.background": "#ffcccc", + //"mergeEditor.changeBase.word.background": "#ffa3a3", + //"mergeEditor.conflict.handled.minimapOverViewRuler": "#adaca8ee", + //"mergeEditor.conflict.handledFocused.border": "#c1c1c1cc", + //"mergeEditor.conflict.handledUnfocused.border": "#86868649", + //"mergeEditor.conflict.input1.background": "#40c8ae33", + //"mergeEditor.conflict.input2.background": "#40a6ff33", + //"mergeEditor.conflict.unhandled.minimapOverViewRuler": "#fcba03", + //"mergeEditor.conflict.unhandledFocused.border": "#ffa600", + //"mergeEditor.conflict.unhandledUnfocused.border": "#ffa600", + //"mergeEditor.conflictingLines.background": "#ffea0047", + //"minimap.foregroundOpacity": "#000000", + //"minimap.infoHighlight": "#1a85ff", + //"minimap.selectionOccurrenceHighlight": "#c9c9c9", + //"multiDiffEditor.background": "#fbf9f8", + //"multiDiffEditor.border": "#cccccc", + //"multiDiffEditor.headerBackground": "#f4f0ed", + //"notebook.cellBorderColor": "#f4f0ed", + //"notebook.cellEditorBackground": "#f4f0ed", + //"notebook.cellInsertionIndicator": "#d9aeb0", + //"notebook.cellStatusBarItemHoverBackground": "#00000014", + //"notebook.cellToolbarSeparator": "#80808059", + //"notebook.editorBackground": "#fbf9f8", + //"notebook.focusedCellBorder": "#d9aeb0", + //"notebook.focusedEditorBorder": "#d9aeb0", + //"notebook.inactiveFocusedCellBorder": "#f4f0ed", + //"notebook.selectedCellBackground": "#f4f0ed", + //"notebook.selectedCellBorder": "#f4f0ed", + //"notebook.symbolHighlightBackground": "#fdff0033", + //"notebookEditorOverviewRuler.runningCellForeground": "#388a34", + //"notebookScrollbarSlider.activeBackground": "#00000099", + //"notebookScrollbarSlider.background": "#64646466", + //"notebookScrollbarSlider.hoverBackground": "#646464b3", + //"notebookStatusErrorIcon.foreground": "#ab323a", + //"notebookStatusRunningIcon.foreground": "#372f28", + //"notebookStatusSuccessIcon.foreground": "#388a34", + //"notificationCenterHeader.background": "#f2ebe8", + //"notificationLink.foreground": "#3f5374", + //"notifications.background": "#fbf9f8", + //"notifications.border": "#f2ebe8", + //"notifications.foreground": "#6b5b50", + //"notificationsErrorIcon.foreground": "#e51400", + //"notificationsInfoIcon.foreground": "#1a85ff", + //"notificationsWarningIcon.foreground": "#bf8803", + //"outlineMap.focusingItemBackground": "#f4f0ed", + //"outlineMap.focusingItemForeground": "#50443c", + //"outlineMap.visibleRangeBackground": "#f4f0ed", + //"panel.background": "#fbf9f8", + //"panel.border": "#80808059", + //"panel.dropBorder": "#424242", + //"panelInput.border": "#dddddd", + //"panelSection.border": "#80808059", + //"panelSection.dropBackground": "#2677cb2e", + //"panelSectionHeader.background": "#80808033", + //"panelStickyScroll.background": "#fbf9f8", + //"panelStickyScroll.shadow": "#dddddd", + //"panelTitle.activeBorder": "#424242", + //"panelTitle.activeForeground": "#424242", + //"panelTitle.inactiveForeground": "#424242bf", + //"peekView.border": "#1a85ff", + //"peekViewEditor.background": "#f2f8fc", + //"peekViewEditor.matchHighlightBackground": "#f5d802de", + //"peekViewEditorGutter.background": "#f2f8fc", + //"peekViewEditorStickyScroll.background": "#f2f8fc", + //"peekViewResult.background": "#f3f3f3", + //"peekViewResult.fileForeground": "#1e1e1e", + //"peekViewResult.lineForeground": "#646465", + //"peekViewResult.matchHighlightBackground": "#ea5c004d", + //"peekViewResult.selectionBackground": "#3399ff33", + //"peekViewResult.selectionForeground": "#6c6c6c", + //"peekViewTitle.background": "#f3f3f3", + //"peekViewTitleDescription.foreground": "#616161", + //"peekViewTitleLabel.foreground": "#000000", + //"ports.iconRunningProcessForeground": "#d9aeb0", + //"problemsErrorIcon.foreground": "#e51400", + //"problemsInfoIcon.foreground": "#1a85ff", + //"problemsWarningIcon.foreground": "#bf8803", + //"profileBadge.background": "#c4c4c4", + //"profileBadge.foreground": "#333333", + //"profiles.sashBorder": "#80808059", + //"progressBar.background": "#0e70c0", + //"quickInput.background": "#fbf9f8", + //"quickInput.foreground": "#6b5b50", + //"quickInputList.focusBackground": "#eae1db", + //"quickInputList.focusForeground": "#50443c", + //"quickInputTitle.background": "#0000000f", + //"radio.activeBackground": "#d9aeb033", + //"radio.activeBorder": "#007acc", + //"radio.activeForeground": "#000000", + //"radio.inactiveBorder": "#00000033", + //"radio.inactiveHoverBackground": "#b8b8b850", + //"sash.hoverBorder": "#d9aeb0", + //"scmGraph.foreground1": "#ffb000", + //"scmGraph.foreground2": "#dc267f", + //"scmGraph.foreground3": "#994f00", + //"scmGraph.foreground4": "#40b0a6", + //"scmGraph.foreground5": "#b66dff", + //"scmGraph.historyItemBaseRefColor": "#ea5c00", + //"scmGraph.historyItemHoverAdditionsForeground": "#587c0c", + //"scmGraph.historyItemHoverDefaultLabelBackground": "#c4c4c4", + //"scmGraph.historyItemHoverDefaultLabelForeground": "#372f28", + //"scmGraph.historyItemHoverDeletionsForeground": "#ad0707", + //"scmGraph.historyItemHoverLabelForeground": "#fbeeee", + //"scmGraph.historyItemRefColor": "#1a85ff", + //"scmGraph.historyItemRemoteRefColor": "#652d90", + //"scrollbar.shadow": "#dddddd", + //"scrollbarSlider.activeBackground": "#00000099", + //"scrollbarSlider.background": "#64646466", + //"scrollbarSlider.hoverBackground": "#646464b3", + //"search.resultsInfoForeground": "#372f28", + //"searchEditor.findMatchBackground": "#ea5c0038", + //"settings.checkboxBackground": "#f4f0ed", + //"settings.checkboxBorder": "#f4f0ed", + //"settings.checkboxForeground": "#6b5b50", + //"settings.dropdownBackground": "#f4f0ed", + //"settings.dropdownBorder": "#f4f0ed", + //"settings.dropdownForeground": "#50443c", + //"settings.dropdownListBorder": "#00000000", + //"settings.focusedRowBackground": "#f4f0ed99", + //"settings.focusedRowBorder": "#d9aeb0", + //"settings.headerBorder": "#80808059", + //"settings.headerForeground": "#444444", + //"settings.numberInputBackground": "#ffffff", + //"settings.numberInputForeground": "#372f28", + //"settings.rowHoverBackground": "#f4f0ed4d", + //"settings.sashBorder": "#80808059", + //"settings.settingsHeaderHoverForeground": "#444444b3", + //"settings.textInputBackground": "#ffffff", + //"settings.textInputForeground": "#372f28", + //"sideBar.dropBackground": "#2677cb2e", + //"sideBarStickyScroll.background": "#f4f0ed", + //"sideBarStickyScroll.shadow": "#dddddd", + //"sideBarTitle.background": "#f4f0ed", + //"sideBySideEditor.horizontalBorder": "#eae1db", + //"sideBySideEditor.verticalBorder": "#eae1db", + //"simpleFindWidget.sashBorder": "#c8c8c8", + //"statusBar.focusBorder": "#867466", + //"statusBarItem.activeBackground": "#ffffff2e", + //"statusBarItem.compactHoverBackground": "#ffffff33", + //"statusBarItem.errorBackground": "#671e23", + //"statusBarItem.errorForeground": "#ffffff", + //"statusBarItem.errorHoverBackground": "#e1d2c8", + //"statusBarItem.errorHoverForeground": "#867466", + //"statusBarItem.focusBorder": "#867466", + //"statusBarItem.hoverForeground": "#867466", + //"statusBarItem.offlineBackground": "#6c1717", + //"statusBarItem.offlineForeground": "#ab323a", + //"statusBarItem.offlineHoverBackground": "#e1d2c8", + //"statusBarItem.offlineHoverForeground": "#867466", + //"statusBarItem.prominentBackground": "#00000080", + //"statusBarItem.prominentForeground": "#867466", + //"statusBarItem.prominentHoverBackground": "#0000004d", + //"statusBarItem.prominentHoverForeground": "#867466", + //"statusBarItem.remoteBackground": "#d9aeb0", + //"statusBarItem.remoteForeground": "#ab323a", + //"statusBarItem.remoteHoverBackground": "#e1d2c8", + //"statusBarItem.remoteHoverForeground": "#867466", + //"statusBarItem.warningBackground": "#725102", + //"statusBarItem.warningForeground": "#ffffff", + //"statusBarItem.warningHoverBackground": "#e1d2c8", + //"statusBarItem.warningHoverForeground": "#867466", + //"symbolIcon.arrayForeground": "#372f28", + //"symbolIcon.booleanForeground": "#372f28", + //"symbolIcon.classForeground": "#d67e00", + //"symbolIcon.colorForeground": "#372f28", + //"symbolIcon.constantForeground": "#372f28", + //"symbolIcon.constructorForeground": "#652d90", + //"symbolIcon.enumeratorForeground": "#d67e00", + //"symbolIcon.enumeratorMemberForeground": "#007acc", + //"symbolIcon.eventForeground": "#d67e00", + //"symbolIcon.fieldForeground": "#007acc", + //"symbolIcon.fileForeground": "#372f28", + //"symbolIcon.folderForeground": "#372f28", + //"symbolIcon.functionForeground": "#652d90", + //"symbolIcon.interfaceForeground": "#007acc", + //"symbolIcon.keyForeground": "#372f28", + //"symbolIcon.keywordForeground": "#372f28", + //"symbolIcon.methodForeground": "#652d90", + //"symbolIcon.moduleForeground": "#372f28", + //"symbolIcon.namespaceForeground": "#372f28", + //"symbolIcon.nullForeground": "#372f28", + //"symbolIcon.numberForeground": "#372f28", + //"symbolIcon.objectForeground": "#372f28", + //"symbolIcon.om_RegionForeground": "#372f28", + //"symbolIcon.om_TagForeground": "#372f28", + //"symbolIcon.operatorForeground": "#372f28", + //"symbolIcon.packageForeground": "#372f28", + //"symbolIcon.propertyForeground": "#372f28", + //"symbolIcon.referenceForeground": "#372f28", + //"symbolIcon.snippetForeground": "#372f28", + //"symbolIcon.stringForeground": "#372f28", + //"symbolIcon.structForeground": "#372f28", + //"symbolIcon.textForeground": "#372f28", + //"symbolIcon.typeParameterForeground": "#372f28", + //"symbolIcon.unitForeground": "#372f28", + //"symbolIcon.variableForeground": "#007acc", + //"tab.activeModifiedBorder": "#33aaee", + //"tab.dragAndDropBorder": "#50443c", + //"tab.inactiveModifiedBorder": "#33aaee80", + //"tab.lastPinnedBorder": "#a9a9a9", + //"tab.selectedBackground": "#f0eae6", + //"tab.selectedForeground": "#50443c", + //"tab.unfocusedActiveBackground": "#f0eae6", + //"tab.unfocusedActiveBorder": "#50443cb3", + //"tab.unfocusedActiveForeground": "#50443cb3", + //"tab.unfocusedActiveModifiedBorder": "#33aaeeb3", + //"tab.unfocusedInactiveBackground": "#f4f0ed", + //"tab.unfocusedInactiveForeground": "#c0a69380", + //"tab.unfocusedInactiveModifiedBorder": "#33aaee40", + //"terminal.border": "#80808059", + //"terminal.dropBackground": "#2677cb2e", + //"terminal.findMatchBackground": "#a8ac94", + //"terminal.findMatchHighlightBackground": "#ea5c0055", + //"terminal.hoverHighlightBackground": "#eae1db80", + //"terminal.inactiveSelectionBackground": "#c0a69380", + //"terminal.initialHintForeground": "#00000077", + //"terminal.tab.activeBorder": "#50443c", + //"terminalCommandDecoration.defaultBackground": "#00000040", + //"terminalCommandDecoration.errorBackground": "#e51400", + //"terminalCommandDecoration.successBackground": "#2090d3", + //"terminalCommandGuide.foreground": "#f4f0ed", + //"terminalOverviewRuler.border": "#7f7f7f4d", + //"terminalOverviewRuler.cursorForeground": "#a0a0a0cc", + //"terminalOverviewRuler.findMatchForeground": "#d186167e", + //"terminalStickyScrollHover.background": "#f0f0f0", + //"testing.coverCountBadgeBackground": "#c4c4c4", + //"testing.coverCountBadgeForeground": "#333333", + //"testing.coveredBackground": "#9ccc2c40", + //"testing.coveredBorder": "#9ccc2c30", + //"testing.coveredGutterBackground": "#9ccc2c27", + //"testing.iconErrored": "#f14c4c", + //"testing.iconErrored.retired": "#f14c4cb3", + //"testing.iconFailed": "#f14c4c", + //"testing.iconFailed.retired": "#f14c4cb3", + //"testing.iconPassed": "#73c991", + //"testing.iconPassed.retired": "#73c991b3", + //"testing.iconQueued": "#cca700", + //"testing.iconQueued.retired": "#cca700b3", + //"testing.iconSkipped": "#848484", + //"testing.iconSkipped.retired": "#848484b3", + //"testing.iconUnset": "#848484", + //"testing.iconUnset.retired": "#848484b3", + //"testing.message.error.badgeBackground": "#e51400", + //"testing.message.error.badgeBorder": "#e51400", + //"testing.message.error.badgeForeground": "#ffffff", + //"testing.message.info.decorationForeground": "#372f2880", + //"testing.messagePeekBorder": "#1a85ff", + //"testing.messagePeekHeaderBackground": "#1a85ff1a", + //"testing.peekBorder": "#e51400", + //"testing.peekHeaderBackground": "#e514001a", + //"testing.runAction": "#73c991", + //"testing.uncoveredBackground": "#ff000033", + //"testing.uncoveredBorder": "#ff000026", + //"testing.uncoveredBranchBackground": "#fc9594", + //"testing.uncoveredGutterBackground": "#ff00004d", + //"textPreformat.background": "#0000001a", + //"toolbar.activeBackground": "#a6a6a650", + //"toolbar.hoverBackground": "#b8b8b850", + //"tree.inactiveIndentGuidesStroke": "#a9a9a966", + //"tree.indentGuidesStroke": "#a9a9a9", + //"tree.tableColumnsBorder": "#61616120", + //"tree.tableOddRowsBackground": "#372f280a", + //"walkThrough.embeddedEditorBackground": "#f4f4f4", + //"walkthrough.stepTitle.foreground": "#000000", + //"welcomePage.progress.background": "#ffffff", + //"welcomePage.progress.foreground": "#3f5374", + //"welcomePage.tileBackground": "#fbf9f8", + //"welcomePage.tileBorder": "#0000001a", + //"welcomePage.tileHoverBackground": "#e9ded8", + //"activityBar.activeBackground": null, + //"activityBar.activeFocusBorder": null, + //"activityBarTop.activeBackground": null, + //"activityBarTop.background": null, + //"button.border": null, + //"contrastActiveBorder": null, + //"contrastBorder": null, + //"debugToolBar.border": null, + //"diffEditor.border": null, + //"diffEditor.insertedTextBorder": null, + //"diffEditor.removedTextBorder": null, + //"diffEditorGutter.insertedLineBackground": null, + //"diffEditorGutter.removedLineBackground": null, + //"diffEditorOverview.insertedForeground": null, + //"diffEditorOverview.removedForeground": null, + //"editor.findMatchBorder": null, + //"editor.findMatchForeground": null, + //"editor.findMatchHighlightBorder": null, + //"editor.findMatchHighlightForeground": null, + //"editor.findRangeHighlightBorder": null, + //"editor.lineHighlightBackground": null, + //"editor.rangeHighlightBorder": null, + //"editor.selectionHighlightBorder": null, + //"editor.snippetFinalTabstopHighlightBackground": null, + //"editor.snippetTabstopHighlightBorder": null, + //"editor.symbolHighlightBorder": null, + //"editor.wordHighlightBorder": null, + //"editor.wordHighlightStrongBorder": null, + //"editor.wordHighlightTextBorder": null, + //"editorCursor.background": null, + //"editorError.background": null, + //"editorError.border": null, + //"editorGhostText.background": null, + //"editorGhostText.border": null, + //"editorGroup.dropIntoPromptBorder": null, + //"editorGroup.emptyBackground": null, + //"editorGroup.focusedEmptyBorder": null, + //"editorHint.border": null, + //"editorInfo.background": null, + //"editorInfo.border": null, + //"editorLineNumber.dimmedForeground": null, + //"editorMultiCursor.primary.background": null, + //"editorMultiCursor.secondary.background": null, + //"editorOverviewRuler.background": null, + //"editorStickyScroll.border": null, + //"editorSuggestWidget.selectedIconForeground": null, + //"editorUnicodeHighlight.background": null, + //"editorUnnecessaryCode.border": null, + //"editorWarning.background": null, + //"editorWarning.border": null, + //"editorWidget.resizeBorder": null, + //"input.border": null, + //"inputValidation.errorForeground": null, + //"inputValidation.infoForeground": null, + //"inputValidation.warningForeground": null, + //"list.activeSelectionIconForeground": null, + //"list.filterMatchBorder": null, + //"list.focusAndSelectionOutline": null, + //"list.inactiveFocusOutline": null, + //"list.inactiveSelectionIconForeground": null, + //"menu.border": null, + //"menu.selectionBorder": null, + //"menubar.selectionBorder": null, + //"merge.border": null, + //"minimap.background": null, + //"notebook.cellHoverBackground": null, + //"notebook.focusedCellBackground": null, + //"notebook.inactiveSelectedCellBorder": null, + //"notebook.outputContainerBackgroundColor": null, + //"notebook.outputContainerBorderColor": null, + //"notificationCenter.border": null, + //"notificationCenterHeader.foreground": null, + //"notificationToast.border": null, + //"outputView.background": null, + //"outputViewStickyScroll.background": null, + //"panelSectionHeader.border": null, + //"panelSectionHeader.foreground": null, + //"panelStickyScroll.border": null, + //"panelTitle.border": null, + //"peekViewEditor.matchHighlightBorder": null, + //"quickInput.list.focusBackground": null, + //"quickInputList.focusIconForeground": null, + //"radio.inactiveBackground": null, + //"radio.inactiveForeground": null, + //"searchEditor.findMatchBorder": null, + //"searchEditor.textInputBorder": null, + //"settings.numberInputBorder": null, + //"settings.textInputBorder": null, + //"sideBar.foreground": null, + //"sideBarActivityBarTop.border": null, + //"sideBarSectionHeader.border": null, + //"sideBarStickyScroll.border": null, + //"sideBarTitle.border": null, + //"sideBarTitle.foreground": null, + //"tab.activeBorderTop": null, + //"tab.hoverBackground": null, + //"tab.hoverBorder": null, + //"tab.hoverForeground": null, + //"tab.selectedBorderTop": null, + //"tab.unfocusedActiveBorderTop": null, + //"tab.unfocusedHoverBackground": null, + //"tab.unfocusedHoverBorder": null, + //"tab.unfocusedHoverForeground": null, + //"terminal.findMatchBorder": null, + //"terminal.findMatchHighlightBorder": null, + //"terminal.selectionForeground": null, + //"terminalStickyScroll.background": null, + //"terminalStickyScroll.border": null, + //"testing.message.error.lineBackground": null, + //"testing.message.info.lineBackground": null, + //"toolbar.hoverOutline": null, + //"welcomePage.background": null, + //"widget.border": null + }, + "tokenColors": [ + { + "scope": "comment", + "settings": { + "foreground": "#98595B", + "fontStyle": "bold" + } + }, + { + "scope": "keyword", + "settings": { + "fontStyle": "bold" + } + }, + { + "scope": "storage", + "settings": { + "fontStyle": "bold" + } + }, + { + "scope": "entity.name.type", + "settings": { + "fontStyle": "italic" + } + }, + { + "scope": "punctuation.separator", + "settings": { + "foreground": "#B19988" + } + }, + { + "scope": "punctuation.terminator", + "settings": { + "foreground": "#B19988" + } + }, + { + "scope": "string", + "settings": { + "foreground": "#5D5046", + "fontStyle": "italic" + } + }, + { + "scope": "punctuation", + "settings": { + "foreground": "#CFB49F", + "fontStyle": "bold" + } + }, + { + "scope": "meta.brace", + "settings": { + "foreground": "#CFB49F", + "fontStyle": "bold" + } + }, + { + "scope": "string.unquoted.plain.out.yaml", + "settings": { + "foreground": "#867466", + "fontStyle": "normal" + } + }, + { + "scope": "string.quoted.double.yaml", + "settings": { + "foreground": "#867466", + "fontStyle": "normal" + } + }, + { + "scope": "string.quoted.double.json", + "settings": { + "foreground": "#867466", + "fontStyle": "normal" + } + }, + { + "scope": "constant.numeric.json", + "settings": { + "foreground": "#867466", + "fontStyle": "bold" + } + }, + { + "scope": "constant.numeric.integer.yaml", + "settings": { + "foreground": "#867466", + "fontStyle": "bold" + } + }, + { + "scope": "constant.numeric.float.yaml", + "settings": { + "foreground": "#867466", + "fontStyle": "bold" + } + }, + { + "scope": "constant.language.json", + "settings": { + "foreground": "#867466", + "fontStyle": "bold" + } + }, + { + "scope": "constant.language.boolean.yaml", + "settings": { + "foreground": "#867466", + "fontStyle": "bold" + } + }, + { + "scope": "support.type.property-name.json", + "settings": { + "foreground": "#6B5B50", + "fontStyle": "bold" + } + }, + { + "scope": "entity.name.tag.yaml", + "settings": { + "foreground": "#6B5B50", + "fontStyle": "bold" + } + }, + { + "scope": "markup.heading", + "settings": { + "fontStyle": "bold" + } + }, + { + "scope": "markup.inline", + "settings": { + "foreground": "#5D5046" + } + }, + { + "scope": "markup.italic", + "settings": { + "fontStyle": "italic" + } + }, + { + "scope": "markup.bold", + "settings": { + "fontStyle": "bold" + } + }, + { + "scope": "markup.quote", + "settings": { + "foreground": "#5D5046", + "fontStyle": "italic" + } + }, + { + "scope": "markup.raw.block", + "settings": { + "foreground": "#5D5046" + } + }, + { + "scope": "markup.fenced_code", + "settings": { + "foreground": "#5D5046" + } + }, + { + "scope": "fenced_code.block.language", + "settings": { + "foreground": "#A38C7C" + } + }, + { + "scope": [ + "sectors.general.mas" + ], + "settings": { + "foreground": "#E0D978", + "fontStyle": "bold" + } + }, + { + "scope": [ + "sectors.directive.mas", + "sectors.directors.mas", + "sectors.contextdirectors.mas" + ], + "settings": { + "foreground": "#FFC400", + "fontStyle": "bold" + } + }, + { + "scope": [ + "symbols.parameters.mas", + "operators.inference.mas", + "operators.access.mas", + "operators.arithmetic.mas", + "operators.comparison.mas", + "operators.declaration.mas" + ], + "settings": { + "foreground": "#4DF9FF" + } + }, + { + "scope": [ + "literals.address", + "literals.boolean.mas", + "literals.integer.mas", + "strings.quoted.single.mas", + "strings.quoted.double.mas" + ], + "settings": { + "foreground": "#8DFFA6" + } + }, + { + "scope": [ + "sectors.control.mas", + "sectors.execution.mas" + ], + "settings": { + "foreground": "#26FF00" + } + }, + { + "scope": [ + "builtins.functions.mas", + "operators.control.mas", + "sectors.memory.mas", + "sectors.macros.mas" + ], + "settings": { + "foreground": "#FF0000", + "fontStyle": "bold" + } + }, + { + "scope": [ + "formatting", + "formmatting.comments" + ], + "settings": { + "foreground": "#817A6C", + "fontStyle": "italic bold" + } + }, + { + "scope": [ + "symbols.sma" + ], + "settings": { + "foreground": "#6F7ED3" + } + }, + { + "scope": [ + "builtins.types" + ], + "settings": { + "foreground": "#A898DB", + "fontStyle": "bold" + } + }, + { + "scope": "token.info-token", + "settings": { + "foreground": "#316BCD" + } + }, + { + "scope": "token.warn-token", + "settings": { + "foreground": "#CD9731" + } + }, + { + "scope": "token.error-token", + "settings": { + "foreground": "#CD3131" + } + }, + { + "scope": "token.debug-token", + "settings": { + "foreground": "#800080" + } + } + ] +} \ No newline at end of file diff --git a/gen_c_library/c_library.cpp b/gen_c_library/c_library.cpp index 0c633c6..e89c66a 100644 --- a/gen_c_library/c_library.cpp +++ b/gen_c_library/c_library.cpp @@ -1,8 +1,6 @@ #define GEN_DEFINE_LIBRARY_CODE_CONSTANTS #define GEN_ENFORCE_STRONG_CODE_TYPES #define GEN_EXPOSE_BACKEND -#define GEN_SUPPORT_CPP_MEMBER_FEATURES 1 -#define GEN_SUPPORT_CPP_REFERENCES 1 #include "../project/gen.cpp" #include "helpers/push_ignores.inline.hpp" @@ -97,6 +95,8 @@ CodeBody parse_file( const char* path ) return code; } +constexpr bool helper_use_c_definition = true; + int gen_main() { #define project_dir "../project/" @@ -138,7 +138,7 @@ int gen_main() if (using_ver->UnderlyingType->ReturnType) { CodeTypename type = using_ver->UnderlyingType; - CodeTypedef typedef_ver = parse_typedef(token_fmt( + CodeTypedef typedef_ver = parse_typedef(token_fmt( "ReturnType", to_string(type->ReturnType).to_strc() , "Name" , using_ver->Name , "Parameters", to_string(type->Params).to_strc() @@ -170,10 +170,12 @@ int gen_main() Code inlines = scan_file( project_dir "components/inlines.hpp" ); Code header_end = scan_file( project_dir "components/header_end.hpp" ); - CodeBody ecode = gen_ecode ( project_dir "enums/ECode.csv" ); - CodeBody eoperator = gen_eoperator ( project_dir "enums/EOperator.csv" ); - CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv" ); - CodeBody ast_inlines = gen_ast_inlines(); + CodeBody ecode = gen_ecode ( project_dir "enums/ECode.csv", helper_use_c_definition ); + CodeBody eoperator = gen_eoperator ( project_dir "enums/EOperator.csv", helper_use_c_definition ); + CodeBody especifier = gen_especifier( project_dir "enums/ESpecifier.csv", helper_use_c_definition ); + + // Only has operator overload definitions that C doesn't need. + // CodeBody ast_inlines = gen_ast_inlines(); CodeBody parsed_ast = parse_file( project_dir "components/ast.hpp" ); CodeBody ast = def_body(CT_Global_Body); @@ -185,7 +187,7 @@ int gen_main() CodePreprocessCond cond = cast(CodePreprocessCond, entry); if (cond->Content.contains(txt("GEN_COMPILER_C"))) { - //++ entry; // + //++ entry; // //ast.append(entry) // typedef //for ( ; entry != parsed_ast.end() && entry->Type != CT_Preprocess_EndIf; ++ entry) {} //++ entry; // Consume endif @@ -292,15 +294,13 @@ R"(#define AST_ArrSpecs_Cap \ case CT_Function: { CodeFn fn = cast(CodeFn, entry); - s32 constexpr_found = fn->Specs.remove( Spec_Constexpr ); - if (constexpr_found > -1) { - log_fmt("Found constexpr: %S\n", entry.to_string()); - fn->Specs.append(Spec_Inline); + if (fn->Specs) { + s32 constexpr_found = fn->Specs.remove( Spec_Constexpr ); + if (constexpr_found > -1) { + log_fmt("Found constexpr: %S\n", entry.to_string()); + fn->Specs.append(Spec_Inline); + } } - // for ( StrC id : to_rename ) if (fn->Name.is_equal(id)) { - // Array(CodeFn) list = * needs_selectors.get(id); - // list.append(rename_function_to_unique_symbol(fn)); - // } memory.append(fn); } break; diff --git a/gen_singleheader/singleheader.cpp b/gen_singleheader/singleheader.cpp index 0e12511..5226d62 100644 --- a/gen_singleheader/singleheader.cpp +++ b/gen_singleheader/singleheader.cpp @@ -1,8 +1,6 @@ #define GEN_DEFINE_LIBRARY_CODE_CONSTANTS #define GEN_ENFORCE_STRONG_CODE_TYPES #define GEN_EXPOSE_BACKEND -#define GEN_SUPPORT_CPP_MEMBER_FEATURES 1 -#define GEN_SUPPORT_CPP_REFERENCES 0 #include "gen.cpp" #include "helpers/push_ignores.inline.hpp" diff --git a/project/bootstrap.cpp b/project/bootstrap.cpp index 5ed2011..84e436c 100644 --- a/project/bootstrap.cpp +++ b/project/bootstrap.cpp @@ -1,8 +1,7 @@ #define GEN_DEFINE_LIBRARY_CODE_CONSTANTS #define GEN_ENFORCE_STRONG_CODE_TYPES #define GEN_EXPOSE_BACKEND -#define GEN_SUPPORT_CPP_MEMBER_FEATURES 0 -#define GEN_SUPPORT_CPP_REFERENCES 0 +#define GEN_C_LIKE_CPP 1 #include "gen.cpp" #include "helpers/push_ignores.inline.hpp" diff --git a/project/components/ast.cpp b/project/components/ast.cpp index c6c36d9..21e3c33 100644 --- a/project/components/ast.cpp +++ b/project/components/ast.cpp @@ -362,7 +362,9 @@ Code code_duplicate(Code self) { Code result = make_code(); - mem_copy( result.ast, self.ast, sizeof( AST ) ); + void* mem_result = rcast(void*, cast(AST*, result)); + void* mem_self = rcast(void*, cast(AST*, self)); + mem_copy( mem_result, mem_self, sizeof( AST ) ); result->Parent = { nullptr }; return result; @@ -409,173 +411,173 @@ void code_to_string_ptr( Code self, String* result ) break; case CT_Class: - to_string_def(cast(CodeClass, self), result ); + class_to_string_def(cast(CodeClass, self), result ); break; case CT_Class_Fwd: - to_string_fwd(cast(CodeClass, self), result ); + class_to_string_fwd(cast(CodeClass, self), result ); break; case CT_Constructor: - to_string_def(cast(CodeConstructor, self), result ); + constructor_to_string_def(cast(CodeConstructor, self), result ); break; case CT_Constructor_Fwd: - to_string_fwd(cast(CodeConstructor, self), result ); + constructor_to_string_fwd(cast(CodeConstructor, self), result ); break; case CT_Destructor: - to_string_def(cast(CodeDestructor, self), result ); + destructor_to_string_def(cast(CodeDestructor, self), result ); break; case CT_Destructor_Fwd: - to_string_fwd(cast(CodeDestructor, self), result ); + destructor_to_string_fwd(cast(CodeDestructor, self), result ); break; case CT_Enum: - to_string_def(cast(CodeEnum, self), result ); + enum_to_string_def(cast(CodeEnum, self), result ); break; case CT_Enum_Fwd: - to_string_fwd(cast(CodeEnum, self), result ); + enum_to_string_fwd(cast(CodeEnum, self), result ); break; case CT_Enum_Class: - to_string_class_def(cast(CodeEnum, self), result ); + enum_to_string_class_def(cast(CodeEnum, self), result ); break; case CT_Enum_Class_Fwd: - to_string_class_fwd(cast(CodeEnum, self), result ); + enum_to_string_class_fwd(cast(CodeEnum, self), result ); break; case CT_Export_Body: - to_string_export(cast(CodeBody, self), result ); + body_to_string_export(cast(CodeBody, self), result ); break; case CT_Extern_Linkage: - to_string(cast(CodeExtern, self), result ); + extern_to_string(cast(CodeExtern, self), result ); break; case CT_Friend: - to_string(cast(CodeFriend, self), result ); + friend_to_string_ref(cast(CodeFriend, self), result ); break; case CT_Function: - to_string_def(cast(CodeFn, self), result ); + fn_to_string_def(cast(CodeFn, self), result ); break; case CT_Function_Fwd: - to_string_fwd(cast(CodeFn, self), result ); + fn_to_string_fwd(cast(CodeFn, self), result ); break; case CT_Module: - to_string(cast(CodeModule, self), result ); + module_to_string_ref(cast(CodeModule, self), result ); break; case CT_Namespace: - to_string(cast(CodeNS, self), result ); + namespace_to_string_ref(cast(CodeNS, self), result ); break; case CT_Operator: case CT_Operator_Member: - to_string_def(cast(CodeOperator, self), result ); + code_op_to_string_def(cast(CodeOperator, self), result ); break; case CT_Operator_Fwd: case CT_Operator_Member_Fwd: - to_string_fwd(cast(CodeOperator, self), result ); + code_op_to_string_fwd(cast(CodeOperator, self), result ); break; case CT_Operator_Cast: - to_string_def(cast(CodeOpCast, self), result ); + opcast_to_string_def(cast(CodeOpCast, self), result ); break; case CT_Operator_Cast_Fwd: - to_string_fwd(cast(CodeOpCast, self), result ); + opcast_to_string_fwd(cast(CodeOpCast, self), result ); break; case CT_Parameters: - to_string(cast(CodeParam, self), result ); + params_to_string_ref(cast(CodeParam, self), result ); break; case CT_Preprocess_Define: - to_string(cast(CodeDefine, self), result ); + define_to_string_ref(cast(CodeDefine, self), result ); break; case CT_Preprocess_If: - to_string_if(cast(CodePreprocessCond, self), result ); + preprocess_to_string_if(cast(CodePreprocessCond, self), result ); break; case CT_Preprocess_IfDef: - to_string_ifdef(cast(CodePreprocessCond, self), result ); + preprocess_to_string_ifdef(cast(CodePreprocessCond, self), result ); break; case CT_Preprocess_IfNotDef: - to_string_ifndef(cast(CodePreprocessCond, self), result ); + preprocess_to_string_ifndef(cast(CodePreprocessCond, self), result ); break; case CT_Preprocess_Include: - to_string(cast(CodeInclude, self), result ); + include_to_string_ref(cast(CodeInclude, self), result ); break; case CT_Preprocess_ElIf: - to_string_elif(cast(CodePreprocessCond, self), result ); + preprocess_to_string_elif(cast(CodePreprocessCond, self), result ); break; case CT_Preprocess_Else: - to_string_else(cast(CodePreprocessCond, self), result ); + preprocess_to_string_else(cast(CodePreprocessCond, self), result ); break; case CT_Preprocess_EndIf: - to_string_endif(cast(CodePreprocessCond, self), result ); + preprocess_to_string_endif(cast(CodePreprocessCond, self), result ); break; case CT_Preprocess_Pragma: - to_string(cast(CodePragma, self), result ); + pragma_to_string_ref(cast(CodePragma, self), result ); break; case CT_Specifiers: - to_string(cast(CodeSpecifiers, self), result ); + specifiers_to_string_ref(cast(CodeSpecifiers, self), result ); break; case CT_Struct: - to_string_def(cast(CodeStruct, self), result ); + struct_to_string_def(cast(CodeStruct, self), result ); break; case CT_Struct_Fwd: - to_string_fwd(cast(CodeStruct, self), result ); + struct_to_string_fwd(cast(CodeStruct, self), result ); break; case CT_Template: - to_string(cast(CodeTemplate, self), result ); + template_to_string_ref(cast(CodeTemplate, self), result ); break; case CT_Typedef: - to_string(cast(CodeTypedef, self), result ); + typedef_to_string_ref(cast(CodeTypedef, self), result ); break; case CT_Typename: - to_string(cast(CodeTypename, self), result ); + typename_to_string_ref(cast(CodeTypename, self), result ); break; case CT_Union: - to_string_def( cast(CodeUnion, self), result ); + union_to_string_def( cast(CodeUnion, self), result ); break; case CT_Union_Fwd: - to_string_fwd( cast(CodeUnion, self), result ); + union_to_string_fwd( cast(CodeUnion, self), result ); break; case CT_Using: - to_string(cast(CodeUsing, self), result ); + using_to_string_ref(cast(CodeUsing, self), result ); break; case CT_Using_Namespace: - to_string_ns(cast(CodeUsing, self), result ); + using_to_string_ns(cast(CodeUsing, self), result ); break; case CT_Variable: - to_string(cast(CodeVar, self), result ); + var_to_string_ref(cast(CodeVar, self), result ); break; case CT_Enum_Body: @@ -586,7 +588,7 @@ void code_to_string_ptr( Code self, String* result ) case CT_Namespace_Body: case CT_Struct_Body: case CT_Union_Body: - to_string( cast(CodeBody, self), result ); + body_to_string_ref( cast(CodeBody, self), result ); break; } } @@ -1159,20 +1161,20 @@ bool code_is_equal( Code self, Code other ) bool code_validate_body(Code self) { -#define CheckEntries( Unallowed_Types ) \ - do \ - { \ - CodeBody body = cast(CodeBody, self); \ - for ( Code code_entry = begin(body); code_entry != end(body); next(body, code_entry) ) \ - { \ - switch ( code_entry->Type ) \ - { \ - Unallowed_Types \ - log_failure( "AST::validate_body: Invalid entry in body %s", code_debug_str(code_entry) ); \ - return false; \ - } \ - } \ - } \ +#define CheckEntries( Unallowed_Types ) \ + do \ + { \ + CodeBody body = cast(CodeBody, self); \ + for ( Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry) ) \ + { \ + switch ( code_entry->Type ) \ + { \ + Unallowed_Types \ + log_failure( "AST::validate_body: Invalid entry in body %s", code_debug_str(code_entry) ); \ + return false; \ + } \ + } \ + } \ while (0); switch ( self->Type ) @@ -1185,7 +1187,7 @@ bool code_validate_body(Code self) case CT_Enum_Body: { CodeBody body = cast(CodeBody, self); - for ( Code entry = begin(body); entry != end(body); next(body, entry) ) + for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) ) { if ( entry->Type != CT_Untyped ) { @@ -1213,7 +1215,7 @@ bool code_validate_body(Code self) case CT_Global_Body: { CodeBody body = cast(CodeBody, self); - for ( Code entry = begin(body); entry != end(body); next(body, entry) ) + for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) ) { switch (entry->Type) { @@ -1253,7 +1255,7 @@ bool code_validate_body(Code self) case CT_Union_Body: { CodeBody body = cast(CodeBody, self); - for ( Code entry = begin(body); entry != end(body); next(body, entry) ) + for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) ) { if ( entry->Type != CT_Untyped ) { diff --git a/project/components/ast.hpp b/project/components/ast.hpp index f003cc5..fb973aa 100644 --- a/project/components/ast.hpp +++ b/project/components/ast.hpp @@ -6,8 +6,6 @@ #include "gen/especifier.hpp" #endif -GEN_API_C_BEGIN - struct AST; struct AST_Body; struct AST_Attributes; @@ -158,17 +156,20 @@ GEN_NS_PARSER_BEGIN struct Token; GEN_NS_PARSER_END -#define Token_Typedef struct Token Token -typedef Token_Typedef; -#undef Token_Typedef - #if GEN_COMPILER_CPP -GEN_API_C_END -template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast( Type*, & self ); } -GEN_API_C_BEGIN +// Note(Ed): This is to alleviate an edge case with parsing usings or typedefs where I don't really have it setup +// to parse a 'namespace' macro or a type with a macro. +// I have ideas for ways to pack that into the typedef/using ast, but for now just keeping it like this +#define ParserTokenType GEN_NS_PARSER Token +typedef ParserTokenType Token; +#undef ParserTokenType #endif -#pragma region Code Interface +#if GEN_COMPILER_CPP +template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast( Type*, & self ); } +#endif + +#pragma region Code C-Interface void code_append (Code code, Code other ); char const* code_debug_str (Code code); Code code_duplicate (Code code); @@ -182,10 +183,9 @@ String code_to_string (Code self ); void code_to_string_ptr(Code self, String* result ); char const* code_type_str (Code self ); bool code_validate_body(Code self ); -#pragma endregion Code Interface +#pragma endregion Code C-Interface #if GEN_COMPILER_CPP -GEN_API_C_END /* AST* wrapper - Not constantly have to append the '*' as this is written often.. @@ -195,34 +195,36 @@ struct Code { AST* ast; -# define Using_Code( Typename ) \ - char const* debug_str() { return code_debug_str(* this); } \ - Code duplicate() { return code_duplicate(* this); } \ - bool is_equal( Code other ) { return code_is_equal(* this, other); } \ - bool is_body() { return code_is_body(* this); } \ - bool is_valid() { return code_is_valid(* this); } \ - void set_global() { return code_set_global(* this); } +# define Using_Code( Typename ) \ + forceinline char const* debug_str() { return code_debug_str(* this); } \ + forceinline Code duplicate() { return code_duplicate(* this); } \ + forceinline bool is_equal( Code other ) { return code_is_equal(* this, other); } \ + forceinline bool is_body() { return code_is_body(* this); } \ + forceinline bool is_valid() { return code_is_valid(* this); } \ + forceinline void set_global() { return code_set_global(* this); } -# define Using_CodeOps( Typename ) \ - Typename& operator = ( Code other ); \ - bool operator ==( Code other ) { return (AST*)ast == other.ast; } \ - bool operator !=( Code other ) { return (AST*)ast != other.ast; } \ +# define Using_CodeOps( Typename ) \ + forceinline Typename& operator = ( Code other ); \ + forceinline bool operator ==( Code other ) { return (AST*)ast == other.ast; } \ + forceinline bool operator !=( Code other ) { return (AST*)ast != other.ast; } \ + forceinline bool operator ==(std::nullptr_t) const { return ast == nullptr; } \ + forceinline bool operator !=(std::nullptr_t) const { return ast != nullptr; } \ operator bool(); -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( Code ); - void append(Code other) { return code_append(* this, other); } - Code* entry(u32 idx) { return code_entry(* this, idx); } - bool has_entries() { return code_has_entries(* this); } - String to_string() { return code_to_string(* this); } - void to_string(String& result) { return code_to_string_ptr(* this, & result); } - char const* type_str() { return code_type_str(* this); } - bool validate_body() { return code_validate_body(*this); } + forceinline void append(Code other) { return code_append(* this, other); } + forceinline Code* entry(u32 idx) { return code_entry(* this, idx); } + forceinline bool has_entries() { return code_has_entries(* this); } + forceinline String to_string() { return code_to_string(* this); } + forceinline void to_string(String& result) { return code_to_string_ptr(* this, & result); } + forceinline char const* type_str() { return code_type_str(* this); } + forceinline bool validate_body() { return code_validate_body(*this); } #endif Using_CodeOps( Code ); + forceinline AST* operator ->() { return ast; } - AST* operator ->() { return ast; } Code& operator ++(); // TODO(Ed) : Remove this overload. @@ -237,11 +239,6 @@ struct Code return *this; } - bool operator==(std::nullptr_t) const { return ast == nullptr; } - bool operator!=(std::nullptr_t) const { return ast != nullptr; } - friend bool operator==(std::nullptr_t, const Code code) { return code.ast == nullptr; } - friend bool operator!=(std::nullptr_t, const Code code) { return code.ast != nullptr; } - #ifdef GEN_ENFORCE_STRONG_CODE_TYPES # define operator explicit operator #endif @@ -276,7 +273,6 @@ struct Code operator CodeVar() const; #undef operator }; -GEN_API_C_BEGIN #endif #pragma region Statics @@ -287,7 +283,6 @@ extern Code Code_Global; extern Code Code_Invalid; #pragma endregion Statics -typedef struct Code_POD Code_POD; struct Code_POD { AST* ast; @@ -362,7 +357,7 @@ struct AST Code Next; Code Back; }; - Token* Token; // Reference to starting token, only avaialble if it was derived from parsing. + Token* Token; // Reference to starting token, only avaialble if it was derived from parsing. Code Parent; StringCached Name; CodeType Type; @@ -385,10 +380,12 @@ static_assert( sizeof(AST) == AST_POD_Size, "ERROR: AST POD is not size of AST_P struct InvalidCode_ImplictCaster; #define InvalidCode (InvalidCode_ImplictCaster{}) #else -#define InvalidCode Code_Invalid +#define InvalidCode { (AST*)Code_Invalid } #endif +#if GEN_COMPILER_CPP // Used when the its desired when omission is allowed in a definition. #define NullCode { nullptr } - -GEN_API_C_END +#else +#define NullCode nullptr +#endif diff --git a/project/components/code_serialization.cpp b/project/components/code_serialization.cpp index 9d89141..c5d488b 100644 --- a/project/components/code_serialization.cpp +++ b/project/components/code_serialization.cpp @@ -3,19 +3,28 @@ #include "ast.cpp" #endif -String to_string(CodeAttributes attributes) { +forceinline +String attributes_to_string(CodeAttributes attributes) { + GEN_ASSERT(attributes); return {(char*) strc_duplicate( attributes->Content, GlobalAllocator ).Ptr}; } -String to_string(CodeBody body) +forceinline +void attributes_to_string_ref(CodeAttributes attributes, String* result) { + GEN_ASSERT(attributes); + GEN_ASSERT(result); + string_append_strc(result, attributes->Content); +} + +String body_to_string(CodeBody body) { - GEN_ASSERT_NOT_NULL(body.ast); + GEN_ASSERT(body); String result = string_make_reserve( GlobalAllocator, 128 ); - switch ( body.ast->Type ) + switch ( body->Type ) { case CT_Untyped: case CT_Execution: - string_append_strc( & result, rcast(AST*, body.ast)->Content ); + string_append_strc( & result, cast(Code, body)->Content ); break; case CT_Enum_Body: @@ -26,67 +35,77 @@ String to_string(CodeBody body) case CT_Namespace_Body: case CT_Struct_Body: case CT_Union_Body: - to_string( body, & result ); + body_to_string_ref( body, & result ); break; case CT_Export_Body: - to_string_export( body, & result ); + body_to_string_export( body, & result ); break; } return result; } -void to_string( CodeBody body, String* result ) +void body_to_string_ref( CodeBody body, String* result ) { - GEN_ASSERT(body.ast != nullptr); - GEN_ASSERT(result != nullptr); - Code curr = body.ast->Front; - s32 left = body.ast->NumEntries; + GEN_ASSERT(body != nullptr); + GEN_ASSERT(result != nullptr); + Code curr = body->Front; + s32 left = body->NumEntries; while ( left -- ) { - string_append_fmt( result, "%S", code_to_string(curr) ); + code_to_string_ptr(curr, result); + // string_append_fmt( result, "%S", code_to_string(curr) ); ++curr; } } -void to_string_export( CodeBody body, String* result ) +void body_to_string_export( CodeBody body, String* result ) { - GEN_ASSERT(body.ast != nullptr); - GEN_ASSERT(result != nullptr); + GEN_ASSERT(body != nullptr); + GEN_ASSERT(result != nullptr); string_append_fmt( result, "export\n{\n" ); - Code curr = body; - s32 left = body.ast->NumEntries; + Code curr = cast(Code, body); + s32 left = body->NumEntries; while ( left-- ) { - string_append_fmt( result, "%S", code_to_string(curr) ); + code_to_string_ptr(curr, result); + // string_append_fmt( result, "%S", code_to_string(curr) ); ++curr; } string_append_fmt( result, "};\n" ); } -String to_string(CodeComment comment) -{ +forceinline +String comment_to_string(CodeComment comment) { + GEN_ASSERT(comment); return {(char*) strc_duplicate( comment->Content, GlobalAllocator ).Ptr}; } -String to_string(CodeConstructor self) +forceinline +void comment_to_string_ref(CodeComment comment, String* result) { + GEN_ASSERT(comment); + GEN_ASSERT(result); + string_append_strc(result, comment->Content); +} + +String constructor_to_string(CodeConstructor self) { String result = string_make_reserve( GlobalAllocator, 128 ); switch (self->Type) { case CT_Constructor: - to_string_def( self, & result ); + constructor_to_string_def( self, & result ); break; case CT_Constructor_Fwd: - to_string_fwd( self, & result ); + constructor_to_string_fwd( self, & result ); break; } return result; } -void to_string_def(CodeConstructor self, String* result ) +void constructor_to_string_def(CodeConstructor self, String* result ) { Code ClassStructParent = self->Parent->Parent; if (ClassStructParent) { @@ -97,7 +116,7 @@ void to_string_def(CodeConstructor self, String* result ) } if ( self->Params ) - string_append_fmt( result, "( %S )", to_string(self->Params) ); + string_append_fmt( result, "( %S )", params_to_string(self->Params) ); else string_append_strc( result, txt("()") ); @@ -110,7 +129,7 @@ void to_string_def(CodeConstructor self, String* result ) string_append_fmt( result, "\n{\n%S\n}\n", code_to_string(self->Body) ); } -void to_string_fwd(CodeConstructor self, String* result ) +void constructor_to_string_fwd(CodeConstructor self, String* result ) { Code ClassStructParent = self->Parent->Parent; if (ClassStructParent) { @@ -121,7 +140,7 @@ void to_string_fwd(CodeConstructor self, String* result ) } if ( self->Params ) - string_append_fmt( result, "( %S )", to_string(self->Params) ); + string_append_fmt( result, "( %S )", params_to_string(self->Params) ); else string_append_fmt( result, "()"); @@ -134,117 +153,115 @@ void to_string_fwd(CodeConstructor self, String* result ) string_append_strc( result, txt(";\n") ); } -String to_string( CodeClass self ) +String class_to_string( CodeClass self ) { String result = string_make_reserve( GlobalAllocator, 512 ); switch ( self->Type ) { case CT_Class: - to_string_def(self, & result ); + class_to_string_def(self, & result ); break; case CT_Class_Fwd: - to_string_fwd(self, & result ); + class_to_string_fwd(self, & result ); break; } return result; } -void to_string_def( CodeClass self, String* result ) +void class_to_string_def( CodeClass self, String* result ) { - GEN_ASSERT(self.ast != nullptr); - AST_Class* ast = self.ast; + GEN_ASSERT(self); - if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export )) + if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); string_append_strc( result, txt("class ") ); - if ( ast->Attributes ) + if ( self->Attributes ) { - string_append_fmt( result, "%S ", GEN_NS to_string(ast->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); } - if ( ast->ParentType ) + if ( self->ParentType ) { - char const* access_level = to_str( ast->ParentAccess ); + char const* access_level = to_str( self->ParentAccess ); - string_append_fmt( result, "%SC : %s %S", ast->Name, access_level, to_string(ast->ParentType) ); + string_append_fmt( result, "%SC : %s %S", self->Name, access_level, typename_to_string(self->ParentType) ); - CodeTypename interface = cast(CodeTypename, ast->ParentType->Next); + CodeTypename interface = cast(CodeTypename, self->ParentType->Next); if ( interface ) string_append_strc( result, txt("\n") ); while ( interface ) { - string_append_fmt( result, ", %S", to_string(interface) ); + string_append_fmt( result, ", %S", typename_to_string(interface) ); interface = interface->Next ? cast(CodeTypename, interface->Next) : CodeTypename { nullptr }; } } - else if ( ast->Name ) + else if ( self->Name ) { - string_append_strc( result, ast->Name ); + string_append_strc( result, self->Name ); } - if ( ast->InlineCmt ) + if ( self->InlineCmt ) { - string_append_fmt( result, " // %SC", ast->InlineCmt->Content ); + string_append_fmt( result, " // %SC", self->InlineCmt->Content ); } - string_append_fmt( result, "\n{\n%S\n}", to_string(ast->Body) ); + string_append_fmt( result, "\n{\n%S\n}", body_to_string(self->Body) ); - if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) + if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) string_append_strc( result, txt(";\n") ); } -void to_string_fwd( CodeClass self, String* result ) +void class_to_string_fwd( CodeClass self, String* result ) { - GEN_ASSERT(self.ast != nullptr); - AST_Class* ast = self.ast; + GEN_ASSERT(self); - if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export )) + if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); - if ( ast->Attributes ) - string_append_fmt( result, "class %S %SC", to_string(ast->Attributes), ast->Name ); + if ( self->Attributes ) + string_append_fmt( result, "class %S %SC", attributes_to_string(self->Attributes), self->Name ); - else string_append_fmt( result, "class %SC", ast->Name ); + else string_append_fmt( result, "class %SC", self->Name ); // Check if it can have an end-statement - if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) + if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) { - if ( ast->InlineCmt ) - string_append_fmt( result, "; // %SC\n", ast->InlineCmt->Content ); + if ( self->InlineCmt ) + string_append_fmt( result, "; // %SC\n", self->InlineCmt->Content ); else string_append_strc( result, txt(";\n") ); } } -String to_string(CodeDefine define) +String define_to_string(CodeDefine define) { return string_fmt_buf( GlobalAllocator, "#define %SC %SC", define->Name, define->Content ); } -void to_string(CodeDefine define, String* result ) +void define_to_string_ref(CodeDefine define, String* result ) { string_append_fmt( result, "#define %SC %SC", define->Name, define->Content ); } -String to_string(CodeDestructor self) +String destructor_to_string(CodeDestructor self) { String result = string_make_reserve( GlobalAllocator, 128 ); switch ( self->Type ) { case CT_Destructor: - to_string_def( self, & result ); + destructor_to_string_def( self, & result ); break; case CT_Destructor_Fwd: - to_string_fwd( self, & result ); + destructor_to_string_fwd( self, & result ); break; } return result; } -void to_string_def(CodeDestructor self, String* result ) +void destructor_to_string_def(CodeDestructor self, String* result ) { if ( self->Name ) { @@ -252,7 +269,7 @@ void to_string_def(CodeDestructor self, String* result ) } else if ( self->Specs ) { - if ( has(self->Specs, Spec_Virtual ) ) + if ( specifiers_has(self->Specs, Spec_Virtual ) ) string_append_fmt( result, "virtual ~%SC()", self->Parent->Name ); else string_append_fmt( result, "~%SC()", self->Parent->Name ); @@ -263,16 +280,16 @@ void to_string_def(CodeDestructor self, String* result ) string_append_fmt( result, "\n{\n%S\n}\n", code_to_string(self->Body) ); } -void to_string_fwd(CodeDestructor self, String* result ) +void destructor_to_string_fwd(CodeDestructor self, String* result ) { if ( self->Specs ) { - if ( has(self->Specs, Spec_Virtual ) ) + if ( specifiers_has(self->Specs, Spec_Virtual ) ) string_append_fmt( result, "virtual ~%SC();\n", self->Parent->Name ); else string_append_fmt( result, "~%SC()", self->Parent->Name ); - if ( has(self->Specs, Spec_Pure ) ) + if ( specifiers_has(self->Specs, Spec_Pure ) ) string_append_strc( result, txt(" = 0;") ); else if (self->Body) string_append_fmt( result, " = %S;", code_to_string(self->Body) ); @@ -286,28 +303,28 @@ void to_string_fwd(CodeDestructor self, String* result ) string_append_strc( result, txt("\n")); } -String to_string(CodeEnum self) +String enum_to_string(CodeEnum self) { String result = string_make_reserve( GlobalAllocator, 512 ); switch ( self->Type ) { case CT_Enum: - to_string_def(self, & result ); + enum_to_string_def(self, & result ); break; case CT_Enum_Fwd: - to_string_fwd(self, & result ); + enum_to_string_fwd(self, & result ); break; case CT_Enum_Class: - to_string_class_def(self, & result ); + enum_to_string_class_def(self, & result ); break; case CT_Enum_Class_Fwd: - to_string_class_fwd(self, & result ); + enum_to_string_class_fwd(self, & result ); break; } return result; } -void to_string_def(CodeEnum self, String* result ) +void enum_to_string_def(CodeEnum self, String* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); @@ -317,45 +334,45 @@ void to_string_def(CodeEnum self, String* result ) string_append_strc( result, txt("enum ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); if ( self->UnderlyingType ) string_append_fmt( result, "%SC : %S\n{\n%S\n}" , self->Name - , to_string(self->UnderlyingType) - , to_string(self->Body) + , typename_to_string(self->UnderlyingType) + , body_to_string(self->Body) ); else if ( self->UnderlyingTypeMacro ) string_append_fmt( result, "%SC %S\n\n{\n%S\n}" , self->Name , code_to_string(self->UnderlyingTypeMacro) - , to_string(self->Body) + , body_to_string(self->Body) ); - else string_append_fmt( result, "%SC\n{\n%S\n}", self->Name, to_string(self->Body) ); + else string_append_fmt( result, "%SC\n{\n%S\n}", self->Name, body_to_string(self->Body) ); } - else string_append_fmt( result, "enum %SC\n{\n%S\n}", self->Name, to_string(self->Body) ); + else string_append_fmt( result, "enum %SC\n{\n%S\n}", self->Name, body_to_string(self->Body) ); - if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) + if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) string_append_strc( result, txt(";\n")); } -void to_string_fwd(CodeEnum self, String* result ) +void enum_to_string_fwd(CodeEnum self, String* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); if ( self->UnderlyingType ) - string_append_fmt( result, "enum %SC : %S", self->Name, to_string(self->UnderlyingType) ); + string_append_fmt( result, "enum %SC : %S", self->Name, typename_to_string(self->UnderlyingType) ); else if (self->UnderlyingTypeMacro) - string_append_fmt( result, "enum %SC %S", self->Name, to_string(self->UnderlyingType) ); + string_append_fmt( result, "enum %SC %S", self->Name, typename_to_string(self->UnderlyingType) ); else string_append_fmt( result, "enum %SC", self->Name ); - if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) + if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) { if ( self->InlineCmt ) string_append_fmt( result, "; %SC", self->InlineCmt->Content ); @@ -364,7 +381,7 @@ void to_string_fwd(CodeEnum self, String* result ) } } -void to_string_class_def(CodeEnum self, String* result ) +void enum_to_string_class_def(CodeEnum self, String* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); @@ -375,28 +392,28 @@ void to_string_class_def(CodeEnum self, String* result ) if ( self->Attributes ) { - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); } if ( self->UnderlyingType ) { - string_append_fmt( result, "%SC : %S\n{\n%S\n}", self->Name, to_string(self->UnderlyingType), to_string(self->Body) ); + string_append_fmt( result, "%SC : %S\n{\n%S\n}", self->Name, typename_to_string(self->UnderlyingType), body_to_string(self->Body) ); } else { - string_append_fmt( result, "%SC\n{\n%S\n}", self->Name, to_string(self->Body) ); + string_append_fmt( result, "%SC\n{\n%S\n}", self->Name, body_to_string(self->Body) ); } } else { - string_append_fmt( result, "enum %SC\n{\n%S\n}", self->Name, to_string(self->Body) ); + string_append_fmt( result, "enum %SC\n{\n%S\n}", self->Name, body_to_string(self->Body) ); } - if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) + if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) string_append_strc( result, txt(";\n")); } -void to_string_class_fwd(CodeEnum self, String* result ) +void enum_to_string_class_fwd(CodeEnum self, String* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); @@ -404,11 +421,11 @@ void to_string_class_fwd(CodeEnum self, String* result ) string_append_strc( result, txt("enum class ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); - string_append_fmt( result, "%SC : %S", self->Name, to_string(self->UnderlyingType) ); + string_append_fmt( result, "%SC : %S", self->Name, typename_to_string(self->UnderlyingType) ); - if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) + if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) { if ( self->InlineCmt ) string_append_fmt( result, "; %SC", self->InlineCmt->Content ); @@ -417,37 +434,37 @@ void to_string_class_fwd(CodeEnum self, String* result ) } } -String to_string(CodeExec exec) +String exec_to_string(CodeExec exec) { return {(char*) strc_duplicate( exec->Content, GlobalAllocator ).Ptr}; } -void to_string(CodeExtern self, String* result ) +void extern_to_string(CodeExtern self, String* result ) { if ( self->Body ) - string_append_fmt( result, "extern \"%SC\"\n{\n%S\n}\n", self->Name, to_string(self->Body) ); + string_append_fmt( result, "extern \"%SC\"\n{\n%S\n}\n", self->Name, body_to_string(self->Body) ); else string_append_fmt( result, "extern \"%SC\"\n{}\n", self->Name ); } -String to_string(CodeInclude include) +String include_to_string(CodeInclude include) { return string_fmt_buf( GlobalAllocator, "#include %SC\n", include->Content ); } -void to_string( CodeInclude include, String* result ) +void include_to_string_ref( CodeInclude include, String* result ) { string_append_fmt( result, "#include %SC\n", include->Content ); } -String to_string(CodeFriend self) +String friend_to_string(CodeFriend self) { String result = string_make_reserve( GlobalAllocator, 256 ); - to_string( self, & result ); + friend_to_string_ref( self, & result ); return result; } -void to_string(CodeFriend self, String* result ) +void friend_to_string_ref(CodeFriend self, String* result ) { string_append_fmt( result, "friend %S", code_to_string(self->Declaration) ); @@ -462,37 +479,37 @@ void to_string(CodeFriend self, String* result ) string_append_strc( result, txt("\n")); } -String to_string(CodeFn self) +String fn_to_string(CodeFn self) { String result = string_make_reserve( GlobalAllocator, 512 ); switch ( self->Type ) { case CT_Function: - to_string_def(self, & result ); + fn_to_string_def(self, & result ); break; case CT_Function_Fwd: - to_string_fwd(self, & result ); + fn_to_string_fwd(self, & result ); break; } return result; } -void to_string_def(CodeFn self, String* result ) +void fn_to_string_def(CodeFn self, String* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export") ); if ( self->Attributes ) - string_append_fmt( result, " %S ", to_string(self->Attributes) ); + string_append_fmt( result, " %S ", attributes_to_string(self->Attributes) ); bool prefix_specs = false; if ( self->Specs ) { - for ( Specifier spec : self->Specs ) + for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { - if ( ! spec_is_trailing( spec ) ) + if ( ! spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( spec ); + StrC spec_str = spec_to_str( * spec ); string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); prefix_specs = true; @@ -504,48 +521,48 @@ void to_string_def(CodeFn self, String* result ) string_append_strc( result, txt("\n") ); if ( self->ReturnType ) - string_append_fmt( result, "%S %SC(", to_string(self->ReturnType), self->Name ); + string_append_fmt( result, "%S %SC(", typename_to_string(self->ReturnType), self->Name ); else string_append_fmt( result, "%SC(", self->Name ); if ( self->Params ) - string_append_fmt( result, "%S)", to_string(self->Params) ); + string_append_fmt( result, "%S)", params_to_string(self->Params) ); else string_append_strc( result, txt(")") ); if ( self->Specs ) { - for ( Specifier spec : self->Specs ) + for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { - if ( spec_is_trailing( spec ) ) + if ( spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( spec ); + StrC spec_str = spec_to_str( * spec ); string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } } - string_append_fmt( result, "\n{\n%S\n}\n", to_string(self->Body) ); + string_append_fmt( result, "\n{\n%S\n}\n", body_to_string(self->Body) ); } -void to_string_fwd(CodeFn self, String* result ) +void fn_to_string_fwd(CodeFn self, String* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); b32 prefix_specs = false; if ( self->Specs ) { - for ( Specifier spec : self->Specs ) + for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { - if ( ! spec_is_trailing( spec ) || ! (spec != Spec_Pure) ) + if ( ! spec_is_trailing( * spec ) || ! ( * spec != Spec_Pure) ) { - StrC spec_str = spec_to_str( spec ); + StrC spec_str = spec_to_str( * spec ); string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); prefix_specs = true; @@ -559,33 +576,33 @@ void to_string_fwd(CodeFn self, String* result ) } if ( self->ReturnType ) - string_append_fmt( result, "%S %SC(", to_string(self->ReturnType), self->Name ); + string_append_fmt( result, "%S %SC(", typename_to_string(self->ReturnType), self->Name ); else string_append_fmt( result, "%SC(", self->Name ); if ( self->Params ) - string_append_fmt( result, "%S)", to_string(self->Params) ); + string_append_fmt( result, "%S)", params_to_string(self->Params) ); else string_append_strc( result, txt(")") ); if ( self->Specs ) { - for ( Specifier spec : self->Specs ) + for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { - if ( spec_is_trailing( spec ) ) + if ( spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( spec ); + StrC spec_str = spec_to_str( * spec ); string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } } - if ( self->Specs && has(self->Specs, Spec_Pure ) >= 0 ) + if ( self->Specs && specifiers_has(self->Specs, Spec_Pure ) >= 0 ) string_append_strc( result, txt(" = 0;") ); else if (self->Body) - string_append_fmt( result, " = %S;", to_string(self->Body) ); + string_append_fmt( result, " = %S;", body_to_string(self->Body) ); if ( self->InlineCmt ) string_append_fmt( result, "; %SC", self->InlineCmt->Content ); @@ -593,14 +610,14 @@ void to_string_fwd(CodeFn self, String* result ) string_append_strc( result, txt(";\n") ); } -String to_string(CodeModule self) +String module_to_string(CodeModule self) { String result = string_make_reserve( GlobalAllocator, 64 ); - to_string( self, & result ); + module_to_string_ref( self, & result ); return result; } -void to_string(CodeModule self, String* result ) +void module_to_string_ref(CodeModule self, String* result ) { if (((u32(ModuleFlag_Export) & u32(self->ModuleFlags)) == u32(ModuleFlag_Export))) string_append_strc( result, txt("export ")); @@ -611,56 +628,56 @@ void to_string(CodeModule self, String* result ) string_append_fmt( result, "%SC;\n", self->Name ); } -String to_string(CodeNS self) +String namespace_to_string(CodeNS self) { String result = string_make_reserve( GlobalAllocator, 512 ); - to_string( self, & result ); + namespace_to_string_ref( self, & result ); return result; } -void to_string(CodeNS self, String* result ) +void namespace_to_string_ref(CodeNS self, String* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); - string_append_fmt( result, "namespace %SC\n{\n%S\n}\n", self->Name, to_string(self->Body) ); + string_append_fmt( result, "namespace %SC\n{\n%S\n}\n", self->Name, body_to_string(self->Body) ); } -String to_string(CodeOperator self) +String code_op_to_string(CodeOperator self) { String result = string_make_reserve( GlobalAllocator, 512 ); switch ( self->Type ) { case CT_Operator: case CT_Operator_Member: - to_string_def( self, & result ); + code_op_to_string_def( self, & result ); break; case CT_Operator_Fwd: case CT_Operator_Member_Fwd: - to_string_fwd( self, & result ); + code_op_to_string_fwd( self, & result ); break; } return result; } -void to_string_def(CodeOperator self, String* result ) +void code_op_to_string_def(CodeOperator self, String* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); if ( self->Specs ) { - for ( Specifier spec : self->Specs ) + for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { - if ( ! spec_is_trailing( spec ) ) + if ( ! spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( spec ); + StrC spec_str = spec_to_str( * spec ); string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } @@ -672,46 +689,46 @@ void to_string_def(CodeOperator self, String* result ) } if ( self->ReturnType ) - string_append_fmt( result, "%S %SC (", to_string(self->ReturnType), self->Name ); + string_append_fmt( result, "%S %SC (", typename_to_string(self->ReturnType), self->Name ); if ( self->Params ) - string_append_fmt( result, "%S)", to_string(self->Params) ); + string_append_fmt( result, "%S)", params_to_string(self->Params) ); else string_append_strc( result, txt(")") ); if ( self->Specs ) { - for ( Specifier spec : self->Specs ) + for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { - if ( spec_is_trailing( spec ) ) + if ( spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( spec ); + StrC spec_str = spec_to_str( * spec ); string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } } string_append_fmt( result, "\n{\n%S\n}\n" - , to_string(self->Body) + , body_to_string(self->Body) ); } -void to_string_fwd(CodeOperator self, String* result ) +void code_op_to_string_fwd(CodeOperator self, String* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); if ( self->Attributes ) - string_append_fmt( result, "%S\n", to_string(self->Attributes) ); + string_append_fmt( result, "%S\n", attributes_to_string(self->Attributes) ); if ( self->Specs ) { - for ( Specifier spec : self->Specs ) + for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { - if ( ! spec_is_trailing( spec ) ) + if ( ! spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( spec ); + StrC spec_str = spec_to_str( * spec ); string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } @@ -722,21 +739,21 @@ void to_string_fwd(CodeOperator self, String* result ) string_append_strc( result, txt("\n") ); } - string_append_fmt( result, "%S %SC (", to_string(self->ReturnType), self->Name ); + string_append_fmt( result, "%S %SC (", typename_to_string(self->ReturnType), self->Name ); if ( self->Params ) - string_append_fmt( result, "%S)", to_string(self->Params) ); + string_append_fmt( result, "%S)", params_to_string(self->Params) ); else string_append_fmt( result, ")" ); if ( self->Specs ) { - for ( Specifier spec : self->Specs ) + for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { - if ( spec_is_trailing( spec ) ) + if ( spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( spec ); + StrC spec_str = spec_to_str( * spec ); string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } @@ -748,78 +765,78 @@ void to_string_fwd(CodeOperator self, String* result ) string_append_strc( result, txt(";\n") ); } -String to_string(CodeOpCast self) +String opcast_to_string(CodeOpCast self) { String result = string_make_reserve( GlobalAllocator, 128 ); switch ( self->Type ) { case CT_Operator_Cast: - to_string_def(self, & result ); + opcast_to_string_def(self, & result ); break; case CT_Operator_Cast_Fwd: - to_string_fwd(self, & result ); + opcast_to_string_fwd(self, & result ); break; } return result; } -void to_string_def(CodeOpCast self, String* result ) +void opcast_to_string_def(CodeOpCast self, String* result ) { if ( self->Specs ) { - for ( Specifier spec : self->Specs ) + for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { - if ( ! spec_is_trailing( spec ) ) + if ( ! spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( spec ); + StrC spec_str = spec_to_str( * spec ); string_append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr ); } } if ( self->Name && self->Name.Len ) - string_append_fmt( result, "%SC operator %S()", self->Name, to_string(self->ValueType) ); + string_append_fmt( result, "%SC operator %S()", self->Name, typename_to_string(self->ValueType) ); else - string_append_fmt( result, "operator %S()", to_string(self->ValueType) ); + string_append_fmt( result, "operator %S()", typename_to_string(self->ValueType) ); - for ( Specifier spec : self->Specs ) + for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { - if ( spec_is_trailing( spec ) ) + if ( spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( spec ); + StrC spec_str = spec_to_str( * spec ); string_append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr ); } } - string_append_fmt( result, "\n{\n%S\n}\n", to_string(self->Body) ); + string_append_fmt( result, "\n{\n%S\n}\n", body_to_string(self->Body) ); return; } if ( self->Name && self->Name.Len ) - string_append_fmt( result, "%SC operator %S()\n{\n%S\n}\n", self->Name, to_string(self->ValueType), to_string(self->Body) ); + string_append_fmt( result, "%SC operator %S()\n{\n%S\n}\n", self->Name, typename_to_string(self->ValueType), body_to_string(self->Body) ); else - string_append_fmt( result, "operator %S()\n{\n%S\n}\n", to_string(self->ValueType), to_string(self->Body) ); + string_append_fmt( result, "operator %S()\n{\n%S\n}\n", typename_to_string(self->ValueType), body_to_string(self->Body) ); } -void to_string_fwd(CodeOpCast self, String* result ) +void opcast_to_string_fwd(CodeOpCast self, String* result ) { if ( self->Specs ) { - for ( Specifier spec : self->Specs ) + for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { - if ( ! spec_is_trailing( spec ) ) + if ( ! spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( spec ); + StrC spec_str = spec_to_str( * spec ); string_append_fmt( result, "%*s ", spec_str.Len, spec_str.Ptr ); } } - string_append_fmt( result, "operator %S()", to_string(self->ValueType) ); + string_append_fmt( result, "operator %S()", typename_to_string(self->ValueType) ); - for ( Specifier spec : self->Specs ) + for ( Specifier* spec = begin_CodeSpecifiers(self->Specs); spec != end_CodeSpecifiers(self->Specs); spec = next_CodeSpecifiers(self->Specs, spec) ) { - if ( spec_is_trailing( spec ) ) + if ( spec_is_trailing( * spec ) ) { - StrC spec_str = spec_to_str( spec ); + StrC spec_str = spec_to_str( * spec ); string_append_fmt( result, " %*s", spec_str.Len, spec_str.Ptr ); } } @@ -832,136 +849,147 @@ void to_string_fwd(CodeOpCast self, String* result ) } if ( self->InlineCmt ) - string_append_fmt( result, "operator %S(); %S", to_string(self->ValueType) ); + string_append_fmt( result, "operator %S(); %S", typename_to_string(self->ValueType) ); else - string_append_fmt( result, "operator %S();\n", to_string(self->ValueType) ); + string_append_fmt( result, "operator %S();\n", typename_to_string(self->ValueType) ); } -String to_string(CodeParam self) +String params_to_string(CodeParam self) { + GEN_ASSERT(self); + GEN_ASSERT(self); String result = string_make_reserve( GlobalAllocator, 128 ); - to_string( self, & result ); + params_to_string_ref( self, & result ); return result; } -void to_string( CodeParam self, String* result ) +void params_to_string_ref( CodeParam self, String* result ) { - AST_Param* ast = self.ast; - if ( ast->Macro ) + GEN_ASSERT(self); + GEN_ASSERT(result); + if ( self->Macro ) { // Related to parsing: ( , ... ) - string_append_strc( result, ast->Macro.ast->Content ); + string_append_strc( result, self->Macro->Content ); // Could also be: ( , ... ) } - if ( ast->Name ) + if ( self->Name ) { - if ( ast->ValueType.ast == nullptr ) - string_append_fmt( result, " %SC", ast->Name ); + if ( self->ValueType == nullptr ) + string_append_fmt( result, " %SC", self->Name ); else - string_append_fmt( result, " %S %SC", to_string(ast->ValueType), ast->Name ); + string_append_fmt( result, " %S %SC", typename_to_string(self->ValueType), self->Name ); } - else if ( ast->ValueType ) - string_append_fmt( result, " %S", to_string(ast->ValueType) ); + else if ( self->ValueType ) + string_append_fmt( result, " %S", typename_to_string(self->ValueType) ); - if ( ast->PostNameMacro ) + if ( self->PostNameMacro ) { - string_append_fmt( result, " %S", code_to_string(ast->PostNameMacro) ); + string_append_fmt( result, " %S", code_to_string(self->PostNameMacro) ); } - if ( ast->Value ) - string_append_fmt( result, " = %S", code_to_string(ast->Value) ); + if ( self->Value ) + string_append_fmt( result, " = %S", code_to_string(self->Value) ); - if ( ast->NumEntries - 1 > 0 ) + if ( self->NumEntries - 1 > 0 ) { - for ( CodeParam param : ast->Next ) + for ( CodeParam param = begin_CodeParam(self->Next); param != end_CodeParam(self->Next); param = next_CodeParam(self->Next, param) ) { - string_append_fmt( result, ", %S", to_string(param) ); + string_append_fmt( result, ", %S", params_to_string(param) ); } } } -String to_string(CodePreprocessCond self) +String preprocess_to_string(CodePreprocessCond self) { + GEN_ASSERT(self); String result = string_make_reserve( GlobalAllocator, 256 ); switch ( self->Type ) { case CT_Preprocess_If: - to_string_if( self, & result ); + preprocess_to_string_if( self, & result ); break; case CT_Preprocess_IfDef: - to_string_ifdef( self, & result ); + preprocess_to_string_ifdef( self, & result ); break; case CT_Preprocess_IfNotDef: - to_string_ifndef( self, & result ); + preprocess_to_string_ifndef( self, & result ); break; case CT_Preprocess_ElIf: - to_string_elif( self, & result ); + preprocess_to_string_elif( self, & result ); break; case CT_Preprocess_Else: - to_string_else( self, & result ); + preprocess_to_string_else( self, & result ); break; case CT_Preprocess_EndIf: - to_string_endif( self, & result ); + preprocess_to_string_endif( self, & result ); break; } return result; } -void to_string_if(CodePreprocessCond cond, String* result ) +void preprocess_to_string_if(CodePreprocessCond cond, String* result ) { + GEN_ASSERT(cond); string_append_fmt( result, "#if %SC", cond->Content ); } -void to_string_ifdef(CodePreprocessCond cond, String* result ) +void preprocess_to_string_ifdef(CodePreprocessCond cond, String* result ) { + GEN_ASSERT(cond); string_append_fmt( result, "#ifdef %SC\n", cond->Content ); } -void to_string_ifndef(CodePreprocessCond cond, String* result ) +void preprocess_to_string_ifndef(CodePreprocessCond cond, String* result ) { + GEN_ASSERT(cond); string_append_fmt( result, "#ifndef %SC", cond->Content ); } -void to_string_elif(CodePreprocessCond cond, String* result ) +void preprocess_to_string_elif(CodePreprocessCond cond, String* result ) { + GEN_ASSERT(cond); string_append_fmt( result, "#elif %SC\n", cond->Content ); } -void to_string_else(CodePreprocessCond cond, String* result ) +void preprocess_to_string_else(CodePreprocessCond cond, String* result ) { + GEN_ASSERT(cond); string_append_strc( result, txt("#else\n") ); } -void to_string_endif(CodePreprocessCond cond, String* result ) +void preprocess_to_string_endif(CodePreprocessCond cond, String* result ) { + GEN_ASSERT(cond); string_append_strc( result, txt("#endif\n") ); } -String to_string(CodePragma self) +String pragma_to_string(CodePragma self) { + GEN_ASSERT(self); String result = string_make_reserve( GlobalAllocator, 256 ); - to_string( self, & result ); + pragma_to_string_ref( self, & result ); return result; } -void to_string(CodePragma self, String* result ) +void pragma_to_string_ref(CodePragma self, String* result ) { - string_append_fmt( result, "#pragma %SC", self->Content ); + string_append_fmt( result, "#pragma %SC\n", self->Content ); } -String to_string(CodeSpecifiers self) +String specifiers_to_string(CodeSpecifiers self) { String result = string_make_reserve( GlobalAllocator, 64 ); - to_string( self, & result ); + specifiers_to_string_ref( self, & result ); return result; } -void to_string( CodeSpecifiers self, String* result ) +void specifiers_to_string_ref( CodeSpecifiers self, String* result ) { - GEN_ASSERT(self.ast != nullptr); - GEN_ASSERT(result != nullptr); + GEN_ASSERT(self); + GEN_ASSERT(result); s32 idx = 0; s32 left = self->NumEntries; while ( left-- ) @@ -972,117 +1000,119 @@ void to_string( CodeSpecifiers self, String* result ) } } -String to_string(CodeStruct self) +String struct_to_string(CodeStruct self) { - GEN_ASSERT(self.ast != nullptr); + GEN_ASSERT(self); + GEN_ASSERT(self); String result = string_make_reserve( GlobalAllocator, 512 ); switch ( self->Type ) { case CT_Struct: - to_string_def( self, & result ); + struct_to_string_def( self, & result ); break; case CT_Struct_Fwd: - to_string_fwd( self, & result ); + struct_to_string_fwd( self, & result ); break; } return result; } -void to_string_def( CodeStruct self, String* result ) +void struct_to_string_def( CodeStruct self, String* result ) { - GEN_ASSERT(self.ast != nullptr); - AST_Struct* ast = self.ast; - - if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export )) + GEN_ASSERT(self); + GEN_ASSERT(result); + if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); string_append_strc( result, txt("struct ") ); - if ( ast->Attributes ) + if ( self->Attributes ) { - string_append_fmt( result, "%S ", to_string(ast->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); } - if ( ast->ParentType ) + if ( self->ParentType ) { - char const* access_level = to_str( ast->ParentAccess ); + char const* access_level = to_str( self->ParentAccess ); - string_append_fmt( result, "%SC : %s %S", ast->Name, access_level, to_string(ast->ParentType) ); + string_append_fmt( result, "%SC : %s %S", self->Name, access_level, typename_to_string(self->ParentType) ); - CodeTypename interface = cast(CodeTypename, ast->ParentType->Next); + CodeTypename interface = cast(CodeTypename, self->ParentType->Next); if ( interface ) string_append_strc( result, txt("\n") ); while ( interface ) { - string_append_fmt( result, ", %S", to_string(interface) ); + string_append_fmt( result, ", %S", typename_to_string(interface) ); interface = interface->Next ? cast( CodeTypename, interface->Next) : CodeTypename { nullptr }; } } - else if ( ast->Name ) + else if ( self->Name ) { - string_append_strc( result, ast->Name ); + string_append_strc( result, self->Name ); } - if ( ast->InlineCmt ) + if ( self->InlineCmt ) { - string_append_fmt( result, " // %SC", ast->InlineCmt->Content ); + string_append_fmt( result, " // %SC", self->InlineCmt->Content ); } - string_append_fmt( result, "\n{\n%S\n}", to_string(ast->Body) ); + string_append_fmt( result, "\n{\n%S\n}", body_to_string(self->Body) ); - if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) + if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) string_append_strc( result, txt(";\n")); } -void to_string_fwd( CodeStruct self, String* result ) +void struct_to_string_fwd( CodeStruct self, String* result ) { - GEN_ASSERT(self.ast != nullptr); - AST_Struct* ast = self.ast; - - if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export )) + GEN_ASSERT(self); + GEN_ASSERT(result); + if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); - if ( ast->Attributes ) - string_append_fmt( result, "struct %S %SC", to_string(ast->Attributes), ast->Name ); + if ( self->Attributes ) + string_append_fmt( result, "struct %S %SC", attributes_to_string(self->Attributes), self->Name ); - else string_append_fmt( result, "struct %SC", ast->Name ); + else string_append_fmt( result, "struct %SC", self->Name ); - if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != CT_Typedef && ast->Parent->Type != CT_Variable ) ) + if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) { - if ( ast->InlineCmt ) - string_append_fmt( result, "; %SC", ast->InlineCmt->Content ); + if ( self->InlineCmt ) + string_append_fmt( result, "; %SC", self->InlineCmt->Content ); else string_append_strc( result, txt( ";\n") ); } } -String to_string(CodeTemplate self) +String template_to_string(CodeTemplate self) { + GEN_ASSERT(self); String result = string_make_reserve( GlobalAllocator, 1024 ); - to_string( self, & result ); + template_to_string_ref( self, & result ); return result; } -void to_string(CodeTemplate self, String* result ) +void template_to_string_ref(CodeTemplate self, String* result ) { + GEN_ASSERT(self); + GEN_ASSERT(result); if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); if ( self->Params ) - string_append_fmt( result, "template< %S >\n%S", to_string(self->Params), code_to_string(self->Declaration) ); + string_append_fmt( result, "template< %S >\n%S", params_to_string(self->Params), code_to_string(self->Declaration) ); else string_append_fmt( result, "template<>\n%S", code_to_string(self->Declaration) ); } -String to_string(CodeTypedef self) +String typedef_to_string(CodeTypedef self) { String result = string_make_reserve( GlobalAllocator, 128 ); - to_string( self, & result ); + typedef_to_string_ref( self, & result ); return result; } -void to_string(CodeTypedef self, String* result ) +void typedef_to_string_ref(CodeTypedef self, String* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); @@ -1117,26 +1147,26 @@ void to_string(CodeTypedef self, String* result ) string_append_strc( result, txt("\n")); } -String to_string(CodeTypename self) +String typename_to_string(CodeTypename self) { String result = string_make_strc( GlobalAllocator, txt("") ); - to_string( self, & result ); + typename_to_string_ref( self, & result ); return result; } -void to_string(CodeTypename self, String* result ) +void typename_to_string_ref(CodeTypename self, String* result ) { #if defined(GEN_USE_NEW_TYPENAME_PARSING) if ( self->ReturnType && self->Params ) { if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); else { if ( self->Specs ) - string_append_fmt( result, "%S ( %SC ) ( %S ) %S", to_string(self->ReturnType), self->Name, to_string(self->Params), to_string(self->Specs) ); + string_append_fmt( result, "%S ( %SC ) ( %S ) %S", typename_to_string(self->ReturnType), self->Name, params_to_string(self->Params), specifiers_to_string(self->Specs) ); else - string_append_fmt( result, "%S ( %SC ) ( %S )", to_string(self->ReturnType), self->Name, to_string(self->Params) ); + string_append_fmt( result, "%S ( %SC ) ( %S )", typename_to_string(self->ReturnType), self->Name, params_to_string(self->Params) ); } break; @@ -1145,13 +1175,13 @@ void to_string(CodeTypename self, String* result ) if ( self->ReturnType && self->Params ) { if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); else { if ( self->Specs ) - string_append_fmt( result, "%S %SC ( %S ) %S", to_string(self->ReturnType), self->Name, to_string(self->Params), to_string(self->Specs) ); + string_append_fmt( result, "%S %SC ( %S ) %S", typename_to_string(self->ReturnType), self->Name, params_to_string(self->Params), specifiers_to_string(self->Specs) ); else - string_append_fmt( result, "%S %SC ( %S )", to_string(self->ReturnType), self->Name, to_string(self->Params) ); + string_append_fmt( result, "%S %SC ( %S )", typename_to_string(self->ReturnType), self->Name, params_to_string(self->Params) ); } return; @@ -1159,10 +1189,10 @@ void to_string(CodeTypename self, String* result ) #endif if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); if ( self->Specs ) - string_append_fmt( result, "%SC %S", self->Name, to_string(self->Specs) ); + string_append_fmt( result, "%SC %S", self->Name, specifiers_to_string(self->Specs) ); else string_append_fmt( result, "%SC", self->Name ); @@ -1170,22 +1200,22 @@ void to_string(CodeTypename self, String* result ) string_append_strc( result, txt("...")); } -String to_string(CodeUnion self) +String union_to_string(CodeUnion self) { String result = string_make_reserve( GlobalAllocator, 512 ); switch ( self->Type ) { case CT_Union: - to_string_def( self, & result ); + union_to_string_def( self, & result ); break; case CT_Union_Fwd: - to_string_fwd( self, & result ); + union_to_string_fwd( self, & result ); break; } return result; } -void to_string_def(CodeUnion self, String* result ) +void union_to_string_def(CodeUnion self, String* result ) { if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); @@ -1193,72 +1223,77 @@ void to_string_def(CodeUnion self, String* result ) string_append_strc( result, txt("union ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); if ( self->Name ) { string_append_fmt( result, "%SC\n{\n%S\n}" , self->Name - , GEN_NS to_string(self->Body) + , body_to_string(self->Body) ); } else { // Anonymous union string_append_fmt( result, "\n{\n%S\n}" - , GEN_NS to_string(self->Body) + , body_to_string(self->Body) ); } - if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) + if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) string_append_strc( result, txt(";\n")); } -void to_string_fwd(CodeUnion self, String* result ) +void union_to_string_fwd(CodeUnion self, String* result ) { + GEN_ASSERT(self); + GEN_ASSERT(result); if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); string_append_strc( result, txt("union ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); if ( self->Name ) { string_append_fmt( result, "%SC", self->Name); } - if ( self->Parent.ast == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) + if ( self->Parent == nullptr || ( self->Parent->Type != CT_Typedef && self->Parent->Type != CT_Variable ) ) string_append_strc( result, txt(";\n")); } -String to_string(CodeUsing self) +String using_to_string(CodeUsing self) { + GEN_ASSERT(self); String result = string_make_reserve( GlobalAllocator, 128 ); switch ( self->Type ) { case CT_Using: - to_string( self, & result ); + using_to_string_ref( self, & result ); break; case CT_Using_Namespace: - to_string_ns( self, & result ); + using_to_string_ns( self, & result ); break; } return result; } -void to_string(CodeUsing self, String* result ) +void using_to_string_ref(CodeUsing self, String* result ) { + GEN_ASSERT(self); + GEN_ASSERT(result); if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export )) string_append_strc( result, txt("export ") ); if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Attributes) ); + string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); if ( self->UnderlyingType ) { - string_append_fmt( result, "using %SC = %S", self->Name, to_string(self->UnderlyingType) ); + string_append_fmt( result, "using %SC = %S", self->Name, typename_to_string(self->UnderlyingType) ); if ( self->UnderlyingType->ArrExpr ) { @@ -1283,29 +1318,37 @@ void to_string(CodeUsing self, String* result ) string_append_strc( result, txt("\n")); } -void to_string_ns(CodeUsing self, String* result ) +forceinline +void using_to_string_ns(CodeUsing self, String* result ) { + GEN_ASSERT(self); + GEN_ASSERT(result); if ( self->InlineCmt ) string_append_fmt( result, "using namespace $SC; %SC", self->Name, self->InlineCmt->Content ); else string_append_fmt( result, "using namespace %SC;\n", self->Name ); } -String to_string(CodeVar self) +forceinline +String var_to_string(CodeVar self) { + GEN_ASSERT(self); String result = string_make_reserve( GlobalAllocator, 256 ); - to_string( self, & result ); + var_to_string_ref( self, & result ); return result; } -void to_string(CodeVar self, String* result ) +neverinline +void var_to_string_ref(CodeVar self, String* result ) { + GEN_ASSERT(self); + GEN_ASSERT(result); if ( self->Parent && self->Parent->Type == CT_Variable ) { // Its a comma-separated variable ( a NextVar ) if ( self->Specs ) - string_append_fmt( result, "%S ", to_string(self->Specs) ); + string_append_fmt( result, "%S ", specifiers_to_string(self->Specs) ); string_append_strc( result, self->Name ); @@ -1331,7 +1374,7 @@ void to_string(CodeVar self, String* result ) // Keep the chain going... if ( self->NextVar ) - string_append_fmt( result, ", %S", to_string(self->NextVar) ); + string_append_fmt( result, ", %S", var_to_string(self->NextVar) ); if ( self->VarConstructorInit ) string_append_strc( result, txt(" )")); @@ -1345,12 +1388,12 @@ void to_string(CodeVar self, String* result ) if ( self->Attributes || self->Specs ) { if ( self->Attributes ) - string_append_fmt( result, "%S ", to_string(self->Specs) ); + string_append_fmt( result, "%S ", specifiers_to_string(self->Specs) ); if ( self->Specs ) - string_append_fmt( result, "%S\n", to_string(self->Specs) ); + string_append_fmt( result, "%S\n", specifiers_to_string(self->Specs) ); - string_append_fmt( result, "%S %SC", to_string(self->ValueType), self->Name ); + string_append_fmt( result, "%S %SC", typename_to_string(self->ValueType), self->Name ); if ( self->ValueType->ArrExpr ) { @@ -1376,7 +1419,7 @@ void to_string(CodeVar self, String* result ) } if ( self->NextVar ) - string_append_fmt( result, ", %S", to_string(self->NextVar) ); + string_append_fmt( result, ", %S", var_to_string(self->NextVar) ); if ( self->VarConstructorInit ) string_append_strc( result, txt(" )")); @@ -1390,11 +1433,11 @@ void to_string(CodeVar self, String* result ) } if ( self->BitfieldSize ) - string_append_fmt( result, "%S %SC : %S", to_string(self->ValueType), self->Name, code_to_string(self->BitfieldSize) ); + string_append_fmt( result, "%S %SC : %S", typename_to_string(self->ValueType), self->Name, code_to_string(self->BitfieldSize) ); else if ( self->ValueType->ArrExpr ) { - string_append_fmt( result, "%S %SC[ %S ]", to_string(self->ValueType), self->Name, code_to_string(self->ValueType->ArrExpr) ); + string_append_fmt( result, "%S %SC[ %S ]", typename_to_string(self->ValueType), self->Name, code_to_string(self->ValueType->ArrExpr) ); Code next_arr_expr = self->ValueType->ArrExpr->Next; while ( next_arr_expr ) @@ -1405,7 +1448,7 @@ void to_string(CodeVar self, String* result ) } else - string_append_fmt( result, "%S %SC", to_string(self->ValueType), self->Name ); + string_append_fmt( result, "%S %SC", typename_to_string(self->ValueType), self->Name ); if ( self->Value ) { @@ -1416,7 +1459,7 @@ void to_string(CodeVar self, String* result ) } if ( self->NextVar ) - string_append_fmt( result, ", %S", to_string( self->NextVar) ); + string_append_fmt( result, ", %S", var_to_string( self->NextVar) ); if ( self->VarConstructorInit ) string_append_strc( result, txt(" )")); diff --git a/project/components/code_types.hpp b/project/components/code_types.hpp index dec644d..b3ce6ea 100644 --- a/project/components/code_types.hpp +++ b/project/components/code_types.hpp @@ -3,177 +3,172 @@ #include "ast.hpp" #endif -#pragma region Code Type Interface -void append ( CodeBody body, Code other ); -void append ( CodeBody body, CodeBody other ); -String to_string ( CodeBody body ); -void to_string ( CodeBody body, String* result ); -void to_string_export ( CodeBody body, String* result ); +#pragma region Code Type C-Interface +void body_append ( CodeBody body, Code other ); +void body_append_body ( CodeBody body, CodeBody other ); +String body_to_string ( CodeBody body ); +void body_to_string_ref ( CodeBody body, String* result ); +void body_to_string_export( CodeBody body, String* result ); -Code begin( CodeBody body); -Code end ( CodeBody body ); -Code next ( CodeBody body ); +Code begin_CodeBody( CodeBody body); +Code end_CodeBody ( CodeBody body ); +Code next_CodeBody ( CodeBody body, Code entry_iter ); -void add_interface( CodeClass self, CodeType interface ); -String to_string ( CodeClass self ); -void to_string_def( CodeClass self, String* result ); -void to_string_fwd( CodeClass self, String* result ); +void class_add_interface( CodeClass self, CodeType interface ); +String class_to_string ( CodeClass self ); +void class_to_string_def( CodeClass self, String* result ); +void class_to_string_fwd( CodeClass self, String* result ); -void append (CodeParam params, CodeParam param ); -CodeParam get (CodeParam params, s32 idx); -bool has_entries(CodeParam params ); -String to_string (CodeParam params ); -void to_string (CodeParam params, String* result ); +void params_append (CodeParam params, CodeParam param ); +CodeParam params_get (CodeParam params, s32 idx); +bool params_has_entries (CodeParam params ); +String params_to_string (CodeParam params ); +void params_to_string_ref(CodeParam params, String* result ); -CodeParam begin(CodeParam params); -CodeParam end (CodeParam params); +CodeParam begin_CodeParam(CodeParam params); +CodeParam end_CodeParam (CodeParam params); +CodeParam next_CodeParam (CodeParam params, CodeParam entry_iter); -bool append (CodeSpecifiers specifiers, Specifier spec); -s32 has (CodeSpecifiers specifiers, Specifier spec); -s32 remove (CodeSpecifiers specifiers, Specifier to_remove ); -String to_string(CodeSpecifiers specifiers); -void to_string(CodeSpecifiers specifiers, String* result); +bool specifiers_append (CodeSpecifiers specifiers, Specifier spec); +s32 specifiers_has (CodeSpecifiers specifiers, Specifier spec); +s32 specifiers_remove (CodeSpecifiers specifiers, Specifier to_remove ); +String specifiers_to_string (CodeSpecifiers specifiers); +void specifiers_to_string_ref(CodeSpecifiers specifiers, String* result); -Specifier* begin(CodeSpecifiers specifiers ); -Specifier* end (CodeSpecifiers specifiers); +Specifier* begin_CodeSpecifiers(CodeSpecifiers specifiers); +Specifier* end_CodeSpecifiers (CodeSpecifiers specifiers); +Specifier* next_CodeSpecifiers (CodeSpecifiers specifiers, Specifier* spec_iter); -void add_interface(CodeStruct self, CodeType interface); -String to_string (CodeStruct self); -void to_string_fwd(CodeStruct self, String* result); -void to_string_def(CodeStruct self, String* result); +void struct_add_interface(CodeStruct self, CodeType interface); +String struct_to_string (CodeStruct self); +void struct_to_string_fwd(CodeStruct self, String* result); +void struct_to_string_def(CodeStruct self, String* result); -String to_string(CodeAttributes attributes); -String to_string(CodeComment comment ); +String attributes_to_string (CodeAttributes attributes); +void attributes_to_string_ref(CodeAttributes attributes, String* result); -String to_string (CodeConstructor constructor); -void to_string_def(CodeConstructor constructor, String* result ); -void to_string_fwd(CodeConstructor constructor, String* result ); +String comment_to_string (CodeComment comment ); +void comment_to_string_ref(CodeComment comment, String* result ); -String to_string(CodeDefine define); -void to_string(CodeDefine define, String* result); +String constructor_to_string (CodeConstructor constructor); +void constructor_to_string_def(CodeConstructor constructor, String* result ); +void constructor_to_string_fwd(CodeConstructor constructor, String* result ); -String to_string (CodeDestructor destructor); -void to_string_def(CodeDestructor destructor, String* result ); -void to_string_fwd(CodeDestructor destructor, String* result ); +String define_to_string (CodeDefine define); +void define_to_string_ref(CodeDefine define, String* result); -String to_string (CodeEnum self); -void to_string_def (CodeEnum self, String* result ); -void to_string_fwd (CodeEnum self, String* result ); -void to_string_class_def(CodeEnum self, String* result ); -void to_string_class_fwd(CodeEnum self, String* result ); +String destructor_to_string (CodeDestructor destructor); +void destructor_to_string_def(CodeDestructor destructor, String* result ); +void destructor_to_string_fwd(CodeDestructor destructor, String* result ); -String to_string(CodeExec exec); +String enum_to_string (CodeEnum self); +void enum_to_string_def (CodeEnum self, String* result ); +void enum_to_string_fwd (CodeEnum self, String* result ); +void enum_to_string_class_def(CodeEnum self, String* result ); +void enum_to_string_class_fwd(CodeEnum self, String* result ); -void to_string(CodeExtern self, String* result); +String exec_to_string (CodeExec exec); +void exec_to_string_ref(CodeExec exec, String* result); -String to_string(CodeInclude include); -void to_string(CodeInclude include, String* result); +void extern_to_string(CodeExtern self, String* result); -String to_string(CodeFriend self); -void to_string(CodeFriend self, String* result); +String include_to_string (CodeInclude include); +void include_to_string_ref(CodeInclude include, String* result); -String to_string (CodeFn self); -void to_string_def(CodeFn self, String* result); -void to_string_fwd(CodeFn self, String* result); +String friend_to_string (CodeFriend self); +void friend_to_string_ref(CodeFriend self, String* result); -String to_string(CodeModule self); -void to_string(CodeModule self, String* result); +String fn_to_string (CodeFn self); +void fn_to_string_def(CodeFn self, String* result); +void fn_to_string_fwd(CodeFn self, String* result); -String to_string(CodeNS self); -void to_string(CodeNS self, String* result); +String module_to_string (CodeModule self); +void module_to_string_ref(CodeModule self, String* result); -String to_string (CodeOperator self); -void to_string_fwd(CodeOperator self, String* result ); -void to_string_def(CodeOperator self, String* result ); +String namespace_to_string (CodeNS self); +void namespace_to_string_ref(CodeNS self, String* result); -String to_string (CodeOpCast op_cast ); -void to_string_def(CodeOpCast op_cast, String* result ); -void to_string_fwd(CodeOpCast op_cast, String* result ); +String code_op_to_string (CodeOperator self); +void code_op_to_string_fwd(CodeOperator self, String* result ); +void code_op_to_string_def(CodeOperator self, String* result ); -String to_string(CodePragma self); -void to_string(CodePragma self, String* result); +String opcast_to_string (CodeOpCast op_cast ); +void opcast_to_string_def(CodeOpCast op_cast, String* result ); +void opcast_to_string_fwd(CodeOpCast op_cast, String* result ); -String to_string (CodePreprocessCond cond); -void to_string_if (CodePreprocessCond cond, String* result ); -void to_string_ifdef (CodePreprocessCond cond, String* result ); -void to_string_ifndef(CodePreprocessCond cond, String* result ); -void to_string_elif (CodePreprocessCond cond, String* result ); -void to_string_else (CodePreprocessCond cond, String* result ); -void to_string_endif (CodePreprocessCond cond, String* result ); +String pragma_to_string (CodePragma self); +void pragma_to_string_ref(CodePragma self, String* result); -String to_string(CodeTemplate self); -void to_string(CodeTemplate self, String* result); +String preprocess_to_string (CodePreprocessCond cond); +void preprocess_to_string_if (CodePreprocessCond cond, String* result ); +void preprocess_to_string_ifdef (CodePreprocessCond cond, String* result ); +void preprocess_to_string_ifndef(CodePreprocessCond cond, String* result ); +void preprocess_to_string_elif (CodePreprocessCond cond, String* result ); +void preprocess_to_string_else (CodePreprocessCond cond, String* result ); +void preprocess_to_string_endif (CodePreprocessCond cond, String* result ); -String to_string(CodeTypename self); -void to_string(CodeTypename self, String* result); +String template_to_string (CodeTemplate self); +void template_to_string_ref(CodeTemplate self, String* result); -String to_string(CodeTypedef self); -void to_string(CodeTypedef self, String* result); +String typename_to_string (CodeTypename self); +void typename_to_string_ref(CodeTypename self, String* result); -String to_string(CodeUnion self); -void to_string_def(CodeUnion self, String* result); -void to_string_fwd(CodeUnion self, String* result); +String typedef_to_string (CodeTypedef self); +void typedef_to_string_ref(CodeTypedef self, String* result ); -String to_string (CodeUsing op_cast ); -void to_string (CodeUsing op_cast, String* result ); -void to_string_ns(CodeUsing op_cast, String* result ); +String union_to_string (CodeUnion self); +void union_to_string_def(CodeUnion self, String* result); +void union_to_string_fwd(CodeUnion self, String* result); -String to_string(CodeVar self); -void to_string(CodeVar self, String* result); -#pragma endregion Code Type Interface +String using_to_string (CodeUsing op_cast ); +void using_to_string_ref(CodeUsing op_cast, String* result ); +void using_to_string_ns (CodeUsing op_cast, String* result ); + +String var_to_string (CodeVar self); +void var_to_string_ref(CodeVar self, String* result); +#pragma endregion Code Type C-Interface + +#pragma region Code Types C++ -#pragma region Code Types // These structs are not used at all by the C vairant. -#if ! GEN_COMPILER_C -// stati_assert( GEN_COMPILER_C, "This should not be compiled with the C-library" ); +#if GEN_COMPILER_CPP +static_assert( GEN_COMPILER_CPP, "This should not be compiled with the C-library" ); #define Verify_POD(Type) static_assert(size_of(Code##Type) == size_of(AST_##Type), "ERROR: Code##Type is not a POD") struct CodeBody { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeBody ); + forceinline void append( Code other ) { return body_append( *this, other ); } + forceinline void append( CodeBody body ) { return body_append(*this, body); } + forceinline bool has_entries() { return code_has_entries(* this); } + forceinline String to_string() { return body_to_string(* this); } + forceinline void to_string( String& result ) { return body_to_string_ref(* this, & result ); } + forceinline void to_string_export( String& result ) { return body_to_string_export(* this, & result); } - void append( Code other ) { return GEN_NS append( *this, other ); } - void append( CodeBody body ) { return GEN_NS append(*this, body); } - bool has_entries() { return GEN_NS code_has_entries(* this); } - - String to_string() { return GEN_NS to_string(* this); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result ); } - void to_string_export( String& result ) { return GEN_NS to_string_export(* this, & result); } - - Code begin() { return GEN_NS begin(* this); } - Code end() { return GEN_NS end(* this); } + forceinline Code begin() { return begin_CodeBody(* this); } + forceinline Code end() { return end_CodeBody(* this); } #endif - Using_CodeOps( CodeBody ); - operator Code() { return * rcast( Code*, this ); } - AST_Body* operator->() { return ast; } - + forceinline operator Code() { return * rcast( Code*, this ); } + forceinline AST_Body* operator->() { return ast; } AST_Body* ast; }; struct CodeClass { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeClass ); - - void add_interface( CodeType interface ); - - String to_string(); - void to_string_def( String& result ); - void to_string_fwd( String& result ); + forceinline void add_interface( CodeType interface ); + forceinline String to_string(); + forceinline void to_string_def( String& result ); + forceinline void to_string_fwd( String& result ); #endif - Using_CodeOps( CodeClass ); - operator Code() { return * rcast( Code*, this ); } - AST_Class* operator->() - { - if ( ast == nullptr ) - { - log_failure("Attempt to dereference a nullptr"); - return nullptr; - } + forceinline operator Code() { return * rcast( Code*, this ); } + forceinline AST_Class* operator->() { + GEN_ASSERT(ast); return ast; } AST_Class* ast; @@ -181,81 +176,57 @@ struct CodeClass struct CodeParam { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeParam ); - - void append( CodeParam other ); - CodeParam get( s32 idx ); - bool has_entries(); - String to_string(); - void to_string( String& result ); + forceinline void append( CodeParam other ); + forceinline CodeParam get( s32 idx ); + forceinline bool has_entries(); + forceinline String to_string(); + forceinline void to_string( String& result ); #endif - Using_CodeOps( CodeParam ); - AST_Param* operator->() - { - if ( ast == nullptr ) - { - log_failure("Attempt to dereference a nullptr!"); - return nullptr; - } + forceinline operator Code() { return { (AST*)ast }; } + forceinline CodeParam operator*() { return * this; } + forceinline AST_Param* operator->() { + GEN_ASSERT(ast); return ast; } - operator Code() { return { (AST*)ast }; } - CodeParam operator*() { return * this; } CodeParam& operator++(); - AST_Param* ast; }; struct CodeSpecifiers { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeSpecifiers ); - - bool append( Specifier spec ) { return GEN_NS append(* this, spec); } - s32 has( Specifier spec ) { return GEN_NS has(* this, spec); } - s32 remove( Specifier to_remove ) { return GEN_NS remove(* this, to_remove); } - String to_string() { return GEN_NS to_string(* this ); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } + bool append( Specifier spec ) { return specifiers_append(* this, spec); } + s32 has( Specifier spec ) { return specifiers_has(* this, spec); } + s32 remove( Specifier to_remove ) { return specifiers_remove(* this, to_remove); } + String to_string() { return specifiers_to_string(* this ); } + void to_string( String& result ) { return specifiers_to_string_ref(* this, & result); } #endif - Using_CodeOps(CodeSpecifiers); - operator Code() { return { (AST*) ast }; } - AST_Specifiers* operator->() - { - if ( ast == nullptr ) - { - log_failure("Attempt to dereference a nullptr!"); - return nullptr; - } + forceinline operator Code() { return { (AST*) ast }; } + forceinline AST_Specifiers* operator->() { + GEN_ASSERT(ast); return ast; } - AST_Specifiers* ast; }; struct CodeStruct { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeStruct ); - - void add_interface( CodeType interface ); - - String to_string(); - void to_string_fwd( String& result ); - void to_string_def( String& result ); + forceinline void add_interface( CodeType interface ) { return struct_add_interface(* this, interface); } + forceinline String to_string() { return struct_to_string(* this); } + forceinline void to_string_fwd( String& result ) { return struct_to_string_fwd(* this, & result); } + forceinline void to_string_def( String& result ) { return struct_to_string_def(* this, & result); } #endif - Using_CodeOps( CodeStruct ); - operator Code() { return * rcast( Code*, this ); } - AST_Struct* operator->() - { - if ( ast == nullptr ) - { - log_failure("Attempt to dereference a nullptr"); - return nullptr; - } + forceinline operator Code() { return * rcast( Code*, this ); } + forceinline AST_Struct* operator->() { + GEN_ASSERT(ast); return ast; } AST_Struct* ast; @@ -263,11 +234,11 @@ struct CodeStruct struct CodeAttributes { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code(CodeAttributes); - String to_string(); + forceinline String to_string() { return attributes_to_string(* this); } + forceinline void to_string(String& result) { return attributes_to_string_ref(* this, & result); } #endif - Using_CodeOps(CodeAttributes); operator Code(); AST_Attributes *operator->(); @@ -278,11 +249,11 @@ struct CodeAttributes struct CodeComment { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code(CodeComment); - String to_string() { return GEN_NS to_string(* this); } + forceinline String to_string() { return comment_to_string (* this); } + forceinline void to_string(String& result) { return comment_to_string_ref(* this, & result); } #endif - Using_CodeOps(CodeComment); operator Code(); AST_Comment *operator->(); @@ -291,14 +262,12 @@ struct CodeComment struct CodeConstructor { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeConstructor ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); } - void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); } + forceinline String to_string() { return constructor_to_string(* this); } + forceinline void to_string_def( String& result ) { return constructor_to_string_def(* this, & result); } + forceinline void to_string_fwd( String& result ) { return constructor_to_string_fwd(* this, & result); } #endif - Using_CodeOps(CodeConstructor); operator Code(); AST_Constructor* operator->(); @@ -307,13 +276,11 @@ struct CodeConstructor struct CodeDefine { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeDefine ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } + forceinline String to_string() { return define_to_string(* this); } + forceinline void to_string( String& result ) { return define_to_string_ref(* this, & result); } #endif - Using_CodeOps(CodeDefine); operator Code(); AST_Define* operator->(); @@ -322,14 +289,12 @@ struct CodeDefine struct CodeDestructor { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeDestructor ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); } - void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); } + forceinline String to_string() { return destructor_to_string(* this); } + forceinline void to_string_def( String& result ) { return destructor_to_string_def(* this, & result); } + forceinline void to_string_fwd( String& result ) { return destructor_to_string_fwd(* this, & result); } #endif - Using_CodeOps(CodeDestructor); operator Code(); AST_Destructor* operator->(); @@ -338,16 +303,14 @@ struct CodeDestructor struct CodeEnum { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeEnum ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); } - void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); } - void to_string_class_def( String& result ) { return GEN_NS to_string_class_def(* this, & result); } - void to_string_class_fwd( String& result ) { return GEN_NS to_string_class_fwd(* this, & result); } + forceinline String to_string() { return enum_to_string(* this); } + forceinline void to_string_def( String& result ) { return enum_to_string_def(* this, & result); } + forceinline void to_string_fwd( String& result ) { return enum_to_string_fwd(* this, & result); } + forceinline void to_string_class_def( String& result ) { return enum_to_string_class_def(* this, & result); } + forceinline void to_string_class_fwd( String& result ) { return enum_to_string_class_fwd(* this, & result); } #endif - Using_CodeOps(CodeEnum); operator Code(); AST_Enum* operator->(); @@ -356,11 +319,11 @@ struct CodeEnum struct CodeExec { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code(CodeExec); - String to_string() { return GEN_NS to_string(* this); } + forceinline String to_string() { return exec_to_string(* this); } + forceinline void to_string(String& result) { return exec_to_string_ref(* this, & result); } #endif - Using_CodeOps(CodeExec); operator Code(); AST_Exec *operator->(); @@ -370,11 +333,10 @@ struct CodeExec #if GEN_EXECUTION_EXPRESSION_SUPPORT struct CodeExpr { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr* operator->(); AST_Expr* ast; @@ -382,11 +344,10 @@ struct CodeExpr struct CodeExpr_Assign { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Assign ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_Assign* operator->(); AST_Expr_Assign* ast; @@ -394,11 +355,10 @@ struct CodeExpr_Assign struct CodeExpr_Alignof { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Alignof ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_Alignof* operator->(); AST_Expr_Alignof* ast; @@ -406,11 +366,10 @@ struct CodeExpr_Alignof struct CodeExpr_Binary { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Binary ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_Binary* operator->(); AST_Expr_Binary* ast; @@ -418,11 +377,10 @@ struct CodeExpr_Binary struct CodeExpr_CStyleCast { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_CStyleCast ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_CStyleCast* operator->(); AST_Expr_CStyleCast* ast; @@ -430,11 +388,10 @@ struct CodeExpr_CStyleCast struct CodeExpr_FunctionalCast { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_FunctionalCast ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_FunctionalCast* operator->(); AST_Expr_FunctionalCast* ast; @@ -442,11 +399,10 @@ struct CodeExpr_FunctionalCast struct CodeExpr_CppCast { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_CppCast ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_CppCast* operator->(); AST_Expr_CppCast* ast; @@ -454,11 +410,10 @@ struct CodeExpr_CppCast struct CodeExpr_Element { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Element ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_Element* operator->(); AST_Expr_Element* ast; @@ -466,11 +421,10 @@ struct CodeExpr_Element struct CodeExpr_ProcCall { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_ProcCall ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_ProcCall* operator->(); AST_Expr_ProcCall* ast; @@ -478,11 +432,10 @@ struct CodeExpr_ProcCall struct CodeExpr_Decltype { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Decltype ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_Decltype* operator->(); AST_Expr_Decltype* ast; @@ -490,11 +443,10 @@ struct CodeExpr_Decltype struct CodeExpr_Comma { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Comma ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_Comma* operator->(); AST_Expr_Comma* ast; @@ -502,11 +454,10 @@ struct CodeExpr_Comma struct CodeExpr_AMS { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_AMS ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_AMS* operator->(); AST_Expr_AMS* ast; @@ -514,11 +465,10 @@ struct CodeExpr_AMS struct CodeExpr_Sizeof { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Sizeof ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_Sizeof* operator->(); AST_Expr_Sizeof* ast; @@ -526,11 +476,10 @@ struct CodeExpr_Sizeof struct CodeExpr_Subscript { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Subscript ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_Subscript* operator->(); AST_Expr_Subscript* ast; @@ -538,11 +487,10 @@ struct CodeExpr_Subscript struct CodeExpr_Ternary { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_Ternary ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_Ternary* operator->(); AST_Expr_Ternary* ast; @@ -550,11 +498,10 @@ struct CodeExpr_Ternary struct CodeExpr_UnaryPrefix { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_UnaryPrefix ); - - void to_string( String& result ); - - AST* raw(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Expr_UnaryPrefix* operator->(); AST_Expr_UnaryPrefix* ast; @@ -562,10 +509,10 @@ struct CodeExpr_UnaryPrefix struct CodeExpr_UnaryPostfix { +#if ! GEN_C_LIKE_CPP Using_Code( CodeExpr_UnaryPostfix ); - - void to_string( String& result ); - + forceinline void to_string( String& result ); +#endif AST* raw(); operator Code(); AST_Expr_UnaryPostfix* operator->(); @@ -575,12 +522,10 @@ struct CodeExpr_UnaryPostfix struct CodeExtern { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeExtern ); - - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } + forceinline void to_string( String& result ) { return extern_to_string(* this, & result); } #endif - Using_CodeOps(CodeExtern); operator Code(); AST_Extern* operator->(); @@ -589,13 +534,11 @@ struct CodeExtern struct CodeInclude { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeInclude ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } + String to_string() { return include_to_string(* this); } + forceinline void to_string( String& result ) { return include_to_string_ref(* this, & result); } #endif - Using_CodeOps(CodeInclude); operator Code(); AST_Include* operator->(); @@ -604,13 +547,11 @@ struct CodeInclude struct CodeFriend { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeFriend ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } + forceinline String to_string() { return friend_to_string(* this); } + forceinline void to_string( String& result ) { return friend_to_string_ref(* this, & result); } #endif - Using_CodeOps(CodeFriend); operator Code(); AST_Friend* operator->(); @@ -619,14 +560,12 @@ struct CodeFriend struct CodeFn { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeFn ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); } - void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); } + forceinline String to_string() { return fn_to_string(* this); } + forceinline void to_string_def( String& result ) { return fn_to_string_def(* this, & result); } + forceinline void to_string_fwd( String& result ) { return fn_to_string_fwd(* this, & result); } #endif - Using_CodeOps(CodeFn); operator Code(); AST_Fn* operator->(); @@ -635,13 +574,11 @@ struct CodeFn struct CodeModule { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeModule ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } + forceinline String to_string() { return module_to_string(* this); } + forceinline void to_string( String& result ) { return module_to_string_ref(* this, & result); } #endif - Using_CodeOps(CodeModule); operator Code(); AST_Module* operator->(); @@ -650,13 +587,11 @@ struct CodeModule struct CodeNS { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeNS ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } + forceinline String to_string() { return namespace_to_string(* this); } + forceinline void to_string( String& result ) { return namespace_to_string_ref(* this, & result); } #endif - Using_CodeOps(CodeNS); operator Code(); AST_NS* operator->(); @@ -665,14 +600,12 @@ struct CodeNS struct CodeOperator { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeOperator ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); } - void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); } + forceinline String to_string() { return code_op_to_string(* this); } + forceinline void to_string_def( String& result ) { return code_op_to_string_def(* this, & result); } + forceinline void to_string_fwd( String& result ) { return code_op_to_string_fwd(* this, & result); } #endif - Using_CodeOps(CodeOperator); operator Code(); AST_Operator* operator->(); @@ -681,14 +614,12 @@ struct CodeOperator struct CodeOpCast { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeOpCast ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); } - void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); } + forceinline String to_string() { return opcast_to_string(* this); } + forceinline void to_string_def( String& result ) { return opcast_to_string_def(* this, & result); } + forceinline void to_string_fwd( String& result ) { return opcast_to_string_fwd(* this, & result); } #endif - Using_CodeOps(CodeOpCast); operator Code(); AST_OpCast* operator->(); @@ -697,13 +628,11 @@ struct CodeOpCast struct CodePragma { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodePragma ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } + forceinline String to_string() { return pragma_to_string(* this); } + forceinline void to_string( String& result ) { return pragma_to_string_ref(* this, & result); } #endif - Using_CodeOps( CodePragma ); operator Code(); AST_Pragma* operator->(); @@ -712,18 +641,16 @@ struct CodePragma struct CodePreprocessCond { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodePreprocessCond ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string_if( String& result ) { return GEN_NS to_string_if(* this, & result); } - void to_string_ifdef( String& result ) { return GEN_NS to_string_ifdef(* this, & result); } - void to_string_ifndef( String& result ) { return GEN_NS to_string_ifndef(* this, & result); } - void to_string_elif( String& result ) { return GEN_NS to_string_elif(* this, & result); } - void to_string_else( String& result ) { return GEN_NS to_string_else(* this, & result); } - void to_string_endif( String& result ) { return GEN_NS to_string_endif(* this, & result); } + forceinline String to_string() { return preprocess_to_string(* this); } + forceinline void to_string_if( String& result ) { return preprocess_to_string_if(* this, & result); } + forceinline void to_string_ifdef( String& result ) { return preprocess_to_string_ifdef(* this, & result); } + forceinline void to_string_ifndef( String& result ) { return preprocess_to_string_ifndef(* this, & result); } + forceinline void to_string_elif( String& result ) { return preprocess_to_string_elif(* this, & result); } + forceinline void to_string_else( String& result ) { return preprocess_to_string_else(* this, & result); } + forceinline void to_string_endif( String& result ) { return preprocess_to_string_endif(* this, & result); } #endif - Using_CodeOps( CodePreprocessCond ); operator Code(); AST_PreprocessCond* operator->(); @@ -733,12 +660,11 @@ struct CodePreprocessCond #if GEN_EXECUTION_EXPRESSION_SUPPORT struct CodeStmt { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt* operator->(); AST_Stmt* ast; @@ -746,12 +672,11 @@ struct CodeStmt struct CodeStmt_Break { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Break ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_Break* operator->(); AST_Stmt_Break* ast; @@ -759,12 +684,11 @@ struct CodeStmt_Break struct CodeStmt_Case { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Case ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_Case* operator->(); AST_Stmt_Case* ast; @@ -772,12 +696,11 @@ struct CodeStmt_Case struct CodeStmt_Continue { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Continue ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_Continue* operator->(); AST_Stmt_Continue* ast; @@ -785,12 +708,11 @@ struct CodeStmt_Continue struct CodeStmt_Decl { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Decl ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_Decl* operator->(); AST_Stmt_Decl* ast; @@ -798,12 +720,11 @@ struct CodeStmt_Decl struct CodeStmt_Do { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Do ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_Do* operator->(); AST_Stmt_Do* ast; @@ -811,12 +732,11 @@ struct CodeStmt_Do struct CodeStmt_Expr { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Expr ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_Expr* operator->(); AST_Stmt_Expr* ast; @@ -824,12 +744,11 @@ struct CodeStmt_Expr struct CodeStmt_Else { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Else ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_Else* operator->(); AST_Stmt_Else* ast; @@ -837,12 +756,11 @@ struct CodeStmt_Else struct CodeStmt_If { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_If ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_If* operator->(); AST_Stmt_If* ast; @@ -850,12 +768,11 @@ struct CodeStmt_If struct CodeStmt_For { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_For ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_For* operator->(); AST_Stmt_For* ast; @@ -863,12 +780,11 @@ struct CodeStmt_For struct CodeStmt_Goto { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Goto ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_Goto* operator->(); AST_Stmt_Goto* ast; @@ -876,12 +792,11 @@ struct CodeStmt_Goto struct CodeStmt_Label { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Label ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_Label* operator->(); AST_Stmt_Label* ast; @@ -889,12 +804,11 @@ struct CodeStmt_Label struct CodeStmt_Switch { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_Switch ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_Switch* operator->(); AST_Stmt_Switch* ast; @@ -902,12 +816,11 @@ struct CodeStmt_Switch struct CodeStmt_While { +#if ! GEN_C_LIKE_CPP Using_Code( CodeStmt_While ); - - String to_string(); - void to_string( String& result ); - - AST* raw(); + forceinline String to_string(); + forceinline void to_string( String& result ); +#endif operator Code(); AST_Stmt_While* operator->(); AST_Stmt_While* ast; @@ -916,13 +829,11 @@ struct CodeStmt_While struct CodeTemplate { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeTemplate ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } + forceinline String to_string() { return template_to_string(* this); } + forceinline void to_string( String& result ) { return template_to_string_ref(* this, & result); } #endif - Using_CodeOps( CodeTemplate ); operator Code(); AST_Template* operator->(); @@ -931,13 +842,11 @@ struct CodeTemplate struct CodeTypename { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeTypename ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } + forceinline String to_string() { return typename_to_string(* this); } + forceinline void to_string( String& result ) { return typename_to_string_ref(* this, & result); } #endif - Using_CodeOps( CodeTypename ); operator Code(); AST_Typename* operator->(); @@ -946,13 +855,11 @@ struct CodeTypename struct CodeTypedef { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeTypedef ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } + forceinline String to_string() { return typedef_to_string(* this); } + forceinline void to_string( String& result ) { return typedef_to_string_ref(* this, & result); } #endif - Using_CodeOps( CodeTypedef ); operator Code(); AST_Typedef* operator->(); @@ -961,14 +868,12 @@ struct CodeTypedef struct CodeUnion { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeUnion ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); } - void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); } + forceinline String to_string() { return union_to_string(* this); } + forceinline void to_string_def( String& result ) { return union_to_string_def(* this, & result); } + forceinline void to_string_fwd( String& result ) { return union_to_string_fwd(* this, & result); } #endif - Using_CodeOps(CodeUnion); operator Code(); AST_Union* operator->(); @@ -977,14 +882,12 @@ struct CodeUnion struct CodeUsing { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeUsing ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } - void to_string_ns( String& result ) { return GEN_NS to_string_ns(* this, & result); } + forceinline String to_string() { return using_to_string(* this); } + forceinline void to_string( String& result ) { return using_to_string_ref(* this, & result); } + forceinline void to_string_ns( String& result ) { return using_to_string_ns(* this, & result); } #endif - Using_CodeOps(CodeUsing); operator Code(); AST_Using* operator->(); @@ -993,13 +896,11 @@ struct CodeUsing struct CodeVar { -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP Using_Code( CodeVar ); - - String to_string() { return GEN_NS to_string(* this); } - void to_string( String& result ) { return GEN_NS to_string(* this, & result); } + forceinline String to_string() { return var_to_string(* this); } + forceinline void to_string( String& result ) { return var_to_string_ref(* this, & result); } #endif - Using_CodeOps(CodeVar); operator Code(); AST_Var* operator->(); @@ -1011,7 +912,7 @@ struct CodeVar #undef Using_CodeOps #if GEN_SUPPORT_CPP_REFERENCES -void to_string_export( CodeBody body, String& result ) { return to_string_export(body, & result); }; +void to_string_export( CodeBody body, String& result ) { return body_to_string_export(body, & result); }; #endif #undef Verify_POD @@ -1050,6 +951,134 @@ struct InvalidCode_ImplictCaster operator CodeVar () const { return cast(CodeVar, Code_Invalid); } }; -#endif //if ! GEN_COMPILER_C -#pragma endregion Code Types +#if ! GEN_C_LIKE_CPP +GEN_OPTIMIZE_MAPPINGS_BEGIN +forceinline void append ( CodeBody body, Code other ) { return body_append(body, other); } +forceinline void append ( CodeBody body, CodeBody other ) { return body_append_body(body, other); }; +forceinline String to_string ( CodeBody body ) { return body_to_string(body); } +forceinline void to_string ( CodeBody body, String& result ) { return body_to_string_ref(body, & result); } +forceinline void to_string_export( CodeBody body, String& result ) { return body_to_string_export(body, & result); } + +forceinline Code begin( CodeBody body) { return begin_CodeBody(body); } +forceinline Code end ( CodeBody body ) { return end_CodeBody(body); } +forceinline Code next ( CodeBody body, Code entry_iter ) { return next_CodeBody(body, entry_iter); } + +forceinline void add_interface( CodeClass self, CodeType interface ) { return class_add_interface(self, interface); } +forceinline String to_string ( CodeClass self ) { return class_to_string(self); } +forceinline void to_string_def( CodeClass self, String& result ) { return class_to_string_def(self, & result); } +forceinline void to_string_fwd( CodeClass self, String& result ) { return class_to_string_fwd(self, & result); } + +forceinline void append (CodeParam params, CodeParam param ) { return params_append(params, param); } +forceinline CodeParam get (CodeParam params, s32 idx) { return params_get(params, idx); } +forceinline bool has_entries(CodeParam params ) { return params_has_entries(params); } +forceinline String to_string (CodeParam params ) { return params_to_string(params); } +forceinline void to_string (CodeParam params, String& result ) { return params_to_string_ref(params, & result); } + +forceinline CodeParam begin(CodeParam params) { return begin_CodeParam(params); } +forceinline CodeParam end (CodeParam params) { return end_CodeParam(params); } +forceinline CodeParam next (CodeParam params, CodeParam entry_iter) { return next_CodeParam(params, entry_iter); } + +forceinline bool append (CodeSpecifiers specifiers, Specifier spec) { return specifiers_append(specifiers, spec); } +forceinline s32 has (CodeSpecifiers specifiers, Specifier spec) { return specifiers_has(specifiers, spec); } +forceinline s32 remove (CodeSpecifiers specifiers, Specifier to_remove ) { return specifiers_remove(specifiers, to_remove); } +forceinline String to_string(CodeSpecifiers specifiers) { return specifiers_to_string(specifiers); } +forceinline void to_string(CodeSpecifiers specifiers, String& result) { return specifiers_to_string_ref(specifiers, & result); } + +forceinline Specifier* begin(CodeSpecifiers specifiers) { return begin_CodeSpecifiers(specifiers); } +forceinline Specifier* end (CodeSpecifiers specifiers) { return end_CodeSpecifiers(specifiers); } +forceinline Specifier* next (CodeSpecifiers specifiers, Specifier& spec_iter) { return next_CodeSpecifiers(specifiers, & spec_iter); } + +forceinline void add_interface(CodeStruct self, CodeType interface) { return struct_add_interface(self, interface); } +forceinline String to_string (CodeStruct self) { return struct_to_string(self); } +forceinline void to_string_fwd(CodeStruct self, String& result) { return struct_to_string_fwd(self, & result); } +forceinline void to_string_def(CodeStruct self, String& result) { return struct_to_string_def(self, & result); } + +forceinline String to_string(CodeAttributes attributes) { return attributes_to_string(attributes); } +forceinline void to_string(CodeAttributes attributes, String& result) { return attributes_to_string_ref(attributes, & result); } + +forceinline String to_string(CodeComment comment ) { return comment_to_string(comment); } +forceinline void to_string(CodeComment comment, String& result ) { return comment_to_string_ref(comment, & result); } + +forceinline String to_string (CodeConstructor constructor) { return constructor_to_string(constructor); } +forceinline void to_string_def(CodeConstructor constructor, String& result ) { return constructor_to_string_def(constructor, & result); } +forceinline void to_string_fwd(CodeConstructor constructor, String& result ) { return constructor_to_string_fwd(constructor, & result); } + +forceinline String to_string(CodeDefine define) { return define_to_string(define); } +forceinline void to_string(CodeDefine define, String& result) { return define_to_string_ref(define, & result); } + +forceinline String to_string (CodeDestructor destructor) { return destructor_to_string(destructor); } +forceinline void to_string_def(CodeDestructor destructor, String& result ) { return destructor_to_string_def(destructor, & result); } +forceinline void to_string_fwd(CodeDestructor destructor, String& result ) { return destructor_to_string_fwd(destructor, & result); } + +forceinline String to_string (CodeEnum self) { return enum_to_string(self); } +forceinline void to_string_def (CodeEnum self, String& result ) { return enum_to_string_def(self, & result); } +forceinline void to_string_fwd (CodeEnum self, String& result ) { return enum_to_string_fwd(self, & result); } +forceinline void to_string_class_def(CodeEnum self, String& result ) { return enum_to_string_class_def(self, & result); } +forceinline void to_string_class_fwd(CodeEnum self, String& result ) { return enum_to_string_class_fwd(self, & result); } + +forceinline String to_string(CodeExec exec) { return exec_to_string(exec); } +forceinline void to_string(CodeExec exec, String& result) { return exec_to_string_ref(exec, & result); } + +forceinline void to_string(CodeExtern self, String& result) { return extern_to_string(self, & result); } + +forceinline String to_string(CodeInclude include) { return include_to_string(include); } +forceinline void to_string(CodeInclude include, String& result) { return include_to_string_ref(include, & result); } + +forceinline String to_string(CodeFriend self) { return friend_to_string(self); } +forceinline void to_string(CodeFriend self, String& result) { return friend_to_string_ref(self, & result); } + +forceinline String to_string (CodeFn self) { return fn_to_string(self); } +forceinline void to_string_def(CodeFn self, String& result) { return fn_to_string_def(self, & result); } +forceinline void to_string_fwd(CodeFn self, String& result) { return fn_to_string_fwd(self, & result); } + +forceinline String to_string(CodeModule self) { return module_to_string(self); } +forceinline void to_string(CodeModule self, String& result) { return module_to_string_ref(self, & result); } + +forceinline String to_string(CodeNS self) { return namespace_to_string(self); } +forceinline void to_string(CodeNS self, String& result) { return namespace_to_string_ref(self, & result); } + +forceinline String to_string (CodeOperator self) { return code_op_to_string(self); } +forceinline void to_string_fwd(CodeOperator self, String& result ) { return code_op_to_string_fwd(self, & result); } +forceinline void to_string_def(CodeOperator self, String& result ) { return code_op_to_string_def(self, & result); } + +forceinline String to_string (CodeOpCast op_cast ) { return opcast_to_string(op_cast); } +forceinline void to_string_def(CodeOpCast op_cast, String& result ) { return opcast_to_string_def(op_cast, & result); } +forceinline void to_string_fwd(CodeOpCast op_cast, String& result ) { return opcast_to_string_fwd(op_cast, & result); } + +forceinline String to_string(CodePragma self) { return pragma_to_string(self); } +forceinline void to_string(CodePragma self, String& result) { return pragma_to_string_ref(self, & result); } + +forceinline String to_string (CodePreprocessCond cond) { return preprocess_to_string(cond); } +forceinline void to_string_if (CodePreprocessCond cond, String& result ) { return preprocess_to_string_if(cond, & result); } +forceinline void to_string_ifdef (CodePreprocessCond cond, String& result ) { return preprocess_to_string_ifdef(cond, & result); } +forceinline void to_string_ifndef(CodePreprocessCond cond, String& result ) { return preprocess_to_string_ifndef(cond, & result); } +forceinline void to_string_elif (CodePreprocessCond cond, String& result ) { return preprocess_to_string_elif(cond, & result); } +forceinline void to_string_else (CodePreprocessCond cond, String& result ) { return preprocess_to_string_else(cond, & result); } +forceinline void to_string_endif (CodePreprocessCond cond, String& result ) { return preprocess_to_string_endif(cond, & result); } + +forceinline String to_string(CodeTemplate self) { return template_to_string(self); } +forceinline void to_string(CodeTemplate self, String& result) { return template_to_string_ref(self, & result); } + +forceinline String to_string(CodeTypename self) { return typename_to_string(self); } +forceinline void to_string(CodeTypename self, String& result) { return typename_to_string_ref(self, & result); } + +forceinline String to_string(CodeTypedef self) { return typedef_to_string(self); } +forceinline void to_string(CodeTypedef self, String& result ) { return typedef_to_string_ref(self, & result); } + +forceinline String to_string (CodeUnion self) { return union_to_string(self); } +forceinline void to_string_def(CodeUnion self, String& result) { return union_to_string_def(self, & result); } +forceinline void to_string_fwd(CodeUnion self, String& result) { return union_to_string_fwd(self, & result); } + +forceinline String to_string (CodeUsing op_cast ) { return using_to_string(op_cast); } +forceinline void to_string (CodeUsing op_cast, String& result ) { return using_to_string_ref(op_cast, & result); } +forceinline void to_string_ns(CodeUsing op_cast, String& result ) { return using_to_string_ns(op_cast, & result); } + +forceinline String to_string(CodeVar self) { return var_to_string(self); } +forceinline void to_string(CodeVar self, String& result) { return var_to_string_ref(self, & result); } +GEN_OPITMIZE_MAPPINGS_END +#endif + +#endif //if GEN_COMPILER_CPP && GEN_SUPPORT_CPP_MEMBER_FEATURES + +#pragma endregion Code Types C++ diff --git a/project/components/gen/ast_inlines.hpp b/project/components/gen/ast_inlines.hpp index 09abbbf..439b8d9 100644 --- a/project/components/gen/ast_inlines.hpp +++ b/project/components/gen/ast_inlines.hpp @@ -1,961 +1,599 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES -#pragma once #include "components/types.hpp" +#pragma once +#include "components/types.hpp" #endif // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) #pragma region generated code inline implementation -inline Code& Code::operator=( Code other ) + inline +Code & Code::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline Code::operator bool() + inline Code:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeBody& CodeBody::operator=( Code other ) + inline +CodeBody & CodeBody::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeBody::operator bool() + inline CodeBody:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeAttributes& CodeAttributes::operator=( Code other ) + inline +CodeAttributes & CodeAttributes::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeAttributes::operator bool() + inline CodeAttributes:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeAttributes::operator Code() + inline CodeAttributes:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Attributes* CodeAttributes::operator->() + inline +AST_Attributes * CodeAttributes::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeComment& CodeComment::operator=( Code other ) + inline +CodeComment & CodeComment::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeComment::operator bool() + inline CodeComment:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeComment::operator Code() + inline CodeComment:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Comment* CodeComment::operator->() + inline +AST_Comment * CodeComment::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeConstructor& CodeConstructor::operator=( Code other ) + inline +CodeConstructor & CodeConstructor::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeConstructor::operator bool() + inline CodeConstructor:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeConstructor::operator Code() + inline CodeConstructor:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Constructor* CodeConstructor::operator->() + inline +AST_Constructor * CodeConstructor::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeClass& CodeClass::operator=( Code other ) + inline +CodeClass & CodeClass::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeClass::operator bool() + inline CodeClass:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeDefine& CodeDefine::operator=( Code other ) + inline +CodeDefine & CodeDefine::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeDefine::operator bool() + inline CodeDefine:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeDefine::operator Code() + inline CodeDefine:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Define* CodeDefine::operator->() + inline +AST_Define * CodeDefine::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeDestructor& CodeDestructor::operator=( Code other ) + inline +CodeDestructor & CodeDestructor::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeDestructor::operator bool() + inline CodeDestructor:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeDestructor::operator Code() + inline CodeDestructor:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Destructor* CodeDestructor::operator->() + inline +AST_Destructor * CodeDestructor::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeEnum& CodeEnum::operator=( Code other ) + inline +CodeEnum & CodeEnum::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeEnum::operator bool() + inline CodeEnum:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeEnum::operator Code() + inline CodeEnum:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Enum* CodeEnum::operator->() + inline +AST_Enum * CodeEnum::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeExec& CodeExec::operator=( Code other ) + inline +CodeExec & CodeExec::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeExec::operator bool() + inline CodeExec:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeExec::operator Code() + inline CodeExec:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Exec* CodeExec::operator->() + inline +AST_Exec * CodeExec::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeExtern& CodeExtern::operator=( Code other ) + inline +CodeExtern & CodeExtern::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeExtern::operator bool() + inline CodeExtern:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeExtern::operator Code() + inline CodeExtern:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Extern* CodeExtern::operator->() + inline +AST_Extern * CodeExtern::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeFriend& CodeFriend::operator=( Code other ) + inline +CodeFriend & CodeFriend::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeFriend::operator bool() + inline CodeFriend:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeFriend::operator Code() + inline CodeFriend:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Friend* CodeFriend::operator->() + inline +AST_Friend * CodeFriend::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeFn& CodeFn::operator=( Code other ) + inline +CodeFn & CodeFn::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeFn::operator bool() + inline CodeFn:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeFn::operator Code() + inline CodeFn:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Fn* CodeFn::operator->() + inline +AST_Fn * CodeFn::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeInclude& CodeInclude::operator=( Code other ) + inline +CodeInclude & CodeInclude::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeInclude::operator bool() + inline CodeInclude:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeInclude::operator Code() + inline CodeInclude:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Include* CodeInclude::operator->() + inline +AST_Include * CodeInclude::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeModule& CodeModule::operator=( Code other ) + inline +CodeModule & CodeModule::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeModule::operator bool() + inline CodeModule:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeModule::operator Code() + inline CodeModule:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Module* CodeModule::operator->() + inline +AST_Module * CodeModule::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeNS& CodeNS::operator=( Code other ) + inline +CodeNS & CodeNS::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeNS::operator bool() + inline CodeNS:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeNS::operator Code() + inline CodeNS:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_NS* CodeNS::operator->() + inline +AST_NS * CodeNS::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeOperator& CodeOperator::operator=( Code other ) + inline +CodeOperator & CodeOperator::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeOperator::operator bool() + inline CodeOperator:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeOperator::operator Code() + inline CodeOperator:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Operator* CodeOperator::operator->() + inline +AST_Operator * CodeOperator::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeOpCast& CodeOpCast::operator=( Code other ) + inline +CodeOpCast & CodeOpCast::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeOpCast::operator bool() + inline CodeOpCast:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeOpCast::operator Code() + inline CodeOpCast:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_OpCast* CodeOpCast::operator->() + inline +AST_OpCast * CodeOpCast::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeParam& CodeParam::operator=( Code other ) + inline +CodeParam & CodeParam::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeParam::operator bool() + inline CodeParam:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodePragma& CodePragma::operator=( Code other ) + inline +CodePragma & CodePragma::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodePragma::operator bool() + inline CodePragma:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodePragma::operator Code() + inline CodePragma:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Pragma* CodePragma::operator->() + inline +AST_Pragma * CodePragma::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodePreprocessCond& CodePreprocessCond::operator=( Code other ) + inline +CodePreprocessCond & CodePreprocessCond::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodePreprocessCond::operator bool() + inline CodePreprocessCond:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodePreprocessCond::operator Code() + inline CodePreprocessCond:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_PreprocessCond* CodePreprocessCond::operator->() + inline +AST_PreprocessCond * CodePreprocessCond::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeSpecifiers& CodeSpecifiers::operator=( Code other ) + inline +CodeSpecifiers & CodeSpecifiers::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeSpecifiers::operator bool() + inline CodeSpecifiers:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeStruct& CodeStruct::operator=( Code other ) + inline +CodeStruct & CodeStruct::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeStruct::operator bool() + inline CodeStruct:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeTemplate& CodeTemplate::operator=( Code other ) + inline +CodeTemplate & CodeTemplate::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeTemplate::operator bool() + inline CodeTemplate:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeTemplate::operator Code() + inline CodeTemplate:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Template* CodeTemplate::operator->() + inline +AST_Template * CodeTemplate::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeTypename& CodeTypename::operator=( Code other ) + inline +CodeTypename & CodeTypename::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeTypename::operator bool() + inline CodeTypename:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeTypename::operator Code() + inline CodeTypename:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Typename* CodeTypename::operator->() + inline +AST_Typename * CodeTypename::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeTypedef& CodeTypedef::operator=( Code other ) + inline +CodeTypedef & CodeTypedef::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeTypedef::operator bool() + inline CodeTypedef:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeTypedef::operator Code() + inline CodeTypedef:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Typedef* CodeTypedef::operator->() + inline +AST_Typedef * CodeTypedef::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeUnion& CodeUnion::operator=( Code other ) + inline +CodeUnion & CodeUnion::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeUnion::operator bool() + inline CodeUnion:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeUnion::operator Code() + inline CodeUnion:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Union* CodeUnion::operator->() + inline +AST_Union * CodeUnion::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeUsing& CodeUsing::operator=( Code other ) + inline +CodeUsing & CodeUsing::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeUsing::operator bool() + inline CodeUsing:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeUsing::operator Code() + inline CodeUsing:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Using* CodeUsing::operator->() + inline +AST_Using * CodeUsing::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } - -inline CodeVar& CodeVar::operator=( Code other ) + inline +CodeVar & CodeVar::operator = ( Code other) { - if ( other.ast && other->Parent ) - { - ast = rcast( decltype( ast ), code_duplicate( other ).ast ); - ast->Parent = { nullptr }; - } - ast = rcast( decltype( ast ), other.ast ); - return *this; +if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; } ast = rcast( decltype( ast ), other.ast ); return * this; } - -inline CodeVar::operator bool() + inline CodeVar:: operator bool() { - return ast != nullptr; +return ast != nullptr; } - -inline CodeVar::operator Code() + inline CodeVar:: operator Code() { - return *rcast( Code*, this ); +return *rcast( Code*, this ); } - -inline AST_Var* CodeVar::operator->() + inline +AST_Var * CodeVar::operator -> () { - if ( ast == nullptr ) - { - log_failure( "Attempt to dereference a nullptr!" ); - return nullptr; - } - return ast; +if ( ast == nullptr ) { log_failure( "Attempt to dereference a nullptr!" ); return nullptr; } return ast; } #pragma endregion generated code inline implementation + #pragma region generated AST/Code cast implementation +GEN_OPTIMIZE_MAPPINGS_BEGIN -inline Code::operator CodeBody() const + forceinline Code:: operator CodeBody() const { - return { (AST_Body*)ast }; +return { (AST_Body*) ast }; +} + forceinline Code:: operator CodeAttributes() const +{ +return { (AST_Attributes*) ast }; +} + forceinline Code:: operator CodeComment() const +{ +return { (AST_Comment*) ast }; +} + forceinline Code:: operator CodeConstructor() const +{ +return { (AST_Constructor*) ast }; +} + forceinline Code:: operator CodeClass() const +{ +return { (AST_Class*) ast }; +} + forceinline Code:: operator CodeDefine() const +{ +return { (AST_Define*) ast }; +} + forceinline Code:: operator CodeDestructor() const +{ +return { (AST_Destructor*) ast }; +} + forceinline Code:: operator CodeEnum() const +{ +return { (AST_Enum*) ast }; +} + forceinline Code:: operator CodeExec() const +{ +return { (AST_Exec*) ast }; +} + forceinline Code:: operator CodeExtern() const +{ +return { (AST_Extern*) ast }; +} + forceinline Code:: operator CodeFriend() const +{ +return { (AST_Friend*) ast }; +} + forceinline Code:: operator CodeFn() const +{ +return { (AST_Fn*) ast }; +} + forceinline Code:: operator CodeInclude() const +{ +return { (AST_Include*) ast }; +} + forceinline Code:: operator CodeModule() const +{ +return { (AST_Module*) ast }; +} + forceinline Code:: operator CodeNS() const +{ +return { (AST_NS*) ast }; +} + forceinline Code:: operator CodeOperator() const +{ +return { (AST_Operator*) ast }; +} + forceinline Code:: operator CodeOpCast() const +{ +return { (AST_OpCast*) ast }; +} + forceinline Code:: operator CodeParam() const +{ +return { (AST_Param*) ast }; +} + forceinline Code:: operator CodePragma() const +{ +return { (AST_Pragma*) ast }; +} + forceinline Code:: operator CodePreprocessCond() const +{ +return { (AST_PreprocessCond*) ast }; +} + forceinline Code:: operator CodeSpecifiers() const +{ +return { (AST_Specifiers*) ast }; +} + forceinline Code:: operator CodeStruct() const +{ +return { (AST_Struct*) ast }; +} + forceinline Code:: operator CodeTemplate() const +{ +return { (AST_Template*) ast }; +} + forceinline Code:: operator CodeTypename() const +{ +return { (AST_Typename*) ast }; +} + forceinline Code:: operator CodeTypedef() const +{ +return { (AST_Typedef*) ast }; +} + forceinline Code:: operator CodeUnion() const +{ +return { (AST_Union*) ast }; +} + forceinline Code:: operator CodeUsing() const +{ +return { (AST_Using*) ast }; +} + forceinline Code:: operator CodeVar() const +{ +return { (AST_Var*) ast }; } -inline Code::operator CodeAttributes() const -{ - return { (AST_Attributes*)ast }; -} +GEN_OPITMIZE_MAPPINGS_END +#pragma endregion generated AST/Code cast implementation -inline Code::operator CodeComment() const -{ - return { (AST_Comment*)ast }; -} - -inline Code::operator CodeConstructor() const -{ - return { (AST_Constructor*)ast }; -} - -inline Code::operator CodeClass() const -{ - return { (AST_Class*)ast }; -} - -inline Code::operator CodeDefine() const -{ - return { (AST_Define*)ast }; -} - -inline Code::operator CodeDestructor() const -{ - return { (AST_Destructor*)ast }; -} - -inline Code::operator CodeEnum() const -{ - return { (AST_Enum*)ast }; -} - -inline Code::operator CodeExec() const -{ - return { (AST_Exec*)ast }; -} - -inline Code::operator CodeExtern() const -{ - return { (AST_Extern*)ast }; -} - -inline Code::operator CodeFriend() const -{ - return { (AST_Friend*)ast }; -} - -inline Code::operator CodeFn() const -{ - return { (AST_Fn*)ast }; -} - -inline Code::operator CodeInclude() const -{ - return { (AST_Include*)ast }; -} - -inline Code::operator CodeModule() const -{ - return { (AST_Module*)ast }; -} - -inline Code::operator CodeNS() const -{ - return { (AST_NS*)ast }; -} - -inline Code::operator CodeOperator() const -{ - return { (AST_Operator*)ast }; -} - -inline Code::operator CodeOpCast() const -{ - return { (AST_OpCast*)ast }; -} - -inline Code::operator CodeParam() const -{ - return { (AST_Param*)ast }; -} - -inline Code::operator CodePragma() const -{ - return { (AST_Pragma*)ast }; -} - -inline Code::operator CodePreprocessCond() const -{ - return { (AST_PreprocessCond*)ast }; -} - -inline Code::operator CodeSpecifiers() const -{ - return { (AST_Specifiers*)ast }; -} - -inline Code::operator CodeStruct() const -{ - return { (AST_Struct*)ast }; -} - -inline Code::operator CodeTemplate() const -{ - return { (AST_Template*)ast }; -} - -inline Code::operator CodeTypename() const -{ - return { (AST_Typename*)ast }; -} - -inline Code::operator CodeTypedef() const -{ - return { (AST_Typedef*)ast }; -} - -inline Code::operator CodeUnion() const -{ - return { (AST_Union*)ast }; -} - -inline Code::operator CodeUsing() const -{ - return { (AST_Using*)ast }; -} - -inline Code::operator CodeVar() const -{ - return { (AST_Var*)ast }; -} - -#pragma endregion generated AST / Code cast implementation diff --git a/project/components/gen/ecode.hpp b/project/components/gen/ecode.hpp index 7245121..2a374e0 100644 --- a/project/components/gen/ecode.hpp +++ b/project/components/gen/ecode.hpp @@ -1,139 +1,79 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES -#pragma once #include "components/types.hpp" +#pragma once +#include "components/types.hpp" #endif // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) -enum CodeType_Def enum_underlying( u32 ) - - { CT_Invalid, - CT_Untyped, - CT_NewLine, - CT_Comment, - CT_Access_Private, - CT_Access_Protected, - CT_Access_Public, - CT_PlatformAttributes, - CT_Class, - CT_Class_Fwd, - CT_Class_Body, - CT_Constructor, - CT_Constructor_Fwd, - CT_Destructor, - CT_Destructor_Fwd, - CT_Enum, - CT_Enum_Fwd, - CT_Enum_Body, - CT_Enum_Class, - CT_Enum_Class_Fwd, - CT_Execution, - CT_Export_Body, - CT_Extern_Linkage, - CT_Extern_Linkage_Body, - CT_Friend, - CT_Function, - CT_Function_Fwd, - CT_Function_Body, - CT_Global_Body, - CT_Module, - CT_Namespace, - CT_Namespace_Body, - CT_Operator, - CT_Operator_Fwd, - CT_Operator_Member, - CT_Operator_Member_Fwd, - CT_Operator_Cast, - CT_Operator_Cast_Fwd, - CT_Parameters, - CT_Preprocess_Define, - CT_Preprocess_Include, - CT_Preprocess_If, - CT_Preprocess_IfDef, - CT_Preprocess_IfNotDef, - CT_Preprocess_ElIf, - CT_Preprocess_Else, - CT_Preprocess_EndIf, - CT_Preprocess_Pragma, - CT_Specifiers, - CT_Struct, - CT_Struct_Fwd, - CT_Struct_Body, - CT_Template, - CT_Typedef, - CT_Typename, - CT_Union, - CT_Union_Fwd, - CT_Union_Body, - CT_Using, - CT_Using_Namespace, - CT_Variable, - CT_NumTypes }; -typedef enum CodeType_Def CodeType; - -inline StrC codetype_to_str( CodeType type ) +enum CodeType : u32 { - local_persist StrC lookup[61] = { - { sizeof( "Invalid" ), "Invalid" }, - { sizeof( "Untyped" ), "Untyped" }, - { sizeof( "NewLine" ), "NewLine" }, - { sizeof( "Comment" ), "Comment" }, - { sizeof( "Access_Private" ), "Access_Private" }, - { sizeof( "Access_Protected" ), "Access_Protected" }, - { sizeof( "Access_Public" ), "Access_Public" }, - { sizeof( "PlatformAttributes" ), "PlatformAttributes" }, - { sizeof( "Class" ), "Class" }, - { sizeof( "Class_Fwd" ), "Class_Fwd" }, - { sizeof( "Class_Body" ), "Class_Body" }, - { sizeof( "Constructor" ), "Constructor" }, - { sizeof( "Constructor_Fwd" ), "Constructor_Fwd" }, - { sizeof( "Destructor" ), "Destructor" }, - { sizeof( "Destructor_Fwd" ), "Destructor_Fwd" }, - { sizeof( "Enum" ), "Enum" }, - { sizeof( "Enum_Fwd" ), "Enum_Fwd" }, - { sizeof( "Enum_Body" ), "Enum_Body" }, - { sizeof( "Enum_Class" ), "Enum_Class" }, - { sizeof( "Enum_Class_Fwd" ), "Enum_Class_Fwd" }, - { sizeof( "Execution" ), "Execution" }, - { sizeof( "Export_Body" ), "Export_Body" }, - { sizeof( "Extern_Linkage" ), "Extern_Linkage" }, - { sizeof( "Extern_Linkage_Body" ), "Extern_Linkage_Body" }, - { sizeof( "Friend" ), "Friend" }, - { sizeof( "Function" ), "Function" }, - { sizeof( "Function_Fwd" ), "Function_Fwd" }, - { sizeof( "Function_Body" ), "Function_Body" }, - { sizeof( "Global_Body" ), "Global_Body" }, - { sizeof( "Module" ), "Module" }, - { sizeof( "Namespace" ), "Namespace" }, - { sizeof( "Namespace_Body" ), "Namespace_Body" }, - { sizeof( "Operator" ), "Operator" }, - { sizeof( "Operator_Fwd" ), "Operator_Fwd" }, - { sizeof( "Operator_Member" ), "Operator_Member" }, - { sizeof( "Operator_Member_Fwd" ), "Operator_Member_Fwd" }, - { sizeof( "Operator_Cast" ), "Operator_Cast" }, - { sizeof( "Operator_Cast_Fwd" ), "Operator_Cast_Fwd" }, - { sizeof( "Parameters" ), "Parameters" }, - { sizeof( "Preprocess_Define" ), "Preprocess_Define" }, - { sizeof( "Preprocess_Include" ), "Preprocess_Include" }, - { sizeof( "Preprocess_If" ), "Preprocess_If" }, - { sizeof( "Preprocess_IfDef" ), "Preprocess_IfDef" }, - { sizeof( "Preprocess_IfNotDef" ), "Preprocess_IfNotDef" }, - { sizeof( "Preprocess_ElIf" ), "Preprocess_ElIf" }, - { sizeof( "Preprocess_Else" ), "Preprocess_Else" }, - { sizeof( "Preprocess_EndIf" ), "Preprocess_EndIf" }, - { sizeof( "Preprocess_Pragma" ), "Preprocess_Pragma" }, - { sizeof( "Specifiers" ), "Specifiers" }, - { sizeof( "Struct" ), "Struct" }, - { sizeof( "Struct_Fwd" ), "Struct_Fwd" }, - { sizeof( "Struct_Body" ), "Struct_Body" }, - { sizeof( "Template" ), "Template" }, - { sizeof( "Typedef" ), "Typedef" }, - { sizeof( "Typename" ), "Typename" }, - { sizeof( "Union" ), "Union" }, - { sizeof( "Union_Fwd" ), "Union_Fwd" }, - { sizeof( "Union_Body" ), "Union_Body" }, - { sizeof( "Using" ), "Using" }, - { sizeof( "Using_Namespace" ), "Using_Namespace" }, - { sizeof( "Variable" ), "Variable" }, - }; - return lookup[type]; +CT_Invalid,CT_Untyped,CT_NewLine,CT_Comment,CT_Access_Private,CT_Access_Protected,CT_Access_Public,CT_PlatformAttributes,CT_Class,CT_Class_Fwd,CT_Class_Body,CT_Constructor,CT_Constructor_Fwd,CT_Destructor,CT_Destructor_Fwd,CT_Enum,CT_Enum_Fwd,CT_Enum_Body,CT_Enum_Class,CT_Enum_Class_Fwd,CT_Execution,CT_Export_Body,CT_Extern_Linkage,CT_Extern_Linkage_Body,CT_Friend,CT_Function,CT_Function_Fwd,CT_Function_Body,CT_Global_Body,CT_Module,CT_Namespace,CT_Namespace_Body,CT_Operator,CT_Operator_Fwd,CT_Operator_Member,CT_Operator_Member_Fwd,CT_Operator_Cast,CT_Operator_Cast_Fwd,CT_Parameters,CT_Preprocess_Define,CT_Preprocess_Include,CT_Preprocess_If,CT_Preprocess_IfDef,CT_Preprocess_IfNotDef,CT_Preprocess_ElIf,CT_Preprocess_Else,CT_Preprocess_EndIf,CT_Preprocess_Pragma,CT_Specifiers,CT_Struct,CT_Struct_Fwd,CT_Struct_Body,CT_Template,CT_Typedef,CT_Typename,CT_Union,CT_Union_Fwd,CT_Union_Body,CT_Using,CT_Using_Namespace,CT_Variable,CT_NumTypes +}; +typedef enum CodeType CodeType; + inline +StrC codetype_to_str( CodeType type) +{ +local_persist StrC lookup[61] = { { sizeof("Invalid"), "Invalid" }, +{ sizeof("Untyped"), "Untyped" }, +{ sizeof("NewLine"), "NewLine" }, +{ sizeof("Comment"), "Comment" }, +{ sizeof("Access_Private"), "Access_Private" }, +{ sizeof("Access_Protected"), "Access_Protected" }, +{ sizeof("Access_Public"), "Access_Public" }, +{ sizeof("PlatformAttributes"), "PlatformAttributes" }, +{ sizeof("Class"), "Class" }, +{ sizeof("Class_Fwd"), "Class_Fwd" }, +{ sizeof("Class_Body"), "Class_Body" }, +{ sizeof("Constructor"), "Constructor" }, +{ sizeof("Constructor_Fwd"), "Constructor_Fwd" }, +{ sizeof("Destructor"), "Destructor" }, +{ sizeof("Destructor_Fwd"), "Destructor_Fwd" }, +{ sizeof("Enum"), "Enum" }, +{ sizeof("Enum_Fwd"), "Enum_Fwd" }, +{ sizeof("Enum_Body"), "Enum_Body" }, +{ sizeof("Enum_Class"), "Enum_Class" }, +{ sizeof("Enum_Class_Fwd"), "Enum_Class_Fwd" }, +{ sizeof("Execution"), "Execution" }, +{ sizeof("Export_Body"), "Export_Body" }, +{ sizeof("Extern_Linkage"), "Extern_Linkage" }, +{ sizeof("Extern_Linkage_Body"), "Extern_Linkage_Body" }, +{ sizeof("Friend"), "Friend" }, +{ sizeof("Function"), "Function" }, +{ sizeof("Function_Fwd"), "Function_Fwd" }, +{ sizeof("Function_Body"), "Function_Body" }, +{ sizeof("Global_Body"), "Global_Body" }, +{ sizeof("Module"), "Module" }, +{ sizeof("Namespace"), "Namespace" }, +{ sizeof("Namespace_Body"), "Namespace_Body" }, +{ sizeof("Operator"), "Operator" }, +{ sizeof("Operator_Fwd"), "Operator_Fwd" }, +{ sizeof("Operator_Member"), "Operator_Member" }, +{ sizeof("Operator_Member_Fwd"), "Operator_Member_Fwd" }, +{ sizeof("Operator_Cast"), "Operator_Cast" }, +{ sizeof("Operator_Cast_Fwd"), "Operator_Cast_Fwd" }, +{ sizeof("Parameters"), "Parameters" }, +{ sizeof("Preprocess_Define"), "Preprocess_Define" }, +{ sizeof("Preprocess_Include"), "Preprocess_Include" }, +{ sizeof("Preprocess_If"), "Preprocess_If" }, +{ sizeof("Preprocess_IfDef"), "Preprocess_IfDef" }, +{ sizeof("Preprocess_IfNotDef"), "Preprocess_IfNotDef" }, +{ sizeof("Preprocess_ElIf"), "Preprocess_ElIf" }, +{ sizeof("Preprocess_Else"), "Preprocess_Else" }, +{ sizeof("Preprocess_EndIf"), "Preprocess_EndIf" }, +{ sizeof("Preprocess_Pragma"), "Preprocess_Pragma" }, +{ sizeof("Specifiers"), "Specifiers" }, +{ sizeof("Struct"), "Struct" }, +{ sizeof("Struct_Fwd"), "Struct_Fwd" }, +{ sizeof("Struct_Body"), "Struct_Body" }, +{ sizeof("Template"), "Template" }, +{ sizeof("Typedef"), "Typedef" }, +{ sizeof("Typename"), "Typename" }, +{ sizeof("Union"), "Union" }, +{ sizeof("Union_Fwd"), "Union_Fwd" }, +{ sizeof("Union_Body"), "Union_Body" }, +{ sizeof("Using"), "Using" }, +{ sizeof("Using_Namespace"), "Using_Namespace" }, +{ sizeof("Variable"), "Variable" }, + }; return lookup[ type ]; } + diff --git a/project/components/gen/eoperator.hpp b/project/components/gen/eoperator.hpp index 5d446d5..34493e5 100644 --- a/project/components/gen/eoperator.hpp +++ b/project/components/gen/eoperator.hpp @@ -1,111 +1,65 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES -#pragma once #include "components/types.hpp" +#pragma once +#include "components/types.hpp" #endif // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) -enum Operator_Def enum_underlying( u32 ) - - { Op_Invalid, - Op_Assign, - Op_Assign_Add, - Op_Assign_Subtract, - Op_Assign_Multiply, - Op_Assign_Divide, - Op_Assign_Modulo, - Op_Assign_BAnd, - Op_Assign_BOr, - Op_Assign_BXOr, - Op_Assign_LShift, - Op_Assign_RShift, - Op_Increment, - Op_Decrement, - Op_Unary_Plus, - Op_Unary_Minus, - Op_UnaryNot, - Op_Add, - Op_Subtract, - Op_Multiply, - Op_Divide, - Op_Modulo, - Op_BNot, - Op_BAnd, - Op_BOr, - Op_BXOr, - Op_LShift, - Op_RShift, - Op_LAnd, - Op_LOr, - Op_LEqual, - Op_LNot, - Op_Lesser, - Op_Greater, - Op_LesserEqual, - Op_GreaterEqual, - Op_Subscript, - Op_Indirection, - Op_AddressOf, - Op_MemberOfPointer, - Op_PtrToMemOfPtr, - Op_FunctionCall, - Op_Comma, - Op_New, - Op_NewArray, - Op_Delete, - Op_DeleteArray, - NumOps }; -typedef enum Operator_Def Operator; - -inline StrC operator_to_str( Operator op ) +enum Operator : u32 { - local_persist StrC lookup[47] = { - { sizeof( "INVALID" ), "INVALID" }, - { sizeof( "=" ), "=" }, - { sizeof( "+=" ), "+=" }, - { sizeof( "-=" ), "-=" }, - { sizeof( "*=" ), "*=" }, - { sizeof( "/=" ), "/=" }, - { sizeof( "%=" ), "%=" }, - { sizeof( "&=" ), "&=" }, - { sizeof( "|=" ), "|=" }, - { sizeof( "^=" ), "^=" }, - { sizeof( "<<=" ), "<<=" }, - { sizeof( ">>=" ), ">>=" }, - { sizeof( "++" ), "++" }, - { sizeof( "--" ), "--" }, - { sizeof( "+" ), "+" }, - { sizeof( "-" ), "-" }, - { sizeof( "!" ), "!" }, - { sizeof( "+" ), "+" }, - { sizeof( "-" ), "-" }, - { sizeof( "*" ), "*" }, - { sizeof( "/" ), "/" }, - { sizeof( "%" ), "%" }, - { sizeof( "~" ), "~" }, - { sizeof( "&" ), "&" }, - { sizeof( "|" ), "|" }, - { sizeof( "^" ), "^" }, - { sizeof( "<<" ), "<<" }, - { sizeof( ">>" ), ">>" }, - { sizeof( "&&" ), "&&" }, - { sizeof( "||" ), "||" }, - { sizeof( "==" ), "==" }, - { sizeof( "!=" ), "!=" }, - { sizeof( "<" ), "<" }, - { sizeof( ">" ), ">" }, - { sizeof( "<=" ), "<=" }, - { sizeof( ">=" ), ">=" }, - { sizeof( "[]" ), "[]" }, - { sizeof( "*" ), "*" }, - { sizeof( "&" ), "&" }, - { sizeof( "->" ), "->" }, - { sizeof( "->*" ), "->*" }, - { sizeof( "()" ), "()" }, - { sizeof( "," ), "," }, - { sizeof( "new" ), "new" }, - { sizeof( "new[]" ), "new[]" }, - { sizeof( "delete" ), "delete" }, - { sizeof( "delete[]" ), "delete[]" }, - }; - return lookup[op]; +Op_Invalid,Op_Assign,Op_Assign_Add,Op_Assign_Subtract,Op_Assign_Multiply,Op_Assign_Divide,Op_Assign_Modulo,Op_Assign_BAnd,Op_Assign_BOr,Op_Assign_BXOr,Op_Assign_LShift,Op_Assign_RShift,Op_Increment,Op_Decrement,Op_Unary_Plus,Op_Unary_Minus,Op_UnaryNot,Op_Add,Op_Subtract,Op_Multiply,Op_Divide,Op_Modulo,Op_BNot,Op_BAnd,Op_BOr,Op_BXOr,Op_LShift,Op_RShift,Op_LAnd,Op_LOr,Op_LEqual,Op_LNot,Op_Lesser,Op_Greater,Op_LesserEqual,Op_GreaterEqual,Op_Subscript,Op_Indirection,Op_AddressOf,Op_MemberOfPointer,Op_PtrToMemOfPtr,Op_FunctionCall,Op_Comma,Op_New,Op_NewArray,Op_Delete,Op_DeleteArray,NumOps +}; +typedef enum Operator Operator; + inline +StrC operator_to_str( Operator op) +{ +local_persist StrC lookup[47] = { { sizeof("INVALID"), "INVALID" }, +{ sizeof("="), "=" }, +{ sizeof("+="), "+=" }, +{ sizeof("-="), "-=" }, +{ sizeof("*="), "*=" }, +{ sizeof("/="), "/=" }, +{ sizeof("%="), "%=" }, +{ sizeof("&="), "&=" }, +{ sizeof("|="), "|=" }, +{ sizeof("^="), "^=" }, +{ sizeof("<<="), "<<=" }, +{ sizeof(">>="), ">>=" }, +{ sizeof("++"), "++" }, +{ sizeof("--"), "--" }, +{ sizeof("+"), "+" }, +{ sizeof("-"), "-" }, +{ sizeof("!"), "!" }, +{ sizeof("+"), "+" }, +{ sizeof("-"), "-" }, +{ sizeof("*"), "*" }, +{ sizeof("/"), "/" }, +{ sizeof("%"), "%" }, +{ sizeof("~"), "~" }, +{ sizeof("&"), "&" }, +{ sizeof("|"), "|" }, +{ sizeof("^"), "^" }, +{ sizeof("<<"), "<<" }, +{ sizeof(">>"), ">>" }, +{ sizeof("&&"), "&&" }, +{ sizeof("||"), "||" }, +{ sizeof("=="), "==" }, +{ sizeof("!="), "!=" }, +{ sizeof("<"), "<" }, +{ sizeof(">"), ">" }, +{ sizeof("<="), "<=" }, +{ sizeof(">="), ">=" }, +{ sizeof("[]"), "[]" }, +{ sizeof("*"), "*" }, +{ sizeof("&"), "&" }, +{ sizeof("->"), "->" }, +{ sizeof("->*"), "->*" }, +{ sizeof("()"), "()" }, +{ sizeof(","), "," }, +{ sizeof("new"), "new" }, +{ sizeof("new[]"), "new[]" }, +{ sizeof("delete"), "delete" }, +{ sizeof("delete[]"), "delete[]" }, + }; return lookup[ op ]; } + diff --git a/project/components/gen/especifier.hpp b/project/components/gen/especifier.hpp index 1b2f8a2..8e56395 100644 --- a/project/components/gen/especifier.hpp +++ b/project/components/gen/especifier.hpp @@ -1,68 +1,54 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES -#pragma once #include "components/types.hpp" +#pragma once +#include "components/types.hpp" #endif // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) -enum Specifier_Def enum_underlying( u32 ) - - { Spec_Invalid, Spec_Consteval, Spec_Constexpr, Spec_Constinit, Spec_Explicit, Spec_External_Linkage, Spec_ForceInline, - Spec_Global, Spec_Inline, Spec_Internal_Linkage, Spec_Local_Persist, Spec_Mutable, Spec_NeverInline, Spec_Ptr, - Spec_Ref, Spec_Register, Spec_RValue, Spec_Static, Spec_Thread_Local, Spec_Virtual, Spec_Const, - Spec_Final, Spec_NoExceptions, Spec_Override, Spec_Pure, Spec_Volatile, Spec_NumSpecifiers }; -typedef enum Specifier_Def Specifier; - -inline bool spec_is_trailing( Specifier specifier ) +enum Specifier : u32 { - return specifier > Spec_Virtual; +Spec_Invalid,Spec_Consteval,Spec_Constexpr,Spec_Constinit,Spec_Explicit,Spec_External_Linkage,Spec_ForceInline,Spec_Global,Spec_Inline,Spec_Internal_Linkage,Spec_Local_Persist,Spec_Mutable,Spec_NeverInline,Spec_Ptr,Spec_Ref,Spec_Register,Spec_RValue,Spec_Static,Spec_Thread_Local,Spec_Virtual,Spec_Const,Spec_Final,Spec_NoExceptions,Spec_Override,Spec_Pure,Spec_Volatile,Spec_NumSpecifiers +}; +typedef enum Specifier Specifier; + inline +bool spec_is_trailing( Specifier specifier) +{ +return specifier > Spec_Virtual; +} + inline +StrC spec_to_str( Specifier type) +{ +local_persist StrC lookup[26] = { { sizeof("INVALID"), "INVALID" }, +{ sizeof("consteval"), "consteval" }, +{ sizeof("constexpr"), "constexpr" }, +{ sizeof("constinit"), "constinit" }, +{ sizeof("explicit"), "explicit" }, +{ sizeof("extern"), "extern" }, +{ sizeof("forceinline"), "forceinline" }, +{ sizeof("global"), "global" }, +{ sizeof("inline"), "inline" }, +{ sizeof("internal"), "internal" }, +{ sizeof("local_persist"), "local_persist" }, +{ sizeof("mutable"), "mutable" }, +{ sizeof("neverinline"), "neverinline" }, +{ sizeof("*"), "*" }, +{ sizeof("&"), "&" }, +{ sizeof("register"), "register" }, +{ sizeof("&&"), "&&" }, +{ sizeof("static"), "static" }, +{ sizeof("thread_local"), "thread_local" }, +{ sizeof("virtual"), "virtual" }, +{ sizeof("const"), "const" }, +{ sizeof("final"), "final" }, +{ sizeof("noexcept"), "noexcept" }, +{ sizeof("override"), "override" }, +{ sizeof("= 0"), "= 0" }, +{ sizeof("volatile"), "volatile" }, + }; return lookup[ type ]; +} + inline +Specifier strc_to_specifier( StrC str) +{ +local_persist u32 keymap[ Spec_NumSpecifiers ]; do_once_start for ( u32 index = 0; index < Spec_NumSpecifiers; index++ ) { StrC enum_str = spec_to_str( (Specifier)index ); keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1); } do_once_end u32 hash = crc32( str.Ptr, str.Len ); for ( u32 index = 0; index < Spec_NumSpecifiers; index++ ) { if ( keymap[index] == hash ) return (Specifier)index; } return Spec_Invalid; } -inline StrC spec_to_str( Specifier type ) -{ - local_persist StrC lookup[26] = { - { sizeof( "INVALID" ), "INVALID" }, - { sizeof( "consteval" ), "consteval" }, - { sizeof( "constexpr" ), "constexpr" }, - { sizeof( "constinit" ), "constinit" }, - { sizeof( "explicit" ), "explicit" }, - { sizeof( "extern" ), "extern" }, - { sizeof( "forceinline" ), "forceinline" }, - { sizeof( "global" ), "global" }, - { sizeof( "inline" ), "inline" }, - { sizeof( "internal" ), "internal" }, - { sizeof( "local_persist" ), "local_persist" }, - { sizeof( "mutable" ), "mutable" }, - { sizeof( "neverinline" ), "neverinline" }, - { sizeof( "*" ), "*" }, - { sizeof( "&" ), "&" }, - { sizeof( "register" ), "register" }, - { sizeof( "&&" ), "&&" }, - { sizeof( "static" ), "static" }, - { sizeof( "thread_local" ), "thread_local" }, - { sizeof( "virtual" ), "virtual" }, - { sizeof( "const" ), "const" }, - { sizeof( "final" ), "final" }, - { sizeof( "noexcept" ), "noexcept" }, - { sizeof( "override" ), "override" }, - { sizeof( "= 0" ), "= 0" }, - { sizeof( "volatile" ), "volatile" }, - }; - return lookup[type]; -} - -inline Specifier strc_to_specifier( StrC str ) -{ - local_persist u32 keymap[Spec_NumSpecifiers]; - do_once_start for ( u32 index = 0; index < Spec_NumSpecifiers; index++ ) - { - StrC enum_str = spec_to_str( (Specifier)index ); - keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 ); - } - do_once_end u32 hash = crc32( str.Ptr, str.Len ); - for ( u32 index = 0; index < Spec_NumSpecifiers; index++ ) - { - if ( keymap[index] == hash ) - return (Specifier)index; - } - return Spec_Invalid; -} diff --git a/project/components/gen/etoktype.cpp b/project/components/gen/etoktype.cpp index 8ebf00f..83e8b66 100644 --- a/project/components/gen/etoktype.cpp +++ b/project/components/gen/etoktype.cpp @@ -1,234 +1,124 @@ #ifdef GEN_INTELLISENSE_DIRECTIVES -#pragma once #include "components/types.hpp" +#pragma once +#include "components/types.hpp" #endif // This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp) GEN_NS_PARSER_BEGIN -#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" ) +#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) \ +Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" ) enum TokType_Def : u32 { - Tok_Invalid, - Tok_Access_Private, - Tok_Access_Protected, - Tok_Access_Public, - Tok_Access_MemberSymbol, - Tok_Access_StaticSymbol, - Tok_Ampersand, - Tok_Ampersand_DBL, - Tok_Assign_Classifer, - Tok_Attribute_Open, - Tok_Attribute_Close, - Tok_BraceCurly_Open, - Tok_BraceCurly_Close, - Tok_BraceSquare_Open, - Tok_BraceSquare_Close, - Tok_Capture_Start, - Tok_Capture_End, - Tok_Comment, - Tok_Comment_End, - Tok_Comment_Start, - Tok_Char, - Tok_Comma, - Tok_Decl_Class, - Tok_Decl_GNU_Attribute, - Tok_Decl_MSVC_Attribute, - Tok_Decl_Enum, - Tok_Decl_Extern_Linkage, - Tok_Decl_Friend, - Tok_Decl_Module, - Tok_Decl_Namespace, - Tok_Decl_Operator, - Tok_Decl_Struct, - Tok_Decl_Template, - Tok_Decl_Typedef, - Tok_Decl_Using, - Tok_Decl_Union, - Tok_Identifier, - Tok_Module_Import, - Tok_Module_Export, - Tok_NewLine, - Tok_Number, - Tok_Operator, - Tok_Preprocess_Hash, - Tok_Preprocess_Define, - Tok_Preprocess_If, - Tok_Preprocess_IfDef, - Tok_Preprocess_IfNotDef, - Tok_Preprocess_ElIf, - Tok_Preprocess_Else, - Tok_Preprocess_EndIf, - Tok_Preprocess_Include, - Tok_Preprocess_Pragma, - Tok_Preprocess_Content, - Tok_Preprocess_Macro, - Tok_Preprocess_Unsupported, - Tok_Spec_Alignas, - Tok_Spec_Const, - Tok_Spec_Consteval, - Tok_Spec_Constexpr, - Tok_Spec_Constinit, - Tok_Spec_Explicit, - Tok_Spec_Extern, - Tok_Spec_Final, - Tok_Spec_ForceInline, - Tok_Spec_Global, - Tok_Spec_Inline, - Tok_Spec_Internal_Linkage, - Tok_Spec_LocalPersist, - Tok_Spec_Mutable, - Tok_Spec_NeverInline, - Tok_Spec_Override, - Tok_Spec_Static, - Tok_Spec_ThreadLocal, - Tok_Spec_Volatile, - Tok_Spec_Virtual, - Tok_Star, - Tok_Statement_End, - Tok_StaticAssert, - Tok_String, - Tok_Type_Typename, - Tok_Type_Unsigned, - Tok_Type_Signed, - Tok_Type_Short, - Tok_Type_Long, - Tok_Type_bool, - Tok_Type_char, - Tok_Type_int, - Tok_Type_double, - Tok_Type_MS_int8, - Tok_Type_MS_int16, - Tok_Type_MS_int32, - Tok_Type_MS_int64, - Tok_Type_MS_W64, - Tok_Varadic_Argument, - Tok___Attributes_Start, - Tok_Attribute_API_Export, - Tok_Attribute_API_Import, - Tok_NumTokens +Tok_Invalid,Tok_Access_Private,Tok_Access_Protected,Tok_Access_Public,Tok_Access_MemberSymbol,Tok_Access_StaticSymbol,Tok_Ampersand,Tok_Ampersand_DBL,Tok_Assign_Classifer,Tok_Attribute_Open,Tok_Attribute_Close,Tok_BraceCurly_Open,Tok_BraceCurly_Close,Tok_BraceSquare_Open,Tok_BraceSquare_Close,Tok_Capture_Start,Tok_Capture_End,Tok_Comment,Tok_Comment_End,Tok_Comment_Start,Tok_Char,Tok_Comma,Tok_Decl_Class,Tok_Decl_GNU_Attribute,Tok_Decl_MSVC_Attribute,Tok_Decl_Enum,Tok_Decl_Extern_Linkage,Tok_Decl_Friend,Tok_Decl_Module,Tok_Decl_Namespace,Tok_Decl_Operator,Tok_Decl_Struct,Tok_Decl_Template,Tok_Decl_Typedef,Tok_Decl_Using,Tok_Decl_Union,Tok_Identifier,Tok_Module_Import,Tok_Module_Export,Tok_NewLine,Tok_Number,Tok_Operator,Tok_Preprocess_Hash,Tok_Preprocess_Define,Tok_Preprocess_If,Tok_Preprocess_IfDef,Tok_Preprocess_IfNotDef,Tok_Preprocess_ElIf,Tok_Preprocess_Else,Tok_Preprocess_EndIf,Tok_Preprocess_Include,Tok_Preprocess_Pragma,Tok_Preprocess_Content,Tok_Preprocess_Macro,Tok_Preprocess_Unsupported,Tok_Spec_Alignas,Tok_Spec_Const,Tok_Spec_Consteval,Tok_Spec_Constexpr,Tok_Spec_Constinit,Tok_Spec_Explicit,Tok_Spec_Extern,Tok_Spec_Final,Tok_Spec_ForceInline,Tok_Spec_Global,Tok_Spec_Inline,Tok_Spec_Internal_Linkage,Tok_Spec_LocalPersist,Tok_Spec_Mutable,Tok_Spec_NeverInline,Tok_Spec_Override,Tok_Spec_Static,Tok_Spec_ThreadLocal,Tok_Spec_Volatile,Tok_Spec_Virtual,Tok_Star,Tok_Statement_End,Tok_StaticAssert,Tok_String,Tok_Type_Typename,Tok_Type_Unsigned,Tok_Type_Signed,Tok_Type_Short,Tok_Type_Long,Tok_Type_bool,Tok_Type_char,Tok_Type_int,Tok_Type_double,Tok_Type_MS_int8,Tok_Type_MS_int16,Tok_Type_MS_int32,Tok_Type_MS_int64,Tok_Type_MS_W64,Tok_Varadic_Argument,Tok___Attributes_Start,Tok_Attribute_API_Export,Tok_Attribute_API_Import,Tok_NumTokens }; typedef enum TokType_Def TokType; - -inline StrC to_str( TokType type ) + inline +StrC to_str( TokType type) { - local_persist StrC lookup[] { - { sizeof( "__invalid__" ), "__invalid__" }, - { sizeof( "private" ), "private" }, - { sizeof( "protected" ), "protected" }, - { sizeof( "public" ), "public" }, - { sizeof( "." ), "." }, - { sizeof( "::" ), "::" }, - { sizeof( "&" ), "&" }, - { sizeof( "&&" ), "&&" }, - { sizeof( ":" ), ":" }, - { sizeof( "[[" ), "[[" }, - { sizeof( "]]" ), "]]" }, - { sizeof( "{" ), "{" }, - { sizeof( "}" ), "}" }, - { sizeof( "[" ), "[" }, - { sizeof( "]" ), "]" }, - { sizeof( "(" ), "(" }, - { sizeof( ")" ), ")" }, - { sizeof( "__comment__" ), "__comment__" }, - { sizeof( "__comment_end__" ), "__comment_end__" }, - { sizeof( "__comment_start__" ), "__comment_start__" }, - { sizeof( "__character__" ), "__character__" }, - { sizeof( "," ), "," }, - { sizeof( "class" ), "class" }, - { sizeof( "__attribute__" ), "__attribute__" }, - { sizeof( "__declspec" ), "__declspec" }, - { sizeof( "enum" ), "enum" }, - { sizeof( "extern" ), "extern" }, - { sizeof( "friend" ), "friend" }, - { sizeof( "module" ), "module" }, - { sizeof( "namespace" ), "namespace" }, - { sizeof( "operator" ), "operator" }, - { sizeof( "struct" ), "struct" }, - { sizeof( "template" ), "template" }, - { sizeof( "typedef" ), "typedef" }, - { sizeof( "using" ), "using" }, - { sizeof( "union" ), "union" }, - { sizeof( "__identifier__" ), "__identifier__" }, - { sizeof( "import" ), "import" }, - { sizeof( "export" ), "export" }, - { sizeof( "__new_line__" ), "__new_line__" }, - { sizeof( "__number__" ), "__number__" }, - { sizeof( "__operator__" ), "__operator__" }, - { sizeof( "#" ), "#" }, - { sizeof( "define" ), "define" }, - { sizeof( "if" ), "if" }, - { sizeof( "ifdef" ), "ifdef" }, - { sizeof( "ifndef" ), "ifndef" }, - { sizeof( "elif" ), "elif" }, - { sizeof( "else" ), "else" }, - { sizeof( "endif" ), "endif" }, - { sizeof( "include" ), "include" }, - { sizeof( "pragma" ), "pragma" }, - { sizeof( "__macro_content__" ), "__macro_content__" }, - { sizeof( "__macro__" ), "__macro__" }, - { sizeof( "__unsupported__" ), "__unsupported__" }, - { sizeof( "alignas" ), "alignas" }, - { sizeof( "const" ), "const" }, - { sizeof( "consteval" ), "consteval" }, - { sizeof( "constexpr" ), "constexpr" }, - { sizeof( "constinit" ), "constinit" }, - { sizeof( "explicit" ), "explicit" }, - { sizeof( "extern" ), "extern" }, - { sizeof( "final" ), "final" }, - { sizeof( "forceinline" ), "forceinline" }, - { sizeof( "global" ), "global" }, - { sizeof( "inline" ), "inline" }, - { sizeof( "internal" ), "internal" }, - { sizeof( "local_persist" ), "local_persist" }, - { sizeof( "mutable" ), "mutable" }, - { sizeof( "neverinline" ), "neverinline" }, - { sizeof( "override" ), "override" }, - { sizeof( "static" ), "static" }, - { sizeof( "thread_local" ), "thread_local" }, - { sizeof( "volatile" ), "volatile" }, - { sizeof( "virtual" ), "virtual" }, - { sizeof( "*" ), "*" }, - { sizeof( ";" ), ";" }, - { sizeof( "static_assert" ), "static_assert" }, - { sizeof( "__string__" ), "__string__" }, - { sizeof( "typename" ), "typename" }, - { sizeof( "unsigned" ), "unsigned" }, - { sizeof( "signed" ), "signed" }, - { sizeof( "short" ), "short" }, - { sizeof( "long" ), "long" }, - { sizeof( "bool" ), "bool" }, - { sizeof( "char" ), "char" }, - { sizeof( "int" ), "int" }, - { sizeof( "double" ), "double" }, - { sizeof( "__int8" ), "__int8" }, - { sizeof( "__int16" ), "__int16" }, - { sizeof( "__int32" ), "__int32" }, - { sizeof( "__int64" ), "__int64" }, - { sizeof( "_W64" ), "_W64" }, - { sizeof( "..." ), "..." }, - { sizeof( "__attrib_start__" ), "__attrib_start__" }, - { sizeof( "GEN_API_Export_Code" ), "GEN_API_Export_Code" }, - { sizeof( "GEN_API_Import_Code" ), "GEN_API_Import_Code" }, - }; - return lookup[type]; +local_persist StrC lookup[] { { sizeof("__invalid__"), "__invalid__" }, +{ sizeof("private"), "private" }, +{ sizeof("protected"), "protected" }, +{ sizeof("public"), "public" }, +{ sizeof("."), "." }, +{ sizeof("::"), "::" }, +{ sizeof("&"), "&" }, +{ sizeof("&&"), "&&" }, +{ sizeof(":"), ":" }, +{ sizeof("[["), "[[" }, +{ sizeof("]]"), "]]" }, +{ sizeof("{"), "{" }, +{ sizeof("}"), "}" }, +{ sizeof("["), "[" }, +{ sizeof("]"), "]" }, +{ sizeof("("), "(" }, +{ sizeof(")"), ")" }, +{ sizeof("__comment__"), "__comment__" }, +{ sizeof("__comment_end__"), "__comment_end__" }, +{ sizeof("__comment_start__"), "__comment_start__" }, +{ sizeof("__character__"), "__character__" }, +{ sizeof(","), "," }, +{ sizeof("class"), "class" }, +{ sizeof("__attribute__"), "__attribute__" }, +{ sizeof("__declspec"), "__declspec" }, +{ sizeof("enum"), "enum" }, +{ sizeof("extern"), "extern" }, +{ sizeof("friend"), "friend" }, +{ sizeof("module"), "module" }, +{ sizeof("namespace"), "namespace" }, +{ sizeof("operator"), "operator" }, +{ sizeof("struct"), "struct" }, +{ sizeof("template"), "template" }, +{ sizeof("typedef"), "typedef" }, +{ sizeof("using"), "using" }, +{ sizeof("union"), "union" }, +{ sizeof("__identifier__"), "__identifier__" }, +{ sizeof("import"), "import" }, +{ sizeof("export"), "export" }, +{ sizeof("__new_line__"), "__new_line__" }, +{ sizeof("__number__"), "__number__" }, +{ sizeof("__operator__"), "__operator__" }, +{ sizeof("#"), "#" }, +{ sizeof("define"), "define" }, +{ sizeof("if"), "if" }, +{ sizeof("ifdef"), "ifdef" }, +{ sizeof("ifndef"), "ifndef" }, +{ sizeof("elif"), "elif" }, +{ sizeof("else"), "else" }, +{ sizeof("endif"), "endif" }, +{ sizeof("include"), "include" }, +{ sizeof("pragma"), "pragma" }, +{ sizeof("__macro_content__"), "__macro_content__" }, +{ sizeof("__macro__"), "__macro__" }, +{ sizeof("__unsupported__"), "__unsupported__" }, +{ sizeof("alignas"), "alignas" }, +{ sizeof("const"), "const" }, +{ sizeof("consteval"), "consteval" }, +{ sizeof("constexpr"), "constexpr" }, +{ sizeof("constinit"), "constinit" }, +{ sizeof("explicit"), "explicit" }, +{ sizeof("extern"), "extern" }, +{ sizeof("final"), "final" }, +{ sizeof("forceinline"), "forceinline" }, +{ sizeof("global"), "global" }, +{ sizeof("inline"), "inline" }, +{ sizeof("internal"), "internal" }, +{ sizeof("local_persist"), "local_persist" }, +{ sizeof("mutable"), "mutable" }, +{ sizeof("neverinline"), "neverinline" }, +{ sizeof("override"), "override" }, +{ sizeof("static"), "static" }, +{ sizeof("thread_local"), "thread_local" }, +{ sizeof("volatile"), "volatile" }, +{ sizeof("virtual"), "virtual" }, +{ sizeof("*"), "*" }, +{ sizeof(";"), ";" }, +{ sizeof("static_assert"), "static_assert" }, +{ sizeof("__string__"), "__string__" }, +{ sizeof("typename"), "typename" }, +{ sizeof("unsigned"), "unsigned" }, +{ sizeof("signed"), "signed" }, +{ sizeof("short"), "short" }, +{ sizeof("long"), "long" }, +{ sizeof("bool"), "bool" }, +{ sizeof("char"), "char" }, +{ sizeof("int"), "int" }, +{ sizeof("double"), "double" }, +{ sizeof("__int8"), "__int8" }, +{ sizeof("__int16"), "__int16" }, +{ sizeof("__int32"), "__int32" }, +{ sizeof("__int64"), "__int64" }, +{ sizeof("_W64"), "_W64" }, +{ sizeof("..."), "..." }, +{ sizeof("__attrib_start__"), "__attrib_start__" }, + { sizeof("GEN_API_Export_Code"), "GEN_API_Export_Code" }, +{ sizeof("GEN_API_Import_Code"), "GEN_API_Import_Code" }, + }; return lookup[ type ]; } - -inline TokType to_toktype( StrC str ) + inline +TokType to_toktype( StrC str) { - local_persist u32 keymap[Tok_NumTokens]; - do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ ) - { - StrC enum_str = to_str( (TokType)index ); - keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 ); - } - do_once_end u32 hash = crc32( str.Ptr, str.Len ); - for ( u32 index = 0; index < Tok_NumTokens; index++ ) - { - if ( keymap[index] == hash ) - return (TokType)index; - } - return Tok_Invalid; +local_persist u32 keymap[ Tok_NumTokens ]; do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ ) { StrC enum_str = to_str( (TokType)index ); keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1); } do_once_end u32 hash = crc32( str.Ptr, str.Len ); for ( u32 index = 0; index < Tok_NumTokens; index++ ) { if ( keymap[index] == hash ) return (TokType)index; } return Tok_Invalid; } - GEN_NS_PARSER_END diff --git a/project/components/inlines.hpp b/project/components/inlines.hpp index 396235b..d2b70ac 100644 --- a/project/components/inlines.hpp +++ b/project/components/inlines.hpp @@ -7,10 +7,11 @@ inline void code_append( Code self, Code other ) { - GEN_ASSERT(self.ast != nullptr); - GEN_ASSERT(other.ast != nullptr); + GEN_ASSERT(self); + GEN_ASSERT(other); + GEN_ASSERT_MSG(self != other, "Attempted to recursively append Code AST to itself."); - if ( other->Parent ) + if ( other->Parent != nullptr ) other = code_duplicate(other); other->Parent = self; @@ -34,7 +35,7 @@ void code_append( Code self, Code other ) inline bool code_is_body(Code self) { - GEN_ASSERT(self != nullptr); + GEN_ASSERT(self); switch (self->Type) { case CT_Enum_Body: @@ -53,7 +54,7 @@ bool code_is_body(Code self) inline Code* code_entry( Code self, u32 idx ) { - GEN_ASSERT(self.ast != nullptr); + GEN_ASSERT(self != nullptr); Code* current = & self->Front; while ( idx >= 0 && current != nullptr ) { @@ -66,29 +67,31 @@ Code* code_entry( Code self, u32 idx ) return rcast( Code*, current); } -inline +forceinline bool code_is_valid(Code self) { - return self.ast != nullptr && self.ast->Type != CT_Invalid; + GEN_ASSERT(self); + return self != nullptr && self->Type != CT_Invalid; } -inline +forceinline bool code_has_entries(AST* self) { - GEN_ASSERT(self != nullptr); + GEN_ASSERT(self); return self->NumEntries > 0; } -inline +forceinline void code_set_global(Code self) { - if ( self.ast == nullptr ) + if ( self == nullptr ) { log_failure("Code::set_global: Cannot set code as global, AST is null!"); return; } - self->Parent.ast = Code_Global.ast; + self->Parent = Code_Global; } -inline +#if GEN_COMPILER_CPP +forceinline Code& Code::operator ++() { if ( ast ) @@ -96,7 +99,8 @@ Code& Code::operator ++() return * this; } -inline +#endif +forceinline char const* code_type_str(Code self) { GEN_ASSERT(self != nullptr); @@ -106,49 +110,57 @@ char const* code_type_str(Code self) #pragma region CodeBody inline -void append( CodeBody self, Code other ) +void body_append( CodeBody self, Code other ) { - GEN_ASSERT(other.ast != nullptr); + GEN_ASSERT(self); + GEN_ASSERT(other); if (code_is_body(other)) { - append( self, cast(CodeBody, other) ); + body_append_body( self, cast(CodeBody, other) ); return; } code_append( cast(Code, self), other ); } inline -void append( CodeBody self, CodeBody body ) +void body_append_body( CodeBody self, CodeBody body ) { - GEN_ASSERT(self.ast != nullptr); + GEN_ASSERT(self); + GEN_ASSERT(body); + GEN_ASSERT_MSG(self != body, "Attempted to append body to itself."); - for ( Code entry : body ) { - append( self, entry ); + for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); entry = next_CodeBody(body, entry) ) { + body_append( self, entry ); } } inline -Code begin( CodeBody body) { - if ( body.ast ) - return { rcast( AST*, body.ast)->Front }; +Code begin_CodeBody( CodeBody body) { + GEN_ASSERT(body); + if ( body != nullptr ) + return body->Front; return { nullptr }; } -inline -Code end(CodeBody body ){ - return { rcast(AST*, body.ast)->Back->Next }; +forceinline +Code end_CodeBody(CodeBody body ){ + GEN_ASSERT(body); + return body->Back->Next; } inline -Code next(CodeBody body, Code entry) { +Code next_CodeBody(CodeBody body, Code entry) { + GEN_ASSERT(body); + GEN_ASSERT(entry); return entry->Next; } #pragma endregion CodeBody #pragma region CodeClass inline -void add_interface( CodeClass self, CodeTypename type ) +void class_add_interface( CodeClass self, CodeTypename type ) { - GEN_ASSERT(self.ast !=nullptr); + GEN_ASSERT(self); + GEN_ASSERT(type); CodeTypename possible_slot = self->ParentType; - if ( possible_slot.ast ) + if ( possible_slot != nullptr ) { // Were adding an interface to parent type, so we need to make sure the parent type is public. self->ParentAccess = AccessSpec_Public; @@ -156,24 +168,25 @@ void add_interface( CodeClass self, CodeTypename type ) // then you'll need to move this over to ParentType->next and update ParentAccess accordingly. } - while ( possible_slot.ast != nullptr ) + while ( possible_slot != nullptr ) { - possible_slot.ast = (AST_Typename*) possible_slot->Next.ast; + possible_slot = possible_slot->Next; } - possible_slot.ast = type.ast; + possible_slot = type; } #pragma endregion CodeClass #pragma region CodeParam inline -void append( CodeParam appendee, CodeParam other ) +void params_append( CodeParam appendee, CodeParam other ) { - GEN_ASSERT(appendee.ast != nullptr); + GEN_ASSERT(appendee); + GEN_ASSERT(other); Code self = cast(Code, appendee); Code entry = cast(Code, other); - if ( entry->Parent ) + if ( entry->Parent != nullptr ) entry = code_duplicate( entry ); entry->Parent = self; @@ -191,54 +204,61 @@ void append( CodeParam appendee, CodeParam other ) self->NumEntries++; } inline -CodeParam get(CodeParam self, s32 idx ) +CodeParam params_get(CodeParam self, s32 idx ) { - GEN_ASSERT(self.ast != nullptr); - CodeParam param = * self; + GEN_ASSERT(self); + CodeParam param = self; do { - if ( ! ++ param ) + if ( ++ param != nullptr ) return { nullptr }; - param = cast(Code, param)->Next; + param = cast(CodeParam, cast(Code, param)->Next); } while ( --idx ); return param; } -inline -bool has_entries(CodeParam self) +forceinline +bool params_has_entries(CodeParam self) { - GEN_ASSERT(self.ast != nullptr); + GEN_ASSERT(self); return self->NumEntries > 0; } -inline +#if GEN_COMPILER_CPP +forceinline CodeParam& CodeParam::operator ++() { - ast = ast->Next.ast; + * this = ast->Next; return * this; } -inline -CodeParam begin(CodeParam params) +#endif +forceinline +CodeParam begin_CodeParam(CodeParam params) { - if ( params.ast ) - return { params.ast }; + if ( params != nullptr ) + return params; - return { nullptr }; + return NullCode; } -inline -CodeParam end(CodeParam params) +forceinline +CodeParam end_CodeParam(CodeParam params) { // return { (AST_Param*) rcast( AST*, ast)->Last }; return { nullptr }; } +forceinline +CodeParam next_CodeParam(CodeParam params, CodeParam param_iter) +{ + return params->Next; +} #pragma endregion CodeParam #pragma region CodeSpecifiers inline -bool append(CodeSpecifiers self, Specifier spec ) +bool specifiers_append(CodeSpecifiers self, Specifier spec ) { - if ( self.ast == nullptr ) + if ( self == nullptr ) { log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!"); return false; @@ -254,9 +274,9 @@ bool append(CodeSpecifiers self, Specifier spec ) return true; } inline -s32 has(CodeSpecifiers self, Specifier spec) +s32 specifiers_has(CodeSpecifiers self, Specifier spec) { - GEN_ASSERT(self.ast != nullptr); + GEN_ASSERT(self != nullptr); for ( s32 idx = 0; idx < self->NumEntries; idx++ ) { if ( self->ArrSpecs[ idx ] == spec ) return idx; @@ -264,10 +284,9 @@ s32 has(CodeSpecifiers self, Specifier spec) return -1; } inline -s32 remove( CodeSpecifiers self, Specifier to_remove ) +s32 specifiers_remove( CodeSpecifiers self, Specifier to_remove ) { - AST_Specifiers* ast = self.ast; - if ( ast == nullptr ) + if ( self == nullptr ) { log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!"); return -1; @@ -304,19 +323,24 @@ s32 remove( CodeSpecifiers self, Specifier to_remove ) } return result; } -inline -Specifier* begin(CodeSpecifiers self) +forceinline +Specifier* begin_CodeSpecifiers(CodeSpecifiers self) { - if ( self.ast ) + if ( self != nullptr ) return & self->ArrSpecs[0]; return nullptr; } -inline -Specifier* end(CodeSpecifiers self) +forceinline +Specifier* end_CodeSpecifiers(CodeSpecifiers self) { return self->ArrSpecs + self->NumEntries; } +forceinline +Specifier* next_CodeSpecifiers(CodeSpecifiers self, Specifier* spec_iter) +{ + return spec_iter + 1; +} #pragma endregion CodeSpecifiers #pragma region CodeStruct @@ -324,7 +348,7 @@ inline void add_interface(CodeStruct self, CodeTypename type ) { CodeTypename possible_slot = self->ParentType; - if ( possible_slot.ast ) + if ( possible_slot != nullptr ) { // Were adding an interface to parent type, so we need to make sure the parent type is public. self->ParentAccess = AccessSpec_Public; @@ -332,12 +356,12 @@ void add_interface(CodeStruct self, CodeTypename type ) // then you'll need to move this over to ParentType->next and update ParentAccess accordingly. } - while ( possible_slot.ast != nullptr ) + while ( possible_slot != nullptr ) { - possible_slot.ast = (AST_Typename*) possible_slot->Next.ast; + possible_slot = possible_slot->Next; } - possible_slot.ast = type.ast; + possible_slot = type; } #pragma endregion Code diff --git a/project/components/interface.cpp b/project/components/interface.cpp index 6b0bbed..747cdf8 100644 --- a/project/components/interface.cpp +++ b/project/components/interface.cpp @@ -84,12 +84,12 @@ void define_constants() t_empty = (CodeTypename) make_code(); t_empty->Type = CT_Typename; t_empty->Name = get_cached_string( txt("") ); - code_set_global(t_empty); + code_set_global(cast(Code, t_empty)); access_private = make_code(); access_private->Type = CT_Access_Private; access_private->Name = get_cached_string( txt("private:\n") ); - code_set_global(access_private); + code_set_global(cast(Code, access_private)); access_protected = make_code(); access_protected->Type = CT_Access_Protected; @@ -102,50 +102,50 @@ void define_constants() code_set_global(access_public); attrib_api_export = def_attributes( code(GEN_API_Export_Code)); - code_set_global(attrib_api_export); + code_set_global(cast(Code, attrib_api_export)); attrib_api_import = def_attributes( code(GEN_API_Import_Code)); - code_set_global(attrib_api_import); + code_set_global(cast(Code, attrib_api_import)); module_global_fragment = make_code(); module_global_fragment->Type = CT_Untyped; module_global_fragment->Name = get_cached_string( txt("module;") ); module_global_fragment->Content = module_global_fragment->Name; - code_set_global(module_global_fragment); + code_set_global(cast(Code, module_global_fragment)); module_private_fragment = make_code(); module_private_fragment->Type = CT_Untyped; module_private_fragment->Name = get_cached_string( txt("module : private;") ); module_private_fragment->Content = module_private_fragment->Name; - code_set_global(module_private_fragment); + code_set_global(cast(Code, module_private_fragment)); fmt_newline = make_code(); fmt_newline->Type = CT_NewLine; - code_set_global(fmt_newline); - + code_set_global((Code)fmt_newline); + pragma_once = (CodePragma) make_code(); pragma_once->Type = CT_Preprocess_Pragma; pragma_once->Name = get_cached_string( txt("once") ); pragma_once->Content = pragma_once->Name; - code_set_global(pragma_once); + code_set_global((Code)pragma_once); - param_varadic = (CodeTypename) make_code(); + param_varadic = (CodeParam) make_code(); param_varadic->Type = CT_Parameters; param_varadic->Name = get_cached_string( txt("...") ); param_varadic->ValueType = t_empty; - code_set_global(param_varadic); + code_set_global((Code)param_varadic); preprocess_else = (CodePreprocessCond) make_code(); preprocess_else->Type = CT_Preprocess_Else; - code_set_global(preprocess_else); + code_set_global((Code)preprocess_else); preprocess_endif = (CodePreprocessCond) make_code(); preprocess_endif->Type = CT_Preprocess_EndIf; - code_set_global(preprocess_endif); + code_set_global((Code)preprocess_endif); # define def_constant_code_type( Type_ ) \ t_##Type_ = def_type( name(Type_) ); \ - code_set_global(t_##Type_); + code_set_global( cast(Code, t_##Type_)); def_constant_code_type( auto ); def_constant_code_type( void ); @@ -180,7 +180,7 @@ void define_constants() # define def_constant_spec( Type_, ... ) \ spec_##Type_ = def_specifiers( num_args(__VA_ARGS__), __VA_ARGS__); \ - code_set_global(spec_##Type_); + code_set_global( cast(Code, spec_##Type_)); # pragma push_macro("forceinline") # pragma push_macro("global") @@ -218,7 +218,7 @@ void define_constants() def_constant_spec( volatile, Spec_Volatile) spec_local_persist = def_specifiers( 1, Spec_Local_Persist ); - code_set_global(spec_local_persist); + code_set_global(cast(Code, spec_local_persist)); # pragma pop_macro("forceinline") # pragma pop_macro("global") @@ -426,7 +426,7 @@ Code make_code() } Code result { rcast( AST*, alloc( pool_allocator_info(allocator), sizeof(AST) )) }; - mem_set( result.ast, 0, sizeof(AST) ); + mem_set( rcast(void*, cast(AST*, result)), 0, sizeof(AST) ); // result->Type = ECode::Invalid; // result->Content = { nullptr }; diff --git a/project/components/interface.upfront.cpp b/project/components/interface.upfront.cpp index 794cde6..839cd99 100644 --- a/project/components/interface.upfront.cpp +++ b/project/components/interface.upfront.cpp @@ -29,19 +29,19 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp } \ if ( params_code->Type != CT_Parameters ) \ { \ - log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str(params_code)); \ + log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str( cast(Code, params_code))); \ return OpValResult_Fail; \ } # define check_param_eq_ret() \ - if ( ! is_member_symbol && ! code_is_equal(params_code->ValueType, ret_type) ) \ + if ( ! is_member_symbol && ! code_is_equal(cast(Code, params_code->ValueType), cast(Code, ret_type)) ) \ { \ log_failure("gen::def_operator: operator%s requires first parameter to equal return type\n" \ "param types: %s\n" \ "return type: %s", \ operator_to_str(op).Ptr, \ - code_debug_str(params_code), \ - code_debug_str(ret_type) \ + code_debug_str(cast(Code, params_code)), \ + code_debug_str(cast(Code, ret_type)) \ ); \ return OpValResult_Fail; \ } @@ -54,7 +54,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp if ( ret_type->Type != CT_Typename ) { - log_failure("gen::def_operator: ret_type is not of typename type - %s", code_debug_str(ret_type)); + log_failure("gen::def_operator: ret_type is not of typename type - %s", code_debug_str(cast(Code, ret_type))); return OpValResult_Fail; } @@ -71,7 +71,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp log_failure("gen::def_operator: " "operator%s does not support non-member definition (more than one parameter provided) - %s", operator_to_str(op), - code_debug_str(params_code) + code_debug_str(cast(Code, params_code)) ); return OpValResult_Fail; } @@ -102,7 +102,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp log_failure("gen::def_operator: operator%s may not be defined with more than two parametes - param count; %d\n%s" , operator_to_str(op) , params_code->NumEntries - , code_debug_str(params_code) + , code_debug_str(cast(Code, params_code)) ); return OpValResult_Fail; } @@ -117,7 +117,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp { log_failure("gen::def_operator: operator%s params code provided is not of Parameters type - %s" , operator_to_str(op) - , code_debug_str(params_code) + , code_debug_str(cast(Code, params_code)) ); return OpValResult_Fail; } @@ -125,7 +125,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp switch ( params_code->NumEntries ) { case 1: - if ( code_is_equal(params_code->ValueType, t_int ) ) + if ( code_is_equal((Code)params_code->ValueType, (Code)t_int ) ) is_member_symbol = true; else @@ -135,7 +135,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp case 2: check_param_eq_ret(); - if ( ! code_is_equal(get(params_code, 1), t_int ) ) + if ( ! code_is_equal((Code)params_get(params_code, 1), (Code)t_int ) ) { log_failure("gen::def_operator: " "operator%s requires second parameter of non-member definition to be int for post-decrement", @@ -164,18 +164,18 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp { if ( params_code->Type != CT_Parameters ) { - log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str(params_code)); + log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str((Code)params_code)); return OpValResult_Fail; } - if ( code_is_equal(params_code->ValueType, ret_type ) ) + if ( code_is_equal((Code)params_code->ValueType, (Code)ret_type ) ) { log_failure("gen::def_operator: " "operator%s is non-member symbol yet first paramter does not equal return type\n" "param type: %s\n" "return type: %s\n" - , code_debug_str(params_code) - , code_debug_str(ret_type) + , code_debug_str((Code)params_code) + , code_debug_str((Code)ret_type) ); return OpValResult_Fail; } @@ -209,7 +209,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp { if ( params_code->Type != CT_Parameters ) { - log_failure( "gen::def_operator: params is not of Parameters type - %s", code_debug_str(params_code) ); + log_failure( "gen::def_operator: params is not of Parameters type - %s", code_debug_str((Code)params_code) ); return OpValResult_Fail; } @@ -245,14 +245,14 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp break; case 2: - if ( ! code_is_equal(params_code->ValueType, ret_type ) ) + if ( ! code_is_equal((Code)params_code->ValueType, (Code)ret_type ) ) { log_failure("gen::def_operator: " "operator%s is non-member symbol yet first paramter does not equal return type\n" "param type: %s\n" "return type: %s\n" - , code_debug_str(params_code) - , code_debug_str(ret_type) + , code_debug_str((Code)params_code) + , code_debug_str((Code)ret_type) ); return OpValResult_Fail; } @@ -275,7 +275,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp { if ( params_code->Type != CT_Parameters ) { - log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str(params_code)); + log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str((Code)params_code)); return OpValResult_Fail; } @@ -289,11 +289,11 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp } } - if ( ! code_is_equal(ret_type, t_bool )) + if ( ! code_is_equal((Code)ret_type, (Code)t_bool )) { log_failure("gen::def_operator: operator%s return type must be of type bool - %s" , operator_to_str(op) - , code_debug_str(ret_type) + , code_debug_str((Code)ret_type) ); return OpValResult_Fail; } @@ -347,7 +347,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp case Op_PtrToMemOfPtr: if ( params_code ) { - log_failure("gen::def_operator: operator%s expects no paramters - %s", operator_to_str(op), code_debug_str(params_code)); + log_failure("gen::def_operator: operator%s expects no paramters - %s", operator_to_str(op), code_debug_str((Code)params_code)); return OpValResult_Fail; } break; @@ -390,7 +390,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp } #define null_check( Context_, Code_ ) \ - if ( ! Code_ ) \ + if ( Code_ != nullptr ) \ { \ log_failure( "gen::" stringize(Context_) ": " stringize(Code_) " provided is null" ); \ return InvalidCode; \ @@ -501,7 +501,7 @@ CodeConstructor def_constructor( Opts_def_constructor p ) if ( params && params->Type != CT_Parameters ) { - log_failure("gen::def_constructor: params must be of Parameters type - %s", code_debug_str(params)); + log_failure("gen::def_constructor: params must be of Parameters type - %s", code_debug_str((Code)params)); return InvalidCode; } @@ -606,7 +606,7 @@ CodeClass def_class( StrC name, Opts_def_struct p ) { for (s32 idx = 0; idx < num_interfaces; idx++ ) { - add_interface(result, interfaces[idx] ); + class_add_interface(result, interfaces[idx] ); } } @@ -692,13 +692,13 @@ CodeEnum def_enum( StrC name, Opts_def_enum p ) if ( type && type->Type != CT_Typename ) { - log_failure( "gen::def_enum: enum underlying type provided was not of type Typename: %s", code_debug_str(type) ); + log_failure( "gen::def_enum: enum underlying type provided was not of type Typename: %s", code_debug_str((Code)type) ); return InvalidCode; } if ( attributes && attributes->Type != CT_PlatformAttributes ) { - log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", code_debug_str(attributes) ); + log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", code_debug_str((Code)attributes) ); return InvalidCode; } @@ -1161,7 +1161,7 @@ CodeSpecifiers def_specifier( Specifier spec ) CodeSpecifiers result = (CodeSpecifiers) make_code(); result->Type = CT_Specifiers; - append(result, spec ); + specifiers_append(result, spec ); return result; } @@ -1178,7 +1178,7 @@ CodeStruct def_struct( StrC name, Opts_def_struct p ) if ( attributes && attributes->Type != CT_PlatformAttributes ) { - log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", code_debug_str(attributes) ); + log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", code_debug_str(cast(Code, attributes)) ); return InvalidCode; } @@ -1273,19 +1273,19 @@ CodeTypename def_type( StrC name, Opts_def_type p ) if ( attributes && attributes->Type != CT_PlatformAttributes ) { - log_failure( "gen::def_type: attributes is not of attributes type - %s", code_debug_str(attributes) ); + log_failure( "gen::def_type: attributes is not of attributes type - %s", code_debug_str((Code)attributes) ); return InvalidCode; } if ( specifiers && specifiers->Type != CT_Specifiers ) { - log_failure( "gen::def_type: specifiers is not of specifiers type - %s", code_debug_str(specifiers) ); + log_failure( "gen::def_type: specifiers is not of specifiers type - %s", code_debug_str((Code)specifiers) ); return InvalidCode; } if ( arrayexpr && arrayexpr->Type != CT_Untyped ) { - log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", code_debug_str(arrayexpr) ); + log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", code_debug_str((Code)arrayexpr) ); return InvalidCode; } @@ -1325,13 +1325,13 @@ CodeTypedef def_typedef( StrC name, Code type, Opts_def_typedef p ) case CT_Typename: break; default: - log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", code_debug_str(type) ); + log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", code_debug_str((Code)type) ); return InvalidCode; } if ( p.attributes && p.attributes->Type != CT_PlatformAttributes ) { - log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", code_debug_str(p.attributes) ); + log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", code_debug_str((Code)p.attributes) ); return InvalidCode; } @@ -1553,7 +1553,7 @@ CodeBody def_class_body( s32 num, ... ) break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); va_end(va); @@ -1590,7 +1590,7 @@ CodeBody def_class_body( s32 num, Code* codes ) break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); @@ -1624,7 +1624,7 @@ CodeBody def_enum_body( s32 num, ... ) return InvalidCode; } - append(result, entry ); + body_append(result, entry ); } while ( num--, num > 0 ); va_end(va); @@ -1656,7 +1656,7 @@ CodeBody def_enum_body( s32 num, Code* codes ) return InvalidCode; } - append(result, entry ); + body_append(result, entry ); } while ( codes++, num--, num > 0 ); @@ -1694,7 +1694,7 @@ CodeBody def_export_body( s32 num, ... ) break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); va_end(va); @@ -1731,7 +1731,7 @@ CodeBody def_export_body( s32 num, Code* codes ) break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); @@ -1769,7 +1769,7 @@ CodeBody def_extern_link_body( s32 num, ... ) break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); va_end(va); @@ -1806,8 +1806,7 @@ CodeBody def_extern_link_body( s32 num, Code* codes ) break; } - append(result, entry); - + body_append(result, entry); } while (num--, num > 0); @@ -1846,7 +1845,7 @@ CodeBody def_function_body( s32 num, ... ) break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); va_end(va); @@ -1882,7 +1881,7 @@ CodeBody def_function_body( s32 num, Code* codes ) default: break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); @@ -1913,8 +1912,8 @@ CodeBody def_global_body( s32 num, ... ) switch (entry->Type) { case CT_Global_Body: - // result.append( entry.code_cast() ) ; - append( result, cast(CodeBody, entry) ); + // result.body_append( entry.code_cast() ) ; + body_append( result, cast(CodeBody, entry) ); continue; GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES @@ -1925,7 +1924,7 @@ CodeBody def_global_body( s32 num, ... ) break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); va_end(va); @@ -1955,7 +1954,7 @@ CodeBody def_global_body( s32 num, Code* codes ) switch (entry->Type) { case CT_Global_Body: - append(result, cast(CodeBody, entry) ); + body_append(result, cast(CodeBody, entry) ); continue; GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES @@ -1966,7 +1965,7 @@ CodeBody def_global_body( s32 num, Code* codes ) break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); @@ -2004,7 +2003,7 @@ CodeBody def_namespace_body( s32 num, ... ) break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); va_end(va); @@ -2040,7 +2039,7 @@ CodeBody def_namespace_body( s32 num, Code* codes ) default: break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); @@ -2078,7 +2077,7 @@ CodeParam def_params( s32 num, ... ) return InvalidCode; } - append(result, param ); + params_append(result, param ); } va_end(va); @@ -2114,7 +2113,7 @@ CodeParam def_params( s32 num, CodeParam* codes ) while( codes++, current = * codes, num--, num > 0 ) { check_current(); - append(result, current ); + params_append(result, current ); } # undef check_current @@ -2145,7 +2144,7 @@ CodeSpecifiers def_specifiers( s32 num, ... ) { Specifier type = (Specifier)va_arg(va, int); - append(result, type ); + specifiers_append(result, type ); } while ( --num, num ); va_end(va); @@ -2174,7 +2173,7 @@ CodeSpecifiers def_specifiers( s32 num, Specifier* specs ) s32 idx = 0; do { - append(result, specs[idx] ); + specifiers_append(result, specs[idx] ); idx++; } while ( --num, num ); @@ -2213,7 +2212,7 @@ CodeBody def_struct_body( s32 num, ... ) break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); va_end(va); @@ -2250,7 +2249,7 @@ CodeBody def_struct_body( s32 num, Code* codes ) break; } - append(result, entry); + body_append(result, entry); } while (num--, num > 0); @@ -2284,7 +2283,7 @@ CodeBody def_union_body( s32 num, ... ) return InvalidCode; } - append(result, entry ); + body_append(result, entry ); } while ( num--, num > 0 ); va_end(va); @@ -2316,7 +2315,7 @@ CodeBody def_union_body( s32 num, CodeUnion* codes ) return InvalidCode; } - append(result, entry ); + body_append(result, entry ); } while ( codes++, num--, num > 0 ); diff --git a/project/components/parser.cpp b/project/components/parser.cpp index 6b8e488..2c44806 100644 --- a/project/components/parser.cpp +++ b/project/components/parser.cpp @@ -1124,7 +1124,7 @@ CodeBody parse_class_struct_body( TokType which, Token name ) return InvalidCode; } - append(result, member ); + body_append(result, member ); } eat( Tok_BraceCurly_Close ); @@ -1438,7 +1438,7 @@ CodeFn parse_function_after_name( CodeParam params = parse_params(); // ( ) - // TODO(Ed), Review old comment : These have to be kept separate from the return type's specifiers. + // TODO(Ed), Review old comment : These have to be kept separate from the return type's specifiers. while ( left && is_specifier(currtok) ) { if ( specifiers.ast == nullptr ) @@ -1448,7 +1448,7 @@ CodeFn parse_function_after_name( continue; } - append(specifiers, strc_to_specifier( to_str(currtok)) ); + specifiers_append(specifiers, strc_to_specifier( to_str(currtok)) ); eat( currtok.Type ); } // ( ) @@ -1468,7 +1468,7 @@ CodeFn parse_function_after_name( else if ( check(Tok_Operator) && currtok.Text[0] == '=' ) { eat(Tok_Operator); - append(specifiers, Spec_Pure ); + specifiers_append(specifiers, Spec_Pure ); eat( Tok_Number); Token stmt_end = currtok; @@ -1544,7 +1544,7 @@ CodeFn parse_function_after_name( internal Code parse_function_body() { - + push_scope(); eat( Tok_BraceCurly_Open ); @@ -1574,7 +1574,7 @@ Code parse_function_body() if ( len > 0 ) { - append( result, def_execution( { len, start.Text } ) ); + body_append( result, def_execution( { len, start.Text } ) ); } eat( Tok_BraceCurly_Close ); @@ -1891,7 +1891,7 @@ CodeBody parse_global_nspace( CodeType which ) } // log_fmt("Global Body Member: %s", member->debug_str()); - append(result, member ); + body_append(result, member ); } if ( which != CT_Global_Body ) @@ -2032,7 +2032,7 @@ Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers ) // TODO(Ed): I want to eventually change the identifier to its own AST type. // This would allow distinction of the qualifier for a symbol :: -// This would also allow +// This would also allow internal Token parse_identifier( bool* possible_member_function ) { @@ -2455,7 +2455,7 @@ CodeOperator parse_operator_after_ret_type( continue; } - append(specifiers, strc_to_specifier( to_str(currtok)) ); + specifiers_append(specifiers, strc_to_specifier( to_str(currtok)) ); eat( currtok.Type ); } // operator ( ) @@ -2771,7 +2771,7 @@ CodeParam parse_params( bool use_template_capture ) if ( check( Tok_Varadic_Argument ) ) { eat( Tok_Varadic_Argument ); - append(result, param_varadic ); + params_append(result, param_varadic ); continue; // ( = , ... } @@ -2875,7 +2875,7 @@ CodeParam parse_params( bool use_template_capture ) if ( value ) param->Value = value; - append(result, param ); + params_append(result, param ); } if ( ! use_template_capture ) @@ -2933,7 +2933,7 @@ CodePreprocessCond parse_preprocess_cond() return cond; } -internal +internal Code parse_simple_preprocess( TokType which, bool dont_consume_braces ) { // TODO(Ed): We can handle a macro a bit better than this. It's AST can be made more robust.. @@ -3305,7 +3305,7 @@ CodeVar parse_variable_declaration_list() "(Parser will add and continue to specifiers, but will most likely fail to compile)\n%s" , to_string(Context) ); - append(specifiers, spec ); + specifiers_append(specifiers, spec ); } break; @@ -3327,7 +3327,7 @@ CodeVar parse_variable_declaration_list() // eat(currtok.Type); if ( specifiers ) - append(specifiers, spec ); + specifiers_append(specifiers, spec ); else specifiers = def_specifier( spec ); } @@ -3467,7 +3467,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers ) if ( check( Tok_Spec_Virtual ) ) { if ( specifiers ) - append(specifiers, Spec_Virtual ); + specifiers_append(specifiers, Spec_Virtual ); else specifiers = def_specifier( Spec_Virtual ); eat( Tok_Spec_Virtual ); @@ -3510,7 +3510,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers ) eat( Tok_Number ); // ~() = 0 - append(specifiers, Spec_Pure ); + specifiers_append(specifiers, Spec_Pure ); } else if ( left && str_compare_len( upcoming.Text, "default", sizeof("default") - 1 ) == 0) { @@ -3762,7 +3762,7 @@ CodeEnum parse_enum( bool inplace_def ) return InvalidCode; } - append(body, member ); + body_append(body, member ); } eat( Tok_BraceCurly_Close ); @@ -4206,7 +4206,7 @@ CodeOpCast parse_operator_cast( CodeSpecifiers specifiers ) specifiers = def_specifier( Spec_Const ); else - append(specifiers, Spec_Const ); + specifiers_append(specifiers, Spec_Const ); eat( Tok_Spec_Const ); } @@ -4965,6 +4965,7 @@ CodeTypedef parse_typedef() name = currtok; eat(Tok_Identifier); } + // typedef } else { @@ -5250,7 +5251,7 @@ CodeUnion parse_union( bool inplace_def ) } if ( member ) - append(body, member ); + body_append(body, member ); } // union { diff --git a/project/dependencies/basic_types.hpp b/project/dependencies/basic_types.hpp index abef4b7..b2711a6 100644 --- a/project/dependencies/basic_types.hpp +++ b/project/dependencies/basic_types.hpp @@ -5,7 +5,6 @@ #endif #pragma region Basic Types -GEN_API_C_BEGIN #define GEN_U8_MIN 0u #define GEN_U8_MAX 0xffu @@ -127,14 +126,12 @@ typedef s32 b32; typedef void* mem_ptr; typedef void const* mem_ptr_const ; -#if ! GEN_COMPILER_C -GEN_API_C_END +#if GEN_COMPILER_CPP template uptr to_uptr( Type* ptr ) { return (uptr)ptr; } template sptr to_sptr( Type* ptr ) { return (sptr)ptr; } template mem_ptr to_mem_ptr ( Type ptr ) { return (mem_ptr) ptr; } template mem_ptr_const to_mem_ptr_const( Type ptr ) { return (mem_ptr_const)ptr; } -GEN_API_C_BEGIN #else #define to_uptr( ptr ) ((uptr)(ptr)) #define to_sptr( ptr ) ((sptr)(ptr)) @@ -143,5 +140,4 @@ GEN_API_C_BEGIN #define to_mem_ptr_const( ptr) ((mem_ptr)ptr) #endif -GEN_API_C_END #pragma endregion Basic Types diff --git a/project/dependencies/containers.hpp b/project/dependencies/containers.hpp index befecda..5ef4c88 100644 --- a/project/dependencies/containers.hpp +++ b/project/dependencies/containers.hpp @@ -26,12 +26,9 @@ template using TRemovePtr = typename RemovePtr::Type; struct ArrayHeader; -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if GEN_COMPILER_CPP template struct Array; # define get_array_underlying_type(array) typename TRemovePtr:: DataType -#else - template using Array = Type*; -# define get_array_underlying_type(array) TRemovePtr #endif usize array_grow_formula(ssize value); @@ -62,7 +59,7 @@ struct ArrayHeader { usize Num; }; -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if GEN_COMPILER_CPP template struct Array { @@ -104,7 +101,7 @@ struct Array }; #endif -#if GEN_SUPPORT_CPP_REFERENCES +#if GEN_COMPILER_CPP && 0 template bool append(Array& array, Array other) { return GEN_NS append( & array, other ); } template bool append(Array& array, Type value) { return GEN_NS append( & array, value ); } template bool append(Array& array, Type* items, usize item_num) { return GEN_NS append( & array, items, item_num ); } diff --git a/project/dependencies/debug.cpp b/project/dependencies/debug.cpp index 5b66730..c5aaf59 100644 --- a/project/dependencies/debug.cpp +++ b/project/dependencies/debug.cpp @@ -6,7 +6,6 @@ #endif #pragma region Debug -GEN_API_C_BEGIN void assert_handler( char const* condition, char const* file, s32 line, char const* msg, ... ) { @@ -46,5 +45,4 @@ s32 assert_crash( char const* condition ) } #endif -GEN_API_C_END #pragma endregion Debug diff --git a/project/dependencies/debug.hpp b/project/dependencies/debug.hpp index 3e20c74..3b041bd 100644 --- a/project/dependencies/debug.hpp +++ b/project/dependencies/debug.hpp @@ -56,10 +56,8 @@ while (0) #endif -GEN_API_C_BEGIN void assert_handler( char const* condition, char const* file, s32 line, char const* msg, ... ); s32 assert_crash( char const* condition ); void process_exit( u32 code ); -GEN_API_C_END #pragma endregion Debug diff --git a/project/dependencies/filesystem.cpp b/project/dependencies/filesystem.cpp index d0e585d..aa1d41d 100644 --- a/project/dependencies/filesystem.cpp +++ b/project/dependencies/filesystem.cpp @@ -4,7 +4,6 @@ #endif #pragma region File Handling -GEN_API_C_BEGIN #if defined( GEN_SYSTEM_WINDOWS ) || defined( GEN_SYSTEM_CYGWIN ) @@ -656,5 +655,4 @@ GEN_FILE_CLOSE_PROC( _memory_file_close ) FileOperations const memory_file_operations = { _memory_file_read, _memory_file_write, _memory_file_seek, _memory_file_close }; -GEN_API_C_END #pragma endregion File Handling diff --git a/project/dependencies/filesystem.hpp b/project/dependencies/filesystem.hpp index 9602e5c..5c3f9da 100644 --- a/project/dependencies/filesystem.hpp +++ b/project/dependencies/filesystem.hpp @@ -4,11 +4,10 @@ #endif #pragma region File Handling -GEN_API_C_BEGIN typedef u32 FileMode; -enum FileModeFlag_Def +enum FileModeFlag { EFileMode_READ = bit( 0 ), EFileMode_WRITE = bit( 1 ), @@ -16,18 +15,16 @@ enum FileModeFlag_Def EFileMode_RW = bit( 3 ), GEN_FILE_MODES = EFileMode_READ | EFileMode_WRITE | EFileMode_APPEND | EFileMode_RW, }; -typedef enum FileModeFlag_Def FileModeFlag; // NOTE: Only used internally and for the file operations -enum SeekWhenceType_Def +enum SeekWhenceType { ESeekWhence_BEGIN = 0, ESeekWhence_CURRENT = 1, ESeekWhence_END = 2, }; -typedef enum SeekWhenceType_Def SeekWhenceType; -enum FileError_Def +enum FileError { EFileError_NONE, EFileError_INVALID, @@ -40,17 +37,15 @@ enum FileError_Def EFileError_NAME_TOO_LONG, EFileError_UNKNOWN, }; -typedef enum FileError_Def FileError; -union FileDescriptor_Def +union FileDescriptor { void* p; sptr i; uptr u; }; -typedef union FileDescriptor_Def FileDescriptor; -typedef struct FileOperations_Def FileOperations; +typedef struct FileOperations FileOperations; #define GEN_FILE_OPEN_PROC( name ) FileError name( FileDescriptor* fd, FileOperations* ops, FileMode mode, char const* filename ) #define GEN_FILE_READ_AT_PROC( name ) b32 name( FileDescriptor fd, void* buffer, ssize size, s64 offset, ssize* bytes_read, b32 stop_at_newline ) @@ -64,39 +59,35 @@ typedef GEN_FILE_WRITE_AT_PROC( FileWriteProc ); typedef GEN_FILE_SEEK_PROC( FileSeekProc ); typedef GEN_FILE_CLOSE_PROC( FileCloseProc ); -struct FileOperations_Def +struct FileOperations { FileReadProc* read_at; FileWriteProc* write_at; FileSeekProc* seek; FileCloseProc* close; }; -typedef struct FileOperations_Def FileOperations; extern FileOperations const default_file_operations; typedef u64 FileTime; -enum DirType_Def +enum DirType { GEN_DIR_TYPE_FILE, GEN_DIR_TYPE_FOLDER, GEN_DIR_TYPE_UNKNOWN, }; -typedef enum DirType_Def DirType; -struct DirInfo_Def; -typedef struct DirInfo_Def DirInfo; +struct DirInfo; -struct DirEntry_Def +struct DirEntry { char const* filename; DirInfo* dir_info; u8 type; }; -typedef struct DirEntry_Def DirEntry; -struct DirInfo_Def +struct DirInfo { char const* fullpath; DirEntry* entries; // zpl_array @@ -106,7 +97,7 @@ struct DirInfo_Def String buf; }; -struct FileInfo_Def +struct FileInfo { FileOperations ops; FileDescriptor fd; @@ -116,9 +107,9 @@ struct FileInfo_Def FileTime last_write_time; DirEntry* dir; }; -typedef struct FileInfo_Def FileInfo; +typedef struct FileInfo FileInfo; -enum FileStandardType_Def +enum FileStandardType { EFileStandard_INPUT, EFileStandard_OUTPUT, @@ -126,7 +117,7 @@ enum FileStandardType_Def EFileStandard_COUNT, }; -typedef enum FileStandardType_Def FileStandardType; +typedef enum FileStandardType FileStandardType; /** * Get standard file I/O. @@ -269,7 +260,7 @@ b32 file_write_at( FileInfo* file, void const* buffer, ssize size, s64 offset ); */ b32 file_write_at_check( FileInfo* file, void const* buffer, ssize size, s64 offset, ssize* bytes_written ); -enum FileStreamFlags_Def enum_underlying(u32) +enum FileStreamFlags : u32 { /* Allows us to write to the buffer directly. Beware: you can not append a new data! */ EFileStream_WRITABLE = bit( 0 ), @@ -280,7 +271,6 @@ enum FileStreamFlags_Def enum_underlying(u32) EFileStream_UNDERLYING = GEN_U32_MAX, }; -typedef enum FileStreamFlags_Def FileStreamFlags; /** * Opens a new memory stream @@ -396,5 +386,4 @@ b32 file_write_at_check( FileInfo* f, void const* buffer, ssize size, s64 offset return f->ops.write_at( f->fd, buffer, size, offset, bytes_written ); } -GEN_API_C_END #pragma endregion File Handling diff --git a/project/dependencies/hashing.cpp b/project/dependencies/hashing.cpp index d11b9c7..6ac5358 100644 --- a/project/dependencies/hashing.cpp +++ b/project/dependencies/hashing.cpp @@ -4,7 +4,6 @@ #endif #pragma region Hashing -GEN_API_C_BEGIN global u32 const _crc32_table[ 256 ] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, @@ -88,5 +87,4 @@ u64 crc64( void const* data, ssize len ) return result; } -GEN_API_C_END #pragma endregion Hashing diff --git a/project/dependencies/hashing.hpp b/project/dependencies/hashing.hpp index 53dffcd..f16a9df 100644 --- a/project/dependencies/hashing.hpp +++ b/project/dependencies/hashing.hpp @@ -4,10 +4,8 @@ #endif #pragma region Hashing -GEN_API_C_BEGIN u32 crc32( void const* data, ssize len ); u64 crc64( void const* data, ssize len ); -GEN_API_C_END #pragma endregion Hashing diff --git a/project/dependencies/macros.hpp b/project/dependencies/macros.hpp index ff0b07c..2cf4ca8 100644 --- a/project/dependencies/macros.hpp +++ b/project/dependencies/macros.hpp @@ -19,10 +19,22 @@ #define bitfield_is_equal( Type, Field, Mask ) ( (Type(Mask) & Type(Field)) == Type(Mask) ) #endif +// Mainly intended for forcing the base library to utilize only C-valid constructs or type coercion +#ifndef GEN_C_LIKE_CPP +#define GEN_C_LIKE_CPP 0 +#endif + #if GEN_COMPILER_CPP # ifndef cast # define cast( type, value ) (tmpl_cast( value )) # endif +#else +# ifndef cast +# define cast( type, value ) ( (type)(value) ) +# endif +#endif + +#if GEN_COMPILER_CPP # ifndef ccast # define ccast( type, value ) ( const_cast< type >( (value) ) ) # endif @@ -36,9 +48,6 @@ # define scast( type, value ) static_cast< type >( value ) # endif #else -# ifndef cast -# define cast( type, value ) ( (type)(value) ) -# endif # ifndef ccast # define ccast( type, value ) ( (type)(value) ) # endif @@ -210,22 +219,6 @@ # error "No thread local support" #endif -#if !defined(GEN_SUPPORT_CPP_REFERENCES) -# define GEN_SUPPORT_CPP_REFERENCES 1 -#endif -#if GEN_COMPILER_C && defined(GEN_SUPPORT_CPP_REFERENCES) -# undef GEN_SUPPORT_CPP_REFERENCES -# define GEN_SUPPORT_CPP_REFERENCES 0 -#endif - -#if !defined(GEN_SUPPORT_CPP_MEMBER_FEATURES) -# define GEN_SUPPORT_CPP_MEMBER_FEATURES 1 -#endif -#if GEN_COMPILER_C && defined(GEN_SUPPORT_CPP_MEMBER_FEATURES) -# undef GEN_SUPPORT_CPP_MEMBER_FEATURES -# define GEN_SUPPORT_CPP_MEMBER_FEATURES 0 -#endif - #if ! defined(typeof) && (!GEN_COMPILER_C || __STDC_VERSION__ < 202311L) # if ! GEN_COMPILER_C # define typeof decltype @@ -239,12 +232,12 @@ #endif #ifndef GEN_API_C_BEGIN -# if GEN_COMPILER_C || (GEN_COMPILER_CPP && GEN_SUPPORT_CPP_REFERENCES) +# if GEN_COMPILER_C # define GEN_API_C_BEGIN # define GEN_API_C_END # else # define GEN_API_C_BEGIN extern "C" { -# define GEN_API_C_END } +# define GEN_API_C_END } # endif #endif @@ -280,6 +273,16 @@ #define struct_init(type, value) {value} #endif +#if 0 +#ifndef GEN_OPTIMIZE_MAPPINGS_BEGIN +# define GEN_OPTIMIZE_MAPPINGS_BEGIN _pragma(optimize("gt", on)) +# define GEN_OPITMIZE_MAPPINGS_END _pragma(optimize("", on)) +#endif +#else +# define GEN_OPTIMIZE_MAPPINGS_BEGIN +# define GEN_OPITMIZE_MAPPINGS_END +#endif + #if GEN_COMPILER_C // ------------------------ _Generic function overloading ----------------------------------------- // This implemnents macros for utilizing "The Naive Extendible _Generic Macro" explained in: @@ -295,12 +298,7 @@ // Helper macros for argument selection #define GEN_SELECT_ARG_1( _1, ... ) _1 // <-- Of all th args passed pick _1. #define GEN_SELECT_ARG_2( _1, _2, ... ) _2 // <-- Of all the args passed pick _2. -#define GEN_SELECT_ARG_3( _1, _2, _3, ... ) _3 // etc.. (by induction until _8, which we don't support any more beyond) -// #define GEN_SELECT_ARG_4( _1, _2, _3, _4, ... ) _4 -// #define GEN_SELECT_ARG_5( _1, _2, _3, _4, _5, ... ) _5 -// #define GEN_SELECT_ARG_6( _1, _2, _3, _4, _5, _6, ... ) _6 -// #define GEN_SELECT_ARG_7( _1, _2, _3, _4, _5, _6, _7, ... ) _7 -// #define GEN_SELECT_ARG_8( _1, _2, _3, _4, _5, _6, _7, _8, ... ) _8 +#define GEN_SELECT_ARG_3( _1, _2, _3, ... ) _3 // etc.. #define GEN_GENERIC_SEL_ENTRY_TYPE GEN_SELECT_ARG_1 // Use the arg expansion macro to select arg 1 which should have the type. #define GEN_GENERIC_SEL_ENTRY_FUNCTION GEN_SELECT_ARG_2 // Use the arg expansion macro to select arg 2 which should have the function. @@ -314,10 +312,10 @@ // Expands to ',' if it can find (type): (function) // Where GEN_GENERIC_SEL_ENTRY_COMMA_DELIMITER is specifically looking for that , #define GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT( slot_exp ) GEN_GENERIC_SEL_ENTRY_COMMA_DELIMITER( slot_exp, GEN_GENERIC_SEL_ENTRY_TYPE( slot_exp, ): GEN_GENERIC_SEL_ENTRY_FUNCTION( slot_exp, ) GEN_COMMA_OPERATOR, , ) -// ^ Selects the comma ^ is the type ^ is the function ^ Insert a comma -// The slot won't exist if that comma is not found. | -// | -// This is the same as above but it does not insert a comma V no comma here. +// ^ Selects the comma ^ is the type ^ is the function ^ Insert a comma +// The slot won't exist if that comma is not found. | +// | +// This is the same as above but it does not insert a comma V no comma here. #define GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT_LAST( slot_exp ) GEN_GENERIC_SEL_ENTRY_COMMA_DELIMITER( slot_exp, GEN_GENERIC_SEL_ENTRY_TYPE( slot_exp, ): GEN_GENERIC_SEL_ENTRY_FUNCTION( slot_exp, ), , ) // Needed for the last slot as they don't allow trailing commas. // ---------------------------------------------------------------------------------------------------------------------------------- @@ -392,6 +390,7 @@ size_t gen_example_hash__P_long_long( long long val ) { return val * 2654435761u // typedef void* GEN_GenericExampleType; // GEN_FUNCTION_GENERIC_EXAMPLE_DIRECT_TYPE( GEN_GenericExampleType ); + // END OF ------------------------ _Generic function overloading ----------------------------------------- END OF #endif diff --git a/project/dependencies/memory.cpp b/project/dependencies/memory.cpp index f53c8fc..d4fae36 100644 --- a/project/dependencies/memory.cpp +++ b/project/dependencies/memory.cpp @@ -4,13 +4,12 @@ #endif #pragma region Memory -GEN_API_C_BEGIN void* mem_copy( void* dest, void const* source, ssize n ) { - if ( dest == NULL ) + if ( dest == nullptr ) { - return NULL; + return nullptr; } return memcpy( dest, source, n ); @@ -518,5 +517,4 @@ void pool_clear(Pool* pool) pool->FreeList = pool->PhysicalStart; } -GEN_API_C_END #pragma endregion Memory diff --git a/project/dependencies/memory.hpp b/project/dependencies/memory.hpp index 3f60bec..59fca53 100644 --- a/project/dependencies/memory.hpp +++ b/project/dependencies/memory.hpp @@ -22,8 +22,6 @@ void swap( Type& a, Type& b ) b = tmp; } -GEN_API_C_BEGIN - //! Checks if value is power of 2. b32 is_power_of_two( ssize x ); @@ -64,23 +62,21 @@ void zero_size( void* ptr, ssize size ); //! Clears up an array. #define zero_array( a, count ) zero_size( ( a ), size_of( *( a ) ) * count ) -enum AllocType_Def //enum_underlying(u8) +enum AllocType : u8 { EAllocation_ALLOC, EAllocation_FREE, EAllocation_FREE_ALL, EAllocation_RESIZE, }; -typedef enum AllocType_Def AllocType; typedef void*(AllocatorProc)( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags ); -struct AllocatorInfo_Def +struct AllocatorInfo { AllocatorProc* Proc; void* Data; }; -typedef struct AllocatorInfo_Def AllocatorInfo; enum AllocFlag { @@ -144,12 +140,11 @@ constexpr AllocatorInfo heap( void ) { AllocatorInfo allocator = { heap_allocato //! Helper to free memory allocated by heap allocator. #define mfree( ptr ) free( heap(), ptr ) -struct VirtualMemory_Def +struct VirtualMemory { void* data; ssize size; }; -typedef struct VirtualMemory_Def VirtualMemory; //! Initialize virtual memory from existing data. VirtualMemory vm_from_memory( void* data, ssize size ); @@ -173,8 +168,7 @@ b32 vm_purge( VirtualMemory vm ); ssize virtual_memory_page_size( ssize* alignment_out ); #pragma region Arena -struct Arena_Def; -typedef struct Arena_Def Arena; +struct Arena; AllocatorInfo arena_allocator_info( Arena* arena ); @@ -191,7 +185,7 @@ void arena_check (Arena* arena); void arena_free (Arena* arena); ssize arena_size_remaining(Arena* arena, ssize alignment); -struct Arena_Def +struct Arena { AllocatorInfo Backing; void* PhysicalStart; @@ -199,7 +193,7 @@ struct Arena_Def ssize TotalUsed; ssize TempCount; -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if GEN_COMPILER_CPP #pragma region Member Mapping forceinline operator AllocatorInfo() { return GEN_NS arena_allocator_info(this); } @@ -221,8 +215,7 @@ struct Arena_Def #endif }; -#if GEN_SUPPORT_CPP_REFERENCES -GEN_API_C_END +#if GEN_COMPILER_CPP forceinline AllocatorInfo allocator_info(Arena& arena ) { return arena_allocator_info(& arena); } forceinline Arena init_sub (Arena& parent, ssize size) { return arena_init_sub( & parent, size); } forceinline ssize alignment_of (Arena& arena, ssize alignment) { return arena_alignment_of( & arena, alignment); } @@ -234,7 +227,6 @@ forceinline ssize size_remaining(Arena& arena, ssize alignment) { return #undef check forceinline void check(Arena& arena) { return arena_check(& arena); }; #pragma pop_macro("check") -GEN_API_C_BEGIN #endif @@ -320,8 +312,6 @@ ssize arena_size_remaining(Arena* arena, ssize alignment) } #pragma endregion Arena -GEN_API_C_END - #pragma region FixedArena template struct FixedArena; @@ -330,7 +320,7 @@ template FixedArena fixed_arena_init(); template AllocatorInfo fixed_arena_allocator_info(FixedArena* fixed_arena ); template ssize fixed_arena_size_remaining(FixedArena* fixed_arena, ssize alignment); -#if GEN_SUPPORT_CPP_REFERENCES +#if 0 template AllocatorInfo allocator_info( FixedArena& fixed_arena ) { return allocator_info(& fixed_arena); } template ssize size_remaining(FixedArena& fixed_arena, ssize alignment) { return size_remaining( & fixed_arena, alignment); } #endif @@ -343,7 +333,7 @@ struct FixedArena char memory[Size]; Arena arena; -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if 0 #pragma region Member Mapping forceinline operator AllocatorInfo() { return GEN_NS allocator_info(this); } @@ -389,11 +379,8 @@ using Arena_2MB = FixedArena< megabytes( 2 ) >; using Arena_4MB = FixedArena< megabytes( 4 ) >; #pragma endregion FixedArena -GEN_API_C_BEGIN - #pragma region Pool -struct Pool_Def; -typedef struct Pool_Def Pool; +struct Pool; void* pool_allocator_proc(void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags); @@ -403,15 +390,13 @@ AllocatorInfo pool_allocator_info(Pool* pool); void pool_clear(Pool* pool); void pool_free(Pool* pool); -#if GEN_SUPPORT_CPP_REFERENCES -GEN_API_C_END +#if 0 AllocatorInfo allocator_info(Pool& pool) { return pool_allocator_info(& pool); } void clear(Pool& pool) { return pool_clear(& pool); } void free(Pool& pool) { return pool_free(& pool); } -GEN_API_C_BEGIN #endif -struct Pool_Def +struct Pool { AllocatorInfo Backing; void* PhysicalStart; @@ -421,7 +406,7 @@ struct Pool_Def ssize TotalSize; ssize NumBlocks; -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP #pragma region Member Mapping forceinline operator AllocatorInfo() { return GEN_NS pool_allocator_info(this); } @@ -684,6 +669,4 @@ void zero_size( void* ptr, ssize size ) { mem_set( ptr, 0, size ); } -GEN_API_C_END - #pragma endregion Memory diff --git a/project/dependencies/parsing.cpp b/project/dependencies/parsing.cpp index bc1fbf3..7882701 100644 --- a/project/dependencies/parsing.cpp +++ b/project/dependencies/parsing.cpp @@ -4,7 +4,6 @@ #endif #pragma region ADT -GEN_API_C_BEGIN #define _adt_fprintf( s_, fmt_, ... ) \ do \ @@ -1112,5 +1111,4 @@ String csv_write_string_delimiter( AllocatorInfo a, CSV_Object* obj, char delimi return output; } -GEN_API_C_END #pragma endregion CSV diff --git a/project/dependencies/parsing.hpp b/project/dependencies/parsing.hpp index 01527ad..b0a721d 100644 --- a/project/dependencies/parsing.hpp +++ b/project/dependencies/parsing.hpp @@ -3,7 +3,6 @@ #endif #pragma region ADT -GEN_API_C_BEGIN enum ADT_Type : u32 { @@ -430,5 +429,4 @@ String csv_write_string( AllocatorInfo a, CSV_Object* obj ) return csv_write_string_delimiter( a, obj, ',' ); } -GEN_API_C_END #pragma endregion CSV diff --git a/project/dependencies/platform.hpp b/project/dependencies/platform.hpp index a3899bf..ab6c0d6 100644 --- a/project/dependencies/platform.hpp +++ b/project/dependencies/platform.hpp @@ -76,17 +76,20 @@ /* Platform compiler */ #if defined( _MSC_VER ) -# define GEN_COMPILER_CLANG 0 +# pragma message("Detected MSVC") +// # define GEN_COMPILER_CLANG 0 # define GEN_COMPILER_MSVC 1 -# define GEN_COMPILER_GCC 0 +// # define GEN_COMPILER_GCC 0 #elif defined( __GNUC__ ) -# define GEN_COMPILER_CLANG 0 -# define GEN_COMPILER_MSVC 0 +# pragma message("Detected GCC") +// # define GEN_COMPILER_CLANG 0 +// # define GEN_COMPILER_MSVC 0 # define GEN_COMPILER_GCC 1 #elif defined( __clang__ ) +# pragma message("Detected CLANG") # define GEN_COMPILER_CLANG 1 -# define GEN_COMPILER_MSVC 0 -# define GEN_COMPILER_GCC 1 +// # define GEN_COMPILER_MSVC 0 +// # define GEN_COMPILER_GCC 0 #else # error Unknown compiler #endif diff --git a/project/dependencies/printing.cpp b/project/dependencies/printing.cpp index 5939106..f37118a 100644 --- a/project/dependencies/printing.cpp +++ b/project/dependencies/printing.cpp @@ -6,7 +6,6 @@ #endif #pragma region Printing -GEN_API_C_BEGIN enum { @@ -598,5 +597,4 @@ ssize str_fmt_out_err( char const* fmt, ... ) return res; } -GEN_API_C_END #pragma endregion Printing diff --git a/project/dependencies/printing.hpp b/project/dependencies/printing.hpp index 2f3148f..3a77225 100644 --- a/project/dependencies/printing.hpp +++ b/project/dependencies/printing.hpp @@ -5,9 +5,7 @@ #pragma region Printing -GEN_API_C_BEGIN - -typedef struct FileInfo_Def FileInfo; +typedef struct FileInfo FileInfo; #ifndef GEN_PRINTF_MAXLEN # define GEN_PRINTF_MAXLEN kilobytes(128) @@ -41,6 +39,4 @@ ssize log_fmt(char const* fmt, ...) return res; } -GEN_API_C_END - #pragma endregion Printing diff --git a/project/dependencies/string_ops.cpp b/project/dependencies/string_ops.cpp index 8edfc2f..954d40a 100644 --- a/project/dependencies/string_ops.cpp +++ b/project/dependencies/string_ops.cpp @@ -5,7 +5,6 @@ #endif #pragma region String Ops -GEN_API_C_BEGIN internal ssize _scan_zpl_i64( const char* text, s32 base, s64* value ) @@ -213,5 +212,4 @@ f64 str_to_f64( const char* str, char** end_ptr ) return result; } -GEN_API_C_END #pragma endregion String Ops diff --git a/project/dependencies/string_ops.hpp b/project/dependencies/string_ops.hpp index 891fec2..a3d547f 100644 --- a/project/dependencies/string_ops.hpp +++ b/project/dependencies/string_ops.hpp @@ -5,8 +5,6 @@ #pragma region String Ops -GEN_API_C_BEGIN - const char* char_first_occurence( const char* str, char c ); b32 char_is_alpha( char c ); @@ -286,6 +284,4 @@ void str_to_upper( char* str ) } } -GEN_API_C_END - #pragma endregion String Ops diff --git a/project/dependencies/strings.cpp b/project/dependencies/strings.cpp index 40e70cd..344bec8 100644 --- a/project/dependencies/strings.cpp +++ b/project/dependencies/strings.cpp @@ -4,7 +4,6 @@ #endif #pragma region String -GEN_API_C_BEGIN String string_make_length( AllocatorInfo allocator, char const* str, ssize length ) { @@ -54,5 +53,4 @@ String string_make_reserve( AllocatorInfo allocator, ssize capacity ) return result; } -GEN_API_C_END #pragma endregion String diff --git a/project/dependencies/strings.hpp b/project/dependencies/strings.hpp index a9deb41..3d8c3a2 100644 --- a/project/dependencies/strings.hpp +++ b/project/dependencies/strings.hpp @@ -5,8 +5,6 @@ #pragma region Strings -GEN_API_C_BEGIN - struct StrC_Def; typedef struct StrC_Def StrC; @@ -18,8 +16,6 @@ b32 strc_starts_with (StrC str, StrC substring); StrC strc_to_str (char const* bad_string); StrC strc_visualize_whitespace(StrC str, AllocatorInfo allocator); -GEN_API_C_END - // Constant string with length. struct StrC_Def { @@ -30,7 +26,7 @@ struct StrC_Def forceinline operator char const* () const { return Ptr; } forceinline char const& operator[]( ssize index ) const { return Ptr[index]; } -#if GEN_SUPPORT_CPP_MEMBER_FEATURES +#if ! GEN_C_LIKE_CPP forceinline bool is_equal (StrC rhs) const { return GEN_NS strc_are_equal(* this, rhs); } forceinline char const* back () const { return GEN_NS strc_back(* this); } forceinline bool contains (StrC substring) const { return GEN_NS strc_contains(* this, substring); } @@ -63,8 +59,6 @@ forceinline char const* end (StrC str) { return str.Ptr + str forceinline char const* next (StrC str, char const* iter) { return iter + 1; } #endif -GEN_API_C_BEGIN - inline bool strc_are_equal(StrC lhs, StrC rhs) { @@ -113,24 +107,21 @@ StrC to_strc_from_c_str( char const* bad_str ) { StrC result = { str_len( bad_str ), bad_str }; return result; } -GEN_API_C_END // Dynamic String // This is directly based off the ZPL string api. // They used a header pattern // I kept it for simplicty of porting but its not necessary to keep it that way. #pragma region String - struct StringHeader_Def; -typedef struct StringHeader_Def StringHeader; + struct StringHeader; +typedef struct StringHeader StringHeader; -#if GEN_COMPILER_C || ! GEN_SUPPORT_CPP_MEMBER_FEATURES +#if GEN_COMPILER_C typedef char* String; #else struct String; #endif -GEN_API_C_BEGIN - forceinline usize string_grow_formula(usize value); String string_make_c_str (AllocatorInfo allocator, char const* str); @@ -168,15 +159,13 @@ void string_trim (String str, char const* cut_set) void string_trim_space (String str); String string_visualize_whitespace(String const str); -GEN_API_C_END - -struct StringHeader_Def { +struct StringHeader { AllocatorInfo Allocator; ssize Capacity; ssize Length; }; -#if GEN_COMPILER_CPP && GEN_SUPPORT_CPP_MEMBER_FEATURES +#if GEN_COMPILER_CPP struct String { char* Data; @@ -203,6 +192,7 @@ struct String friend forceinline bool operator==(std::nullptr_t, const String str) { return str.Data == nullptr; } friend forceinline bool operator!=(std::nullptr_t, const String str) { return str.Data != nullptr; } +#if ! GEN_C_LIKE_CPP forceinline char* begin() const { return Data; } forceinline char* end() const { return Data + string_length(* this); } @@ -273,6 +263,7 @@ struct String return string_append_c_str_len(this, buf, res); } #pragma endregion Member Mapping +#endif }; #endif @@ -282,13 +273,13 @@ forceinline char* string_end (String str) { return ((char*) s forceinline char* string_next (String str, char const* iter) { return ((char*) iter + 1); } GEN_API_C_END -#if GEN_COMPILER_CPP && 0 +#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP forceinline char* begin(String str) { return ((char*) str); } forceinline char* end (String str) { return ((char*) str + string_length(str)); } forceinline char* next (String str, char* iter) { return ((char*) iter + 1); } #endif -#if GEN_SUPPORT_CPP_REFERENCES +#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP forceinline bool make_space_for(String& str, char const* to_append, ssize add_len); forceinline bool append(String& str, char c); forceinline bool append(String& str, char const* str_to_append); @@ -301,8 +292,6 @@ forceinline void clear(String& str); forceinline void free(String& str); #endif -GEN_API_C_BEGIN - forceinline usize string_grow_formula(usize value) { // Using a very aggressive growth formula to reduce time mem_copying with recursive calls to append in this library. @@ -755,8 +744,6 @@ StrC strc_visualize_whitespace(StrC str, AllocatorInfo allocator) // Should never be modified, if changed string is desired, cache_string( str ) another. typedef StrC StringCached; -GEN_API_C_END - // Implements basic string interning. Data structure is based off the ZPL Hashtable. typedef HashTable(StringCached) StringTable; #pragma endregion Strings diff --git a/project/dependencies/timing.cpp b/project/dependencies/timing.cpp index 91840c6..5258045 100644 --- a/project/dependencies/timing.cpp +++ b/project/dependencies/timing.cpp @@ -4,7 +4,6 @@ #endif #pragma region Timing -GEN_API_C_BEGIN #ifdef GEN_BENCHMARK #if defined( GEN_COMPILER_MSVC ) && ! defined( __clang__ ) @@ -165,5 +164,4 @@ GEN_API_C_BEGIN } #endif -GEN_API_C_END #pragma endregion Timing diff --git a/project/dependencies/timing.hpp b/project/dependencies/timing.hpp index d9ac5ca..e4b9575 100644 --- a/project/dependencies/timing.hpp +++ b/project/dependencies/timing.hpp @@ -5,8 +5,6 @@ #pragma region Timing -GEN_API_C_BEGIN - #ifdef GEN_BENCHMARK //! Return CPU timestamp. u64 read_cpu_time_stamp_counter( void ); @@ -18,6 +16,4 @@ f64 time_rel( void ); u64 time_rel_ms( void ); #endif -GEN_API_C_END - #pragma endregion Timing diff --git a/project/helpers/helper.hpp b/project/helpers/helper.hpp index 7eb15f9..09f8782 100644 --- a/project/helpers/helper.hpp +++ b/project/helpers/helper.hpp @@ -8,7 +8,7 @@ GEN_NS_END using namespace gen; -CodeBody gen_ecode( char const* path ) +CodeBody gen_ecode( char const* path, bool use_c_definition = false ) { char scratch_mem[kilobytes(1)]; Arena scratch = arena_init_from_memory( scratch_mem, sizeof(scratch_mem) ); @@ -31,14 +31,24 @@ CodeBody gen_ecode( char const* path ) string_append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", code, code ); } - CodeEnum enum_code = parse_enum(gen::token_fmt_impl((3 + 1) / 2, "entries", string_to_strc(enum_entries), - "enum CodeType_Def enum_underlying(u32) { CT_NumTypes };" - )); + CodeEnum enum_code; + if (use_c_definition) + { + enum_code = parse_enum(token_fmt_impl((3 + 1) / 2, "entries", string_to_strc(enum_entries), + "enum CodeType enum_underlying(u32) { CT_NumTypes };" + )); + } + else + { + enum_code = parse_enum(token_fmt_impl((3 + 1) / 2, "entries", string_to_strc(enum_entries), + "enum CodeType : u32 { CT_NumTypes };" + )); + } #pragma push_macro("local_persist") #undef local_persist StrC lookup_size = string_to_strc(string_fmt_buf(GlobalAllocator, "%d", array_num(enum_strs) )); - CodeFn to_str = parse_function( token_fmt( + CodeFn to_str = parse_function( token_fmt( "entries", string_to_strc(to_str_entries) , "num", lookup_size , stringize( @@ -57,12 +67,12 @@ CodeBody gen_ecode( char const* path ) //CodeNS nspace = def_namespace( name(ECode), def_namespace_body( args( enum_code, to_str ) ) ); //CodeUsing code_t = def_using( name(CodeT), def_type( name(ECode::Type) ) ); - CodeTypedef code_t = parse_typedef(code(typedef enum CodeType_Def CodeType; )); + CodeTypedef code_t = parse_typedef(code(typedef enum CodeType CodeType; )); return def_global_body( args( enum_code, code_t, to_str, fmt_newline ) ); } -CodeBody gen_eoperator( char const* path ) +CodeBody gen_eoperator( char const* path, bool use_c_definition = false ) { char scratch_mem[kilobytes(4)]; Arena scratch = arena_init_from_memory( scratch_mem, sizeof(scratch_mem) ); @@ -87,16 +97,30 @@ CodeBody gen_eoperator( char const* path ) string_append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str); } -#pragma push_macro("enum_underlying") -#undef enum_underlying - CodeEnum enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize( - enum Operator_Def enum_underlying(u32) - { - - NumOps - }; - ))); -#pragma pop_macro("enum_underlying") + CodeEnum enum_code; + if (use_c_definition) + { + #pragma push_macro("enum_underlying") + #undef enum_underlying + enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize( + enum Operator enum_underlying(u32) + { + + NumOps + }; + ))); + #pragma pop_macro("enum_underlying") + } + else + { + enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize( + enum Operator : u32 + { + + NumOps + }; + ))); + } #pragma push_macro("local_persist") #undef local_persist @@ -120,12 +144,12 @@ CodeBody gen_eoperator( char const* path ) //CodeNS nspace = def_namespace( name(EOperator), def_namespace_body( args( enum_code, to_str ) ) ); //CodeUsing operator_t = def_using( name(OperatorT), def_type( name(EOperator::Type) ) ); - CodeTypedef operator_t = parse_typedef(code( typedef enum Operator_Def Operator; )); + CodeTypedef operator_t = parse_typedef(code( typedef enum Operator Operator; )); return def_global_body( args( enum_code, operator_t, to_str, fmt_newline ) ); } -CodeBody gen_especifier( char const* path ) +CodeBody gen_especifier( char const* path, bool use_c_definition = false ) { char scratch_mem[kilobytes(4)]; Arena scratch = arena_init_from_memory( scratch_mem, sizeof(scratch_mem) ); @@ -150,16 +174,30 @@ CodeBody gen_especifier( char const* path ) string_append_fmt( & to_str_entries, "{ sizeof(\"%s\"), \"%s\" },\n", entry_to_str, entry_to_str); } -#pragma push_macro("enum_underlying") -#undef enum_underlying - CodeEnum enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize( - enum Specifier_Def enum_underlying(u32) - { - - Spec_NumSpecifiers - }; - ))); -#pragma pop_macro("enum_underlying") + CodeEnum enum_code; + if (use_c_definition) + { + #pragma push_macro("enum_underlying") + #undef enum_underlying + enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize( + enum Specifier enum_underlying(u32) + { + + Spec_NumSpecifiers + }; + ))); + #pragma pop_macro("enum_underlying") + } + else + { + enum_code = parse_enum(token_fmt("entries", string_to_strc(enum_entries), stringize( + enum Specifier : u32 + { + + Spec_NumSpecifiers + }; + ))); + } CodeFn is_trailing = parse_function(token_fmt("specifier", string_to_strc(to_str_entries), stringize( inline @@ -233,7 +271,7 @@ CodeBody gen_especifier( char const* path ) //CodeNS nspace = def_namespace( name(ESpecifier), def_namespace_body( args( enum_code, is_trailing, to_str, to_type ) ) ); //CodeUsing specifier_t = def_using( name(SpecifierT), def_type( name(ESpecifier::Type) ) ); - CodeTypedef specifier_t = parse_typedef( code(typedef enum Specifier_Def Specifier; )); + CodeTypedef specifier_t = parse_typedef( code(typedef enum Specifier Specifier; )); return def_global_body( args( enum_code, specifier_t, is_trailing, to_str, to_type, fmt_newline ) ); } @@ -384,7 +422,7 @@ CodeBody gen_ast_inlines() inline & ::operator =( Code other ) { - if ( other.ast && other->Parent ) + if ( other.ast != nullptr && other->Parent != nullptr ) { ast = rcast( decltype(ast), code_duplicate(other).ast); ast->Parent = { nullptr }; @@ -451,36 +489,39 @@ CodeBody gen_ast_inlines() CodeBody impl_code_using = parse_global_body( token_fmt( "typename", StrC name(CodeUsing), code_impl_tmpl )); CodeBody impl_code_var = parse_global_body( token_fmt( "typename", StrC name(CodeVar), code_impl_tmpl )); - append(impl_code_attr, parse_global_body( token_fmt( "typename", StrC name(Attributes), codetype_impl_tmpl ))); - append(impl_code_cmt, parse_global_body( token_fmt( "typename", StrC name(Comment), codetype_impl_tmpl ))); - append(impl_code_constr, parse_global_body( token_fmt( "typename", StrC name(Constructor), codetype_impl_tmpl ))); - append(impl_code_define, parse_global_body( token_fmt( "typename", StrC name(Define), codetype_impl_tmpl ))); - append(impl_code_destruct, parse_global_body( token_fmt( "typename", StrC name(Destructor), codetype_impl_tmpl ))); - append(impl_code_enum, parse_global_body( token_fmt( "typename", StrC name(Enum), codetype_impl_tmpl ))); - append(impl_code_exec, parse_global_body( token_fmt( "typename", StrC name(Exec), codetype_impl_tmpl ))); - append(impl_code_extern, parse_global_body( token_fmt( "typename", StrC name(Extern), codetype_impl_tmpl ))); - append(impl_code_include, parse_global_body( token_fmt( "typename", StrC name(Include), codetype_impl_tmpl ))); - append(impl_code_friend, parse_global_body( token_fmt( "typename", StrC name(Friend), codetype_impl_tmpl ))); - append(impl_code_fn, parse_global_body( token_fmt( "typename", StrC name(Fn), codetype_impl_tmpl ))); - append(impl_code_module, parse_global_body( token_fmt( "typename", StrC name(Module), codetype_impl_tmpl ))); - append(impl_code_ns, parse_global_body( token_fmt( "typename", StrC name(NS), codetype_impl_tmpl ))); - append(impl_code_op, parse_global_body( token_fmt( "typename", StrC name(Operator), codetype_impl_tmpl ))); - append(impl_code_opcast, parse_global_body( token_fmt( "typename", StrC name(OpCast), codetype_impl_tmpl ))); - append(impl_code_pragma, parse_global_body( token_fmt( "typename", StrC name(Pragma), codetype_impl_tmpl ))); - append(impl_code_precond, parse_global_body( token_fmt( "typename", StrC name(PreprocessCond), codetype_impl_tmpl ))); - append(impl_code_tmpl, parse_global_body( token_fmt( "typename", StrC name(Template), codetype_impl_tmpl ))); - append(impl_code_type, parse_global_body( token_fmt( "typename", StrC name(Typename), codetype_impl_tmpl ))); - append(impl_code_typedef, parse_global_body( token_fmt( "typename", StrC name(Typedef), codetype_impl_tmpl ))); - append(impl_code_union, parse_global_body( token_fmt( "typename", StrC name(Union), codetype_impl_tmpl ))); - append(impl_code_using, parse_global_body( token_fmt( "typename", StrC name(Using), codetype_impl_tmpl ))); - append(impl_code_var, parse_global_body( token_fmt( "typename", StrC name(Var), codetype_impl_tmpl ))); + body_append(impl_code_attr, parse_global_body( token_fmt( "typename", StrC name(Attributes), codetype_impl_tmpl ))); + body_append(impl_code_cmt, parse_global_body( token_fmt( "typename", StrC name(Comment), codetype_impl_tmpl ))); + body_append(impl_code_constr, parse_global_body( token_fmt( "typename", StrC name(Constructor), codetype_impl_tmpl ))); + body_append(impl_code_define, parse_global_body( token_fmt( "typename", StrC name(Define), codetype_impl_tmpl ))); + body_append(impl_code_destruct, parse_global_body( token_fmt( "typename", StrC name(Destructor), codetype_impl_tmpl ))); + body_append(impl_code_enum, parse_global_body( token_fmt( "typename", StrC name(Enum), codetype_impl_tmpl ))); + body_append(impl_code_exec, parse_global_body( token_fmt( "typename", StrC name(Exec), codetype_impl_tmpl ))); + body_append(impl_code_extern, parse_global_body( token_fmt( "typename", StrC name(Extern), codetype_impl_tmpl ))); + body_append(impl_code_include, parse_global_body( token_fmt( "typename", StrC name(Include), codetype_impl_tmpl ))); + body_append(impl_code_friend, parse_global_body( token_fmt( "typename", StrC name(Friend), codetype_impl_tmpl ))); + body_append(impl_code_fn, parse_global_body( token_fmt( "typename", StrC name(Fn), codetype_impl_tmpl ))); + body_append(impl_code_module, parse_global_body( token_fmt( "typename", StrC name(Module), codetype_impl_tmpl ))); + body_append(impl_code_ns, parse_global_body( token_fmt( "typename", StrC name(NS), codetype_impl_tmpl ))); + body_append(impl_code_op, parse_global_body( token_fmt( "typename", StrC name(Operator), codetype_impl_tmpl ))); + body_append(impl_code_opcast, parse_global_body( token_fmt( "typename", StrC name(OpCast), codetype_impl_tmpl ))); + body_append(impl_code_pragma, parse_global_body( token_fmt( "typename", StrC name(Pragma), codetype_impl_tmpl ))); + body_append(impl_code_precond, parse_global_body( token_fmt( "typename", StrC name(PreprocessCond), codetype_impl_tmpl ))); + body_append(impl_code_tmpl, parse_global_body( token_fmt( "typename", StrC name(Template), codetype_impl_tmpl ))); + body_append(impl_code_type, parse_global_body( token_fmt( "typename", StrC name(Typename), codetype_impl_tmpl ))); + body_append(impl_code_typedef, parse_global_body( token_fmt( "typename", StrC name(Typedef), codetype_impl_tmpl ))); + body_append(impl_code_union, parse_global_body( token_fmt( "typename", StrC name(Union), codetype_impl_tmpl ))); + body_append(impl_code_using, parse_global_body( token_fmt( "typename", StrC name(Using), codetype_impl_tmpl ))); + body_append(impl_code_var, parse_global_body( token_fmt( "typename", StrC name(Var), codetype_impl_tmpl ))); + #pragma push_macro("forceinline") + #undef forceinline char const* cast_tmpl = stringize( - inline Code::operator Code() const + forceinline Code::operator Code() const { return { (AST_*) ast }; } ); + #pragma pop_macro("forceinline") CodeBody impl_cast_body = parse_global_body( token_fmt( "typename", StrC name(Body), cast_tmpl )); CodeBody impl_cast_attribute = parse_global_body( token_fmt( "typename", StrC name(Attributes), cast_tmpl )); @@ -547,6 +588,7 @@ CodeBody gen_ast_inlines() def_pragma( txt("endregion generated code inline implementation")), fmt_newline, def_pragma( txt("region generated AST/Code cast implementation")), + untyped_str(txt("GEN_OPTIMIZE_MAPPINGS_BEGIN\n")), fmt_newline, impl_cast_body, impl_cast_attribute, @@ -577,6 +619,7 @@ CodeBody gen_ast_inlines() impl_cast_using, impl_cast_var, fmt_newline, + untyped_str(txt("GEN_OPITMIZE_MAPPINGS_END\n")), def_pragma( txt("endregion generated AST/Code cast implementation")), fmt_newline )); diff --git a/scripts/build.ci.ps1 b/scripts/build.ci.ps1 index 0a1935d..a471ceb 100644 --- a/scripts/build.ci.ps1 +++ b/scripts/build.ci.ps1 @@ -9,8 +9,6 @@ $refactor_unreal = Join-Path $PSScriptRoot 'refactor_unreal.ps1' $incremental_checks = Join-Path $PSScriptRoot 'helpers/incremental_checks.ps1' $vendor_toolchain = Join-Path $PSScriptRoot 'helpers/vendor_toolchain.ps1' -Import-Module $target_arch - function Get-ScriptRepoRoot { $currentPath = $PSScriptRoot while ($currentPath -ne $null -and $currentPath -ne "") @@ -33,7 +31,7 @@ function Get-ScriptRepoRoot { } $path_root = Get-ScriptRepoRoot -Import-Module $target_arch +# Import-Module $target_arch Import-Module $format_cpp Push-Location $path_root diff --git a/scripts/helpers/vendor_toolchain.ps1 b/scripts/helpers/vendor_toolchain.ps1 index 75ceeef..133597c 100644 --- a/scripts/helpers/vendor_toolchain.ps1 +++ b/scripts/helpers/vendor_toolchain.ps1 @@ -188,7 +188,7 @@ if ( $vendor -match "clang" ) # $compiler_args += $flag_time_trace } if ( $optimize ) { - $compiler_args += $flag_optimize_fast + $compiler_args += $flag_optimize_size } else { $compiler_args += $flag_no_optimization @@ -268,7 +268,7 @@ if ( $vendor -match "clang" ) # $compiler_args += $flag_time_trace } if ( $optimize ) { - $compiler_args += $flag_optimize_fast + $compiler_args += $flag_optimize_size } else { $compiler_args += $flag_no_optimization @@ -316,48 +316,50 @@ if ( $vendor -match "clang" ) if ( $vendor -match "msvc" ) { # https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=msvc-170 - $flag_all_c = '/TC' - $flag_all_cpp = '/TP' - $flag_compile = '/c' - $flag_debug = '/Zi' - $flag_define = '/D' - $flag_exceptions_disabled = '/EHsc-' - $flag_RTTI_disabled = '/GR-' - $flag_include = '/I' - $flag_full_src_path = '/FC' - $flag_nologo = '/nologo' - $flag_dll = '/LD' - $flag_dll_debug = '/LDd' - $flag_linker = '/link' - $flag_link_dll = '/DLL' - $flag_link_no_incremental = '/INCREMENTAL:NO' - $flag_link_mapfile = '/MAP:' - $flag_link_optimize_references = '/OPT:REF' - $flag_link_win_debug = '/DEBUG' - $flag_link_win_pdb = '/PDB:' - $flag_link_win_machine_32 = '/MACHINE:X86' - $flag_link_win_machine_64 = '/MACHINE:X64' - $flag_link_win_path_output = '/OUT:' - $flag_link_win_rt_dll = '/MD' - $flag_link_win_rt_dll_debug = '/MDd' - $flag_link_win_rt_static = '/MT' - $flag_link_win_rt_static_debug = '/MTd' - $flag_link_win_subsystem_console = '/SUBSYSTEM:CONSOLE' - $flag_link_win_subsystem_windows = '/SUBSYSTEM:WINDOWS' - $flag_no_optimization = '/Od' - $flag_optimize_fast = '/O2' - $flag_optimize_size = '/O1' - $flag_optimize_intrinsics = '/Oi' - $flag_optimized_debug = '/Zo' - $flag_out_name = '/OUT:' - $flag_path_interm = '/Fo' - $flag_path_debug = '/Fd' - $flag_path_output = '/Fe' - $flag_preprocess_conform = '/Zc:preprocessor' - $flag_set_stack_size = '/F' - $flag_syntax_only = '/Zs' - $flag_wall = '/Wall' - $flag_warnings_as_errors = '/WX' + $flag_all_c = '/TC' + $flag_all_cpp = '/TP' + $flag_compile = '/c' + $flag_debug = '/Zi' + $flag_define = '/D' + $flag_exceptions_disabled = '/EHsc-' + $flag_RTTI_disabled = '/GR-' + $flag_include = '/I' + $flag_full_src_path = '/FC' + $flag_nologo = '/nologo' + $flag_dll = '/LD' + $flag_dll_debug = '/LDd' + $flag_linker = '/link' + $flag_link_dll = '/DLL' + $flag_link_no_incremental = '/INCREMENTAL:NO' + $flag_link_mapfile = '/MAP:' + $flag_link_optimize_references = '/OPT:REF' + $flag_link_win_debug = '/DEBUG' + $flag_link_win_pdb = '/PDB:' + $flag_link_win_machine_32 = '/MACHINE:X86' + $flag_link_win_machine_64 = '/MACHINE:X64' + $flag_link_win_path_output = '/OUT:' + $flag_link_win_rt_dll = '/MD' + $flag_link_win_rt_dll_debug = '/MDd' + $flag_link_win_rt_static = '/MT' + $flag_link_win_rt_static_debug = '/MTd' + $flag_link_win_subsystem_console = '/SUBSYSTEM:CONSOLE' + $flag_link_win_subsystem_windows = '/SUBSYSTEM:WINDOWS' + $flag_no_optimization = '/Od' + $flag_optimize_fast = '/O2' + $flag_optimize_size = '/O1' + $flag_optimize_intrinsics = '/Oi' + $flag_optimized_debug_forceinline = '/d2Obforceinline' + $flag_optimized_debug = '/Zo' + $flag_ + $flag_out_name = '/OUT:' + $flag_path_interm = '/Fo' + $flag_path_debug = '/Fd' + $flag_path_output = '/Fe' + $flag_preprocess_conform = '/Zc:preprocessor' + $flag_set_stack_size = '/F' + $flag_syntax_only = '/Zs' + $flag_wall = '/Wall' + $flag_warnings_as_errors = '/WX' function build { @@ -388,7 +390,7 @@ if ( $vendor -match "msvc" ) } if ( $optimize ) { - $compiler_args += $flag_optimize_fast + $compiler_args += $flag_optimize_size } else { $compiler_args += $flag_no_optimization @@ -403,6 +405,7 @@ if ( $vendor -match "msvc" ) if ( $optimize ) { $compiler_args += $flag_optimized_debug + $compiler_args += $flag_optimized_debug_forceinline } } else { @@ -474,7 +477,7 @@ if ( $vendor -match "msvc" ) } if ( $optimize ) { - $compiler_args += $flag_optimize_fast + $compiler_args += $flag_optimize_size } else { $compiler_args += $flag_no_optimization