aboutsummaryrefslogtreecommitdiffstats
path: root/Visitor
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-10 14:23:49 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-10 14:23:49 +0200
commitd2f8208f2951691b550d912b5f725d2371af9e9a (patch)
treee2f35a3b7de9f591fa0de3e8c47bf94bbed2407e /Visitor
parent95d8e9a76566f980fb7e08fb7c27b6b884d53f57 (diff)
downloadPraspel-d2f8208f2951691b550d912b5f725d2371af9e9a.zip
Praspel-d2f8208f2951691b550d912b5f725d2371af9e9a.tar.gz
Praspel-d2f8208f2951691b550d912b5f725d2371af9e9a.tar.bz2
Use the Model\Behavior::getAllowedClauses().
It helps maintenance and modularity of the code.
Diffstat (limited to 'Visitor')
-rw-r--r--Visitor/Compiler.php24
-rw-r--r--Visitor/Praspel.php24
2 files changed, 7 insertions, 41 deletions
diff --git a/Visitor/Compiler.php b/Visitor/Compiler.php
index d083572..d20b61c 100644
--- a/Visitor/Compiler.php
+++ b/Visitor/Compiler.php
@@ -82,17 +82,8 @@ class Compiler implements \Hoa\Visitor\Visit {
$variable = '$' . $element->getId();
$out = $variable . ' = new \Hoa\Praspel\Model\Specification();' . "\n";
- $clauses = array(
- 'is',
- 'invariant',
- 'requires',
- 'ensures',
- 'behavior',
- 'throwable',
- 'description'
- );
-
- foreach($clauses as $clause)
+
+ foreach($element::getAllowedClauses() as $clause)
if(true === $element->clauseExists($clause))
$out .= $element->getClause($clause)->accept(
$this,
@@ -201,15 +192,8 @@ class Compiler implements \Hoa\Visitor\Visit {
$variable . ' = ' . $parent .
'->getClause(\'behavior\')' .
'->get(\'' . $identifier . '\');' . "\n";
- $clauses = array(
- 'invariant',
- 'requires',
- 'ensures',
- 'behavior',
- 'throwable'
- );
-
- foreach($clauses as $clause)
+
+ foreach($element::getAllowedClauses() as $clause)
if(true === $element->clauseExists($clause))
$out .= $element->getClause($clause)->accept(
$this,
diff --git a/Visitor/Praspel.php b/Visitor/Praspel.php
index 4ad2b07..82c34a3 100644
--- a/Visitor/Praspel.php
+++ b/Visitor/Praspel.php
@@ -80,19 +80,9 @@ class Praspel implements \Hoa\Visitor\Visit {
if($element instanceof \Hoa\Praspel\Model\Specification) {
- $clauses = array(
- 'is',
- 'invariant',
- 'requires',
- 'ensures',
- 'behavior',
- 'throwable',
- 'description'
- );
-
$oout = array();
- foreach($clauses as $clause)
+ foreach($element::getAllowedClauses() as $clause)
if(true === $element->clauseExists($clause))
$oout[] = $element->getClause($clause)->accept(
$this,
@@ -192,18 +182,10 @@ class Praspel implements \Hoa\Visitor\Visit {
}
elseif($element instanceof \Hoa\Praspel\Model\Behavior) {
- $out = '@behavior ' . $element->getIdentifier() . ' {' . "\n";
- $clauses = array(
- 'invariant',
- 'requires',
- 'ensures',
- 'behavior',
- 'throwable'
- );
-
+ $out = '@behavior ' . $element->getIdentifier() . ' {' . "\n";
$oout = array();
- foreach($clauses as $clause)
+ foreach($element::getAllowedClauses() as $clause)
if(true === $element->clauseExists($clause))
$oout[] = ' ' . str_replace(
"\n",