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

Side by Side Diff: compiler/java/com/google/dart/compiler/util/AstUtil.java

Issue 8232014: Fix named parameters handling of values that are falsy in JS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 package com.google.dart.compiler.util; 5 package com.google.dart.compiler.util;
6 6
7 import com.google.dart.compiler.InternalCompilerException; 7 import com.google.dart.compiler.InternalCompilerException;
8 import com.google.dart.compiler.backend.js.ast.JsArrayAccess; 8 import com.google.dart.compiler.backend.js.ast.JsArrayAccess;
9 import com.google.dart.compiler.backend.js.ast.JsBinaryOperation; 9 import com.google.dart.compiler.backend.js.ast.JsBinaryOperation;
10 import com.google.dart.compiler.backend.js.ast.JsBinaryOperator; 10 import com.google.dart.compiler.backend.js.ast.JsBinaryOperator;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 public static JsNameRef newNameRef(JsExpression qualifier, String prop) { 61 public static JsNameRef newNameRef(JsExpression qualifier, String prop) {
62 JsNameRef nameRef = new JsNameRef(prop); 62 JsNameRef nameRef = new JsNameRef(prop);
63 if (qualifier != null) { 63 if (qualifier != null) {
64 nameRef.setQualifier(qualifier); 64 nameRef.setQualifier(qualifier);
65 } 65 }
66 return nameRef; 66 return nameRef;
67 } 67 }
68 68
69 public static JsNameRef nameref(SourceInfo info, JsName qualifier, JsName prop ) {
70 JsNameRef nameRef = new JsNameRef(prop);
71 if (qualifier != null) {
72 nameRef.setQualifier(qualifier.makeRef());
73 }
74 nameRef.setSourceRef(info);
75 return nameRef;
76 }
77
69 public static JsNameRef newNameRef(JsExpression qualifier, JsName prop) { 78 public static JsNameRef newNameRef(JsExpression qualifier, JsName prop) {
70 JsNameRef nameRef = new JsNameRef(prop); 79 JsNameRef nameRef = new JsNameRef(prop);
71 if (qualifier != null) { 80 if (qualifier != null) {
72 nameRef.setQualifier(qualifier); 81 nameRef.setQualifier(qualifier);
73 } 82 }
74 return nameRef; 83 return nameRef;
75 } 84 }
76 85
77 public static JsNameRef newPrototypeNameRef(JsExpression qualifier) { 86 public static JsNameRef newPrototypeNameRef(JsExpression qualifier) {
78 return newNameRef(qualifier, "prototype"); 87 return newNameRef(qualifier, "prototype");
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 176 }
168 } 177 }
169 fn.setBody(newBlock(stmts)); 178 fn.setBody(newBlock(stmts));
170 return fn; 179 return fn;
171 } 180 }
172 181
173 public static JsInvocation call(SourceInfo src, JsExpression target, JsExpress ion ... params) { 182 public static JsInvocation call(SourceInfo src, JsExpression target, JsExpress ion ... params) {
174 return (JsInvocation) newInvocation(target, params).setSourceRef(src); 183 return (JsInvocation) newInvocation(target, params).setSourceRef(src);
175 } 184 }
176 185
177 public static JsExpression comma(SourceInfo src, JsExpression op1, JsExpressio n op2) { 186 public static JsBinaryOperation comma(SourceInfo src, JsExpression op1, JsExpr ession op2) {
178 return new JsBinaryOperation(JsBinaryOperator.COMMA, op1, op2).setSourceRef( src); 187 return (JsBinaryOperation)new JsBinaryOperation(JsBinaryOperator.COMMA, op1, op2)
188 .setSourceRef(src);
179 } 189 }
180 190
181 public static JsNameRef nameref(SourceInfo src, String name) { 191 public static JsNameRef nameref(SourceInfo src, String name) {
182 return (JsNameRef) new JsNameRef(name).setSourceRef(src); 192 return (JsNameRef) new JsNameRef(name).setSourceRef(src);
183 } 193 }
184 194
185 public static JsNameRef nameref(SourceInfo src, JsName qualifier, String prop) { 195 public static JsNameRef nameref(SourceInfo src, JsName qualifier, String prop) {
186 return AstUtil.nameref(src, qualifier.makeRef().setSourceRef(src), prop); 196 return AstUtil.nameref(src, qualifier.makeRef().setSourceRef(src), prop);
187 } 197 }
188 198
189 public static JsNameRef nameref(SourceInfo src, JsExpression qualifier, String prop) { 199 public static JsNameRef nameref(SourceInfo src, JsExpression qualifier, String prop) {
190 return (JsNameRef) newNameRef(qualifier, prop).setSourceRef(src); 200 return (JsNameRef) newNameRef(qualifier, prop).setSourceRef(src);
191 } 201 }
192 202
193 public static JsExpression assign(SourceInfo src, JsNameRef op1, JsExpression op2) { 203 public static JsExpression assign(SourceInfo src, JsNameRef op1, JsExpression op2) {
194 return newAssignment(op1, op2).setSourceRef(src); 204 return newAssignment(op1, op2).setSourceRef(src);
195 } 205 }
196 206
197 public static JsExpression neq(SourceInfo src, JsExpression op1, JsExpression op2) { 207 public static JsExpression neq(SourceInfo src, JsExpression op1, JsExpression op2) {
198 return new JsBinaryOperation(JsBinaryOperator.NEQ, op1, op2).setSourceRef(sr c); 208 return new JsBinaryOperation(JsBinaryOperator.NEQ, op1, op2).setSourceRef(sr c);
199 } 209 }
200 210
201 public static JsExpression not(SourceInfo src, JsExpression op1) { 211 public static JsExpression not(SourceInfo src, JsExpression op1) {
202 return new JsPrefixOperation(JsUnaryOperator.NOT, op1).setSourceRef(src); 212 return new JsPrefixOperation(JsUnaryOperator.NOT, op1).setSourceRef(src);
203 } 213 }
204 214
215 public static JsExpression preinc(SourceInfo src, JsExpression op1) {
216 return new JsPrefixOperation(JsUnaryOperator.INC, op1).setSourceRef(src);
217 }
218
205 public static JsExpression and(SourceInfo src, JsExpression op1, JsExpression op2) { 219 public static JsExpression and(SourceInfo src, JsExpression op1, JsExpression op2) {
206 return new JsBinaryOperation(JsBinaryOperator.AND, op1, op2); 220 return new JsBinaryOperation(JsBinaryOperator.AND, op1, op2).setSourceRef(sr c);
221 }
222
223 public static JsExpression in(SourceInfo src, JsExpression propName, JsExpress ion obj) {
224 return new JsBinaryOperation(JsBinaryOperator.INOP, propName, obj).setSource Ref(src);
207 } 225 }
208 } 226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698