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

Side by Side Diff: pkg/compiler/lib/src/constants/evaluation.dart

Issue 2669703003: Refactor ConstantExpression/ConstantConstructor to use entities. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library dart2js.constants.evaluation; 5 library dart2js.constants.evaluation;
6 6
7 import '../compiler.dart' show Compiler; 7 import '../compiler.dart' show Compiler;
8 import '../elements/elements.dart';
9 import '../elements/entities.dart';
10 import '../elements/resolution_types.dart';
11 import '../elements/types.dart';
8 import '../universe/call_structure.dart' show CallStructure; 12 import '../universe/call_structure.dart' show CallStructure;
13 import 'constructors.dart';
9 import 'expressions.dart'; 14 import 'expressions.dart';
10 15
11 /// Environment used for evaluating constant expressions. 16 /// Environment used for evaluating constant expressions.
12 abstract class Environment { 17 abstract class Environment {
13 // TODO(johnniwinther): Replace this with [CommonElements] and maybe 18 // TODO(johnniwinther): Replace this with [CommonElements] and maybe
14 // [Backend]. 19 // [Backend].
15 Compiler get compiler; 20 Compiler get compiler;
16 21
17 /// Read environments string passed in using the '-Dname=value' option. 22 /// Read environments string passed in using the '-Dname=value' option.
18 String readFromEnvironment(String name); 23 String readFromEnvironment(String name);
24
25 /// Returns the [ConstantExpression] for the value of the constant [local].
26 ConstantExpression getLocalConstant(Local local);
27
28 /// Returns the [ConstantExpression] for the value of the constant [field].
29 ConstantExpression getFieldConstant(FieldEntity field);
30
31 /// Returns the [ConstantConstructor] corresponding to the constant
32 /// [constructor].
33 ConstantConstructor getConstructorConstant(ConstructorEntity constructor);
34
35 /// Performs the substitution of the type arguments of [target] for their
36 /// corresponding type variables in [type].
37 InterfaceType substByContext(InterfaceType base, InterfaceType target);
19 } 38 }
20 39
21 /// The normalized arguments passed to a const constructor computed from the 40 /// The normalized arguments passed to a const constructor computed from the
22 /// actual [arguments] and the [defaultValues] of the called construrctor. 41 /// actual [arguments] and the [defaultValues] of the called construrctor.
23 class NormalizedArguments { 42 class NormalizedArguments {
24 final Map<dynamic /*int|String*/, ConstantExpression> defaultValues; 43 final Map<dynamic /*int|String*/, ConstantExpression> defaultValues;
25 final CallStructure callStructure; 44 final CallStructure callStructure;
26 final List<ConstantExpression> arguments; 45 final List<ConstantExpression> arguments;
27 46
28 NormalizedArguments(this.defaultValues, this.callStructure, this.arguments); 47 NormalizedArguments(this.defaultValues, this.callStructure, this.arguments);
(...skipping 10 matching lines...) Expand all
39 58
40 /// Returns the normalized [index]th positional argument. 59 /// Returns the normalized [index]th positional argument.
41 ConstantExpression getPositionalArgument(int index) { 60 ConstantExpression getPositionalArgument(int index) {
42 if (index >= callStructure.positionalArgumentCount) { 61 if (index >= callStructure.positionalArgumentCount) {
43 // The positional argument is not provided. 62 // The positional argument is not provided.
44 return defaultValues[index]; 63 return defaultValues[index];
45 } 64 }
46 return arguments[index]; 65 return arguments[index];
47 } 66 }
48 } 67 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/constants/constructors.dart ('k') | pkg/compiler/lib/src/constants/expressions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698