source: Dev/trunk/src/client/util/docscripts/lib/parser2/JavaScriptVariable.php

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.5 KB
Line 
1<?php
2
3require_once('Destructable.php');
4
5class JavaScriptVariable extends Destructable {
6  protected $variable;
7  protected $resolved_variables;
8  protected $global_scope;
9
10  public function __construct($variable, $instantiated = FALSE) {
11    $this->variable = $variable;
12  }
13
14  public function __destruct() {
15    $this->mem_flush('variable', 'resolved_variables', 'global_scope');
16  }
17
18  private function resolve() {
19    if (!$this->variable->is_lookup()) {
20      $this->global_scope = FALSE;
21      $this->resolved_variables = array();
22    }
23    else {
24      foreach ($this->variable->resolve(TRUE) as $resolved) {
25        list($global_scope, $variable) = $resolved;
26        if ($global_scope) {
27          $this->global_scope = TRUE;
28        }
29        $this->resolved_variables[] = $variable;
30      }
31    }
32  }
33
34  public function value() {
35    if (!isset($this->resolved_variables)) {
36      $this->resolve();
37    }
38    return count($this->resolved_variables) ? $this->resolved_variables[0] : NULL;
39  }
40
41  public function values() {
42    if (!isset($this->resolved_variables)) {
43      $this->resolve();
44    }
45    return is_array($this->resolved_variables) ? $this->resolved_variables : array();
46  }
47
48  public function type() {
49    // TODO: Things that receive this value should reassign to aliases as appropriate
50    return 'variable';
51  }
52
53  public function is_global () {
54    if (!isset($this->global_scope)) {
55      $this->resolve();
56    }
57    return !!$this->global_scope;
58  }
59
60  public function __toString() {
61    return '(' . $this->type() . ')';
62  }
63}
Note: See TracBrowser for help on using the repository browser.