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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/old_emitter/reflection_data_parser.dart

Issue 981143003: dart2js: split out types from metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 5 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 // TODO(ahe): Share these with js_helper.dart. 7 // TODO(ahe): Share these with js_helper.dart.
8 const FUNCTION_INDEX = 0; 8 const FUNCTION_INDEX = 0;
9 const NAME_INDEX = 1; 9 const NAME_INDEX = 1;
10 const CALL_NAME_INDEX = 2; 10 const CALL_NAME_INDEX = 2;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 jsAst.Expression staticsAccess = 43 jsAst.Expression staticsAccess =
44 emitter.generateEmbeddedGlobalAccess(embeddedNames.STATICS); 44 emitter.generateEmbeddedGlobalAccess(embeddedNames.STATICS);
45 jsAst.Expression interceptedNamesAccess = 45 jsAst.Expression interceptedNamesAccess =
46 emitter.generateEmbeddedGlobalAccess(embeddedNames.INTERCEPTED_NAMES); 46 emitter.generateEmbeddedGlobalAccess(embeddedNames.INTERCEPTED_NAMES);
47 jsAst.Expression mangledGlobalNamesAccess = 47 jsAst.Expression mangledGlobalNamesAccess =
48 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_GLOBAL_NAMES); 48 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_GLOBAL_NAMES);
49 jsAst.Expression mangledNamesAccess = 49 jsAst.Expression mangledNamesAccess =
50 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_NAMES); 50 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_NAMES);
51 jsAst.Expression librariesAccess = 51 jsAst.Expression librariesAccess =
52 emitter.generateEmbeddedGlobalAccess(embeddedNames.LIBRARIES); 52 emitter.generateEmbeddedGlobalAccess(embeddedNames.LIBRARIES);
53 jsAst.Expression metadataAccess = 53 jsAst.Expression typesAccess =
54 emitter.generateEmbeddedGlobalAccess(embeddedNames.METADATA); 54 emitter.generateEmbeddedGlobalAccess(embeddedNames.TYPES);
55 55
56 jsAst.Statement processClassData = js.statement('''{ 56 jsAst.Statement processClassData = js.statement('''{
57 function processClassData(cls, descriptor, processedClasses) { 57 function processClassData(cls, descriptor, processedClasses) {
58 var newDesc = {}; 58 var newDesc = {};
59 var previousProperty; 59 var previousProperty;
60 var properties = Object.keys(descriptor); 60 var properties = Object.keys(descriptor);
61 for (var i = 0; i < properties.length; i++) { 61 for (var i = 0; i < properties.length; i++) {
62 var property = properties[i]; 62 var property = properties[i];
63 var firstChar = property.substring(0, 1); 63 var firstChar = property.substring(0, 1);
64 if (property === "static") { 64 if (property === "static") {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 fields = s[1] == "" ? [] : s[1].split(","); 108 fields = s[1] == "" ? [] : s[1].split(",");
109 supr = s[0]; 109 supr = s[0];
110 // ${ClassBuilder.functionTypeEncodingDescription}. 110 // ${ClassBuilder.functionTypeEncodingDescription}.
111 split = supr.split(":"); 111 split = supr.split(":");
112 if (split.length == 2) { 112 if (split.length == 2) {
113 supr = split[0]; 113 supr = split[0];
114 var functionSignature = split[1]; 114 var functionSignature = split[1];
115 if (functionSignature) 115 if (functionSignature)
116 newDesc.${namer.operatorSignature} = function(s) { 116 newDesc.${namer.operatorSignature} = function(s) {
117 return function() { 117 return function() {
118 return #metadata[s]; 118 return #types[s];
119 }; 119 };
120 }(functionSignature); 120 }(functionSignature);
121 } 121 }
122 122
123 if (supr) processedClasses.pending[cls] = supr; 123 if (supr) processedClasses.pending[cls] = supr;
124 if (#notInCspMode) { 124 if (#notInCspMode) {
125 processedClasses.combinedConstructorFunction += defineClass(cls, fields); 125 processedClasses.combinedConstructorFunction += defineClass(cls, fields);
126 processedClasses.constructorsList.push(cls); 126 processedClasses.constructorsList.push(cls);
127 } 127 }
128 processedClasses.collected[cls] = [globalObject, newDesc]; 128 processedClasses.collected[cls] = [globalObject, newDesc];
129 classes.push(cls); 129 classes.push(cls);
130 } 130 }
131 }''', {'embeddedStatics': staticsAccess, 131 }''', {'embeddedStatics': staticsAccess,
132 'hasRetainedMetadata': backend.hasRetainedMetadata, 132 'hasRetainedMetadata': backend.hasRetainedMetadata,
133 'metadata': metadataAccess, 133 'types': typesAccess,
134 'notInCspMode': !compiler.useContentSecurityPolicy}); 134 'notInCspMode': !compiler.useContentSecurityPolicy});
135 135
136 // TODO(zarah): Remove empty else branches in output when if(#hole) is false. 136 // TODO(zarah): Remove empty else branches in output when if(#hole) is false.
137 jsAst.Statement processStatics = js.statement(''' 137 jsAst.Statement processStatics = js.statement('''
138 function processStatics(descriptor, processedClasses) { 138 function processStatics(descriptor, processedClasses) {
139 var properties = Object.keys(descriptor); 139 var properties = Object.keys(descriptor);
140 for (var i = 0; i < properties.length; i++) { 140 for (var i = 0; i < properties.length; i++) {
141 var property = properties[i]; 141 var property = properties[i];
142 if (property === "${namer.classDescriptorProperty}") continue; 142 if (property === "${namer.classDescriptorProperty}") continue;
143 var element = descriptor[property]; 143 var element = descriptor[property];
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 (function() { 486 (function() {
487 var result = $array[$index]; 487 var result = $array[$index];
488 if ($check) { 488 if ($check) {
489 throw new Error( 489 throw new Error(
490 name + ": expected value of type \'$type\' at index " + ($index) + 490 name + ": expected value of type \'$type\' at index " + ($index) +
491 " but got " + (typeof result)); 491 " but got " + (typeof result));
492 } 492 }
493 return result; 493 return result;
494 })()'''; 494 })()''';
495 } 495 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart ('k') | sdk/lib/_internal/compiler/js_lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698