Ejemplo n.º 1
0
 public function execute(Runtime $vm)
 {
     foreach (array('source', 'key', 'value', 'body') as $var) {
         ${$var} = $this->{$var};
     }
     if ($source instanceof Variable) {
         /* it's a json definition */
         $val = $vm->get($source);
         if (is_null($val)) {
             throw new \RuntimeException("Cannot find variable " . $source);
         }
         $source = $vm->getValue($val);
     } else {
         $source = $vm->getValue($source);
     }
     foreach ($source as $zkey => $zvalue) {
         if ($key) {
             $vm->define($key, new Term($zkey));
         }
         $vm->define($value, $zvalue);
         foreach ($body as $stmt) {
             $vm->execute($stmt);
             if ($vm->isSuspended()) {
                 $vm->isSuspended(false);
                 break;
             }
             if ($vm->isStopped()) {
                 break 2;
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function Execute(Runtime $vm)
 {
     $value = $vm->getValue($this->args[0]);
     if ($value) {
         $vm->execStmts($this->args[1]);
     } else {
         if (isset($this->args[2])) {
             if (is_array($this->args[2])) {
                 /* else */
                 $vm->execStmts($this->args[2]);
             } else {
                 /* else if */
                 $vm->execute($this->args[2]);
             }
         }
     }
 }