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

Side by Side Diff: src/js/macros.py

Issue 1579613002: [builtins] Refactor the remaining Date builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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
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 21 matching lines...) Expand all
32 define READ_ONLY = 1; 32 define READ_ONLY = 1;
33 define DONT_ENUM = 2; 33 define DONT_ENUM = 2;
34 define DONT_DELETE = 4; 34 define DONT_DELETE = 4;
35 define NEW_ONE_BYTE_STRING = true; 35 define NEW_ONE_BYTE_STRING = true;
36 define NEW_TWO_BYTE_STRING = false; 36 define NEW_TWO_BYTE_STRING = false;
37 37
38 # Constants used for getter and setter operations. 38 # Constants used for getter and setter operations.
39 define GETTER = 0; 39 define GETTER = 0;
40 define SETTER = 1; 40 define SETTER = 1;
41 41
42 # For date.js.
43 define HoursPerDay = 24;
44 define MinutesPerHour = 60;
45 define SecondsPerMinute = 60;
46 define msPerSecond = 1000;
47 define msPerMinute = 60000;
48 define msPerHour = 3600000;
49 define msPerDay = 86400000;
50 define msPerMonth = 2592000000;
51
52 # Note: kDayZeroInJulianDay = ToJulianDay(1970, 0, 1).
53 define kInvalidDate = 'Invalid Date';
54 define kDayZeroInJulianDay = 2440588;
55 define kMonthMask = 0x1e0;
56 define kDayMask = 0x01f;
57 define kYearShift = 9;
58 define kMonthShift = 5;
59
60 # Limits for parts of the date, so that we support all the dates that
61 # ECMA 262 - 15.9.1.1 requires us to, but at the same time be sure that
62 # the date (days since 1970) is in SMI range.
63 define kMinYear = -1000000;
64 define kMaxYear = 1000000;
65 define kMinMonth = -10000000;
66 define kMaxMonth = 10000000;
67
68 # Safe maximum number of arguments to push to stack, when multiplied by 42 # Safe maximum number of arguments to push to stack, when multiplied by
69 # pointer size. Used by Function.prototype.apply(), Reflect.apply() and 43 # pointer size. Used by Function.prototype.apply(), Reflect.apply() and
70 # Reflect.construct(). 44 # Reflect.construct().
71 define kSafeArgumentsLength = 0x800000; 45 define kSafeArgumentsLength = 0x800000;
72 46
73 # 2^53 - 1 47 # 2^53 - 1
74 define kMaxSafeInteger = 9007199254740991; 48 define kMaxSafeInteger = 9007199254740991;
75 49
76 # 2^32 - 1 50 # 2^32 - 1
77 define kMaxUint32 = 4294967295; 51 define kMaxUint32 = 4294967295;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 macro REGEXP_IGNORE_CASE(regexp) = (%_RegExpFlags(regexp) & 2); 155 macro REGEXP_IGNORE_CASE(regexp) = (%_RegExpFlags(regexp) & 2);
182 macro REGEXP_MULTILINE(regexp) = (%_RegExpFlags(regexp) & 4); 156 macro REGEXP_MULTILINE(regexp) = (%_RegExpFlags(regexp) & 4);
183 macro REGEXP_STICKY(regexp) = (%_RegExpFlags(regexp) & 8); 157 macro REGEXP_STICKY(regexp) = (%_RegExpFlags(regexp) & 8);
184 macro REGEXP_UNICODE(regexp) = (%_RegExpFlags(regexp) & 16); 158 macro REGEXP_UNICODE(regexp) = (%_RegExpFlags(regexp) & 16);
185 macro REGEXP_SOURCE(regexp) = (%_RegExpSource(regexp)); 159 macro REGEXP_SOURCE(regexp) = (%_RegExpSource(regexp));
186 160
187 # We can't put macros in macros so we use constants here. 161 # We can't put macros in macros so we use constants here.
188 # REGEXP_NUMBER_OF_CAPTURES 162 # REGEXP_NUMBER_OF_CAPTURES
189 macro NUMBER_OF_CAPTURES(array) = ((array)[0]); 163 macro NUMBER_OF_CAPTURES(array) = ((array)[0]);
190 164
191 # Limit according to ECMA 262 15.9.1.1
192 define MAX_TIME_MS = 8640000000000000;
193 # Limit which is MAX_TIME_MS + msPerMonth.
194 define MAX_TIME_BEFORE_UTC = 8640002592000000;
195
196 # Gets the value of a Date object. If arg is not a Date object
197 # a type error is thrown.
198 macro CHECK_DATE(arg) = if (!%_IsDate(arg)) %_ThrowNotDateError();
199 macro LOCAL_DATE_VALUE(arg) = (%_DateField(arg, 0) + %_DateField(arg, 21));
200 macro UTC_DATE_VALUE(arg) = (%_DateField(arg, 0));
201
202 macro LOCAL_YEAR(arg) = (%_DateField(arg, 1));
203 macro LOCAL_MONTH(arg) = (%_DateField(arg, 2));
204 macro LOCAL_DAY(arg) = (%_DateField(arg, 3));
205 macro LOCAL_WEEKDAY(arg) = (%_DateField(arg, 4));
206 macro LOCAL_HOUR(arg) = (%_DateField(arg, 5));
207 macro LOCAL_MIN(arg) = (%_DateField(arg, 6));
208 macro LOCAL_SEC(arg) = (%_DateField(arg, 7));
209 macro LOCAL_MS(arg) = (%_DateField(arg, 8));
210 macro LOCAL_DAYS(arg) = (%_DateField(arg, 9));
211 macro LOCAL_TIME_IN_DAY(arg) = (%_DateField(arg, 10));
212
213 macro UTC_YEAR(arg) = (%_DateField(arg, 11));
214 macro UTC_MONTH(arg) = (%_DateField(arg, 12));
215 macro UTC_DAY(arg) = (%_DateField(arg, 13));
216 macro UTC_WEEKDAY(arg) = (%_DateField(arg, 14));
217 macro UTC_HOUR(arg) = (%_DateField(arg, 15));
218 macro UTC_MIN(arg) = (%_DateField(arg, 16));
219 macro UTC_SEC(arg) = (%_DateField(arg, 17));
220 macro UTC_MS(arg) = (%_DateField(arg, 18));
221 macro UTC_DAYS(arg) = (%_DateField(arg, 19));
222 macro UTC_TIME_IN_DAY(arg) = (%_DateField(arg, 20));
223
224 macro TIMEZONE_OFFSET(arg) = (%_DateField(arg, 21));
225
226 macro SET_UTC_DATE_VALUE(arg, value) = (%DateSetValue(arg, value, 1));
227 macro SET_LOCAL_DATE_VALUE(arg, value) = (%DateSetValue(arg, value, 0));
228
229 # Last input and last subject of regexp matches. 165 # Last input and last subject of regexp matches.
230 define LAST_SUBJECT_INDEX = 1; 166 define LAST_SUBJECT_INDEX = 1;
231 macro LAST_SUBJECT(array) = ((array)[1]); 167 macro LAST_SUBJECT(array) = ((array)[1]);
232 macro LAST_INPUT(array) = ((array)[2]); 168 macro LAST_INPUT(array) = ((array)[2]);
233 169
234 # REGEXP_FIRST_CAPTURE 170 # REGEXP_FIRST_CAPTURE
235 macro CAPTURE(index) = (3 + (index)); 171 macro CAPTURE(index) = (3 + (index));
236 define CAPTURE0 = 3; 172 define CAPTURE0 = 3;
237 define CAPTURE1 = 4; 173 define CAPTURE1 = 4;
238 174
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 define kStrongMode = 10; 265 define kStrongMode = 10;
330 define kRegExpPrototypeStickyGetter = 11; 266 define kRegExpPrototypeStickyGetter = 11;
331 define kRegExpPrototypeToString = 12; 267 define kRegExpPrototypeToString = 12;
332 define kRegExpPrototypeUnicodeGetter = 13; 268 define kRegExpPrototypeUnicodeGetter = 13;
333 define kIntlV8Parse = 14; 269 define kIntlV8Parse = 14;
334 define kIntlPattern = 15; 270 define kIntlPattern = 15;
335 define kIntlResolved = 16; 271 define kIntlResolved = 16;
336 define kPromiseChain = 17; 272 define kPromiseChain = 17;
337 define kPromiseAccept = 18; 273 define kPromiseAccept = 18;
338 define kPromiseDefer = 19; 274 define kPromiseDefer = 19;
OLDNEW
« src/js/date.js ('K') | « src/js/date.js ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698