Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: src/objects-printer.cc

Issue 9572008: Implement date library functions in C++. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 case JS_GLOBAL_OBJECT_TYPE: 144 case JS_GLOBAL_OBJECT_TYPE:
145 JSGlobalObject::cast(this)->JSGlobalObjectPrint(out); 145 JSGlobalObject::cast(this)->JSGlobalObjectPrint(out);
146 break; 146 break;
147 case JS_BUILTINS_OBJECT_TYPE: 147 case JS_BUILTINS_OBJECT_TYPE:
148 JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out); 148 JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out);
149 break; 149 break;
150 case JS_VALUE_TYPE: 150 case JS_VALUE_TYPE:
151 PrintF(out, "Value wrapper around:"); 151 PrintF(out, "Value wrapper around:");
152 JSValue::cast(this)->value()->Print(out); 152 JSValue::cast(this)->value()->Print(out);
153 break; 153 break;
154 case JS_DATE_TYPE:
155 JSDate::cast(this)->value()->Print(out);
156 break;
154 case CODE_TYPE: 157 case CODE_TYPE:
155 Code::cast(this)->CodePrint(out); 158 Code::cast(this)->CodePrint(out);
156 break; 159 break;
157 case JS_PROXY_TYPE: 160 case JS_PROXY_TYPE:
158 JSProxy::cast(this)->JSProxyPrint(out); 161 JSProxy::cast(this)->JSProxyPrint(out);
159 break; 162 break;
160 case JS_FUNCTION_PROXY_TYPE: 163 case JS_FUNCTION_PROXY_TYPE:
161 JSFunctionProxy::cast(this)->JSFunctionProxyPrint(out); 164 JSFunctionProxy::cast(this)->JSFunctionProxyPrint(out);
162 break; 165 break;
163 case JS_WEAK_MAP_TYPE: 166 case JS_WEAK_MAP_TYPE:
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 // This also means that previous results will be overwritten. 656 // This also means that previous results will be overwritten.
654 static char* buffer = NULL; 657 static char* buffer = NULL;
655 if (buffer != NULL) free(buffer); 658 if (buffer != NULL) free(buffer);
656 buffer = new char[length()+1]; 659 buffer = new char[length()+1];
657 WriteToFlat(this, buffer, 0, length()); 660 WriteToFlat(this, buffer, 0, length());
658 buffer[length()] = 0; 661 buffer[length()] = 0;
659 return buffer; 662 return buffer;
660 } 663 }
661 664
662 665
666 static const char* const weekdays[] = {
667 "???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
668 };
669
670 void JSDate::JSDatePrint(FILE* out) {
671 HeapObject::PrintHeader(out, "JSDate");
672 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map()));
673 PrintF(out, " - value = ");
674 value()->Print(out);
675 if (!year()->IsSmi()) {
676 PrintF(out, " - time = NaN\n");
677 } else {
678 PrintF(out, " - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
679 weekdays[weekday()->IsSmi()? Smi::cast(weekday())->value() + 1 : -1],
680 year()->IsSmi() ? Smi::cast(year())->value() : -1,
681 month()->IsSmi() ? Smi::cast(month())->value() : -1,
682 day()->IsSmi() ? Smi::cast(day())->value() : -1,
683 hour()->IsSmi() ? Smi::cast(hour())->value() : -1,
684 min()->IsSmi() ? Smi::cast(min())->value() : -1,
685 sec()->IsSmi() ? Smi::cast(sec())->value() : -1);
686 }
687 }
688
689
663 void JSProxy::JSProxyPrint(FILE* out) { 690 void JSProxy::JSProxyPrint(FILE* out) {
664 HeapObject::PrintHeader(out, "JSProxy"); 691 HeapObject::PrintHeader(out, "JSProxy");
665 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); 692 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map()));
666 PrintF(out, " - handler = "); 693 PrintF(out, " - handler = ");
667 handler()->Print(out); 694 handler()->Print(out);
668 PrintF(out, " - hash = "); 695 PrintF(out, " - hash = ");
669 hash()->Print(out); 696 hash()->Print(out);
670 PrintF(out, "\n"); 697 PrintF(out, "\n");
671 } 698 }
672 699
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 desc.Print(out); 1011 desc.Print(out);
985 } 1012 }
986 PrintF(out, "\n"); 1013 PrintF(out, "\n");
987 } 1014 }
988 1015
989 1016
990 #endif // OBJECT_PRINT 1017 #endif // OBJECT_PRINT
991 1018
992 1019
993 } } // namespace v8::internal 1020 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698