summaryrefslogtreecommitdiffstats
path: root/source/slang/syntax.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-09-27 11:17:39 -0700
committerGitHub <noreply@github.com>2017-09-27 11:17:39 -0700
commit74f2f47cb63b02638270beecd20acea1a0f5665e (patch)
treeaf50d0355c7fccb4fb93fc1a0d45c66b5d07f1c9 /source/slang/syntax.cpp
parentb6cf0f4ae0f3f9d1f377d3f134dcf994676e68b4 (diff)
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.
Diffstat (limited to 'source/slang/syntax.cpp')
-rw-r--r--source/slang/syntax.cpp49
1 files changed, 28 insertions, 21 deletions
diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp
index d02f880fd..475802cb1 100644
--- a/source/slang/syntax.cpp
+++ b/source/slang/syntax.cpp
@@ -15,7 +15,7 @@ namespace Slang
auto basicType = dynamic_cast<const BasicExpressionType*>(type);
if (basicType == nullptr)
return false;
- return basicType->BaseType == BaseType;
+ return basicType->baseType == this->baseType;
}
Type* BasicExpressionType::CreateCanonicalType()
@@ -28,7 +28,7 @@ namespace Slang
{
Slang::StringBuilder res;
- switch (BaseType)
+ switch (this->baseType)
{
case Slang::BaseType::Int:
res.Append("int");
@@ -63,21 +63,19 @@ namespace Slang
#undef ABSTRACT_SYNTAX_CLASS
#define ABSTRACT_SYNTAX_CLASS(NAME, BASE) \
+ template<> \
SyntaxClassBase::ClassInfo const SyntaxClassBase::Impl<NAME>::kClassInfo = { #NAME, &SyntaxClassBase::Impl<BASE>::kClassInfo, nullptr };
-#define SYNTAX_CLASS(NAME, BASE) \
- void NAME::accept(NAME::Visitor* visitor, void* extra) \
- { visitor->dispatch_##NAME(this, extra); } \
- void* SyntaxClassBase::Impl<NAME>::createFunc() { return new NAME(); } \
- SyntaxClass<NodeBase> NAME::getClass() { return Slang::getClass<NAME>(); } \
+#define SYNTAX_CLASS(NAME, BASE) \
+ void NAME::accept(NAME::Visitor* visitor, void* extra) \
+ { visitor->dispatch_##NAME(this, extra); } \
+ template<> \
+ void* SyntaxClassBase::Impl<NAME>::createFunc() { return new NAME(); } \
+ SyntaxClass<NodeBase> NAME::getClass() { return Slang::getClass<NAME>(); } \
+ template<> \
SyntaxClassBase::ClassInfo const SyntaxClassBase::Impl<NAME>::kClassInfo = { #NAME, &SyntaxClassBase::Impl<BASE>::kClassInfo, &SyntaxClassBase::Impl<NAME>::createFunc };
-#include "expr-defs.h"
-#include "decl-defs.h"
-#include "modifier-defs.h"
-#include "stmt-defs.h"
-#include "type-defs.h"
-#include "val-defs.h"
+template<>
SyntaxClassBase::ClassInfo const SyntaxClassBase::Impl<RefObject>::kClassInfo = { "RefObject", nullptr, nullptr };
ABSTRACT_SYNTAX_CLASS(NodeBase, RefObject);
@@ -94,6 +92,14 @@ ABSTRACT_SYNTAX_CLASS(Expr, SyntaxNode);
ABSTRACT_SYNTAX_CLASS(Substitutions, SyntaxNode);
+#include "expr-defs.h"
+#include "decl-defs.h"
+#include "modifier-defs.h"
+#include "stmt-defs.h"
+#include "type-defs.h"
+#include "val-defs.h"
+
+
#include "object-meta-end.h"
bool SyntaxClassBase::isSubClassOfImpl(SyntaxClassBase const& super) const
@@ -278,11 +284,12 @@ void Type::accept(IValVisitor* visitor, void* extra)
auto arrType = type->AsArrayType();
if (!arrType)
return false;
- return (ArrayLength == arrType->ArrayLength && BaseType->Equals(arrType->BaseType.Ptr()));
+ return (ArrayLength == arrType->ArrayLength && baseType->Equals(arrType->baseType.Ptr()));
}
+
Type* ArrayExpressionType::CreateCanonicalType()
{
- auto canonicalElementType = BaseType->GetCanonicalType();
+ auto canonicalElementType = baseType->GetCanonicalType();
auto canonicalArrayType = getArrayType(
canonicalElementType,
ArrayLength);
@@ -292,16 +299,16 @@ void Type::accept(IValVisitor* visitor, void* extra)
int ArrayExpressionType::GetHashCode()
{
if (ArrayLength)
- return (BaseType->GetHashCode() * 16777619) ^ ArrayLength->GetHashCode();
+ return (baseType->GetHashCode() * 16777619) ^ ArrayLength->GetHashCode();
else
- return BaseType->GetHashCode();
+ return baseType->GetHashCode();
}
Slang::String ArrayExpressionType::ToString()
{
if (ArrayLength)
- return BaseType->ToString() + "[" + ArrayLength->ToString() + "]";
+ return baseType->ToString() + "[" + ArrayLength->ToString() + "]";
else
- return BaseType->ToString() + "[]";
+ return baseType->ToString() + "[]";
}
// DeclRefType
@@ -1115,7 +1122,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
auto session = elementType->getSession();
auto arrayType = new ArrayExpressionType();
arrayType->setSession(session);
- arrayType->BaseType = elementType;
+ arrayType->baseType = elementType;
arrayType->ArrayLength = elementCount;
return arrayType;
}
@@ -1126,7 +1133,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
auto session = elementType->getSession();
auto arrayType = new ArrayExpressionType();
arrayType->setSession(session);
- arrayType->BaseType = elementType;
+ arrayType->baseType = elementType;
return arrayType;
}