summaryrefslogtreecommitdiffstats
path: root/source/slang/parser.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-08-25 20:13:19 -0700
committerGitHub <noreply@github.com>2017-08-25 20:13:19 -0700
commit227f9f5a9d8ac0d88079b6175b3f31c8f05fabd0 (patch)
tree48f73703ca00c91ab23cd3750ac42ac71feca9a2 /source/slang/parser.cpp
parent7e05e062a0b7c39dbce6e850227d2038aca2f38e (diff)
parentc077a08652377194f9076fc41b1b3793301b25ae (diff)
Merge pull request #173 from tfoleyNV/resources-in-structs-fixes
Fix some resources-in-structs bugs
Diffstat (limited to 'source/slang/parser.cpp')
-rw-r--r--source/slang/parser.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp
index 7ea3fe864..e232880e9 100644
--- a/source/slang/parser.cpp
+++ b/source/slang/parser.cpp
@@ -549,8 +549,39 @@ namespace Slang
{
RefPtr<Modifier>*& modifierLink = *ioModifierLink;
- while(*modifierLink)
+ // We'd like to add the modifier to the end of the list,
+ // but we need to be careful, in case there is a "shared"
+ // section of modifiers for multiple declarations.
+ //
+ // TODO: This whole approach is a mess because we are "accidentally quadratic"
+ // when adding many modifiers.
+ for(;;)
+ {
+ // At end of the chain? Done.
+ if(!*modifierLink)
+ break;
+
+ // About to look at shared modifiers? Done.
+ RefPtr<Modifier> linkMod = *modifierLink;
+ if(linkMod.As<SharedModifiers>())
+ break;
+
+ // Otherwise: keep traversing the modifier list.
modifierLink = &(*modifierLink)->next;
+ }
+
+ // Splice the modifier into the linked list
+
+ // We need to deal with the case where the modifeir to
+ // be spliced in might actually be a modifier *list*,
+ // so that we actually want to splice in at the
+ // end of the new list...
+ auto spliceLink = &modifier->next;
+ while(*spliceLink)
+ spliceLink = &(*spliceLink)->next;
+
+ // Do the splice.
+ *spliceLink = *modifierLink;
*modifierLink = modifier;
modifierLink = &modifier->next;