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

Unified Diff: src/js/messages.js

Issue 2222893002: Move family of MakeError functions to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix in prologue.js Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: src/js/messages.js
diff --git a/src/js/messages.js b/src/js/messages.js
index ea979f6e208b58a426cae1e94db725c38a31237d..de7ce7678ac430a8a752d8abf141af7e8067f3de 100644
--- a/src/js/messages.js
+++ b/src/js/messages.js
@@ -11,15 +11,10 @@
// -------------------------------------------------------------------
// Imports
-var MakeGenericError = utils.ImportNow("make_generic_error");
-var GlobalError = global.Error;
-var GlobalRangeError = global.RangeError;
-var GlobalSyntaxError = global.SyntaxError;
-var GlobalTypeError = global.TypeError;
-var GlobalURIError = global.URIError;
var Script = utils.ImportNow("Script");
// -------------------------------------------------------------------
+// Script
/**
* Set up the Script function and constructor.
@@ -27,40 +22,6 @@ var Script = utils.ImportNow("Script");
%FunctionSetInstanceClassName(Script, 'Script');
%AddNamedProperty(Script.prototype, 'constructor', Script,
DONT_ENUM | DONT_DELETE | READ_ONLY);
-%SetCode(Script, function(x) {
- // Script objects can only be created by the VM.
- throw MakeError(kUnsupported);
-});
-
-function GetLineNumber(message) {
- var start_position = %MessageGetStartPosition(message);
- if (start_position == -1) return kNoLineNumberInfo;
- var script = %MessageGetScript(message);
- var location = script.locationFromPosition(start_position, true);
- if (location == null) return kNoLineNumberInfo;
- return location.line + 1;
-}
-
-
-//Returns the offset of the given position within the containing line.
-function GetColumnNumber(message) {
- var script = %MessageGetScript(message);
- var start_position = %MessageGetStartPosition(message);
- var location = script.locationFromPosition(start_position, true);
- if (location == null) return -1;
- return location.column;
-}
-
-
-// Returns the source code line containing the given source
-// position, or the empty string if the position is invalid.
-function GetSourceLine(message) {
- var script = %MessageGetScript(message);
- var start_position = %MessageGetStartPosition(message);
- var location = script.locationFromPosition(start_position, true);
- if (location == null) return "";
- return location.sourceText;
-}
/**
@@ -112,43 +73,43 @@ utils.SetUpLockedPrototype(Script, [
]
);
-// ----------------------------------------------------------------------------
-// Error implementation
+// -------------------------------------------------------------------
+// Message
-function MakeError(type, arg0, arg1, arg2) {
- return MakeGenericError(GlobalError, type, arg0, arg1, arg2);
+function GetLineNumber(message) {
+ var start_position = %MessageGetStartPosition(message);
+ if (start_position == -1) return kNoLineNumberInfo;
+ var script = %MessageGetScript(message);
+ var location = script.locationFromPosition(start_position, true);
+ if (location == null) return kNoLineNumberInfo;
+ return location.line + 1;
}
-function MakeRangeError(type, arg0, arg1, arg2) {
- return MakeGenericError(GlobalRangeError, type, arg0, arg1, arg2);
-}
-function MakeSyntaxError(type, arg0, arg1, arg2) {
- return MakeGenericError(GlobalSyntaxError, type, arg0, arg1, arg2);
+//Returns the offset of the given position within the containing line.
+function GetColumnNumber(message) {
+ var script = %MessageGetScript(message);
+ var start_position = %MessageGetStartPosition(message);
+ var location = script.locationFromPosition(start_position, true);
+ if (location == null) return -1;
+ return location.column;
}
-function MakeTypeError(type, arg0, arg1, arg2) {
- return MakeGenericError(GlobalTypeError, type, arg0, arg1, arg2);
-}
-function MakeURIError() {
- return MakeGenericError(GlobalURIError, kURIMalformed);
+// Returns the source code line containing the given source
+// position, or the empty string if the position is invalid.
+function GetSourceLine(message) {
+ var script = %MessageGetScript(message);
+ var start_position = %MessageGetStartPosition(message);
+ var location = script.locationFromPosition(start_position, true);
+ if (location == null) return "";
+ return location.sourceText;
}
%InstallToContext([
- "make_range_error", MakeRangeError,
- "make_type_error", MakeTypeError,
"message_get_column_number", GetColumnNumber,
"message_get_line_number", GetLineNumber,
"message_get_source_line", GetSourceLine,
]);
-utils.Export(function(to) {
- to.MakeError = MakeError;
- to.MakeRangeError = MakeRangeError;
- to.MakeSyntaxError = MakeSyntaxError;
- to.MakeTypeError = MakeTypeError;
- to.MakeURIError = MakeURIError;
-});
-
});
« src/bootstrapper.cc ('K') | « src/js/macros.py ('k') | src/js/prologue.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698