public function register($element) { if (!is_a($element, 'LangElement')) { throw CainException::for_element($element); } // Don't need to verify uniqueness, that's been done by CainInterpreter if (is_a($element, 'LangContainer') && $element->name !== null) { $this->containers_by_name[$element->name] = $element; } if ($element->unique !== null) { $this->by_unique[$element->unique] = $element; } return $element; }
public function bind_execs($ba, $lang_parent) { if (!$this->lang_element) { throw CainException::for_element($this, "Unable to bind statements for \"{$this->get_name_ref}()}\": no language element defined"); } // prevent reentrancy if ($this->bound_stmts) { return $this->lang_element; } $this->bound_stmts = true; $ba->push($this); $this->bind_softrefs_stmts($ba, $lang_parent, $this->lang_element); $ba->pop(); return $this->lang_element; }
public function set_stmts($lang_parent, $stmts) { $this->parent = $lang_parent; $this->stmts = $stmts; if ($this->is_builtin()) { // if builtin, verify parent has defined it ... because :bind is invoked at the end of the // interpretation process, this is static analysis of code and not determined at execution time if ($this->is_static && !$this->parent->has_static_message($this->name)) { throw CainException::for_element($this, "Builtin static message \"{$this->parent->name}:{$this->name}\" not defined"); } else { if (!$this->is_static && !$this->parent->has_instance_message($this->name)) { throw CainException::for_element($this, "Builtin instance message \"{$this->parent->name}:{$this->name}\" not defined"); } } } }
/** * All BindElements created during the interpretation process must be registered with this * binding agent, which is then in turn passed to all elements during the bind() process. */ public function register_element($element) { if (!is_a($element, 'BindElement')) { throw CainException::for_element($element, 'Unable to register element of type ' . get_class($element)); } if (is_a($element, 'BindContainer')) { $this->all_containers_by_unique[$element->softref->checked_unique()] = $element; if (isset($element->name)) { // name uniqueness if (isset($this->all_containers_by_name[$element->name])) { throw CainException::for_element($element, "Container \"{$element->name}\" already defined"); } $this->all_containers_by_name[$element->name] = $element; } } if (is_a($element, 'BindLiteral')) { $this->all_literals[$element->softref->checked_unique()] = $element; } $this->all_elements_by_unique[$element->softref->checked_unique()] = $element; }