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

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

Issue 1069493002: implement opassign, fix bugs in pre/postfix, introduce a let* helper (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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/runtime/dart/math.js ('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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 89
90 static Expression parenthesize(Expression exp) { 90 static Expression parenthesize(Expression exp) {
91 if (exp is Identifier || 91 if (exp is Identifier ||
92 exp is ParenthesizedExpression || 92 exp is ParenthesizedExpression ||
93 exp is FunctionExpressionInvocation || 93 exp is FunctionExpressionInvocation ||
94 exp is MethodInvocation) return exp; 94 exp is MethodInvocation) return exp;
95 return parenthesizedExpression(exp); 95 return parenthesizedExpression(exp);
96 } 96 }
97 97
98 static TokenType getTokenType(String lexeme) {
99 switch (lexeme) {
100 case "&":
101 return TokenType.AMPERSAND;
102 case "&&":
103 return TokenType.AMPERSAND_AMPERSAND;
104 case "&=":
105 return TokenType.AMPERSAND_EQ;
106 case "@":
107 return TokenType.AT;
108 case "!":
109 return TokenType.BANG;
110 case "!=":
111 return TokenType.BANG_EQ;
112 case "|":
113 return TokenType.BAR;
114 case "||":
115 return TokenType.BAR_BAR;
116 case "|=":
117 return TokenType.BAR_EQ;
118 case ":":
119 return TokenType.COLON;
120 case ",":
121 return TokenType.COMMA;
122 case "^":
123 return TokenType.CARET;
124 case "^=":
125 return TokenType.CARET_EQ;
126 case "}":
127 return TokenType.CLOSE_CURLY_BRACKET;
128 case ")":
129 return TokenType.CLOSE_PAREN;
130 case "]":
131 return TokenType.CLOSE_SQUARE_BRACKET;
132 case "=":
133 return TokenType.EQ;
134 case "==":
135 return TokenType.EQ_EQ;
136 case "=>":
137 return TokenType.FUNCTION;
138 case ">":
139 return TokenType.GT;
140 case ">=":
141 return TokenType.GT_EQ;
142 case ">>":
143 return TokenType.GT_GT;
144 case ">>=":
145 return TokenType.GT_GT_EQ;
146 case "#":
147 return TokenType.HASH;
148 case "[]":
149 return TokenType.INDEX;
150 case "[]=":
151 return TokenType.INDEX_EQ;
152 case "is":
153 return TokenType.IS;
154 case "<":
155 return TokenType.LT;
156 case "<=":
157 return TokenType.LT_EQ;
158 case "<<":
159 return TokenType.LT_LT;
160 case "<<=":
161 return TokenType.LT_LT_EQ;
162 case "-":
163 return TokenType.MINUS;
164 case "-=":
165 return TokenType.MINUS_EQ;
166 case "--":
167 return TokenType.MINUS_MINUS;
168 case "{":
169 return TokenType.OPEN_CURLY_BRACKET;
170 case "(":
171 return TokenType.OPEN_PAREN;
172 case "[":
173 return TokenType.OPEN_SQUARE_BRACKET;
174 case "%":
175 return TokenType.PERCENT;
176 case "%=":
177 return TokenType.PERCENT_EQ;
178 case ".":
179 return TokenType.PERIOD;
180 case "..":
181 return TokenType.PERIOD_PERIOD;
182 case "+":
183 return TokenType.PLUS;
184 case "+=":
185 return TokenType.PLUS_EQ;
186 case "++":
187 return TokenType.PLUS_PLUS;
188 case "?":
189 return TokenType.QUESTION;
190 case ";":
191 return TokenType.SEMICOLON;
192 case "/":
193 return TokenType.SLASH;
194 case "/=":
195 return TokenType.SLASH_EQ;
196 case "*":
197 return TokenType.STAR;
198 case "*=":
199 return TokenType.STAR_EQ;
200 case "\${":
201 return TokenType.STRING_INTERPOLATION_EXPRESSION;
202 case "\$":
203 return TokenType.STRING_INTERPOLATION_IDENTIFIER;
204 case "~":
205 return TokenType.TILDE;
206 case "~/":
207 return TokenType.TILDE_SLASH;
208 case "~/=":
209 return TokenType.TILDE_SLASH_EQ;
210 case "`":
211 return TokenType.BACKPING;
212 case "\\":
213 return TokenType.BACKSLASH;
214 case "...":
215 return TokenType.PERIOD_PERIOD_PERIOD;
216 default:
217 return null;
218 }
219 }
220
98 static Token _binaryOperation(String oper) { 221 static Token _binaryOperation(String oper) {
99 switch (oper) { 222 var type = getTokenType(oper);
100 case '==': 223 assert(type != null);
101 return new Token(TokenType.EQ_EQ, 0); 224 return new Token(type, 0);
102 case '+':
103 return new Token(TokenType.PLUS, 0);
104 case '-':
105 return new Token(TokenType.MINUS, 0);
106 }
107 // TODO(vsm): Add cases as needed.
108 assert(false);
109 return null;
110 } 225 }
111 226
112 static BinaryExpression binaryExpression( 227 static BinaryExpression binaryExpression(
113 Expression l, String oper, Expression r) { 228 Expression l, String oper, Expression r) {
114 Token token = _binaryOperation(oper); 229 Token token = _binaryOperation(oper);
115 return RawAstBuilder.binaryExpression(l, token, r); 230 return RawAstBuilder.binaryExpression(l, token, r);
116 } 231 }
117 232
118 static ConditionalExpression conditionalExpression( 233 static ConditionalExpression conditionalExpression(
119 Expression cond, Expression tExp, Expression fExp) { 234 Expression cond, Expression tExp, Expression fExp) {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 519
405 static NamedExpression namedParameter(Identifier s, Expression e) { 520 static NamedExpression namedParameter(Identifier s, Expression e) {
406 return namedExpression(s, e); 521 return namedExpression(s, e);
407 } 522 }
408 523
409 static NamedExpression namedExpression(Identifier s, Expression e) { 524 static NamedExpression namedExpression(Identifier s, Expression e) {
410 Label l = new Label(s, new Token(TokenType.COLON, 0)); 525 Label l = new Label(s, new Token(TokenType.COLON, 0));
411 return new NamedExpression(l, e); 526 return new NamedExpression(l, e);
412 } 527 }
413 } 528 }
OLDNEW
« no previous file with comments | « lib/runtime/dart/math.js ('k') | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698