diff options
author | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2013-09-16 17:16:38 +0200 |
---|---|---|
committer | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2013-09-16 17:16:38 +0200 |
commit | d44a853b840c8629e3272a8a552d8e2d72c637fb (patch) | |
tree | bb96ca609ebb7caec5b2f5ca7666c009ec5b80b1 /Visitor | |
parent | 22efd46b04b4e551d3c8fbab812225e7433367f4 (diff) | |
download | Praspel-d44a853b840c8629e3272a8a552d8e2d72c637fb.zip Praspel-d44a853b840c8629e3272a8a552d8e2d72c637fb.tar.gz Praspel-d44a853b840c8629e3272a8a552d8e2d72c637fb.tar.bz2 |
Add borrowing variables and \old(…) support.
A borrowing variable represents a link between two variables (kind a
redirection). It is useful to create link between pre- and post-state in
the contract, such as \old(…).
Diffstat (limited to 'Visitor')
-rw-r--r-- | Visitor/Interpreter.php | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/Visitor/Interpreter.php b/Visitor/Interpreter.php index 5de4848..a7926c8 100644 --- a/Visitor/Interpreter.php +++ b/Visitor/Interpreter.php @@ -54,6 +54,11 @@ from('Hoa') -> import('Visitor.Visit') /** + * \Hoa\Realdom\Crate\Constant + */ +-> import('Realdom.Crate.Constant') + +/** * \Hoa\String */ -> import('String.~'); @@ -300,6 +305,12 @@ class Interpreter implements \Hoa\Visitor\Visit { $argument = $child->accept($this, $handle, $eldnah); + if( $argument instanceof \Hoa\Praspel\Model\Variable\Borrowing + && $argument::TYPE_OLD === $argument->getType()) + $argument = new \Hoa\Realdom\Crate\Constant( + $argument->getBorrowedVariable() + ); + if($argument instanceof \Hoa\Realdom\Disjunction) { $realdoms = $argument->getRealdoms(); @@ -406,9 +417,17 @@ class Interpreter implements \Hoa\Visitor\Visit { break; case '#old': - return '\old(' . - $element->getChild(0)->accept($this, $handle, false) . - ')'; + $value = '\old(' . + $element->getChild(0)->accept($this, $handle, false) . + ')'; + + if(false !== $eldnah) + return $this->_clause->getVariable( + $value, + true + ); + + return $value; break; case '#result': @@ -551,6 +570,7 @@ class Interpreter implements \Hoa\Visitor\Visit { * Get identifier object. * * @access public + * @param string $identifier Identifier. * @return \Hoa\Praspel\Model\Variable */ public function getIdentifier ( $identifier ) { |