aboutsummaryrefslogtreecommitdiffstats
path: root/Visitor/Compiler.php
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-10 14:58:35 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-10 14:58:35 +0200
commit467d39b9047547ff94a37fdcb8805623ef09d542 (patch)
tree9fbb23471e3718c35546d4b6ff0a1e959a18459d /Visitor/Compiler.php
parentd2f8208f2951691b550d912b5f725d2371af9e9a (diff)
downloadPraspel-467d39b9047547ff94a37fdcb8805623ef09d542.zip
Praspel-467d39b9047547ff94a37fdcb8805623ef09d542.tar.gz
Praspel-467d39b9047547ff94a37fdcb8805623ef09d542.tar.bz2
Add the @default clause!
The default clause represents a default/else behavior.
Diffstat (limited to 'Visitor/Compiler.php')
-rw-r--r--Visitor/Compiler.php27
1 files changed, 20 insertions, 7 deletions
diff --git a/Visitor/Compiler.php b/Visitor/Compiler.php
index d20b61c..40a835d 100644
--- a/Visitor/Compiler.php
+++ b/Visitor/Compiler.php
@@ -183,15 +183,28 @@ class Compiler implements \Hoa\Visitor\Visit {
$exception->getDisjunction() . '\');' . "\n";
}
}
+ elseif($element instanceof \Hoa\Praspel\Model\DefaultBehavior) {
+
+ $out = "\n" .
+ '$' . $element->getId() . ' = $' .
+ $element->getParent()->getId() .
+ '->getClause(\'default\')' . "\n";
+
+ foreach($element::getAllowedClauses() as $clause)
+ if(true === $element->clauseExists($clause))
+ $out .= $element->getClause($clause)->accept(
+ $this,
+ $handle,
+ $eldnah
+ );
+ }
elseif($element instanceof \Hoa\Praspel\Model\Behavior) {
- $parent = '$' . $element->getParent()->getId();
- $variable = '$' . $element->getId();
- $identifier = $element->getIdentifier();
- $out = "\n" .
- $variable . ' = ' . $parent .
- '->getClause(\'behavior\')' .
- '->get(\'' . $identifier . '\');' . "\n";
+ $out = "\n" .
+ '$' . $element->getId() . ' = $' .
+ $element->getParent()->getId() .
+ '->getClause(\'behavior\')' .
+ '->get(\'' . $element->getIdentifier() . '\');' . "\n";
foreach($element::getAllowedClauses() as $clause)
if(true === $element->clauseExists($clause))