summaryrefslogtreecommitdiffstats
path: root/source/slang/parameter-binding.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-08-14 14:48:37 -0700
committerTim Foley <tfoley@nvidia.com>2017-08-14 14:48:37 -0700
commit9885c972a6bfa6f856e505cdd90d9b71fdbdadaf (patch)
tree7314b26e21ded966b6a4fe2430f0421c0c0970bd /source/slang/parameter-binding.cpp
parent7f57ea4ad86c2a3eb5a14fef458e711845c1f87e (diff)
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.
Diffstat (limited to 'source/slang/parameter-binding.cpp')
-rw-r--r--source/slang/parameter-binding.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp
index 4a6eac472..877597640 100644
--- a/source/slang/parameter-binding.cpp
+++ b/source/slang/parameter-binding.cpp
@@ -226,7 +226,7 @@ struct ParameterBindingContext
LayoutRulesFamilyImpl* layoutRules;
// A dictionary to accellerate looking up parameters by name
- Dictionary<String, ParameterInfo*> mapNameToParameterInfo;
+ Dictionary<Name*, ParameterInfo*> mapNameToParameterInfo;
// What stage (if any) are we compiling for?
Stage stage;
@@ -377,17 +377,17 @@ static bool findLayoutArg(
//
-static String getReflectionName(VarDeclBase* varDecl)
+static Name* getReflectionName(VarDeclBase* varDecl)
{
if (auto reflectionNameModifier = varDecl->FindModifier<ParameterBlockReflectionName>())
- return reflectionNameModifier->nameToken.Content;
+ return reflectionNameModifier->nameAndLoc.name;
return varDecl->getName();
}
static bool isGLSLBuiltinName(VarDeclBase* varDecl)
{
- return getReflectionName(varDecl).StartsWith("gl_");
+ return getText(getReflectionName(varDecl)).StartsWith("gl_");
}
RefPtr<Type> tryGetEffectiveTypeForGLSLVaryingInput(
@@ -1688,7 +1688,7 @@ void generateParameterBindings(
programLayout->bindingForHackSampler = (int)binding;
RefPtr<Variable> var = new Variable();
- var->name.Content = "SLANG_hack_samplerForTexelFetch";
+ var->nameAndLoc.name = request->getNamePool()->getName("SLANG_hack_samplerForTexelFetch");
var->type.type = getSamplerStateType(request->mSession);
auto typeLayout = new TypeLayout();