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

Side by Side Diff: lib/src/codegen/ast_builder.dart

Issue 1316723003: implement null aware ops, fixes #249 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 4 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 | « lib/src/checker/checker.dart ('k') | lib/src/codegen/js_codegen.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library dev_compiler.src.codegen.ast_builder; 5 library dev_compiler.src.codegen.ast_builder;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/scanner.dart'; 8 import 'package:analyzer/src/generated/scanner.dart';
9 import 'package:analyzer/src/generated/utilities_dart.dart'; 9 import 'package:analyzer/src/generated/utilities_dart.dart';
10 import 'package:logging/logging.dart' as logger; 10 import 'package:logging/logging.dart' as logger;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 static Expression parenthesize(Expression exp) { 95 static Expression parenthesize(Expression exp) {
96 if (exp is Identifier || 96 if (exp is Identifier ||
97 exp is ParenthesizedExpression || 97 exp is ParenthesizedExpression ||
98 exp is FunctionExpressionInvocation || 98 exp is FunctionExpressionInvocation ||
99 exp is MethodInvocation) return exp; 99 exp is MethodInvocation) return exp;
100 return parenthesizedExpression(exp); 100 return parenthesizedExpression(exp);
101 } 101 }
102 102
103 static PropertyAccess propertyAccess(
104 Expression target, SimpleIdentifier name) {
105 var p = new Token(TokenType.PERIOD, 0);
106 return new PropertyAccess(target, p, name);
107 }
108
109 static MethodInvocation methodInvoke(
110 Expression target, SimpleIdentifier name, NodeList<Expression> args) {
111 var p = new Token(TokenType.PERIOD, 0);
112 return new MethodInvocation(target, p, name, null, argumentList(args));
113 }
114
103 static TokenType getTokenType(String lexeme) { 115 static TokenType getTokenType(String lexeme) {
104 switch (lexeme) { 116 switch (lexeme) {
105 case "&": 117 case "&":
106 return TokenType.AMPERSAND; 118 return TokenType.AMPERSAND;
107 case "&&": 119 case "&&":
108 return TokenType.AMPERSAND_AMPERSAND; 120 return TokenType.AMPERSAND_AMPERSAND;
109 case "&=": 121 case "&=":
110 return TokenType.AMPERSAND_EQ; 122 return TokenType.AMPERSAND_EQ;
111 case "@": 123 case "@":
112 return TokenType.AT; 124 return TokenType.AT;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 case "~/": 223 case "~/":
212 return TokenType.TILDE_SLASH; 224 return TokenType.TILDE_SLASH;
213 case "~/=": 225 case "~/=":
214 return TokenType.TILDE_SLASH_EQ; 226 return TokenType.TILDE_SLASH_EQ;
215 case "`": 227 case "`":
216 return TokenType.BACKPING; 228 return TokenType.BACKPING;
217 case "\\": 229 case "\\":
218 return TokenType.BACKSLASH; 230 return TokenType.BACKSLASH;
219 case "...": 231 case "...":
220 return TokenType.PERIOD_PERIOD_PERIOD; 232 return TokenType.PERIOD_PERIOD_PERIOD;
233 case "??":
234 return TokenType.QUESTION_QUESTION;
235 case "??=":
236 return TokenType.QUESTION_QUESTION_EQ;
221 default: 237 default:
222 return null; 238 return null;
223 } 239 }
224 } 240 }
225 241
226 static Token _binaryOperation(String oper) { 242 static Token _binaryOperation(String oper) {
227 var type = getTokenType(oper); 243 var type = getTokenType(oper);
228 assert(type != null); 244 assert(type != null);
229 return new Token(type, 0); 245 return new Token(type, 0);
230 } 246 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 Label l = new Label(s, new Token(TokenType.COLON, 0)); 586 Label l = new Label(s, new Token(TokenType.COLON, 0));
571 return new NamedExpression(l, e); 587 return new NamedExpression(l, e);
572 } 588 }
573 589
574 static VariableDeclarationStatement variableDeclarationStatement( 590 static VariableDeclarationStatement variableDeclarationStatement(
575 VariableDeclarationList varDecl) { 591 VariableDeclarationList varDecl) {
576 var semi = new Token(TokenType.SEMICOLON, 0); 592 var semi = new Token(TokenType.SEMICOLON, 0);
577 return new VariableDeclarationStatement(varDecl, semi); 593 return new VariableDeclarationStatement(varDecl, semi);
578 } 594 }
579 } 595 }
OLDNEW
« no previous file with comments | « lib/src/checker/checker.dart ('k') | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698