diff options
| author | Tim Foley <tim.foley.is@gmail.com> | 2017-08-14 18:50:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-14 18:50:46 -0700 |
| commit | aeb247cdf02e4dcfc0bb6839cfd291be5128f8ad (patch) | |
| tree | 7314b26e21ded966b6a4fe2430f0421c0c0970bd /source/slang/syntax.h | |
| parent | bb66d6eddd649d8861cecefa2d6ccb7a28a827bc (diff) | |
| parent | 9885c972a6bfa6f856e505cdd90d9b71fdbdadaf (diff) | |
Merge pull request #159 from tfoleyNV/name-type
Name type
Diffstat (limited to 'source/slang/syntax.h')
| -rw-r--r-- | source/slang/syntax.h | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/source/slang/syntax.h b/source/slang/syntax.h index 6f3c32d18..e25f096ff 100644 --- a/source/slang/syntax.h +++ b/source/slang/syntax.h @@ -11,6 +11,7 @@ namespace Slang { + class Name; class Session; class Substitutions; class SyntaxVisitor; @@ -44,6 +45,32 @@ namespace Slang IntrinsicOp findIntrinsicOp(char const* name); + // Helper type for pairing up a name and the location where it appeared + struct NameLoc + { + Name* name; + SourceLoc loc; + + NameLoc() + : name(nullptr) + {} + + explicit NameLoc(Name* name) + : name(name) + {} + + + NameLoc(Name* name, SourceLoc loc) + : name(name) + , loc(loc) + {} + + NameLoc(Token const& token) + : name(token.getNameOrNull()) + , loc(token.getLoc()) + {} + }; + // Helper class for iterating over a list of heap-allocated modifiers struct ModifierList { @@ -371,7 +398,7 @@ namespace Slang } // Convenience accessors for common properties of declarations - String const& GetName() const; + Name* GetName() const; DeclRefBase GetParent() const; int GetHashCode() const; @@ -772,7 +799,7 @@ namespace Slang bool isOverloaded() const { return items.Count() > 1; } - String const& getName() const + Name* getName() const { return items.Count() > 1 ? items[0].declRef.GetName() : item.declRef.GetName(); } |
