From 04a3c882271c4984f7ddc24ee5aeb4ae2a354933 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sun, 6 Nov 2011 20:26:10 -0800 Subject: [PATCH] vm: readable feps for more types --- vm/debug.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++- vm/vm.hpp | 2 ++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/vm/debug.cpp b/vm/debug.cpp index 0349e3ff25..52db681f41 100755 --- a/vm/debug.cpp +++ b/vm/debug.cpp @@ -54,6 +54,46 @@ void factor_vm::print_array(array *array, cell nesting) std::cout << "..."; } +void factor_vm::print_alien(alien *alien, cell nesting) +{ + if (to_boolean(alien->expired)) + std::cout << "#"; + else if (to_boolean(alien->base)) + { + std::cout << "#displacement << "+"; + print_nested_obj(alien->base, nesting); + std::cout << ">"; + } + else + { + std::cout << "#address << ">"; + } +} + +void factor_vm::print_byte_array(byte_array *array, cell nesting) +{ + cell length = array->capacity; + cell i; + bool trimmed; + unsigned char *data = array->data(); + + if(length > 16 && !full_output) + { + trimmed = true; + length = 16; + } + else + trimmed = false; + + for(i = 0; i < length; i++) + { + std::cout << " " << (unsigned)data[i]; + } + + if(trimmed) + std::cout << "..."; +} + void factor_vm::print_tuple(tuple *tuple, cell nesting) { tuple_layout *layout = untag(tuple->layout); @@ -96,6 +136,9 @@ void factor_vm::print_nested_obj(cell obj, fixnum nesting) case FIXNUM_TYPE: std::cout << untag_fixnum(obj); break; + case FLOAT_TYPE: + std::cout << untag_float(obj); + break; case WORD_TYPE: print_word(untag(obj),nesting - 1); break; @@ -110,6 +153,16 @@ void factor_vm::print_nested_obj(cell obj, fixnum nesting) print_tuple(untag(obj),nesting - 1); std::cout << " }"; break; + case WRAPPER_TYPE: + std::cout << "W{ "; + print_nested_obj(untag(obj)->object,nesting - 1); + std::cout << " }"; + break; + case BYTE_ARRAY_TYPE: + std::cout << "B{"; + print_byte_array(untag(obj),nesting - 1); + std::cout << " }"; + break; case ARRAY_TYPE: std::cout << "{"; print_array(untag(obj),nesting - 1); @@ -121,8 +174,11 @@ void factor_vm::print_nested_obj(cell obj, fixnum nesting) print_array(untag(quot->array),nesting - 1); std::cout << " ]"; break; + case ALIEN_TYPE: + print_alien(untag(obj), nesting - 1); + break; default: - std::cout << "#<" << type_name(tagged(obj).type()) << " "; + std::cout << "#<" << type_name(tagged(obj).type()) << " @ "; std::cout << (void*)obj << ">"; break; } diff --git a/vm/vm.hpp b/vm/vm.hpp index 9004364b37..6ba860c230 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -394,7 +394,9 @@ struct factor_vm void print_word(word* word, cell nesting); void print_factor_string(string* str); void print_array(array* array, cell nesting); + void print_byte_array(byte_array *array, cell nesting); void print_tuple(tuple *tuple, cell nesting); + void print_alien(alien *alien, cell nesting); void print_nested_obj(cell obj, fixnum nesting); void print_obj(cell obj); void print_objects(cell *start, cell *end);