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

Side by Side Diff: src/d8.cc

Issue 12330171: Simplify line editor choice in d8. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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
« 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 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 #undef DEFINE_SYMBOL_GETTER 116 #undef DEFINE_SYMBOL_GETTER
117 117
118 private: 118 private:
119 Isolate* isolate_; 119 Isolate* isolate_;
120 #define DEFINE_MEMBER(name, value) Persistent<String> name##_; 120 #define DEFINE_MEMBER(name, value) Persistent<String> name##_;
121 FOR_EACH_SYMBOL(DEFINE_MEMBER) 121 FOR_EACH_SYMBOL(DEFINE_MEMBER)
122 #undef DEFINE_MEMBER 122 #undef DEFINE_MEMBER
123 }; 123 };
124 124
125 125
126 LineEditor *LineEditor::first_ = NULL; 126 LineEditor *LineEditor::current_ = NULL;
127 127
128 128
129 LineEditor::LineEditor(Type type, const char* name) 129 LineEditor::LineEditor(Type type, const char* name)
130 : type_(type), 130 : type_(type), name_(name) {
131 name_(name), 131 if (current_ == NULL || current_->type_ < type) current_ = this;
rossberg 2013/02/27 16:32:48 Shouldn't you perhaps delete the current current_
Yang 2013/02/28 12:59:57 Would that be safe? Both DumbLineEditor and ReadLi
132 next_(first_) {
133 first_ = this;
134 } 132 }
135 133
136 134
137 LineEditor* LineEditor::Get() {
138 LineEditor* current = first_;
139 LineEditor* best = current;
140 while (current != NULL) {
141 if (current->type_ > best->type_)
142 best = current;
143 current = current->next_;
144 }
145 return best;
146 }
147
148
149 class DumbLineEditor: public LineEditor { 135 class DumbLineEditor: public LineEditor {
150 public: 136 public:
151 explicit DumbLineEditor(Isolate* isolate) 137 explicit DumbLineEditor(Isolate* isolate)
152 : LineEditor(LineEditor::DUMB, "dumb"), isolate_(isolate) { } 138 : LineEditor(LineEditor::DUMB, "dumb"), isolate_(isolate) { }
153 virtual Handle<String> Prompt(const char* prompt); 139 virtual Handle<String> Prompt(const char* prompt);
154 private: 140 private:
155 Isolate* isolate_; 141 Isolate* isolate_;
156 }; 142 };
157 143
158 144
(...skipping 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 } 1962 }
1977 1963
1978 } // namespace v8 1964 } // namespace v8
1979 1965
1980 1966
1981 #ifndef GOOGLE3 1967 #ifndef GOOGLE3
1982 int main(int argc, char* argv[]) { 1968 int main(int argc, char* argv[]) {
1983 return v8::Shell::Main(argc, argv); 1969 return v8::Shell::Main(argc, argv);
1984 } 1970 }
1985 #endif 1971 #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