From ef474d24145b85f933d06a1648b0d9cbf6695fe5 Mon Sep 17 00:00:00 2001 From: jistone Date: Fri, 22 Dec 2006 02:34:05 +0000 Subject: 2006-12-21 Josh Stone PR 3671 * parse.cxx (parser::parse_global): Allow a maxsize on global arrays. * staptree.h (struct vardecl): Add the maxsize field. * staptree.cxx (vardecl::vardecl): Init. maxsize. (vardecl::set_arity): Don't allow arity 0 when there's a maxsize. (vardecl::compatible_arity): Ditto. (vardecl::print): Include maxsize in output. (target_symbol::print): Ditto. * translate.cxx (struct mapvar, mapvar::mapvar): Add maxsize. (mapvar::init): Init maps with the given maxsize if specified, else keep using MAXMAPENTRIES. (mapvar::set): Make the error message give the maxsize. (mapvar::add): Ditto, and check for overflow on pmap add. (c_unparser::getmap): Pass the maxsize from the vardecl to mapvar. --- staptree.cxx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'staptree.cxx') diff --git a/staptree.cxx b/staptree.cxx index aa464469..151d6863 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -104,7 +104,7 @@ probe_point::component::component (std::string const & f, literal * a): vardecl::vardecl (): - arity (-1), init(NULL) + arity (-1), maxsize(0), init(NULL) { } @@ -115,7 +115,7 @@ vardecl::set_arity (int a) if (a < 0) return; - if (arity != a && arity >= 0) + if ((arity != a && arity >= 0) || (a == 0 && maxsize > 0)) throw semantic_error ("inconsistent arity", tok); if (arity != a) @@ -130,6 +130,8 @@ vardecl::set_arity (int a) bool vardecl::compatible_arity (int a) { + if (a == 0 && maxsize > 0) + return false; if (arity == -1 || a == -1) return true; return arity == a; @@ -265,6 +267,8 @@ void target_symbol::print (std::ostream& o) const void vardecl::print (ostream& o) const { o << name; + if (maxsize > 0) + o << "[" << maxsize << "]"; if (arity > 0 || index_types.size() > 0) o << "[...]"; if (init) @@ -277,7 +281,10 @@ void vardecl::print (ostream& o) const void vardecl::printsig (ostream& o) const { - o << name << ":" << type; + o << name; + if (maxsize > 0) + o << "[" << maxsize << "]"; + o << ":" << type; if (index_types.size() > 0) { o << " ["; -- cgit