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

Side by Side Diff: src/string.js

Issue 7799027: Lock the prototype of internal classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 3 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
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 // ReplaceResultBuilder support. 904 // ReplaceResultBuilder support.
905 function ReplaceResultBuilder(str) { 905 function ReplaceResultBuilder(str) {
906 if (%_ArgumentsLength() > 1) { 906 if (%_ArgumentsLength() > 1) {
907 this.elements = %_Arguments(1); 907 this.elements = %_Arguments(1);
908 } else { 908 } else {
909 this.elements = new InternalArray(); 909 this.elements = new InternalArray();
910 } 910 }
911 this.special_string = str; 911 this.special_string = str;
912 } 912 }
913 913
914 ReplaceResultBuilder.prototype.__proto__ = null; 914 SetupLockedPrototype(ReplaceResultBuilder,
915 915 $Array("elements", "special_string"), $Array(
916 916 "add", function(str) {
917 ReplaceResultBuilder.prototype.add = function(str) { 917 str = TO_STRING_INLINE(str);
918 str = TO_STRING_INLINE(str); 918 if (str.length > 0) this.elements.push(str);
919 if (str.length > 0) this.elements.push(str); 919 },
920 } 920 "addSpecialSlice", function(start, end) {
921 921 var len = end - start;
922 922 if (start < 0 || len <= 0) return;
923 ReplaceResultBuilder.prototype.addSpecialSlice = function(start, end) { 923 if (start < 0x80000 && len < 0x800) {
924 var len = end - start; 924 this.elements.push((start << 11) | len);
925 if (start < 0 || len <= 0) return; 925 } else {
926 if (start < 0x80000 && len < 0x800) { 926 // 0 < len <= String::kMaxLength and Smi::kMaxValue >= String::kMaxLength,
927 this.elements.push((start << 11) | len); 927 // so -len is a smi.
928 } else { 928 var elements = this.elements;
929 // 0 < len <= String::kMaxLength and Smi::kMaxValue >= String::kMaxLength, 929 elements.push(-len);
930 // so -len is a smi. 930 elements.push(start);
931 }
932 },
933 "generate", function() {
931 var elements = this.elements; 934 var elements = this.elements;
932 elements.push(-len); 935 return %StringBuilderConcat(elements, elements.length, this.special_string);
933 elements.push(start);
934 } 936 }
935 } 937 ));
936
937
938 ReplaceResultBuilder.prototype.generate = function() {
939 var elements = this.elements;
940 return %StringBuilderConcat(elements, elements.length, this.special_string);
941 }
942 938
943 939
944 // ------------------------------------------------------------------- 940 // -------------------------------------------------------------------
945 941
946 function SetupString() { 942 function SetupString() {
Erik Corry 2011/08/31 05:46:04 SetUpString
943 %AssertIsBootstrapping();
947 // Setup the constructor property on the String prototype object. 944 // Setup the constructor property on the String prototype object.
948 %SetProperty($String.prototype, "constructor", $String, DONT_ENUM); 945 %SetProperty($String.prototype, "constructor", $String, DONT_ENUM);
949 946
950 947
951 // Setup the non-enumerable functions on the String object. 948 // Setup the non-enumerable functions on the String object.
952 InstallFunctions($String, DONT_ENUM, $Array( 949 InstallFunctions($String, DONT_ENUM, $Array(
953 "fromCharCode", StringFromCharCode 950 "fromCharCode", StringFromCharCode
954 )); 951 ));
955 952
956 953
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 "italics", StringItalics, 986 "italics", StringItalics,
990 "small", StringSmall, 987 "small", StringSmall,
991 "strike", StringStrike, 988 "strike", StringStrike,
992 "sub", StringSub, 989 "sub", StringSub,
993 "sup", StringSup 990 "sup", StringSup
994 )); 991 ));
995 } 992 }
996 993
997 994
998 SetupString(); 995 SetupString();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698