-/* $Id: statement.h 19 2007-08-21 14:11:23Z tdb $
-
-This file is part of libmspdatafile
-Copyright © 2006 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
#include "statement.h"
+#include "type.h"
+
+using namespace std;
namespace Msp {
namespace DataFile {
-std::string Statement::get_location() const
+Statement::Statement():
+ valid(false),
+ control(false),
+ line(0)
+{ }
+
+Statement::Statement(const string &kw):
+ keyword(kw),
+ valid(true),
+ control(!kw.compare(0, 2, "__")),
+ line(0)
+{ }
+
+string Statement::get_location() const
{
- std::string result = source;
+ string result = source;
if(line)
result += format(":%d", line);
return result;
}
+string Statement::get_signature() const
+{
+ string result;
+ for(Arguments::const_iterator i = args.begin(); i!=args.end(); ++i)
+ result += i->get_signature();
+ return result;
+}
+
+
+StatementInfo::StatementInfo():
+ args_size(0)
+{ }
+
+StatementInfo::StatementInfo(const string &k, const string &s):
+ key(k, s),
+ args_size(0)
+{
+ for(string::const_iterator i=key.signature.begin(); i!=key.signature.end(); ++i)
+ {
+ arg_offsets.push_back(args_size);
+ switch(*i)
+ {
+ case IntType::signature:
+ args_size += sizeof(IntType::Store);
+ break;
+ case FloatType::signature:
+ args_size += sizeof(FloatType::Store);
+ break;
+ case BoolType::signature:
+ args_size += sizeof(BoolType::Store);
+ break;
+ case StringType::signature:
+ args_size += sizeof(StringType::Store);
+ break;
+ case SymbolType::signature:
+ args_size += sizeof(SymbolType::Store);
+ break;
+ }
+ }
+}
+
} // namespace DataFile
} // namespace Msp