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

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

Issue 1892183002: Refactor Parsing to remove compiler dependency (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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) 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 library dart2js.serialization.resolved_ast; 5 library dart2js.serialization.resolved_ast;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart'; 8 import '../common/resolution.dart';
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
297 token = token.next; 297 token = token.next;
298 } 298 }
299 return null; 299 return null;
300 } 300 }
301 301
302 /// Deserializes the [ResolvedAst] for [element] from [objectDecoder]. 302 /// Deserializes the [ResolvedAst] for [element] from [objectDecoder].
303 /// [parsing] and [getBeginToken] are used for parsing the [Node] for 303 /// [parsing] and [getBeginToken] are used for parsing the [Node] for
304 /// [element] from its source code. 304 /// [element] from its source code.
305 static ResolvedAst deserialize(Element element, ObjectDecoder objectDecoder, 305 static ResolvedAst deserialize(Element element, ObjectDecoder objectDecoder,
306 Parsing parsing, Token getBeginToken(Uri uri, int charOffset)) { 306 ParsingContext parsing, Token getBeginToken(Uri uri, int charOffset)) {
307 ResolvedAstKind kind = 307 ResolvedAstKind kind =
308 objectDecoder.getEnum(Key.KIND, ResolvedAstKind.values); 308 objectDecoder.getEnum(Key.KIND, ResolvedAstKind.values);
309 switch (kind) { 309 switch (kind) {
310 case ResolvedAstKind.PARSED: 310 case ResolvedAstKind.PARSED:
311 return deserializeParsed( 311 return deserializeParsed(
312 element, objectDecoder, parsing, getBeginToken); 312 element, objectDecoder, parsing, getBeginToken);
313 case ResolvedAstKind.DEFAULT_CONSTRUCTOR: 313 case ResolvedAstKind.DEFAULT_CONSTRUCTOR:
314 case ResolvedAstKind.FORWARDING_CONSTRUCTOR: 314 case ResolvedAstKind.FORWARDING_CONSTRUCTOR:
315 return new SynthesizedResolvedAst(element, kind); 315 return new SynthesizedResolvedAst(element, kind);
316 } 316 }
317 } 317 }
318 318
319 /// Deserialize a [ResolvedAst] that is defined in terms of an AST together 319 /// Deserialize a [ResolvedAst] that is defined in terms of an AST together
320 /// with [TreeElements]. 320 /// with [TreeElements].
321 static ResolvedAst deserializeParsed( 321 static ResolvedAst deserializeParsed(
322 Element element, 322 Element element,
323 ObjectDecoder objectDecoder, 323 ObjectDecoder objectDecoder,
324 Parsing parsing, 324 ParsingContext parsing,
325 Token getBeginToken(Uri uri, int charOffset)) { 325 Token getBeginToken(Uri uri, int charOffset)) {
326 CompilationUnitElement compilationUnit = element.compilationUnit; 326 CompilationUnitElement compilationUnit = element.compilationUnit;
327 DiagnosticReporter reporter = parsing.reporter; 327 DiagnosticReporter reporter = parsing.reporter;
328 328
329 /// Returns the first [Token] for parsing the [Node] for [element]. 329 /// Returns the first [Token] for parsing the [Node] for [element].
330 Token readBeginToken() { 330 Token readBeginToken() {
331 Uri uri = objectDecoder.getUri(Key.URI); 331 Uri uri = objectDecoder.getUri(Key.URI);
332 int charOffset = objectDecoder.getInt(Key.OFFSET); 332 int charOffset = objectDecoder.getInt(Key.OFFSET);
333 Token beginToken = getBeginToken(uri, charOffset); 333 Token beginToken = getBeginToken(uri, charOffset);
334 if (beginToken == null) { 334 if (beginToken == null) {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 int targetLabelId = 590 int targetLabelId =
591 objectDecoder.getInt(Key.TARGET_LABEL, isOptional: true); 591 objectDecoder.getInt(Key.TARGET_LABEL, isOptional: true);
592 if (targetLabelId != null) { 592 if (targetLabelId != null) {
593 elements.registerTargetLabel(node, labelDefinitions[targetLabelId]); 593 elements.registerTargetLabel(node, labelDefinitions[targetLabelId]);
594 } 594 }
595 } 595 }
596 } 596 }
597 return new ParsedResolvedAst(element, root, elements); 597 return new ParsedResolvedAst(element, root, elements);
598 } 598 }
599 } 599 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/resolution.dart ('k') | tests/compiler/dart2js/compiler_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698