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

Side by Side Diff: pkg/analyzer/lib/src/generated/constant.dart

Issue 384093002: Resolve names in combinators for PropertyInducingElements instead of PropertyAccessorElements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.constant; 8 library engine.constant;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 * exactly once. Any use of an instance after invoking the method [computeValues ] will 285 * exactly once. Any use of an instance after invoking the method [computeValues ] will
286 * result in unpredictable behavior. 286 * result in unpredictable behavior.
287 */ 287 */
288 class ConstantValueComputer { 288 class ConstantValueComputer {
289 /** 289 /**
290 * Parameter to "fromEnvironment" methods that denotes the default value. 290 * Parameter to "fromEnvironment" methods that denotes the default value.
291 */ 291 */
292 static String _DEFAULT_VALUE_PARAM = "defaultValue"; 292 static String _DEFAULT_VALUE_PARAM = "defaultValue";
293 293
294 /** 294 /**
295 * Source of RegExp matching declarable operator names. From sdk/lib/internal/ symbol.dart.
296 */
297 static String _OPERATOR_RE = "(?:[\\-+*/%&|^]|\\[\\]=?|==|~/?|<[<=]?|>[>=]?|un ary-)";
298
299 /**
300 * Source of RegExp matching any public identifier. From sdk/lib/internal/symb ol.dart.
301 */
302 static String _PUBLIC_IDENTIFIER_RE = "(?!${ConstantValueComputer._RESERVED_WO RD_RE}\\b(?!\\\$))[a-zA-Z\$][\\w\$]*";
303
304 /**
305 * Source of RegExp matching Dart reserved words. From sdk/lib/internal/symbol .dart.
306 */
307 static String _RESERVED_WORD_RE = "(?:assert|break|c(?:a(?:se|tch)|lass|on(?:s t|tinue))|d(?:efault|o)|e(?:lse|num|xtends)|f(?:alse|inal(?:ly)?|or)|i[fns]|n(?: ew|ull)|ret(?:hrow|urn)|s(?:uper|witch)|t(?:h(?:is|row)|r(?:ue|y))|v(?:ar|oid)|w (?:hile|ith))";
308
309 /**
310 * RegExp that validates a non-empty non-private symbol. From sdk/lib/internal /symbol.dart.
311 */
312 static RegExp _PUBLIC_SYMBOL_PATTERN = new RegExp("^(?:${ConstantValueComputer ._OPERATOR_RE}\$|${_PUBLIC_IDENTIFIER_RE}(?:=?\$|[.](?!\$)))+?\$");
313
314 /**
315 * Determine whether the given string is a valid name for a public symbol (i.e . whether it is
316 * allowed for a call to the Symbol constructor).
317 */
318 static bool isValidPublicSymbol(String name) => name.isEmpty || new JavaPatter nMatcher(_PUBLIC_SYMBOL_PATTERN, name).matches();
319
320 /**
295 * The type provider used to access the known types. 321 * The type provider used to access the known types.
296 */ 322 */
297 TypeProvider typeProvider; 323 TypeProvider typeProvider;
298 324
299 /** 325 /**
300 * The object used to find constant variables and constant constructor invocat ions in the 326 * The object used to find constant variables and constant constructor invocat ions in the
301 * compilation units that were added. 327 * compilation units that were added.
302 */ 328 */
303 ConstantFinder _constantFinder = new ConstantFinder(); 329 ConstantFinder _constantFinder = new ConstantFinder();
304 330
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 511 }
486 InterfaceType defaultValueType = namedArgumentValues[_DEFAULT_VALUE_PARAM] .type; 512 InterfaceType defaultValueType = namedArgumentValues[_DEFAULT_VALUE_PARAM] .type;
487 if (!(identical(defaultValueType, expectedDefaultValueType) || identical(d efaultValueType, typeProvider.nullType))) { 513 if (!(identical(defaultValueType, expectedDefaultValueType) || identical(d efaultValueType, typeProvider.nullType))) {
488 return false; 514 return false;
489 } 515 }
490 } 516 }
491 return true; 517 return true;
492 } 518 }
493 519
494 /** 520 /**
521 * Check that the arguments to a call to Symbol() are correct.
522 *
523 * @param arguments the AST nodes of the arguments.
524 * @param argumentValues the values of the unnamed arguments.
525 * @param namedArgumentValues the values of the named arguments.
526 * @return true if the arguments are correct, false if there is an error.
527 */
528 bool _checkSymbolArguments(NodeList<Expression> arguments, List<DartObjectImpl > argumentValues, HashMap<String, DartObjectImpl> namedArgumentValues) {
529 if (arguments.length != 1) {
530 return false;
531 }
532 if (arguments[0] is NamedExpression) {
533 return false;
534 }
535 if (!identical(argumentValues[0].type, typeProvider.stringType)) {
536 return false;
537 }
538 String name = argumentValues[0].stringValue;
539 return isValidPublicSymbol(name);
540 }
541
542 /**
495 * Compute a value for the given constant. 543 * Compute a value for the given constant.
496 * 544 *
497 * @param constNode the constant for which a value is to be computed 545 * @param constNode the constant for which a value is to be computed
498 */ 546 */
499 void _computeValueFor(AstNode constNode) { 547 void _computeValueFor(AstNode constNode) {
500 beforeComputeValue(constNode); 548 beforeComputeValue(constNode);
501 if (constNode is VariableDeclaration) { 549 if (constNode is VariableDeclaration) {
502 VariableDeclaration declaration = constNode; 550 VariableDeclaration declaration = constNode;
503 Element element = declaration.element; 551 Element element = declaration.element;
504 EvaluationResultImpl result = declaration.initializer.accept(createConstan tVisitor()); 552 EvaluationResultImpl result = declaration.initializer.accept(createConstan tVisitor());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } else if (identical(definingClass, typeProvider.intType)) { 643 } else if (identical(definingClass, typeProvider.intType)) {
596 DartObject valueFromEnvironment; 644 DartObject valueFromEnvironment;
597 valueFromEnvironment = _declaredVariables.getInt(typeProvider, variabl eName); 645 valueFromEnvironment = _declaredVariables.getInt(typeProvider, variabl eName);
598 return _computeValueFromEnvironment(valueFromEnvironment, new DartObje ctImpl(typeProvider.nullType, NullState.NULL_STATE), namedArgumentValues); 646 return _computeValueFromEnvironment(valueFromEnvironment, new DartObje ctImpl(typeProvider.nullType, NullState.NULL_STATE), namedArgumentValues);
599 } else if (identical(definingClass, typeProvider.stringType)) { 647 } else if (identical(definingClass, typeProvider.stringType)) {
600 DartObject valueFromEnvironment; 648 DartObject valueFromEnvironment;
601 valueFromEnvironment = _declaredVariables.getString(typeProvider, vari ableName); 649 valueFromEnvironment = _declaredVariables.getString(typeProvider, vari ableName);
602 return _computeValueFromEnvironment(valueFromEnvironment, new DartObje ctImpl(typeProvider.nullType, NullState.NULL_STATE), namedArgumentValues); 650 return _computeValueFromEnvironment(valueFromEnvironment, new DartObje ctImpl(typeProvider.nullType, NullState.NULL_STATE), namedArgumentValues);
603 } 651 }
604 } else if (constructor.name == "" && identical(definingClass, typeProvider .symbolType) && argumentCount == 1) { 652 } else if (constructor.name == "" && identical(definingClass, typeProvider .symbolType) && argumentCount == 1) {
653 if (!_checkSymbolArguments(arguments, argumentValues, namedArgumentValue s)) {
654 return new ErrorResult.con1(node, CompileTimeErrorCode.CONST_EVAL_THRO WS_EXCEPTION);
655 }
605 String argumentValue = argumentValues[0].stringValue; 656 String argumentValue = argumentValues[0].stringValue;
606 if (argumentValue != null) { 657 return constantVisitor._valid(definingClass, new SymbolState(argumentVal ue));
607 return constantVisitor._valid(definingClass, new SymbolState(argumentV alue));
608 }
609 } 658 }
610 // Either it's an external const factory constructor that we can't emulate , or an error 659 // Either it's an external const factory constructor that we can't emulate , or an error
611 // occurred (a cycle, or a const constructor trying to delegate to a non-c onst constructor). 660 // occurred (a cycle, or a const constructor trying to delegate to a non-c onst constructor).
612 // In the former case, the best we can do is consider it an unknown value. In the latter 661 // In the former case, the best we can do is consider it an unknown value. In the latter
613 // case, the error has already been reported, so considering it an unknown value will 662 // case, the error has already been reported, so considering it an unknown value will
614 // suppress further errors. 663 // suppress further errors.
615 return constantVisitor._validWithUnknownValue(definingClass); 664 return constantVisitor._validWithUnknownValue(definingClass);
616 } 665 }
617 beforeGetConstantInitializers(constructor); 666 beforeGetConstantInitializers(constructor);
618 ConstructorElementImpl constructorBase = _getConstructorBase(constructor) as ConstructorElementImpl; 667 ConstructorElementImpl constructorBase = _getConstructorBase(constructor) as ConstructorElementImpl;
(...skipping 4296 matching lines...) Expand 10 before | Expand all | Expand 10 after
4915 ErrorResult _error(AstNode node, ErrorCode code) => new ErrorResult.con1(node, code); 4964 ErrorResult _error(AstNode node, ErrorCode code) => new ErrorResult.con1(node, code);
4916 4965
4917 /** 4966 /**
4918 * Return a result object representing the given value. 4967 * Return a result object representing the given value.
4919 * 4968 *
4920 * @param value the value to be represented as a result object 4969 * @param value the value to be represented as a result object
4921 * @return a result object representing the given value 4970 * @return a result object representing the given value
4922 */ 4971 */
4923 ValidResult _valueOf(DartObjectImpl value) => new ValidResult(value); 4972 ValidResult _valueOf(DartObjectImpl value) => new ValidResult(value);
4924 } 4973 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698