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

Side by Side Diff: src/d8.cc

Issue 7218042: reverting revision r8454 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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
« no previous file with comments | « src/d8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 #ifdef LIVE_OBJECT_LIST 592 #ifdef LIVE_OBJECT_LIST
593 global_template->Set(String::New("lol_is_enabled"), Boolean::New(true)); 593 global_template->Set(String::New("lol_is_enabled"), Boolean::New(true));
594 #else 594 #else
595 global_template->Set(String::New("lol_is_enabled"), Boolean::New(false)); 595 global_template->Set(String::New("lol_is_enabled"), Boolean::New(false));
596 #endif 596 #endif
597 597
598 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(); 598 Handle<ObjectTemplate> os_templ = ObjectTemplate::New();
599 AddOSMethods(os_templ); 599 AddOSMethods(os_templ);
600 global_template->Set(String::New("os"), os_templ); 600 global_template->Set(String::New("os"), os_templ);
601 601
602 Handle<ObjectTemplate> counter_templ = ObjectTemplate::New();
603 counter_templ->Set(String::New("get"),
604 FunctionTemplate::New(CounterGetValue));
605 global_template->Set(String::New("counter"), counter_templ);
606
607 return global_template; 602 return global_template;
608 } 603 }
609 604
610 605
611 Handle<Value> Shell::CounterGetValue(const Arguments& args){
612 if (args.Length() != 1) {
613 return ThrowException(String::New("get() takes one argument"));
614 }
615 if (args[0]->IsString()) {
616 String::AsciiValue name(args[0]);
617 Counter* counter = counter_map_->Lookup(*name);
618 if (!counter) {
619 String::AsciiValue prefixed(String::Concat(String::New("c:"),
620 String::New(*name)));
621 counter = counter_map_->Lookup(*prefixed);
622 if (!counter) {
623 return ThrowException(String::New("invalid counter name"));
624 }
625 }
626 return Handle<Integer>::Cast(Integer::New(counter->count()));
627 }
628 return ThrowException(String::New("counter name must be a string"));
629 }
630
631
632 void Shell::Initialize(bool test_shell) { 606 void Shell::Initialize(bool test_shell) {
633 #ifdef COMPRESS_STARTUP_DATA_BZ2 607 #ifdef COMPRESS_STARTUP_DATA_BZ2
634 BZip2Decompressor startup_data_decompressor; 608 BZip2Decompressor startup_data_decompressor;
635 int bz2_result = startup_data_decompressor.Decompress(); 609 int bz2_result = startup_data_decompressor.Decompress();
636 if (bz2_result != BZ_OK) { 610 if (bz2_result != BZ_OK) {
637 fprintf(stderr, "bzip error code: %d\n", bz2_result); 611 fprintf(stderr, "bzip error code: %d\n", bz2_result);
638 exit(1); 612 exit(1);
639 } 613 }
640 #endif 614 #endif
641 615
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 } 992 }
1019 993
1020 } // namespace v8 994 } // namespace v8
1021 995
1022 996
1023 #ifndef GOOGLE3 997 #ifndef GOOGLE3
1024 int main(int argc, char* argv[]) { 998 int main(int argc, char* argv[]) {
1025 return v8::Shell::Main(argc, argv); 999 return v8::Shell::Main(argc, argv);
1026 } 1000 }
1027 #endif 1001 #endif
OLDNEW
« no previous file with comments | « src/d8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698