aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AssertionChecker/Runtime.php9
-rw-r--r--Model/Declaration.php19
-rw-r--r--Visitor/Interpreter.php15
3 files changed, 16 insertions, 27 deletions
diff --git a/AssertionChecker/Runtime.php b/AssertionChecker/Runtime.php
index 5f99c62..e0b8265 100644
--- a/AssertionChecker/Runtime.php
+++ b/AssertionChecker/Runtime.php
@@ -546,12 +546,7 @@ class Runtime extends AssertionChecker {
foreach($clause as $name => $variable) {
- $_name = $name;
-
- if('\old(' === substr($name, 0, 5))
- $_name = substr($name, 5, -1);
-
- if(false === array_key_exists($_name, $data)) {
+ if(false === array_key_exists($name, $data)) {
$exceptions[] = new $exception(
'Variable %s is required and has no value.', 7, $name);
@@ -559,7 +554,7 @@ class Runtime extends AssertionChecker {
continue;
}
- $datum = &$data[$_name];
+ $datum = &$data[$name];
$_verdict = false;
$traceVariable = null;
diff --git a/Model/Declaration.php b/Model/Declaration.php
index ffbf936..2e1abf9 100644
--- a/Model/Declaration.php
+++ b/Model/Declaration.php
@@ -146,8 +146,7 @@ abstract class Declaration
* @access public
* @param string $name Variable name.
* @param bool $borrowing Borrowing variable or not.
- * @return \Hoa\Praspel\Model\Variable
- * @throw \Hoa\Praspel\Exception\Model
+ * @return mixed
*/
public function getVariable ( $name, $borrowing = false ) {
@@ -159,10 +158,18 @@ abstract class Declaration
return $out;
}
- if('\old(' === substr($name, 0, 5))
- throw new \Hoa\Praspel\Exception\Model(
- 'Cannot declare domains for %s in @%s.',
- 0, array($name, $this->getName()));
+ if('\old(' === substr($name, 0, 5)) {
+
+ $variable = $this->getVariable($name, true);
+
+ return new \Hoa\Realdom\Crate\Constant(
+ $variable->getBorrowedVariable(),
+ function ( ) use ( $variable ) {
+
+ return $variable->getName();
+ }
+ );
+ }
if(false === $this->offsetExists($name)) {
diff --git a/Visitor/Interpreter.php b/Visitor/Interpreter.php
index bf9a3d9..9d20411 100644
--- a/Visitor/Interpreter.php
+++ b/Visitor/Interpreter.php
@@ -332,16 +332,6 @@ 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(),
- function ( ) use ( $argument ) {
-
- return $argument->getName();
- }
- );
-
if($argument instanceof \Hoa\Realdom\Disjunction) {
$realdoms = $argument->getRealdoms();
@@ -464,10 +454,7 @@ class Interpreter implements \Hoa\Visitor\Visit {
')';
if(false !== $eldnah)
- return $this->_clause->getVariable(
- $value,
- true
- );
+ return $this->_clause->getVariable($value);
return $value;
break;