Пример #1
0
 static function itemToString($b, $s)
 {
     $»t = $s;
     switch ($»t->index) {
         case 0:
             $b->b .= "a C function";
             break;
         case 1:
             $m = $»t->params[0];
             $b->b .= "module ";
             $b->b .= $m;
             break;
         case 2:
             $line = $»t->params[2];
             $file = $»t->params[1];
             $s1 = $»t->params[0];
             if ($s1 !== null) {
                 haxe_Stack::itemToString($b, $s1);
                 $b->b .= " (";
             }
             $b->b .= $file;
             $b->b .= " line ";
             $b->b .= $line;
             if ($s1 !== null) {
                 $b->b .= ")";
             }
             break;
         case 3:
             $meth = $»t->params[1];
             $cname = $»t->params[0];
             $b->b .= $cname;
             $b->b .= ".";
             $b->b .= $meth;
             break;
         case 4:
             $n = $»t->params[0];
             $b->b .= "local function #";
             $b->b .= $n;
             break;
     }
 }
Пример #2
0
 static function run($app)
 {
     sinatra_Base::$request = new sinatra_Request();
     haxe_Log::trace(sinatra_Base::$request, _hx_anonymous(array("fileName" => "Base.hx", "lineNumber" => 56, "className" => "sinatra.Base", "methodName" => "run")));
     $route = null;
     $»it = sinatra_Base::$_routes->get(sinatra_Base::$request->method)->iterator();
     while ($»it->hasNext()) {
         $r = $»it->next();
         if (sinatra_Route::match($r->route, sinatra_Base::$request->path)) {
             $route = $r;
             break;
         }
     }
     if ($route === null) {
         throw new HException("Found no route matching \"" . sinatra_Base::$request->path . "\"");
     }
     $view = null;
     try {
         $view = $route->call();
     } catch (Exception $»e) {
         $_ex_ = $»e instanceof HException ? $»e->e : $»e;
         if (is_int($code = $_ex_)) {
             haxe_Log::trace("CODE:" . Std::string($code), _hx_anonymous(array("fileName" => "Base.hx", "lineNumber" => 76, "className" => "sinatra.Base", "methodName" => "run")));
         } else {
             if (is_string($err = $_ex_)) {
                 haxe_Log::trace("ERR:" . $err . " stack: " . haxe_Stack::toString(haxe_Stack::exceptionStack()), _hx_anonymous(array("fileName" => "Base.hx", "lineNumber" => 78, "className" => "sinatra.Base", "methodName" => "run")));
             } else {
                 $other = $_ex_;
                 haxe_Log::trace("WARN:" . Std::string($other), _hx_anonymous(array("fileName" => "Base.hx", "lineNumber" => 80, "className" => "sinatra.Base", "methodName" => "run")));
             }
         }
     }
     if ($view !== null) {
         $view->render();
     }
     return 0;
 }