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

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

Issue 2070493003: Revert "Remove Registry from registerMetadataConstant" and "Serialize metadata" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 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
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 /** 5 /**
6 * This library contains the infrastructure to parse and integrate patch files. 6 * This library contains the infrastructure to parse and integrate patch files.
7 * 7 *
8 * Three types of elements can be patched: [LibraryElement], [ClassElement], 8 * Three types of elements can be patched: [LibraryElement], [ClassElement],
9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded 9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded
10 * together with the corresponding origin library. Which libraries that are 10 * together with the corresponding origin library. Which libraries that are
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 import 'compiler.dart' show Compiler; 121 import 'compiler.dart' show Compiler;
122 import 'constants/values.dart' show ConstantValue; 122 import 'constants/values.dart' show ConstantValue;
123 import 'dart_types.dart' show DartType; 123 import 'dart_types.dart' show DartType;
124 import 'elements/elements.dart'; 124 import 'elements/elements.dart';
125 import 'elements/modelx.dart' 125 import 'elements/modelx.dart'
126 show 126 show
127 BaseFunctionElementX, 127 BaseFunctionElementX,
128 ClassElementX, 128 ClassElementX,
129 GetterElementX, 129 GetterElementX,
130 LibraryElementX, 130 LibraryElementX,
131 MetadataAnnotationX,
132 SetterElementX; 131 SetterElementX;
133 import 'id_generator.dart'; 132 import 'id_generator.dart';
134 import 'js_backend/js_backend.dart' show JavaScriptBackend; 133 import 'js_backend/js_backend.dart' show JavaScriptBackend;
135 import 'library_loader.dart' show LibraryLoader; 134 import 'library_loader.dart' show LibraryLoader;
136 import 'options.dart' show ParserOptions; 135 import 'options.dart' show ParserOptions;
137 import 'parser/element_listener.dart' show ElementListener; 136 import 'parser/element_listener.dart' show ElementListener;
138 import 'parser/listener.dart' show Listener, ParserError; 137 import 'parser/listener.dart' show Listener, ParserError;
139 import 'parser/member_listener.dart' show MemberListener; 138 import 'parser/member_listener.dart' show MemberListener;
140 import 'parser/parser.dart' show Parser; 139 import 'parser/parser.dart' show Parser;
141 import 'parser/partial_elements.dart' show PartialClassElement; 140 import 'parser/partial_elements.dart' show PartialClassElement;
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 396 }
398 return null; 397 return null;
399 } 398 }
400 } 399 }
401 400
402 /// Annotation handler for pre-resolution detection of `@Native(...)` 401 /// Annotation handler for pre-resolution detection of `@Native(...)`
403 /// annotations. 402 /// annotations.
404 class NativeAnnotationHandler implements EagerAnnotationHandler<String> { 403 class NativeAnnotationHandler implements EagerAnnotationHandler<String> {
405 const NativeAnnotationHandler(); 404 const NativeAnnotationHandler();
406 405
407 String getNativeAnnotation(MetadataAnnotationX annotation) { 406 String getNativeAnnotation(MetadataAnnotation annotation) {
408 if (annotation.beginToken != null && 407 if (annotation.beginToken != null &&
409 annotation.beginToken.next.value == 'Native') { 408 annotation.beginToken.next.value == 'Native') {
410 // Skipping '@', 'Native', and '('. 409 // Skipping '@', 'Native', and '('.
411 Token argument = annotation.beginToken.next.next.next; 410 Token argument = annotation.beginToken.next.next.next;
412 if (argument is StringToken) { 411 if (argument is StringToken) {
413 return argument.value; 412 return argument.value;
414 } 413 }
415 } 414 }
416 return null; 415 return null;
417 } 416 }
(...skipping 19 matching lines...) Expand all
437 reporter.internalError(annotation, 'Invalid @Native(...) annotation.'); 436 reporter.internalError(annotation, 'Invalid @Native(...) annotation.');
438 } 437 }
439 } 438 }
440 } 439 }
441 440
442 /// Annotation handler for pre-resolution detection of `@JS(...)` 441 /// Annotation handler for pre-resolution detection of `@JS(...)`
443 /// annotations. 442 /// annotations.
444 class JsInteropAnnotationHandler implements EagerAnnotationHandler<bool> { 443 class JsInteropAnnotationHandler implements EagerAnnotationHandler<bool> {
445 const JsInteropAnnotationHandler(); 444 const JsInteropAnnotationHandler();
446 445
447 bool hasJsNameAnnotation(MetadataAnnotationX annotation) => 446 bool hasJsNameAnnotation(MetadataAnnotation annotation) =>
448 annotation.beginToken != null && annotation.beginToken.next.value == 'JS'; 447 annotation.beginToken != null && annotation.beginToken.next.value == 'JS';
449 448
450 bool apply( 449 bool apply(
451 Compiler compiler, Element element, MetadataAnnotation annotation) { 450 Compiler compiler, Element element, MetadataAnnotation annotation) {
452 bool hasJsInterop = hasJsNameAnnotation(annotation); 451 bool hasJsInterop = hasJsNameAnnotation(annotation);
453 if (hasJsInterop) { 452 if (hasJsInterop) {
454 JavaScriptBackend backend = compiler.backend; 453 JavaScriptBackend backend = compiler.backend;
455 backend.nativeData.markAsJsInterop(element); 454 backend.nativeData.markAsJsInterop(element);
456 } 455 }
457 // Due to semantics of apply in the baseclass we have to return null to 456 // Due to semantics of apply in the baseclass we have to return null to
(...skipping 10 matching lines...) Expand all
468 compiler.reporter 467 compiler.reporter
469 .internalError(annotation, 'Invalid @JS(...) annotation.'); 468 .internalError(annotation, 'Invalid @JS(...) annotation.');
470 } 469 }
471 } 470 }
472 } 471 }
473 472
474 /// Annotation handler for pre-resolution detection of `@patch` annotations. 473 /// Annotation handler for pre-resolution detection of `@patch` annotations.
475 class PatchAnnotationHandler implements EagerAnnotationHandler<PatchVersion> { 474 class PatchAnnotationHandler implements EagerAnnotationHandler<PatchVersion> {
476 const PatchAnnotationHandler(); 475 const PatchAnnotationHandler();
477 476
478 PatchVersion getPatchVersion(MetadataAnnotationX annotation) { 477 PatchVersion getPatchVersion(MetadataAnnotation annotation) {
479 if (annotation.beginToken != null) { 478 if (annotation.beginToken != null) {
480 if (annotation.beginToken.next.value == 'patch') { 479 if (annotation.beginToken.next.value == 'patch') {
481 return const PatchVersion(null); 480 return const PatchVersion(null);
482 } else if (annotation.beginToken.next.value == 'patch_full') { 481 } else if (annotation.beginToken.next.value == 'patch_full') {
483 return const PatchVersion('full'); 482 return const PatchVersion('full');
484 } else if (annotation.beginToken.next.value == 'patch_lazy') { 483 } else if (annotation.beginToken.next.value == 'patch_lazy') {
485 return const PatchVersion('lazy'); 484 return const PatchVersion('lazy');
486 } else if (annotation.beginToken.next.value == 'patch_startup') { 485 } else if (annotation.beginToken.next.value == 'patch_startup') {
487 return const PatchVersion('startup'); 486 return const PatchVersion('startup');
488 } 487 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 615
617 class PatchVersion { 616 class PatchVersion {
618 final String tag; 617 final String tag;
619 618
620 const PatchVersion(this.tag); 619 const PatchVersion(this.tag);
621 620
622 bool isActive(String patchTag) => tag == null || tag == patchTag; 621 bool isActive(String patchTag) => tag == null || tag == patchTag;
623 622
624 String toString() => 'PatchVersion($tag)'; 623 String toString() => 'PatchVersion($tag)';
625 } 624 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/parser/element_listener.dart ('k') | pkg/compiler/lib/src/resolution/registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698