public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/libbash:master commit in: bashast/
Date: Sat, 11 Jun 2011 08:52:14 +0000 (UTC)	[thread overview]
Message-ID: <500e3427ff9ec64473f052e8c11a992d34f5e09f.betelgeuse@gentoo> (raw)

commit:     500e3427ff9ec64473f052e8c11a992d34f5e09f
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 10 08:30:05 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Jun 11 08:09:12 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=500e3427

Walker: use namespace instead of static functions

We removed the inline keyword as compiler will do it when proper
optimization level/flag is on.

---
 bashast/libbashWalker.g |  137 ++++++++++++++++++++++++-----------------------
 1 files changed, 70 insertions(+), 67 deletions(-)

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 5587bfa..962a57d 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -62,84 +62,87 @@ options
 		walker = w;
 	}
 
-	inline void set_index(const std::string& name, unsigned& index, int value)
+	namespace
 	{
-		if(value < 0)
-			throw interpreter_exception((boost::format("Array index is less than 0: \%s[\%d]") \% name \% value).str());
-		index = value;
-	}
-
-	// seek to LT(2) and consume
-	static void seek_to_next_tree(plibbashWalker ctx)
-	{
-		// Current depth of the tree we are traversing
-		int depth = 1;
-
-		// The beginning should always be ROOT DOWN ANY_TOKEN
-		// So we start from LA(4)
-		int index = 4;
-		for(; depth != 0; ++index)
+		void set_index(const std::string& name, unsigned& index, int value)
 		{
-			// Go one level done if we encounter DOWN
-			if(LA(index) == DOWN)
-				++depth;
-			// Go one level up if we encounter UP. When depth==0, we finishe one node
-			else if(LA(index) == UP)
-				--depth;
+			if(value < 0)
+				throw interpreter_exception((boost::format("Array index is less than 0: \%s[\%d]") \% name \% value).str());
+			index = value;
 		}
 
-		// Seek to the correct offset and consume.
-		SEEK(INDEX() + index - 2);
-		CONSUME();
-	}
-
-	// The method is used to append a pattern with another one. Because it's not allowed to append an empty pattern,
-	// we need the argument 'do_append' to indicate whether the pattern is empty. 'do_append' will be set to true after
-	// the first assignment.
-	inline void append(boost::xpressive::sregex& pattern, const boost::xpressive::sregex& new_pattern, bool& do_append)
-	{
-		using namespace boost::xpressive;
-		if(do_append)
+		// seek to LT(2) and consume
+		void seek_to_next_tree(plibbashWalker ctx)
 		{
-			pattern = sregex(pattern >> new_pattern);
+			// Current depth of the tree we are traversing
+			int depth = 1;
+
+			// The beginning should always be ROOT DOWN ANY_TOKEN
+			// So we start from LA(4)
+			int index = 4;
+			for(; depth != 0; ++index)
+			{
+				// Go one level done if we encounter DOWN
+				if(LA(index) == DOWN)
+					++depth;
+				// Go one level up if we encounter UP. When depth==0, we finishe one node
+				else if(LA(index) == UP)
+					--depth;
+			}
+
+			// Seek to the correct offset and consume.
+			SEEK(INDEX() + index - 2);
+			CONSUME();
 		}
-		else
+
+		// The method is used to append a pattern with another one. Because it's not allowed to append an empty pattern,
+		// we need the argument 'do_append' to indicate whether the pattern is empty. 'do_append' will be set to true after
+		// the first assignment.
+		void append(boost::xpressive::sregex& pattern, const boost::xpressive::sregex& new_pattern, bool& do_append)
 		{
-			pattern = new_pattern;
-			do_append = true;
+			using namespace boost::xpressive;
+			if(do_append)
+			{
+				pattern = sregex(pattern >> new_pattern);
+			}
+			else
+			{
+				pattern = new_pattern;
+				do_append = true;
+			}
 		}
-	}
 
-	bool match(const std::string& target,
-			   const boost::xpressive::sregex& pattern)
-	{
-	  return boost::xpressive::regex_match(target, pattern);
-	}
+		bool match(const std::string& target,
+				   const boost::xpressive::sregex& pattern)
+		{
+		  return boost::xpressive::regex_match(target, pattern);
+		}
 
-	/// \brief parse the text value of a tree to integer
-	/// \param the target tree
-	/// \return the parsed value
-	static int parse_int(ANTLR3_BASE_TREE* tree)
-	{
-		return tree->getText(tree)->toInt32(tree->getText(tree));
-	}
+		/// \brief parse the text value of a tree to integer
+		/// \param the target tree
+		/// \return the parsed value
+		int parse_int(ANTLR3_BASE_TREE* tree)
+		{
+			return tree->getText(tree)->toInt32(tree->getText(tree));
+		}
 
-	/// \brief a helper function that get the string value
-	///        of the given pANTLR3_BASE_TREE node.
-	/// \param the target tree node
-	/// \return the value of node->text
-	static std::string get_string(pANTLR3_BASE_TREE node)
-	{
-		pANTLR3_COMMON_TOKEN token = node->getToken(node);
-		// The tree walker may send null pointer here, so return an empty
-		// string if that's the case.
-		if(!token->start)
-			return "";
-		// Use reinterpret_cast here because we have to cast C code.
-		// The real type here is int64_t which is used as a pointer.
-		// token->stop - token->start + 1 should be bigger than 0.
-		return std::string(reinterpret_cast<const char *>(token->start),
-						   boost::numeric_cast<unsigned>(token->stop - token->start + 1));
+		/// \brief a helper function that get the string value
+		///        of the given pANTLR3_BASE_TREE node.
+		/// \param the target tree node
+		/// \return the value of node->text
+		std::string get_string(pANTLR3_BASE_TREE node)
+		{
+			pANTLR3_COMMON_TOKEN token = node->getToken(node);
+			// The tree walker may send null pointer here, so return an empty
+			// string if that's the case.
+			if(!token->start)
+				return "";
+			// Use reinterpret_cast here because we have to cast C code.
+			// The real type here is int64_t which is used as a pointer.
+			// token->stop - token->start + 1 should be bigger than 0.
+			return std::string(reinterpret_cast<const char *>(token->start),
+							   boost::numeric_cast<unsigned>(token->stop - token->start + 1));
+		}
 	}
 }
 



             reply	other threads:[~2011-06-11  8:52 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-11  8:52 Petteri Räty [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-08-04 13:53 [gentoo-commits] proj/libbash:master commit in: bashast/ Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-06-26 13:38 Petteri Räty
2011-06-14  8:28 Petteri Räty
2011-06-14  8:28 Petteri Räty
2011-05-29 11:20 Petteri Räty
2011-05-29 11:20 Petteri Räty
2011-05-22 21:00 Petteri Räty
2011-05-12 14:06 Petteri Räty
2011-04-27 15:11 Petteri Räty
2011-04-21  7:55 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-14  4:50 Petteri Räty
2011-04-12 18:29 Petteri Räty
2011-04-12  7:19 Petteri Räty
2011-04-12  7:19 Petteri Räty
2011-04-12  7:19 Petteri Räty
2011-04-11  6:50 Petteri Räty
2011-04-11  6:50 Petteri Räty
2011-04-09 13:08 Petteri Räty
2011-04-09 13:08 Petteri Räty
2011-04-09  6:36 Petteri Räty
2011-04-09  6:27 Petteri Räty
2011-04-09  6:27 Petteri Räty
2011-04-09  6:27 Petteri Räty
2011-04-09  6:27 Petteri Räty
2011-04-09  6:27 Petteri Räty
2011-04-08 14:26 Petteri Räty
2011-04-08 14:26 Petteri Räty
2011-04-07 16:44 Petteri Räty
2011-04-07  7:48 Petteri Räty
2011-04-06 15:07 Petteri Räty
2011-04-04 15:52 Petteri Räty
2011-04-02 15:50 Petteri Räty
2011-04-02 15:50 Petteri Räty
2011-03-22 20:52 Petteri Räty

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=500e3427ff9ec64473f052e8c11a992d34f5e09f.betelgeuse@gentoo \
    --to=betelgeuse@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox