From 74f2f47cb63b02638270beecd20acea1a0f5665e Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 27 Sep 2017 11:17:39 -0700 Subject: First attempt at a Linux build (#193) * First attempt at a Linux build - Fix up places where C++ idioms were written assuming lenient behavior of Microsoft's compiler - Add a few more alternatives for platform-specific behavior where Windows was the only platform accounted for. - Add a basic Makefile that can at least invoke our build, even if it isn't going good dependency tracking, etc. - Build `libslang.so` and `slangc` that depends on it, using a relative `RPATH` to make the binary portable (I hope) - Add an initial `.travis.yml` to see if we can trigger their build process. * Fixup: const bug in `List::Sort` I'm not clear why this gets picked up by the gcc *and* clang that Travis uses, but not the (newer) gcc I'm using on Ubuntu here, but I'm hoping it is just some missing `const` qualifiers. * Fixup: reorder specialization of "class info" Clang complains about things being specialized after being instantiated (implicilty), and I hope it is just the fact that I generate the class info for the roots of the hierarchy after the other cases. We'll see. * Fixup: add `platform.cpp` to unified/lumped build * Fixup: Windows uses `FreeLibrary` and not `UnloadLibrary` * Fixup: fix Windows project file to include new source file This obviously points to the fact that we are going to need to be generating these files sooner or later. --- source/slang/syntax.h | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'source/slang/syntax.h') diff --git a/source/slang/syntax.h b/source/slang/syntax.h index 2fcfe8d39..8d6a1edbc 100644 --- a/source/slang/syntax.h +++ b/source/slang/syntax.h @@ -168,10 +168,12 @@ namespace Slang return (T*)current; } - void operator++() + void operator++(); + #if 0 { current = Adjust(current->next.Ptr()); } + #endif bool operator!=(Iterator other) { @@ -198,7 +200,8 @@ namespace Slang Iterator begin() { return Iterator(modifiers); } Iterator end() { return Iterator(nullptr); } - static Modifier* Adjust(Modifier* modifier) + static Modifier* Adjust(Modifier* modifier); + #if 0 { Modifier* m = modifier; for (;;) @@ -208,6 +211,7 @@ namespace Slang m = m->next.Ptr(); } } + #endif Modifier* modifiers; }; @@ -445,11 +449,11 @@ namespace Slang } // "dynamic cast" to a more specific declaration reference type - template - DeclRef As() const + template + DeclRef As() const { - DeclRef result; - result.decl = dynamic_cast(decl); + DeclRef result; + result.decl = dynamic_cast(decl); result.substitutions = substitutions; return result; } @@ -904,7 +908,7 @@ namespace Slang // inline BaseType GetVectorBaseType(VectorExpressionType* vecType) { - return vecType->elementType->AsBasicType()->BaseType; + return vecType->elementType->AsBasicType()->baseType; } inline int GetVectorSize(VectorExpressionType* vecType) @@ -1011,6 +1015,28 @@ namespace Slang RefPtr getSamplerStateType( Session* session); + + // Definitions that can't come earlier despite + // being in templates, because gcc/clang get angry. + // + template + void FilteredModifierList::Iterator::operator++() + { + current = Adjust(current->next.Ptr()); + } + // + template + Modifier* FilteredModifierList::Adjust(Modifier* modifier) + { + Modifier* m = modifier; + for (;;) + { + if (!m) return m; + if (dynamic_cast(m)) return m; + m = m->next.Ptr(); + } + } + } // namespace Slang #endif \ No newline at end of file -- cgit v1.2.3