예제 #1
0
 /**
  * Returns the value of the variable with given name in current/parent scope. If it does not
  * exist, a new one is created (but not stored in scope).
  * 
  * @param PC_Obj_MultiType $var the variable-name
  * @param bool $parent whether to search in the parent scope
  * @return PC_Obj_Variable the variable
  */
 public function get_var($var, $parent = false)
 {
     if (!$var instanceof PC_Obj_MultiType) {
         return $this->create_var('', $this->handle_error('$var is invalid'));
     }
     $name = $var->get_string();
     if ($name == null) {
         return $this->create_var();
     }
     if ($name == 'this') {
         $res = PC_Obj_Variable::create_object($this->get_file(), $this->get_line(), $this->scope->get_name_of(T_CLASS_C, $parent));
         return $res;
     }
     $scopename = $this->scope->get_name($parent);
     if (!$this->vars->exists($scopename, $name)) {
         $type = $this->create_unknown();
         $type->set_missing_varname($name);
         return $this->create_var($name, $type);
     }
     return $this->vars->get($scopename, $name);
 }