c-next 0.1.70 → 0.1.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/__tests__/parseCHeader.mocked.test.ts +69 -54
- package/src/lib/parseCHeader.ts +56 -23
- package/src/lib/parseWithSymbols.ts +195 -53
- package/src/transpiler/Transpiler.ts +180 -63
- package/src/transpiler/logic/analysis/FunctionCallAnalyzer.ts +1 -2
- package/src/transpiler/logic/analysis/InitializationAnalyzer.ts +1 -2
- package/src/transpiler/logic/analysis/PassByValueAnalyzer.ts +51 -2
- package/src/transpiler/logic/analysis/__tests__/FunctionCallAnalyzer.test.ts +18 -12
- package/src/transpiler/logic/analysis/__tests__/InitializationAnalyzer.test.ts +9 -9
- package/src/transpiler/logic/analysis/__tests__/runAnalyzers.test.ts +5 -5
- package/src/transpiler/logic/symbols/SymbolTable.ts +729 -265
- package/src/transpiler/logic/symbols/SymbolUtils.ts +2 -2
- package/src/transpiler/logic/symbols/__tests__/SymbolTable.test.ts +415 -751
- package/src/transpiler/logic/symbols/c/__tests__/CResolver.integration.test.ts +573 -0
- package/src/transpiler/logic/symbols/c/__tests__/testHelpers.ts +20 -0
- package/src/transpiler/logic/symbols/c/collectors/EnumCollector.ts +82 -0
- package/src/transpiler/logic/symbols/c/collectors/FunctionCollector.ts +106 -0
- package/src/transpiler/logic/symbols/c/collectors/StructCollector.ts +173 -0
- package/src/transpiler/logic/symbols/c/collectors/TypedefCollector.ts +35 -0
- package/src/transpiler/logic/symbols/c/collectors/VariableCollector.ts +80 -0
- package/src/transpiler/logic/symbols/c/index.ts +333 -0
- package/src/transpiler/logic/symbols/c/utils/DeclaratorUtils.ts +269 -0
- package/src/transpiler/logic/symbols/cnext/__tests__/BitmapCollector.test.ts +50 -11
- package/src/transpiler/logic/symbols/cnext/__tests__/CNextResolver.integration.test.ts +45 -34
- package/src/transpiler/logic/symbols/cnext/__tests__/EnumCollector.test.ts +30 -13
- package/src/transpiler/logic/symbols/cnext/__tests__/FunctionCollector.test.ts +279 -64
- package/src/transpiler/logic/symbols/cnext/__tests__/RegisterCollector.test.ts +60 -13
- package/src/transpiler/logic/symbols/cnext/__tests__/ScopeCollector.test.ts +40 -37
- package/src/transpiler/logic/symbols/cnext/__tests__/StructCollector.test.ts +131 -45
- package/src/transpiler/logic/symbols/cnext/__tests__/TSymbolInfoAdapter.test.ts +223 -139
- package/src/transpiler/logic/symbols/cnext/__tests__/VariableCollector.test.ts +79 -25
- package/src/transpiler/logic/symbols/cnext/__tests__/testUtils.ts +53 -0
- package/src/transpiler/logic/symbols/cnext/adapters/TSymbolInfoAdapter.ts +83 -43
- package/src/transpiler/logic/symbols/cnext/collectors/BitmapCollector.ts +14 -13
- package/src/transpiler/logic/symbols/cnext/collectors/EnumCollector.ts +11 -10
- package/src/transpiler/logic/symbols/cnext/collectors/FunctionCollector.ts +83 -34
- package/src/transpiler/logic/symbols/cnext/collectors/RegisterCollector.ts +22 -18
- package/src/transpiler/logic/symbols/cnext/collectors/ScopeCollector.ts +53 -35
- package/src/transpiler/logic/symbols/cnext/collectors/StructCollector.ts +30 -23
- package/src/transpiler/logic/symbols/cnext/collectors/VariableCollector.ts +18 -19
- package/src/transpiler/logic/symbols/cnext/index.ts +36 -14
- package/src/transpiler/logic/symbols/cnext/types/IScopeCollectorResult.ts +2 -2
- package/src/transpiler/logic/symbols/cnext/utils/SymbolNameUtils.ts +27 -0
- package/src/transpiler/logic/symbols/cpp/__tests__/CppResolver.integration.test.ts +270 -0
- package/src/transpiler/logic/symbols/cpp/__tests__/testHelpers.ts +20 -0
- package/src/transpiler/logic/symbols/cpp/collectors/ClassCollector.ts +317 -0
- package/src/transpiler/logic/symbols/cpp/collectors/EnumCollector.ts +71 -0
- package/src/transpiler/logic/symbols/cpp/collectors/FunctionCollector.ts +155 -0
- package/src/transpiler/logic/symbols/cpp/collectors/NamespaceCollector.ts +65 -0
- package/src/transpiler/logic/symbols/cpp/collectors/TypeAliasCollector.ts +46 -0
- package/src/transpiler/logic/symbols/cpp/collectors/VariableCollector.ts +54 -0
- package/src/transpiler/logic/symbols/cpp/index.ts +366 -0
- package/src/transpiler/logic/symbols/cpp/utils/DeclaratorUtils.ts +248 -0
- package/src/transpiler/logic/symbols/shared/IExtractedParameter.ts +18 -0
- package/src/transpiler/logic/symbols/shared/ParameterExtractorUtils.ts +73 -0
- package/src/transpiler/output/codegen/CodeGenerator.ts +268 -1674
- package/src/transpiler/output/codegen/__tests__/CodeGenerator.test.ts +7 -1
- package/src/transpiler/output/codegen/assignment/AssignmentClassifier.ts +2 -1
- package/src/transpiler/output/codegen/assignment/handlers/AssignmentHandlerUtils.ts +7 -1
- package/src/transpiler/output/codegen/assignment/handlers/BitmapHandlers.ts +6 -2
- package/src/transpiler/output/codegen/assignment/handlers/RegisterHandlers.ts +2 -1
- package/src/transpiler/output/codegen/generators/declarationGenerators/ScopeGenerator.ts +21 -8
- package/src/transpiler/output/codegen/generators/declarationGenerators/ScopedRegisterGenerator.ts +3 -2
- package/src/transpiler/output/codegen/generators/expressions/CallExprUtils.ts +9 -3
- package/src/transpiler/output/codegen/generators/expressions/__tests__/CallExprGenerator.test.ts +3 -4
- package/src/transpiler/output/codegen/generators/expressions/__tests__/CallExprUtils.test.ts +4 -8
- package/src/transpiler/output/codegen/helpers/ArgumentGenerator.ts +236 -0
- package/src/transpiler/output/codegen/helpers/CppConstructorHelper.ts +3 -3
- package/src/transpiler/output/codegen/helpers/FunctionContextManager.ts +435 -0
- package/src/transpiler/output/codegen/helpers/StringOperationsHelper.ts +203 -0
- package/src/transpiler/output/codegen/helpers/SymbolLookupHelper.ts +8 -12
- package/src/transpiler/output/codegen/helpers/TypeRegistrationEngine.ts +520 -0
- package/src/transpiler/output/codegen/helpers/VariableDeclHelper.ts +735 -0
- package/src/transpiler/output/codegen/helpers/VariableDeclarationFormatter.ts +1 -1
- package/src/transpiler/output/codegen/helpers/__tests__/ArgumentGenerator.test.ts +521 -0
- package/src/transpiler/output/codegen/helpers/__tests__/CppConstructorHelper.test.ts +4 -5
- package/src/transpiler/output/codegen/helpers/__tests__/FunctionContextManager.test.ts +983 -0
- package/src/transpiler/output/codegen/helpers/__tests__/StringOperationsHelper.test.ts +269 -0
- package/src/transpiler/output/codegen/helpers/__tests__/SymbolLookupHelper.test.ts +31 -32
- package/src/transpiler/output/codegen/helpers/__tests__/TypeRegistrationEngine.test.ts +186 -0
- package/src/transpiler/output/codegen/helpers/__tests__/VariableDeclHelper.test.ts +460 -0
- package/src/transpiler/output/codegen/helpers/types/IArgumentGeneratorCallbacks.ts +32 -0
- package/src/transpiler/output/codegen/resolution/EnumTypeResolver.ts +5 -1
- package/src/transpiler/output/codegen/types/IFunctionContextCallbacks.ts +12 -0
- package/src/transpiler/output/codegen/types/IVariableFormatInput.ts +1 -1
- package/src/transpiler/output/codegen/utils/QualifiedNameGenerator.ts +114 -0
- package/src/transpiler/output/codegen/utils/__tests__/QualifiedNameGenerator.test.ts +183 -0
- package/src/transpiler/output/headers/BaseHeaderGenerator.ts +4 -4
- package/src/transpiler/output/headers/ExternalTypeHeaderBuilder.ts +7 -7
- package/src/transpiler/output/headers/HeaderGenerator.ts +9 -7
- package/src/transpiler/output/headers/HeaderGeneratorUtils.ts +19 -20
- package/src/transpiler/output/headers/__tests__/BaseHeaderGenerator.test.ts +15 -18
- package/src/transpiler/output/headers/__tests__/CHeaderGenerator.test.ts +63 -64
- package/src/transpiler/output/headers/__tests__/CppHeaderGenerator.test.ts +36 -32
- package/src/transpiler/output/headers/__tests__/ExternalTypeHeaderBuilder.test.ts +26 -26
- package/src/transpiler/output/headers/__tests__/HeaderGenerator.test.ts +87 -59
- package/src/transpiler/output/headers/__tests__/HeaderGeneratorUtils.test.ts +57 -58
- package/src/transpiler/output/headers/adapters/HeaderSymbolAdapter.ts +222 -0
- package/src/transpiler/output/headers/adapters/__tests__/HeaderSymbolAdapter.test.ts +538 -0
- package/src/transpiler/output/headers/types/IGroupedSymbols.ts +8 -8
- package/src/transpiler/output/headers/types/IHeaderSymbol.ts +62 -0
- package/src/transpiler/state/CodeGenState.ts +20 -33
- package/src/transpiler/state/SymbolRegistry.ts +181 -0
- package/src/transpiler/{types → state}/TranspilerState.ts +1 -1
- package/src/transpiler/state/__tests__/CodeGenState.test.ts +67 -59
- package/src/transpiler/state/__tests__/SymbolRegistry.test.ts +249 -0
- package/src/transpiler/{types → state}/__tests__/TranspilerState.test.ts +1 -1
- package/src/transpiler/types/ICachedFileEntry.ts +1 -1
- package/src/transpiler/types/IConflict.ts +14 -0
- package/src/transpiler/types/IPipelineInput.ts +0 -3
- package/src/transpiler/types/ISerializedSymbol.ts +11 -0
- package/src/transpiler/types/TPrimitiveKind.ts +20 -0
- package/src/transpiler/types/TType.ts +103 -0
- package/src/transpiler/types/TVisibility.ts +6 -0
- package/src/transpiler/types/symbol-kinds/TSymbolKind.ts +10 -0
- package/src/transpiler/types/symbol-kinds/TSymbolKindC.ts +12 -0
- package/src/transpiler/types/symbol-kinds/TSymbolKindCNext.ts +16 -0
- package/src/transpiler/types/symbol-kinds/TSymbolKindCpp.ts +14 -0
- package/src/transpiler/types/symbols/IBaseSymbol.ts +31 -0
- package/src/transpiler/{logic/symbols/types → types/symbols}/IBitmapFieldInfo.ts +2 -2
- package/src/transpiler/types/symbols/IBitmapSymbol.ts +21 -0
- package/src/transpiler/{logic/symbols/types → types/symbols}/IEnumSymbol.ts +5 -6
- package/src/transpiler/types/symbols/IFieldInfo.ts +26 -0
- package/src/transpiler/types/symbols/IFunctionSymbol.ts +30 -0
- package/src/transpiler/types/symbols/IParameterInfo.ts +26 -0
- package/src/transpiler/{logic/symbols/types → types/symbols}/IRegisterMemberInfo.ts +4 -4
- package/src/transpiler/types/symbols/IRegisterSymbol.ts +18 -0
- package/src/transpiler/types/symbols/IScopeSymbol.ts +32 -0
- package/src/transpiler/{logic/symbols/types → types/symbols}/IStructFieldInfo.ts +2 -1
- package/src/transpiler/types/symbols/IStructSymbol.ts +15 -0
- package/src/transpiler/types/symbols/IVariableSymbol.ts +30 -0
- package/src/transpiler/types/symbols/SymbolGuards.ts +43 -0
- package/src/transpiler/types/symbols/TAnySymbol.ts +22 -0
- package/src/transpiler/types/symbols/TSymbol.ts +32 -0
- package/src/transpiler/types/symbols/__tests__/IBaseSymbol.test.ts +56 -0
- package/src/transpiler/types/symbols/__tests__/SymbolGuards.test.ts +57 -0
- package/src/transpiler/types/symbols/c/ICBaseSymbol.ts +28 -0
- package/src/transpiler/types/symbols/c/ICEnumMemberSymbol.ts +17 -0
- package/src/transpiler/types/symbols/c/ICEnumSymbol.ts +17 -0
- package/src/transpiler/types/symbols/c/ICFieldInfo.ts +16 -0
- package/src/transpiler/types/symbols/c/ICFunctionSymbol.ts +21 -0
- package/src/transpiler/types/symbols/c/ICParameterInfo.ts +19 -0
- package/src/transpiler/types/symbols/c/ICStructSymbol.ts +21 -0
- package/src/transpiler/types/symbols/c/ICTypedefSymbol.ts +14 -0
- package/src/transpiler/types/symbols/c/ICVariableSymbol.ts +26 -0
- package/src/transpiler/types/symbols/c/TCSymbol.ts +26 -0
- package/src/transpiler/types/symbols/cpp/ICppBaseSymbol.ts +31 -0
- package/src/transpiler/types/symbols/cpp/ICppClassSymbol.ts +15 -0
- package/src/transpiler/types/symbols/cpp/ICppEnumMemberSymbol.ts +14 -0
- package/src/transpiler/types/symbols/cpp/ICppEnumSymbol.ts +14 -0
- package/src/transpiler/types/symbols/cpp/ICppFieldInfo.ts +16 -0
- package/src/transpiler/types/symbols/cpp/ICppFunctionSymbol.ts +21 -0
- package/src/transpiler/types/symbols/cpp/ICppNamespaceSymbol.ts +11 -0
- package/src/transpiler/types/symbols/cpp/ICppParameterInfo.ts +19 -0
- package/src/transpiler/types/symbols/cpp/ICppStructSymbol.ts +16 -0
- package/src/transpiler/types/symbols/cpp/ICppTypeAliasSymbol.ts +14 -0
- package/src/transpiler/types/symbols/cpp/ICppVariableSymbol.ts +23 -0
- package/src/transpiler/types/symbols/cpp/TCppSymbol.ts +30 -0
- package/src/utils/CppNamespaceUtils.ts +3 -4
- package/src/utils/FunctionUtils.ts +92 -0
- package/src/utils/ParameterUtils.ts +55 -0
- package/src/utils/PrimitiveKindUtils.ts +33 -0
- package/src/utils/ScopeUtils.ts +105 -0
- package/src/utils/TTypeUtils.ts +159 -0
- package/src/utils/TypeResolver.ts +132 -0
- package/src/utils/__tests__/CppNamespaceUtils.test.ts +92 -99
- package/src/utils/__tests__/FunctionUtils.test.ts +284 -0
- package/src/utils/__tests__/ParameterUtils.test.ts +174 -0
- package/src/utils/__tests__/PrimitiveKindUtils.test.ts +59 -0
- package/src/utils/__tests__/ScopeUtils.test.ts +53 -0
- package/src/utils/__tests__/TTypeUtils.test.ts +245 -0
- package/src/utils/__tests__/TypeResolver.test.ts +332 -0
- package/src/utils/cache/CacheManager.ts +91 -50
- package/src/utils/cache/__tests__/CacheManager.test.ts +180 -114
- package/src/transpiler/logic/symbols/AutoConstUpdater.ts +0 -93
- package/src/transpiler/logic/symbols/CSymbolCollector.ts +0 -648
- package/src/transpiler/logic/symbols/CppSymbolCollector.ts +0 -874
- package/src/transpiler/logic/symbols/SymbolCollectorContext.ts +0 -68
- package/src/transpiler/logic/symbols/__tests__/AutoConstUpdater.test.ts +0 -418
- package/src/transpiler/logic/symbols/__tests__/CSymbolCollector.test.ts +0 -685
- package/src/transpiler/logic/symbols/__tests__/CppSymbolCollector.test.ts +0 -1146
- package/src/transpiler/logic/symbols/__tests__/SymbolCollectorContext.test.ts +0 -290
- package/src/transpiler/logic/symbols/__tests__/cTestHelpers.ts +0 -43
- package/src/transpiler/logic/symbols/__tests__/cppTestHelpers.ts +0 -40
- package/src/transpiler/logic/symbols/cnext/__tests__/TSymbolAdapter.test.ts +0 -595
- package/src/transpiler/logic/symbols/cnext/adapters/TSymbolAdapter.ts +0 -345
- package/src/transpiler/logic/symbols/types/IBaseSymbol.ts +0 -27
- package/src/transpiler/logic/symbols/types/IBitmapSymbol.ts +0 -23
- package/src/transpiler/logic/symbols/types/ICollectorContext.ts +0 -19
- package/src/transpiler/logic/symbols/types/IConflict.ts +0 -20
- package/src/transpiler/logic/symbols/types/IFieldInfo.ts +0 -18
- package/src/transpiler/logic/symbols/types/IFunctionSymbol.ts +0 -25
- package/src/transpiler/logic/symbols/types/IParameterInfo.ts +0 -24
- package/src/transpiler/logic/symbols/types/IRegisterSymbol.ts +0 -20
- package/src/transpiler/logic/symbols/types/IScopeSymbol.ts +0 -19
- package/src/transpiler/logic/symbols/types/IStructSymbol.ts +0 -16
- package/src/transpiler/logic/symbols/types/IVariableSymbol.ts +0 -30
- package/src/transpiler/logic/symbols/types/TSymbol.ts +0 -36
- package/src/transpiler/logic/symbols/types/__tests__/SymbolGuards.test.ts +0 -244
- package/src/transpiler/logic/symbols/types/typeGuards.ts +0 -44
- package/src/utils/types/ESymbolKind.ts +0 -19
- package/src/utils/types/ISymbol.ts +0 -64
- /package/src/transpiler/{types → constants}/BITMAP_BACKING_TYPE.ts +0 -0
- /package/src/transpiler/{types → constants}/BITMAP_SIZE.ts +0 -0
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
interface IRegisterMemberInfo {
|
|
6
6
|
/** Offset from base address (as string to support expressions like "0x04") */
|
|
7
|
-
offset: string;
|
|
7
|
+
readonly offset: string;
|
|
8
8
|
|
|
9
9
|
/** C type for the register (e.g., "uint32_t") */
|
|
10
|
-
cType: string;
|
|
10
|
+
readonly cType: string;
|
|
11
11
|
|
|
12
12
|
/** Access mode for the register */
|
|
13
|
-
access: "rw" | "ro" | "wo" | "w1c" | "w1s";
|
|
13
|
+
readonly access: "rw" | "ro" | "wo" | "w1c" | "w1s";
|
|
14
14
|
|
|
15
15
|
/** Optional bitmap type for structured bit access */
|
|
16
|
-
bitmapType?: string;
|
|
16
|
+
readonly bitmapType?: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export default IRegisterMemberInfo;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type IBaseSymbol from "./IBaseSymbol";
|
|
2
|
+
import type IRegisterMemberInfo from "./IRegisterMemberInfo";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Symbol representing a register block definition.
|
|
6
|
+
*/
|
|
7
|
+
interface IRegisterSymbol extends IBaseSymbol {
|
|
8
|
+
/** Discriminator narrowed to "register" */
|
|
9
|
+
readonly kind: "register";
|
|
10
|
+
|
|
11
|
+
/** Base address expression (as string, e.g., "0x40000000") */
|
|
12
|
+
readonly baseAddress: string;
|
|
13
|
+
|
|
14
|
+
/** Map of member name to register member metadata */
|
|
15
|
+
readonly members: ReadonlyMap<string, IRegisterMemberInfo>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default IRegisterSymbol;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type IBaseSymbol from "./IBaseSymbol";
|
|
2
|
+
import type IFunctionSymbol from "./IFunctionSymbol";
|
|
3
|
+
import type TVisibility from "../TVisibility";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Symbol representing a scope (namespace) definition.
|
|
7
|
+
* Scopes group related functions and variables.
|
|
8
|
+
*
|
|
9
|
+
* Note: IScopeSymbol has circular references with IFunctionSymbol.
|
|
10
|
+
* Functions have a scope, scopes contain functions.
|
|
11
|
+
*/
|
|
12
|
+
interface IScopeSymbol extends IBaseSymbol {
|
|
13
|
+
/** Discriminator narrowed to "scope" */
|
|
14
|
+
readonly kind: "scope";
|
|
15
|
+
|
|
16
|
+
/** Parent scope (global scope's parent is itself) */
|
|
17
|
+
readonly parent: IScopeSymbol;
|
|
18
|
+
|
|
19
|
+
/** List of member names (local names, not mangled) */
|
|
20
|
+
readonly members: string[];
|
|
21
|
+
|
|
22
|
+
/** Functions in this scope */
|
|
23
|
+
readonly functions: IFunctionSymbol[];
|
|
24
|
+
|
|
25
|
+
/** Variables in this scope */
|
|
26
|
+
readonly variables: unknown[];
|
|
27
|
+
|
|
28
|
+
/** Visibility of each member */
|
|
29
|
+
readonly memberVisibility: ReadonlyMap<string, TVisibility>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default IScopeSymbol;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type IBaseSymbol from "./IBaseSymbol";
|
|
2
|
+
import type IFieldInfo from "./IFieldInfo";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Symbol representing a struct type definition.
|
|
6
|
+
*/
|
|
7
|
+
interface IStructSymbol extends IBaseSymbol {
|
|
8
|
+
/** Discriminator narrowed to "struct" */
|
|
9
|
+
readonly kind: "struct";
|
|
10
|
+
|
|
11
|
+
/** Map of field name to field metadata */
|
|
12
|
+
readonly fields: ReadonlyMap<string, IFieldInfo>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default IStructSymbol;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type IBaseSymbol from "./IBaseSymbol";
|
|
2
|
+
import type TType from "../TType";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Symbol representing a variable (global, static, or extern).
|
|
6
|
+
*/
|
|
7
|
+
interface IVariableSymbol extends IBaseSymbol {
|
|
8
|
+
/** Discriminator narrowed to "variable" */
|
|
9
|
+
readonly kind: "variable";
|
|
10
|
+
|
|
11
|
+
/** Variable type */
|
|
12
|
+
readonly type: TType;
|
|
13
|
+
|
|
14
|
+
/** Whether this variable is const */
|
|
15
|
+
readonly isConst: boolean;
|
|
16
|
+
|
|
17
|
+
/** Whether this variable is atomic (volatile in C) */
|
|
18
|
+
readonly isAtomic: boolean;
|
|
19
|
+
|
|
20
|
+
/** Whether this variable is an array */
|
|
21
|
+
readonly isArray: boolean;
|
|
22
|
+
|
|
23
|
+
/** Array dimensions if isArray is true - numbers for resolved, strings for macros */
|
|
24
|
+
readonly arrayDimensions?: ReadonlyArray<number | string>;
|
|
25
|
+
|
|
26
|
+
/** Initial value expression (as string) */
|
|
27
|
+
readonly initialValue?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default IVariableSymbol;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type TSymbol from "./TSymbol";
|
|
2
|
+
import type IFunctionSymbol from "./IFunctionSymbol";
|
|
3
|
+
import type IScopeSymbol from "./IScopeSymbol";
|
|
4
|
+
import type IStructSymbol from "./IStructSymbol";
|
|
5
|
+
import type IEnumSymbol from "./IEnumSymbol";
|
|
6
|
+
import type IVariableSymbol from "./IVariableSymbol";
|
|
7
|
+
import type IBitmapSymbol from "./IBitmapSymbol";
|
|
8
|
+
import type IRegisterSymbol from "./IRegisterSymbol";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Type guard functions for TSymbol discriminated union.
|
|
12
|
+
*/
|
|
13
|
+
class SymbolGuards {
|
|
14
|
+
static isFunction(symbol: TSymbol): symbol is IFunctionSymbol {
|
|
15
|
+
return symbol.kind === "function";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static isScope(symbol: TSymbol): symbol is IScopeSymbol {
|
|
19
|
+
return symbol.kind === "scope";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static isStruct(symbol: TSymbol): symbol is IStructSymbol {
|
|
23
|
+
return symbol.kind === "struct";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static isEnum(symbol: TSymbol): symbol is IEnumSymbol {
|
|
27
|
+
return symbol.kind === "enum";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static isVariable(symbol: TSymbol): symbol is IVariableSymbol {
|
|
31
|
+
return symbol.kind === "variable";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static isBitmap(symbol: TSymbol): symbol is IBitmapSymbol {
|
|
35
|
+
return symbol.kind === "bitmap";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static isRegister(symbol: TSymbol): symbol is IRegisterSymbol {
|
|
39
|
+
return symbol.kind === "register";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default SymbolGuards;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type TSymbol from "./TSymbol";
|
|
2
|
+
import type TCSymbol from "./c/TCSymbol";
|
|
3
|
+
import type TCppSymbol from "./cpp/TCppSymbol";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Union of all symbol types across all supported languages (C-Next, C, C++).
|
|
7
|
+
*
|
|
8
|
+
* Use this type when handling symbols that could come from any source file type:
|
|
9
|
+
* - C-Next (.cnx) → TSymbol
|
|
10
|
+
* - C (.c, .h) → TCSymbol
|
|
11
|
+
* - C++ (.cpp, .hpp) → TCppSymbol
|
|
12
|
+
*
|
|
13
|
+
* The `sourceLanguage` field can be used to narrow the type:
|
|
14
|
+
* ```typescript
|
|
15
|
+
* if (symbol.sourceLanguage === ESourceLanguage.CNext) {
|
|
16
|
+
* // TypeScript knows symbol is TSymbol here
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
type TAnySymbol = TSymbol | TCSymbol | TCppSymbol;
|
|
21
|
+
|
|
22
|
+
export default TAnySymbol;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type IFunctionSymbol from "./IFunctionSymbol";
|
|
2
|
+
import type IScopeSymbol from "./IScopeSymbol";
|
|
3
|
+
import type IStructSymbol from "./IStructSymbol";
|
|
4
|
+
import type IEnumSymbol from "./IEnumSymbol";
|
|
5
|
+
import type IVariableSymbol from "./IVariableSymbol";
|
|
6
|
+
import type IBitmapSymbol from "./IBitmapSymbol";
|
|
7
|
+
import type IRegisterSymbol from "./IRegisterSymbol";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Discriminated union of all C-Next symbol types.
|
|
11
|
+
*
|
|
12
|
+
* Use the `kind` field to narrow to a specific symbol type:
|
|
13
|
+
* ```typescript
|
|
14
|
+
* if (symbol.kind === "struct") {
|
|
15
|
+
* // TypeScript knows symbol is IStructSymbol here
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Note: For C and C++ symbols, use TCSymbol and TCppSymbol respectively.
|
|
20
|
+
* These are kept separate because C/C++ symbols have different properties
|
|
21
|
+
* (e.g., no scope reference, string types instead of TType).
|
|
22
|
+
*/
|
|
23
|
+
type TSymbol =
|
|
24
|
+
| IFunctionSymbol
|
|
25
|
+
| IScopeSymbol
|
|
26
|
+
| IStructSymbol
|
|
27
|
+
| IEnumSymbol
|
|
28
|
+
| IVariableSymbol
|
|
29
|
+
| IBitmapSymbol
|
|
30
|
+
| IRegisterSymbol;
|
|
31
|
+
|
|
32
|
+
export default TSymbol;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import type IBaseSymbol from "../IBaseSymbol";
|
|
3
|
+
import type TSymbolKindCNext from "../../symbol-kinds/TSymbolKindCNext";
|
|
4
|
+
import ESourceLanguage from "../../../../utils/types/ESourceLanguage";
|
|
5
|
+
|
|
6
|
+
describe("IBaseSymbol", () => {
|
|
7
|
+
it("accepts valid symbol with TSymbolKindCNext kind", () => {
|
|
8
|
+
// Create a mock scope for circular reference using object literal with self-reference
|
|
9
|
+
const mockScope: IBaseSymbol = {
|
|
10
|
+
kind: "scope",
|
|
11
|
+
name: "global",
|
|
12
|
+
scope: null as unknown as IBaseSymbol, // Will be set after creation
|
|
13
|
+
sourceFile: "test.cnx",
|
|
14
|
+
sourceLine: 1,
|
|
15
|
+
sourceLanguage: ESourceLanguage.CNext,
|
|
16
|
+
isExported: true,
|
|
17
|
+
};
|
|
18
|
+
// Use Object.defineProperty to set the circular reference
|
|
19
|
+
Object.defineProperty(mockScope, "scope", { value: mockScope });
|
|
20
|
+
|
|
21
|
+
const symbol: IBaseSymbol = {
|
|
22
|
+
kind: "function" as TSymbolKindCNext,
|
|
23
|
+
name: "testFunc",
|
|
24
|
+
scope: mockScope,
|
|
25
|
+
sourceFile: "test.cnx",
|
|
26
|
+
sourceLine: 10,
|
|
27
|
+
sourceLanguage: ESourceLanguage.CNext,
|
|
28
|
+
isExported: true,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
expect(symbol.kind).toBe("function");
|
|
32
|
+
expect(symbol.name).toBe("testFunc");
|
|
33
|
+
expect(symbol.sourceLanguage).toBe(ESourceLanguage.CNext);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("kind field accepts all TSymbolKindCNext values", () => {
|
|
37
|
+
const validKinds: TSymbolKindCNext[] = [
|
|
38
|
+
"function",
|
|
39
|
+
"variable",
|
|
40
|
+
"struct",
|
|
41
|
+
"enum",
|
|
42
|
+
"enum_member",
|
|
43
|
+
"bitmap",
|
|
44
|
+
"bitmap_field",
|
|
45
|
+
"register",
|
|
46
|
+
"register_member",
|
|
47
|
+
"scope",
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
// Type check - if this compiles, the types are correct
|
|
51
|
+
validKinds.forEach((kind) => {
|
|
52
|
+
const partial: Pick<IBaseSymbol, "kind"> = { kind };
|
|
53
|
+
expect(partial.kind).toBe(kind);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import SymbolGuards from "../SymbolGuards";
|
|
3
|
+
import type TSymbol from "../TSymbol";
|
|
4
|
+
import type IFunctionSymbol from "../IFunctionSymbol";
|
|
5
|
+
import type IStructSymbol from "../IStructSymbol";
|
|
6
|
+
import ESourceLanguage from "../../../../utils/types/ESourceLanguage";
|
|
7
|
+
|
|
8
|
+
describe("SymbolGuards", () => {
|
|
9
|
+
// Helper to create a minimal mock symbol
|
|
10
|
+
const createMockSymbol = (kind: string): TSymbol => {
|
|
11
|
+
const mockScope = { kind: "scope" } as unknown;
|
|
12
|
+
(mockScope as { scope: unknown }).scope = mockScope;
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
kind,
|
|
16
|
+
name: "test",
|
|
17
|
+
scope: mockScope,
|
|
18
|
+
sourceFile: "test.cnx",
|
|
19
|
+
sourceLine: 1,
|
|
20
|
+
sourceLanguage: ESourceLanguage.CNext,
|
|
21
|
+
isExported: true,
|
|
22
|
+
} as TSymbol;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
it("isFunction returns true for function symbols", () => {
|
|
26
|
+
const funcSymbol = {
|
|
27
|
+
...createMockSymbol("function"),
|
|
28
|
+
parameters: [],
|
|
29
|
+
returnType: { kind: "primitive", primitive: "void" },
|
|
30
|
+
visibility: "public",
|
|
31
|
+
body: null,
|
|
32
|
+
} as IFunctionSymbol;
|
|
33
|
+
|
|
34
|
+
expect(SymbolGuards.isFunction(funcSymbol)).toBe(true);
|
|
35
|
+
expect(SymbolGuards.isStruct(funcSymbol)).toBe(false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("isStruct returns true for struct symbols", () => {
|
|
39
|
+
const structSymbol = {
|
|
40
|
+
...createMockSymbol("struct"),
|
|
41
|
+
fields: new Map(),
|
|
42
|
+
} as IStructSymbol;
|
|
43
|
+
|
|
44
|
+
expect(SymbolGuards.isStruct(structSymbol)).toBe(true);
|
|
45
|
+
expect(SymbolGuards.isFunction(structSymbol)).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("all guards return false for non-matching kinds", () => {
|
|
49
|
+
const funcSymbol = createMockSymbol("function") as TSymbol;
|
|
50
|
+
|
|
51
|
+
expect(SymbolGuards.isScope(funcSymbol)).toBe(false);
|
|
52
|
+
expect(SymbolGuards.isEnum(funcSymbol)).toBe(false);
|
|
53
|
+
expect(SymbolGuards.isVariable(funcSymbol)).toBe(false);
|
|
54
|
+
expect(SymbolGuards.isBitmap(funcSymbol)).toBe(false);
|
|
55
|
+
expect(SymbolGuards.isRegister(funcSymbol)).toBe(false);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type TSymbolKindC from "../../symbol-kinds/TSymbolKindC";
|
|
2
|
+
import type ESourceLanguage from "../../../../utils/types/ESourceLanguage";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base interface for all C language symbol types.
|
|
6
|
+
* C symbols use simple strings for types since they pass through to codegen unchanged.
|
|
7
|
+
*/
|
|
8
|
+
interface ICBaseSymbol {
|
|
9
|
+
/** Symbol kind - discriminator for type narrowing */
|
|
10
|
+
readonly kind: TSymbolKindC;
|
|
11
|
+
|
|
12
|
+
/** Symbol name */
|
|
13
|
+
readonly name: string;
|
|
14
|
+
|
|
15
|
+
/** Source file where the symbol is defined */
|
|
16
|
+
readonly sourceFile: string;
|
|
17
|
+
|
|
18
|
+
/** Line number in the source file */
|
|
19
|
+
readonly sourceLine: number;
|
|
20
|
+
|
|
21
|
+
/** Source language - always C for C symbols */
|
|
22
|
+
readonly sourceLanguage: ESourceLanguage.C;
|
|
23
|
+
|
|
24
|
+
/** Whether this symbol is exported/public */
|
|
25
|
+
readonly isExported: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default ICBaseSymbol;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type ICBaseSymbol from "./ICBaseSymbol";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Symbol representing a C enum member.
|
|
5
|
+
*/
|
|
6
|
+
interface ICEnumMemberSymbol extends ICBaseSymbol {
|
|
7
|
+
/** Discriminator narrowed to "enum_member" */
|
|
8
|
+
readonly kind: "enum_member";
|
|
9
|
+
|
|
10
|
+
/** Parent enum name */
|
|
11
|
+
readonly parent: string;
|
|
12
|
+
|
|
13
|
+
/** Optional explicit value */
|
|
14
|
+
readonly value?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default ICEnumMemberSymbol;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type ICBaseSymbol from "./ICBaseSymbol";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Symbol representing a C enum type definition.
|
|
5
|
+
*/
|
|
6
|
+
interface ICEnumSymbol extends ICBaseSymbol {
|
|
7
|
+
/** Discriminator narrowed to "enum" */
|
|
8
|
+
readonly kind: "enum";
|
|
9
|
+
|
|
10
|
+
/** Enum members with their values */
|
|
11
|
+
readonly members: ReadonlyArray<{
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly value?: number;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default ICEnumSymbol;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata for a C struct field.
|
|
3
|
+
* Uses simple strings for types since C types pass through unchanged.
|
|
4
|
+
*/
|
|
5
|
+
interface ICFieldInfo {
|
|
6
|
+
/** Field name */
|
|
7
|
+
readonly name: string;
|
|
8
|
+
|
|
9
|
+
/** Field type as string (e.g., "int", "char*") */
|
|
10
|
+
readonly type: string;
|
|
11
|
+
|
|
12
|
+
/** Array dimensions if this field is an array */
|
|
13
|
+
readonly arrayDimensions?: ReadonlyArray<number>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default ICFieldInfo;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type ICBaseSymbol from "./ICBaseSymbol";
|
|
2
|
+
import type ICParameterInfo from "./ICParameterInfo";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Symbol representing a C function definition or declaration.
|
|
6
|
+
*/
|
|
7
|
+
interface ICFunctionSymbol extends ICBaseSymbol {
|
|
8
|
+
/** Discriminator narrowed to "function" */
|
|
9
|
+
readonly kind: "function";
|
|
10
|
+
|
|
11
|
+
/** Return type as string */
|
|
12
|
+
readonly type: string;
|
|
13
|
+
|
|
14
|
+
/** Function parameters */
|
|
15
|
+
readonly parameters?: ReadonlyArray<ICParameterInfo>;
|
|
16
|
+
|
|
17
|
+
/** Whether this is a declaration (prototype) vs definition */
|
|
18
|
+
readonly isDeclaration?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default ICFunctionSymbol;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameter info for C functions.
|
|
3
|
+
* Uses simple strings for types since C types pass through unchanged.
|
|
4
|
+
*/
|
|
5
|
+
interface ICParameterInfo {
|
|
6
|
+
/** Parameter name (may be empty for prototypes) */
|
|
7
|
+
readonly name: string;
|
|
8
|
+
|
|
9
|
+
/** Parameter type as string (e.g., "int", "const char*") */
|
|
10
|
+
readonly type: string;
|
|
11
|
+
|
|
12
|
+
/** Whether this parameter is const */
|
|
13
|
+
readonly isConst: boolean;
|
|
14
|
+
|
|
15
|
+
/** Whether this parameter is an array */
|
|
16
|
+
readonly isArray: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default ICParameterInfo;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type ICBaseSymbol from "./ICBaseSymbol";
|
|
2
|
+
import type ICFieldInfo from "./ICFieldInfo";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Symbol representing a C struct or union type definition.
|
|
6
|
+
*/
|
|
7
|
+
interface ICStructSymbol extends ICBaseSymbol {
|
|
8
|
+
/** Discriminator narrowed to "struct" */
|
|
9
|
+
readonly kind: "struct";
|
|
10
|
+
|
|
11
|
+
/** Whether this is a union (true) or struct (false) */
|
|
12
|
+
readonly isUnion: boolean;
|
|
13
|
+
|
|
14
|
+
/** Map of field name to field metadata (only populated if SymbolTable was provided) */
|
|
15
|
+
readonly fields?: ReadonlyMap<string, ICFieldInfo>;
|
|
16
|
+
|
|
17
|
+
/** Whether this struct requires 'struct' keyword when referenced */
|
|
18
|
+
readonly needsStructKeyword?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default ICStructSymbol;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type ICBaseSymbol from "./ICBaseSymbol";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Symbol representing a C typedef.
|
|
5
|
+
*/
|
|
6
|
+
interface ICTypedefSymbol extends ICBaseSymbol {
|
|
7
|
+
/** Discriminator narrowed to "type" */
|
|
8
|
+
readonly kind: "type";
|
|
9
|
+
|
|
10
|
+
/** The underlying type being aliased */
|
|
11
|
+
readonly type: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default ICTypedefSymbol;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type ICBaseSymbol from "./ICBaseSymbol";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Symbol representing a C variable.
|
|
5
|
+
*/
|
|
6
|
+
interface ICVariableSymbol extends ICBaseSymbol {
|
|
7
|
+
/** Discriminator narrowed to "variable" */
|
|
8
|
+
readonly kind: "variable";
|
|
9
|
+
|
|
10
|
+
/** Variable type as string */
|
|
11
|
+
readonly type: string;
|
|
12
|
+
|
|
13
|
+
/** Whether this variable is const */
|
|
14
|
+
readonly isConst?: boolean;
|
|
15
|
+
|
|
16
|
+
/** Whether this variable is extern */
|
|
17
|
+
readonly isExtern?: boolean;
|
|
18
|
+
|
|
19
|
+
/** Whether this variable is an array */
|
|
20
|
+
readonly isArray?: boolean;
|
|
21
|
+
|
|
22
|
+
/** Array dimensions if this is an array */
|
|
23
|
+
readonly arrayDimensions?: ReadonlyArray<number | string>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default ICVariableSymbol;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type ICStructSymbol from "./ICStructSymbol";
|
|
2
|
+
import type ICEnumSymbol from "./ICEnumSymbol";
|
|
3
|
+
import type ICEnumMemberSymbol from "./ICEnumMemberSymbol";
|
|
4
|
+
import type ICFunctionSymbol from "./ICFunctionSymbol";
|
|
5
|
+
import type ICVariableSymbol from "./ICVariableSymbol";
|
|
6
|
+
import type ICTypedefSymbol from "./ICTypedefSymbol";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Discriminated union of all C language symbol types.
|
|
10
|
+
*
|
|
11
|
+
* Use the `kind` field to narrow to a specific symbol type:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* if (symbol.kind === "struct") {
|
|
14
|
+
* // TypeScript knows symbol is ICStructSymbol here
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
type TCSymbol =
|
|
19
|
+
| ICStructSymbol
|
|
20
|
+
| ICEnumSymbol
|
|
21
|
+
| ICEnumMemberSymbol
|
|
22
|
+
| ICFunctionSymbol
|
|
23
|
+
| ICVariableSymbol
|
|
24
|
+
| ICTypedefSymbol;
|
|
25
|
+
|
|
26
|
+
export default TCSymbol;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type TSymbolKindCpp from "../../symbol-kinds/TSymbolKindCpp";
|
|
2
|
+
import type ESourceLanguage from "../../../../utils/types/ESourceLanguage";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base interface for all C++ language symbol types.
|
|
6
|
+
* C++ symbols use simple strings for types since they pass through to codegen unchanged.
|
|
7
|
+
*/
|
|
8
|
+
interface ICppBaseSymbol {
|
|
9
|
+
/** Symbol kind - discriminator for type narrowing */
|
|
10
|
+
readonly kind: TSymbolKindCpp;
|
|
11
|
+
|
|
12
|
+
/** Symbol name */
|
|
13
|
+
readonly name: string;
|
|
14
|
+
|
|
15
|
+
/** Source file where the symbol is defined */
|
|
16
|
+
readonly sourceFile: string;
|
|
17
|
+
|
|
18
|
+
/** Line number in the source file */
|
|
19
|
+
readonly sourceLine: number;
|
|
20
|
+
|
|
21
|
+
/** Source language - always Cpp for C++ symbols */
|
|
22
|
+
readonly sourceLanguage: ESourceLanguage.Cpp;
|
|
23
|
+
|
|
24
|
+
/** Whether this symbol is exported/public */
|
|
25
|
+
readonly isExported: boolean;
|
|
26
|
+
|
|
27
|
+
/** Parent namespace or class name */
|
|
28
|
+
readonly parent?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default ICppBaseSymbol;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type ICppBaseSymbol from "./ICppBaseSymbol";
|
|
2
|
+
import type ICppFieldInfo from "./ICppFieldInfo";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Symbol representing a C++ class or struct type definition.
|
|
6
|
+
*/
|
|
7
|
+
interface ICppClassSymbol extends ICppBaseSymbol {
|
|
8
|
+
/** Discriminator narrowed to "class" */
|
|
9
|
+
readonly kind: "class";
|
|
10
|
+
|
|
11
|
+
/** Map of field name to field metadata (only populated if SymbolTable was provided) */
|
|
12
|
+
readonly fields?: ReadonlyMap<string, ICppFieldInfo>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default ICppClassSymbol;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type ICppBaseSymbol from "./ICppBaseSymbol";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Symbol representing a C++ enum member.
|
|
5
|
+
*/
|
|
6
|
+
interface ICppEnumMemberSymbol extends ICppBaseSymbol {
|
|
7
|
+
/** Discriminator narrowed to "enum_member" */
|
|
8
|
+
readonly kind: "enum_member";
|
|
9
|
+
|
|
10
|
+
/** Optional explicit value */
|
|
11
|
+
readonly value?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default ICppEnumMemberSymbol;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type ICppBaseSymbol from "./ICppBaseSymbol";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Symbol representing a C++ enum type definition.
|
|
5
|
+
*/
|
|
6
|
+
interface ICppEnumSymbol extends ICppBaseSymbol {
|
|
7
|
+
/** Discriminator narrowed to "enum" */
|
|
8
|
+
readonly kind: "enum";
|
|
9
|
+
|
|
10
|
+
/** Optional bit width for typed enums (e.g., 8 for uint8_t backing type) */
|
|
11
|
+
readonly bitWidth?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default ICppEnumSymbol;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata for a C++ class/struct field.
|
|
3
|
+
* Uses simple strings for types since C++ types pass through unchanged.
|
|
4
|
+
*/
|
|
5
|
+
interface ICppFieldInfo {
|
|
6
|
+
/** Field name */
|
|
7
|
+
readonly name: string;
|
|
8
|
+
|
|
9
|
+
/** Field type as string (e.g., "int", "std::string") */
|
|
10
|
+
readonly type: string;
|
|
11
|
+
|
|
12
|
+
/** Array dimensions if this field is an array */
|
|
13
|
+
readonly arrayDimensions?: ReadonlyArray<number>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default ICppFieldInfo;
|