From 0f30d8254ff8b9e63795960ec031577cf68fbf95 Mon Sep 17 00:00:00 2001
From: Daniel Karbach <daniel.karbach@localhorst.tv>
Date: Sat, 15 Sep 2012 21:34:37 +0200
Subject: [PATCH] added loader to main

---
 src/main.cpp | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/main.cpp b/src/main.cpp
index f0811de..bdde265 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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());
 					}
-- 
2.39.5