v8/src/char-predicates.cc
yangguo@chromium.org 0dd69ec439 Allow identifier code points from supplementary multilingual planes.
ES5.1 section 6 ("Source Text"):
"Throughout the rest of this document, the phrase “code unit” and the
word “character” will be used to refer to a 16-bit unsigned value
used to represent a single 16-bit unit of text."

This changed in ES6 draft section 10.1 ("Source Text"):
"The ECMAScript code is expressed using Unicode, version 5.1 or later.
ECMAScript source text is a sequence of code points. All Unicode code
point values from U+0000 to U+10FFFF, including surrogate code points,
may occur in source text where permitted by the ECMAScript grammars."

This patch is to reflect this spec change.

BUG=v8:3617
LOG=Y
R=jochen@chromium.org

Review URL: https://codereview.chromium.org/640193002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24510 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-10-10 07:13:46 +00:00

43 lines
1.2 KiB
C++

// Copyright 2011 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/char-predicates.h"
#ifdef V8_I18N_SUPPORT
#include "unicode/uchar.h"
#include "unicode/urename.h"
#endif // V8_I18N_SUPPORT
namespace v8 {
namespace internal {
bool SupplementaryPlanes::IsIDStart(uc32 c) {
DCHECK(c > 0xFFFF);
#ifdef V8_I18N_SUPPORT
// This only works for code points in the SMPs, since ICU does not exclude
// code points with properties 'Pattern_Syntax' or 'Pattern_White_Space'.
// Code points in the SMP do not have those properties.
return u_isIDStart(c);
#else
// This is incorrect, but if we don't have ICU, use this as fallback.
return false;
#endif // V8_I18N_SUPPORT
}
bool SupplementaryPlanes::IsIDPart(uc32 c) {
DCHECK(c > 0xFFFF);
#ifdef V8_I18N_SUPPORT
// This only works for code points in the SMPs, since ICU does not exclude
// code points with properties 'Pattern_Syntax' or 'Pattern_White_Space'.
// Code points in the SMP do not have those properties.
return u_isIDPart(c);
#else
// This is incorrect, but if we don't have ICU, use this as fallback.
return false;
#endif // V8_I18N_SUPPORT
}
}
} // namespace v8::internal