]> git.localhorst.tv Git - l2e.git/commitdiff
added loader to main
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 15 Sep 2012 19:34:37 +0000 (21:34 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 24 Feb 2013 21:33:58 +0000 (22:33 +0100)
src/main.cpp

index f0811de23ede1282543681de19c6996aff6223f2..bdde265098a54a10ab8881d1ff021d56a61c0716 100644 (file)
@@ -32,6 +32,7 @@
 #include "graphics/Texture.h"
 #include "loader/Caster.h"
 #include "loader/Interpreter.h"
+#include "loader/Loader.h"
 #include "loader/ParsedSource.h"
 #include "loader/Parser.h"
 #include "loader/TypeDescription.h"
@@ -71,6 +72,7 @@ using math::Vector;
 using graphics::Texture;
 using loader::Caster;
 using loader::Interpreter;
+using loader::Loader;
 using loader::ParsedSource;
 using loader::Parser;
 using loader::TypeDescription;
@@ -140,8 +142,20 @@ int main(int argc, char **argv) {
 
                ParsedSource source;
 
+               Loader ld;
+
                for (vector<char *>::const_iterator i(args.Infiles().begin()), end(args.Infiles().end()); i != end; ++i) {
-                       Parser(*i, source).Parse();
+                       string filePath(*i);
+                       switch (filePath[filePath.size() - 1]) {
+                               case 'o':
+                                       ld.Load(filePath);
+                                       break;
+                               case 's':
+                                       Parser(filePath, source).Parse();
+                                       break;
+                               default:
+                                       throw std::runtime_error("don't know what to do with " + filePath);
+                       }
                }
 
                switch (args.GetRunLevel()) {
@@ -154,6 +168,10 @@ int main(int argc, char **argv) {
                                                source.WriteHeader(outstream);
                                                break;
                                        }
+                                       case 'o': {
+                                               std::ofstream outstream(args.OutfilePath());
+                                               Compiler(intp).Write(outstream);
+                                               break;
                                        default: {
                                                throw std::runtime_error(string("don't know how to write file ") + args.OutfilePath());
                                        }