summaryrefslogtreecommitdiffstats
path: root/libvtv/testsuite/libvtv.cc/v8-test-2.cc
diff options
context:
space:
mode:
authorctice <ctice@138bc75d-0d04-0410-961f-82ee72b054a4>2013-09-08 23:35:14 +0000
committerctice <ctice@138bc75d-0d04-0410-961f-82ee72b054a4>2013-09-08 23:35:14 +0000
commit786f817740a7dca966e5f49b0b4976b32d0be744 (patch)
tree7aed39930d05ef1f28db4df7227d5b55ec792763 /libvtv/testsuite/libvtv.cc/v8-test-2.cc
parent1eadcdffcb14af40bebaec65de4bf7ef75756164 (diff)
downloadppe42-gcc-786f817740a7dca966e5f49b0b4976b32d0be744.tar.gz
ppe42-gcc-786f817740a7dca966e5f49b0b4976b32d0be744.zip
Update libvtv testsuite so that most of the tests now run under
the dejagnu test harness. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202373 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libvtv/testsuite/libvtv.cc/v8-test-2.cc')
-rw-r--r--libvtv/testsuite/libvtv.cc/v8-test-2.cc97
1 files changed, 97 insertions, 0 deletions
diff --git a/libvtv/testsuite/libvtv.cc/v8-test-2.cc b/libvtv/testsuite/libvtv.cc/v8-test-2.cc
new file mode 100644
index 00000000000..6bfda56e8c6
--- /dev/null
+++ b/libvtv/testsuite/libvtv.cc/v8-test-2.cc
@@ -0,0 +1,97 @@
+// { dg-do run }
+
+#include <stdlib.h>
+#include <string>
+
+class Literal;
+class CallRuntime;
+
+class AstNode {
+public:
+
+ enum Type {
+ kLiteral, kCallRuntime,
+ kInvalid = -1
+ };
+
+ AstNode() { }
+
+ virtual ~AstNode() { }
+
+ virtual Type node_type() const = 0;
+
+ bool
+ IsLiteral() { return node_type() == AstNode::kLiteral; }
+
+ Literal *
+ AsLiteral() { return IsLiteral() ? reinterpret_cast<Literal*>(this)
+ : NULL; }
+
+ bool
+ IsCallRuntime() { return node_type() == AstNode::kCallRuntime; }
+
+ CallRuntime *
+ AsCallRuntime() { return IsCallRuntime() ? reinterpret_cast<CallRuntime*>(this)
+ : NULL; }
+
+};
+
+class Expression: public AstNode {
+public:
+private:
+ int id_;
+};
+
+class Literal: public Expression {
+public:
+
+ virtual AstNode::Type node_type() const { return AstNode::kLiteral; }
+
+ private:
+ std::string ToString();
+
+};
+
+class CallRuntime: public Expression {
+public:
+
+ virtual AstNode::Type node_type() const { return AstNode::kCallRuntime; }
+
+ private:
+ std::string name_;
+};
+
+Expression *
+ExpressionCheck (bool *ok)
+{
+ if (*ok == true)
+ return new CallRuntime();
+ else
+ return new Literal ();
+
+ return NULL;
+}
+
+Expression *
+GetExpression (bool *ok)
+{
+ Expression *expression = ExpressionCheck (ok);
+ Expression *return_expr = NULL;
+
+ if (expression != NULL && expression->AsLiteral() != NULL)
+ return_expr = new Literal();
+ else if (expression != NULL && expression->AsCallRuntime() != NULL)
+ return_expr = expression;
+
+ return return_expr;
+}
+
+int
+main (int argc, char **argv)
+{
+ bool a_bool = true;
+
+ AstNode *node = GetExpression (&a_bool);
+
+ return 0;
+}
OpenPOWER on IntegriCloud