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

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

Issue 1881013002: Expand ResolvedAst to handle synthetic constructors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments + fix test, cps and compilation units for injected members. Created 4 years, 8 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) 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 library dart2js.compiler_base; 5 library dart2js.compiler_base;
6 6
7 import 'dart:async' show EventSink, Future; 7 import 'dart:async' show EventSink, Future;
8 8
9 import '../compiler_new.dart' as api; 9 import '../compiler_new.dart' as api;
10 import 'cache_strategy.dart' show CacheStrategy; 10 import 'cache_strategy.dart' show CacheStrategy;
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 reporter.log('Resolved ${enqueuer.resolution.processedElements.length} ' 1056 reporter.log('Resolved ${enqueuer.resolution.processedElements.length} '
1057 'elements.'); 1057 'elements.');
1058 progress.reset(); 1058 progress.reset();
1059 } 1059 }
1060 } 1060 }
1061 AstElement element = work.element; 1061 AstElement element = work.element;
1062 if (world.hasBeenProcessed(element)) { 1062 if (world.hasBeenProcessed(element)) {
1063 return const WorldImpact(); 1063 return const WorldImpact();
1064 } 1064 }
1065 WorldImpact worldImpact = analyzeElement(element); 1065 WorldImpact worldImpact = analyzeElement(element);
1066 backend.onElementResolved(element, element.resolvedAst.elements); 1066 backend.onElementResolved(element);
1067 world.registerProcessedElement(element); 1067 world.registerProcessedElement(element);
1068 return worldImpact; 1068 return worldImpact;
1069 } 1069 }
1070 1070
1071 WorldImpact codegen(CodegenWorkItem work, CodegenEnqueuer world) { 1071 WorldImpact codegen(CodegenWorkItem work, CodegenEnqueuer world) {
1072 assert(invariant(work.element, identical(world, enqueuer.codegen))); 1072 assert(invariant(work.element, identical(world, enqueuer.codegen)));
1073 if (shouldPrintProgress) { 1073 if (shouldPrintProgress) {
1074 // TODO(ahe): Add structured diagnostics to the compiler API and 1074 // TODO(ahe): Add structured diagnostics to the compiler API and
1075 // use it to separate this from the --verbose option. 1075 // use it to separate this from the --verbose option.
1076 reporter 1076 reporter
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 return compiler.resolver.resolveSignature(function); 1888 return compiler.resolver.resolveSignature(function);
1889 } 1889 }
1890 1890
1891 @override 1891 @override
1892 DartType resolveTypeAnnotation(Element element, TypeAnnotation node) { 1892 DartType resolveTypeAnnotation(Element element, TypeAnnotation node) {
1893 return compiler.resolver.resolveTypeAnnotation(element, node); 1893 return compiler.resolver.resolveTypeAnnotation(element, node);
1894 } 1894 }
1895 1895
1896 @override 1896 @override
1897 bool hasResolvedAst(Element element) { 1897 bool hasResolvedAst(Element element) {
1898 assert(invariant(element, element.isDeclaration,
1899 message: "Element $element must be the declaration."));
1898 return element is AstElement && 1900 return element is AstElement &&
1899 hasBeenResolved(element) && 1901 hasBeenResolved(element) &&
1900 element.hasResolvedAst; 1902 element.hasResolvedAst;
1901 } 1903 }
1902 1904
1903 @override 1905 @override
1904 ResolvedAst getResolvedAst(Element element) { 1906 ResolvedAst getResolvedAst(Element element) {
1907 assert(invariant(element, element.isDeclaration,
1908 message: "Element $element must be the declaration."));
1905 if (hasResolvedAst(element)) { 1909 if (hasResolvedAst(element)) {
1906 AstElement astElement = element; 1910 AstElement astElement = element;
1907 return astElement.resolvedAst; 1911 return astElement.resolvedAst;
1908 } 1912 }
1909 assert(invariant(element, hasResolvedAst(element), 1913 assert(invariant(element, hasResolvedAst(element),
1910 message: "ResolvedAst not available for $element.")); 1914 message: "ResolvedAst not available for $element."));
1911 return null; 1915 return null;
1912 } 1916 }
1913 1917
1914
1915 @override 1918 @override
1916 bool hasResolutionImpact(Element element) { 1919 bool hasResolutionImpact(Element element) {
1920 assert(invariant(element, element.isDeclaration,
1921 message: "Element $element must be the declaration."));
1917 return _resolutionImpactCache.containsKey(element); 1922 return _resolutionImpactCache.containsKey(element);
1918 } 1923 }
1919 1924
1920 @override 1925 @override
1921 ResolutionImpact getResolutionImpact(Element element) { 1926 ResolutionImpact getResolutionImpact(Element element) {
1927 assert(invariant(element, element.isDeclaration,
1928 message: "Element $element must be the declaration."));
1922 ResolutionImpact resolutionImpact = _resolutionImpactCache[element]; 1929 ResolutionImpact resolutionImpact = _resolutionImpactCache[element];
1923 assert(invariant(element, resolutionImpact != null, 1930 assert(invariant(element, resolutionImpact != null,
1924 message: "ResolutionImpact not available for $element.")); 1931 message: "ResolutionImpact not available for $element."));
1925 return resolutionImpact; 1932 return resolutionImpact;
1926 } 1933 }
1927 1934
1928 @override 1935 @override
1929 WorldImpact getWorldImpact(Element element) { 1936 WorldImpact getWorldImpact(Element element) {
1937 assert(invariant(element, element.isDeclaration,
1938 message: "Element $element must be the declaration."));
1930 WorldImpact worldImpact = _worldImpactCache[element]; 1939 WorldImpact worldImpact = _worldImpactCache[element];
1931 assert(invariant(element, worldImpact != null, 1940 assert(invariant(element, worldImpact != null,
1932 message: "WorldImpact not computed for $element.")); 1941 message: "WorldImpact not computed for $element."));
1933 return worldImpact; 1942 return worldImpact;
1934 } 1943 }
1935 1944
1936 @override 1945 @override
1937 WorldImpact computeWorldImpact(Element element) { 1946 WorldImpact computeWorldImpact(Element element) {
1947 assert(invariant(element, element.isDeclaration,
1948 message: "Element $element must be the declaration."));
1938 return _worldImpactCache.putIfAbsent(element, () { 1949 return _worldImpactCache.putIfAbsent(element, () {
1939 assert(compiler.parser != null); 1950 assert(compiler.parser != null);
1940 Node tree = compiler.parser.parse(element); 1951 Node tree = compiler.parser.parse(element);
1941 assert(invariant(element, !element.isSynthesized || tree == null)); 1952 assert(invariant(element, !element.isSynthesized || tree == null));
1942 ResolutionImpact resolutionImpact = compiler.resolver.resolve(element); 1953 ResolutionImpact resolutionImpact = compiler.resolver.resolve(element);
1943 if (compiler.serialization.supportSerialization || 1954 if (compiler.serialization.supportSerialization ||
1944 retainCachesForTesting) { 1955 retainCachesForTesting) {
1945 // [ResolutionImpact] is currently only used by serialization. The 1956 // [ResolutionImpact] is currently only used by serialization. The
1946 // enqueuer uses the [WorldImpact] which is always cached. 1957 // enqueuer uses the [WorldImpact] which is always cached.
1947 // TODO(johnniwinther): Align these use cases better; maybe only 1958 // TODO(johnniwinther): Align these use cases better; maybe only
1948 // cache [ResolutionImpact] and let the enqueuer transform it into 1959 // cache [ResolutionImpact] and let the enqueuer transform it into
1949 // a [WorldImpact]. 1960 // a [WorldImpact].
1950 _resolutionImpactCache[element] = resolutionImpact; 1961 _resolutionImpactCache[element] = resolutionImpact;
1951 } 1962 }
1952 if (tree != null && !compiler.options.analyzeSignaturesOnly) { 1963 if (tree != null && !compiler.options.analyzeSignaturesOnly) {
1953 // TODO(het): don't do this if suppressWarnings is on, currently we have 1964 // TODO(het): don't do this if suppressWarnings is on, currently we have
1954 // to do it because the typechecker also sets types 1965 // to do it because the typechecker also sets types
1955 // Only analyze nodes with a corresponding [TreeElements]. 1966 // Only analyze nodes with a corresponding [TreeElements].
1956 compiler.checker.check(element); 1967 compiler.checker.check(element);
1957 } 1968 }
1958 WorldImpact worldImpact = compiler.backend.impactTransformer 1969 WorldImpact worldImpact = compiler.backend.impactTransformer
1959 .transformResolutionImpact(resolutionImpact); 1970 .transformResolutionImpact(resolutionImpact);
1960 return worldImpact; 1971 return worldImpact;
1961 }); 1972 });
1962 } 1973 }
1963 1974
1964 @override 1975 @override
1965 void uncacheWorldImpact(Element element) { 1976 void uncacheWorldImpact(Element element) {
1977 assert(invariant(element, element.isDeclaration,
1978 message: "Element $element must be the declaration."));
1966 if (retainCachesForTesting) return; 1979 if (retainCachesForTesting) return;
1967 if (compiler.serialization.isDeserialized(element)) return; 1980 if (compiler.serialization.isDeserialized(element)) return;
1968 assert(invariant(element, _worldImpactCache[element] != null, 1981 assert(invariant(element, _worldImpactCache[element] != null,
1969 message: "WorldImpact not computed for $element.")); 1982 message: "WorldImpact not computed for $element."));
1970 _worldImpactCache[element] = const WorldImpact(); 1983 _worldImpactCache[element] = const WorldImpact();
1971 _resolutionImpactCache.remove(element); 1984 _resolutionImpactCache.remove(element);
1972 } 1985 }
1973 1986
1974 @override 1987 @override
1975 void emptyCache() { 1988 void emptyCache() {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 _ElementScanner(this.scanner); 2086 _ElementScanner(this.scanner);
2074 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); 2087 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library);
2075 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); 2088 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit);
2076 } 2089 }
2077 2090
2078 class _EmptyEnvironment implements Environment { 2091 class _EmptyEnvironment implements Environment {
2079 const _EmptyEnvironment(); 2092 const _EmptyEnvironment();
2080 2093
2081 String valueOf(String key) => null; 2094 String valueOf(String key) => null;
2082 } 2095 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compile_time_constants.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698