diff options
author | David Robillard <d@drobilla.net> | 2009-03-15 15:30:00 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-03-15 15:30:00 +0000 |
commit | d5bff57e97494e5a25626c2877880a7eda5485c7 (patch) | |
tree | b97176827c2d52f3b2a19b3b5210a009e1aabbdb /write.cpp | |
parent | 52ae7f1842e0f079152902ee73008a2a00aaeb3f (diff) | |
download | resp-d5bff57e97494e5a25626c2877880a7eda5485c7.tar.gz resp-d5bff57e97494e5a25626c2877880a7eda5485c7.tar.bz2 resp-d5bff57e97494e5a25626c2877880a7eda5485c7.zip |
Abstract away (and prettify/shrink) dynamic_cast of AST objects.
git-svn-id: http://svn.drobilla.net/resp/tuplr@104 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'write.cpp')
-rw-r--r-- | write.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -20,23 +20,23 @@ ostream& operator<<(ostream& out, const AST* ast) { - const ALiteral<float>* flit = dynamic_cast<const ALiteral<float>*>(ast); + const ALiteral<float>* flit = ast->to<const ALiteral<float>*>(); if (flit) return out << showpoint << flit->val; - const ALiteral<int32_t>* ilit = dynamic_cast<const ALiteral<int32_t>*>(ast); + const ALiteral<int32_t>* ilit = ast->to<const ALiteral<int32_t>*>(); if (ilit) return out << ilit->val; - const ALiteral<bool>* blit = dynamic_cast<const ALiteral<bool>*>(ast); + const ALiteral<bool>* blit = ast->to<const ALiteral<bool>*>(); if (blit) return out << (blit->val ? "#t" : "#f"); - const ASymbol* sym = dynamic_cast<const ASymbol*>(ast); + const ASymbol* sym = ast->to<const ASymbol*>(); if (sym) return out << sym->cppstr; - const AType* type = dynamic_cast<const AType*>(ast); + const AType* type = ast->to<const AType*>(); if (type) { switch (type->kind) { case AType::VAR: return out << "?" << type->id; @@ -45,7 +45,7 @@ operator<<(ostream& out, const AST* ast) } } - const ATuple* tup = dynamic_cast<const ATuple*>(ast); + const ATuple* tup = ast->to<const ATuple*>(); if (tup) { out << "("; for (size_t i = 0; i != tup->size(); ++i) |