コード例 #1
0
 function pushScope($type, $name, $variableFlag = 0)
 {
     if ($this->currentScope != null) {
         array_push($this->scopesStack, $this->currentScope);
     }
     switch ($type) {
         case CODE_SCOPE_GLOBAL:
             $newScope = new GlobalScope($name, $this->currentScope);
             break;
         case CODE_SCOPE_CLASS:
             $newScope = new ClassScope($name, $this->currentScope);
             break;
         case CODE_SCOPE_FUNCTION_PARAMETERS:
             $newScope = new FunctionParameterScope($name, $this->currentScope, $variableFlag);
             break;
         case CODE_SCOPE_FUNCTION:
             $newScope = new FunctionScope($name, $this->currentScope);
             break;
         case CODE_SCOPE_ARRAY:
             $newScope = new ArrayScope($name, $this->currentScope, $variableFlag);
             break;
         case CODE_SCOPE_CATCH:
             $newScope = new CatchScope($name, $this->currentScope);
             break;
         default:
             throw new \Exception("Unknown scope type [" . $type . "]");
             break;
     }
     if ($this->currentScope == null) {
         $this->rootScope = $newScope;
     } else {
         $this->currentScope->addChild($newScope);
     }
     $this->currentScope = $newScope;
     if ($type == CODE_SCOPE_CLASS) {
         $this->methodsStartIndex = 0;
     }
 }