From 9885c972a6bfa6f856e505cdd90d9b71fdbdadaf Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 14 Aug 2017 14:48:37 -0700 Subject: Add an explicit `Name` type Fixes #23 Up to this point, the compiler has used the ordinary `String` type to represent declaration names, which means a bunch of lookup structures throughout the compiler were string-to-whatever maps, which can reduce efficiency. It also means that things like the `Token` type end up carying a `String` by value and paying for things like reference-counting. This change adds a `Name` type that is used to represent names of variables, types, macros, etc. Names are cached and unique'd globally for a session, and the string-to-name mapping gets done during lexing. From that point on, most mapping is from pointers, which should make all the various table lookups faster. More importantly (possibly), this brings us one step closer to being able to pool-allocate the AST nodes. --- source/slang/diagnostics.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source/slang/diagnostics.h') diff --git a/source/slang/diagnostics.h b/source/slang/diagnostics.h index e22320d3d..f92df030b 100644 --- a/source/slang/diagnostics.h +++ b/source/slang/diagnostics.h @@ -46,7 +46,7 @@ namespace Slang { public: String Message; - SourceLoc Position; + SourceLoc loc; int ErrorID; Severity severity; @@ -63,15 +63,13 @@ namespace Slang { Message = msg; ErrorID = id; - Position = pos; + loc = pos; } }; + class Name; class Decl; - class type; class Type; - class ILType; - class StageAttribute; struct TypeExp; struct QualType; @@ -79,8 +77,8 @@ namespace Slang void printDiagnosticArg(StringBuilder& sb, int val); void printDiagnosticArg(StringBuilder& sb, UInt val); void printDiagnosticArg(StringBuilder& sb, Slang::String const& str); + void printDiagnosticArg(StringBuilder& sb, Name* name); void printDiagnosticArg(StringBuilder& sb, Decl* decl); - void printDiagnosticArg(StringBuilder& sb, type* type); void printDiagnosticArg(StringBuilder& sb, Type* type); void printDiagnosticArg(StringBuilder& sb, TypeExp const& type); void printDiagnosticArg(StringBuilder& sb, QualType const& type); -- cgit v1.2.3