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

Side by Side Diff: lib/compiler/implementation/ssa/codegen_helpers.dart

Issue 10825180: Add JavaScript AST. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated. Created 8 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 | Annotate | Revision Log
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 /** 5 /**
6 * Instead of emitting each SSA instruction with a temporary variable 6 * Instead of emitting each SSA instruction with a temporary variable
7 * mark instructions that can be emitted at their use-site. 7 * mark instructions that can be emitted at their use-site.
8 * For example, in: 8 * For example, in:
9 * t0 = 4; 9 * t0 = 4;
10 * t1 = 3; 10 * t1 = 3;
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } 318 }
319 319
320 // If [thenInput] is defined in the first predecessor, then it is only used 320 // If [thenInput] is defined in the first predecessor, then it is only used
321 // by [phi] and can be generated at use site. 321 // by [phi] and can be generated at use site.
322 if (thenInput.block === end.predecessors[0]) { 322 if (thenInput.block === end.predecessors[0]) {
323 assert(thenInput.usedBy.length == 1); 323 assert(thenInput.usedBy.length == 1);
324 markAsGenerateAtUseSite(thenInput); 324 markAsGenerateAtUseSite(thenInput);
325 } 325 }
326 } 326 }
327 } 327 }
328
329 // Precedence information for JavaScript operators.
330 class JSPrecedence {
331 // Used as precedence for something that's not even an expression.
332 static final int STATEMENT_PRECEDENCE = 0;
333 // Precedences of JS operators.
334 static final int EXPRESSION_PRECEDENCE = 1;
335 static final int ASSIGNMENT_PRECEDENCE = 2;
336 static final int CONDITIONAL_PRECEDENCE = 3;
337 static final int LOGICAL_OR_PRECEDENCE = 4;
338 static final int LOGICAL_AND_PRECEDENCE = 5;
339 static final int BITWISE_OR_PRECEDENCE = 6;
340 static final int BITWISE_XOR_PRECEDENCE = 7;
341 static final int BITWISE_AND_PRECEDENCE = 8;
342 static final int EQUALITY_PRECEDENCE = 9;
343 static final int RELATIONAL_PRECEDENCE = 10;
344 static final int SHIFT_PRECEDENCE = 11;
345 static final int ADDITIVE_PRECEDENCE = 12;
346 static final int MULTIPLICATIVE_PRECEDENCE = 13;
347 static final int PREFIX_PRECEDENCE = 14;
348 static final int POSTFIX_PRECEDENCE = 15;
349 static final int CALL_PRECEDENCE = 16;
350 // We never use "new MemberExpression" without arguments, so we can
351 // combine CallExpression and MemberExpression without ambiguity.
352 static final int MEMBER_PRECEDENCE = CALL_PRECEDENCE;
353 static final int PRIMARY_PRECEDENCE = 17;
354
355 // The operators that an occur in HBinaryOp.
356 static final Map<String, JSBinaryOperatorPrecedence> binary = const {
357 "||" : const JSBinaryOperatorPrecedence(LOGICAL_OR_PRECEDENCE,
358 LOGICAL_AND_PRECEDENCE),
359 "&&" : const JSBinaryOperatorPrecedence(LOGICAL_AND_PRECEDENCE,
360 BITWISE_OR_PRECEDENCE),
361 "|" : const JSBinaryOperatorPrecedence(BITWISE_OR_PRECEDENCE,
362 BITWISE_XOR_PRECEDENCE),
363 "^" : const JSBinaryOperatorPrecedence(BITWISE_XOR_PRECEDENCE,
364 BITWISE_AND_PRECEDENCE),
365 "&" : const JSBinaryOperatorPrecedence(BITWISE_AND_PRECEDENCE,
366 EQUALITY_PRECEDENCE),
367 "==" : const JSBinaryOperatorPrecedence(EQUALITY_PRECEDENCE,
368 RELATIONAL_PRECEDENCE),
369 "!=" : const JSBinaryOperatorPrecedence(EQUALITY_PRECEDENCE,
370 RELATIONAL_PRECEDENCE),
371 "===" : const JSBinaryOperatorPrecedence(EQUALITY_PRECEDENCE,
372 RELATIONAL_PRECEDENCE),
373 "!==" : const JSBinaryOperatorPrecedence(EQUALITY_PRECEDENCE,
374 RELATIONAL_PRECEDENCE),
375 "<" : const JSBinaryOperatorPrecedence(RELATIONAL_PRECEDENCE,
376 SHIFT_PRECEDENCE),
377 ">" : const JSBinaryOperatorPrecedence(RELATIONAL_PRECEDENCE,
378 SHIFT_PRECEDENCE),
379 "<=" : const JSBinaryOperatorPrecedence(RELATIONAL_PRECEDENCE,
380 SHIFT_PRECEDENCE),
381 ">=" : const JSBinaryOperatorPrecedence(RELATIONAL_PRECEDENCE,
382 SHIFT_PRECEDENCE),
383 "<<" : const JSBinaryOperatorPrecedence(SHIFT_PRECEDENCE,
384 ADDITIVE_PRECEDENCE),
385 ">>" : const JSBinaryOperatorPrecedence(SHIFT_PRECEDENCE,
386 ADDITIVE_PRECEDENCE),
387 ">>>" : const JSBinaryOperatorPrecedence(SHIFT_PRECEDENCE,
388 ADDITIVE_PRECEDENCE),
389 "+" : const JSBinaryOperatorPrecedence(ADDITIVE_PRECEDENCE,
390 MULTIPLICATIVE_PRECEDENCE),
391 "-" : const JSBinaryOperatorPrecedence(ADDITIVE_PRECEDENCE,
392 MULTIPLICATIVE_PRECEDENCE),
393 "*" : const JSBinaryOperatorPrecedence(MULTIPLICATIVE_PRECEDENCE,
394 PREFIX_PRECEDENCE),
395 "/" : const JSBinaryOperatorPrecedence(MULTIPLICATIVE_PRECEDENCE,
396 PREFIX_PRECEDENCE),
397 "%" : const JSBinaryOperatorPrecedence(MULTIPLICATIVE_PRECEDENCE,
398 PREFIX_PRECEDENCE),
399 };
400 }
401
402 class JSBinaryOperatorPrecedence {
403 final int left;
404 final int right;
405 const JSBinaryOperatorPrecedence(this.left, this.right);
406 // All binary operators (excluding assignment) are left associative.
407 int get precedence() => left;
408 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698