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

Unified Diff: tools/patch_sdk.dart

Issue 2693863006: VM: Restore old implementation of ClassID.cid* fields (Closed)
Patch Set: Done Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/patch_sdk.dart
diff --git a/tools/patch_sdk.dart b/tools/patch_sdk.dart
index e9980eab858fc52d212d1ab8e4b1b2710547f4fc..04e3df84be2ea194679d744395c365f171fa579e 100644
--- a/tools/patch_sdk.dart
+++ b/tools/patch_sdk.dart
@@ -257,6 +257,11 @@ List<String> _patchLibrary(String name,
return new List<String>.from(results.map((e) => e.toString()));
}
+final injectedCidFields = [
+ 'Array', 'ExternalOneByteString', 'GrowableObjectArray',
+ 'ImmutableArray', 'OneByteString', 'TwoByteString', 'Bigint'
+].map((name) => "static final int cid${name} = 0;").join('\n');
+
/// Merge `@patch` declarations into `external` declarations.
class PatchApplier extends GeneralizingAstVisitor {
final StringEditBuffer edits;
@@ -274,6 +279,15 @@ class PatchApplier extends GeneralizingAstVisitor {
void _merge(AstNode node, int pos) {
var code = patch.contents.substring(node.offset, node.end);
+
+ // We inject a number of static fields into dart:internal.ClassID class.
+ // These fields represent various VM class ids and are only used to
+ // make core libraries compile. Kernel reader will actually ignore this
+ // fields and instead inject concrete constants into this class.
+ if (node is ClassDeclaration && node.name.name == 'ClassID') {
+ code = code.replaceFirst(
+ new RegExp(r'}$'), injectedCidFields + '}');
+ }
edits.insert(pos, '\n' + code);
}
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698