X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FParsedSource.cpp;h=422c5a0e31ce525bb0287f2870a76c493bd44e80;hb=refs%2Fheads%2Flinker;hp=8c3d3bd17415d5cd4fe7ff92df6b42a45204127a;hpb=535f472174fd386567bec7002f645183b80cb2ef;p=l2e.git diff --git a/src/loader/ParsedSource.cpp b/src/loader/ParsedSource.cpp index 8c3d3bd..422c5a0 100644 --- a/src/loader/ParsedSource.cpp +++ b/src/loader/ParsedSource.cpp @@ -1,10 +1,3 @@ -/* - * ParsedSource.cpp - * - * Created on: Aug 26, 2012 - * Author: holy - */ - #include "ParsedSource.h" #include "utility.h" @@ -207,6 +200,17 @@ Literal::Literal(const string &typeName, const vector &pls) } +Literal::Literal(const string &typeName, const vector &ids) +: props(0) +, typeName(typeName) +, identifiers(ids) +, i1(0), i2(0) +, i3(0), i4(0) +, b(false) +, type(ARRAY_IDENTS) { + +} + Literal::Literal(bool b) : props(0) , typeName("Boolean") @@ -331,6 +335,14 @@ const vector &Literal::GetPropertyLists() const { } } +const vector &Literal::GetIdentifiers() const { + if (type == ARRAY_IDENTS) { + return identifiers; + } else { + throw runtime_error("tried to access identifiers of non-array literal"); + } +} + bool Literal::GetBoolean() const { if (type == BOOLEAN) { return b; @@ -515,7 +527,8 @@ const Literal *ScriptToken::GetLiteral() const { namespace std { ostream &operator <<(ostream &out, const loader::ParsedSource &source) { - out << "parsed source file" << endl; + out << "parsed sources" << endl; + out << "==============" << endl; out << "declared objects: " << endl; for (map::const_iterator i(source.Declarations().begin()), end(source.Declarations().end()); i != end; ++i) { out << " - " << i->first << " of type " << i->second->TypeName() << endl; @@ -531,6 +544,7 @@ ostream &operator <<(ostream &out, const loader::ParsedSource &source) { for (set::const_iterator i(source.Exports().begin()), end(source.Exports().end()); i != end; ++i) { out << " - " << *i << endl; } + out << endl; return out; } @@ -542,6 +556,9 @@ ostream &operator <<(ostream &out, const loader::Literal &l) { case loader::Literal::ARRAY_PROPS: out << "array of property lists"; break; + case loader::Literal::ARRAY_IDENTS: + out << "array of identifiers"; + break; case loader::Literal::BOOLEAN: out << "boolean, " << (l.GetBoolean() ? "true" : "false"); break;