aboutsummaryrefslogtreecommitdiffstats
path: root/Model/Declaration.php
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-11-22 15:11:57 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-11-22 15:11:57 +0100
commitc5b344986d8a65aeea69848f765a8267296681a8 (patch)
treea5dea8839bd7140baf771720673246e87de6a8bc /Model/Declaration.php
parent61f09f7049928d3f4813a6623ec2c055adf792c2 (diff)
downloadPraspel-c5b344986d8a65aeea69848f765a8267296681a8.zip
Praspel-c5b344986d8a65aeea69848f765a8267296681a8.tar.gz
Praspel-c5b344986d8a65aeea69848f765a8267296681a8.tar.bz2
Clean a little bit \old(e) support.
Remove a useless code in the RAC. And move the `\old(e)` support from the interpreter to the model.
Diffstat (limited to 'Model/Declaration.php')
-rw-r--r--Model/Declaration.php19
1 files changed, 13 insertions, 6 deletions
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)) {