Index: src/macros.py |
diff --git a/src/macros.py b/src/macros.py |
index c160b4916842a456631c0b4a1adb07ff2c53ff59..94c97a7c27b6a2234c7cf5b1e712a9c82b02ae99 100644 |
--- a/src/macros.py |
+++ b/src/macros.py |
@@ -74,6 +74,10 @@ const kYearShift = 9; |
const kMonthShift = 5; |
# Type query macros. |
+# |
+# Note: We have special support for typeof(foo) === 'bar' in the compiler. |
+# It will *not* generate a runtime typeof call for the most important |
+# values of 'bar'. |
macro IS_NULL(arg) = (arg === null); |
macro IS_NULL_OR_UNDEFINED(arg) = (arg == null); |
macro IS_UNDEFINED(arg) = (typeof(arg) === 'undefined'); |
@@ -83,7 +87,7 @@ macro IS_BOOLEAN(arg) = (typeof(arg) === 'boolean'); |
macro IS_OBJECT(arg) = (%_IsObject(arg)); |
macro IS_ARRAY(arg) = (%_IsArray(arg)); |
macro IS_FUNCTION(arg) = (%_IsFunction(arg)); |
-macro IS_REGEXP(arg) = (%_ClassOf(arg) === 'RegExp'); |
+macro IS_REGEXP(arg) = (%_IsRegExp(arg)); |
macro IS_DATE(arg) = (%_ClassOf(arg) === 'Date'); |
macro IS_NUMBER_WRAPPER(arg) = (%_ClassOf(arg) === 'Number'); |
macro IS_STRING_WRAPPER(arg) = (%_ClassOf(arg) === 'String'); |
@@ -100,6 +104,8 @@ macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg)); |
macro TO_INTEGER(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : ToInteger(arg)); |
macro TO_INT32(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : (arg >> 0)); |
macro TO_UINT32(arg) = (arg >>> 0); |
+macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : NonStringToString(arg)); |
Mads Ager (chromium)
2010/02/19 09:56:29
Remove extra spaces before '=' on this line. I wo
Vitaly Repeshko
2010/02/19 13:12:35
Done.
|
+ |
# Macros implemented in Python. |
python macro CHAR_CODE(str) = ord(str[1]); |