summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErick Ochoa <erick.ochoa@theobroma-systems.com>2020-06-15 16:23:37 +0200
committerErick Ochoa <erick.ochoa@theobroma-systems.com>2020-06-16 08:58:13 +0200
commit606a16466ebebff9715e159651ea123778cc2e57 (patch)
treef132ab920a24a775c5777b1176a5c26d31dba152
parent57dde08f7d34c88edb7cce7046f2424de605c4a1 (diff)
arrays
-rw-r--r--gcc/type-reconstructor.c40
-rw-r--r--gcc/type-reconstructor.hpp2
2 files changed, 41 insertions, 1 deletions
diff --git a/gcc/type-reconstructor.c b/gcc/type-reconstructor.c
index 39ef4aea385..530569c074f 100644
--- a/gcc/type-reconstructor.c
+++ b/gcc/type-reconstructor.c
@@ -53,6 +53,45 @@ get_new_identifier(const_tree type)
return get_identifier(new_name);
}
+// Invariant for all _pre functions:
+// _reorg_map[t] == NULL (due to memoization)
+//
+// Invariant for all _post functions:
+// _reorg_map[TREE_TYPE(t)] != NULL
+//
+// To preserve invariant, we must include
+// the following at the end of all _post functions:
+// _reorg_map[t] = /* reorg type */
+//
+// How information is passed?
+// To further _post functions via stacks
+//
+// To previous _post functions via _reorg_map (and maybe others?)
+//
+//
+void
+TypeReconstructor::_walk_ARRAY_TYPE_pre(const_tree t)
+{
+ _working_stack.push(build_distinct_type_copy((tree)t));
+}
+
+void
+TypeReconstructor::_walk_ARRAY_TYPE_post(const_tree t)
+{
+ const_tree inner_type = TREE_TYPE(t);
+ gcc_assert(inner_type);
+ tree inner_reorg_type = (tree)_reorg_map[inner_type];
+ gcc_assert(inner_reorg_type);
+ tree t_reorg = (tree)_working_stack.top();
+ _working_stack.pop();
+
+ TREE_TYPE(t_reorg) = inner_reorg_type;
+ TYPE_NAME((tree)t_reorg) = get_new_identifier(t_reorg);
+ _reorg_map[t] = t_reorg;
+
+
+}
+
void
TypeReconstructor::_walk_POINTER_TYPE_pre(const_tree t)
{
@@ -77,7 +116,6 @@ TypeReconstructor::_walk_POINTER_TYPE_post(const_tree t)
return;
}
- log ("here\n");
tree tf = (tree)_reorg_map[tt];
TREE_TYPE((tree)modifications) = tf;
TYPE_NAME((tree)modifications) = get_new_identifier(modifications);
diff --git a/gcc/type-reconstructor.hpp b/gcc/type-reconstructor.hpp
index ca596c5d86d..12260f9a48b 100644
--- a/gcc/type-reconstructor.hpp
+++ b/gcc/type-reconstructor.hpp
@@ -33,6 +33,8 @@ private:
virtual void _walk_field_post(const_tree);
virtual void _walk_RECORD_TYPE_pre(const_tree);
virtual void _walk_RECORD_TYPE_post(const_tree);
+ virtual void _walk_ARRAY_TYPE_pre(const_tree);
+ virtual void _walk_ARRAY_TYPE_post(const_tree);
virtual void _walk_POINTER_TYPE_pre(const_tree);
virtual void _walk_POINTER_TYPE_post(const_tree);
public: