Index: src/d8.cc |
diff --git a/src/d8.cc b/src/d8.cc |
index c70ff42dc7b511692260b3b4e09f6269424ee430..4dc54c09445bc76e81ff0b052ec9eba0d94a08f7 100644 |
--- a/src/d8.cc |
+++ b/src/d8.cc |
@@ -646,33 +646,34 @@ void Shell::Print(const v8::FunctionCallbackInfo<v8::Value>& args) { |
void Shell::Write(const v8::FunctionCallbackInfo<v8::Value>& args) { |
- for (int i = 0; i < args.Length(); i++) { |
- HandleScope handle_scope(args.GetIsolate()); |
- if (i != 0) { |
- printf(" "); |
- } |
+ FOR_WITH_HANDLE_SCOPE( |
+ args.GetIsolate(), int, i = 0, i, i < args.Length(), i++, { |
+ if (i != 0) { |
+ printf(" "); |
+ } |
- // Explicitly catch potential exceptions in toString(). |
- v8::TryCatch try_catch(args.GetIsolate()); |
- Local<Value> arg = args[i]; |
- Local<String> str_obj; |
+ // Explicitly catch potential exceptions in toString(). |
+ v8::TryCatch try_catch(args.GetIsolate()); |
+ Local<Value> arg = args[i]; |
+ Local<String> str_obj; |
- if (arg->IsSymbol()) { |
- arg = Local<Symbol>::Cast(arg)->Name(); |
- } |
- if (!arg->ToString(args.GetIsolate()->GetCurrentContext()) |
- .ToLocal(&str_obj)) { |
- try_catch.ReThrow(); |
- return; |
- } |
+ if (arg->IsSymbol()) { |
+ arg = Local<Symbol>::Cast(arg)->Name(); |
+ } |
+ if (!arg->ToString(args.GetIsolate()->GetCurrentContext()) |
+ .ToLocal(&str_obj)) { |
+ try_catch.ReThrow(); |
+ return; |
+ } |
- v8::String::Utf8Value str(str_obj); |
- int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); |
- if (n != str.length()) { |
- printf("Error in fwrite\n"); |
- Exit(1); |
- } |
- } |
+ v8::String::Utf8Value str(str_obj); |
+ int n = |
+ static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); |
+ if (n != str.length()) { |
+ printf("Error in fwrite\n"); |
+ Exit(1); |
+ } |
+ }); |
} |
@@ -729,27 +730,27 @@ Local<String> Shell::ReadFromStdin(Isolate* isolate) { |
void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) { |
- for (int i = 0; i < args.Length(); i++) { |
- HandleScope handle_scope(args.GetIsolate()); |
- String::Utf8Value file(args[i]); |
- if (*file == NULL) { |
- Throw(args.GetIsolate(), "Error loading file"); |
- return; |
- } |
- Local<String> source = ReadFile(args.GetIsolate(), *file); |
- if (source.IsEmpty()) { |
- Throw(args.GetIsolate(), "Error loading file"); |
- return; |
- } |
- if (!ExecuteString( |
- args.GetIsolate(), source, |
- String::NewFromUtf8(args.GetIsolate(), *file, |
- NewStringType::kNormal).ToLocalChecked(), |
- false, true)) { |
- Throw(args.GetIsolate(), "Error executing file"); |
- return; |
- } |
- } |
+ FOR_WITH_HANDLE_SCOPE( |
+ args.GetIsolate(), int, i = 0, i, i < args.Length(), i++, { |
+ String::Utf8Value file(args[i]); |
+ if (*file == NULL) { |
+ Throw(args.GetIsolate(), "Error loading file"); |
+ return; |
+ } |
+ Local<String> source = ReadFile(args.GetIsolate(), *file); |
+ if (source.IsEmpty()) { |
+ Throw(args.GetIsolate(), "Error loading file"); |
+ return; |
+ } |
+ if (!ExecuteString(args.GetIsolate(), source, |
+ String::NewFromUtf8(args.GetIsolate(), *file, |
+ NewStringType::kNormal) |
+ .ToLocalChecked(), |
+ false, true)) { |
+ Throw(args.GetIsolate(), "Error executing file"); |
+ return; |
+ } |
+ }); |
} |