001 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 002 // for details. All rights reserved. Use of this source code is governed by a 003 // BSD-style license that can be found in the LICENSE file. 004 005 package com.google.dart.compiler.util; 006 007 import com.google.dart.compiler.backend.js.ast.*; 008 009 public final class AstUtil { 010 private AstUtil() { 011 } 012 013 /** 014 * Returns a sequence of expressions (using the binary sequence operator). 015 * 016 * @param exprs - expressions to add to sequence 017 * @return a sequence of expressions. 018 */ 019 public static JsBinaryOperation newSequence(JsExpression... exprs) { 020 if (exprs.length < 2) { 021 throw new RuntimeException("newSequence expects at least two arguments"); 022 } 023 JsExpression result = exprs[exprs.length - 1]; 024 for (int i = exprs.length - 2; i >= 0; i--) { 025 result = new JsBinaryOperation(JsBinaryOperator.COMMA, exprs[i], result); 026 } 027 return (JsBinaryOperation) result; 028 } 029 }