[opengtl-commits] [730] start work on CTL templates

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 730
Author:   cyrille
Date:     2009-05-06 16:06:10 +0200 (Wed, 06 May 2009)

Log Message:
-----------
start work on CTL templates

Modified Paths:
--------------
    trunk/OpenGTL/OpenCTL/OpenCTL/CMakeLists.txt
    trunk/OpenGTL/OpenCTL/OpenCTL/Module.cpp

Added Paths:
-----------
    trunk/OpenGTL/OpenCTL/OpenCTL/Template.cpp
    trunk/OpenGTL/OpenCTL/OpenCTL/Template.h
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateLexer.cpp
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateLexer_p.h
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateParser.cpp
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateParser_p.h


Modified: trunk/OpenGTL/OpenCTL/OpenCTL/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/CMakeLists.txt	2009-05-06 13:13:08 UTC (rev 729)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/CMakeLists.txt	2009-05-06 14:06:10 UTC (rev 730)
@@ -7,12 +7,17 @@
   Module.cpp
   ModulesManager.cpp
   Program.cpp
+  Template.cpp
   Version.cpp
 # Internal files
   StdLibFunctions.cpp
   compiler/Compiler.cpp
   compiler/LexerNG.cpp
   compiler/ParserNG.cpp
+# Template files
+  templatecompiler/TemplateAST.cpp
+  templatecompiler/TemplateLexer.cpp
+  templatecompiler/TemplateParser.cpp
   ${LLVM_NATIVE_OBJECTS}
     )
 

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/Module.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Module.cpp	2009-05-06 13:13:08 UTC (rev 729)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Module.cpp	2009-05-06 14:06:10 UTC (rev 730)
@@ -41,8 +41,6 @@
 #include <llvm/ModuleProvider.h>
 #include <llvm/System/DynamicLibrary.h>
 
-#include <iostream>
-
 struct Module::Private {
   Private() : moduleData(0), moduleProvider(0) {}
   GTLCore::String name;

Added: trunk/OpenGTL/OpenCTL/OpenCTL/Template.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Template.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Template.cpp	2009-05-06 14:06:10 UTC (rev 730)
@@ -0,0 +1,75 @@
+/*
+ *  Copyright (c) 2009 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "Template.h"
+
+#include <sstream>
+#include <fstream>
+
+#include "Debug.h"
+
+using namespace OpenCTL;
+
+struct Template::Private {
+  Private() : isCompiled(false) {}
+  GTLCore::String source;
+  bool isCompiled;
+};
+
+Template::Template() : d(new Private)
+{
+}
+
+Template::~Template()
+{
+  delete d;
+}
+
+void Template::setSource(const GTLCore::String& source)
+{
+  d->source = source;
+}
+
+void Template::loadFromFile(const GTLCore::String& fileName)
+{
+  std::ifstream in;
+  in.open(fileName.c_str() );
+  if(not in)
+  {
+    OCTL_DEBUG( "Impossible to open file " << fileName );
+    return;
+  }
+  GTLCore::String str;
+  std::getline(in,str);
+  while ( in ) {
+    d->source += str;
+    d->source += "\n";
+    std::getline(in,str);
+  }
+}
+
+void Template::compile()
+{
+  
+}
+
+bool Template::isCompiled() const
+{
+  return d->isCompiled;
+}


Property changes on: trunk/OpenGTL/OpenCTL/OpenCTL/Template.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenCTL/OpenCTL/Template.h
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Template.h	                        (rev 0)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Template.h	2009-05-06 14:06:10 UTC (rev 730)
@@ -0,0 +1,52 @@
+/*
+ *  Copyright (c) 2009 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _OPENCTL_TEMPLATE_H_
+#define _OPENCTL_TEMPLATE_H_
+
+#include <GTLCore/String.h>
+
+namespace OpenCTL {
+  class Template {
+    public:
+/*      class GenerationContext {
+      };*/
+    public:
+      Template();
+      ~Template();
+      /**
+       * Set the code source of the module.
+       */
+      void setSource(const GTLCore::String& source);
+      /**
+       * Load the module from the given file name.
+       */
+      void loadFromFile(const GTLCore::String& fileName);
+      void compile();
+      /**
+       * @return true if the module was successfully compiled.
+       */
+      bool isCompiled() const;
+    private:
+      struct Private;
+      Private* const d;
+  };
+}
+
+#endif


Property changes on: trunk/OpenGTL/OpenCTL/OpenCTL/Template.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp
===================================================================


Property changes on: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h
===================================================================


Property changes on: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateLexer.cpp
===================================================================


Property changes on: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateLexer.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateLexer_p.h
===================================================================


Property changes on: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateLexer_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateParser.cpp
===================================================================


Property changes on: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateParser.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateParser_p.h
===================================================================


Property changes on: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateParser_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/