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

Unified Diff: src/macros.py

Issue 1110963003: Use "define" instead of "const" for natives macros (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | src/third_party/fdlibm/fdlibm.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/macros.py
diff --git a/src/macros.py b/src/macros.py
index f00a8b70e35ffeedd1ed1416409006198d16a7ae..b39cd85826e5743ae6845883ac2bdd69e1ea8fc2 100644
--- a/src/macros.py
+++ b/src/macros.py
@@ -28,58 +28,58 @@
# Dictionary that is passed as defines for js2c.py.
# Used for defines that must be defined for all native JS files.
-const NONE = 0;
-const READ_ONLY = 1;
-const DONT_ENUM = 2;
-const DONT_DELETE = 4;
-const NEW_ONE_BYTE_STRING = true;
-const NEW_TWO_BYTE_STRING = false;
+define NONE = 0;
+define READ_ONLY = 1;
+define DONT_ENUM = 2;
+define DONT_DELETE = 4;
+define NEW_ONE_BYTE_STRING = true;
+define NEW_TWO_BYTE_STRING = false;
# Constants used for getter and setter operations.
-const GETTER = 0;
-const SETTER = 1;
+define GETTER = 0;
+define SETTER = 1;
-const NO_HINT = 0;
-const NUMBER_HINT = 1;
-const STRING_HINT = 2;
+define NO_HINT = 0;
+define NUMBER_HINT = 1;
+define STRING_HINT = 2;
# For date.js.
-const HoursPerDay = 24;
-const MinutesPerHour = 60;
-const SecondsPerMinute = 60;
-const msPerSecond = 1000;
-const msPerMinute = 60000;
-const msPerHour = 3600000;
-const msPerDay = 86400000;
-const msPerMonth = 2592000000;
+define HoursPerDay = 24;
+define MinutesPerHour = 60;
+define SecondsPerMinute = 60;
+define msPerSecond = 1000;
+define msPerMinute = 60000;
+define msPerHour = 3600000;
+define msPerDay = 86400000;
+define msPerMonth = 2592000000;
# Note: kDayZeroInJulianDay = ToJulianDay(1970, 0, 1).
-const kInvalidDate = 'Invalid Date';
-const kDayZeroInJulianDay = 2440588;
-const kMonthMask = 0x1e0;
-const kDayMask = 0x01f;
-const kYearShift = 9;
-const kMonthShift = 5;
+define kInvalidDate = 'Invalid Date';
+define kDayZeroInJulianDay = 2440588;
+define kMonthMask = 0x1e0;
+define kDayMask = 0x01f;
+define kYearShift = 9;
+define kMonthShift = 5;
# Limits for parts of the date, so that we support all the dates that
# ECMA 262 - 15.9.1.1 requires us to, but at the same time be sure that
# the date (days since 1970) is in SMI range.
-const kMinYear = -1000000;
-const kMaxYear = 1000000;
-const kMinMonth = -10000000;
-const kMaxMonth = 10000000;
+define kMinYear = -1000000;
+define kMaxYear = 1000000;
+define kMinMonth = -10000000;
+define kMaxMonth = 10000000;
# Safe maximum number of arguments to push to stack, when multiplied by
# pointer size. Used by Function.prototype.apply(), Reflect.apply() and
# Reflect.construct().
-const kSafeArgumentsLength = 0x800000;
+define kSafeArgumentsLength = 0x800000;
# Strict mode flags for passing to %SetProperty
-const kSloppyMode = 0;
-const kStrictMode = 1;
+define kSloppyMode = 0;
+define kStrictMode = 1;
# Native cache ids.
-const STRING_TO_REGEXP_CACHE_ID = 0;
+define STRING_TO_REGEXP_CACHE_ID = 0;
# Type query macros.
#
@@ -136,9 +136,9 @@ macro IS_SPEC_FUNCTION(arg) = (%_ClassOf(arg) === 'Function');
macro CHECK_OBJECT_COERCIBLE(arg, functionName) = if (IS_NULL_OR_UNDEFINED(arg) && !IS_UNDETECTABLE(arg)) throw MakeTypeError(kCalledOnNullOrUndefined, functionName);
# Indices in bound function info retrieved by %BoundFunctionGetBindings(...).
-const kBoundFunctionIndex = 0;
-const kBoundThisIndex = 1;
-const kBoundArgumentsStartIndex = 2;
+define kBoundFunctionIndex = 0;
+define kBoundThisIndex = 1;
+define kBoundArgumentsStartIndex = 2;
# Inline macros. Use %IS_VAR to make sure arg is evaluated only once.
macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg));
@@ -169,25 +169,25 @@ macro SET_PRIVATE(obj, sym, val) = (obj[sym] = val);
macro DELETE_PRIVATE(obj, sym) = (delete obj[sym]);
# Constants. The compiler constant folds them.
-const NAN = $NaN;
-const INFINITY = (1/0);
-const UNDEFINED = (void 0);
+define NAN = $NaN;
+define INFINITY = (1/0);
+define UNDEFINED = (void 0);
# Macros implemented in Python.
python macro CHAR_CODE(str) = ord(str[1]);
# Constants used on an array to implement the properties of the RegExp object.
-const REGEXP_NUMBER_OF_CAPTURES = 0;
-const REGEXP_FIRST_CAPTURE = 3;
+define REGEXP_NUMBER_OF_CAPTURES = 0;
+define REGEXP_FIRST_CAPTURE = 3;
# We can't put macros in macros so we use constants here.
# REGEXP_NUMBER_OF_CAPTURES
macro NUMBER_OF_CAPTURES(array) = ((array)[0]);
# Limit according to ECMA 262 15.9.1.1
-const MAX_TIME_MS = 8640000000000000;
+define MAX_TIME_MS = 8640000000000000;
# Limit which is MAX_TIME_MS + msPerMonth.
-const MAX_TIME_BEFORE_UTC = 8640002592000000;
+define MAX_TIME_BEFORE_UTC = 8640002592000000;
# Gets the value of a Date object. If arg is not a Date object
# a type error is thrown.
@@ -223,14 +223,14 @@ macro SET_UTC_DATE_VALUE(arg, value) = (%DateSetValue(arg, value, 1));
macro SET_LOCAL_DATE_VALUE(arg, value) = (%DateSetValue(arg, value, 0));
# Last input and last subject of regexp matches.
-const LAST_SUBJECT_INDEX = 1;
+define LAST_SUBJECT_INDEX = 1;
macro LAST_SUBJECT(array) = ((array)[1]);
macro LAST_INPUT(array) = ((array)[2]);
# REGEXP_FIRST_CAPTURE
macro CAPTURE(index) = (3 + (index));
-const CAPTURE0 = 3;
-const CAPTURE1 = 4;
+define CAPTURE0 = 3;
+define CAPTURE1 = 4;
# For the regexp capture override array. This has the same
# format as the arguments to a function called from
@@ -243,38 +243,38 @@ macro OVERRIDE_CAPTURE(override, index) = ((override)[(index)]);
# PropertyDescriptor return value indices - must match
# PropertyDescriptorIndices in runtime-object.cc.
-const IS_ACCESSOR_INDEX = 0;
-const VALUE_INDEX = 1;
-const GETTER_INDEX = 2;
-const SETTER_INDEX = 3;
-const WRITABLE_INDEX = 4;
-const ENUMERABLE_INDEX = 5;
-const CONFIGURABLE_INDEX = 6;
+define IS_ACCESSOR_INDEX = 0;
+define VALUE_INDEX = 1;
+define GETTER_INDEX = 2;
+define SETTER_INDEX = 3;
+define WRITABLE_INDEX = 4;
+define ENUMERABLE_INDEX = 5;
+define CONFIGURABLE_INDEX = 6;
# For messages.js
# Matches Script::Type from objects.h
-const TYPE_NATIVE = 0;
-const TYPE_EXTENSION = 1;
-const TYPE_NORMAL = 2;
+define TYPE_NATIVE = 0;
+define TYPE_EXTENSION = 1;
+define TYPE_NORMAL = 2;
# Matches Script::CompilationType from objects.h
-const COMPILATION_TYPE_HOST = 0;
-const COMPILATION_TYPE_EVAL = 1;
-const COMPILATION_TYPE_JSON = 2;
+define COMPILATION_TYPE_HOST = 0;
+define COMPILATION_TYPE_EVAL = 1;
+define COMPILATION_TYPE_JSON = 2;
# Matches Messages::kNoLineNumberInfo from v8.h
-const kNoLineNumberInfo = 0;
+define kNoLineNumberInfo = 0;
# Matches PropertyAttributes from property-details.h
-const PROPERTY_ATTRIBUTES_NONE = 0;
-const PROPERTY_ATTRIBUTES_STRING = 8;
-const PROPERTY_ATTRIBUTES_SYMBOLIC = 16;
-const PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL = 32;
+define PROPERTY_ATTRIBUTES_NONE = 0;
+define PROPERTY_ATTRIBUTES_STRING = 8;
+define PROPERTY_ATTRIBUTES_SYMBOLIC = 16;
+define PROPERTY_ATTRIBUTES_PRIVATE_SYMBOL = 32;
# Use for keys, values and entries iterators.
-const ITERATOR_KIND_KEYS = 1;
-const ITERATOR_KIND_VALUES = 2;
-const ITERATOR_KIND_ENTRIES = 3;
+define ITERATOR_KIND_KEYS = 1;
+define ITERATOR_KIND_VALUES = 2;
+define ITERATOR_KIND_ENTRIES = 3;
macro FIXED_ARRAY_GET(array, index) = (%_FixedArrayGet(array, (index) | 0));
macro FIXED_ARRAY_SET(array, index, value) = (%_FixedArraySet(array, (index) | 0, value));
@@ -301,9 +301,9 @@ macro ORDERED_HASH_MAP_VALUE_AT(table, entry, numBuckets) = (FIXED_ARRAY_GET(tab
macro ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets) = (FIXED_ARRAY_GET(table, ORDERED_HASH_MAP_ENTRY_TO_INDEX(entry, numBuckets) + 2));
# Must match OrderedHashTable::kNotFound.
-const NOT_FOUND = -1;
+define NOT_FOUND = -1;
# Check whether debug is active.
-const DEBUG_IS_ACTIVE = (%_DebugIsActive() != 0);
+define DEBUG_IS_ACTIVE = (%_DebugIsActive() != 0);
macro DEBUG_IS_STEPPING(function) = (%_DebugIsActive() != 0 && %DebugCallbackSupportsStepping(function));
macro DEBUG_PREPARE_STEP_IN_IF_STEPPING(function) = if (DEBUG_IS_STEPPING(function)) %DebugPrepareStepInIfStepping(function);
« no previous file with comments | « no previous file | src/third_party/fdlibm/fdlibm.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698