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

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

Issue 1245013005: fixes #259, clone ast before mutation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: revert dependency_overrides in pubspec Created 5 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
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;
(...skipping 2784 matching lines...) Expand 10 before | Expand all | Expand 10 after
2795 2795
2796 void _addExtensionType(InterfaceType t) { 2796 void _addExtensionType(InterfaceType t) {
2797 if (t.isObject || !_extensionTypes.add(t.element)) return; 2797 if (t.isObject || !_extensionTypes.add(t.element)) return;
2798 t = fillDynamicTypeArgs(t, rules.provider); 2798 t = fillDynamicTypeArgs(t, rules.provider);
2799 t.interfaces.forEach(_addExtensionType); 2799 t.interfaces.forEach(_addExtensionType);
2800 t.mixins.forEach(_addExtensionType); 2800 t.mixins.forEach(_addExtensionType);
2801 _addExtensionType(t.superclass); 2801 _addExtensionType(t.superclass);
2802 } 2802 }
2803 2803
2804 String generateLibrary(LibraryUnit unit) { 2804 String generateLibrary(LibraryUnit unit) {
2805 // Clone the AST first, so we can mutate it.
2806 unit = unit.clone();
2805 var library = unit.library.element.library; 2807 var library = unit.library.element.library;
2806 var fields = findFieldsNeedingStorage(unit); 2808 var fields = findFieldsNeedingStorage(unit);
2807 var codegen = 2809 var codegen =
2808 new JSCodegenVisitor(compiler, library, _extensionTypes, fields); 2810 new JSCodegenVisitor(compiler, library, _extensionTypes, fields);
2809 var module = codegen.emitLibrary(unit); 2811 var module = codegen.emitLibrary(unit);
2810 var out = compiler.getOutputPath(library.source.uri); 2812 var out = compiler.getOutputPath(library.source.uri);
2811 return writeJsLibrary(module, out, emitSourceMaps: options.emitSourceMaps); 2813 return writeJsLibrary(module, out, emitSourceMaps: options.emitSourceMaps);
2812 } 2814 }
2813 } 2815 }
2814 2816
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2846 2848
2847 class _JsThisFinder extends JS.BaseVisitor { 2849 class _JsThisFinder extends JS.BaseVisitor {
2848 bool found = false; 2850 bool found = false;
2849 visitThis(JS.This node) { 2851 visitThis(JS.This node) {
2850 found = true; 2852 found = true;
2851 } 2853 }
2852 visitNode(JS.Node node) { 2854 visitNode(JS.Node node) {
2853 if (!found) super.visitNode(node); 2855 if (!found) super.visitNode(node);
2854 } 2856 }
2855 } 2857 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698