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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart

Issue 2909013002: Clean up shared names. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/names.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /// A library to help transform compounds and null-aware accessors into 5 /// A library to help transform compounds and null-aware accessors into
6 /// let expressions. 6 /// let expressions.
7 7
8 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' 8 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'
9 show 9 show
10 KernelArguments, 10 KernelArguments,
11 KernelMethodInvocation, 11 KernelMethodInvocation,
12 KernelPropertyGet, 12 KernelPropertyGet,
13 KernelPropertySet, 13 KernelPropertySet,
14 KernelVariableGet, 14 KernelVariableGet,
15 KernelVariableSet; 15 KernelVariableSet;
16 16
17 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken; 17 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken;
18 18
19 import 'package:front_end/src/scanner/token.dart' show Token; 19 import 'package:front_end/src/scanner/token.dart' show Token;
20 20
21 import 'package:front_end/src/fasta/kernel/fasta_accessors.dart' 21 import 'package:front_end/src/fasta/kernel/fasta_accessors.dart'
22 show BuilderHelper; 22 show BuilderHelper;
23 23
24 import 'package:kernel/ast.dart' hide MethodInvocation; 24 import 'package:kernel/ast.dart' hide MethodInvocation;
25 25
26 final Name indexGetName = new Name("[]"); 26 import '../names.dart' show equalsName, indexGetName, indexSetName;
27
28 final Name indexSetName = new Name("[]=");
29 27
30 /// An [Accessor] represents a subexpression for which we can't yet build a 28 /// An [Accessor] represents a subexpression for which we can't yet build a
31 /// kernel [Expression] because we don't yet know the context in which it is 29 /// kernel [Expression] because we don't yet know the context in which it is
32 /// used. 30 /// used.
33 /// 31 ///
34 /// Once the context is known, an [Accessor] can be converted into an 32 /// Once the context is known, an [Accessor] can be converted into an
35 /// [Expression] by calling a "build" method. 33 /// [Expression] by calling a "build" method.
36 /// 34 ///
37 /// For example, when building a kernel representation for `a[x] = b`, after 35 /// For example, when building a kernel representation for `a[x] = b`, after
38 /// parsing `a[x]` but before parsing `= b`, we don't yet know whether to 36 /// parsing `a[x]` but before parsing `= b`, we don't yet know whether to
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 } 514 }
517 515
518 Expression makeBinary( 516 Expression makeBinary(
519 Expression left, Name operator, Procedure interfaceTarget, Expression right, 517 Expression left, Name operator, Procedure interfaceTarget, Expression right,
520 {int offset: TreeNode.noOffset}) { 518 {int offset: TreeNode.noOffset}) {
521 return new KernelMethodInvocation( 519 return new KernelMethodInvocation(
522 left, operator, new KernelArguments(<Expression>[right]), interfaceTarget) 520 left, operator, new KernelArguments(<Expression>[right]), interfaceTarget)
523 ..fileOffset = offset; 521 ..fileOffset = offset;
524 } 522 }
525 523
526 final Name _equalOperator = new Name('==');
527
528 Expression buildIsNull(Expression value, {int offset: TreeNode.noOffset}) { 524 Expression buildIsNull(Expression value, {int offset: TreeNode.noOffset}) {
529 return makeBinary(value, _equalOperator, null, new NullLiteral(), 525 return makeBinary(value, equalsName, null, new NullLiteral(), offset: offset);
530 offset: offset);
531 } 526 }
532 527
533 VariableDeclaration makeOrReuseVariable(Expression value) { 528 VariableDeclaration makeOrReuseVariable(Expression value) {
534 // TODO: Devise a way to remember if a variable declaration was reused 529 // TODO: Devise a way to remember if a variable declaration was reused
535 // or is fresh (hence needs a let binding). 530 // or is fresh (hence needs a let binding).
536 return new VariableDeclaration.forValue(value); 531 return new VariableDeclaration.forValue(value);
537 } 532 }
538 533
539 Expression wrapInvalid(Expression e) { 534 Expression wrapInvalid(Expression e) {
540 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression()); 535 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression());
541 } 536 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/names.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698