Skip to content

Commit 714fb7e

Browse files
committed
Add per-declaration support for decl maps.
1 parent 73dbdc4 commit 714fb7e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/AST/Declaration.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ private static string GetDeclName(Declaration decl, string name)
334334

335335
public List<Declaration> Redeclarations { get; } = new List<Declaration>();
336336

337+
// Custom declaration map for custom code generation.
338+
public object DeclMap { get; set; }
339+
337340
protected Declaration()
338341
{
339342
Access = AccessSpecifier.Public;
@@ -372,6 +375,7 @@ protected Declaration(Declaration declaration)
372375
LineNumberEnd = declaration.LineNumberEnd;
373376
IsImplicit = declaration.IsImplicit;
374377
AssociatedDeclaration = declaration.AssociatedDeclaration;
378+
DeclMap = declaration.DeclMap;
375379
}
376380

377381
public override string ToString()

src/Generator/Types/DeclMapDatabase.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ private void SetupDeclMaps(IEnumerable<System.Type> types,
6060

6161
public bool FindDeclMap(Declaration decl, out DeclMap declMap)
6262
{
63+
if (decl.DeclMap != null)
64+
{
65+
declMap = decl.DeclMap as DeclMap;
66+
return true;
67+
}
68+
6369
// Looks up the decl in the cache map.
6470
if (declMaps.ContainsKey(decl))
6571
{

0 commit comments

Comments
 (0)