src/share/vm/utilities/xmlstream.cpp

Fri, 29 Apr 2016 00:06:10 +0800

author
aoqi
date
Fri, 29 Apr 2016 00:06:10 +0800
changeset 1
2d8a650513c2
parent 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Added MIPS 64-bit port.

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #include "precompiled.hpp"
aoqi@0 26 #include "code/nmethod.hpp"
aoqi@0 27 #include "memory/allocation.hpp"
aoqi@0 28 #include "memory/allocation.inline.hpp"
aoqi@0 29 #include "oops/methodData.hpp"
aoqi@0 30 #include "oops/method.hpp"
aoqi@0 31 #include "oops/oop.inline.hpp"
aoqi@0 32 #include "runtime/deoptimization.hpp"
aoqi@0 33 #include "runtime/vmThread.hpp"
aoqi@0 34 #include "utilities/xmlstream.hpp"
aoqi@0 35
aoqi@0 36 void xmlStream::initialize(outputStream* out) {
aoqi@0 37 _out = out;
aoqi@0 38 _last_flush = 0;
aoqi@0 39 _markup_state = BODY;
aoqi@0 40 _text_init._outer_xmlStream = this;
aoqi@0 41 _text = &_text_init;
aoqi@0 42
aoqi@0 43 #ifdef ASSERT
aoqi@0 44 _element_depth = 0;
aoqi@0 45 int init_len = 100;
aoqi@0 46 char* init_buf = NEW_C_HEAP_ARRAY(char, init_len, mtInternal);
aoqi@0 47 _element_close_stack_low = init_buf;
aoqi@0 48 _element_close_stack_high = init_buf + init_len;
aoqi@0 49 _element_close_stack_ptr = init_buf + init_len - 1;
aoqi@0 50 _element_close_stack_ptr[0] = '\0';
aoqi@0 51 #endif
aoqi@0 52
aoqi@0 53 // Make sure each log uses the same base for time stamps.
aoqi@0 54 if (is_open()) {
aoqi@0 55 _out->time_stamp().update_to(1);
aoqi@0 56 }
aoqi@0 57 }
aoqi@0 58
aoqi@0 59 #ifdef ASSERT
aoqi@0 60 xmlStream::~xmlStream() {
aoqi@0 61 FREE_C_HEAP_ARRAY(char, _element_close_stack_low, mtInternal);
aoqi@0 62 }
aoqi@0 63 #endif
aoqi@0 64
aoqi@0 65 // Pass the given chars directly to _out.
aoqi@0 66 void xmlStream::write(const char* s, size_t len) {
aoqi@0 67 if (!is_open()) return;
aoqi@0 68
aoqi@0 69 out()->write(s, len);
aoqi@0 70 update_position(s, len);
aoqi@0 71 }
aoqi@0 72
aoqi@0 73
aoqi@0 74 // Pass the given chars directly to _out, except that
aoqi@0 75 // we watch for special "<&>" chars.
aoqi@0 76 // This is suitable for either attribute text or for body text.
aoqi@0 77 // We don't fool with "<![CDATA[" quotes, just single-character entities.
aoqi@0 78 // This makes it easier for dumb tools to parse the output.
aoqi@0 79 void xmlStream::write_text(const char* s, size_t len) {
aoqi@0 80 if (!is_open()) return;
aoqi@0 81
aoqi@0 82 size_t written = 0;
aoqi@0 83 // All normally printed material goes inside XML quotes.
aoqi@0 84 // This leaves the output free to include markup also.
aoqi@0 85 // Scan the string looking for inadvertant "<&>" chars
aoqi@0 86 for (size_t i = 0; i < len; i++) {
aoqi@0 87 char ch = s[i];
aoqi@0 88 // Escape special chars.
aoqi@0 89 const char* esc = NULL;
aoqi@0 90 switch (ch) {
aoqi@0 91 // These are important only in attrs, but we do them always:
aoqi@0 92 case '\'': esc = "&apos;"; break;
aoqi@0 93 case '"': esc = "&quot;"; break;
aoqi@0 94 case '<': esc = "&lt;"; break;
aoqi@0 95 case '&': esc = "&amp;"; break;
aoqi@0 96 // This is a freebie.
aoqi@0 97 case '>': esc = "&gt;"; break;
aoqi@0 98 }
aoqi@0 99 if (esc != NULL) {
aoqi@0 100 if (written < i) {
aoqi@0 101 out()->write(&s[written], i - written);
aoqi@0 102 written = i;
aoqi@0 103 }
aoqi@0 104 out()->print_raw(esc);
aoqi@0 105 written++;
aoqi@0 106 }
aoqi@0 107 }
aoqi@0 108
aoqi@0 109 // Print the clean remainder. Usually, it is all of s.
aoqi@0 110 if (written < len) {
aoqi@0 111 out()->write(&s[written], len - written);
aoqi@0 112 }
aoqi@0 113 }
aoqi@0 114
aoqi@0 115 // ------------------------------------------------------------------
aoqi@0 116 // Outputs XML text, with special characters quoted.
aoqi@0 117 void xmlStream::text(const char* format, ...) {
aoqi@0 118 va_list ap;
aoqi@0 119 va_start(ap, format);
aoqi@0 120 va_text(format, ap);
aoqi@0 121 va_end(ap);
aoqi@0 122 }
aoqi@0 123
aoqi@0 124 #define BUFLEN 2*K /* max size of output of individual print methods */
aoqi@0 125
aoqi@0 126 // ------------------------------------------------------------------
aoqi@0 127 void xmlStream::va_tag(bool push, const char* format, va_list ap) {
aoqi@0 128 assert_if_no_error(!inside_attrs(), "cannot print tag inside attrs");
aoqi@0 129 char buffer[BUFLEN];
aoqi@0 130 size_t len;
aoqi@0 131 const char* kind = do_vsnprintf(buffer, BUFLEN, format, ap, false, len);
aoqi@0 132 see_tag(kind, push);
aoqi@0 133 print_raw("<");
aoqi@0 134 write(kind, len);
aoqi@0 135 _markup_state = (push ? HEAD : ELEM);
aoqi@0 136 }
aoqi@0 137
aoqi@0 138 #ifdef ASSERT
aoqi@0 139 /// Debugging goo to make sure element tags nest properly.
aoqi@0 140
aoqi@0 141 // ------------------------------------------------------------------
aoqi@0 142 void xmlStream::see_tag(const char* tag, bool push) {
aoqi@0 143 assert_if_no_error(!inside_attrs(), "cannot start new element inside attrs");
aoqi@0 144 if (!push) return;
aoqi@0 145
aoqi@0 146 // tag goes up until either null or space:
aoqi@0 147 const char* tag_end = strchr(tag, ' ');
aoqi@0 148 size_t tag_len = (tag_end == NULL) ? strlen(tag) : tag_end - tag;
aoqi@0 149 assert(tag_len > 0, "tag must not be empty");
aoqi@0 150 // push the tag onto the stack, pulling down the pointer
aoqi@0 151 char* old_ptr = _element_close_stack_ptr;
aoqi@0 152 char* old_low = _element_close_stack_low;
aoqi@0 153 char* push_ptr = old_ptr - (tag_len+1);
aoqi@0 154 if (push_ptr < old_low) {
aoqi@0 155 int old_len = _element_close_stack_high - old_ptr;
aoqi@0 156 int new_len = old_len * 2;
aoqi@0 157 if (new_len < 100) new_len = 100;
aoqi@0 158 char* new_low = NEW_C_HEAP_ARRAY(char, new_len, mtInternal);
aoqi@0 159 char* new_high = new_low + new_len;
aoqi@0 160 char* new_ptr = new_high - old_len;
aoqi@0 161 memcpy(new_ptr, old_ptr, old_len);
aoqi@0 162 _element_close_stack_high = new_high;
aoqi@0 163 _element_close_stack_low = new_low;
aoqi@0 164 _element_close_stack_ptr = new_ptr;
aoqi@0 165 FREE_C_HEAP_ARRAY(char, old_low, mtInternal);
aoqi@0 166 push_ptr = new_ptr - (tag_len+1);
aoqi@0 167 }
aoqi@0 168 assert(push_ptr >= _element_close_stack_low, "in range");
aoqi@0 169 memcpy(push_ptr, tag, tag_len);
aoqi@0 170 push_ptr[tag_len] = 0;
aoqi@0 171 _element_close_stack_ptr = push_ptr;
aoqi@0 172 _element_depth += 1;
aoqi@0 173 }
aoqi@0 174
aoqi@0 175 // ------------------------------------------------------------------
aoqi@0 176 void xmlStream::pop_tag(const char* tag) {
aoqi@0 177 assert_if_no_error(!inside_attrs(), "cannot close element inside attrs");
aoqi@0 178 assert(_element_depth > 0, "must be in an element to close");
aoqi@0 179 assert(*tag != 0, "tag must not be empty");
aoqi@0 180 char* cur_tag = _element_close_stack_ptr;
aoqi@0 181 bool bad_tag = false;
aoqi@0 182 while (*cur_tag != 0 && strcmp(cur_tag, tag) != 0) {
aoqi@0 183 this->print_cr("</%s> <!-- missing closing tag -->", cur_tag);
aoqi@0 184 _element_close_stack_ptr = (cur_tag += strlen(cur_tag) + 1);
aoqi@0 185 _element_depth -= 1;
aoqi@0 186 bad_tag = true;
aoqi@0 187 }
aoqi@0 188 if (*cur_tag == 0) {
aoqi@0 189 bad_tag = true;
aoqi@0 190 } else {
aoqi@0 191 // Pop the stack, by skipping over the tag and its null.
aoqi@0 192 _element_close_stack_ptr = cur_tag + strlen(cur_tag) + 1;
aoqi@0 193 _element_depth -= 1;
aoqi@0 194 }
aoqi@0 195 if (bad_tag && !VMThread::should_terminate() && !VM_Exit::vm_exited() &&
aoqi@0 196 !is_error_reported())
aoqi@0 197 {
aoqi@0 198 assert(false, "bad tag in log");
aoqi@0 199 }
aoqi@0 200 }
aoqi@0 201 #endif
aoqi@0 202
aoqi@0 203
aoqi@0 204 // ------------------------------------------------------------------
aoqi@0 205 // First word in formatted string is element kind, and any subsequent
aoqi@0 206 // words must be XML attributes. Outputs "<kind .../>".
aoqi@0 207 void xmlStream::elem(const char* format, ...) {
aoqi@0 208 va_list ap;
aoqi@0 209 va_start(ap, format);
aoqi@0 210 va_elem(format, ap);
aoqi@0 211 va_end(ap);
aoqi@0 212 }
aoqi@0 213
aoqi@0 214 // ------------------------------------------------------------------
aoqi@0 215 void xmlStream::va_elem(const char* format, va_list ap) {
aoqi@0 216 va_begin_elem(format, ap);
aoqi@0 217 end_elem();
aoqi@0 218 }
aoqi@0 219
aoqi@0 220
aoqi@0 221 // ------------------------------------------------------------------
aoqi@0 222 // First word in formatted string is element kind, and any subsequent
aoqi@0 223 // words must be XML attributes. Outputs "<kind ...", not including "/>".
aoqi@0 224 void xmlStream::begin_elem(const char* format, ...) {
aoqi@0 225 va_list ap;
aoqi@0 226 va_start(ap, format);
aoqi@0 227 va_tag(false, format, ap);
aoqi@0 228 va_end(ap);
aoqi@0 229 }
aoqi@0 230
aoqi@0 231 // ------------------------------------------------------------------
aoqi@0 232 void xmlStream::va_begin_elem(const char* format, va_list ap) {
aoqi@0 233 va_tag(false, format, ap);
aoqi@0 234 }
aoqi@0 235
aoqi@0 236 // ------------------------------------------------------------------
aoqi@0 237 // Outputs "/>".
aoqi@0 238 void xmlStream::end_elem() {
aoqi@0 239 assert(_markup_state == ELEM, "misplaced end_elem");
aoqi@0 240 print_raw("/>\n");
aoqi@0 241 _markup_state = BODY;
aoqi@0 242 }
aoqi@0 243
aoqi@0 244 // ------------------------------------------------------------------
aoqi@0 245 // Outputs formatted text, followed by "/>".
aoqi@0 246 void xmlStream::end_elem(const char* format, ...) {
aoqi@0 247 va_list ap;
aoqi@0 248 va_start(ap, format);
aoqi@0 249 out()->vprint(format, ap);
aoqi@0 250 va_end(ap);
aoqi@0 251 end_elem();
aoqi@0 252 }
aoqi@0 253
aoqi@0 254
aoqi@0 255 // ------------------------------------------------------------------
aoqi@0 256 // First word in formatted string is element kind, and any subsequent
aoqi@0 257 // words must be XML attributes. Outputs "<kind ...>".
aoqi@0 258 void xmlStream::head(const char* format, ...) {
aoqi@0 259 va_list ap;
aoqi@0 260 va_start(ap, format);
aoqi@0 261 va_head(format, ap);
aoqi@0 262 va_end(ap);
aoqi@0 263 }
aoqi@0 264
aoqi@0 265 // ------------------------------------------------------------------
aoqi@0 266 void xmlStream::va_head(const char* format, va_list ap) {
aoqi@0 267 va_begin_head(format, ap);
aoqi@0 268 end_head();
aoqi@0 269 }
aoqi@0 270
aoqi@0 271 // ------------------------------------------------------------------
aoqi@0 272 // First word in formatted string is element kind, and any subsequent
aoqi@0 273 // words must be XML attributes. Outputs "<kind ...", not including ">".
aoqi@0 274 void xmlStream::begin_head(const char* format, ...) {
aoqi@0 275 va_list ap;
aoqi@0 276 va_start(ap, format);
aoqi@0 277 va_tag(true, format, ap);
aoqi@0 278 va_end(ap);
aoqi@0 279 }
aoqi@0 280
aoqi@0 281 // ------------------------------------------------------------------
aoqi@0 282 void xmlStream::va_begin_head(const char* format, va_list ap) {
aoqi@0 283 va_tag(true, format, ap);
aoqi@0 284 }
aoqi@0 285
aoqi@0 286 // ------------------------------------------------------------------
aoqi@0 287 // Outputs ">".
aoqi@0 288 void xmlStream::end_head() {
aoqi@0 289 assert(_markup_state == HEAD, "misplaced end_head");
aoqi@0 290 print_raw(">\n");
aoqi@0 291 _markup_state = BODY;
aoqi@0 292 }
aoqi@0 293
aoqi@0 294
aoqi@0 295 // ------------------------------------------------------------------
aoqi@0 296 // Outputs formatted text, followed by ">".
aoqi@0 297 void xmlStream::end_head(const char* format, ...) {
aoqi@0 298 va_list ap;
aoqi@0 299 va_start(ap, format);
aoqi@0 300 out()->vprint(format, ap);
aoqi@0 301 va_end(ap);
aoqi@0 302 end_head();
aoqi@0 303 }
aoqi@0 304
aoqi@0 305
aoqi@0 306 // ------------------------------------------------------------------
aoqi@0 307 // Outputs "</kind>".
aoqi@0 308 void xmlStream::tail(const char* kind) {
aoqi@0 309 pop_tag(kind);
aoqi@0 310 print_raw("</");
aoqi@0 311 print_raw(kind);
aoqi@0 312 print_raw(">\n");
aoqi@0 313 }
aoqi@0 314
aoqi@0 315 // ------------------------------------------------------------------
aoqi@0 316 // Outputs "<kind_done ... stamp='D.DD'/> </kind>".
aoqi@0 317 void xmlStream::done(const char* format, ...) {
aoqi@0 318 va_list ap;
aoqi@0 319 va_start(ap, format);
aoqi@0 320 va_done(format, ap);
aoqi@0 321 va_end(ap);
aoqi@0 322 }
aoqi@0 323
aoqi@0 324 // ------------------------------------------------------------------
aoqi@0 325 // Outputs "<kind_done stamp='D.DD'/> </kind>".
aoqi@0 326 // Because done_raw() doesn't need to format strings, it's simpler than
aoqi@0 327 // done(), and can be called safely by fatal error handler.
aoqi@0 328 void xmlStream::done_raw(const char* kind) {
aoqi@0 329 print_raw("<");
aoqi@0 330 print_raw(kind);
aoqi@0 331 print_raw("_done stamp='");
aoqi@0 332 out()->stamp();
aoqi@0 333 print_raw_cr("'/>");
aoqi@0 334 print_raw("</");
aoqi@0 335 print_raw(kind);
aoqi@0 336 print_raw_cr(">");
aoqi@0 337 }
aoqi@0 338
aoqi@0 339 PRAGMA_DIAG_PUSH
aoqi@0 340 PRAGMA_FORMAT_NONLITERAL_IGNORED
aoqi@0 341 // ------------------------------------------------------------------
aoqi@0 342 void xmlStream::va_done(const char* format, va_list ap) {
aoqi@0 343 char buffer[200];
aoqi@0 344 guarantee(strlen(format) + 10 < sizeof(buffer), "bigger format buffer");
aoqi@0 345 const char* kind = format;
aoqi@0 346 const char* kind_end = strchr(kind, ' ');
aoqi@0 347 size_t kind_len = (kind_end != NULL) ? (kind_end - kind) : strlen(kind);
aoqi@0 348 strncpy(buffer, kind, kind_len);
aoqi@0 349 strcpy(buffer + kind_len, "_done");
aoqi@0 350 strcat(buffer, format + kind_len);
aoqi@0 351 // Output the trailing event with the timestamp.
aoqi@0 352 va_begin_elem(buffer, ap);
aoqi@0 353 stamp();
aoqi@0 354 end_elem();
aoqi@0 355 // Output the tail-tag of the enclosing element.
aoqi@0 356 buffer[kind_len] = 0;
aoqi@0 357 tail(buffer);
aoqi@0 358 }
aoqi@0 359 PRAGMA_DIAG_POP
aoqi@0 360
aoqi@0 361 // Output a timestamp attribute.
aoqi@0 362 void xmlStream::stamp() {
aoqi@0 363 assert_if_no_error(inside_attrs(), "stamp must be an attribute");
aoqi@0 364 print_raw(" stamp='");
aoqi@0 365 out()->stamp();
aoqi@0 366 print_raw("'");
aoqi@0 367 }
aoqi@0 368
aoqi@0 369
aoqi@0 370 // ------------------------------------------------------------------
aoqi@0 371 // Output a method attribute, in the form " method='pkg/cls name sig'".
aoqi@0 372 // This is used only when there is no ciMethod available.
aoqi@0 373 void xmlStream::method(methodHandle method) {
aoqi@0 374 assert_if_no_error(inside_attrs(), "printing attributes");
aoqi@0 375 if (method.is_null()) return;
aoqi@0 376 print_raw(" method='");
aoqi@0 377 method_text(method);
aoqi@0 378 print("' bytes='%d'", method->code_size());
aoqi@0 379 print(" count='%d'", method->invocation_count());
aoqi@0 380 int bec = method->backedge_count();
aoqi@0 381 if (bec != 0) print(" backedge_count='%d'", bec);
aoqi@0 382 print(" iicount='%d'", method->interpreter_invocation_count());
aoqi@0 383 int throwouts = method->interpreter_throwout_count();
aoqi@0 384 if (throwouts != 0) print(" throwouts='%d'", throwouts);
aoqi@0 385 MethodData* mdo = method->method_data();
aoqi@0 386 if (mdo != NULL) {
aoqi@0 387 uint cnt;
aoqi@0 388 cnt = mdo->decompile_count();
aoqi@0 389 if (cnt != 0) print(" decompiles='%d'", cnt);
aoqi@0 390 for (uint reason = 0; reason < mdo->trap_reason_limit(); reason++) {
aoqi@0 391 cnt = mdo->trap_count(reason);
aoqi@0 392 if (cnt != 0) print(" %s_traps='%d'", Deoptimization::trap_reason_name(reason), cnt);
aoqi@0 393 }
aoqi@0 394 cnt = mdo->overflow_trap_count();
aoqi@0 395 if (cnt != 0) print(" overflow_traps='%d'", cnt);
aoqi@0 396 cnt = mdo->overflow_recompile_count();
aoqi@0 397 if (cnt != 0) print(" overflow_recompiles='%d'", cnt);
aoqi@0 398 }
aoqi@0 399 }
aoqi@0 400
aoqi@0 401 void xmlStream::method_text(methodHandle method) {
aoqi@0 402 assert_if_no_error(inside_attrs(), "printing attributes");
aoqi@0 403 if (method.is_null()) return;
aoqi@0 404 //method->print_short_name(text());
aoqi@0 405 method->method_holder()->name()->print_symbol_on(text());
aoqi@0 406 print_raw(" "); // " " is easier for tools to parse than "::"
aoqi@0 407 method->name()->print_symbol_on(text());
aoqi@0 408 print_raw(" "); // separator
aoqi@0 409 method->signature()->print_symbol_on(text());
aoqi@0 410 }
aoqi@0 411
aoqi@0 412
aoqi@0 413 // ------------------------------------------------------------------
aoqi@0 414 // Output a klass attribute, in the form " klass='pkg/cls'".
aoqi@0 415 // This is used only when there is no ciKlass available.
aoqi@0 416 void xmlStream::klass(KlassHandle klass) {
aoqi@0 417 assert_if_no_error(inside_attrs(), "printing attributes");
aoqi@0 418 if (klass.is_null()) return;
aoqi@0 419 print_raw(" klass='");
aoqi@0 420 klass_text(klass);
aoqi@0 421 print_raw("'");
aoqi@0 422 }
aoqi@0 423
aoqi@0 424 void xmlStream::klass_text(KlassHandle klass) {
aoqi@0 425 assert_if_no_error(inside_attrs(), "printing attributes");
aoqi@0 426 if (klass.is_null()) return;
aoqi@0 427 //klass->print_short_name(log->out());
aoqi@0 428 klass->name()->print_symbol_on(out());
aoqi@0 429 }
aoqi@0 430
aoqi@0 431 void xmlStream::name(const Symbol* name) {
aoqi@0 432 assert_if_no_error(inside_attrs(), "printing attributes");
aoqi@0 433 if (name == NULL) return;
aoqi@0 434 print_raw(" name='");
aoqi@0 435 name_text(name);
aoqi@0 436 print_raw("'");
aoqi@0 437 }
aoqi@0 438
aoqi@0 439 void xmlStream::name_text(const Symbol* name) {
aoqi@0 440 assert_if_no_error(inside_attrs(), "printing attributes");
aoqi@0 441 if (name == NULL) return;
aoqi@0 442 //name->print_short_name(text());
aoqi@0 443 name->print_symbol_on(text());
aoqi@0 444 }
aoqi@0 445
aoqi@0 446 void xmlStream::object(const char* attr, Handle x) {
aoqi@0 447 assert_if_no_error(inside_attrs(), "printing attributes");
aoqi@0 448 if (x == NULL) return;
aoqi@0 449 print_raw(" ");
aoqi@0 450 print_raw(attr);
aoqi@0 451 print_raw("='");
aoqi@0 452 object_text(x);
aoqi@0 453 print_raw("'");
aoqi@0 454 }
aoqi@0 455
aoqi@0 456 void xmlStream::object_text(Handle x) {
aoqi@0 457 assert_if_no_error(inside_attrs(), "printing attributes");
aoqi@0 458 if (x == NULL) return;
aoqi@0 459 x->print_value_on(text());
aoqi@0 460 }
aoqi@0 461
aoqi@0 462
aoqi@0 463 void xmlStream::object(const char* attr, Metadata* x) {
aoqi@0 464 assert_if_no_error(inside_attrs(), "printing attributes");
aoqi@0 465 if (x == NULL) return;
aoqi@0 466 print_raw(" ");
aoqi@0 467 print_raw(attr);
aoqi@0 468 print_raw("='");
aoqi@0 469 object_text(x);
aoqi@0 470 print_raw("'");
aoqi@0 471 }
aoqi@0 472
aoqi@0 473 void xmlStream::object_text(Metadata* x) {
aoqi@0 474 assert_if_no_error(inside_attrs(), "printing attributes");
aoqi@0 475 if (x == NULL) return;
aoqi@0 476 //x->print_value_on(text());
aoqi@0 477 if (x->is_method())
aoqi@0 478 method_text((Method*)x);
aoqi@0 479 else if (x->is_klass())
aoqi@0 480 klass_text((Klass*)x);
aoqi@0 481 else
aoqi@0 482 ShouldNotReachHere(); // Add impl if this is reached.
aoqi@0 483 }
aoqi@0 484
aoqi@0 485
aoqi@0 486 void xmlStream::flush() {
aoqi@0 487 out()->flush();
aoqi@0 488 _last_flush = count();
aoqi@0 489 }
aoqi@0 490
aoqi@0 491 void xmlTextStream::flush() {
aoqi@0 492 if (_outer_xmlStream == NULL) return;
aoqi@0 493 _outer_xmlStream->flush();
aoqi@0 494 }
aoqi@0 495
aoqi@0 496 void xmlTextStream::write(const char* str, size_t len) {
aoqi@0 497 if (_outer_xmlStream == NULL) return;
aoqi@0 498 _outer_xmlStream->write_text(str, len);
aoqi@0 499 update_position(str, len);
aoqi@0 500 }

mercurial