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

Side by Side Diff: pkg/compiler/lib/src/js_backend/constant_emitter.dart

Issue 2466393002: Change to <- for types.
Patch Set: Fixes. Created 4 years, 1 month 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import '../common.dart'; 5 import '../common.dart';
6 import '../compiler.dart' show Compiler; 6 import '../compiler.dart' show Compiler;
7 import '../constants/values.dart'; 7 import '../constants/values.dart';
8 import '../dart_types.dart'; 8 import '../dart_types.dart';
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../io/code_output.dart'; 10 import '../io/code_output.dart';
(...skipping 15 matching lines...) Expand all
26 * constants should be inlined or not. 26 * constants should be inlined or not.
27 */ 27 */
28 class ConstantEmitter implements ConstantValueVisitor<jsAst.Expression, Null> { 28 class ConstantEmitter implements ConstantValueVisitor<jsAst.Expression, Null> {
29 // Matches blank lines, comment lines and trailing comments that can't be part 29 // Matches blank lines, comment lines and trailing comments that can't be part
30 // of a string. 30 // of a string.
31 static final RegExp COMMENT_RE = 31 static final RegExp COMMENT_RE =
32 new RegExp(r'''^ *(//.*)?\n| *//[^''"\n]*$''', multiLine: true); 32 new RegExp(r'''^ *(//.*)?\n| *//[^''"\n]*$''', multiLine: true);
33 33
34 final Compiler compiler; 34 final Compiler compiler;
35 final Namer namer; 35 final Namer namer;
36 final _ConstantReferenceGenerator constantReferenceGenerator; 36 final jsAst.Expression<-ConstantValue constantReferenceGenerator;
37 final _ConstantListGenerator makeConstantList; 37 final jsAst.Expression <- (jsAst.Expression array) makeConstantList;
38 38
39 /** 39 /**
40 * The given [constantReferenceGenerator] function must, when invoked with a 40 * The given [constantReferenceGenerator] function must, when invoked with a
41 * constant, either return a reference or return its literal expression if it 41 * constant, either return a reference or return its literal expression if it
42 * can be inlined. 42 * can be inlined.
43 */ 43 */
44 ConstantEmitter( 44 ConstantEmitter(
45 this.compiler, 45 this.compiler,
46 this.namer, 46 this.namer,
47 jsAst.Expression this.constantReferenceGenerator(ConstantValue constant), 47 jsAst.Expression<-ConstantValue this.constantReferenceGenerator,
48 this.makeConstantList); 48 this.makeConstantList);
49 49
50 DiagnosticReporter get reporter => compiler.reporter; 50 DiagnosticReporter get reporter => compiler.reporter;
51 51
52 /** 52 /**
53 * Constructs a literal expression that evaluates to the constant. Uses a 53 * Constructs a literal expression that evaluates to the constant. Uses a
54 * canonical name unless the constant can be emitted multiple times (as for 54 * canonical name unless the constant can be emitted multiple times (as for
55 * numbers and strings). 55 * numbers and strings).
56 */ 56 */
57 jsAst.Expression generate(ConstantValue constant) { 57 jsAst.Expression generate(ConstantValue constant) {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 arguments.add(rtiEncoder.getTypeRepresentation(argument, unexpected)); 349 arguments.add(rtiEncoder.getTypeRepresentation(argument, unexpected));
350 } 350 }
351 return new jsAst.ArrayInitializer(arguments); 351 return new jsAst.ArrayInitializer(arguments);
352 } 352 }
353 353
354 @override 354 @override
355 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { 355 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) {
356 return constantReferenceGenerator(constant.referenced); 356 return constantReferenceGenerator(constant.referenced);
357 } 357 }
358 } 358 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/helpers/trace.dart ('k') | pkg/compiler/lib/src/js_emitter/full_emitter/declarations.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698