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

Side by Side Diff: lib/src/codegen/js_codegen.dart

Issue 1174643003: expose strong checker API, for use by analyzer_cli (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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 | « lib/src/codegen/code_generator.dart ('k') | lib/src/dependency_graph.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) 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 dev_compiler.src.codegen.js_codegen; 5 library dev_compiler.src.codegen.js_codegen;
6 6
7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; 7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator;
11 import 'package:analyzer/src/generated/constant.dart'; 11 import 'package:analyzer/src/generated/constant.dart';
12 import 'package:analyzer/src/generated/element.dart'; 12 import 'package:analyzer/src/generated/element.dart';
13 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; 13 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider;
14 import 'package:analyzer/src/generated/scanner.dart' 14 import 'package:analyzer/src/generated/scanner.dart'
15 show StringToken, Token, TokenType; 15 show StringToken, Token, TokenType;
16 import 'package:path/path.dart' as path; 16 import 'package:path/path.dart' as path;
17 17
18 import 'package:dev_compiler/src/codegen/ast_builder.dart' show AstBuilder; 18 import 'package:dev_compiler/src/codegen/ast_builder.dart' show AstBuilder;
19 import 'package:dev_compiler/src/codegen/reify_coercions.dart' 19 import 'package:dev_compiler/src/codegen/reify_coercions.dart'
20 show CoercionReifier; 20 show CoercionReifier;
21 21
22 // TODO(jmesserly): import from its own package 22 // TODO(jmesserly): import from its own package
23 import 'package:dev_compiler/src/js/js_ast.dart' as JS; 23 import 'package:dev_compiler/src/js/js_ast.dart' as JS;
24 import 'package:dev_compiler/src/js/js_ast.dart' show js; 24 import 'package:dev_compiler/src/js/js_ast.dart' show js;
25 25
26 import 'package:dev_compiler/devc.dart' show AbstractCompiler; 26 import 'package:dev_compiler/devc.dart' show AbstractCompiler;
27 import 'package:dev_compiler/src/checker/rules.dart'; 27 import 'package:dev_compiler/src/checker/rules.dart';
28 import 'package:dev_compiler/src/info.dart'; 28 import 'package:dev_compiler/src/info.dart';
29 import 'package:dev_compiler/src/options.dart'; 29 import 'package:dev_compiler/src/options.dart' show CodegenOptions;
30 import 'package:dev_compiler/src/utils.dart'; 30 import 'package:dev_compiler/src/utils.dart';
31 31
32 import 'code_generator.dart'; 32 import 'code_generator.dart';
33 import 'js_field_storage.dart'; 33 import 'js_field_storage.dart';
34 import 'js_names.dart' as JS; 34 import 'js_names.dart' as JS;
35 import 'js_metalet.dart' as JS; 35 import 'js_metalet.dart' as JS;
36 import 'js_module_item_order.dart'; 36 import 'js_module_item_order.dart';
37 import 'js_printer.dart' show writeJsLibrary; 37 import 'js_printer.dart' show writeJsLibrary;
38 import 'side_effect_analysis.dart'; 38 import 'side_effect_analysis.dart';
39 39
40 // Various dynamic helpers we call. 40 // Various dynamic helpers we call.
41 // If renaming these, make sure to check other places like the 41 // If renaming these, make sure to check other places like the
42 // dart_runtime.js file and comments. 42 // dart_runtime.js file and comments.
43 // TODO(jmesserly): ideally we'd have a "dynamic call" dart library we can 43 // TODO(jmesserly): ideally we'd have a "dynamic call" dart library we can
44 // import and generate calls to, rather than dart_runtime.js 44 // import and generate calls to, rather than dart_runtime.js
45 const DPUT = 'dput'; 45 const DPUT = 'dput';
46 const DLOAD = 'dload'; 46 const DLOAD = 'dload';
47 const DINDEX = 'dindex'; 47 const DINDEX = 'dindex';
48 const DSETINDEX = 'dsetindex'; 48 const DSETINDEX = 'dsetindex';
49 const DCALL = 'dcall'; 49 const DCALL = 'dcall';
50 const DSEND = 'dsend'; 50 const DSEND = 'dsend';
51 51
52 class JSCodegenVisitor extends GeneralizingAstVisitor { 52 class JSCodegenVisitor extends GeneralizingAstVisitor {
53 final AbstractCompiler compiler; 53 final AbstractCompiler compiler;
54 final CompilerOptions options; 54 final CodegenOptions options;
55 final TypeRules rules; 55 final TypeRules rules;
56 final LibraryInfo libraryInfo; 56 final LibraryInfo libraryInfo;
57 57
58 /// Entry point uri 58 /// Entry point uri
59 final Uri root; 59 final Uri root;
60 60
61 /// The global extension type table. 61 /// The global extension type table.
62 final HashSet<ClassElement> _extensionTypes; 62 final HashSet<ClassElement> _extensionTypes;
63 63
64 /// Information that is precomputed for this library, indicates which fields 64 /// Information that is precomputed for this library, indicates which fields
(...skipping 27 matching lines...) Expand all
92 ModuleItemLoadOrder _loader; 92 ModuleItemLoadOrder _loader;
93 93
94 /// _interceptors.JSArray<E>, used for List literals. 94 /// _interceptors.JSArray<E>, used for List literals.
95 ClassElement _jsArray; 95 ClassElement _jsArray;
96 96
97 Map<String, DartType> _objectMembers; 97 Map<String, DartType> _objectMembers;
98 98
99 JSCodegenVisitor(AbstractCompiler compiler, this.libraryInfo, 99 JSCodegenVisitor(AbstractCompiler compiler, this.libraryInfo,
100 this._extensionTypes, this._fieldsNeedingStorage) 100 this._extensionTypes, this._fieldsNeedingStorage)
101 : compiler = compiler, 101 : compiler = compiler,
102 options = compiler.options, 102 options = compiler.options.codegenOptions,
103 rules = compiler.rules, 103 rules = compiler.rules,
104 root = compiler.entryPointUri { 104 root = compiler.entryPointUri {
105 _loader = new ModuleItemLoadOrder(_emitModuleItem); 105 _loader = new ModuleItemLoadOrder(_emitModuleItem);
106 106
107 var context = compiler.context; 107 var context = compiler.context;
108 var src = context.sourceFactory.forUri('dart:_interceptors'); 108 var src = context.sourceFactory.forUri('dart:_interceptors');
109 var interceptors = context.computeLibraryElement(src); 109 var interceptors = context.computeLibraryElement(src);
110 _jsArray = interceptors.getType('JSArray'); 110 _jsArray = interceptors.getType('JSArray');
111 111
112 _objectMembers = getObjectMemberMap(types); 112 _objectMembers = getObjectMemberMap(types);
(...skipping 2673 matching lines...) Expand 10 before | Expand all | Expand 10 after
2786 2786
2787 /// A special kind of element created by the compiler, signifying a temporary 2787 /// A special kind of element created by the compiler, signifying a temporary
2788 /// variable. These objects use instance equality, and should be shared 2788 /// variable. These objects use instance equality, and should be shared
2789 /// everywhere in the tree where they are treated as the same variable. 2789 /// everywhere in the tree where they are treated as the same variable.
2790 class TemporaryVariableElement extends LocalVariableElementImpl { 2790 class TemporaryVariableElement extends LocalVariableElementImpl {
2791 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); 2791 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name);
2792 2792
2793 int get hashCode => identityHashCode(this); 2793 int get hashCode => identityHashCode(this);
2794 bool operator ==(Object other) => identical(this, other); 2794 bool operator ==(Object other) => identical(this, other);
2795 } 2795 }
OLDNEW
« no previous file with comments | « lib/src/codegen/code_generator.dart ('k') | lib/src/dependency_graph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698