summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-04 03:05:40 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-04 03:05:40 +0300
commitaf598a91862ae52862d4c90a84fa82ed8c16f739 (patch)
tree477d4c1849cd803f63f14791d8d0b7f4041193cd
parentf8d6836ae34d4ac0385f4290cc990a77cc2e9bf6 (diff)
downloadparanucker-af598a91862ae52862d4c90a84fa82ed8c16f739.tar.gz
paranucker-af598a91862ae52862d4c90a84fa82ed8c16f739.tar.bz2
paranucker-af598a91862ae52862d4c90a84fa82ed8c16f739.tar.xz
paranucker-af598a91862ae52862d4c90a84fa82ed8c16f739.zip
Add macro and function for log int fields if it non zero.
-rw-r--r--src/localconsts.h6
-rw-r--r--src/logger.cpp15
-rw-r--r--src/logger.h4
-rw-r--r--src/parsers/declnode.cpp4
-rw-r--r--src/parsers/functiondeclnode.cpp14
-rw-r--r--src/parsers/functiontypenode.cpp4
-rw-r--r--src/parsers/resultdeclnode.cpp4
7 files changed, 39 insertions, 12 deletions
diff --git a/src/localconsts.h b/src/localconsts.h
index ca104ff..02566ad 100644
--- a/src/localconsts.h
+++ b/src/localconsts.h
@@ -39,3 +39,9 @@
#define FOR_CHAIN(node, var) \
for (tree var = DECL_ARGUMENTS(node); var; var = DECL_CHAIN(var))
+
+#define setPrintField(node, macro, method) \
+ node->method = macro(node->gccNode); \
+ Log::logInt(node, \
+ "- "#method": %d", \
+ node->method)
diff --git a/src/logger.cpp b/src/logger.cpp
index 025eab4..b3465a5 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -28,8 +28,7 @@ namespace Log
void log(const Node *const node,
const char *const text,
- ...
- )
+ ...)
{
va_list ap;
va_start(ap, text);
@@ -44,6 +43,18 @@ void log(const Node *const node,
va_end(ap);
}
+void logInt(const Node *const node,
+ const char *const text,
+ const int val)
+{
+ if (!val || !node)
+ return;
+
+ fprintf(stderr, "%s", node->getIndent().c_str());
+ fprintf(stderr, text, val);
+ fprintf(stderr, "\n");
+}
+
void log(const Node *const node,
const int indent,
const char *const text,
diff --git a/src/logger.h b/src/logger.h
index cbedba6..4830665 100644
--- a/src/logger.h
+++ b/src/logger.h
@@ -30,6 +30,10 @@ namespace Log
const char *const text,
...);
+ void logInt(const Node *const node,
+ const char *const text,
+ const int val);
+
void log(const Node *const node,
const int indent,
const char *const text,
diff --git a/src/parsers/declnode.cpp b/src/parsers/declnode.cpp
index d6a8268..7717f28 100644
--- a/src/parsers/declnode.cpp
+++ b/src/parsers/declnode.cpp
@@ -60,6 +60,10 @@ void fillDeclAutoGenerated(DeclNode *node)
return;
}
node->isAutoGenerated = DECL_ARTIFICIAL(node->gccNode);
+
+ Log::logInt(node,
+ "- isAutogenerated: %d",
+ node->isAutoGenerated);
}
}
diff --git a/src/parsers/functiondeclnode.cpp b/src/parsers/functiondeclnode.cpp
index 8ce872c..6b757aa 100644
--- a/src/parsers/functiondeclnode.cpp
+++ b/src/parsers/functiondeclnode.cpp
@@ -37,8 +37,15 @@ void parseFunctionDeclNode(FunctionDeclNode *node)
fillType(node);
fillLocation(node);
fillDeclLabel(node);
- fillDeclAutoGenerated(node);
Log::log(node);
+
+ fillDeclAutoGenerated(node);
+ setPrintField(node, DECL_FUNCTION_VERSIONED, hasTargets);
+ setPrintField(node, DECL_VIRTUAL_P, isVirtual);
+ setPrintField(node, DECL_FINAL_P, isFinal);
+ setPrintField(node, TREE_READONLY, isConst);
+ setPrintField(node, DECL_PURE_P, isPure);
+
fillDeclAttributes(node);
node->functionType = static_cast<FunctionTypeNode*>(createParseNode(
node,
@@ -63,15 +70,10 @@ void parseFunctionDeclNode(FunctionDeclNode *node)
node,
DECL_FUNCTION_SPECIFIC_TARGET(node->gccNode),
"target");
- node->hasTargets = DECL_FUNCTION_VERSIONED(node->gccNode);
node->optimisation = createParseNode(
node,
DECL_FUNCTION_SPECIFIC_OPTIMIZATION(node->gccNode),
"optiomisations");
- node->isVirtual = DECL_VIRTUAL_P(node->gccNode);
- node->isFinal = DECL_FINAL_P(node->gccNode);
- node->isConst = TREE_READONLY(node->gccNode);
- node->isPure = DECL_PURE_P(node->gccNode);
}
}
diff --git a/src/parsers/functiontypenode.cpp b/src/parsers/functiontypenode.cpp
index b28a9d8..73d0326 100644
--- a/src/parsers/functiontypenode.cpp
+++ b/src/parsers/functiontypenode.cpp
@@ -35,15 +35,13 @@ void parseFunctionTypeNode(FunctionTypeNode *node)
{
fillType(node);
Log::log(node);
- fillTypeName(node);
+ fillTypeName(node);
node->returnType = static_cast<TypeNode*>(createParseNode(
node,
TREE_TYPE(node->gccNode),
"function return type"));
-
fillTypeAttributes(node);
-
node->argTypes = static_cast<TreeListNode*>(createParseNode(
node,
TYPE_ARG_TYPES(node->gccNode),
diff --git a/src/parsers/resultdeclnode.cpp b/src/parsers/resultdeclnode.cpp
index 7c5bfb3..ecf4db1 100644
--- a/src/parsers/resultdeclnode.cpp
+++ b/src/parsers/resultdeclnode.cpp
@@ -37,8 +37,10 @@ void parseResultDeclNode(ResultDeclNode *node)
fillType(node);
fillLocation(node);
fillDeclLabel(node);
- fillDeclAutoGenerated(node);
Log::log(node);
+
+ fillDeclAutoGenerated(node);
+
fillDeclAttributes(node);
node->resultType = static_cast<TypeNode*>(createParseNode(
node,