Permalink
Browse files

Added frame.

  • Loading branch information...
1 parent 248aca7 commit 738702903667495691ccc99f4e60c649018da1ac @clemahieu committed Mar 26, 2012
View
@@ -12,6 +12,7 @@ add_library (mu_script STATIC
builder.cpp
check.cpp
context.cpp
+ frame.cpp
iterator.cpp
location.cpp
operation.cpp
View
@@ -0,0 +1,22 @@
+#include <mu/script/frame.h>
+
+#include <mu/script/context.h>
+#include <mu/script/location.h>
+
+#include <boost/make_shared.hpp>
+
+mu::script::frame::frame (mu::script::context & context_a)
+ : context (context_a)
+{
+ context_a.stack.push_back (boost::make_shared <mu::script::location> (context_a.frame_begin));
+ context_a.slide ();
+}
+
+mu::script::frame::~frame ()
+{
+ assert (boost::dynamic_pointer_cast <mu::script::location> (context.stack [context.frame_begin - 1]) != nullptr);
+ context.drop ();
+ auto location (boost::static_pointer_cast <mu::script::location> (context.stack [context.frame_begin - 1]));
+ context.frame_begin = location->position;
+ context.stack.resize (context.stack.size () - 1);
+}
View
@@ -0,0 +1,18 @@
+#pragma once
+
+#include <boost/noncopyable.hpp>
+
+namespace mu
+{
+ namespace script
+ {
+ class context;
+ class frame : boost::noncopyable
+ {
+ public:
+ frame (mu::script::context & context_a);
+ ~frame ();
+ mu::script::context & context;
+ };
+ }
+}
@@ -4,6 +4,7 @@ project (script_test)
add_library (mu_script_test STATIC
tests.cpp
context.cpp
+ frame.cpp
analyzer/operation.cpp
ast/extension.cpp
chain/operation.cpp
View
@@ -0,0 +1,52 @@
+#include <mu/script_test/frame.h>
+
+#include <mu/script/context.h>
+#include <mu/script/frame.h>
+#include <mu/core/node.h>
+
+#include <boost/make_shared.hpp>
+
+void mu::script_test::frame::run ()
+{
+ run_1 ();
+ run_2 ();
+ run_3 ();
+}
+
+void mu::script_test::frame::run_1 ()
+{
+ mu::script::context context;
+ assert (context.stack.size () == 2);
+ {
+ mu::script::frame frame (context);
+ }
+ assert (context.stack.size () == 2);
+}
+
+void mu::script_test::frame::run_2 ()
+{
+ mu::script::context context;
+ assert (context.stack.size () == 2);
+ {
+ mu::script::frame frame (context);
+ assert (context.stack.size () == 3);
+ context.push (boost::make_shared <mu::core::node> ());
+ assert (context.stack.size () == 4);
+ }
+ assert (context.stack.size () == 2);
+}
+
+void mu::script_test::frame::run_3 ()
+{
+ mu::script::context context;
+ assert (context.stack.size () == 2);
+ context.push (boost::make_shared <mu::core::node> ());
+ assert (context.stack.size () == 3);
+ {
+ mu::script::frame frame (context);
+ assert (context.stack.size () == 4);
+ context.push (boost::make_shared <mu::core::node> ());
+ assert (context.stack.size () == 5);
+ }
+ assert (context.stack.size () == 3);
+}
View
@@ -0,0 +1,16 @@
+#pragma once
+
+namespace mu
+{
+ namespace script_test
+ {
+ class frame
+ {
+ public:
+ void run ();
+ void run_1 ();
+ void run_2 ();
+ void run_3 ();
+ };
+ }
+}
View
@@ -20,6 +20,7 @@
#include <mu/script_test/synthesizer/operation.h>
#include <mu/script_test/cluster/remap.h>
#include <mu/script_test/debugging/trace_types.h>
+#include <mu/script_test/frame.h>
void mu::script_test::tests::run ()
{
@@ -28,6 +29,10 @@ void mu::script_test::tests::run ()
test.run ();
}
{
+ mu::script_test::frame test;
+ test.run ();
+ }
+ {
mu::script_test::topology::core test;
test.run ();
}

0 comments on commit 7387029

Please sign in to comment.