aboutsummaryrefslogtreecommitdiffstats
path: root/Visitor
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2012-12-18 09:41:13 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2012-12-18 09:41:13 +0100
commit73e34fffa1bbb2f5ac8ccdccea6900edfd7982c7 (patch)
tree1c0e4445e33375ca561b07d1dda73f17054a566e /Visitor
parent9c6f176e225620010168bd3b0e00eba834074949 (diff)
downloadPraspel-73e34fffa1bbb2f5ac8ccdccea6900edfd7982c7.zip
Praspel-73e34fffa1bbb2f5ac8ccdccea6900edfd7982c7.tar.gz
Praspel-73e34fffa1bbb2f5ac8ccdccea6900edfd7982c7.tar.bz2
Better variable identifiers handling.
Diffstat (limited to 'Visitor')
-rw-r--r--Visitor/Compiler.php39
1 files changed, 20 insertions, 19 deletions
diff --git a/Visitor/Compiler.php b/Visitor/Compiler.php
index 15e058f..e878928 100644
--- a/Visitor/Compiler.php
+++ b/Visitor/Compiler.php
@@ -71,16 +71,13 @@ class Compiler implements \Hoa\Visitor\Visit {
public function visit ( \Hoa\Visitor\Element $element,
&$handle = null, $eldnah = null ) {
- $out = null;
- $parent = '$praspel';
-
- if(null !== $eldnah)
- $parent = '$' . substr($eldnah, 0, -1);
+ $out = null;
if($element instanceof \Hoa\Praspel\Model\Specification) {
- $out = $parent . ' = new \Hoa\Praspel\Model\Specification();' . "\n";
- $clauses = array(
+ $variable = '$' . $element->getId();
+ $out = $variable . ' = new \Hoa\Praspel\Model\Specification();' . "\n";
+ $clauses = array(
'is',
'invariant',
'requires',
@@ -100,15 +97,17 @@ class Compiler implements \Hoa\Visitor\Visit {
}
elseif($element instanceof \Hoa\Praspel\Model\Is) {
- $out = "\n" .
- $parent . '->getClause(\'is\')->setProperty(' .
- $element->getProperty() .
- ');' . "\n";
+ $variable = '$' . $element->getParent()->getId();
+ $out = "\n" .
+ $variable . '->getClause(\'is\')->setProperty(' .
+ $element->getProperty() .
+ ');' . "\n";
}
elseif($element instanceof \Hoa\Praspel\Model\Declaration) {
+ $parent = '$' . $element->getParent()->getId();
+ $variable = '$' . $element->getId();
$clause = $element->getName();
- $variable = '$' . $eldnah . $clause;
$out = "\n" .
$variable . ' = ' . $parent .
'->getClause(\'' . $clause . '\');' . "\n";
@@ -145,23 +144,24 @@ class Compiler implements \Hoa\Visitor\Visit {
}
elseif($element instanceof \Hoa\Praspel\Model\Throwable) {
- $variable = '$' . $eldnah . 'throwable';
- $out = "\n" .
- $variable . ' = ' . $parent .
- '->getClause(\'throwable\');' . "\n";
+ $parent = '$' . $element->getParent()->getId();
+ $variable = '$' . $element->getId();
+ $out = "\n" .
+ $variable . ' = ' . $parent .
+ '->getClause(\'throwable\');' . "\n";
foreach($element->getExceptions() as $class)
$out .= $variable . '->exception(\'' . $class . '\');' . "\n";
}
elseif($element instanceof \Hoa\Praspel\Model\Behavior) {
+ $parent = '$' . $element->getParent()->getId();
+ $variable = '$' . $element->getId();
$identifier = $element->getIdentifier();
- $variable = '$' . $eldnah . 'behavior_' . $identifier;
$out = "\n" .
$variable . ' = ' . $parent .
'->getClause(\'behavior\');' . "\n" .
$variable . '->setIdentifier(\'' . $identifier . '\');' . "\n";
- $eldnah = $eldnah . 'behavior_' . $identifier . '_';
$clauses = array(
'invariant',
'requires',
@@ -180,7 +180,8 @@ class Compiler implements \Hoa\Visitor\Visit {
}
elseif($element instanceof \Hoa\Praspel\Model\Forexample) {
- $variable = '$' . $eldnah . 'forexample';
+ $parent = '$' . $element->getParent()->getId();
+ $variable = '$' . $element->getId();
$out = "\n" .
$variable . ' = ' . $parent .
'->getClause(\'forexample\');' . "\n";