aboutsummaryrefslogtreecommitdiffstats
path: root/Visitor/Interpreter.php
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-10 10:27:58 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-10 10:27:58 +0200
commit824e66a0399b20931678e1fdea2ce5fa018f6319 (patch)
treef1cb6550c318b05eabb4f3511917eddd59c7fccb /Visitor/Interpreter.php
parentfaba6ec19b03e8ae2e37d4a8a5bb01e7107b7cb3 (diff)
downloadPraspel-824e66a0399b20931678e1fdea2ce5fa018f6319.zip
Praspel-824e66a0399b20931678e1fdea2ce5fa018f6319.tar.gz
Praspel-824e66a0399b20931678e1fdea2ce5fa018f6319.tar.bz2
Add support of “with” in @throwable.
It allows to specify the post-state of data. Example: @throwable T1 t1 with this->foo: true;
Diffstat (limited to 'Visitor/Interpreter.php')
-rw-r--r--Visitor/Interpreter.php63
1 files changed, 44 insertions, 19 deletions
diff --git a/Visitor/Interpreter.php b/Visitor/Interpreter.php
index f0f6fc3..4337740 100644
--- a/Visitor/Interpreter.php
+++ b/Visitor/Interpreter.php
@@ -139,7 +139,6 @@ class Interpreter implements \Hoa\Visitor\Visit {
case '#requires':
case '#ensures':
case '#invariant':
- case '#throwable':
$this->_clause = $this->_current->getClause(substr($id, 1));
foreach($element->getChildren() as $child)
@@ -163,6 +162,50 @@ class Interpreter implements \Hoa\Visitor\Visit {
$this->_current = $previous;
break;
+ case '#throwable':
+ $this->_clause = $this->_current->getClause('throwable');
+ $identifier = null;
+
+ foreach($element->getChildren() as $child) {
+
+ switch($child->getId()) {
+
+ case '#exception_identifier':
+ $_identifier = $child->getChild(1)->accept(
+ $this,
+ $handle,
+ false
+ );
+ $_instanceof = $child->getChild(0)->accept(
+ $this,
+ $handle,
+ false
+ );
+
+ $this->_clause[$_identifier] = $_instanceof;
+
+ if(null === $identifier)
+ $identifier = $_identifier;
+ else
+ $this->_clause[$_identifier]->disjunctionWith(
+ $identifier
+ );
+ break;
+
+ case '#exception_with':
+ $old = $this->_clause;
+ $this->_clause = $old->newWith();
+
+ foreach($child->getChildren() as $_child)
+ $_child->accept($this, $handle, $eldnah);
+
+ $old[$identifier]->setWith($this->_clause);
+ $this->_clause = $old;
+ break;
+ }
+ }
+ break;
+
case '#description':
$this->_clause = $this->_root->getClause('description');
$this->_clause[] = $element->getChild(0)->accept(
@@ -172,24 +215,6 @@ class Interpreter implements \Hoa\Visitor\Visit {
);
break;
- case '#exception_list':
- for($i = 0, $max = $element->getChildrenNumber(); $i < $max; $i += 2) {
-
- $identifier = $element->getChild($i + 1)->accept(
- $this,
- $handle,
- false
- );
- $classname = $element->getChild($i)->accept(
- $this,
- $handle,
- false
- );
-
- $this->_clause[$identifier] = $classname;
- }
- break;
-
case '#declaration':
$variable = $element->getChild(0)
->accept($this, $handle, false);