Changeset 181404 in webkit for trunk/Source/JavaScriptCore/parser/Parser.cpp
- Timestamp:
- Mar 11, 2015, 2:03:24 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/parser/Parser.cpp
r181293 r181404 1378 1378 } 1379 1379 if (functionScope->hasDirectSuper()) { 1380 bool nameIsConstructor = info.name && *info.name == m_vm->propertyNames->constructor; 1381 semanticFailIfTrue(mode != MethodMode || !nameIsConstructor, "Cannot call super() outside of a class constructor"); 1382 } 1380 bool isClassConstructor = mode == MethodMode && info.name && *info.name == m_vm->propertyNames->constructor; 1381 semanticFailIfTrue(!isClassConstructor, "Cannot call super() outside of a class constructor"); 1382 semanticFailIfTrue(constructorKind == ConstructorKind::Base, "Cannot call super() in a base class constructor"); 1383 } 1384 if (functionScope->needsSuperBinding()) 1385 semanticFailIfTrue(constructorKind == ConstructorKind::Base, "super can only be used in a method of a derived class"); 1386 1383 1387 info.closeBraceOffset = m_token.m_data.offset; 1384 1388 unsigned closeBraceLine = m_token.m_data.line; … … 1504 1508 semanticFailIfTrue(isStaticMethod, "Cannot declare a static", stringForFunctionMode(isGetter ? GetterMode : SetterMode)); 1505 1509 nextExpectIdentifier(LexerFlagsIgnoreReservedWords); 1506 property = parseGetterSetter(context, alwaysStrictInsideClass, isGetter ? PropertyNode::Getter : PropertyNode::Setter, methodStart, SuperBinding::Needed);1510 property = parseGetterSetter(context, alwaysStrictInsideClass, isGetter ? PropertyNode::Getter : PropertyNode::Setter, methodStart, constructorKind, SuperBinding::Needed); 1507 1511 failIfFalse(property, "Cannot parse this method"); 1508 1512 } else { … … 2019 2023 2020 2024 template <typename LexerType> 2021 template <class TreeBuilder> TreeProperty Parser<LexerType>::parseGetterSetter(TreeBuilder& context, bool strict, PropertyNode::Type type, unsigned getterOrSetterStartOffset, SuperBinding superBinding) 2025 template <class TreeBuilder> TreeProperty Parser<LexerType>::parseGetterSetter(TreeBuilder& context, bool strict, PropertyNode::Type type, unsigned getterOrSetterStartOffset, 2026 ConstructorKind constructorKind, SuperBinding superBinding) 2022 2027 { 2023 2028 const Identifier* stringPropertyName = 0; … … 2034 2039 if (type == PropertyNode::Getter) { 2035 2040 failIfFalse(match(OPENPAREN), "Expected a parameter list for getter definition"); 2036 failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, GetterMode, false, ConstructorKind::Base, info)), "Cannot parse getter definition");2041 failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, GetterMode, false, constructorKind, info)), "Cannot parse getter definition"); 2037 2042 } else { 2038 2043 failIfFalse(match(OPENPAREN), "Expected a parameter list for setter definition"); 2039 failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, SetterMode, false, ConstructorKind::Base, info)), "Cannot parse setter definition");2044 failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, SetterMode, false, constructorKind, info)), "Cannot parse setter definition"); 2040 2045 } 2041 2046 if (stringPropertyName) … … 2385 2390 base = context.superExpr(location); 2386 2391 next(); 2392 currentScope()->setNeedsSuperBinding(); 2387 2393 } else 2388 2394 base = parsePrimaryExpression(context);
Note:
See TracChangeset
for help on using the changeset viewer.