<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv='Content-Type' content='text/html; charset=EUC-JP'>

<style type="text/css">

* {
  margin: 0px;
  padding: 0px;
}

body {
  margin: 5px;
  padding: 0px;
}

/* タイトル */
.caption {
  font-size: 12pt;
  font-weight: bold;
  color: #666666;
  padding: 2px;
  margin-bottom: 10px;
  border-left: 15px #555555 solid;
  border-bottom: 1px #555555 solid;
}

/* 例外スタック */
/* バックトレース */
.backtrace {
  width: 930px;
  margin-bottom: 10px;
}

div.backtrace_row_level {
  background-color: orange;
  color: white;
  font-size: 9pt;
  width: 20px;
  height: 250px;
  text-align: center;
  display: inline;
}

div.backtrace_row_level_caption {
  margin: 5px;
}

div.backtrace_row {
  background-color: #FFF68F;
  margin: 5px;
}

.backtrace_row_detail {
  vertical-align: top;
  display: inline;
  width: 900px;
}

.backtrace_spec {
  text-align: left;
  border-bottom: 1px silver solid;
  height: 20px;
}

.backtrace_history {
  text-align: left;
  border-bottom: 1px silver solid;
  height: 20px;
}

.backtrace_source {
  text-align: left;
  height: 200px;
}


.backtrace_header {
  background-color: #CD950C;
  color: white;
  font-size: 9pt;
  height: 20px;
  width: 100px;
  text-align: center;
  float: left;
  padding: 2px;
}

.backtrace_detail {
  color: darkblue;
  font-size: 9pt;
  padding: 2px;
  width: 770px;
  float: right;
  text-align: left;
  background-color: transparent; 
}


/* ソースコード */
.source_code {
  font-family: 'Courier New', Arial, Tahoma, Verdana;
  font-size: 10pt;
}

.line_no {
  width: 50px;
  color: blue;
  font-weight: bold;
  text-align: right;
  margin-right: 10px;
}

.even {
  background-color: #EEFEEF;
}

.odd {
  background-color: #DDEDDE;
}

.keyword {
  color: orange;
  font-weight: bold;
}

.comment {
  color: green;
  font-weight: bold;
}

.identifier {
  color: teal;
  font-weight: bold;
}

.const_string {
  color: darkblue;
  font-weight: bold;
}

</style>

</HEAD>
<BODY>

<div class="caption">例外スタック</div>
<div class="backtrace">

<?php
$backtrace = NULL;
$details = NULL;

$level = 0;
while( !ExceptionStack::isEmpty() )
{
	list( $e, $file, $line ) = ExceptionStack::pop();
	$src = new PhpSourceInfo( $file, $line );
	$class_name  = get_class($e);
	$message     = $e->getMessage();

	if ( $e instanceof CharcoalException ){
		$backtrace = $e->getBackTrace();
		$details = $backtrace->build();
	}

	print "<div class=\"backtrace_row\">" . PHP_EOL;

	// レベル
	print "  <div class=\"backtrace_row_level\">" . PHP_EOL;
	print "    <div class=\"backtrace_row_level_caption\">$level</div>" . PHP_EOL;
	print "  </div>" . PHP_EOL;

	print "  <div class=\"backtrace_row_detail\">" . PHP_EOL;

	// 例外
	print "    <div class=\"backtrace_spec\">" . PHP_EOL;
	print "      <div class=\"backtrace_header\">例外クラス名</div>" . PHP_EOL;
	print "      <div class=\"backtrace_detail\">$class_name</div>" . PHP_EOL;
	print "    </div>" . PHP_EOL;

	// メッセージ
	print "    <div class=\"backtrace_history\">" . PHP_EOL;
	print "      <div class=\"backtrace_header\">メッセージ</div>" . PHP_EOL;
	print "      <div class=\"backtrace_detail\">$message</div>" . PHP_EOL;
	print "    </div>" . PHP_EOL;

	// ソース
	print "    <div class=\"backtrace_source\">" . PHP_EOL;
	print "      <div class=\"backtrace_header\">ソース</div>" . PHP_EOL;
	print "      <div class=\"backtrace_detail\">$file($line)</div>" . PHP_EOL;
	print "      <br style=\clear:both;\" /><br>" . PHP_EOL;
	print "      $src" . PHP_EOL;
	print "    </div>" . PHP_EOL;

	print "  </div>" . PHP_EOL;

	print "</div>" . PHP_EOL;

	$level ++;
}
print "</div>" . PHP_EOL;

?>
</div>


<P>

<div class="caption">バックトレース</div>
<div class="backtrace">

<?php
foreach( $details as $level => $trace )
{
	$spec = $trace->getSpec();
	$hist = $trace->getHistory();
	$src  = $trace->getSource();

	$file = $src->getFile();
	$line = $src->getLine();

	print "<div class=\"backtrace_row\">" . PHP_EOL;

	// レベル
	print "  <div class=\"backtrace_row_level\">" . PHP_EOL;
	print "    <div class=\"backtrace_row_level_caption\">$level</div>" . PHP_EOL;
	print "  </div>" . PHP_EOL;

	print "  <div class=\"backtrace_row_detail\">" . PHP_EOL;

	// 仕様
	print "    <div class=\"backtrace_spec\">" . PHP_EOL;
	print "      <div class=\"backtrace_header\">関数名</div>" . PHP_EOL;
	print "      <div class=\"backtrace_detail\">$spec</div>" . PHP_EOL;
	print "    </div>" . PHP_EOL;
	// 引数
	print "    <div class=\"backtrace_history\">" . PHP_EOL;
	print "      <div class=\"backtrace_header\">引数</div>" . PHP_EOL;
	print "      <div class=\"backtrace_detail\">$hist</div>" . PHP_EOL;
	print "    </div>" . PHP_EOL;
	// ソース
	print "    <div class=\"backtrace_source\">" . PHP_EOL;
	print "      <div class=\"backtrace_header\">ソース</div>" . PHP_EOL;
	print "      <div class=\"backtrace_detail\">$file($line)</div>" . PHP_EOL;
	print "      <br style=\clear:both;\" /><br>" . PHP_EOL;
	print "      $src" . PHP_EOL;
	print "    </div>" . PHP_EOL;

	print "  </div>" . PHP_EOL;

	print "</div>" . PHP_EOL;
}
?>

</div>

</body>
</html>
