summaryrefslogtreecommitdiff
path: root/lib/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/codegen')
-rw-r--r--lib/codegen/include/code_gen/CG_outputBuilder.h4
-rw-r--r--lib/codegen/include/code_gen/CG_stringBuilder.h2
-rw-r--r--lib/codegen/include/code_gen/CGdebug.h31
-rwxr-xr-xlib/codegen/src/CG_stringBuilder.cc6
4 files changed, 35 insertions, 8 deletions
diff --git a/lib/codegen/include/code_gen/CG_outputBuilder.h b/lib/codegen/include/code_gen/CG_outputBuilder.h
index cb0cd5d..58f8a2f 100644
--- a/lib/codegen/include/code_gen/CG_outputBuilder.h
+++ b/lib/codegen/include/code_gen/CG_outputBuilder.h
@@ -91,12 +91,10 @@ namespace omega {
* @brief function invoation generation
* @param funcName
* @param argList
- * @param is_array
* @return
*/
virtual CG_outputRepr *CreateInvoke(const std::string &funcName,
- std::vector<CG_outputRepr *> &argList,
- bool is_array = false) const = 0;
+ std::vector<CG_outputRepr *> &argList) const = 0;
/*!
* @brief comment generation
* @param indent
diff --git a/lib/codegen/include/code_gen/CG_stringBuilder.h b/lib/codegen/include/code_gen/CG_stringBuilder.h
index 390039a..ce33bde 100644
--- a/lib/codegen/include/code_gen/CG_stringBuilder.h
+++ b/lib/codegen/include/code_gen/CG_stringBuilder.h
@@ -21,7 +21,7 @@ public:
CG_stringRepr *CreateSubstitutedStmt(int indent, CG_outputRepr *stmt, const std::vector<std::string> &vars, std::vector<CG_outputRepr *> &subs, bool actuallyPrint) const;
CG_stringRepr *CreateAssignment(int indent, CG_outputRepr *lhs, CG_outputRepr *rhs) const;
CG_stringRepr *CreatePlusAssignment(int indent, CG_outputRepr *lhs, CG_outputRepr *rhs) const;
- CG_stringRepr *CreateInvoke(const std::string &funcName, std::vector<CG_outputRepr *> &argList,bool is_array=false) const;
+ CG_stringRepr *CreateInvoke(const std::string &funcName, std::vector<CG_outputRepr *> &argList) const;
CG_stringRepr *CreateComment(int indent, const std::string &commentText) const;
CG_stringRepr* CreateAttribute(CG_outputRepr *control,
const std::string &commentText) const;
diff --git a/lib/codegen/include/code_gen/CGdebug.h b/lib/codegen/include/code_gen/CGdebug.h
new file mode 100644
index 0000000..cf72c36
--- /dev/null
+++ b/lib/codegen/include/code_gen/CGdebug.h
@@ -0,0 +1,31 @@
+#ifndef CGDEBUG_H
+#define CGDEBUG_H
+
+#include <libgen.h>
+#include <string.h>
+#include <stdlib.h>
+
+#ifndef NDEBUG // means that CMAKE_BUILD_TYPE=Debug
+#define DEBUGCODEGEN
+#endif
+// This thing below potentially create leaks
+#define FILENAME basename(strdup(__FILE__))
+
+#ifdef DEBUGCODEGEN
+#define CG_DEBUG_PRINT(format,args...) fprintf(stderr,"%15s | %15s | LN%-4d:\t" format,FILENAME,__FUNCTION__, \
+ __LINE__, ##args )
+#define CG_DEBUG_BEGIN { \
+ fprintf(stderr,"=========\t%15s, %15s, LN%-4d\t=========\n",FILENAME,__FUNCTION__,__LINE__);
+#define CG_DEBUG_END fprintf(stderr,"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");}
+#else
+#define CG_DEBUG_PRINT(format,args...) do {} while(0) /* Don't do anything */
+#define CG_DEBUG_BEGIN while(0) {
+#define CG_DEBUG_END }
+#endif
+
+// TODO below should be substituted by some error throwing? to be more consistent with cpp style
+#define CG_ERROR(format,args...) fprintf(stderr,"ERROR:\t%s, %s, LN%d:\t" format,FILENAME,__FUNCTION__, \
+ __LINE__, ##args )
+
+
+#endif
diff --git a/lib/codegen/src/CG_stringBuilder.cc b/lib/codegen/src/CG_stringBuilder.cc
index d0f6693..7a19f66 100755
--- a/lib/codegen/src/CG_stringBuilder.cc
+++ b/lib/codegen/src/CG_stringBuilder.cc
@@ -182,11 +182,9 @@ namespace omega {
CG_stringRepr *CG_stringBuilder::CreateInvoke(const std::string &funcName,
- std::vector<CG_outputRepr *> &list,
- bool is_array) const {
+ std::vector<CG_outputRepr *> &list) const {
fprintf(stderr, "CG_stringBuilder::CreateInvoke( %s, ..., is_array ", funcName.c_str());
- if (is_array) fprintf(stderr, " true )\n");
- else fprintf(stderr, " false )\n");
+ fprintf(stderr, " false )\n");
std::string listStr = "";