OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 Handle<Script> script = Script::Compile(source, name); | 121 Handle<Script> script = Script::Compile(source, name); |
122 if (script.IsEmpty()) { | 122 if (script.IsEmpty()) { |
123 // Print errors that happened during compilation. | 123 // Print errors that happened during compilation. |
124 if (report_exceptions && !i::FLAG_debugger) | 124 if (report_exceptions && !i::FLAG_debugger) |
125 ReportException(&try_catch); | 125 ReportException(&try_catch); |
126 return false; | 126 return false; |
127 } else { | 127 } else { |
128 Handle<Value> result = script->Run(); | 128 Handle<Value> result = script->Run(); |
129 if (result.IsEmpty()) { | 129 if (result.IsEmpty()) { |
| 130 ASSERT(try_catch.HasCaught()); |
130 // Print errors that happened during execution. | 131 // Print errors that happened during execution. |
131 if (report_exceptions && !i::FLAG_debugger) | 132 if (report_exceptions && !i::FLAG_debugger) |
132 ReportException(&try_catch); | 133 ReportException(&try_catch); |
133 return false; | 134 return false; |
134 } else { | 135 } else { |
| 136 ASSERT(!try_catch.HasCaught()); |
135 if (print_result && !result->IsUndefined()) { | 137 if (print_result && !result->IsUndefined()) { |
136 // If all went well and the result wasn't undefined then print | 138 // If all went well and the result wasn't undefined then print |
137 // the returned value. | 139 // the returned value. |
138 v8::String::Utf8Value str(result); | 140 v8::String::Utf8Value str(result); |
139 const char* cstr = ToCString(str); | 141 const char* cstr = ToCString(str); |
140 printf("%s\n", cstr); | 142 printf("%s\n", cstr); |
141 } | 143 } |
142 return true; | 144 return true; |
143 } | 145 } |
144 } | 146 } |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 return 0; | 777 return 0; |
776 } | 778 } |
777 | 779 |
778 | 780 |
779 } // namespace v8 | 781 } // namespace v8 |
780 | 782 |
781 | 783 |
782 int main(int argc, char* argv[]) { | 784 int main(int argc, char* argv[]) { |
783 return v8::Shell::Main(argc, argv); | 785 return v8::Shell::Main(argc, argv); |
784 } | 786 } |
OLD | NEW |