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

Side by Side Diff: lib/binary/ast_to_binary.dart

Issue 2502343002: Store named parameters in sorted lists instead of using maps. (Closed)
Patch Set: Remove duplicates from named parameter lists to recover from erroneous inputs Created 4 years, 1 month 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
« no previous file with comments | « lib/binary/ast_from_binary.dart ('k') | lib/checks.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library kernel.ast_to_binary; 4 library kernel.ast_to_binary;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import '../import_table.dart'; 7 import '../import_table.dart';
8 import 'tag.dart'; 8 import 'tag.dart';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 node.namedParameters.isEmpty) { 886 node.namedParameters.isEmpty) {
887 writeByte(Tag.SimpleFunctionType); 887 writeByte(Tag.SimpleFunctionType);
888 writeNodeList(node.positionalParameters); 888 writeNodeList(node.positionalParameters);
889 writeNode(node.returnType); 889 writeNode(node.returnType);
890 } else { 890 } else {
891 writeByte(Tag.FunctionType); 891 writeByte(Tag.FunctionType);
892 _typeParameterIndexer.push(node.typeParameters); 892 _typeParameterIndexer.push(node.typeParameters);
893 writeNodeList(node.typeParameters); 893 writeNodeList(node.typeParameters);
894 writeUInt30(node.requiredParameterCount); 894 writeUInt30(node.requiredParameterCount);
895 writeNodeList(node.positionalParameters); 895 writeNodeList(node.positionalParameters);
896 writeList(node.namedParameters.keys.toList(), (String name) { 896 writeNodeList(node.namedParameters);
897 writeStringReference(name);
898 writeNode(node.namedParameters[name]);
899 });
900 writeNode(node.returnType); 897 writeNode(node.returnType);
901 _typeParameterIndexer.pop(node.typeParameters); 898 _typeParameterIndexer.pop(node.typeParameters);
902 } 899 }
903 } 900 }
904 901
902 visitNamedType(NamedType node) {
903 writeStringReference(node.name);
904 writeNode(node.type);
905 }
906
905 visitTypeParameterType(TypeParameterType node) { 907 visitTypeParameterType(TypeParameterType node) {
906 writeByte(Tag.TypeParameterType); 908 writeByte(Tag.TypeParameterType);
907 writeUInt30(_typeParameterIndexer[node.parameter]); 909 writeUInt30(_typeParameterIndexer[node.parameter]);
908 } 910 }
909 911
910 visitTypeParameter(TypeParameter node) { 912 visitTypeParameter(TypeParameter node) {
911 writeStringReference(node.name ?? ''); 913 writeStringReference(node.name ?? '');
912 writeNode(node.bound); 914 writeNode(node.bound);
913 } 915 }
914 916
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 1134
1133 visitSymbolLiteral(SymbolLiteral node) { 1135 visitSymbolLiteral(SymbolLiteral node) {
1134 put(node.value); 1136 put(node.value);
1135 } 1137 }
1136 1138
1137 visitVariableDeclaration(VariableDeclaration node) { 1139 visitVariableDeclaration(VariableDeclaration node) {
1138 putOptional(node.name); 1140 putOptional(node.name);
1139 node.visitChildren(this); 1141 node.visitChildren(this);
1140 } 1142 }
1141 1143
1142 visitFunctionType(FunctionType node) { 1144 visitNamedType(NamedType node) {
1143 node.namedParameters.keys.forEach(put); 1145 put(node.name);
1144 node.visitChildren(this); 1146 node.visitChildren(this);
1145 } 1147 }
1146 1148
1147 visitTypeParameter(TypeParameter node) { 1149 visitTypeParameter(TypeParameter node) {
1148 putOptional(node.name); 1150 putOptional(node.name);
1149 node.visitChildren(this); 1151 node.visitChildren(this);
1150 } 1152 }
1151 } 1153 }
1152 1154
1153 /// Computes and stores the index of a library, class, or member within its 1155 /// Computes and stores the index of a library, class, or member within its
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 void flush() { 1251 void flush() {
1250 _sink.add(_buffer.sublist(0, length)); 1252 _sink.add(_buffer.sublist(0, length));
1251 _buffer = new Uint8List(SIZE); 1253 _buffer = new Uint8List(SIZE);
1252 length = 0; 1254 length = 0;
1253 } 1255 }
1254 1256
1255 void flushAndDestroy() { 1257 void flushAndDestroy() {
1256 _sink.add(_buffer.sublist(0, length)); 1258 _sink.add(_buffer.sublist(0, length));
1257 } 1259 }
1258 } 1260 }
OLDNEW
« no previous file with comments | « lib/binary/ast_from_binary.dart ('k') | lib/checks.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698