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

Side by Side Diff: src/factory.cc

Issue 176843003: Add StackOverflowError and expose error type to api. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix test Created 6 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/factory.h ('k') | src/heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 Vector< Handle<Object> > args) { 1062 Vector< Handle<Object> > args) {
1063 return NewError("MakeReferenceError", message, args); 1063 return NewError("MakeReferenceError", message, args);
1064 } 1064 }
1065 1065
1066 1066
1067 Handle<Object> Factory::NewReferenceError(Handle<String> message) { 1067 Handle<Object> Factory::NewReferenceError(Handle<String> message) {
1068 return NewError("$ReferenceError", message); 1068 return NewError("$ReferenceError", message);
1069 } 1069 }
1070 1070
1071 1071
1072 Handle<Object> Factory::NewError(const char* maker, 1072 Handle<Object> Factory::NewStackOverflowError(Handle<String> message) {
1073 const char* message, 1073 return NewError("$StackOverflowError", message);
1074 Vector< Handle<Object> > args) {
1075 // Instantiate a closeable HandleScope for EscapeFrom.
1076 v8::EscapableHandleScope scope(reinterpret_cast<v8::Isolate*>(isolate()));
1077 Handle<FixedArray> array = NewFixedArray(args.length());
1078 for (int i = 0; i < args.length(); i++) {
1079 array->set(i, *args[i]);
1080 }
1081 Handle<JSArray> object = NewJSArrayWithElements(array);
1082 Handle<Object> result = NewError(maker, message, object);
1083 return result.EscapeFrom(&scope);
1084 } 1074 }
1085 1075
1086 1076
1087 Handle<Object> Factory::NewEvalError(const char* message, 1077 Handle<Object> Factory::NewEvalError(const char* message,
1088 Vector< Handle<Object> > args) { 1078 Vector< Handle<Object> > args) {
1089 return NewError("MakeEvalError", message, args); 1079 return NewError("MakeEvalError", message, args);
1090 } 1080 }
1091 1081
1092 1082
1083 Handle<Object> Factory::NewEvalError(Handle<String> message) {
1084 return NewError("$EvalError", message);
1085 }
1086
1087
1088 Handle<Object> Factory::NewURIError(Handle<String> message) {
1089 return NewError("$URIError", message);
1090 }
1091
1092
1093 Handle<Object> Factory::NewError(const char* message, 1093 Handle<Object> Factory::NewError(const char* message,
1094 Vector< Handle<Object> > args) { 1094 Vector< Handle<Object> > args) {
1095 return NewError("MakeError", message, args); 1095 return NewError("MakeError", message, args);
1096 } 1096 }
1097 1097
1098 1098
1099 Handle<Object> Factory::NewError(const char* maker,
1100 const char* message,
1101 Vector< Handle<Object> > args) {
1102 // Instantiate a closeable HandleScope for EscapeFrom.
1103 v8::EscapableHandleScope scope(reinterpret_cast<v8::Isolate*>(isolate()));
1104 Handle<FixedArray> array = NewFixedArray(args.length());
1105 for (int i = 0; i < args.length(); i++) {
1106 array->set(i, *args[i]);
1107 }
1108 Handle<JSArray> object = NewJSArrayWithElements(array);
1109 Handle<Object> result = NewError(maker, message, object);
1110 return result.EscapeFrom(&scope);
1111 }
1112
1113
1099 Handle<String> Factory::EmergencyNewError(const char* message, 1114 Handle<String> Factory::EmergencyNewError(const char* message,
1100 Handle<JSArray> args) { 1115 Handle<JSArray> args) {
1101 const int kBufferSize = 1000; 1116 const int kBufferSize = 1000;
1102 char buffer[kBufferSize]; 1117 char buffer[kBufferSize];
1103 size_t space = kBufferSize; 1118 size_t space = kBufferSize;
1104 char* p = &buffer[0]; 1119 char* p = &buffer[0];
1105 1120
1106 Vector<char> v(buffer, kBufferSize); 1121 Vector<char> v(buffer, kBufferSize);
1107 OS::StrNCpy(v, message, space); 1122 OS::StrNCpy(v, message, space);
1108 space -= Min(space, strlen(message)); 1123 space -= Min(space, strlen(message));
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 return Handle<Object>::null(); 2003 return Handle<Object>::null();
1989 } 2004 }
1990 2005
1991 2006
1992 Handle<Object> Factory::ToBoolean(bool value) { 2007 Handle<Object> Factory::ToBoolean(bool value) {
1993 return value ? true_value() : false_value(); 2008 return value ? true_value() : false_value();
1994 } 2009 }
1995 2010
1996 2011
1997 } } // namespace v8::internal 2012 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698