/**
  * Creates a backup of the given variable, if necessary
  * 
  * @param PC_Obj_Variable $var the variable
  * @param PC_Engine_Scope $scope the current scope
  */
 public function backup($var, $scope)
 {
     if (count($this->layers) > 0) {
         $varname = $var->get_name();
         if ($varname) {
             $layer =& $this->layers[count($this->layers) - 1];
             $blockno = $layer['blockno'];
             if (!isset($layer['vars'][$blockno][$varname])) {
                 // don't use null because isset() is false if the value is null
                 $clone = isset($this->vars[$scope->get_name()][$varname]) ? clone $var : 0;
                 $layer['vars'][$blockno][$varname] = $clone;
             }
         }
     }
 }
Example #2
0
 /**
  * Handles the given binary-assignment-operator
  * 
  * @param string $op the operator (+,-,...)
  * @param PC_Obj_Variable $var the variable
  * @param PC_Obj_MultiType $e the expression
  * @return PC_Obj_MultiType the result
  */
 public function handle_bin_assign_op($op, $var, $e)
 {
     if (!$var instanceof PC_Obj_Variable) {
         return $this->handle_error('$var is invalid');
     }
     if (!$e instanceof PC_Obj_MultiType) {
         return $this->handle_error('$e is invalid');
     }
     // it does not exist, if it's not a local/global variable, e.g., a class field
     if ($this->vars->exists($this->scope->get_name(), $var->get_name())) {
         // since the variable does not occur literally in the code, we have to emulate a read access
         $this->vars->get($this->scope->get_name(), $var->get_name());
     }
     $res = $this->handle_bin_op($op, $var->get_type(), $e);
     $this->set_var($var, $res, true);
     return $res;
 }
Example #3
0
 /**
  * Builds an instance of PC_Obj_Variable from the given row
  *
  * @param array $row the row from the db
  * @return PC_Obj_Variable the var
  */
 private function build_var($row)
 {
     $var = PC_Obj_Variable::create_from_scope($row['file'], $row['line'], $row['name'], unserialize($row['type']), $row['scope']);
     $var->set_id($row['id']);
     return $var;
 }