You are here

public function SassFunctionDefinitionNode::execute in Sassy 7.3

File

phpsass/tree/SassFunctionDefinitionNode.php, line 91

Class

SassFunctionDefinitionNode
SassFunctionDefinitionNode class. Represents a Function definition. @package PHamlP @subpackage Sass.tree

Code

public function execute($pcontext, $arguments) {

  // print "execute " . $this->name . "\n";
  $context = new SassContext($pcontext);
  $argc = count($arguments);
  $count = 0;
  foreach ($this->args as $name => $value) {
    if ($count < $argc) {
      $arg = $this
        ->evaluate($arguments[$count++], $context);
      $arguments[$name] = $arg;
      $context
        ->setVariable($name, $arg);
    }
    elseif (!is_null($value)) {
      $arguments[$name] = $value;
      $context
        ->setVariable($name, $this
        ->evaluate($value, $context));
    }
    else {
      throw new SassMixinNodeException("Function::{$name}: Required variable ({$name}) not given.\nFunction defined: ' . {$this->token}->filename . '::' . {$this->token}->line . '\nFunction used", $this);
    }
  }
  $parser = $this->parent->parser;
  $lexer = $this->parent->script->lexer;
  $children = array();
  try {
    foreach ($this->children as $child) {
      $child->parent = $this;
      $children = array_merge($children, $child
        ->parse($context));
    }
  } catch (SassReturn $e) {
    return $e->value;
  }
  return new SassBoolean('false');
}