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

Side by Side Diff: pkg/js_ast/lib/src/printer.dart

Issue 1153243003: dart2js: Use frequency of occurence to sort metadata indices. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Addressed sra's comments Created 5 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
« no previous file with comments | « pkg/js_ast/lib/src/nodes.dart ('k') | pkg/js_ast/lib/src/template.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) 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 part of js_ast; 5 part of js_ast;
6 6
7 7
8 class JavaScriptPrintingOptions { 8 class JavaScriptPrintingOptions {
9 final bool shouldCompressOutput; 9 final bool shouldCompressOutput;
10 final bool minifyLocalVariables; 10 final bool minifyLocalVariables;
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 } 945 }
946 946
947 @override 947 @override
948 void visitFun(Fun fun) { 948 void visitFun(Fun fun) {
949 VarCollector vars = new VarCollector(); 949 VarCollector vars = new VarCollector();
950 vars.visitFun(fun); 950 vars.visitFun(fun);
951 currentNode.closingPosition = functionOut(fun, null, vars); 951 currentNode.closingPosition = functionOut(fun, null, vars);
952 } 952 }
953 953
954 @override 954 @override
955 void visitLiteralBool(LiteralBool node) { 955 visitDeferredExpression(DeferredExpression node) {
956 // Continue printing with the expression value.
957 assert(node.precedenceLevel == node.value.precedenceLevel);
958 node.value.accept(this);
959 }
960
961 outputNumberWithRequiredWhitespace(String number) {
962 int charCode = number.codeUnitAt(0);
963 if (charCode == charCodes.$MINUS && lastCharCode == charCodes.$MINUS) {
964 out(" ", isWhitespace: true);
965 }
966 out(number);
967 }
968
969 @override
970 visitDeferredNumber(DeferredNumber node) {
971 outputNumberWithRequiredWhitespace("${node.value}");
972 }
973
974 @override
975 visitDeferredString(DeferredString node) {
976 out(node.value);
977 }
978
979 @override
980 visitLiteralBool(LiteralBool node) {
956 out(node.value ? "true" : "false"); 981 out(node.value ? "true" : "false");
957 } 982 }
958 983
959 @override 984 @override
960 void visitLiteralString(LiteralString node) { 985 void visitLiteralString(LiteralString node) {
961 out(node.value); 986 out(node.value);
962 } 987 }
963 988
964 @override 989 @override
965 void visitLiteralNumber(LiteralNumber node) { 990 visitStringConcatenation(StringConcatenation node) {
966 int charCode = node.value.codeUnitAt(0); 991 node.visitChildren(this);
967 if (charCode == charCodes.$MINUS && lastCharCode == charCodes.$MINUS) {
968 out(" ", isWhitespace: true);
969 }
970 out(node.value);
971 } 992 }
972 993
973 @override 994 @override
995 visitLiteralNumber(LiteralNumber node) {
996 outputNumberWithRequiredWhitespace(node.value);
997 }
998
999 @override
974 void visitLiteralNull(LiteralNull node) { 1000 void visitLiteralNull(LiteralNull node) {
975 out("null"); 1001 out("null");
976 } 1002 }
977 1003
978 @override 1004 @override
979 void visitArrayInitializer(ArrayInitializer node) { 1005 void visitArrayInitializer(ArrayInitializer node) {
980 out("["); 1006 out("[");
981 List<Expression> elements = node.elements; 1007 List<Expression> elements = node.elements;
982 for (int i = 0; i < elements.length; i++) { 1008 for (int i = 0; i < elements.length; i++) {
983 Expression element = elements[i]; 1009 Expression element = elements[i];
(...skipping 22 matching lines...) Expand all
1006 1032
1007 @override 1033 @override
1008 void visitObjectInitializer(ObjectInitializer node) { 1034 void visitObjectInitializer(ObjectInitializer node) {
1009 // Print all the properties on one line until we see a function-valued 1035 // Print all the properties on one line until we see a function-valued
1010 // property. Ideally, we would use a proper pretty-printer to make the 1036 // property. Ideally, we would use a proper pretty-printer to make the
1011 // decision based on layout. 1037 // decision based on layout.
1012 List<Property> properties = node.properties; 1038 List<Property> properties = node.properties;
1013 out("{"); 1039 out("{");
1014 indentMore(); 1040 indentMore();
1015 for (int i = 0; i < properties.length; i++) { 1041 for (int i = 0; i < properties.length; i++) {
1016 Expression value = properties[i].value;
1017 if (i != 0) { 1042 if (i != 0) {
1018 out(","); 1043 out(",");
1019 if (node.isOneLiner) spaceOut(); 1044 if (node.isOneLiner) spaceOut();
1020 } 1045 }
1021 if (!node.isOneLiner) { 1046 if (!node.isOneLiner) {
1022 forceLine(); 1047 forceLine();
1023 indent(); 1048 indent();
1024 } 1049 }
1025 visit(properties[i]); 1050 visit(properties[i]);
1026 } 1051 }
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 } 1450 }
1426 } 1451 }
1427 1452
1428 EnterExitNode exitNode(JavaScriptPrintingContext context, int position) { 1453 EnterExitNode exitNode(JavaScriptPrintingContext context, int position) {
1429 // Enter must happen before exit. 1454 // Enter must happen before exit.
1430 addToNode(context, position); 1455 addToNode(context, position);
1431 context.exitNode(node, startPosition, position, closingPosition); 1456 context.exitNode(node, startPosition, position, closingPosition);
1432 return parent; 1457 return parent;
1433 } 1458 }
1434 } 1459 }
OLDNEW
« no previous file with comments | « pkg/js_ast/lib/src/nodes.dart ('k') | pkg/js_ast/lib/src/template.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698